iflow-engine-base 3.1.3 → 3.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -33
- package/dist/bim-engine-sdk.es.js +9755 -7957
- package/dist/bim-engine-sdk.es.js.map +1 -1
- package/dist/bim-engine-sdk.umd.js +811 -583
- package/dist/bim-engine-sdk.umd.js.map +1 -1
- package/dist/fonts/simfang.ttf +0 -0
- package/dist/iflow-engine-base.css +1 -1
- package/dist/index.d.ts +328 -6
- package/dist/main-2Txx2Vau.mjs +175 -0
- package/dist/main-2Txx2Vau.mjs.map +1 -0
- package/dist/model00/info +0 -0
- package/dist/model00/lod0 +0 -0
- package/dist/model00/lod1 +0 -0
- package/dist/model00/lod2 +0 -0
- package/dist/model00/property +0 -0
- package/dist/step-CkmZYIvn.mjs +251 -0
- package/dist/step-CkmZYIvn.mjs.map +1 -0
- package/dist/textture/waternormals.jpg +0 -0
- package/package.json +53 -51
- package/dist/main-Bcaj0lBB.mjs +0 -175
- package/dist/main-Bcaj0lBB.mjs.map +0 -1
- package/dist/model0/info +0 -0
- package/dist/model0/lod0 +0 -0
- package/dist/model0/property +0 -0
- package/dist/model1/info +0 -0
- package/dist/model1/info~/info.json +0 -1
- package/dist/model1/lod0 +0 -0
- package/dist/model1/lod0~/instances.json +0 -1
- package/dist/model1/lod0~/nodes.json +0 -1
- package/dist/model1/lod0~/primitives/0.glb +0 -0
- package/dist/model1/lod0~/primitives/1.glb +0 -0
- package/dist/model1/lod0~/primitives/10.glb +0 -0
- package/dist/model1/lod0~/primitives/11.glb +0 -0
- package/dist/model1/lod0~/primitives/12.glb +0 -0
- package/dist/model1/lod0~/primitives/13.glb +0 -0
- package/dist/model1/lod0~/primitives/14.glb +0 -0
- package/dist/model1/lod0~/primitives/15.glb +0 -0
- package/dist/model1/lod0~/primitives/16.glb +0 -0
- package/dist/model1/lod0~/primitives/17.glb +0 -0
- package/dist/model1/lod0~/primitives/18.glb +0 -0
- package/dist/model1/lod0~/primitives/19.glb +0 -0
- package/dist/model1/lod0~/primitives/2.glb +0 -0
- package/dist/model1/lod0~/primitives/20.glb +0 -0
- package/dist/model1/lod0~/primitives/21.glb +0 -0
- package/dist/model1/lod0~/primitives/22.glb +0 -0
- package/dist/model1/lod0~/primitives/23.glb +0 -0
- package/dist/model1/lod0~/primitives/24.glb +0 -0
- package/dist/model1/lod0~/primitives/25.glb +0 -0
- package/dist/model1/lod0~/primitives/26.glb +0 -0
- package/dist/model1/lod0~/primitives/27.glb +0 -0
- package/dist/model1/lod0~/primitives/28.glb +0 -0
- package/dist/model1/lod0~/primitives/29.glb +0 -0
- package/dist/model1/lod0~/primitives/3.glb +0 -0
- package/dist/model1/lod0~/primitives/30.glb +0 -0
- package/dist/model1/lod0~/primitives/31.glb +0 -0
- package/dist/model1/lod0~/primitives/4.glb +0 -0
- package/dist/model1/lod0~/primitives/5.glb +0 -0
- package/dist/model1/lod0~/primitives/6.glb +0 -0
- package/dist/model1/lod0~/primitives/7.glb +0 -0
- package/dist/model1/lod0~/primitives/8.glb +0 -0
- package/dist/model1/lod0~/primitives/9.glb +0 -0
- package/dist/model1/property +0 -0
- package/dist/model2/info +0 -0
- package/dist/model2/lod0 +0 -0
- package/dist/model2/property +0 -0
- package/dist/model2d/cad.json +0 -1
- package/dist/model2d/info +0 -0
- package/dist/model4/info +0 -0
- package/dist/model4/lod0 +0 -0
- package/dist/model4/property +0 -0
- package/dist/model720/720.png +0 -0
- package/dist/step-Ci61eU9h.mjs +0 -251
- package/dist/step-Ci61eU9h.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(it,_){typeof exports=="object"&&typeof module<"u"?_(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],_):(it=typeof globalThis<"u"?globalThis:it||self,_(it.BimEngineSDK={},it.THREE))})(this,(function(it,_){"use strict";function Xo(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const b=Xo(_);class Zo{engine;scene;constructor(e){this.engine=e,this.scene=new b.Scene;let t=new b.Group;t.name="groupEdge",this.scene.add(t)}}class Yo{engine;perspectiveCamera;orthographicCamera;constructor(e){this.engine=e,this.perspectiveCamera=new b.PerspectiveCamera(60,this.engine.container.clientWidth/this.engine.container.clientHeight,.1,1e3),this.perspectiveCamera.position.set(2,2,2),this.perspectiveCamera.lookAt(0,0,0);const t=50,n=this.engine.container.clientWidth/this.engine.container.clientHeight;this.orthographicCamera=new b.OrthographicCamera(t*n/-2,t*n/2,t/2,t/-2,.1,1e3)}switchCurrentCamera(){this.engine.camera===this.perspectiveCamera?this.switchToOrthographicCamera():this.switchToPerspectiveCamera()}updateComposerCamera(){if(!this.engine.composerModule?.composer)return;const e=this.engine.camera,t=this.engine.composerModule.composer;if(t.passes)for(const n of t.passes)n.camera!==void 0&&(n.camera=e)}switchToPerspectiveCamera(){if(!this.engine.controls)return;const e=this.engine.camera.position.clone(),t=this.engine.controls.target.clone();this.engine.camera=this.perspectiveCamera,this.engine.scene.camera=this.perspectiveCamera,this.perspectiveCamera.position.copy(e),this.perspectiveCamera.lookAt(t),this.engine.controlModule.orbitControls.object=this.perspectiveCamera,this.engine.controlModule.firstPersonControls.camera=this.perspectiveCamera,this.updateComposerCamera(),this.perspectiveCamera.updateProjectionMatrix(),this.perspectiveCamera.updateMatrixWorld()}switchToOrthographicCamera(){if(!this.engine.controls)return;const e=this.engine.camera.position.clone(),t=this.engine.controls.target.clone();this.engine.camera=this.orthographicCamera,this.engine.scene.camera=this.orthographicCamera,this.orthographicCamera.position.copy(e),this.orthographicCamera.lookAt(t),this.engine.controlModule.orbitControls.object=this.orthographicCamera,this.engine.controlModule.firstPersonControls.camera=this.orthographicCamera,this.updateComposerCamera(),this.orthographicCamera.updateProjectionMatrix(),this.orthographicCamera.updateMatrixWorld()}getCameraType(){return this.engine.camera===this.perspectiveCamera?"perspective":this.engine.camera===this.orthographicCamera?"orthographic":"perspective"}getCameraPose(){const e=this.engine.camera,t=this.getCameraType(),n={type:t,position:{x:e.position.x,y:e.position.y,z:e.position.z},rotation:{x:e.rotation.x,y:e.rotation.y,z:e.rotation.z},quaternion:{x:e.quaternion.x,y:e.quaternion.y,z:e.quaternion.z,w:e.quaternion.w}};return this.engine.controls&&this.engine.controls.target&&(n.target={x:this.engine.controls.target.x,y:this.engine.controls.target.y,z:this.engine.controls.target.z}),t==="orthographic"&&(n.zoom=e.zoom),n}restoreCameraPose(e){this.getCameraType()!==e.type&&(e.type==="perspective"?this.switchToPerspectiveCamera():this.switchToOrthographicCamera());const n=this.engine.camera;n.position.set(e.position.x,e.position.y,e.position.z),e.quaternion?n.quaternion.set(e.quaternion.x,e.quaternion.y,e.quaternion.z,e.quaternion.w):e.rotation&&n.rotation.set(e.rotation.x,e.rotation.y,e.rotation.z),e.target&&this.engine.controls&&this.engine.controls.target&&this.engine.controls.target.set(e.target.x,e.target.y,e.target.z),e.type==="orthographic"&&e.zoom!==void 0&&(n.zoom=e.zoom,n.updateProjectionMatrix()),n.updateMatrix(),n.updateMatrixWorld(!0),this.engine.controls&&this.engine.controls.update&&this.engine.controls.update()}}class Ko{engine;deviceType;constructor(e){this.engine=e,this.deviceType=this.detectDeviceType()}detectDeviceType(){const e=[/Android/i,/webOS/i,/iPhone/i,/iPad/i,/iPod/i,/BlackBerry/i,/Windows Phone/i,/Mobile/i],t=navigator.userAgent||globalThis.opera,n=e.some(h=>h.test(t)),i="ontouchstart"in globalThis||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,s=globalThis.screen.width,r=globalThis.screen.height,a=s<=768||r<=768,c=(globalThis.devicePixelRatio||1)>=2;return n||i&&a||i&&c?"mobile":"PC"}getDeviceType(){return this.deviceType}isMobile(){return this.deviceType==="mobile"}isPC(){return this.deviceType==="PC"}redetectDeviceType(){return this.deviceType=this.detectDeviceType(),this.deviceType}getContainerSize(){return{width:this.engine.container.clientWidth,height:this.engine.container.clientHeight}}}class qo{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new b.WebGLRenderer({alpha:!0,premultipliedAlpha:!1,stencil:!0}),this.renderer.setClearColor(0,0),this.renderer.setSize(e,t),this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=b.PCFSoftShadowMap,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=b.SRGBColorSpace,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const Ns={type:"change"},Ti={type:"start"},Fs={type:"end"},Pn=new _.Ray,Us=new _.Plane,$o=Math.cos(70*_.MathUtils.DEG2RAD),xe=new _.Vector3,Oe=.25*Math.PI,de={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Di=1e-6;class Ho extends _.Controls{constructor(e,t,n=null){super(t,n),this.engine=e,this.state=de.NONE,this.target=new _.Vector3,this.cursor=new _.Vector3,this.origin=new _.Vector3(0,0,0),this.showOriginIcon=!0,this.originPosition={x:0,y:0},this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:_.MOUSE.ROTATE,MIDDLE:_.MOUSE.DOLLY,RIGHT:_.MOUSE.PAN},this.touches={ONE:_.TOUCH.ROTATE,TWO:_.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new _.Vector3,this._lastQuaternion=new _.Quaternion,this._lastTargetPosition=new _.Vector3,this._quat=new _.Quaternion().setFromUnitVectors(t.up,new _.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new _.Spherical,this._sphericalDelta=new _.Spherical,this._scale=1,this._panOffset=new _.Vector3,this._rotateStart=new _.Vector2,this._rotateEnd=new _.Vector2,this._rotateDelta=new _.Vector2,this._panStart=new _.Vector2,this._panEnd=new _.Vector2,this._panDelta=new _.Vector2,this._dollyStart=new _.Vector2,this._dollyEnd=new _.Vector2,this._dollyDelta=new _.Vector2,this._dollyDirection=new _.Vector3,this._mouse=new _.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Qo.bind(this),this._onPointerDown=Jo.bind(this),this._onPointerUp=ea.bind(this),this._onContextMenu=aa.bind(this),this._onMouseWheel=ia.bind(this),this._onKeyDown=sa.bind(this),this._onTouchStart=ra.bind(this),this._onTouchMove=oa.bind(this),this._onMouseDown=ta.bind(this),this._onMouseMove=na.bind(this),this._interceptControlDown=la.bind(this),this._interceptControlUp=ca.bind(this),this.domElement!==null&&this.connect(this.domElement),this.update()}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointercancel",this._onPointerUp),this.domElement.addEventListener("contextmenu",this._onContextMenu),this.domElement.addEventListener("wheel",this._onMouseWheel,{passive:!1}),this.domElement.getRootNode().addEventListener("keydown",this._interceptControlDown,{passive:!0,capture:!0}),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.removeEventListener("pointercancel",this._onPointerUp),this.domElement.removeEventListener("wheel",this._onMouseWheel),this.domElement.removeEventListener("contextmenu",this._onContextMenu),this.stopListenToKeyEvents(),this.domElement.getRootNode().removeEventListener("keydown",this._interceptControlDown,{capture:!0}),this.domElement.style.touchAction="auto"}dispose(){this.disconnect()}getPolarAngle(){return this._spherical.phi}getAzimuthalAngle(){return this._spherical.theta}getDistance(){return this.object.position.distanceTo(this.target)}listenToKeyEvents(e){e.addEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=e}stopListenToKeyEvents(){this._domElementKeyEvents!==null&&(this._domElementKeyEvents.removeEventListener("keydown",this._onKeyDown),this._domElementKeyEvents=null)}saveState(){this.target0.copy(this.target),this.position0.copy(this.object.position),this.zoom0=this.object.zoom}reset(){this.target.copy(this.target0),this.object.position.copy(this.position0),this.object.zoom=this.zoom0,this.object.updateProjectionMatrix(),this.dispatchEvent(Ns),this.update(),this.state=de.NONE}update(e=null){this.engine&&this.engine.interactionManager&&this.engine.interactionManager.origin&&this.origin.copy(this.engine.interactionManager.origin);const t=this.object.position;xe.copy(t).sub(this.target),xe.applyQuaternion(this._quat),this._spherical.setFromVector3(xe),this.autoRotate&&this.state===de.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Oe:n>Math.PI&&(n-=Oe),i<-Math.PI?i+=Oe:i>Math.PI&&(i-=Oe),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const r=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=r!=this._spherical.radius}if(xe.setFromSpherical(this._spherical),xe.applyQuaternion(this._quatInverse),this.engine&&this.engine.deviceType==="PC"){const r=new _.Vector3;if(r.copy(this.origin).sub(this.target),r.lengthSq()>1e-4&&(this._sphericalDelta.theta!==0||this._sphericalDelta.phi!==0)){const l=this.enableDamping?this.dampingFactor*3:1,c=new _.Vector3(0,1,0),h=new _.Vector3;this.object.getWorldDirection(h);const d=h.clone().cross(c).normalize(),m=new _.Vector3().copy(this.object.position).sub(this.origin);m.applyAxisAngle(c,Math.PI*this._sphericalDelta.theta*l),m.applyAxisAngle(d,Math.PI*this._sphericalDelta.phi*l),t.copy(this.origin).add(m);const p=new _.Vector3().copy(this.target).sub(this.origin);p.applyAxisAngle(c,Math.PI*this._sphericalDelta.theta*l),p.applyAxisAngle(d,Math.PI*this._sphericalDelta.phi*l),this.target.copy(this.origin).add(p)}else if(this._panOffset.lengthSq()===0&&this._sphericalDelta.phi===0&&this._sphericalDelta.theta===0){if(this._scale!==1){const l=new _.Vector3;this.object.getWorldDirection(l);const c=this._spherical.radius*.05*(this._scale-1);t.add(l.multiplyScalar(c))}}else t.copy(this.target).add(xe);this.object.lookAt(this.target)}else t.copy(this.target).add(xe),this.object.lookAt(this.target);if(this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let r=null;if(this.object.isPerspectiveCamera){const a=xe.length();r=this._clampDistance(a*this._scale);const l=a-r;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const a=new _.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new _.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),r=xe.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;r!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(r).add(this.object.position):(Pn.origin.copy(this.object.position),Pn.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Pn.direction))<$o?this.object.lookAt(this.target):(Us.setFromNormalAndCoplanarPoint(this.object.up,this.target),Pn.intersectPlane(Us,this.target))))}else if(this.object.isOrthographicCamera){const r=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),r!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Di||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Di||this._lastTargetPosition.distanceToSquared(this.target)>Di?(this.dispatchEvent(Ns),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Oe/60*this.autoRotateSpeed*e:Oe/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){xe.setFromMatrixColumn(t,0),xe.multiplyScalar(-e),this._panOffset.add(xe)}_panUp(e,t){this.screenSpacePanning===!0?xe.setFromMatrixColumn(t,1):(xe.setFromMatrixColumn(t,0),xe.crossVectors(this.object.up,xe)),xe.multiplyScalar(e),this._panOffset.add(xe)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;xe.copy(i).sub(this.target);let s=xe.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,s=t-n.top,r=n.width,a=n.height;this._mouse.x=i/r*2-1,this._mouse.y=-(s/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Oe*this._rotateDelta.x/t.clientHeight),this._rotateUp(Oe*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY);let t;if(this.object.isOrthographicCamera)e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY!==0&&this._dollyOut(this._getZoomScale(e.deltaY));else{const n=Math.abs(e.deltaY*.01);t=Math.pow(1.15,this.zoomSpeed*n),e.deltaY>0?this._scale/=t:e.deltaY!==0&&(this._scale*=t)}this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(Oe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-Oe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(Oe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-Oe*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._rotateStart.set(n,i)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panStart.set(n,i)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyStart.set(0,s)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const n=this._getSecondPointerPosition(e),i=.5*(e.pageX+n.x),s=.5*(e.pageY+n.y);this._rotateEnd.set(i,s)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Oe*this._rotateDelta.x/t.clientHeight),this._rotateUp(Oe*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const r=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(r,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new _.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Jo(o){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(o.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(o)&&(this._addPointer(o),o.pointerType==="touch"?this._onTouchStart(o):this._onMouseDown(o)))}function Qo(o){this.enabled!==!1&&(o.pointerType==="touch"?this._onTouchMove(o):this._onMouseMove(o))}function ea(o){switch(this._removePointer(o),this._pointers.length){case 0:this.domElement.releasePointerCapture(o.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Fs),this.state=de.NONE;break;case 1:const e=this._pointers[0],t=this._pointerPositions[e];this._onTouchStart({pointerId:e,pageX:t.x,pageY:t.y});break}}function ta(o){if(this.showOriginIcon&&this.engine&&this.engine.ToolUntils){const t=this.engine.scene?.camera||this.object;this.originPosition=this.engine.ToolUntils.WorldPointToScreenPoint(this.origin.clone(),t),console.log("Origin position:",this.originPosition,"Origin:",this.origin)}let e;switch(o.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case _.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(o),this.state=de.DOLLY;break;case _.MOUSE.ROTATE:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=de.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=de.ROTATE}break;case _.MOUSE.PAN:if(o.ctrlKey||o.metaKey||o.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(o),this.state=de.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(o),this.state=de.PAN}break;default:this.state=de.NONE}this.state!==de.NONE&&this.dispatchEvent(Ti)}function na(o){switch(this.state){case de.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(o);break;case de.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(o);break;case de.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(o);break}}function ia(o){this.enabled===!1||this.enableZoom===!1||this.state!==de.NONE||(o.preventDefault(),this.dispatchEvent(Ti),this._handleMouseWheel(this._customWheelEvent(o)),this.dispatchEvent(Fs))}function sa(o){this.enabled!==!1&&this._handleKeyDown(o)}function ra(o){switch(this._trackPointer(o),this._pointers.length){case 1:switch(this.touches.ONE){case _.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(o),this.state=de.TOUCH_ROTATE;break;case _.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(o),this.state=de.TOUCH_PAN;break;default:this.state=de.NONE}break;case 2:switch(this.touches.TWO){case _.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(o),this.state=de.TOUCH_DOLLY_PAN;break;case _.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(o),this.state=de.TOUCH_DOLLY_ROTATE;break;default:this.state=de.NONE}break;default:this.state=de.NONE}this.state!==de.NONE&&this.dispatchEvent(Ti)}function oa(o){switch(this._trackPointer(o),this.state){case de.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(o),this.update();break;case de.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(o),this.update();break;case de.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(o),this.update();break;case de.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(o),this.update();break;default:this.state=de.NONE}}function aa(o){this.enabled!==!1&&o.preventDefault()}function la(o){o.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function ca(o){o.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class Vs{constructor(e,t,n,i){this._Engine=e,this.camera=t,this.domElement=n,this._isEnabled=!1,this._rayOriginOffset=new b.Vector3(0,-1,0),this._camerLocalDirection=new b.Vector3,this._tmpVector=new b.Vector3,this._rayCaster=new b.Raycaster,this._fallingTime=0,this._euler=new b.Euler(0,0,0,"YZX"),this._prevMouseX=0,this._prevMouseY=0,this.applyGravity=!1,this.gravityMinHeight=!0,this.applyCollision=!0,this.positionEasing=!0,this.lookflag=1,this.lookSpeed=.008,this.moveSpeed=.02,this.playerHeight=1.4,this.maxRotateX=.8,this.g=9.8,this.bindmousedown=this._Engine&&this._Engine.deviceType!=="PC"?this.onTouchStart.bind(this):this.onMouseDown.bind(this),this.bindmouseup=this._Engine&&this._Engine.deviceType!=="PC"?this.onTouchEnd.bind(this):this.onMouseUp.bind(this),this.bindmousemove=this._Engine&&this._Engine.deviceType!=="PC"?this.onTouchMove.bind(this):this.onMouseMove.bind(this),this.bindonKeyDown=this.onKeyDown.bind(this),this.bindonKeyUp=this.onKeyUp.bind(this),this.bindMousewheel=this.onMousewheel.bind(this),this.needMousewheel=!1,this.moveWheelRun=!0,this.moveWheelStop=!1,this.wheelClock,this.keydown=!1,this.GetEngine=()=>e}set colliders(e){this._rayCastObjects=e}set enabled(e){this._isEnabled!==e&&(this._isEnabled=e,this._euler.setFromQuaternion(this.camera.quaternion),e?this.addEvents():this.removeEvents())}get enabled(){return this._isEnabled}addEvents(){const e=this._Engine?.DeviceType,t=e==="PC"||!e;console.log("[FirstPersonCameraControl] addEvents - DeviceType:",e,"isPC:",t),t?(console.log("[FirstPersonCameraControl] 添加鼠标事件监听器 - mousedown, mouseup"),this.domElement.addEventListener("mousedown",this.bindmousedown,!1),this.domElement.addEventListener("mouseup",this.bindmouseup,!1)):(console.log("[FirstPersonCameraControl] 添加触摸事件监听器"),this.domElement.addEventListener("touchstart",this.bindmousedown,!1),this.domElement.addEventListener("touchend",this.bindmouseup,!1)),window.addEventListener("keydown",this.bindonKeyDown,!1),window.addEventListener("keyup",this.bindonKeyUp,!1),this.needMousewheel&&(document.addEventListener&&document.addEventListener("DOMMouseScroll",this.bindMousewheel,!1),window.addEventListener("mousewheel",this.bindMousewheel,!1))}removeEvents(){this._Engine&&this._Engine.deviceType!=="PC"?(this.domElement.removeEventListener("touchstart",this.bindmousedown),this.domElement.removeEventListener("touchend",this.bindmouseup),this.domElement.removeEventListener("touchmove",this.bindmousemove)):(this.domElement.removeEventListener("mousedown",this.bindmousedown),this.domElement.removeEventListener("mouseup",this.bindmouseup),this.domElement.removeEventListener("mousemove",this.bindmousemove)),window.removeEventListener("keydown",this.bindonKeyDown),window.removeEventListener("keyup",this.bindonKeyUp),this.needMousewheel&&(document.addEventListener&&document.removeEventListener("DOMMouseScroll",this.bindMousewheel),window.removeEventListener("mousewheel",this.bindMousewheel))}onMousewheel(e){debugger;let t;switch(e.wheelDelta?(e.wheelDelta>0&&(t="up"),e.wheelDelta<0&&(t="down")):e.detail&&(e.detail<0&&(t="up"),e.detail>0&&(t="down")),t){case"up":this._camerLocalDirection.z=1;break;case"down":this._camerLocalDirection.z=-1;break}this.moveWheelRun==!0?(this.moveWheelRun=!1,this.moveWheelStop=!0,this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},200)):(clearTimeout(this.wheelClock),this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},150))}onMouseDown(e){console.log("[FirstPersonCameraControl] onMouseDown 被调用",e),this.domElement.addEventListener("mousemove",this.bindmousemove,!1),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY}onMouseMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.screenX-this._prevMouseX:0,n=this._prevMouseY?e.screenY-this._prevMouseY:0,i=this._euler.x-n*this.lookflag*this.lookSpeed;i>=0?i<this.maxRotateX?this._euler.x=i:this._euler.x=this.maxRotateX:i>-this.maxRotateX?this._euler.x=i:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY;let s=this.GetEngine();s.movefirst=!0;var r=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(r)}onMouseUp(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("mousemove",this.bindmousemove)}onTouchStart(e){this.domElement.addEventListener("touchmove",this.bindmousemove,!1),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY}onTouchMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.targetTouches[0].clientX-this._prevMouseX:0,n=this._prevMouseY?e.targetTouches[0].clientY-this._prevMouseY:0,i=this._euler.x-n*this.lookflag*this.lookSpeed;i>=0?i<this.maxRotateX?this._euler.x=i:this._euler.x=this.maxRotateX:i>-this.maxRotateX?this._euler.x=i:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY;let s=this.GetEngine();s.movefirst=!0;var r=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(r)}onTouchEnd(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("touchmove",this.bindmousemove)}onKeyDown(e){var t=new CustomEvent("bimengine:camerachange",{detail:""});let n=this.GetEngine();switch(n.movefirst=!0,window.dispatchEvent(t),e.keyCode){case 38:this.rotateY(-1);break;case 81:this.keydown=!0,this._camerLocalDirection.y=1;break;case 69:this._camerLocalDirection.y=-1;break;case 87:this._camerLocalDirection.z=1;break;case 37:this.rotateX(-1);break;case 65:this._camerLocalDirection.x=-1;break;case 40:this.rotateY(1);break;case 83:this._camerLocalDirection.z=-1;break;case 39:this.rotateX(1);break;case 68:this._camerLocalDirection.x=1;break}}onKeyUp(e){let t=this.GetEngine();switch(t.movefirst=!1,e.keyCode){case 38:case 87:this._camerLocalDirection.z=0;break;case 37:case 65:this._camerLocalDirection.x=0;break;case 40:case 83:this._camerLocalDirection.z=0;break;case 39:case 68:this._camerLocalDirection.x=0;break;case 81:case 69:this.keydown=!1,this._camerLocalDirection.y=0;break}}rotateX(e){this._euler.y-=e*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler)}rotateY(e){let t=this._euler.x-e*this.lookflag*.5*this.lookSpeed;t>=0?t<this.maxRotateX?this._euler.x=t:this._euler.x=this.maxRotateX:t>-this.maxRotateX?this._euler.x=t:this._euler.x=-this.maxRotateX,this.camera.quaternion.setFromEuler(this._euler)}update(){this.keydown||this.gravityTest(),this.collisionTest()}gravityTest(){if(this.applyGravity){let e=!0;this._fallingTime+=.01,this._tmpVector.set(0,-1,0);const t=this.hitTest();if(t){const n=t.point.add(new b.Vector3(0,this.playerHeight,0));if(this.positionEasing){if(n.y>=this.camera.position.y||n.y-this.camera.position.y<.2){this.setCameraHeight(this.camera.position.y+(n.y-this.camera.position.y)*.08),this._fallingTime=0,e=!1;return}}else t.distance<this.playerHeight&&(this.setCameraHeight(n.y),this._fallingTime=0,e=!1)}e&&this.setCameraHeight(this.camera.position.y-this.g*Math.pow(this._fallingTime,2))}else this.setCameraHeight(this.camera.position.y)}collisionTest(){this._camerLocalDirection.x!==0&&this.collisionTestX(),this._camerLocalDirection.z!==0&&this.collisionTestZ(),this._camerLocalDirection.y!==0&&this.collisionTestY()}collisionTestX(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.x),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed)}collisionTestZ(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector.crossVectors(this.camera.up,this._tmpVector),this._tmpVector.multiplyScalar(this._camerLocalDirection.z),this.applyCollision){const t=this.hitTest();if(t&&t.distance<.3)return}this.camera.position.addScaledVector(this._tmpVector,this.moveSpeed)}collisionTestY(){let e=this.GetEngine();if(e.movefirst=!0,this._tmpVector.setFromMatrixColumn(this.camera.matrix,0),this._tmpVector=new b.Vector3(0,1,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.y),this.applyCollision){const n=this.hitTest();if(n&&n.distance<.3)return}let t=this.camera.position.clone().addScaledVector(this._tmpVector,this.moveSpeed);this.setCameraHeight(t.y)}setCameraHeight(e){let t=this.getMinHeight();this.gravityMinHeight&&t!==void 0&&e<t?this.camera.position.y=t:this.camera.position.y=e}getMinHeight(){let e,t=this.GetEngine(),n=t.ToolUntils?t.ToolUntils.GetBoundingBox(t):null;return t&&n&&(e=n.min.y),e}hitTest(){const e=this.camera.position.clone().add(this._rayOriginOffset);this._rayCaster.ray.origin=e,this._rayCaster.ray.direction=this._tmpVector;var n=this.GetEngine().scene.ground;return n&&n.material.type,null}}class De{constructor(e,t,n){this.camera=e,this.renderer=t,this.scene=n,this.raycaster=new b.Raycaster}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new b.Vector2(t.x,t.y)}worldToScreen(e){const t=new b.Vector3;return t.copy(e).project(this.camera),t.x=t.x*this.renderer.domElement.clientWidth*.5,t.y=-t.y*this.renderer.domElement.clientHeight*.5,t.z=(t.z+1)*.5,t.x+=this.renderer.domElement.clientWidth*.5,t.y+=this.renderer.domElement.clientHeight*.5,new b.Vector2(t.x,t.y)}screenToNormalized(e,t){const n=this.renderer.domElement.clientWidth,i=this.renderer.domElement.clientHeight,s=e/n*2-1,r=-(t/i*2-1);return new b.Vector2(s,r)}screenToWorld(e,t,n){if(!this.scene&&!n)return console.warn("WorldToScreen: 需要提供 scene 或 objects 参数才能进行屏幕坐标转世界坐标"),null;const i=this.screenToNormalized(e,t);this.raycaster.setFromCamera(i,this.camera);const s=n||this.scene.children,r=this.raycaster.intersectObjects(s,!0);return r.length>0?r[0].point:null}screenToWorldWithDepth(e,t,n=0){const i=this.screenToNormalized(e,t);this.raycaster.setFromCamera(i,this.camera);const s=new b.Vector3;return this.raycaster.ray.at(n,s),s}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}function ki(o){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(u,g){e.self!=null&&e.self.disActive!=null&&e.self.type!=u.type&&e.self.disActive(),e.self=u,g==null&&(g={showCatch:!1}),e.options=g},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){o.renderer.domElement.addEventListener("mousedown",a),o.renderer.domElement.addEventListener("mouseup",c),o.renderer.domElement.addEventListener("mousemove",l),o.renderer.domElement.addEventListener("touchstart",d,{passive:!1}),o.renderer.domElement.addEventListener("touchend",p,{passive:!1}),o.renderer.domElement.addEventListener("touchmove",m,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",n)},e.disActive=function(){o.renderer.domElement.removeEventListener("mousedown",a),o.renderer.domElement.removeEventListener("mouseup",c),o.renderer.domElement.removeEventListener("mousemove",l),o.renderer.domElement.removeEventListener("touchstart",d),o.renderer.domElement.removeEventListener("touchend",p),o.renderer.domElement.removeEventListener("touchmove",m),window.removeEventListener("keydown",t),window.removeEventListener("keyup",n)};function t(u){(u.keyCode===8||u.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),u.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),u.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),u.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),u.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),u.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),u.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),u.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function n(u){u.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),u.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),u.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),u.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),u.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),u.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),u.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function i(u){const g=new b.Vector2,y=o.renderer.domElement.clientWidth,v=o.renderer.domElement.clientHeight;return g.x=u.offsetX/y*2-1,g.y=-(u.offsetY/v)*2+1,g}function s(u){const g=new b.Raycaster,y=i(u);return g.setFromCamera(y,o.camera),g}function r(u,g=!1){const y=s(u);if(u.raycaster=y,g){const v=f(y,u);u.catch=v}}function a(u){u.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new b.Vector3(u.offsetX,u.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(o.engineStatus.isFree=!0,r(u,!0),u.catch!=null&&o.controlModule.orbitControls.origin.set(u.catch.point.x,u.catch.point.y,u.catch.point.z),e.self.handleMouseDown(u)))}function l(u){e.self&&e.self.handleMouseMove!=null&&(r(u,!0),e.self.handleMouseMove(u))}function c(u){if(u.button!==0)return;const g=Date.now(),y=g-e.mouseDownTime,v=new b.Vector3(u.offsetX,u.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(r(u,!1),e.self.handleMouseUp(u));const w=v.distanceTo(e.mouseDownPosition);if((y<100||w==0)&&e.self&&e.self.handleMouseClick!=null){r(u,!0);const x=g-e.lastClickTime;console.log(x),x<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(u):e.self.handleMouseClick!=null&&e.self.handleMouseClick(u),e.lastClickTime=Date.now()}}function h(u){const g=u.touches[0]||u.changedTouches[0];if(!g)return null;const v=o.renderer.domElement.getBoundingClientRect(),w=g.clientX-v.left,x=g.clientY-v.top;return{offsetX:w,offsetY:x,button:0,clientX:g.clientX,clientY:g.clientY,preventDefault:()=>u.preventDefault(),stopPropagation:()=>u.stopPropagation(),originalEvent:u}}function d(u){if(u.preventDefault(),u.touches.length!==1)return;const g=h(u);g&&a(g)}function m(u){if(u.preventDefault(),u.touches.length!==1)return;const g=h(u);g&&l(g)}function p(u){u.preventDefault();const g=h(u);g&&c(g)}function f(u,g){if(!o.engineStatus.isFree){o.hoverHighLight.clearHighlight();return}o.catchSvg.innerHTML="";const y=o.octreeBox.rayInterationModel(u);let v=u.intersectObjects(o.scene.children.filter(z=>z instanceof b.InstancedMesh),!0);if(v.length>0&&(y.length==0||v[0].distance<y[0].distance)){let z=v[0].object;if(z.ids!=null&&z.ids.length!=0){let V=z.ids[v[0].instanceId],U={object:{url:z.url,id:V,name:V,isInstance:!0},face:v[0].face,distance:v[0].distance,point:v[0].point,instanceId:v[0].instanceId,matrix:z.matrixs[v[0].instanceId]};y.splice(0,0,U)}}if(y.length===0)return;let w=y[0].object.url,x=y[0].object.name,M=o.modelEdge.getModelEdge(w,x);M||(M=[0,0,[]]);let T=[];M[2].forEach(z=>{z[0]!=null&&z[1]!=null&&T.push({X:z[0].X*.5+z[1].X*.5,Y:z[0].Y*.5+z[1].Y*.5,Z:z[0].Z*.5+z[1].Z*.5})});let P=[...M[2].map(z=>z[0]),...T],k="face",D=[],E=[],O=10;if(P.forEach(z=>{if(z!=null){let V=new b.Vector3(z.X,z.Z,-z.Y),U=o.worldToScreen.worldToScreen(V),H=Math.sqrt(Math.pow(U.x-g.offsetX,2)+Math.pow(U.y-g.offsetY,2));H<O&&(O=H,D.push({point:V,distance:H,pointxy:U}))}}),D.length>0?(D.sort((z,V)=>z.distance-V.distance),k="point"):(M[2].forEach(z=>{if(z[0]!=null&&z[1]!=null){let V=new b.Vector3(z[0].X,z[0].Z,-z[0].Y),U=new b.Vector3(z[1].X,z[1].Z,-z[1].Y),H=o.worldToScreen.worldToScreen(V),G=o.worldToScreen.worldToScreen(U),$=A(new b.Vector2(g.offsetX,g.offsetY),H,G);if($<O){let F=I(new b.Vector2(g.offsetX,g.offsetY),H,G),R=S(F,V,U);E.push({distance:$,point:R,pointxy:o.worldToScreen.worldToScreen(R),start:H,end:G})}}}),E.length>0&&(E.sort((z,V)=>z.distance-V.distance),k="line")),k=="point"&&e.options.showCatch){const z=new De(o.camera,o.renderer,o.scene).worldToScreen(D[0].point);o.catchSvg.innerHTML="";const V=z.x+o.reactBoundingClientRect.left,U=z.y+o.reactBoundingClientRect.top;console.log(V,U);const H=document.createElementNS("http://www.w3.org/2000/svg","polygon");H.setAttribute("class","catchPoint"),H.setAttribute("points",`${V},${U-8} ${V-7},${U+4} ${V+7},${U+4}`),o.catchSvg.appendChild(H),y[0].point=D[0].point}else if(k=="line"&&e.options.showCatch){o.worldToScreen.worldToScreen(E[0].point);const z=E[0].start,V=E[0].end;o.catchSvg.innerHTML="";const U=document.createElementNS("http://www.w3.org/2000/svg","line");U.setAttribute("class","catchLine"),U.setAttribute("x1",(z.x+o.reactBoundingClientRect.left).toString()),U.setAttribute("y1",(z.y+o.reactBoundingClientRect.top).toString()),U.setAttribute("x2",(V.x+o.reactBoundingClientRect.left).toString()),U.setAttribute("y2",(V.y+o.reactBoundingClientRect.top).toString()),U.setAttribute("stroke","rgb(8, 223, 215)"),U.setAttribute("stroke-width","2"),o.catchSvg.appendChild(U),y[0].point=E[0].point}else if(k=="face"&&e.options.showCatch){let z=y[0].point.clone(),V=y[0].normal||(y[0].face?y[0].face.normal:null);const U=(V?V.clone():new b.Vector3(0,0,1)).normalize(),H=Math.abs(U.y)<.9?new b.Vector3(0,1,0):new b.Vector3(1,0,0),G=new b.Vector3().crossVectors(U,H).normalize(),$=new b.Vector3().crossVectors(U,G).normalize(),F=.05,ee=[new b.Vector3().copy(G).add($).multiplyScalar(F),new b.Vector3().copy(G).sub($).multiplyScalar(F),new b.Vector3().copy(G).multiplyScalar(-1).sub($).multiplyScalar(F),new b.Vector3().copy(G).multiplyScalar(-1).add($).multiplyScalar(F)].map(ce=>new b.Vector3().copy(z).add(ce)).map(ce=>o.worldToScreen.worldToScreen(ce));o.catchSvg.innerHTML="";const q=document.createElementNS("http://www.w3.org/2000/svg","polygon");q.setAttribute("class","catchFace"),q.setAttribute("points",ee.map(ce=>`${ce.x+o.reactBoundingClientRect.left},${ce.y+o.reactBoundingClientRect.top}`).join(" ")),q.setAttribute("fill","rgba(1, 238, 255, 0.2)"),q.setAttribute("stroke","rgb(0, 255, 247)"),q.setAttribute("stroke-width","1"),o.catchSvg.appendChild(q)}return y[0];function A(z,V,U){const H=new b.Vector2().subVectors(U,V),G=H.lengthSq();if(G<1e-10)return z.distanceTo(V);const $=new b.Vector2().subVectors(z,V),F=b.MathUtils.clamp($.dot(H)/G,0,1),R=new b.Vector2().copy(H).multiplyScalar(F).add(V);return z.distanceTo(R)}function I(z,V,U){const H=new b.Vector2().subVectors(U,V),G=H.lengthSq();if(G<1e-10)return 0;const $=new b.Vector2().subVectors(z,V);return b.MathUtils.clamp($.dot(H)/G,0,1)}function S(z,V,U){const H=b.MathUtils.clamp(z,0,1);return new b.Vector3().lerpVectors(V,U,H)}}return e}class ha{engine;orbitControls;firstPersonControls;isActive=!0;originDiv=null;handelBehaved;isDragging=!1;isDown=!1;containerOffset={left:0,top:0};constructor(e){this.engine=e,this.init(),this.handelBehaved=ki(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new Ho(this.engine,this.engine.camera,this.engine.renderer.domElement),this.orbitControls.showOriginIcon=!0,this.firstPersonControls=new Vs(this.engine,this.engine.camera,this.engine.renderer.domElement);const e=document.createElement("div");this.originDiv=e,e.className="originDiv",e.style.position="absolute",e.style.top="0px",e.style.left="0px",e.style.width="30px",e.style.height="30px",e.style.borderRadius="50%",e.style.pointerEvents="none",e.style.backgroundImage="url(/assets/svg/rotate-orbit.svg)",this.engine.container.appendChild(this.originDiv)}active(){this.isActive=!0,this.orbitControls.enabled=!0}disActive(){this.isActive=!1,this.orbitControls.enabled=!1}setMoveSpeed(e){this.firstPersonControls.moveSpeed=e*.1}getMoveSpeed(){return this.firstPersonControls.moveSpeed*10}setApplyCollision(e){this.firstPersonControls.applyCollision=e}getApplyCollision(){return this.firstPersonControls.applyCollision}setApplyGravity(e){this.firstPersonControls.applyGravity=e}getApplyGravity(){return this.firstPersonControls.applyGravity}toggleMinMap(){this.engine.minMap.toggle()}switchFirstPersonMode(){this.engine.cameraModule.switchToPerspectiveCamera(),this.firstPersonControls=new Vs(this.engine,this.engine.camera,this.engine.renderer.domElement,[]),this.orbitControls.enabled=!1,this.firstPersonControls.enabled=!0,this.firstPersonControls.isActive=!0}switchDefaultMode(){this.firstPersonControls&&(this.firstPersonControls.enabled=!1),this.orbitControls.enabled=!0}handleMouseUp(e){this.isDragging=!1,this.isDown=!1}handleMouseMove(e){this.isDown?this.isDragging=!0:this.isDragging=!1}handleMouseDown(e){this.isDown=!0}handleMouseClick(e){this.isDragging=!1,this.isDown=!1}update(){if(this.firstPersonControls.enabled&&this.firstPersonControls.update(),this.orbitControls.enabled){const e=this.engine.controlModule.orbitControls.origin,n=this.engine.worldToScreen.worldToScreen(e);this.originDiv&&this.isDragging?(this.originDiv.style.left=n.x-15+this.engine.reactBoundingClientRect.left+"px",this.originDiv.style.top=n.y-15+this.engine.reactBoundingClientRect.top+"px",this.originDiv.style.display="block"):this.originDiv&&(this.originDiv.style.display="none")}}}const St={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
1
|
+
(function(Qe,M){typeof exports=="object"&&typeof module<"u"?M(exports,require("three"),require("opentype.js")):typeof define=="function"&&define.amd?define(["exports","three","opentype.js"],M):(Qe=typeof globalThis<"u"?globalThis:Qe||self,M(Qe.BimEngineSDK={},Qe.THREE,Qe["{}"]))})(this,(function(Qe,M,ia){"use strict";function Gs(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const w=Gs(M),sa=Gs(ia);class oa{engine;scene;constructor(e){this.engine=e,this.scene=new w.Scene;let t=new w.Group;t.name="groupEdge",this.scene.add(t)}}class ra{engine;perspectiveCamera;orthographicCamera;constructor(e){this.engine=e,this.perspectiveCamera=new w.PerspectiveCamera(30,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 w.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)}setPerspectiveFov(e,t){const n=this.perspectiveCamera,i=n.fov,s=Math.max(1,Math.min(120,e));if(t?.adjustDistance!==!1&&this.engine.camera===n&&this.engine.controls?.target){const a=this.engine.controls.target.clone(),l=n.position.clone(),c=l.distanceTo(a);if(c>1e-6){const h=i*Math.PI/180*.5,u=s*Math.PI/180*.5,m=Math.tan(h)/Math.tan(u),p=c*m,f=new w.Vector3().subVectors(l,a).normalize();n.position.copy(a).add(f.multiplyScalar(p))}}n.fov=s,n.updateProjectionMatrix()}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()}setViewFromOriginAndDirection(e,t,n){const i=new w.Vector3(t.x,t.y,t.z).normalize(),s=new w.Vector3(e.x,e.y,e.z);if(n==null||n<=0){const l=this.engine.octreeBox?.getBoundingBox?.();if(l&&l.min&&l.max){const c=new w.Vector3().subVectors(l.max,l.min);n=Math.max(c.x,c.y,c.z)*1.2}else n=50}const o=s.clone().add(i.clone().negate().multiplyScalar(n)),a=this.engine.camera;a&&(a.position.copy(o),a.lookAt(s),this.engine.controls?.target&&this.engine.controls.target.copy(s),this.engine.controls?.update&&this.engine.controls.update(),a.updateMatrix(),a.updateMatrixWorld(!0))}}class aa{engine;deviceType;constructor(e){this.engine=e,this.deviceType=this.detectDeviceType()}detectDeviceType(){const e=[/Android/i,/webOS/i,/iPhone/i,/iPad/i,/iPod/i,/BlackBerry/i,/Windows Phone/i,/Mobile/i],t=navigator.userAgent||globalThis.opera,n=e.some(h=>h.test(t)),i="ontouchstart"in globalThis||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0,s=globalThis.screen.width,o=globalThis.screen.height,a=s<=768||o<=768,c=(globalThis.devicePixelRatio||1)>=2;return n||i&&a||i&&c?"mobile":"PC"}getDeviceType(){return this.deviceType}isMobile(){return this.deviceType==="mobile"}isPC(){return this.deviceType==="PC"}redetectDeviceType(){return this.deviceType=this.detectDeviceType(),this.deviceType}getContainerSize(){return{width:this.engine.container.clientWidth,height:this.engine.container.clientHeight}}}class la{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new w.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=w.PCFSoftShadowMap,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=w.SRGBColorSpace,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const js={type:"change"},Ii={type:"start"},Ws={type:"end"},kn=new M.Ray,Xs=new M.Plane,ca=Math.cos(70*M.MathUtils.DEG2RAD),xe=new M.Vector3,ha=new M.Vector3,da=new M.Vector3,ua=new M.Vector3(0,1,0),fa=new M.Vector3(1,0,0),pa=new M.Vector3(0,0,1),Re=.25*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},Dn=1e-6;class ma extends M.Controls{constructor(e,t,n=null){super(t,n),this.engine=e,this.state=ue.NONE,this.target=new M.Vector3,this.cursor=new M.Vector3,this.origin=new M.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.polarSafetyAngle=M.MathUtils.degToRad(5),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:M.MOUSE.ROTATE,MIDDLE:M.MOUSE.DOLLY,RIGHT:M.MOUSE.PAN},this.touches={ONE:M.TOUCH.ROTATE,TWO:M.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 M.Vector3,this._lastQuaternion=new M.Quaternion,this._lastTargetPosition=new M.Vector3,this._quat=new M.Quaternion().setFromUnitVectors(t.up,new M.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new M.Spherical,this._sphericalDelta=new M.Spherical,this._scale=1,this._panOffset=new M.Vector3,this._rotateStart=new M.Vector2,this._rotateEnd=new M.Vector2,this._rotateDelta=new M.Vector2,this._panStart=new M.Vector2,this._panEnd=new M.Vector2,this._panDelta=new M.Vector2,this._dollyStart=new M.Vector2,this._dollyEnd=new M.Vector2,this._dollyDelta=new M.Vector2,this._dollyDirection=new M.Vector3,this._mouse=new M.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=ya.bind(this),this._onPointerDown=ga.bind(this),this._onPointerUp=va.bind(this),this._onContextMenu=Ca.bind(this),this._onMouseWheel=ba.bind(this),this._onKeyDown=Ma.bind(this),this._onTouchStart=_a.bind(this),this._onTouchMove=Sa.bind(this),this._onMouseDown=wa.bind(this),this._onMouseMove=xa.bind(this),this._interceptControlDown=Aa.bind(this),this._interceptControlUp=Pa.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(js),this.update(),this.state=ue.NONE}update(e=null){this.engine&&this.engine.interactionManager&&this.engine.interactionManager.origin&&this.origin.copy(this.engine.interactionManager.origin);const t=this.object.position;xe.copy(t).sub(this.target),xe.applyQuaternion(this._quat),this._spherical.setFromVector3(xe),this.autoRotate&&this.state===ue.NONE&&this._rotateLeft(this._getAutoRotationAngle(e)),this.enableDamping?(this._spherical.theta+=this._sphericalDelta.theta*this.dampingFactor,this._spherical.phi+=this._sphericalDelta.phi*this.dampingFactor):(this._spherical.theta+=this._sphericalDelta.theta,this._spherical.phi+=this._sphericalDelta.phi);let n=this.minAzimuthAngle,i=this.maxAzimuthAngle;isFinite(n)&&isFinite(i)&&(n<-Math.PI?n+=Re:n>Math.PI&&(n-=Re),i<-Math.PI?i+=Re:i>Math.PI&&(i-=Re),n<=i?this._spherical.theta=Math.max(n,Math.min(i,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(n+i)/2?Math.max(n,this._spherical.theta):Math.min(i,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let s=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const o=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),s=o!=this._spherical.radius}if(xe.setFromSpherical(this._spherical),xe.applyQuaternion(this._quatInverse),this.engine&&this.engine.deviceType==="PC"){const o=new M.Vector3;if(o.copy(this.origin).sub(this.target),o.lengthSq()>1e-4&&(this._sphericalDelta.theta!==0||this._sphericalDelta.phi!==0)){const l=this.enableDamping?this.dampingFactor*3:1,c=ua,h=ha;this.object.getWorldDirection(h);const u=Math.abs(h.y)>.999?fa:c,m=da;m.crossVectors(h,u),m.lengthSq()<Dn&&m.crossVectors(h,pa),m.normalize();const p=new M.Vector3().copy(this.object.position).sub(this.origin);p.applyAxisAngle(c,Math.PI*this._sphericalDelta.theta*l),p.applyAxisAngle(m,Math.PI*this._sphericalDelta.phi*l),t.copy(this.origin).add(p);const f=new M.Vector3().copy(this.target).sub(this.origin);f.applyAxisAngle(c,Math.PI*this._sphericalDelta.theta*l),f.applyAxisAngle(m,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 M.Vector3;this.object.getWorldDirection(l);const c=this._spherical.radius*.05*(this._scale-1);t.add(l.multiplyScalar(c))}}else t.copy(this.target).add(xe);this.object.lookAt(this.target)}else t.copy(this.target).add(xe),this.object.lookAt(this.target);if(this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let o=null;if(this.object.isPerspectiveCamera){const a=xe.length();o=this._clampDistance(a*this._scale);const l=a-o;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),s=!!l}else if(this.object.isOrthographicCamera){const a=new M.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),s=l!==this.object.zoom;const c=new M.Vector3(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(a),this.object.updateMatrixWorld(),o=xe.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;o!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(o).add(this.object.position):(kn.origin.copy(this.object.position),kn.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(kn.direction))<ca?this.object.lookAt(this.target):(Xs.setFromNormalAndCoplanarPoint(this.object.up,this.target),kn.intersectPlane(Xs,this.target))))}else if(this.object.isOrthographicCamera){const o=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),o!==this.object.zoom&&(this.object.updateProjectionMatrix(),s=!0)}return this._scale=1,this._performCursorZoom=!1,s||this._lastPosition.distanceToSquared(this.object.position)>Dn||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Dn||this._lastTargetPosition.distanceToSquared(this.target)>Dn?(this.dispatchEvent(js),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?Re/60*this.autoRotateSpeed*e:Re/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){xe.setFromMatrixColumn(t,0),xe.multiplyScalar(-e),this._panOffset.add(xe)}_panUp(e,t){this.screenSpacePanning===!0?xe.setFromMatrixColumn(t,1):(xe.setFromMatrixColumn(t,0),xe.crossVectors(this.object.up,xe)),xe.multiplyScalar(e),this._panOffset.add(xe)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;xe.copy(i).sub(this.target);let s=xe.length();s*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*s/n.clientHeight,this.object.matrix),this._panUp(2*t*s/n.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/n.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/n.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const n=this.domElement.getBoundingClientRect(),i=e-n.left,s=t-n.top,o=n.width,a=n.height;this._mouse.x=i/o*2-1,this._mouse.y=-(s/a)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(Re*this._rotateDelta.x/t.clientHeight),this._rotateUp(Re*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(Re*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(-Re*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(Re*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(-Re*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(Re*this._rotateDelta.x/t.clientHeight),this._rotateUp(Re*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),n=.5*(e.pageX+t.x),i=.5*(e.pageY+t.y);this._panEnd.set(n,i)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),n=e.pageX-t.x,i=e.pageY-t.y,s=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,s),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const o=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(o,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new M.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 ga(r){this.enabled!==!1&&(this._pointers.length===0&&(this.domElement.setPointerCapture(r.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.domElement.addEventListener("pointerup",this._onPointerUp)),!this._isTrackingPointer(r)&&(this._addPointer(r),r.pointerType==="touch"?this._onTouchStart(r):this._onMouseDown(r)))}function ya(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function va(r){switch(this._removePointer(r),this._pointers.length){case 0:this.domElement.releasePointerCapture(r.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.dispatchEvent(Ws),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 wa(r){if(this.showOriginIcon&&this.engine&&this.engine.ToolUntils){const t=this.engine.scene?.camera||this.object;this.originPosition=this.engine.ToolUntils.WorldPointToScreenPoint(this.origin.clone(),t),console.log("Origin position:",this.originPosition,"Origin:",this.origin)}let e;switch(r.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case M.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=ue.DOLLY;break;case M.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=ue.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=ue.ROTATE}break;case M.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=ue.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=ue.PAN}break;default:this.state=ue.NONE}this.state!==ue.NONE&&this.dispatchEvent(Ii)}function xa(r){switch(this.state){case ue.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case ue.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case ue.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function ba(r){this.enabled===!1||this.enableZoom===!1||this.state!==ue.NONE||(r.preventDefault(),this.dispatchEvent(Ii),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(Ws))}function Ma(r){this.enabled!==!1&&this._handleKeyDown(r)}function _a(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case M.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=ue.TOUCH_ROTATE;break;case M.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=ue.TOUCH_PAN;break;default:this.state=ue.NONE}break;case 2:switch(this.touches.TWO){case M.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=ue.TOUCH_DOLLY_PAN;break;case M.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=ue.TOUCH_DOLLY_ROTATE;break;default:this.state=ue.NONE}break;default:this.state=ue.NONE}this.state!==ue.NONE&&this.dispatchEvent(Ii)}function Sa(r){switch(this._trackPointer(r),this.state){case ue.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case ue.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case ue.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case ue.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=ue.NONE}}function Ca(r){this.enabled!==!1&&r.preventDefault()}function Aa(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function Pa(r){r.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 w.Vector3(0,-1,0),this._camerLocalDirection=new w.Vector3,this._tmpVector=new w.Vector3,this._rayCaster=new w.Raycaster,this._fallingTime=0,this._isMouseInElement=!1,this._euler=new w.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.bindMouseEnter=this.onMouseEnter.bind(this),this.bindMouseLeave=this.onMouseLeave.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)),this.domElement.addEventListener("mouseenter",this.bindMouseEnter,!1),this.domElement.addEventListener("mouseleave",this.bindMouseLeave,!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)),this.domElement.removeEventListener("mouseenter",this.bindMouseEnter),this.domElement.removeEventListener("mouseleave",this.bindMouseLeave),window.removeEventListener("keydown",this.bindonKeyDown),window.removeEventListener("keyup",this.bindonKeyUp),this.needMousewheel&&(document.addEventListener&&document.removeEventListener("DOMMouseScroll",this.bindMousewheel),window.removeEventListener("mousewheel",this.bindMousewheel))}onMouseEnter(e){this._isMouseInElement=!0}onMouseLeave(e){this._isMouseInElement=!1}onMousewheel(e){debugger;let t;switch(e.wheelDelta?(e.wheelDelta>0&&(t="up"),e.wheelDelta<0&&(t="down")):e.detail&&(e.detail<0&&(t="up"),e.detail>0&&(t="down")),t){case"up":this._camerLocalDirection.z=1;break;case"down":this._camerLocalDirection.z=-1;break}this.moveWheelRun==!0?(this.moveWheelRun=!1,this.moveWheelStop=!0,this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},200)):(clearTimeout(this.wheelClock),this.wheelClock=setTimeout(()=>{this.moveWheelStop==!0&&(this.moveWheelStop=!1,this.moveWheelRun=!0,this._camerLocalDirection.z=0)},150))}onMouseDown(e){console.log("[FirstPersonCameraControl] onMouseDown 被调用",e),this.domElement.addEventListener("mousemove",this.bindmousemove,!1),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY}onMouseMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.screenX-this._prevMouseX:0,n=this._prevMouseY?e.screenY-this._prevMouseY:0,i=this._euler.x-n*this.lookflag*this.lookSpeed;i>=0?i<this.maxRotateX?this._euler.x=i:this._euler.x=this.maxRotateX:i>-this.maxRotateX?this._euler.x=i:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.screenX,this._prevMouseY=e.screenY;let s=this.GetEngine();s.movefirst=!0;var o=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(o)}onMouseUp(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("mousemove",this.bindmousemove)}onTouchStart(e){this.domElement.addEventListener("touchmove",this.bindmousemove,!1),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY}onTouchMove(e){if(this._isEnabled==!1)return;let t=this._prevMouseX?e.targetTouches[0].clientX-this._prevMouseX:0,n=this._prevMouseY?e.targetTouches[0].clientY-this._prevMouseY:0,i=this._euler.x-n*this.lookflag*this.lookSpeed;i>=0?i<this.maxRotateX?this._euler.x=i:this._euler.x=this.maxRotateX:i>-this.maxRotateX?this._euler.x=i:this._euler.x=-this.maxRotateX,this._euler.y-=t*this.lookSpeed,this.camera.quaternion.setFromEuler(this._euler),this._prevMouseX=e.targetTouches[0].clientX,this._prevMouseY=e.targetTouches[0].clientY;let s=this.GetEngine();s.movefirst=!0;var o=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(o)}onTouchEnd(e){let t=this.GetEngine();t.movefirst=!1,this.domElement.removeEventListener("touchmove",this.bindmousemove)}onKeyDown(e){if(!this._isMouseInElement)return;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){if(!this._isMouseInElement)return;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 w.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 w.Vector3(0,1,0),this._tmpVector.multiplyScalar(this._camerLocalDirection.y),this.applyCollision){const n=this.hitTest();if(n&&n.distance<.3)return}let t=this.camera.position.clone().addScaledVector(this._tmpVector,this.moveSpeed);this.setCameraHeight(t.y)}setCameraHeight(e){let t=this.getMinHeight();this.gravityMinHeight&&t!==void 0&&e<t?this.camera.position.y=t:this.camera.position.y=e}getMinHeight(){let e,t=this.GetEngine(),n=t.ToolUntils?t.ToolUntils.GetBoundingBox(t):null;return t&&n&&(e=n.min.y),e}hitTest(){const e=this.camera.position.clone().add(this._rayOriginOffset);this._rayCaster.ray.origin=e,this._rayCaster.ray.direction=this._tmpVector;var n=this.GetEngine().scene.ground;return n&&n.material.type,null}}class _e{constructor(e,t,n){this.camera=e,this.renderer=t,this.scene=n,this.raycaster=new w.Raycaster}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new w.Vector2(t.x,t.y)}worldToScreen(e){const t=new w.Vector3;return t.copy(e).project(this.camera),t.x=t.x*this.renderer.domElement.clientWidth*.5,t.y=-t.y*this.renderer.domElement.clientHeight*.5,t.z=(t.z+1)*.5,t.x+=this.renderer.domElement.clientWidth*.5,t.y+=this.renderer.domElement.clientHeight*.5,new w.Vector2(t.x,t.y)}screenToNormalized(e,t){const n=this.renderer.domElement.clientWidth,i=this.renderer.domElement.clientHeight,s=e/n*2-1,o=-(t/i*2-1);return new w.Vector2(s,o)}screenToWorld(e,t,n){if(!this.scene&&!n)return console.warn("WorldToScreen: 需要提供 scene 或 objects 参数才能进行屏幕坐标转世界坐标"),null;const i=this.screenToNormalized(e,t);this.raycaster.setFromCamera(i,this.camera);const s=n||this.scene.children,o=this.raycaster.intersectObjects(s,!0);return o.length>0?o[0].point:null}screenToWorldWithDepth(e,t,n=0){const i=this.screenToNormalized(e,t);this.raycaster.setFromCamera(i,this.camera);const s=new w.Vector3;return this.raycaster.ray.at(n,s),s}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}function zi(r){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(d,g){e.self!=null&&e.self.disActive!=null&&e.self.type!=d.type&&e.self.disActive(),e.self=d,g==null&&(g={showCatch:!1}),e.options=g},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){r.renderer.domElement.addEventListener("mousedown",a),r.renderer.domElement.addEventListener("mouseup",c),r.renderer.domElement.addEventListener("mousemove",l),r.renderer.domElement.addEventListener("touchstart",u,{passive:!1}),r.renderer.domElement.addEventListener("touchend",p,{passive:!1}),r.renderer.domElement.addEventListener("touchmove",m,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",n)},e.disActive=function(){r.renderer.domElement.removeEventListener("mousedown",a),r.renderer.domElement.removeEventListener("mouseup",c),r.renderer.domElement.removeEventListener("mousemove",l),r.renderer.domElement.removeEventListener("touchstart",u),r.renderer.domElement.removeEventListener("touchend",p),r.renderer.domElement.removeEventListener("touchmove",m),window.removeEventListener("keydown",t),window.removeEventListener("keyup",n)};function t(d){(d.keyCode===8||d.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),d.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),d.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),d.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),d.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),d.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),d.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),d.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function n(d){d.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),d.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),d.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),d.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),d.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),d.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),d.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function i(d){const g=new w.Vector2,y=r.renderer.domElement.clientWidth,v=r.renderer.domElement.clientHeight;return g.x=d.offsetX/y*2-1,g.y=-(d.offsetY/v)*2+1,g}function s(d){const g=new w.Raycaster,y=i(d);return g.setFromCamera(y,r.camera),g}function o(d,g=!1){const y=s(d);if(d.raycaster=y,g){const v=f(y,d);d.catch=v}}function a(d){d.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new w.Vector3(d.offsetX,d.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(r.engineStatus.isFree=!0,o(d,!0),d.catch!=null&&r.controlModule.orbitControls.origin.set(d.catch.point.x,d.catch.point.y,d.catch.point.z),e.self.handleMouseDown(d)))}function l(d){e.self&&e.self.handleMouseMove!=null&&(o(d,!0),e.self.handleMouseMove(d))}function c(d){if(d.button!==0)return;const g=Date.now(),y=g-e.mouseDownTime,v=new w.Vector3(d.offsetX,d.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(o(d,!1),e.self.handleMouseUp(d));const x=v.distanceTo(e.mouseDownPosition);if((y<100||x==0)&&e.self&&e.self.handleMouseClick!=null){o(d,!0);const b=g-e.lastClickTime;console.log(b),b<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(d):e.self.handleMouseClick!=null&&e.self.handleMouseClick(d),e.lastClickTime=Date.now()}}function h(d){const g=d.touches[0]||d.changedTouches[0];if(!g)return null;const v=r.renderer.domElement.getBoundingClientRect(),x=g.clientX-v.left,b=g.clientY-v.top;return{offsetX:x,offsetY:b,button:0,clientX:g.clientX,clientY:g.clientY,preventDefault:()=>d.preventDefault(),stopPropagation:()=>d.stopPropagation(),originalEvent:d}}function u(d){if(d.preventDefault(),d.touches.length!==1)return;const g=h(d);g&&a(g)}function m(d){if(d.preventDefault(),d.touches.length!==1)return;const g=h(d);g&&l(g)}function p(d){d.preventDefault();const g=h(d);g&&c(g)}function f(d,g){if(!r.engineStatus.isFree){r.hoverHighLight.clearHighlight();return}r.catchSvg.innerHTML="";const y=r.octreeBox.rayInterationModel(d);let v=d.intersectObjects(r.scene.children.filter(z=>z instanceof w.InstancedMesh),!0);if(v.length>0&&(y.length==0||v[0].distance<y[0].distance)){let z=v[0].object;if(z.ids!=null&&z.ids.length!=0){let U=z.ids[v[0].instanceId],V={object:{url:z.url,id:U,name:U,isInstance:!0},face:v[0].face,distance:v[0].distance,point:v[0].point,instanceId:v[0].instanceId,matrix:z.matrixs[v[0].instanceId]};y.splice(0,0,V)}}if(y.length===0)return;let x=y[0].object.url,b=y[0].object.name,_=r.modelEdge.getModelEdge(x,b);_||(_=[0,0,[]]);let T=[];_[2].forEach(z=>{z[0]!=null&&z[1]!=null&&T.push({X:z[0].X*.5+z[1].X*.5,Y:z[0].Y*.5+z[1].Y*.5,Z:z[0].Z*.5+z[1].Z*.5})});let P=[..._[2].map(z=>z[0]),...T],D="face",k=[],E=[],R=10;if(P.forEach(z=>{if(z!=null){let U=new w.Vector3(z.X,z.Z,-z.Y),V=r.worldToScreen.worldToScreen(U),$=Math.sqrt(Math.pow(V.x-g.offsetX,2)+Math.pow(V.y-g.offsetY,2));$<R&&(R=$,k.push({point:U,distance:$,pointxy:V}))}}),k.length>0?(k.sort((z,U)=>z.distance-U.distance),D="point"):(_[2].forEach(z=>{if(z[0]!=null&&z[1]!=null){let U=new w.Vector3(z[0].X,z[0].Z,-z[0].Y),V=new w.Vector3(z[1].X,z[1].Z,-z[1].Y),$=r.worldToScreen.worldToScreen(U),G=r.worldToScreen.worldToScreen(V),q=A(new w.Vector2(g.offsetX,g.offsetY),$,G);if(q<R){let N=I(new w.Vector2(g.offsetX,g.offsetY),$,G),O=S(N,U,V);E.push({distance:q,point:O,pointxy:r.worldToScreen.worldToScreen(O),start:$,end:G})}}}),E.length>0&&(E.sort((z,U)=>z.distance-U.distance),D="line")),D=="point"&&e.options.showCatch){const z=new _e(r.camera,r.renderer,r.scene).worldToScreen(k[0].point);r.catchSvg.innerHTML="";const U=z.x+r.reactBoundingClientRect.left,V=z.y+r.reactBoundingClientRect.top;console.log(U,V);const $=document.createElementNS("http://www.w3.org/2000/svg","polygon");$.setAttribute("class","catchPoint"),$.setAttribute("points",`${U},${V-8} ${U-7},${V+4} ${U+7},${V+4}`),r.catchSvg.appendChild($),y[0].point=k[0].point}else if(D=="line"&&e.options.showCatch){r.worldToScreen.worldToScreen(E[0].point);const z=E[0].start,U=E[0].end;r.catchSvg.innerHTML="";const V=document.createElementNS("http://www.w3.org/2000/svg","line");V.setAttribute("class","catchLine"),V.setAttribute("x1",(z.x+r.reactBoundingClientRect.left).toString()),V.setAttribute("y1",(z.y+r.reactBoundingClientRect.top).toString()),V.setAttribute("x2",(U.x+r.reactBoundingClientRect.left).toString()),V.setAttribute("y2",(U.y+r.reactBoundingClientRect.top).toString()),V.setAttribute("stroke","rgb(8, 223, 215)"),V.setAttribute("stroke-width","2"),r.catchSvg.appendChild(V),y[0].point=E[0].point}else if(D=="face"&&e.options.showCatch){let z=y[0].point.clone(),U=y[0].normal||(y[0].face?y[0].face.normal:null);const V=(U?U.clone():new w.Vector3(0,0,1)).normalize(),$=Math.abs(V.y)<.9?new w.Vector3(0,1,0):new w.Vector3(1,0,0),G=new w.Vector3().crossVectors(V,$).normalize(),q=new w.Vector3().crossVectors(V,G).normalize(),N=.05,te=[new w.Vector3().copy(G).add(q).multiplyScalar(N),new w.Vector3().copy(G).sub(q).multiplyScalar(N),new w.Vector3().copy(G).multiplyScalar(-1).sub(q).multiplyScalar(N),new w.Vector3().copy(G).multiplyScalar(-1).add(q).multiplyScalar(N)].map(ce=>new w.Vector3().copy(z).add(ce)).map(ce=>r.worldToScreen.worldToScreen(ce));r.catchSvg.innerHTML="";const H=document.createElementNS("http://www.w3.org/2000/svg","polygon");H.setAttribute("class","catchFace"),H.setAttribute("points",te.map(ce=>`${ce.x+r.reactBoundingClientRect.left},${ce.y+r.reactBoundingClientRect.top}`).join(" ")),H.setAttribute("fill","rgba(1, 238, 255, 0.2)"),H.setAttribute("stroke","rgb(0, 255, 247)"),H.setAttribute("stroke-width","1"),r.catchSvg.appendChild(H)}return y[0];function A(z,U,V){const $=new w.Vector2().subVectors(V,U),G=$.lengthSq();if(G<1e-10)return z.distanceTo(U);const q=new w.Vector2().subVectors(z,U),N=w.MathUtils.clamp(q.dot($)/G,0,1),O=new w.Vector2().copy($).multiplyScalar(N).add(U);return z.distanceTo(O)}function I(z,U,V){const $=new w.Vector2().subVectors(V,U),G=$.lengthSq();if(G<1e-10)return 0;const q=new w.Vector2().subVectors(z,U);return w.MathUtils.clamp(q.dot($)/G,0,1)}function S(z,U,V){const $=w.MathUtils.clamp(z,0,1);return new w.Vector3().lerpVectors(U,V,$)}}return e}class Ta{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=zi(this.engine),this.handelBehaved.init(this,null),this.handelBehaved.active()}init(){this.orbitControls=new ma(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*.1}getMoveSpeed(){return this.firstPersonControls.moveSpeed*10}setApplyCollision(e){this.firstPersonControls.applyCollision=e}getApplyCollision(){return this.firstPersonControls.applyCollision}setApplyGravity(e){this.firstPersonControls.applyGravity=e}getApplyGravity(){return this.firstPersonControls.applyGravity}toggleMinMap(){this.engine.minMap.toggle()}switchFirstPersonMode(){this.engine.cameraModule.switchToPerspectiveCamera(),this.firstPersonControls=new 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.orbitControls.enabled=!0}handleMouseUp(e){this.isDragging=!1,this.isDown=!1}handleMouseMove(e){this.isDown?this.isDragging=!0:this.isDragging=!1}handleMouseDown(e){this.isDown=!0}handleMouseClick(e){this.isDragging=!1,this.isDown=!1}update(){if(this.firstPersonControls.enabled&&this.firstPersonControls.update(),this.orbitControls.enabled){const e=this.engine.controlModule.orbitControls.origin,n=this.engine.worldToScreen.worldToScreen(e);this.originDiv&&this.isDragging?(this.originDiv.style.left=n.x-15+this.engine.reactBoundingClientRect.left+"px",this.originDiv.style.top=n.y-15+this.engine.reactBoundingClientRect.top+"px",this.originDiv.style.display="block"):this.originDiv&&(this.originDiv.style.display="none")}}}const St={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
|
|
2
2
|
|
|
3
3
|
varying vec2 vUv;
|
|
4
4
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
gl_FragColor = opacity * texel;
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
}`};class Ct{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const
|
|
24
|
+
}`};class Ct{constructor(){this.isPass=!0,this.enabled=!0,this.needsSwap=!0,this.clear=!1,this.renderToScreen=!1}setSize(){}render(){console.error("THREE.Pass: .render() must be implemented in derived pass.")}dispose(){}}const ka=new M.OrthographicCamera(-1,1,1,-1,0,1);class Da extends M.BufferGeometry{constructor(){super(),this.setAttribute("position",new M.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new M.Float32BufferAttribute([0,2,0,0,2,0],2))}}const Ea=new Da;class En{constructor(e){this._mesh=new M.Mesh(Ea,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,ka)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class Ln extends Ct{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof M.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=M.UniformsUtils.clone(e.uniforms),this.material=new M.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 En(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 Ys extends Ct{constructor(e,t){super(),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1}render(e,t,n){const i=e.getContext(),s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);let o,a;this.inverse?(o=0,a=1):(o=1,a=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),s.buffers.stencil.setFunc(i.ALWAYS,o,4294967295),s.buffers.stencil.setClear(a),s.buffers.stencil.setLocked(!0),e.setRenderTarget(n),this.clear&&e.clear(),e.render(this.scene,this.camera),e.setRenderTarget(t),this.clear&&e.clear(),e.render(this.scene,this.camera),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.color.setMask(!0),s.buffers.depth.setMask(!0),s.buffers.stencil.setLocked(!1),s.buffers.stencil.setFunc(i.EQUAL,1,4294967295),s.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),s.buffers.stencil.setLocked(!0)}}class La extends Ct{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class Ia{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new M.Vector2);this._width=n.width,this._height=n.height,t=new M.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:M.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 Ln(St),this.copyPass.material.blending=M.NoBlending,this.clock=new M.Clock}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let i=0,s=this.passes.length;i<s;i++){const o=this.passes[i];if(o.enabled!==!1){if(o.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),o.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),o.needsSwap){if(n){const a=this.renderer.getContext(),l=this.renderer.state.buffers.stencil;l.setFunc(a.NOTEQUAL,1,4294967295),this.copyPass.render(this.renderer,this.writeBuffer,this.readBuffer,e),l.setFunc(a.EQUAL,1,4294967295)}this.swapBuffers()}Ys!==void 0&&(o instanceof Ys?n=!0:o instanceof La&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new M.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 za extends Ct{constructor(e,t,n=null,i=null,s=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=s,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new M.Color}render(e,t,n){const i=e.autoClear;e.autoClear=!1;let s,o;this.overrideMaterial!==null&&(o=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(s=e.getClearAlpha(),e.setClearAlpha(this.clearAlpha)),this.clearDepth==!0&&e.clearDepth(),e.setRenderTarget(this.renderToScreen?null:n),this.clear===!0&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),e.render(this.scene,this.camera),this.clearColor!==null&&e.setClearColor(this._oldClearColor),this.clearAlpha!==null&&e.setClearAlpha(s),this.overrideMaterial!==null&&(this.scene.overrideMaterial=o),e.autoClear=i}}const In={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 M.Vector2},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new M.Matrix4},cameraProjectionMatrixInverse:{value:new M.Matrix4},cameraWorldMatrix:{value:new M.Matrix4},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new M.Vector3(-1,-1,-1)},sceneBoxMax:{value:new M.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
|
+
}`},zn={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
|
+
}`},Bi={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 Ba(r=5){const e=Math.floor(r)%2===0?Math.floor(r)+1:Math.floor(r),t=Ra(e),n=t.length,i=new Uint8Array(n*4);for(let o=0;o<n;++o){const a=t[o],l=2*Math.PI*a/n,c=new M.Vector3(Math.cos(l),Math.sin(l),0).normalize();i[o*4]=(c.x*.5+.5)*255,i[o*4+1]=(c.y*.5+.5)*255,i[o*4+2]=127,i[o*4+3]=255}const s=new M.DataTexture(i,e,e);return s.wrapS=M.RepeatWrapping,s.wrapT=M.RepeatWrapping,s.needsUpdate=!0,s}function Ra(r){const e=Math.floor(r)%2===0?Math.floor(r)+1:Math.floor(r),t=e*e,n=Array(t).fill(0);let i=Math.floor(e/2),s=e-1;for(let o=1;o<=t;){if(i===-1&&s===e?(s=e-2,i=0):(s===e&&(s=0),i<0&&(i=e-1)),n[i*e+s]!==0){s-=2,i++;continue}else n[i*e+s]=o++;s++,i--}return n}const Bn={defines:{SAMPLES:16,SAMPLE_VECTORS:Ks(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 M.Vector2},cameraProjectionMatrixInverse:{value:new M.Matrix4},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`
|
|
250
250
|
|
|
251
251
|
varying vec2 vUv;
|
|
252
252
|
|
|
@@ -391,7 +391,7 @@
|
|
|
391
391
|
denoised /= totalWeight;
|
|
392
392
|
}
|
|
393
393
|
gl_FragColor = FRAGMENT_OUTPUT;
|
|
394
|
-
}`};function Gs(o,e,t){const n=wa(o,e,t);let i="vec3[SAMPLES](";for(let s=0;s<o;s++){const r=n[s];i+=`vec3(${r.x}, ${r.y}, ${r.z})${s<o-1?",":")"}`}return i}function wa(o,e,t){const n=[];for(let i=0;i<o;i++){const s=2*Math.PI*e*i/o,r=Math.pow(i/(o-1),t);n.push(new _.Vector3(Math.cos(s),Math.sin(s),r))}return n}class Ws{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let t=0;t<512;t++)this.perm[t]=this.p[t&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}noise(e,t){let n,i,s;const r=.5*(Math.sqrt(3)-1),a=(e+t)*r,l=Math.floor(e+a),c=Math.floor(t+a),h=(3-Math.sqrt(3))/6,d=(l+c)*h,m=l-d,p=c-d,f=e-m,u=t-p;let g,y;f>u?(g=1,y=0):(g=0,y=1);const v=f-g+h,w=u-y+h,x=f-1+2*h,M=u-1+2*h,T=l&255,P=c&255,k=this.perm[T+this.perm[P]]%12,D=this.perm[T+g+this.perm[P+y]]%12,E=this.perm[T+1+this.perm[P+1]]%12;let O=.5-f*f-u*u;O<0?n=0:(O*=O,n=O*O*this._dot(this.grad3[k],f,u));let A=.5-v*v-w*w;A<0?i=0:(A*=A,i=A*A*this._dot(this.grad3[D],v,w));let I=.5-x*x-M*M;return I<0?s=0:(I*=I,s=I*I*this._dot(this.grad3[E],x,M)),70*(n+i+s)}noise3d(e,t,n){let i,s,r,a;const c=(e+t+n)*.3333333333333333,h=Math.floor(e+c),d=Math.floor(t+c),m=Math.floor(n+c),p=1/6,f=(h+d+m)*p,u=h-f,g=d-f,y=m-f,v=e-u,w=t-g,x=n-y;let M,T,P,k,D,E;v>=w?w>=x?(M=1,T=0,P=0,k=1,D=1,E=0):v>=x?(M=1,T=0,P=0,k=1,D=0,E=1):(M=0,T=0,P=1,k=1,D=0,E=1):w<x?(M=0,T=0,P=1,k=0,D=1,E=1):v<x?(M=0,T=1,P=0,k=0,D=1,E=1):(M=0,T=1,P=0,k=1,D=1,E=0);const O=v-M+p,A=w-T+p,I=x-P+p,S=v-k+2*p,z=w-D+2*p,V=x-E+2*p,U=v-1+3*p,H=w-1+3*p,G=x-1+3*p,$=h&255,F=d&255,R=m&255,te=this.perm[$+this.perm[F+this.perm[R]]]%12,ee=this.perm[$+M+this.perm[F+T+this.perm[R+P]]]%12,q=this.perm[$+k+this.perm[F+D+this.perm[R+E]]]%12,ce=this.perm[$+1+this.perm[F+1+this.perm[R+1]]]%12;let fe=.6-v*v-w*w-x*x;fe<0?i=0:(fe*=fe,i=fe*fe*this._dot3(this.grad3[te],v,w,x));let se=.6-O*O-A*A-I*I;se<0?s=0:(se*=se,s=se*se*this._dot3(this.grad3[ee],O,A,I));let oe=.6-S*S-z*z-V*V;oe<0?r=0:(oe*=oe,r=oe*oe*this._dot3(this.grad3[q],S,z,V));let ue=.6-U*U-H*H-G*G;return ue<0?a=0:(ue*=ue,a=ue*ue*this._dot3(this.grad3[ce],U,H,G)),32*(i+s+r+a)}noise4d(e,t,n,i){const s=this.grad4,r=this.simplex,a=this.perm,l=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20;let h,d,m,p,f;const u=(e+t+n+i)*l,g=Math.floor(e+u),y=Math.floor(t+u),v=Math.floor(n+u),w=Math.floor(i+u),x=(g+y+v+w)*c,M=g-x,T=y-x,P=v-x,k=w-x,D=e-M,E=t-T,O=n-P,A=i-k,I=D>E?32:0,S=D>O?16:0,z=E>O?8:0,V=D>A?4:0,U=E>A?2:0,H=O>A?1:0,G=I+S+z+V+U+H,$=r[G][0]>=3?1:0,F=r[G][1]>=3?1:0,R=r[G][2]>=3?1:0,te=r[G][3]>=3?1:0,ee=r[G][0]>=2?1:0,q=r[G][1]>=2?1:0,ce=r[G][2]>=2?1:0,fe=r[G][3]>=2?1:0,se=r[G][0]>=1?1:0,oe=r[G][1]>=1?1:0,ue=r[G][2]>=1?1:0,pe=r[G][3]>=1?1:0,Ce=D-$+c,Be=E-F+c,C=O-R+c,Z=A-te+c,X=D-ee+2*c,B=E-q+2*c,L=O-ce+2*c,N=A-fe+2*c,Y=D-se+3*c,K=E-oe+3*c,j=O-ue+3*c,J=A-pe+3*c,ne=D-1+4*c,Q=E-1+4*c,ie=O-1+4*c,he=A-1+4*c,ae=g&255,Ae=y&255,$e=v&255,Ee=w&255,Ft=a[ae+a[Ae+a[$e+a[Ee]]]]%32,ge=a[ae+$+a[Ae+F+a[$e+R+a[Ee+te]]]]%32,nn=a[ae+ee+a[Ae+q+a[$e+ce+a[Ee+fe]]]]%32,Cn=a[ae+se+a[Ae+oe+a[$e+ue+a[Ee+pe]]]]%32,He=a[ae+1+a[Ae+1+a[$e+1+a[Ee+1]]]]%32;let Mt=.6-D*D-E*E-O*O-A*A;Mt<0?h=0:(Mt*=Mt,h=Mt*Mt*this._dot4(s[Ft],D,E,O,A));let Ut=.6-Ce*Ce-Be*Be-C*C-Z*Z;Ut<0?d=0:(Ut*=Ut,d=Ut*Ut*this._dot4(s[ge],Ce,Be,C,Z));let Vt=.6-X*X-B*B-L*L-N*N;Vt<0?m=0:(Vt*=Vt,m=Vt*Vt*this._dot4(s[nn],X,B,L,N));let jt=.6-Y*Y-K*K-j*j-J*J;jt<0?p=0:(jt*=jt,p=jt*jt*this._dot4(s[Cn],Y,K,j,J));let _t=.6-ne*ne-Q*Q-ie*ie-he*he;return _t<0?f=0:(_t*=_t,f=_t*_t*this._dot4(s[He],ne,Q,ie,he)),27*(h+d+m+p+f)}_dot(e,t,n){return e[0]*t+e[1]*n}_dot3(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}_dot4(e,t,n,i,s){return e[0]*t+e[1]*n+e[2]*i+e[3]*s}}class Re extends Ct{constructor(e,t,n=512,i=512,s,r,a){super(),this.width=n,this.height=i,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=[],this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=ya(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new _.WebGLRenderTarget(this.width,this.height,{type:_.HalfFloatType}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new _.ShaderMaterial({defines:Object.assign({},kn.defines),uniforms:_.UniformsUtils.clone(kn.uniforms),vertexShader:kn.vertexShader,fragmentShader:kn.fragmentShader,blending:_.NoBlending,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new _.MeshNormalMaterial,this.normalMaterial.blending=_.NoBlending,this.pdMaterial=new _.ShaderMaterial({defines:Object.assign({},Ln.defines),uniforms:_.UniformsUtils.clone(Ln.uniforms),vertexShader:Ln.vertexShader,fragmentShader:Ln.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new _.ShaderMaterial({defines:Object.assign({},En.defines),uniforms:_.UniformsUtils.clone(En.uniforms),vertexShader:En.vertexShader,fragmentShader:En.fragmentShader,blending:_.NoBlending}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new _.ShaderMaterial({uniforms:_.UniformsUtils.clone(St.uniforms),vertexShader:St.vertexShader,fragmentShader:St.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:_.DstColorFactor,blendDst:_.ZeroFactor,blendEquation:_.AddEquation,blendSrcAlpha:_.DstAlphaFactor,blendDstAlpha:_.ZeroFactor,blendEquationAlpha:_.AddEquation}),this.blendMaterial=new _.ShaderMaterial({uniforms:_.UniformsUtils.clone(Ei.uniforms),vertexShader:Ei.vertexShader,fragmentShader:Ei.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:_.CustomBlending,blendSrc:_.DstColorFactor,blendDst:_.ZeroFactor,blendEquation:_.AddEquation,blendSrcAlpha:_.DstAlphaFactor,blendDstAlpha:_.ZeroFactor,blendEquationAlpha:_.AddEquation}),this._fsQuad=new Tn(null),this._originalClearColor=new _.Color,this.setGBuffer(s?s.depthTexture:void 0,s?s.normalTexture:void 0),r!==void 0&&this.updateGtaoMaterial(r),a!==void 0&&this.updatePdMaterial(a)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){e!==void 0?(this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1):(this.depthTexture=new _.DepthTexture,this.depthTexture.format=_.DepthStencilFormat,this.depthTexture.type=_.UnsignedInt248Type,this.normalRenderTarget=new _.WebGLRenderTarget(this.width,this.height,{minFilter:_.NearestFilter,magFilter:_.NearestFilter,type:_.HalfFloatType,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const n=this.normalTexture?1:0,i=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.defines.DEPTH_SWIZZLING=i,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.defines.DEPTH_SWIZZLING=i,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&(e.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=e.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=Gs(this.pdSamples,this.pdRings,this.pdRadiusExponent),this.pdMaterial.needsUpdate=!0)}render(e,t,n){switch(this._renderGBuffer&&(this._overrideVisibility(),this._renderOverride(e,this.normalMaterial,this.normalRenderTarget,7829503,1),this._restoreVisibility()),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.gtaoMaterial.uniforms.cameraWorldMatrix.value.copy(this.camera.matrixWorld),this._renderPass(e,this.gtaoMaterial,this.gtaoRenderTarget,16777215,1),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this._renderPass(e,this.pdMaterial,this.pdRenderTarget,16777215,1),this.output){case Re.OUTPUT.Off:break;case Re.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Re.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Re.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Re.OUTPUT.Depth:this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:t);break;case Re.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Re.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=_.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(e,this.blendMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}_renderPass(e,t,n,i,s){e.getClearColor(this._originalClearColor);const r=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i!=null&&(e.setClearColor(i),e.setClearAlpha(s||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=a,e.setClearColor(this._originalClearColor),e.setClearAlpha(r)}_renderOverride(e,t,n,i,s){e.getClearColor(this._originalClearColor);const r=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,s=t.clearAlpha||s,i!=null&&(e.setClearColor(i),e.setClearAlpha(s||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=a,e.setClearColor(this._originalClearColor),e.setClearAlpha(r)}_overrideVisibility(){const e=this.scene,t=this._visibilityCache;e.traverse(function(n){(n.isPoints||n.isLine||n.isLine2)&&n.visible&&(n.visible=!1,t.push(n))})}_restoreVisibility(){const e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}_generateNoise(e=64){const t=new Ws,n=e*e*4,i=new Uint8Array(n);for(let r=0;r<e;r++)for(let a=0;a<e;a++){const l=r,c=a;i[(r*e+a)*4]=(t.noise(l,c)*.5+.5)*255,i[(r*e+a)*4+1]=(t.noise(l+e,c)*.5+.5)*255,i[(r*e+a)*4+2]=(t.noise(l,c+e)*.5+.5)*255,i[(r*e+a)*4+3]=(t.noise(l+e,c+e)*.5+.5)*255}const s=new _.DataTexture(i,e,e,_.RGBAFormat,_.UnsignedByteType);return s.wrapS=_.RepeatWrapping,s.wrapT=_.RepeatWrapping,s.needsUpdate=!0,s}}Re.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const In={defines:{PERSPECTIVE_CAMERA:1,KERNEL_SIZE:32},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},kernel:{value:null},cameraNear:{value:null},cameraFar:{value:null},resolution:{value:new _.Vector2},cameraProjectionMatrix:{value:new _.Matrix4},cameraInverseProjectionMatrix:{value:new _.Matrix4},kernelRadius:{value:8},minDistance:{value:.005},maxDistance:{value:.05}},vertexShader:`
|
|
394
|
+
}`};function Ks(r,e,t){const n=Oa(r,e,t);let i="vec3[SAMPLES](";for(let s=0;s<r;s++){const o=n[s];i+=`vec3(${o.x}, ${o.y}, ${o.z})${s<r-1?",":")"}`}return i}function Oa(r,e,t){const n=[];for(let i=0;i<r;i++){const s=2*Math.PI*e*i/r,o=Math.pow(i/(r-1),t);n.push(new M.Vector3(Math.cos(s),Math.sin(s),o))}return n}class $s{constructor(e=Math){this.grad3=[[1,1,0],[-1,1,0],[1,-1,0],[-1,-1,0],[1,0,1],[-1,0,1],[1,0,-1],[-1,0,-1],[0,1,1],[0,-1,1],[0,1,-1],[0,-1,-1]],this.grad4=[[0,1,1,1],[0,1,1,-1],[0,1,-1,1],[0,1,-1,-1],[0,-1,1,1],[0,-1,1,-1],[0,-1,-1,1],[0,-1,-1,-1],[1,0,1,1],[1,0,1,-1],[1,0,-1,1],[1,0,-1,-1],[-1,0,1,1],[-1,0,1,-1],[-1,0,-1,1],[-1,0,-1,-1],[1,1,0,1],[1,1,0,-1],[1,-1,0,1],[1,-1,0,-1],[-1,1,0,1],[-1,1,0,-1],[-1,-1,0,1],[-1,-1,0,-1],[1,1,1,0],[1,1,-1,0],[1,-1,1,0],[1,-1,-1,0],[-1,1,1,0],[-1,1,-1,0],[-1,-1,1,0],[-1,-1,-1,0]],this.p=[];for(let t=0;t<256;t++)this.p[t]=Math.floor(e.random()*256);this.perm=[];for(let t=0;t<512;t++)this.perm[t]=this.p[t&255];this.simplex=[[0,1,2,3],[0,1,3,2],[0,0,0,0],[0,2,3,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,3,0],[0,2,1,3],[0,0,0,0],[0,3,1,2],[0,3,2,1],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,3,2,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[1,2,0,3],[0,0,0,0],[1,3,0,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,3,0,1],[2,3,1,0],[1,0,2,3],[1,0,3,2],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,3,1],[0,0,0,0],[2,1,3,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0],[2,0,1,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,0,1,2],[3,0,2,1],[0,0,0,0],[3,1,2,0],[2,1,0,3],[0,0,0,0],[0,0,0,0],[0,0,0,0],[3,1,0,2],[0,0,0,0],[3,2,0,1],[3,2,1,0]]}noise(e,t){let n,i,s;const o=.5*(Math.sqrt(3)-1),a=(e+t)*o,l=Math.floor(e+a),c=Math.floor(t+a),h=(3-Math.sqrt(3))/6,u=(l+c)*h,m=l-u,p=c-u,f=e-m,d=t-p;let g,y;f>d?(g=1,y=0):(g=0,y=1);const v=f-g+h,x=d-y+h,b=f-1+2*h,_=d-1+2*h,T=l&255,P=c&255,D=this.perm[T+this.perm[P]]%12,k=this.perm[T+g+this.perm[P+y]]%12,E=this.perm[T+1+this.perm[P+1]]%12;let R=.5-f*f-d*d;R<0?n=0:(R*=R,n=R*R*this._dot(this.grad3[D],f,d));let A=.5-v*v-x*x;A<0?i=0:(A*=A,i=A*A*this._dot(this.grad3[k],v,x));let I=.5-b*b-_*_;return I<0?s=0:(I*=I,s=I*I*this._dot(this.grad3[E],b,_)),70*(n+i+s)}noise3d(e,t,n){let i,s,o,a;const c=(e+t+n)*.3333333333333333,h=Math.floor(e+c),u=Math.floor(t+c),m=Math.floor(n+c),p=1/6,f=(h+u+m)*p,d=h-f,g=u-f,y=m-f,v=e-d,x=t-g,b=n-y;let _,T,P,D,k,E;v>=x?x>=b?(_=1,T=0,P=0,D=1,k=1,E=0):v>=b?(_=1,T=0,P=0,D=1,k=0,E=1):(_=0,T=0,P=1,D=1,k=0,E=1):x<b?(_=0,T=0,P=1,D=0,k=1,E=1):v<b?(_=0,T=1,P=0,D=0,k=1,E=1):(_=0,T=1,P=0,D=1,k=1,E=0);const R=v-_+p,A=x-T+p,I=b-P+p,S=v-D+2*p,z=x-k+2*p,U=b-E+2*p,V=v-1+3*p,$=x-1+3*p,G=b-1+3*p,q=h&255,N=u&255,O=m&255,ee=this.perm[q+this.perm[N+this.perm[O]]]%12,te=this.perm[q+_+this.perm[N+T+this.perm[O+P]]]%12,H=this.perm[q+D+this.perm[N+k+this.perm[O+E]]]%12,ce=this.perm[q+1+this.perm[N+1+this.perm[O+1]]]%12;let fe=.6-v*v-x*x-b*b;fe<0?i=0:(fe*=fe,i=fe*fe*this._dot3(this.grad3[ee],v,x,b));let se=.6-R*R-A*A-I*I;se<0?s=0:(se*=se,s=se*se*this._dot3(this.grad3[te],R,A,I));let re=.6-S*S-z*z-U*U;re<0?o=0:(re*=re,o=re*re*this._dot3(this.grad3[H],S,z,U));let de=.6-V*V-$*$-G*G;return de<0?a=0:(de*=de,a=de*de*this._dot3(this.grad3[ce],V,$,G)),32*(i+s+o+a)}noise4d(e,t,n,i){const s=this.grad4,o=this.simplex,a=this.perm,l=(Math.sqrt(5)-1)/4,c=(5-Math.sqrt(5))/20;let h,u,m,p,f;const d=(e+t+n+i)*l,g=Math.floor(e+d),y=Math.floor(t+d),v=Math.floor(n+d),x=Math.floor(i+d),b=(g+y+v+x)*c,_=g-b,T=y-b,P=v-b,D=x-b,k=e-_,E=t-T,R=n-P,A=i-D,I=k>E?32:0,S=k>R?16:0,z=E>R?8:0,U=k>A?4:0,V=E>A?2:0,$=R>A?1:0,G=I+S+z+U+V+$,q=o[G][0]>=3?1:0,N=o[G][1]>=3?1:0,O=o[G][2]>=3?1:0,ee=o[G][3]>=3?1:0,te=o[G][0]>=2?1:0,H=o[G][1]>=2?1:0,ce=o[G][2]>=2?1:0,fe=o[G][3]>=2?1:0,se=o[G][0]>=1?1:0,re=o[G][1]>=1?1:0,de=o[G][2]>=1?1:0,pe=o[G][3]>=1?1:0,Ae=k-q+c,Be=E-N+c,C=R-O+c,Z=A-ee+c,X=k-te+2*c,B=E-H+2*c,L=R-ce+2*c,F=A-fe+2*c,Y=k-se+3*c,K=E-re+3*c,j=R-de+3*c,J=A-pe+3*c,ne=k-1+4*c,Q=E-1+4*c,ie=R-1+4*c,he=A-1+4*c,ae=g&255,Pe=y&255,He=v&255,Ee=x&255,Ft=a[ae+a[Pe+a[He+a[Ee]]]]%32,ge=a[ae+q+a[Pe+N+a[He+O+a[Ee+ee]]]]%32,on=a[ae+te+a[Pe+H+a[He+ce+a[Ee+fe]]]]%32,Pn=a[ae+se+a[Pe+re+a[He+de+a[Ee+pe]]]]%32,Je=a[ae+1+a[Pe+1+a[He+1+a[Ee+1]]]]%32;let Mt=.6-k*k-E*E-R*R-A*A;Mt<0?h=0:(Mt*=Mt,h=Mt*Mt*this._dot4(s[Ft],k,E,R,A));let Ut=.6-Ae*Ae-Be*Be-C*C-Z*Z;Ut<0?u=0:(Ut*=Ut,u=Ut*Ut*this._dot4(s[ge],Ae,Be,C,Z));let Vt=.6-X*X-B*B-L*L-F*F;Vt<0?m=0:(Vt*=Vt,m=Vt*Vt*this._dot4(s[on],X,B,L,F));let Gt=.6-Y*Y-K*K-j*j-J*J;Gt<0?p=0:(Gt*=Gt,p=Gt*Gt*this._dot4(s[Pn],Y,K,j,J));let _t=.6-ne*ne-Q*Q-ie*ie-he*he;return _t<0?f=0:(_t*=_t,f=_t*_t*this._dot4(s[Je],ne,Q,ie,he)),27*(h+u+m+p+f)}_dot(e,t,n){return e[0]*t+e[1]*n}_dot3(e,t,n,i){return e[0]*t+e[1]*n+e[2]*i}_dot4(e,t,n,i,s){return e[0]*t+e[1]*n+e[2]*i+e[3]*s}}class Oe extends Ct{constructor(e,t,n=512,i=512,s,o,a){super(),this.width=n,this.height=i,this.clear=!0,this.camera=t,this.scene=e,this.output=0,this._renderGBuffer=!0,this._visibilityCache=[],this.blendIntensity=1,this.pdRings=2,this.pdRadiusExponent=2,this.pdSamples=16,this.gtaoNoiseTexture=Ba(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new M.WebGLRenderTarget(this.width,this.height,{type:M.HalfFloatType}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new M.ShaderMaterial({defines:Object.assign({},In.defines),uniforms:M.UniformsUtils.clone(In.uniforms),vertexShader:In.vertexShader,fragmentShader:In.fragmentShader,blending:M.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 M.MeshNormalMaterial,this.normalMaterial.blending=M.NoBlending,this.pdMaterial=new M.ShaderMaterial({defines:Object.assign({},Bn.defines),uniforms:M.UniformsUtils.clone(Bn.uniforms),vertexShader:Bn.vertexShader,fragmentShader:Bn.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 M.ShaderMaterial({defines:Object.assign({},zn.defines),uniforms:M.UniformsUtils.clone(zn.uniforms),vertexShader:zn.vertexShader,fragmentShader:zn.fragmentShader,blending:M.NoBlending}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new M.ShaderMaterial({uniforms:M.UniformsUtils.clone(St.uniforms),vertexShader:St.vertexShader,fragmentShader:St.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:M.DstColorFactor,blendDst:M.ZeroFactor,blendEquation:M.AddEquation,blendSrcAlpha:M.DstAlphaFactor,blendDstAlpha:M.ZeroFactor,blendEquationAlpha:M.AddEquation}),this.blendMaterial=new M.ShaderMaterial({uniforms:M.UniformsUtils.clone(Bi.uniforms),vertexShader:Bi.vertexShader,fragmentShader:Bi.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:M.CustomBlending,blendSrc:M.DstColorFactor,blendDst:M.ZeroFactor,blendEquation:M.AddEquation,blendSrcAlpha:M.DstAlphaFactor,blendDstAlpha:M.ZeroFactor,blendEquationAlpha:M.AddEquation}),this._fsQuad=new En(null),this._originalClearColor=new M.Color,this.setGBuffer(s?s.depthTexture:void 0,s?s.normalTexture:void 0),o!==void 0&&this.updateGtaoMaterial(o),a!==void 0&&this.updatePdMaterial(a)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){e!==void 0?(this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1):(this.depthTexture=new M.DepthTexture,this.depthTexture.format=M.DepthStencilFormat,this.depthTexture.type=M.UnsignedInt248Type,this.normalRenderTarget=new M.WebGLRenderTarget(this.width,this.height,{minFilter:M.NearestFilter,magFilter:M.NearestFilter,type:M.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=Ks(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 Oe.OUTPUT.Off:break;case Oe.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=M.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Oe.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=M.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Oe.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=M.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Oe.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 Oe.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=M.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Oe.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=M.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(e,this.blendMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}_renderPass(e,t,n,i,s){e.getClearColor(this._originalClearColor);const o=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i!=null&&(e.setClearColor(i),e.setClearAlpha(s||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=a,e.setClearColor(this._originalClearColor),e.setClearAlpha(o)}_renderOverride(e,t,n,i,s){e.getClearColor(this._originalClearColor);const o=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,s=t.clearAlpha||s,i!=null&&(e.setClearColor(i),e.setClearAlpha(s||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=a,e.setClearColor(this._originalClearColor),e.setClearAlpha(o)}_overrideVisibility(){const e=this.scene,t=this._visibilityCache;e.traverse(function(n){(n.isPoints||n.isLine||n.isLine2)&&n.visible&&(n.visible=!1,t.push(n))})}_restoreVisibility(){const e=this._visibilityCache;for(let t=0;t<e.length;t++)e[t].visible=!0;e.length=0}_generateNoise(e=64){const t=new $s,n=e*e*4,i=new Uint8Array(n);for(let o=0;o<e;o++)for(let a=0;a<e;a++){const l=o,c=a;i[(o*e+a)*4]=(t.noise(l,c)*.5+.5)*255,i[(o*e+a)*4+1]=(t.noise(l+e,c)*.5+.5)*255,i[(o*e+a)*4+2]=(t.noise(l,c+e)*.5+.5)*255,i[(o*e+a)*4+3]=(t.noise(l+e,c+e)*.5+.5)*255}const s=new M.DataTexture(i,e,e,M.RGBAFormat,M.UnsignedByteType);return s.wrapS=M.RepeatWrapping,s.wrapT=M.RepeatWrapping,s.needsUpdate=!0,s}}Oe.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const Rn={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 M.Vector2},cameraProjectionMatrix:{value:new M.Matrix4},cameraInverseProjectionMatrix:{value:new M.Matrix4},kernelRadius:{value:8},minDistance:{value:.005},maxDistance:{value:.05}},vertexShader:`
|
|
395
395
|
|
|
396
396
|
varying vec2 vUv;
|
|
397
397
|
|
|
@@ -531,7 +531,7 @@
|
|
|
531
531
|
|
|
532
532
|
}
|
|
533
533
|
|
|
534
|
-
}`},
|
|
534
|
+
}`},On={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`varying vec2 vUv;
|
|
535
535
|
|
|
536
536
|
void main() {
|
|
537
537
|
|
|
@@ -568,7 +568,7 @@
|
|
|
568
568
|
float depth = getLinearDepth( vUv );
|
|
569
569
|
gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
|
|
570
570
|
|
|
571
|
-
}`},
|
|
571
|
+
}`},Nn={uniforms:{tDiffuse:{value:null},resolution:{value:new M.Vector2}},vertexShader:`varying vec2 vUv;
|
|
572
572
|
|
|
573
573
|
void main() {
|
|
574
574
|
|
|
@@ -599,7 +599,7 @@
|
|
|
599
599
|
|
|
600
600
|
gl_FragColor = vec4( vec3( result / ( 5.0 * 5.0 ) ), 1.0 );
|
|
601
601
|
|
|
602
|
-
}`};class
|
|
602
|
+
}`};class ot extends Ct{constructor(e,t,n=512,i=512,s=32){super(),this.width=n,this.height=i,this.clear=!0,this.needsSwap=!1,this.camera=t,this.scene=e,this.kernelRadius=8,this.kernel=[],this.noiseTexture=null,this.output=0,this.minDistance=.005,this.maxDistance=.1,this._visibilityCache=[],this._generateSampleKernel(s),this._generateRandomKernelRotations();const o=new M.DepthTexture;o.format=M.DepthStencilFormat,o.type=M.UnsignedInt248Type,this.normalRenderTarget=new M.WebGLRenderTarget(this.width,this.height,{minFilter:M.NearestFilter,magFilter:M.NearestFilter,type:M.HalfFloatType,depthTexture:o}),this.ssaoRenderTarget=new M.WebGLRenderTarget(this.width,this.height,{type:M.HalfFloatType}),this.blurRenderTarget=this.ssaoRenderTarget.clone(),this.ssaoMaterial=new M.ShaderMaterial({defines:Object.assign({},Rn.defines),uniforms:M.UniformsUtils.clone(Rn.uniforms),vertexShader:Rn.vertexShader,fragmentShader:Rn.fragmentShader,blending:M.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 M.MeshNormalMaterial,this.normalMaterial.blending=M.NoBlending,this.blurMaterial=new M.ShaderMaterial({defines:Object.assign({},Nn.defines),uniforms:M.UniformsUtils.clone(Nn.uniforms),vertexShader:Nn.vertexShader,fragmentShader:Nn.fragmentShader}),this.blurMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.blurMaterial.uniforms.resolution.value.set(this.width,this.height),this.depthRenderMaterial=new M.ShaderMaterial({defines:Object.assign({},On.defines),uniforms:M.UniformsUtils.clone(On.uniforms),vertexShader:On.vertexShader,fragmentShader:On.fragmentShader,blending:M.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 M.ShaderMaterial({uniforms:M.UniformsUtils.clone(St.uniforms),vertexShader:St.vertexShader,fragmentShader:St.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:M.DstColorFactor,blendDst:M.ZeroFactor,blendEquation:M.AddEquation,blendSrcAlpha:M.DstAlphaFactor,blendDstAlpha:M.ZeroFactor,blendEquationAlpha:M.AddEquation}),this._fsQuad=new En(null),this._originalClearColor=new M.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 ot.OUTPUT.SSAO:this.copyMaterial.uniforms.tDiffuse.value=this.ssaoRenderTarget.texture,this.copyMaterial.blending=M.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;case ot.OUTPUT.Blur:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=M.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;case ot.OUTPUT.Depth:this._renderPass(e,this.depthRenderMaterial,this.renderToScreen?null:n);break;case ot.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=M.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:n);break;case ot.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=this.blurRenderTarget.texture,this.copyMaterial.blending=M.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 o=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i!=null&&(e.setClearColor(i),e.setClearAlpha(s||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=a,e.setClearColor(this._originalClearColor),e.setClearAlpha(o)}_renderOverride(e,t,n,i,s){e.getClearColor(this._originalClearColor);const o=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,s=t.clearAlpha||s,i!=null&&(e.setClearColor(i),e.setClearAlpha(s||0),e.clear()),this.scene.overrideMaterial=t,e.render(this.scene,this.camera),this.scene.overrideMaterial=null,e.autoClear=a,e.setClearColor(this._originalClearColor),e.setClearAlpha(o)}_generateSampleKernel(e){const t=this.kernel;for(let n=0;n<e;n++){const i=new M.Vector3;i.x=Math.random()*2-1,i.y=Math.random()*2-1,i.z=Math.random(),i.normalize();let s=n/e;s=M.MathUtils.lerp(.1,1,s*s),i.multiplyScalar(s),t.push(i)}}_generateRandomKernelRotations(){const n=new $s,i=16,s=new Float32Array(i);for(let o=0;o<i;o++){const a=Math.random()*2-1,l=Math.random()*2-1,c=0;s[o]=n.noise3d(a,l,c)}this.noiseTexture=new M.DataTexture(s,4,4,M.RedFormat,M.FloatType),this.noiseTexture.wrapS=M.RepeatWrapping,this.noiseTexture.wrapT=M.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}}ot.OUTPUT={Default:0,SSAO:1,Blur:2,Depth:3,Normal:4};const Fn={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
|
|
603
603
|
precision highp float;
|
|
604
604
|
|
|
605
605
|
uniform mat4 modelViewMatrix;
|
|
@@ -670,7 +670,7 @@
|
|
|
670
670
|
|
|
671
671
|
#endif
|
|
672
672
|
|
|
673
|
-
}`};class
|
|
673
|
+
}`};class Na extends Ct{constructor(){super(),this.uniforms=M.UniformsUtils.clone(Fn.uniforms),this.material=new M.RawShaderMaterial({name:Fn.name,uniforms:this.uniforms,vertexShader:Fn.vertexShader,fragmentShader:Fn.fragmentShader}),this._fsQuad=new En(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={},M.ColorManagement.getTransfer(this._outputColorSpace)===M.SRGBTransfer&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===M.LinearToneMapping?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===M.ReinhardToneMapping?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===M.CineonToneMapping?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===M.ACESFilmicToneMapping?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===M.AgXToneMapping?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===M.NeutralToneMapping?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===M.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 Fa={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new M.Vector2(1/1024,1/512)}},vertexShader:`
|
|
674
674
|
|
|
675
675
|
varying vec2 vUv;
|
|
676
676
|
|
|
@@ -931,7 +931,7 @@
|
|
|
931
931
|
|
|
932
932
|
gl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );
|
|
933
933
|
|
|
934
|
-
}`},
|
|
934
|
+
}`},Ua={uniforms:{tDiffuse:{value:null},saturation:{value:1.2},contrast:{value:1.2}},vertexShader:`
|
|
935
935
|
varying vec2 vUv;
|
|
936
936
|
void main() {
|
|
937
937
|
vUv = uv;
|
|
@@ -957,24 +957,24 @@
|
|
|
957
957
|
|
|
958
958
|
gl_FragColor = color;
|
|
959
959
|
}
|
|
960
|
-
`};class
|
|
961
|
-
\0`,ee+=s(F,2),ee+=T.magic,ee+=s(w,2),ee+=s(x,2),ee+=s($.crc32,4),ee+=s($.compressedSize,4),ee+=s($.uncompressedSize,4),ee+=s(k.length,2),ee+=s(z.length,2),{fileRecord:d.LOCAL_FILE_HEADER+ee+k+z,dirRecord:d.CENTRAL_FILE_HEADER+s(te,2)+ee+s(O.length,2)+"\0\0\0\0"+s(R,4)+s(g,4)+k+z+O}}var a=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),h=t("../crc32"),d=t("../signature");function m(p,f,u,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=f,this.zipPlatform=u,this.encodeFileName=g,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(m,l),m.prototype.push=function(p){var f=p.meta.percent||0,u=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,l.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:u?(f+100*(u-g-1))/u:100}}))},m.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var f=this.streamFiles&&!p.file.dir;if(f){var u=r(p,f,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:u.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(p){this.accumulate=!1;var f=this.streamFiles&&!p.file.dir,u=r(p,f,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(u.dirRecord),f)this.push({data:(function(g){return d.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:u.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var p=this.bytesWritten,f=0;f<this.dirRecords.length;f++)this.push({data:this.dirRecords[f],meta:{percent:100}});var u=this.bytesWritten-p,g=(function(y,v,w,x,M){var T=a.transformTo("string",M(x));return d.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(y,2)+s(y,2)+s(v,4)+s(w,4)+s(T.length,2)+T})(this.dirRecords.length,u,p,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(p){this._sources.push(p);var f=this;return p.on("data",function(u){f.processChunk(u)}),p.on("end",function(){f.closedSource(f.previous.streamInfo),f._sources.length?f.prepareNextSource():f.end()}),p.on("error",function(u){f.error(u)}),this},m.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},m.prototype.error=function(p){var f=this._sources;if(!l.prototype.error.call(this,p))return!1;for(var u=0;u<f.length;u++)try{f[u].error(p)}catch{}return!0},m.prototype.lock=function(){l.prototype.lock.call(this);for(var p=this._sources,f=0;f<p.length;f++)p[f].lock()},n.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,n,i){var s=t("../compressions"),r=t("./ZipFileWorker");i.generateWorker=function(a,l,c){var h=new r(l.streamFiles,c,l.platform,l.encodeFileName),d=0;try{a.forEach(function(m,p){d++;var f=(function(v,w){var x=v||w,M=s[x];if(!M)throw new Error(x+" is not a valid compression method !");return M})(p.options.compression,l.compression),u=p.options.compressionOptions||l.compressionOptions||{},g=p.dir,y=p.date;p._compressWorker(f,u).withStreamInfo("file",{name:m,dir:g,date:y,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(h)}),h.entriesCount=d}catch(m){h.error(m)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,n,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var r=new s;for(var a in this)typeof this[a]!="function"&&(r[a]=this[a]);return r}}(s.prototype=t("./object")).loadAsync=t("./load"),s.support=t("./support"),s.defaults=t("./defaults"),s.version="3.10.1",s.loadAsync=function(r,a){return new s().loadAsync(r,a)},s.external=t("./external"),n.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,n,i){var s=t("./utils"),r=t("./external"),a=t("./utf8"),l=t("./zipEntries"),c=t("./stream/Crc32Probe"),h=t("./nodejsUtils");function d(m){return new r.Promise(function(p,f){var u=m.decompressed.getContentWorker().pipe(new c);u.on("error",function(g){f(g)}).on("end",function(){u.streamInfo.crc32!==m.decompressed.crc32?f(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}n.exports=function(m,p){var f=this;return p=s.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),h.isNode&&h.isStream(m)?r.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",m,!0,p.optimizedBinaryString,p.base64).then(function(u){var g=new l(p);return g.load(u),g}).then(function(u){var g=[r.Promise.resolve(u)],y=u.files;if(p.checkCRC32)for(var v=0;v<y.length;v++)g.push(d(y[v]));return r.Promise.all(g)}).then(function(u){for(var g=u.shift(),y=g.files,v=0;v<y.length;v++){var w=y[v],x=w.fileNameStr,M=s.resolve(w.fileNameStr);f.file(M,w.decompressed,{binary:!0,optimizedBinaryString:!0,date:w.date,dir:w.dir,comment:w.fileCommentStr.length?w.fileCommentStr:null,unixPermissions:w.unixPermissions,dosPermissions:w.dosPermissions,createFolders:p.createFolders}),w.dir||(f.file(M).unsafeOriginalName=x)}return g.zipComment.length&&(f.comment=g.zipComment),f})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,n,i){var s=t("../utils"),r=t("../stream/GenericWorker");function a(l,c){r.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}s.inherits(a,r),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(h){c.push({data:h,meta:{percent:0}})}).on("error",function(h){c.isPaused?this.generatedError=h:c.error(h)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!r.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},n.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,n,i){var s=t("readable-stream").Readable;function r(a,l,c){s.call(this,l),this._helper=a;var h=this;a.on("data",function(d,m){h.push(d)||h._helper.pause(),c&&c(m)}).on("error",function(d){h.emit("error",d)}).on("end",function(){h.push(null)})}t("../utils").inherits(r,s),r.prototype._read=function(){this._helper.resume()},n.exports=r},{"../utils":32,"readable-stream":16}],14:[function(t,n,i){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,r){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,r);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,r)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var r=new Buffer(s);return r.fill(0),r},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(t,n,i){function s(M,T,P){var k,D=a.getTypeOf(T),E=a.extend(P||{},h);E.date=E.date||new Date,E.compression!==null&&(E.compression=E.compression.toUpperCase()),typeof E.unixPermissions=="string"&&(E.unixPermissions=parseInt(E.unixPermissions,8)),E.unixPermissions&&16384&E.unixPermissions&&(E.dir=!0),E.dosPermissions&&16&E.dosPermissions&&(E.dir=!0),E.dir&&(M=y(M)),E.createFolders&&(k=g(M))&&v.call(this,k,!0);var O=D==="string"&&E.binary===!1&&E.base64===!1;P&&P.binary!==void 0||(E.binary=!O),(T instanceof d&&T.uncompressedSize===0||E.dir||!T||T.length===0)&&(E.base64=!1,E.binary=!0,T="",E.compression="STORE",D="string");var A=null;A=T instanceof d||T instanceof l?T:f.isNode&&f.isStream(T)?new u(M,T):a.prepareContent(M,T,E.binary,E.optimizedBinaryString,E.base64);var I=new m(M,A,E);this.files[M]=I}var r=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),c=t("./stream/StreamHelper"),h=t("./defaults"),d=t("./compressedObject"),m=t("./zipObject"),p=t("./generate"),f=t("./nodejsUtils"),u=t("./nodejs/NodejsStreamInputAdapter"),g=function(M){M.slice(-1)==="/"&&(M=M.substring(0,M.length-1));var T=M.lastIndexOf("/");return 0<T?M.substring(0,T):""},y=function(M){return M.slice(-1)!=="/"&&(M+="/"),M},v=function(M,T){return T=T!==void 0?T:h.createFolders,M=y(M),this.files[M]||s.call(this,M,null,{dir:!0,createFolders:T}),this.files[M]};function w(M){return Object.prototype.toString.call(M)==="[object RegExp]"}var x={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(M){var T,P,k;for(T in this.files)k=this.files[T],(P=T.slice(this.root.length,T.length))&&T.slice(0,this.root.length)===this.root&&M(P,k)},filter:function(M){var T=[];return this.forEach(function(P,k){M(P,k)&&T.push(k)}),T},file:function(M,T,P){if(arguments.length!==1)return M=this.root+M,s.call(this,M,T,P),this;if(w(M)){var k=M;return this.filter(function(E,O){return!O.dir&&k.test(E)})}var D=this.files[this.root+M];return D&&!D.dir?D:null},folder:function(M){if(!M)return this;if(w(M))return this.filter(function(D,E){return E.dir&&M.test(D)});var T=this.root+M,P=v.call(this,T),k=this.clone();return k.root=P.name,k},remove:function(M){M=this.root+M;var T=this.files[M];if(T||(M.slice(-1)!=="/"&&(M+="/"),T=this.files[M]),T&&!T.dir)delete this.files[M];else for(var P=this.filter(function(D,E){return E.name.slice(0,M.length)===M}),k=0;k<P.length;k++)delete this.files[P[k].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(M){var T,P={};try{if((P=a.extend(M||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:r.utf8encode})).type=P.type.toLowerCase(),P.compression=P.compression.toUpperCase(),P.type==="binarystring"&&(P.type="string"),!P.type)throw new Error("No output type specified.");a.checkSupport(P.type),P.platform!=="darwin"&&P.platform!=="freebsd"&&P.platform!=="linux"&&P.platform!=="sunos"||(P.platform="UNIX"),P.platform==="win32"&&(P.platform="DOS");var k=P.comment||this.comment||"";T=p.generateWorker(this,P,k)}catch(D){(T=new l("error")).error(D)}return new c(T,P.type||"string",P.mimeType)},generateAsync:function(M,T){return this.generateInternalStream(M).accumulate(T)},generateNodeStream:function(M,T){return(M=M||{}).type||(M.type="nodebuffer"),this.generateInternalStream(M).toNodejsStream(T)}};n.exports=x},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(t,n,i){n.exports=t("stream")},{stream:void 0}],17:[function(t,n,i){var s=t("./DataReader");function r(a){s.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}t("../utils").inherits(r,s),r.prototype.byteAt=function(a){return this.data[this.zero+a]},r.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),d=a.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===l&&this.data[m+1]===c&&this.data[m+2]===h&&this.data[m+3]===d)return m-this.zero;return-1},r.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),d=a.charCodeAt(3),m=this.readData(4);return l===m[0]&&c===m[1]&&h===m[2]&&d===m[3]},r.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=r},{"../utils":32,"./DataReader":18}],18:[function(t,n,i){var s=t("../utils");function r(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}r.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},n.exports=r},{"../utils":32}],19:[function(t,n,i){var s=t("./Uint8ArrayReader");function r(a){s.call(this,a)}t("../utils").inherits(r,s),r.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=r},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,n,i){var s=t("./DataReader");function r(a){s.call(this,a)}t("../utils").inherits(r,s),r.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},r.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},r.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},r.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=r},{"../utils":32,"./DataReader":18}],21:[function(t,n,i){var s=t("./ArrayReader");function r(a){s.call(this,a)}t("../utils").inherits(r,s),r.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=r},{"../utils":32,"./ArrayReader":17}],22:[function(t,n,i){var s=t("../utils"),r=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),h=t("./Uint8ArrayReader");n.exports=function(d){var m=s.getTypeOf(d);return s.checkSupport(m),m!=="string"||r.uint8array?m==="nodebuffer"?new c(d):r.uint8array?new h(s.transformTo("uint8array",d)):new a(s.transformTo("array",d)):new l(d)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,n,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,n,i){var s=t("./GenericWorker"),r=t("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}r.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:r.transformTo(this.destType,l.data),meta:l.meta})},n.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,n,i){var s=t("./GenericWorker"),r=t("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=r(l.data,this.streamInfo.crc32||0),this.push(l)},n.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,n,i){var s=t("../utils"),r=t("./GenericWorker");function a(l){r.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,r),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}r.prototype.processChunk.call(this,l)},n.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,n,i){var s=t("../utils"),r=t("./GenericWorker");function a(l){r.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(h){c.dataIsReady=!0,c.data=h,c.max=h&&h.length||0,c.type=s.getTypeOf(h),c.isPaused||c._tickAndRepeat()},function(h){c.error(h)})}s.inherits(a,r),a.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(t,n,i){function s(r){this.name=r||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(r){this.emit("data",r)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(r){this.emit("error",r)}return!0},error:function(r){return!this.isFinished&&(this.isPaused?this.generatedError=r:(this.isFinished=!0,this.emit("error",r),this.previous&&this.previous.error(r),this.cleanUp()),!0)},on:function(r,a){return this._listeners[r].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(r,a){if(this._listeners[r])for(var l=0;l<this._listeners[r].length;l++)this._listeners[r][l].call(this,a)},pipe:function(r){return r.registerPrevious(this)},registerPrevious:function(r){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=r.streamInfo,this.mergeStreamInfo(),this.previous=r;var a=this;return r.on("data",function(l){a.processChunk(l)}),r.on("end",function(){a.end()}),r.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var r=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),r=!0),this.previous&&this.previous.resume(),!r},flush:function(){},processChunk:function(r){this.push(r)},withStreamInfo:function(r,a){return this.extraStreamInfo[r]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var r in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,r)&&(this.streamInfo[r]=this.extraStreamInfo[r])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var r="Worker "+this.name;return this.previous?this.previous+" -> "+r:r}},n.exports=s},{}],29:[function(t,n,i){var s=t("../utils"),r=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),c=t("../support"),h=t("../external"),d=null;if(c.nodestream)try{d=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(f,u){return new h.Promise(function(g,y){var v=[],w=f._internalType,x=f._outputType,M=f._mimeType;f.on("data",function(T,P){v.push(T),u&&u(P)}).on("error",function(T){v=[],y(T)}).on("end",function(){try{var T=(function(P,k,D){switch(P){case"blob":return s.newBlob(s.transformTo("arraybuffer",k),D);case"base64":return l.encode(k);default:return s.transformTo(P,k)}})(x,(function(P,k){var D,E=0,O=null,A=0;for(D=0;D<k.length;D++)A+=k[D].length;switch(P){case"string":return k.join("");case"array":return Array.prototype.concat.apply([],k);case"uint8array":for(O=new Uint8Array(A),D=0;D<k.length;D++)O.set(k[D],E),E+=k[D].length;return O;case"nodebuffer":return Buffer.concat(k);default:throw new Error("concat : unsupported type '"+P+"'")}})(w,v),M);g(T)}catch(P){y(P)}v=[]}).resume()})}function p(f,u,g){var y=u;switch(u){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=u,this._mimeType=g,s.checkSupport(y),this._worker=f.pipe(new r(y)),f.lock()}catch(v){this._worker=new a("error"),this._worker.error(v)}}p.prototype={accumulate:function(f){return m(this,f)},on:function(f,u){var g=this;return f==="data"?this._worker.on(f,function(y){u.call(g,y.data,y.meta)}):this._worker.on(f,function(){s.delay(u,arguments,g)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(f){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new d(this,{objectMode:this._outputType!=="nodebuffer"},f)}},n.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,n,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);r.append(s),i.blob=r.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!t("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(t,n,i){for(var s=t("./utils"),r=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),h=0;h<256;h++)c[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;c[254]=c[254]=1;function d(){l.call(this,"utf-8 decode"),this.leftOver=null}function m(){l.call(this,"utf-8 encode")}i.utf8encode=function(p){return r.nodebuffer?a.newBufferFrom(p,"utf-8"):(function(f){var u,g,y,v,w,x=f.length,M=0;for(v=0;v<x;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<x&&(64512&(y=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),M+=g<128?1:g<2048?2:g<65536?3:4;for(u=r.uint8array?new Uint8Array(M):new Array(M),v=w=0;w<M;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<x&&(64512&(y=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),g<128?u[w++]=g:(g<2048?u[w++]=192|g>>>6:(g<65536?u[w++]=224|g>>>12:(u[w++]=240|g>>>18,u[w++]=128|g>>>12&63),u[w++]=128|g>>>6&63),u[w++]=128|63&g);return u})(p)},i.utf8decode=function(p){return r.nodebuffer?s.transformTo("nodebuffer",p).toString("utf-8"):(function(f){var u,g,y,v,w=f.length,x=new Array(2*w);for(u=g=0;u<w;)if((y=f[u++])<128)x[g++]=y;else if(4<(v=c[y]))x[g++]=65533,u+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&u<w;)y=y<<6|63&f[u++],v--;1<v?x[g++]=65533:y<65536?x[g++]=y:(y-=65536,x[g++]=55296|y>>10&1023,x[g++]=56320|1023&y)}return x.length!==g&&(x.subarray?x=x.subarray(0,g):x.length=g),s.applyFromCharCode(x)})(p=s.transformTo(r.uint8array?"uint8array":"array",p))},s.inherits(d,l),d.prototype.processChunk=function(p){var f=s.transformTo(r.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var u=f;(f=new Uint8Array(u.length+this.leftOver.length)).set(this.leftOver,0),f.set(u,this.leftOver.length)}else f=this.leftOver.concat(f);this.leftOver=null}var g=(function(v,w){var x;for((w=w||v.length)>v.length&&(w=v.length),x=w-1;0<=x&&(192&v[x])==128;)x--;return x<0||x===0?w:x+c[v[x]]>w?x:w})(f),y=f;g!==f.length&&(r.uint8array?(y=f.subarray(0,g),this.leftOver=f.subarray(g,f.length)):(y=f.slice(0,g),this.leftOver=f.slice(g,f.length))),this.push({data:i.utf8decode(y),meta:p.meta})},d.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=d,s.inherits(m,l),m.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=m},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var s=t("./support"),r=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function c(u){return u}function h(u,g){for(var y=0;y<u.length;++y)g[y]=255&u.charCodeAt(y);return g}t("setimmediate"),i.newBlob=function(u,g){i.checkSupport("blob");try{return new Blob([u],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(u),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var d={stringifyByChunk:function(u,g,y){var v=[],w=0,x=u.length;if(x<=y)return String.fromCharCode.apply(null,u);for(;w<x;)g==="array"||g==="nodebuffer"?v.push(String.fromCharCode.apply(null,u.slice(w,Math.min(w+y,x)))):v.push(String.fromCharCode.apply(null,u.subarray(w,Math.min(w+y,x)))),w+=y;return v.join("")},stringifyByChar:function(u){for(var g="",y=0;y<u.length;y++)g+=String.fromCharCode(u[y]);return g},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function m(u){var g=65536,y=i.getTypeOf(u),v=!0;if(y==="uint8array"?v=d.applyCanBeUsed.uint8array:y==="nodebuffer"&&(v=d.applyCanBeUsed.nodebuffer),v)for(;1<g;)try{return d.stringifyByChunk(u,y,g)}catch{g=Math.floor(g/2)}return d.stringifyByChar(u)}function p(u,g){for(var y=0;y<u.length;y++)g[y]=u[y];return g}i.applyFromCharCode=m;var f={};f.string={string:c,array:function(u){return h(u,new Array(u.length))},arraybuffer:function(u){return f.string.uint8array(u).buffer},uint8array:function(u){return h(u,new Uint8Array(u.length))},nodebuffer:function(u){return h(u,a.allocBuffer(u.length))}},f.array={string:m,array:c,arraybuffer:function(u){return new Uint8Array(u).buffer},uint8array:function(u){return new Uint8Array(u)},nodebuffer:function(u){return a.newBufferFrom(u)}},f.arraybuffer={string:function(u){return m(new Uint8Array(u))},array:function(u){return p(new Uint8Array(u),new Array(u.byteLength))},arraybuffer:c,uint8array:function(u){return new Uint8Array(u)},nodebuffer:function(u){return a.newBufferFrom(new Uint8Array(u))}},f.uint8array={string:m,array:function(u){return p(u,new Array(u.length))},arraybuffer:function(u){return u.buffer},uint8array:c,nodebuffer:function(u){return a.newBufferFrom(u)}},f.nodebuffer={string:m,array:function(u){return p(u,new Array(u.length))},arraybuffer:function(u){return f.nodebuffer.uint8array(u).buffer},uint8array:function(u){return p(u,new Uint8Array(u.length))},nodebuffer:c},i.transformTo=function(u,g){if(g=g||"",!u)return g;i.checkSupport(u);var y=i.getTypeOf(g);return f[y][u](g)},i.resolve=function(u){for(var g=u.split("/"),y=[],v=0;v<g.length;v++){var w=g[v];w==="."||w===""&&v!==0&&v!==g.length-1||(w===".."?y.pop():y.push(w))}return y.join("/")},i.getTypeOf=function(u){return typeof u=="string"?"string":Object.prototype.toString.call(u)==="[object Array]"?"array":s.nodebuffer&&a.isBuffer(u)?"nodebuffer":s.uint8array&&u instanceof Uint8Array?"uint8array":s.arraybuffer&&u instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(u){if(!s[u.toLowerCase()])throw new Error(u+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(u){var g,y,v="";for(y=0;y<(u||"").length;y++)v+="\\x"+((g=u.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return v},i.delay=function(u,g,y){setImmediate(function(){u.apply(y||null,g||[])})},i.inherits=function(u,g){function y(){}y.prototype=g.prototype,u.prototype=new y},i.extend=function(){var u,g,y={};for(u=0;u<arguments.length;u++)for(g in arguments[u])Object.prototype.hasOwnProperty.call(arguments[u],g)&&y[g]===void 0&&(y[g]=arguments[u][g]);return y},i.prepareContent=function(u,g,y,v,w){return l.Promise.resolve(g).then(function(x){return s.blob&&(x instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(x))!==-1)&&typeof FileReader<"u"?new l.Promise(function(M,T){var P=new FileReader;P.onload=function(k){M(k.target.result)},P.onerror=function(k){T(k.target.error)},P.readAsArrayBuffer(x)}):x}).then(function(x){var M=i.getTypeOf(x);return M?(M==="arraybuffer"?x=i.transformTo("uint8array",x):M==="string"&&(w?x=r.decode(x):y&&v!==!0&&(x=(function(T){return h(T,s.uint8array?new Uint8Array(T.length):new Array(T.length))})(x))),x):l.Promise.reject(new Error("Can't read the data of '"+u+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,n,i){var s=t("./reader/readerFor"),r=t("./utils"),a=t("./signature"),l=t("./zipEntry"),c=t("./support");function h(d){this.files=[],this.loadOptions=d}h.prototype={checkSignature:function(d){if(!this.reader.readAndCheckSignature(d)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+r.pretty(m)+", expected "+r.pretty(d)+")")}},isSignature:function(d,m){var p=this.reader.index;this.reader.setIndex(d);var f=this.reader.readString(4)===m;return this.reader.setIndex(p),f},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var d=this.reader.readData(this.zipCommentLength),m=c.uint8array?"uint8array":"array",p=r.transformTo(m,d);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var d,m,p,f=this.zip64EndOfCentralSize-44;0<f;)d=this.reader.readInt(2),m=this.reader.readInt(4),p=this.reader.readData(m),this.zip64ExtensibleData[d]={id:d,length:m,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var d,m;for(d=0;d<this.files.length;d++)m=this.files[d],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.processAttributes()},readCentralDir:function(){var d;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(d=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(d);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var d=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(d<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(d);var m=d;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===r.MAX_VALUE_16BITS||this.diskWithCentralDirStart===r.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===r.MAX_VALUE_16BITS||this.centralDirRecords===r.MAX_VALUE_16BITS||this.centralDirSize===r.MAX_VALUE_32BITS||this.centralDirOffset===r.MAX_VALUE_32BITS){if(this.zip64=!0,(d=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(d),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var f=m-p;if(0<f)this.isSignature(m,a.CENTRAL_FILE_HEADER)||(this.reader.zero=f);else if(f<0)throw new Error("Corrupted zip: missing "+Math.abs(f)+" bytes.")},prepareReader:function(d){this.reader=s(d)},load:function(d){this.prepareReader(d),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,n,i){var s=t("./reader/readerFor"),r=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),c=t("./utf8"),h=t("./compressions"),d=t("./support");function m(p,f){this.options=p,this.loadOptions=f}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var f,u;if(p.skip(22),this.fileNameLength=p.readInt(2),u=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(u),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((f=(function(g){for(var y in h)if(Object.prototype.hasOwnProperty.call(h,y)&&h[y].magic===g)return h[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,f,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var f=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(f),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=s(this.extraFields[1].value);this.uncompressedSize===r.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var f,u,g,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<y;)f=p.readInt(2),u=p.readInt(2),g=p.readData(u),this.extraFields[f]={id:f,length:u,value:g};p.setIndex(y)},handleUTF8:function(){var p=d.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var f=this.findExtraFieldUnicodePath();if(f!==null)this.fileNameStr=f;else{var u=r.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(u)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=r.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var f=s(p.value);return f.readInt(1)!==1||l(this.fileName)!==f.readInt(4)?null:c.utf8decode(f.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var f=s(p.value);return f.readInt(1)!==1||l(this.fileComment)!==f.readInt(4)?null:c.utf8decode(f.readData(p.length-5))}return null}},n.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,n,i){function s(f,u,g){this.name=f,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=u,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var r=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),c=t("./compressedObject"),h=t("./stream/GenericWorker");s.prototype={internalStream:function(f){var u=null,g="string";try{if(!f)throw new Error("No output type specified.");var y=(g=f.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),u=this._decompressWorker();var v=!this._dataBinary;v&&!y&&(u=u.pipe(new l.Utf8EncodeWorker)),!v&&y&&(u=u.pipe(new l.Utf8DecodeWorker))}catch(w){(u=new h("error")).error(w)}return new r(u,g,"")},async:function(f,u){return this.internalStream(f).accumulate(u)},nodeStream:function(f,u){return this.internalStream(f||"nodebuffer").toNodejsStream(u)},_compressWorker:function(f,u){if(this._data instanceof c&&this._data.compression.magic===f.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(g,f,u)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof h?this._data:new a(this._data)}};for(var d=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<d.length;p++)s.prototype[d[p]]=m;n.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,n,i){(function(s){var r,a,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var c=0,h=new l(f),d=s.document.createTextNode("");h.observe(d,{characterData:!0}),r=function(){d.data=c=++c%2}}else if(s.setImmediate||s.MessageChannel===void 0)r="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var u=s.document.createElement("script");u.onreadystatechange=function(){f(),u.onreadystatechange=null,u.parentNode.removeChild(u),u=null},s.document.documentElement.appendChild(u)}:function(){setTimeout(f,0)};else{var m=new s.MessageChannel;m.port1.onmessage=f,r=function(){m.port2.postMessage(0)}}var p=[];function f(){var u,g;a=!0;for(var y=p.length;y;){for(g=p,p=[],u=-1;++u<y;)g[u]();y=p.length}a=!1}n.exports=function(u){p.push(u)!==1||a||r()}}).call(this,typeof Rn<"u"?Rn:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,n,i){var s=t("immediate");function r(){}var a={},l=["REJECTED"],c=["FULFILLED"],h=["PENDING"];function d(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,y!==r&&u(this,y)}function m(y,v,w){this.promise=y,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof w=="function"&&(this.onRejected=w,this.callRejected=this.otherCallRejected)}function p(y,v,w){s(function(){var x;try{x=v(w)}catch(M){return a.reject(y,M)}x===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,x)})}function f(y){var v=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof v=="function")return function(){v.apply(y,arguments)}}function u(y,v){var w=!1;function x(P){w||(w=!0,a.reject(y,P))}function M(P){w||(w=!0,a.resolve(y,P))}var T=g(function(){v(M,x)});T.status==="error"&&x(T.value)}function g(y,v){var w={};try{w.value=y(v),w.status="success"}catch(x){w.status="error",w.value=x}return w}(n.exports=d).prototype.finally=function(y){if(typeof y!="function")return this;var v=this.constructor;return this.then(function(w){return v.resolve(y()).then(function(){return w})},function(w){return v.resolve(y()).then(function(){throw w})})},d.prototype.catch=function(y){return this.then(null,y)},d.prototype.then=function(y,v){if(typeof y!="function"&&this.state===c||typeof v!="function"&&this.state===l)return this;var w=new this.constructor(r);return this.state!==h?p(w,this.state===c?y:v,this.outcome):this.queue.push(new m(w,y,v)),w},m.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},m.prototype.otherCallFulfilled=function(y){p(this.promise,this.onFulfilled,y)},m.prototype.callRejected=function(y){a.reject(this.promise,y)},m.prototype.otherCallRejected=function(y){p(this.promise,this.onRejected,y)},a.resolve=function(y,v){var w=g(f,v);if(w.status==="error")return a.reject(y,w.value);var x=w.value;if(x)u(y,x);else{y.state=c,y.outcome=v;for(var M=-1,T=y.queue.length;++M<T;)y.queue[M].callFulfilled(v)}return y},a.reject=function(y,v){y.state=l,y.outcome=v;for(var w=-1,x=y.queue.length;++w<x;)y.queue[w].callRejected(v);return y},d.resolve=function(y){return y instanceof this?y:a.resolve(new this(r),y)},d.reject=function(y){var v=new this(r);return a.reject(v,y)},d.all=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=y.length,x=!1;if(!w)return this.resolve([]);for(var M=new Array(w),T=0,P=-1,k=new this(r);++P<w;)D(y[P],P);return k;function D(E,O){v.resolve(E).then(function(A){M[O]=A,++T!==w||x||(x=!0,a.resolve(k,M))},function(A){x||(x=!0,a.reject(k,A))})}},d.race=function(y){var v=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var w=y.length,x=!1;if(!w)return this.resolve([]);for(var M=-1,T=new this(r);++M<w;)P=y[M],v.resolve(P).then(function(k){x||(x=!0,a.resolve(T,k))},function(k){x||(x=!0,a.reject(T,k))});var P;return T}},{immediate:36}],38:[function(t,n,i){var s={};(0,t("./lib/utils/common").assign)(s,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),n.exports=s},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,n,i){var s=t("./zlib/deflate"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/messages"),c=t("./zlib/zstream"),h=Object.prototype.toString,d=0,m=-1,p=0,f=8;function u(y){if(!(this instanceof u))return new u(y);this.options=r.assign({level:m,method:f,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},y||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var w=s.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(w!==d)throw new Error(l[w]);if(v.header&&s.deflateSetHeader(this.strm,v.header),v.dictionary){var x;if(x=typeof v.dictionary=="string"?a.string2buf(v.dictionary):h.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(w=s.deflateSetDictionary(this.strm,x))!==d)throw new Error(l[w]);this._dict_set=!0}}function g(y,v){var w=new u(v);if(w.push(y,!0),w.err)throw w.msg||l[w.err];return w.result}u.prototype.push=function(y,v){var w,x,M=this.strm,T=this.options.chunkSize;if(this.ended)return!1;x=v===~~v?v:v===!0?4:0,typeof y=="string"?M.input=a.string2buf(y):h.call(y)==="[object ArrayBuffer]"?M.input=new Uint8Array(y):M.input=y,M.next_in=0,M.avail_in=M.input.length;do{if(M.avail_out===0&&(M.output=new r.Buf8(T),M.next_out=0,M.avail_out=T),(w=s.deflate(M,x))!==1&&w!==d)return this.onEnd(w),!(this.ended=!0);M.avail_out!==0&&(M.avail_in!==0||x!==4&&x!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(r.shrinkBuf(M.output,M.next_out))):this.onData(r.shrinkBuf(M.output,M.next_out)))}while((0<M.avail_in||M.avail_out===0)&&w!==1);return x===4?(w=s.deflateEnd(this.strm),this.onEnd(w),this.ended=!0,w===d):x!==2||(this.onEnd(d),!(M.avail_out=0))},u.prototype.onData=function(y){this.chunks.push(y)},u.prototype.onEnd=function(y){y===d&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=u,i.deflate=g,i.deflateRaw=function(y,v){return(v=v||{}).raw=!0,g(y,v)},i.gzip=function(y,v){return(v=v||{}).gzip=!0,g(y,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,n,i){var s=t("./zlib/inflate"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),c=t("./zlib/messages"),h=t("./zlib/zstream"),d=t("./zlib/gzheader"),m=Object.prototype.toString;function p(u){if(!(this instanceof p))return new p(u);this.options=r.assign({chunkSize:16384,windowBits:0,to:""},u||{});var g=this.options;g.raw&&0<=g.windowBits&&g.windowBits<16&&(g.windowBits=-g.windowBits,g.windowBits===0&&(g.windowBits=-15)),!(0<=g.windowBits&&g.windowBits<16)||u&&u.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var y=s.inflateInit2(this.strm,g.windowBits);if(y!==l.Z_OK)throw new Error(c[y]);this.header=new d,s.inflateGetHeader(this.strm,this.header)}function f(u,g){var y=new p(g);if(y.push(u,!0),y.err)throw y.msg||c[y.err];return y.result}p.prototype.push=function(u,g){var y,v,w,x,M,T,P=this.strm,k=this.options.chunkSize,D=this.options.dictionary,E=!1;if(this.ended)return!1;v=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof u=="string"?P.input=a.binstring2buf(u):m.call(u)==="[object ArrayBuffer]"?P.input=new Uint8Array(u):P.input=u,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new r.Buf8(k),P.next_out=0,P.avail_out=k),(y=s.inflate(P,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&D&&(T=typeof D=="string"?a.string2buf(D):m.call(D)==="[object ArrayBuffer]"?new Uint8Array(D):D,y=s.inflateSetDictionary(this.strm,T)),y===l.Z_BUF_ERROR&&E===!0&&(y=l.Z_OK,E=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);P.next_out&&(P.avail_out!==0&&y!==l.Z_STREAM_END&&(P.avail_in!==0||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(w=a.utf8border(P.output,P.next_out),x=P.next_out-w,M=a.buf2string(P.output,w),P.next_out=x,P.avail_out=k-x,x&&r.arraySet(P.output,P.output,w,x,0),this.onData(M)):this.onData(r.shrinkBuf(P.output,P.next_out)))),P.avail_in===0&&P.avail_out===0&&(E=!0)}while((0<P.avail_in||P.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(y=s.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(P.avail_out=0))},p.prototype.onData=function(u){this.chunks.push(u)},p.prototype.onEnd=function(u){u===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=r.flattenChunks(this.chunks)),this.chunks=[],this.err=u,this.msg=this.strm.msg},i.Inflate=p,i.inflate=f,i.inflateRaw=function(u,g){return(g=g||{}).raw=!0,f(u,g)},i.ungzip=f},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,n,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var h=c.shift();if(h){if(typeof h!="object")throw new TypeError(h+"must be non-object");for(var d in h)h.hasOwnProperty(d)&&(l[d]=h[d])}}return l},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var r={arraySet:function(l,c,h,d,m){if(c.subarray&&l.subarray)l.set(c.subarray(h,h+d),m);else for(var p=0;p<d;p++)l[m+p]=c[h+p]},flattenChunks:function(l){var c,h,d,m,p,f;for(c=d=0,h=l.length;c<h;c++)d+=l[c].length;for(f=new Uint8Array(d),c=m=0,h=l.length;c<h;c++)p=l[c],f.set(p,m),m+=p.length;return f}},a={arraySet:function(l,c,h,d,m){for(var p=0;p<d;p++)l[m+p]=c[h+p]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,r)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,a))},i.setTyped(s)},{}],42:[function(t,n,i){var s=t("./common"),r=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new s.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function h(d,m){if(m<65537&&(d.subarray&&a||!d.subarray&&r))return String.fromCharCode.apply(null,s.shrinkBuf(d,m));for(var p="",f=0;f<m;f++)p+=String.fromCharCode(d[f]);return p}l[254]=l[254]=1,i.string2buf=function(d){var m,p,f,u,g,y=d.length,v=0;for(u=0;u<y;u++)(64512&(p=d.charCodeAt(u)))==55296&&u+1<y&&(64512&(f=d.charCodeAt(u+1)))==56320&&(p=65536+(p-55296<<10)+(f-56320),u++),v+=p<128?1:p<2048?2:p<65536?3:4;for(m=new s.Buf8(v),u=g=0;g<v;u++)(64512&(p=d.charCodeAt(u)))==55296&&u+1<y&&(64512&(f=d.charCodeAt(u+1)))==56320&&(p=65536+(p-55296<<10)+(f-56320),u++),p<128?m[g++]=p:(p<2048?m[g++]=192|p>>>6:(p<65536?m[g++]=224|p>>>12:(m[g++]=240|p>>>18,m[g++]=128|p>>>12&63),m[g++]=128|p>>>6&63),m[g++]=128|63&p);return m},i.buf2binstring=function(d){return h(d,d.length)},i.binstring2buf=function(d){for(var m=new s.Buf8(d.length),p=0,f=m.length;p<f;p++)m[p]=d.charCodeAt(p);return m},i.buf2string=function(d,m){var p,f,u,g,y=m||d.length,v=new Array(2*y);for(p=f=0;p<y;)if((u=d[p++])<128)v[f++]=u;else if(4<(g=l[u]))v[f++]=65533,p+=g-1;else{for(u&=g===2?31:g===3?15:7;1<g&&p<y;)u=u<<6|63&d[p++],g--;1<g?v[f++]=65533:u<65536?v[f++]=u:(u-=65536,v[f++]=55296|u>>10&1023,v[f++]=56320|1023&u)}return h(v,f)},i.utf8border=function(d,m){var p;for((m=m||d.length)>d.length&&(m=d.length),p=m-1;0<=p&&(192&d[p])==128;)p--;return p<0||p===0?m:p+l[d[p]]>m?p:m}},{"./common":41}],43:[function(t,n,i){n.exports=function(s,r,a,l){for(var c=65535&s|0,h=s>>>16&65535|0,d=0;a!==0;){for(a-=d=2e3<a?2e3:a;h=h+(c=c+r[l++]|0)|0,--d;);c%=65521,h%=65521}return c|h<<16|0}},{}],44:[function(t,n,i){n.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,n,i){var s=(function(){for(var r,a=[],l=0;l<256;l++){r=l;for(var c=0;c<8;c++)r=1&r?3988292384^r>>>1:r>>>1;a[l]=r}return a})();n.exports=function(r,a,l,c){var h=s,d=c+l;r^=-1;for(var m=c;m<d;m++)r=r>>>8^h[255&(r^a[m])];return-1^r}},{}],46:[function(t,n,i){var s,r=t("../utils/common"),a=t("./trees"),l=t("./adler32"),c=t("./crc32"),h=t("./messages"),d=0,m=4,p=0,f=-2,u=-1,g=4,y=2,v=8,w=9,x=286,M=30,T=19,P=2*x+1,k=15,D=3,E=258,O=E+D+1,A=42,I=113,S=1,z=2,V=3,U=4;function H(C,Z){return C.msg=h[Z],Z}function G(C){return(C<<1)-(4<C?9:0)}function $(C){for(var Z=C.length;0<=--Z;)C[Z]=0}function F(C){var Z=C.state,X=Z.pending;X>C.avail_out&&(X=C.avail_out),X!==0&&(r.arraySet(C.output,Z.pending_buf,Z.pending_out,X,C.next_out),C.next_out+=X,Z.pending_out+=X,C.total_out+=X,C.avail_out-=X,Z.pending-=X,Z.pending===0&&(Z.pending_out=0))}function R(C,Z){a._tr_flush_block(C,0<=C.block_start?C.block_start:-1,C.strstart-C.block_start,Z),C.block_start=C.strstart,F(C.strm)}function te(C,Z){C.pending_buf[C.pending++]=Z}function ee(C,Z){C.pending_buf[C.pending++]=Z>>>8&255,C.pending_buf[C.pending++]=255&Z}function q(C,Z){var X,B,L=C.max_chain_length,N=C.strstart,Y=C.prev_length,K=C.nice_match,j=C.strstart>C.w_size-O?C.strstart-(C.w_size-O):0,J=C.window,ne=C.w_mask,Q=C.prev,ie=C.strstart+E,he=J[N+Y-1],ae=J[N+Y];C.prev_length>=C.good_match&&(L>>=2),K>C.lookahead&&(K=C.lookahead);do if(J[(X=Z)+Y]===ae&&J[X+Y-1]===he&&J[X]===J[N]&&J[++X]===J[N+1]){N+=2,X++;do;while(J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&J[++N]===J[++X]&&N<ie);if(B=E-(ie-N),N=ie-E,Y<B){if(C.match_start=Z,K<=(Y=B))break;he=J[N+Y-1],ae=J[N+Y]}}while((Z=Q[Z&ne])>j&&--L!=0);return Y<=C.lookahead?Y:C.lookahead}function ce(C){var Z,X,B,L,N,Y,K,j,J,ne,Q=C.w_size;do{if(L=C.window_size-C.lookahead-C.strstart,C.strstart>=Q+(Q-O)){for(r.arraySet(C.window,C.window,Q,Q,0),C.match_start-=Q,C.strstart-=Q,C.block_start-=Q,Z=X=C.hash_size;B=C.head[--Z],C.head[Z]=Q<=B?B-Q:0,--X;);for(Z=X=Q;B=C.prev[--Z],C.prev[Z]=Q<=B?B-Q:0,--X;);L+=Q}if(C.strm.avail_in===0)break;if(Y=C.strm,K=C.window,j=C.strstart+C.lookahead,J=L,ne=void 0,ne=Y.avail_in,J<ne&&(ne=J),X=ne===0?0:(Y.avail_in-=ne,r.arraySet(K,Y.input,Y.next_in,ne,j),Y.state.wrap===1?Y.adler=l(Y.adler,K,ne,j):Y.state.wrap===2&&(Y.adler=c(Y.adler,K,ne,j)),Y.next_in+=ne,Y.total_in+=ne,ne),C.lookahead+=X,C.lookahead+C.insert>=D)for(N=C.strstart-C.insert,C.ins_h=C.window[N],C.ins_h=(C.ins_h<<C.hash_shift^C.window[N+1])&C.hash_mask;C.insert&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[N+D-1])&C.hash_mask,C.prev[N&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=N,N++,C.insert--,!(C.lookahead+C.insert<D)););}while(C.lookahead<O&&C.strm.avail_in!==0)}function fe(C,Z){for(var X,B;;){if(C.lookahead<O){if(ce(C),C.lookahead<O&&Z===d)return S;if(C.lookahead===0)break}if(X=0,C.lookahead>=D&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+D-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),X!==0&&C.strstart-X<=C.w_size-O&&(C.match_length=q(C,X)),C.match_length>=D)if(B=a._tr_tally(C,C.strstart-C.match_start,C.match_length-D),C.lookahead-=C.match_length,C.match_length<=C.max_lazy_match&&C.lookahead>=D){for(C.match_length--;C.strstart++,C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+D-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart,--C.match_length!=0;);C.strstart++}else C.strstart+=C.match_length,C.match_length=0,C.ins_h=C.window[C.strstart],C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+1])&C.hash_mask;else B=a._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++;if(B&&(R(C,!1),C.strm.avail_out===0))return S}return C.insert=C.strstart<D-1?C.strstart:D-1,Z===m?(R(C,!0),C.strm.avail_out===0?V:U):C.last_lit&&(R(C,!1),C.strm.avail_out===0)?S:z}function se(C,Z){for(var X,B,L;;){if(C.lookahead<O){if(ce(C),C.lookahead<O&&Z===d)return S;if(C.lookahead===0)break}if(X=0,C.lookahead>=D&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+D-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),C.prev_length=C.match_length,C.prev_match=C.match_start,C.match_length=D-1,X!==0&&C.prev_length<C.max_lazy_match&&C.strstart-X<=C.w_size-O&&(C.match_length=q(C,X),C.match_length<=5&&(C.strategy===1||C.match_length===D&&4096<C.strstart-C.match_start)&&(C.match_length=D-1)),C.prev_length>=D&&C.match_length<=C.prev_length){for(L=C.strstart+C.lookahead-D,B=a._tr_tally(C,C.strstart-1-C.prev_match,C.prev_length-D),C.lookahead-=C.prev_length-1,C.prev_length-=2;++C.strstart<=L&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+D-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),--C.prev_length!=0;);if(C.match_available=0,C.match_length=D-1,C.strstart++,B&&(R(C,!1),C.strm.avail_out===0))return S}else if(C.match_available){if((B=a._tr_tally(C,0,C.window[C.strstart-1]))&&R(C,!1),C.strstart++,C.lookahead--,C.strm.avail_out===0)return S}else C.match_available=1,C.strstart++,C.lookahead--}return C.match_available&&(B=a._tr_tally(C,0,C.window[C.strstart-1]),C.match_available=0),C.insert=C.strstart<D-1?C.strstart:D-1,Z===m?(R(C,!0),C.strm.avail_out===0?V:U):C.last_lit&&(R(C,!1),C.strm.avail_out===0)?S:z}function oe(C,Z,X,B,L){this.good_length=C,this.max_lazy=Z,this.nice_length=X,this.max_chain=B,this.func=L}function ue(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new r.Buf16(2*P),this.dyn_dtree=new r.Buf16(2*(2*M+1)),this.bl_tree=new r.Buf16(2*(2*T+1)),$(this.dyn_ltree),$(this.dyn_dtree),$(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new r.Buf16(k+1),this.heap=new r.Buf16(2*x+1),$(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new r.Buf16(2*x+1),$(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function pe(C){var Z;return C&&C.state?(C.total_in=C.total_out=0,C.data_type=y,(Z=C.state).pending=0,Z.pending_out=0,Z.wrap<0&&(Z.wrap=-Z.wrap),Z.status=Z.wrap?A:I,C.adler=Z.wrap===2?0:1,Z.last_flush=d,a._tr_init(Z),p):H(C,f)}function Ce(C){var Z=pe(C);return Z===p&&(function(X){X.window_size=2*X.w_size,$(X.head),X.max_lazy_match=s[X.level].max_lazy,X.good_match=s[X.level].good_length,X.nice_match=s[X.level].nice_length,X.max_chain_length=s[X.level].max_chain,X.strstart=0,X.block_start=0,X.lookahead=0,X.insert=0,X.match_length=X.prev_length=D-1,X.match_available=0,X.ins_h=0})(C.state),Z}function Be(C,Z,X,B,L,N){if(!C)return f;var Y=1;if(Z===u&&(Z=6),B<0?(Y=0,B=-B):15<B&&(Y=2,B-=16),L<1||w<L||X!==v||B<8||15<B||Z<0||9<Z||N<0||g<N)return H(C,f);B===8&&(B=9);var K=new ue;return(C.state=K).strm=C,K.wrap=Y,K.gzhead=null,K.w_bits=B,K.w_size=1<<K.w_bits,K.w_mask=K.w_size-1,K.hash_bits=L+7,K.hash_size=1<<K.hash_bits,K.hash_mask=K.hash_size-1,K.hash_shift=~~((K.hash_bits+D-1)/D),K.window=new r.Buf8(2*K.w_size),K.head=new r.Buf16(K.hash_size),K.prev=new r.Buf16(K.w_size),K.lit_bufsize=1<<L+6,K.pending_buf_size=4*K.lit_bufsize,K.pending_buf=new r.Buf8(K.pending_buf_size),K.d_buf=1*K.lit_bufsize,K.l_buf=3*K.lit_bufsize,K.level=Z,K.strategy=N,K.method=X,Ce(C)}s=[new oe(0,0,0,0,function(C,Z){var X=65535;for(X>C.pending_buf_size-5&&(X=C.pending_buf_size-5);;){if(C.lookahead<=1){if(ce(C),C.lookahead===0&&Z===d)return S;if(C.lookahead===0)break}C.strstart+=C.lookahead,C.lookahead=0;var B=C.block_start+X;if((C.strstart===0||C.strstart>=B)&&(C.lookahead=C.strstart-B,C.strstart=B,R(C,!1),C.strm.avail_out===0)||C.strstart-C.block_start>=C.w_size-O&&(R(C,!1),C.strm.avail_out===0))return S}return C.insert=0,Z===m?(R(C,!0),C.strm.avail_out===0?V:U):(C.strstart>C.block_start&&(R(C,!1),C.strm.avail_out),S)}),new oe(4,4,8,4,fe),new oe(4,5,16,8,fe),new oe(4,6,32,32,fe),new oe(4,4,16,16,se),new oe(8,16,32,32,se),new oe(8,16,128,128,se),new oe(8,32,128,256,se),new oe(32,128,258,1024,se),new oe(32,258,258,4096,se)],i.deflateInit=function(C,Z){return Be(C,Z,v,15,8,0)},i.deflateInit2=Be,i.deflateReset=Ce,i.deflateResetKeep=pe,i.deflateSetHeader=function(C,Z){return C&&C.state?C.state.wrap!==2?f:(C.state.gzhead=Z,p):f},i.deflate=function(C,Z){var X,B,L,N;if(!C||!C.state||5<Z||Z<0)return C?H(C,f):f;if(B=C.state,!C.output||!C.input&&C.avail_in!==0||B.status===666&&Z!==m)return H(C,C.avail_out===0?-5:f);if(B.strm=C,X=B.last_flush,B.last_flush=Z,B.status===A)if(B.wrap===2)C.adler=0,te(B,31),te(B,139),te(B,8),B.gzhead?(te(B,(B.gzhead.text?1:0)+(B.gzhead.hcrc?2:0)+(B.gzhead.extra?4:0)+(B.gzhead.name?8:0)+(B.gzhead.comment?16:0)),te(B,255&B.gzhead.time),te(B,B.gzhead.time>>8&255),te(B,B.gzhead.time>>16&255),te(B,B.gzhead.time>>24&255),te(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),te(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(te(B,255&B.gzhead.extra.length),te(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(C.adler=c(C.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(te(B,0),te(B,0),te(B,0),te(B,0),te(B,0),te(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),te(B,3),B.status=I);else{var Y=v+(B.w_bits-8<<4)<<8;Y|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(Y|=32),Y+=31-Y%31,B.status=I,ee(B,Y),B.strstart!==0&&(ee(B,C.adler>>>16),ee(B,65535&C.adler)),C.adler=1}if(B.status===69)if(B.gzhead.extra){for(L=B.pending;B.gzindex<(65535&B.gzhead.extra.length)&&(B.pending!==B.pending_buf_size||(B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),F(C),L=B.pending,B.pending!==B.pending_buf_size));)te(B,255&B.gzhead.extra[B.gzindex]),B.gzindex++;B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),B.gzindex===B.gzhead.extra.length&&(B.gzindex=0,B.status=73)}else B.status=73;if(B.status===73)if(B.gzhead.name){L=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),F(C),L=B.pending,B.pending===B.pending_buf_size)){N=1;break}N=B.gzindex<B.gzhead.name.length?255&B.gzhead.name.charCodeAt(B.gzindex++):0,te(B,N)}while(N!==0);B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),N===0&&(B.gzindex=0,B.status=91)}else B.status=91;if(B.status===91)if(B.gzhead.comment){L=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),F(C),L=B.pending,B.pending===B.pending_buf_size)){N=1;break}N=B.gzindex<B.gzhead.comment.length?255&B.gzhead.comment.charCodeAt(B.gzindex++):0,te(B,N)}while(N!==0);B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),N===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&F(C),B.pending+2<=B.pending_buf_size&&(te(B,255&C.adler),te(B,C.adler>>8&255),C.adler=0,B.status=I)):B.status=I),B.pending!==0){if(F(C),C.avail_out===0)return B.last_flush=-1,p}else if(C.avail_in===0&&G(Z)<=G(X)&&Z!==m)return H(C,-5);if(B.status===666&&C.avail_in!==0)return H(C,-5);if(C.avail_in!==0||B.lookahead!==0||Z!==d&&B.status!==666){var K=B.strategy===2?(function(j,J){for(var ne;;){if(j.lookahead===0&&(ce(j),j.lookahead===0)){if(J===d)return S;break}if(j.match_length=0,ne=a._tr_tally(j,0,j.window[j.strstart]),j.lookahead--,j.strstart++,ne&&(R(j,!1),j.strm.avail_out===0))return S}return j.insert=0,J===m?(R(j,!0),j.strm.avail_out===0?V:U):j.last_lit&&(R(j,!1),j.strm.avail_out===0)?S:z})(B,Z):B.strategy===3?(function(j,J){for(var ne,Q,ie,he,ae=j.window;;){if(j.lookahead<=E){if(ce(j),j.lookahead<=E&&J===d)return S;if(j.lookahead===0)break}if(j.match_length=0,j.lookahead>=D&&0<j.strstart&&(Q=ae[ie=j.strstart-1])===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]){he=j.strstart+E;do;while(Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&ie<he);j.match_length=E-(he-ie),j.match_length>j.lookahead&&(j.match_length=j.lookahead)}if(j.match_length>=D?(ne=a._tr_tally(j,1,j.match_length-D),j.lookahead-=j.match_length,j.strstart+=j.match_length,j.match_length=0):(ne=a._tr_tally(j,0,j.window[j.strstart]),j.lookahead--,j.strstart++),ne&&(R(j,!1),j.strm.avail_out===0))return S}return j.insert=0,J===m?(R(j,!0),j.strm.avail_out===0?V:U):j.last_lit&&(R(j,!1),j.strm.avail_out===0)?S:z})(B,Z):s[B.level].func(B,Z);if(K!==V&&K!==U||(B.status=666),K===S||K===V)return C.avail_out===0&&(B.last_flush=-1),p;if(K===z&&(Z===1?a._tr_align(B):Z!==5&&(a._tr_stored_block(B,0,0,!1),Z===3&&($(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),F(C),C.avail_out===0))return B.last_flush=-1,p}return Z!==m?p:B.wrap<=0?1:(B.wrap===2?(te(B,255&C.adler),te(B,C.adler>>8&255),te(B,C.adler>>16&255),te(B,C.adler>>24&255),te(B,255&C.total_in),te(B,C.total_in>>8&255),te(B,C.total_in>>16&255),te(B,C.total_in>>24&255)):(ee(B,C.adler>>>16),ee(B,65535&C.adler)),F(C),0<B.wrap&&(B.wrap=-B.wrap),B.pending!==0?p:1)},i.deflateEnd=function(C){var Z;return C&&C.state?(Z=C.state.status)!==A&&Z!==69&&Z!==73&&Z!==91&&Z!==103&&Z!==I&&Z!==666?H(C,f):(C.state=null,Z===I?H(C,-3):p):f},i.deflateSetDictionary=function(C,Z){var X,B,L,N,Y,K,j,J,ne=Z.length;if(!C||!C.state||(N=(X=C.state).wrap)===2||N===1&&X.status!==A||X.lookahead)return f;for(N===1&&(C.adler=l(C.adler,Z,ne,0)),X.wrap=0,ne>=X.w_size&&(N===0&&($(X.head),X.strstart=0,X.block_start=0,X.insert=0),J=new r.Buf8(X.w_size),r.arraySet(J,Z,ne-X.w_size,X.w_size,0),Z=J,ne=X.w_size),Y=C.avail_in,K=C.next_in,j=C.input,C.avail_in=ne,C.next_in=0,C.input=Z,ce(X);X.lookahead>=D;){for(B=X.strstart,L=X.lookahead-(D-1);X.ins_h=(X.ins_h<<X.hash_shift^X.window[B+D-1])&X.hash_mask,X.prev[B&X.w_mask]=X.head[X.ins_h],X.head[X.ins_h]=B,B++,--L;);X.strstart=B,X.lookahead=D-1,ce(X)}return X.strstart+=X.lookahead,X.block_start=X.strstart,X.insert=X.lookahead,X.lookahead=0,X.match_length=X.prev_length=D-1,X.match_available=0,C.next_in=K,C.input=j,C.avail_in=Y,X.wrap=N,p},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,n,i){n.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,n,i){n.exports=function(s,r){var a,l,c,h,d,m,p,f,u,g,y,v,w,x,M,T,P,k,D,E,O,A,I,S,z;a=s.state,l=s.next_in,S=s.input,c=l+(s.avail_in-5),h=s.next_out,z=s.output,d=h-(r-s.avail_out),m=h+(s.avail_out-257),p=a.dmax,f=a.wsize,u=a.whave,g=a.wnext,y=a.window,v=a.hold,w=a.bits,x=a.lencode,M=a.distcode,T=(1<<a.lenbits)-1,P=(1<<a.distbits)-1;e:do{w<15&&(v+=S[l++]<<w,w+=8,v+=S[l++]<<w,w+=8),k=x[v&T];t:for(;;){if(v>>>=D=k>>>24,w-=D,(D=k>>>16&255)===0)z[h++]=65535&k;else{if(!(16&D)){if((64&D)==0){k=x[(65535&k)+(v&(1<<D)-1)];continue t}if(32&D){a.mode=12;break e}s.msg="invalid literal/length code",a.mode=30;break e}E=65535&k,(D&=15)&&(w<D&&(v+=S[l++]<<w,w+=8),E+=v&(1<<D)-1,v>>>=D,w-=D),w<15&&(v+=S[l++]<<w,w+=8,v+=S[l++]<<w,w+=8),k=M[v&P];n:for(;;){if(v>>>=D=k>>>24,w-=D,!(16&(D=k>>>16&255))){if((64&D)==0){k=M[(65535&k)+(v&(1<<D)-1)];continue n}s.msg="invalid distance code",a.mode=30;break e}if(O=65535&k,w<(D&=15)&&(v+=S[l++]<<w,(w+=8)<D&&(v+=S[l++]<<w,w+=8)),p<(O+=v&(1<<D)-1)){s.msg="invalid distance too far back",a.mode=30;break e}if(v>>>=D,w-=D,(D=h-d)<O){if(u<(D=O-D)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(I=y,(A=0)===g){if(A+=f-D,D<E){for(E-=D;z[h++]=y[A++],--D;);A=h-O,I=z}}else if(g<D){if(A+=f+g-D,(D-=g)<E){for(E-=D;z[h++]=y[A++],--D;);if(A=0,g<E){for(E-=D=g;z[h++]=y[A++],--D;);A=h-O,I=z}}}else if(A+=g-D,D<E){for(E-=D;z[h++]=y[A++],--D;);A=h-O,I=z}for(;2<E;)z[h++]=I[A++],z[h++]=I[A++],z[h++]=I[A++],E-=3;E&&(z[h++]=I[A++],1<E&&(z[h++]=I[A++]))}else{for(A=h-O;z[h++]=z[A++],z[h++]=z[A++],z[h++]=z[A++],2<(E-=3););E&&(z[h++]=z[A++],1<E&&(z[h++]=z[A++]))}break}}break}}while(l<c&&h<m);l-=E=w>>3,v&=(1<<(w-=E<<3))-1,s.next_in=l,s.next_out=h,s.avail_in=l<c?c-l+5:5-(l-c),s.avail_out=h<m?m-h+257:257-(h-m),a.hold=v,a.bits=w}},{}],49:[function(t,n,i){var s=t("../utils/common"),r=t("./adler32"),a=t("./crc32"),l=t("./inffast"),c=t("./inftrees"),h=1,d=2,m=0,p=-2,f=1,u=852,g=592;function y(A){return(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function w(A){var I;return A&&A.state?(I=A.state,A.total_in=A.total_out=I.total=0,A.msg="",I.wrap&&(A.adler=1&I.wrap),I.mode=f,I.last=0,I.havedict=0,I.dmax=32768,I.head=null,I.hold=0,I.bits=0,I.lencode=I.lendyn=new s.Buf32(u),I.distcode=I.distdyn=new s.Buf32(g),I.sane=1,I.back=-1,m):p}function x(A){var I;return A&&A.state?((I=A.state).wsize=0,I.whave=0,I.wnext=0,w(A)):p}function M(A,I){var S,z;return A&&A.state?(z=A.state,I<0?(S=0,I=-I):(S=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15<I)?p:(z.window!==null&&z.wbits!==I&&(z.window=null),z.wrap=S,z.wbits=I,x(A))):p}function T(A,I){var S,z;return A?(z=new v,(A.state=z).window=null,(S=M(A,I))!==m&&(A.state=null),S):p}var P,k,D=!0;function E(A){if(D){var I;for(P=new s.Buf32(512),k=new s.Buf32(32),I=0;I<144;)A.lens[I++]=8;for(;I<256;)A.lens[I++]=9;for(;I<280;)A.lens[I++]=7;for(;I<288;)A.lens[I++]=8;for(c(h,A.lens,0,288,P,0,A.work,{bits:9}),I=0;I<32;)A.lens[I++]=5;c(d,A.lens,0,32,k,0,A.work,{bits:5}),D=!1}A.lencode=P,A.lenbits=9,A.distcode=k,A.distbits=5}function O(A,I,S,z){var V,U=A.state;return U.window===null&&(U.wsize=1<<U.wbits,U.wnext=0,U.whave=0,U.window=new s.Buf8(U.wsize)),z>=U.wsize?(s.arraySet(U.window,I,S-U.wsize,U.wsize,0),U.wnext=0,U.whave=U.wsize):(z<(V=U.wsize-U.wnext)&&(V=z),s.arraySet(U.window,I,S-z,V,U.wnext),(z-=V)?(s.arraySet(U.window,I,S-z,z,0),U.wnext=z,U.whave=U.wsize):(U.wnext+=V,U.wnext===U.wsize&&(U.wnext=0),U.whave<U.wsize&&(U.whave+=V))),0}i.inflateReset=x,i.inflateReset2=M,i.inflateResetKeep=w,i.inflateInit=function(A){return T(A,15)},i.inflateInit2=T,i.inflate=function(A,I){var S,z,V,U,H,G,$,F,R,te,ee,q,ce,fe,se,oe,ue,pe,Ce,Be,C,Z,X,B,L=0,N=new s.Buf8(4),Y=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!A||!A.state||!A.output||!A.input&&A.avail_in!==0)return p;(S=A.state).mode===12&&(S.mode=13),H=A.next_out,V=A.output,$=A.avail_out,U=A.next_in,z=A.input,G=A.avail_in,F=S.hold,R=S.bits,te=G,ee=$,Z=m;e:for(;;)switch(S.mode){case f:if(S.wrap===0){S.mode=13;break}for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(2&S.wrap&&F===35615){N[S.check=0]=255&F,N[1]=F>>>8&255,S.check=a(S.check,N,2,0),R=F=0,S.mode=2;break}if(S.flags=0,S.head&&(S.head.done=!1),!(1&S.wrap)||(((255&F)<<8)+(F>>8))%31){A.msg="incorrect header check",S.mode=30;break}if((15&F)!=8){A.msg="unknown compression method",S.mode=30;break}if(R-=4,C=8+(15&(F>>>=4)),S.wbits===0)S.wbits=C;else if(C>S.wbits){A.msg="invalid window size",S.mode=30;break}S.dmax=1<<C,A.adler=S.check=1,S.mode=512&F?10:12,R=F=0;break;case 2:for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(S.flags=F,(255&S.flags)!=8){A.msg="unknown compression method",S.mode=30;break}if(57344&S.flags){A.msg="unknown header flags set",S.mode=30;break}S.head&&(S.head.text=F>>8&1),512&S.flags&&(N[0]=255&F,N[1]=F>>>8&255,S.check=a(S.check,N,2,0)),R=F=0,S.mode=3;case 3:for(;R<32;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.head&&(S.head.time=F),512&S.flags&&(N[0]=255&F,N[1]=F>>>8&255,N[2]=F>>>16&255,N[3]=F>>>24&255,S.check=a(S.check,N,4,0)),R=F=0,S.mode=4;case 4:for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.head&&(S.head.xflags=255&F,S.head.os=F>>8),512&S.flags&&(N[0]=255&F,N[1]=F>>>8&255,S.check=a(S.check,N,2,0)),R=F=0,S.mode=5;case 5:if(1024&S.flags){for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.length=F,S.head&&(S.head.extra_len=F),512&S.flags&&(N[0]=255&F,N[1]=F>>>8&255,S.check=a(S.check,N,2,0)),R=F=0}else S.head&&(S.head.extra=null);S.mode=6;case 6:if(1024&S.flags&&(G<(q=S.length)&&(q=G),q&&(S.head&&(C=S.head.extra_len-S.length,S.head.extra||(S.head.extra=new Array(S.head.extra_len)),s.arraySet(S.head.extra,z,U,q,C)),512&S.flags&&(S.check=a(S.check,z,q,U)),G-=q,U+=q,S.length-=q),S.length))break e;S.length=0,S.mode=7;case 7:if(2048&S.flags){if(G===0)break e;for(q=0;C=z[U+q++],S.head&&C&&S.length<65536&&(S.head.name+=String.fromCharCode(C)),C&&q<G;);if(512&S.flags&&(S.check=a(S.check,z,q,U)),G-=q,U+=q,C)break e}else S.head&&(S.head.name=null);S.length=0,S.mode=8;case 8:if(4096&S.flags){if(G===0)break e;for(q=0;C=z[U+q++],S.head&&C&&S.length<65536&&(S.head.comment+=String.fromCharCode(C)),C&&q<G;);if(512&S.flags&&(S.check=a(S.check,z,q,U)),G-=q,U+=q,C)break e}else S.head&&(S.head.comment=null);S.mode=9;case 9:if(512&S.flags){for(;R<16;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(F!==(65535&S.check)){A.msg="header crc mismatch",S.mode=30;break}R=F=0}S.head&&(S.head.hcrc=S.flags>>9&1,S.head.done=!0),A.adler=S.check=0,S.mode=12;break;case 10:for(;R<32;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}A.adler=S.check=y(F),R=F=0,S.mode=11;case 11:if(S.havedict===0)return A.next_out=H,A.avail_out=$,A.next_in=U,A.avail_in=G,S.hold=F,S.bits=R,2;A.adler=S.check=1,S.mode=12;case 12:if(I===5||I===6)break e;case 13:if(S.last){F>>>=7&R,R-=7&R,S.mode=27;break}for(;R<3;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}switch(S.last=1&F,R-=1,3&(F>>>=1)){case 0:S.mode=14;break;case 1:if(E(S),S.mode=20,I!==6)break;F>>>=2,R-=2;break e;case 2:S.mode=17;break;case 3:A.msg="invalid block type",S.mode=30}F>>>=2,R-=2;break;case 14:for(F>>>=7&R,R-=7&R;R<32;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if((65535&F)!=(F>>>16^65535)){A.msg="invalid stored block lengths",S.mode=30;break}if(S.length=65535&F,R=F=0,S.mode=15,I===6)break e;case 15:S.mode=16;case 16:if(q=S.length){if(G<q&&(q=G),$<q&&(q=$),q===0)break e;s.arraySet(V,z,U,q,H),G-=q,U+=q,$-=q,H+=q,S.length-=q;break}S.mode=12;break;case 17:for(;R<14;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(S.nlen=257+(31&F),F>>>=5,R-=5,S.ndist=1+(31&F),F>>>=5,R-=5,S.ncode=4+(15&F),F>>>=4,R-=4,286<S.nlen||30<S.ndist){A.msg="too many length or distance symbols",S.mode=30;break}S.have=0,S.mode=18;case 18:for(;S.have<S.ncode;){for(;R<3;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.lens[Y[S.have++]]=7&F,F>>>=3,R-=3}for(;S.have<19;)S.lens[Y[S.have++]]=0;if(S.lencode=S.lendyn,S.lenbits=7,X={bits:S.lenbits},Z=c(0,S.lens,0,19,S.lencode,0,S.work,X),S.lenbits=X.bits,Z){A.msg="invalid code lengths set",S.mode=30;break}S.have=0,S.mode=19;case 19:for(;S.have<S.nlen+S.ndist;){for(;oe=(L=S.lencode[F&(1<<S.lenbits)-1])>>>16&255,ue=65535&L,!((se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(ue<16)F>>>=se,R-=se,S.lens[S.have++]=ue;else{if(ue===16){for(B=se+2;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(F>>>=se,R-=se,S.have===0){A.msg="invalid bit length repeat",S.mode=30;break}C=S.lens[S.have-1],q=3+(3&F),F>>>=2,R-=2}else if(ue===17){for(B=se+3;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}R-=se,C=0,q=3+(7&(F>>>=se)),F>>>=3,R-=3}else{for(B=se+7;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}R-=se,C=0,q=11+(127&(F>>>=se)),F>>>=7,R-=7}if(S.have+q>S.nlen+S.ndist){A.msg="invalid bit length repeat",S.mode=30;break}for(;q--;)S.lens[S.have++]=C}}if(S.mode===30)break;if(S.lens[256]===0){A.msg="invalid code -- missing end-of-block",S.mode=30;break}if(S.lenbits=9,X={bits:S.lenbits},Z=c(h,S.lens,0,S.nlen,S.lencode,0,S.work,X),S.lenbits=X.bits,Z){A.msg="invalid literal/lengths set",S.mode=30;break}if(S.distbits=6,S.distcode=S.distdyn,X={bits:S.distbits},Z=c(d,S.lens,S.nlen,S.ndist,S.distcode,0,S.work,X),S.distbits=X.bits,Z){A.msg="invalid distances set",S.mode=30;break}if(S.mode=20,I===6)break e;case 20:S.mode=21;case 21:if(6<=G&&258<=$){A.next_out=H,A.avail_out=$,A.next_in=U,A.avail_in=G,S.hold=F,S.bits=R,l(A,ee),H=A.next_out,V=A.output,$=A.avail_out,U=A.next_in,z=A.input,G=A.avail_in,F=S.hold,R=S.bits,S.mode===12&&(S.back=-1);break}for(S.back=0;oe=(L=S.lencode[F&(1<<S.lenbits)-1])>>>16&255,ue=65535&L,!((se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(oe&&(240&oe)==0){for(pe=se,Ce=oe,Be=ue;oe=(L=S.lencode[Be+((F&(1<<pe+Ce)-1)>>pe)])>>>16&255,ue=65535&L,!(pe+(se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}F>>>=pe,R-=pe,S.back+=pe}if(F>>>=se,R-=se,S.back+=se,S.length=ue,oe===0){S.mode=26;break}if(32&oe){S.back=-1,S.mode=12;break}if(64&oe){A.msg="invalid literal/length code",S.mode=30;break}S.extra=15&oe,S.mode=22;case 22:if(S.extra){for(B=S.extra;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.length+=F&(1<<S.extra)-1,F>>>=S.extra,R-=S.extra,S.back+=S.extra}S.was=S.length,S.mode=23;case 23:for(;oe=(L=S.distcode[F&(1<<S.distbits)-1])>>>16&255,ue=65535&L,!((se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if((240&oe)==0){for(pe=se,Ce=oe,Be=ue;oe=(L=S.distcode[Be+((F&(1<<pe+Ce)-1)>>pe)])>>>16&255,ue=65535&L,!(pe+(se=L>>>24)<=R);){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}F>>>=pe,R-=pe,S.back+=pe}if(F>>>=se,R-=se,S.back+=se,64&oe){A.msg="invalid distance code",S.mode=30;break}S.offset=ue,S.extra=15&oe,S.mode=24;case 24:if(S.extra){for(B=S.extra;R<B;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}S.offset+=F&(1<<S.extra)-1,F>>>=S.extra,R-=S.extra,S.back+=S.extra}if(S.offset>S.dmax){A.msg="invalid distance too far back",S.mode=30;break}S.mode=25;case 25:if($===0)break e;if(q=ee-$,S.offset>q){if((q=S.offset-q)>S.whave&&S.sane){A.msg="invalid distance too far back",S.mode=30;break}ce=q>S.wnext?(q-=S.wnext,S.wsize-q):S.wnext-q,q>S.length&&(q=S.length),fe=S.window}else fe=V,ce=H-S.offset,q=S.length;for($<q&&(q=$),$-=q,S.length-=q;V[H++]=fe[ce++],--q;);S.length===0&&(S.mode=21);break;case 26:if($===0)break e;V[H++]=S.length,$--,S.mode=21;break;case 27:if(S.wrap){for(;R<32;){if(G===0)break e;G--,F|=z[U++]<<R,R+=8}if(ee-=$,A.total_out+=ee,S.total+=ee,ee&&(A.adler=S.check=S.flags?a(S.check,V,ee,H-ee):r(S.check,V,ee,H-ee)),ee=$,(S.flags?F:y(F))!==S.check){A.msg="incorrect data check",S.mode=30;break}R=F=0}S.mode=28;case 28:if(S.wrap&&S.flags){for(;R<32;){if(G===0)break e;G--,F+=z[U++]<<R,R+=8}if(F!==(4294967295&S.total)){A.msg="incorrect length check",S.mode=30;break}R=F=0}S.mode=29;case 29:Z=1;break e;case 30:Z=-3;break e;case 31:return-4;case 32:default:return p}return A.next_out=H,A.avail_out=$,A.next_in=U,A.avail_in=G,S.hold=F,S.bits=R,(S.wsize||ee!==A.avail_out&&S.mode<30&&(S.mode<27||I!==4))&&O(A,A.output,A.next_out,ee-A.avail_out)?(S.mode=31,-4):(te-=A.avail_in,ee-=A.avail_out,A.total_in+=te,A.total_out+=ee,S.total+=ee,S.wrap&&ee&&(A.adler=S.check=S.flags?a(S.check,V,ee,A.next_out-ee):r(S.check,V,ee,A.next_out-ee)),A.data_type=S.bits+(S.last?64:0)+(S.mode===12?128:0)+(S.mode===20||S.mode===15?256:0),(te==0&&ee===0||I===4)&&Z===m&&(Z=-5),Z)},i.inflateEnd=function(A){if(!A||!A.state)return p;var I=A.state;return I.window&&(I.window=null),A.state=null,m},i.inflateGetHeader=function(A,I){var S;return A&&A.state?(2&(S=A.state).wrap)==0?p:((S.head=I).done=!1,m):p},i.inflateSetDictionary=function(A,I){var S,z=I.length;return A&&A.state?(S=A.state).wrap!==0&&S.mode!==11?p:S.mode===11&&r(1,I,z,0)!==S.check?-3:O(A,I,z,z)?(S.mode=31,-4):(S.havedict=1,m):p},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,n,i){var s=t("../utils/common"),r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];n.exports=function(h,d,m,p,f,u,g,y){var v,w,x,M,T,P,k,D,E,O=y.bits,A=0,I=0,S=0,z=0,V=0,U=0,H=0,G=0,$=0,F=0,R=null,te=0,ee=new s.Buf16(16),q=new s.Buf16(16),ce=null,fe=0;for(A=0;A<=15;A++)ee[A]=0;for(I=0;I<p;I++)ee[d[m+I]]++;for(V=O,z=15;1<=z&&ee[z]===0;z--);if(z<V&&(V=z),z===0)return f[u++]=20971520,f[u++]=20971520,y.bits=1,0;for(S=1;S<z&&ee[S]===0;S++);for(V<S&&(V=S),A=G=1;A<=15;A++)if(G<<=1,(G-=ee[A])<0)return-1;if(0<G&&(h===0||z!==1))return-1;for(q[1]=0,A=1;A<15;A++)q[A+1]=q[A]+ee[A];for(I=0;I<p;I++)d[m+I]!==0&&(g[q[d[m+I]]++]=I);if(P=h===0?(R=ce=g,19):h===1?(R=r,te-=257,ce=a,fe-=257,256):(R=l,ce=c,-1),A=S,T=u,H=I=F=0,x=-1,M=($=1<<(U=V))-1,h===1&&852<$||h===2&&592<$)return 1;for(;;){for(k=A-H,E=g[I]<P?(D=0,g[I]):g[I]>P?(D=ce[fe+g[I]],R[te+g[I]]):(D=96,0),v=1<<A-H,S=w=1<<U;f[T+(F>>H)+(w-=v)]=k<<24|D<<16|E|0,w!==0;);for(v=1<<A-1;F&v;)v>>=1;if(v!==0?(F&=v-1,F+=v):F=0,I++,--ee[A]==0){if(A===z)break;A=d[m+g[I]]}if(V<A&&(F&M)!==x){for(H===0&&(H=V),T+=S,G=1<<(U=A-H);U+H<z&&!((G-=ee[U+H])<=0);)U++,G<<=1;if($+=1<<U,h===1&&852<$||h===2&&592<$)return 1;f[x=F&M]=V<<24|U<<16|T-u|0}}return F!==0&&(f[T+F]=A-H<<24|64<<16|0),y.bits=V,0}},{"../utils/common":41}],51:[function(t,n,i){n.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(t,n,i){var s=t("../utils/common"),r=0,a=1;function l(L){for(var N=L.length;0<=--N;)L[N]=0}var c=0,h=29,d=256,m=d+1+h,p=30,f=19,u=2*m+1,g=15,y=16,v=7,w=256,x=16,M=17,T=18,P=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],k=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],D=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],E=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],O=new Array(2*(m+2));l(O);var A=new Array(2*p);l(A);var I=new Array(512);l(I);var S=new Array(256);l(S);var z=new Array(h);l(z);var V,U,H,G=new Array(p);function $(L,N,Y,K,j){this.static_tree=L,this.extra_bits=N,this.extra_base=Y,this.elems=K,this.max_length=j,this.has_stree=L&&L.length}function F(L,N){this.dyn_tree=L,this.max_code=0,this.stat_desc=N}function R(L){return L<256?I[L]:I[256+(L>>>7)]}function te(L,N){L.pending_buf[L.pending++]=255&N,L.pending_buf[L.pending++]=N>>>8&255}function ee(L,N,Y){L.bi_valid>y-Y?(L.bi_buf|=N<<L.bi_valid&65535,te(L,L.bi_buf),L.bi_buf=N>>y-L.bi_valid,L.bi_valid+=Y-y):(L.bi_buf|=N<<L.bi_valid&65535,L.bi_valid+=Y)}function q(L,N,Y){ee(L,Y[2*N],Y[2*N+1])}function ce(L,N){for(var Y=0;Y|=1&L,L>>>=1,Y<<=1,0<--N;);return Y>>>1}function fe(L,N,Y){var K,j,J=new Array(g+1),ne=0;for(K=1;K<=g;K++)J[K]=ne=ne+Y[K-1]<<1;for(j=0;j<=N;j++){var Q=L[2*j+1];Q!==0&&(L[2*j]=ce(J[Q]++,Q))}}function se(L){var N;for(N=0;N<m;N++)L.dyn_ltree[2*N]=0;for(N=0;N<p;N++)L.dyn_dtree[2*N]=0;for(N=0;N<f;N++)L.bl_tree[2*N]=0;L.dyn_ltree[2*w]=1,L.opt_len=L.static_len=0,L.last_lit=L.matches=0}function oe(L){8<L.bi_valid?te(L,L.bi_buf):0<L.bi_valid&&(L.pending_buf[L.pending++]=L.bi_buf),L.bi_buf=0,L.bi_valid=0}function ue(L,N,Y,K){var j=2*N,J=2*Y;return L[j]<L[J]||L[j]===L[J]&&K[N]<=K[Y]}function pe(L,N,Y){for(var K=L.heap[Y],j=Y<<1;j<=L.heap_len&&(j<L.heap_len&&ue(N,L.heap[j+1],L.heap[j],L.depth)&&j++,!ue(N,K,L.heap[j],L.depth));)L.heap[Y]=L.heap[j],Y=j,j<<=1;L.heap[Y]=K}function Ce(L,N,Y){var K,j,J,ne,Q=0;if(L.last_lit!==0)for(;K=L.pending_buf[L.d_buf+2*Q]<<8|L.pending_buf[L.d_buf+2*Q+1],j=L.pending_buf[L.l_buf+Q],Q++,K===0?q(L,j,N):(q(L,(J=S[j])+d+1,N),(ne=P[J])!==0&&ee(L,j-=z[J],ne),q(L,J=R(--K),Y),(ne=k[J])!==0&&ee(L,K-=G[J],ne)),Q<L.last_lit;);q(L,w,N)}function Be(L,N){var Y,K,j,J=N.dyn_tree,ne=N.stat_desc.static_tree,Q=N.stat_desc.has_stree,ie=N.stat_desc.elems,he=-1;for(L.heap_len=0,L.heap_max=u,Y=0;Y<ie;Y++)J[2*Y]!==0?(L.heap[++L.heap_len]=he=Y,L.depth[Y]=0):J[2*Y+1]=0;for(;L.heap_len<2;)J[2*(j=L.heap[++L.heap_len]=he<2?++he:0)]=1,L.depth[j]=0,L.opt_len--,Q&&(L.static_len-=ne[2*j+1]);for(N.max_code=he,Y=L.heap_len>>1;1<=Y;Y--)pe(L,J,Y);for(j=ie;Y=L.heap[1],L.heap[1]=L.heap[L.heap_len--],pe(L,J,1),K=L.heap[1],L.heap[--L.heap_max]=Y,L.heap[--L.heap_max]=K,J[2*j]=J[2*Y]+J[2*K],L.depth[j]=(L.depth[Y]>=L.depth[K]?L.depth[Y]:L.depth[K])+1,J[2*Y+1]=J[2*K+1]=j,L.heap[1]=j++,pe(L,J,1),2<=L.heap_len;);L.heap[--L.heap_max]=L.heap[1],(function(ae,Ae){var $e,Ee,Ft,ge,nn,Cn,He=Ae.dyn_tree,Mt=Ae.max_code,Ut=Ae.stat_desc.static_tree,Vt=Ae.stat_desc.has_stree,jt=Ae.stat_desc.extra_bits,_t=Ae.stat_desc.extra_base,An=Ae.stat_desc.max_length,Pi=0;for(ge=0;ge<=g;ge++)ae.bl_count[ge]=0;for(He[2*ae.heap[ae.heap_max]+1]=0,$e=ae.heap_max+1;$e<u;$e++)An<(ge=He[2*He[2*(Ee=ae.heap[$e])+1]+1]+1)&&(ge=An,Pi++),He[2*Ee+1]=ge,Mt<Ee||(ae.bl_count[ge]++,nn=0,_t<=Ee&&(nn=jt[Ee-_t]),Cn=He[2*Ee],ae.opt_len+=Cn*(ge+nn),Vt&&(ae.static_len+=Cn*(Ut[2*Ee+1]+nn)));if(Pi!==0){do{for(ge=An-1;ae.bl_count[ge]===0;)ge--;ae.bl_count[ge]--,ae.bl_count[ge+1]+=2,ae.bl_count[An]--,Pi-=2}while(0<Pi);for(ge=An;ge!==0;ge--)for(Ee=ae.bl_count[ge];Ee!==0;)Mt<(Ft=ae.heap[--$e])||(He[2*Ft+1]!==ge&&(ae.opt_len+=(ge-He[2*Ft+1])*He[2*Ft],He[2*Ft+1]=ge),Ee--)}})(L,N),fe(J,he,L.bl_count)}function C(L,N,Y){var K,j,J=-1,ne=N[1],Q=0,ie=7,he=4;for(ne===0&&(ie=138,he=3),N[2*(Y+1)+1]=65535,K=0;K<=Y;K++)j=ne,ne=N[2*(K+1)+1],++Q<ie&&j===ne||(Q<he?L.bl_tree[2*j]+=Q:j!==0?(j!==J&&L.bl_tree[2*j]++,L.bl_tree[2*x]++):Q<=10?L.bl_tree[2*M]++:L.bl_tree[2*T]++,J=j,he=(Q=0)===ne?(ie=138,3):j===ne?(ie=6,3):(ie=7,4))}function Z(L,N,Y){var K,j,J=-1,ne=N[1],Q=0,ie=7,he=4;for(ne===0&&(ie=138,he=3),K=0;K<=Y;K++)if(j=ne,ne=N[2*(K+1)+1],!(++Q<ie&&j===ne)){if(Q<he)for(;q(L,j,L.bl_tree),--Q!=0;);else j!==0?(j!==J&&(q(L,j,L.bl_tree),Q--),q(L,x,L.bl_tree),ee(L,Q-3,2)):Q<=10?(q(L,M,L.bl_tree),ee(L,Q-3,3)):(q(L,T,L.bl_tree),ee(L,Q-11,7));J=j,he=(Q=0)===ne?(ie=138,3):j===ne?(ie=6,3):(ie=7,4)}}l(G);var X=!1;function B(L,N,Y,K){ee(L,(c<<1)+(K?1:0),3),(function(j,J,ne,Q){oe(j),te(j,ne),te(j,~ne),s.arraySet(j.pending_buf,j.window,J,ne,j.pending),j.pending+=ne})(L,N,Y)}i._tr_init=function(L){X||((function(){var N,Y,K,j,J,ne=new Array(g+1);for(j=K=0;j<h-1;j++)for(z[j]=K,N=0;N<1<<P[j];N++)S[K++]=j;for(S[K-1]=j,j=J=0;j<16;j++)for(G[j]=J,N=0;N<1<<k[j];N++)I[J++]=j;for(J>>=7;j<p;j++)for(G[j]=J<<7,N=0;N<1<<k[j]-7;N++)I[256+J++]=j;for(Y=0;Y<=g;Y++)ne[Y]=0;for(N=0;N<=143;)O[2*N+1]=8,N++,ne[8]++;for(;N<=255;)O[2*N+1]=9,N++,ne[9]++;for(;N<=279;)O[2*N+1]=7,N++,ne[7]++;for(;N<=287;)O[2*N+1]=8,N++,ne[8]++;for(fe(O,m+1,ne),N=0;N<p;N++)A[2*N+1]=5,A[2*N]=ce(N,5);V=new $(O,P,d+1,m,g),U=new $(A,k,0,p,g),H=new $(new Array(0),D,0,f,v)})(),X=!0),L.l_desc=new F(L.dyn_ltree,V),L.d_desc=new F(L.dyn_dtree,U),L.bl_desc=new F(L.bl_tree,H),L.bi_buf=0,L.bi_valid=0,se(L)},i._tr_stored_block=B,i._tr_flush_block=function(L,N,Y,K){var j,J,ne=0;0<L.level?(L.strm.data_type===2&&(L.strm.data_type=(function(Q){var ie,he=4093624447;for(ie=0;ie<=31;ie++,he>>>=1)if(1&he&&Q.dyn_ltree[2*ie]!==0)return r;if(Q.dyn_ltree[18]!==0||Q.dyn_ltree[20]!==0||Q.dyn_ltree[26]!==0)return a;for(ie=32;ie<d;ie++)if(Q.dyn_ltree[2*ie]!==0)return a;return r})(L)),Be(L,L.l_desc),Be(L,L.d_desc),ne=(function(Q){var ie;for(C(Q,Q.dyn_ltree,Q.l_desc.max_code),C(Q,Q.dyn_dtree,Q.d_desc.max_code),Be(Q,Q.bl_desc),ie=f-1;3<=ie&&Q.bl_tree[2*E[ie]+1]===0;ie--);return Q.opt_len+=3*(ie+1)+5+5+4,ie})(L),j=L.opt_len+3+7>>>3,(J=L.static_len+3+7>>>3)<=j&&(j=J)):j=J=Y+5,Y+4<=j&&N!==-1?B(L,N,Y,K):L.strategy===4||J===j?(ee(L,2+(K?1:0),3),Ce(L,O,A)):(ee(L,4+(K?1:0),3),(function(Q,ie,he,ae){var Ae;for(ee(Q,ie-257,5),ee(Q,he-1,5),ee(Q,ae-4,4),Ae=0;Ae<ae;Ae++)ee(Q,Q.bl_tree[2*E[Ae]+1],3);Z(Q,Q.dyn_ltree,ie-1),Z(Q,Q.dyn_dtree,he-1)})(L,L.l_desc.max_code+1,L.d_desc.max_code+1,ne+1),Ce(L,L.dyn_ltree,L.dyn_dtree)),se(L),K&&oe(L)},i._tr_tally=function(L,N,Y){return L.pending_buf[L.d_buf+2*L.last_lit]=N>>>8&255,L.pending_buf[L.d_buf+2*L.last_lit+1]=255&N,L.pending_buf[L.l_buf+L.last_lit]=255&Y,L.last_lit++,N===0?L.dyn_ltree[2*Y]++:(L.matches++,N--,L.dyn_ltree[2*(S[Y]+d+1)]++,L.dyn_dtree[2*R(N)]++),L.last_lit===L.lit_bufsize-1},i._tr_align=function(L){ee(L,2,3),q(L,w,O),(function(N){N.bi_valid===16?(te(N,N.bi_buf),N.bi_buf=0,N.bi_valid=0):8<=N.bi_valid&&(N.pending_buf[N.pending++]=255&N.bi_buf,N.bi_buf>>=8,N.bi_valid-=8)})(L)}},{"../utils/common":41}],53:[function(t,n,i){n.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(t,n,i){(function(s){(function(r,a){if(!r.setImmediate){var l,c,h,d,m=1,p={},f=!1,u=r.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(r);g=g&&g.setTimeout?g:r,l={}.toString.call(r.process)==="[object process]"?function(x){process.nextTick(function(){v(x)})}:(function(){if(r.postMessage&&!r.importScripts){var x=!0,M=r.onmessage;return r.onmessage=function(){x=!1},r.postMessage("","*"),r.onmessage=M,x}})()?(d="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",w,!1):r.attachEvent("onmessage",w),function(x){r.postMessage(d+x,"*")}):r.MessageChannel?((h=new MessageChannel).port1.onmessage=function(x){v(x.data)},function(x){h.port2.postMessage(x)}):u&&"onreadystatechange"in u.createElement("script")?(c=u.documentElement,function(x){var M=u.createElement("script");M.onreadystatechange=function(){v(x),M.onreadystatechange=null,c.removeChild(M),M=null},c.appendChild(M)}):function(x){setTimeout(v,0,x)},g.setImmediate=function(x){typeof x!="function"&&(x=new Function(""+x));for(var M=new Array(arguments.length-1),T=0;T<M.length;T++)M[T]=arguments[T+1];var P={callback:x,args:M};return p[m]=P,l(m),m++},g.clearImmediate=y}function y(x){delete p[x]}function v(x){if(f)setTimeout(v,0,x);else{var M=p[x];if(M){f=!0;try{(function(T){var P=T.callback,k=T.args;switch(k.length){case 0:P();break;case 1:P(k[0]);break;case 2:P(k[0],k[1]);break;case 3:P(k[0],k[1],k[2]);break;default:P.apply(a,k)}})(M)}finally{y(x),f=!1}}}}function w(x){x.source===r&&typeof x.data=="string"&&x.data.indexOf(d)===0&&v(+x.data.slice(d.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Rn<"u"?Rn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Li)),Li.exports}var Ca=Sa();const Ys=Xs(Ca);function Ks(o,e){return function(){return o.apply(e,arguments)}}const{toString:Aa}=Object.prototype,{getPrototypeOf:Ii}=Object,{iterator:Fn,toStringTag:qs}=Symbol,Un=(o=>e=>{const t=Aa.call(e);return o[t]||(o[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ye=o=>(o=o.toLowerCase(),e=>Un(e)===o),Vn=o=>e=>typeof e===o,{isArray:Gt}=Array,Wt=Vn("undefined");function sn(o){return o!==null&&!Wt(o)&&o.constructor!==null&&!Wt(o.constructor)&&Ne(o.constructor.isBuffer)&&o.constructor.isBuffer(o)}const $s=Ye("ArrayBuffer");function Pa(o){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(o):e=o&&o.buffer&&$s(o.buffer),e}const Ta=Vn("string"),Ne=Vn("function"),Hs=Vn("number"),rn=o=>o!==null&&typeof o=="object",Da=o=>o===!0||o===!1,jn=o=>{if(Un(o)!=="object")return!1;const e=Ii(o);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(qs in o)&&!(Fn in o)},ka=o=>{if(!rn(o)||sn(o))return!1;try{return Object.keys(o).length===0&&Object.getPrototypeOf(o)===Object.prototype}catch{return!1}},Ea=Ye("Date"),La=Ye("File"),Ia=Ye("Blob"),za=Ye("FileList"),Ba=o=>rn(o)&&Ne(o.pipe),Oa=o=>{let e;return o&&(typeof FormData=="function"&&o instanceof FormData||Ne(o.append)&&((e=Un(o))==="formdata"||e==="object"&&Ne(o.toString)&&o.toString()==="[object FormData]"))},Ra=Ye("URLSearchParams"),[Na,Fa,Ua,Va]=["ReadableStream","Request","Response","Headers"].map(Ye),ja=o=>o.trim?o.trim():o.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function on(o,e,{allOwnKeys:t=!1}={}){if(o===null||typeof o>"u")return;let n,i;if(typeof o!="object"&&(o=[o]),Gt(o))for(n=0,i=o.length;n<i;n++)e.call(null,o[n],n,o);else{if(sn(o))return;const s=t?Object.getOwnPropertyNames(o):Object.keys(o),r=s.length;let a;for(n=0;n<r;n++)a=s[n],e.call(null,o[a],a,o)}}function Js(o,e){if(sn(o))return null;e=e.toLowerCase();const t=Object.keys(o);let n=t.length,i;for(;n-- >0;)if(i=t[n],e===i.toLowerCase())return i;return null}const At=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Qs=o=>!Wt(o)&&o!==At;function zi(){const{caseless:o,skipUndefined:e}=Qs(this)&&this||{},t={},n=(i,s)=>{const r=o&&Js(t,s)||s;jn(t[r])&&jn(i)?t[r]=zi(t[r],i):jn(i)?t[r]=zi({},i):Gt(i)?t[r]=i.slice():(!e||!Wt(i))&&(t[r]=i)};for(let i=0,s=arguments.length;i<s;i++)arguments[i]&&on(arguments[i],n);return t}const Ga=(o,e,t,{allOwnKeys:n}={})=>(on(e,(i,s)=>{t&&Ne(i)?o[s]=Ks(i,t):o[s]=i},{allOwnKeys:n}),o),Wa=o=>(o.charCodeAt(0)===65279&&(o=o.slice(1)),o),Xa=(o,e,t,n)=>{o.prototype=Object.create(e.prototype,n),o.prototype.constructor=o,Object.defineProperty(o,"super",{value:e.prototype}),t&&Object.assign(o.prototype,t)},Za=(o,e,t,n)=>{let i,s,r;const a={};if(e=e||{},o==null)return e;do{for(i=Object.getOwnPropertyNames(o),s=i.length;s-- >0;)r=i[s],(!n||n(r,o,e))&&!a[r]&&(e[r]=o[r],a[r]=!0);o=t!==!1&&Ii(o)}while(o&&(!t||t(o,e))&&o!==Object.prototype);return e},Ya=(o,e,t)=>{o=String(o),(t===void 0||t>o.length)&&(t=o.length),t-=e.length;const n=o.indexOf(e,t);return n!==-1&&n===t},Ka=o=>{if(!o)return null;if(Gt(o))return o;let e=o.length;if(!Hs(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=o[e];return t},qa=(o=>e=>o&&e instanceof o)(typeof Uint8Array<"u"&&Ii(Uint8Array)),$a=(o,e)=>{const n=(o&&o[Fn]).call(o);let i;for(;(i=n.next())&&!i.done;){const s=i.value;e.call(o,s[0],s[1])}},Ha=(o,e)=>{let t;const n=[];for(;(t=o.exec(e))!==null;)n.push(t);return n},Ja=Ye("HTMLFormElement"),Qa=o=>o.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),er=(({hasOwnProperty:o})=>(e,t)=>o.call(e,t))(Object.prototype),el=Ye("RegExp"),tr=(o,e)=>{const t=Object.getOwnPropertyDescriptors(o),n={};on(t,(i,s)=>{let r;(r=e(i,s,o))!==!1&&(n[s]=r||i)}),Object.defineProperties(o,n)},tl=o=>{tr(o,(e,t)=>{if(Ne(o)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=o[t];if(Ne(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},nl=(o,e)=>{const t={},n=i=>{i.forEach(s=>{t[s]=!0})};return Gt(o)?n(o):n(String(o).split(e)),t},il=()=>{},sl=(o,e)=>o!=null&&Number.isFinite(o=+o)?o:e;function rl(o){return!!(o&&Ne(o.append)&&o[qs]==="FormData"&&o[Fn])}const ol=o=>{const e=new Array(10),t=(n,i)=>{if(rn(n)){if(e.indexOf(n)>=0)return;if(sn(n))return n;if(!("toJSON"in n)){e[i]=n;const s=Gt(n)?[]:{};return on(n,(r,a)=>{const l=t(r,i+1);!Wt(l)&&(s[a]=l)}),e[i]=void 0,s}}return n};return t(o,0)},al=Ye("AsyncFunction"),ll=o=>o&&(rn(o)||Ne(o))&&Ne(o.then)&&Ne(o.catch),nr=((o,e)=>o?setImmediate:e?((t,n)=>(At.addEventListener("message",({source:i,data:s})=>{i===At&&s===t&&n.length&&n.shift()()},!1),i=>{n.push(i),At.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Ne(At.postMessage)),cl=typeof queueMicrotask<"u"?queueMicrotask.bind(At):typeof process<"u"&&process.nextTick||nr,W={isArray:Gt,isArrayBuffer:$s,isBuffer:sn,isFormData:Oa,isArrayBufferView:Pa,isString:Ta,isNumber:Hs,isBoolean:Da,isObject:rn,isPlainObject:jn,isEmptyObject:ka,isReadableStream:Na,isRequest:Fa,isResponse:Ua,isHeaders:Va,isUndefined:Wt,isDate:Ea,isFile:La,isBlob:Ia,isRegExp:el,isFunction:Ne,isStream:Ba,isURLSearchParams:Ra,isTypedArray:qa,isFileList:za,forEach:on,merge:zi,extend:Ga,trim:ja,stripBOM:Wa,inherits:Xa,toFlatObject:Za,kindOf:Un,kindOfTest:Ye,endsWith:Ya,toArray:Ka,forEachEntry:$a,matchAll:Ha,isHTMLForm:Ja,hasOwnProperty:er,hasOwnProp:er,reduceDescriptors:tr,freezeMethods:tl,toObjectSet:nl,toCamelCase:Qa,noop:il,toFiniteNumber:sl,findKey:Js,global:At,isContextDefined:Qs,isSpecCompliantForm:rl,toJSONObject:ol,isAsyncFn:al,isThenable:ll,setImmediate:nr,asap:cl,isIterable:o=>o!=null&&Ne(o[Fn])};function re(o,e,t,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=o,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}W.inherits(re,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:W.toJSONObject(this.config),code:this.code,status:this.status}}});const ir=re.prototype,sr={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(o=>{sr[o]={value:o}}),Object.defineProperties(re,sr),Object.defineProperty(ir,"isAxiosError",{value:!0}),re.from=(o,e,t,n,i,s)=>{const r=Object.create(ir);W.toFlatObject(o,r,function(h){return h!==Error.prototype},c=>c!=="isAxiosError");const a=o&&o.message?o.message:"Error",l=e==null&&o?o.code:e;return re.call(r,a,l,t,n,i),o&&r.cause==null&&Object.defineProperty(r,"cause",{value:o,configurable:!0}),r.name=o&&o.name||"Error",s&&Object.assign(r,s),r};const hl=null;function Bi(o){return W.isPlainObject(o)||W.isArray(o)}function rr(o){return W.endsWith(o,"[]")?o.slice(0,-2):o}function or(o,e,t){return o?o.concat(e).map(function(i,s){return i=rr(i),!t&&s?"["+i+"]":i}).join(t?".":""):e}function ul(o){return W.isArray(o)&&!o.some(Bi)}const dl=W.toFlatObject(W,{},null,function(e){return/^is[A-Z]/.test(e)});function Gn(o,e,t){if(!W.isObject(o))throw new TypeError("target must be an object");e=e||new FormData,t=W.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(u,g){return!W.isUndefined(g[u])});const n=t.metaTokens,i=t.visitor||h,s=t.dots,r=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&W.isSpecCompliantForm(e);if(!W.isFunction(i))throw new TypeError("visitor must be a function");function c(f){if(f===null)return"";if(W.isDate(f))return f.toISOString();if(W.isBoolean(f))return f.toString();if(!l&&W.isBlob(f))throw new re("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(f)||W.isTypedArray(f)?l&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function h(f,u,g){let y=f;if(f&&!g&&typeof f=="object"){if(W.endsWith(u,"{}"))u=n?u:u.slice(0,-2),f=JSON.stringify(f);else if(W.isArray(f)&&ul(f)||(W.isFileList(f)||W.endsWith(u,"[]"))&&(y=W.toArray(f)))return u=rr(u),y.forEach(function(w,x){!(W.isUndefined(w)||w===null)&&e.append(r===!0?or([u],x,s):r===null?u:u+"[]",c(w))}),!1}return Bi(f)?!0:(e.append(or(g,u,s),c(f)),!1)}const d=[],m=Object.assign(dl,{defaultVisitor:h,convertValue:c,isVisitable:Bi});function p(f,u){if(!W.isUndefined(f)){if(d.indexOf(f)!==-1)throw Error("Circular reference detected in "+u.join("."));d.push(f),W.forEach(f,function(y,v){(!(W.isUndefined(y)||y===null)&&i.call(e,y,W.isString(v)?v.trim():v,u,m))===!0&&p(y,u?u.concat(v):[v])}),d.pop()}}if(!W.isObject(o))throw new TypeError("data must be an object");return p(o),e}function ar(o){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(o).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function Oi(o,e){this._pairs=[],o&&Gn(o,this,e)}const lr=Oi.prototype;lr.append=function(e,t){this._pairs.push([e,t])},lr.toString=function(e){const t=e?function(n){return e.call(this,n,ar)}:ar;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function fl(o){return encodeURIComponent(o).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function cr(o,e,t){if(!e)return o;const n=t&&t.encode||fl;W.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let s;if(i?s=i(e,t):s=W.isURLSearchParams(e)?e.toString():new Oi(e,t).toString(n),s){const r=o.indexOf("#");r!==-1&&(o=o.slice(0,r)),o+=(o.indexOf("?")===-1?"?":"&")+s}return o}class hr{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){W.forEach(this.handlers,function(n){n!==null&&e(n)})}}const ur={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},pl={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Oi,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ri=typeof window<"u"&&typeof document<"u",Ni=typeof navigator=="object"&&navigator||void 0,ml=Ri&&(!Ni||["ReactNative","NativeScript","NS"].indexOf(Ni.product)<0),gl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",yl=Ri&&window.location.href||"http://localhost",ke={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ri,hasStandardBrowserEnv:ml,hasStandardBrowserWebWorkerEnv:gl,navigator:Ni,origin:yl},Symbol.toStringTag,{value:"Module"})),...pl};function vl(o,e){return Gn(o,new ke.classes.URLSearchParams,{visitor:function(t,n,i,s){return ke.isNode&&W.isBuffer(t)?(this.append(n,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function wl(o){return W.matchAll(/\w+|\[(\w*)]/g,o).map(e=>e[0]==="[]"?"":e[1]||e[0])}function xl(o){const e={},t=Object.keys(o);let n;const i=t.length;let s;for(n=0;n<i;n++)s=t[n],e[s]=o[s];return e}function dr(o){function e(t,n,i,s){let r=t[s++];if(r==="__proto__")return!0;const a=Number.isFinite(+r),l=s>=t.length;return r=!r&&W.isArray(i)?i.length:r,l?(W.hasOwnProp(i,r)?i[r]=[i[r],n]:i[r]=n,!a):((!i[r]||!W.isObject(i[r]))&&(i[r]=[]),e(t,n,i[r],s)&&W.isArray(i[r])&&(i[r]=xl(i[r])),!a)}if(W.isFormData(o)&&W.isFunction(o.entries)){const t={};return W.forEachEntry(o,(n,i)=>{e(wl(n),i,t,0)}),t}return null}function bl(o,e,t){if(W.isString(o))try{return(e||JSON.parse)(o),W.trim(o)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(o)}const an={transitional:ur,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",i=n.indexOf("application/json")>-1,s=W.isObject(e);if(s&&W.isHTMLForm(e)&&(e=new FormData(e)),W.isFormData(e))return i?JSON.stringify(dr(e)):e;if(W.isArrayBuffer(e)||W.isBuffer(e)||W.isStream(e)||W.isFile(e)||W.isBlob(e)||W.isReadableStream(e))return e;if(W.isArrayBufferView(e))return e.buffer;if(W.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return vl(e,this.formSerializer).toString();if((a=W.isFileList(e))||n.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Gn(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return s||i?(t.setContentType("application/json",!1),bl(e)):e}],transformResponse:[function(e){const t=this.transitional||an.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(W.isResponse(e)||W.isReadableStream(e))return e;if(e&&W.isString(e)&&(n&&!this.responseType||i)){const r=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(a){if(r)throw a.name==="SyntaxError"?re.from(a,re.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ke.classes.FormData,Blob:ke.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};W.forEach(["delete","get","head","post","put","patch"],o=>{an.headers[o]={}});const Ml=W.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),_l=o=>{const e={};let t,n,i;return o&&o.split(`
|
|
962
|
-
`).forEach(function(
|
|
963
|
-
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[fr]=this[fr]={accessors:{}}).accessors,i=this.prototype;function s(r){const a=ln(r);n[a]||(Pl(i,r),n[a]=!0)}return W.isArray(e)?e.forEach(s):s(e),this}};Fe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),W.reduceDescriptors(Fe.prototype,({value:o},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>o,set(n){this[t]=n}}}),W.freezeMethods(Fe);function Ui(o,e){const t=this||an,n=e||t,i=Fe.from(n.headers);let s=n.data;return W.forEach(o,function(a){s=a.call(t,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function pr(o){return!!(o&&o.__CANCEL__)}function Xt(o,e,t){re.call(this,o??"canceled",re.ERR_CANCELED,e,t),this.name="CanceledError"}W.inherits(Xt,re,{__CANCEL__:!0});function mr(o,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?o(t):e(new re("Request failed with status code "+t.status,[re.ERR_BAD_REQUEST,re.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Tl(o){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(o);return e&&e[1]||""}function Dl(o,e){o=o||10;const t=new Array(o),n=new Array(o);let i=0,s=0,r;return e=e!==void 0?e:1e3,function(l){const c=Date.now(),h=n[s];r||(r=c),t[i]=l,n[i]=c;let d=s,m=0;for(;d!==i;)m+=t[d++],d=d%o;if(i=(i+1)%o,i===s&&(s=(s+1)%o),c-r<e)return;const p=h&&c-h;return p?Math.round(m*1e3/p):void 0}}function kl(o,e){let t=0,n=1e3/e,i,s;const r=(c,h=Date.now())=>{t=h,i=null,s&&(clearTimeout(s),s=null),o(...c)};return[(...c)=>{const h=Date.now(),d=h-t;d>=n?r(c,h):(i=c,s||(s=setTimeout(()=>{s=null,r(i)},n-d)))},()=>i&&r(i)]}const Xn=(o,e,t=3)=>{let n=0;const i=Dl(50,250);return kl(s=>{const r=s.loaded,a=s.lengthComputable?s.total:void 0,l=r-n,c=i(l),h=r<=a;n=r;const d={loaded:r,total:a,progress:a?r/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&h?(a-r)/c:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};o(d)},t)},gr=(o,e)=>{const t=o!=null;return[n=>e[0]({lengthComputable:t,total:o,loaded:n}),e[1]]},yr=o=>(...e)=>W.asap(()=>o(...e)),El=ke.hasStandardBrowserEnv?((o,e)=>t=>(t=new URL(t,ke.origin),o.protocol===t.protocol&&o.host===t.host&&(e||o.port===t.port)))(new URL(ke.origin),ke.navigator&&/(msie|trident)/i.test(ke.navigator.userAgent)):()=>!0,Ll=ke.hasStandardBrowserEnv?{write(o,e,t,n,i,s,r){if(typeof document>"u")return;const a=[`${o}=${encodeURIComponent(e)}`];W.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),W.isString(n)&&a.push(`path=${n}`),W.isString(i)&&a.push(`domain=${i}`),s===!0&&a.push("secure"),W.isString(r)&&a.push(`SameSite=${r}`),document.cookie=a.join("; ")},read(o){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+o+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(o){this.write(o,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Il(o){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(o)}function zl(o,e){return e?o.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):o}function vr(o,e,t){let n=!Il(e);return o&&(n||t==!1)?zl(o,e):e}const wr=o=>o instanceof Fe?{...o}:o;function Pt(o,e){e=e||{};const t={};function n(c,h,d,m){return W.isPlainObject(c)&&W.isPlainObject(h)?W.merge.call({caseless:m},c,h):W.isPlainObject(h)?W.merge({},h):W.isArray(h)?h.slice():h}function i(c,h,d,m){if(W.isUndefined(h)){if(!W.isUndefined(c))return n(void 0,c,d,m)}else return n(c,h,d,m)}function s(c,h){if(!W.isUndefined(h))return n(void 0,h)}function r(c,h){if(W.isUndefined(h)){if(!W.isUndefined(c))return n(void 0,c)}else return n(void 0,h)}function a(c,h,d){if(d in e)return n(c,h);if(d in o)return n(void 0,c)}const l={url:s,method:s,data:s,baseURL:r,transformRequest:r,transformResponse:r,paramsSerializer:r,timeout:r,timeoutMessage:r,withCredentials:r,withXSRFToken:r,adapter:r,responseType:r,xsrfCookieName:r,xsrfHeaderName:r,onUploadProgress:r,onDownloadProgress:r,decompress:r,maxContentLength:r,maxBodyLength:r,beforeRedirect:r,transport:r,httpAgent:r,httpsAgent:r,cancelToken:r,socketPath:r,responseEncoding:r,validateStatus:a,headers:(c,h,d)=>i(wr(c),wr(h),d,!0)};return W.forEach(Object.keys({...o,...e}),function(h){const d=l[h]||i,m=d(o[h],e[h],h);W.isUndefined(m)&&d!==a||(t[h]=m)}),t}const xr=o=>{const e=Pt({},o);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:r,auth:a}=e;if(e.headers=r=Fe.from(r),e.url=cr(vr(e.baseURL,e.url,e.allowAbsoluteUrls),o.params,o.paramsSerializer),a&&r.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),W.isFormData(t)){if(ke.hasStandardBrowserEnv||ke.hasStandardBrowserWebWorkerEnv)r.setContentType(void 0);else if(W.isFunction(t.getHeaders)){const l=t.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([h,d])=>{c.includes(h.toLowerCase())&&r.set(h,d)})}}if(ke.hasStandardBrowserEnv&&(n&&W.isFunction(n)&&(n=n(e)),n||n!==!1&&El(e.url))){const l=i&&s&&Ll.read(s);l&&r.set(i,l)}return e},Bl=typeof XMLHttpRequest<"u"&&function(o){return new Promise(function(t,n){const i=xr(o);let s=i.data;const r=Fe.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=i,h,d,m,p,f;function u(){p&&p(),f&&f(),i.cancelToken&&i.cancelToken.unsubscribe(h),i.signal&&i.signal.removeEventListener("abort",h)}let g=new XMLHttpRequest;g.open(i.method.toUpperCase(),i.url,!0),g.timeout=i.timeout;function y(){if(!g)return;const w=Fe.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),M={data:!a||a==="text"||a==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:w,config:o,request:g};mr(function(P){t(P),u()},function(P){n(P),u()},M),g=null}"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(y)},g.onabort=function(){g&&(n(new re("Request aborted",re.ECONNABORTED,o,g)),g=null)},g.onerror=function(x){const M=x&&x.message?x.message:"Network Error",T=new re(M,re.ERR_NETWORK,o,g);T.event=x||null,n(T),g=null},g.ontimeout=function(){let x=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const M=i.transitional||ur;i.timeoutErrorMessage&&(x=i.timeoutErrorMessage),n(new re(x,M.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,o,g)),g=null},s===void 0&&r.setContentType(null),"setRequestHeader"in g&&W.forEach(r.toJSON(),function(x,M){g.setRequestHeader(M,x)}),W.isUndefined(i.withCredentials)||(g.withCredentials=!!i.withCredentials),a&&a!=="json"&&(g.responseType=i.responseType),c&&([m,f]=Xn(c,!0),g.addEventListener("progress",m)),l&&g.upload&&([d,p]=Xn(l),g.upload.addEventListener("progress",d),g.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(h=w=>{g&&(n(!w||w.type?new Xt(null,o,g):w),g.abort(),g=null)},i.cancelToken&&i.cancelToken.subscribe(h),i.signal&&(i.signal.aborted?h():i.signal.addEventListener("abort",h)));const v=Tl(i.url);if(v&&ke.protocols.indexOf(v)===-1){n(new re("Unsupported protocol "+v+":",re.ERR_BAD_REQUEST,o));return}g.send(s||null)})},Ol=(o,e)=>{const{length:t}=o=o?o.filter(Boolean):[];if(e||t){let n=new AbortController,i;const s=function(c){if(!i){i=!0,a();const h=c instanceof Error?c:this.reason;n.abort(h instanceof re?h:new Xt(h instanceof Error?h.message:h))}};let r=e&&setTimeout(()=>{r=null,s(new re(`timeout ${e} of ms exceeded`,re.ETIMEDOUT))},e);const a=()=>{o&&(r&&clearTimeout(r),r=null,o.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),o=null)};o.forEach(c=>c.addEventListener("abort",s));const{signal:l}=n;return l.unsubscribe=()=>W.asap(a),l}},Rl=function*(o,e){let t=o.byteLength;if(t<e){yield o;return}let n=0,i;for(;n<t;)i=n+e,yield o.slice(n,i),n=i},Nl=async function*(o,e){for await(const t of Fl(o))yield*Rl(t,e)},Fl=async function*(o){if(o[Symbol.asyncIterator]){yield*o;return}const e=o.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},br=(o,e,t,n)=>{const i=Nl(o,e);let s=0,r,a=l=>{r||(r=!0,n&&n(l))};return new ReadableStream({async pull(l){try{const{done:c,value:h}=await i.next();if(c){a(),l.close();return}let d=h.byteLength;if(t){let m=s+=d;t(m)}l.enqueue(new Uint8Array(h))}catch(c){throw a(c),c}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},Mr=64*1024,{isFunction:Zn}=W,Ul=(({Request:o,Response:e})=>({Request:o,Response:e}))(W.global),{ReadableStream:_r,TextEncoder:Sr}=W.global,Cr=(o,...e)=>{try{return!!o(...e)}catch{return!1}},Vl=o=>{o=W.merge.call({skipUndefined:!0},Ul,o);const{fetch:e,Request:t,Response:n}=o,i=e?Zn(e):typeof fetch=="function",s=Zn(t),r=Zn(n);if(!i)return!1;const a=i&&Zn(_r),l=i&&(typeof Sr=="function"?(f=>u=>f.encode(u))(new Sr):async f=>new Uint8Array(await new t(f).arrayBuffer())),c=s&&a&&Cr(()=>{let f=!1;const u=new t(ke.origin,{body:new _r,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!u}),h=r&&a&&Cr(()=>W.isReadableStream(new n("").body)),d={stream:h&&(f=>f.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!d[f]&&(d[f]=(u,g)=>{let y=u&&u[f];if(y)return y.call(u);throw new re(`Response type '${f}' is not supported`,re.ERR_NOT_SUPPORT,g)})});const m=async f=>{if(f==null)return 0;if(W.isBlob(f))return f.size;if(W.isSpecCompliantForm(f))return(await new t(ke.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(W.isArrayBufferView(f)||W.isArrayBuffer(f))return f.byteLength;if(W.isURLSearchParams(f)&&(f=f+""),W.isString(f))return(await l(f)).byteLength},p=async(f,u)=>{const g=W.toFiniteNumber(f.getContentLength());return g??m(u)};return async f=>{let{url:u,method:g,data:y,signal:v,cancelToken:w,timeout:x,onDownloadProgress:M,onUploadProgress:T,responseType:P,headers:k,withCredentials:D="same-origin",fetchOptions:E}=xr(f),O=e||fetch;P=P?(P+"").toLowerCase():"text";let A=Ol([v,w&&w.toAbortSignal()],x),I=null;const S=A&&A.unsubscribe&&(()=>{A.unsubscribe()});let z;try{if(T&&c&&g!=="get"&&g!=="head"&&(z=await p(k,y))!==0){let F=new t(u,{method:"POST",body:y,duplex:"half"}),R;if(W.isFormData(y)&&(R=F.headers.get("content-type"))&&k.setContentType(R),F.body){const[te,ee]=gr(z,Xn(yr(T)));y=br(F.body,Mr,te,ee)}}W.isString(D)||(D=D?"include":"omit");const V=s&&"credentials"in t.prototype,U={...E,signal:A,method:g.toUpperCase(),headers:k.normalize().toJSON(),body:y,duplex:"half",credentials:V?D:void 0};I=s&&new t(u,U);let H=await(s?O(I,E):O(u,U));const G=h&&(P==="stream"||P==="response");if(h&&(M||G&&S)){const F={};["status","statusText","headers"].forEach(q=>{F[q]=H[q]});const R=W.toFiniteNumber(H.headers.get("content-length")),[te,ee]=M&&gr(R,Xn(yr(M),!0))||[];H=new n(br(H.body,Mr,te,()=>{ee&&ee(),S&&S()}),F)}P=P||"text";let $=await d[W.findKey(d,P)||"text"](H,f);return!G&&S&&S(),await new Promise((F,R)=>{mr(F,R,{data:$,headers:Fe.from(H.headers),status:H.status,statusText:H.statusText,config:f,request:I})})}catch(V){throw S&&S(),V&&V.name==="TypeError"&&/Load failed|fetch/i.test(V.message)?Object.assign(new re("Network Error",re.ERR_NETWORK,f,I),{cause:V.cause||V}):re.from(V,V&&V.code,f,I)}}},jl=new Map,Ar=o=>{let e=o&&o.env||{};const{fetch:t,Request:n,Response:i}=e,s=[n,i,t];let r=s.length,a=r,l,c,h=jl;for(;a--;)l=s[a],c=h.get(l),c===void 0&&h.set(l,c=a?new Map:Vl(e)),h=c;return c};Ar();const Vi={http:hl,xhr:Bl,fetch:{get:Ar}};W.forEach(Vi,(o,e)=>{if(o){try{Object.defineProperty(o,"name",{value:e})}catch{}Object.defineProperty(o,"adapterName",{value:e})}});const Pr=o=>`- ${o}`,Gl=o=>W.isFunction(o)||o===null||o===!1;function Wl(o,e){o=W.isArray(o)?o:[o];const{length:t}=o;let n,i;const s={};for(let r=0;r<t;r++){n=o[r];let a;if(i=n,!Gl(n)&&(i=Vi[(a=String(n)).toLowerCase()],i===void 0))throw new re(`Unknown adapter '${a}'`);if(i&&(W.isFunction(i)||(i=i.get(e))))break;s[a||"#"+r]=i}if(!i){const r=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=t?r.length>1?`since :
|
|
964
|
-
`+
|
|
965
|
-
`):" "+
|
|
966
|
-
`+s):n.stack=s}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Pt(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:s}=t;n!==void 0&&Kn.assertOptions(n,{silentJSONParsing:Je.transitional(Je.boolean),forcedJSONParsing:Je.transitional(Je.boolean),clarifyTimeoutError:Je.transitional(Je.boolean)},!1),i!=null&&(W.isFunction(i)?t.paramsSerializer={serialize:i}:Kn.assertOptions(i,{encode:Je.function,serialize:Je.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Kn.assertOptions(t,{baseUrl:Je.spelling("baseURL"),withXsrfToken:Je.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=s&&W.merge(s.common,s[t.method]);s&&W.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),t.headers=Fe.concat(r,s);const a=[];let l=!0;this.interceptors.request.forEach(function(u){typeof u.runWhen=="function"&&u.runWhen(t)===!1||(l=l&&u.synchronous,a.unshift(u.fulfilled,u.rejected))});const c=[];this.interceptors.response.forEach(function(u){c.push(u.fulfilled,u.rejected)});let h,d=0,m;if(!l){const f=[Dr.bind(this),void 0];for(f.unshift(...a),f.push(...c),m=f.length,h=Promise.resolve(t);d<m;)h=h.then(f[d++],f[d++]);return h}m=a.length;let p=t;for(;d<m;){const f=a[d++],u=a[d++];try{p=f(p)}catch(g){u.call(this,g);break}}try{h=Dr.call(this,p)}catch(f){return Promise.reject(f)}for(d=0,m=c.length;d<m;)h=h.then(c[d++],c[d++]);return h}getUri(e){e=Pt(this.defaults,e);const t=vr(e.baseURL,e.url,e.allowAbsoluteUrls);return cr(t,e.params,e.paramsSerializer)}};W.forEach(["delete","get","head","options"],function(e){Tt.prototype[e]=function(t,n){return this.request(Pt(n||{},{method:e,url:t,data:(n||{}).data}))}}),W.forEach(["post","put","patch"],function(e){function t(n){return function(s,r,a){return this.request(Pt(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:r}))}}Tt.prototype[e]=t(),Tt.prototype[e+"Form"]=t(!0)});let Zl=class Wo{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const r=new Promise(a=>{n.subscribe(a),s=a}).then(i);return r.cancel=function(){n.unsubscribe(s)},r},e(function(s,r,a){n.reason||(n.reason=new Xt(s,r,a),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new Wo(function(i){e=i}),cancel:e}}};function Yl(o){return function(t){return o.apply(null,t)}}function Kl(o){return W.isObject(o)&&o.isAxiosError===!0}const Gi={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Gi).forEach(([o,e])=>{Gi[e]=o});function Lr(o){const e=new Tt(o),t=Ks(Tt.prototype.request,e);return W.extend(t,Tt.prototype,e,{allOwnKeys:!0}),W.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return Lr(Pt(o,i))},t}const ye=Lr(an);ye.Axios=Tt,ye.CanceledError=Xt,ye.CancelToken=Zl,ye.isCancel=pr,ye.VERSION=kr,ye.toFormData=Gn,ye.AxiosError=re,ye.Cancel=ye.CanceledError,ye.all=function(e){return Promise.all(e)},ye.spread=Yl,ye.isAxiosError=Kl,ye.mergeConfig=Pt,ye.AxiosHeaders=Fe,ye.formToJSON=o=>dr(W.isHTMLForm(o)?new FormData(o):o),ye.getAdapter=Tr.getAdapter,ye.HttpStatusCode=Gi,ye.default=ye;const{Axios:Lf,AxiosError:If,CanceledError:zf,isCancel:Bf,CancelToken:Of,VERSION:Rf,all:Nf,Cancel:Ff,isAxiosError:Uf,spread:Vf,toFormData:jf,AxiosHeaders:Gf,HttpStatusCode:Wf,formToJSON:Xf,getAdapter:Zf,mergeConfig:Yf}=ye;function Ir(o,e){var t;if(window.XMLHttpRequest?t=new XMLHttpRequest:window.ActiveXObject?t=new window.ActiveXObject:alert("请升级至最新版本的浏览器"),t!=null){let n=o;t.open("GET",n,!0),t.send(null),t.onreadystatechange=function(){t.readyState==4&&t.status==200&&(t.responseText.includes("</html>",0)&&t.responseText.includes("</body>",0)&&t.responseText.includes("</head>",0)?e(null):e(t.responseText))},t.onloadend=function(){t.readyState==4&&t.status==404&&t.status==502&&e(null)}}}function ql(o,e){ye({method:"get",responseType:"blob",url:o}).then(t=>{let n=new window.File([t.data],"zipFolder",{type:"zip"});Ys.loadAsync(n).then(i=>{const s=new Map,r=[];for(let a in i.files){if(i.files[a].dir)continue;const l=i.file(i.files[a].name);if(l){const c=l.async("blob").then(h=>{const d=URL.createObjectURL(h);s.set("/"+i.files[a].name.replace("\\","/"),d)});r.push(c)}}Promise.all(r).then(()=>{e(s)}).catch(a=>{console.error("解压zip文件失败:",a),e(new Map)})}).catch(i=>{console.error("加载zip文件失败:",i),e(new Map)})}).catch(t=>{console.error("下载zip文件失败:",t),e(new Map)})}function Wi(o,e){ye({method:"get",responseType:"blob",url:o}).then(n=>{let i=new window.File([n.data],"semantics",{type:"zip"});Ys.loadAsync(i).then(s=>{for(let r in s.files)s.file(s.files[r].name).async("blob").then(l=>{t(l,"utf-8",function(c,h){e(h)})})})});function t(n,i,s){var r=new FileReader,a=new Blob([n]);r.onload=function(l){s(null,l.target.result)},r.onerror=function(l){s(l.error,null)},r.readAsText(a,i)}}const Xi=new WeakMap;class $l extends _.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const s=new _.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,r=>{this.parse(r,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,_.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,i,s=_.LinearSRGBColorSpace,r=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,a).then(t).catch(r)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Xi.has(e)){const l=Xi.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,r=e.byteLength,a=this._getWorker(s,r).then(l=>(i=l,new Promise((c,h)=>{i._callbacks[s]={resolve:c,reject:h},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Xi.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new _.BufferGeometry;e.index&&t.setIndex(new _.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:s,itemSize:r,stride:a,vertexColorSpace:l}=e.attributes[n];let c;if(r===a)c=new _.BufferAttribute(s,r);else{const h=new _.InterleavedBuffer(s,a);c=new _.InterleavedBufferAttribute(h,r,0)}i==="color"&&(this._assignVertexColorSpace(c,l),c.normalized=!(s instanceof Float32Array)),t.setAttribute(i,c)}return t}_assignVertexColorSpace(e,t){if(t!==_.SRGBColorSpace)return;const n=new _.Color;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i),_.ColorManagement.colorSpaceToWorking(n,_.SRGBColorSpace),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new _.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,s)=>{n.load(e,i,void 0,s)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e=typeof WebAssembly!="object"||this.decoderConfig.type==="js",t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then(n=>{const i=n[0];e||(this.decoderConfig.wasmBinary=n[1]);const s=Hl.toString(),r=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
967
|
-
`);this.workerSourceURL=URL.createObjectURL(new Blob([r]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){const r=s.data;switch(r.type){case"decode":i._callbacks[r.id].resolve(r);break;case"error":i._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function Hl(){let o,e;onmessage=function(r){const a=r.data;switch(a.type){case"init":o=a.decoderConfig,e=new Promise(function(h){o.onModuleLoaded=function(d){h({draco:d})},DracoDecoderModule(o)});break;case"decode":const l=a.buffer,c=a.taskConfig;e.then(h=>{const d=h.draco,m=new d.Decoder;try{const p=t(d,m,new Int8Array(l),c),f=p.attributes.map(u=>u.array.buffer);p.index&&f.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},f)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{d.destroy(m)}});break}};function t(r,a,l,c){const h=c.attributeIDs,d=c.attributeTypes;let m,p;const f=a.GetEncodedGeometryType(l);if(f===r.TRIANGULAR_MESH)m=new r.Mesh,p=a.DecodeArrayToMesh(l,l.byteLength,m);else if(f===r.POINT_CLOUD)m=new r.PointCloud,p=a.DecodeArrayToPointCloud(l,l.byteLength,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const u={index:null,attributes:[]};for(const g in h){const y=self[d[g]];let v,w;if(c.useUniqueIDs)w=h[g],v=a.GetAttributeByUniqueId(m,w);else{if(w=a.GetAttributeId(m,r[h[g]]),w===-1)continue;v=a.GetAttribute(m,w)}const x=i(r,a,m,g,y,v);g==="color"&&(x.vertexColorSpace=c.vertexColorSpace),u.attributes.push(x)}return f===r.TRIANGULAR_MESH&&(u.index=n(r,a,m)),r.destroy(m),u}function n(r,a,l){const h=l.num_faces()*3,d=h*4,m=r._malloc(d);a.GetTrianglesUInt32Array(l,d,m);const p=new Uint32Array(r.HEAPF32.buffer,m,h).slice();return r._free(m),{array:p,itemSize:1}}function i(r,a,l,c,h,d){const m=l.num_points(),p=d.num_components(),f=s(r,h),u=p*h.BYTES_PER_ELEMENT,g=Math.ceil(u/4)*4,y=g/h.BYTES_PER_ELEMENT,v=m*u,w=m*g,x=r._malloc(v);a.GetAttributeDataArrayForAllPoints(l,d,f,v,x);const M=new h(r.HEAPF32.buffer,x,v/h.BYTES_PER_ELEMENT);let T;if(u===g)T=M.slice();else{T=new h(w/h.BYTES_PER_ELEMENT);let P=0;for(let k=0,D=M.length;k<D;k++){for(let E=0;E<p;E++)T[P+E]=M[k*p+E];P+=y}}return r._free(x),{name:c,count:m,itemSize:p,array:T,stride:y}}function s(r,a){switch(a){case Float32Array:return r.DT_FLOAT32;case Int8Array:return r.DT_INT8;case Int16Array:return r.DT_INT16;case Int32Array:return r.DT_INT32;case Uint8Array:return r.DT_UINT8;case Uint16Array:return r.DT_UINT16;case Uint32Array:return r.DT_UINT32}}}var ft=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoadProgress="model-load-progress",o.ModelLoaded="model-loaded",o.ModelError="model-error",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.Click="click",o.MouseMove="mouse-move",o.CameraChanged="camera-changed",o.CameraIdle="camera-idle",o.ViewportResize="viewport-resize",o.EngineFree="engine-free",o.EngineBusy="engine-busy",o.MeasureChanged="measure-changed",o.SectionMove="section-move",o))(ft||{});function Jl(o,e,t,n){let i=0,s=0,r=0,a=o.models.find(p=>p.url==t),l=e.circularMeps,c=e.rectMeps?.filter(p=>p.type==="风管"),h=e.rectMeps?.filter(p=>p.type==="桥架"),d=e.ellipseMeps,m=o.scene;if(new b.MeshBasicMaterial,new b.BufferGeometry,l&&l.length){let p=[],f=0;for(let u of l)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new b.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);qn("Circle",m,p,t)}if(c&&c.length){let p=[],f=0;for(let u of c)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new b.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);qn("Rect",m,p,t)}if(d&&d.length){let p=[],f=0;for(let u of d)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new b.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);qn("Ellipse",m,p,t)}if(h&&h.length){let p=[],f=0;for(let u of h)u.color=u.color.split(",").map(g=>parseInt(g)/255),u.color=new b.Color(u.color[0],u.color[1],u.color[2]),u.position={x:u.startPoint.X*.3048+i,y:u.startPoint.Z*.3048+s,z:-u.startPoint.Y*.3048+r},u.rotation={x:0,y:0,z:0},u.indexes=[[o.scene.children.length,f++,0,0]],a.nodesMap.set(Number(u.id),u),p.push(u);qn("Bridge",m,p,t)}}function qn(o,e,t,n,i){let s,r,a={width:1,height:1,length:1,diameter:1,color:new b.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(o){case"Rect":r=$n("Rect",a);break;case"Bridge":r=$n("Bridge",a);break;case"Circle":r=$n("Circle",a);break;case"Ellipse":r=$n("Ellipse",a);break}r&&(s=new b.InstancedMesh(r.geometry,r.material,t.length),s.url=n,e.add(s));let l=[],c=[];for(var h=0;h<t.length;h++){let p=t[h],f=new b.Vector3(p.startPoint.X,0,-p.startPoint.Y),u=new b.Vector3(p.endPoint.X,0,-p.endPoint.Y),g=new b.Vector3(p.startPoint.X,p.startPoint.Z,-p.startPoint.Y),y=new b.Vector3(p.endPoint.X,p.endPoint.Z,-p.endPoint.Y),v=0,w=0,x=0;if(Math.abs(u.clone().sub(f.clone()).z)<.01&&Math.abs(u.clone().sub(f.clone()).x)<.01){if(v=(p.startPoint.Z>p.endPoint.Z?1:-1)*Math.PI*.5,p.base_x!=null){var d=new b.Vector3(p.base_x.X,0,-p.base_x.Y);w=(d.clone().cross(new b.Vector3(0,0,1)).y<=0?1:-1)*d.angleTo(new b.Vector3(0,0,1))+Math.PI*.5}}else w=(u.clone().sub(f.clone()).cross(new b.Vector3(0,0,1)).y>0?-1:1)*u.clone().sub(f.clone()).angleTo(new b.Vector3(0,0,1)),v=(p.startPoint.Z>p.endPoint.Z?1:-1)*u.clone().sub(f.clone()).angleTo(y.clone().sub(g.clone()));let M=new b.Matrix4;const T=new b.Euler(v,w,x,"YXZ");let P=M.clone().makeRotationFromEuler(T),k,D;o==="Circle"?(k=p.diameter,D=p.diameter):(k=p.width,D=p.height);let E=M.clone().makeScale(k,D,p.length);M.multiplyMatrices(P,E),M.setPosition(p.position.x,p.position.y,p.position.z),s.setMatrixAt(h,M.clone()),s.setColorAt(h,p.color),s.geometry.computeBoundingBox();let O=s.geometry.boundingBox.min.clone().applyMatrix4(M.clone()),A=s.geometry.boundingBox.max.clone().applyMatrix4(M.clone()),I=new b.Vector3(Math.min(O.x,A.x),Math.min(O.y,A.y),Math.min(O.z,A.z)),S=new b.Vector3(Math.max(O.x,A.x),Math.max(O.y,A.y),Math.max(O.z,A.z)),z=I.clone().add(S.clone()).multiplyScalar(.5),V={name:p.name,min:I,max:S,center:z,dbid:h,materialName:r.material.name},U=null,H=null;o==="Circle"&&(U={x:p.startPoint.X*.3048,y:p.startPoint.Z*.3048,z:-p.startPoint.Y*.3048},H={x:p.endPoint.X*.3048,y:p.endPoint.Z*.3048,z:-p.endPoint.Y*.3048},V.minC=U,V.maxC=H),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(M.clone()),c.push(M.clone()),s.ids.push(Number(p.id)),l.push(V)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=o,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone(),s.matrixsClone=c;let m=[];m={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=m,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function $n(o,e,t){let n=new b.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,o){case"Rect":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Bridge":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(-e.width/2+.01,e.height/2),n.lineTo(-e.width/2+.01,-e.height/2+.01),n.lineTo(e.width/2-.01,-e.height/2+.01),n.lineTo(e.width/2-.01,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Circle":n.moveTo(0,0),n.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const i={depth:e.length*.3048,bevelEnabled:!1};return s(n,i,e.color,e.position,e.rotation);function s(r,a,l,c,h){let d=new b.ExtrudeGeometry(r,a),m=new b.MeshStandardMaterial({color:l,side:b.DoubleSide}),p=new b.Mesh(d,m);return p.position.set(c.x,c.y,c.z),p.rotation._order="YXZ",p.rotation.set(h.x,h.y,h.z),p}}function cn(o,e=!1){const t=o[0].index!==null,n=new Set(Object.keys(o[0].attributes)),i=new Set(Object.keys(o[0].morphAttributes)),s={},r={},a=o[0].morphTargetsRelative,l=new _.BufferGeometry;let c=0;for(let h=0;h<o.length;++h){const d=o[h];let m=0;if(t!==(d.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in d.attributes){if(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(d.attributes[p]),m++}if(m!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in d.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;r[p]===void 0&&(r[p]=[]),r[p].push(d.morphAttributes[p])}if(e){let p;if(t)p=d.index.count;else if(d.attributes.position!==void 0)p=d.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,p,h),c+=p}}if(t){let h=0;const d=[];for(let m=0;m<o.length;++m){const p=o[m].index;for(let f=0;f<p.count;++f)d.push(p.getX(f)+h);h+=o[m].attributes.position.count}l.setIndex(d)}for(const h in s){const d=zr(s[h]);if(!d)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,d)}for(const h in r){const d=r[h][0].length;if(d===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let m=0;m<d;++m){const p=[];for(let u=0;u<r[h].length;++u)p.push(r[h][u][m]);const f=zr(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(f)}}return l}function zr(o){let e,t,n,i=-1,s=0;for(let c=0;c<o.length;++c){const h=o[c];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*t}const r=new e(s),a=new _.BufferAttribute(r,t,n);let l=0;for(let c=0;c<o.length;++c){const h=o[c];if(h.isInterleavedBufferAttribute){const d=l/t;for(let m=0,p=h.count;m<p;m++)for(let f=0;f<t;f++){const u=h.getComponent(m,f);a.setComponent(m+d,f,u)}}else r.set(h.array,l);l+=h.count*t}return i!==void 0&&(a.gpuType=i),a}function Br(o,e){if(e===_.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),o;if(e===_.TriangleFanDrawMode||e===_.TriangleStripDrawMode){let t=o.getIndex();if(t===null){const r=[],a=o.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)r.push(l);o.setIndex(r),t=o.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),o}const n=t.count-2,i=[];if(e===_.TriangleFanDrawMode)for(let r=1;r<=n;r++)i.push(t.getX(0)),i.push(t.getX(r)),i.push(t.getX(r+1));else for(let r=0;r<n;r++)r%2===0?(i.push(t.getX(r)),i.push(t.getX(r+1)),i.push(t.getX(r+2))):(i.push(t.getX(r+2)),i.push(t.getX(r+1)),i.push(t.getX(r)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=o.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),o}class Ql extends _.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new sc(t)}),this.register(function(t){return new rc(t)}),this.register(function(t){return new pc(t)}),this.register(function(t){return new mc(t)}),this.register(function(t){return new gc(t)}),this.register(function(t){return new ac(t)}),this.register(function(t){return new lc(t)}),this.register(function(t){return new cc(t)}),this.register(function(t){return new hc(t)}),this.register(function(t){return new ic(t)}),this.register(function(t){return new uc(t)}),this.register(function(t){return new oc(t)}),this.register(function(t){return new fc(t)}),this.register(function(t){return new dc(t)}),this.register(function(t){return new tc(t)}),this.register(function(t){return new yc(t)}),this.register(function(t){return new vc(t)})}load(e,t,n,i){const s=this;let r;if(this.resourcePath!=="")r=this.resourcePath;else if(this.path!==""){const c=_.LoaderUtils.extractUrlBase(e);r=_.LoaderUtils.resolveURL(c,this.path)}else r=_.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){i?i(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new _.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,r,function(h){t(h),s.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let s;const r={},a={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Or){try{r[le.KHR_BINARY_GLTF]=new wc(e)}catch(d){i&&i(d);return}s=JSON.parse(r[le.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new Lc(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const d=this.pluginCallbacks[h](c);d.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[d.name]=d,r[d.name]=!0}if(s.extensionsUsed)for(let h=0;h<s.extensionsUsed.length;++h){const d=s.extensionsUsed[h],m=s.extensionsRequired||[];switch(d){case le.KHR_MATERIALS_UNLIT:r[d]=new nc;break;case le.KHR_DRACO_MESH_COMPRESSION:r[d]=new xc(s,this.dracoLoader);break;case le.KHR_TEXTURE_TRANSFORM:r[d]=new bc;break;case le.KHR_MESH_QUANTIZATION:r[d]=new Mc;break;default:m.indexOf(d)>=0&&a[d]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+d+'".')}}c.setExtensions(r),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function ec(){let o={};return{get:function(e){return o[e]},add:function(e,t){o[e]=t},remove:function(e){delete o[e]},removeAll:function(){o={}}}}const le={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class tc{constructor(e){this.parser=e,this.name=le.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let c;const h=new _.Color(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],_.LinearSRGBColorSpace);const d=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new _.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new _.PointLight(h),c.distance=d;break;case"spot":c=new _.SpotLight(h),c.distance=d,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),Qe(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class nc{constructor(){this.name=le.KHR_MATERIALS_UNLIT}getMaterialType(){return _.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new _.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const r=s.baseColorFactor;e.color.setRGB(r[0],r[1],r[2],_.LinearSRGBColorSpace),e.opacity=r[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,_.SRGBColorSpace))}return Promise.all(i)}}class ic{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name].emissiveStrength;return s!==void 0&&(t.emissiveIntensity=s),Promise.resolve()}}class sc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];if(r.clearcoatFactor!==void 0&&(t.clearcoat=r.clearcoatFactor),r.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",r.clearcoatTexture)),r.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=r.clearcoatRoughnessFactor),r.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",r.clearcoatRoughnessTexture)),r.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",r.clearcoatNormalTexture)),r.clearcoatNormalTexture.scale!==void 0)){const a=r.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new _.Vector2(a,a)}return Promise.all(s)}}class rc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.dispersion=s.dispersion!==void 0?s.dispersion:0,Promise.resolve()}}class oc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return r.iridescenceFactor!==void 0&&(t.iridescence=r.iridescenceFactor),r.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",r.iridescenceTexture)),r.iridescenceIor!==void 0&&(t.iridescenceIOR=r.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),r.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=r.iridescenceThicknessMinimum),r.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=r.iridescenceThicknessMaximum),r.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",r.iridescenceThicknessTexture)),Promise.all(s)}}class ac{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new _.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const r=i.extensions[this.name];if(r.sheenColorFactor!==void 0){const a=r.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace)}return r.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=r.sheenRoughnessFactor),r.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",r.sheenColorTexture,_.SRGBColorSpace)),r.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",r.sheenRoughnessTexture)),Promise.all(s)}}class lc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return r.transmissionFactor!==void 0&&(t.transmission=r.transmissionFactor),r.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",r.transmissionTexture)),Promise.all(s)}}class cc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];t.thickness=r.thicknessFactor!==void 0?r.thicknessFactor:0,r.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",r.thicknessTexture)),t.attenuationDistance=r.attenuationDistance||1/0;const a=r.attenuationColor||[1,1,1];return t.attenuationColor=new _.Color().setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace),Promise.all(s)}}class hc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=i.extensions[this.name];return t.ior=s.ior!==void 0?s.ior:1.5,Promise.resolve()}}class uc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];t.specularIntensity=r.specularFactor!==void 0?r.specularFactor:1,r.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",r.specularTexture));const a=r.specularColorFactor||[1,1,1];return t.specularColor=new _.Color().setRGB(a[0],a[1],a[2],_.LinearSRGBColorSpace),r.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",r.specularColorTexture,_.SRGBColorSpace)),Promise.all(s)}}class dc{constructor(e){this.parser=e,this.name=le.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return t.bumpScale=r.bumpFactor!==void 0?r.bumpFactor:1,r.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",r.bumpTexture)),Promise.all(s)}}class fc{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:_.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],r=i.extensions[this.name];return r.anisotropyStrength!==void 0&&(t.anisotropy=r.anisotropyStrength),r.anisotropyRotation!==void 0&&(t.anisotropyRotation=r.anisotropyRotation),r.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",r.anisotropyTexture)),Promise.all(s)}}class pc{constructor(e){this.parser=e,this.name=le.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],r=t.options.ktx2Loader;if(!r){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,r)}}class mc{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const r=s.extensions[t],a=i.images[r.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,r.source,l)}}class gc{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const r=s.extensions[t],a=i.images[r.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,r.source,l)}}class yc{constructor(e){this.name=le.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),r=this.parser.options.meshoptDecoder;if(!r||!r.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,h=i.count,d=i.byteStride,m=new Uint8Array(a,l,c);return r.decodeGltfBufferAsync?r.decodeGltfBufferAsync(h,d,m,i.mode,i.filter).then(function(p){return p.buffer}):r.ready.then(function(){const p=new ArrayBuffer(h*d);return r.decodeGltfBuffer(new Uint8Array(p),h,d,m,i.mode,i.filter),p})})}else return null}}class vc{constructor(e){this.name=le.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==Ve.TRIANGLES&&c.mode!==Ve.TRIANGLE_STRIP&&c.mode!==Ve.TRIANGLE_FAN&&c.mode!==void 0)return null;const r=n.extensions[this.name].attributes,a=[],l={};for(const c in r)a.push(this.parser.getDependency("accessor",r[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const h=c.pop(),d=h.isGroup?h.children:[h],m=c[0].count,p=[];for(const f of d){const u=new _.Matrix4,g=new _.Vector3,y=new _.Quaternion,v=new _.Vector3(1,1,1),w=new _.InstancedMesh(f.geometry,f.material,m);for(let x=0;x<m;x++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,x),l.ROTATION&&y.fromBufferAttribute(l.ROTATION,x),l.SCALE&&v.fromBufferAttribute(l.SCALE,x),w.setMatrixAt(x,u.compose(g,y,v));for(const x in l)if(x==="_COLOR_0"){const M=l[x];w.instanceColor=new _.InstancedBufferAttribute(M.array,M.itemSize,M.normalized)}else x!=="TRANSLATION"&&x!=="ROTATION"&&x!=="SCALE"&&f.geometry.setAttribute(x,l[x]);_.Object3D.prototype.copy.call(w,f),this.parser.assignFinalMaterial(w),p.push(w)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}}const Or="glTF",hn=12,Rr={JSON:1313821514,BIN:5130562};class wc{constructor(e){this.name=le.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,hn),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Or)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-hn,s=new DataView(e,hn);let r=0;for(;r<i;){const a=s.getUint32(r,!0);r+=4;const l=s.getUint32(r,!0);if(r+=4,l===Rr.JSON){const c=new Uint8Array(e,hn+r,a);this.content=n.decode(c)}else if(l===Rr.BIN){const c=hn+r;this.body=e.slice(c,c+a)}r+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class xc{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=le.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,r=e.extensions[this.name].attributes,a={},l={},c={};for(const h in r){const d=Yi[h]||h.toLowerCase();a[d]=r[h]}for(const h in e.attributes){const d=Yi[h]||h.toLowerCase();if(r[h]!==void 0){const m=n.accessors[e.attributes[h]],p=Zt[m.componentType];c[d]=p.name,l[d]=m.normalized===!0}}return t.getDependency("bufferView",s).then(function(h){return new Promise(function(d,m){i.decodeDracoFile(h,function(p){for(const f in p.attributes){const u=p.attributes[f],g=l[f];g!==void 0&&(u.normalized=g)}d(p)},a,c,_.LinearSRGBColorSpace,m)})})}}class bc{constructor(){this.name=le.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(t.texCoord===void 0||t.texCoord===e.channel)&&t.offset===void 0&&t.rotation===void 0&&t.scale===void 0||(e=e.clone(),t.texCoord!==void 0&&(e.channel=t.texCoord),t.offset!==void 0&&e.offset.fromArray(t.offset),t.rotation!==void 0&&(e.rotation=t.rotation),t.scale!==void 0&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Mc{constructor(){this.name=le.KHR_MESH_QUANTIZATION}}class Nr extends _.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let r=0;r!==i;r++)t[r]=n[s+r];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,r=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,h=i-t,d=(n-t)/h,m=d*d,p=m*d,f=e*c,u=f-c,g=-2*p+3*m,y=p-m,v=1-g,w=y-m+d;for(let x=0;x!==a;x++){const M=r[u+x+a],T=r[u+x+l]*h,P=r[f+x+a],k=r[f+x]*h;s[x]=v*M+w*T+g*P+y*k}return s}}const _c=new _.Quaternion;class Sc extends Nr{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return _c.fromArray(s).normalize().toArray(s),s}}const Ve={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Zt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Fr={9728:_.NearestFilter,9729:_.LinearFilter,9984:_.NearestMipmapNearestFilter,9985:_.LinearMipmapNearestFilter,9986:_.NearestMipmapLinearFilter,9987:_.LinearMipmapLinearFilter},Ur={33071:_.ClampToEdgeWrapping,33648:_.MirroredRepeatWrapping,10497:_.RepeatWrapping},Zi={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Yi={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},pt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Cc={CUBICSPLINE:void 0,LINEAR:_.InterpolateLinear,STEP:_.InterpolateDiscrete},Ki={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Ac(o){return o.DefaultMaterial===void 0&&(o.DefaultMaterial=new _.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:_.FrontSide})),o.DefaultMaterial}function Dt(o,e,t){for(const n in t.extensions)o[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function Qe(o,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(o.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Pc(o,e,t){let n=!1,i=!1,s=!1;for(let c=0,h=e.length;c<h;c++){const d=e[c];if(d.POSITION!==void 0&&(n=!0),d.NORMAL!==void 0&&(i=!0),d.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(o);const r=[],a=[],l=[];for(let c=0,h=e.length;c<h;c++){const d=e[c];if(n){const m=d.POSITION!==void 0?t.getDependency("accessor",d.POSITION):o.attributes.position;r.push(m)}if(i){const m=d.NORMAL!==void 0?t.getDependency("accessor",d.NORMAL):o.attributes.normal;a.push(m)}if(s){const m=d.COLOR_0!==void 0?t.getDependency("accessor",d.COLOR_0):o.attributes.color;l.push(m)}}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],d=c[1],m=c[2];return n&&(o.morphAttributes.position=h),i&&(o.morphAttributes.normal=d),s&&(o.morphAttributes.color=m),o.morphTargetsRelative=!0,o})}function Tc(o,e){if(o.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)o.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(o.morphTargetInfluences.length===t.length){o.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)o.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Dc(o){let e;const t=o.extensions&&o.extensions[le.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+qi(t.attributes):e=o.indices+":"+qi(o.attributes)+":"+o.mode,o.targets!==void 0)for(let n=0,i=o.targets.length;n<i;n++)e+=":"+qi(o.targets[n]);return e}function qi(o){let e="";const t=Object.keys(o).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+o[t[n]]+";";return e}function $i(o){switch(o){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function kc(o){return o.search(/\.jpe?g($|\?)/i)>0||o.search(/^data\:image\/jpeg/)===0?"image/jpeg":o.search(/\.webp($|\?)/i)>0||o.search(/^data\:image\/webp/)===0?"image/webp":o.search(/\.ktx2($|\?)/i)>0||o.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const Ec=new _.Matrix4;class Lc{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ec,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,s=!1,r=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,s=a.indexOf("Firefox")>-1,r=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||s&&r<98?this.textureLoader=new _.TextureLoader(this.options.manager):this.textureLoader=new _.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new _.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(r){return r._markDefs&&r._markDefs()}),Promise.all(this._invokeAll(function(r){return r.beforeRoot&&r.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(r){const a={scene:r[0][i.scene||0],scenes:r[0],animations:r[1],cameras:r[2],asset:i.asset,parser:n,userData:{}};return Dt(s,a,i),Qe(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const r=t[i].joints;for(let a=0,l=r.length;a<l;a++)e[r[a]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const r=e[i];r.mesh!==void 0&&(this._addNodeRef(this.meshCache,r.mesh),r.skin!==void 0&&(n[r.mesh].isSkinnedMesh=!0)),r.camera!==void 0&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(r,a)=>{const l=this.associations.get(r);l!=null&&this.associations.set(a,l);for(const[c,h]of r.children.entries())s(h,a.children[c])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[le.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,r){n.load(_.LoaderUtils.resolveURL(t.uri,i.path),s,void 0,function(){r(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const r=Zi[i.type],a=Zt[i.componentType],l=i.normalized===!0,c=new a(i.count*r);return Promise.resolve(new _.BufferAttribute(c,r,l))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(r){const a=r[0],l=Zi[i.type],c=Zt[i.componentType],h=c.BYTES_PER_ELEMENT,d=h*l,m=i.byteOffset||0,p=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0;let u,g;if(p&&p!==d){const y=Math.floor(m/p),v="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+y+":"+i.count;let w=t.cache.get(v);w||(u=new c(a,y*p,i.count*p/h),w=new _.InterleavedBuffer(u,p/h),t.cache.add(v,w)),g=new _.InterleavedBufferAttribute(w,l,m%p/h,f)}else a===null?u=new c(i.count*l):u=new c(a,m,i.count*l),g=new _.BufferAttribute(u,l,f);if(i.sparse!==void 0){const y=Zi.SCALAR,v=Zt[i.sparse.indices.componentType],w=i.sparse.indices.byteOffset||0,x=i.sparse.values.byteOffset||0,M=new v(r[1],w,i.sparse.count*y),T=new c(r[2],x,i.sparse.count*l);a!==null&&(g=new _.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let P=0,k=M.length;P<k;P++){const D=M[P];if(g.setX(D,T[P*l]),l>=2&&g.setY(D,T[P*l+1]),l>=3&&g.setZ(D,T[P*l+2]),l>=4&&g.setW(D,T[P*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=f}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,r=t.images[s];let a=this.textureLoader;if(r.uri){const l=n.manager.getHandler(r.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,r=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+r.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=r.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const m=(s.samplers||{})[r.sampler]||{};return h.magFilter=Fr[m.magFilter]||_.LinearFilter,h.minFilter=Fr[m.minFilter]||_.LinearMipmapLinearFilter,h.wrapS=Ur[m.wrapS]||_.RepeatWrapping,h.wrapT=Ur[m.wrapT]||_.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==_.NearestFilter&&h.minFilter!==_.LinearFilter,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(d=>d.clone());const r=i.images[e],a=self.URL||self.webkitURL;let l=r.uri||"",c=!1;if(r.bufferView!==void 0)l=n.getDependency("bufferView",r.bufferView).then(function(d){c=!0;const m=new Blob([d],{type:r.mimeType});return l=a.createObjectURL(m),l});else if(r.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(d){return new Promise(function(m,p){let f=m;t.isImageBitmapLoader===!0&&(f=function(u){const g=new _.Texture(u);g.needsUpdate=!0,m(g)}),t.load(_.LoaderUtils.resolveURL(d,s.path),f,void 0,p)})}).then(function(d){return c===!0&&a.revokeObjectURL(l),Qe(d,r),d.userData.mimeType=r.mimeType||kc(r.uri),d}).catch(function(d){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),d});return this.sourceCache[e]=h,h}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(r){if(!r)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(r=r.clone(),r.channel=n.texCoord),s.extensions[le.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[le.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(r);r=s.extensions[le.KHR_TEXTURE_TRANSFORM].extendTexture(r,a),s.associations.set(r,l)}}return i!==void 0&&(r.colorSpace=i),e[t]=r,r})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,r=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new _.PointsMaterial,_.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new _.LineBasicMaterial,_.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||s||r){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),r&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),r&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return _.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let r;const a={},l=s.extensions||{},c=[];if(l[le.KHR_MATERIALS_UNLIT]){const d=i[le.KHR_MATERIALS_UNLIT];r=d.getMaterialType(),c.push(d.extendParams(a,s,t))}else{const d=s.pbrMetallicRoughness||{};if(a.color=new _.Color(1,1,1),a.opacity=1,Array.isArray(d.baseColorFactor)){const m=d.baseColorFactor;a.color.setRGB(m[0],m[1],m[2],_.LinearSRGBColorSpace),a.opacity=m[3]}d.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",d.baseColorTexture,_.SRGBColorSpace)),a.metalness=d.metallicFactor!==void 0?d.metallicFactor:1,a.roughness=d.roughnessFactor!==void 0?d.roughnessFactor:1,d.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",d.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",d.metallicRoughnessTexture))),r=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=_.DoubleSide);const h=s.alphaMode||Ki.OPAQUE;if(h===Ki.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Ki.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&r!==_.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new _.Vector2(1,1),s.normalTexture.scale!==void 0)){const d=s.normalTexture.scale;a.normalScale.set(d,d)}if(s.occlusionTexture!==void 0&&r!==_.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&r!==_.MeshBasicMaterial){const d=s.emissiveFactor;a.emissive=new _.Color().setRGB(d[0],d[1],d[2],_.LinearSRGBColorSpace)}return s.emissiveTexture!==void 0&&r!==_.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,_.SRGBColorSpace)),Promise.all(c).then(function(){const d=new r(a);return s.name&&(d.name=s.name),Qe(d,s),t.associations.set(d,{materials:e}),s.extensions&&Dt(i,d,s),d})}createUniqueName(e){const t=_.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function s(a){return n[le.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return Vr(l,a,t)})}const r=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],h=Dc(c),d=i[h];if(d)r.push(d.promise);else{let m;c.extensions&&c.extensions[le.KHR_DRACO_MESH_COMPRESSION]?m=s(c):m=Vr(new _.BufferGeometry,c,t),i[h]={primitive:c,promise:m},r.push(m)}}return Promise.all(r)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],r=s.primitives,a=[];for(let l=0,c=r.length;l<c;l++){const h=r[l].material===void 0?Ac(this.cache):this.getDependency("material",r[l].material);a.push(h)}return a.push(t.loadGeometries(r)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],d=[];for(let p=0,f=h.length;p<f;p++){const u=h[p],g=r[p];let y;const v=c[p];if(g.mode===Ve.TRIANGLES||g.mode===Ve.TRIANGLE_STRIP||g.mode===Ve.TRIANGLE_FAN||g.mode===void 0)y=s.isSkinnedMesh===!0?new _.SkinnedMesh(u,v):new _.Mesh(u,v),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),g.mode===Ve.TRIANGLE_STRIP?y.geometry=Br(y.geometry,_.TriangleStripDrawMode):g.mode===Ve.TRIANGLE_FAN&&(y.geometry=Br(y.geometry,_.TriangleFanDrawMode));else if(g.mode===Ve.LINES)y=new _.LineSegments(u,v);else if(g.mode===Ve.LINE_STRIP)y=new _.Line(u,v);else if(g.mode===Ve.LINE_LOOP)y=new _.LineLoop(u,v);else if(g.mode===Ve.POINTS)y=new _.Points(u,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(y.geometry.morphAttributes).length>0&&Tc(y,s),y.name=t.createUniqueName(s.name||"mesh_"+e),Qe(y,s),g.extensions&&Dt(i,y,g),t.assignFinalMaterial(y),d.push(y)}for(let p=0,f=d.length;p<f;p++)t.associations.set(d[p],{meshes:e,primitives:p});if(d.length===1)return s.extensions&&Dt(i,d[0],s),d[0];const m=new _.Group;s.extensions&&Dt(i,m,s),t.associations.set(m,{meshes:e});for(let p=0,f=d.length;p<f;p++)m.add(d[p]);return m})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new _.PerspectiveCamera(_.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new _.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Qe(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i<s;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),r=i,a=[],l=[];for(let c=0,h=r.length;c<h;c++){const d=r[c];if(d){a.push(d);const m=new _.Matrix4;s!==null&&m.fromArray(s.array,c*16),l.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new _.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,r=[],a=[],l=[],c=[],h=[];for(let d=0,m=i.channels.length;d<m;d++){const p=i.channels[d],f=i.samplers[p.sampler],u=p.target,g=u.node,y=i.parameters!==void 0?i.parameters[f.input]:f.input,v=i.parameters!==void 0?i.parameters[f.output]:f.output;u.node!==void 0&&(r.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",y)),l.push(this.getDependency("accessor",v)),c.push(f),h.push(u))}return Promise.all([Promise.all(r),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(d){const m=d[0],p=d[1],f=d[2],u=d[3],g=d[4],y=[];for(let w=0,x=m.length;w<x;w++){const M=m[w],T=p[w],P=f[w],k=u[w],D=g[w];if(M===void 0)continue;M.updateMatrix&&M.updateMatrix();const E=n._createAnimationTracks(M,T,P,k,D);if(E)for(let O=0;O<E.length;O++)y.push(E[O])}const v=new _.AnimationClip(s,void 0,y);return Qe(v,i),v})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const r=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&r.traverse(function(a){if(a.isMesh)for(let l=0,c=i.weights.length;l<c;l++)a.morphTargetInfluences[l]=i.weights[l]}),r})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),r=[],a=i.children||[];for(let c=0,h=a.length;c<h;c++)r.push(n.getDependency("node",a[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(r),l]).then(function(c){const h=c[0],d=c[1],m=c[2];m!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(m,Ec)});for(let p=0,f=d.length;p<f;p++)h.add(d[p]);return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],r=s.name?i.createUniqueName(s.name):"",a=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),s.camera!==void 0&&a.push(i.getDependency("camera",s.camera).then(function(c){return i._getNodeRef(i.cameraCache,s.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(s.isBone===!0?h=new _.Bone:c.length>1?h=new _.Group:c.length===1?h=c[0]:h=new _.Object3D,h!==c[0])for(let d=0,m=c.length;d<m;d++)h.add(c[d]);if(s.name&&(h.userData.name=s.name,h.name=r),Qe(h,s),s.extensions&&Dt(n,h,s),s.matrix!==void 0){const d=new _.Matrix4;d.fromArray(s.matrix),h.applyMatrix4(d)}else s.translation!==void 0&&h.position.fromArray(s.translation),s.rotation!==void 0&&h.quaternion.fromArray(s.rotation),s.scale!==void 0&&h.scale.fromArray(s.scale);if(!i.associations.has(h))i.associations.set(h,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const d=i.associations.get(h);i.associations.set(h,{...d})}return i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new _.Group;n.name&&(s.name=i.createUniqueName(n.name)),Qe(s,n),n.extensions&&Dt(t,s,n);const r=n.nodes||[],a=[];for(let l=0,c=r.length;l<c;l++)a.push(i.getDependency("node",r[l]));return Promise.all(a).then(function(l){for(let h=0,d=l.length;h<d;h++)s.add(l[h]);const c=h=>{const d=new Map;for(const[m,p]of i.associations)(m instanceof _.Material||m instanceof _.Texture)&&d.set(m,p);return h.traverse(m=>{const p=i.associations.get(m);p!=null&&d.set(m,p)}),d};return i.associations=c(s),s})}_createAnimationTracks(e,t,n,i,s){const r=[],a=e.name?e.name:e.uuid,l=[];pt[s.path]===pt.weights?e.traverse(function(m){m.morphTargetInfluences&&l.push(m.name?m.name:m.uuid)}):l.push(a);let c;switch(pt[s.path]){case pt.weights:c=_.NumberKeyframeTrack;break;case pt.rotation:c=_.QuaternionKeyframeTrack;break;case pt.translation:case pt.scale:c=_.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=_.NumberKeyframeTrack;break;case 2:case 3:default:c=_.VectorKeyframeTrack;break}break}const h=i.interpolation!==void 0?Cc[i.interpolation]:_.InterpolateLinear,d=this._getArrayFromAccessor(n);for(let m=0,p=l.length;m<p;m++){const f=new c(l[m]+"."+pt[s.path],t.array,d,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(f),r.push(f)}return r}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=$i(t.constructor),i=new Float32Array(t.length);for(let s=0,r=t.length;s<r;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof _.QuaternionKeyframeTrack?Sc:Nr;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Ic(o,e,t){const n=e.attributes,i=new _.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(i.set(new _.Vector3(l[0],l[1],l[2]),new _.Vector3(c[0],c[1],c[2])),a.normalized){const h=$i(Zt[a.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new _.Vector3,l=new _.Vector3;for(let c=0,h=s.length;c<h;c++){const d=s[c];if(d.POSITION!==void 0){const m=t.json.accessors[d.POSITION],p=m.min,f=m.max;if(p!==void 0&&f!==void 0){if(l.setX(Math.max(Math.abs(p[0]),Math.abs(f[0]))),l.setY(Math.max(Math.abs(p[1]),Math.abs(f[1]))),l.setZ(Math.max(Math.abs(p[2]),Math.abs(f[2]))),m.normalized){const u=$i(Zt[m.componentType]);l.multiplyScalar(u)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}o.boundingBox=i;const r=new _.Sphere;i.getCenter(r.center),r.radius=i.min.distanceTo(i.max)/2,o.boundingSphere=r}function Vr(o,e,t){const n=e.attributes,i=[];function s(r,a){return t.getDependency("accessor",r).then(function(l){o.setAttribute(a,l)})}for(const r in n){const a=Yi[r]||r.toLowerCase();a in o.attributes||i.push(s(n[r],a))}if(e.indices!==void 0&&!o.index){const r=t.getDependency("accessor",e.indices).then(function(a){o.setIndex(a)});i.push(r)}return _.ColorManagement.workingColorSpace!==_.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${_.ColorManagement.workingColorSpace}" not supported.`),Qe(o,e),Ic(o,e,t),Promise.all(i).then(function(){return e.targets!==void 0?Pc(o,e.targets,t):o})}function zc(o,e,t){let n=new b.Group;n.name=e,o.scene.add(n),Wi(e+"/info",i=>{let s=JSON.parse(i);o.engineStatus.models.push({type:"light",info:s,name:s.baseInfo.name,status:"loading",url:e,elements:new Map}),o.models==null&&(o.models=[]),o.models.push({url:e,nodesMap:new Map,boundingBox:{min:new b.Vector3(s.baseInfo.min.X*.3048,s.baseInfo.min.Z*.3048,-s.baseInfo.min.Y*.3048),max:new b.Vector3(s.baseInfo.max.X*.3048,s.baseInfo.max.Z*.3048,-s.baseInfo.max.Y*.3048)}}),o.events.trigger(ft.EngineFree,e)})}function Bc(o,e){o.engineStatus.models.filter(t=>e==null||t.url==e).forEach(t=>{t.loadStatus==null&&(t.loadStatus={mep:!1,instance:!1,normal:!1}),t.status==="loading"&&t.type==="light"&&(t.loadStatus.modelMep!=!0&&(t.loadStatus.modelMep=!0,Jl(o,t.info.modelMep,t.url)),t.loadStatus.normal!=!0&&Oc(o,t))})}function Oc(o,e){if(o.camera.position,e.size,e.info==null||e.info.lods==null)return;e.info.lods.forEach(i=>{if(i.status!=!0)if(i.glbs==null)console.log("加载GLB............."),i.glbs={},ql(e.url+i.path,s=>{Ir(s.get("/nodes.json"),r=>{let a=JSON.parse(r);o.models.find(h=>h.url==e.url).nodesMap==null&&(o.models.find(h=>h.url==e.url).nodesMap=new Map);let l=o.models.find(h=>h.url==e.url).nodesMap,c=0;for(let h in a){a[h].forEach(p=>{p.glb=h,l.has(p.id)==!1?l.set(p.id,{infos:[p]}):l.get(p.id).infos.push(p)});let d=new Ql;const m=new $l;m.setDecoderPath("/draco/"),m.preload(),d.setDRACOLoader(m),d.load(s.get(h+".glb"),p=>{i.glbs[h]=p.scene.children,i.glbs[h].forEach(f=>{f.geometry.computeVertexNormals()}),c++,c==Object.keys(a).length&&o.engineStatus.isFree&&(o.events.trigger(ft.EngineFree,e.url),o.viewCube.CameraGoHome())})}Ir(s.get("/instances.json"),h=>{let d=JSON.parse(h);o.models.find(m=>m.url==e.url).instanceNodes=d})})});else{let s=n(e,i,i.octreeBox),r=[],a=o.models.find(c=>c.url==e.url);s.forEach(c=>{a.nodesMap.has(c)&&a.nodesMap.get(c).infos.forEach(h=>{let d=i.glbs[h.glb][h.mesh];if(d!=null&&d.geometry!=null&&d.material!=null){let m=new b.Matrix4;m.elements=h.matrix;let p=new b.Mesh(d.geometry.clone().applyMatrix4(m),d.material),f=new b.Box3().setFromObject(p);h.box=f,h.mesh=p,p.name=c,p.glb=h.glb,p.url=e.url,d.geometry.attributes.position!=null&&r.push(p)}})}),Rc(e.url,o,r);let l=a.instanceNodes;if(l!=null)for(let c in l)(l[c].isLoaded==null||l[c].isLoaded==!1)&&(l[c].isLoaded=!0,l[c].forEach(h=>{if(i.glbs[c]!=null){let d=i.glbs[c][h.mesh];Nc(e.url,h.mesh,o,d,h.children)}}))}});function n(i,s,r){let a=[];if(r.status!=!0){if(!o.engineStatus.isFree)return a;let l=new b.Vector3(r.min.X,r.min.Z,-r.min.Y),c=new b.Vector3(r.max.X,r.max.Z,-r.max.Y);c.distanceTo(l);let h=o.camera.position,d=new b.Vector3(l.x+c.x/2,l.y+c.y/2,l.z+c.z/2);h.distanceTo(d),r.elements.forEach(m=>{a.push(m)}),r.children.forEach(m=>{a.push(...n(i,s,m))}),r.children.findIndex(m=>m.status!=!0)==-1&&(r.status=!0),r.children.length==0&&(r.status=!0)}return a}}function Rc(o,e,t){let n=[];t.forEach(i=>{n.findIndex(r=>r.glb==i.glb)==-1?n.push({glb:i.glb,meshes:[i],currentIndex:i.geometry.index.count,indexes:new Map}):(n.find(r=>r.glb==i.glb).meshes.push(i),n.find(r=>r.glb==i.glb).currentIndex+=i.geometry.index.count);let s=n.find(r=>r.glb==i.glb);s.indexes.has(Number(i.name))?s.indexes.get(Number(i.name)).push([s.currentIndex-i.geometry.index.count,s.currentIndex]):s.indexes.set(Number(i.name),[[s.currentIndex-i.geometry.index.count,s.currentIndex]])}),n.forEach(i=>{let s=e.scene.children.find(r=>r instanceof b.Mesh&&r.url==o&&r.glb==i.glb);if(s!=null)s.castShadow=!0,s.receiveShadow=!0;else{let r=new b.BufferGeometry,a=Fc(i.meshes[0].material);r=cn(i.meshes.map(h=>h.geometry),!1);let l=new b.Mesh(r,a);l.castShadow=!0,l.receiveShadow=!0,e.scene.add(l),l.index=e.scene.children.length-1,l.url=o,l.glb=i.glb,l.indexes=i.indexes,l.materialClone=a,l.geometrys=i.meshes.map(h=>h.geometry);let c=e.models.find(h=>h.url==o);if(c!=null){let h=0;i.indexes.forEach(d=>{d.forEach(m=>{c.nodesMap.get(Number(i.meshes[h].name)).indexes==null&&(c.nodesMap.get(Number(i.meshes[h].name)).indexes=[]),c.nodesMap.get(Number(i.meshes[h].name)).indexes.push([l.index,h++,m[0],m[1]])})})}}})}function Nc(o,e,t,n,i){if(n==null)return;let s=new b.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(s);const r=new Float32Array(i.length*3);for(let l=0;l<i.length;l++)r[l*3]=1,r[l*3+1]=1,r[l*3+2]=1;s.instanceColor=new b.InstancedBufferAttribute(r,3);let a=[];for(let l=0;l<i.length;l++){let c=i[l],h=new b.Matrix4;h.elements=c.matrix,s.setMatrixAt(l,h),s.matrixs||(s.matrixs=[]),s.matrixs.push(h.clone()),a.push(h.clone()),t.models.find(d=>d.url==o).nodesMap.has(c.id)?(t.models.find(d=>d.url==o).nodesMap.get(c.id).indexes==null&&(t.models.find(d=>d.url==o).nodesMap.get(c.id).indexes=[]),t.models.find(d=>d.url==o).nodesMap.get(c.id).indexes.push([t.scene.children.length-1,l,0,0])):t.models.find(d=>d.url==o).nodesMap.set(c.id,{instance:!0,info:c,indexes:[[t.scene.children.length-1,l,0,0]]})}s.index=t.scene.children.length-1,s.materialClone=n.material,s.url=o,s.glb=n.glb,s.ids=i.map(l=>l.id),s.matrixsClone=a}function Fc(o){return o.map!=null&&(o.map.colorSpace=b.SRGBColorSpace,o.map.needsUpdate=!0),o.shadowSide=b.FrontSide,o.side=o.side,o}class Uc{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&zc(this.engine,i);function n(i){const s=i.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}class Vc{engine;isFree;highlightModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.models=[]}init(){this.engine.events.on(ft.EngineFree,e=>{this.updateFree(!0),Bc(this.engine,e)}),this.engine.events.on(ft.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let jc=class{listeners=new Map;debugMode=!1;setDebugMode(e){this.debugMode=e}on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${n}, 当前监听器数量: ${this.listeners.get(n).length}`)}off(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${n}`);return}const i=this.listeners.get(n),s=i.indexOf(t);s!==-1?(i.splice(s,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${n}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${n}`)}trigger(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${n}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(n);this.debugMode&&console.debug(`[EventModule] 触发事件: ${n}, 监听器数量: ${i.length}`,t),i.forEach((s,r)=>{try{s(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${r}:`,a)}})}};class Gc{engine;constructor(e){this.engine=e}init(){const e=new b.DirectionalLight(16777215,1);e.position.set(100,200,100),e.castShadow=!0,e.shadow.mapSize.width=2048,e.shadow.mapSize.height=2048,e.shadow.camera.near=.1,e.shadow.camera.far=5e3,e.shadow.bias=-5e-5,e.shadow.normalBias=.02;const t=50;e.shadow.camera.left=-t,e.shadow.camera.right=t,e.shadow.camera.top=t,e.shadow.camera.bottom=-t,e.shadow.radius=2;const n=new b.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new b.AmbientLight(16777215,1);this.engine.scene.add(i)}}var Me=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoadProgress="model-load-progress",o.ModelLoaded="model-loaded",o.ModelError="model-error",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.Click="click",o.MouseMove="mouse-move",o.CameraChanged="camera-changed",o.CameraIdle="camera-idle",o.EngineFree="engine-free",o.EngineBusy="engine-busy",o.MeasureChanged="measure-changed",o.MeasureClick="measure-click",o.SectionMove="section-move",o))(Me||{});class Wc{engine;behavior;isCtrlDown=!1;highlightedInstances=[];highlightColor=new b.Color(43775);constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1}handelKeyCtrlDown(){this.isCtrlDown=!0}hoverOldId=null;timeOutEvent;handleMouseMove(e){if(this.timeOutEvent!=null&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=null),e.catch!=null&&(this.engine.hoverHighLight.showModelNameTag(null,null),this.timeOutEvent=setTimeout(()=>{this.hoverOldId=null;let n=this.getCatchMeshs(e,!0);n.length>0&&this.engine.hoverHighLight.showModelNameTag({url:n[0].url,ids:[n[0].name]},e.catch.point)},1e3)),!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}let t=this.getCatchMeshs(e);t!=null?t.length>0&&this.engine.hoverHighLight.hightMesh(t):this.engine.hoverHighLight.clearHighlight()}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){let n=e.catch.object,i=e.catch.object.id,s=this.engine.models.find(l=>l.url==n.url).nodesMap.get(i),r=new Map;s?.indexes.forEach(l=>{this.engine.scene.children[l[0]]instanceof b.InstancedMesh&&(r.has(l[0])?r.get(l[0])?.push(l[1]):r.set(l[0],[l[1]]))});let a=[];return r.forEach((l,c)=>{let h=this.engine.scene.children[c];l.forEach(d=>{let m=h.geometry.clone();m.applyMatrix4(h.matrixs[d]),a.push(new b.Mesh(m,h.material))})}),this.hoverOldId==i?[]:(this.hoverOldId=i,t||this.engine.hoverHighLight.clearHighlight(),a)}else{let i=e.catch.object,s=i.name,l=this.engine.models.find(c=>c.url===i.url).nodesMap.get(s).infos.map(c=>c.mesh);return this.hoverOldId==s?[]:(this.hoverOldId=s,t||this.engine.hoverHighLight.clearHighlight(),l)}}handleMouseClick(e){if(e.catch!=null){const t=e.catch;let n=t.object;this.isCtrlDown||this.engine.modelToolModule.unhighlightAllModels(),console.log([{url:n.url,ids:[n.name]}]),this.engine.controlModule.orbitControls.origin.set(t.point.x,t.point.y,t.point.z),this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.name]}]),this.engine.events.trigger(Me.Click,[{url:n.url,ids:[n.name]}])}else this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(e.catch){const n=e.catch;let i=n.object,r=this.engine.models.find(a=>a.url===i.url).nodesMap.get(i.name);if(n.object.isInstance){let a=n.matrix;const l=[];r.indexes.forEach(h=>{let d=h[0],m=this.engine.scene.children[d].geometry.boundingSphere;const p=new b.Box3,f=m.center.clone().applyMatrix4(a),u=m.radius,g=new b.Vector3;g.setFromMatrixScale(a);const y=Math.max(g.x,g.y,g.z),v=u*y;p.min.set(f.x-v,f.y-v,f.z-v),p.max.set(f.x+v,f.y+v,f.z+v),l.push(p)});let c=t(l);this.engine.viewCube.zoomToModel(c)}else{const a=r.infos.map(c=>c.box);let l=t(a);this.engine.viewCube.zoomToModel(l)}}function t(n){let i=new b.Vector3(1e8,1e9,1e10),s=new b.Vector3(-1e8,-1e9,-1e10);return n.forEach(r=>{r.min.x<i.x&&(i.x=r.min.x),r.min.y<i.y&&(i.y=r.min.y),r.min.z<i.z&&(i.z=r.min.z),r.max.x>s.x&&(s.x=r.max.x),r.max.y>s.y&&(s.y=r.max.y),r.max.z>s.z&&(s.z=r.max.z)}),new b.Box3(i,s)}}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(n=>n instanceof b.InstancedMesh),!0)}}class Xc{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new b.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:b.DoubleSide}),this.hideMaterial=new b.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:b.DoubleSide}),this.translucentMaterial=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:b.DoubleSide}),this.highlightMaterial.clippingPlanes=this.engine.sectionPlane,this.hideMaterial.clippingPlanes=this.engine.sectionPlane,this.translucentMaterial.clippingPlanes=this.engine.sectionPlane}split_merge_model(e){if(e.isSplit||e instanceof b.InstancedMesh)return;let t=e.materialClone.clone(),n=cn(e.geometrys,!0);n.groups.forEach(i=>{i.materialIndex=0}),e.geometry=n,e.material=[t,this.highlightMaterial,this.translucentMaterial],e.needsUpdate=!0,e.isSplit=!0}un_split_merge_model(e){}highlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{this.engine.scene.children[a[0]]instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(console.log(this.engine.scene.children[a[0]].materialClone.color),this.split_merge_model(this.engine.scene.children[a[0]]),this.engine.scene.children[a[0]].geometry.groups[a[1]].materialIndex=1)})}),Zc(n,this.engine);let i=this.engine.engineStatus.highlightModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(r=>r.url==t.url).nodesMap.get(i);s!=null&&s.indexes!=null&&s.indexes.forEach(r=>{this.engine.scene.children[r[0]]instanceof b.InstancedMesh?n.has(r[0])?n.get(r[0])?.push(r[1]):n.set(r[0],[r[1]]):this.engine.scene.children[r[0]].geometry.groups[r[1]].materialIndex=0})}),jr(n,this.engine,"highlightModel")})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.engine.scene.children[a[0]]),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),n.size>0&&Kc(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(l.geometry.groups[a[1]].materialIndex=0,l.geometry.groups[a[1]].visible=!0)})}),n.size>0&&Gr(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i&&(t.ids.forEach(s=>{const r=i.ids.indexOf(s);r!==-1&&i.ids.splice(r,1)}),i.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(s=>s!==i)))})}isolateModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},s=e.find(r=>r.url==n.url);for(let r of n.nodesMap)s==null?i.ids.push(r[0]):s.ids.includes(r[0])||i.ids.push(r[0]);t.push(i)}),this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},s=e.find(r=>r.url==n.url);for(let r of n.nodesMap)s==null?i.ids.push(r[0]):s.ids.includes(r[0])||i.ids.push(r[0]);t.push(i)}),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let r=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);r!=null&&r.indexes!=null&&r.indexes.forEach(a=>{const l=this.engine.scene.children[a[0]];l instanceof b.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.engine.scene.children[a[0]]),l.geometry.groups[a[1]].materialIndex=2)})}),Yc(n,this.engine);let i=this.engine.engineStatus.translucentModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(r=>r.url==t.url).nodesMap.get(i);s!=null&&s.indexes!=null&&s.indexes.forEach(r=>{const a=this.engine.scene.children[r[0]];a instanceof b.InstancedMesh?n.has(r[0])?n.get(r[0])?.push(r[1]):n.set(r[0],[r[1]]):(this.split_merge_model(this.engine.scene.children[r[0]]),a.geometry.groups[r[1]].materialIndex=0)})}),n.size>0&&Gr(n,this.engine),jr(n,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function Zc(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof b.InstancedMesh))return;const s=i.geometry,r=new b.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:b.DoubleSide}),a=new b.InstancedMesh(s,r,t.length);a.name="highlightModel",a.key=n;const l=new Map,c=new b.Matrix4,h=new b.Matrix4;h.makeScale(0,0,0),t.forEach((d,m)=>{i.getMatrixAt(d,c),l.set(d,c.clone()),i.setMatrixAt(d,h),a.setMatrixAt(m,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function jr(o,e,t){o.forEach((n,i)=>{const s=e.scene.children[i];if(!(s instanceof b.InstancedMesh))return;n.forEach(a=>{const l=s.matrixsClone[a];l&&s.setMatrixAt(a,l)}),s.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==i&&a.name==t).forEach(a=>{e.scene.remove(a)})})}function Yc(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof b.InstancedMesh))return;const s=i.geometry,r=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:b.DoubleSide}),a=new b.InstancedMesh(s,r,t.length);a.name="translucentModel",a.key=n;const l=new Map,c=new b.Matrix4,h=new b.Matrix4;h.makeScale(0,0,0),t.forEach((d,m)=>{i.getMatrixAt(d,c),l.set(d,c.clone()),i.setMatrixAt(d,h),a.setMatrixAt(m,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function Kc(o,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),o.forEach((t,n)=>{const i=e.scene.children[n];if(!(i instanceof b.InstancedMesh))return;const s=new Map,r=new b.Matrix4,a=new b.Matrix4;a.makeScale(0,0,0),t.forEach((l,c)=>{i.getMatrixAt(l,r),s.set(l,r.clone()),i.setMatrixAt(l,a)}),i.instanceMatrix.needsUpdate=!0})}function Gr(o,e){o.forEach((t,n)=>{const i=e.scene.children[n];i instanceof b.InstancedMesh&&(t.forEach(s=>{const r=i.matrixs[s];r&&i.setMatrixAt(s,r)}),i.instanceMatrix.needsUpdate=!0)})}class qc{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch("advanced")}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!0),this.setOutputPass(!0),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof b.DirectionalLight);t&&(t.castShadow=e),this.engine.scene?.traverse(n=>{n.material&&(n.castShadow!==void 0&&(n.castShadow=e),n.receiveShadow!==void 0&&(n.receiveShadow=e))})}setGTAO(e){this.engine.composerModule?.composer&&this.gtaoPass&&(this.gtaoPass.enabled=e)}setSSAO(e){this.engine.composerModule?.composer&&this.ssaoPass&&(this.ssaoPass.enabled=e)}setSaturation(e){this.saturationPass&&(this.saturationPass.enabled=e)}setOutputPass(e){this.outputPass&&(this.outputPass.enabled=e)}setFXAA(e){this.fxaaPass&&(this.fxaaPass.enabled=e)}setPerformanceMode(){this.setMode("simple")}setBalancedMode(){this.setMode("balance")}setQualityMode(){this.setMode("advanced")}setSuperQualityMode(){this.setMode("superAdvanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(s=>s instanceof b.DirectionalLight),i={low:1024,medium:2048,high:2048}[e];t?.shadow&&i&&(t.shadow.mapSize.width=i,t.shadow.mapSize.height=i,t.shadow.map?.dispose(),t.shadow.map=null)}setSaturationValue(e){this.saturationPass&&(this.saturationPass.uniforms.saturation.value=e)}setContrastValue(e){this.saturationPass&&(this.saturationPass.uniforms.contrast.value=e)}setGTAOIntensity(e){this.gtaoPass&&(this.gtaoPass.blendIntensity=e)}}class Hn{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;tagDiv;constructor(e){this.engine=e,this.init();const t=document.createElement("div");this.tagDiv=t,t.className="tagDiv",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.borderRadius="10px",t.style.pointerEvents="none",this.engine.container.appendChild(this.tagDiv)}showModelNameTag(e,t){if(e==null){this.tagDiv.style.display="none";return}let n=this.engine.models.find(a=>a.url==e.url);if(n==null){this.tagDiv.style.display="none";return}let i=n.nodesMap.get(e.ids[0]);i.infos&&i.infos.length>0&&(this.tagDiv.innerHTML=i.infos[0].name);const r=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=r.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=r.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new b.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:b.AdditiveBlending,depthWrite:!1}),this.overlayMaterial.clippingPlanes=this.engine.sectionPlane}hightMesh(e,t=16777215,n=.15){this.animState==="fadeOut"&&this.removeOverlayMeshes();const i=(Array.isArray(e)?e:e?[e]:[]).filter(s=>s?.geometry);if(i.length===0){this.clearHighlight();return}this.overlayMaterial.color.set(t),this.overlayMaterial.opacity=0,this.overlayMaterial.userData.targetOpacity=n;for(const s of i){const r=new b.Mesh(s.geometry,this.overlayMaterial);s.updateWorldMatrix(!0,!1),r.matrix.copy(s.matrixWorld),r.matrixAutoUpdate=!1,this.engine.scene.add(r),this.overlayMeshes.push(r)}this.animState="fadeIn",this.animStartTime=performance.now()}clearHighlight(){this.overlayMeshes.length===0||this.animState==="fadeOut"||(this.animState="fadeOut",this.animStartTime=performance.now())}update(){if(this.animState==="idle"||this.overlayMeshes.length===0)return;const e=performance.now()-this.animStartTime,t=this.overlayMaterial.userData.targetOpacity??.35;if(this.animState==="fadeIn"){const n=Math.min(e/Hn.FADE_IN_MS,1);this.overlayMaterial.opacity=this.easeOutQuad(n)*t,n>=1&&(this.animState="idle")}else if(this.animState==="fadeOut"){const n=Math.min(e/Hn.FADE_OUT_MS,1);this.overlayMaterial.opacity=(1-this.easeOutQuad(n))*t,n>=1&&(this.removeOverlayMeshes(),this.animState="idle")}}removeOverlayMeshes(){for(const e of this.overlayMeshes)this.engine.scene.remove(e);this.overlayMeshes=[]}easeOutQuad(e){return 1-(1-e)*(1-e)}dispose(){this.removeOverlayMeshes(),this.overlayMaterial.dispose(),this.animState="idle"}}var Jn={exports:{}},$c=Jn.exports,Wr;function Hc(){return Wr||(Wr=1,(function(o,e){(function(t,n){o.exports=n()})($c,function(){var t=function(){function n(p){return r.appendChild(p.dom),p}function i(p){for(var f=0;f<r.children.length;f++)r.children[f].style.display=f===p?"block":"none";s=p}var s=0,r=document.createElement("div");r.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",r.addEventListener("click",function(p){p.preventDefault(),i(++s%r.children.length)},!1);var a=(performance||Date).now(),l=a,c=0,h=n(new t.Panel("FPS","#0ff","#002")),d=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var m=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:r,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){c++;var p=(performance||Date).now();if(d.update(p-a,200),p>l+1e3&&(h.update(1e3*c/(p-l),100),l=p,c=0,m)){var f=performance.memory;m.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return p},update:function(){a=this.end()},domElement:r,setMode:i}};return t.Panel=function(n,i,s){var r=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,d=48*c,m=3*c,p=2*c,f=3*c,u=15*c,g=74*c,y=30*c,v=document.createElement("canvas");v.width=h,v.height=d,v.style.cssText="width:80px;height:48px";var w=v.getContext("2d");return w.font="bold "+9*c+"px Helvetica,Arial,sans-serif",w.textBaseline="top",w.fillStyle=s,w.fillRect(0,0,h,d),w.fillStyle=i,w.fillText(n,m,p),w.fillRect(f,u,g,y),w.fillStyle=s,w.globalAlpha=.9,w.fillRect(f,u,g,y),{dom:v,update:function(x,M){r=Math.min(r,x),a=Math.max(a,x),w.fillStyle=s,w.globalAlpha=1,w.fillRect(0,0,h,u),w.fillStyle=i,w.fillText(l(x)+" "+n+" ("+l(r)+"-"+l(a)+")",m,p),w.drawImage(v,f+c,u,g-c,y,f,u,g-c,y),w.fillRect(f+g-c,u,c,y),w.fillStyle=s,w.globalAlpha=.9,w.fillRect(f+g-c,u,c,l((1-x/M)*y))}}},t})})(Jn)),Jn.exports}var Jc=Hc();const Qc=Xs(Jc);var Yt=Object.freeze({Linear:Object.freeze({None:function(o){return o},In:function(o){return o},Out:function(o){return o},InOut:function(o){return o}}),Quadratic:Object.freeze({In:function(o){return o*o},Out:function(o){return o*(2-o)},InOut:function(o){return(o*=2)<1?.5*o*o:-.5*(--o*(o-2)-1)}}),Cubic:Object.freeze({In:function(o){return o*o*o},Out:function(o){return--o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o:.5*((o-=2)*o*o+2)}}),Quartic:Object.freeze({In:function(o){return o*o*o*o},Out:function(o){return 1- --o*o*o*o},InOut:function(o){return(o*=2)<1?.5*o*o*o*o:-.5*((o-=2)*o*o*o-2)}}),Quintic:Object.freeze({In:function(o){return o*o*o*o*o},Out:function(o){return--o*o*o*o*o+1},InOut:function(o){return(o*=2)<1?.5*o*o*o*o*o:.5*((o-=2)*o*o*o*o+2)}}),Sinusoidal:Object.freeze({In:function(o){return 1-Math.sin((1-o)*Math.PI/2)},Out:function(o){return Math.sin(o*Math.PI/2)},InOut:function(o){return .5*(1-Math.sin(Math.PI*(.5-o)))}}),Exponential:Object.freeze({In:function(o){return o===0?0:Math.pow(1024,o-1)},Out:function(o){return o===1?1:1-Math.pow(2,-10*o)},InOut:function(o){return o===0?0:o===1?1:(o*=2)<1?.5*Math.pow(1024,o-1):.5*(-Math.pow(2,-10*(o-1))+2)}}),Circular:Object.freeze({In:function(o){return 1-Math.sqrt(1-o*o)},Out:function(o){return Math.sqrt(1- --o*o)},InOut:function(o){return(o*=2)<1?-.5*(Math.sqrt(1-o*o)-1):.5*(Math.sqrt(1-(o-=2)*o)+1)}}),Elastic:Object.freeze({In:function(o){return o===0?0:o===1?1:-Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI)},Out:function(o){return o===0?0:o===1?1:Math.pow(2,-10*o)*Math.sin((o-.1)*5*Math.PI)+1},InOut:function(o){return o===0?0:o===1?1:(o*=2,o<1?-.5*Math.pow(2,10*(o-1))*Math.sin((o-1.1)*5*Math.PI):.5*Math.pow(2,-10*(o-1))*Math.sin((o-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(o){var e=1.70158;return o===1?1:o*o*((e+1)*o-e)},Out:function(o){var e=1.70158;return o===0?0:--o*o*((e+1)*o+e)+1},InOut:function(o){var e=2.5949095;return(o*=2)<1?.5*(o*o*((e+1)*o-e)):.5*((o-=2)*o*((e+1)*o+e)+2)}}),Bounce:Object.freeze({In:function(o){return 1-Yt.Bounce.Out(1-o)},Out:function(o){return o<1/2.75?7.5625*o*o:o<2/2.75?7.5625*(o-=1.5/2.75)*o+.75:o<2.5/2.75?7.5625*(o-=2.25/2.75)*o+.9375:7.5625*(o-=2.625/2.75)*o+.984375},InOut:function(o){return o<.5?Yt.Bounce.In(o*2)*.5:Yt.Bounce.Out(o*2-1)*.5+.5}}),generatePow:function(o){return o===void 0&&(o=4),o=o<Number.EPSILON?Number.EPSILON:o,o=o>1e4?1e4:o,{In:function(e){return Math.pow(e,o)},Out:function(e){return 1-Math.pow(1-e,o)},InOut:function(e){return e<.5?Math.pow(e*2,o)/2:(1-Math.pow(2-e*2,o))/2+.5}}}}),un=function(){return performance.now()},eh=(function(){function o(){this._tweens={},this._tweensAddedDuringUpdate={}}return o.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},o.prototype.removeAll=function(){this._tweens={}},o.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},o.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},o.prototype.update=function(e,t){e===void 0&&(e=un()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var s=this._tweens[n[i]],r=!t;s&&s.update(e,r)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},o})(),Hi={Linear:function(o,e){var t=o.length-1,n=t*e,i=Math.floor(n),s=Hi.Utils.Linear;return e<0?s(o[0],o[1],n):e>1?s(o[t],o[t-1],t-n):s(o[i],o[i+1>t?t:i+1],n-i)},Utils:{Linear:function(o,e,t){return(e-o)*t+o}}},Xr=(function(){function o(){}return o.nextId=function(){return o._nextId++},o._nextId=0,o})(),Ji=new eh,th=(function(){function o(e,t){t===void 0&&(t=Ji),this._object=e,this._group=t,this._isPaused=!1,this._pauseStart=0,this._valuesStart={},this._valuesEnd={},this._valuesStartRepeat={},this._duration=1e3,this._isDynamic=!1,this._initialRepeat=0,this._repeat=0,this._yoyo=!1,this._isPlaying=!1,this._reversed=!1,this._delayTime=0,this._startTime=0,this._easingFunction=Yt.Linear.None,this._interpolationFunction=Hi.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Xr.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return o.prototype.getId=function(){return this._id},o.prototype.isPlaying=function(){return this._isPlaying},o.prototype.isPaused=function(){return this._isPaused},o.prototype.getDuration=function(){return this._duration},o.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},o.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},o.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},o.prototype.start=function(e,t){if(e===void 0&&(e=un()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var s in this._valuesEnd)i[s]=this._valuesEnd[s];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},o.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},o.prototype._setupProperties=function(e,t,n,i,s){for(var r in n){var a=e[r],l=Array.isArray(a),c=l?"array":typeof a,h=!l&&Array.isArray(n[r]);if(!(c==="undefined"||c==="function")){if(h){var d=n[r];if(d.length===0)continue;for(var m=[a],p=0,f=d.length;p<f;p+=1){var u=this._handleRelativeValue(a,d[p]);if(isNaN(u)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}m.push(u)}h&&(n[r]=m)}if((c==="object"||l)&&a&&!h){t[r]=l?[]:{};var g=a;for(var y in g)t[r][y]=g[y];i[r]=l?[]:{};var d=n[r];if(!this._isDynamic){var v={};for(var y in d)v[y]=d[y];n[r]=d=v}this._setupProperties(g,t[r],d,i[r],s)}else(typeof t[r]>"u"||s)&&(t[r]=a),l||(t[r]*=1),h?i[r]=n[r].slice().reverse():i[r]=t[r]||0}}},o.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},o.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},o.prototype.pause=function(e){return e===void 0&&(e=un()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},o.prototype.resume=function(e){return e===void 0&&(e=un()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},o.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},o.prototype.group=function(e){return e===void 0&&(e=Ji),this._group=e,this},o.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},o.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},o.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},o.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},o.prototype.easing=function(e){return e===void 0&&(e=Yt.Linear.None),this._easingFunction=e,this},o.prototype.interpolation=function(e){return e===void 0&&(e=Hi.Linear),this._interpolationFunction=e,this},o.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},o.prototype.onStart=function(e){return this._onStartCallback=e,this},o.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},o.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},o.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},o.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},o.prototype.onStop=function(e){return this._onStopCallback=e,this},o.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=un()),t===void 0&&(t=!0),this._isPaused)return!0;var s,r=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>r)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,l=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(n._duration===0||a>c)return 1;var g=Math.trunc(a/l),y=a-g*l,v=Math.min(y/n._duration,1);return v===0&&a===n._duration?1:v},d=h(),m=this._easingFunction(d);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,m),this._onUpdateCallback&&this._onUpdateCallback(this._object,d),this._duration===0||a>=this._duration)if(this._repeat>0){var p=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=p);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*p,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var f=0,u=this._chainedTweens.length;f<u;f++)this._chainedTweens[f].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},o.prototype._updateProperties=function(e,t,n,i){for(var s in n)if(t[s]!==void 0){var r=t[s]||0,a=n[s],l=Array.isArray(e[s]),c=Array.isArray(a),h=!l&&c;h?e[s]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(e[s],r,a,i):(a=this._handleRelativeValue(r,a),typeof a=="number"&&(e[s]=r+(a-r)*i))}},o.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},o.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},o})();Xr.nextId;var et=Ji;et.getAll.bind(et),et.removeAll.bind(et),et.add.bind(et),et.remove.bind(et),et.update.bind(et);var dn={Easing:Yt,Tween:th};class nh extends _.DataTextureLoader{constructor(e){super(e),this.type=_.HalfFloatType}parse(e){const r=function(k,D){switch(k){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(D||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(D||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(D||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(D||""))}},d=function(k,D,E){D=D||1024;let A=k.pos,I=-1,S=0,z="",V=String.fromCharCode.apply(null,new Uint16Array(k.subarray(A,A+128)));for(;0>(I=V.indexOf(`
|
|
968
|
-
`))&&S<
|
|
969
|
-
`;z=
|
|
960
|
+
`};class Va{engine;composer;saturationPass;ssaoPass;gtaoPass;outputPass;fxaaPass;constructor(e){this.engine=e}resize(e,t){if(e===void 0||t===void 0){const s=this.engine.deviceModule.getContainerSize();e=e??s.width,t=t??s.height}if(!e||!t||!this.composer)return;const n=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1;this.composer.setPixelRatio(n),this.composer.setSize(e,t);const i=this.composer.passes.find(s=>s instanceof Ln&&s.material.uniforms.resolution);i&&(i.material.uniforms.resolution.value.x=1/(e*n),i.material.uniforms.resolution.value.y=1/(t*n))}init(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize(),n=this.engine.scene,i=this.engine.camera,s=this.engine.renderer,o=this.engine.renderer?.getPixelRatio?.()??window.devicePixelRatio??1,a=new w.WebGLRenderTarget(e,t,{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat,samples:4});this.composer=new Ia(s,a),this.composer.setPixelRatio(o),this.composer.setSize(e,t);const l=new za(n,i);this.composer.addPass(l),this.gtaoPass=new Oe(n,i,e,t),this.gtaoPass.output=Oe.OUTPUT.Default,this.gtaoPass.blendIntensity=.3,this.gtaoPass.enabled=!1,this.gtaoPass.updateGtaoMaterial&&this.gtaoPass.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0}),this.composer.addPass(this.gtaoPass),this.ssaoPass=new ot(n,i,e,t),this.ssaoPass.kernelRadius=8,this.ssaoPass.minDistance=.005,this.ssaoPass.maxDistance=.1,this.ssaoPass.output=ot.OUTPUT.Default,this.ssaoPass.enabled=!1,this.composer.addPass(this.ssaoPass),this.saturationPass=new Ln(Ua),this.saturationPass.uniforms.saturation.value=1.3,this.saturationPass.uniforms.contrast.value=1.1,this.saturationPass.enabled=!1,this.composer.addPass(this.saturationPass),this.outputPass=new Na,this.outputPass.enabled=!1,this.composer.addPass(this.outputPass),this.fxaaPass=new Ln(Fa),this.fxaaPass.material.uniforms.resolution.value.x=1/(e*o),this.fxaaPass.material.uniforms.resolution.value.y=1/(t*o),this.fxaaPass.enabled=!1,this.composer.addPass(this.fxaaPass)}}var Un=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qs(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function Vn(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Ri={exports:{}};var Hs;function Ga(){return Hs||(Hs=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function t(n,i,s){function o(c,h){if(!i[c]){if(!n[c]){var u=typeof Vn=="function"&&Vn;if(!h&&u)return u(c,!0);if(a)return a(c,!0);var m=new Error("Cannot find module '"+c+"'");throw m.code="MODULE_NOT_FOUND",m}var p=i[c]={exports:{}};n[c][0].call(p.exports,function(f){var d=n[c][1][f];return o(d||f)},p,p.exports,t,n,i,s)}return i[c].exports}for(var a=typeof Vn=="function"&&Vn,l=0;l<s.length;l++)o(s[l]);return o})({1:[function(t,n,i){var s=t("./utils"),o=t("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var c,h,u,m,p,f,d,g=[],y=0,v=l.length,x=v,b=s.getTypeOf(l)!=="string";y<l.length;)x=v-y,u=b?(c=l[y++],h=y<v?l[y++]:0,y<v?l[y++]:0):(c=l.charCodeAt(y++),h=y<v?l.charCodeAt(y++):0,y<v?l.charCodeAt(y++):0),m=c>>2,p=(3&c)<<4|h>>4,f=1<x?(15&h)<<2|u>>6:64,d=2<x?63&u:64,g.push(a.charAt(m)+a.charAt(p)+a.charAt(f)+a.charAt(d));return g.join("")},i.decode=function(l){var c,h,u,m,p,f,d=0,g=0,y="data:";if(l.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var v,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(v=o.uint8array?new Uint8Array(0|x):new Array(0|x);d<l.length;)c=a.indexOf(l.charAt(d++))<<2|(m=a.indexOf(l.charAt(d++)))>>4,h=(15&m)<<4|(p=a.indexOf(l.charAt(d++)))>>2,u=(3&p)<<6|(f=a.indexOf(l.charAt(d++))),v[g++]=c,p!==64&&(v[g++]=h),f!==64&&(v[g++]=u);return v}},{"./support":30,"./utils":32}],2:[function(t,n,i){var s=t("./external"),o=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(h,u,m,p,f){this.compressedSize=h,this.uncompressedSize=u,this.crc32=m,this.compression=p,this.compressedContent=f}c.prototype={getContentWorker:function(){var h=new o(s.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),u=this;return h.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),h},getCompressedWorker:function(){return new o(s.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(h,u,m){return h.pipe(new a).pipe(new l("uncompressedSize")).pipe(u.compressWorker(m)).pipe(new l("compressedSize")).withStreamInfo("compression",u)},n.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,n,i){var s=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new s("STORE compression")},uncompressWorker:function(){return new s("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,n,i){var s=t("./utils"),o=(function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var h=0;h<8;h++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l})();n.exports=function(a,l){return a!==void 0&&a.length?s.getTypeOf(a)!=="string"?(function(c,h,u,m){var p=o,f=m+u;c^=-1;for(var d=m;d<f;d++)c=c>>>8^p[255&(c^h[d])];return-1^c})(0|l,a,a.length,0):(function(c,h,u,m){var p=o,f=m+u;c^=-1;for(var d=m;d<f;d++)c=c>>>8^p[255&(c^h.charCodeAt(d))];return-1^c})(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(t,n,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(t,n,i){var s=null;s=typeof Promise<"u"?Promise:t("lie"),n.exports={Promise:s}},{lie:37}],7:[function(t,n,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),c=s?"uint8array":"array";function h(u,m){l.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=m,this.meta={}}i.magic="\b\0",a.inherits(h,l),h.prototype.processChunk=function(u){this.meta=u.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(c,u.data),!1)},h.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(m){u.push({data:m,meta:u.meta})}},i.compressWorker=function(u){return new h("Deflate",u)},i.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,n,i){function s(p,f){var d,g="";for(d=0;d<f;d++)g+=String.fromCharCode(255&p),p>>>=8;return g}function o(p,f,d,g,y,v){var x,b,_=p.file,T=p.compression,P=v!==c.utf8encode,D=a.transformTo("string",v(_.name)),k=a.transformTo("string",c.utf8encode(_.name)),E=_.comment,R=a.transformTo("string",v(E)),A=a.transformTo("string",c.utf8encode(E)),I=k.length!==_.name.length,S=A.length!==E.length,z="",U="",V="",$=_.dir,G=_.date,q={crc32:0,compressedSize:0,uncompressedSize:0};f&&!d||(q.crc32=p.crc32,q.compressedSize=p.compressedSize,q.uncompressedSize=p.uncompressedSize);var N=0;f&&(N|=8),P||!I&&!S||(N|=2048);var O=0,ee=0;$&&(O|=16),y==="UNIX"?(ee=798,O|=(function(H,ce){var fe=H;return H||(fe=ce?16893:33204),(65535&fe)<<16})(_.unixPermissions,$)):(ee=20,O|=(function(H){return 63&(H||0)})(_.dosPermissions)),x=G.getUTCHours(),x<<=6,x|=G.getUTCMinutes(),x<<=5,x|=G.getUTCSeconds()/2,b=G.getUTCFullYear()-1980,b<<=4,b|=G.getUTCMonth()+1,b<<=5,b|=G.getUTCDate(),I&&(U=s(1,1)+s(h(D),4)+k,z+="up"+s(U.length,2)+U),S&&(V=s(1,1)+s(h(R),4)+A,z+="uc"+s(V.length,2)+V);var te="";return te+=`
|
|
961
|
+
\0`,te+=s(N,2),te+=T.magic,te+=s(x,2),te+=s(b,2),te+=s(q.crc32,4),te+=s(q.compressedSize,4),te+=s(q.uncompressedSize,4),te+=s(D.length,2),te+=s(z.length,2),{fileRecord:u.LOCAL_FILE_HEADER+te+D+z,dirRecord:u.CENTRAL_FILE_HEADER+s(ee,2)+te+s(R.length,2)+"\0\0\0\0"+s(O,4)+s(g,4)+D+z+R}}var a=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),h=t("../crc32"),u=t("../signature");function m(p,f,d,g){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=f,this.zipPlatform=d,this.encodeFileName=g,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(m,l),m.prototype.push=function(p){var f=p.meta.percent||0,d=this.entriesCount,g=this._sources.length;this.accumulate?this.contentBuffer.push(p):(this.bytesWritten+=p.data.length,l.prototype.push.call(this,{data:p.data,meta:{currentFile:this.currentFile,percent:d?(f+100*(d-g-1))/d:100}}))},m.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var f=this.streamFiles&&!p.file.dir;if(f){var d=o(p,f,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:d.fileRecord,meta:{percent:0}})}else this.accumulate=!0},m.prototype.closedSource=function(p){this.accumulate=!1;var f=this.streamFiles&&!p.file.dir,d=o(p,f,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(d.dirRecord),f)this.push({data:(function(g){return u.DATA_DESCRIPTOR+s(g.crc32,4)+s(g.compressedSize,4)+s(g.uncompressedSize,4)})(p),meta:{percent:100}});else for(this.push({data:d.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},m.prototype.flush=function(){for(var p=this.bytesWritten,f=0;f<this.dirRecords.length;f++)this.push({data:this.dirRecords[f],meta:{percent:100}});var d=this.bytesWritten-p,g=(function(y,v,x,b,_){var T=a.transformTo("string",_(b));return u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+s(y,2)+s(y,2)+s(v,4)+s(x,4)+s(T.length,2)+T})(this.dirRecords.length,d,p,this.zipComment,this.encodeFileName);this.push({data:g,meta:{percent:100}})},m.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},m.prototype.registerPrevious=function(p){this._sources.push(p);var f=this;return p.on("data",function(d){f.processChunk(d)}),p.on("end",function(){f.closedSource(f.previous.streamInfo),f._sources.length?f.prepareNextSource():f.end()}),p.on("error",function(d){f.error(d)}),this},m.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},m.prototype.error=function(p){var f=this._sources;if(!l.prototype.error.call(this,p))return!1;for(var d=0;d<f.length;d++)try{f[d].error(p)}catch{}return!0},m.prototype.lock=function(){l.prototype.lock.call(this);for(var p=this._sources,f=0;f<p.length;f++)p[f].lock()},n.exports=m},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,n,i){var s=t("../compressions"),o=t("./ZipFileWorker");i.generateWorker=function(a,l,c){var h=new o(l.streamFiles,c,l.platform,l.encodeFileName),u=0;try{a.forEach(function(m,p){u++;var f=(function(v,x){var b=v||x,_=s[b];if(!_)throw new Error(b+" is not a valid compression method !");return _})(p.options.compression,l.compression),d=p.options.compressionOptions||l.compressionOptions||{},g=p.dir,y=p.date;p._compressWorker(f,d).withStreamInfo("file",{name:m,dir:g,date:y,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(h)}),h.entriesCount=u}catch(m){h.error(m)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,n,i){function s(){if(!(this instanceof s))return new s;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new s;for(var a in this)typeof this[a]!="function"&&(o[a]=this[a]);return o}}(s.prototype=t("./object")).loadAsync=t("./load"),s.support=t("./support"),s.defaults=t("./defaults"),s.version="3.10.1",s.loadAsync=function(o,a){return new s().loadAsync(o,a)},s.external=t("./external"),n.exports=s},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,n,i){var s=t("./utils"),o=t("./external"),a=t("./utf8"),l=t("./zipEntries"),c=t("./stream/Crc32Probe"),h=t("./nodejsUtils");function u(m){return new o.Promise(function(p,f){var d=m.decompressed.getContentWorker().pipe(new c);d.on("error",function(g){f(g)}).on("end",function(){d.streamInfo.crc32!==m.decompressed.crc32?f(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}n.exports=function(m,p){var f=this;return p=s.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),h.isNode&&h.isStream(m)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):s.prepareContent("the loaded zip file",m,!0,p.optimizedBinaryString,p.base64).then(function(d){var g=new l(p);return g.load(d),g}).then(function(d){var g=[o.Promise.resolve(d)],y=d.files;if(p.checkCRC32)for(var v=0;v<y.length;v++)g.push(u(y[v]));return o.Promise.all(g)}).then(function(d){for(var g=d.shift(),y=g.files,v=0;v<y.length;v++){var x=y[v],b=x.fileNameStr,_=s.resolve(x.fileNameStr);f.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:p.createFolders}),x.dir||(f.file(_).unsafeOriginalName=b)}return g.zipComment.length&&(f.comment=g.zipComment),f})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,n,i){var s=t("../utils"),o=t("../stream/GenericWorker");function a(l,c){o.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}s.inherits(a,o),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(h){c.push({data:h,meta:{percent:0}})}).on("error",function(h){c.isPaused?this.generatedError=h:c.error(h)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},n.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,n,i){var s=t("readable-stream").Readable;function o(a,l,c){s.call(this,l),this._helper=a;var h=this;a.on("data",function(u,m){h.push(u)||h._helper.pause(),c&&c(m)}).on("error",function(u){h.emit("error",u)}).on("end",function(){h.push(null)})}t("../utils").inherits(o,s),o.prototype._read=function(){this._helper.resume()},n.exports=o},{"../utils":32,"readable-stream":16}],14:[function(t,n,i){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(s,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(s,o);if(typeof s=="number")throw new Error('The "data" argument must not be a number');return new Buffer(s,o)},allocBuffer:function(s){if(Buffer.alloc)return Buffer.alloc(s);var o=new Buffer(s);return o.fill(0),o},isBuffer:function(s){return Buffer.isBuffer(s)},isStream:function(s){return s&&typeof s.on=="function"&&typeof s.pause=="function"&&typeof s.resume=="function"}}},{}],15:[function(t,n,i){function s(_,T,P){var D,k=a.getTypeOf(T),E=a.extend(P||{},h);E.date=E.date||new Date,E.compression!==null&&(E.compression=E.compression.toUpperCase()),typeof E.unixPermissions=="string"&&(E.unixPermissions=parseInt(E.unixPermissions,8)),E.unixPermissions&&16384&E.unixPermissions&&(E.dir=!0),E.dosPermissions&&16&E.dosPermissions&&(E.dir=!0),E.dir&&(_=y(_)),E.createFolders&&(D=g(_))&&v.call(this,D,!0);var R=k==="string"&&E.binary===!1&&E.base64===!1;P&&P.binary!==void 0||(E.binary=!R),(T instanceof u&&T.uncompressedSize===0||E.dir||!T||T.length===0)&&(E.base64=!1,E.binary=!0,T="",E.compression="STORE",k="string");var A=null;A=T instanceof u||T instanceof l?T:f.isNode&&f.isStream(T)?new d(_,T):a.prepareContent(_,T,E.binary,E.optimizedBinaryString,E.base64);var I=new m(_,A,E);this.files[_]=I}var o=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),c=t("./stream/StreamHelper"),h=t("./defaults"),u=t("./compressedObject"),m=t("./zipObject"),p=t("./generate"),f=t("./nodejsUtils"),d=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)!=="/"&&(_+="/"),_},v=function(_,T){return T=T!==void 0?T:h.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,D;for(T in this.files)D=this.files[T],(P=T.slice(this.root.length,T.length))&&T.slice(0,this.root.length)===this.root&&_(P,D)},filter:function(_){var T=[];return this.forEach(function(P,D){_(P,D)&&T.push(D)}),T},file:function(_,T,P){if(arguments.length!==1)return _=this.root+_,s.call(this,_,T,P),this;if(x(_)){var D=_;return this.filter(function(E,R){return!R.dir&&D.test(E)})}var k=this.files[this.root+_];return k&&!k.dir?k:null},folder:function(_){if(!_)return this;if(x(_))return this.filter(function(k,E){return E.dir&&_.test(k)});var T=this.root+_,P=v.call(this,T),D=this.clone();return D.root=P.name,D},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(k,E){return E.name.slice(0,_.length)===_}),D=0;D<P.length;D++)delete this.files[P[D].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:o.utf8encode})).type=P.type.toLowerCase(),P.compression=P.compression.toUpperCase(),P.type==="binarystring"&&(P.type="string"),!P.type)throw new Error("No output type specified.");a.checkSupport(P.type),P.platform!=="darwin"&&P.platform!=="freebsd"&&P.platform!=="linux"&&P.platform!=="sunos"||(P.platform="UNIX"),P.platform==="win32"&&(P.platform="DOS");var D=P.comment||this.comment||"";T=p.generateWorker(this,P,D)}catch(k){(T=new l("error")).error(k)}return new c(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 o(a){s.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}t("../utils").inherits(o,s),o.prototype.byteAt=function(a){return this.data[this.zero+a]},o.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),u=a.charCodeAt(3),m=this.length-4;0<=m;--m)if(this.data[m]===l&&this.data[m+1]===c&&this.data[m+2]===h&&this.data[m+3]===u)return m-this.zero;return-1},o.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),u=a.charCodeAt(3),m=this.readData(4);return l===m[0]&&c===m[1]&&h===m[2]&&u===m[3]},o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./DataReader":18}],18:[function(t,n,i){var s=t("../utils");function o(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return s.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date(Date.UTC(1980+(a>>25&127),(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1))}},n.exports=o},{"../utils":32}],19:[function(t,n,i){var s=t("./Uint8ArrayReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,n,i){var s=t("./DataReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},o.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},o.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./DataReader":18}],21:[function(t,n,i){var s=t("./ArrayReader");function o(a){s.call(this,a)}t("../utils").inherits(o,s),o.prototype.readData=function(a){if(this.checkOffset(a),a===0)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},n.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(t,n,i){var s=t("../utils"),o=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),h=t("./Uint8ArrayReader");n.exports=function(u){var m=s.getTypeOf(u);return s.checkSupport(m),m!=="string"||o.uint8array?m==="nodebuffer"?new c(u):o.uint8array?new h(s.transformTo("uint8array",u)):new a(s.transformTo("array",u)):new l(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,n,i){i.LOCAL_FILE_HEADER="PK",i.CENTRAL_FILE_HEADER="PK",i.CENTRAL_DIRECTORY_END="PK",i.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",i.ZIP64_CENTRAL_DIRECTORY_END="PK",i.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(t,n,i){var s=t("./GenericWorker"),o=t("../utils");function a(l){s.call(this,"ConvertWorker to "+l),this.destType=l}o.inherits(a,s),a.prototype.processChunk=function(l){this.push({data:o.transformTo(this.destType,l.data),meta:l.meta})},n.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,n,i){var s=t("./GenericWorker"),o=t("../crc32");function a(){s.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,s),a.prototype.processChunk=function(l){this.streamInfo.crc32=o(l.data,this.streamInfo.crc32||0),this.push(l)},n.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,n,i){var s=t("../utils"),o=t("./GenericWorker");function a(l){o.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}s.inherits(a,o),a.prototype.processChunk=function(l){if(l){var c=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=c+l.data.length}o.prototype.processChunk.call(this,l)},n.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,n,i){var s=t("../utils"),o=t("./GenericWorker");function a(l){o.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(h){c.dataIsReady=!0,c.data=h,c.max=h&&h.length||0,c.type=s.getTypeOf(h),c.isPaused||c._tickAndRepeat()},function(h){c.error(h)})}s.inherits(a,o),a.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,s.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(s.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(t,n,i){function s(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}s.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,a){return this._listeners[o].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,a){if(this._listeners[o])for(var l=0;l<this._listeners[o].length;l++)this._listeners[o][l].call(this,a)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var a=this;return o.on("data",function(l){a.processChunk(l)}),o.on("end",function(){a.end()}),o.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,a){return this.extraStreamInfo[o]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},n.exports=s},{}],29:[function(t,n,i){var s=t("../utils"),o=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),c=t("../support"),h=t("../external"),u=null;if(c.nodestream)try{u=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function m(f,d){return new h.Promise(function(g,y){var v=[],x=f._internalType,b=f._outputType,_=f._mimeType;f.on("data",function(T,P){v.push(T),d&&d(P)}).on("error",function(T){v=[],y(T)}).on("end",function(){try{var T=(function(P,D,k){switch(P){case"blob":return s.newBlob(s.transformTo("arraybuffer",D),k);case"base64":return l.encode(D);default:return s.transformTo(P,D)}})(b,(function(P,D){var k,E=0,R=null,A=0;for(k=0;k<D.length;k++)A+=D[k].length;switch(P){case"string":return D.join("");case"array":return Array.prototype.concat.apply([],D);case"uint8array":for(R=new Uint8Array(A),k=0;k<D.length;k++)R.set(D[k],E),E+=D[k].length;return R;case"nodebuffer":return Buffer.concat(D);default:throw new Error("concat : unsupported type '"+P+"'")}})(x,v),_);g(T)}catch(P){y(P)}v=[]}).resume()})}function p(f,d,g){var y=d;switch(d){case"blob":case"arraybuffer":y="uint8array";break;case"base64":y="string"}try{this._internalType=y,this._outputType=d,this._mimeType=g,s.checkSupport(y),this._worker=f.pipe(new o(y)),f.lock()}catch(v){this._worker=new a("error"),this._worker.error(v)}}p.prototype={accumulate:function(f){return m(this,f)},on:function(f,d){var g=this;return f==="data"?this._worker.on(f,function(y){d.call(g,y.data,y.meta)}):this._worker.on(f,function(){s.delay(d,arguments,g)}),this},resume:function(){return s.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(f){if(s.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:this._outputType!=="nodebuffer"},f)}},n.exports=p},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,n,i){if(i.base64=!0,i.array=!0,i.string=!0,i.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",i.nodebuffer=typeof Buffer<"u",i.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")i.blob=!1;else{var s=new ArrayBuffer(0);try{i.blob=new Blob([s],{type:"application/zip"}).size===0}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(s),i.blob=o.getBlob("application/zip").size===0}catch{i.blob=!1}}}try{i.nodestream=!!t("readable-stream").Readable}catch{i.nodestream=!1}},{"readable-stream":16}],31:[function(t,n,i){for(var s=t("./utils"),o=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),h=0;h<256;h++)c[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;c[254]=c[254]=1;function u(){l.call(this,"utf-8 decode"),this.leftOver=null}function m(){l.call(this,"utf-8 encode")}i.utf8encode=function(p){return o.nodebuffer?a.newBufferFrom(p,"utf-8"):(function(f){var d,g,y,v,x,b=f.length,_=0;for(v=0;v<b;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<b&&(64512&(y=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),_+=g<128?1:g<2048?2:g<65536?3:4;for(d=o.uint8array?new Uint8Array(_):new Array(_),v=x=0;x<_;v++)(64512&(g=f.charCodeAt(v)))==55296&&v+1<b&&(64512&(y=f.charCodeAt(v+1)))==56320&&(g=65536+(g-55296<<10)+(y-56320),v++),g<128?d[x++]=g:(g<2048?d[x++]=192|g>>>6:(g<65536?d[x++]=224|g>>>12:(d[x++]=240|g>>>18,d[x++]=128|g>>>12&63),d[x++]=128|g>>>6&63),d[x++]=128|63&g);return d})(p)},i.utf8decode=function(p){return o.nodebuffer?s.transformTo("nodebuffer",p).toString("utf-8"):(function(f){var d,g,y,v,x=f.length,b=new Array(2*x);for(d=g=0;d<x;)if((y=f[d++])<128)b[g++]=y;else if(4<(v=c[y]))b[g++]=65533,d+=v-1;else{for(y&=v===2?31:v===3?15:7;1<v&&d<x;)y=y<<6|63&f[d++],v--;1<v?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)})(p=s.transformTo(o.uint8array?"uint8array":"array",p))},s.inherits(u,l),u.prototype.processChunk=function(p){var f=s.transformTo(o.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var d=f;(f=new Uint8Array(d.length+this.leftOver.length)).set(this.leftOver,0),f.set(d,this.leftOver.length)}else f=this.leftOver.concat(f);this.leftOver=null}var g=(function(v,x){var b;for((x=x||v.length)>v.length&&(x=v.length),b=x-1;0<=b&&(192&v[b])==128;)b--;return b<0||b===0?x:b+c[v[b]]>x?b:x})(f),y=f;g!==f.length&&(o.uint8array?(y=f.subarray(0,g),this.leftOver=f.subarray(g,f.length)):(y=f.slice(0,g),this.leftOver=f.slice(g,f.length))),this.push({data:i.utf8decode(y),meta:p.meta})},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(m,l),m.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=m},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var s=t("./support"),o=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function c(d){return d}function h(d,g){for(var y=0;y<d.length;++y)g[y]=255&d.charCodeAt(y);return g}t("setimmediate"),i.newBlob=function(d,g){i.checkSupport("blob");try{return new Blob([d],{type:g})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(d),y.getBlob(g)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(d,g,y){var v=[],x=0,b=d.length;if(b<=y)return String.fromCharCode.apply(null,d);for(;x<b;)g==="array"||g==="nodebuffer"?v.push(String.fromCharCode.apply(null,d.slice(x,Math.min(x+y,b)))):v.push(String.fromCharCode.apply(null,d.subarray(x,Math.min(x+y,b)))),x+=y;return v.join("")},stringifyByChar:function(d){for(var g="",y=0;y<d.length;y++)g+=String.fromCharCode(d[y]);return g},applyCanBeUsed:{uint8array:(function(){try{return s.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return s.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function m(d){var g=65536,y=i.getTypeOf(d),v=!0;if(y==="uint8array"?v=u.applyCanBeUsed.uint8array:y==="nodebuffer"&&(v=u.applyCanBeUsed.nodebuffer),v)for(;1<g;)try{return u.stringifyByChunk(d,y,g)}catch{g=Math.floor(g/2)}return u.stringifyByChar(d)}function p(d,g){for(var y=0;y<d.length;y++)g[y]=d[y];return g}i.applyFromCharCode=m;var f={};f.string={string:c,array:function(d){return h(d,new Array(d.length))},arraybuffer:function(d){return f.string.uint8array(d).buffer},uint8array:function(d){return h(d,new Uint8Array(d.length))},nodebuffer:function(d){return h(d,a.allocBuffer(d.length))}},f.array={string:m,array:c,arraybuffer:function(d){return new Uint8Array(d).buffer},uint8array:function(d){return new Uint8Array(d)},nodebuffer:function(d){return a.newBufferFrom(d)}},f.arraybuffer={string:function(d){return m(new Uint8Array(d))},array:function(d){return p(new Uint8Array(d),new Array(d.byteLength))},arraybuffer:c,uint8array:function(d){return new Uint8Array(d)},nodebuffer:function(d){return a.newBufferFrom(new Uint8Array(d))}},f.uint8array={string:m,array:function(d){return p(d,new Array(d.length))},arraybuffer:function(d){return d.buffer},uint8array:c,nodebuffer:function(d){return a.newBufferFrom(d)}},f.nodebuffer={string:m,array:function(d){return p(d,new Array(d.length))},arraybuffer:function(d){return f.nodebuffer.uint8array(d).buffer},uint8array:function(d){return p(d,new Uint8Array(d.length))},nodebuffer:c},i.transformTo=function(d,g){if(g=g||"",!d)return g;i.checkSupport(d);var y=i.getTypeOf(g);return f[y][d](g)},i.resolve=function(d){for(var g=d.split("/"),y=[],v=0;v<g.length;v++){var x=g[v];x==="."||x===""&&v!==0&&v!==g.length-1||(x===".."?y.pop():y.push(x))}return y.join("/")},i.getTypeOf=function(d){return typeof d=="string"?"string":Object.prototype.toString.call(d)==="[object Array]"?"array":s.nodebuffer&&a.isBuffer(d)?"nodebuffer":s.uint8array&&d instanceof Uint8Array?"uint8array":s.arraybuffer&&d instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(d){if(!s[d.toLowerCase()])throw new Error(d+" is not supported by this platform")},i.MAX_VALUE_16BITS=65535,i.MAX_VALUE_32BITS=-1,i.pretty=function(d){var g,y,v="";for(y=0;y<(d||"").length;y++)v+="\\x"+((g=d.charCodeAt(y))<16?"0":"")+g.toString(16).toUpperCase();return v},i.delay=function(d,g,y){setImmediate(function(){d.apply(y||null,g||[])})},i.inherits=function(d,g){function y(){}y.prototype=g.prototype,d.prototype=new y},i.extend=function(){var d,g,y={};for(d=0;d<arguments.length;d++)for(g in arguments[d])Object.prototype.hasOwnProperty.call(arguments[d],g)&&y[g]===void 0&&(y[g]=arguments[d][g]);return y},i.prepareContent=function(d,g,y,v,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(D){_(D.target.result)},P.onerror=function(D){T(D.target.error)},P.readAsArrayBuffer(b)}):b}).then(function(b){var _=i.getTypeOf(b);return _?(_==="arraybuffer"?b=i.transformTo("uint8array",b):_==="string"&&(x?b=o.decode(b):y&&v!==!0&&(b=(function(T){return h(T,s.uint8array?new Uint8Array(T.length):new Array(T.length))})(b))),b):l.Promise.reject(new Error("Can't read the data of '"+d+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,n,i){var s=t("./reader/readerFor"),o=t("./utils"),a=t("./signature"),l=t("./zipEntry"),c=t("./support");function h(u){this.files=[],this.loadOptions=u}h.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var m=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(m)+", expected "+o.pretty(u)+")")}},isSignature:function(u,m){var p=this.reader.index;this.reader.setIndex(u);var f=this.reader.readString(4)===m;return this.reader.setIndex(p),f},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var u=this.reader.readData(this.zipCommentLength),m=c.uint8array?"uint8array":"array",p=o.transformTo(m,u);this.zipComment=this.loadOptions.decodeFileName(p)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,m,p,f=this.zip64EndOfCentralSize-44;0<f;)u=this.reader.readInt(2),m=this.reader.readInt(4),p=this.reader.readData(m),this.zip64ExtensibleData[u]={id:u,length:m,value:p}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,m;for(u=0;u<this.files.length;u++)m=this.files[u],this.reader.setIndex(m.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),m.readLocalPart(this.reader),m.handleUTF8(),m.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 m=u;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(u=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var p=this.centralDirOffset+this.centralDirSize;this.zip64&&(p+=20,p+=12+this.zip64EndOfCentralSize);var f=m-p;if(0<f)this.isSignature(m,a.CENTRAL_FILE_HEADER)||(this.reader.zero=f);else if(f<0)throw new Error("Corrupted zip: missing "+Math.abs(f)+" bytes.")},prepareReader:function(u){this.reader=s(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,n,i){var s=t("./reader/readerFor"),o=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),c=t("./utf8"),h=t("./compressions"),u=t("./support");function m(p,f){this.options=p,this.loadOptions=f}m.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var f,d;if(p.skip(22),this.fileNameLength=p.readInt(2),d=p.readInt(2),this.fileName=p.readData(this.fileNameLength),p.skip(d),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((f=(function(g){for(var y in h)if(Object.prototype.hasOwnProperty.call(h,y)&&h[y].magic===g)return h[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,f,p.readData(this.compressedSize))},readCentralPart:function(p){this.versionMadeBy=p.readInt(2),p.skip(2),this.bitFlag=p.readInt(2),this.compressionMethod=p.readString(2),this.date=p.readDate(),this.crc32=p.readInt(4),this.compressedSize=p.readInt(4),this.uncompressedSize=p.readInt(4);var f=p.readInt(2);if(this.extraFieldsLength=p.readInt(2),this.fileCommentLength=p.readInt(2),this.diskNumberStart=p.readInt(2),this.internalFileAttributes=p.readInt(2),this.externalFileAttributes=p.readInt(4),this.localHeaderOffset=p.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");p.skip(f),this.readExtraFields(p),this.parseZIP64ExtraField(p),this.fileComment=p.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var p=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),p==0&&(this.dosPermissions=63&this.externalFileAttributes),p==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var p=s(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var f,d,g,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<y;)f=p.readInt(2),d=p.readInt(2),g=p.readData(d),this.extraFields[f]={id:f,length:d,value:g};p.setIndex(y)},handleUTF8:function(){var p=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var f=this.findExtraFieldUnicodePath();if(f!==null)this.fileNameStr=f;else{var d=o.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(d)}var g=this.findExtraFieldUnicodeComment();if(g!==null)this.fileCommentStr=g;else{var y=o.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var f=s(p.value);return f.readInt(1)!==1||l(this.fileName)!==f.readInt(4)?null:c.utf8decode(f.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var f=s(p.value);return f.readInt(1)!==1||l(this.fileComment)!==f.readInt(4)?null:c.utf8decode(f.readData(p.length-5))}return null}},n.exports=m},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,n,i){function s(f,d,g){this.name=f,this.dir=g.dir,this.date=g.date,this.comment=g.comment,this.unixPermissions=g.unixPermissions,this.dosPermissions=g.dosPermissions,this._data=d,this._dataBinary=g.binary,this.options={compression:g.compression,compressionOptions:g.compressionOptions}}var o=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),c=t("./compressedObject"),h=t("./stream/GenericWorker");s.prototype={internalStream:function(f){var d=null,g="string";try{if(!f)throw new Error("No output type specified.");var y=(g=f.toLowerCase())==="string"||g==="text";g!=="binarystring"&&g!=="text"||(g="string"),d=this._decompressWorker();var v=!this._dataBinary;v&&!y&&(d=d.pipe(new l.Utf8EncodeWorker)),!v&&y&&(d=d.pipe(new l.Utf8DecodeWorker))}catch(x){(d=new h("error")).error(x)}return new o(d,g,"")},async:function(f,d){return this.internalStream(f).accumulate(d)},nodeStream:function(f,d){return this.internalStream(f||"nodebuffer").toNodejsStream(d)},_compressWorker:function(f,d){if(this._data instanceof c&&this._data.compression.magic===f.magic)return this._data.getCompressedWorker();var g=this._decompressWorker();return this._dataBinary||(g=g.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(g,f,d)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof h?this._data:new a(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],m=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<u.length;p++)s.prototype[u[p]]=m;n.exports=s},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,n,i){(function(s){var o,a,l=s.MutationObserver||s.WebKitMutationObserver;if(l){var c=0,h=new l(f),u=s.document.createTextNode("");h.observe(u,{characterData:!0}),o=function(){u.data=c=++c%2}}else if(s.setImmediate||s.MessageChannel===void 0)o="document"in s&&"onreadystatechange"in s.document.createElement("script")?function(){var d=s.document.createElement("script");d.onreadystatechange=function(){f(),d.onreadystatechange=null,d.parentNode.removeChild(d),d=null},s.document.documentElement.appendChild(d)}:function(){setTimeout(f,0)};else{var m=new s.MessageChannel;m.port1.onmessage=f,o=function(){m.port2.postMessage(0)}}var p=[];function f(){var d,g;a=!0;for(var y=p.length;y;){for(g=p,p=[],d=-1;++d<y;)g[d]();y=p.length}a=!1}n.exports=function(d){p.push(d)!==1||a||o()}}).call(this,typeof Un<"u"?Un:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,n,i){var s=t("immediate");function o(){}var a={},l=["REJECTED"],c=["FULFILLED"],h=["PENDING"];function u(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,y!==o&&d(this,y)}function m(y,v,x){this.promise=y,typeof v=="function"&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),typeof x=="function"&&(this.onRejected=x,this.callRejected=this.otherCallRejected)}function p(y,v,x){s(function(){var b;try{b=v(x)}catch(_){return a.reject(y,_)}b===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,b)})}function f(y){var v=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof v=="function")return function(){v.apply(y,arguments)}}function d(y,v){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(){v(_,b)});T.status==="error"&&b(T.value)}function g(y,v){var x={};try{x.value=y(v),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 v=this.constructor;return this.then(function(x){return v.resolve(y()).then(function(){return x})},function(x){return v.resolve(y()).then(function(){throw x})})},u.prototype.catch=function(y){return this.then(null,y)},u.prototype.then=function(y,v){if(typeof y!="function"&&this.state===c||typeof v!="function"&&this.state===l)return this;var x=new this.constructor(o);return this.state!==h?p(x,this.state===c?y:v,this.outcome):this.queue.push(new m(x,y,v)),x},m.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},m.prototype.otherCallFulfilled=function(y){p(this.promise,this.onFulfilled,y)},m.prototype.callRejected=function(y){a.reject(this.promise,y)},m.prototype.otherCallRejected=function(y){p(this.promise,this.onRejected,y)},a.resolve=function(y,v){var x=g(f,v);if(x.status==="error")return a.reject(y,x.value);var b=x.value;if(b)d(y,b);else{y.state=c,y.outcome=v;for(var _=-1,T=y.queue.length;++_<T;)y.queue[_].callFulfilled(v)}return y},a.reject=function(y,v){y.state=l,y.outcome=v;for(var x=-1,b=y.queue.length;++x<b;)y.queue[x].callRejected(v);return y},u.resolve=function(y){return y instanceof this?y:a.resolve(new this(o),y)},u.reject=function(y){var v=new this(o);return a.reject(v,y)},u.all=function(y){var v=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,D=new this(o);++P<x;)k(y[P],P);return D;function k(E,R){v.resolve(E).then(function(A){_[R]=A,++T!==x||b||(b=!0,a.resolve(D,_))},function(A){b||(b=!0,a.reject(D,A))})}},u.race=function(y){var v=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(o);++_<x;)P=y[_],v.resolve(P).then(function(D){b||(b=!0,a.resolve(T,D))},function(D){b||(b=!0,a.reject(T,D))});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"),o=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/messages"),c=t("./zlib/zstream"),h=Object.prototype.toString,u=0,m=-1,p=0,f=8;function d(y){if(!(this instanceof d))return new d(y);this.options=o.assign({level:m,method:f,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},y||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var x=s.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(x!==u)throw new Error(l[x]);if(v.header&&s.deflateSetHeader(this.strm,v.header),v.dictionary){var b;if(b=typeof v.dictionary=="string"?a.string2buf(v.dictionary):h.call(v.dictionary)==="[object ArrayBuffer]"?new Uint8Array(v.dictionary):v.dictionary,(x=s.deflateSetDictionary(this.strm,b))!==u)throw new Error(l[x]);this._dict_set=!0}}function g(y,v){var x=new d(v);if(x.push(y,!0),x.err)throw x.msg||l[x.err];return x.result}d.prototype.push=function(y,v){var x,b,_=this.strm,T=this.options.chunkSize;if(this.ended)return!1;b=v===~~v?v:v===!0?4:0,typeof y=="string"?_.input=a.string2buf(y):h.call(y)==="[object ArrayBuffer]"?_.input=new Uint8Array(y):_.input=y,_.next_in=0,_.avail_in=_.input.length;do{if(_.avail_out===0&&(_.output=new o.Buf8(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(o.shrinkBuf(_.output,_.next_out))):this.onData(o.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))},d.prototype.onData=function(y){this.chunks.push(y)},d.prototype.onEnd=function(y){y===u&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=d,i.deflate=g,i.deflateRaw=function(y,v){return(v=v||{}).raw=!0,g(y,v)},i.gzip=function(y,v){return(v=v||{}).gzip=!0,g(y,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,n,i){var s=t("./zlib/inflate"),o=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),c=t("./zlib/messages"),h=t("./zlib/zstream"),u=t("./zlib/gzheader"),m=Object.prototype.toString;function p(d){if(!(this instanceof p))return new p(d);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},d||{});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)||d&&d.windowBits||(g.windowBits+=32),15<g.windowBits&&g.windowBits<48&&(15&g.windowBits)==0&&(g.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var y=s.inflateInit2(this.strm,g.windowBits);if(y!==l.Z_OK)throw new Error(c[y]);this.header=new u,s.inflateGetHeader(this.strm,this.header)}function f(d,g){var y=new p(g);if(y.push(d,!0),y.err)throw y.msg||c[y.err];return y.result}p.prototype.push=function(d,g){var y,v,x,b,_,T,P=this.strm,D=this.options.chunkSize,k=this.options.dictionary,E=!1;if(this.ended)return!1;v=g===~~g?g:g===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof d=="string"?P.input=a.binstring2buf(d):m.call(d)==="[object ArrayBuffer]"?P.input=new Uint8Array(d):P.input=d,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new o.Buf8(D),P.next_out=0,P.avail_out=D),(y=s.inflate(P,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&k&&(T=typeof k=="string"?a.string2buf(k):m.call(k)==="[object ArrayBuffer]"?new Uint8Array(k):k,y=s.inflateSetDictionary(this.strm,T)),y===l.Z_BUF_ERROR&&E===!0&&(y=l.Z_OK,E=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);P.next_out&&(P.avail_out!==0&&y!==l.Z_STREAM_END&&(P.avail_in!==0||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(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=D-b,b&&o.arraySet(P.output,P.output,x,b,0),this.onData(_)):this.onData(o.shrinkBuf(P.output,P.next_out)))),P.avail_in===0&&P.avail_out===0&&(E=!0)}while((0<P.avail_in||P.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(y=s.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(P.avail_out=0))},p.prototype.onData=function(d){this.chunks.push(d)},p.prototype.onEnd=function(d){d===l.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=o.flattenChunks(this.chunks)),this.chunks=[],this.err=d,this.msg=this.strm.msg},i.Inflate=p,i.inflate=f,i.inflateRaw=function(d,g){return(g=g||{}).raw=!0,f(d,g)},i.ungzip=f},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,n,i){var s=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var h=c.shift();if(h){if(typeof h!="object")throw new TypeError(h+"must be non-object");for(var u in h)h.hasOwnProperty(u)&&(l[u]=h[u])}}return l},i.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var o={arraySet:function(l,c,h,u,m){if(c.subarray&&l.subarray)l.set(c.subarray(h,h+u),m);else for(var p=0;p<u;p++)l[m+p]=c[h+p]},flattenChunks:function(l){var c,h,u,m,p,f;for(c=u=0,h=l.length;c<h;c++)u+=l[c].length;for(f=new Uint8Array(u),c=m=0,h=l.length;c<h;c++)p=l[c],f.set(p,m),m+=p.length;return f}},a={arraySet:function(l,c,h,u,m){for(var p=0;p<u;p++)l[m+p]=c[h+p]},flattenChunks:function(l){return[].concat.apply([],l)}};i.setTyped=function(l){l?(i.Buf8=Uint8Array,i.Buf16=Uint16Array,i.Buf32=Int32Array,i.assign(i,o)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,a))},i.setTyped(s)},{}],42:[function(t,n,i){var s=t("./common"),o=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new s.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function h(u,m){if(m<65537&&(u.subarray&&a||!u.subarray&&o))return String.fromCharCode.apply(null,s.shrinkBuf(u,m));for(var p="",f=0;f<m;f++)p+=String.fromCharCode(u[f]);return p}l[254]=l[254]=1,i.string2buf=function(u){var m,p,f,d,g,y=u.length,v=0;for(d=0;d<y;d++)(64512&(p=u.charCodeAt(d)))==55296&&d+1<y&&(64512&(f=u.charCodeAt(d+1)))==56320&&(p=65536+(p-55296<<10)+(f-56320),d++),v+=p<128?1:p<2048?2:p<65536?3:4;for(m=new s.Buf8(v),d=g=0;g<v;d++)(64512&(p=u.charCodeAt(d)))==55296&&d+1<y&&(64512&(f=u.charCodeAt(d+1)))==56320&&(p=65536+(p-55296<<10)+(f-56320),d++),p<128?m[g++]=p:(p<2048?m[g++]=192|p>>>6:(p<65536?m[g++]=224|p>>>12:(m[g++]=240|p>>>18,m[g++]=128|p>>>12&63),m[g++]=128|p>>>6&63),m[g++]=128|63&p);return m},i.buf2binstring=function(u){return h(u,u.length)},i.binstring2buf=function(u){for(var m=new s.Buf8(u.length),p=0,f=m.length;p<f;p++)m[p]=u.charCodeAt(p);return m},i.buf2string=function(u,m){var p,f,d,g,y=m||u.length,v=new Array(2*y);for(p=f=0;p<y;)if((d=u[p++])<128)v[f++]=d;else if(4<(g=l[d]))v[f++]=65533,p+=g-1;else{for(d&=g===2?31:g===3?15:7;1<g&&p<y;)d=d<<6|63&u[p++],g--;1<g?v[f++]=65533:d<65536?v[f++]=d:(d-=65536,v[f++]=55296|d>>10&1023,v[f++]=56320|1023&d)}return h(v,f)},i.utf8border=function(u,m){var p;for((m=m||u.length)>u.length&&(m=u.length),p=m-1;0<=p&&(192&u[p])==128;)p--;return p<0||p===0?m:p+l[u[p]]>m?p:m}},{"./common":41}],43:[function(t,n,i){n.exports=function(s,o,a,l){for(var c=65535&s|0,h=s>>>16&65535|0,u=0;a!==0;){for(a-=u=2e3<a?2e3:a;h=h+(c=c+o[l++]|0)|0,--u;);c%=65521,h%=65521}return c|h<<16|0}},{}],44:[function(t,n,i){n.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(t,n,i){var s=(function(){for(var o,a=[],l=0;l<256;l++){o=l;for(var c=0;c<8;c++)o=1&o?3988292384^o>>>1:o>>>1;a[l]=o}return a})();n.exports=function(o,a,l,c){var h=s,u=c+l;o^=-1;for(var m=c;m<u;m++)o=o>>>8^h[255&(o^a[m])];return-1^o}},{}],46:[function(t,n,i){var s,o=t("../utils/common"),a=t("./trees"),l=t("./adler32"),c=t("./crc32"),h=t("./messages"),u=0,m=4,p=0,f=-2,d=-1,g=4,y=2,v=8,x=9,b=286,_=30,T=19,P=2*b+1,D=15,k=3,E=258,R=E+k+1,A=42,I=113,S=1,z=2,U=3,V=4;function $(C,Z){return C.msg=h[Z],Z}function G(C){return(C<<1)-(4<C?9:0)}function q(C){for(var Z=C.length;0<=--Z;)C[Z]=0}function N(C){var Z=C.state,X=Z.pending;X>C.avail_out&&(X=C.avail_out),X!==0&&(o.arraySet(C.output,Z.pending_buf,Z.pending_out,X,C.next_out),C.next_out+=X,Z.pending_out+=X,C.total_out+=X,C.avail_out-=X,Z.pending-=X,Z.pending===0&&(Z.pending_out=0))}function O(C,Z){a._tr_flush_block(C,0<=C.block_start?C.block_start:-1,C.strstart-C.block_start,Z),C.block_start=C.strstart,N(C.strm)}function ee(C,Z){C.pending_buf[C.pending++]=Z}function te(C,Z){C.pending_buf[C.pending++]=Z>>>8&255,C.pending_buf[C.pending++]=255&Z}function H(C,Z){var X,B,L=C.max_chain_length,F=C.strstart,Y=C.prev_length,K=C.nice_match,j=C.strstart>C.w_size-R?C.strstart-(C.w_size-R):0,J=C.window,ne=C.w_mask,Q=C.prev,ie=C.strstart+E,he=J[F+Y-1],ae=J[F+Y];C.prev_length>=C.good_match&&(L>>=2),K>C.lookahead&&(K=C.lookahead);do if(J[(X=Z)+Y]===ae&&J[X+Y-1]===he&&J[X]===J[F]&&J[++X]===J[F+1]){F+=2,X++;do;while(J[++F]===J[++X]&&J[++F]===J[++X]&&J[++F]===J[++X]&&J[++F]===J[++X]&&J[++F]===J[++X]&&J[++F]===J[++X]&&J[++F]===J[++X]&&J[++F]===J[++X]&&F<ie);if(B=E-(ie-F),F=ie-E,Y<B){if(C.match_start=Z,K<=(Y=B))break;he=J[F+Y-1],ae=J[F+Y]}}while((Z=Q[Z&ne])>j&&--L!=0);return Y<=C.lookahead?Y:C.lookahead}function ce(C){var Z,X,B,L,F,Y,K,j,J,ne,Q=C.w_size;do{if(L=C.window_size-C.lookahead-C.strstart,C.strstart>=Q+(Q-R)){for(o.arraySet(C.window,C.window,Q,Q,0),C.match_start-=Q,C.strstart-=Q,C.block_start-=Q,Z=X=C.hash_size;B=C.head[--Z],C.head[Z]=Q<=B?B-Q:0,--X;);for(Z=X=Q;B=C.prev[--Z],C.prev[Z]=Q<=B?B-Q:0,--X;);L+=Q}if(C.strm.avail_in===0)break;if(Y=C.strm,K=C.window,j=C.strstart+C.lookahead,J=L,ne=void 0,ne=Y.avail_in,J<ne&&(ne=J),X=ne===0?0:(Y.avail_in-=ne,o.arraySet(K,Y.input,Y.next_in,ne,j),Y.state.wrap===1?Y.adler=l(Y.adler,K,ne,j):Y.state.wrap===2&&(Y.adler=c(Y.adler,K,ne,j)),Y.next_in+=ne,Y.total_in+=ne,ne),C.lookahead+=X,C.lookahead+C.insert>=k)for(F=C.strstart-C.insert,C.ins_h=C.window[F],C.ins_h=(C.ins_h<<C.hash_shift^C.window[F+1])&C.hash_mask;C.insert&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[F+k-1])&C.hash_mask,C.prev[F&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=F,F++,C.insert--,!(C.lookahead+C.insert<k)););}while(C.lookahead<R&&C.strm.avail_in!==0)}function fe(C,Z){for(var X,B;;){if(C.lookahead<R){if(ce(C),C.lookahead<R&&Z===u)return S;if(C.lookahead===0)break}if(X=0,C.lookahead>=k&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+k-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),X!==0&&C.strstart-X<=C.w_size-R&&(C.match_length=H(C,X)),C.match_length>=k)if(B=a._tr_tally(C,C.strstart-C.match_start,C.match_length-k),C.lookahead-=C.match_length,C.match_length<=C.max_lazy_match&&C.lookahead>=k){for(C.match_length--;C.strstart++,C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+k-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart,--C.match_length!=0;);C.strstart++}else C.strstart+=C.match_length,C.match_length=0,C.ins_h=C.window[C.strstart],C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+1])&C.hash_mask;else B=a._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++;if(B&&(O(C,!1),C.strm.avail_out===0))return S}return C.insert=C.strstart<k-1?C.strstart:k-1,Z===m?(O(C,!0),C.strm.avail_out===0?U:V):C.last_lit&&(O(C,!1),C.strm.avail_out===0)?S:z}function se(C,Z){for(var X,B,L;;){if(C.lookahead<R){if(ce(C),C.lookahead<R&&Z===u)return S;if(C.lookahead===0)break}if(X=0,C.lookahead>=k&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+k-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),C.prev_length=C.match_length,C.prev_match=C.match_start,C.match_length=k-1,X!==0&&C.prev_length<C.max_lazy_match&&C.strstart-X<=C.w_size-R&&(C.match_length=H(C,X),C.match_length<=5&&(C.strategy===1||C.match_length===k&&4096<C.strstart-C.match_start)&&(C.match_length=k-1)),C.prev_length>=k&&C.match_length<=C.prev_length){for(L=C.strstart+C.lookahead-k,B=a._tr_tally(C,C.strstart-1-C.prev_match,C.prev_length-k),C.lookahead-=C.prev_length-1,C.prev_length-=2;++C.strstart<=L&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+k-1])&C.hash_mask,X=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),--C.prev_length!=0;);if(C.match_available=0,C.match_length=k-1,C.strstart++,B&&(O(C,!1),C.strm.avail_out===0))return S}else if(C.match_available){if((B=a._tr_tally(C,0,C.window[C.strstart-1]))&&O(C,!1),C.strstart++,C.lookahead--,C.strm.avail_out===0)return S}else C.match_available=1,C.strstart++,C.lookahead--}return C.match_available&&(B=a._tr_tally(C,0,C.window[C.strstart-1]),C.match_available=0),C.insert=C.strstart<k-1?C.strstart:k-1,Z===m?(O(C,!0),C.strm.avail_out===0?U:V):C.last_lit&&(O(C,!1),C.strm.avail_out===0)?S:z}function re(C,Z,X,B,L){this.good_length=C,this.max_lazy=Z,this.nice_length=X,this.max_chain=B,this.func=L}function de(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=v,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(2*P),this.dyn_dtree=new o.Buf16(2*(2*_+1)),this.bl_tree=new o.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 o.Buf16(D+1),this.heap=new o.Buf16(2*b+1),q(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.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(C){var Z;return C&&C.state?(C.total_in=C.total_out=0,C.data_type=y,(Z=C.state).pending=0,Z.pending_out=0,Z.wrap<0&&(Z.wrap=-Z.wrap),Z.status=Z.wrap?A:I,C.adler=Z.wrap===2?0:1,Z.last_flush=u,a._tr_init(Z),p):$(C,f)}function Ae(C){var Z=pe(C);return Z===p&&(function(X){X.window_size=2*X.w_size,q(X.head),X.max_lazy_match=s[X.level].max_lazy,X.good_match=s[X.level].good_length,X.nice_match=s[X.level].nice_length,X.max_chain_length=s[X.level].max_chain,X.strstart=0,X.block_start=0,X.lookahead=0,X.insert=0,X.match_length=X.prev_length=k-1,X.match_available=0,X.ins_h=0})(C.state),Z}function Be(C,Z,X,B,L,F){if(!C)return f;var Y=1;if(Z===d&&(Z=6),B<0?(Y=0,B=-B):15<B&&(Y=2,B-=16),L<1||x<L||X!==v||B<8||15<B||Z<0||9<Z||F<0||g<F)return $(C,f);B===8&&(B=9);var K=new de;return(C.state=K).strm=C,K.wrap=Y,K.gzhead=null,K.w_bits=B,K.w_size=1<<K.w_bits,K.w_mask=K.w_size-1,K.hash_bits=L+7,K.hash_size=1<<K.hash_bits,K.hash_mask=K.hash_size-1,K.hash_shift=~~((K.hash_bits+k-1)/k),K.window=new o.Buf8(2*K.w_size),K.head=new o.Buf16(K.hash_size),K.prev=new o.Buf16(K.w_size),K.lit_bufsize=1<<L+6,K.pending_buf_size=4*K.lit_bufsize,K.pending_buf=new o.Buf8(K.pending_buf_size),K.d_buf=1*K.lit_bufsize,K.l_buf=3*K.lit_bufsize,K.level=Z,K.strategy=F,K.method=X,Ae(C)}s=[new re(0,0,0,0,function(C,Z){var X=65535;for(X>C.pending_buf_size-5&&(X=C.pending_buf_size-5);;){if(C.lookahead<=1){if(ce(C),C.lookahead===0&&Z===u)return S;if(C.lookahead===0)break}C.strstart+=C.lookahead,C.lookahead=0;var B=C.block_start+X;if((C.strstart===0||C.strstart>=B)&&(C.lookahead=C.strstart-B,C.strstart=B,O(C,!1),C.strm.avail_out===0)||C.strstart-C.block_start>=C.w_size-R&&(O(C,!1),C.strm.avail_out===0))return S}return C.insert=0,Z===m?(O(C,!0),C.strm.avail_out===0?U:V):(C.strstart>C.block_start&&(O(C,!1),C.strm.avail_out),S)}),new re(4,4,8,4,fe),new re(4,5,16,8,fe),new re(4,6,32,32,fe),new re(4,4,16,16,se),new re(8,16,32,32,se),new re(8,16,128,128,se),new re(8,32,128,256,se),new re(32,128,258,1024,se),new re(32,258,258,4096,se)],i.deflateInit=function(C,Z){return Be(C,Z,v,15,8,0)},i.deflateInit2=Be,i.deflateReset=Ae,i.deflateResetKeep=pe,i.deflateSetHeader=function(C,Z){return C&&C.state?C.state.wrap!==2?f:(C.state.gzhead=Z,p):f},i.deflate=function(C,Z){var X,B,L,F;if(!C||!C.state||5<Z||Z<0)return C?$(C,f):f;if(B=C.state,!C.output||!C.input&&C.avail_in!==0||B.status===666&&Z!==m)return $(C,C.avail_out===0?-5:f);if(B.strm=C,X=B.last_flush,B.last_flush=Z,B.status===A)if(B.wrap===2)C.adler=0,ee(B,31),ee(B,139),ee(B,8),B.gzhead?(ee(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)),ee(B,255&B.gzhead.time),ee(B,B.gzhead.time>>8&255),ee(B,B.gzhead.time>>16&255),ee(B,B.gzhead.time>>24&255),ee(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ee(B,255&B.gzhead.os),B.gzhead.extra&&B.gzhead.extra.length&&(ee(B,255&B.gzhead.extra.length),ee(B,B.gzhead.extra.length>>8&255)),B.gzhead.hcrc&&(C.adler=c(C.adler,B.pending_buf,B.pending,0)),B.gzindex=0,B.status=69):(ee(B,0),ee(B,0),ee(B,0),ee(B,0),ee(B,0),ee(B,B.level===9?2:2<=B.strategy||B.level<2?4:0),ee(B,3),B.status=I);else{var Y=v+(B.w_bits-8<<4)<<8;Y|=(2<=B.strategy||B.level<2?0:B.level<6?1:B.level===6?2:3)<<6,B.strstart!==0&&(Y|=32),Y+=31-Y%31,B.status=I,te(B,Y),B.strstart!==0&&(te(B,C.adler>>>16),te(B,65535&C.adler)),C.adler=1}if(B.status===69)if(B.gzhead.extra){for(L=B.pending;B.gzindex<(65535&B.gzhead.extra.length)&&(B.pending!==B.pending_buf_size||(B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),N(C),L=B.pending,B.pending!==B.pending_buf_size));)ee(B,255&B.gzhead.extra[B.gzindex]),B.gzindex++;B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),B.gzindex===B.gzhead.extra.length&&(B.gzindex=0,B.status=73)}else B.status=73;if(B.status===73)if(B.gzhead.name){L=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),N(C),L=B.pending,B.pending===B.pending_buf_size)){F=1;break}F=B.gzindex<B.gzhead.name.length?255&B.gzhead.name.charCodeAt(B.gzindex++):0,ee(B,F)}while(F!==0);B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),F===0&&(B.gzindex=0,B.status=91)}else B.status=91;if(B.status===91)if(B.gzhead.comment){L=B.pending;do{if(B.pending===B.pending_buf_size&&(B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),N(C),L=B.pending,B.pending===B.pending_buf_size)){F=1;break}F=B.gzindex<B.gzhead.comment.length?255&B.gzhead.comment.charCodeAt(B.gzindex++):0,ee(B,F)}while(F!==0);B.gzhead.hcrc&&B.pending>L&&(C.adler=c(C.adler,B.pending_buf,B.pending-L,L)),F===0&&(B.status=103)}else B.status=103;if(B.status===103&&(B.gzhead.hcrc?(B.pending+2>B.pending_buf_size&&N(C),B.pending+2<=B.pending_buf_size&&(ee(B,255&C.adler),ee(B,C.adler>>8&255),C.adler=0,B.status=I)):B.status=I),B.pending!==0){if(N(C),C.avail_out===0)return B.last_flush=-1,p}else if(C.avail_in===0&&G(Z)<=G(X)&&Z!==m)return $(C,-5);if(B.status===666&&C.avail_in!==0)return $(C,-5);if(C.avail_in!==0||B.lookahead!==0||Z!==u&&B.status!==666){var K=B.strategy===2?(function(j,J){for(var ne;;){if(j.lookahead===0&&(ce(j),j.lookahead===0)){if(J===u)return S;break}if(j.match_length=0,ne=a._tr_tally(j,0,j.window[j.strstart]),j.lookahead--,j.strstart++,ne&&(O(j,!1),j.strm.avail_out===0))return S}return j.insert=0,J===m?(O(j,!0),j.strm.avail_out===0?U:V):j.last_lit&&(O(j,!1),j.strm.avail_out===0)?S:z})(B,Z):B.strategy===3?(function(j,J){for(var ne,Q,ie,he,ae=j.window;;){if(j.lookahead<=E){if(ce(j),j.lookahead<=E&&J===u)return S;if(j.lookahead===0)break}if(j.match_length=0,j.lookahead>=k&&0<j.strstart&&(Q=ae[ie=j.strstart-1])===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]){he=j.strstart+E;do;while(Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&Q===ae[++ie]&&ie<he);j.match_length=E-(he-ie),j.match_length>j.lookahead&&(j.match_length=j.lookahead)}if(j.match_length>=k?(ne=a._tr_tally(j,1,j.match_length-k),j.lookahead-=j.match_length,j.strstart+=j.match_length,j.match_length=0):(ne=a._tr_tally(j,0,j.window[j.strstart]),j.lookahead--,j.strstart++),ne&&(O(j,!1),j.strm.avail_out===0))return S}return j.insert=0,J===m?(O(j,!0),j.strm.avail_out===0?U:V):j.last_lit&&(O(j,!1),j.strm.avail_out===0)?S:z})(B,Z):s[B.level].func(B,Z);if(K!==U&&K!==V||(B.status=666),K===S||K===U)return C.avail_out===0&&(B.last_flush=-1),p;if(K===z&&(Z===1?a._tr_align(B):Z!==5&&(a._tr_stored_block(B,0,0,!1),Z===3&&(q(B.head),B.lookahead===0&&(B.strstart=0,B.block_start=0,B.insert=0))),N(C),C.avail_out===0))return B.last_flush=-1,p}return Z!==m?p:B.wrap<=0?1:(B.wrap===2?(ee(B,255&C.adler),ee(B,C.adler>>8&255),ee(B,C.adler>>16&255),ee(B,C.adler>>24&255),ee(B,255&C.total_in),ee(B,C.total_in>>8&255),ee(B,C.total_in>>16&255),ee(B,C.total_in>>24&255)):(te(B,C.adler>>>16),te(B,65535&C.adler)),N(C),0<B.wrap&&(B.wrap=-B.wrap),B.pending!==0?p:1)},i.deflateEnd=function(C){var Z;return C&&C.state?(Z=C.state.status)!==A&&Z!==69&&Z!==73&&Z!==91&&Z!==103&&Z!==I&&Z!==666?$(C,f):(C.state=null,Z===I?$(C,-3):p):f},i.deflateSetDictionary=function(C,Z){var X,B,L,F,Y,K,j,J,ne=Z.length;if(!C||!C.state||(F=(X=C.state).wrap)===2||F===1&&X.status!==A||X.lookahead)return f;for(F===1&&(C.adler=l(C.adler,Z,ne,0)),X.wrap=0,ne>=X.w_size&&(F===0&&(q(X.head),X.strstart=0,X.block_start=0,X.insert=0),J=new o.Buf8(X.w_size),o.arraySet(J,Z,ne-X.w_size,X.w_size,0),Z=J,ne=X.w_size),Y=C.avail_in,K=C.next_in,j=C.input,C.avail_in=ne,C.next_in=0,C.input=Z,ce(X);X.lookahead>=k;){for(B=X.strstart,L=X.lookahead-(k-1);X.ins_h=(X.ins_h<<X.hash_shift^X.window[B+k-1])&X.hash_mask,X.prev[B&X.w_mask]=X.head[X.ins_h],X.head[X.ins_h]=B,B++,--L;);X.strstart=B,X.lookahead=k-1,ce(X)}return X.strstart+=X.lookahead,X.block_start=X.strstart,X.insert=X.lookahead,X.lookahead=0,X.match_length=X.prev_length=k-1,X.match_available=0,C.next_in=K,C.input=j,C.avail_in=Y,X.wrap=F,p},i.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,n,i){n.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(t,n,i){n.exports=function(s,o){var a,l,c,h,u,m,p,f,d,g,y,v,x,b,_,T,P,D,k,E,R,A,I,S,z;a=s.state,l=s.next_in,S=s.input,c=l+(s.avail_in-5),h=s.next_out,z=s.output,u=h-(o-s.avail_out),m=h+(s.avail_out-257),p=a.dmax,f=a.wsize,d=a.whave,g=a.wnext,y=a.window,v=a.hold,x=a.bits,b=a.lencode,_=a.distcode,T=(1<<a.lenbits)-1,P=(1<<a.distbits)-1;e:do{x<15&&(v+=S[l++]<<x,x+=8,v+=S[l++]<<x,x+=8),D=b[v&T];t:for(;;){if(v>>>=k=D>>>24,x-=k,(k=D>>>16&255)===0)z[h++]=65535&D;else{if(!(16&k)){if((64&k)==0){D=b[(65535&D)+(v&(1<<k)-1)];continue t}if(32&k){a.mode=12;break e}s.msg="invalid literal/length code",a.mode=30;break e}E=65535&D,(k&=15)&&(x<k&&(v+=S[l++]<<x,x+=8),E+=v&(1<<k)-1,v>>>=k,x-=k),x<15&&(v+=S[l++]<<x,x+=8,v+=S[l++]<<x,x+=8),D=_[v&P];n:for(;;){if(v>>>=k=D>>>24,x-=k,!(16&(k=D>>>16&255))){if((64&k)==0){D=_[(65535&D)+(v&(1<<k)-1)];continue n}s.msg="invalid distance code",a.mode=30;break e}if(R=65535&D,x<(k&=15)&&(v+=S[l++]<<x,(x+=8)<k&&(v+=S[l++]<<x,x+=8)),p<(R+=v&(1<<k)-1)){s.msg="invalid distance too far back",a.mode=30;break e}if(v>>>=k,x-=k,(k=h-u)<R){if(d<(k=R-k)&&a.sane){s.msg="invalid distance too far back",a.mode=30;break e}if(I=y,(A=0)===g){if(A+=f-k,k<E){for(E-=k;z[h++]=y[A++],--k;);A=h-R,I=z}}else if(g<k){if(A+=f+g-k,(k-=g)<E){for(E-=k;z[h++]=y[A++],--k;);if(A=0,g<E){for(E-=k=g;z[h++]=y[A++],--k;);A=h-R,I=z}}}else if(A+=g-k,k<E){for(E-=k;z[h++]=y[A++],--k;);A=h-R,I=z}for(;2<E;)z[h++]=I[A++],z[h++]=I[A++],z[h++]=I[A++],E-=3;E&&(z[h++]=I[A++],1<E&&(z[h++]=I[A++]))}else{for(A=h-R;z[h++]=z[A++],z[h++]=z[A++],z[h++]=z[A++],2<(E-=3););E&&(z[h++]=z[A++],1<E&&(z[h++]=z[A++]))}break}}break}}while(l<c&&h<m);l-=E=x>>3,v&=(1<<(x-=E<<3))-1,s.next_in=l,s.next_out=h,s.avail_in=l<c?c-l+5:5-(l-c),s.avail_out=h<m?m-h+257:257-(h-m),a.hold=v,a.bits=x}},{}],49:[function(t,n,i){var s=t("../utils/common"),o=t("./adler32"),a=t("./crc32"),l=t("./inffast"),c=t("./inftrees"),h=1,u=2,m=0,p=-2,f=1,d=852,g=592;function y(A){return(A>>>24&255)+(A>>>8&65280)+((65280&A)<<8)+((255&A)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new s.Buf16(320),this.work=new s.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function x(A){var I;return A&&A.state?(I=A.state,A.total_in=A.total_out=I.total=0,A.msg="",I.wrap&&(A.adler=1&I.wrap),I.mode=f,I.last=0,I.havedict=0,I.dmax=32768,I.head=null,I.hold=0,I.bits=0,I.lencode=I.lendyn=new s.Buf32(d),I.distcode=I.distdyn=new s.Buf32(g),I.sane=1,I.back=-1,m):p}function b(A){var I;return A&&A.state?((I=A.state).wsize=0,I.whave=0,I.wnext=0,x(A)):p}function _(A,I){var S,z;return A&&A.state?(z=A.state,I<0?(S=0,I=-I):(S=1+(I>>4),I<48&&(I&=15)),I&&(I<8||15<I)?p:(z.window!==null&&z.wbits!==I&&(z.window=null),z.wrap=S,z.wbits=I,b(A))):p}function T(A,I){var S,z;return A?(z=new v,(A.state=z).window=null,(S=_(A,I))!==m&&(A.state=null),S):p}var P,D,k=!0;function E(A){if(k){var I;for(P=new s.Buf32(512),D=new s.Buf32(32),I=0;I<144;)A.lens[I++]=8;for(;I<256;)A.lens[I++]=9;for(;I<280;)A.lens[I++]=7;for(;I<288;)A.lens[I++]=8;for(c(h,A.lens,0,288,P,0,A.work,{bits:9}),I=0;I<32;)A.lens[I++]=5;c(u,A.lens,0,32,D,0,A.work,{bits:5}),k=!1}A.lencode=P,A.lenbits=9,A.distcode=D,A.distbits=5}function R(A,I,S,z){var U,V=A.state;return V.window===null&&(V.wsize=1<<V.wbits,V.wnext=0,V.whave=0,V.window=new s.Buf8(V.wsize)),z>=V.wsize?(s.arraySet(V.window,I,S-V.wsize,V.wsize,0),V.wnext=0,V.whave=V.wsize):(z<(U=V.wsize-V.wnext)&&(U=z),s.arraySet(V.window,I,S-z,U,V.wnext),(z-=U)?(s.arraySet(V.window,I,S-z,z,0),V.wnext=z,V.whave=V.wsize):(V.wnext+=U,V.wnext===V.wsize&&(V.wnext=0),V.whave<V.wsize&&(V.whave+=U))),0}i.inflateReset=b,i.inflateReset2=_,i.inflateResetKeep=x,i.inflateInit=function(A){return T(A,15)},i.inflateInit2=T,i.inflate=function(A,I){var S,z,U,V,$,G,q,N,O,ee,te,H,ce,fe,se,re,de,pe,Ae,Be,C,Z,X,B,L=0,F=new s.Buf8(4),Y=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!A||!A.state||!A.output||!A.input&&A.avail_in!==0)return p;(S=A.state).mode===12&&(S.mode=13),$=A.next_out,U=A.output,q=A.avail_out,V=A.next_in,z=A.input,G=A.avail_in,N=S.hold,O=S.bits,ee=G,te=q,Z=m;e:for(;;)switch(S.mode){case f:if(S.wrap===0){S.mode=13;break}for(;O<16;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}if(2&S.wrap&&N===35615){F[S.check=0]=255&N,F[1]=N>>>8&255,S.check=a(S.check,F,2,0),O=N=0,S.mode=2;break}if(S.flags=0,S.head&&(S.head.done=!1),!(1&S.wrap)||(((255&N)<<8)+(N>>8))%31){A.msg="incorrect header check",S.mode=30;break}if((15&N)!=8){A.msg="unknown compression method",S.mode=30;break}if(O-=4,C=8+(15&(N>>>=4)),S.wbits===0)S.wbits=C;else if(C>S.wbits){A.msg="invalid window size",S.mode=30;break}S.dmax=1<<C,A.adler=S.check=1,S.mode=512&N?10:12,O=N=0;break;case 2:for(;O<16;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}if(S.flags=N,(255&S.flags)!=8){A.msg="unknown compression method",S.mode=30;break}if(57344&S.flags){A.msg="unknown header flags set",S.mode=30;break}S.head&&(S.head.text=N>>8&1),512&S.flags&&(F[0]=255&N,F[1]=N>>>8&255,S.check=a(S.check,F,2,0)),O=N=0,S.mode=3;case 3:for(;O<32;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}S.head&&(S.head.time=N),512&S.flags&&(F[0]=255&N,F[1]=N>>>8&255,F[2]=N>>>16&255,F[3]=N>>>24&255,S.check=a(S.check,F,4,0)),O=N=0,S.mode=4;case 4:for(;O<16;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}S.head&&(S.head.xflags=255&N,S.head.os=N>>8),512&S.flags&&(F[0]=255&N,F[1]=N>>>8&255,S.check=a(S.check,F,2,0)),O=N=0,S.mode=5;case 5:if(1024&S.flags){for(;O<16;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}S.length=N,S.head&&(S.head.extra_len=N),512&S.flags&&(F[0]=255&N,F[1]=N>>>8&255,S.check=a(S.check,F,2,0)),O=N=0}else S.head&&(S.head.extra=null);S.mode=6;case 6:if(1024&S.flags&&(G<(H=S.length)&&(H=G),H&&(S.head&&(C=S.head.extra_len-S.length,S.head.extra||(S.head.extra=new Array(S.head.extra_len)),s.arraySet(S.head.extra,z,V,H,C)),512&S.flags&&(S.check=a(S.check,z,H,V)),G-=H,V+=H,S.length-=H),S.length))break e;S.length=0,S.mode=7;case 7:if(2048&S.flags){if(G===0)break e;for(H=0;C=z[V+H++],S.head&&C&&S.length<65536&&(S.head.name+=String.fromCharCode(C)),C&&H<G;);if(512&S.flags&&(S.check=a(S.check,z,H,V)),G-=H,V+=H,C)break e}else S.head&&(S.head.name=null);S.length=0,S.mode=8;case 8:if(4096&S.flags){if(G===0)break e;for(H=0;C=z[V+H++],S.head&&C&&S.length<65536&&(S.head.comment+=String.fromCharCode(C)),C&&H<G;);if(512&S.flags&&(S.check=a(S.check,z,H,V)),G-=H,V+=H,C)break e}else S.head&&(S.head.comment=null);S.mode=9;case 9:if(512&S.flags){for(;O<16;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}if(N!==(65535&S.check)){A.msg="header crc mismatch",S.mode=30;break}O=N=0}S.head&&(S.head.hcrc=S.flags>>9&1,S.head.done=!0),A.adler=S.check=0,S.mode=12;break;case 10:for(;O<32;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}A.adler=S.check=y(N),O=N=0,S.mode=11;case 11:if(S.havedict===0)return A.next_out=$,A.avail_out=q,A.next_in=V,A.avail_in=G,S.hold=N,S.bits=O,2;A.adler=S.check=1,S.mode=12;case 12:if(I===5||I===6)break e;case 13:if(S.last){N>>>=7&O,O-=7&O,S.mode=27;break}for(;O<3;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}switch(S.last=1&N,O-=1,3&(N>>>=1)){case 0:S.mode=14;break;case 1:if(E(S),S.mode=20,I!==6)break;N>>>=2,O-=2;break e;case 2:S.mode=17;break;case 3:A.msg="invalid block type",S.mode=30}N>>>=2,O-=2;break;case 14:for(N>>>=7&O,O-=7&O;O<32;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}if((65535&N)!=(N>>>16^65535)){A.msg="invalid stored block lengths",S.mode=30;break}if(S.length=65535&N,O=N=0,S.mode=15,I===6)break e;case 15:S.mode=16;case 16:if(H=S.length){if(G<H&&(H=G),q<H&&(H=q),H===0)break e;s.arraySet(U,z,V,H,$),G-=H,V+=H,q-=H,$+=H,S.length-=H;break}S.mode=12;break;case 17:for(;O<14;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}if(S.nlen=257+(31&N),N>>>=5,O-=5,S.ndist=1+(31&N),N>>>=5,O-=5,S.ncode=4+(15&N),N>>>=4,O-=4,286<S.nlen||30<S.ndist){A.msg="too many length or distance symbols",S.mode=30;break}S.have=0,S.mode=18;case 18:for(;S.have<S.ncode;){for(;O<3;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}S.lens[Y[S.have++]]=7&N,N>>>=3,O-=3}for(;S.have<19;)S.lens[Y[S.have++]]=0;if(S.lencode=S.lendyn,S.lenbits=7,X={bits:S.lenbits},Z=c(0,S.lens,0,19,S.lencode,0,S.work,X),S.lenbits=X.bits,Z){A.msg="invalid code lengths set",S.mode=30;break}S.have=0,S.mode=19;case 19:for(;S.have<S.nlen+S.ndist;){for(;re=(L=S.lencode[N&(1<<S.lenbits)-1])>>>16&255,de=65535&L,!((se=L>>>24)<=O);){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}if(de<16)N>>>=se,O-=se,S.lens[S.have++]=de;else{if(de===16){for(B=se+2;O<B;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}if(N>>>=se,O-=se,S.have===0){A.msg="invalid bit length repeat",S.mode=30;break}C=S.lens[S.have-1],H=3+(3&N),N>>>=2,O-=2}else if(de===17){for(B=se+3;O<B;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}O-=se,C=0,H=3+(7&(N>>>=se)),N>>>=3,O-=3}else{for(B=se+7;O<B;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}O-=se,C=0,H=11+(127&(N>>>=se)),N>>>=7,O-=7}if(S.have+H>S.nlen+S.ndist){A.msg="invalid bit length repeat",S.mode=30;break}for(;H--;)S.lens[S.have++]=C}}if(S.mode===30)break;if(S.lens[256]===0){A.msg="invalid code -- missing end-of-block",S.mode=30;break}if(S.lenbits=9,X={bits:S.lenbits},Z=c(h,S.lens,0,S.nlen,S.lencode,0,S.work,X),S.lenbits=X.bits,Z){A.msg="invalid literal/lengths set",S.mode=30;break}if(S.distbits=6,S.distcode=S.distdyn,X={bits:S.distbits},Z=c(u,S.lens,S.nlen,S.ndist,S.distcode,0,S.work,X),S.distbits=X.bits,Z){A.msg="invalid distances set",S.mode=30;break}if(S.mode=20,I===6)break e;case 20:S.mode=21;case 21:if(6<=G&&258<=q){A.next_out=$,A.avail_out=q,A.next_in=V,A.avail_in=G,S.hold=N,S.bits=O,l(A,te),$=A.next_out,U=A.output,q=A.avail_out,V=A.next_in,z=A.input,G=A.avail_in,N=S.hold,O=S.bits,S.mode===12&&(S.back=-1);break}for(S.back=0;re=(L=S.lencode[N&(1<<S.lenbits)-1])>>>16&255,de=65535&L,!((se=L>>>24)<=O);){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}if(re&&(240&re)==0){for(pe=se,Ae=re,Be=de;re=(L=S.lencode[Be+((N&(1<<pe+Ae)-1)>>pe)])>>>16&255,de=65535&L,!(pe+(se=L>>>24)<=O);){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}N>>>=pe,O-=pe,S.back+=pe}if(N>>>=se,O-=se,S.back+=se,S.length=de,re===0){S.mode=26;break}if(32&re){S.back=-1,S.mode=12;break}if(64&re){A.msg="invalid literal/length code",S.mode=30;break}S.extra=15&re,S.mode=22;case 22:if(S.extra){for(B=S.extra;O<B;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}S.length+=N&(1<<S.extra)-1,N>>>=S.extra,O-=S.extra,S.back+=S.extra}S.was=S.length,S.mode=23;case 23:for(;re=(L=S.distcode[N&(1<<S.distbits)-1])>>>16&255,de=65535&L,!((se=L>>>24)<=O);){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}if((240&re)==0){for(pe=se,Ae=re,Be=de;re=(L=S.distcode[Be+((N&(1<<pe+Ae)-1)>>pe)])>>>16&255,de=65535&L,!(pe+(se=L>>>24)<=O);){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}N>>>=pe,O-=pe,S.back+=pe}if(N>>>=se,O-=se,S.back+=se,64&re){A.msg="invalid distance code",S.mode=30;break}S.offset=de,S.extra=15&re,S.mode=24;case 24:if(S.extra){for(B=S.extra;O<B;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}S.offset+=N&(1<<S.extra)-1,N>>>=S.extra,O-=S.extra,S.back+=S.extra}if(S.offset>S.dmax){A.msg="invalid distance too far back",S.mode=30;break}S.mode=25;case 25:if(q===0)break e;if(H=te-q,S.offset>H){if((H=S.offset-H)>S.whave&&S.sane){A.msg="invalid distance too far back",S.mode=30;break}ce=H>S.wnext?(H-=S.wnext,S.wsize-H):S.wnext-H,H>S.length&&(H=S.length),fe=S.window}else fe=U,ce=$-S.offset,H=S.length;for(q<H&&(H=q),q-=H,S.length-=H;U[$++]=fe[ce++],--H;);S.length===0&&(S.mode=21);break;case 26:if(q===0)break e;U[$++]=S.length,q--,S.mode=21;break;case 27:if(S.wrap){for(;O<32;){if(G===0)break e;G--,N|=z[V++]<<O,O+=8}if(te-=q,A.total_out+=te,S.total+=te,te&&(A.adler=S.check=S.flags?a(S.check,U,te,$-te):o(S.check,U,te,$-te)),te=q,(S.flags?N:y(N))!==S.check){A.msg="incorrect data check",S.mode=30;break}O=N=0}S.mode=28;case 28:if(S.wrap&&S.flags){for(;O<32;){if(G===0)break e;G--,N+=z[V++]<<O,O+=8}if(N!==(4294967295&S.total)){A.msg="incorrect length check",S.mode=30;break}O=N=0}S.mode=29;case 29:Z=1;break e;case 30:Z=-3;break e;case 31:return-4;case 32:default:return p}return A.next_out=$,A.avail_out=q,A.next_in=V,A.avail_in=G,S.hold=N,S.bits=O,(S.wsize||te!==A.avail_out&&S.mode<30&&(S.mode<27||I!==4))&&R(A,A.output,A.next_out,te-A.avail_out)?(S.mode=31,-4):(ee-=A.avail_in,te-=A.avail_out,A.total_in+=ee,A.total_out+=te,S.total+=te,S.wrap&&te&&(A.adler=S.check=S.flags?a(S.check,U,te,A.next_out-te):o(S.check,U,te,A.next_out-te)),A.data_type=S.bits+(S.last?64:0)+(S.mode===12?128:0)+(S.mode===20||S.mode===15?256:0),(ee==0&&te===0||I===4)&&Z===m&&(Z=-5),Z)},i.inflateEnd=function(A){if(!A||!A.state)return p;var I=A.state;return I.window&&(I.window=null),A.state=null,m},i.inflateGetHeader=function(A,I){var S;return A&&A.state?(2&(S=A.state).wrap)==0?p:((S.head=I).done=!1,m):p},i.inflateSetDictionary=function(A,I){var S,z=I.length;return A&&A.state?(S=A.state).wrap!==0&&S.mode!==11?p:S.mode===11&&o(1,I,z,0)!==S.check?-3:R(A,I,z,z)?(S.mode=31,-4):(S.havedict=1,m):p},i.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,n,i){var s=t("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];n.exports=function(h,u,m,p,f,d,g,y){var v,x,b,_,T,P,D,k,E,R=y.bits,A=0,I=0,S=0,z=0,U=0,V=0,$=0,G=0,q=0,N=0,O=null,ee=0,te=new s.Buf16(16),H=new s.Buf16(16),ce=null,fe=0;for(A=0;A<=15;A++)te[A]=0;for(I=0;I<p;I++)te[u[m+I]]++;for(U=R,z=15;1<=z&&te[z]===0;z--);if(z<U&&(U=z),z===0)return f[d++]=20971520,f[d++]=20971520,y.bits=1,0;for(S=1;S<z&&te[S]===0;S++);for(U<S&&(U=S),A=G=1;A<=15;A++)if(G<<=1,(G-=te[A])<0)return-1;if(0<G&&(h===0||z!==1))return-1;for(H[1]=0,A=1;A<15;A++)H[A+1]=H[A]+te[A];for(I=0;I<p;I++)u[m+I]!==0&&(g[H[u[m+I]]++]=I);if(P=h===0?(O=ce=g,19):h===1?(O=o,ee-=257,ce=a,fe-=257,256):(O=l,ce=c,-1),A=S,T=d,$=I=N=0,b=-1,_=(q=1<<(V=U))-1,h===1&&852<q||h===2&&592<q)return 1;for(;;){for(D=A-$,E=g[I]<P?(k=0,g[I]):g[I]>P?(k=ce[fe+g[I]],O[ee+g[I]]):(k=96,0),v=1<<A-$,S=x=1<<V;f[T+(N>>$)+(x-=v)]=D<<24|k<<16|E|0,x!==0;);for(v=1<<A-1;N&v;)v>>=1;if(v!==0?(N&=v-1,N+=v):N=0,I++,--te[A]==0){if(A===z)break;A=u[m+g[I]]}if(U<A&&(N&_)!==b){for($===0&&($=U),T+=S,G=1<<(V=A-$);V+$<z&&!((G-=te[V+$])<=0);)V++,G<<=1;if(q+=1<<V,h===1&&852<q||h===2&&592<q)return 1;f[b=N&_]=U<<24|V<<16|T-d|0}}return N!==0&&(f[T+N]=A-$<<24|64<<16|0),y.bits=U,0}},{"../utils/common":41}],51:[function(t,n,i){n.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(t,n,i){var s=t("../utils/common"),o=0,a=1;function l(L){for(var F=L.length;0<=--F;)L[F]=0}var c=0,h=29,u=256,m=u+1+h,p=30,f=19,d=2*m+1,g=15,y=16,v=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],D=[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],k=[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],R=new Array(2*(m+2));l(R);var A=new Array(2*p);l(A);var I=new Array(512);l(I);var S=new Array(256);l(S);var z=new Array(h);l(z);var U,V,$,G=new Array(p);function q(L,F,Y,K,j){this.static_tree=L,this.extra_bits=F,this.extra_base=Y,this.elems=K,this.max_length=j,this.has_stree=L&&L.length}function N(L,F){this.dyn_tree=L,this.max_code=0,this.stat_desc=F}function O(L){return L<256?I[L]:I[256+(L>>>7)]}function ee(L,F){L.pending_buf[L.pending++]=255&F,L.pending_buf[L.pending++]=F>>>8&255}function te(L,F,Y){L.bi_valid>y-Y?(L.bi_buf|=F<<L.bi_valid&65535,ee(L,L.bi_buf),L.bi_buf=F>>y-L.bi_valid,L.bi_valid+=Y-y):(L.bi_buf|=F<<L.bi_valid&65535,L.bi_valid+=Y)}function H(L,F,Y){te(L,Y[2*F],Y[2*F+1])}function ce(L,F){for(var Y=0;Y|=1&L,L>>>=1,Y<<=1,0<--F;);return Y>>>1}function fe(L,F,Y){var K,j,J=new Array(g+1),ne=0;for(K=1;K<=g;K++)J[K]=ne=ne+Y[K-1]<<1;for(j=0;j<=F;j++){var Q=L[2*j+1];Q!==0&&(L[2*j]=ce(J[Q]++,Q))}}function se(L){var F;for(F=0;F<m;F++)L.dyn_ltree[2*F]=0;for(F=0;F<p;F++)L.dyn_dtree[2*F]=0;for(F=0;F<f;F++)L.bl_tree[2*F]=0;L.dyn_ltree[2*x]=1,L.opt_len=L.static_len=0,L.last_lit=L.matches=0}function re(L){8<L.bi_valid?ee(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 de(L,F,Y,K){var j=2*F,J=2*Y;return L[j]<L[J]||L[j]===L[J]&&K[F]<=K[Y]}function pe(L,F,Y){for(var K=L.heap[Y],j=Y<<1;j<=L.heap_len&&(j<L.heap_len&&de(F,L.heap[j+1],L.heap[j],L.depth)&&j++,!de(F,K,L.heap[j],L.depth));)L.heap[Y]=L.heap[j],Y=j,j<<=1;L.heap[Y]=K}function Ae(L,F,Y){var K,j,J,ne,Q=0;if(L.last_lit!==0)for(;K=L.pending_buf[L.d_buf+2*Q]<<8|L.pending_buf[L.d_buf+2*Q+1],j=L.pending_buf[L.l_buf+Q],Q++,K===0?H(L,j,F):(H(L,(J=S[j])+u+1,F),(ne=P[J])!==0&&te(L,j-=z[J],ne),H(L,J=O(--K),Y),(ne=D[J])!==0&&te(L,K-=G[J],ne)),Q<L.last_lit;);H(L,x,F)}function Be(L,F){var Y,K,j,J=F.dyn_tree,ne=F.stat_desc.static_tree,Q=F.stat_desc.has_stree,ie=F.stat_desc.elems,he=-1;for(L.heap_len=0,L.heap_max=d,Y=0;Y<ie;Y++)J[2*Y]!==0?(L.heap[++L.heap_len]=he=Y,L.depth[Y]=0):J[2*Y+1]=0;for(;L.heap_len<2;)J[2*(j=L.heap[++L.heap_len]=he<2?++he:0)]=1,L.depth[j]=0,L.opt_len--,Q&&(L.static_len-=ne[2*j+1]);for(F.max_code=he,Y=L.heap_len>>1;1<=Y;Y--)pe(L,J,Y);for(j=ie;Y=L.heap[1],L.heap[1]=L.heap[L.heap_len--],pe(L,J,1),K=L.heap[1],L.heap[--L.heap_max]=Y,L.heap[--L.heap_max]=K,J[2*j]=J[2*Y]+J[2*K],L.depth[j]=(L.depth[Y]>=L.depth[K]?L.depth[Y]:L.depth[K])+1,J[2*Y+1]=J[2*K+1]=j,L.heap[1]=j++,pe(L,J,1),2<=L.heap_len;);L.heap[--L.heap_max]=L.heap[1],(function(ae,Pe){var He,Ee,Ft,ge,on,Pn,Je=Pe.dyn_tree,Mt=Pe.max_code,Ut=Pe.stat_desc.static_tree,Vt=Pe.stat_desc.has_stree,Gt=Pe.stat_desc.extra_bits,_t=Pe.stat_desc.extra_base,Tn=Pe.stat_desc.max_length,Li=0;for(ge=0;ge<=g;ge++)ae.bl_count[ge]=0;for(Je[2*ae.heap[ae.heap_max]+1]=0,He=ae.heap_max+1;He<d;He++)Tn<(ge=Je[2*Je[2*(Ee=ae.heap[He])+1]+1]+1)&&(ge=Tn,Li++),Je[2*Ee+1]=ge,Mt<Ee||(ae.bl_count[ge]++,on=0,_t<=Ee&&(on=Gt[Ee-_t]),Pn=Je[2*Ee],ae.opt_len+=Pn*(ge+on),Vt&&(ae.static_len+=Pn*(Ut[2*Ee+1]+on)));if(Li!==0){do{for(ge=Tn-1;ae.bl_count[ge]===0;)ge--;ae.bl_count[ge]--,ae.bl_count[ge+1]+=2,ae.bl_count[Tn]--,Li-=2}while(0<Li);for(ge=Tn;ge!==0;ge--)for(Ee=ae.bl_count[ge];Ee!==0;)Mt<(Ft=ae.heap[--He])||(Je[2*Ft+1]!==ge&&(ae.opt_len+=(ge-Je[2*Ft+1])*Je[2*Ft],Je[2*Ft+1]=ge),Ee--)}})(L,F),fe(J,he,L.bl_count)}function C(L,F,Y){var K,j,J=-1,ne=F[1],Q=0,ie=7,he=4;for(ne===0&&(ie=138,he=3),F[2*(Y+1)+1]=65535,K=0;K<=Y;K++)j=ne,ne=F[2*(K+1)+1],++Q<ie&&j===ne||(Q<he?L.bl_tree[2*j]+=Q:j!==0?(j!==J&&L.bl_tree[2*j]++,L.bl_tree[2*b]++):Q<=10?L.bl_tree[2*_]++:L.bl_tree[2*T]++,J=j,he=(Q=0)===ne?(ie=138,3):j===ne?(ie=6,3):(ie=7,4))}function Z(L,F,Y){var K,j,J=-1,ne=F[1],Q=0,ie=7,he=4;for(ne===0&&(ie=138,he=3),K=0;K<=Y;K++)if(j=ne,ne=F[2*(K+1)+1],!(++Q<ie&&j===ne)){if(Q<he)for(;H(L,j,L.bl_tree),--Q!=0;);else j!==0?(j!==J&&(H(L,j,L.bl_tree),Q--),H(L,b,L.bl_tree),te(L,Q-3,2)):Q<=10?(H(L,_,L.bl_tree),te(L,Q-3,3)):(H(L,T,L.bl_tree),te(L,Q-11,7));J=j,he=(Q=0)===ne?(ie=138,3):j===ne?(ie=6,3):(ie=7,4)}}l(G);var X=!1;function B(L,F,Y,K){te(L,(c<<1)+(K?1:0),3),(function(j,J,ne,Q){re(j),ee(j,ne),ee(j,~ne),s.arraySet(j.pending_buf,j.window,J,ne,j.pending),j.pending+=ne})(L,F,Y)}i._tr_init=function(L){X||((function(){var F,Y,K,j,J,ne=new Array(g+1);for(j=K=0;j<h-1;j++)for(z[j]=K,F=0;F<1<<P[j];F++)S[K++]=j;for(S[K-1]=j,j=J=0;j<16;j++)for(G[j]=J,F=0;F<1<<D[j];F++)I[J++]=j;for(J>>=7;j<p;j++)for(G[j]=J<<7,F=0;F<1<<D[j]-7;F++)I[256+J++]=j;for(Y=0;Y<=g;Y++)ne[Y]=0;for(F=0;F<=143;)R[2*F+1]=8,F++,ne[8]++;for(;F<=255;)R[2*F+1]=9,F++,ne[9]++;for(;F<=279;)R[2*F+1]=7,F++,ne[7]++;for(;F<=287;)R[2*F+1]=8,F++,ne[8]++;for(fe(R,m+1,ne),F=0;F<p;F++)A[2*F+1]=5,A[2*F]=ce(F,5);U=new q(R,P,u+1,m,g),V=new q(A,D,0,p,g),$=new q(new Array(0),k,0,f,v)})(),X=!0),L.l_desc=new N(L.dyn_ltree,U),L.d_desc=new N(L.dyn_dtree,V),L.bl_desc=new N(L.bl_tree,$),L.bi_buf=0,L.bi_valid=0,se(L)},i._tr_stored_block=B,i._tr_flush_block=function(L,F,Y,K){var j,J,ne=0;0<L.level?(L.strm.data_type===2&&(L.strm.data_type=(function(Q){var ie,he=4093624447;for(ie=0;ie<=31;ie++,he>>>=1)if(1&he&&Q.dyn_ltree[2*ie]!==0)return o;if(Q.dyn_ltree[18]!==0||Q.dyn_ltree[20]!==0||Q.dyn_ltree[26]!==0)return a;for(ie=32;ie<u;ie++)if(Q.dyn_ltree[2*ie]!==0)return a;return o})(L)),Be(L,L.l_desc),Be(L,L.d_desc),ne=(function(Q){var ie;for(C(Q,Q.dyn_ltree,Q.l_desc.max_code),C(Q,Q.dyn_dtree,Q.d_desc.max_code),Be(Q,Q.bl_desc),ie=f-1;3<=ie&&Q.bl_tree[2*E[ie]+1]===0;ie--);return Q.opt_len+=3*(ie+1)+5+5+4,ie})(L),j=L.opt_len+3+7>>>3,(J=L.static_len+3+7>>>3)<=j&&(j=J)):j=J=Y+5,Y+4<=j&&F!==-1?B(L,F,Y,K):L.strategy===4||J===j?(te(L,2+(K?1:0),3),Ae(L,R,A)):(te(L,4+(K?1:0),3),(function(Q,ie,he,ae){var Pe;for(te(Q,ie-257,5),te(Q,he-1,5),te(Q,ae-4,4),Pe=0;Pe<ae;Pe++)te(Q,Q.bl_tree[2*E[Pe]+1],3);Z(Q,Q.dyn_ltree,ie-1),Z(Q,Q.dyn_dtree,he-1)})(L,L.l_desc.max_code+1,L.d_desc.max_code+1,ne+1),Ae(L,L.dyn_ltree,L.dyn_dtree)),se(L),K&&re(L)},i._tr_tally=function(L,F,Y){return L.pending_buf[L.d_buf+2*L.last_lit]=F>>>8&255,L.pending_buf[L.d_buf+2*L.last_lit+1]=255&F,L.pending_buf[L.l_buf+L.last_lit]=255&Y,L.last_lit++,F===0?L.dyn_ltree[2*Y]++:(L.matches++,F--,L.dyn_ltree[2*(S[Y]+u+1)]++,L.dyn_dtree[2*O(F)]++),L.last_lit===L.lit_bufsize-1},i._tr_align=function(L){te(L,2,3),H(L,x,R),(function(F){F.bi_valid===16?(ee(F,F.bi_buf),F.bi_buf=0,F.bi_valid=0):8<=F.bi_valid&&(F.pending_buf[F.pending++]=255&F.bi_buf,F.bi_buf>>=8,F.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(o,a){if(!o.setImmediate){var l,c,h,u,m=1,p={},f=!1,d=o.document,g=Object.getPrototypeOf&&Object.getPrototypeOf(o);g=g&&g.setTimeout?g:o,l={}.toString.call(o.process)==="[object process]"?function(b){process.nextTick(function(){v(b)})}:(function(){if(o.postMessage&&!o.importScripts){var b=!0,_=o.onmessage;return o.onmessage=function(){b=!1},o.postMessage("","*"),o.onmessage=_,b}})()?(u="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",x,!1):o.attachEvent("onmessage",x),function(b){o.postMessage(u+b,"*")}):o.MessageChannel?((h=new MessageChannel).port1.onmessage=function(b){v(b.data)},function(b){h.port2.postMessage(b)}):d&&"onreadystatechange"in d.createElement("script")?(c=d.documentElement,function(b){var _=d.createElement("script");_.onreadystatechange=function(){v(b),_.onreadystatechange=null,c.removeChild(_),_=null},c.appendChild(_)}):function(b){setTimeout(v,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 p[m]=P,l(m),m++},g.clearImmediate=y}function y(b){delete p[b]}function v(b){if(f)setTimeout(v,0,b);else{var _=p[b];if(_){f=!0;try{(function(T){var P=T.callback,D=T.args;switch(D.length){case 0:P();break;case 1:P(D[0]);break;case 2:P(D[0],D[1]);break;case 3:P(D[0],D[1],D[2]);break;default:P.apply(a,D)}})(_)}finally{y(b),f=!1}}}}function x(b){b.source===o&&typeof b.data=="string"&&b.data.indexOf(u)===0&&v(+b.data.slice(u.length))}})(typeof self>"u"?s===void 0?this:s:self)}).call(this,typeof Un<"u"?Un:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(Ri)),Ri.exports}var ja=Ga();const Js=qs(ja);function Qs(r,e){return function(){return r.apply(e,arguments)}}const{toString:Wa}=Object.prototype,{getPrototypeOf:Oi}=Object,{iterator:Gn,toStringTag:eo}=Symbol,jn=(r=>e=>{const t=Wa.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ke=r=>(r=r.toLowerCase(),e=>jn(e)===r),Wn=r=>e=>typeof e===r,{isArray:jt}=Array,Wt=Wn("undefined");function rn(r){return r!==null&&!Wt(r)&&r.constructor!==null&&!Wt(r.constructor)&&Ne(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const to=Ke("ArrayBuffer");function Xa(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&to(r.buffer),e}const Za=Wn("string"),Ne=Wn("function"),no=Wn("number"),an=r=>r!==null&&typeof r=="object",Ya=r=>r===!0||r===!1,Xn=r=>{if(jn(r)!=="object")return!1;const e=Oi(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(eo in r)&&!(Gn in r)},Ka=r=>{if(!an(r)||rn(r))return!1;try{return Object.keys(r).length===0&&Object.getPrototypeOf(r)===Object.prototype}catch{return!1}},$a=Ke("Date"),qa=Ke("File"),Ha=Ke("Blob"),Ja=Ke("FileList"),Qa=r=>an(r)&&Ne(r.pipe),el=r=>{let e;return r&&(typeof FormData=="function"&&r instanceof FormData||Ne(r.append)&&((e=jn(r))==="formdata"||e==="object"&&Ne(r.toString)&&r.toString()==="[object FormData]"))},tl=Ke("URLSearchParams"),[nl,il,sl,ol]=["ReadableStream","Request","Response","Headers"].map(Ke),rl=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ln(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let n,i;if(typeof r!="object"&&(r=[r]),jt(r))for(n=0,i=r.length;n<i;n++)e.call(null,r[n],n,r);else{if(rn(r))return;const s=t?Object.getOwnPropertyNames(r):Object.keys(r),o=s.length;let a;for(n=0;n<o;n++)a=s[n],e.call(null,r[a],a,r)}}function io(r,e){if(rn(r))return null;e=e.toLowerCase();const t=Object.keys(r);let n=t.length,i;for(;n-- >0;)if(i=t[n],e===i.toLowerCase())return i;return null}const At=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,so=r=>!Wt(r)&&r!==At;function Ni(){const{caseless:r,skipUndefined:e}=so(this)&&this||{},t={},n=(i,s)=>{const o=r&&io(t,s)||s;Xn(t[o])&&Xn(i)?t[o]=Ni(t[o],i):Xn(i)?t[o]=Ni({},i):jt(i)?t[o]=i.slice():(!e||!Wt(i))&&(t[o]=i)};for(let i=0,s=arguments.length;i<s;i++)arguments[i]&&ln(arguments[i],n);return t}const al=(r,e,t,{allOwnKeys:n}={})=>(ln(e,(i,s)=>{t&&Ne(i)?r[s]=Qs(i,t):r[s]=i},{allOwnKeys:n}),r),ll=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),cl=(r,e,t,n)=>{r.prototype=Object.create(e.prototype,n),r.prototype.constructor=r,Object.defineProperty(r,"super",{value:e.prototype}),t&&Object.assign(r.prototype,t)},hl=(r,e,t,n)=>{let i,s,o;const a={};if(e=e||{},r==null)return e;do{for(i=Object.getOwnPropertyNames(r),s=i.length;s-- >0;)o=i[s],(!n||n(o,r,e))&&!a[o]&&(e[o]=r[o],a[o]=!0);r=t!==!1&&Oi(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},dl=(r,e,t)=>{r=String(r),(t===void 0||t>r.length)&&(t=r.length),t-=e.length;const n=r.indexOf(e,t);return n!==-1&&n===t},ul=r=>{if(!r)return null;if(jt(r))return r;let e=r.length;if(!no(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},fl=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&Oi(Uint8Array)),pl=(r,e)=>{const n=(r&&r[Gn]).call(r);let i;for(;(i=n.next())&&!i.done;){const s=i.value;e.call(r,s[0],s[1])}},ml=(r,e)=>{let t;const n=[];for(;(t=r.exec(e))!==null;)n.push(t);return n},gl=Ke("HTMLFormElement"),yl=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),oo=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),vl=Ke("RegExp"),ro=(r,e)=>{const t=Object.getOwnPropertyDescriptors(r),n={};ln(t,(i,s)=>{let o;(o=e(i,s,r))!==!1&&(n[s]=o||i)}),Object.defineProperties(r,n)},wl=r=>{ro(r,(e,t)=>{if(Ne(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=r[t];if(Ne(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},xl=(r,e)=>{const t={},n=i=>{i.forEach(s=>{t[s]=!0})};return jt(r)?n(r):n(String(r).split(e)),t},bl=()=>{},Ml=(r,e)=>r!=null&&Number.isFinite(r=+r)?r:e;function _l(r){return!!(r&&Ne(r.append)&&r[eo]==="FormData"&&r[Gn])}const Sl=r=>{const e=new Array(10),t=(n,i)=>{if(an(n)){if(e.indexOf(n)>=0)return;if(rn(n))return n;if(!("toJSON"in n)){e[i]=n;const s=jt(n)?[]:{};return ln(n,(o,a)=>{const l=t(o,i+1);!Wt(l)&&(s[a]=l)}),e[i]=void 0,s}}return n};return t(r,0)},Cl=Ke("AsyncFunction"),Al=r=>r&&(an(r)||Ne(r))&&Ne(r.then)&&Ne(r.catch),ao=((r,e)=>r?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)),Pl=typeof queueMicrotask<"u"?queueMicrotask.bind(At):typeof process<"u"&&process.nextTick||ao,W={isArray:jt,isArrayBuffer:to,isBuffer:rn,isFormData:el,isArrayBufferView:Xa,isString:Za,isNumber:no,isBoolean:Ya,isObject:an,isPlainObject:Xn,isEmptyObject:Ka,isReadableStream:nl,isRequest:il,isResponse:sl,isHeaders:ol,isUndefined:Wt,isDate:$a,isFile:qa,isBlob:Ha,isRegExp:vl,isFunction:Ne,isStream:Qa,isURLSearchParams:tl,isTypedArray:fl,isFileList:Ja,forEach:ln,merge:Ni,extend:al,trim:rl,stripBOM:ll,inherits:cl,toFlatObject:hl,kindOf:jn,kindOfTest:Ke,endsWith:dl,toArray:ul,forEachEntry:pl,matchAll:ml,isHTMLForm:gl,hasOwnProperty:oo,hasOwnProp:oo,reduceDescriptors:ro,freezeMethods:wl,toObjectSet:xl,toCamelCase:yl,noop:bl,toFiniteNumber:Ml,findKey:io,global:At,isContextDefined:so,isSpecCompliantForm:_l,toJSONObject:Sl,isAsyncFn:Cl,isThenable:Al,setImmediate:ao,asap:Pl,isIterable:r=>r!=null&&Ne(r[Gn])};function oe(r,e,t,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}W.inherits(oe,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:W.toJSONObject(this.config),code:this.code,status:this.status}}});const lo=oe.prototype,co={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(r=>{co[r]={value:r}}),Object.defineProperties(oe,co),Object.defineProperty(lo,"isAxiosError",{value:!0}),oe.from=(r,e,t,n,i,s)=>{const o=Object.create(lo);W.toFlatObject(r,o,function(h){return h!==Error.prototype},c=>c!=="isAxiosError");const a=r&&r.message?r.message:"Error",l=e==null&&r?r.code:e;return oe.call(o,a,l,t,n,i),r&&o.cause==null&&Object.defineProperty(o,"cause",{value:r,configurable:!0}),o.name=r&&r.name||"Error",s&&Object.assign(o,s),o};const Tl=null;function Fi(r){return W.isPlainObject(r)||W.isArray(r)}function ho(r){return W.endsWith(r,"[]")?r.slice(0,-2):r}function uo(r,e,t){return r?r.concat(e).map(function(i,s){return i=ho(i),!t&&s?"["+i+"]":i}).join(t?".":""):e}function kl(r){return W.isArray(r)&&!r.some(Fi)}const Dl=W.toFlatObject(W,{},null,function(e){return/^is[A-Z]/.test(e)});function Zn(r,e,t){if(!W.isObject(r))throw new TypeError("target must be an object");e=e||new FormData,t=W.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(d,g){return!W.isUndefined(g[d])});const n=t.metaTokens,i=t.visitor||h,s=t.dots,o=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&W.isSpecCompliantForm(e);if(!W.isFunction(i))throw new TypeError("visitor must be a function");function c(f){if(f===null)return"";if(W.isDate(f))return f.toISOString();if(W.isBoolean(f))return f.toString();if(!l&&W.isBlob(f))throw new oe("Blob is not supported. Use a Buffer instead.");return W.isArrayBuffer(f)||W.isTypedArray(f)?l&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function h(f,d,g){let y=f;if(f&&!g&&typeof f=="object"){if(W.endsWith(d,"{}"))d=n?d:d.slice(0,-2),f=JSON.stringify(f);else if(W.isArray(f)&&kl(f)||(W.isFileList(f)||W.endsWith(d,"[]"))&&(y=W.toArray(f)))return d=ho(d),y.forEach(function(x,b){!(W.isUndefined(x)||x===null)&&e.append(o===!0?uo([d],b,s):o===null?d:d+"[]",c(x))}),!1}return Fi(f)?!0:(e.append(uo(g,d,s),c(f)),!1)}const u=[],m=Object.assign(Dl,{defaultVisitor:h,convertValue:c,isVisitable:Fi});function p(f,d){if(!W.isUndefined(f)){if(u.indexOf(f)!==-1)throw Error("Circular reference detected in "+d.join("."));u.push(f),W.forEach(f,function(y,v){(!(W.isUndefined(y)||y===null)&&i.call(e,y,W.isString(v)?v.trim():v,d,m))===!0&&p(y,d?d.concat(v):[v])}),u.pop()}}if(!W.isObject(r))throw new TypeError("data must be an object");return p(r),e}function fo(r){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function Ui(r,e){this._pairs=[],r&&Zn(r,this,e)}const po=Ui.prototype;po.append=function(e,t){this._pairs.push([e,t])},po.toString=function(e){const t=e?function(n){return e.call(this,n,fo)}:fo;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function El(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function mo(r,e,t){if(!e)return r;const n=t&&t.encode||El;W.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let s;if(i?s=i(e,t):s=W.isURLSearchParams(e)?e.toString():new Ui(e,t).toString(n),s){const o=r.indexOf("#");o!==-1&&(r=r.slice(0,o)),r+=(r.indexOf("?")===-1?"?":"&")+s}return r}class go{constructor(){this.handlers=[]}use(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){W.forEach(this.handlers,function(n){n!==null&&e(n)})}}const yo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ll={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Ui,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Vi=typeof window<"u"&&typeof document<"u",Gi=typeof navigator=="object"&&navigator||void 0,Il=Vi&&(!Gi||["ReactNative","NativeScript","NS"].indexOf(Gi.product)<0),zl=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Bl=Vi&&window.location.href||"http://localhost",De={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Vi,hasStandardBrowserEnv:Il,hasStandardBrowserWebWorkerEnv:zl,navigator:Gi,origin:Bl},Symbol.toStringTag,{value:"Module"})),...Ll};function Rl(r,e){return Zn(r,new De.classes.URLSearchParams,{visitor:function(t,n,i,s){return De.isNode&&W.isBuffer(t)?(this.append(n,t.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...e})}function Ol(r){return W.matchAll(/\w+|\[(\w*)]/g,r).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Nl(r){const e={},t=Object.keys(r);let n;const i=t.length;let s;for(n=0;n<i;n++)s=t[n],e[s]=r[s];return e}function vo(r){function e(t,n,i,s){let o=t[s++];if(o==="__proto__")return!0;const a=Number.isFinite(+o),l=s>=t.length;return o=!o&&W.isArray(i)?i.length:o,l?(W.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!a):((!i[o]||!W.isObject(i[o]))&&(i[o]=[]),e(t,n,i[o],s)&&W.isArray(i[o])&&(i[o]=Nl(i[o])),!a)}if(W.isFormData(r)&&W.isFunction(r.entries)){const t={};return W.forEachEntry(r,(n,i)=>{e(Ol(n),i,t,0)}),t}return null}function Fl(r,e,t){if(W.isString(r))try{return(e||JSON.parse)(r),W.trim(r)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(r)}const cn={transitional:yo,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",i=n.indexOf("application/json")>-1,s=W.isObject(e);if(s&&W.isHTMLForm(e)&&(e=new FormData(e)),W.isFormData(e))return i?JSON.stringify(vo(e)):e;if(W.isArrayBuffer(e)||W.isBuffer(e)||W.isStream(e)||W.isFile(e)||W.isBlob(e)||W.isReadableStream(e))return e;if(W.isArrayBufferView(e))return e.buffer;if(W.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Rl(e,this.formSerializer).toString();if((a=W.isFileList(e))||n.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Zn(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return s||i?(t.setContentType("application/json",!1),Fl(e)):e}],transformResponse:[function(e){const t=this.transitional||cn.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(W.isResponse(e)||W.isReadableStream(e))return e;if(e&&W.isString(e)&&(n&&!this.responseType||i)){const o=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(a){if(o)throw a.name==="SyntaxError"?oe.from(a,oe.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}}};W.forEach(["delete","get","head","post","put","patch"],r=>{cn.headers[r]={}});const Ul=W.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Vl=r=>{const e={};let t,n,i;return r&&r.split(`
|
|
962
|
+
`).forEach(function(o){i=o.indexOf(":"),t=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!t||e[t]&&Ul[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e},wo=Symbol("internals");function hn(r){return r&&String(r).trim().toLowerCase()}function Yn(r){return r===!1||r==null?r:W.isArray(r)?r.map(Yn):String(r)}function Gl(r){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=t.exec(r);)e[n[1]]=n[2];return e}const jl=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function ji(r,e,t,n,i){if(W.isFunction(n))return n.call(this,e,t);if(i&&(e=t),!!W.isString(e)){if(W.isString(n))return e.indexOf(n)!==-1;if(W.isRegExp(n))return n.test(e)}}function Wl(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function Xl(r,e){const t=W.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(r,n+t,{value:function(i,s,o){return this[n].call(this,e,i,s,o)},configurable:!0})})}let Fe=class{constructor(e){e&&this.set(e)}set(e,t,n){const i=this;function s(a,l,c){const h=hn(l);if(!h)throw new Error("header name must be a non-empty string");const u=W.findKey(i,h);(!u||i[u]===void 0||c===!0||c===void 0&&i[u]!==!1)&&(i[u||l]=Yn(a))}const o=(a,l)=>W.forEach(a,(c,h)=>s(c,h,l));if(W.isPlainObject(e)||e instanceof this.constructor)o(e,t);else if(W.isString(e)&&(e=e.trim())&&!jl(e))o(Vl(e),t);else if(W.isObject(e)&&W.isIterable(e)){let a={},l,c;for(const h of e){if(!W.isArray(h))throw TypeError("Object iterator must return a key-value pair");a[c=h[0]]=(l=a[c])?W.isArray(l)?[...l,h[1]]:[l,h[1]]:h[1]}o(a,t)}else e!=null&&s(t,e,n);return this}get(e,t){if(e=hn(e),e){const n=W.findKey(this,e);if(n){const i=this[n];if(!t)return i;if(t===!0)return Gl(i);if(W.isFunction(t))return t.call(this,i,n);if(W.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=hn(e),e){const n=W.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||ji(this,this[n],n,t)))}return!1}delete(e,t){const n=this;let i=!1;function s(o){if(o=hn(o),o){const a=W.findKey(n,o);a&&(!t||ji(n,n[a],a,t))&&(delete n[a],i=!0)}}return W.isArray(e)?e.forEach(s):s(e),i}clear(e){const t=Object.keys(this);let n=t.length,i=!1;for(;n--;){const s=t[n];(!e||ji(this,this[s],s,e,!0))&&(delete this[s],i=!0)}return i}normalize(e){const t=this,n={};return W.forEach(this,(i,s)=>{const o=W.findKey(n,s);if(o){t[o]=Yn(i),delete t[s];return}const a=e?Wl(s):String(s).trim();a!==s&&delete t[s],t[a]=Yn(i),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return W.forEach(this,(n,i)=>{n!=null&&n!==!1&&(t[i]=e&&W.isArray(n)?n.join(", "):n)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
|
|
963
|
+
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const n=new this(e);return t.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[wo]=this[wo]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=hn(o);n[a]||(Xl(i,o),n[a]=!0)}return W.isArray(e)?e.forEach(s):s(e),this}};Fe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),W.reduceDescriptors(Fe.prototype,({value:r},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>r,set(n){this[t]=n}}}),W.freezeMethods(Fe);function Wi(r,e){const t=this||cn,n=e||t,i=Fe.from(n.headers);let s=n.data;return W.forEach(r,function(a){s=a.call(t,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function xo(r){return!!(r&&r.__CANCEL__)}function Xt(r,e,t){oe.call(this,r??"canceled",oe.ERR_CANCELED,e,t),this.name="CanceledError"}W.inherits(Xt,oe,{__CANCEL__:!0});function bo(r,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?r(t):e(new oe("Request failed with status code "+t.status,[oe.ERR_BAD_REQUEST,oe.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function Zl(r){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return e&&e[1]||""}function Yl(r,e){r=r||10;const t=new Array(r),n=new Array(r);let i=0,s=0,o;return e=e!==void 0?e:1e3,function(l){const c=Date.now(),h=n[s];o||(o=c),t[i]=l,n[i]=c;let u=s,m=0;for(;u!==i;)m+=t[u++],u=u%r;if(i=(i+1)%r,i===s&&(s=(s+1)%r),c-o<e)return;const p=h&&c-h;return p?Math.round(m*1e3/p):void 0}}function Kl(r,e){let t=0,n=1e3/e,i,s;const o=(c,h=Date.now())=>{t=h,i=null,s&&(clearTimeout(s),s=null),r(...c)};return[(...c)=>{const h=Date.now(),u=h-t;u>=n?o(c,h):(i=c,s||(s=setTimeout(()=>{s=null,o(i)},n-u)))},()=>i&&o(i)]}const Kn=(r,e,t=3)=>{let n=0;const i=Yl(50,250);return Kl(s=>{const o=s.loaded,a=s.lengthComputable?s.total:void 0,l=o-n,c=i(l),h=o<=a;n=o;const u={loaded:o,total:a,progress:a?o/a:void 0,bytes:l,rate:c||void 0,estimated:c&&a&&h?(a-o)/c:void 0,event:s,lengthComputable:a!=null,[e?"download":"upload"]:!0};r(u)},t)},Mo=(r,e)=>{const t=r!=null;return[n=>e[0]({lengthComputable:t,total:r,loaded:n}),e[1]]},_o=r=>(...e)=>W.asap(()=>r(...e)),$l=De.hasStandardBrowserEnv?((r,e)=>t=>(t=new URL(t,De.origin),r.protocol===t.protocol&&r.host===t.host&&(e||r.port===t.port)))(new URL(De.origin),De.navigator&&/(msie|trident)/i.test(De.navigator.userAgent)):()=>!0,ql=De.hasStandardBrowserEnv?{write(r,e,t,n,i,s,o){if(typeof document>"u")return;const a=[`${r}=${encodeURIComponent(e)}`];W.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),W.isString(n)&&a.push(`path=${n}`),W.isString(i)&&a.push(`domain=${i}`),s===!0&&a.push("secure"),W.isString(o)&&a.push(`SameSite=${o}`),document.cookie=a.join("; ")},read(r){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+r+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(r){this.write(r,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Hl(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function Jl(r,e){return e?r.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):r}function So(r,e,t){let n=!Hl(e);return r&&(n||t==!1)?Jl(r,e):e}const Co=r=>r instanceof Fe?{...r}:r;function Pt(r,e){e=e||{};const t={};function n(c,h,u,m){return W.isPlainObject(c)&&W.isPlainObject(h)?W.merge.call({caseless:m},c,h):W.isPlainObject(h)?W.merge({},h):W.isArray(h)?h.slice():h}function i(c,h,u,m){if(W.isUndefined(h)){if(!W.isUndefined(c))return n(void 0,c,u,m)}else return n(c,h,u,m)}function s(c,h){if(!W.isUndefined(h))return n(void 0,h)}function o(c,h){if(W.isUndefined(h)){if(!W.isUndefined(c))return n(void 0,c)}else return n(void 0,h)}function a(c,h,u){if(u in e)return n(c,h);if(u in r)return n(void 0,c)}const l={url:s,method:s,data:s,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(c,h,u)=>i(Co(c),Co(h),u,!0)};return W.forEach(Object.keys({...r,...e}),function(h){const u=l[h]||i,m=u(r[h],e[h],h);W.isUndefined(m)&&u!==a||(t[h]=m)}),t}const Ao=r=>{const e=Pt({},r);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:s,headers:o,auth:a}=e;if(e.headers=o=Fe.from(o),e.url=mo(So(e.baseURL,e.url,e.allowAbsoluteUrls),r.params,r.paramsSerializer),a&&o.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),W.isFormData(t)){if(De.hasStandardBrowserEnv||De.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(W.isFunction(t.getHeaders)){const l=t.getHeaders(),c=["content-type","content-length"];Object.entries(l).forEach(([h,u])=>{c.includes(h.toLowerCase())&&o.set(h,u)})}}if(De.hasStandardBrowserEnv&&(n&&W.isFunction(n)&&(n=n(e)),n||n!==!1&&$l(e.url))){const l=i&&s&&ql.read(s);l&&o.set(i,l)}return e},Ql=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(t,n){const i=Ao(r);let s=i.data;const o=Fe.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:c}=i,h,u,m,p,f;function d(){p&&p(),f&&f(),i.cancelToken&&i.cancelToken.unsubscribe(h),i.signal&&i.signal.removeEventListener("abort",h)}let g=new XMLHttpRequest;g.open(i.method.toUpperCase(),i.url,!0),g.timeout=i.timeout;function y(){if(!g)return;const x=Fe.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:r,request:g};bo(function(P){t(P),d()},function(P){n(P),d()},_),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 oe("Request aborted",oe.ECONNABORTED,r,g)),g=null)},g.onerror=function(b){const _=b&&b.message?b.message:"Network Error",T=new oe(_,oe.ERR_NETWORK,r,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||yo;i.timeoutErrorMessage&&(b=i.timeoutErrorMessage),n(new oe(b,_.clarifyTimeoutError?oe.ETIMEDOUT:oe.ECONNABORTED,r,g)),g=null},s===void 0&&o.setContentType(null),"setRequestHeader"in g&&W.forEach(o.toJSON(),function(b,_){g.setRequestHeader(_,b)}),W.isUndefined(i.withCredentials)||(g.withCredentials=!!i.withCredentials),a&&a!=="json"&&(g.responseType=i.responseType),c&&([m,f]=Kn(c,!0),g.addEventListener("progress",m)),l&&g.upload&&([u,p]=Kn(l),g.upload.addEventListener("progress",u),g.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(h=x=>{g&&(n(!x||x.type?new Xt(null,r,g):x),g.abort(),g=null)},i.cancelToken&&i.cancelToken.subscribe(h),i.signal&&(i.signal.aborted?h():i.signal.addEventListener("abort",h)));const v=Zl(i.url);if(v&&De.protocols.indexOf(v)===-1){n(new oe("Unsupported protocol "+v+":",oe.ERR_BAD_REQUEST,r));return}g.send(s||null)})},ec=(r,e)=>{const{length:t}=r=r?r.filter(Boolean):[];if(e||t){let n=new AbortController,i;const s=function(c){if(!i){i=!0,a();const h=c instanceof Error?c:this.reason;n.abort(h instanceof oe?h:new Xt(h instanceof Error?h.message:h))}};let o=e&&setTimeout(()=>{o=null,s(new oe(`timeout ${e} of ms exceeded`,oe.ETIMEDOUT))},e);const a=()=>{r&&(o&&clearTimeout(o),o=null,r.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),r=null)};r.forEach(c=>c.addEventListener("abort",s));const{signal:l}=n;return l.unsubscribe=()=>W.asap(a),l}},tc=function*(r,e){let t=r.byteLength;if(t<e){yield r;return}let n=0,i;for(;n<t;)i=n+e,yield r.slice(n,i),n=i},nc=async function*(r,e){for await(const t of ic(r))yield*tc(t,e)},ic=async function*(r){if(r[Symbol.asyncIterator]){yield*r;return}const e=r.getReader();try{for(;;){const{done:t,value:n}=await e.read();if(t)break;yield n}}finally{await e.cancel()}},Po=(r,e,t,n)=>{const i=nc(r,e);let s=0,o,a=l=>{o||(o=!0,n&&n(l))};return new ReadableStream({async pull(l){try{const{done:c,value:h}=await i.next();if(c){a(),l.close();return}let u=h.byteLength;if(t){let m=s+=u;t(m)}l.enqueue(new Uint8Array(h))}catch(c){throw a(c),c}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},To=64*1024,{isFunction:$n}=W,sc=(({Request:r,Response:e})=>({Request:r,Response:e}))(W.global),{ReadableStream:ko,TextEncoder:Do}=W.global,Eo=(r,...e)=>{try{return!!r(...e)}catch{return!1}},oc=r=>{r=W.merge.call({skipUndefined:!0},sc,r);const{fetch:e,Request:t,Response:n}=r,i=e?$n(e):typeof fetch=="function",s=$n(t),o=$n(n);if(!i)return!1;const a=i&&$n(ko),l=i&&(typeof Do=="function"?(f=>d=>f.encode(d))(new Do):async f=>new Uint8Array(await new t(f).arrayBuffer())),c=s&&a&&Eo(()=>{let f=!1;const d=new t(De.origin,{body:new ko,method:"POST",get duplex(){return f=!0,"half"}}).headers.has("Content-Type");return f&&!d}),h=o&&a&&Eo(()=>W.isReadableStream(new n("").body)),u={stream:h&&(f=>f.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!u[f]&&(u[f]=(d,g)=>{let y=d&&d[f];if(y)return y.call(d);throw new oe(`Response type '${f}' is not supported`,oe.ERR_NOT_SUPPORT,g)})});const m=async f=>{if(f==null)return 0;if(W.isBlob(f))return f.size;if(W.isSpecCompliantForm(f))return(await new t(De.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(W.isArrayBufferView(f)||W.isArrayBuffer(f))return f.byteLength;if(W.isURLSearchParams(f)&&(f=f+""),W.isString(f))return(await l(f)).byteLength},p=async(f,d)=>{const g=W.toFiniteNumber(f.getContentLength());return g??m(d)};return async f=>{let{url:d,method:g,data:y,signal:v,cancelToken:x,timeout:b,onDownloadProgress:_,onUploadProgress:T,responseType:P,headers:D,withCredentials:k="same-origin",fetchOptions:E}=Ao(f),R=e||fetch;P=P?(P+"").toLowerCase():"text";let A=ec([v,x&&x.toAbortSignal()],b),I=null;const S=A&&A.unsubscribe&&(()=>{A.unsubscribe()});let z;try{if(T&&c&&g!=="get"&&g!=="head"&&(z=await p(D,y))!==0){let N=new t(d,{method:"POST",body:y,duplex:"half"}),O;if(W.isFormData(y)&&(O=N.headers.get("content-type"))&&D.setContentType(O),N.body){const[ee,te]=Mo(z,Kn(_o(T)));y=Po(N.body,To,ee,te)}}W.isString(k)||(k=k?"include":"omit");const U=s&&"credentials"in t.prototype,V={...E,signal:A,method:g.toUpperCase(),headers:D.normalize().toJSON(),body:y,duplex:"half",credentials:U?k:void 0};I=s&&new t(d,V);let $=await(s?R(I,E):R(d,V));const G=h&&(P==="stream"||P==="response");if(h&&(_||G&&S)){const N={};["status","statusText","headers"].forEach(H=>{N[H]=$[H]});const O=W.toFiniteNumber($.headers.get("content-length")),[ee,te]=_&&Mo(O,Kn(_o(_),!0))||[];$=new n(Po($.body,To,ee,()=>{te&&te(),S&&S()}),N)}P=P||"text";let q=await u[W.findKey(u,P)||"text"]($,f);return!G&&S&&S(),await new Promise((N,O)=>{bo(N,O,{data:q,headers:Fe.from($.headers),status:$.status,statusText:$.statusText,config:f,request:I})})}catch(U){throw S&&S(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new oe("Network Error",oe.ERR_NETWORK,f,I),{cause:U.cause||U}):oe.from(U,U&&U.code,f,I)}}},rc=new Map,Lo=r=>{let e=r&&r.env||{};const{fetch:t,Request:n,Response:i}=e,s=[n,i,t];let o=s.length,a=o,l,c,h=rc;for(;a--;)l=s[a],c=h.get(l),c===void 0&&h.set(l,c=a?new Map:oc(e)),h=c;return c};Lo();const Xi={http:Tl,xhr:Ql,fetch:{get:Lo}};W.forEach(Xi,(r,e)=>{if(r){try{Object.defineProperty(r,"name",{value:e})}catch{}Object.defineProperty(r,"adapterName",{value:e})}});const Io=r=>`- ${r}`,ac=r=>W.isFunction(r)||r===null||r===!1;function lc(r,e){r=W.isArray(r)?r:[r];const{length:t}=r;let n,i;const s={};for(let o=0;o<t;o++){n=r[o];let a;if(i=n,!ac(n)&&(i=Xi[(a=String(n)).toLowerCase()],i===void 0))throw new oe(`Unknown adapter '${a}'`);if(i&&(W.isFunction(i)||(i=i.get(e))))break;s[a||"#"+o]=i}if(!i){const o=Object.entries(s).map(([l,c])=>`adapter ${l} `+(c===!1?"is not supported by the environment":"is not available in the build"));let a=t?o.length>1?`since :
|
|
964
|
+
`+o.map(Io).join(`
|
|
965
|
+
`):" "+Io(o[0]):"as no adapter specified";throw new oe("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i}const zo={getAdapter:lc,adapters:Xi};function Zi(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new Xt(null,r)}function Bo(r){return Zi(r),r.headers=Fe.from(r.headers),r.data=Wi.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),zo.getAdapter(r.adapter||cn.adapter,r)(r).then(function(n){return Zi(r),n.data=Wi.call(r,r.transformResponse,n),n.headers=Fe.from(n.headers),n},function(n){return xo(n)||(Zi(r),n&&n.response&&(n.response.data=Wi.call(r,r.transformResponse,n.response),n.response.headers=Fe.from(n.response.headers))),Promise.reject(n)})}const Ro="1.13.2",qn={};["object","boolean","number","function","string","symbol"].forEach((r,e)=>{qn[r]=function(n){return typeof n===r||"a"+(e<1?"n ":" ")+r}});const Oo={};qn.transitional=function(e,t,n){function i(s,o){return"[Axios v"+Ro+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return(s,o,a)=>{if(e===!1)throw new oe(i(o," has been removed"+(t?" in "+t:"")),oe.ERR_DEPRECATED);return t&&!Oo[o]&&(Oo[o]=!0,console.warn(i(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(s,o,a):!0}},qn.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function cc(r,e,t){if(typeof r!="object")throw new oe("options must be an object",oe.ERR_BAD_OPTION_VALUE);const n=Object.keys(r);let i=n.length;for(;i-- >0;){const s=n[i],o=e[s];if(o){const a=r[s],l=a===void 0||o(a,s,r);if(l!==!0)throw new oe("option "+s+" must be "+l,oe.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new oe("Unknown option "+s,oe.ERR_BAD_OPTION)}}const Hn={assertOptions:cc,validators:qn},et=Hn.validators;let Tt=class{constructor(e){this.defaults=e||{},this.interceptors={request:new go,response:new go}}async request(e,t){try{return await this._request(e,t)}catch(n){if(n instanceof Error){let i={};Error.captureStackTrace?Error.captureStackTrace(i):i=new Error;const s=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?s&&!String(n.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(n.stack+=`
|
|
966
|
+
`+s):n.stack=s}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Pt(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:s}=t;n!==void 0&&Hn.assertOptions(n,{silentJSONParsing:et.transitional(et.boolean),forcedJSONParsing:et.transitional(et.boolean),clarifyTimeoutError:et.transitional(et.boolean)},!1),i!=null&&(W.isFunction(i)?t.paramsSerializer={serialize:i}:Hn.assertOptions(i,{encode:et.function,serialize:et.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Hn.assertOptions(t,{baseUrl:et.spelling("baseURL"),withXsrfToken:et.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o=s&&W.merge(s.common,s[t.method]);s&&W.forEach(["delete","get","head","post","put","patch","common"],f=>{delete s[f]}),t.headers=Fe.concat(o,s);const a=[];let l=!0;this.interceptors.request.forEach(function(d){typeof d.runWhen=="function"&&d.runWhen(t)===!1||(l=l&&d.synchronous,a.unshift(d.fulfilled,d.rejected))});const c=[];this.interceptors.response.forEach(function(d){c.push(d.fulfilled,d.rejected)});let h,u=0,m;if(!l){const f=[Bo.bind(this),void 0];for(f.unshift(...a),f.push(...c),m=f.length,h=Promise.resolve(t);u<m;)h=h.then(f[u++],f[u++]);return h}m=a.length;let p=t;for(;u<m;){const f=a[u++],d=a[u++];try{p=f(p)}catch(g){d.call(this,g);break}}try{h=Bo.call(this,p)}catch(f){return Promise.reject(f)}for(u=0,m=c.length;u<m;)h=h.then(c[u++],c[u++]);return h}getUri(e){e=Pt(this.defaults,e);const t=So(e.baseURL,e.url,e.allowAbsoluteUrls);return mo(t,e.params,e.paramsSerializer)}};W.forEach(["delete","get","head","options"],function(e){Tt.prototype[e]=function(t,n){return this.request(Pt(n||{},{method:e,url:t,data:(n||{}).data}))}}),W.forEach(["post","put","patch"],function(e){function t(n){return function(s,o,a){return this.request(Pt(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}Tt.prototype[e]=t(),Tt.prototype[e+"Form"]=t(!0)});let hc=class na{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(s){t=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{n.subscribe(a),s=a}).then(i);return o.cancel=function(){n.unsubscribe(s)},o},e(function(s,o,a){n.reason||(n.reason=new Xt(s,o,a),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new na(function(i){e=i}),cancel:e}}};function dc(r){return function(t){return r.apply(null,t)}}function uc(r){return W.isObject(r)&&r.isAxiosError===!0}const Yi={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(Yi).forEach(([r,e])=>{Yi[e]=r});function No(r){const e=new Tt(r),t=Qs(Tt.prototype.request,e);return W.extend(t,Tt.prototype,e,{allOwnKeys:!0}),W.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return No(Pt(r,i))},t}const ye=No(cn);ye.Axios=Tt,ye.CanceledError=Xt,ye.CancelToken=hc,ye.isCancel=xo,ye.VERSION=Ro,ye.toFormData=Zn,ye.AxiosError=oe,ye.Cancel=ye.CanceledError,ye.all=function(e){return Promise.all(e)},ye.spread=dc,ye.isAxiosError=uc,ye.mergeConfig=Pt,ye.AxiosHeaders=Fe,ye.formToJSON=r=>vo(W.isHTMLForm(r)?new FormData(r):r),ye.getAdapter=zo.getAdapter,ye.HttpStatusCode=Yi,ye.default=ye;const{Axios:tp,AxiosError:np,CanceledError:ip,isCancel:sp,CancelToken:op,VERSION:rp,all:ap,Cancel:lp,isAxiosError:cp,spread:hp,toFormData:dp,AxiosHeaders:up,HttpStatusCode:fp,formToJSON:pp,getAdapter:mp,mergeConfig:gp}=ye;function Fo(r,e){var t;if(window.XMLHttpRequest?t=new XMLHttpRequest:window.ActiveXObject?t=new window.ActiveXObject:alert("请升级至最新版本的浏览器"),t!=null){let n=r;t.open("GET",n,!0),t.send(null),t.onreadystatechange=function(){t.readyState==4&&t.status==200&&(t.responseText.includes("</html>",0)&&t.responseText.includes("</body>",0)&&t.responseText.includes("</head>",0)?e(null):e(t.responseText))},t.onloadend=function(){t.readyState==4&&t.status==404&&t.status==502&&e(null)}}}function fc(r,e){ye({method:"get",responseType:"blob",url:r}).then(t=>{let n=new window.File([t.data],"zipFolder",{type:"zip"});Js.loadAsync(n).then(i=>{const s=new Map,o=[];for(let a in i.files){if(i.files[a].dir)continue;const l=i.file(i.files[a].name);if(l){const c=l.async("blob").then(h=>{const u=URL.createObjectURL(h);s.set("/"+i.files[a].name.replace("\\","/"),u)});o.push(c)}}Promise.all(o).then(()=>{e(s)}).catch(a=>{console.error("解压zip文件失败:",a),e(new Map)})}).catch(i=>{console.error("加载zip文件失败:",i),e(new Map)})}).catch(t=>{console.error("下载zip文件失败:",t),e(new Map)})}function Jn(r,e,t){ye({method:"get",responseType:"blob",url:r}).then(i=>{let s=new window.File([i.data],"semantics",{type:"zip"});Js.loadAsync(s).then(o=>{for(let a in o.files){const l=o.file(o.files[a].name);l&&l.async("blob").then(c=>{n(c,"utf-8",function(h,u){e(u)})}).catch(()=>{t()})}}).catch(()=>{t()})}).catch(i=>{t()});function n(i,s,o){var a=new FileReader,l=new Blob([i]);a.onload=function(c){o(null,c.target.result)},a.onerror=function(c){o(c.error,null)},a.readAsText(l,s)}}const Ki=new WeakMap;class pc extends M.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 M.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,o=>{this.parse(o,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,M.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,i,s=M.LinearSRGBColorSpace,o=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:s};return this.decodeGeometry(e,a).then(t).catch(o)}decodeGeometry(e,t){const n=JSON.stringify(t);if(Ki.has(e)){const l=Ki.get(e);if(l.key===n)return l.promise;if(e.byteLength===0)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const s=this.workerNextTaskID++,o=e.byteLength,a=this._getWorker(s,o).then(l=>(i=l,new Promise((c,h)=>{i._callbacks[s]={resolve:c,reject:h},i.postMessage({type:"decode",id:s,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&s&&this._releaseTask(i,s)}),Ki.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new M.BufferGeometry;e.index&&t.setIndex(new M.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:s,itemSize:o,stride:a,vertexColorSpace:l}=e.attributes[n];let c;if(o===a)c=new M.BufferAttribute(s,o);else{const h=new M.InterleavedBuffer(s,a);c=new M.InterleavedBufferAttribute(h,o,0)}i==="color"&&(this._assignVertexColorSpace(c,l),c.normalized=!(s instanceof Float32Array)),t.setAttribute(i,c)}return t}_assignVertexColorSpace(e,t){if(t!==M.SRGBColorSpace)return;const n=new M.Color;for(let i=0,s=e.count;i<s;i++)n.fromBufferAttribute(e,i),M.ColorManagement.colorSpaceToWorking(n,M.SRGBColorSpace),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new M.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=mc.toString(),o=["/* draco decoder */",i,"","/* worker */",s.substring(s.indexOf("{")+1,s.lastIndexOf("}"))].join(`
|
|
967
|
+
`);this.workerSourceURL=URL.createObjectURL(new Blob([o]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){const i=new Worker(this.workerSourceURL);i._callbacks={},i._taskCosts={},i._taskLoad=0,i.postMessage({type:"init",decoderConfig:this.decoderConfig}),i.onmessage=function(s){const o=s.data;switch(o.type){case"decode":i._callbacks[o.id].resolve(o);break;case"error":i._callbacks[o.id].reject(o);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+o.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,s){return i._taskLoad>s._taskLoad?-1:1});const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n})}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map(e=>e._taskLoad))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this.workerSourceURL!==""&&URL.revokeObjectURL(this.workerSourceURL),this}}function mc(){let r,e;onmessage=function(o){const a=o.data;switch(a.type){case"init":r=a.decoderConfig,e=new Promise(function(h){r.onModuleLoaded=function(u){h({draco:u})},DracoDecoderModule(r)});break;case"decode":const l=a.buffer,c=a.taskConfig;e.then(h=>{const u=h.draco,m=new u.Decoder;try{const p=t(u,m,new Int8Array(l),c),f=p.attributes.map(d=>d.array.buffer);p.index&&f.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},f)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{u.destroy(m)}});break}};function t(o,a,l,c){const h=c.attributeIDs,u=c.attributeTypes;let m,p;const f=a.GetEncodedGeometryType(l);if(f===o.TRIANGULAR_MESH)m=new o.Mesh,p=a.DecodeArrayToMesh(l,l.byteLength,m);else if(f===o.POINT_CLOUD)m=new o.PointCloud,p=a.DecodeArrayToPointCloud(l,l.byteLength,m);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||m.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const d={index:null,attributes:[]};for(const g in h){const y=self[u[g]];let v,x;if(c.useUniqueIDs)x=h[g],v=a.GetAttributeByUniqueId(m,x);else{if(x=a.GetAttributeId(m,o[h[g]]),x===-1)continue;v=a.GetAttribute(m,x)}const b=i(o,a,m,g,y,v);g==="color"&&(b.vertexColorSpace=c.vertexColorSpace),d.attributes.push(b)}return f===o.TRIANGULAR_MESH&&(d.index=n(o,a,m)),o.destroy(m),d}function n(o,a,l){const h=l.num_faces()*3,u=h*4,m=o._malloc(u);a.GetTrianglesUInt32Array(l,u,m);const p=new Uint32Array(o.HEAPF32.buffer,m,h).slice();return o._free(m),{array:p,itemSize:1}}function i(o,a,l,c,h,u){const m=l.num_points(),p=u.num_components(),f=s(o,h),d=p*h.BYTES_PER_ELEMENT,g=Math.ceil(d/4)*4,y=g/h.BYTES_PER_ELEMENT,v=m*d,x=m*g,b=o._malloc(v);a.GetAttributeDataArrayForAllPoints(l,u,f,v,b);const _=new h(o.HEAPF32.buffer,b,v/h.BYTES_PER_ELEMENT);let T;if(d===g)T=_.slice();else{T=new h(x/h.BYTES_PER_ELEMENT);let P=0;for(let D=0,k=_.length;D<k;D++){for(let E=0;E<p;E++)T[P+E]=_[D*p+E];P+=y}}return o._free(b),{name:c,count:m,itemSize:p,array:T,stride:y}}function s(o,a){switch(a){case Float32Array:return o.DT_FLOAT32;case Int8Array:return o.DT_INT8;case Int16Array:return o.DT_INT16;case Int32Array:return o.DT_INT32;case Uint8Array:return o.DT_UINT8;case Uint16Array:return o.DT_UINT16;case Uint32Array:return o.DT_UINT32}}}function gc(r,e,t,n){let i=0,s=0,o=0,a=r.models.find(p=>p.url==t),l=e.circularMeps,c=e.rectMeps?.filter(p=>p.type==="风管"),h=e.rectMeps?.filter(p=>p.type==="桥架"),u=e.ellipseMeps,m=r.scene;if(new w.MeshBasicMaterial,new w.BufferGeometry,l&&l.length){let p=[],f=0;for(let d of l)d.color=d.color.split(",").map(g=>parseInt(g)/255),d.color=new w.Color(d.color[0],d.color[1],d.color[2]),d.position={x:d.startPoint.X*.3048+i,y:d.startPoint.Z*.3048+s,z:-d.startPoint.Y*.3048+o},d.rotation={x:0,y:0,z:0},d.indexes=[[r.scene.children.length,f++,0,0]],a.nodesMap.set(Number(d.id),d),p.push(d);Qn("Circle",m,p,t)}if(c&&c.length){let p=[],f=0;for(let d of c)d.color=d.color.split(",").map(g=>parseInt(g)/255),d.color=new w.Color(d.color[0],d.color[1],d.color[2]),d.position={x:d.startPoint.X*.3048+i,y:d.startPoint.Z*.3048+s,z:-d.startPoint.Y*.3048+o},d.rotation={x:0,y:0,z:0},d.indexes=[[r.scene.children.length,f++,0,0]],a.nodesMap.set(Number(d.id),d),p.push(d);Qn("Rect",m,p,t)}if(u&&u.length){let p=[],f=0;for(let d of u)d.color=d.color.split(",").map(g=>parseInt(g)/255),d.color=new w.Color(d.color[0],d.color[1],d.color[2]),d.position={x:d.startPoint.X*.3048+i,y:d.startPoint.Z*.3048+s,z:-d.startPoint.Y*.3048+o},d.rotation={x:0,y:0,z:0},d.indexes=[[r.scene.children.length,f++,0,0]],a.nodesMap.set(Number(d.id),d),p.push(d);Qn("Ellipse",m,p,t)}if(h&&h.length){let p=[],f=0;for(let d of h)d.color=d.color.split(",").map(g=>parseInt(g)/255),d.color=new w.Color(d.color[0],d.color[1],d.color[2]),d.position={x:d.startPoint.X*.3048+i,y:d.startPoint.Z*.3048+s,z:-d.startPoint.Y*.3048+o},d.rotation={x:0,y:0,z:0},d.indexes=[[r.scene.children.length,f++,0,0]],a.nodesMap.set(Number(d.id),d),p.push(d);Qn("Bridge",m,p,t)}}function Qn(r,e,t,n,i){let s,o,a={width:1,height:1,length:1,diameter:1,color:new w.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(r){case"Rect":o=ei("Rect",a);break;case"Bridge":o=ei("Bridge",a);break;case"Circle":o=ei("Circle",a);break;case"Ellipse":o=ei("Ellipse",a);break}o&&(s=new w.InstancedMesh(o.geometry,o.material,t.length),s.url=n,e.add(s),s.index=e.children.length-1);let l=[],c=[];for(var h=0;h<t.length;h++){let p=t[h],f=new w.Vector3(p.startPoint.X,0,-p.startPoint.Y),d=new w.Vector3(p.endPoint.X,0,-p.endPoint.Y),g=new w.Vector3(p.startPoint.X,p.startPoint.Z,-p.startPoint.Y),y=new w.Vector3(p.endPoint.X,p.endPoint.Z,-p.endPoint.Y),v=0,x=0,b=0;if(Math.abs(d.clone().sub(f.clone()).z)<.01&&Math.abs(d.clone().sub(f.clone()).x)<.01){if(v=(p.startPoint.Z>p.endPoint.Z?1:-1)*Math.PI*.5,p.base_x!=null){var u=new w.Vector3(p.base_x.X,0,-p.base_x.Y);x=(u.clone().cross(new w.Vector3(0,0,1)).y<=0?1:-1)*u.angleTo(new w.Vector3(0,0,1))+Math.PI*.5}}else x=(d.clone().sub(f.clone()).cross(new w.Vector3(0,0,1)).y>0?-1:1)*d.clone().sub(f.clone()).angleTo(new w.Vector3(0,0,1)),v=(p.startPoint.Z>p.endPoint.Z?1:-1)*d.clone().sub(f.clone()).angleTo(y.clone().sub(g.clone()));let _=new w.Matrix4;const T=new w.Euler(v,x,b,"YXZ");let P=_.clone().makeRotationFromEuler(T),D,k;r==="Circle"?(D=p.diameter,k=p.diameter):(D=p.width,k=p.height);let E=_.clone().makeScale(D,k,p.length);_.multiplyMatrices(P,E),_.setPosition(p.position.x,p.position.y,p.position.z),s.setMatrixAt(h,_.clone()),s.setColorAt(h,p.color),s.geometry.computeBoundingBox();let R=s.geometry.boundingBox.min.clone().applyMatrix4(_.clone()),A=s.geometry.boundingBox.max.clone().applyMatrix4(_.clone()),I=new w.Vector3(Math.min(R.x,A.x),Math.min(R.y,A.y),Math.min(R.z,A.z)),S=new w.Vector3(Math.max(R.x,A.x),Math.max(R.y,A.y),Math.max(R.z,A.z)),z=I.clone().add(S.clone()).multiplyScalar(.5),U={name:p.name,min:I,max:S,center:z,dbid:h,materialName:o.material.name},V=null,$=null;r==="Circle"&&(V={x:p.startPoint.X*.3048,y:p.startPoint.Z*.3048,z:-p.startPoint.Y*.3048},$={x:p.endPoint.X*.3048,y:p.endPoint.Z*.3048,z:-p.endPoint.Y*.3048},U.minC=V,U.maxC=$),s.ids||(s.ids=[]),s.matrixs||(s.matrixs=[]),s.matrixs.push(_.clone()),c.push(_.clone()),s.ids.push(Number(p.id)),l.push(U)}s.castShadow=!0,s.ElementInfos=l,s.name="rootModel",s.TypeName="InstancedMesh-Pipe",s.PipeType=r,s.MeshId=null,s.realMaterial=s.material.clone(),s.originalMaterial=s.material.clone(),s.matrixsClone=c;let m=[];m={geometry:s.geometry,matrix:s.matrix,position:s.position,rotation:s.rotation},s.meshs=m,s.instanceMatrix&&s.instanceMatrix.array&&(s.cloneInstanceMatrix=Array.from(s.instanceMatrix.array))}function ei(r,e,t){let n=new w.Shape;switch(e.width=e.width*.3048,e.height=e.height*.3048,e.diameter=e.diameter*.3048,r){case"Rect":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Ellipse":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Bridge":n.moveTo(-e.width/2,-e.height/2),n.lineTo(-e.width/2,e.height/2),n.lineTo(-e.width/2+.01,e.height/2),n.lineTo(-e.width/2+.01,-e.height/2+.01),n.lineTo(e.width/2-.01,-e.height/2+.01),n.lineTo(e.width/2-.01,e.height/2),n.lineTo(e.width/2,e.height/2),n.lineTo(e.width/2,-e.height/2),n.lineTo(-e.width/2,-e.height/2);break;case"Circle":n.moveTo(0,0),n.absarc(0,0,e.diameter*.5,0,Math.PI*2,!1);break}const i={depth:e.length*.3048,bevelEnabled:!1};return s(n,i,e.color,e.position,e.rotation);function s(o,a,l,c,h){let u=new w.ExtrudeGeometry(o,a),m=new w.MeshStandardMaterial({color:l,side:w.DoubleSide}),p=new w.Mesh(u,m);return p.position.set(c.x,c.y,c.z),p.rotation._order="YXZ",p.rotation.set(h.x,h.y,h.z),p}}function Zt(r,e=!1){const t=r[0].index!==null,n=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),s={},o={},a=r[0].morphTargetsRelative,l=new M.BufferGeometry;let c=0;for(let h=0;h<r.length;++h){const u=r[h];let m=0;if(t!==(u.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in u.attributes){if(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;s[p]===void 0&&(s[p]=[]),s[p].push(u.attributes[p]),m++}if(m!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". Make sure all geometries have the same number of attributes."),null;if(a!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in u.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". .morphAttributes must be consistent throughout all geometries."),null;o[p]===void 0&&(o[p]=[]),o[p].push(u.morphAttributes[p])}if(e){let p;if(t)p=u.index.count;else if(u.attributes.position!==void 0)p=u.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+h+". The geometry must have either an index or a position attribute"),null;l.addGroup(c,p,h),c+=p}}if(t){let h=0;const u=[];for(let m=0;m<r.length;++m){const p=r[m].index;for(let f=0;f<p.count;++f)u.push(p.getX(f)+h);h+=r[m].attributes.position.count}l.setIndex(u)}for(const h in s){const u=Uo(s[h]);if(!u)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" attribute."),null;l.setAttribute(h,u)}for(const h in o){const u=o[h][0].length;if(u===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[h]=[];for(let m=0;m<u;++m){const p=[];for(let d=0;d<o[h].length;++d)p.push(o[h][d][m]);const f=Uo(p);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+h+" morphAttribute."),null;l.morphAttributes[h].push(f)}}return l}function Uo(r){let e,t,n,i=-1,s=0;for(let c=0;c<r.length;++c){const h=r[c];if(e===void 0&&(e=h.array.constructor),e!==h.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=h.itemSize),t!==h.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=h.normalized),n!==h.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=h.gpuType),i!==h.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;s+=h.count*t}const o=new e(s),a=new M.BufferAttribute(o,t,n);let l=0;for(let c=0;c<r.length;++c){const h=r[c];if(h.isInterleavedBufferAttribute){const u=l/t;for(let m=0,p=h.count;m<p;m++)for(let f=0;f<t;f++){const d=h.getComponent(m,f);a.setComponent(m+u,f,d)}}else o.set(h.array,l);l+=h.count*t}return i!==void 0&&(a.gpuType=i),a}function Vo(r,e){if(e===M.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===M.TriangleFanDrawMode||e===M.TriangleStripDrawMode){let t=r.getIndex();if(t===null){const o=[],a=r.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)o.push(l);r.setIndex(o),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,i=[];if(e===M.TriangleFanDrawMode)for(let o=1;o<=n;o++)i.push(t.getX(0)),i.push(t.getX(o)),i.push(t.getX(o+1));else for(let o=0;o<n;o++)o%2===0?(i.push(t.getX(o)),i.push(t.getX(o+1)),i.push(t.getX(o+2))):(i.push(t.getX(o+2)),i.push(t.getX(o+1)),i.push(t.getX(o)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=r.clone();return s.setIndex(i),s.clearGroups(),s}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}class yc extends M.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Mc(t)}),this.register(function(t){return new _c(t)}),this.register(function(t){return new Lc(t)}),this.register(function(t){return new Ic(t)}),this.register(function(t){return new zc(t)}),this.register(function(t){return new Cc(t)}),this.register(function(t){return new Ac(t)}),this.register(function(t){return new Pc(t)}),this.register(function(t){return new Tc(t)}),this.register(function(t){return new bc(t)}),this.register(function(t){return new kc(t)}),this.register(function(t){return new Sc(t)}),this.register(function(t){return new Ec(t)}),this.register(function(t){return new Dc(t)}),this.register(function(t){return new wc(t)}),this.register(function(t){return new Bc(t)}),this.register(function(t){return new Rc(t)})}load(e,t,n,i){const s=this;let o;if(this.resourcePath!=="")o=this.resourcePath;else if(this.path!==""){const c=M.LoaderUtils.extractUrlBase(e);o=M.LoaderUtils.resolveURL(c,this.path)}else o=M.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(c){i?i(c):console.error(c),s.manager.itemError(e),s.manager.itemEnd(e)},l=new M.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(c){try{s.parse(c,o,function(h){t(h),s.manager.itemEnd(e)},a)}catch(h){a(h)}},n,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,i){let s;const o={},a={},l=new TextDecoder;if(typeof e=="string")s=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===Go){try{o[le.KHR_BINARY_GLTF]=new Oc(e)}catch(u){i&&i(u);return}s=JSON.parse(o[le.KHR_BINARY_GLTF].content)}else s=JSON.parse(l.decode(e));else s=e;if(s.asset===void 0||s.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const c=new qc(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let h=0;h<this.pluginCallbacks.length;h++){const u=this.pluginCallbacks[h](c);u.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[u.name]=u,o[u.name]=!0}if(s.extensionsUsed)for(let h=0;h<s.extensionsUsed.length;++h){const u=s.extensionsUsed[h],m=s.extensionsRequired||[];switch(u){case le.KHR_MATERIALS_UNLIT:o[u]=new xc;break;case le.KHR_DRACO_MESH_COMPRESSION:o[u]=new Nc(s,this.dracoLoader);break;case le.KHR_TEXTURE_TRANSFORM:o[u]=new Fc;break;case le.KHR_MESH_QUANTIZATION:o[u]=new Uc;break;default:m.indexOf(u)>=0&&a[u]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+u+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,s){n.parse(e,t,i,s)})}}function vc(){let r={};return{get:function(e){return r[e]},add:function(e,t){r[e]=t},remove:function(e){delete r[e]},removeAll:function(){r={}}}}const le={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class wc{constructor(e){this.parser=e,this.name=le.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,i=t.length;n<i;n++){const s=t[n];s.extensions&&s.extensions[this.name]&&s.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,s.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const s=t.json,l=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let c;const h=new M.Color(16777215);l.color!==void 0&&h.setRGB(l.color[0],l.color[1],l.color[2],M.LinearSRGBColorSpace);const u=l.range!==void 0?l.range:0;switch(l.type){case"directional":c=new M.DirectionalLight(h),c.target.position.set(0,0,-1),c.add(c.target);break;case"point":c=new M.PointLight(h),c.distance=u;break;case"spot":c=new M.SpotLight(h),c.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,c.angle=l.spot.outerConeAngle,c.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,c.target.position.set(0,0,-1),c.add(c.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return c.position.set(0,0,0),tt(c,l),l.intensity!==void 0&&(c.intensity=l.intensity),c.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(c),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,s=n.json.nodes[e],a=(s.extensions&&s.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class xc{constructor(){this.name=le.KHR_MATERIALS_UNLIT}getMaterialType(){return M.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new M.Color(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const o=s.baseColorFactor;e.color.setRGB(o[0],o[1],o[2],M.LinearSRGBColorSpace),e.opacity=o[3]}s.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",s.baseColorTexture,M.SRGBColorSpace))}return Promise.all(i)}}class bc{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 Mc{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:M.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];if(o.clearcoatFactor!==void 0&&(t.clearcoat=o.clearcoatFactor),o.clearcoatTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatMap",o.clearcoatTexture)),o.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=o.clearcoatRoughnessFactor),o.clearcoatRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),o.clearcoatNormalTexture!==void 0&&(s.push(n.assignTexture(t,"clearcoatNormalMap",o.clearcoatNormalTexture)),o.clearcoatNormalTexture.scale!==void 0)){const a=o.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new M.Vector2(a,a)}return Promise.all(s)}}class _c{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:M.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 Sc{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:M.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.iridescenceFactor!==void 0&&(t.iridescence=o.iridescenceFactor),o.iridescenceTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceMap",o.iridescenceTexture)),o.iridescenceIor!==void 0&&(t.iridescenceIOR=o.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),o.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=o.iridescenceThicknessMinimum),o.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=o.iridescenceThicknessMaximum),o.iridescenceThicknessTexture!==void 0&&s.push(n.assignTexture(t,"iridescenceThicknessMap",o.iridescenceThicknessTexture)),Promise.all(s)}}class Cc{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:M.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 M.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const o=i.extensions[this.name];if(o.sheenColorFactor!==void 0){const a=o.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],M.LinearSRGBColorSpace)}return o.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=o.sheenRoughnessFactor),o.sheenColorTexture!==void 0&&s.push(n.assignTexture(t,"sheenColorMap",o.sheenColorTexture,M.SRGBColorSpace)),o.sheenRoughnessTexture!==void 0&&s.push(n.assignTexture(t,"sheenRoughnessMap",o.sheenRoughnessTexture)),Promise.all(s)}}class Ac{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:M.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.transmissionFactor!==void 0&&(t.transmission=o.transmissionFactor),o.transmissionTexture!==void 0&&s.push(n.assignTexture(t,"transmissionMap",o.transmissionTexture)),Promise.all(s)}}class Pc{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:M.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];t.thickness=o.thicknessFactor!==void 0?o.thicknessFactor:0,o.thicknessTexture!==void 0&&s.push(n.assignTexture(t,"thicknessMap",o.thicknessTexture)),t.attenuationDistance=o.attenuationDistance||1/0;const a=o.attenuationColor||[1,1,1];return t.attenuationColor=new M.Color().setRGB(a[0],a[1],a[2],M.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:M.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 kc{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:M.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];t.specularIntensity=o.specularFactor!==void 0?o.specularFactor:1,o.specularTexture!==void 0&&s.push(n.assignTexture(t,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return t.specularColor=new M.Color().setRGB(a[0],a[1],a[2],M.LinearSRGBColorSpace),o.specularColorTexture!==void 0&&s.push(n.assignTexture(t,"specularColorMap",o.specularColorTexture,M.SRGBColorSpace)),Promise.all(s)}}class Dc{constructor(e){this.parser=e,this.name=le.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:M.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return t.bumpScale=o.bumpFactor!==void 0?o.bumpFactor:1,o.bumpTexture!==void 0&&s.push(n.assignTexture(t,"bumpMap",o.bumpTexture)),Promise.all(s)}}class Ec{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:M.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const s=[],o=i.extensions[this.name];return o.anisotropyStrength!==void 0&&(t.anisotropy=o.anisotropyStrength),o.anisotropyRotation!==void 0&&(t.anisotropyRotation=o.anisotropyRotation),o.anisotropyTexture!==void 0&&s.push(n.assignTexture(t,"anisotropyMap",o.anisotropyTexture)),Promise.all(s)}}class Lc{constructor(e){this.parser=e,this.name=le.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,i=n.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const s=i.extensions[this.name],o=t.options.ktx2Loader;if(!o){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,o)}}class Ic{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}}class zc{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,s=i.textures[e];if(!s.extensions||!s.extensions[t])return null;const o=s.extensions[t],a=i.images[o.source];let l=n.textureLoader;if(a.uri){const c=n.options.manager.getHandler(a.uri);c!==null&&(l=c)}return n.loadTextureImage(e,o.source,l)}}class Bc{constructor(e){this.name=le.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const i=n.extensions[this.name],s=this.parser.getDependency("buffer",i.buffer),o=this.parser.options.meshoptDecoder;if(!o||!o.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return s.then(function(a){const l=i.byteOffset||0,c=i.byteLength||0,h=i.count,u=i.byteStride,m=new Uint8Array(a,l,c);return o.decodeGltfBufferAsync?o.decodeGltfBufferAsync(h,u,m,i.mode,i.filter).then(function(p){return p.buffer}):o.ready.then(function(){const p=new ArrayBuffer(h*u);return o.decodeGltfBuffer(new Uint8Array(p),h,u,m,i.mode,i.filter),p})})}else return null}}class Rc{constructor(e){this.name=le.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const c of i.primitives)if(c.mode!==Ge.TRIANGLES&&c.mode!==Ge.TRIANGLE_STRIP&&c.mode!==Ge.TRIANGLE_FAN&&c.mode!==void 0)return null;const o=n.extensions[this.name].attributes,a=[],l={};for(const c in o)a.push(this.parser.getDependency("accessor",o[c]).then(h=>(l[c]=h,l[c])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(c=>{const h=c.pop(),u=h.isGroup?h.children:[h],m=c[0].count,p=[];for(const f of u){const d=new M.Matrix4,g=new M.Vector3,y=new M.Quaternion,v=new M.Vector3(1,1,1),x=new M.InstancedMesh(f.geometry,f.material,m);for(let b=0;b<m;b++)l.TRANSLATION&&g.fromBufferAttribute(l.TRANSLATION,b),l.ROTATION&&y.fromBufferAttribute(l.ROTATION,b),l.SCALE&&v.fromBufferAttribute(l.SCALE,b),x.setMatrixAt(b,d.compose(g,y,v));for(const b in l)if(b==="_COLOR_0"){const _=l[b];x.instanceColor=new M.InstancedBufferAttribute(_.array,_.itemSize,_.normalized)}else b!=="TRANSLATION"&&b!=="ROTATION"&&b!=="SCALE"&&f.geometry.setAttribute(b,l[b]);M.Object3D.prototype.copy.call(x,f),this.parser.assignFinalMaterial(x),p.push(x)}return h.isGroup?(h.clear(),h.add(...p),h):p[0]}))}}const Go="glTF",dn=12,jo={JSON:1313821514,BIN:5130562};class Oc{constructor(e){this.name=le.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,dn),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!==Go)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-dn,s=new DataView(e,dn);let o=0;for(;o<i;){const a=s.getUint32(o,!0);o+=4;const l=s.getUint32(o,!0);if(o+=4,l===jo.JSON){const c=new Uint8Array(e,dn+o,a);this.content=n.decode(c)}else if(l===jo.BIN){const c=dn+o;this.body=e.slice(c,c+a)}o+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Nc{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=le.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,i=this.dracoLoader,s=e.extensions[this.name].bufferView,o=e.extensions[this.name].attributes,a={},l={},c={};for(const h in o){const u=qi[h]||h.toLowerCase();a[u]=o[h]}for(const h in e.attributes){const u=qi[h]||h.toLowerCase();if(o[h]!==void 0){const m=n.accessors[e.attributes[h]],p=Yt[m.componentType];c[u]=p.name,l[u]=m.normalized===!0}}return t.getDependency("bufferView",s).then(function(h){return new Promise(function(u,m){i.decodeDracoFile(h,function(p){for(const f in p.attributes){const d=p.attributes[f],g=l[f];g!==void 0&&(d.normalized=g)}u(p)},a,c,M.LinearSRGBColorSpace,m)})})}}class Fc{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 Uc{constructor(){this.name=le.KHR_MESH_QUANTIZATION}}class Wo extends M.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,s=e*i*3+i;for(let o=0;o!==i;o++)t[o]=n[s+o];return t}interpolate_(e,t,n,i){const s=this.resultBuffer,o=this.sampleValues,a=this.valueSize,l=a*2,c=a*3,h=i-t,u=(n-t)/h,m=u*u,p=m*u,f=e*c,d=f-c,g=-2*p+3*m,y=p-m,v=1-g,x=y-m+u;for(let b=0;b!==a;b++){const _=o[d+b+a],T=o[d+b+l]*h,P=o[f+b+a],D=o[f+b]*h;s[b]=v*_+x*T+g*P+y*D}return s}}const Vc=new M.Quaternion;class Gc extends Wo{interpolate_(e,t,n,i){const s=super.interpolate_(e,t,n,i);return Vc.fromArray(s).normalize().toArray(s),s}}const Ge={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},Yt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Xo={9728:M.NearestFilter,9729:M.LinearFilter,9984:M.NearestMipmapNearestFilter,9985:M.LinearMipmapNearestFilter,9986:M.NearestMipmapLinearFilter,9987:M.LinearMipmapLinearFilter},Zo={33071:M.ClampToEdgeWrapping,33648:M.MirroredRepeatWrapping,10497:M.RepeatWrapping},$i={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qi={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},pt={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},jc={CUBICSPLINE:void 0,LINEAR:M.InterpolateLinear,STEP:M.InterpolateDiscrete},Hi={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function Wc(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new M.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:M.FrontSide})),r.DefaultMaterial}function kt(r,e,t){for(const n in t.extensions)r[n]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[n]=t.extensions[n])}function tt(r,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(r.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function Xc(r,e,t){let n=!1,i=!1,s=!1;for(let c=0,h=e.length;c<h;c++){const u=e[c];if(u.POSITION!==void 0&&(n=!0),u.NORMAL!==void 0&&(i=!0),u.COLOR_0!==void 0&&(s=!0),n&&i&&s)break}if(!n&&!i&&!s)return Promise.resolve(r);const o=[],a=[],l=[];for(let c=0,h=e.length;c<h;c++){const u=e[c];if(n){const m=u.POSITION!==void 0?t.getDependency("accessor",u.POSITION):r.attributes.position;o.push(m)}if(i){const m=u.NORMAL!==void 0?t.getDependency("accessor",u.NORMAL):r.attributes.normal;a.push(m)}if(s){const m=u.COLOR_0!==void 0?t.getDependency("accessor",u.COLOR_0):r.attributes.color;l.push(m)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then(function(c){const h=c[0],u=c[1],m=c[2];return n&&(r.morphAttributes.position=h),i&&(r.morphAttributes.normal=u),s&&(r.morphAttributes.color=m),r.morphTargetsRelative=!0,r})}function Zc(r,e){if(r.updateMorphTargets(),e.weights!==void 0)for(let t=0,n=e.weights.length;t<n;t++)r.morphTargetInfluences[t]=e.weights[t];if(e.extras&&Array.isArray(e.extras.targetNames)){const t=e.extras.targetNames;if(r.morphTargetInfluences.length===t.length){r.morphTargetDictionary={};for(let n=0,i=t.length;n<i;n++)r.morphTargetDictionary[t[n]]=n}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Yc(r){let e;const t=r.extensions&&r.extensions[le.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+Ji(t.attributes):e=r.indices+":"+Ji(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+Ji(r.targets[n]);return e}function Ji(r){let e="";const t=Object.keys(r).sort();for(let n=0,i=t.length;n<i;n++)e+=t[n]+":"+r[t[n]]+";";return e}function Qi(r){switch(r){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function Kc(r){return r.search(/\.jpe?g($|\?)/i)>0||r.search(/^data\:image\/jpeg/)===0?"image/jpeg":r.search(/\.webp($|\?)/i)>0||r.search(/^data\:image\/webp/)===0?"image/webp":r.search(/\.ktx2($|\?)/i)>0||r.search(/^data\:image\/ktx2/)===0?"image/ktx2":"image/png"}const $c=new M.Matrix4;class qc{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new vc,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let n=!1,i=-1,s=!1,o=-1;if(typeof navigator<"u"){const a=navigator.userAgent;n=/^((?!chrome|android).)*safari/i.test(a)===!0;const l=a.match(/Version\/(\d+)/);i=n&&l?parseInt(l[1],10):-1,s=a.indexOf("Firefox")>-1,o=s?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||s&&o<98?this.textureLoader=new M.TextureLoader(this.options.manager):this.textureLoader=new M.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new M.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,s=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(o){return o._markDefs&&o._markDefs()}),Promise.all(this._invokeAll(function(o){return o.beforeRoot&&o.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(o){const a={scene:o[0][i.scene||0],scenes:o[0],animations:o[1],cameras:o[2],asset:i.asset,parser:n,userData:{}};return kt(s,a,i),tt(a,i),Promise.all(n._invokeAll(function(l){return l.afterRoot&&l.afterRoot(a)})).then(function(){for(const l of a.scenes)l.updateMatrixWorld();e(a)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let i=0,s=t.length;i<s;i++){const o=t[i].joints;for(let a=0,l=o.length;a<l;a++)e[o[a]].isBone=!0}for(let i=0,s=e.length;i<s;i++){const o=e[i];o.mesh!==void 0&&(this._addNodeRef(this.meshCache,o.mesh),o.skin!==void 0&&(n[o.mesh].isSkinnedMesh=!0)),o.camera!==void 0&&this._addNodeRef(this.cameraCache,o.camera)}}_addNodeRef(e,t){t!==void 0&&(e.refs[t]===void 0&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const i=n.clone(),s=(o,a)=>{const l=this.associations.get(o);l!=null&&this.associations.set(a,l);for(const[c,h]of o.children.entries())s(h,a.children[c])};return s(n,i),i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const i=e(t[n]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let i=0;i<t.length;i++){const s=e(t[i]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let i=this.cache.get(n);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this._invokeOne(function(s){return s.loadNode&&s.loadNode(t)});break;case"mesh":i=this._invokeOne(function(s){return s.loadMesh&&s.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(s){return s.loadBufferView&&s.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(s){return s.loadMaterial&&s.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(s){return s.loadTexture&&s.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(s){return s.loadAnimation&&s.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(s){return s!=this&&s.getDependency&&s.getDependency(e,t)}),!i)throw new Error("Unknown type: "+e);break}this.cache.add(n,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,i=this.json[e+(e==="mesh"?"es":"s")]||[];t=Promise.all(i.map(function(s,o){return n.getDependency(e,o)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&t.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(t.uri===void 0&&e===0)return Promise.resolve(this.extensions[le.KHR_BINARY_GLTF].body);const i=this.options;return new Promise(function(s,o){n.load(M.LoaderUtils.resolveURL(t.uri,i.path),s,void 0,function(){o(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(n){const i=t.byteLength||0,s=t.byteOffset||0;return n.slice(s,s+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const o=$i[i.type],a=Yt[i.componentType],l=i.normalized===!0,c=new a(i.count*o);return Promise.resolve(new M.BufferAttribute(c,o,l))}const s=[];return i.bufferView!==void 0?s.push(this.getDependency("bufferView",i.bufferView)):s.push(null),i.sparse!==void 0&&(s.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(s).then(function(o){const a=o[0],l=$i[i.type],c=Yt[i.componentType],h=c.BYTES_PER_ELEMENT,u=h*l,m=i.byteOffset||0,p=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,f=i.normalized===!0;let d,g;if(p&&p!==u){const y=Math.floor(m/p),v="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+y+":"+i.count;let x=t.cache.get(v);x||(d=new c(a,y*p,i.count*p/h),x=new M.InterleavedBuffer(d,p/h),t.cache.add(v,x)),g=new M.InterleavedBufferAttribute(x,l,m%p/h,f)}else a===null?d=new c(i.count*l):d=new c(a,m,i.count*l),g=new M.BufferAttribute(d,l,f);if(i.sparse!==void 0){const y=$i.SCALAR,v=Yt[i.sparse.indices.componentType],x=i.sparse.indices.byteOffset||0,b=i.sparse.values.byteOffset||0,_=new v(o[1],x,i.sparse.count*y),T=new c(o[2],b,i.sparse.count*l);a!==null&&(g=new M.BufferAttribute(g.array.slice(),g.itemSize,g.normalized)),g.normalized=!1;for(let P=0,D=_.length;P<D;P++){const k=_[P];if(g.setX(k,T[P*l]),l>=2&&g.setY(k,T[P*l+1]),l>=3&&g.setZ(k,T[P*l+2]),l>=4&&g.setW(k,T[P*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}g.normalized=f}return g})}loadTexture(e){const t=this.json,n=this.options,s=t.textures[e].source,o=t.images[s];let a=this.textureLoader;if(o.uri){const l=n.manager.getHandler(o.uri);l!==null&&(a=l)}return this.loadTextureImage(e,s,a)}loadTextureImage(e,t,n){const i=this,s=this.json,o=s.textures[e],a=s.images[t],l=(a.uri||a.bufferView)+":"+o.sampler;if(this.textureCache[l])return this.textureCache[l];const c=this.loadImageSource(t,n).then(function(h){h.flipY=!1,h.name=o.name||a.name||"",h.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(h.name=a.uri);const m=(s.samplers||{})[o.sampler]||{};return h.magFilter=Xo[m.magFilter]||M.LinearFilter,h.minFilter=Xo[m.minFilter]||M.LinearMipmapLinearFilter,h.wrapS=Zo[m.wrapS]||M.RepeatWrapping,h.wrapT=Zo[m.wrapT]||M.RepeatWrapping,h.generateMipmaps=!h.isCompressedTexture&&h.minFilter!==M.NearestFilter&&h.minFilter!==M.LinearFilter,i.associations.set(h,{textures:e}),h}).catch(function(){return null});return this.textureCache[l]=c,c}loadImageSource(e,t){const n=this,i=this.json,s=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(u=>u.clone());const o=i.images[e],a=self.URL||self.webkitURL;let l=o.uri||"",c=!1;if(o.bufferView!==void 0)l=n.getDependency("bufferView",o.bufferView).then(function(u){c=!0;const m=new Blob([u],{type:o.mimeType});return l=a.createObjectURL(m),l});else if(o.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const h=Promise.resolve(l).then(function(u){return new Promise(function(m,p){let f=m;t.isImageBitmapLoader===!0&&(f=function(d){const g=new M.Texture(d);g.needsUpdate=!0,m(g)}),t.load(M.LoaderUtils.resolveURL(u,s.path),f,void 0,p)})}).then(function(u){return c===!0&&a.revokeObjectURL(l),tt(u,o),u.userData.mimeType=o.mimeType||Kc(o.uri),u}).catch(function(u){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),u});return this.sourceCache[e]=h,h}assignTexture(e,t,n,i){const s=this;return this.getDependency("texture",n.index).then(function(o){if(!o)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(o=o.clone(),o.channel=n.texCoord),s.extensions[le.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[le.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=s.associations.get(o);o=s.extensions[le.KHR_TEXTURE_TRANSFORM].extendTexture(o,a),s.associations.set(o,l)}}return i!==void 0&&(o.colorSpace=i),e[t]=o,o})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,s=t.attributes.color!==void 0,o=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new M.PointsMaterial,M.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 M.LineBasicMaterial,M.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||s||o){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),s&&(a+="vertex-colors:"),o&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),s&&(l.vertexColors=!0),o&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return M.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,s=n.materials[e];let o;const a={},l=s.extensions||{},c=[];if(l[le.KHR_MATERIALS_UNLIT]){const u=i[le.KHR_MATERIALS_UNLIT];o=u.getMaterialType(),c.push(u.extendParams(a,s,t))}else{const u=s.pbrMetallicRoughness||{};if(a.color=new M.Color(1,1,1),a.opacity=1,Array.isArray(u.baseColorFactor)){const m=u.baseColorFactor;a.color.setRGB(m[0],m[1],m[2],M.LinearSRGBColorSpace),a.opacity=m[3]}u.baseColorTexture!==void 0&&c.push(t.assignTexture(a,"map",u.baseColorTexture,M.SRGBColorSpace)),a.metalness=u.metallicFactor!==void 0?u.metallicFactor:1,a.roughness=u.roughnessFactor!==void 0?u.roughnessFactor:1,u.metallicRoughnessTexture!==void 0&&(c.push(t.assignTexture(a,"metalnessMap",u.metallicRoughnessTexture)),c.push(t.assignTexture(a,"roughnessMap",u.metallicRoughnessTexture))),o=this._invokeOne(function(m){return m.getMaterialType&&m.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(m){return m.extendMaterialParams&&m.extendMaterialParams(e,a)})))}s.doubleSided===!0&&(a.side=M.DoubleSide);const h=s.alphaMode||Hi.OPAQUE;if(h===Hi.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===Hi.MASK&&(a.alphaTest=s.alphaCutoff!==void 0?s.alphaCutoff:.5)),s.normalTexture!==void 0&&o!==M.MeshBasicMaterial&&(c.push(t.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new M.Vector2(1,1),s.normalTexture.scale!==void 0)){const u=s.normalTexture.scale;a.normalScale.set(u,u)}if(s.occlusionTexture!==void 0&&o!==M.MeshBasicMaterial&&(c.push(t.assignTexture(a,"aoMap",s.occlusionTexture)),s.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=s.occlusionTexture.strength)),s.emissiveFactor!==void 0&&o!==M.MeshBasicMaterial){const u=s.emissiveFactor;a.emissive=new M.Color().setRGB(u[0],u[1],u[2],M.LinearSRGBColorSpace)}return s.emissiveTexture!==void 0&&o!==M.MeshBasicMaterial&&c.push(t.assignTexture(a,"emissiveMap",s.emissiveTexture,M.SRGBColorSpace)),Promise.all(c).then(function(){const u=new o(a);return s.name&&(u.name=s.name),tt(u,s),t.associations.set(u,{materials:e}),s.extensions&&kt(i,u,s),u})}createUniqueName(e){const t=M.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 Yo(l,a,t)})}const o=[];for(let a=0,l=e.length;a<l;a++){const c=e[a],h=Yc(c),u=i[h];if(u)o.push(u.promise);else{let m;c.extensions&&c.extensions[le.KHR_DRACO_MESH_COMPRESSION]?m=s(c):m=Yo(new M.BufferGeometry,c,t),i[h]={primitive:c,promise:m},o.push(m)}}return Promise.all(o)}loadMesh(e){const t=this,n=this.json,i=this.extensions,s=n.meshes[e],o=s.primitives,a=[];for(let l=0,c=o.length;l<c;l++){const h=o[l].material===void 0?Wc(this.cache):this.getDependency("material",o[l].material);a.push(h)}return a.push(t.loadGeometries(o)),Promise.all(a).then(function(l){const c=l.slice(0,l.length-1),h=l[l.length-1],u=[];for(let p=0,f=h.length;p<f;p++){const d=h[p],g=o[p];let y;const v=c[p];if(g.mode===Ge.TRIANGLES||g.mode===Ge.TRIANGLE_STRIP||g.mode===Ge.TRIANGLE_FAN||g.mode===void 0)y=s.isSkinnedMesh===!0?new M.SkinnedMesh(d,v):new M.Mesh(d,v),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),g.mode===Ge.TRIANGLE_STRIP?y.geometry=Vo(y.geometry,M.TriangleStripDrawMode):g.mode===Ge.TRIANGLE_FAN&&(y.geometry=Vo(y.geometry,M.TriangleFanDrawMode));else if(g.mode===Ge.LINES)y=new M.LineSegments(d,v);else if(g.mode===Ge.LINE_STRIP)y=new M.Line(d,v);else if(g.mode===Ge.LINE_LOOP)y=new M.LineLoop(d,v);else if(g.mode===Ge.POINTS)y=new M.Points(d,v);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+g.mode);Object.keys(y.geometry.morphAttributes).length>0&&Zc(y,s),y.name=t.createUniqueName(s.name||"mesh_"+e),tt(y,s),g.extensions&&kt(i,y,g),t.assignFinalMaterial(y),u.push(y)}for(let p=0,f=u.length;p<f;p++)t.associations.set(u[p],{meshes:e,primitives:p});if(u.length===1)return s.extensions&&kt(i,u[0],s),u[0];const m=new M.Group;s.extensions&&kt(i,m,s),t.associations.set(m,{meshes:e});for(let p=0,f=u.length;p<f;p++)m.add(u[p]);return m})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new M.PerspectiveCamera(M.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new M.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),tt(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,s=t.joints.length;i<s;i++)n.push(this._loadNodeShallow(t.joints[i]));return t.inverseBindMatrices!==void 0?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(i){const s=i.pop(),o=i,a=[],l=[];for(let c=0,h=o.length;c<h;c++){const u=o[c];if(u){a.push(u);const m=new M.Matrix4;s!==null&&m.fromArray(s.array,c*16),l.push(m)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[c])}return new M.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],s=i.name?i.name:"animation_"+e,o=[],a=[],l=[],c=[],h=[];for(let u=0,m=i.channels.length;u<m;u++){const p=i.channels[u],f=i.samplers[p.sampler],d=p.target,g=d.node,y=i.parameters!==void 0?i.parameters[f.input]:f.input,v=i.parameters!==void 0?i.parameters[f.output]:f.output;d.node!==void 0&&(o.push(this.getDependency("node",g)),a.push(this.getDependency("accessor",y)),l.push(this.getDependency("accessor",v)),c.push(f),h.push(d))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l),Promise.all(c),Promise.all(h)]).then(function(u){const m=u[0],p=u[1],f=u[2],d=u[3],g=u[4],y=[];for(let x=0,b=m.length;x<b;x++){const _=m[x],T=p[x],P=f[x],D=d[x],k=g[x];if(_===void 0)continue;_.updateMatrix&&_.updateMatrix();const E=n._createAnimationTracks(_,T,P,D,k);if(E)for(let R=0;R<E.length;R++)y.push(E[R])}const v=new M.AnimationClip(s,void 0,y);return tt(v,i),v})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(s){const o=n._getNodeRef(n.meshCache,i.mesh,s);return i.weights!==void 0&&o.traverse(function(a){if(a.isMesh)for(let l=0,c=i.weights.length;l<c;l++)a.morphTargetInfluences[l]=i.weights[l]}),o})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],s=n._loadNodeShallow(e),o=[],a=i.children||[];for(let c=0,h=a.length;c<h;c++)o.push(n.getDependency("node",a[c]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([s,Promise.all(o),l]).then(function(c){const h=c[0],u=c[1],m=c[2];m!==null&&h.traverse(function(p){p.isSkinnedMesh&&p.bind(m,$c)});for(let p=0,f=u.length;p<f;p++)h.add(u[p]);return h})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const s=t.nodes[e],o=s.name?i.createUniqueName(s.name):"",a=[],l=i._invokeOne(function(c){return c.createNodeMesh&&c.createNodeMesh(e)});return l&&a.push(l),s.camera!==void 0&&a.push(i.getDependency("camera",s.camera).then(function(c){return i._getNodeRef(i.cameraCache,s.camera,c)})),i._invokeAll(function(c){return c.createNodeAttachment&&c.createNodeAttachment(e)}).forEach(function(c){a.push(c)}),this.nodeCache[e]=Promise.all(a).then(function(c){let h;if(s.isBone===!0?h=new M.Bone:c.length>1?h=new M.Group:c.length===1?h=c[0]:h=new M.Object3D,h!==c[0])for(let u=0,m=c.length;u<m;u++)h.add(c[u]);if(s.name&&(h.userData.name=s.name,h.name=o),tt(h,s),s.extensions&&kt(n,h,s),s.matrix!==void 0){const u=new M.Matrix4;u.fromArray(s.matrix),h.applyMatrix4(u)}else s.translation!==void 0&&h.position.fromArray(s.translation),s.rotation!==void 0&&h.quaternion.fromArray(s.rotation),s.scale!==void 0&&h.scale.fromArray(s.scale);if(!i.associations.has(h))i.associations.set(h,{});else if(s.mesh!==void 0&&i.meshCache.refs[s.mesh]>1){const u=i.associations.get(h);i.associations.set(h,{...u})}return i.associations.get(h).nodes=e,h}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,s=new M.Group;n.name&&(s.name=i.createUniqueName(n.name)),tt(s,n),n.extensions&&kt(t,s,n);const o=n.nodes||[],a=[];for(let l=0,c=o.length;l<c;l++)a.push(i.getDependency("node",o[l]));return Promise.all(a).then(function(l){for(let h=0,u=l.length;h<u;h++)s.add(l[h]);const c=h=>{const u=new Map;for(const[m,p]of i.associations)(m instanceof M.Material||m instanceof M.Texture)&&u.set(m,p);return h.traverse(m=>{const p=i.associations.get(m);p!=null&&u.set(m,p)}),u};return i.associations=c(s),s})}_createAnimationTracks(e,t,n,i,s){const o=[],a=e.name?e.name:e.uuid,l=[];pt[s.path]===pt.weights?e.traverse(function(m){m.morphTargetInfluences&&l.push(m.name?m.name:m.uuid)}):l.push(a);let c;switch(pt[s.path]){case pt.weights:c=M.NumberKeyframeTrack;break;case pt.rotation:c=M.QuaternionKeyframeTrack;break;case pt.translation:case pt.scale:c=M.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:c=M.NumberKeyframeTrack;break;case 2:case 3:default:c=M.VectorKeyframeTrack;break}break}const h=i.interpolation!==void 0?jc[i.interpolation]:M.InterpolateLinear,u=this._getArrayFromAccessor(n);for(let m=0,p=l.length;m<p;m++){const f=new c(l[m]+"."+pt[s.path],t.array,u,h);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(f),o.push(f)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=Qi(t.constructor),i=new Float32Array(t.length);for(let s=0,o=t.length;s<o;s++)i[s]=t[s]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof M.QuaternionKeyframeTrack?Gc:Wo;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function Hc(r,e,t){const n=e.attributes,i=new M.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,c=a.max;if(l!==void 0&&c!==void 0){if(i.set(new M.Vector3(l[0],l[1],l[2]),new M.Vector3(c[0],c[1],c[2])),a.normalized){const h=Qi(Yt[a.componentType]);i.min.multiplyScalar(h),i.max.multiplyScalar(h)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const s=e.targets;if(s!==void 0){const a=new M.Vector3,l=new M.Vector3;for(let c=0,h=s.length;c<h;c++){const u=s[c];if(u.POSITION!==void 0){const m=t.json.accessors[u.POSITION],p=m.min,f=m.max;if(p!==void 0&&f!==void 0){if(l.setX(Math.max(Math.abs(p[0]),Math.abs(f[0]))),l.setY(Math.max(Math.abs(p[1]),Math.abs(f[1]))),l.setZ(Math.max(Math.abs(p[2]),Math.abs(f[2]))),m.normalized){const d=Qi(Yt[m.componentType]);l.multiplyScalar(d)}a.max(l)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(a)}r.boundingBox=i;const o=new M.Sphere;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=o}function Yo(r,e,t){const n=e.attributes,i=[];function s(o,a){return t.getDependency("accessor",o).then(function(l){r.setAttribute(a,l)})}for(const o in n){const a=qi[o]||o.toLowerCase();a in r.attributes||i.push(s(n[o],a))}if(e.indices!==void 0&&!r.index){const o=t.getDependency("accessor",e.indices).then(function(a){r.setIndex(a)});i.push(o)}return M.ColorManagement.workingColorSpace!==M.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${M.ColorManagement.workingColorSpace}" not supported.`),tt(r,e),Hc(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?Xc(r,e.targets,t):r})}function Jc(r,e,t,n){let i=new w.Group;i.name=e,r.scene.add(i),Jn(e+"/info",s=>{let o=JSON.parse(s);if(r.engineStatus.models.push({type:"light",info:o,name:o.baseInfo.name,status:"loading",url:e,elements:new Map}),r.models==null&&(r.models=[]),r.models.push({url:e,nodesMap:new Map,grids:o.modelGrid,levels:o.modelLevel,rooms:o.modelRoom,views:o.modelView,boundingBox:{min:new w.Vector3(o.baseInfo.min.X*.3048,o.baseInfo.min.Z*.3048,-o.baseInfo.min.Y*.3048),max:new w.Vector3(o.baseInfo.max.X*.3048,o.baseInfo.max.Z*.3048,-o.baseInfo.max.Y*.3048)}}),r.engineStatus.models.length==n){console.log("相机位置设置"),r.viewCube.CameraGoHome(1);let a=new w.Vector3(1e6,1e7,1e6),l=new w.Vector3(-1e6,-1e7,-1e6);r.models.forEach(c=>{let h=c.boundingBox;h.min.x<a.x&&(a.x=h.min.x),h.min.y<a.y&&(a.y=h.min.y),h.min.z<a.z&&(a.z=h.min.z),h.max.x>l.x&&(l.x=h.max.x),h.max.y>l.y&&(l.y=h.max.y),h.max.z>l.z&&(l.z=h.max.z)}),console.log(a,l),a.distanceTo(l),window.startTime=Date.now(),setTimeout(function(){Ko(r,e)},100)}})}function Ko(r,e){r.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,t.info.modelMep==null&&(t.info.modelMep={}),gc(r,t.info.modelMep,t.url)),t.loadStatus.normal!=!0&&Qc(r,t))})}function Qc(r,e){if(console.log(`开始加载模型: ${Date.now()-window.startTime}ms`),r.camera.position,e.size,e.info==null||e.info.lods==null)return;e.info.lods.forEach(o=>{let a=!0;i(r,r.camera,o)<10&&(a=!1),o.status!=!0&&a&&(o.glbs==null?(console.log("加载GLB.............",o.path),o.glbs={},fc(e.url+o.path,c=>{Fo(c.get("/nodes.json"),h=>{let u=JSON.parse(h);r.models.find(f=>f.url==e.url).nodesMap==null&&(r.models.find(f=>f.url==e.url).nodesMap=new Map);let m=r.models.find(f=>f.url==e.url).nodesMap,p=0;for(let f in u){u[f].forEach(y=>{y.glb=f,m.has(y.id)==!1?m.set(y.id,{infos:[y]}):m.get(y.id).infos.push(y)});let d=new yc;const g=new pc;g.setDecoderPath("/draco/"),g.preload(),d.setDRACOLoader(g),d.load(c.get(f+".glb"),y=>{o.glbs[f]=y.scene.children,o.glbs[f].forEach(v=>{v.geometry.computeVertexNormals()}),p++,p==Object.keys(u).length&&Fo(c.get("/instances.json"),v=>{let x=JSON.parse(v);o.instanceNodes=x,o.loadSuccess=!0,r.engineStatus.isFree&&n(r,e,o)})})}})})):o.loadSuccess&&n(r,e,o))});function n(o,a,l){console.log(`准备加载模型mesh模型: ${Date.now()-window.startTime}ms`);let c=s(o,a,l,l.octreeBox);console.log("待加载模型",l.path,c.length);let h=[],u=o.models.find(p=>p.url==a.url);c.forEach(p=>{u.nodesMap.has(p)&&u.nodesMap.get(p).infos.forEach(f=>{let d=l.glbs[f.glb][f.mesh];if(d!=null&&d.geometry!=null&&d.material!=null){let g=new w.Matrix4;g.elements=f.matrix;let y=new w.Mesh(d.geometry.clone().applyMatrix4(g),d.material),v=new w.Box3().setFromObject(y);f.box=v,f.mesh=y,y.name=p,y.glb=f.glb,y.url=a.url,d.geometry.attributes.position!=null&&h.push(y)}})}),eh(a.url,o,h),console.log(`合并完模型: ${Date.now()-window.startTime}ms`);let m=l.instanceNodes;if(m!=null)for(let p in m)(m[p].isLoaded==null||m[p].isLoaded==!1)&&(m[p].isLoaded=!0,m[p].forEach(f=>{if(l.glbs[p]!=null){let d=l.glbs[p][f.mesh];th(a.url,f.mesh,o,d,f.children)}}))}function i(o,a,l){l.boundingBox||(l.boundingBox=new w.Box3,l.boundingBox.min=new w.Vector3(l.octreeBox.min.X,l.octreeBox.min.Z,-l.octreeBox.min.Y),l.boundingBox.max=new w.Vector3(l.octreeBox.max.X,l.octreeBox.max.Z,-l.octreeBox.max.Y));const c=l.boundingBox;let h=c.min,u=c.max,m=h.clone().add(u.clone()).multiplyScalar(.5),p=h.distanceTo(u);const f=new w.Vector3,d=new w.Vector3;a.getWorldDirection(d),o.camera.matrixWorld.extractBasis(f,d,new w.Vector3);let g=m.clone().add(d.setLength(-p)),y=g.clone().add(f.setLength(l.maxSize)),v=o.worldToScreen.worldToScreen(g),x=o.worldToScreen.worldToScreen(y);return v.distanceTo(x)}function s(o,a,l,c){let h=[];return c.status!=!0&&(c.elements.forEach(u=>{h.push(u)}),c.children.forEach(u=>{h.push(...s(o,a,l,u))}),c.children.findIndex(u=>u.status!=!0)==-1&&(c.status=!0),c.children.length==0&&(c.status=!0)),h}}function eh(r,e,t){let n=[];t.forEach(i=>{n.findIndex(o=>o.glb==i.glb)==-1?n.push({glb:i.glb,meshes:[i],currentIndex:i.geometry.index.count,indexes:new Map}):(n.find(o=>o.glb==i.glb).meshes.push(i),n.find(o=>o.glb==i.glb).currentIndex+=i.geometry.index.count);let s=n.find(o=>o.glb==i.glb);s.indexes.has(Number(i.name))?s.indexes.get(Number(i.name)).push([s.currentIndex-i.geometry.index.count,s.currentIndex]):s.indexes.set(Number(i.name),[[s.currentIndex-i.geometry.index.count,s.currentIndex]])}),n.forEach(i=>{let s=e.scene.children.find(o=>o instanceof w.Mesh&&o.url==r&&o.glb==i.glb);if(s!=null)s.castShadow=!0,s.receiveShadow=!0;else{let o=new w.BufferGeometry,a=nh(i.meshes[0].material);o=Zt(i.meshes.map(h=>h.geometry),!1);let l=new w.Mesh(o,a);l.castShadow=!0,l.receiveShadow=!0,e.scene.add(l),l.index=e.scene.children.length-1,l.url=r,l.glb=i.glb,l.indexes=i.indexes,l.materialClone=a,l.geometrys=i.meshes.map(h=>h.geometry);let c=e.models.find(h=>h.url==r);if(c!=null){let h=0;i.indexes.forEach(u=>{u.forEach(m=>{c.nodesMap.get(Number(i.meshes[h].name)).indexes==null&&(c.nodesMap.get(Number(i.meshes[h].name)).indexes=[]),c.nodesMap.get(Number(i.meshes[h].name)).indexes.push([l.index,h,m[0],m[1]])}),h=h+1})}}})}function th(r,e,t,n,i){if(n==null)return;let s=new w.InstancedMesh(n.geometry,n.material,i.length);t.scene.add(s);const o=new Float32Array(i.length*3);for(let l=0;l<i.length;l++)o[l*3]=1,o[l*3+1]=1,o[l*3+2]=1;s.instanceColor=new w.InstancedBufferAttribute(o,3);let a=[];for(let l=0;l<i.length;l++){let c=i[l],h=new w.Matrix4;h.elements=c.matrix,s.setMatrixAt(l,h),s.matrixs||(s.matrixs=[]),s.matrixs.push(h.clone()),a.push(h.clone()),t.models.find(u=>u.url==r).nodesMap.has(c.id)?(t.models.find(u=>u.url==r).nodesMap.get(c.id).indexes==null&&(t.models.find(u=>u.url==r).nodesMap.get(c.id).indexes=[]),t.models.find(u=>u.url==r).nodesMap.get(c.id).indexes.push([t.scene.children.length-1,l,0,0])):t.models.find(u=>u.url==r).nodesMap.set(c.id,{instance:!0,info:c,indexes:[[t.scene.children.length-1,l,0,0]]})}s.index=t.scene.children.length-1,s.materialClone=n.material,s.url=r,s.glb=n.glb,s.ids=i.map(l=>l.id),s.matrixsClone=a}function nh(r){return r.map!=null&&(r.map.colorSpace=w.SRGBColorSpace,r.map.needsUpdate=!0),r.shadowSide=w.FrontSide,r.side=r.side,r}class ih{engine;constructor(e){this.engine=e}async loadModels(e,t){console.log("待加载模型",e);for(const i of e)n(i)==="light"&&Jc(this.engine,i,t,e.length);function n(i){const s=i.split(".").pop();return s==="glb"||s==="gltf"?"gltf":"light"}}}var Kt=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.ViewportResize="viewport-resize",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.SectionMove="section-move",r))(Kt||{});class sh{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(Kt.EngineFree,e=>{this.updateFree(!0),Ko(this.engine,e)}),this.engine.events.on(Kt.EngineBusy,()=>{this.updateFree(!1)})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}let oh=class{listeners=new Map;debugMode=!1;setDebugMode(e){this.debugMode=e}on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t),this.debugMode&&console.debug(`[EventModule] 注册事件监听器: ${n}, 当前监听器数量: ${this.listeners.get(n).length}`)}off(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&console.warn(`[EventModule] 尝试移除不存在的事件监听器: ${n}`);return}const i=this.listeners.get(n),s=i.indexOf(t);s!==-1?(i.splice(s,1),this.debugMode&&console.debug(`[EventModule] 移除事件监听器: ${n}, 剩余监听器数量: ${i.length}`)):this.debugMode&&console.warn(`[EventModule] 尝试移除的回调函数未找到: ${n}`)}trigger(e,t){const n=String(e);if(!this.listeners.has(n)){this.debugMode&&(console.warn(`[EventModule] 触发事件但未找到监听器: ${n}`),console.debug("[EventModule] 当前已注册的事件类型:",Array.from(this.listeners.keys())));return}const i=this.listeners.get(n);this.debugMode&&console.debug(`[EventModule] 触发事件: ${n}, 监听器数量: ${i.length}`,t),i.forEach((s,o)=>{try{s(t)}catch(a){console.error(`[EventModule] 事件监听器执行错误 [${n}] #${o}:`,a)}})}};class rh{engine;constructor(e){this.engine=e}init(){const e=new w.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 w.DirectionalLight(16777215,2);this.engine.scene.add(e),this.engine.scene.add(n),this.engine.scene.dirLight=n;const i=new w.AmbientLight(16777215,1);this.engine.scene.add(i)}}var Me=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.MeasureClick="measure-click",r.SectionMove="section-move",r))(Me||{});class ah{engine;behavior;isCtrlDown=!1;highlightedInstances=[];highlightColor=new w.Color(43775);constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1}handelKeyCtrlDown(){this.isCtrlDown=!0}hoverOldId=null;timeOutEvent;handleMouseMove(e){if(this.timeOutEvent!=null&&(clearTimeout(this.timeOutEvent),this.timeOutEvent=null),e.catch!=null&&(this.engine.hoverHighLight.showModelNameTag(null,null),this.timeOutEvent=setTimeout(()=>{this.hoverOldId=null;let n=this.getCatchMeshs(e,!0);n.length>0&&this.engine.hoverHighLight.showModelNameTag({url:n[0].url,ids:[n[0].name]},e.catch.point)},1e3)),!this.engine.engineStatus.isFree){this.engine.hoverHighLight.clearHighlight();return}let t=this.getCatchMeshs(e);t!=null?t.length>0&&this.engine.hoverHighLight.hightMesh(t):this.engine.hoverHighLight.clearHighlight()}getCatchMeshs(e,t=!1){if(e.catch==null)return this.hoverOldId=null,null;if(e.catch.object.isInstance){let n=e.catch.object,i=e.catch.object.id,s=this.engine.models.find(l=>l.url==n.url).nodesMap.get(i),o=new Map;s?.indexes.forEach(l=>{this.engine.scene.children[l[0]]instanceof w.InstancedMesh&&(o.has(l[0])?o.get(l[0])?.push(l[1]):o.set(l[0],[l[1]]))});let a=[];return o.forEach((l,c)=>{let h=this.engine.scene.children[c];l.forEach(u=>{let m=h.geometry.clone();m.applyMatrix4(h.matrixs[u]),a.push(new w.Mesh(m,h.material))})}),this.hoverOldId==i?[]:(this.hoverOldId=i,t||this.engine.hoverHighLight.clearHighlight(),a)}else{let i=e.catch.object,s=i.name,l=this.engine.models.find(c=>c.url===i.url).nodesMap.get(s).infos.map(c=>c.mesh);return this.hoverOldId==s?[]:(this.hoverOldId=s,t||this.engine.hoverHighLight.clearHighlight(),l)}}handleMouseClick(e){if(e.catch!=null){const t=e.catch;let n=t.object;if(!this.isCtrlDown){this.engine.modelToolModule.unhighlightAllModels();let s=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(s)}console.log([{url:n.url,ids:[n.name]}]),this.engine.controlModule.orbitControls.origin.set(t.point.x,t.point.y,t.point.z),this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.name]}]),this.engine.events.trigger(Me.Click,[{url:n.url,ids:[n.name]}]);let i=new CustomEvent("D3ElementClick",{detail:{id:n.name}});window.dispatchEvent(i)}else{let t=new CustomEvent("D3ElementClick",{detail:{id:-1}});window.dispatchEvent(t),this.engine.modelToolModule.unhighlightAllModels()}}handleMouseDoubleClick(e){if(e.catch){const n=e.catch;let i=n.object,o=this.engine.models.find(a=>a.url===i.url).nodesMap.get(i.name);if(n.object.isInstance){let a=n.matrix;const l=[];o.indexes.forEach(h=>{let u=h[0],m=this.engine.scene.children[u].geometry.boundingSphere;const p=new w.Box3,f=m.center.clone().applyMatrix4(a),d=m.radius,g=new w.Vector3;g.setFromMatrixScale(a);const y=Math.max(g.x,g.y,g.z),v=d*y;p.min.set(f.x-v,f.y-v,f.z-v),p.max.set(f.x+v,f.y+v,f.z+v),l.push(p)});let c=t(l);this.engine.viewCube.zoomToModel(c)}else{const a=o.infos.map(c=>c.box);let l=t(a);this.engine.viewCube.zoomToModel(l)}}function t(n){let i=new w.Vector3(1e8,1e9,1e10),s=new w.Vector3(-1e8,-1e9,-1e10);return n.forEach(o=>{o.min.x<i.x&&(i.x=o.min.x),o.min.y<i.y&&(i.y=o.min.y),o.min.z<i.z&&(i.z=o.min.z),o.max.x>s.x&&(s.x=o.max.x),o.max.y>s.y&&(s.y=o.max.y),o.max.z>s.z&&(s.z=o.max.z)}),new w.Box3(i,s)}}handleMouseClickInstance(e){return e.intersectObjects(this.engine.scene.children.filter(n=>n instanceof w.InstancedMesh),!0)}}class lh{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new w.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:w.DoubleSide}),this.hideMaterial=new w.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:w.DoubleSide}),this.translucentMaterial=new w.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:w.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 w.InstancedMesh)return;let t=e.materialClone.clone(),n=Zt(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){}getSceneModel(e){return this.engine.scene.children.find(t=>t.index==e)}highlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{this.getSceneModel(a[0])instanceof w.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(console.log(this.getSceneModel(a[0]).materialClone.color),this.split_merge_model(this.getSceneModel(a[0])),this.getSceneModel(a[0]).geometry.groups[a[1]].materialIndex=1)})}),ch(n,this.engine);let i=this.engine.engineStatus.highlightModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);s!=null&&s.indexes!=null&&s.indexes.forEach(o=>{this.getSceneModel(o[0])instanceof w.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):this.getSceneModel(o[0]).geometry.groups[o[1]].materialIndex=0})}),$o(n,this.engine,"highlightModel")})}unhighlightAllModels(e=!0){this.engine.engineStatus.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus.highlightModels=[])}hideModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.hideModelEdge(t.url,s),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof w.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=-1,l.geometry.groups[a[1]].visible=!1)})}),n.size>0&&dh(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);this.engine.modelEdge.showModelEdge(t.url,s),o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof w.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&&qo(n,this.engine);let i=this.engine.engineStatus.hideModels.find(s=>s.url==t.url);i&&(t.ids.forEach(s=>{const o=i.ids.indexOf(s);o!==-1&&i.ids.splice(o,1)}),i.ids.length===0&&(this.engine.engineStatus.hideModels=this.engine.engineStatus.hideModels.filter(s=>s!==i)))})}isolateModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},s=e.find(o=>o.url==n.url);for(let o of n.nodesMap)s==null?i.ids.push(o[0]):s.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)});debugger;this.unhighlightAllModels(),this.hideModel(t)}translucentOtherModel(e){let t=[];this.engine.models.forEach(n=>{let i={url:n.url,ids:[]},s=e.find(o=>o.url==n.url);for(let o of n.nodesMap)s==null?i.ids.push(o[0]):s.ids.includes(o[0])||i.ids.push(o[0]);t.push(i)}),this.translucentModel(t)}setModelColor(e,t){e.material.color.set(t)}setAllModelsColor(e){this.engine.scene.children.forEach(t=>{t.isMesh})}restoreAllModelsColor(){this.engine.scene.children.forEach(e=>{e.isMesh})}translucentModel(e){this.unhighlightAllModels(),e.forEach(t=>{let n=new Map;t.ids.forEach(s=>{let o=this.engine.models.find(a=>a.url==t.url).nodesMap.get(s);o!=null&&o.indexes!=null&&o.indexes.forEach(a=>{const l=this.getSceneModel(a[0]);l instanceof w.InstancedMesh?n.has(a[0])?n.get(a[0])?.push(a[1]):n.set(a[0],[a[1]]):(this.split_merge_model(this.getSceneModel(a[0])),l.geometry.groups[a[1]].materialIndex=2)})}),hh(n,this.engine);let i=this.engine.engineStatus.translucentModels.find(s=>s.url==t.url);i!=null?i.ids.push(...t.ids):this.engine.engineStatus.translucentModels.push({url:t.url,ids:t.ids})}),this.engine.engineStatus.highlightModels=[]}unTranslucentModel(){this.engine.engineStatus.translucentModels.forEach(t=>{let n=new Map;t.ids.forEach(i=>{let s=this.engine.models.find(o=>o.url==t.url).nodesMap.get(i);s!=null&&s.indexes!=null&&s.indexes.forEach(o=>{const a=this.getSceneModel(o[0]);a instanceof w.InstancedMesh?n.has(o[0])?n.get(o[0])?.push(o[1]):n.set(o[0],[o[1]]):(this.split_merge_model(this.getSceneModel(o[0])),a.geometry.groups[o[1]].materialIndex=0)})}),n.size>0&&qo(n,this.engine),$o(n,this.engine,"translucentModel")}),this.engine.engineStatus.translucentModels=[]}showAllModels(){this.engine.engineStatus.hideModels&&this.engine.engineStatus.hideModels.length>0&&this.showModel(this.engine.engineStatus.hideModels),this.engine.engineStatus.hideModels=[],this.unhighlightAllModels()}batchSelectSameLevelTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevelType(n.levelName,n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameLevelModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithLevel(n.levelName,i=>{this.engine.modelToolModule.highlightModel(i)})}batchSelectSameTypeModel(e){if(e.length==0)return;let t=e[0],n=this.engine.modelMapperBatch.getModelMapper(t.url,t.ids[0]);this.engine.modelMapperBatch.getModelsWithType(n.typeName,i=>{this.engine.modelToolModule.highlightModel(i)})}}function ch(r,e){r.forEach((t,n)=>{const i=un(e,n);if(!(i instanceof w.InstancedMesh))return;const s=i.geometry,o=new w.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:w.DoubleSide}),a=new w.InstancedMesh(s,o,t.length);a.name="highlightModel",a.key=n;const l=new Map,c=new w.Matrix4,h=new w.Matrix4;h.makeScale(0,0,0),t.forEach((u,m)=>{i.getMatrixAt(u,c),l.set(u,c.clone()),i.setMatrixAt(u,h),a.setMatrixAt(m,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function $o(r,e,t){r.forEach((n,i)=>{const s=un(e,i);if(!(s instanceof w.InstancedMesh))return;n.forEach(a=>{const l=s.matrixsClone[a];l&&s.setMatrixAt(a,l)}),s.instanceMatrix.needsUpdate=!0,e.scene.children.filter(a=>a.key==i&&a.name==t).forEach(a=>{e.scene.remove(a)})})}function hh(r,e){r.forEach((t,n)=>{const i=un(e,n);if(!(i instanceof w.InstancedMesh))return;const s=i.geometry,o=new w.MeshBasicMaterial({color:16777215,transparent:!0,opacity:.05,side:w.DoubleSide}),a=new w.InstancedMesh(s,o,t.length);a.name="translucentModel",a.key=n;const l=new Map,c=new w.Matrix4,h=new w.Matrix4;h.makeScale(0,0,0),t.forEach((u,m)=>{i.getMatrixAt(u,c),l.set(u,c.clone()),i.setMatrixAt(u,h),a.setMatrixAt(m,c)}),i.instanceMatrix.needsUpdate=!0,a.instanceMatrix.needsUpdate=!0,e.scene.add(a)})}function dh(r,e){e.scene.children.filter(t=>t.name=="highlightModel").forEach(t=>{e.scene.remove(t)}),r.forEach((t,n)=>{const i=un(e,n);if(!(i instanceof w.InstancedMesh))return;const s=new Map,o=new w.Matrix4,a=new w.Matrix4;a.makeScale(0,0,0),t.forEach((l,c)=>{i.getMatrixAt(l,o),s.set(l,o.clone()),i.setMatrixAt(l,a)}),i.instanceMatrix.needsUpdate=!0})}function qo(r,e){r.forEach((t,n)=>{const i=un(e,n);i instanceof w.InstancedMesh&&(t.forEach(s=>{const o=i.matrixs[s];o&&i.setMatrixAt(s,o)}),i.instanceMatrix.needsUpdate=!0)})}function un(r,e){return r.scene.children.find(t=>t.index==e)}class uh{engine;currentMode="";isManualMode=!1;gtaoPass=null;ssaoPass=null;saturationPass=null;outputPass=null;fxaaPass=null;constructor(e){this.engine=e}init(){this.cachePassReferences(),this.autoSwitch("advanced")}switchModel(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}autoSwitch(e){this.isManualMode||(this.currentMode=e,this.applyMode(e))}enableAutoMode(){this.isManualMode=!1}get isManual(){return this.isManualMode}setMode(e){this.isManualMode=!0,this.currentMode=e,this.applyMode(e)}getCurrentMode(){return this.currentMode}cachePassReferences(){this.engine.composerModule?.composer&&(this.engine.composerModule.gtaoPass&&(this.gtaoPass=this.engine.composerModule.gtaoPass),this.engine.composerModule.ssaoPass&&(this.ssaoPass=this.engine.composerModule.ssaoPass),this.engine.composerModule.saturationPass&&(this.saturationPass=this.engine.composerModule.saturationPass),this.engine.composerModule.outputPass&&(this.outputPass=this.engine.composerModule.outputPass),this.engine.composerModule.fxaaPass&&(this.fxaaPass=this.engine.composerModule.fxaaPass))}applyMode(e){switch(e){case"simple":this.setShadows(!1),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"balance":this.setShadows(!0),this.setGTAO(!1),this.setSSAO(!1),this.setSaturation(!1),this.setOutputPass(!1),this.setFXAA(!1);break;case"advanced":this.setShadows(!0),this.setSSAO(!1),this.setGTAO(!0),this.setSaturation(!0),this.setOutputPass(!0),this.setFXAA(!0);break;default:console.warn(`[EngineModelModule] Unknown mode: ${e}`)}this.engine.updateVersionDisplay?.()}setShadows(e){this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e);const t=this.engine.scene?.children.find(n=>n instanceof w.DirectionalLight);t&&(t.castShadow=e),this.engine.scene?.traverse(n=>{n.material&&(n.castShadow!==void 0&&(n.castShadow=e),n.receiveShadow!==void 0&&(n.receiveShadow=e))})}setGTAO(e){this.engine.composerModule?.composer&&this.gtaoPass&&(this.gtaoPass.enabled=e)}setSSAO(e){this.engine.composerModule?.composer&&this.ssaoPass&&(this.ssaoPass.enabled=e)}setSaturation(e){this.saturationPass&&(this.saturationPass.enabled=e)}setOutputPass(e){this.outputPass&&(this.outputPass.enabled=e)}setFXAA(e){this.fxaaPass&&(this.fxaaPass.enabled=e)}setPerformanceMode(){this.setMode("simple")}setBalancedMode(){this.setMode("balance")}setQualityMode(){this.setMode("advanced")}setSuperQualityMode(){this.setMode("superAdvanced")}setShadowQuality(e){const t=this.engine.scene?.children.find(s=>s instanceof w.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 ti{engine;overlayMaterial;overlayMeshes=[];animState="idle";animStartTime=0;static FADE_IN_MS=200;static FADE_OUT_MS=150;tagDiv;constructor(e){this.engine=e,this.init();const t=document.createElement("div");this.tagDiv=t,t.className="tagDiv",t.style.position="absolute",t.style.top="0px",t.style.left="0px",t.style.borderRadius="10px",t.style.pointerEvents="none",this.engine.container.appendChild(this.tagDiv)}showModelNameTag(e,t){if(e==null){this.tagDiv.style.display="none";return}let n=this.engine.models.find(a=>a.url==e.url);if(n==null){this.tagDiv.style.display="none";return}let i=n.nodesMap.get(e.ids[0]);if(i.infos&&i.infos.length>0){let a=i.infos[0].name.replace(/\s*\[[a-f0-9-]+\]$/,"");this.tagDiv.innerHTML=a}const o=this.engine.worldToScreen.worldToScreen(t);this.tagDiv?(this.tagDiv.style.left=o.x+10+this.engine.reactBoundingClientRect.left+"px",this.tagDiv.style.top=o.y-10+this.engine.reactBoundingClientRect.top+"px",this.tagDiv.style.display="block"):this.tagDiv&&(this.tagDiv.style.display="none")}init(){this.overlayMaterial=new w.MeshBasicMaterial({color:16777215,transparent:!0,opacity:0,blending:w.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 o=new w.Mesh(s.geometry,this.overlayMaterial);s.updateWorldMatrix(!0,!1),o.matrix.copy(s.matrixWorld),o.matrixAutoUpdate=!1,this.engine.scene.add(o),this.overlayMeshes.push(o)}this.animState="fadeIn",this.animStartTime=performance.now()}clearHighlight(){this.overlayMeshes.length===0||this.animState==="fadeOut"||(this.animState="fadeOut",this.animStartTime=performance.now())}update(){if(this.animState==="idle"||this.overlayMeshes.length===0)return;const e=performance.now()-this.animStartTime,t=this.overlayMaterial.userData.targetOpacity??.35;if(this.animState==="fadeIn"){const n=Math.min(e/ti.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/ti.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 ni={exports:{}},fh=ni.exports,Ho;function ph(){return Ho||(Ho=1,(function(r,e){(function(t,n){r.exports=n()})(fh,function(){var t=function(){function n(p){return o.appendChild(p.dom),p}function i(p){for(var f=0;f<o.children.length;f++)o.children[f].style.display=f===p?"block":"none";s=p}var s=0,o=document.createElement("div");o.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",o.addEventListener("click",function(p){p.preventDefault(),i(++s%o.children.length)},!1);var a=(performance||Date).now(),l=a,c=0,h=n(new t.Panel("FPS","#0ff","#002")),u=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var m=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:o,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){c++;var p=(performance||Date).now();if(u.update(p-a,200),p>l+1e3&&(h.update(1e3*c/(p-l),100),l=p,c=0,m)){var f=performance.memory;m.update(f.usedJSHeapSize/1048576,f.jsHeapSizeLimit/1048576)}return p},update:function(){a=this.end()},domElement:o,setMode:i}};return t.Panel=function(n,i,s){var o=1/0,a=0,l=Math.round,c=l(window.devicePixelRatio||1),h=80*c,u=48*c,m=3*c,p=2*c,f=3*c,d=15*c,g=74*c,y=30*c,v=document.createElement("canvas");v.width=h,v.height=u,v.style.cssText="width:80px;height:48px";var x=v.getContext("2d");return x.font="bold "+9*c+"px Helvetica,Arial,sans-serif",x.textBaseline="top",x.fillStyle=s,x.fillRect(0,0,h,u),x.fillStyle=i,x.fillText(n,m,p),x.fillRect(f,d,g,y),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(f,d,g,y),{dom:v,update:function(b,_){o=Math.min(o,b),a=Math.max(a,b),x.fillStyle=s,x.globalAlpha=1,x.fillRect(0,0,h,d),x.fillStyle=i,x.fillText(l(b)+" "+n+" ("+l(o)+"-"+l(a)+")",m,p),x.drawImage(v,f+c,d,g-c,y,f,d,g-c,y),x.fillRect(f+g-c,d,c,y),x.fillStyle=s,x.globalAlpha=.9,x.fillRect(f+g-c,d,c,l((1-b/_)*y))}}},t})})(ni)),ni.exports}var mh=ph();const gh=qs(mh);var $t=Object.freeze({Linear:Object.freeze({None:function(r){return r},In:function(r){return r},Out:function(r){return r},InOut:function(r){return r}}),Quadratic:Object.freeze({In:function(r){return r*r},Out:function(r){return r*(2-r)},InOut:function(r){return(r*=2)<1?.5*r*r:-.5*(--r*(r-2)-1)}}),Cubic:Object.freeze({In:function(r){return r*r*r},Out:function(r){return--r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r:.5*((r-=2)*r*r+2)}}),Quartic:Object.freeze({In:function(r){return r*r*r*r},Out:function(r){return 1- --r*r*r*r},InOut:function(r){return(r*=2)<1?.5*r*r*r*r:-.5*((r-=2)*r*r*r-2)}}),Quintic:Object.freeze({In:function(r){return r*r*r*r*r},Out:function(r){return--r*r*r*r*r+1},InOut:function(r){return(r*=2)<1?.5*r*r*r*r*r:.5*((r-=2)*r*r*r*r+2)}}),Sinusoidal:Object.freeze({In:function(r){return 1-Math.sin((1-r)*Math.PI/2)},Out:function(r){return Math.sin(r*Math.PI/2)},InOut:function(r){return .5*(1-Math.sin(Math.PI*(.5-r)))}}),Exponential:Object.freeze({In:function(r){return r===0?0:Math.pow(1024,r-1)},Out:function(r){return r===1?1:1-Math.pow(2,-10*r)},InOut:function(r){return r===0?0:r===1?1:(r*=2)<1?.5*Math.pow(1024,r-1):.5*(-Math.pow(2,-10*(r-1))+2)}}),Circular:Object.freeze({In:function(r){return 1-Math.sqrt(1-r*r)},Out:function(r){return Math.sqrt(1- --r*r)},InOut:function(r){return(r*=2)<1?-.5*(Math.sqrt(1-r*r)-1):.5*(Math.sqrt(1-(r-=2)*r)+1)}}),Elastic:Object.freeze({In:function(r){return r===0?0:r===1?1:-Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI)},Out:function(r){return r===0?0:r===1?1:Math.pow(2,-10*r)*Math.sin((r-.1)*5*Math.PI)+1},InOut:function(r){return r===0?0:r===1?1:(r*=2,r<1?-.5*Math.pow(2,10*(r-1))*Math.sin((r-1.1)*5*Math.PI):.5*Math.pow(2,-10*(r-1))*Math.sin((r-1.1)*5*Math.PI)+1)}}),Back:Object.freeze({In:function(r){var e=1.70158;return r===1?1:r*r*((e+1)*r-e)},Out:function(r){var e=1.70158;return r===0?0:--r*r*((e+1)*r+e)+1},InOut:function(r){var e=2.5949095;return(r*=2)<1?.5*(r*r*((e+1)*r-e)):.5*((r-=2)*r*((e+1)*r+e)+2)}}),Bounce:Object.freeze({In:function(r){return 1-$t.Bounce.Out(1-r)},Out:function(r){return r<1/2.75?7.5625*r*r:r<2/2.75?7.5625*(r-=1.5/2.75)*r+.75:r<2.5/2.75?7.5625*(r-=2.25/2.75)*r+.9375:7.5625*(r-=2.625/2.75)*r+.984375},InOut:function(r){return r<.5?$t.Bounce.In(r*2)*.5:$t.Bounce.Out(r*2-1)*.5+.5}}),generatePow:function(r){return r===void 0&&(r=4),r=r<Number.EPSILON?Number.EPSILON:r,r=r>1e4?1e4:r,{In:function(e){return Math.pow(e,r)},Out:function(e){return 1-Math.pow(1-e,r)},InOut:function(e){return e<.5?Math.pow(e*2,r)/2:(1-Math.pow(2-e*2,r))/2+.5}}}}),fn=function(){return performance.now()},yh=(function(){function r(){this._tweens={},this._tweensAddedDuringUpdate={}}return r.prototype.getAll=function(){var e=this;return Object.keys(this._tweens).map(function(t){return e._tweens[t]})},r.prototype.removeAll=function(){this._tweens={}},r.prototype.add=function(e){this._tweens[e.getId()]=e,this._tweensAddedDuringUpdate[e.getId()]=e},r.prototype.remove=function(e){delete this._tweens[e.getId()],delete this._tweensAddedDuringUpdate[e.getId()]},r.prototype.update=function(e,t){e===void 0&&(e=fn()),t===void 0&&(t=!1);var n=Object.keys(this._tweens);if(n.length===0)return!1;for(;n.length>0;){this._tweensAddedDuringUpdate={};for(var i=0;i<n.length;i++){var s=this._tweens[n[i]],o=!t;s&&s.update(e,o)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},r})(),es={Linear:function(r,e){var t=r.length-1,n=t*e,i=Math.floor(n),s=es.Utils.Linear;return e<0?s(r[0],r[1],n):e>1?s(r[t],r[t-1],t-n):s(r[i],r[i+1>t?t:i+1],n-i)},Utils:{Linear:function(r,e,t){return(e-r)*t+r}}},Jo=(function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r})(),ts=new yh,vh=(function(){function r(e,t){t===void 0&&(t=ts),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=$t.Linear.None,this._interpolationFunction=es.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=Jo.nextId(),this._isChainStopped=!1,this._propertiesAreSetUp=!1,this._goToEnd=!1}return r.prototype.getId=function(){return this._id},r.prototype.isPlaying=function(){return this._isPlaying},r.prototype.isPaused=function(){return this._isPaused},r.prototype.getDuration=function(){return this._duration},r.prototype.to=function(e,t){if(t===void 0&&(t=1e3),this._isPlaying)throw new Error("Can not call Tween.to() while Tween is already started or paused. Stop the Tween first.");return this._valuesEnd=e,this._propertiesAreSetUp=!1,this._duration=t<0?0:t,this},r.prototype.duration=function(e){return e===void 0&&(e=1e3),this._duration=e<0?0:e,this},r.prototype.dynamic=function(e){return e===void 0&&(e=!1),this._isDynamic=e,this},r.prototype.start=function(e,t){if(e===void 0&&(e=fn()),t===void 0&&(t=!1),this._isPlaying)return this;if(this._group&&this._group.add(this),this._repeat=this._initialRepeat,this._reversed){this._reversed=!1;for(var n in this._valuesStartRepeat)this._swapEndStartRepeatValues(n),this._valuesStart[n]=this._valuesStartRepeat[n]}if(this._isPlaying=!0,this._isPaused=!1,this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._isChainStopped=!1,this._startTime=e,this._startTime+=this._delayTime,!this._propertiesAreSetUp||t){if(this._propertiesAreSetUp=!0,!this._isDynamic){var i={};for(var s in this._valuesEnd)i[s]=this._valuesEnd[s];this._valuesEnd=i}this._setupProperties(this._object,this._valuesStart,this._valuesEnd,this._valuesStartRepeat,t)}return this},r.prototype.startFromCurrentValues=function(e){return this.start(e,!0)},r.prototype._setupProperties=function(e,t,n,i,s){for(var o in n){var a=e[o],l=Array.isArray(a),c=l?"array":typeof a,h=!l&&Array.isArray(n[o]);if(!(c==="undefined"||c==="function")){if(h){var u=n[o];if(u.length===0)continue;for(var m=[a],p=0,f=u.length;p<f;p+=1){var d=this._handleRelativeValue(a,u[p]);if(isNaN(d)){h=!1,console.warn("Found invalid interpolation list. Skipping.");break}m.push(d)}h&&(n[o]=m)}if((c==="object"||l)&&a&&!h){t[o]=l?[]:{};var g=a;for(var y in g)t[o][y]=g[y];i[o]=l?[]:{};var u=n[o];if(!this._isDynamic){var v={};for(var y in u)v[y]=u[y];n[o]=u=v}this._setupProperties(g,t[o],u,i[o],s)}else(typeof t[o]>"u"||s)&&(t[o]=a),l||(t[o]*=1),h?i[o]=n[o].slice().reverse():i[o]=t[o]||0}}},r.prototype.stop=function(){return this._isChainStopped||(this._isChainStopped=!0,this.stopChainedTweens()),this._isPlaying?(this._group&&this._group.remove(this),this._isPlaying=!1,this._isPaused=!1,this._onStopCallback&&this._onStopCallback(this._object),this):this},r.prototype.end=function(){return this._goToEnd=!0,this.update(1/0),this},r.prototype.pause=function(e){return e===void 0&&(e=fn()),this._isPaused||!this._isPlaying?this:(this._isPaused=!0,this._pauseStart=e,this._group&&this._group.remove(this),this)},r.prototype.resume=function(e){return e===void 0&&(e=fn()),!this._isPaused||!this._isPlaying?this:(this._isPaused=!1,this._startTime+=e-this._pauseStart,this._pauseStart=0,this._group&&this._group.add(this),this)},r.prototype.stopChainedTweens=function(){for(var e=0,t=this._chainedTweens.length;e<t;e++)this._chainedTweens[e].stop();return this},r.prototype.group=function(e){return e===void 0&&(e=ts),this._group=e,this},r.prototype.delay=function(e){return e===void 0&&(e=0),this._delayTime=e,this},r.prototype.repeat=function(e){return e===void 0&&(e=0),this._initialRepeat=e,this._repeat=e,this},r.prototype.repeatDelay=function(e){return this._repeatDelayTime=e,this},r.prototype.yoyo=function(e){return e===void 0&&(e=!1),this._yoyo=e,this},r.prototype.easing=function(e){return e===void 0&&(e=$t.Linear.None),this._easingFunction=e,this},r.prototype.interpolation=function(e){return e===void 0&&(e=es.Linear),this._interpolationFunction=e,this},r.prototype.chain=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return this._chainedTweens=e,this},r.prototype.onStart=function(e){return this._onStartCallback=e,this},r.prototype.onEveryStart=function(e){return this._onEveryStartCallback=e,this},r.prototype.onUpdate=function(e){return this._onUpdateCallback=e,this},r.prototype.onRepeat=function(e){return this._onRepeatCallback=e,this},r.prototype.onComplete=function(e){return this._onCompleteCallback=e,this},r.prototype.onStop=function(e){return this._onStopCallback=e,this},r.prototype.update=function(e,t){var n=this,i;if(e===void 0&&(e=fn()),t===void 0&&(t=!0),this._isPaused)return!0;var s,o=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>o)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,l=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),c=this._duration+this._repeat*l,h=function(){if(n._duration===0||a>c)return 1;var g=Math.trunc(a/l),y=a-g*l,v=Math.min(y/n._duration,1);return v===0&&a===n._duration?1:v},u=h(),m=this._easingFunction(u);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,m),this._onUpdateCallback&&this._onUpdateCallback(this._object,u),this._duration===0||a>=this._duration)if(this._repeat>0){var p=Math.min(Math.trunc((a-this._duration)/l)+1,this._repeat);isFinite(this._repeat)&&(this._repeat-=p);for(s in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[s]=="string"&&(this._valuesStartRepeat[s]=this._valuesStartRepeat[s]+parseFloat(this._valuesEnd[s])),this._yoyo&&this._swapEndStartRepeatValues(s),this._valuesStart[s]=this._valuesStartRepeat[s];return this._yoyo&&(this._reversed=!this._reversed),this._startTime+=l*p,this._onRepeatCallback&&this._onRepeatCallback(this._object),this._onEveryStartCallbackFired=!1,!0}else{this._onCompleteCallback&&this._onCompleteCallback(this._object);for(var f=0,d=this._chainedTweens.length;f<d;f++)this._chainedTweens[f].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},r.prototype._updateProperties=function(e,t,n,i){for(var s in n)if(t[s]!==void 0){var o=t[s]||0,a=n[s],l=Array.isArray(e[s]),c=Array.isArray(a),h=!l&&c;h?e[s]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(e[s],o,a,i):(a=this._handleRelativeValue(o,a),typeof a=="number"&&(e[s]=o+(a-o)*i))}},r.prototype._handleRelativeValue=function(e,t){return typeof t!="string"?t:t.charAt(0)==="+"||t.charAt(0)==="-"?e+parseFloat(t):parseFloat(t)},r.prototype._swapEndStartRepeatValues=function(e){var t=this._valuesStartRepeat[e],n=this._valuesEnd[e];typeof n=="string"?this._valuesStartRepeat[e]=this._valuesStartRepeat[e]+parseFloat(n):this._valuesStartRepeat[e]=this._valuesEnd[e],this._valuesEnd[e]=t},r})();Jo.nextId;var nt=ts;nt.getAll.bind(nt),nt.removeAll.bind(nt),nt.add.bind(nt),nt.remove.bind(nt),nt.update.bind(nt);var pn={Easing:$t,Tween:vh};class wh extends M.DataTextureLoader{constructor(e){super(e),this.type=M.HalfFloatType}parse(e){const o=function(D,k){switch(D){case 1:throw new Error("THREE.HDRLoader: Read Error: "+(k||""));case 2:throw new Error("THREE.HDRLoader: Write Error: "+(k||""));case 3:throw new Error("THREE.HDRLoader: Bad File Format: "+(k||""));default:case 4:throw new Error("THREE.HDRLoader: Memory Error: "+(k||""))}},u=function(D,k,E){k=k||1024;let A=D.pos,I=-1,S=0,z="",U=String.fromCharCode.apply(null,new Uint16Array(D.subarray(A,A+128)));for(;0>(I=U.indexOf(`
|
|
968
|
+
`))&&S<k&&A<D.byteLength;)z+=U,S+=U.length,A+=128,U+=String.fromCharCode.apply(null,new Uint16Array(D.subarray(A,A+128)));return-1<I?(D.pos+=S+I+1,z+U.slice(0,I)):!1},m=function(D){const k=/^#\?(\S+)/,E=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,R=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,A=/^\s*FORMAT=(\S+)\s*$/,I=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,S={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};let z,U;for((D.pos>=D.byteLength||!(z=u(D)))&&o(1,"no header found"),(U=z.match(k))||o(3,"bad initial token"),S.valid|=1,S.programtype=U[1],S.string+=z+`
|
|
969
|
+
`;z=u(D),z!==!1;){if(S.string+=z+`
|
|
970
970
|
`,z.charAt(0)==="#"){S.comments+=z+`
|
|
971
|
-
`;continue}if((V=z.match(E))&&(S.gamma=parseFloat(V[1])),(V=z.match(O))&&(S.exposure=parseFloat(V[1])),(V=z.match(A))&&(S.valid|=2,S.format=V[1]),(V=z.match(I))&&(S.valid|=4,S.height=parseInt(V[1],10),S.width=parseInt(V[2],10)),S.valid&2&&S.valid&4)break}return S.valid&2||r(3,"missing format specifier"),S.valid&4||r(3,"missing image size specifier"),S},p=function(k,D,E){const O=D;if(O<8||O>32767||k[0]!==2||k[1]!==2||k[2]&128)return new Uint8Array(k);O!==(k[2]<<8|k[3])&&r(3,"wrong scanline width");const A=new Uint8Array(4*D*E);A.length||r(4,"unable to allocate buffer space");let I=0,S=0;const z=4*O,V=new Uint8Array(4),U=new Uint8Array(z);let H=E;for(;H>0&&S<k.byteLength;){S+4>k.byteLength&&r(1),V[0]=k[S++],V[1]=k[S++],V[2]=k[S++],V[3]=k[S++],(V[0]!=2||V[1]!=2||(V[2]<<8|V[3])!=O)&&r(3,"bad rgbe scanline format");let G=0,$;for(;G<z&&S<k.byteLength;){$=k[S++];const R=$>128;if(R&&($-=128),($===0||G+$>z)&&r(3,"bad scanline data"),R){const te=k[S++];for(let ee=0;ee<$;ee++)U[G++]=te}else U.set(k.subarray(S,S+$),G),G+=$,S+=$}const F=O;for(let R=0;R<F;R++){let te=0;A[I]=U[R+te],te+=O,A[I+1]=U[R+te],te+=O,A[I+2]=U[R+te],te+=O,A[I+3]=U[R+te],I+=4}H--}return A},f=function(k,D,E,O){const A=k[D+3],I=Math.pow(2,A-128)/255;E[O+0]=k[D+0]*I,E[O+1]=k[D+1]*I,E[O+2]=k[D+2]*I,E[O+3]=1},u=function(k,D,E,O){const A=k[D+3],I=Math.pow(2,A-128)/255;E[O+0]=_.DataUtils.toHalfFloat(Math.min(k[D+0]*I,65504)),E[O+1]=_.DataUtils.toHalfFloat(Math.min(k[D+1]*I,65504)),E[O+2]=_.DataUtils.toHalfFloat(Math.min(k[D+2]*I,65504)),E[O+3]=_.DataUtils.toHalfFloat(1)},g=new Uint8Array(e);g.pos=0;const y=m(g),v=y.width,w=y.height,x=p(g.subarray(g.pos),v,w);let M,T,P;switch(this.type){case _.FloatType:P=x.length/4;const k=new Float32Array(P*4);for(let E=0;E<P;E++)f(x,E*4,k,E*4);M=k,T=_.FloatType;break;case _.HalfFloatType:P=x.length/4;const D=new Uint16Array(P*4);for(let E=0;E<P;E++)u(x,E*4,D,E*4);M=D,T=_.HalfFloatType;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:v,height:w,data:M,header:y.string,gamma:y.gamma,exposure:y.exposure,type:T}}setDataType(e){return this.type=e,this}load(e,t,n,i){function s(r,a){switch(r.type){case _.FloatType:case _.HalfFloatType:r.colorSpace=_.LinearSRGBColorSpace,r.minFilter=_.LinearFilter,r.magFilter=_.LinearFilter,r.generateMipmaps=!1,r.flipY=!0;break}t&&t(r,a)}return super.load(e,s,n,i)}}function ih(){return new b.Scene}function sh(o,e){o.appendChild(e.domElement)}function rh(o,e,t){var n=new Object;n.visible=!0;let i=null,s,r,a=[];n.init=function(){s||(c(),h(),d())},n.Hide=function(){s.style.display="none",n.visible=!1},n.Show=function(){s.style.display="block",n.visible=!0},n.RenderScene=function(){n.camera.quaternion.copy(e.camera.quaternion);const f=new b.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);n.camera.position.copy(f.multiplyScalar(100)),n.sceneOrtho.renderer.render(n.sceneOrtho,n.camera)},n.ToggleDirectionView=function(f){var u=new b.Vector3(0,0,0);f=="top"?u=new b.Vector3(0,1,1e-5):f=="down"?u=new b.Vector3(0,-1,1e-5):f=="front"?u=new b.Vector3(0,0,1):f=="left"?u=new b.Vector3(-1,0,0):f=="back"?u=new b.Vector3(0,0,-1):f=="right"?u=new b.Vector3(1,0,0):f=="top_front"?u=new b.Vector3(1,1,0):f=="top_left"?u=new b.Vector3(0,1,-1):f=="top_back"?u=new b.Vector3(-1,1,0):f=="top_right"?u=new b.Vector3(0,1,1):f=="down_front"?u=new b.Vector3(1,-1,0):f=="down_left"?u=new b.Vector3(0,-1,-1):f=="down_back"?u=new b.Vector3(-1,-1,0):f=="down_right"?u=new b.Vector3(0,-1,1):f=="front_right"?u=new b.Vector3(1,0,1):f=="right_back"?u=new b.Vector3(-1,0,1):f=="back_left"?u=new b.Vector3(-1,0,-1):f=="left_front"?u=new b.Vector3(1,0,-1):f=="top_left_front"?u=new b.Vector3(1,1,-1):f=="top_front_right"?u=new b.Vector3(1,1,1):f=="top_right_back"?u=new b.Vector3(-1,1,1):f=="top_back_left"?u=new b.Vector3(-1,1,-1):f=="button_left_front"?u=new b.Vector3(1,-1,-1):f=="button_front_right"?u=new b.Vector3(1,-1,1):f=="button_right_back"?u=new b.Vector3(-1,1,1):f=="button_back_left"&&(u=new b.Vector3(-1,-1,-1));var g=o.octreeBox.getBoundingBox(),y=g.min,v=g.max,w=y.clone().add(v.clone()).multiplyScalar(.5),x=w.clone().add(u.multiplyScalar(1*v.distanceTo(y)));l(e.camera.position,x,o.controls.target.clone(),w)},n.GetCameraPose=function(){var f=e.camera.quaternion,u=e.camera.position,g=o.controls.target,y={quaternion:f,position:u,target:g};return y},n.ReductionCameraPose=function(f,u=1e3,g){var y=new b.Quaternion(f.quaternion._x,f.quaternion._y,f.quaternion._z,f.quaternion._w),v=new b.Vector3(f.position.x,f.position.y,f.position.z),w=new b.Vector3(f.target.x,f.target.y,f.target.z);let x=!1;l(e.camera.position,v,o.controls.target.clone(),w,e.camera.quaternion,y,u,M=>{g&&(x||(g(M),x=!0))}),g&&setTimeout(()=>{x||(g(!0),x=!0)},u+10)},n.CameraGoHome=function(){var f=o.octreeBox.getBoundingBox(),u=f.min.clone().add(f.max.clone()).multiplyScalar(.5);let g=new b.Vector3(1,1,1);var y=f.max.distanceTo(f.min),v=u.clone().add(g.multiplyScalar(y*.5));if(e.camera.isOrthographicCamera){var w=o.container.clientWidth/o.container.clientHeight,x=y*.6;e.camera.left=-x*w,e.camera.right=x*w,e.camera.top=x,e.camera.bottom=-x,e.camera.zoom=1,e.camera.updateProjectionMatrix()}o.controlModule.orbitControls.origin=u.clone(),l(e.camera.position,v,o.controls.target.clone(),u)},n.zoomToBox=function(f){if(e.camera.isOrthographicCamera){let R=function(){i=requestAnimationFrame(R),F.update()};var u=f.min.clone().add(f.max.clone()).multiplyScalar(.5),g=e.camera.position.clone().sub(o.controls.target.clone()).normalize(),y=e.camera.position.distanceTo(o.controls.target),v=u.clone().add(g.multiplyScalar(y)),w=e.camera.zoom,x=new b.Vector3(1,0,0).applyQuaternion(e.camera.quaternion),M=new b.Vector3(0,1,0).applyQuaternion(e.camera.quaternion),T=[new b.Vector3(f.min.x,f.min.y,f.min.z),new b.Vector3(f.max.x,f.min.y,f.min.z),new b.Vector3(f.min.x,f.max.y,f.min.z),new b.Vector3(f.max.x,f.max.y,f.min.z),new b.Vector3(f.min.x,f.min.y,f.max.z),new b.Vector3(f.max.x,f.min.y,f.max.z),new b.Vector3(f.min.x,f.max.y,f.max.z),new b.Vector3(f.max.x,f.max.y,f.max.z)],P=1/0,k=-1/0,D=1/0,E=-1/0;for(var O of T){var A=O.dot(x),I=O.dot(M);P=Math.min(P,A),k=Math.max(k,A),D=Math.min(D,I),E=Math.max(E,I)}var S=(k-P)/2,z=(E-D)/2,V=(e.camera.right-e.camera.left)/2,U=(e.camera.top-e.camera.bottom)/2;w=Math.min(V/S,U/z)*.75;var H=e.camera.position.clone(),G=o.controls.target.clone(),$=e.camera.zoom,F=new dn.Tween({x1:H.x,y1:H.y,z1:H.z,x2:G.x,y2:G.y,z2:G.z,zoom:$}).to({x1:v.x,y1:v.y,z1:v.z,x2:u.x,y2:u.y,z2:u.z,zoom:w},1e3);F.onUpdate(function(te){o.controls&&(e.camera.position.set(te.x1,te.y1,te.z1),o.controls.target.set(te.x2,te.y2,te.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=te.zoom,e.camera.updateProjectionMatrix()),o.controls.auto=!0,o.controls.update(),n.RenderScene())}),F.onComplete(function(){o.controls&&(o.controls.auto=!1,n.RenderScene(),cancelAnimationFrame(i),i=null)}),F.easing(dn.Easing.Cubic.InOut),F.start(),R()}else{var u=f.min.clone().add(f.max.clone()).multiplyScalar(.5);let ee=e.camera.position.clone().sub(o.controls.target.clone()).normalize();var v=u.clone().add(ee.multiplyScalar(2*f.max.distanceTo(f.min)));l(e.camera.position,v,o.controls.target.clone(),u)}};function l(f,u,g,y,v,w,x=1e3,M){var T;v&&w?(T=new dn.Tween({x1:f.x,y1:f.y,z1:f.z,x2:g.x,y2:g.y,z2:g.z,_x:v._x,_y:v._y,_z:v._z,_w:v._w}),T.to({x1:u.x,y1:u.y,z1:u.z,x2:y.x,y2:y.y,z2:y.z,_x:w._x,_y:w._y,_z:w._z,_w:w._w},x)):(T=new dn.Tween({x1:f.x,y1:f.y,z1:f.z,x2:g.x,y2:g.y,z2:g.z}),T.to({x1:u.x,y1:u.y,z1:u.z,x2:y.x,y2:y.y,z2:y.z},x)),T.onUpdate(function(k){o.controls&&(v&&w?(e.camera.quaternion._x=k._x,e.camera.quaternion._y=k._y,e.camera.quaternion._z=k._z,e.camera.quaternion._w=k._w):o.controls.auto=!0,e.camera.position.x=k.x1,e.camera.position.y=k.y1,e.camera.position.z=k.z1,o.controls.target.x=k.x2,o.controls.target.y=k.y2,o.controls.target.z=k.z2,o.controls.update(),n.RenderScene())}),T.onComplete(function(k){o.controls&&(o.controls.auto=!1,n.RenderScene(),M&&M(!0),cancelAnimationFrame(i),i=null)}),T.easing(dn.Easing.Cubic.InOut);function P(k){i=requestAnimationFrame(P),T.update()}T.start(),P()}function c(){s=document.createElement("div"),s.className="ViewCube",t.appendChild(s),r=document.createElement("div"),r.className="viewSettingWrapper",r.innerHTML="...",s.appendChild(r);var f=document.createElement("div");f.className="homeViewWrapper",f.addEventListener("mousedown",function(){console.log("归位"),n.CameraGoHome()}),s.appendChild(f);const u=document.createElement("div");u.className="cameraToggleWrapper",u.title="切换正交/透视视图",u.innerHTML="⊞",u.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("切换视图"),n.ToggleCameraType(),v()}),s.appendChild(u);const g=document.createElement("div");g.className="screenshotWrapper",g.title="截图",g.innerHTML="📷",g.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("截图"),n.TakeScreenshot(),v()}),s.appendChild(g);const y=document.createElement("div");y.className="fullscreenWrapper",y.title="全屏",y.innerHTML="⛶",y.addEventListener("mousedown",function(x){x.stopPropagation(),console.log("全屏"),n.ToggleFullscreen(),v()}),s.appendChild(y),r.addEventListener("mousedown",function(x){x.stopPropagation(),u.classList.contains("show")?(v(),console.log("隐藏功能按钮")):(w(),console.log("显示功能按钮"))});function v(){u.classList.remove("show"),g.classList.remove("show"),y.classList.remove("show")}function w(){u.classList.add("show"),g.classList.add("show"),y.classList.add("show")}}function h(){n.sceneOrtho=ih();var g=t.clientWidth,y=t.clientWidth,f=g>y?g/y:y/g,u=300;n.camera=new b.OrthographicCamera(u*f/-2,u*f/2,u/2,u/-2,.01,1e4);var g=s.clientWidth,y=s.clientHeight,v=new b.WebGLRenderer({alpha:!0});v.setSize(g,y),v.setClearAlpha(0),n.sceneOrtho.renderer=v;let w=new b.AmbientLight(16777215,.8);n.sceneOrtho.add(w),sh(s,v)}function d(){const f="/assets/viewcube/";let u=[{label:"右",icon:f+"cn_right.png"},{label:"左",icon:f+"cn_left.png"},{label:"顶",icon:f+"cn_top.png"},{label:"底",icon:f+"cn_bottom.png"},{label:"前",icon:f+"cn_front.png"},{label:"后",icon:f+"cn_back.png"}];var g=[];for(const v of u)g.push(new b.MeshBasicMaterial({color:16777215,map:new b.TextureLoader().load(v.icon)}));new b.MeshLambertMaterial({color:255});var y=new b.Mesh(new b.BoxGeometry(110,110,110),g);n.sceneOrtho.add(y),m(122),s.addEventListener("mousedown",v=>{var w={};w.x=v.offsetX/s.clientWidth*2-1,w.y=-(v.offsetY/s.clientHeight)*2+1;var x=new b.Raycaster;x.setFromCamera(w,n.camera);const M=x.intersectObjects(a,!1);M.length>0&&n.ToggleDirectionView(M[0].object.name)}),s.addEventListener("mousemove",v=>{var w={};w.x=v.offsetX/s.clientWidth*2-1,w.y=-(v.offsetY/s.clientHeight)*2+1;var x=new b.Raycaster;x.setFromCamera(w,n.camera);const M=x.intersectObjects(a,!1);for(var T of a)T.material.opacity=.01;M.length>0&&(M[0].object.material.opacity=.2)})}function m(f){for(var u=f*.5-20,g=[{name:"right",a:30,b:75,c:75,point:new b.Vector3(u,0,0)},{name:"back",a:75,b:75,c:30,point:new b.Vector3(0,0,-u)},{name:"left",a:30,b:75,c:75,point:new b.Vector3(-u,0,0)},{name:"front",a:75,b:75,c:30,point:new b.Vector3(0,0,u)},{name:"top",a:75,b:30,c:75,point:new b.Vector3(0,u,0)},{name:"button",a:75,b:30,c:75,point:new b.Vector3(0,-u,0)}],y=[{name:"top_right_back",a:30,b:30,c:30,point:new b.Vector3(-u,u,u)},{name:"button_front_right",a:30,b:30,c:30,point:new b.Vector3(-u,-u,u)},{name:"top_front_right",a:30,b:30,c:30,point:new b.Vector3(u,u,u)},{name:"button_right_back",a:30,b:30,c:30,point:new b.Vector3(u,-u,u)},{name:"top_back_left",a:30,b:30,c:30,point:new b.Vector3(-u,u,-u)},{name:"button_back_left",a:30,b:30,c:30,point:new b.Vector3(-u,-u,-u)},{name:"top_left_front",a:30,b:30,c:30,point:new b.Vector3(u,u,-u)},{name:"button_left_front",a:30,b:30,c:30,point:new b.Vector3(u,-u,-u)}],v=[{name:"top_front",a:30,b:30,c:75,point:new b.Vector3(u,u,0)},{name:"top_right",a:75,b:30,c:30,point:new b.Vector3(0,u,u)},{name:"top_back",a:30,b:30,c:75,point:new b.Vector3(-u,u,0)},{name:"top_left",a:75,b:30,c:30,point:new b.Vector3(0,u,-u)},{name:"button_front",a:30,b:30,c:75,point:new b.Vector3(u,-u,0)},{name:"button_right",a:75,b:30,c:30,point:new b.Vector3(0,-u,u)},{name:"button_back",a:30,b:30,c:75,point:new b.Vector3(-u,-u,0)},{name:"button_left",a:75,b:30,c:30,point:new b.Vector3(0,-u,-u)},{name:"front_right",a:30,b:75,c:30,point:new b.Vector3(u,0,u)},{name:"right_back",a:30,b:75,c:30,point:new b.Vector3(-u,0,u)},{name:"back_left",a:30,b:75,c:30,point:new b.Vector3(-u,0,-u)},{name:"left_front",a:30,b:75,c:30,point:new b.Vector3(u,0,-u)}],w=0;w<g.length;w++)a.push(p(g[w]));for(var w=0;w<y.length;w++)a.push(p(y[w]));for(var w=0;w<v.length;w++)a.push(p(v[w]))}function p(f){const u=new b.BoxGeometry(f.a,f.b,f.c),g=new b.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),y=new b.Matrix4().makeTranslation(f.point.x,f.point.y,f.point.z);let v=u.applyMatrix4(y),w=new b.Mesh(v,g);return w.name=f.name,n.sceneOrtho.add(w),w}return n.ToggleCameraType=function(){o.cameraModule.switchCurrentCamera()},n.TakeScreenshot=function(){try{if(!o.renderer){console.error("渲染器未初始化");return}o.renderer.render(e,e.camera);const u=o.renderer.domElement.toDataURL("image/png"),g=document.createElement("a"),y=new Date().toISOString().replaceAll(/[:.]/g,"-");g.download=`screenshot_${y}.png`,g.href=u,g.click(),console.log("截图已保存")}catch(f){console.error("截图失败:",f)}},n.ToggleFullscreen=function(){const f=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(f.requestFullscreen?f.requestFullscreen():f.webkitRequestFullscreen?f.webkitRequestFullscreen():f.mozRequestFullScreen?f.mozRequestFullScreen():f.msRequestFullscreen&&f.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},n}class oh{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=rh(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(){this.cubeTool.CameraGoHome()}zoomToModel(e){this.cubeTool.zoomToBox(e)}hide(){}}function ah(o){let e=new Object;return e.getBoundingBox=function(){let t=o.models,n=new b.Vector3(1e8,1e9,1e10),i=new b.Vector3(-1e8,-1e9,-1e10);t.forEach(d=>{let m=d.boundingBox.min,p=d.boundingBox.max;m.x<n.x&&(n.x=m.x),m.y<n.y&&(n.y=m.y),m.z<n.z&&(n.z=m.z),p.x>i.x&&(i.x=p.x),p.y>i.y&&(i.y=p.y),p.z>i.z&&(i.z=p.z)});let s=Math.min(n.x,i.x),r=Math.min(n.y,i.y),a=Math.min(n.z,i.z),l=Math.max(n.x,i.x),c=Math.max(n.y,i.y),h=Math.max(n.z,i.z);return{min:new b.Vector3(s,r,a),max:new b.Vector3(l,c,h)}},e.rayInterationModel=function(t){let n=[];return o.engineStatus.models.forEach(r=>{r.info.lods.forEach(a=>{let l=a.octreeBox;s(t,l,r)})}),n=n.filter(r=>r instanceof b.Mesh),t.intersectObjects(n,!1);function s(r,a,l){if(a==null)return;let c=new b.Vector3(a.min.X*.3048,a.min.Z*.3048,-a.min.Y*.3048),h=new b.Vector3(a.max.X*.3048,a.max.Z*.3048,-a.max.Y*.3048),d=new b.Vector3(Math.min(c.x,h.X),Math.min(c.y,h.y),Math.min(c.z,h.z)),m=new b.Vector3(Math.max(h.x,c.x),Math.max(h.y,c.y),Math.max(h.z,c.z)),p=new b.Box3(d,m),f=r.ray.intersectsBox(p);if(!(f==null||f==!1))if(a.children==null||a.children.length==0){if(a.elements!=null)for(var u of a.elements){let g=o.engineStatus.hideModels.find(x=>x.url==l.url)?.ids;if(g!=null&&g.includes(u))continue;let y=o.engineStatus.translucentModels.find(x=>x.url==l.url)?.ids;if(y!=null&&y.includes(u))continue;let w=o.models.find(x=>x.url==l.url).nodesMap.get(u);w!=null&&!w.instance&&w.infos.map(M=>M.mesh).forEach(M=>{n.push(M)})}}else{if(a.elements!=null)for(var u of a.elements){let y=o.engineStatus.hideModels.find(M=>M.url==l.url)?.ids;if(y!=null&&y.includes(u))continue;let v=o.engineStatus.translucentModels.find(M=>M.url==l.url)?.ids;if(v!=null&&v.includes(u))continue;let x=o.models.find(M=>M.url==l.url).nodesMap.get(u);x!=null&&!x.instance&&x.infos.map(T=>T.mesh).forEach(T=>{n.push(T)})}for(let g of a.children)s(r,g,l)}}},e}class lh{engine;isDrawing=!1;startPoint=new b.Vector2;endPoint=new b.Vector2;selectionBox=null;worldToScreen=null;boundMouseDown;boundMouseMove;boundMouseUp;boundKeyDown;constructor(e){this.engine=e,this.boundMouseDown=this.onMouseDown.bind(this),this.boundMouseMove=this.onMouseMove.bind(this),this.boundMouseUp=this.onMouseUp.bind(this),this.boundKeyDown=this.onKeyDown.bind(this)}init(){this.createSelectionBoxElement(),this.engine.scene&&this.engine.camera&&this.engine.renderer&&(this.worldToScreen=new De(this.engine.camera,this.engine.renderer,this.engine.scene))}active(){this.engine.controlModule.disActive();const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.boundMouseDown),e.addEventListener("mousemove",this.boundMouseMove),e.addEventListener("mouseup",this.boundMouseUp),e.style.cursor="crosshair"),window.addEventListener("keydown",this.boundKeyDown)}disActive(){this.engine.controlModule.active();const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.boundMouseDown),e.removeEventListener("mousemove",this.boundMouseMove),e.removeEventListener("mouseup",this.boundMouseUp),e.style.cursor="default"),window.removeEventListener("keydown",this.boundKeyDown),this.isDrawing&&this.endDrawing()}createSelectionBoxElement(){this.selectionBox=document.createElement("div"),this.selectionBox.style.position="absolute",this.selectionBox.style.border="2px dashed #00aaff",this.selectionBox.style.backgroundColor="rgba(0, 170, 255, 0.1)",this.selectionBox.style.pointerEvents="none",this.selectionBox.style.display="none",this.selectionBox.style.zIndex="1000",this.selectionBox.style.boxSizing="border-box";const e=this.engine.renderer?.domElement;e&&e.parentElement&&e.parentElement.appendChild(this.selectionBox)}onMouseDown(e){e.button!==0||!this.engine.renderer?.domElement||(this.startPoint.set(e.offsetX,e.offsetY),this.endPoint.copy(this.startPoint),this.isDrawing=!0,this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation())}onMouseMove(e){!this.isDrawing||!this.engine.renderer?.domElement||(this.endPoint.set(e.offsetX,e.offsetY),this.updateSelectionBoxUI(),e.preventDefault(),e.stopPropagation())}onMouseUp(e){this.isDrawing&&(this.endDrawing(),this.performZoom(),e.preventDefault(),e.stopPropagation(),this.disActive())}onKeyDown(e){e.key==="Escape"&&(this.disActive(),e.preventDefault(),e.stopPropagation())}endDrawing(){this.isDrawing&&(this.isDrawing=!1,this.selectionBox&&(this.selectionBox.style.display="none"))}updateSelectionBoxUI(){if(!this.selectionBox||!this.engine.renderer?.domElement)return;const t=Math.min(this.startPoint.x,this.endPoint.x),n=Math.min(this.startPoint.y,this.endPoint.y),i=Math.abs(this.endPoint.x-this.startPoint.x),s=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${t}px`,this.selectionBox.style.top=`${n}px`,this.selectionBox.style.width=`${i}px`,this.selectionBox.style.height=`${s}px`}performZoom(){const e=Math.abs(this.endPoint.x-this.startPoint.x),t=Math.abs(this.endPoint.y-this.startPoint.y);if(e<5||t<5)return;if(!this.worldToScreen){console.warn("RangeScale: 坐标转换工具未初始化");return}const n=Math.min(this.startPoint.x,this.endPoint.x),i=Math.max(this.startPoint.x,this.endPoint.x),s=Math.min(this.startPoint.y,this.endPoint.y),r=Math.max(this.startPoint.y,this.endPoint.y),a=[],l=[{x:n,y:s},{x:i,y:s},{x:i,y:r},{x:n,y:r}];for(const h of l){const d=this.worldToScreen.screenToWorld(h.x,h.y);d&&a.push(d)}if(a.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const c=new b.Box3;for(const h of a)c.expandByPoint(h);if(c.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(c)}fitCameraToBoundingBox(e){const t=this.engine.camera,n=this.engine.controls;if(!t||!n){console.warn("RangeScale: 相机或控制器未初始化");return}const i=new b.Vector3;e.getCenter(i);const s=new b.Vector3;e.getSize(s);const r=Math.max(s.x,s.y,s.z);if(t instanceof b.PerspectiveCamera){const a=t.fov*(Math.PI/180),c=r/(2*Math.tan(a/2))*1.2,h=new b.Vector3;t.getWorldDirection(h);const d=i.clone().sub(t.position);h.dot(d.normalize())<0&&h.negate();const p=i.clone().sub(h.multiplyScalar(c));t.position.copy(p),n.target&&n.target.copy(i),t.lookAt(i),n.update()}else if(t instanceof b.OrthographicCamera){const l=r*1.2,c=this.engine.renderer?.domElement,h=c?c.width/c.height:1;t.left=-l*h/2,t.right=l*h/2,t.top=l/2,t.bottom=-l/2,t.updateProjectionMatrix();const d=new b.Vector3;t.getWorldDirection(d);const m=r*1.5,p=i.clone().sub(d.multiplyScalar(m));t.position.copy(p),n.target&&n.target.copy(i),t.lookAt(i),n.update()}}}class ch{engine;ground=null;constructor(e){this.engine=e}init(){}setStatsVisible(e){this.engine.stats?.dom&&(this.engine.stats.dom.style.display=e?"block":"none")}setAmbientLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof b.AmbientLight);t&&(t.intensity=e)}setAmbientLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof b.AmbientLight);t&&t.color.set(e)}setDirectionalLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof b.DirectionalLight);t&&(t.intensity=e)}setDirectionalLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof b.DirectionalLight);t&&t.color.set(e)}setShadowQuality(e){const t=this.engine.scene.children.find(n=>n instanceof b.DirectionalLight);if(t?.shadow){const i={low:1024,medium:2048,high:4096,ultra:8192}[e];t.shadow.mapSize.width=i,t.shadow.mapSize.height=i,t.shadow.map?.dispose(),t.shadow.map=null}}setDirectionalLightShadow(e){const t=this.engine.scene.children.find(n=>n instanceof b.DirectionalLight);t&&(t.castShadow=e),this.engine.renderer&&(this.engine.renderer.shadowMap.enabled=e)}setGTAOEnabled(e){if(!this.engine.composerModule?.composer){console.warn("Composer not initialized");return}const t=this.engine.composerModule.composer,n=t.passes.find(i=>i instanceof Re);if(e)if(n)n.enabled=!0;else{const{width:i,height:s}=this.engine.deviceModule.getContainerSize(),r=new Re(this.engine.scene,this.engine.camera,i,s);r.output=Re.OUTPUT.Default,r.blendIntensity=.5,r.updateGtaoMaterial&&r.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0});const a=t.passes.findIndex(l=>l.constructor.name==="RenderPass");t.passes.splice(a+1,0,r)}else n&&(n.enabled=!1)}setSceneSaturation(e){if(!this.engine.composerModule?.saturationPass){console.warn("Saturation pass not initialized");return}this.engine.composerModule.saturationPass.uniforms.saturation.value=e}setSceneContrast(e){if(!this.engine.composerModule?.saturationPass){console.warn("Saturation pass not initialized");return}this.engine.composerModule.saturationPass.uniforms.contrast.value=e}setGroundEnabled(e,t){if(e)if(this.ground)this.ground.visible=!0;else{const n=t?.size??100,i=t?.color??8421504,s=t?.opacity??.3,r=new b.PlaneGeometry(n,n),a=new b.MeshStandardMaterial({color:i,transparent:!0,opacity:s,side:b.DoubleSide});this.ground=new b.Mesh(r,a),this.ground.rotation.x=-Math.PI/2,this.ground.position.y=0,this.ground.receiveShadow=!0,this.ground.name="ground",this.engine.scene.add(this.ground)}else this.ground&&(this.ground.visible=!1)}setHDRBackground(e){e?(this.engine.scene.background=e,this.engine.scene.environment=e):(this.engine.scene.background=null,this.engine.scene.environment=null)}}function rt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(o){var e=Math.random()*16|0,t=o=="x"?e:e&3|8;return t.toString(16)})}class ot{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=ki(e),this.handelBehaved.init(this,null),this.setting={unit:"m",precision:3}}getSetting(){return this.setting}saveSetting(e){this.setting=e}active(){this.handelBehaved.active()}disActive(){this.handelBehaved.disActive()}getMeasureText(e,t){if(e==null)return null;let n=this.setting.unit,i=n;return t==1?n=="mm"?e=e*1e3:n=="cm"?e=e*100:n=="dm"?e=e*10:n=="m"?e=e*1:n=="km"&&(e=e*.001):t==2&&(n=="mm"?e=e*1e3*1e3:n=="cm"?e=e*100*100:n=="dm"?e=e*10*10:n=="m"?e=e*1*1:n=="km"&&(e=e*.001*.001),i=i+"²"),e.toFixed(this.setting.precision)+" "+i}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight==!0&&(n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.isSelect==!0&&(i.container.remove(),e[t].splice(n,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.highlight==!0&&(i.container.remove(),e[t].splice(n,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(f=>{p(f)}),this.engine.measure.annotationData.elevationAnnotation.forEach(f=>{m(f)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(f=>{d(f)}),this.engine.measure.annotationData.angleAnnotation.forEach(f=>{l(f)}),this.engine.measure.annotationData.areaAnnotation.forEach(f=>{c(f)}),this.engine.measure.annotationData.slopeAnnotation.forEach(f=>{h(f)});function l(f){if(f.container==null){let P=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+f.text+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="angle-annotation",f.container.id=f.id,f.container.style.pointerEvents="none",f.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point1),g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point2),y=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point3),v=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;u.x+=v,u.y+=w,g.x+=v,g.y+=w,y.x+=v,y.y+=w;let x=f.container;x.getElementsByTagName("circle")[0].setAttribute("cx",u.x),x.getElementsByTagName("circle")[0].setAttribute("cy",u.y),x.getElementsByTagName("circle")[1].setAttribute("cx",g.x),x.getElementsByTagName("circle")[1].setAttribute("cy",g.y),x.getElementsByTagName("circle")[2].setAttribute("cx",y.x),x.getElementsByTagName("circle")[2].setAttribute("cy",y.y),x.getElementsByTagName("polyline")[0].setAttribute("points",u.x+","+u.y+" "+g.x+","+g.y),x.getElementsByTagName("polyline")[1].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y);let M=g.x,T=g.y-30;x.getElementsByTagName("rect")[0].setAttribute("x",M-40),x.getElementsByTagName("rect")[0].setAttribute("y",T-12.5),x.getElementsByTagName("text")[0].setAttribute("x",M),x.getElementsByTagName("text")[0].setAttribute("y",T+4),x.getElementsByTagName("text")[0].innerHTML=f.text,x.style.top="0px",x.style.left="0px"}function c(f){if(f.container==null){let k=['<svg class="measureSvg">','<polygon fill="rgba(255, 165, 0, 0.3)" stroke="orange" stroke-width="2" points="" style="opacity: 0.3;"/>','<polyline stroke="orange" stroke-width="2" points="" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(f.text,2)+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="area-annotation",f.container.id=f.id,f.container.innerHTML=k,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}if(!f.points||f.points.length<3)return;let u=e.engine.reactBoundingClientRect.left,g=e.engine.reactBoundingClientRect.top,y=[],v=0,w=0;for(let k=0;k<f.points.length;k++){let D=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.points[k]);D.x+=u,D.y+=g,y.push(D),v+=D.x,w+=D.y}v=v/y.length,w=w/y.length;let x=y.map(k=>k.x+","+k.y).join(" "),M=f.container;M.getElementsByTagName("polygon")[0].setAttribute("points",x),M.getElementsByTagName("polyline")[0].setAttribute("points",x);let T=v,P=w;M.getElementsByTagName("rect")[0].setAttribute("x",T-40),M.getElementsByTagName("rect")[0].setAttribute("y",P-12.5),M.getElementsByTagName("text")[0].setAttribute("x",T),M.getElementsByTagName("text")[0].setAttribute("y",P+4),M.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(f.text,2),M.style.top="0px",M.style.left="0px"}function h(f){if(f.container==null){let T=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+f.id+'" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">','<path d="M0,0 L0,6 L9,3 z" fill="orange" stroke="orange" />',"</marker>","</defs>",'<polyline stroke="orange" stroke-width="2" points="0,0 0,0" marker-end="url(#slope-arrow-'+f.id+')" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel">'+f.text+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="slope-annotation",f.container.id=f.id,f.container.innerHTML=T,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point1),g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point2),y=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;u.x+=y,u.y+=v,g.x+=y,g.y+=v;let w=f.container;w.getElementsByTagName("polyline")[0].setAttribute("points",u.x+","+u.y+" "+g.x+","+g.y);let x=(u.x+g.x)/2,M=(u.y+g.y)/2-30;w.getElementsByTagName("rect")[0].setAttribute("x",x-50),w.getElementsByTagName("rect")[0].setAttribute("y",M-12.5),w.getElementsByTagName("text")[0].setAttribute("x",x),w.getElementsByTagName("text")[0].setAttribute("y",M+4),w.getElementsByTagName("text")[0].innerHTML=f.text,w.style.top="0px",w.style.left="0px"}function d(f){if(f.container==null){let P=['<svg class="measureSvg">','<circle cx="0" cy="0" r="5" fill="#f99d0b" />','<rect x="0" y="-25" width="100" height="25" class="measureBack" />','<text x="40" y="-11" text-anchor="middle" class="measureLabel">X: '+e.getMeasureText(f.textX,1)+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="40" y="25" text-anchor="middle" class="measureLabel">Y: '+e.getMeasureText(-f.textZ,1)+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="40" y="51" text-anchor="middle" class="measureLabel">Z: '+e.getMeasureText(f.textY,1)+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="coordinate-annotation",f.container.id=f.id,f.container.style.position="absolute",f.container.style.pointerEvents="none",f.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=f.container,g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point),y=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;g.x+=y,g.y+=v,u.style.top="0px",u.style.left="0px";let w=u.getElementsByTagName("circle")[0];w&&(w.setAttribute("cx",g.x),w.setAttribute("cy",g.y));let x=u.getElementsByTagName("rect"),M=u.getElementsByTagName("text"),T=-55;x[0]&&(x[0].setAttribute("x",g.x+10),x[0].setAttribute("y",g.y+10+T)),M[0]&&(M[0].setAttribute("x",g.x+10+40),M[0].setAttribute("y",g.y+10+16+T)),x[1]&&(x[1].setAttribute("x",g.x+10),x[1].setAttribute("y",g.y+10+30+T)),M[1]&&(M[1].setAttribute("x",g.x+10+40),M[1].setAttribute("y",g.y+10+46+T)),x[2]&&(x[2].setAttribute("x",g.x+10),x[2].setAttribute("y",g.y+10+60+T)),M[2]&&(M[2].setAttribute("x",g.x+10+40),M[2].setAttribute("y",g.y+10+76+T)),M[0]&&(M[0].innerHTML="X: "+e.getMeasureText(f.textX,1)),M[1]&&(M[1].innerHTML="Y: "+e.getMeasureText(-f.textZ,1)),M[2]&&(M[2].innerHTML="Z: "+e.getMeasureText(f.textY,1))}function m(f){if(f.container==null){let w=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(f.text,1)+"</text>",'<polyline stroke="#f99d0b" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");f.container=document.createElement("div"),f.container.className="elevation-annotation",f.container.id=f.id,f.container.style.position="absolute",f.container.style.pointerEvents="none",f.container.innerHTML=w,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=f.container,g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point),y=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;u.style.top=g.y+v-48+"px",u.style.left=g.x+y-16+"px",u.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(f.text,1)}function p(f){if(f.container==null){let x=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="80,32 0,32" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(f.text,1)+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="normal-annotation",f.container.id=f.id,f.container.innerHTML=x,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let u=f.container;if(f.point1==null||f.point2==null){u.style.display="none";return}else u.style.display="block";let g=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point1),y=new De(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point2),v=e.engine.reactBoundingClientRect.left,w=e.engine.reactBoundingClientRect.top;g.x+=v,g.y+=w,y.x+=v,y.y+=w,u.getElementsByTagName("polyline")[0].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y),u.getElementsByTagName("circle")[0].setAttribute("cx",g.x),u.getElementsByTagName("circle")[0].setAttribute("cy",g.y),u.getElementsByTagName("circle")[1].setAttribute("cx",y.x),u.getElementsByTagName("circle")[1].setAttribute("cy",y.y),u.getElementsByTagName("rect")[0].setAttribute("x",g.x*.5+y.x*.5-40),u.getElementsByTagName("rect")[0].setAttribute("y",g.y*.5+y.y*.5-12.5),u.getElementsByTagName("text")[0].setAttribute("x",g.x*.5+y.x*.5+40-40),u.getElementsByTagName("text")[0].setAttribute("y",g.y*.5+y.y*.5+16-12.5),u.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(f.text,1),u.style.top="0px",u.style.left="0px"}}}class hh{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}setDirection(e){this.catchDir=e}setSelectType(e){this.type=e}getMeshesMinMaxY(e){if(!Array.isArray(e)||e.length===0)return null;let t=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(let i=0;i<e.length;i++){const s=e[i];if(!s)continue;typeof s.updateMatrixWorld=="function"&&s.updateMatrixWorld(!0);const r=new b.Box3().setFromObject(s);!Number.isFinite(r.min.y)||!Number.isFinite(r.max.y)||(r.min.y<t&&(t=r.min.y),r.max.y>n&&(n=r.max.y))}return!Number.isFinite(t)||!Number.isFinite(n)?null:{minY:t,maxY:n}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch.point;if(this.type=="element"){let s=this.engine.interactionModule.getCatchMeshs(e);var n=this.getMeshesMinMaxY(s);this.catchDir==0?t.set(t.x,n?.minY,t.z):t.set(t.x,n?.maxY,t.z)}else t=e.catch.point;if(this.points.length==0){this.points.push(t);return}let i=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);i!=null&&(i.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);t==null&&(t={text:null,id:rt(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=e.catch;if(this.type=="element"){let i=e.catch.point.clone();i.set(i.x,this.points[0].y,i.z);let s=new b.Raycaster(i.add(new b.Vector3(0,.01,0)),new b.Vector3(0,this.catchDir==0?-1:1,0));n.point=this.points[0];const r=this.engine.octreeBox.rayInterationModel(s);if(r.length===0){t.point2=null;return}t.point1=i,t.point2=r[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Me.MeasureChanged,t)}else{let i=new b.Raycaster(e.catch.point.clone().add(new b.Vector3(0,.01,0)),new b.Vector3(0,this.catchDir==0?-1:1,0));const s=this.engine.octreeBox.rayInterationModel(i);if(s.length===0){t.point2=null;return}t.point1=n.point,t.point2=s[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Me.MeasureChanged,t)}}}class uh{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.isActive=!1,this.engine.handelBehaved.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point2=t.point,n.isSelect=!1,this.points=[],this.engine.events.trigger(Me.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);n==null&&(n={id:rt(),point1:this.points[0].clone(),point2:t.point.clone(),text:this.points[0].clone().distanceTo(t.point.clone()),type:"distance",isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(n)),n.point2=t.point,n.text=n.point1.clone().distanceTo(n.point2.clone())}}}class dh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(r=>r.isSelect==!0);t==null&&(t={text:null,id:rt(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new b.Raycaster(e.catch.point.clone().add(e.catch.face.normal.clone().setLength(.01)),e.catch.face.normal);const i=this.engine.octreeBox.rayInterationModel(n);if(i.length==0){t.point2=null;return}let s=e.catch;t.point1=s.point,t.point2=i[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Me.MeasureChanged,t)}}class fh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:rt(),point:e.catch.point.clone(),text:e.catch.point.y,isSelect:!0,type:"elevation"},this.engine.measure.annotationData.elevationAnnotation.push(t)),t.point=e.catch.point.clone(),t.text=e.catch.point.y}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(Me.MeasureChanged,t))}}class ph{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseUp(e){this.engine.deviceType!="PC"&&this.createMeasure()}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:rt(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t)),t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,t.isSelect=!1,this.engine.events.trigger(Me.MeasureChanged,t))}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(Me.MeasureChanged,e))}}class mh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateAngle(e,t,n){const i=new b.Vector3().subVectors(e,t),s=new b.Vector3().subVectors(n,t),r=i.length(),a=s.length();if(r===0||a===0)return 0;const c=i.dot(s)/(r*a),h=Math.max(-1,Math.min(1,c));return Math.acos(h)*(180/Math.PI)}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1)this.points.push(t.point);else if(this.points.length==2){let n=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point3=t.point.clone(),n.angle=this.calculateAngle(n.point1,n.point2,n.point3),n.text=n.angle.toFixed(2)+"°",n.isSelect=!1,n.type="angle",this.points=[],this.engine.events.trigger(Me.MeasureChanged,n)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:rt(),point1:this.points[0].clone(),point2:this.points[1].clone(),point3:e.catch.point.clone(),angle:0,text:"0.00°",isSelect:!0,type:"angle"},this.engine.measure.annotationData.angleAnnotation.push(t)),t.point3=e.catch.point.clone(),t.angle=this.calculateAngle(t.point1,t.point2,t.point3),t.text=t.angle.toFixed(2)+"°",console.log("角度",t.text)}}}class gh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateArea(e){if(e.length<3)return 0;let t=0;const n=e.length;for(let i=0;i<n;i++){const s=(i+1)%n;t+=e[i].x*e[s].z,t-=e[s].x*e[i].z}return t=Math.abs(t)/2,t}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.push(t.point.clone()),this.points.length>=3){let n=this.engine.measure.annotationData.areaAnnotation.find(i=>i.isSelect==!0);n==null?(n={id:rt(),points:this.points.map(i=>i.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(n)):(this.points.push(t.point.clone()),n.points=this.points.map(i=>i.clone())),n.area=this.calculateArea(n.points),n.text=n.area,console.log("面积",n.text)}}handleMouseMove(e){if(e.catch!=null&&this.points.length>=2){let t=this.engine.measure.annotationData.areaAnnotation.find(n=>n.isSelect==!0);if(t==null){if(this.points.length>=2){let n=this.points.map(i=>i.clone());n.push(e.catch.point.clone()),n.length>=3&&(t={id:rt(),points:n,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const n=t.points.length-1;t.points[n]=e.catch.point.clone()}else t.points=this.points.map(n=>n.clone()),t.points.push(e.catch.point.clone());t&&t.points.length>=3&&(t.area=this.calculateArea(t.points),t.text=t.area)}}handelKeyEnterDown(){this.finishMeasure()}finishMeasure(){this.points=this.points.slice(0,this.points.length-1);let e=this.engine.measure.annotationData.areaAnnotation.find(t=>t.isSelect==!0);e!=null&&e.points.length>=3&&(e.points.length>this.points.length&&(e.points=this.points.map(t=>t.clone())),e.area=this.calculateArea(e.points),e.text=e.area,e.isSelect=!1,this.points=[],this.engine.events.trigger(Me.MeasureChanged,e))}}class yh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new ot(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateSlope(e,t){const n=t.y-e.y,i=t.x-e.x,s=t.z-e.z,r=Math.sqrt(i*i+s*s);if(r===0)return{percentage:0,angle:0,heightDiff:n,horizontalDist:0,type:"slope"};const a=n/r*100,c=Math.atan(n/r)*(180/Math.PI);return{percentage:a,angle:c,heightDiff:n,horizontalDist:r,type:"slope"}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);if(n==null)return;console.log("进来了"),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)",n.isSelect=!1,this.points=[],this.engine.events.trigger(Me.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);n==null&&(n={id:rt(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"0.00% (0.00°)",isSelect:!0,type:"slope"},this.engine.measure.annotationData.slopeAnnotation.push(n)),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)"}}}class vh{isActive=!1;engine;clearHeightMeasure;distanceMeasure;clearDistanceMeasure;elevationMeasure;pointMeasure;angleMeasure;areaMeasure;slopeMeasure;tools;annotationContainer;annotationData={normalAnnotation:[],textAnnotation:[],coordinateAnnotation:[],angleAnnotation:[],distanceAnnotation:[],areaAnnotation:[],slopeAnnotation:[],elevationAnnotation:[],volumeAnnotation:[]};constructor(e){this.engine=e,this.clearHeightMeasure=new hh(e),this.distanceMeasure=new uh(e),this.clearDistanceMeasure=new dh(e),this.elevationMeasure=new fh(e),this.pointMeasure=new ph(e),this.angleMeasure=new mh(e),this.areaMeasure=new gh(e),this.slopeMeasure=new yh(e),this.tools=new ot(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.engine.modelEdge.loadModelEdge(),this.tools.active()}disActive(){this.tools.disActive(),this.clearAll(),this.isActive=!1,this.clearHeightMeasure.disActive(),this.distanceMeasure.disActive(),this.clearDistanceMeasure.disActive(),this.elevationMeasure.disActive(),this.pointMeasure.disActive(),this.angleMeasure.disActive(),this.areaMeasure.disActive(),this.slopeMeasure.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active()}clearAllPoints(){this.clearHeightMeasure.clearAllPoints(),this.distanceMeasure.clearAllPoints(),this.clearDistanceMeasure.clearAllPoints(),this.elevationMeasure.clearAllPoints(),this.pointMeasure.clearAllPoints(),this.angleMeasure.clearAllPoints(),this.areaMeasure.clearAllPoints(),this.slopeMeasure.clearAllPoints()}clearAll(){e(this.annotationData.normalAnnotation),e(this.annotationData.textAnnotation),e(this.annotationData.coordinateAnnotation),e(this.annotationData.angleAnnotation),e(this.annotationData.distanceAnnotation),e(this.annotationData.areaAnnotation),e(this.annotationData.slopeAnnotation),e(this.annotationData.elevationAnnotation),e(this.annotationData.volumeAnnotation);function e(t){for(let n=0;n<t.length;n++)t[n].container.remove();t=[]}}saveSetting(e){this.tools.saveSetting(e)}getSetting(){return this.tools.getSetting()}update(){this.isActive&&this.tools.drawNormalAnnotation()}}const Zr=0,wh=1,xh=2,Yr=2,Qi=1.25,Kr=1,Le=32,_e=Le/4,qr=65535,bh=Math.pow(2,-24),es=Symbol("SKIP_GENERATION");function Mh(o){return o.index?o.index.count:o.attributes.position.count}function kt(o){return Mh(o)/3}function _h(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function Sh(o,e){if(!o.index){const t=o.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=_h(t,n);o.setIndex(new _.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function $r(o,e){const t=kt(o),n=e||o.drawRange,i=n.start/3,s=(n.start+n.count)/3,r=Math.max(0,i),a=Math.min(t,s)-r;return[{offset:Math.floor(r),count:Math.floor(a)}]}function Hr(o,e){if(!o.groups||!o.groups.length)return $r(o,e);const t=[],n=e||o.drawRange,i=n.start/3,s=(n.start+n.count)/3,r=kt(o),a=[];for(const h of o.groups){const{start:d,count:m}=h,p=d/3,f=isFinite(m)?m:r*3-d,u=(d+f)/3;p<s&&u>i&&(a.push({pos:Math.max(i,p),isStart:!0}),a.push({pos:Math.min(s,u),isStart:!1}))}a.sort((h,d)=>h.pos!==d.pos?h.pos-d.pos:h.type==="end"?-1:1);let l=0,c=null;for(const h of a){const d=h.pos;l!==0&&d!==c&&t.push({offset:c,count:d-c}),l+=h.isStart?1:-1,c=d}return t}function ts(o,e,t,n,i){let s=1/0,r=1/0,a=1/0,l=-1/0,c=-1/0,h=-1/0,d=1/0,m=1/0,p=1/0,f=-1/0,u=-1/0,g=-1/0;const y=o.offset||0;for(let v=(e-y)*6,w=(e+t-y)*6;v<w;v+=6){const x=o[v+0],M=o[v+1],T=x-M,P=x+M;T<s&&(s=T),P>l&&(l=P),x<d&&(d=x),x>f&&(f=x);const k=o[v+2],D=o[v+3],E=k-D,O=k+D;E<r&&(r=E),O>c&&(c=O),k<m&&(m=k),k>u&&(u=k);const A=o[v+4],I=o[v+5],S=A-I,z=A+I;S<a&&(a=S),z>h&&(h=z),A<p&&(p=A),A>g&&(g=A)}n[0]=s,n[1]=r,n[2]=a,n[3]=l,n[4]=c,n[5]=h,i[0]=d,i[1]=m,i[2]=p,i[3]=f,i[4]=u,i[5]=g}function Jr(o,e,t=null,n=null,i=null){const s=o.attributes.position,r=o.index?o.index.array:null,a=s.normalized;if(i===null)i=new Float32Array(t*6),i.offset=e;else if(e<0||t+e>i.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=s.array,c=s.offset||0;let h=3;s.isInterleavedBufferAttribute&&(h=s.data.stride);const d=["getX","getY","getZ"],m=i.offset;for(let p=e,f=e+t;p<f;p++){const g=(n?n[p]:p)*3,y=(p-m)*6;let v=g+0,w=g+1,x=g+2;r&&(v=r[v],w=r[w],x=r[x]),a||(v=v*h+c,w=w*h+c,x=x*h+c);for(let M=0;M<3;M++){let T,P,k;a?(T=s[d[M]](v),P=s[d[M]](w),k=s[d[M]](x)):(T=l[v+M],P=l[w+M],k=l[x+M]);let D=T;P<D&&(D=P),k<D&&(D=k);let E=T;P>E&&(E=P),k>E&&(E=k);const O=(E-D)/2,A=M*2;i[y+A+0]=D+O,i[y+A+1]=O+(Math.abs(D)+O)*bh}}return i}function ve(o,e,t){return t.min.x=e[o],t.min.y=e[o+1],t.min.z=e[o+2],t.max.x=e[o+3],t.max.y=e[o+4],t.max.z=e[o+5],t}function Qr(o){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=o[n+3]-o[n];i>t&&(t=i,e=n)}return e}function eo(o,e){e.set(o)}function to(o,e,t){let n,i;for(let s=0;s<3;s++){const r=s+3;n=o[s],i=e[s],t[s]=n<i?n:i,n=o[r],i=e[r],t[r]=n>i?n:i}}function Qn(o,e,t){for(let n=0;n<3;n++){const i=e[o+2*n],s=e[o+2*n+1],r=i-s,a=i+s;r<t[n]&&(t[n]=r),a>t[n+3]&&(t[n+3]=a)}}function fn(o){const e=o[3]-o[0],t=o[4]-o[1],n=o[5]-o[2];return 2*(e*t+t*n+n*e)}const at=32,Ch=(o,e)=>o.candidate-e.candidate,mt=new Array(at).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ei=new Float32Array(6);function Ah(o,e,t,n,i,s){let r=-1,a=0;if(s===Zr)r=Qr(e),r!==-1&&(a=(e[r]+e[r+3])/2);else if(s===wh)r=Qr(o),r!==-1&&(a=Ph(t,n,i,r));else if(s===xh){const l=fn(o);let c=Qi*i;const h=t.offset||0,d=(n-h)*6,m=(n+i-h)*6;for(let p=0;p<3;p++){const f=e[p],y=(e[p+3]-f)/at;if(i<at/4){const v=[...mt];v.length=i;let w=0;for(let M=d;M<m;M+=6,w++){const T=v[w];T.candidate=t[M+2*p],T.count=0;const{bounds:P,leftCacheBounds:k,rightCacheBounds:D}=T;for(let E=0;E<3;E++)D[E]=1/0,D[E+3]=-1/0,k[E]=1/0,k[E+3]=-1/0,P[E]=1/0,P[E+3]=-1/0;Qn(M,t,P)}v.sort(Ch);let x=i;for(let M=0;M<x;M++){const T=v[M];for(;M+1<x&&v[M+1].candidate===T.candidate;)v.splice(M+1,1),x--}for(let M=d;M<m;M+=6){const T=t[M+2*p];for(let P=0;P<x;P++){const k=v[P];T>=k.candidate?Qn(M,t,k.rightCacheBounds):(Qn(M,t,k.leftCacheBounds),k.count++)}}for(let M=0;M<x;M++){const T=v[M],P=T.count,k=i-T.count,D=T.leftCacheBounds,E=T.rightCacheBounds;let O=0;P!==0&&(O=fn(D)/l);let A=0;k!==0&&(A=fn(E)/l);const I=Kr+Qi*(O*P+A*k);I<c&&(r=p,c=I,a=T.candidate)}}else{for(let x=0;x<at;x++){const M=mt[x];M.count=0,M.candidate=f+y+x*y;const T=M.bounds;for(let P=0;P<3;P++)T[P]=1/0,T[P+3]=-1/0}for(let x=d;x<m;x+=6){let P=~~((t[x+2*p]-f)/y);P>=at&&(P=at-1);const k=mt[P];k.count++,Qn(x,t,k.bounds)}const v=mt[at-1];eo(v.bounds,v.rightCacheBounds);for(let x=at-2;x>=0;x--){const M=mt[x],T=mt[x+1];to(M.bounds,T.rightCacheBounds,M.rightCacheBounds)}let w=0;for(let x=0;x<at-1;x++){const M=mt[x],T=M.count,P=M.bounds,D=mt[x+1].rightCacheBounds;T!==0&&(w===0?eo(P,ei):to(P,ei,ei)),w+=T;let E=0,O=0;w!==0&&(E=fn(ei)/l);const A=i-w;A!==0&&(O=fn(D)/l);const I=Kr+Qi*(E*w+O*A);I<c&&(r=p,c=I,a=M.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:r,pos:a}}function Ph(o,e,t,n){let i=0;const s=o.offset;for(let r=e,a=e+t;r<a;r++)i+=o[(r-s)*6+n*2];return i/t}class ns{constructor(){this.boundingData=new Float32Array(6)}}function Th(o,e,t,n,i,s){let r=n,a=n+i-1;const l=s.pos,c=s.axis*2,h=t.offset||0;for(;;){for(;r<=a&&t[(r-h)*6+c]<l;)r++;for(;r<=a&&t[(a-h)*6+c]>=l;)a--;if(r<a){for(let d=0;d<3;d++){let m=e[r*3+d];e[r*3+d]=e[a*3+d],e[a*3+d]=m}for(let d=0;d<6;d++){const m=r-h,p=a-h,f=t[m*6+d];t[m*6+d]=t[p*6+d],t[p*6+d]=f}r++,a--}else return r}}function Dh(o,e,t,n,i,s){let r=n,a=n+i-1;const l=s.pos,c=s.axis*2,h=t.offset||0;for(;;){for(;r<=a&&t[(r-h)*6+c]<l;)r++;for(;r<=a&&t[(a-h)*6+c]>=l;)a--;if(r<a){let d=o[r];o[r]=o[a],o[a]=d;for(let m=0;m<6;m++){const p=r-h,f=a-h,u=t[p*6+m];t[p*6+m]=t[f*6+m],t[f*6+m]=u}r++,a--}else return r}}let no,ti,is,io;const kh=Math.pow(2,32);function ss(o){return"count"in o?1:1+ss(o.left)+ss(o.right)}function Eh(o,e,t){return no=new Float32Array(t),ti=new Uint32Array(t),is=new Uint16Array(t),io=new Uint8Array(t),rs(o,e)}function rs(o,e){const t=o/4,n=o/2,i="count"in e,s=e.boundingData;for(let r=0;r<6;r++)no[t+r]=s[r];if(i)return e.buffer?(io.set(new Uint8Array(e.buffer),o),o+e.buffer.byteLength):(ti[t+6]=e.offset,is[n+14]=e.count,is[n+15]=qr,o+Le);{const{left:r,right:a,splitAxis:l}=e,c=o+Le;let h=rs(c,r);const d=o/Le,p=h/Le-d;if(p>kh)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return ti[t+6]=p,ti[t+7]=l,rs(h,a)}}function Lh(o,e,t){const i=(o.index?o.index.count:o.attributes.position.count)/3>2**16,s=t.reduce((h,d)=>h+d.count,0),r=i?4:2,a=e?new SharedArrayBuffer(s*r):new ArrayBuffer(s*r),l=i?new Uint32Array(a):new Uint16Array(a);let c=0;for(let h=0;h<t.length;h++){const{offset:d,count:m}=t[h];for(let p=0;p<m;p++)l[c+p]=d+p;c+=m}return l}function Ih(o,e,t,n,i){const{maxDepth:s,verbose:r,maxLeafTris:a,strategy:l,onProgress:c,indirect:h}=i,d=o._indirectBuffer,m=o.geometry,p=m.index?m.index.array:null,f=h?Dh:Th,u=kt(m),g=new Float32Array(6);let y=!1;const v=new ns;return ts(e,t,n,v.boundingData,g),x(v,t,n,g),v;function w(M){c&&c(M/u)}function x(M,T,P,k=null,D=0){if(!y&&D>=s&&(y=!0,r&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(m))),P<=a||D>=s)return w(T+P),M.offset=T,M.count=P,M;const E=Ah(M.boundingData,k,e,T,P,l);if(E.axis===-1)return w(T+P),M.offset=T,M.count=P,M;const O=f(d,p,e,T,P,E);if(O===T||O===T+P)w(T+P),M.offset=T,M.count=P;else{M.splitAxis=E.axis;const A=new ns,I=T,S=O-T;M.left=A,ts(e,I,S,A.boundingData,g),x(A,I,S,g,D+1);const z=new ns,V=O,U=P-S;M.right=z,ts(e,V,U,z.boundingData,g),x(z,V,U,g,D+1)}return M}}function zh(o,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=o.geometry;let i,s;if(e.indirect){const r=Hr(n,e.range),a=Lh(n,e.useSharedArrayBuffer,r);o._indirectBuffer=a,i=Jr(n,0,a.length,a),s=[{offset:0,count:a.length}]}else{Sh(n,e);const r=$r(n,e.range)[0];i=Jr(n,r.offset,r.count),s=Hr(n,e.range)}o._roots=s.map(r=>{const a=Ih(o,i,r.offset,r.count,e),l=ss(a),c=new t(Le*l);return Eh(0,a,c),c})}class lt{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,r=e.length;s<r;s++){const l=e[s][t];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,r=t.length;s<r;s++){const a=t[s],l=e.dot(a);n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}lt.prototype.setFromBox=(function(){const o=new _.Vector3;return function(t,n){const i=n.min,s=n.max;let r=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){o.x=i.x*l+s.x*(1-l),o.y=i.y*c+s.y*(1-c),o.z=i.z*h+s.z*(1-h);const d=t.dot(o);r=Math.min(d,r),a=Math.max(d,a)}this.min=r,this.max=a}})();const Bh=(function(){const o=new _.Vector3,e=new _.Vector3,t=new _.Vector3;return function(i,s,r){const a=i.start,l=o,c=s.start,h=e;t.subVectors(a,c),o.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const d=t.dot(h),m=h.dot(l),p=h.dot(h),f=t.dot(l),g=l.dot(l)*p-m*m;let y,v;g!==0?y=(d*m-f*p)/g:y=0,v=(d+y*m)/p,r.x=y,r.y=v}})(),os=(function(){const o=new _.Vector2,e=new _.Vector3,t=new _.Vector3;return function(i,s,r,a){Bh(i,s,o);let l=o.x,c=o.y;if(l>=0&&l<=1&&c>=0&&c<=1){i.at(l,r),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,r);return}else if(c>=0&&c<=1){l<0?i.at(0,r):i.at(1,r),s.closestPointToPoint(r,!0,a);return}else{let h;l<0?h=i.start:h=i.end;let d;c<0?d=s.start:d=s.end;const m=e,p=t;if(i.closestPointToPoint(d,!0,e),s.closestPointToPoint(h,!0,t),m.distanceToSquared(d)<=p.distanceToSquared(h)){r.copy(m),a.copy(d);return}else{r.copy(h),a.copy(p);return}}}})(),Oh=(function(){const o=new _.Vector3,e=new _.Vector3,t=new _.Plane,n=new _.Line3;return function(s,r){const{radius:a,center:l}=s,{a:c,b:h,c:d}=r;if(n.start=c,n.end=h,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a||(n.start=c,n.end=d,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a)||(n.start=h,n.end=d,n.closestPointToPoint(l,!0,o).distanceTo(l)<=a))return!0;const u=r.getPlane(t);if(Math.abs(u.distanceToPoint(l))<=a){const y=u.projectPoint(l,e);if(r.containsPoint(y))return!0}return!1}})(),Rh=["x","y","z"],ct=1e-15,so=ct*ct;function je(o){return Math.abs(o)<ct}class Ge extends _.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new _.Vector3),this.satBounds=new Array(4).fill().map(()=>new lt),this.points=[this.a,this.b,this.c],this.plane=new _.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new _.Line3,this.needsUpdate=!0}intersectsSphere(e){return Oh(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,r=this.satBounds,a=s[0],l=r[0];this.getNormal(a),l.setFromPoints(a,i);const c=s[1],h=r[1];c.subVectors(e,t),h.setFromPoints(c,i);const d=s[2],m=r[2];d.subVectors(t,n),m.setFromPoints(d,i);const p=s[3],f=r[3];p.subVectors(n,e),f.setFromPoints(p,i);const u=c.length(),g=d.length(),y=p.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,u<ct?g<ct||y<ct?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<ct?y<ct?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):y<ct&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}Ge.prototype.closestPointToSegment=(function(){const o=new _.Vector3,e=new _.Vector3,t=new _.Line3;return function(i,s=null,r=null){const{start:a,end:l}=i,c=this.points;let h,d=1/0;for(let m=0;m<3;m++){const p=(m+1)%3;t.start.copy(c[m]),t.end.copy(c[p]),os(t,i,o,e),h=o.distanceToSquared(e),h<d&&(d=h,s&&s.copy(o),r&&r.copy(e))}return this.closestPointToPoint(a,o),h=a.distanceToSquared(o),h<d&&(d=h,s&&s.copy(o),r&&r.copy(a)),this.closestPointToPoint(l,o),h=l.distanceToSquared(o),h<d&&(d=h,s&&s.copy(o),r&&r.copy(l)),Math.sqrt(d)}})(),Ge.prototype.intersectsTriangle=(function(){const o=new Ge,e=new lt,t=new lt,n=new _.Vector3,i=new _.Vector3,s=new _.Vector3,r=new _.Vector3,a=new _.Line3,l=new _.Line3,c=new _.Vector3,h=new _.Vector2,d=new _.Vector2;function m(w,x,M,T){const P=n;!w.isDegenerateIntoPoint&&!w.isDegenerateIntoSegment?P.copy(w.plane.normal):P.copy(x.plane.normal);const k=w.satBounds,D=w.satAxes;for(let A=1;A<4;A++){const I=k[A],S=D[A];if(e.setFromPoints(S,x.points),I.isSeparated(e)||(r.copy(P).cross(S),e.setFromPoints(r,w.points),t.setFromPoints(r,x.points),e.isSeparated(t)))return!1}const E=x.satBounds,O=x.satAxes;for(let A=1;A<4;A++){const I=E[A],S=O[A];if(e.setFromPoints(S,w.points),I.isSeparated(e)||(r.crossVectors(P,S),e.setFromPoints(r,w.points),t.setFromPoints(r,x.points),e.isSeparated(t)))return!1}return M&&(T||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),M.start.set(0,0,0),M.end.set(0,0,0)),!0}function p(w,x,M,T,P,k,D,E,O,A,I){let S=D/(D-E);A.x=T+(P-T)*S,I.start.subVectors(x,w).multiplyScalar(S).add(w),S=D/(D-O),A.y=T+(k-T)*S,I.end.subVectors(M,w).multiplyScalar(S).add(w)}function f(w,x,M,T,P,k,D,E,O,A,I){if(P>0)p(w.c,w.a,w.b,T,x,M,O,D,E,A,I);else if(k>0)p(w.b,w.a,w.c,M,x,T,E,D,O,A,I);else if(E*O>0||D!=0)p(w.a,w.b,w.c,x,M,T,D,E,O,A,I);else if(E!=0)p(w.b,w.a,w.c,M,x,T,E,D,O,A,I);else if(O!=0)p(w.c,w.a,w.b,T,x,M,O,D,E,A,I);else return!0;return!1}function u(w,x,M,T){const P=x.degenerateSegment,k=w.plane.distanceToPoint(P.start),D=w.plane.distanceToPoint(P.end);return je(k)?je(D)?m(w,x,M,T):(M&&(M.start.copy(P.start),M.end.copy(P.start)),w.containsPoint(P.start)):je(D)?(M&&(M.start.copy(P.end),M.end.copy(P.end)),w.containsPoint(P.end)):w.plane.intersectLine(P,n)!=null?(M&&(M.start.copy(n),M.end.copy(n)),w.containsPoint(n)):!1}function g(w,x,M){const T=x.a;return je(w.plane.distanceToPoint(T))&&w.containsPoint(T)?(M&&(M.start.copy(T),M.end.copy(T)),!0):!1}function y(w,x,M){const T=w.degenerateSegment,P=x.a;return T.closestPointToPoint(P,!0,n),P.distanceToSquared(n)<so?(M&&(M.start.copy(P),M.end.copy(P)),!0):!1}function v(w,x,M,T){if(w.isDegenerateIntoSegment)if(x.isDegenerateIntoSegment){const P=w.degenerateSegment,k=x.degenerateSegment,D=i,E=s;P.delta(D),k.delta(E);const O=n.subVectors(k.start,P.start),A=D.x*E.y-D.y*E.x;if(je(A))return!1;const I=(O.x*E.y-O.y*E.x)/A,S=-(D.x*O.y-D.y*O.x)/A;if(I<0||I>1||S<0||S>1)return!1;const z=P.start.z+D.z*I,V=k.start.z+E.z*S;return je(z-V)?(M&&(M.start.copy(P.start).addScaledVector(D,I),M.end.copy(P.start).addScaledVector(D,I)),!0):!1}else return x.isDegenerateIntoPoint?y(w,x,M):u(x,w,M,T);else{if(w.isDegenerateIntoPoint)return x.isDegenerateIntoPoint?x.a.distanceToSquared(w.a)<so?(M&&(M.start.copy(w.a),M.end.copy(w.a)),!0):!1:x.isDegenerateIntoSegment?y(x,w,M):g(x,w,M);if(x.isDegenerateIntoPoint)return g(w,x,M);if(x.isDegenerateIntoSegment)return u(w,x,M,T)}}return function(x,M=null,T=!1){this.needsUpdate&&this.update(),x.isExtendedTriangle?x.needsUpdate&&x.update():(o.copy(x),o.update(),x=o);const P=v(this,x,M,T);if(P!==void 0)return P;const k=this.plane,D=x.plane;let E=D.distanceToPoint(this.a),O=D.distanceToPoint(this.b),A=D.distanceToPoint(this.c);je(E)&&(E=0),je(O)&&(O=0),je(A)&&(A=0);const I=E*O,S=E*A;if(I>0&&S>0)return!1;let z=k.distanceToPoint(x.a),V=k.distanceToPoint(x.b),U=k.distanceToPoint(x.c);je(z)&&(z=0),je(V)&&(V=0),je(U)&&(U=0);const H=z*V,G=z*U;if(H>0&&G>0)return!1;i.copy(k.normal),s.copy(D.normal);const $=i.cross(s);let F=0,R=Math.abs($.x);const te=Math.abs($.y);te>R&&(R=te,F=1),Math.abs($.z)>R&&(F=2);const q=Rh[F],ce=this.a[q],fe=this.b[q],se=this.c[q],oe=x.a[q],ue=x.b[q],pe=x.c[q];if(f(this,ce,fe,se,I,S,E,O,A,h,a))return m(this,x,M,T);if(f(x,oe,ue,pe,H,G,z,V,U,d,l))return m(this,x,M,T);if(h.y<h.x){const Ce=h.y;h.y=h.x,h.x=Ce,c.copy(a.start),a.start.copy(a.end),a.end.copy(c)}if(d.y<d.x){const Ce=d.y;d.y=d.x,d.x=Ce,c.copy(l.start),l.start.copy(l.end),l.end.copy(c)}return h.y<d.x||d.y<h.x?!1:(M&&(d.x>h.x?M.start.copy(l.start):M.start.copy(a.start),d.y<h.y?M.end.copy(l.end):M.end.copy(a.end)),!0)}})(),Ge.prototype.distanceToPoint=(function(){const o=new _.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}})(),Ge.prototype.distanceToTriangle=(function(){const o=new _.Vector3,e=new _.Vector3,t=["a","b","c"],n=new _.Line3,i=new _.Line3;return function(r,a=null,l=null){const c=a||l?n:null;if(this.intersectsTriangle(r,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let h=1/0;for(let d=0;d<3;d++){let m;const p=t[d],f=r[p];this.closestPointToPoint(f,o),m=f.distanceToSquared(o),m<h&&(h=m,a&&a.copy(o),l&&l.copy(f));const u=this[p];r.closestPointToPoint(u,o),m=u.distanceToSquared(o),m<h&&(h=m,a&&a.copy(u),l&&l.copy(o))}for(let d=0;d<3;d++){const m=t[d],p=t[(d+1)%3];n.set(this[m],this[p]);for(let f=0;f<3;f++){const u=t[f],g=t[(f+1)%3];i.set(r[u],r[g]),os(n,i,o,e);const y=o.distanceToSquared(e);y<h&&(h=y,a&&a.copy(o),l&&l.copy(e))}}return Math.sqrt(h)}})();class Ie{constructor(e,t,n){this.isOrientedBox=!0,this.min=new _.Vector3,this.max=new _.Vector3,this.matrix=new _.Matrix4,this.invMatrix=new _.Matrix4,this.points=new Array(8).fill().map(()=>new _.Vector3),this.satAxes=new Array(3).fill().map(()=>new _.Vector3),this.satBounds=new Array(3).fill().map(()=>new lt),this.alignedSatBounds=new Array(3).fill().map(()=>new lt),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ie.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let c=0;c<=1;c++)for(let h=0;h<=1;h++)for(let d=0;d<=1;d++){const m=1*c|2*h|4*d,p=i[m];p.x=c?n.x:t.x,p.y=h?n.y:t.y,p.z=d?n.z:t.z,p.applyMatrix4(e)}const s=this.satBounds,r=this.satAxes,a=i[0];for(let c=0;c<3;c++){const h=r[c],d=s[c],m=1<<c,p=i[m];h.subVectors(a,p),d.setFromPoints(h,i)}const l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),Ie.prototype.intersectsBox=(function(){const o=new lt;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,s=this.satBounds,r=this.satAxes,a=this.alignedSatBounds;if(o.min=n.x,o.max=i.x,a[0].isSeparated(o)||(o.min=n.y,o.max=i.y,a[1].isSeparated(o))||(o.min=n.z,o.max=i.z,a[2].isSeparated(o)))return!1;for(let l=0;l<3;l++){const c=r[l],h=s[l];if(o.setFromBox(c,t),h.isSeparated(o))return!1}return!0}})(),Ie.prototype.intersectsTriangle=(function(){const o=new Ge,e=new Array(3),t=new lt,n=new lt,i=new _.Vector3;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(o.copy(r),o.update(),r=o);const a=this.satBounds,l=this.satAxes;e[0]=r.a,e[1]=r.b,e[2]=r.c;for(let m=0;m<3;m++){const p=a[m],f=l[m];if(t.setFromPoints(f,e),p.isSeparated(t))return!1}const c=r.satBounds,h=r.satAxes,d=this.points;for(let m=0;m<3;m++){const p=c[m],f=h[m];if(t.setFromPoints(f,d),p.isSeparated(t))return!1}for(let m=0;m<3;m++){const p=l[m];for(let f=0;f<4;f++){const u=h[f];if(i.crossVectors(p,u),t.setFromPoints(i,e),n.setFromPoints(i,d),t.isSeparated(n))return!1}}return!0}})(),Ie.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})(),Ie.prototype.distanceToPoint=(function(){const o=new _.Vector3;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}})(),Ie.prototype.distanceToBox=(function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new _.Line3),t=new Array(12).fill().map(()=>new _.Line3),n=new _.Vector3,i=new _.Vector3;return function(r,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(l||c)&&(r.getCenter(i),this.closestPointToPoint(i,n),r.closestPointToPoint(n,i),l&&l.copy(n),c&&c.copy(i)),0;const h=a*a,d=r.min,m=r.max,p=this.points;let f=1/0;for(let g=0;g<8;g++){const y=p[g];i.copy(y).clamp(d,m);const v=y.distanceToSquared(i);if(v<f&&(f=v,l&&l.copy(y),c&&c.copy(i),v<h))return Math.sqrt(v)}let u=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){const w=(g+1)%3,x=(g+2)%3,M=y<<w|v<<x,T=1<<g|y<<w|v<<x,P=p[M],k=p[T];e[u].set(P,k);const E=o[g],O=o[w],A=o[x],I=t[u],S=I.start,z=I.end;S[E]=d[E],S[O]=y?d[O]:m[O],S[A]=v?d[A]:m[O],z[E]=m[E],z[O]=y?d[O]:m[O],z[A]=v?d[A]:m[O],u++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=g?m.x:d.x,i.y=y?m.y:d.y,i.z=v?m.z:d.z,this.closestPointToPoint(i,n);const w=i.distanceToSquared(n);if(w<f&&(f=w,l&&l.copy(n),c&&c.copy(i),w<h))return Math.sqrt(w)}for(let g=0;g<12;g++){const y=e[g];for(let v=0;v<12;v++){const w=t[v];os(y,w,n,i);const x=n.distanceToSquared(i);if(x<f&&(f=x,l&&l.copy(n),c&&c.copy(i),x<h))return Math.sqrt(x)}}return Math.sqrt(f)}})();class as{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return e.length===0?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class Nh extends as{constructor(){super(()=>new Ge)}}const We=new Nh;function Se(o,e){return e[o+15]===qr}function Ue(o,e){return e[o+6]}function Xe(o,e){return e[o+14]}function Pe(o){return o+_e}function Te(o,e){const t=e[o+6];return o+t*_e}function ls(o,e){return e[o+7]}function Kf(o){return o}class Fh{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=n=>{t&&e.push(t),t=n,this.float32Array=new Float32Array(n),this.uint16Array=new Uint16Array(n),this.uint32Array=new Uint32Array(n)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,e.length!==0&&this.setBuffer(e.pop())}}}const me=new Fh;let gt,Kt;const qt=[],ni=new as(()=>new _.Box3);function Uh(o,e,t,n,i,s){gt=ni.getPrimitive(),Kt=ni.getPrimitive(),qt.push(gt,Kt),me.setBuffer(o._roots[e]);const r=cs(0,o.geometry,t,n,i,s);me.clearBuffer(),ni.releasePrimitive(gt),ni.releasePrimitive(Kt),qt.pop(),qt.pop();const a=qt.length;return a>0&&(Kt=qt[a-1],gt=qt[a-2]),r}function cs(o,e,t,n,i=null,s=0,r=0){const{float32Array:a,uint16Array:l,uint32Array:c}=me;let h=o*2;if(Se(h,l)){const m=Ue(o,c),p=Xe(h,l);return ve(o,a,gt),n(m,p,!1,r,s+o/_e,gt)}else{let E=function(A){const{uint16Array:I,uint32Array:S}=me;let z=A*2;for(;!Se(z,I);)A=Pe(A),z=A*2;return Ue(A,S)},O=function(A){const{uint16Array:I,uint32Array:S}=me;let z=A*2;for(;!Se(z,I);)A=Te(A,S),z=A*2;return Ue(A,S)+Xe(z,I)};const m=Pe(o),p=Te(o,c);let f=m,u=p,g,y,v,w;if(i&&(v=gt,w=Kt,ve(f,a,v),ve(u,a,w),g=i(v),y=i(w),y<g)){f=p,u=m;const A=g;g=y,y=A,v=w}v||(v=gt,ve(f,a,v));const x=Se(f*2,l),M=t(v,x,g,r+1,s+f/_e);let T;if(M===Yr){const A=E(f),S=O(f)-A;T=n(A,S,!0,r+1,s+f/_e,v)}else T=M&&cs(f,e,t,n,i,s,r+1);if(T)return!0;w=Kt,ve(u,a,w);const P=Se(u*2,l),k=t(w,P,y,r+1,s+u/_e);let D;if(k===Yr){const A=E(u),S=O(u)-A;D=n(A,S,!0,r+1,s+u/_e,w)}else D=k&&cs(u,e,t,n,i,s,r+1);return!!D}}const pn=new _.Vector3,hs=new _.Vector3;function Vh(o,e,t={},n=0,i=1/0){const s=n*n,r=i*i;let a=1/0,l=null;if(o.shapecast({boundsTraverseOrder:h=>(pn.copy(e).clamp(h.min,h.max),pn.distanceToSquared(e)),intersectsBounds:(h,d,m)=>m<a&&m<r,intersectsTriangle:(h,d)=>{h.closestPointToPoint(e,pn);const m=e.distanceToSquared(pn);return m<a&&(hs.copy(pn),a=m,l=d),m<s}}),a===1/0)return null;const c=Math.sqrt(a);return t.point?t.point.copy(hs):t.point=hs.clone(),t.distance=c,t.faceIndex=l,t}const ii=parseInt(_.REVISION)>=169,jh=parseInt(_.REVISION)<=161,Et=new _.Vector3,Lt=new _.Vector3,It=new _.Vector3,si=new _.Vector2,ri=new _.Vector2,oi=new _.Vector2,ro=new _.Vector3,oo=new _.Vector3,ao=new _.Vector3,mn=new _.Vector3;function Gh(o,e,t,n,i,s,r,a){let l;if(s===_.BackSide?l=o.intersectTriangle(n,t,e,!0,i):l=o.intersectTriangle(e,t,n,s!==_.DoubleSide,i),l===null)return null;const c=o.origin.distanceTo(i);return c<r||c>a?null:{distance:c,point:i.clone()}}function lo(o,e,t,n,i,s,r,a,l,c,h){Et.fromBufferAttribute(e,s),Lt.fromBufferAttribute(e,r),It.fromBufferAttribute(e,a);const d=Gh(o,Et,Lt,It,mn,l,c,h);if(d){if(n){si.fromBufferAttribute(n,s),ri.fromBufferAttribute(n,r),oi.fromBufferAttribute(n,a),d.uv=new _.Vector2;const p=_.Triangle.getInterpolation(mn,Et,Lt,It,si,ri,oi,d.uv);ii||(d.uv=p)}if(i){si.fromBufferAttribute(i,s),ri.fromBufferAttribute(i,r),oi.fromBufferAttribute(i,a),d.uv1=new _.Vector2;const p=_.Triangle.getInterpolation(mn,Et,Lt,It,si,ri,oi,d.uv1);ii||(d.uv1=p),jh&&(d.uv2=d.uv1)}if(t){ro.fromBufferAttribute(t,s),oo.fromBufferAttribute(t,r),ao.fromBufferAttribute(t,a),d.normal=new _.Vector3;const p=_.Triangle.getInterpolation(mn,Et,Lt,It,ro,oo,ao,d.normal);d.normal.dot(o.direction)>0&&d.normal.multiplyScalar(-1),ii||(d.normal=p)}const m={a:s,b:r,c:a,normal:new _.Vector3,materialIndex:0};if(_.Triangle.getNormal(Et,Lt,It,m.normal),d.face=m,d.faceIndex=s,ii){const p=new _.Vector3;_.Triangle.getBarycoord(mn,Et,Lt,It,p),d.barycoord=p}}return d}function co(o){return o&&o.isMaterial?o.side:o}function ai(o,e,t,n,i,s,r){const a=n*3;let l=a+0,c=a+1,h=a+2;const{index:d,groups:m}=o;o.index&&(l=d.getX(l),c=d.getX(c),h=d.getX(h));const{position:p,normal:f,uv:u,uv1:g}=o.attributes;if(Array.isArray(e)){const y=n*3;for(let v=0,w=m.length;v<w;v++){const{start:x,count:M,materialIndex:T}=m[v];if(y>=x&&y<x+M){const P=co(e[T]),k=lo(t,p,f,u,g,l,c,h,P,s,r);if(k)if(k.faceIndex=n,k.face.materialIndex=T,i)i.push(k);else return k}}}else{const y=co(e),v=lo(t,p,f,u,g,l,c,h,y,s,r);if(v)if(v.faceIndex=n,v.face.materialIndex=0,i)i.push(v);else return v}return null}function be(o,e,t,n){const i=o.a,s=o.b,r=o.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),r.x=n.getX(c),r.y=n.getY(c),r.z=n.getZ(c)}function Wh(o,e,t,n,i,s,r,a){const{geometry:l,_indirectBuffer:c}=o;for(let h=n,d=n+i;h<d;h++)ai(l,e,t,h,s,r,a)}function Xh(o,e,t,n,i,s,r){const{geometry:a,_indirectBuffer:l}=o;let c=1/0,h=null;for(let d=n,m=n+i;d<m;d++){let p;p=ai(a,e,t,d,null,s,r),p&&p.distance<c&&(h=p,c=p.distance)}return h}function Zh(o,e,t,n,i,s,r){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let h=o,d=e+o;h<d;h++){let m;if(m=h,be(r,m*3,l,c),r.needsUpdate=!0,n(r,m,i,s))return!0}return!1}function Yh(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,r,a,l,c=0;const h=o._roots;for(let m=0,p=h.length;m<p;m++)s=h[m],r=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),d(0,c),c+=s.byteLength;function d(m,p,f=!1){const u=m*2;if(Se(u,a)){const g=r[m+6],y=a[u+14];let v=1/0,w=1/0,x=1/0,M=-1/0,T=-1/0,P=-1/0;for(let k=3*g,D=3*(g+y);k<D;k++){let E=n[k];const O=i.getX(E),A=i.getY(E),I=i.getZ(E);O<v&&(v=O),O>M&&(M=O),A<w&&(w=A),A>T&&(T=A),I<x&&(x=I),I>P&&(P=I)}return l[m+0]!==v||l[m+1]!==w||l[m+2]!==x||l[m+3]!==M||l[m+4]!==T||l[m+5]!==P?(l[m+0]=v,l[m+1]=w,l[m+2]=x,l[m+3]=M,l[m+4]=T,l[m+5]=P,!0):!1}else{const g=Pe(m),y=Te(m,r);let v=f,w=!1,x=!1;if(e){if(!v){const E=g/_e+p/Le,O=y/_e+p/Le;w=e.has(E),x=e.has(O),v=!w&&!x}}else w=!0,x=!0;const M=v||w,T=v||x;let P=!1;M&&(P=d(g,p,v));let k=!1;T&&(k=d(y,p,v));const D=P||k;if(D)for(let E=0;E<3;E++){const O=g+E,A=y+E,I=l[O],S=l[O+3],z=l[A],V=l[A+3];l[m+E]=I<z?I:z,l[m+E+3]=S>V?S:V}return D}}}function yt(o,e,t,n,i){let s,r,a,l,c,h;const d=1/t.direction.x,m=1/t.direction.y,p=1/t.direction.z,f=t.origin.x,u=t.origin.y,g=t.origin.z;let y=e[o],v=e[o+3],w=e[o+1],x=e[o+3+1],M=e[o+2],T=e[o+3+2];return d>=0?(s=(y-f)*d,r=(v-f)*d):(s=(v-f)*d,r=(y-f)*d),m>=0?(a=(w-u)*m,l=(x-u)*m):(a=(x-u)*m,l=(w-u)*m),s>l||a>r||((a>s||isNaN(s))&&(s=a),(l<r||isNaN(r))&&(r=l),p>=0?(c=(M-g)*p,h=(T-g)*p):(c=(T-g)*p,h=(M-g)*p),s>h||c>r)?!1:((c>s||s!==s)&&(s=c),(h<r||r!==r)&&(r=h),s<=i&&r>=n)}function Kh(o,e,t,n,i,s,r,a){const{geometry:l,_indirectBuffer:c}=o;for(let h=n,d=n+i;h<d;h++){let m=c?c[h]:h;ai(l,e,t,m,s,r,a)}}function qh(o,e,t,n,i,s,r){const{geometry:a,_indirectBuffer:l}=o;let c=1/0,h=null;for(let d=n,m=n+i;d<m;d++){let p;p=ai(a,e,t,l?l[d]:d,null,s,r),p&&p.distance<c&&(h=p,c=p.distance)}return h}function $h(o,e,t,n,i,s,r){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let h=o,d=e+o;h<d;h++){let m;if(m=t.resolveTriangleIndex(h),be(r,m*3,l,c),r.needsUpdate=!0,n(r,m,i,s))return!0}return!1}function Hh(o,e,t,n,i,s,r){me.setBuffer(o._roots[e]),us(0,o,t,n,i,s,r),me.clearBuffer()}function us(o,e,t,n,i,s,r){const{float32Array:a,uint16Array:l,uint32Array:c}=me,h=o*2;if(Se(h,l)){const m=Ue(o,c),p=Xe(h,l);Wh(e,t,n,m,p,i,s,r)}else{const m=Pe(o);yt(m,a,n,s,r)&&us(m,e,t,n,i,s,r);const p=Te(o,c);yt(p,a,n,s,r)&&us(p,e,t,n,i,s,r)}}const Jh=["x","y","z"];function Qh(o,e,t,n,i,s){me.setBuffer(o._roots[e]);const r=ds(0,o,t,n,i,s);return me.clearBuffer(),r}function ds(o,e,t,n,i,s){const{float32Array:r,uint16Array:a,uint32Array:l}=me;let c=o*2;if(Se(c,a)){const d=Ue(o,l),m=Xe(c,a);return Xh(e,t,n,d,m,i,s)}else{const d=ls(o,l),m=Jh[d],f=n.direction[m]>=0;let u,g;f?(u=Pe(o),g=Te(o,l)):(u=Te(o,l),g=Pe(o));const v=yt(u,r,n,i,s)?ds(u,e,t,n,i,s):null;if(v){const M=v.point[m];if(f?M<=r[g+d]:M>=r[g+d+3])return v}const x=yt(g,r,n,i,s)?ds(g,e,t,n,i,s):null;return v&&x?v.distance<=x.distance?v:x:v||x||null}}const li=new _.Box3,$t=new Ge,Ht=new Ge,gn=new _.Matrix4,ho=new Ie,ci=new Ie;function eu(o,e,t,n){me.setBuffer(o._roots[e]);const i=fs(0,o,t,n);return me.clearBuffer(),i}function fs(o,e,t,n,i=null){const{float32Array:s,uint16Array:r,uint32Array:a}=me;let l=o*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),ho.set(t.boundingBox.min,t.boundingBox.max,n),i=ho),Se(l,r)){const h=e.geometry,d=h.index,m=h.attributes.position,p=t.index,f=t.attributes.position,u=Ue(o,a),g=Xe(l,r);if(gn.copy(n).invert(),t.boundsTree)return ve(o,s,ci),ci.matrix.copy(gn),ci.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:v=>ci.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(n),v.b.applyMatrix4(n),v.c.applyMatrix4(n),v.needsUpdate=!0;for(let w=u*3,x=(g+u)*3;w<x;w+=3)if(be(Ht,w,d,m),Ht.needsUpdate=!0,v.intersectsTriangle(Ht))return!0;return!1}});{const y=kt(t);for(let v=u*3,w=(g+u)*3;v<w;v+=3){be($t,v,d,m),$t.a.applyMatrix4(gn),$t.b.applyMatrix4(gn),$t.c.applyMatrix4(gn),$t.needsUpdate=!0;for(let x=0,M=y*3;x<M;x+=3)if(be(Ht,x,p,f),Ht.needsUpdate=!0,$t.intersectsTriangle(Ht))return!0}}}else{const h=Pe(o),d=Te(o,a);return ve(h,s,li),!!(i.intersectsBox(li)&&fs(h,e,t,n,i)||(ve(d,s,li),i.intersectsBox(li)&&fs(d,e,t,n,i)))}}const hi=new _.Matrix4,ps=new Ie,yn=new Ie,tu=new _.Vector3,nu=new _.Vector3,iu=new _.Vector3,su=new _.Vector3;function ru(o,e,t,n={},i={},s=0,r=1/0){e.boundingBox||e.computeBoundingBox(),ps.set(e.boundingBox.min,e.boundingBox.max,t),ps.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,c=a.index,h=e.attributes.position,d=e.index,m=We.getPrimitive(),p=We.getPrimitive();let f=tu,u=nu,g=null,y=null;i&&(g=iu,y=su);let v=1/0,w=null,x=null;return hi.copy(t).invert(),yn.matrix.copy(hi),o.shapecast({boundsTraverseOrder:M=>ps.distanceToBox(M),intersectsBounds:(M,T,P)=>P<v&&P<r?(T&&(yn.min.copy(M.min),yn.max.copy(M.max),yn.needsUpdate=!0),!0):!1,intersectsRange:(M,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:k=>yn.distanceToBox(k),intersectsBounds:(k,D,E)=>E<v&&E<r,intersectsRange:(k,D)=>{for(let E=k,O=k+D;E<O;E++){be(p,3*E,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let A=M,I=M+T;A<I;A++){be(m,3*A,c,l),m.needsUpdate=!0;const S=m.distanceToTriangle(p,f,g);if(S<v&&(u.copy(f),y&&y.copy(g),v=S,w=A,x=E),S<s)return!0}}}});{const P=kt(e);for(let k=0,D=P;k<D;k++){be(p,3*k,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let E=M,O=M+T;E<O;E++){be(m,3*E,c,l),m.needsUpdate=!0;const A=m.distanceToTriangle(p,f,g);if(A<v&&(u.copy(f),y&&y.copy(g),v=A,w=E,x=k),A<s)return!0}}}}}),We.releasePrimitive(m),We.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(u):n.point=u.clone(),n.distance=v,n.faceIndex=w,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(hi),u.applyMatrix4(hi),i.distance=u.sub(i.point).length(),i.faceIndex=x),n)}function ou(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,r,a,l,c=0;const h=o._roots;for(let m=0,p=h.length;m<p;m++)s=h[m],r=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),d(0,c),c+=s.byteLength;function d(m,p,f=!1){const u=m*2;if(Se(u,a)){const g=r[m+6],y=a[u+14];let v=1/0,w=1/0,x=1/0,M=-1/0,T=-1/0,P=-1/0;for(let k=g,D=g+y;k<D;k++){const E=3*o.resolveTriangleIndex(k);for(let O=0;O<3;O++){let A=E+O;A=n?n[A]:A;const I=i.getX(A),S=i.getY(A),z=i.getZ(A);I<v&&(v=I),I>M&&(M=I),S<w&&(w=S),S>T&&(T=S),z<x&&(x=z),z>P&&(P=z)}}return l[m+0]!==v||l[m+1]!==w||l[m+2]!==x||l[m+3]!==M||l[m+4]!==T||l[m+5]!==P?(l[m+0]=v,l[m+1]=w,l[m+2]=x,l[m+3]=M,l[m+4]=T,l[m+5]=P,!0):!1}else{const g=Pe(m),y=Te(m,r);let v=f,w=!1,x=!1;if(e){if(!v){const E=g/_e+p/Le,O=y/_e+p/Le;w=e.has(E),x=e.has(O),v=!w&&!x}}else w=!0,x=!0;const M=v||w,T=v||x;let P=!1;M&&(P=d(g,p,v));let k=!1;T&&(k=d(y,p,v));const D=P||k;if(D)for(let E=0;E<3;E++){const O=g+E,A=y+E,I=l[O],S=l[O+3],z=l[A],V=l[A+3];l[m+E]=I<z?I:z,l[m+E+3]=S>V?S:V}return D}}}function au(o,e,t,n,i,s,r){me.setBuffer(o._roots[e]),ms(0,o,t,n,i,s,r),me.clearBuffer()}function ms(o,e,t,n,i,s,r){const{float32Array:a,uint16Array:l,uint32Array:c}=me,h=o*2;if(Se(h,l)){const m=Ue(o,c),p=Xe(h,l);Kh(e,t,n,m,p,i,s,r)}else{const m=Pe(o);yt(m,a,n,s,r)&&ms(m,e,t,n,i,s,r);const p=Te(o,c);yt(p,a,n,s,r)&&ms(p,e,t,n,i,s,r)}}const lu=["x","y","z"];function cu(o,e,t,n,i,s){me.setBuffer(o._roots[e]);const r=gs(0,o,t,n,i,s);return me.clearBuffer(),r}function gs(o,e,t,n,i,s){const{float32Array:r,uint16Array:a,uint32Array:l}=me;let c=o*2;if(Se(c,a)){const d=Ue(o,l),m=Xe(c,a);return qh(e,t,n,d,m,i,s)}else{const d=ls(o,l),m=lu[d],f=n.direction[m]>=0;let u,g;f?(u=Pe(o),g=Te(o,l)):(u=Te(o,l),g=Pe(o));const v=yt(u,r,n,i,s)?gs(u,e,t,n,i,s):null;if(v){const M=v.point[m];if(f?M<=r[g+d]:M>=r[g+d+3])return v}const x=yt(g,r,n,i,s)?gs(g,e,t,n,i,s):null;return v&&x?v.distance<=x.distance?v:x:v||x||null}}const ui=new _.Box3,Jt=new Ge,Qt=new Ge,vn=new _.Matrix4,uo=new Ie,di=new Ie;function hu(o,e,t,n){me.setBuffer(o._roots[e]);const i=ys(0,o,t,n);return me.clearBuffer(),i}function ys(o,e,t,n,i=null){const{float32Array:s,uint16Array:r,uint32Array:a}=me;let l=o*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),uo.set(t.boundingBox.min,t.boundingBox.max,n),i=uo),Se(l,r)){const h=e.geometry,d=h.index,m=h.attributes.position,p=t.index,f=t.attributes.position,u=Ue(o,a),g=Xe(l,r);if(vn.copy(n).invert(),t.boundsTree)return ve(o,s,di),di.matrix.copy(vn),di.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:v=>di.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(n),v.b.applyMatrix4(n),v.c.applyMatrix4(n),v.needsUpdate=!0;for(let w=u,x=g+u;w<x;w++)if(be(Qt,3*e.resolveTriangleIndex(w),d,m),Qt.needsUpdate=!0,v.intersectsTriangle(Qt))return!0;return!1}});{const y=kt(t);for(let v=u,w=g+u;v<w;v++){const x=e.resolveTriangleIndex(v);be(Jt,3*x,d,m),Jt.a.applyMatrix4(vn),Jt.b.applyMatrix4(vn),Jt.c.applyMatrix4(vn),Jt.needsUpdate=!0;for(let M=0,T=y*3;M<T;M+=3)if(be(Qt,M,p,f),Qt.needsUpdate=!0,Jt.intersectsTriangle(Qt))return!0}}}else{const h=Pe(o),d=Te(o,a);return ve(h,s,ui),!!(i.intersectsBox(ui)&&ys(h,e,t,n,i)||(ve(d,s,ui),i.intersectsBox(ui)&&ys(d,e,t,n,i)))}}const fi=new _.Matrix4,vs=new Ie,wn=new Ie,uu=new _.Vector3,du=new _.Vector3,fu=new _.Vector3,pu=new _.Vector3;function mu(o,e,t,n={},i={},s=0,r=1/0){e.boundingBox||e.computeBoundingBox(),vs.set(e.boundingBox.min,e.boundingBox.max,t),vs.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,c=a.index,h=e.attributes.position,d=e.index,m=We.getPrimitive(),p=We.getPrimitive();let f=uu,u=du,g=null,y=null;i&&(g=fu,y=pu);let v=1/0,w=null,x=null;return fi.copy(t).invert(),wn.matrix.copy(fi),o.shapecast({boundsTraverseOrder:M=>vs.distanceToBox(M),intersectsBounds:(M,T,P)=>P<v&&P<r?(T&&(wn.min.copy(M.min),wn.max.copy(M.max),wn.needsUpdate=!0),!0):!1,intersectsRange:(M,T)=>{if(e.boundsTree){const P=e.boundsTree;return P.shapecast({boundsTraverseOrder:k=>wn.distanceToBox(k),intersectsBounds:(k,D,E)=>E<v&&E<r,intersectsRange:(k,D)=>{for(let E=k,O=k+D;E<O;E++){const A=P.resolveTriangleIndex(E);be(p,3*A,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let I=M,S=M+T;I<S;I++){const z=o.resolveTriangleIndex(I);be(m,3*z,c,l),m.needsUpdate=!0;const V=m.distanceToTriangle(p,f,g);if(V<v&&(u.copy(f),y&&y.copy(g),v=V,w=I,x=E),V<s)return!0}}}})}else{const P=kt(e);for(let k=0,D=P;k<D;k++){be(p,3*k,d,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let E=M,O=M+T;E<O;E++){const A=o.resolveTriangleIndex(E);be(m,3*A,c,l),m.needsUpdate=!0;const I=m.distanceToTriangle(p,f,g);if(I<v&&(u.copy(f),y&&y.copy(g),v=I,w=E,x=k),I<s)return!0}}}}}),We.releasePrimitive(m),We.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(u):n.point=u.clone(),n.distance=v,n.faceIndex=w,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(fi),u.applyMatrix4(fi),i.distance=u.sub(i.point).length(),i.faceIndex=x),n)}function gu(){return typeof SharedArrayBuffer<"u"}const xn=new me.constructor,pi=new me.constructor,vt=new as(()=>new _.Box3),en=new _.Box3,tn=new _.Box3,ws=new _.Box3,xs=new _.Box3;let bs=!1;function yu(o,e,t,n){if(bs)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");bs=!0;const i=o._roots,s=e._roots;let r,a=0,l=0;const c=new _.Matrix4().copy(t).invert();for(let h=0,d=i.length;h<d;h++){xn.setBuffer(i[h]),l=0;const m=vt.getPrimitive();ve(0,xn.float32Array,m),m.applyMatrix4(c);for(let p=0,f=s.length;p<f&&(pi.setBuffer(s[p]),r=Ke(0,0,t,c,n,a,l,0,0,m),pi.clearBuffer(),l+=s[p].byteLength/Le,!r);p++);if(vt.releasePrimitive(m),xn.clearBuffer(),a+=i[h].byteLength/Le,r)break}return bs=!1,r}function Ke(o,e,t,n,i,s=0,r=0,a=0,l=0,c=null,h=!1){let d,m;h?(d=pi,m=xn):(d=xn,m=pi);const p=d.float32Array,f=d.uint32Array,u=d.uint16Array,g=m.float32Array,y=m.uint32Array,v=m.uint16Array,w=o*2,x=e*2,M=Se(w,u),T=Se(x,v);let P=!1;if(T&&M)h?P=i(Ue(e,y),Xe(e*2,v),Ue(o,f),Xe(o*2,u),l,r+e/_e,a,s+o/_e):P=i(Ue(o,f),Xe(o*2,u),Ue(e,y),Xe(e*2,v),a,s+o/_e,l,r+e/_e);else if(T){const k=vt.getPrimitive();ve(e,g,k),k.applyMatrix4(t);const D=Pe(o),E=Te(o,f);ve(D,p,en),ve(E,p,tn);const O=k.intersectsBox(en),A=k.intersectsBox(tn);P=O&&Ke(e,D,n,t,i,r,s,l,a+1,k,!h)||A&&Ke(e,E,n,t,i,r,s,l,a+1,k,!h),vt.releasePrimitive(k)}else{const k=Pe(e),D=Te(e,y);ve(k,g,ws),ve(D,g,xs);const E=c.intersectsBox(ws),O=c.intersectsBox(xs);if(E&&O)P=Ke(o,k,t,n,i,s,r,a,l+1,c,h)||Ke(o,D,t,n,i,s,r,a,l+1,c,h);else if(E)if(M)P=Ke(o,k,t,n,i,s,r,a,l+1,c,h);else{const A=vt.getPrimitive();A.copy(ws).applyMatrix4(t);const I=Pe(o),S=Te(o,f);ve(I,p,en),ve(S,p,tn);const z=A.intersectsBox(en),V=A.intersectsBox(tn);P=z&&Ke(k,I,n,t,i,r,s,l,a+1,A,!h)||V&&Ke(k,S,n,t,i,r,s,l,a+1,A,!h),vt.releasePrimitive(A)}else if(O)if(M)P=Ke(o,D,t,n,i,s,r,a,l+1,c,h);else{const A=vt.getPrimitive();A.copy(xs).applyMatrix4(t);const I=Pe(o),S=Te(o,f);ve(I,p,en),ve(S,p,tn);const z=A.intersectsBox(en),V=A.intersectsBox(tn);P=z&&Ke(D,I,n,t,i,r,s,l,a+1,A,!h)||V&&Ke(D,S,n,t,i,r,s,l,a+1,A,!h),vt.releasePrimitive(A)}}return P}const mi=new Ie,fo=new _.Box3,vu={strategy:Zr,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Ms{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,r=n.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(a.roots=i.map(l=>l.slice()),a.index=r?r.array.slice():null,a.indirectBuffer=s?s.slice():null):(a.roots=i,a.index=r?r.array:null,a.indirectBuffer=s),a}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:r}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),l(s));const a=new Ms(t,{...n,[es]:!0});if(a._roots=s,a._indirectBuffer=r||null,n.setIndex){const c=t.getIndex();if(c===null){const h=new _.BufferAttribute(e.index,1,!1);t.setIndex(h)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return a;function l(c){for(let h=0;h<c.length;h++){const d=c[h],m=new Uint32Array(d),p=new Uint16Array(d);for(let f=0,u=d.byteLength/Le;f<u;f++){const g=_e*f,y=2*g;Se(y,p)||(m[g+6]=m[g+6]/_e-f)}}}}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...vu,[es]:!1},t),t.useSharedArrayBuffer&&!gu())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[es]||(zh(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new _.Box3))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}shiftTriangleOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const s=n[i],r=new Uint32Array(s),a=new Uint16Array(s),l=s.byteLength/Le;for(let c=0;c<l;c++){const h=_e*c,d=2*h;Se(d,a)&&(r[h+6]+=e)}}}}refit(e=null){return(this.indirect?ou:Yh)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);r(0);function r(a,l=0){const c=a*2,h=Se(c,s);if(h){const d=i[a+6],m=s[c+14];e(l,h,new Float32Array(n,a*4,6),d,m)}else{const d=Pe(a),m=Te(a,i),p=ls(a,i);e(l,h,new Float32Array(n,a*4,6),p)||(r(d,l+1),r(m,l+1))}}}raycast(e,t=_.FrontSide,n=0,i=1/0){const s=this._roots,r=[],a=this.indirect?au:Hh;for(let l=0,c=s.length;l<c;l++)a(this,l,t,e,r,n,i);return r}raycastFirst(e,t=_.FrontSide,n=0,i=1/0){const s=this._roots;let r=null;const a=this.indirect?cu:Qh;for(let l=0,c=s.length;l<c;l++){const h=a(this,l,t,e,n,i);h!=null&&(r==null||h.distance<r.distance)&&(r=h)}return r}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?hu:eu;for(let r=0,a=i.length;r<a&&(n=s(this,r,e,t),!n);r++);return n}shapecast(e){const t=We.getPrimitive(),n=this.indirect?$h:Zh;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:r,intersectsTriangle:a}=e;if(r&&a){const d=r;r=(m,p,f,u,g)=>d(m,p,f,u,g)?!0:n(m,p,this,a,f,u,t)}else r||(a?r=(d,m,p,f)=>n(d,m,this,a,p,f,t):r=(d,m,p)=>p);let l=!1,c=0;const h=this._roots;for(let d=0,m=h.length;d<m;d++){const p=h[d];if(l=Uh(this,d,s,r,i,c),l)break;c+=p.byteLength/Le}return We.releasePrimitive(t),l}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const r=We.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?f=>{const u=this.resolveTriangleIndex(f);be(r,u*3,a,l)}:f=>{be(r,f*3,a,l)},h=We.getPrimitive(),d=e.geometry.index,m=e.geometry.attributes.position,p=e.indirect?f=>{const u=e.resolveTriangleIndex(f);be(h,u*3,d,m)}:f=>{be(h,f*3,d,m)};if(s){const f=(u,g,y,v,w,x,M,T)=>{for(let P=y,k=y+v;P<k;P++){p(P),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let D=u,E=u+g;D<E;D++)if(c(D),r.needsUpdate=!0,s(r,h,D,P,w,x,M,T))return!0}return!1};if(i){const u=i;i=function(g,y,v,w,x,M,T,P){return u(g,y,v,w,x,M,T,P)?!0:f(g,y,v,w,x,M,T,P)}}else i=f}return yu(this,e,t,i)}intersectsBox(e,t){return mi.set(e.min,e.max,t),mi.needsUpdate=!0,this.shapecast({intersectsBounds:n=>mi.intersectsBox(n),intersectsTriangle:n=>mi.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,r=1/0){return(this.indirect?mu:ru)(this,e,t,n,i,s,r)}closestPointToPoint(e,t={},n=0,i=1/0){return Vh(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{ve(0,new Float32Array(n),fo),e.union(fo)}),e}}const po=1e-6,wu=po*.5,mo=Math.pow(10,-Math.log10(po)),xu=wu*mo;function tt(o){return~~(o*mo+xu)}function bu(o){return`${tt(o.x)},${tt(o.y)}`}function go(o){return`${tt(o.x)},${tt(o.y)},${tt(o.z)}`}function Mu(o){return`${tt(o.x)},${tt(o.y)},${tt(o.z)},${tt(o.w)}`}function _u(o,e,t){t.direction.subVectors(e,o).normalize();const n=o.dot(t.direction);return t.origin.copy(o).addScaledVector(t.direction,-n),t}function yo(){return typeof SharedArrayBuffer<"u"}function Su(o){if(o.buffer instanceof SharedArrayBuffer)return o;const e=o.constructor,t=o.buffer,n=new SharedArrayBuffer(t.byteLength),i=new Uint8Array(t);return new Uint8Array(n).set(i,0),new e(n)}function Cu(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}function Au(o,e){if(!o.index){const t=o.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Cu(t,n);o.setIndex(new _.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function Pu(o){return o.index?o.index.count:o.attributes.position.count}function _s(o){return Pu(o)/3}const Tu=1e-8,Du=new _.Vector3;function ku(o){return~~(o/3)}function Eu(o){return o%3}function vo(o,e){return o.start-e.start}function wo(o,e){return Du.subVectors(e,o.origin).dot(o.direction)}function Lu(o,e,t,n=Tu){o.sort(vo),e.sort(vo);for(let a=0;a<o.length;a++){const l=o[a];for(let c=0;c<e.length;c++){const h=e[c];if(!(h.start>l.end)){if(l.end<h.start||h.end<l.start)continue;if(l.start<=h.start&&l.end>=h.end)s(h.end,l.end)||o.splice(a+1,0,{start:h.end,end:l.end,index:l.index}),l.end=h.start,h.start=0,h.end=0;else if(l.start>=h.start&&l.end<=h.end)s(l.end,h.end)||e.splice(c+1,0,{start:l.end,end:h.end,index:h.index}),h.end=l.start,l.start=0,l.end=0;else if(l.start<=h.start&&l.end<=h.end){const d=l.end;l.end=h.start,h.start=d}else if(l.start>=h.start&&l.end>=h.end){const d=h.end;h.end=l.start,l.start=d}else throw new Error}if(t.has(l.index)||t.set(l.index,[]),t.has(h.index)||t.set(h.index,[]),t.get(l.index).push(h.index),t.get(h.index).push(l.index),r(h)&&(e.splice(c,1),c--),r(l)){o.splice(a,1),a--;break}}}i(o),i(e);function i(a){for(let l=0;l<a.length;l++)r(a[l])&&(a.splice(l,1),l--)}function s(a,l){return Math.abs(l-a)<n}function r(a){return Math.abs(a.end-a.start)<n}}const xo=1e-5,bo=1e-4;class Iu{constructor(){this._rays=[]}addRay(e){this._rays.push(e)}findClosestRay(e){const t=this._rays,n=e.clone();n.direction.multiplyScalar(-1);let i=1/0,s=null;for(let l=0,c=t.length;l<c;l++){const h=t[l];if(r(h,e)&&r(h,n))continue;const d=a(h,e),m=a(h,n),p=Math.min(d,m);p<i&&(i=p,s=h)}return s;function r(l,c){const h=l.origin.distanceTo(c.origin)>xo;return l.direction.angleTo(c.direction)>bo||h}function a(l,c){const h=l.origin.distanceTo(c.origin),d=l.direction.angleTo(c.direction);return h/xo+d/bo}}}const Ss=new _.Vector3,Cs=new _.Vector3,gi=new _.Ray;function zu(o,e,t){const n=o.attributes,i=o.index,s=n.position,r=new Map,a=new Map,l=Array.from(e),c=new Iu;for(let h=0,d=l.length;h<d;h++){const m=l[h],p=ku(m),f=Eu(m);let u=3*p+f,g=3*p+(f+1)%3;i&&(u=i.getX(u),g=i.getX(g)),Ss.fromBufferAttribute(s,u),Cs.fromBufferAttribute(s,g),_u(Ss,Cs,gi);let y,v=c.findClosestRay(gi);v===null&&(v=gi.clone(),c.addRay(v)),a.has(v)||a.set(v,{forward:[],reverse:[],ray:v}),y=a.get(v);let w=wo(v,Ss),x=wo(v,Cs);w>x&&([w,x]=[x,w]),gi.direction.dot(v.direction)<0?y.reverse.push({start:w,end:x,index:m}):y.forward.push({start:w,end:x,index:m})}return a.forEach(({forward:h,reverse:d},m)=>{Lu(h,d,r,t),h.length===0&&d.length===0&&a.delete(m)}),{disjointConnectivityMap:r,fragmentMap:a}}const Bu=new _.Vector2,As=new _.Vector3,Ou=new _.Vector4,Ps=["","",""];class Ru{constructor(e=null){this.data=null,this.disjointConnections=null,this.unmatchedDisjointEdges=null,this.unmatchedEdges=-1,this.matchedEdges=-1,this.useDrawRange=!0,this.useAllAttributes=!1,this.matchDisjointEdges=!1,this.degenerateEpsilon=1e-8,e&&this.updateFrom(e)}getSiblingTriangleIndex(e,t){const n=this.data[e*3+t];return n===-1?-1:~~(n/3)}getSiblingEdgeIndex(e,t){const n=this.data[e*3+t];return n===-1?-1:n%3}getDisjointSiblingTriangleIndices(e,t){const n=e*3+t,i=this.disjointConnections.get(n);return i?i.map(s=>~~(s/3)):[]}getDisjointSiblingEdgeIndices(e,t){const n=e*3+t,i=this.disjointConnections.get(n);return i?i.map(s=>s%3):[]}isFullyConnected(){return this.unmatchedEdges===0}updateFrom(e){const{useAllAttributes:t,useDrawRange:n,matchDisjointEdges:i,degenerateEpsilon:s}=this,r=t?w:v,a=new Map,{attributes:l}=e,c=t?Object.keys(l):null,h=e.index,d=l.position;let m=_s(e);const p=m;let f=0;n&&(f=e.drawRange.start,e.drawRange.count!==1/0&&(m=~~(e.drawRange.count/3)));let u=this.data;(!u||u.length<3*p)&&(u=new Int32Array(3*p)),u.fill(-1);let g=0,y=new Set;for(let x=f,M=m*3+f;x<M;x+=3){const T=x;for(let P=0;P<3;P++){let k=T+P;h&&(k=h.getX(k)),Ps[P]=r(k)}for(let P=0;P<3;P++){const k=(P+1)%3,D=Ps[P],E=Ps[k],O=`${E}_${D}`;if(a.has(O)){const A=T+P,I=a.get(O);u[A]=I,u[I]=A,a.delete(O),g+=2,y.delete(I)}else{const A=`${D}_${E}`,I=T+P;a.set(A,I),y.add(I)}}}if(i){const{fragmentMap:x,disjointConnectivityMap:M}=zu(e,y,s);y.clear(),x.forEach(({forward:T,reverse:P})=>{T.forEach(({index:k})=>y.add(k)),P.forEach(({index:k})=>y.add(k))}),this.unmatchedDisjointEdges=x,this.disjointConnections=M,g=m*3-y.size}this.matchedEdges=g,this.unmatchedEdges=y.size,this.data=u;function v(x){return As.fromBufferAttribute(d,x),go(As)}function w(x){let M="";for(let T=0,P=c.length;T<P;T++){const k=l[c[T]];let D;switch(k.itemSize){case 1:D=tt(k.getX(x));break;case 2:D=bu(Bu.fromBufferAttribute(k,x));break;case 3:D=go(As.fromBufferAttribute(k,x));break;case 4:D=Mu(Ou.fromBufferAttribute(k,x));break}M!==""&&(M+="|"),M+=D}return M}}}class yi extends _.Mesh{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new _.Matrix4,this._previousMatrix.elements.fill(0)}markUpdated(){this._previousMatrix.copy(this.matrix)}isDirty(){const{matrix:e,_previousMatrix:t}=this,n=e.elements,i=t.elements;for(let s=0;s<16;s++)if(n[s]!==i[s])return!0;return!1}prepareGeometry(){const e=this.geometry,t=e.attributes,n=yo();if(n)for(const i in t){const s=t[i];if(s.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");s.array=Su(s.array)}if(e.boundsTree||(Au(e,{useSharedArrayBuffer:n}),e.boundsTree=new Ms(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:n})),e.halfEdges||(e.halfEdges=new Ru(e)),!e.groupIndices){const i=_s(e),s=new Uint16Array(i),r=e.groups;for(let a=0,l=r.length;a<l;a++){const{start:c,count:h}=r[a];for(let d=c/3,m=(c+h)/3;d<m;d++)s[d]=a}e.groupIndices=s}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const Nu=1e-14,Ts=new _.Vector3,Mo=new _.Vector3,_o=new _.Vector3;function wt(o,e=Nu){Ts.subVectors(o.b,o.a),Mo.subVectors(o.c,o.a),_o.subVectors(o.b,o.c);const t=Ts.angleTo(Mo),n=Ts.angleTo(_o),i=Math.PI-t-n;return Math.abs(t)<e||Math.abs(n)<e||Math.abs(i)<e||o.a.distanceToSquared(o.b)<e||o.a.distanceToSquared(o.c)<e||o.b.distanceToSquared(o.c)<e}const Ds=1e-10,bn=1e-10,Fu=1e-10,ht=new _.Line3,we=new _.Line3,ut=new _.Vector3,ks=new _.Vector3,So=new _.Vector3,vi=new _.Plane,Es=new Ge;class Uu{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new _.Triangle),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class Vu{constructor(){this.trianglePool=new Uu,this.triangles=[],this.normal=new _.Vector3,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:n,normal:i}=this;if(Array.isArray(e))for(let s=0,r=e.length;s<r;s++){const a=e[s];if(s===0)a.getNormal(i);else if(Math.abs(1-a.getNormal(ut).dot(i))>Ds)throw new Error("Triangle Splitter: Cannot initialize with triangles that have different normals.");const l=n.getTriangle();l.copy(a),t.push(l)}else{e.getNormal(i);const s=n.getTriangle();s.copy(e),t.push(s)}}splitByTriangle(e){const{normal:t,triangles:n}=this;if(e.getNormal(ks).normalize(),Math.abs(1-Math.abs(ks.dot(t)))<Fu){this.coplanarTriangleUsed=!0;for(let s=0,r=n.length;s<r;s++){const a=n[s];a.coplanarCount=0}const i=[e.a,e.b,e.c];for(let s=0;s<3;s++){const r=(s+1)%3,a=i[s],l=i[r];ut.subVectors(l,a).normalize(),So.crossVectors(ks,ut),vi.setFromNormalAndCoplanarPoint(So,a),this.splitByPlane(vi,e)}}else e.getPlane(vi),this.splitByPlane(vi,e)}splitByPlane(e,t){const{triangles:n,trianglePool:i}=this;Es.copy(t),Es.needsUpdate=!0;for(let s=0,r=n.length;s<r;s++){const a=n[s];if(!Es.intersectsTriangle(a,ht,!0))continue;const{a:l,b:c,c:h}=a;let d=0,m=-1,p=!1,f=[],u=[];const g=[l,c,h];for(let y=0;y<3;y++){const v=(y+1)%3;ht.start.copy(g[y]),ht.end.copy(g[v]);const w=e.distanceToPoint(ht.start),x=e.distanceToPoint(ht.end);if(Math.abs(w)<bn&&Math.abs(x)<bn){p=!0;break}if(w>0?f.push(y):u.push(y),Math.abs(w)<bn)continue;let M=!!e.intersectLine(ht,ut);!M&&Math.abs(x)<bn&&(ut.copy(ht.end),M=!0),M&&!(ut.distanceTo(ht.start)<Ds)&&(ut.distanceTo(ht.end)<Ds&&(m=y),d===0?we.start.copy(ut):we.end.copy(ut),d++)}if(!p&&d===2&&we.distance()>bn)if(m!==-1){m=(m+1)%3;let y=0;y===m&&(y=(y+1)%3);let v=y+1;v===m&&(v=(v+1)%3);const w=i.getTriangle();w.a.copy(g[v]),w.b.copy(we.end),w.c.copy(we.start),wt(w)||n.push(w),a.a.copy(g[y]),a.b.copy(we.start),a.c.copy(we.end),wt(a)&&(n.splice(s,1),s--,r--)}else{const y=f.length>=2?u[0]:f[0];if(y===0){let T=we.start;we.start=we.end,we.end=T}const v=(y+1)%3,w=(y+2)%3,x=i.getTriangle(),M=i.getTriangle();g[v].distanceToSquared(we.start)<g[w].distanceToSquared(we.end)?(x.a.copy(g[v]),x.b.copy(we.start),x.c.copy(we.end),M.a.copy(g[v]),M.b.copy(g[w]),M.c.copy(we.start)):(x.a.copy(g[w]),x.b.copy(we.start),x.c.copy(we.end),M.a.copy(g[v]),M.b.copy(g[w]),M.c.copy(we.end)),a.a.copy(g[y]),a.b.copy(we.end),a.c.copy(we.start),wt(x)||n.push(x),wt(M)||n.push(M),wt(a)&&(n.splice(s,1),s--,r--)}else d===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}function ju(o){return o=~~o,o+4-o%4}class Co{constructor(e,t=500){this.expansionFactor=1.5,this.type=e,this.length=0,this.array=null,this.setSize(t)}setType(e){if(this.length!==0)throw new Error("TypeBackedArray: Cannot change the type while there is used data in the buffer.");const t=this.array.buffer;this.array=new e(t),this.type=e}setSize(e){if(this.array&&e===this.array.length)return;const t=this.type,n=yo()?SharedArrayBuffer:ArrayBuffer,i=new t(new n(ju(e*t.BYTES_PER_ELEMENT)));this.array&&i.set(this.array,0),this.array=i}expand(){const{array:e,expansionFactor:t}=this;this.setSize(e.length*t)}push(...e){let{array:t,length:n}=this;n+e.length>t.length&&(this.expand(),t=this.array);for(let i=0,s=e.length;i<s;i++)t[n+i]=e[i];this.length+=e.length}clear(){this.length=0}}class Gu{constructor(){this.groupAttributes=[{}],this.groupCount=0}getType(e){return this.groupAttributes[0][e].type}getItemSize(e){return this.groupAttributes[0][e].itemSize}getNormalized(e){return this.groupAttributes[0][e].normalized}getCount(e){if(this.groupCount<=e)return 0;const t=this.getGroupAttrArray("position",e);return t.length/t.itemSize}getTotalLength(e){const{groupCount:t,groupAttributes:n}=this;let i=0;for(let s=0;s<t;s++){const r=n[s];i+=r[e].length}return i}getGroupAttrSet(e=0){const{groupAttributes:t}=this;if(t[e])return this.groupCount=Math.max(this.groupCount,e+1),t[e];const n=t[0];for(this.groupCount=Math.max(this.groupCount,e+1);e>=t.length;){const i={};t.push(i);for(const s in n){const r=n[s],a=new Co(r.type);a.itemSize=r.itemSize,a.normalized=r.normalized,i[s]=a}}return t[e]}getGroupAttrArray(e,t=0){const{groupAttributes:n}=this;if(!n[0][e])throw new Error(`TypedAttributeData: Attribute with "${e}" has not been initialized`);return this.getGroupAttrSet(t)[e]}initializeArray(e,t,n,i){const{groupAttributes:s}=this,a=s[0][e];if(a){if(a.type!==t)for(let l=0,c=s.length;l<c;l++){const h=s[l][e];h.setType(t),h.itemSize=n,h.normalized=i}}else for(let l=0,c=s.length;l<c;l++){const h=new Co(t);h.itemSize=n,h.normalized=i,s[l][e]=h}}clear(){this.groupCount=0;const{groupAttributes:e}=this;e.forEach(t=>{for(const n in t)t[n].clear()})}delete(e){this.groupAttributes.forEach(t=>{delete t[e]})}reset(){this.groupAttributes=[],this.groupCount=0}}class Ao{constructor(){this.intersectionSet={},this.ids=[]}add(e,t){const{intersectionSet:n,ids:i}=this;n[e]||(n[e]=[],i.push(e)),n[e].push(t)}}const Wu=0,Xu=1,Zu=2,Po=3,Yu=4,To=5,Do=6,Ze=new _.Ray,ko=new _.Matrix4,ze=new _.Triangle,dt=new _.Vector3,Eo=new _.Vector4,Lo=new _.Vector4,Io=new _.Vector4,Ls=new _.Vector4,wi=new _.Vector4,xi=new _.Vector4,zo=new _.Line3,Is=new _.Vector3,zs=1e-8,Ku=1e-15,zt=-1,Bt=1,bi=-2,Mi=2,Mn=0,Ot=1,Bs=2,qu=1e-14;let _i=null;function Bo(o){_i=o}function Oo(o,e){o.getMidpoint(Ze.origin),o.getNormal(Ze.direction);const t=e.raycastFirst(Ze,_.DoubleSide);return!!(t&&Ze.direction.dot(t.face.normal)>0)?zt:Bt}function $u(o,e){function t(){return Math.random()-.5}o.getNormal(Is),Ze.direction.copy(Is),o.getMidpoint(Ze.origin);const n=3;let i=0,s=1/0;for(let r=0;r<n;r++){Ze.direction.x+=t()*zs,Ze.direction.y+=t()*zs,Ze.direction.z+=t()*zs,Ze.direction.multiplyScalar(-1);const a=e.raycastFirst(Ze,_.DoubleSide);if(!!(a&&Ze.direction.dot(a.face.normal)>0)&&i++,a!==null&&(s=Math.min(s,a.distance)),s<=Ku)return a.face.normal.dot(Is)>0?Mi:bi;if(i/n>.5||(r-i+1)/n>.5)break}return i/n>.5?zt:Bt}function Hu(o,e){const t=new Ao,n=new Ao;return ko.copy(o.matrixWorld).invert().multiply(e.matrixWorld),o.geometry.boundsTree.bvhcast(e.geometry.boundsTree,ko,{intersectsTriangles(i,s,r,a){if(!wt(i)&&!wt(s)){let l=i.intersectsTriangle(s,zo,!0);if(!l){const c=i.plane,h=s.plane,d=c.normal,m=h.normal;d.dot(m)===1&&Math.abs(c.constant-h.constant)<qu&&(l=!0)}if(l){let c=o.geometry.boundsTree.resolveTriangleIndex(r),h=e.geometry.boundsTree.resolveTriangleIndex(a);t.add(c,h),n.add(h,c),_i&&(_i.addEdge(zo),_i.addIntersectingTriangles(r,i,a,s))}}return!1}}),{aIntersections:t,bIntersections:n}}function Ju(o,e,t,n,i,s,r=!1){const a=t.attributes,l=t.index,c=o*3,h=l.getX(c+0),d=l.getX(c+1),m=l.getX(c+2);for(const p in s){const f=a[p],u=s[p];if(!(p in a))throw new Error(`CSG Operations: Attribute ${p} not available on geometry.`);const g=f.itemSize;p==="position"?(ze.a.fromBufferAttribute(f,h).applyMatrix4(n),ze.b.fromBufferAttribute(f,d).applyMatrix4(n),ze.c.fromBufferAttribute(f,m).applyMatrix4(n),Os(ze.a,ze.b,ze.c,e,3,u,r)):p==="normal"?(ze.a.fromBufferAttribute(f,h).applyNormalMatrix(i),ze.b.fromBufferAttribute(f,d).applyNormalMatrix(i),ze.c.fromBufferAttribute(f,m).applyNormalMatrix(i),r&&(ze.a.multiplyScalar(-1),ze.b.multiplyScalar(-1),ze.c.multiplyScalar(-1)),Os(ze.a,ze.b,ze.c,e,3,u,r,!0)):(Eo.fromBufferAttribute(f,h),Lo.fromBufferAttribute(f,d),Io.fromBufferAttribute(f,m),Os(Eo,Lo,Io,e,g,u,r))}}function Qu(o,e,t,n,i,s,r,a=!1){Rs(o,n,i,s,r,a),Rs(a?t:e,n,i,s,r,a),Rs(a?e:t,n,i,s,r,a)}function Ro(o,e,t=!1){switch(o){case Wu:if(e===Bt||e===Mi&&!t)return Ot;break;case Xu:if(t){if(e===zt)return Mn}else if(e===Bt||e===bi)return Ot;break;case Zu:if(t){if(e===Bt||e===bi)return Ot}else if(e===zt)return Mn;break;case Yu:if(e===zt)return Mn;if(e===Bt)return Ot;break;case Po:if(e===zt||e===Mi&&!t)return Ot;break;case To:if(!t&&(e===Bt||e===bi))return Ot;break;case Do:if(!t&&(e===zt||e===Mi))return Ot;break;default:throw new Error(`Unrecognized CSG operation enum "${o}".`)}return Bs}function Os(o,e,t,n,i,s,r=!1,a=!1){const l=c=>{s.push(c.x),i>1&&s.push(c.y),i>2&&s.push(c.z),i>3&&s.push(c.w)};Ls.set(0,0,0,0).addScaledVector(o,n.a.x).addScaledVector(e,n.a.y).addScaledVector(t,n.a.z),wi.set(0,0,0,0).addScaledVector(o,n.b.x).addScaledVector(e,n.b.y).addScaledVector(t,n.b.z),xi.set(0,0,0,0).addScaledVector(o,n.c.x).addScaledVector(e,n.c.y).addScaledVector(t,n.c.z),a&&(Ls.normalize(),wi.normalize(),xi.normalize()),l(Ls),r?(l(xi),l(wi)):(l(wi),l(xi))}function Rs(o,e,t,n,i,s=!1){for(const r in i){const a=e[r],l=i[r];if(!(r in e))throw new Error(`CSG Operations: Attribute ${r} no available on geometry.`);const c=a.itemSize;r==="position"?(dt.fromBufferAttribute(a,o).applyMatrix4(t),l.push(dt.x,dt.y,dt.z)):r==="normal"?(dt.fromBufferAttribute(a,o).applyNormalMatrix(n),s&&dt.multiplyScalar(-1),l.push(dt.x,dt.y,dt.z)):(l.push(a.getX(o)),c>1&&l.push(a.getY(o)),c>2&&l.push(a.getZ(o)),c>3&&l.push(a.getW(o)))}}class ed{constructor(e){this.triangle=new _.Triangle().copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=new _.Triangle().copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const n in t)e.push(t[n]);return e}}class No{constructor(){this.data={}}addTriangleIntersection(e,t,n,i){const{data:s}=this;s[e]||(s[e]=new ed(t)),s[e].addTriangle(n,i)}getTrianglesAsArray(e=null){const{data:t}=this,n=[];if(e!==null)e in t&&n.push(t[e].triangle);else for(const i in t)n.push(t[i].triangle);return n}getTriangleIndices(){return Object.keys(this.data).map(e=>parseInt(e))}getIntersectionIndices(e){const{data:t}=this;return t[e]?Object.keys(t[e].intersects).map(n=>parseInt(n)):[]}getIntersectionsAsArray(e=null,t=null){const{data:n}=this,i=new Set,s=[],r=a=>{if(n[a])if(t!==null)n[a].intersects[t]&&s.push(n[a].intersects[t]);else{const l=n[a].intersects;for(const c in l)i.has(c)||(i.add(c),s.push(l[c]))}};if(e!==null)r(e);else for(const a in n)r(a);return s}reset(){this.data={}}}class td{constructor(){this.enabled=!1,this.triangleIntersectsA=new No,this.triangleIntersectsB=new No,this.intersectionEdges=[]}addIntersectingTriangles(e,t,n,i){const{triangleIntersectsA:s,triangleIntersectsB:r}=this;s.addTriangleIntersection(e,t,n,i),r.addTriangleIntersection(n,i,e,t)}addEdge(e){this.intersectionEdges.push(e.clone())}reset(){this.triangleIntersectsA.reset(),this.triangleIntersectsB.reset(),this.intersectionEdges=[]}init(){this.enabled&&(this.reset(),Bo(this))}complete(){this.enabled&&Bo(null)}}const xt=new _.Matrix4,Si=new _.Matrix3,Rt=new _.Triangle,Ci=new _.Triangle,bt=new _.Triangle,Ai=new _.Triangle,qe=[],Nt=[];function nd(o){for(const e of o)return e}function id(o,e,t,n,i,s={}){const{useGroups:r=!0}=s,{aIntersections:a,bIntersections:l}=Hu(o,e),c=[];let h=null,d;return d=r?0:-1,Fo(o,e,a,t,!1,n,i,d),Uo(o,e,a,t,!1,i,d),t.findIndex(p=>p!==Do&&p!==To)!==-1&&(d=r?o.geometry.groups.length||1:-1,Fo(e,o,l,t,!0,n,i,d),Uo(e,o,l,t,!0,i,d)),qe.length=0,Nt.length=0,{groups:c,materials:h}}function Fo(o,e,t,n,i,s,r,a=0){const l=o.matrixWorld.determinant()<0;xt.copy(e.matrixWorld).invert().multiply(o.matrixWorld),Si.getNormalMatrix(o.matrixWorld).multiplyScalar(l?-1:1);const c=o.geometry.groupIndices,h=o.geometry.index,d=o.geometry.attributes.position,m=e.geometry.boundsTree,p=e.geometry.index,f=e.geometry.attributes.position,u=t.ids,g=t.intersectionSet;for(let y=0,v=u.length;y<v;y++){const w=u[y],x=a===-1?0:c[w]+a,M=3*w,T=h.getX(M+0),P=h.getX(M+1),k=h.getX(M+2);Rt.a.fromBufferAttribute(d,T).applyMatrix4(xt),Rt.b.fromBufferAttribute(d,P).applyMatrix4(xt),Rt.c.fromBufferAttribute(d,k).applyMatrix4(xt),s.reset(),s.initialize(Rt);const D=g[w];for(let O=0,A=D.length;O<A;O++){const I=3*D[O],S=p.getX(I+0),z=p.getX(I+1),V=p.getX(I+2);Ci.a.fromBufferAttribute(f,S),Ci.b.fromBufferAttribute(f,z),Ci.c.fromBufferAttribute(f,V),s.splitByTriangle(Ci)}const E=s.triangles;for(let O=0,A=E.length;O<A;O++){const I=E[O],S=s.coplanarTriangleUsed?$u(I,m):Oo(I,m);qe.length=0,Nt.length=0;for(let z=0,V=n.length;z<V;z++){const U=Ro(n[z],S,i);U!==Bs&&(Nt.push(U),qe.push(r[z].getGroupAttrSet(x)))}if(qe.length!==0){Rt.getBarycoord(I.a,Ai.a),Rt.getBarycoord(I.b,Ai.b),Rt.getBarycoord(I.c,Ai.c);for(let z=0,V=qe.length;z<V;z++){const U=qe[z],G=Nt[z]===Mn;Ju(w,Ai,o.geometry,o.matrixWorld,Si,U,l!==G)}}}}return u.length}function Uo(o,e,t,n,i,s,r=0){const a=o.matrixWorld.determinant()<0;xt.copy(e.matrixWorld).invert().multiply(o.matrixWorld),Si.getNormalMatrix(o.matrixWorld).multiplyScalar(a?-1:1);const l=e.geometry.boundsTree,c=o.geometry.groupIndices,h=o.geometry.index,d=o.geometry.attributes,m=d.position,p=[],f=o.geometry.halfEdges,u=new Set,g=_s(o.geometry);for(let y=0,v=g;y<v;y++)y in t.intersectionSet||u.add(y);for(;u.size>0;){const y=nd(u);u.delete(y),p.push(y);const v=3*y,w=h.getX(v+0),x=h.getX(v+1),M=h.getX(v+2);bt.a.fromBufferAttribute(m,w).applyMatrix4(xt),bt.b.fromBufferAttribute(m,x).applyMatrix4(xt),bt.c.fromBufferAttribute(m,M).applyMatrix4(xt);const T=Oo(bt,l);Nt.length=0,qe.length=0;for(let P=0,k=n.length;P<k;P++){const D=Ro(n[P],T,i);D!==Bs&&(Nt.push(D),qe.push(s[P]))}for(;p.length>0;){const P=p.pop();for(let k=0;k<3;k++){const D=f.getSiblingTriangleIndex(P,k);D!==-1&&u.has(D)&&(p.push(D),u.delete(D))}if(qe.length!==0){const k=3*P,D=h.getX(k+0),E=h.getX(k+1),O=h.getX(k+2),A=r===-1?0:c[P]+r;if(bt.a.fromBufferAttribute(m,D),bt.b.fromBufferAttribute(m,E),bt.c.fromBufferAttribute(m,O),!wt(bt))for(let I=0,S=qe.length;I<S;I++){const z=Nt[I],V=qe[I].getGroupAttrSet(A),U=z===Mn;Qu(D,E,O,d,o.matrixWorld,Si,V,U!==a)}}}}}function sd(o){for(let e=0;e<o.length-1;e++){const t=o[e],n=o[e+1];if(t.materialIndex===n.materialIndex){const i=t.start,s=n.start+n.count;n.start=i,n.count=s-i,o.splice(e,1),e--}}}function rd(o,e,t,n){t.clear();const i=o.attributes;for(let s=0,r=n.length;s<r;s++){const a=n[s],l=i[a];t.initializeArray(a,l.array.constructor,l.itemSize,l.normalized)}for(const s in t.attributes)n.includes(s)||t.delete(s);for(const s in e.attributes)n.includes(s)||(e.deleteAttribute(s),e.dispose())}function od(o,e,t){let n=!1,i=-1;const s=o.attributes,r=e.groupAttributes[0];for(const l in r){const c=e.getTotalLength(l),h=e.getType(l),d=e.getItemSize(l),m=e.getNormalized(l);let p=s[l];(!p||p.array.length<c)&&(p=new _.BufferAttribute(new h(c),d,m),o.setAttribute(l,p),n=!0);let f=0;for(let u=0,g=Math.min(t.length,e.groupCount);u<g;u++){const y=t[u].index,{array:v,type:w,length:x}=e.groupAttributes[y][l],M=new w(v.buffer,0,x);p.array.set(M,f),f+=M.length}p.needsUpdate=!0,i=c/p.itemSize}if(o.index){const l=o.index.array;if(l.length<i)o.index=null,n=!0;else for(let c=0,h=l.length;c<h;c++)l[c]=c}let a=0;o.clearGroups();for(let l=0,c=Math.min(t.length,e.groupCount);l<c;l++){const{index:h,materialIndex:d}=t[l],m=e.getCount(h);m!==0&&(o.addGroup(a,m,d),a+=m)}o.setDrawRange(0,i),o.boundsTree=null,n&&o.dispose()}function Vo(o,e){let t=e;return Array.isArray(e)||(t=[],o.forEach(n=>{t[n.materialIndex]=e})),t}class ad{constructor(){this.triangleSplitter=new Vu,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new td}getGroupRanges(e){return!this.useGroups||e.groups.length===0?[{start:0,count:1/0,materialIndex:0}]:e.groups.map(t=>({...t}))}evaluate(e,t,n,i=new yi){let s=!0;if(Array.isArray(n)||(n=[n]),Array.isArray(i)||(i=[i],s=!1),i.length!==n.length)throw new Error("Evaluator: operations and target array passed as different sizes.");e.prepareGeometry(),t.prepareGeometry();const{triangleSplitter:r,attributeData:a,attributes:l,useGroups:c,consolidateGroups:h,debug:d}=this;for(;a.length<i.length;)a.push(new Gu);i.forEach((y,v)=>{rd(e.geometry,y.geometry,a[v],l)}),d.init(),id(e,t,n,r,a,{useGroups:c}),d.complete();const m=this.getGroupRanges(e.geometry),p=Vo(m,e.material),f=this.getGroupRanges(t.geometry),u=Vo(f,t.material);f.forEach(y=>y.materialIndex+=p.length);let g=[...m,...f].map((y,v)=>({...y,index:v}));if(c){const y=[...p,...u];h&&(g=g.map(w=>{const x=y[w.materialIndex];return w.materialIndex=y.indexOf(x),w}).sort((w,x)=>w.materialIndex-x.materialIndex));const v=[];for(let w=0,x=y.length;w<x;w++){let M=!1;for(let T=0,P=g.length;T<P;T++){const k=g[T];k.materialIndex===w&&(M=!0,k.materialIndex=v.length)}M&&v.push(y[w])}i.forEach(w=>{w.material=v})}else g=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach(y=>{y.material=p[0]});return i.forEach((y,v)=>{const w=y.geometry;od(w,a[v],g),h&&sd(w.groups)}),s?i:i[0]}evaluateHierarchy(e,t=new yi){e.updateMatrixWorld(!0);const n=(s,r)=>{const a=s.children;for(let l=0,c=a.length;l<c;l++){const h=a[l];h.isOperationGroup?n(h,r):r(h)}},i=s=>{const r=s.children;let a=!1;for(let c=0,h=r.length;c<h;c++){const d=r[c];a=i(d)||a}const l=s.isDirty();if(l&&s.markUpdated(),a&&!s.isOperationGroup){let c;return n(s,h=>{c?c=this.evaluate(c,h,h.operation):c=this.evaluate(s,h,h.operation)}),s._cachedGeometry=c.geometry,s._cachedMaterials=c.material,!0}else return a||l};return i(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}class ld{engine;planeObjects=[];planes=[];isActive=!1;evaluator;geometryCache=new Map;sectionMeshes=new Map;planeGroup;planeSize=1e3;sourceMeshes=new Map;planeThickness=.01;updateThrottleTime=100;lastUpdateTime=0;pendingUpdate=!1;updateTimer=null;cacheExpireTime=3e4;planeStates=new Map;constructor(e,t={}){this.engine=e,this.evaluator=new ad,this.planeGroup=new b.Group,this.planeGroup.name="CSG_ClippingPlanes_Optimized",t.updateThrottleTime!==void 0&&(this.updateThrottleTime=t.updateThrottleTime),t.cacheExpireTime!==void 0&&(this.cacheExpireTime=t.cacheExpireTime),t.planeThickness!==void 0&&(this.planeThickness=t.planeThickness),this.evaluator.attributes=["position","normal"],this.evaluator.useGroups=!1}init(){this.calculateSceneSize(),this.engine.scene.add(this.planeGroup),this.planes.forEach((e,t)=>{const n=this.createEmptySectionMesh(e,t);this.planeGroup.add(n),this.sectionMeshes.set(`plane_${t}`,n),this.planeObjects.push(n),this.planeStates.set(t,{constant:e.constant,normal:e.normal.clone()})})}createEmptySectionMesh(e,t){const n=new b.BufferGeometry,i=new b.MeshStandardMaterial({color:new b.Color(33023),metalness:.1,roughness:.75,side:b.DoubleSide,depthWrite:!0,depthTest:!0,clippingPlanes:this.planes.filter((r,a)=>a!==t)}),s=new b.Mesh(n,i);return s.name=`CSG_Section_Optimized_${t}`,s.visible=!1,s.renderOrder=t+1,s}active(){this.isActive=!0,this.requestUpdate(),this.planeObjects.forEach(e=>{e.visible=!0})}disActive(){this.isActive=!1,this.planeObjects.forEach(e=>{e.visible=!1}),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null)}setSourceMeshes(e){this.sourceMeshes.clear(),e.forEach(t=>{const n=t.uuid;this.sourceMeshes.set(n,t)}),this.isActive&&this.requestUpdate()}addSourceMesh(e){const t=e.uuid;this.sourceMeshes.has(t)||(this.sourceMeshes.set(t,e),this.isActive&&this.requestUpdate())}removeSourceMesh(e){const t=e.uuid;this.sourceMeshes.delete(t)&&(this.clearMeshCache(t),this.isActive&&this.requestUpdate())}requestUpdate(){if(!this.isActive)return;const e=Date.now(),t=e-this.lastUpdateTime;t>=this.updateThrottleTime?(this.lastUpdateTime=e,this.pendingUpdate=!1):(this.pendingUpdate=!0,this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.pendingUpdate&&this.isActive&&(this.lastUpdateTime=Date.now(),this.pendingUpdate=!1),this.updateTimer=null},this.updateThrottleTime-t))}updateAllSections(){this.isActive&&(this.planes.forEach((e,t)=>{if(Math.abs(e.constant)<99999)this.hasPlaneChanged(t,e)&&(this.updateSection(e,t),this.updatePlaneState(t,e));else{const n=this.sectionMeshes.get(`plane_${t}`);n&&(n.visible=!1)}}),this.cleanExpiredCache())}hasPlaneChanged(e,t){const n=this.planeStates.get(e);if(!n)return!0;const i=Math.abs(n.constant-t.constant)>1e-4,s=!n.normal.equals(t.normal);return i||s}updatePlaneState(e,t){this.planeStates.set(e,{constant:t.constant,normal:t.normal.clone()})}getPlaneHash(e){const t=e.normal,n=e.constant;return`${t.x.toFixed(4)}_${t.y.toFixed(4)}_${t.z.toFixed(4)}_${n.toFixed(4)}`}getCacheKey(e,t){return`${e}_plane_${t}`}updateSection(e,t){const n=this.sectionMeshes.get(`plane_${t}`);if(!n)return;const i=this.getPlaneHash(e),s=[];if(this.sourceMeshes.forEach((r,a)=>{const l=this.getCacheKey(a,t),c=this.geometryCache.get(l);if(c&&c.planeHash===i)s.push(c.geometry.clone()),c.timestamp=Date.now();else try{const h=this.createPlaneBrush(e),d=new yi(r.geometry);r.updateMatrixWorld(!0),d.matrix.copy(r.matrixWorld),d.updateMatrixWorld();const m=this.evaluator.evaluate(h,d,Po);m&&m.geometry.attributes.position.count>0?(s.push(m.geometry),this.geometryCache.set(l,{geometry:m.geometry.clone(),planeHash:i,timestamp:Date.now()})):this.geometryCache.delete(l)}catch(h){console.warn(`CSG intersection failed for mesh ${a}:`,h)}}),s.length>0){const r=this.mergeGeometries(s);n.geometry&&n.geometry.dispose(),n.geometry=r,n.visible=!0,n.position.set(0,0,0),n.rotation.set(0,0,0),n.scale.set(1,1,1),n.updateMatrixWorld()}else n.visible=!1;s.forEach(r=>r.dispose())}clearMeshCache(e){const t=[];this.geometryCache.forEach((n,i)=>{i.startsWith(e)&&(n.geometry.dispose(),t.push(i))}),t.forEach(n=>this.geometryCache.delete(n))}cleanExpiredCache(){const e=Date.now(),t=[];this.geometryCache.forEach((n,i)=>{e-n.timestamp>this.cacheExpireTime&&(n.geometry.dispose(),t.push(i))}),t.forEach(n=>this.geometryCache.delete(n))}clearAllCache(){this.geometryCache.forEach(e=>{e.geometry.dispose()}),this.geometryCache.clear()}createPlaneBrush(e){const t=new b.BoxGeometry(this.planeSize,this.planeThickness,this.planeSize);t.translate(0,e.constant,0),t.applyQuaternion(new b.Quaternion().setFromUnitVectors(new b.Vector3(0,-1,0),e.normal));const n=new b.Mesh(t),i=new yi(t);return i.matrix.copy(n.matrixWorld),i.updateMatrixWorld(),i}mergeGeometries(e){if(e.length===1)return e[0].clone();const t=new b.BufferGeometry,n=[],i=[],s=[];let r=0;return e.forEach(a=>{const l=a.attributes.position,c=a.attributes.normal;for(let h=0;h<l.count;h++)n.push(l.getX(h),l.getY(h),l.getZ(h));if(c)for(let h=0;h<c.count;h++)i.push(c.getX(h),c.getY(h),c.getZ(h));if(a.index)for(let h=0;h<a.index.count;h++)s.push(a.index.getX(h)+r);r+=l.count}),t.setAttribute("position",new b.Float32BufferAttribute(n,3)),i.length>0?t.setAttribute("normal",new b.Float32BufferAttribute(i,3)):t.computeVertexNormals(),s.length>0&&t.setIndex(s),t}calculateSceneSize(){const e=new b.Box3;if(this.engine.scene.traverse(t=>{if(t.isMesh&&t.geometry){const n=new b.Box3().setFromObject(t);e.union(n)}}),e.isEmpty())this.planeSize=1e3;else{const t=e.getSize(new b.Vector3),n=Math.max(t.x,t.y,t.z);this.planeSize=n*3}}update(){this.isActive&&this.pendingUpdate&&!this.updateTimer&&this.requestUpdate()}dispose(){this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null),this.clearAllCache(),this.planeObjects.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}),this.sectionMeshes.clear(),this.planeObjects=[],this.sourceMeshes.clear(),this.planeGroup.parent&&this.planeGroup.parent.remove(this.planeGroup)}setSectionColor(e){this.planeObjects.forEach(t=>{t.material instanceof b.MeshStandardMaterial&&t.material.color.set(e)})}getCacheStats(){return{cacheSize:this.geometryCache.size,sourceMeshCount:this.sourceMeshes.size,sectionMeshCount:this.sectionMeshes.size}}setPlaneThickness(e){if(e<=0){console.warn("Plane thickness must be positive");return}this.planeThickness=e,this.clearAllCache(),this.isActive&&this.requestUpdate()}getPlaneThickness(){return this.planeThickness}showSections(){this.sectionMeshes.forEach(e=>{e.geometry?.attributes.position?.count&&e.geometry.attributes.position.count>0&&(e.visible=!0)})}hideSections(){this.sectionMeshes.forEach(e=>{e.visible=!1})}showSection(){this.planeGroup.visible=!0}hideSection(){this.planeGroup.visible=!1}toggleSectionsVisibility(){let e=!1;return this.sectionMeshes.forEach(t=>{t.visible&&(e=!0)}),e?(this.hideSections(),!1):(this.showSections(),!0)}toggleSectionVisibility(e){const t=this.sectionMeshes.get(`plane_${e}`);return t?(t.visible=!t.visible,t.visible):!1}}class cd{engine;isActive=!1;box;pickPoint;pickNormal;pickMesh;box_;plane;meshs;isDrag=!1;maxBox;csgClipping=null;useCsgClipping=!1;constructor(e,t){this.engine=e,this.meshs=[],t?.useCsgClipping!==void 0&&(this.useCsgClipping=t.useCsgClipping),this.useCsgClipping&&this.initCsgClipping()}initCsgClipping(){this.csgClipping=new ld(this.engine,{updateThrottleTime:150,cacheExpireTime:45e3}),this.csgClipping.planes=this.engine.sectionPlane,this.csgClipping.init()}active(){this.isActive||(this.engine.handelBehaved.init(this),this.engine.handelBehaved.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0,this.init())}disActive(){this.init(),this.isActive=!1,this.engine.handelBehaved.disActive(),this.csgClipping&&this.csgClipping.disActive(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})}),this.engine.interactionModule.init(),this.engine.interactionModule.active()}disabled(){this.isActive=!1,this.engine.handelBehaved.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!1)})})}recover(){this.isActive||(this.engine.handelBehaved.init(this),this.engine.handelBehaved.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")||(t.visible=!0)})}),this.isActive=!0)}init(){let e=this.engine.octreeBox.getBoundingBox();this.maxBox=JSON.parse(JSON.stringify(e)),this.box=e,this.updata_face(e)}getboxXyz(){return{minX:this.box.min.x,minY:this.box.min.y,minZ:this.box.min.z,maxX:this.box.max.x,maxY:this.box.max.y,maxZ:this.box.max.z}}setboxXyz(e){this.box.min.x=e.minX,this.box.min.y=e.minY,this.box.min.z=e.minZ,this.box.max.x=e.maxX,this.box.max.y=e.maxY,this.box.max.z=e.maxZ,this.updata_face(this.box)}setBox(e){this.box=e,this.updata_face(e)}reverseBox(){}handleMouseDown(e){this.isDrag=!0;const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0)if(this.pickPoint=t[0].point,this.pickNormal=t[0].face.normal,this.engine.controls.enabled=!1,this.pickMesh=t[0].object,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.pickNormal.y==0){const n=new b.Plane;n.setFromNormalAndCoplanarPoint(new b.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new b.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new b.Plane;i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=i}}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.engine.controls.enabled=!0,this.csgClipping&&this.isActive}handleMouseMove(e){this.meshs.forEach(n=>{n.material.opacity=0});const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=.05),this.pickPoint!=null){const n=new b.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,n)){let i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());this.pickMesh.name=="前"||this.pickMesh.name=="左"||this.pickMesh.name=="底"?this.box.min=this.box_.min.clone().add(this.pickNormal.clone().setLength(i)):this.box.max=this.box_.max.clone().add(this.pickNormal.clone().setLength(i)),this.updata_face(this.box),this.calculate_ratio()}}}calculate_ratio(){let e=this.maxBox.max.x-this.maxBox.min.x,t=this.maxBox.max.y-this.maxBox.min.y,n=this.maxBox.max.z-this.maxBox.min.z,i=(this.box.min.x-this.maxBox.min.x)/e*100,s=(this.box.max.x-this.maxBox.min.x)/e*100,r=(this.box.min.y-this.maxBox.min.y)/t*100,a=(this.box.max.y-this.maxBox.min.y)/t*100,l=(this.box.min.z-this.maxBox.min.z)/n*100,c=(this.box.max.z-this.maxBox.min.z)/n*100;i<0&&(i=0),s<0&&(s=0),r<0&&(r=0),a<0&&(a=0),l<0&&(l=0),c<0&&(c=0),i>100&&(i=100),s>100&&(s=100),r>100&&(r=100),a>100&&(a=100),l>100&&(l=100),c>100&&(c=100);let h={x:{min:i,max:s},y:{min:r,max:a},z:{min:l,max:c}};this.engine.events.trigger(Me.SectionMove,h)}updata_face(e){let t=this,n=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.min.x,e.max.y,e.min.z)],i=[new b.Vector3(e.min.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.max.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.max.z)],s=[new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.max.z)],r=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.min.x,e.min.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.min.z)],a=[new b.Vector3(e.min.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.min.z),new b.Vector3(e.max.x,e.max.y,e.max.z),new b.Vector3(e.min.x,e.max.y,e.max.z)],l=[new b.Vector3(e.min.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.min.z),new b.Vector3(e.max.x,e.min.y,e.max.z),new b.Vector3(e.min.x,e.min.y,e.max.z)];c(n,new b.Vector3(0,0,-1),"前"),c(i,new b.Vector3(0,0,1),"后"),c(s,new b.Vector3(1,0,0),"右"),c(r,new b.Vector3(-1,0,0),"左"),c(a,new b.Vector3(0,1,0),"顶"),c(l,new b.Vector3(0,-1,0),"底");function c(h,d,m){const p=new b.BufferGeometry,f=new Float32Array([h[0].x,h[0].y,h[0].z,h[1].x,h[1].y,h[1].z,h[2].x,h[2].y,h[2].z,h[3].x,h[3].y,h[3].z]),u=[0,1,2,0,2,3];p.setAttribute("position",new b.BufferAttribute(f,3)),p.setIndex(u);let g=t.engine.scene.children.find(T=>T.type=="Group"&&T.name=="ClippingBox");g==null&&(g=new b.Group,g.name="ClippingBox",t.engine.scene.add(g));let y=t.meshs.find(T=>T.name==m);if(y==null){const T=new b.MeshBasicMaterial({color:65280,transparent:!0,opacity:0,side:b.DoubleSide});T.polygonOffset=!0,T.polygonOffsetFactor=1,T.polygonOffsetUnits=4;const P=new b.Mesh(p,T);P.normal=d,P.name=m,g.add(P),t.meshs.push(P)}else y.geometry=p;const v=new Float32Array([h[0].x,h[0].y,h[0].z,h[1].x,h[1].y,h[1].z,h[2].x,h[2].y,h[2].z,h[3].x,h[3].y,h[3].z,h[0].x,h[0].y,h[0].z]);let w=new b.LineBasicMaterial({color:255}),x=new b.BufferGeometry;x.setAttribute("position",new b.BufferAttribute(v,3));let M=t.meshs.find(T=>T.name==m+"Line");M==null&&(M=new b.Line(x,w),M.name=m+"Line",g.add(M),t.meshs.push(M)),M.geometry=x,M.material=w,m=="前"||m=="左"||m=="底"?t.engine.sectionPlane.find(T=>T.name==m).setFromNormalAndCoplanarPoint(d.clone().setLength(-1),e.min):t.engine.sectionPlane.find(T=>T.name==m).setFromNormalAndCoplanarPoint(d.clone().setLength(-1),e.max),t.engine.scene.children.filter(T=>T.type=="Mesh"&&T.url).forEach(T=>{T.material&&Array.isArray(T.material)?T.material.forEach(P=>{P.clippingPlanes=t.engine.sectionPlane}):T.material.clippingPlanes=t.engine.sectionPlane})}}}class hd{engine;isActive=!1;isDrag=!1;meshs=[];box;pickPoint;pickNormal;pickMesh;box_;plane;angleX=0;angleY=0;angleZ=0;direction=1;normal=new b.Vector3(0,0,1);distance=0;center=null;current_center=null;constructor(e){this.engine=e,this.meshs=[],this.box=null}active(){if(this.isActive==!0)return;this.isActive=!0,this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(n=>{n.name.includes("face")&&(n.visible=!0)})}),this.engine.handelBehaved.init(this),this.engine.handelBehaved.active();let e=this;e.engine.scene.children.filter(t=>t.type=="Mesh"&&t.url).forEach(t=>{t.material&&Array.isArray(t.material)?t.material.forEach(n=>{n.clippingPlanes=e.engine.sectionPlane}):t.material.clippingPlanes=e.engine.sectionPlane,e.engine.clipping.clippingStencil?.addMesh(e.engine.sectionPlane.find(n=>n.name=="face"),t)}),this.init()}disActive(){this.init(),this.isActive=!1,this.engine.handelBehaved.disActive();const e=this.engine.sectionPlane.find(t=>t.name=="face");e&&(e.constant=1e5),this.engine.scene.children.filter(t=>t.type=="Group"&&t.name=="ClippingBox").forEach(t=>{t.children.forEach(n=>{n.name.includes("face")&&(n.visible=!1)})})}init(){let e=this.engine.octreeBox.getBoundingBox();this.box=e,this.updata_face(0)}disabled(){this.isActive=!1,this.engine.handelBehaved.disActive(),this.engine.interactionModule.init(),this.engine.interactionModule.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!1)})})}recover(){this.isActive||(this.engine.handelBehaved.init(this),this.engine.handelBehaved.active(),this.engine.scene.children.filter(e=>e.type=="Group"&&e.name=="ClippingBox").forEach(e=>{e.children.forEach(t=>{t.name.includes("face")&&(t.visible=!0)})}),this.isActive=!0)}setFaceAngle(e,t,n){this.angleX=e,this.angleY=t,this.angleZ=n,this.normal=new b.Vector3(0,1,0).applyAxisAngle(new b.Vector3(1,0,0),e).applyAxisAngle(new b.Vector3(0,0,1),t).applyAxisAngle(new b.Vector3(0,1,0),n),this.normal.normalize(),this.updata_face(0)}setFaceNormal(e,t=0){this.normal=e,this.distance=t,this.updata_face(t)}reverse(){this.direction=this.direction*-1,this.updata_face(this.distance)}getFaceAngle(){return{angleX:this.angleX,angleY:this.angleY,angleZ:this.angleZ,direction:this.direction}}updata_face(e){let t=this,n=t.engine.scene.children.find(D=>D.type=="Group"&&D.name=="ClippingBox");n==null&&(n=new b.Group,n.name="ClippingBox",t.engine.scene.add(n));let i=new b.Vector3(1,0,0),s=new b.Vector3(0,1,0),r=new b.Vector3(0,0,1),a,l,c=this.normal.clone().normalize(),h=Math.abs(c.dot(i)),d=Math.abs(c.dot(s)),m=Math.abs(c.dot(r));h<=d&&h<=m?a=i:d<=h&&d<=m?a=s:a=r,a=a.clone().sub(c.clone().multiplyScalar(a.dot(c))).normalize(),l=new b.Vector3().crossVectors(c,a).normalize();let p=null;this.center==null?(p=new b.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2),this.center=p.clone()):p=this.center.clone();let f=this.box.max.x-this.box.min.x,u=this.box.max.y-this.box.min.y,g=this.box.max.z-this.box.min.z,y=Math.max(Math.abs(a.x)*f,Math.abs(a.y)*u,Math.abs(a.z)*g),v=Math.max(Math.abs(l.x)*f,Math.abs(l.y)*u,Math.abs(l.z)*g),w=p.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(-v/2)),x=p.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(-v/2)),M=p.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(v/2)),T=p.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(v/2));w.add(c.clone().multiplyScalar(e)),x.add(c.clone().multiplyScalar(e)),M.add(c.clone().multiplyScalar(e)),T.add(c.clone().multiplyScalar(e)),this.current_center=p.clone().add(c.clone().multiplyScalar(e)),k([w,x,M,T],c,"face");function k(D,E,O){const A=new b.BufferGeometry,I=new Float32Array([D[0].x,D[0].y,D[0].z,D[1].x,D[1].y,D[1].z,D[2].x,D[2].y,D[2].z,D[3].x,D[3].y,D[3].z]),S=[0,1,2,0,2,3];A.setAttribute("position",new b.BufferAttribute(I,3)),A.setIndex(S);let z=t.meshs.find($=>$.name==O);if(z==null){const $=new b.MeshBasicMaterial({color:65280,transparent:!0,opacity:.02,side:b.DoubleSide});$.polygonOffset=!0,$.polygonOffsetFactor=1,$.polygonOffsetUnits=4;const F=new b.Mesh(A,$);F.normal=E,F.name=O,n.add(F),t.meshs.push(F)}else z.geometry=A;const V=new Float32Array([D[0].x,D[0].y,D[0].z,D[1].x,D[1].y,D[1].z,D[2].x,D[2].y,D[2].z,D[3].x,D[3].y,D[3].z,D[0].x,D[0].y,D[0].z]);let U=new b.LineBasicMaterial({color:255}),H=new b.BufferGeometry;H.setAttribute("position",new b.BufferAttribute(V,3));let G=t.meshs.find($=>$.name==O+"Line");G==null&&(G=new b.Line(H,U),G.name=O+"Line",n.add(G),t.meshs.push(G)),G.geometry=H,G.material=U,t.engine.sectionPlane.find($=>$.name==O).setFromNormalAndCoplanarPoint(E.clone().setLength(t.direction),D[0])}}handleMouseDown(e){this.isDrag=!0;const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0)if(this.pickPoint=t[0].point,this.pickNormal=t[0].face.normal,this.engine.controls.enabled=!1,this.pickMesh=t[0].object,this.box_={min:this.box.min.clone(),max:this.box.max.clone()},this.center=this.current_center.clone(),this.pickNormal.y==0){const n=new b.Plane;n.setFromNormalAndCoplanarPoint(new b.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new b.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new b.Plane;i.setFromNormalAndCoplanarPoint(n.clone().sub(this.pickPoint.clone()).setLength(1),this.pickPoint),this.plane=i}}handleMouseUp(e){this.isDrag=!1,this.pickPoint=null,this.pickNormal=null,this.pickMesh=null,this.engine.controls.enabled=!0}handleMouseMove(e){this.meshs.forEach(n=>{n.material.opacity=0});const t=e.raycaster.intersectObjects(this.meshs,!1);if(t!=null&&t.length>0&&(t[0].object.material.opacity=.05),this.pickPoint!=null){const n=new b.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,n)){let i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());this.distance=i,this.updata_face(this.distance)}}}}class ud{engine;callback_;constructor(e){this.engine=e}init(){this.engine.handelBehaved.init(this,{showCatch:!0}),this.engine.handelBehaved.active()}catch_face(e){this.callback_=e}handleMouseMove(e){}handleMouseClick(e){let t=e.catch.normal;this.engine.handelBehaved.disActive(),this.callback_({dir:t,position:e.catch.point})}}class dd{engine;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new b.Plane(new b.Vector3(0,0,1),1e5);t.name="前";let n=new b.Plane(new b.Vector3(0,0,1),1e5);n.name="左";let i=new b.Plane(new b.Vector3(0,0,1),1e5);i.name="后";let s=new b.Plane(new b.Vector3(0,0,1),1e5);s.name="右";let r=new b.Plane(new b.Vector3(0,0,1),1e5);r.name="顶";let a=new b.Plane(new b.Vector3(0,0,1),1e5);a.name="底";let l=new b.Plane(new b.Vector3(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,n,i,s,r,a,l]}init(){this.sectionBox=new cd(this.engine),this.sectionFace=new hd(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}clippingModel(e){let t=[];e.forEach(s=>{let r=this.engine.models.find(a=>a.url===s.url);s.ids.forEach(a=>{r.nodesMap.get(a).infos.forEach(l=>{t.push(l.box)})})}),this.active("box");let n=i(t);this.sectionBox.setBox(n);function i(s){let r=new b.Vector3(1e8,1e9,1e10),a=new b.Vector3(-1e8,-1e9,-1e10);return s.forEach(l=>{l.min.x<r.x&&(r.x=l.min.x),l.min.y<r.y&&(r.y=l.min.y),l.min.z<r.z&&(r.z=l.min.z),l.max.x>a.x&&(a.x=l.max.x),l.max.y>a.y&&(a.y=l.max.y),l.max.z>a.z&&(a.z=l.max.z)}),new b.Box3(r,a)}}updateClippingValue(e){let t=this.sectionBox.maxBox,n=t.min.x+(t.max.x-t.min.x)*e.x.min*.01,i=t.min.y+(t.max.y-t.min.y)*e.y.min*.01,s=t.min.z+(t.max.z-t.min.z)*e.z.min*.01,r=t.min.x+(t.max.x-t.min.x)*e.x.max*.01,a=t.min.y+(t.max.y-t.min.y)*e.y.max*.01,l=t.min.z+(t.max.z-t.min.z)*e.z.max*.01;this.sectionBox.setboxXyz({minX:n,minY:i,minZ:s,maxX:r,maxY:a,maxZ:l})}active(e){if(this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=e,e=="x")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(Math.PI/2,0,0);else if(e=="y")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,Math.PI/2,0);else if(e=="z")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,0,Math.PI/2);else if(e=="box")this.sectionBox.init(),this.sectionBox.active();else if(e=="face"){let t=new ud(this.engine);t.init(),t.catch_face(n=>{this.sectionFace.init(),this.sectionFace.active();let i=this.engine.octreeBox.getBoundingBox(),s=n.position.clone().sub(i.min.clone().add(i.max.clone()).setLength(.5)),r=new b.Vector3(n.dir.x,n.dir.y,n.dir.z),a=s.dot(r);this.sectionFace.setFaceNormal(n.dir,a)})}}disabled(){this.currentClippingMode=="box"?this.sectionBox.disabled():this.sectionFace.disabled()}recover(){this.currentClippingMode=="box"?this.sectionBox.recover():this.sectionFace.recover()}reverse(){this.sectionFace.reverse()}disActive(){this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=""}}class fd{engine;constructor(e){this.engine=e}getLevelTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeLevel,name:t.info.baseInfo.name,url:t.url})}),e}getTypeTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeType,name:t.info.baseInfo.name,url:t.url})}),e}getMajorTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeMajor,name:t.info.baseInfo.name,url:t.url})}),e}}class pd{engine;constructor(e){this.engine=e}getEngineInfo(){let e=0,t=0,n=0;return!this.engine||!this.engine.scene?{totalVertices:0,totalTriangles:0,meshCount:0}:(this.engine.scene.traverse(i=>{if(i instanceof b.Mesh){const s=i.geometry;if(s&&s.attributes){const r=s.attributes.position;if(r){const a=r.count;e+=a;let l=0;s.index?l=s.index.count/3:l=a/3,t+=l}}}}),this.engine.engineStatus.models.forEach(i=>{n=n+i.info.modelEdge.length}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:n})}}class md{engine;constructor(e){this.engine=e}init(){}getModelProperties(e,t,n){let i=this.engine.engineStatus.models.find(r=>r.url===e);i.properties==null&&Wi(e+"/property",r=>{let a=JSON.parse(r);i.properties=a,setTimeout(()=>{s(a,t,n)},100)}),s(i.properties,t,n);function s(r,a,l){let c=[],h=r.models[a.toString()||""],d=h.map(m=>m[0]);d=d.filter((m,p)=>d.indexOf(m)===p),d.forEach(m=>{let p={name:r.categorys[m],children:[]};c.push(p),h.filter(f=>f[0]===m).forEach(f=>{p.children.push({name:r.names[f[1]],value:r.values[f[2]]})})}),l?.({properties:c,materials:c})}}}class gd{engine;constructor(e){this.engine=e}getModelTypes(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.typeName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.majorName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.levelName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMappers(e){}getModelMapper(e,t){let n=this.engine.engineStatus.models.find(r=>r.url==e);return n?n.info.modelMapper.find(r=>r.id==t):null}getModelsWithLevelType(e,t,n=null){let i=[];return this.engine.engineStatus.models.forEach(s=>{let r={url:s.url,ids:[]};i.push(r),s.info.modelMapper.filter(l=>l.levelName===e&&l.typeName===t).forEach(l=>{r.ids.push(Number(l.id))})}),n&&n(i),i}getModelsWithType(e,t=null){let n=[];return this.engine.engineStatus.models.forEach(i=>{let s={url:i.url,ids:[]};n.push(s),i.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithLevel(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let s={url:i.url,ids:[]};n.push(s),i.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithMajor(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let s={url:i.url,ids:[]};n.push(s),i.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(n),n}}class yd{engine;isActive=!1;groupEdge;material;modelEdgeLoaded=!1;indexes=new Map;constructor(e){this.engine=e,this.groupEdge=this.engine.scene.getObjectByName("groupEdge"),this.material=new b.LineBasicMaterial({color:"#000000",depthTest:!0,transparent:!0,opacity:.3}),this.material.clippingPlanes=this.engine.sectionPlane}active(){this.isActive=!0,this.groupEdge.visible=!0,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{n.polygonOffset=!0,n.polygonOffsetFactor=1,n.polygonOffsetUnits=4})}),this.show()}disActive(){this.isActive=!1,this.groupEdge.visible=!1,this.engine.scene.traverse(e=>{e.isMesh&&e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(n=>{n.polygonOffset=!1})})}loadModelEdge(){this.modelEdgeLoaded||(this.engine.engineStatus.models.forEach(e=>{if(!this.groupEdge.children.find(n=>n.url==e.url)){let n=e.info,i=[],s=new Map;n.modelEdge.forEach(r=>{let a=i.length;for(let l=0;l<r.points.length;l++)r.points[l].length==2&&(i.push(r.points[l][0].X),i.push(r.points[l][0].Z),i.push(-r.points[l][0].Y),i.push(r.points[l][1].X),i.push(r.points[l][1].Z),i.push(-r.points[l][1].Y));s.set(Number(r.id),[a,i.length,r.points])}),this.indexes.set(e.url,s)}}),this.modelEdgeLoaded=!0)}show(){this.modelEdgeLoaded||this.loadModelEdge(),this.indexes.forEach((e,t)=>{let n=[];e.forEach((r,a)=>{r[2].forEach((l,c)=>{l.length==2&&(n.push(l[0].X),n.push(l[0].Z),n.push(-l[0].Y),n.push(l[1].X),n.push(l[1].Z),n.push(-l[1].Y))})});let i=new b.BufferGeometry;i.setAttribute("position",new b.Float32BufferAttribute(n,3));let s=new b.LineSegments(i,this.material);s.url=t,this.groupEdge.add(s)})}getModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i)return i.slice()}return null}hideModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i){let[s,r,a]=i,l=this.groupEdge.children.find(c=>c.url==e);if(l){let c=l.geometry.attributes.position.array;for(let h=s;h<r;h++)c[h]=NaN;l.geometry.attributes.position.needsUpdate=!0}}}}showModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i){let[s,r,a]=i,l=this.groupEdge.children.find(c=>c.url==e);if(l){let c=l.geometry.attributes.position.array,h=0;for(let d=s;d<r;d+=3){const m=Math.floor(h/6),p=h%6>=3;if(a[m]&&a[m].length===2){const f=p?a[m][1]:a[m][0];c[d]=f.X,c[d+1]=f.Z,c[d+2]=-f.Y}h+=3}l.geometry.attributes.position.needsUpdate=!0}}}}}class vd{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,n=setTimeout(()=>t.abort(),this.config.timeout);try{const i=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!1}),signal:t.signal});if(clearTimeout(n),!i.ok){const r=await i.json().catch(()=>({}));throw new Error(`API请求失败 (${i.status}): ${r.error?.message||r.message||i.statusText}`)}return(await i.json()).choices?.[0]?.message?.content||""}catch(i){throw clearTimeout(n),i.name==="AbortError"?new Error("请求超时,请重试"):i.message.includes("Failed to fetch")?new Error(`网络请求失败,请检查:
|
|
971
|
+
`;continue}if((U=z.match(E))&&(S.gamma=parseFloat(U[1])),(U=z.match(R))&&(S.exposure=parseFloat(U[1])),(U=z.match(A))&&(S.valid|=2,S.format=U[1]),(U=z.match(I))&&(S.valid|=4,S.height=parseInt(U[1],10),S.width=parseInt(U[2],10)),S.valid&2&&S.valid&4)break}return S.valid&2||o(3,"missing format specifier"),S.valid&4||o(3,"missing image size specifier"),S},p=function(D,k,E){const R=k;if(R<8||R>32767||D[0]!==2||D[1]!==2||D[2]&128)return new Uint8Array(D);R!==(D[2]<<8|D[3])&&o(3,"wrong scanline width");const A=new Uint8Array(4*k*E);A.length||o(4,"unable to allocate buffer space");let I=0,S=0;const z=4*R,U=new Uint8Array(4),V=new Uint8Array(z);let $=E;for(;$>0&&S<D.byteLength;){S+4>D.byteLength&&o(1),U[0]=D[S++],U[1]=D[S++],U[2]=D[S++],U[3]=D[S++],(U[0]!=2||U[1]!=2||(U[2]<<8|U[3])!=R)&&o(3,"bad rgbe scanline format");let G=0,q;for(;G<z&&S<D.byteLength;){q=D[S++];const O=q>128;if(O&&(q-=128),(q===0||G+q>z)&&o(3,"bad scanline data"),O){const ee=D[S++];for(let te=0;te<q;te++)V[G++]=ee}else V.set(D.subarray(S,S+q),G),G+=q,S+=q}const N=R;for(let O=0;O<N;O++){let ee=0;A[I]=V[O+ee],ee+=R,A[I+1]=V[O+ee],ee+=R,A[I+2]=V[O+ee],ee+=R,A[I+3]=V[O+ee],I+=4}$--}return A},f=function(D,k,E,R){const A=D[k+3],I=Math.pow(2,A-128)/255;E[R+0]=D[k+0]*I,E[R+1]=D[k+1]*I,E[R+2]=D[k+2]*I,E[R+3]=1},d=function(D,k,E,R){const A=D[k+3],I=Math.pow(2,A-128)/255;E[R+0]=M.DataUtils.toHalfFloat(Math.min(D[k+0]*I,65504)),E[R+1]=M.DataUtils.toHalfFloat(Math.min(D[k+1]*I,65504)),E[R+2]=M.DataUtils.toHalfFloat(Math.min(D[k+2]*I,65504)),E[R+3]=M.DataUtils.toHalfFloat(1)},g=new Uint8Array(e);g.pos=0;const y=m(g),v=y.width,x=y.height,b=p(g.subarray(g.pos),v,x);let _,T,P;switch(this.type){case M.FloatType:P=b.length/4;const D=new Float32Array(P*4);for(let E=0;E<P;E++)f(b,E*4,D,E*4);_=D,T=M.FloatType;break;case M.HalfFloatType:P=b.length/4;const k=new Uint16Array(P*4);for(let E=0;E<P;E++)d(b,E*4,k,E*4);_=k,T=M.HalfFloatType;break;default:throw new Error("THREE.HDRLoader: Unsupported type: "+this.type)}return{width:v,height:x,data:_,header:y.string,gamma:y.gamma,exposure:y.exposure,type:T}}setDataType(e){return this.type=e,this}load(e,t,n,i){function s(o,a){switch(o.type){case M.FloatType:case M.HalfFloatType:o.colorSpace=M.LinearSRGBColorSpace,o.minFilter=M.LinearFilter,o.magFilter=M.LinearFilter,o.generateMipmaps=!1,o.flipY=!0;break}t&&t(o,a)}return super.load(e,s,n,i)}}function xh(){return new w.Scene}function bh(r,e){r.appendChild(e.domElement)}function Mh(r,e,t){var n=new Object;n.visible=!0;let i=null,s,o,a=[];n.init=function(){s||(c(),h(),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 f=new w.Vector3(0,0,1).applyQuaternion(e.camera.quaternion);n.camera.position.copy(f.multiplyScalar(100)),n.sceneOrtho.renderer.render(n.sceneOrtho,n.camera)},n.ToggleDirectionView=function(f){var d=new w.Vector3(0,0,0);f=="top"?d=new w.Vector3(0,1,1e-5):f=="down"?d=new w.Vector3(0,-1,1e-5):f=="front"?d=new w.Vector3(0,0,1):f=="left"?d=new w.Vector3(-1,0,0):f=="back"?d=new w.Vector3(0,0,-1):f=="right"?d=new w.Vector3(1,0,0):f=="top_front"?d=new w.Vector3(1,1,0):f=="top_left"?d=new w.Vector3(0,1,-1):f=="top_back"?d=new w.Vector3(-1,1,0):f=="top_right"?d=new w.Vector3(0,1,1):f=="down_front"?d=new w.Vector3(1,-1,0):f=="down_left"?d=new w.Vector3(0,-1,-1):f=="down_back"?d=new w.Vector3(-1,-1,0):f=="down_right"?d=new w.Vector3(0,-1,1):f=="front_right"?d=new w.Vector3(1,0,1):f=="right_back"?d=new w.Vector3(-1,0,1):f=="back_left"?d=new w.Vector3(-1,0,-1):f=="left_front"?d=new w.Vector3(1,0,-1):f=="top_left_front"?d=new w.Vector3(1,1,-1):f=="top_front_right"?d=new w.Vector3(1,1,1):f=="top_right_back"?d=new w.Vector3(-1,1,1):f=="top_back_left"?d=new w.Vector3(-1,1,-1):f=="button_left_front"?d=new w.Vector3(1,-1,-1):f=="button_front_right"?d=new w.Vector3(1,-1,1):f=="button_right_back"?d=new w.Vector3(-1,1,1):f=="button_back_left"&&(d=new w.Vector3(-1,-1,-1));var g=r.octreeBox.getBoundingBox(),y=g.min,v=g.max,x=y.clone().add(v.clone()).multiplyScalar(.5),b=x.clone().add(d.multiplyScalar(1*v.distanceTo(y)));l(e.camera.position,b,r.controls.target.clone(),x)},n.GetCameraPose=function(){var f=e.camera.quaternion,d=e.camera.position,g=r.controls.target,y={quaternion:f,position:d,target:g};return y},n.ReductionCameraPose=function(f,d=1e3,g){var y=new w.Quaternion(f.quaternion._x,f.quaternion._y,f.quaternion._z,f.quaternion._w),v=new w.Vector3(f.position.x,f.position.y,f.position.z),x=new w.Vector3(f.target.x,f.target.y,f.target.z);let b=!1;l(e.camera.position,v,r.controls.target.clone(),x,e.camera.quaternion,y,d,_=>{g&&(b||(g(_),b=!0))}),g&&setTimeout(()=>{b||(g(!0),b=!0)},d+10)},n.CameraGoHome=function(f=1e3){var d=r.octreeBox.getBoundingBox(),g=d.min.clone().add(d.max.clone()).multiplyScalar(.5);let y=new w.Vector3(1,1,1);var v=d.max.distanceTo(d.min),x=g.clone().add(y.multiplyScalar(v*2));if(r.camera.far=v*5,e.camera.isOrthographicCamera){var b=r.container.clientWidth/r.container.clientHeight,_=v*.6;e.camera.left=-_*b,e.camera.right=_*b,e.camera.top=_,e.camera.bottom=-_,e.camera.zoom=1,e.camera.updateProjectionMatrix()}r.controlModule.orbitControls.origin=g.clone(),l(e.camera.position,x,r.controls.target.clone(),g,null,null,f)},n.zoomToBox=function(f){if(e.camera.isOrthographicCamera){let O=function(){i=requestAnimationFrame(O),N.update()};var d=f.min.clone().add(f.max.clone()).multiplyScalar(.5),g=e.camera.position.clone().sub(r.controls.target.clone()).normalize(),y=e.camera.position.distanceTo(r.controls.target),v=d.clone().add(g.multiplyScalar(y)),x=e.camera.zoom,b=new w.Vector3(1,0,0).applyQuaternion(e.camera.quaternion),_=new w.Vector3(0,1,0).applyQuaternion(e.camera.quaternion),T=[new w.Vector3(f.min.x,f.min.y,f.min.z),new w.Vector3(f.max.x,f.min.y,f.min.z),new w.Vector3(f.min.x,f.max.y,f.min.z),new w.Vector3(f.max.x,f.max.y,f.min.z),new w.Vector3(f.min.x,f.min.y,f.max.z),new w.Vector3(f.max.x,f.min.y,f.max.z),new w.Vector3(f.min.x,f.max.y,f.max.z),new w.Vector3(f.max.x,f.max.y,f.max.z)],P=1/0,D=-1/0,k=1/0,E=-1/0;for(var R of T){var A=R.dot(b),I=R.dot(_);P=Math.min(P,A),D=Math.max(D,A),k=Math.min(k,I),E=Math.max(E,I)}var S=(D-P)/2,z=(E-k)/2,U=(e.camera.right-e.camera.left)/2,V=(e.camera.top-e.camera.bottom)/2;x=Math.min(U/S,V/z)*.75;var $=e.camera.position.clone(),G=r.controls.target.clone(),q=e.camera.zoom,N=new pn.Tween({x1:$.x,y1:$.y,z1:$.z,x2:G.x,y2:G.y,z2:G.z,zoom:q}).to({x1:v.x,y1:v.y,z1:v.z,x2:d.x,y2:d.y,z2:d.z,zoom:x},1e3);N.onUpdate(function(ee){r.controls&&(e.camera.position.set(ee.x1,ee.y1,ee.z1),r.controls.target.set(ee.x2,ee.y2,ee.z2),e.camera.isOrthographicCamera&&(e.camera.zoom=ee.zoom,e.camera.updateProjectionMatrix()),r.controls.auto=!0,r.controls.update(),n.RenderScene())}),N.onComplete(function(){r.controls&&(r.controls.auto=!1,n.RenderScene(),cancelAnimationFrame(i),i=null)}),N.easing(pn.Easing.Cubic.InOut),N.start(),O()}else{var d=f.min.clone().add(f.max.clone()).multiplyScalar(.5);let te=e.camera.position.clone().sub(r.controls.target.clone()).normalize();var v=d.clone().add(te.multiplyScalar(2*f.max.distanceTo(f.min)));l(e.camera.position,v,r.controls.target.clone(),d)}};function l(f,d,g,y,v,x,b=1e3,_){var T;v&&x?(T=new pn.Tween({x1:f.x,y1:f.y,z1:f.z,x2:g.x,y2:g.y,z2:g.z,_x:v._x,_y:v._y,_z:v._z,_w:v._w}),T.to({x1:d.x,y1:d.y,z1:d.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 pn.Tween({x1:f.x,y1:f.y,z1:f.z,x2:g.x,y2:g.y,z2:g.z}),T.to({x1:d.x,y1:d.y,z1:d.z,x2:y.x,y2:y.y,z2:y.z},b)),T.onUpdate(function(D){r.controls&&(v&&x?(e.camera.quaternion._x=D._x,e.camera.quaternion._y=D._y,e.camera.quaternion._z=D._z,e.camera.quaternion._w=D._w):r.controls.auto=!0,e.camera.position.x=D.x1,e.camera.position.y=D.y1,e.camera.position.z=D.z1,r.controls.target.x=D.x2,r.controls.target.y=D.y2,r.controls.target.z=D.z2,r.controls.update(),n.RenderScene())}),T.onComplete(function(D){r.controls&&(r.controls.auto=!1,n.RenderScene(),_&&_(!0),cancelAnimationFrame(i),i=null)}),T.easing(pn.Easing.Cubic.InOut);function P(D){i=requestAnimationFrame(P),T.update()}T.start(),P()}function c(){s=document.createElement("div"),s.className="ViewCube",t.appendChild(s),o=document.createElement("div"),o.className="viewSettingWrapper",o.innerHTML="...",s.appendChild(o);var f=document.createElement("div");f.className="homeViewWrapper",f.addEventListener("mousedown",function(){console.log("归位"),n.CameraGoHome()}),s.appendChild(f);const d=document.createElement("div");d.className="cameraToggleWrapper",d.title="切换正交/透视视图",d.innerHTML="⊞",d.addEventListener("mousedown",function(b){b.stopPropagation(),console.log("切换视图"),n.ToggleCameraType(),v()}),s.appendChild(d);const g=document.createElement("div");g.className="screenshotWrapper",g.title="截图",g.innerHTML="📷",g.addEventListener("mousedown",function(b){b.stopPropagation(),console.log("截图"),n.TakeScreenshot(),v()}),s.appendChild(g);const y=document.createElement("div");y.className="fullscreenWrapper",y.title="全屏",y.innerHTML="⛶",y.addEventListener("mousedown",function(b){b.stopPropagation(),console.log("全屏"),n.ToggleFullscreen(),v()}),s.appendChild(y),o.addEventListener("mousedown",function(b){b.stopPropagation(),d.classList.contains("show")?(v(),console.log("隐藏功能按钮")):(x(),console.log("显示功能按钮"))});function v(){d.classList.remove("show"),g.classList.remove("show"),y.classList.remove("show")}function x(){d.classList.add("show"),g.classList.add("show"),y.classList.add("show")}}function h(){n.sceneOrtho=xh();var g=t.clientWidth,y=t.clientWidth,f=g>y?g/y:y/g,d=300;n.camera=new w.OrthographicCamera(d*f/-2,d*f/2,d/2,d/-2,.01,1e4);var g=s.clientWidth,y=s.clientHeight,v=new w.WebGLRenderer({alpha:!0});v.setSize(g,y),v.setClearAlpha(0),n.sceneOrtho.renderer=v;let x=new w.AmbientLight(16777215,.8);n.sceneOrtho.add(x),bh(s,v)}function u(){const f="/assets/viewcube/";let d=[{label:"右",icon:f+"cn_right.png"},{label:"左",icon:f+"cn_left.png"},{label:"顶",icon:f+"cn_top.png"},{label:"底",icon:f+"cn_bottom.png"},{label:"前",icon:f+"cn_front.png"},{label:"后",icon:f+"cn_back.png"}];var g=[];for(const v of d)g.push(new w.MeshBasicMaterial({color:16777215,map:new w.TextureLoader().load(v.icon)}));new w.MeshLambertMaterial({color:255});var y=new w.Mesh(new w.BoxGeometry(110,110,110),g);n.sceneOrtho.add(y),m(122),s.addEventListener("mousedown",v=>{var x={};x.x=v.offsetX/s.clientWidth*2-1,x.y=-(v.offsetY/s.clientHeight)*2+1;var b=new w.Raycaster;b.setFromCamera(x,n.camera);const _=b.intersectObjects(a,!1);_.length>0&&n.ToggleDirectionView(_[0].object.name)}),s.addEventListener("mousemove",v=>{var x={};x.x=v.offsetX/s.clientWidth*2-1,x.y=-(v.offsetY/s.clientHeight)*2+1;var b=new w.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 m(f){for(var d=f*.5-20,g=[{name:"right",a:30,b:75,c:75,point:new w.Vector3(d,0,0)},{name:"back",a:75,b:75,c:30,point:new w.Vector3(0,0,-d)},{name:"left",a:30,b:75,c:75,point:new w.Vector3(-d,0,0)},{name:"front",a:75,b:75,c:30,point:new w.Vector3(0,0,d)},{name:"top",a:75,b:30,c:75,point:new w.Vector3(0,d,0)},{name:"button",a:75,b:30,c:75,point:new w.Vector3(0,-d,0)}],y=[{name:"top_right_back",a:30,b:30,c:30,point:new w.Vector3(-d,d,d)},{name:"button_front_right",a:30,b:30,c:30,point:new w.Vector3(-d,-d,d)},{name:"top_front_right",a:30,b:30,c:30,point:new w.Vector3(d,d,d)},{name:"button_right_back",a:30,b:30,c:30,point:new w.Vector3(d,-d,d)},{name:"top_back_left",a:30,b:30,c:30,point:new w.Vector3(-d,d,-d)},{name:"button_back_left",a:30,b:30,c:30,point:new w.Vector3(-d,-d,-d)},{name:"top_left_front",a:30,b:30,c:30,point:new w.Vector3(d,d,-d)},{name:"button_left_front",a:30,b:30,c:30,point:new w.Vector3(d,-d,-d)}],v=[{name:"top_front",a:30,b:30,c:75,point:new w.Vector3(d,d,0)},{name:"top_right",a:75,b:30,c:30,point:new w.Vector3(0,d,d)},{name:"top_back",a:30,b:30,c:75,point:new w.Vector3(-d,d,0)},{name:"top_left",a:75,b:30,c:30,point:new w.Vector3(0,d,-d)},{name:"button_front",a:30,b:30,c:75,point:new w.Vector3(d,-d,0)},{name:"button_right",a:75,b:30,c:30,point:new w.Vector3(0,-d,d)},{name:"button_back",a:30,b:30,c:75,point:new w.Vector3(-d,-d,0)},{name:"button_left",a:75,b:30,c:30,point:new w.Vector3(0,-d,-d)},{name:"front_right",a:30,b:75,c:30,point:new w.Vector3(d,0,d)},{name:"right_back",a:30,b:75,c:30,point:new w.Vector3(-d,0,d)},{name:"back_left",a:30,b:75,c:30,point:new w.Vector3(-d,0,-d)},{name:"left_front",a:30,b:75,c:30,point:new w.Vector3(d,0,-d)}],x=0;x<g.length;x++)a.push(p(g[x]));for(var x=0;x<y.length;x++)a.push(p(y[x]));for(var x=0;x<v.length;x++)a.push(p(v[x]))}function p(f){const d=new w.BoxGeometry(f.a,f.b,f.c),g=new w.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),y=new w.Matrix4().makeTranslation(f.point.x,f.point.y,f.point.z);let v=d.applyMatrix4(y),x=new w.Mesh(v,g);return x.name=f.name,n.sceneOrtho.add(x),x}return n.ToggleCameraType=function(){r.cameraModule.switchCurrentCamera()},n.TakeScreenshot=function(){try{if(!r.renderer){console.error("渲染器未初始化");return}r.renderer.render(e,e.camera);const d=r.renderer.domElement.toDataURL("image/png"),g=document.createElement("a"),y=new Date().toISOString().replaceAll(/[:.]/g,"-");g.download=`screenshot_${y}.png`,g.href=d,g.click(),console.log("截图已保存")}catch(f){console.error("截图失败:",f)}},n.ToggleFullscreen=function(){const f=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(f.requestFullscreen?f.requestFullscreen():f.webkitRequestFullscreen?f.webkitRequestFullscreen():f.mozRequestFullScreen?f.mozRequestFullScreen():f.msRequestFullscreen&&f.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},n}class _h{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=Mh(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(e){this.cubeTool.CameraGoHome(e)}zoomToModel(e){this.cubeTool.zoomToBox(e)}zoomToModels(e){try{let t=this.engine.models.find(n=>n.url==e.url);this.cubeTool.zoomToBox(t.nodesMap.get(e.id).infos[0].box)}catch{}}hide(){}}function Sh(r){let e=new Object;return e.getBoundingBox=function(){let t=r.models,n=new w.Vector3(1e8,1e9,1e10),i=new w.Vector3(-1e8,-1e9,-1e10);t.forEach(u=>{let m=u.boundingBox.min,p=u.boundingBox.max;m.x<n.x&&(n.x=m.x),m.y<n.y&&(n.y=m.y),m.z<n.z&&(n.z=m.z),p.x>i.x&&(i.x=p.x),p.y>i.y&&(i.y=p.y),p.z>i.z&&(i.z=p.z)});let s=Math.min(n.x,i.x),o=Math.min(n.y,i.y),a=Math.min(n.z,i.z),l=Math.max(n.x,i.x),c=Math.max(n.y,i.y),h=Math.max(n.z,i.z);return{min:new w.Vector3(s,o,a),max:new w.Vector3(l,c,h)}},e.rayInterationModel=function(t){let n=[];return r.engineStatus.models.forEach(o=>{o.info.lods.forEach(a=>{let l=a.octreeBox;s(t,l,o)})}),n=n.filter(o=>o instanceof w.Mesh),t.intersectObjects(n,!1);function s(o,a,l){if(a==null)return;let c=new w.Vector3(a.min.X*.3048,a.min.Z*.3048,-a.min.Y*.3048),h=new w.Vector3(a.max.X*.3048,a.max.Z*.3048,-a.max.Y*.3048),u=new w.Vector3(Math.min(c.x,h.X),Math.min(c.y,h.y),Math.min(c.z,h.z)),m=new w.Vector3(Math.max(h.x,c.x),Math.max(h.y,c.y),Math.max(h.z,c.z)),p=new w.Box3(u,m),f=o.ray.intersectsBox(p);if(!(f==null||f==!1))if(a.children==null||a.children.length==0){if(a.elements!=null)for(var d of a.elements){let g=r.engineStatus.hideModels.find(b=>b.url==l.url)?.ids;if(g!=null&&g.includes(d))continue;let y=r.engineStatus.translucentModels.find(b=>b.url==l.url)?.ids;if(y!=null&&y.includes(d))continue;let x=r.models.find(b=>b.url==l.url).nodesMap.get(d);x!=null&&!x.instance&&x.infos.map(_=>_.mesh).forEach(_=>{n.push(_)})}}else{if(a.elements!=null)for(var d of a.elements){let y=r.engineStatus.hideModels.find(_=>_.url==l.url)?.ids;if(y!=null&&y.includes(d))continue;let v=r.engineStatus.translucentModels.find(_=>_.url==l.url)?.ids;if(v!=null&&v.includes(d))continue;let b=r.models.find(_=>_.url==l.url).nodesMap.get(d);b!=null&&!b.instance&&b.infos.map(T=>T.mesh).forEach(T=>{n.push(T)})}for(let g of a.children)s(o,g,l)}}},e}class Ch{engine;isDrawing=!1;startPoint=new w.Vector2;endPoint=new w.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 _e(this.engine.camera,this.engine.renderer,this.engine.scene))}active(){this.engine.controlModule.disActive();const e=this.engine.renderer?.domElement;e&&(e.addEventListener("mousedown",this.boundMouseDown),e.addEventListener("mousemove",this.boundMouseMove),e.addEventListener("mouseup",this.boundMouseUp),e.style.cursor="crosshair"),window.addEventListener("keydown",this.boundKeyDown)}disActive(){this.engine.controlModule.active();const e=this.engine.renderer?.domElement;e&&(e.removeEventListener("mousedown",this.boundMouseDown),e.removeEventListener("mousemove",this.boundMouseMove),e.removeEventListener("mouseup",this.boundMouseUp),e.style.cursor="default"),window.removeEventListener("keydown",this.boundKeyDown),this.isDrawing&&this.endDrawing()}createSelectionBoxElement(){this.selectionBox=document.createElement("div"),this.selectionBox.style.position="absolute",this.selectionBox.style.border="2px dashed #00aaff",this.selectionBox.style.backgroundColor="rgba(0, 170, 255, 0.1)",this.selectionBox.style.pointerEvents="none",this.selectionBox.style.display="none",this.selectionBox.style.zIndex="1000",this.selectionBox.style.boxSizing="border-box";const e=this.engine.renderer?.domElement;e&&e.parentElement&&e.parentElement.appendChild(this.selectionBox)}onMouseDown(e){e.button!==0||!this.engine.renderer?.domElement||(this.startPoint.set(e.offsetX,e.offsetY),this.endPoint.copy(this.startPoint),this.isDrawing=!0,this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation())}onMouseMove(e){!this.isDrawing||!this.engine.renderer?.domElement||(this.endPoint.set(e.offsetX,e.offsetY),this.updateSelectionBoxUI(),e.preventDefault(),e.stopPropagation())}onMouseUp(e){this.isDrawing&&(this.endDrawing(),this.performZoom(),e.preventDefault(),e.stopPropagation(),this.disActive())}onKeyDown(e){e.key==="Escape"&&(this.disActive(),e.preventDefault(),e.stopPropagation())}endDrawing(){this.isDrawing&&(this.isDrawing=!1,this.selectionBox&&(this.selectionBox.style.display="none"))}updateSelectionBoxUI(){if(!this.selectionBox||!this.engine.renderer?.domElement)return;const t=Math.min(this.startPoint.x,this.endPoint.x),n=Math.min(this.startPoint.y,this.endPoint.y),i=Math.abs(this.endPoint.x-this.startPoint.x),s=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${t}px`,this.selectionBox.style.top=`${n}px`,this.selectionBox.style.width=`${i}px`,this.selectionBox.style.height=`${s}px`}performZoom(){const e=Math.abs(this.endPoint.x-this.startPoint.x),t=Math.abs(this.endPoint.y-this.startPoint.y);if(e<5||t<5)return;if(!this.worldToScreen){console.warn("RangeScale: 坐标转换工具未初始化");return}const n=Math.min(this.startPoint.x,this.endPoint.x),i=Math.max(this.startPoint.x,this.endPoint.x),s=Math.min(this.startPoint.y,this.endPoint.y),o=Math.max(this.startPoint.y,this.endPoint.y),a=[],l=[{x:n,y:s},{x:i,y:s},{x:i,y:o},{x:n,y:o}];for(const h of l){const u=this.worldToScreen.screenToWorld(h.x,h.y);u&&a.push(u)}if(a.length<3){console.warn("RangeScale: 框选区域未命中模型,无法执行缩放操作");return}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const c=new w.Box3;for(const h of a)c.expandByPoint(h);if(c.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(c)}fitCameraToBoundingBox(e){const t=this.engine.camera,n=this.engine.controls;if(!t||!n){console.warn("RangeScale: 相机或控制器未初始化");return}const i=new w.Vector3;e.getCenter(i);const s=new w.Vector3;e.getSize(s);const o=Math.max(s.x,s.y,s.z);if(t instanceof w.PerspectiveCamera){const a=t.fov*(Math.PI/180),c=o/(2*Math.tan(a/2))*1.2,h=new w.Vector3;t.getWorldDirection(h);const u=i.clone().sub(t.position);h.dot(u.normalize())<0&&h.negate();const p=i.clone().sub(h.multiplyScalar(c));t.position.copy(p),n.target&&n.target.copy(i),t.lookAt(i),n.update()}else if(t instanceof w.OrthographicCamera){const l=o*1.2,c=this.engine.renderer?.domElement,h=c?c.width/c.height:1;t.left=-l*h/2,t.right=l*h/2,t.top=l/2,t.bottom=-l/2,t.updateProjectionMatrix();const u=new w.Vector3;t.getWorldDirection(u);const m=o*1.5,p=i.clone().sub(u.multiplyScalar(m));t.position.copy(p),n.target&&n.target.copy(i),t.lookAt(i),n.update()}}}class Ah{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 w.AmbientLight);t&&(t.intensity=e)}setAmbientLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof w.AmbientLight);t&&t.color.set(e)}setDirectionalLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof w.DirectionalLight);t&&(t.intensity=e)}setDirectionalLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof w.DirectionalLight);t&&t.color.set(e)}setShadowQuality(e){const t=this.engine.scene.children.find(n=>n instanceof w.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 w.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 Oe);if(e)if(n)n.enabled=!0;else{const{width:i,height:s}=this.engine.deviceModule.getContainerSize(),o=new Oe(this.engine.scene,this.engine.camera,i,s);o.output=Oe.OUTPUT.Default,o.blendIntensity=.5,o.updateGtaoMaterial&&o.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0});const a=t.passes.findIndex(l=>l.constructor.name==="RenderPass");t.passes.splice(a+1,0,o)}else n&&(n.enabled=!1)}setSceneSaturation(e){if(!this.engine.composerModule?.saturationPass){console.warn("Saturation pass not initialized");return}this.engine.composerModule.saturationPass.uniforms.saturation.value=e}setSceneContrast(e){if(!this.engine.composerModule?.saturationPass){console.warn("Saturation pass not initialized");return}this.engine.composerModule.saturationPass.uniforms.contrast.value=e}setGroundEnabled(e,t){if(e)if(this.ground)this.ground.visible=!0;else{const n=t?.size??100,i=t?.color??8421504,s=t?.opacity??.3,o=new w.PlaneGeometry(n,n),a=new w.MeshStandardMaterial({color:i,transparent:!0,opacity:s,side:w.DoubleSide});this.ground=new w.Mesh(o,a),this.ground.rotation.x=-Math.PI/2,this.ground.position.y=0,this.ground.receiveShadow=!0,this.ground.name="ground",this.engine.scene.add(this.ground)}else this.ground&&(this.ground.visible=!1)}setHDRBackground(e){e?(this.engine.scene.background=e,this.engine.scene.environment=e):(this.engine.scene.background=null,this.engine.scene.environment=null)}}function rt(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){var e=Math.random()*16|0,t=r=="x"?e:e&3|8;return t.toString(16)})}class at{engine;handelBehaved;setting;constructor(e){this.engine=e,this.handelBehaved=zi(e),this.handelBehaved.init(this,null),this.setting={unit:"m",precision:3}}getSetting(){return this.setting}saveSetting(e){this.setting=e}active(){this.handelBehaved.active()}disActive(){this.handelBehaved.disActive()}getMeasureText(e,t){if(e==null)return null;let n=this.setting.unit,i=n;return t==1?n=="mm"?e=e*1e3:n=="cm"?e=e*100:n=="dm"?e=e*10:n=="m"?e=e*1:n=="km"&&(e=e*.001):t==2&&(n=="mm"?e=e*1e3*1e3:n=="cm"?e=e*100*100:n=="dm"?e=e*10*10:n=="m"?e=e*1*1:n=="km"&&(e=e*.001*.001),i=i+"²"),e.toFixed(this.setting.precision)+" "+i}cancelCurrentSelectedAnnotation(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight==!0&&(n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight"))})}handelKeyEscDown(){this.cancelCurrentSelectedAnnotation();let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.isSelect==!0&&(i.container.remove(),e[t].splice(n,1))}this.engine.measure.clearAllPoints()}handelKeyDeleteDown(){let e=this.engine.measure.annotationData;for(let t in e)for(let n=e[t].length-1;n>=0;n--){let i=e[t][n];i.highlight==!0&&(i.container.remove(),e[t].splice(n,1))}}clearHighlight(){let e=this.engine.measure.annotationData;for(let t in e)e[t].forEach(n=>{n.highlight=!1,n.container.classList.remove("Hight"),n.container.getElementsByTagName("svg")[0].classList.remove("Hight")})}drawNormalAnnotation(){let e=this;this.engine.measure.annotationData.normalAnnotation.forEach(f=>{p(f)}),this.engine.measure.annotationData.elevationAnnotation.forEach(f=>{m(f)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(f=>{u(f)}),this.engine.measure.annotationData.angleAnnotation.forEach(f=>{l(f)}),this.engine.measure.annotationData.areaAnnotation.forEach(f=>{c(f)}),this.engine.measure.annotationData.slopeAnnotation.forEach(f=>{h(f)});function l(f){if(f.container==null){let P=['<svg class="measureSvg">','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<circle cx="50" cy="50" r="5" fill="#f99d0b" />','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<polyline stroke="orange" stroke-width="2" points="0,0 0,0" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+f.text+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="angle-annotation",f.container.id=f.id,f.container.style.pointerEvents="none",f.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let d=new _e(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point1),g=new _e(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point2),y=new _e(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point3),v=e.engine.reactBoundingClientRect.left,x=e.engine.reactBoundingClientRect.top;d.x+=v,d.y+=x,g.x+=v,g.y+=x,y.x+=v,y.y+=x;let b=f.container;b.getElementsByTagName("circle")[0].setAttribute("cx",d.x),b.getElementsByTagName("circle")[0].setAttribute("cy",d.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",d.x+","+d.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=f.text,b.style.top="0px",b.style.left="0px"}function c(f){if(f.container==null){let D=['<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="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(f.text,2)+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="area-annotation",f.container.id=f.id,f.container.innerHTML=D,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}if(!f.points||f.points.length<3)return;let d=e.engine.reactBoundingClientRect.left,g=e.engine.reactBoundingClientRect.top,y=[],v=0,x=0;for(let D=0;D<f.points.length;D++){let k=new _e(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.points[D]);k.x+=d,k.y+=g,y.push(k),v+=k.x,x+=k.y}v=v/y.length,x=x/y.length;let b=y.map(D=>D.x+","+D.y).join(" "),_=f.container;_.getElementsByTagName("polygon")[0].setAttribute("points",b),_.getElementsByTagName("polyline")[0].setAttribute("points",b);let T=v,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(f.text,2),_.style.top="0px",_.style.left="0px"}function h(f){if(f.container==null){let T=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+f.id+'" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto" markerUnits="strokeWidth">','<path d="M0,0 L0,6 L9,3 z" fill="orange" stroke="orange" />',"</marker>","</defs>",'<polyline stroke="orange" stroke-width="2" points="0,0 0,0" marker-end="url(#slope-arrow-'+f.id+')" style="fill: none; opacity: 1;"/>','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="50" y="16" text-anchor="middle" class="measureLabel">'+f.text+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="slope-annotation",f.container.id=f.id,f.container.innerHTML=T,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let d=new _e(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point1),g=new _e(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point2),y=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;d.x+=y,d.y+=v,g.x+=y,g.y+=v;let x=f.container;x.getElementsByTagName("polyline")[0].setAttribute("points",d.x+","+d.y+" "+g.x+","+g.y);let b=(d.x+g.x)/2,_=(d.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=f.text,x.style.top="0px",x.style.left="0px"}function u(f){if(f.container==null){let P=['<svg class="measureSvg">','<circle cx="0" cy="0" r="5" fill="#f99d0b" />','<rect x="0" y="-25" width="100" height="25" class="measureBack" />','<text x="40" y="-11" text-anchor="middle" class="measureLabel">X: '+e.getMeasureText(f.textX,1)+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="40" y="25" text-anchor="middle" class="measureLabel">Y: '+e.getMeasureText(-f.textZ,1)+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="40" y="51" text-anchor="middle" class="measureLabel">Z: '+e.getMeasureText(f.textY,1)+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="coordinate-annotation",f.container.id=f.id,f.container.style.position="absolute",f.container.style.pointerEvents="none",f.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let d=f.container,g=new _e(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point),y=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;g.x+=y,g.y+=v,d.style.top="0px",d.style.left="0px";let x=d.getElementsByTagName("circle")[0];x&&(x.setAttribute("cx",g.x),x.setAttribute("cy",g.y));let b=d.getElementsByTagName("rect"),_=d.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(f.textX,1)),_[1]&&(_[1].innerHTML="Y: "+e.getMeasureText(-f.textZ,1)),_[2]&&(_[2].innerHTML="Z: "+e.getMeasureText(f.textY,1))}function m(f){if(f.container==null){let x=['<svg width="100" height="50" class="measureSvg">','<rect x="0" y="0" width="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(f.text,1)+"</text>",'<polyline stroke="#f99d0b" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");f.container=document.createElement("div"),f.container.className="elevation-annotation",f.container.id=f.id,f.container.style.position="absolute",f.container.style.pointerEvents="none",f.container.innerHTML=x,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let d=f.container,g=new _e(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point),y=e.engine.reactBoundingClientRect.left,v=e.engine.reactBoundingClientRect.top;d.style.top=g.y+v-48+"px",d.style.left=g.x+y-16+"px",d.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(f.text,1)}function p(f){if(f.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="100" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+e.getMeasureText(f.text,1)+"</text>","</svg>"].join("");f.container=document.createElement("div"),f.container.className="normal-annotation",f.container.id=f.id,f.container.innerHTML=b,e.engine.measure.annotationContainer.appendChild(f.container),f.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),f.container.getElementsByTagName("svg")[0].classList.add("Hight"),f.highlight=!0,e.engine.events.trigger(Me.MeasureClick,f)})}let d=f.container;if(f.point1==null||f.point2==null){d.style.display="none";return}else d.style.display="block";let g=new _e(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point1),y=new _e(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(f.point2),v=e.engine.reactBoundingClientRect.left,x=e.engine.reactBoundingClientRect.top;g.x+=v,g.y+=x,y.x+=v,y.y+=x,d.getElementsByTagName("polyline")[0].setAttribute("points",g.x+","+g.y+" "+y.x+","+y.y),d.getElementsByTagName("circle")[0].setAttribute("cx",g.x),d.getElementsByTagName("circle")[0].setAttribute("cy",g.y),d.getElementsByTagName("circle")[1].setAttribute("cx",y.x),d.getElementsByTagName("circle")[1].setAttribute("cy",y.y),d.getElementsByTagName("rect")[0].setAttribute("x",g.x*.5+y.x*.5-40),d.getElementsByTagName("rect")[0].setAttribute("y",g.y*.5+y.y*.5-12.5),d.getElementsByTagName("text")[0].setAttribute("x",g.x*.5+y.x*.5+40-40),d.getElementsByTagName("text")[0].setAttribute("y",g.y*.5+y.y*.5+16-12.5),d.getElementsByTagName("text")[0].innerHTML=e.getMeasureText(f.text,1),d.style.top="0px",d.style.left="0px"}}}class Ph{engine;isActive=!1;tools;points=[];behavior;catchDir=0;type="point";constructor(e){this.engine=e,this.tools=new at(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 o=new w.Box3().setFromObject(s);!Number.isFinite(o.min.y)||!Number.isFinite(o.max.y)||(o.min.y<t&&(t=o.min.y),o.max.y>n&&(n=o.max.y))}return!Number.isFinite(t)||!Number.isFinite(n)?null:{minY:t,maxY:n}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch.point;if(this.type=="element"){let s=this.engine.interactionModule.getCatchMeshs(e);var n=this.getMeshesMinMaxY(s);this.catchDir==0?t.set(t.x,n?.minY,t.z):t.set(t.x,n?.maxY,t.z)}else t=e.catch.point;if(this.points.length==0){this.points.push(t);return}let i=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);i!=null&&(i.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);t==null&&(t={text:null,id:rt(),isSelect:!0,type:"clear-height"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=e.catch;if(this.type=="element"){let i=e.catch.point.clone();i.set(i.x,this.points[0].y,i.z);let s=new w.Raycaster(i.add(new w.Vector3(0,.01,0)),new w.Vector3(0,this.catchDir==0?-1:1,0));n.point=this.points[0];const o=this.engine.octreeBox.rayInterationModel(s);if(o.length===0){t.point2=null;return}t.point1=i,t.point2=o[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Me.MeasureChanged,t)}else{let i=new w.Raycaster(e.catch.point.clone().add(new w.Vector3(0,.01,0)),new w.Vector3(0,this.catchDir==0?-1:1,0));const s=this.engine.octreeBox.rayInterationModel(i);if(s.length===0){t.point2=null;return}t.point1=n.point,t.point2=s[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Me.MeasureChanged,t)}}}class Th{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new at(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this,{showCatch:!0}),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.isActive=!1,this.engine.handelBehaved.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point2=t.point,n.isSelect=!1,this.points=[],this.engine.events.trigger(Me.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.normalAnnotation.find(i=>i.isSelect==!0);n==null&&(n={id:rt(),point1:this.points[0].clone(),point2:t.point.clone(),text:this.points[0].clone().distanceTo(t.point.clone()),type:"distance",isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(n)),n.point2=t.point,n.text=n.point1.clone().distanceTo(n.point2.clone())}}}class kh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new at(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(o=>o.isSelect==!0);t==null&&(t={text:null,id:rt(),isSelect:!0,type:"clear-distance"},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new w.Raycaster(e.catch.point.clone().add(e.catch.face.normal.clone().setLength(.01)),e.catch.face.normal);const i=this.engine.octreeBox.rayInterationModel(n);if(i.length==0){t.point2=null;return}let s=e.catch;t.point1=s.point,t.point2=i[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()),this.engine.events.trigger(Me.MeasureChanged,t)}}class Dh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new at(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:rt(),point:e.catch.point.clone(),text:e.catch.point.y,isSelect:!0,type:"elevation"},this.engine.measure.annotationData.elevationAnnotation.push(t)),t.point=e.catch.point.clone(),t.text=e.catch.point.y}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.text=e.catch.point.y,this.engine.events.trigger(Me.MeasureChanged,t))}}class Eh{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new at(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0;let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.isActive=!1,this.behavior?.disActive()}clearAllPoints(){this.points=[]}handleMouseUp(e){this.engine.deviceType!="PC"&&this.createMeasure()}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:rt(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0,type:"point"},this.engine.measure.annotationData.coordinateAnnotation.push(t)),t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.point=e.catch.point.clone(),t.textX=e.catch.point.x,t.textY=e.catch.point.y,t.textZ=e.catch.point.z,t.isSelect=!1,this.engine.events.trigger(Me.MeasureChanged,t))}createMeasure(){let e=this.engine.measure.annotationData.coordinateAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1,this.engine.events.trigger(Me.MeasureChanged,e))}}class Lh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new at(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 w.Vector3().subVectors(e,t),s=new w.Vector3().subVectors(n,t),o=i.length(),a=s.length();if(o===0||a===0)return 0;const c=i.dot(s)/(o*a),h=Math.max(-1,Math.min(1,c));return Math.acos(h)*(180/Math.PI)}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1)this.points.push(t.point);else if(this.points.length==2){let n=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);if(n==null)return;n.point3=t.point.clone(),n.angle=this.calculateAngle(n.point1,n.point2,n.point3),n.text=n.angle.toFixed(2)+"°",n.isSelect=!1,n.type="angle",this.points=[],this.engine.events.trigger(Me.MeasureChanged,n)}}handleMouseMove(e){if(e.catch!=null&&this.points.length!=1&&this.points.length==2){let t=this.engine.measure.annotationData.angleAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:rt(),point1:this.points[0].clone(),point2:this.points[1].clone(),point3:e.catch.point.clone(),angle:0,text:"0.00°",isSelect:!0,type:"angle"},this.engine.measure.annotationData.angleAnnotation.push(t)),t.point3=e.catch.point.clone(),t.angle=this.calculateAngle(t.point1,t.point2,t.point3),t.text=t.angle.toFixed(2)+"°",console.log("角度",t.text)}}}class Ih{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new at(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active();let e=this.engine.measure.annotationData.normalAnnotation.find(t=>t.isSelect==!0);e!=null&&(e.isSelect=!1)}disActive(){this.points=[],this.behavior?.disActive()}clearAllPoints(){this.points=[]}calculateArea(e){if(e.length<3)return 0;let t=0;const n=e.length;for(let i=0;i<n;i++){const s=(i+1)%n;t+=e[i].x*e[s].z,t-=e[s].x*e[i].z}return t=Math.abs(t)/2,t}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.push(t.point.clone()),this.points.length>=3){let n=this.engine.measure.annotationData.areaAnnotation.find(i=>i.isSelect==!0);n==null?(n={id:rt(),points:this.points.map(i=>i.clone()),area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(n)):(this.points.push(t.point.clone()),n.points=this.points.map(i=>i.clone())),n.area=this.calculateArea(n.points),n.text=n.area,console.log("面积",n.text)}}handleMouseMove(e){if(e.catch!=null&&this.points.length>=2){let t=this.engine.measure.annotationData.areaAnnotation.find(n=>n.isSelect==!0);if(t==null){if(this.points.length>=2){let n=this.points.map(i=>i.clone());n.push(e.catch.point.clone()),n.length>=3&&(t={id:rt(),points:n,area:0,text:0,isSelect:!0,type:"area"},this.engine.measure.annotationData.areaAnnotation.push(t))}}else if(t.points.length>0){const n=t.points.length-1;t.points[n]=e.catch.point.clone()}else t.points=this.points.map(n=>n.clone()),t.points.push(e.catch.point.clone());t&&t.points.length>=3&&(t.area=this.calculateArea(t.points),t.text=t.area)}}handelKeyEnterDown(){this.finishMeasure()}finishMeasure(){this.points=this.points.slice(0,this.points.length-1);let e=this.engine.measure.annotationData.areaAnnotation.find(t=>t.isSelect==!0);e!=null&&e.points.length>=3&&(e.points.length>this.points.length&&(e.points=this.points.map(t=>t.clone())),e.area=this.calculateArea(e.points),e.text=e.area,e.isSelect=!1,this.points=[],this.engine.events.trigger(Me.MeasureChanged,e))}}class zh{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new at(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,o=Math.sqrt(i*i+s*s);if(o===0)return{percentage:0,angle:0,heightDiff:n,horizontalDist:0,type:"slope"};const a=n/o*100,c=Math.atan(n/o)*(180/Math.PI);return{percentage:a,angle:c,heightDiff:n,horizontalDist:o,type:"slope"}}handleMouseClick(e){if(e.catch==null)return;let t=e.catch;if(this.points.length==0)this.points.push(t.point);else if(this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);if(n==null)return;console.log("进来了"),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)",n.isSelect=!1,this.points=[],this.engine.events.trigger(Me.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=e.catch;if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(s=>s.isSelect==!0);n==null&&(n={id:rt(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"0.00% (0.00°)",isSelect:!0,type:"slope"},this.engine.measure.annotationData.slopeAnnotation.push(n)),n.point2=t.point.clone();const i=this.calculateSlope(n.point1,n.point2);n.slopePercentage=i.percentage,n.slopeAngle=i.angle,n.heightDiff=i.heightDiff,n.horizontalDist=i.horizontalDist,n.text=i.percentage.toFixed(2)+"% ("+i.angle.toFixed(2)+"°)"}}}class Bh{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 Ph(e),this.distanceMeasure=new Th(e),this.clearDistanceMeasure=new kh(e),this.elevationMeasure=new Dh(e),this.pointMeasure=new Eh(e),this.angleMeasure=new Lh(e),this.areaMeasure=new Ih(e),this.slopeMeasure=new zh(e),this.tools=new at(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 Qo=0,Rh=1,Oh=2,er=2,ns=1.25,tr=1,Le=32,Se=Le/4,nr=65535,Nh=Math.pow(2,-24),is=Symbol("SKIP_GENERATION");function Fh(r){return r.index?r.index.count:r.attributes.position.count}function Dt(r){return Fh(r)/3}function Uh(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function Vh(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Uh(t,n);r.setIndex(new M.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function ir(r,e){const t=Dt(r),n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,o=Math.max(0,i),a=Math.min(t,s)-o;return[{offset:Math.floor(o),count:Math.floor(a)}]}function sr(r,e){if(!r.groups||!r.groups.length)return ir(r,e);const t=[],n=e||r.drawRange,i=n.start/3,s=(n.start+n.count)/3,o=Dt(r),a=[];for(const h of r.groups){const{start:u,count:m}=h,p=u/3,f=isFinite(m)?m:o*3-u,d=(u+f)/3;p<s&&d>i&&(a.push({pos:Math.max(i,p),isStart:!0}),a.push({pos:Math.min(s,d),isStart:!1}))}a.sort((h,u)=>h.pos!==u.pos?h.pos-u.pos:h.type==="end"?-1:1);let l=0,c=null;for(const h of a){const u=h.pos;l!==0&&u!==c&&t.push({offset:c,count:u-c}),l+=h.isStart?1:-1,c=u}return t}function ss(r,e,t,n,i){let s=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,h=-1/0,u=1/0,m=1/0,p=1/0,f=-1/0,d=-1/0,g=-1/0;const y=r.offset||0;for(let v=(e-y)*6,x=(e+t-y)*6;v<x;v+=6){const b=r[v+0],_=r[v+1],T=b-_,P=b+_;T<s&&(s=T),P>l&&(l=P),b<u&&(u=b),b>f&&(f=b);const D=r[v+2],k=r[v+3],E=D-k,R=D+k;E<o&&(o=E),R>c&&(c=R),D<m&&(m=D),D>d&&(d=D);const A=r[v+4],I=r[v+5],S=A-I,z=A+I;S<a&&(a=S),z>h&&(h=z),A<p&&(p=A),A>g&&(g=A)}n[0]=s,n[1]=o,n[2]=a,n[3]=l,n[4]=c,n[5]=h,i[0]=u,i[1]=m,i[2]=p,i[3]=f,i[4]=d,i[5]=g}function or(r,e,t=null,n=null,i=null){const s=r.attributes.position,o=r.index?r.index.array:null,a=s.normalized;if(i===null)i=new Float32Array(t*6),i.offset=e;else if(e<0||t+e>i.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const l=s.array,c=s.offset||0;let h=3;s.isInterleavedBufferAttribute&&(h=s.data.stride);const u=["getX","getY","getZ"],m=i.offset;for(let p=e,f=e+t;p<f;p++){const g=(n?n[p]:p)*3,y=(p-m)*6;let v=g+0,x=g+1,b=g+2;o&&(v=o[v],x=o[x],b=o[b]),a||(v=v*h+c,x=x*h+c,b=b*h+c);for(let _=0;_<3;_++){let T,P,D;a?(T=s[u[_]](v),P=s[u[_]](x),D=s[u[_]](b)):(T=l[v+_],P=l[x+_],D=l[b+_]);let k=T;P<k&&(k=P),D<k&&(k=D);let E=T;P>E&&(E=P),D>E&&(E=D);const R=(E-k)/2,A=_*2;i[y+A+0]=k+R,i[y+A+1]=R+(Math.abs(k)+R)*Nh}}return i}function ve(r,e,t){return t.min.x=e[r],t.min.y=e[r+1],t.min.z=e[r+2],t.max.x=e[r+3],t.max.y=e[r+4],t.max.z=e[r+5],t}function rr(r){let e=-1,t=-1/0;for(let n=0;n<3;n++){const i=r[n+3]-r[n];i>t&&(t=i,e=n)}return e}function ar(r,e){e.set(r)}function lr(r,e,t){let n,i;for(let s=0;s<3;s++){const o=s+3;n=r[s],i=e[s],t[s]=n<i?n:i,n=r[o],i=e[o],t[o]=n>i?n:i}}function ii(r,e,t){for(let n=0;n<3;n++){const i=e[r+2*n],s=e[r+2*n+1],o=i-s,a=i+s;o<t[n]&&(t[n]=o),a>t[n+3]&&(t[n+3]=a)}}function mn(r){const e=r[3]-r[0],t=r[4]-r[1],n=r[5]-r[2];return 2*(e*t+t*n+n*e)}const lt=32,Gh=(r,e)=>r.candidate-e.candidate,mt=new Array(lt).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),si=new Float32Array(6);function jh(r,e,t,n,i,s){let o=-1,a=0;if(s===Qo)o=rr(e),o!==-1&&(a=(e[o]+e[o+3])/2);else if(s===Rh)o=rr(r),o!==-1&&(a=Wh(t,n,i,o));else if(s===Oh){const l=mn(r);let c=ns*i;const h=t.offset||0,u=(n-h)*6,m=(n+i-h)*6;for(let p=0;p<3;p++){const f=e[p],y=(e[p+3]-f)/lt;if(i<lt/4){const v=[...mt];v.length=i;let x=0;for(let _=u;_<m;_+=6,x++){const T=v[x];T.candidate=t[_+2*p],T.count=0;const{bounds:P,leftCacheBounds:D,rightCacheBounds:k}=T;for(let E=0;E<3;E++)k[E]=1/0,k[E+3]=-1/0,D[E]=1/0,D[E+3]=-1/0,P[E]=1/0,P[E+3]=-1/0;ii(_,t,P)}v.sort(Gh);let b=i;for(let _=0;_<b;_++){const T=v[_];for(;_+1<b&&v[_+1].candidate===T.candidate;)v.splice(_+1,1),b--}for(let _=u;_<m;_+=6){const T=t[_+2*p];for(let P=0;P<b;P++){const D=v[P];T>=D.candidate?ii(_,t,D.rightCacheBounds):(ii(_,t,D.leftCacheBounds),D.count++)}}for(let _=0;_<b;_++){const T=v[_],P=T.count,D=i-T.count,k=T.leftCacheBounds,E=T.rightCacheBounds;let R=0;P!==0&&(R=mn(k)/l);let A=0;D!==0&&(A=mn(E)/l);const I=tr+ns*(R*P+A*D);I<c&&(o=p,c=I,a=T.candidate)}}else{for(let b=0;b<lt;b++){const _=mt[b];_.count=0,_.candidate=f+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<m;b+=6){let P=~~((t[b+2*p]-f)/y);P>=lt&&(P=lt-1);const D=mt[P];D.count++,ii(b,t,D.bounds)}const v=mt[lt-1];ar(v.bounds,v.rightCacheBounds);for(let b=lt-2;b>=0;b--){const _=mt[b],T=mt[b+1];lr(_.bounds,T.rightCacheBounds,_.rightCacheBounds)}let x=0;for(let b=0;b<lt-1;b++){const _=mt[b],T=_.count,P=_.bounds,k=mt[b+1].rightCacheBounds;T!==0&&(x===0?ar(P,si):lr(P,si,si)),x+=T;let E=0,R=0;x!==0&&(E=mn(si)/l);const A=i-x;A!==0&&(R=mn(k)/l);const I=tr+ns*(E*x+R*A);I<c&&(o=p,c=I,a=_.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${s} used.`);return{axis:o,pos:a}}function Wh(r,e,t,n){let i=0;const s=r.offset;for(let o=e,a=e+t;o<a;o++)i+=r[(o-s)*6+n*2];return i/t}class os{constructor(){this.boundingData=new Float32Array(6)}}function Xh(r,e,t,n,i,s){let o=n,a=n+i-1;const l=s.pos,c=s.axis*2,h=t.offset||0;for(;;){for(;o<=a&&t[(o-h)*6+c]<l;)o++;for(;o<=a&&t[(a-h)*6+c]>=l;)a--;if(o<a){for(let u=0;u<3;u++){let m=e[o*3+u];e[o*3+u]=e[a*3+u],e[a*3+u]=m}for(let u=0;u<6;u++){const m=o-h,p=a-h,f=t[m*6+u];t[m*6+u]=t[p*6+u],t[p*6+u]=f}o++,a--}else return o}}function Zh(r,e,t,n,i,s){let o=n,a=n+i-1;const l=s.pos,c=s.axis*2,h=t.offset||0;for(;;){for(;o<=a&&t[(o-h)*6+c]<l;)o++;for(;o<=a&&t[(a-h)*6+c]>=l;)a--;if(o<a){let u=r[o];r[o]=r[a],r[a]=u;for(let m=0;m<6;m++){const p=o-h,f=a-h,d=t[p*6+m];t[p*6+m]=t[f*6+m],t[f*6+m]=d}o++,a--}else return o}}let cr,oi,rs,hr;const Yh=Math.pow(2,32);function as(r){return"count"in r?1:1+as(r.left)+as(r.right)}function Kh(r,e,t){return cr=new Float32Array(t),oi=new Uint32Array(t),rs=new Uint16Array(t),hr=new Uint8Array(t),ls(r,e)}function ls(r,e){const t=r/4,n=r/2,i="count"in e,s=e.boundingData;for(let o=0;o<6;o++)cr[t+o]=s[o];if(i)return e.buffer?(hr.set(new Uint8Array(e.buffer),r),r+e.buffer.byteLength):(oi[t+6]=e.offset,rs[n+14]=e.count,rs[n+15]=nr,r+Le);{const{left:o,right:a,splitAxis:l}=e,c=r+Le;let h=ls(c,o);const u=r/Le,p=h/Le-u;if(p>Yh)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return oi[t+6]=p,oi[t+7]=l,ls(h,a)}}function $h(r,e,t){const i=(r.index?r.index.count:r.attributes.position.count)/3>2**16,s=t.reduce((h,u)=>h+u.count,0),o=i?4:2,a=e?new SharedArrayBuffer(s*o):new ArrayBuffer(s*o),l=i?new Uint32Array(a):new Uint16Array(a);let c=0;for(let h=0;h<t.length;h++){const{offset:u,count:m}=t[h];for(let p=0;p<m;p++)l[c+p]=u+p;c+=m}return l}function qh(r,e,t,n,i){const{maxDepth:s,verbose:o,maxLeafTris:a,strategy:l,onProgress:c,indirect:h}=i,u=r._indirectBuffer,m=r.geometry,p=m.index?m.index.array:null,f=h?Zh:Xh,d=Dt(m),g=new Float32Array(6);let y=!1;const v=new os;return ss(e,t,n,v.boundingData,g),b(v,t,n,g),v;function x(_){c&&c(_/d)}function b(_,T,P,D=null,k=0){if(!y&&k>=s&&(y=!0,o&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(m))),P<=a||k>=s)return x(T+P),_.offset=T,_.count=P,_;const E=jh(_.boundingData,D,e,T,P,l);if(E.axis===-1)return x(T+P),_.offset=T,_.count=P,_;const R=f(u,p,e,T,P,E);if(R===T||R===T+P)x(T+P),_.offset=T,_.count=P;else{_.splitAxis=E.axis;const A=new os,I=T,S=R-T;_.left=A,ss(e,I,S,A.boundingData,g),b(A,I,S,g,k+1);const z=new os,U=R,V=P-S;_.right=z,ss(e,U,V,z.boundingData,g),b(z,U,V,g,k+1)}return _}}function Hh(r,e){const t=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,n=r.geometry;let i,s;if(e.indirect){const o=sr(n,e.range),a=$h(n,e.useSharedArrayBuffer,o);r._indirectBuffer=a,i=or(n,0,a.length,a),s=[{offset:0,count:a.length}]}else{Vh(n,e);const o=ir(n,e.range)[0];i=or(n,o.offset,o.count),s=sr(n,e.range)}r._roots=s.map(o=>{const a=qh(r,i,o.offset,o.count,e),l=as(a),c=new t(Le*l);return Kh(0,a,c),c})}class ct{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let n=1/0,i=-1/0;for(let s=0,o=e.length;s<o;s++){const l=e[s][t];n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}setFromPoints(e,t){let n=1/0,i=-1/0;for(let s=0,o=t.length;s<o;s++){const a=t[s],l=e.dot(a);n=l<n?l:n,i=l>i?l:i}this.min=n,this.max=i}isSeparated(e){return this.min>e.max||e.min>this.max}}ct.prototype.setFromBox=(function(){const r=new M.Vector3;return function(t,n){const i=n.min,s=n.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){r.x=i.x*l+s.x*(1-l),r.y=i.y*c+s.y*(1-c),r.z=i.z*h+s.z*(1-h);const u=t.dot(r);o=Math.min(u,o),a=Math.max(u,a)}this.min=o,this.max=a}})();const Jh=(function(){const r=new M.Vector3,e=new M.Vector3,t=new M.Vector3;return function(i,s,o){const a=i.start,l=r,c=s.start,h=e;t.subVectors(a,c),r.subVectors(i.end,i.start),e.subVectors(s.end,s.start);const u=t.dot(h),m=h.dot(l),p=h.dot(h),f=t.dot(l),g=l.dot(l)*p-m*m;let y,v;g!==0?y=(u*m-f*p)/g:y=0,v=(u+y*m)/p,o.x=y,o.y=v}})(),cs=(function(){const r=new M.Vector2,e=new M.Vector3,t=new M.Vector3;return function(i,s,o,a){Jh(i,s,r);let l=r.x,c=r.y;if(l>=0&&l<=1&&c>=0&&c<=1){i.at(l,o),s.at(c,a);return}else if(l>=0&&l<=1){c<0?s.at(0,a):s.at(1,a),i.closestPointToPoint(a,!0,o);return}else if(c>=0&&c<=1){l<0?i.at(0,o):i.at(1,o),s.closestPointToPoint(o,!0,a);return}else{let h;l<0?h=i.start:h=i.end;let u;c<0?u=s.start:u=s.end;const m=e,p=t;if(i.closestPointToPoint(u,!0,e),s.closestPointToPoint(h,!0,t),m.distanceToSquared(u)<=p.distanceToSquared(h)){o.copy(m),a.copy(u);return}else{o.copy(h),a.copy(p);return}}}})(),Qh=(function(){const r=new M.Vector3,e=new M.Vector3,t=new M.Plane,n=new M.Line3;return function(s,o){const{radius:a,center:l}=s,{a:c,b:h,c:u}=o;if(n.start=c,n.end=h,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(n.start=c,n.end=u,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(n.start=h,n.end=u,n.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;const d=o.getPlane(t);if(Math.abs(d.distanceToPoint(l))<=a){const y=d.projectPoint(l,e);if(o.containsPoint(y))return!0}return!1}})(),ed=["x","y","z"],ht=1e-15,dr=ht*ht;function je(r){return Math.abs(r)<ht}class We extends M.Triangle{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new M.Vector3),this.satBounds=new Array(4).fill().map(()=>new ct),this.points=[this.a,this.b,this.c],this.plane=new M.Plane,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new M.Line3,this.needsUpdate=!0}intersectsSphere(e){return Qh(e,this)}update(){const e=this.a,t=this.b,n=this.c,i=this.points,s=this.satAxes,o=this.satBounds,a=s[0],l=o[0];this.getNormal(a),l.setFromPoints(a,i);const c=s[1],h=o[1];c.subVectors(e,t),h.setFromPoints(c,i);const u=s[2],m=o[2];u.subVectors(t,n),m.setFromPoints(u,i);const p=s[3],f=o[3];p.subVectors(n,e),f.setFromPoints(p,i);const d=c.length(),g=u.length(),y=p.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,d<ht?g<ht||y<ht?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(n)):g<ht?y<ht?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(e)):y<ht&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(n),this.degenerateSegment.end.copy(t)),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}We.prototype.closestPointToSegment=(function(){const r=new M.Vector3,e=new M.Vector3,t=new M.Line3;return function(i,s=null,o=null){const{start:a,end:l}=i,c=this.points;let h,u=1/0;for(let m=0;m<3;m++){const p=(m+1)%3;t.start.copy(c[m]),t.end.copy(c[p]),cs(t,i,r,e),h=r.distanceToSquared(e),h<u&&(u=h,s&&s.copy(r),o&&o.copy(e))}return this.closestPointToPoint(a,r),h=a.distanceToSquared(r),h<u&&(u=h,s&&s.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),h=l.distanceToSquared(r),h<u&&(u=h,s&&s.copy(r),o&&o.copy(l)),Math.sqrt(u)}})(),We.prototype.intersectsTriangle=(function(){const r=new We,e=new ct,t=new ct,n=new M.Vector3,i=new M.Vector3,s=new M.Vector3,o=new M.Vector3,a=new M.Line3,l=new M.Line3,c=new M.Vector3,h=new M.Vector2,u=new M.Vector2;function m(x,b,_,T){const P=n;!x.isDegenerateIntoPoint&&!x.isDegenerateIntoSegment?P.copy(x.plane.normal):P.copy(b.plane.normal);const D=x.satBounds,k=x.satAxes;for(let A=1;A<4;A++){const I=D[A],S=k[A];if(e.setFromPoints(S,b.points),I.isSeparated(e)||(o.copy(P).cross(S),e.setFromPoints(o,x.points),t.setFromPoints(o,b.points),e.isSeparated(t)))return!1}const E=b.satBounds,R=b.satAxes;for(let A=1;A<4;A++){const I=E[A],S=R[A];if(e.setFromPoints(S,x.points),I.isSeparated(e)||(o.crossVectors(P,S),e.setFromPoints(o,x.points),t.setFromPoints(o,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 p(x,b,_,T,P,D,k,E,R,A,I){let S=k/(k-E);A.x=T+(P-T)*S,I.start.subVectors(b,x).multiplyScalar(S).add(x),S=k/(k-R),A.y=T+(D-T)*S,I.end.subVectors(_,x).multiplyScalar(S).add(x)}function f(x,b,_,T,P,D,k,E,R,A,I){if(P>0)p(x.c,x.a,x.b,T,b,_,R,k,E,A,I);else if(D>0)p(x.b,x.a,x.c,_,b,T,E,k,R,A,I);else if(E*R>0||k!=0)p(x.a,x.b,x.c,b,_,T,k,E,R,A,I);else if(E!=0)p(x.b,x.a,x.c,_,b,T,E,k,R,A,I);else if(R!=0)p(x.c,x.a,x.b,T,b,_,R,k,E,A,I);else return!0;return!1}function d(x,b,_,T){const P=b.degenerateSegment,D=x.plane.distanceToPoint(P.start),k=x.plane.distanceToPoint(P.end);return je(D)?je(k)?m(x,b,_,T):(_&&(_.start.copy(P.start),_.end.copy(P.start)),x.containsPoint(P.start)):je(k)?(_&&(_.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)<dr?(_&&(_.start.copy(P),_.end.copy(P)),!0):!1}function v(x,b,_,T){if(x.isDegenerateIntoSegment)if(b.isDegenerateIntoSegment){const P=x.degenerateSegment,D=b.degenerateSegment,k=i,E=s;P.delta(k),D.delta(E);const R=n.subVectors(D.start,P.start),A=k.x*E.y-k.y*E.x;if(je(A))return!1;const I=(R.x*E.y-R.y*E.x)/A,S=-(k.x*R.y-k.y*R.x)/A;if(I<0||I>1||S<0||S>1)return!1;const z=P.start.z+k.z*I,U=D.start.z+E.z*S;return je(z-U)?(_&&(_.start.copy(P.start).addScaledVector(k,I),_.end.copy(P.start).addScaledVector(k,I)),!0):!1}else return b.isDegenerateIntoPoint?y(x,b,_):d(b,x,_,T);else{if(x.isDegenerateIntoPoint)return b.isDegenerateIntoPoint?b.a.distanceToSquared(x.a)<dr?(_&&(_.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 d(x,b,_,T)}}return function(b,_=null,T=!1){this.needsUpdate&&this.update(),b.isExtendedTriangle?b.needsUpdate&&b.update():(r.copy(b),r.update(),b=r);const P=v(this,b,_,T);if(P!==void 0)return P;const D=this.plane,k=b.plane;let E=k.distanceToPoint(this.a),R=k.distanceToPoint(this.b),A=k.distanceToPoint(this.c);je(E)&&(E=0),je(R)&&(R=0),je(A)&&(A=0);const I=E*R,S=E*A;if(I>0&&S>0)return!1;let z=D.distanceToPoint(b.a),U=D.distanceToPoint(b.b),V=D.distanceToPoint(b.c);je(z)&&(z=0),je(U)&&(U=0),je(V)&&(V=0);const $=z*U,G=z*V;if($>0&&G>0)return!1;i.copy(D.normal),s.copy(k.normal);const q=i.cross(s);let N=0,O=Math.abs(q.x);const ee=Math.abs(q.y);ee>O&&(O=ee,N=1),Math.abs(q.z)>O&&(N=2);const H=ed[N],ce=this.a[H],fe=this.b[H],se=this.c[H],re=b.a[H],de=b.b[H],pe=b.c[H];if(f(this,ce,fe,se,I,S,E,R,A,h,a))return m(this,b,_,T);if(f(b,re,de,pe,$,G,z,U,V,u,l))return m(this,b,_,T);if(h.y<h.x){const Ae=h.y;h.y=h.x,h.x=Ae,c.copy(a.start),a.start.copy(a.end),a.end.copy(c)}if(u.y<u.x){const Ae=u.y;u.y=u.x,u.x=Ae,c.copy(l.start),l.start.copy(l.end),l.end.copy(c)}return h.y<u.x||u.y<h.x?!1:(_&&(u.x>h.x?_.start.copy(l.start):_.start.copy(a.start),u.y<h.y?_.end.copy(l.end):_.end.copy(a.end)),!0)}})(),We.prototype.distanceToPoint=(function(){const r=new M.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})(),We.prototype.distanceToTriangle=(function(){const r=new M.Vector3,e=new M.Vector3,t=["a","b","c"],n=new M.Line3,i=new M.Line3;return function(o,a=null,l=null){const c=a||l?n:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let h=1/0;for(let u=0;u<3;u++){let m;const p=t[u],f=o[p];this.closestPointToPoint(f,r),m=f.distanceToSquared(r),m<h&&(h=m,a&&a.copy(r),l&&l.copy(f));const d=this[p];o.closestPointToPoint(d,r),m=d.distanceToSquared(r),m<h&&(h=m,a&&a.copy(d),l&&l.copy(r))}for(let u=0;u<3;u++){const m=t[u],p=t[(u+1)%3];n.set(this[m],this[p]);for(let f=0;f<3;f++){const d=t[f],g=t[(f+1)%3];i.set(o[d],o[g]),cs(n,i,r,e);const y=r.distanceToSquared(e);y<h&&(h=y,a&&a.copy(r),l&&l.copy(e))}}return Math.sqrt(h)}})();class Ie{constructor(e,t,n){this.isOrientedBox=!0,this.min=new M.Vector3,this.max=new M.Vector3,this.matrix=new M.Matrix4,this.invMatrix=new M.Matrix4,this.points=new Array(8).fill().map(()=>new M.Vector3),this.satAxes=new Array(3).fill().map(()=>new M.Vector3),this.satBounds=new Array(3).fill().map(()=>new ct),this.alignedSatBounds=new Array(3).fill().map(()=>new ct),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),n&&this.matrix.copy(n)}set(e,t,n){this.min.copy(e),this.max.copy(t),this.matrix.copy(n),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}Ie.prototype.update=(function(){return function(){const e=this.matrix,t=this.min,n=this.max,i=this.points;for(let c=0;c<=1;c++)for(let h=0;h<=1;h++)for(let u=0;u<=1;u++){const m=1*c|2*h|4*u,p=i[m];p.x=c?n.x:t.x,p.y=h?n.y:t.y,p.z=u?n.z:t.z,p.applyMatrix4(e)}const s=this.satBounds,o=this.satAxes,a=i[0];for(let c=0;c<3;c++){const h=o[c],u=s[c],m=1<<c,p=i[m];h.subVectors(a,p),u.setFromPoints(h,i)}const l=this.alignedSatBounds;l[0].setFromPointsField(i,"x"),l[1].setFromPointsField(i,"y"),l[2].setFromPointsField(i,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}})(),Ie.prototype.intersectsBox=(function(){const r=new ct;return function(t){this.needsUpdate&&this.update();const n=t.min,i=t.max,s=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=n.x,r.max=i.x,a[0].isSeparated(r)||(r.min=n.y,r.max=i.y,a[1].isSeparated(r))||(r.min=n.z,r.max=i.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){const c=o[l],h=s[l];if(r.setFromBox(c,t),h.isSeparated(r))return!1}return!0}})(),Ie.prototype.intersectsTriangle=(function(){const r=new We,e=new Array(3),t=new ct,n=new ct,i=new M.Vector3;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);const a=this.satBounds,l=this.satAxes;e[0]=o.a,e[1]=o.b,e[2]=o.c;for(let m=0;m<3;m++){const p=a[m],f=l[m];if(t.setFromPoints(f,e),p.isSeparated(t))return!1}const c=o.satBounds,h=o.satAxes,u=this.points;for(let m=0;m<3;m++){const p=c[m],f=h[m];if(t.setFromPoints(f,u),p.isSeparated(t))return!1}for(let m=0;m<3;m++){const p=l[m];for(let f=0;f<4;f++){const d=h[f];if(i.crossVectors(p,d),t.setFromPoints(i,e),n.setFromPoints(i,u),t.isSeparated(n))return!1}}return!0}})(),Ie.prototype.closestPointToPoint=(function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}})(),Ie.prototype.distanceToPoint=(function(){const r=new M.Vector3;return function(t){return this.closestPointToPoint(t,r),t.distanceTo(r)}})(),Ie.prototype.distanceToBox=(function(){const r=["x","y","z"],e=new Array(12).fill().map(()=>new M.Line3),t=new Array(12).fill().map(()=>new M.Line3),n=new M.Vector3,i=new M.Vector3;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(i),this.closestPointToPoint(i,n),o.closestPointToPoint(n,i),l&&l.copy(n),c&&c.copy(i)),0;const h=a*a,u=o.min,m=o.max,p=this.points;let f=1/0;for(let g=0;g<8;g++){const y=p[g];i.copy(y).clamp(u,m);const v=y.distanceToSquared(i);if(v<f&&(f=v,l&&l.copy(y),c&&c.copy(i),v<h))return Math.sqrt(v)}let d=0;for(let g=0;g<3;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){const x=(g+1)%3,b=(g+2)%3,_=y<<x|v<<b,T=1<<g|y<<x|v<<b,P=p[_],D=p[T];e[d].set(P,D);const E=r[g],R=r[x],A=r[b],I=t[d],S=I.start,z=I.end;S[E]=u[E],S[R]=y?u[R]:m[R],S[A]=v?u[A]:m[R],z[E]=m[E],z[R]=y?u[R]:m[R],z[A]=v?u[A]:m[R],d++}for(let g=0;g<=1;g++)for(let y=0;y<=1;y++)for(let v=0;v<=1;v++){i.x=g?m.x:u.x,i.y=y?m.y:u.y,i.z=v?m.z:u.z,this.closestPointToPoint(i,n);const x=i.distanceToSquared(n);if(x<f&&(f=x,l&&l.copy(n),c&&c.copy(i),x<h))return Math.sqrt(x)}for(let g=0;g<12;g++){const y=e[g];for(let v=0;v<12;v++){const x=t[v];cs(y,x,n,i);const b=n.distanceToSquared(i);if(b<f&&(f=b,l&&l.copy(n),c&&c.copy(i),b<h))return Math.sqrt(b)}}return Math.sqrt(f)}})();class hs{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 td extends hs{constructor(){super(()=>new We)}}const Xe=new td;function Ce(r,e){return e[r+15]===nr}function Ue(r,e){return e[r+6]}function Ze(r,e){return e[r+14]}function Te(r){return r+Se}function ke(r,e){const t=e[r+6];return r+t*Se}function ds(r,e){return e[r+7]}function yp(r){return r}class nd{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 nd;let gt,qt;const Ht=[],ri=new hs(()=>new M.Box3);function id(r,e,t,n,i,s){gt=ri.getPrimitive(),qt=ri.getPrimitive(),Ht.push(gt,qt),me.setBuffer(r._roots[e]);const o=us(0,r.geometry,t,n,i,s);me.clearBuffer(),ri.releasePrimitive(gt),ri.releasePrimitive(qt),Ht.pop(),Ht.pop();const a=Ht.length;return a>0&&(qt=Ht[a-1],gt=Ht[a-2]),o}function us(r,e,t,n,i=null,s=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:c}=me;let h=r*2;if(Ce(h,l)){const m=Ue(r,c),p=Ze(h,l);return ve(r,a,gt),n(m,p,!1,o,s+r/Se,gt)}else{let E=function(A){const{uint16Array:I,uint32Array:S}=me;let z=A*2;for(;!Ce(z,I);)A=Te(A),z=A*2;return Ue(A,S)},R=function(A){const{uint16Array:I,uint32Array:S}=me;let z=A*2;for(;!Ce(z,I);)A=ke(A,S),z=A*2;return Ue(A,S)+Ze(z,I)};const m=Te(r),p=ke(r,c);let f=m,d=p,g,y,v,x;if(i&&(v=gt,x=qt,ve(f,a,v),ve(d,a,x),g=i(v),y=i(x),y<g)){f=p,d=m;const A=g;g=y,y=A,v=x}v||(v=gt,ve(f,a,v));const b=Ce(f*2,l),_=t(v,b,g,o+1,s+f/Se);let T;if(_===er){const A=E(f),S=R(f)-A;T=n(A,S,!0,o+1,s+f/Se,v)}else T=_&&us(f,e,t,n,i,s,o+1);if(T)return!0;x=qt,ve(d,a,x);const P=Ce(d*2,l),D=t(x,P,y,o+1,s+d/Se);let k;if(D===er){const A=E(d),S=R(d)-A;k=n(A,S,!0,o+1,s+d/Se,x)}else k=D&&us(d,e,t,n,i,s,o+1);return!!k}}const gn=new M.Vector3,fs=new M.Vector3;function sd(r,e,t={},n=0,i=1/0){const s=n*n,o=i*i;let a=1/0,l=null;if(r.shapecast({boundsTraverseOrder:h=>(gn.copy(e).clamp(h.min,h.max),gn.distanceToSquared(e)),intersectsBounds:(h,u,m)=>m<a&&m<o,intersectsTriangle:(h,u)=>{h.closestPointToPoint(e,gn);const m=e.distanceToSquared(gn);return m<a&&(fs.copy(gn),a=m,l=u),m<s}}),a===1/0)return null;const c=Math.sqrt(a);return t.point?t.point.copy(fs):t.point=fs.clone(),t.distance=c,t.faceIndex=l,t}const ai=parseInt(M.REVISION)>=169,od=parseInt(M.REVISION)<=161,Et=new M.Vector3,Lt=new M.Vector3,It=new M.Vector3,li=new M.Vector2,ci=new M.Vector2,hi=new M.Vector2,ur=new M.Vector3,fr=new M.Vector3,pr=new M.Vector3,yn=new M.Vector3;function rd(r,e,t,n,i,s,o,a){let l;if(s===M.BackSide?l=r.intersectTriangle(n,t,e,!0,i):l=r.intersectTriangle(e,t,n,s!==M.DoubleSide,i),l===null)return null;const c=r.origin.distanceTo(i);return c<o||c>a?null:{distance:c,point:i.clone()}}function mr(r,e,t,n,i,s,o,a,l,c,h){Et.fromBufferAttribute(e,s),Lt.fromBufferAttribute(e,o),It.fromBufferAttribute(e,a);const u=rd(r,Et,Lt,It,yn,l,c,h);if(u){if(n){li.fromBufferAttribute(n,s),ci.fromBufferAttribute(n,o),hi.fromBufferAttribute(n,a),u.uv=new M.Vector2;const p=M.Triangle.getInterpolation(yn,Et,Lt,It,li,ci,hi,u.uv);ai||(u.uv=p)}if(i){li.fromBufferAttribute(i,s),ci.fromBufferAttribute(i,o),hi.fromBufferAttribute(i,a),u.uv1=new M.Vector2;const p=M.Triangle.getInterpolation(yn,Et,Lt,It,li,ci,hi,u.uv1);ai||(u.uv1=p),od&&(u.uv2=u.uv1)}if(t){ur.fromBufferAttribute(t,s),fr.fromBufferAttribute(t,o),pr.fromBufferAttribute(t,a),u.normal=new M.Vector3;const p=M.Triangle.getInterpolation(yn,Et,Lt,It,ur,fr,pr,u.normal);u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1),ai||(u.normal=p)}const m={a:s,b:o,c:a,normal:new M.Vector3,materialIndex:0};if(M.Triangle.getNormal(Et,Lt,It,m.normal),u.face=m,u.faceIndex=s,ai){const p=new M.Vector3;M.Triangle.getBarycoord(yn,Et,Lt,It,p),u.barycoord=p}}return u}function gr(r){return r&&r.isMaterial?r.side:r}function di(r,e,t,n,i,s,o){const a=n*3;let l=a+0,c=a+1,h=a+2;const{index:u,groups:m}=r;r.index&&(l=u.getX(l),c=u.getX(c),h=u.getX(h));const{position:p,normal:f,uv:d,uv1:g}=r.attributes;if(Array.isArray(e)){const y=n*3;for(let v=0,x=m.length;v<x;v++){const{start:b,count:_,materialIndex:T}=m[v];if(y>=b&&y<b+_){const P=gr(e[T]),D=mr(t,p,f,d,g,l,c,h,P,s,o);if(D)if(D.faceIndex=n,D.face.materialIndex=T,i)i.push(D);else return D}}}else{const y=gr(e),v=mr(t,p,f,d,g,l,c,h,y,s,o);if(v)if(v.faceIndex=n,v.face.materialIndex=0,i)i.push(v);else return v}return null}function be(r,e,t,n){const i=r.a,s=r.b,o=r.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),i.x=n.getX(a),i.y=n.getY(a),i.z=n.getZ(a),s.x=n.getX(l),s.y=n.getY(l),s.z=n.getZ(l),o.x=n.getX(c),o.y=n.getY(c),o.z=n.getZ(c)}function ad(r,e,t,n,i,s,o,a){const{geometry:l,_indirectBuffer:c}=r;for(let h=n,u=n+i;h<u;h++)di(l,e,t,h,s,o,a)}function ld(r,e,t,n,i,s,o){const{geometry:a,_indirectBuffer:l}=r;let c=1/0,h=null;for(let u=n,m=n+i;u<m;u++){let p;p=di(a,e,t,u,null,s,o),p&&p.distance<c&&(h=p,c=p.distance)}return h}function cd(r,e,t,n,i,s,o){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let h=r,u=e+r;h<u;h++){let m;if(m=h,be(o,m*3,l,c),o.needsUpdate=!0,n(o,m,i,s))return!0}return!1}function hd(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,o,a,l,c=0;const h=r._roots;for(let m=0,p=h.length;m<p;m++)s=h[m],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),u(0,c),c+=s.byteLength;function u(m,p,f=!1){const d=m*2;if(Ce(d,a)){const g=o[m+6],y=a[d+14];let v=1/0,x=1/0,b=1/0,_=-1/0,T=-1/0,P=-1/0;for(let D=3*g,k=3*(g+y);D<k;D++){let E=n[D];const R=i.getX(E),A=i.getY(E),I=i.getZ(E);R<v&&(v=R),R>_&&(_=R),A<x&&(x=A),A>T&&(T=A),I<b&&(b=I),I>P&&(P=I)}return l[m+0]!==v||l[m+1]!==x||l[m+2]!==b||l[m+3]!==_||l[m+4]!==T||l[m+5]!==P?(l[m+0]=v,l[m+1]=x,l[m+2]=b,l[m+3]=_,l[m+4]=T,l[m+5]=P,!0):!1}else{const g=Te(m),y=ke(m,o);let v=f,x=!1,b=!1;if(e){if(!v){const E=g/Se+p/Le,R=y/Se+p/Le;x=e.has(E),b=e.has(R),v=!x&&!b}}else x=!0,b=!0;const _=v||x,T=v||b;let P=!1;_&&(P=u(g,p,v));let D=!1;T&&(D=u(y,p,v));const k=P||D;if(k)for(let E=0;E<3;E++){const R=g+E,A=y+E,I=l[R],S=l[R+3],z=l[A],U=l[A+3];l[m+E]=I<z?I:z,l[m+E+3]=S>U?S:U}return k}}}function yt(r,e,t,n,i){let s,o,a,l,c,h;const u=1/t.direction.x,m=1/t.direction.y,p=1/t.direction.z,f=t.origin.x,d=t.origin.y,g=t.origin.z;let y=e[r],v=e[r+3],x=e[r+1],b=e[r+3+1],_=e[r+2],T=e[r+3+2];return u>=0?(s=(y-f)*u,o=(v-f)*u):(s=(v-f)*u,o=(y-f)*u),m>=0?(a=(x-d)*m,l=(b-d)*m):(a=(b-d)*m,l=(x-d)*m),s>l||a>o||((a>s||isNaN(s))&&(s=a),(l<o||isNaN(o))&&(o=l),p>=0?(c=(_-g)*p,h=(T-g)*p):(c=(T-g)*p,h=(_-g)*p),s>h||c>o)?!1:((c>s||s!==s)&&(s=c),(h<o||o!==o)&&(o=h),s<=i&&o>=n)}function dd(r,e,t,n,i,s,o,a){const{geometry:l,_indirectBuffer:c}=r;for(let h=n,u=n+i;h<u;h++){let m=c?c[h]:h;di(l,e,t,m,s,o,a)}}function ud(r,e,t,n,i,s,o){const{geometry:a,_indirectBuffer:l}=r;let c=1/0,h=null;for(let u=n,m=n+i;u<m;u++){let p;p=di(a,e,t,l?l[u]:u,null,s,o),p&&p.distance<c&&(h=p,c=p.distance)}return h}function fd(r,e,t,n,i,s,o){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let h=r,u=e+r;h<u;h++){let m;if(m=t.resolveTriangleIndex(h),be(o,m*3,l,c),o.needsUpdate=!0,n(o,m,i,s))return!0}return!1}function pd(r,e,t,n,i,s,o){me.setBuffer(r._roots[e]),ps(0,r,t,n,i,s,o),me.clearBuffer()}function ps(r,e,t,n,i,s,o){const{float32Array:a,uint16Array:l,uint32Array:c}=me,h=r*2;if(Ce(h,l)){const m=Ue(r,c),p=Ze(h,l);ad(e,t,n,m,p,i,s,o)}else{const m=Te(r);yt(m,a,n,s,o)&&ps(m,e,t,n,i,s,o);const p=ke(r,c);yt(p,a,n,s,o)&&ps(p,e,t,n,i,s,o)}}const md=["x","y","z"];function gd(r,e,t,n,i,s){me.setBuffer(r._roots[e]);const o=ms(0,r,t,n,i,s);return me.clearBuffer(),o}function ms(r,e,t,n,i,s){const{float32Array:o,uint16Array:a,uint32Array:l}=me;let c=r*2;if(Ce(c,a)){const u=Ue(r,l),m=Ze(c,a);return ld(e,t,n,u,m,i,s)}else{const u=ds(r,l),m=md[u],f=n.direction[m]>=0;let d,g;f?(d=Te(r),g=ke(r,l)):(d=ke(r,l),g=Te(r));const v=yt(d,o,n,i,s)?ms(d,e,t,n,i,s):null;if(v){const _=v.point[m];if(f?_<=o[g+u]:_>=o[g+u+3])return v}const b=yt(g,o,n,i,s)?ms(g,e,t,n,i,s):null;return v&&b?v.distance<=b.distance?v:b:v||b||null}}const ui=new M.Box3,Jt=new We,Qt=new We,vn=new M.Matrix4,yr=new Ie,fi=new Ie;function yd(r,e,t,n){me.setBuffer(r._roots[e]);const i=gs(0,r,t,n);return me.clearBuffer(),i}function gs(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=me;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),yr.set(t.boundingBox.min,t.boundingBox.max,n),i=yr),Ce(l,o)){const h=e.geometry,u=h.index,m=h.attributes.position,p=t.index,f=t.attributes.position,d=Ue(r,a),g=Ze(l,o);if(vn.copy(n).invert(),t.boundsTree)return ve(r,s,fi),fi.matrix.copy(vn),fi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:v=>fi.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(n),v.b.applyMatrix4(n),v.c.applyMatrix4(n),v.needsUpdate=!0;for(let x=d*3,b=(g+d)*3;x<b;x+=3)if(be(Qt,x,u,m),Qt.needsUpdate=!0,v.intersectsTriangle(Qt))return!0;return!1}});{const y=Dt(t);for(let v=d*3,x=(g+d)*3;v<x;v+=3){be(Jt,v,u,m),Jt.a.applyMatrix4(vn),Jt.b.applyMatrix4(vn),Jt.c.applyMatrix4(vn),Jt.needsUpdate=!0;for(let b=0,_=y*3;b<_;b+=3)if(be(Qt,b,p,f),Qt.needsUpdate=!0,Jt.intersectsTriangle(Qt))return!0}}}else{const h=Te(r),u=ke(r,a);return ve(h,s,ui),!!(i.intersectsBox(ui)&&gs(h,e,t,n,i)||(ve(u,s,ui),i.intersectsBox(ui)&&gs(u,e,t,n,i)))}}const pi=new M.Matrix4,ys=new Ie,wn=new Ie,vd=new M.Vector3,wd=new M.Vector3,xd=new M.Vector3,bd=new M.Vector3;function Md(r,e,t,n={},i={},s=0,o=1/0){e.boundingBox||e.computeBoundingBox(),ys.set(e.boundingBox.min,e.boundingBox.max,t),ys.needsUpdate=!0;const a=r.geometry,l=a.attributes.position,c=a.index,h=e.attributes.position,u=e.index,m=Xe.getPrimitive(),p=Xe.getPrimitive();let f=vd,d=wd,g=null,y=null;i&&(g=xd,y=bd);let v=1/0,x=null,b=null;return pi.copy(t).invert(),wn.matrix.copy(pi),r.shapecast({boundsTraverseOrder:_=>ys.distanceToBox(_),intersectsBounds:(_,T,P)=>P<v&&P<o?(T&&(wn.min.copy(_.min),wn.max.copy(_.max),wn.needsUpdate=!0),!0):!1,intersectsRange:(_,T)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:D=>wn.distanceToBox(D),intersectsBounds:(D,k,E)=>E<v&&E<o,intersectsRange:(D,k)=>{for(let E=D,R=D+k;E<R;E++){be(p,3*E,u,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let A=_,I=_+T;A<I;A++){be(m,3*A,c,l),m.needsUpdate=!0;const S=m.distanceToTriangle(p,f,g);if(S<v&&(d.copy(f),y&&y.copy(g),v=S,x=A,b=E),S<s)return!0}}}});{const P=Dt(e);for(let D=0,k=P;D<k;D++){be(p,3*D,u,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let E=_,R=_+T;E<R;E++){be(m,3*E,c,l),m.needsUpdate=!0;const A=m.distanceToTriangle(p,f,g);if(A<v&&(d.copy(f),y&&y.copy(g),v=A,x=E,b=D),A<s)return!0}}}}}),Xe.releasePrimitive(m),Xe.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(d):n.point=d.clone(),n.distance=v,n.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(pi),d.applyMatrix4(pi),i.distance=d.sub(i.point).length(),i.faceIndex=b),n)}function _d(r,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=r.geometry,n=t.index?t.index.array:null,i=t.attributes.position;let s,o,a,l,c=0;const h=r._roots;for(let m=0,p=h.length;m<p;m++)s=h[m],o=new Uint32Array(s),a=new Uint16Array(s),l=new Float32Array(s),u(0,c),c+=s.byteLength;function u(m,p,f=!1){const d=m*2;if(Ce(d,a)){const g=o[m+6],y=a[d+14];let v=1/0,x=1/0,b=1/0,_=-1/0,T=-1/0,P=-1/0;for(let D=g,k=g+y;D<k;D++){const E=3*r.resolveTriangleIndex(D);for(let R=0;R<3;R++){let A=E+R;A=n?n[A]:A;const I=i.getX(A),S=i.getY(A),z=i.getZ(A);I<v&&(v=I),I>_&&(_=I),S<x&&(x=S),S>T&&(T=S),z<b&&(b=z),z>P&&(P=z)}}return l[m+0]!==v||l[m+1]!==x||l[m+2]!==b||l[m+3]!==_||l[m+4]!==T||l[m+5]!==P?(l[m+0]=v,l[m+1]=x,l[m+2]=b,l[m+3]=_,l[m+4]=T,l[m+5]=P,!0):!1}else{const g=Te(m),y=ke(m,o);let v=f,x=!1,b=!1;if(e){if(!v){const E=g/Se+p/Le,R=y/Se+p/Le;x=e.has(E),b=e.has(R),v=!x&&!b}}else x=!0,b=!0;const _=v||x,T=v||b;let P=!1;_&&(P=u(g,p,v));let D=!1;T&&(D=u(y,p,v));const k=P||D;if(k)for(let E=0;E<3;E++){const R=g+E,A=y+E,I=l[R],S=l[R+3],z=l[A],U=l[A+3];l[m+E]=I<z?I:z,l[m+E+3]=S>U?S:U}return k}}}function Sd(r,e,t,n,i,s,o){me.setBuffer(r._roots[e]),vs(0,r,t,n,i,s,o),me.clearBuffer()}function vs(r,e,t,n,i,s,o){const{float32Array:a,uint16Array:l,uint32Array:c}=me,h=r*2;if(Ce(h,l)){const m=Ue(r,c),p=Ze(h,l);dd(e,t,n,m,p,i,s,o)}else{const m=Te(r);yt(m,a,n,s,o)&&vs(m,e,t,n,i,s,o);const p=ke(r,c);yt(p,a,n,s,o)&&vs(p,e,t,n,i,s,o)}}const Cd=["x","y","z"];function Ad(r,e,t,n,i,s){me.setBuffer(r._roots[e]);const o=ws(0,r,t,n,i,s);return me.clearBuffer(),o}function ws(r,e,t,n,i,s){const{float32Array:o,uint16Array:a,uint32Array:l}=me;let c=r*2;if(Ce(c,a)){const u=Ue(r,l),m=Ze(c,a);return ud(e,t,n,u,m,i,s)}else{const u=ds(r,l),m=Cd[u],f=n.direction[m]>=0;let d,g;f?(d=Te(r),g=ke(r,l)):(d=ke(r,l),g=Te(r));const v=yt(d,o,n,i,s)?ws(d,e,t,n,i,s):null;if(v){const _=v.point[m];if(f?_<=o[g+u]:_>=o[g+u+3])return v}const b=yt(g,o,n,i,s)?ws(g,e,t,n,i,s):null;return v&&b?v.distance<=b.distance?v:b:v||b||null}}const mi=new M.Box3,en=new We,tn=new We,xn=new M.Matrix4,vr=new Ie,gi=new Ie;function Pd(r,e,t,n){me.setBuffer(r._roots[e]);const i=xs(0,r,t,n);return me.clearBuffer(),i}function xs(r,e,t,n,i=null){const{float32Array:s,uint16Array:o,uint32Array:a}=me;let l=r*2;if(i===null&&(t.boundingBox||t.computeBoundingBox(),vr.set(t.boundingBox.min,t.boundingBox.max,n),i=vr),Ce(l,o)){const h=e.geometry,u=h.index,m=h.attributes.position,p=t.index,f=t.attributes.position,d=Ue(r,a),g=Ze(l,o);if(xn.copy(n).invert(),t.boundsTree)return ve(r,s,gi),gi.matrix.copy(xn),gi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:v=>gi.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(n),v.b.applyMatrix4(n),v.c.applyMatrix4(n),v.needsUpdate=!0;for(let x=d,b=g+d;x<b;x++)if(be(tn,3*e.resolveTriangleIndex(x),u,m),tn.needsUpdate=!0,v.intersectsTriangle(tn))return!0;return!1}});{const y=Dt(t);for(let v=d,x=g+d;v<x;v++){const b=e.resolveTriangleIndex(v);be(en,3*b,u,m),en.a.applyMatrix4(xn),en.b.applyMatrix4(xn),en.c.applyMatrix4(xn),en.needsUpdate=!0;for(let _=0,T=y*3;_<T;_+=3)if(be(tn,_,p,f),tn.needsUpdate=!0,en.intersectsTriangle(tn))return!0}}}else{const h=Te(r),u=ke(r,a);return ve(h,s,mi),!!(i.intersectsBox(mi)&&xs(h,e,t,n,i)||(ve(u,s,mi),i.intersectsBox(mi)&&xs(u,e,t,n,i)))}}const yi=new M.Matrix4,bs=new Ie,bn=new Ie,Td=new M.Vector3,kd=new M.Vector3,Dd=new M.Vector3,Ed=new M.Vector3;function Ld(r,e,t,n={},i={},s=0,o=1/0){e.boundingBox||e.computeBoundingBox(),bs.set(e.boundingBox.min,e.boundingBox.max,t),bs.needsUpdate=!0;const a=r.geometry,l=a.attributes.position,c=a.index,h=e.attributes.position,u=e.index,m=Xe.getPrimitive(),p=Xe.getPrimitive();let f=Td,d=kd,g=null,y=null;i&&(g=Dd,y=Ed);let v=1/0,x=null,b=null;return yi.copy(t).invert(),bn.matrix.copy(yi),r.shapecast({boundsTraverseOrder:_=>bs.distanceToBox(_),intersectsBounds:(_,T,P)=>P<v&&P<o?(T&&(bn.min.copy(_.min),bn.max.copy(_.max),bn.needsUpdate=!0),!0):!1,intersectsRange:(_,T)=>{if(e.boundsTree){const P=e.boundsTree;return P.shapecast({boundsTraverseOrder:D=>bn.distanceToBox(D),intersectsBounds:(D,k,E)=>E<v&&E<o,intersectsRange:(D,k)=>{for(let E=D,R=D+k;E<R;E++){const A=P.resolveTriangleIndex(E);be(p,3*A,u,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let I=_,S=_+T;I<S;I++){const z=r.resolveTriangleIndex(I);be(m,3*z,c,l),m.needsUpdate=!0;const U=m.distanceToTriangle(p,f,g);if(U<v&&(d.copy(f),y&&y.copy(g),v=U,x=I,b=E),U<s)return!0}}}})}else{const P=Dt(e);for(let D=0,k=P;D<k;D++){be(p,3*D,u,h),p.a.applyMatrix4(t),p.b.applyMatrix4(t),p.c.applyMatrix4(t),p.needsUpdate=!0;for(let E=_,R=_+T;E<R;E++){const A=r.resolveTriangleIndex(E);be(m,3*A,c,l),m.needsUpdate=!0;const I=m.distanceToTriangle(p,f,g);if(I<v&&(d.copy(f),y&&y.copy(g),v=I,x=E,b=D),I<s)return!0}}}}}),Xe.releasePrimitive(m),Xe.releasePrimitive(p),v===1/0?null:(n.point?n.point.copy(d):n.point=d.clone(),n.distance=v,n.faceIndex=x,i&&(i.point?i.point.copy(y):i.point=y.clone(),i.point.applyMatrix4(yi),d.applyMatrix4(yi),i.distance=d.sub(i.point).length(),i.faceIndex=b),n)}function Id(){return typeof SharedArrayBuffer<"u"}const Mn=new me.constructor,vi=new me.constructor,vt=new hs(()=>new M.Box3),nn=new M.Box3,sn=new M.Box3,Ms=new M.Box3,_s=new M.Box3;let Ss=!1;function zd(r,e,t,n){if(Ss)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Ss=!0;const i=r._roots,s=e._roots;let o,a=0,l=0;const c=new M.Matrix4().copy(t).invert();for(let h=0,u=i.length;h<u;h++){Mn.setBuffer(i[h]),l=0;const m=vt.getPrimitive();ve(0,Mn.float32Array,m),m.applyMatrix4(c);for(let p=0,f=s.length;p<f&&(vi.setBuffer(s[p]),o=$e(0,0,t,c,n,a,l,0,0,m),vi.clearBuffer(),l+=s[p].byteLength/Le,!o);p++);if(vt.releasePrimitive(m),Mn.clearBuffer(),a+=i[h].byteLength/Le,o)break}return Ss=!1,o}function $e(r,e,t,n,i,s=0,o=0,a=0,l=0,c=null,h=!1){let u,m;h?(u=vi,m=Mn):(u=Mn,m=vi);const p=u.float32Array,f=u.uint32Array,d=u.uint16Array,g=m.float32Array,y=m.uint32Array,v=m.uint16Array,x=r*2,b=e*2,_=Ce(x,d),T=Ce(b,v);let P=!1;if(T&&_)h?P=i(Ue(e,y),Ze(e*2,v),Ue(r,f),Ze(r*2,d),l,o+e/Se,a,s+r/Se):P=i(Ue(r,f),Ze(r*2,d),Ue(e,y),Ze(e*2,v),a,s+r/Se,l,o+e/Se);else if(T){const D=vt.getPrimitive();ve(e,g,D),D.applyMatrix4(t);const k=Te(r),E=ke(r,f);ve(k,p,nn),ve(E,p,sn);const R=D.intersectsBox(nn),A=D.intersectsBox(sn);P=R&&$e(e,k,n,t,i,o,s,l,a+1,D,!h)||A&&$e(e,E,n,t,i,o,s,l,a+1,D,!h),vt.releasePrimitive(D)}else{const D=Te(e),k=ke(e,y);ve(D,g,Ms),ve(k,g,_s);const E=c.intersectsBox(Ms),R=c.intersectsBox(_s);if(E&&R)P=$e(r,D,t,n,i,s,o,a,l+1,c,h)||$e(r,k,t,n,i,s,o,a,l+1,c,h);else if(E)if(_)P=$e(r,D,t,n,i,s,o,a,l+1,c,h);else{const A=vt.getPrimitive();A.copy(Ms).applyMatrix4(t);const I=Te(r),S=ke(r,f);ve(I,p,nn),ve(S,p,sn);const z=A.intersectsBox(nn),U=A.intersectsBox(sn);P=z&&$e(D,I,n,t,i,o,s,l,a+1,A,!h)||U&&$e(D,S,n,t,i,o,s,l,a+1,A,!h),vt.releasePrimitive(A)}else if(R)if(_)P=$e(r,k,t,n,i,s,o,a,l+1,c,h);else{const A=vt.getPrimitive();A.copy(_s).applyMatrix4(t);const I=Te(r),S=ke(r,f);ve(I,p,nn),ve(S,p,sn);const z=A.intersectsBox(nn),U=A.intersectsBox(sn);P=z&&$e(k,I,n,t,i,o,s,l,a+1,A,!h)||U&&$e(k,S,n,t,i,o,s,l,a+1,A,!h),vt.releasePrimitive(A)}}return P}const wi=new Ie,wr=new M.Box3,Bd={strategy:Qo,maxDepth:40,maxLeafTris:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null};class Cs{static serialize(e,t={}){t={cloneBuffers:!0,...t};const n=e.geometry,i=e._roots,s=e._indirectBuffer,o=n.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return t.cloneBuffers?(a.roots=i.map(l=>l.slice()),a.index=o?o.array.slice():null,a.indirectBuffer=s?s.slice():null):(a.roots=i,a.index=o?o.array:null,a.indirectBuffer=s),a}static deserialize(e,t,n={}){n={setIndex:!0,indirect:!!e.indirectBuffer,...n};const{index:i,roots:s,indirectBuffer:o}=e;e.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),l(s));const a=new Cs(t,{...n,[is]:!0});if(a._roots=s,a._indirectBuffer=o||null,n.setIndex){const c=t.getIndex();if(c===null){const h=new M.BufferAttribute(e.index,1,!1);t.setIndex(h)}else c.array!==i&&(c.array.set(i),c.needsUpdate=!0)}return a;function l(c){for(let h=0;h<c.length;h++){const u=c[h],m=new Uint32Array(u),p=new Uint16Array(u);for(let f=0,d=u.byteLength/Le;f<d;f++){const g=Se*f,y=2*g;Ce(y,p)||(m[g+6]=m[g+6]/Se-f)}}}}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(e.isBufferGeometry){if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.")}else throw new Error("MeshBVH: Only BufferGeometries are supported.");if(t=Object.assign({...Bd,[is]:!1},t),t.useSharedArrayBuffer&&!Id())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[is]||(Hh(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new M.Box3))),this.resolveTriangleIndex=t.indirect?n=>this._indirectBuffer[n]:n=>n}shiftTriangleOffsets(e){const t=this._indirectBuffer;if(t)for(let n=0,i=t.length;n<i;n++)t[n]+=e;else{const n=this._roots;for(let i=0;i<n.length;i++){const s=n[i],o=new Uint32Array(s),a=new Uint16Array(s),l=s.byteLength/Le;for(let c=0;c<l;c++){const h=Se*c,u=2*h;Ce(u,a)&&(o[h+6]+=e)}}}}refit(e=null){return(this.indirect?_d:hd)(this,e)}traverse(e,t=0){const n=this._roots[t],i=new Uint32Array(n),s=new Uint16Array(n);o(0);function o(a,l=0){const c=a*2,h=Ce(c,s);if(h){const u=i[a+6],m=s[c+14];e(l,h,new Float32Array(n,a*4,6),u,m)}else{const u=Te(a),m=ke(a,i),p=ds(a,i);e(l,h,new Float32Array(n,a*4,6),p)||(o(u,l+1),o(m,l+1))}}}raycast(e,t=M.FrontSide,n=0,i=1/0){const s=this._roots,o=[],a=this.indirect?Sd:pd;for(let l=0,c=s.length;l<c;l++)a(this,l,t,e,o,n,i);return o}raycastFirst(e,t=M.FrontSide,n=0,i=1/0){const s=this._roots;let o=null;const a=this.indirect?Ad:gd;for(let l=0,c=s.length;l<c;l++){const h=a(this,l,t,e,n,i);h!=null&&(o==null||h.distance<o.distance)&&(o=h)}return o}intersectsGeometry(e,t){let n=!1;const i=this._roots,s=this.indirect?Pd:yd;for(let o=0,a=i.length;o<a&&(n=s(this,o,e,t),!n);o++);return n}shapecast(e){const t=Xe.getPrimitive(),n=this.indirect?fd:cd;let{boundsTraverseOrder:i,intersectsBounds:s,intersectsRange:o,intersectsTriangle:a}=e;if(o&&a){const u=o;o=(m,p,f,d,g)=>u(m,p,f,d,g)?!0:n(m,p,this,a,f,d,t)}else o||(a?o=(u,m,p,f)=>n(u,m,this,a,p,f,t):o=(u,m,p)=>p);let l=!1,c=0;const h=this._roots;for(let u=0,m=h.length;u<m;u++){const p=h[u];if(l=id(this,u,s,o,i,c),l)break;c+=p.byteLength/Le}return Xe.releasePrimitive(t),l}bvhcast(e,t,n){let{intersectsRanges:i,intersectsTriangles:s}=n;const o=Xe.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?f=>{const d=this.resolveTriangleIndex(f);be(o,d*3,a,l)}:f=>{be(o,f*3,a,l)},h=Xe.getPrimitive(),u=e.geometry.index,m=e.geometry.attributes.position,p=e.indirect?f=>{const d=e.resolveTriangleIndex(f);be(h,d*3,u,m)}:f=>{be(h,f*3,u,m)};if(s){const f=(d,g,y,v,x,b,_,T)=>{for(let P=y,D=y+v;P<D;P++){p(P),h.a.applyMatrix4(t),h.b.applyMatrix4(t),h.c.applyMatrix4(t),h.needsUpdate=!0;for(let k=d,E=d+g;k<E;k++)if(c(k),o.needsUpdate=!0,s(o,h,k,P,x,b,_,T))return!0}return!1};if(i){const d=i;i=function(g,y,v,x,b,_,T,P){return d(g,y,v,x,b,_,T,P)?!0:f(g,y,v,x,b,_,T,P)}}else i=f}return zd(this,e,t,i)}intersectsBox(e,t){return wi.set(e.min,e.max,t),wi.needsUpdate=!0,this.shapecast({intersectsBounds:n=>wi.intersectsBox(n),intersectsTriangle:n=>wi.intersectsTriangle(n)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,n={},i={},s=0,o=1/0){return(this.indirect?Ld:Md)(this,e,t,n,i,s,o)}closestPointToPoint(e,t={},n=0,i=1/0){return sd(this,e,t,n,i)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(n=>{ve(0,new Float32Array(n),wr),e.union(wr)}),e}}const xr=1e-6,Rd=xr*.5,br=Math.pow(10,-Math.log10(xr)),Od=Rd*br;function it(r){return~~(r*br+Od)}function Nd(r){return`${it(r.x)},${it(r.y)}`}function Mr(r){return`${it(r.x)},${it(r.y)},${it(r.z)}`}function Fd(r){return`${it(r.x)},${it(r.y)},${it(r.z)},${it(r.w)}`}function Ud(r,e,t){t.direction.subVectors(e,r).normalize();const n=r.dot(t.direction);return t.origin.copy(r).addScaledVector(t.direction,-n),t}function _r(){return typeof SharedArrayBuffer<"u"}function Vd(r){if(r.buffer instanceof SharedArrayBuffer)return r;const e=r.constructor,t=r.buffer,n=new SharedArrayBuffer(t.byteLength),i=new Uint8Array(t);return new Uint8Array(n).set(i,0),new e(n)}function Gd(r,e=ArrayBuffer){return r>65535?new Uint32Array(new e(4*r)):new Uint16Array(new e(2*r))}function jd(r,e){if(!r.index){const t=r.attributes.position.count,n=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=Gd(t,n);r.setIndex(new M.BufferAttribute(i,1));for(let s=0;s<t;s++)i[s]=s}}function Wd(r){return r.index?r.index.count:r.attributes.position.count}function As(r){return Wd(r)/3}const Xd=1e-8,Zd=new M.Vector3;function Yd(r){return~~(r/3)}function Kd(r){return r%3}function Sr(r,e){return r.start-e.start}function Cr(r,e){return Zd.subVectors(e,r.origin).dot(r.direction)}function $d(r,e,t,n=Xd){r.sort(Sr),e.sort(Sr);for(let a=0;a<r.length;a++){const l=r[a];for(let c=0;c<e.length;c++){const h=e[c];if(!(h.start>l.end)){if(l.end<h.start||h.end<l.start)continue;if(l.start<=h.start&&l.end>=h.end)s(h.end,l.end)||r.splice(a+1,0,{start:h.end,end:l.end,index:l.index}),l.end=h.start,h.start=0,h.end=0;else if(l.start>=h.start&&l.end<=h.end)s(l.end,h.end)||e.splice(c+1,0,{start:l.end,end:h.end,index:h.index}),h.end=l.start,l.start=0,l.end=0;else if(l.start<=h.start&&l.end<=h.end){const u=l.end;l.end=h.start,h.start=u}else if(l.start>=h.start&&l.end>=h.end){const u=h.end;h.end=l.start,l.start=u}else throw new Error}if(t.has(l.index)||t.set(l.index,[]),t.has(h.index)||t.set(h.index,[]),t.get(l.index).push(h.index),t.get(h.index).push(l.index),o(h)&&(e.splice(c,1),c--),o(l)){r.splice(a,1),a--;break}}}i(r),i(e);function i(a){for(let l=0;l<a.length;l++)o(a[l])&&(a.splice(l,1),l--)}function s(a,l){return Math.abs(l-a)<n}function o(a){return Math.abs(a.end-a.start)<n}}const Ar=1e-5,Pr=1e-4;class qd{constructor(){this._rays=[]}addRay(e){this._rays.push(e)}findClosestRay(e){const t=this._rays,n=e.clone();n.direction.multiplyScalar(-1);let i=1/0,s=null;for(let l=0,c=t.length;l<c;l++){const h=t[l];if(o(h,e)&&o(h,n))continue;const u=a(h,e),m=a(h,n),p=Math.min(u,m);p<i&&(i=p,s=h)}return s;function o(l,c){const h=l.origin.distanceTo(c.origin)>Ar;return l.direction.angleTo(c.direction)>Pr||h}function a(l,c){const h=l.origin.distanceTo(c.origin),u=l.direction.angleTo(c.direction);return h/Ar+u/Pr}}}const Ps=new M.Vector3,Ts=new M.Vector3,xi=new M.Ray;function Hd(r,e,t){const n=r.attributes,i=r.index,s=n.position,o=new Map,a=new Map,l=Array.from(e),c=new qd;for(let h=0,u=l.length;h<u;h++){const m=l[h],p=Yd(m),f=Kd(m);let d=3*p+f,g=3*p+(f+1)%3;i&&(d=i.getX(d),g=i.getX(g)),Ps.fromBufferAttribute(s,d),Ts.fromBufferAttribute(s,g),Ud(Ps,Ts,xi);let y,v=c.findClosestRay(xi);v===null&&(v=xi.clone(),c.addRay(v)),a.has(v)||a.set(v,{forward:[],reverse:[],ray:v}),y=a.get(v);let x=Cr(v,Ps),b=Cr(v,Ts);x>b&&([x,b]=[b,x]),xi.direction.dot(v.direction)<0?y.reverse.push({start:x,end:b,index:m}):y.forward.push({start:x,end:b,index:m})}return a.forEach(({forward:h,reverse:u},m)=>{$d(h,u,o,t),h.length===0&&u.length===0&&a.delete(m)}),{disjointConnectivityMap:o,fragmentMap:a}}const Jd=new M.Vector2,ks=new M.Vector3,Qd=new M.Vector4,Ds=["","",""];class eu{constructor(e=null){this.data=null,this.disjointConnections=null,this.unmatchedDisjointEdges=null,this.unmatchedEdges=-1,this.matchedEdges=-1,this.useDrawRange=!0,this.useAllAttributes=!1,this.matchDisjointEdges=!1,this.degenerateEpsilon=1e-8,e&&this.updateFrom(e)}getSiblingTriangleIndex(e,t){const n=this.data[e*3+t];return n===-1?-1:~~(n/3)}getSiblingEdgeIndex(e,t){const n=this.data[e*3+t];return n===-1?-1:n%3}getDisjointSiblingTriangleIndices(e,t){const n=e*3+t,i=this.disjointConnections.get(n);return i?i.map(s=>~~(s/3)):[]}getDisjointSiblingEdgeIndices(e,t){const n=e*3+t,i=this.disjointConnections.get(n);return i?i.map(s=>s%3):[]}isFullyConnected(){return this.unmatchedEdges===0}updateFrom(e){const{useAllAttributes:t,useDrawRange:n,matchDisjointEdges:i,degenerateEpsilon:s}=this,o=t?x:v,a=new Map,{attributes:l}=e,c=t?Object.keys(l):null,h=e.index,u=l.position;let m=As(e);const p=m;let f=0;n&&(f=e.drawRange.start,e.drawRange.count!==1/0&&(m=~~(e.drawRange.count/3)));let d=this.data;(!d||d.length<3*p)&&(d=new Int32Array(3*p)),d.fill(-1);let g=0,y=new Set;for(let b=f,_=m*3+f;b<_;b+=3){const T=b;for(let P=0;P<3;P++){let D=T+P;h&&(D=h.getX(D)),Ds[P]=o(D)}for(let P=0;P<3;P++){const D=(P+1)%3,k=Ds[P],E=Ds[D],R=`${E}_${k}`;if(a.has(R)){const A=T+P,I=a.get(R);d[A]=I,d[I]=A,a.delete(R),g+=2,y.delete(I)}else{const A=`${k}_${E}`,I=T+P;a.set(A,I),y.add(I)}}}if(i){const{fragmentMap:b,disjointConnectivityMap:_}=Hd(e,y,s);y.clear(),b.forEach(({forward:T,reverse:P})=>{T.forEach(({index:D})=>y.add(D)),P.forEach(({index:D})=>y.add(D))}),this.unmatchedDisjointEdges=b,this.disjointConnections=_,g=m*3-y.size}this.matchedEdges=g,this.unmatchedEdges=y.size,this.data=d;function v(b){return ks.fromBufferAttribute(u,b),Mr(ks)}function x(b){let _="";for(let T=0,P=c.length;T<P;T++){const D=l[c[T]];let k;switch(D.itemSize){case 1:k=it(D.getX(b));break;case 2:k=Nd(Jd.fromBufferAttribute(D,b));break;case 3:k=Mr(ks.fromBufferAttribute(D,b));break;case 4:k=Fd(Qd.fromBufferAttribute(D,b));break}_!==""&&(_+="|"),_+=k}return _}}}class bi extends M.Mesh{constructor(...e){super(...e),this.isBrush=!0,this._previousMatrix=new M.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=_r();if(n)for(const i in t){const s=t[i];if(s.isInterleavedBufferAttribute)throw new Error("Brush: InterleavedBufferAttributes are not supported.");s.array=Vd(s.array)}if(e.boundsTree||(jd(e,{useSharedArrayBuffer:n}),e.boundsTree=new Cs(e,{maxLeafTris:3,indirect:!0,useSharedArrayBuffer:n})),e.halfEdges||(e.halfEdges=new eu(e)),!e.groupIndices){const i=As(e),s=new Uint16Array(i),o=e.groups;for(let a=0,l=o.length;a<l;a++){const{start:c,count:h}=o[a];for(let u=c/3,m=(c+h)/3;u<m;u++)s[u]=a}e.groupIndices=s}}disposeCacheData(){const{geometry:e}=this;e.halfEdges=null,e.boundsTree=null,e.groupIndices=null}}const tu=1e-14,Es=new M.Vector3,Tr=new M.Vector3,kr=new M.Vector3;function wt(r,e=tu){Es.subVectors(r.b,r.a),Tr.subVectors(r.c,r.a),kr.subVectors(r.b,r.c);const t=Es.angleTo(Tr),n=Es.angleTo(kr),i=Math.PI-t-n;return Math.abs(t)<e||Math.abs(n)<e||Math.abs(i)<e||r.a.distanceToSquared(r.b)<e||r.a.distanceToSquared(r.c)<e||r.b.distanceToSquared(r.c)<e}const Ls=1e-10,_n=1e-10,nu=1e-10,dt=new M.Line3,we=new M.Line3,ut=new M.Vector3,Is=new M.Vector3,Dr=new M.Vector3,Mi=new M.Plane,zs=new We;class iu{constructor(){this._pool=[],this._index=0}getTriangle(){return this._index>=this._pool.length&&this._pool.push(new M.Triangle),this._pool[this._index++]}clear(){this._index=0}reset(){this._pool.length=0,this._index=0}}class su{constructor(){this.trianglePool=new iu,this.triangles=[],this.normal=new M.Vector3,this.coplanarTriangleUsed=!1}initialize(e){this.reset();const{triangles:t,trianglePool:n,normal:i}=this;if(Array.isArray(e))for(let s=0,o=e.length;s<o;s++){const a=e[s];if(s===0)a.getNormal(i);else if(Math.abs(1-a.getNormal(ut).dot(i))>Ls)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(Is).normalize(),Math.abs(1-Math.abs(Is.dot(t)))<nu){this.coplanarTriangleUsed=!0;for(let s=0,o=n.length;s<o;s++){const a=n[s];a.coplanarCount=0}const i=[e.a,e.b,e.c];for(let s=0;s<3;s++){const o=(s+1)%3,a=i[s],l=i[o];ut.subVectors(l,a).normalize(),Dr.crossVectors(Is,ut),Mi.setFromNormalAndCoplanarPoint(Dr,a),this.splitByPlane(Mi,e)}}else e.getPlane(Mi),this.splitByPlane(Mi,e)}splitByPlane(e,t){const{triangles:n,trianglePool:i}=this;zs.copy(t),zs.needsUpdate=!0;for(let s=0,o=n.length;s<o;s++){const a=n[s];if(!zs.intersectsTriangle(a,dt,!0))continue;const{a:l,b:c,c:h}=a;let u=0,m=-1,p=!1,f=[],d=[];const g=[l,c,h];for(let y=0;y<3;y++){const v=(y+1)%3;dt.start.copy(g[y]),dt.end.copy(g[v]);const x=e.distanceToPoint(dt.start),b=e.distanceToPoint(dt.end);if(Math.abs(x)<_n&&Math.abs(b)<_n){p=!0;break}if(x>0?f.push(y):d.push(y),Math.abs(x)<_n)continue;let _=!!e.intersectLine(dt,ut);!_&&Math.abs(b)<_n&&(ut.copy(dt.end),_=!0),_&&!(ut.distanceTo(dt.start)<Ls)&&(ut.distanceTo(dt.end)<Ls&&(m=y),u===0?we.start.copy(ut):we.end.copy(ut),u++)}if(!p&&u===2&&we.distance()>_n)if(m!==-1){m=(m+1)%3;let y=0;y===m&&(y=(y+1)%3);let v=y+1;v===m&&(v=(v+1)%3);const x=i.getTriangle();x.a.copy(g[v]),x.b.copy(we.end),x.c.copy(we.start),wt(x)||n.push(x),a.a.copy(g[y]),a.b.copy(we.start),a.c.copy(we.end),wt(a)&&(n.splice(s,1),s--,o--)}else{const y=f.length>=2?d[0]:f[0];if(y===0){let T=we.start;we.start=we.end,we.end=T}const v=(y+1)%3,x=(y+2)%3,b=i.getTriangle(),_=i.getTriangle();g[v].distanceToSquared(we.start)<g[x].distanceToSquared(we.end)?(b.a.copy(g[v]),b.b.copy(we.start),b.c.copy(we.end),_.a.copy(g[v]),_.b.copy(g[x]),_.c.copy(we.start)):(b.a.copy(g[x]),b.b.copy(we.start),b.c.copy(we.end),_.a.copy(g[v]),_.b.copy(g[x]),_.c.copy(we.end)),a.a.copy(g[y]),a.b.copy(we.end),a.c.copy(we.start),wt(b)||n.push(b),wt(_)||n.push(_),wt(a)&&(n.splice(s,1),s--,o--)}else u===3&&console.warn("TriangleClipper: Coplanar clip not handled")}}reset(){this.triangles.length=0,this.trianglePool.clear(),this.coplanarTriangleUsed=!1}}function ou(r){return r=~~r,r+4-r%4}class Er{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=_r()?SharedArrayBuffer:ArrayBuffer,i=new t(new n(ou(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 ru{constructor(){this.groupAttributes=[{}],this.groupCount=0}getType(e){return this.groupAttributes[0][e].type}getItemSize(e){return this.groupAttributes[0][e].itemSize}getNormalized(e){return this.groupAttributes[0][e].normalized}getCount(e){if(this.groupCount<=e)return 0;const t=this.getGroupAttrArray("position",e);return t.length/t.itemSize}getTotalLength(e){const{groupCount:t,groupAttributes:n}=this;let i=0;for(let s=0;s<t;s++){const o=n[s];i+=o[e].length}return i}getGroupAttrSet(e=0){const{groupAttributes:t}=this;if(t[e])return this.groupCount=Math.max(this.groupCount,e+1),t[e];const n=t[0];for(this.groupCount=Math.max(this.groupCount,e+1);e>=t.length;){const i={};t.push(i);for(const s in n){const o=n[s],a=new Er(o.type);a.itemSize=o.itemSize,a.normalized=o.normalized,i[s]=a}}return t[e]}getGroupAttrArray(e,t=0){const{groupAttributes:n}=this;if(!n[0][e])throw new Error(`TypedAttributeData: Attribute with "${e}" has not been initialized`);return this.getGroupAttrSet(t)[e]}initializeArray(e,t,n,i){const{groupAttributes:s}=this,a=s[0][e];if(a){if(a.type!==t)for(let l=0,c=s.length;l<c;l++){const h=s[l][e];h.setType(t),h.itemSize=n,h.normalized=i}}else for(let l=0,c=s.length;l<c;l++){const h=new Er(t);h.itemSize=n,h.normalized=i,s[l][e]=h}}clear(){this.groupCount=0;const{groupAttributes:e}=this;e.forEach(t=>{for(const n in t)t[n].clear()})}delete(e){this.groupAttributes.forEach(t=>{delete t[e]})}reset(){this.groupAttributes=[],this.groupCount=0}}class Lr{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 au=0,lu=1,cu=2,Ir=3,hu=4,zr=5,Br=6,Ye=new M.Ray,Rr=new M.Matrix4,ze=new M.Triangle,ft=new M.Vector3,Or=new M.Vector4,Nr=new M.Vector4,Fr=new M.Vector4,Bs=new M.Vector4,_i=new M.Vector4,Si=new M.Vector4,Ur=new M.Line3,Rs=new M.Vector3,Os=1e-8,du=1e-15,zt=-1,Bt=1,Ci=-2,Ai=2,Sn=0,Rt=1,Ns=2,uu=1e-14;let Pi=null;function Vr(r){Pi=r}function Gr(r,e){r.getMidpoint(Ye.origin),r.getNormal(Ye.direction);const t=e.raycastFirst(Ye,M.DoubleSide);return!!(t&&Ye.direction.dot(t.face.normal)>0)?zt:Bt}function fu(r,e){function t(){return Math.random()-.5}r.getNormal(Rs),Ye.direction.copy(Rs),r.getMidpoint(Ye.origin);const n=3;let i=0,s=1/0;for(let o=0;o<n;o++){Ye.direction.x+=t()*Os,Ye.direction.y+=t()*Os,Ye.direction.z+=t()*Os,Ye.direction.multiplyScalar(-1);const a=e.raycastFirst(Ye,M.DoubleSide);if(!!(a&&Ye.direction.dot(a.face.normal)>0)&&i++,a!==null&&(s=Math.min(s,a.distance)),s<=du)return a.face.normal.dot(Rs)>0?Ai:Ci;if(i/n>.5||(o-i+1)/n>.5)break}return i/n>.5?zt:Bt}function pu(r,e){const t=new Lr,n=new Lr;return Rr.copy(r.matrixWorld).invert().multiply(e.matrixWorld),r.geometry.boundsTree.bvhcast(e.geometry.boundsTree,Rr,{intersectsTriangles(i,s,o,a){if(!wt(i)&&!wt(s)){let l=i.intersectsTriangle(s,Ur,!0);if(!l){const c=i.plane,h=s.plane,u=c.normal,m=h.normal;u.dot(m)===1&&Math.abs(c.constant-h.constant)<uu&&(l=!0)}if(l){let c=r.geometry.boundsTree.resolveTriangleIndex(o),h=e.geometry.boundsTree.resolveTriangleIndex(a);t.add(c,h),n.add(h,c),Pi&&(Pi.addEdge(Ur),Pi.addIntersectingTriangles(o,i,a,s))}}return!1}}),{aIntersections:t,bIntersections:n}}function mu(r,e,t,n,i,s,o=!1){const a=t.attributes,l=t.index,c=r*3,h=l.getX(c+0),u=l.getX(c+1),m=l.getX(c+2);for(const p in s){const f=a[p],d=s[p];if(!(p in a))throw new Error(`CSG Operations: Attribute ${p} not available on geometry.`);const g=f.itemSize;p==="position"?(ze.a.fromBufferAttribute(f,h).applyMatrix4(n),ze.b.fromBufferAttribute(f,u).applyMatrix4(n),ze.c.fromBufferAttribute(f,m).applyMatrix4(n),Fs(ze.a,ze.b,ze.c,e,3,d,o)):p==="normal"?(ze.a.fromBufferAttribute(f,h).applyNormalMatrix(i),ze.b.fromBufferAttribute(f,u).applyNormalMatrix(i),ze.c.fromBufferAttribute(f,m).applyNormalMatrix(i),o&&(ze.a.multiplyScalar(-1),ze.b.multiplyScalar(-1),ze.c.multiplyScalar(-1)),Fs(ze.a,ze.b,ze.c,e,3,d,o,!0)):(Or.fromBufferAttribute(f,h),Nr.fromBufferAttribute(f,u),Fr.fromBufferAttribute(f,m),Fs(Or,Nr,Fr,e,g,d,o))}}function gu(r,e,t,n,i,s,o,a=!1){Us(r,n,i,s,o,a),Us(a?t:e,n,i,s,o,a),Us(a?e:t,n,i,s,o,a)}function jr(r,e,t=!1){switch(r){case au:if(e===Bt||e===Ai&&!t)return Rt;break;case lu:if(t){if(e===zt)return Sn}else if(e===Bt||e===Ci)return Rt;break;case cu:if(t){if(e===Bt||e===Ci)return Rt}else if(e===zt)return Sn;break;case hu:if(e===zt)return Sn;if(e===Bt)return Rt;break;case Ir:if(e===zt||e===Ai&&!t)return Rt;break;case zr:if(!t&&(e===Bt||e===Ci))return Rt;break;case Br:if(!t&&(e===zt||e===Ai))return Rt;break;default:throw new Error(`Unrecognized CSG operation enum "${r}".`)}return Ns}function Fs(r,e,t,n,i,s,o=!1,a=!1){const l=c=>{s.push(c.x),i>1&&s.push(c.y),i>2&&s.push(c.z),i>3&&s.push(c.w)};Bs.set(0,0,0,0).addScaledVector(r,n.a.x).addScaledVector(e,n.a.y).addScaledVector(t,n.a.z),_i.set(0,0,0,0).addScaledVector(r,n.b.x).addScaledVector(e,n.b.y).addScaledVector(t,n.b.z),Si.set(0,0,0,0).addScaledVector(r,n.c.x).addScaledVector(e,n.c.y).addScaledVector(t,n.c.z),a&&(Bs.normalize(),_i.normalize(),Si.normalize()),l(Bs),o?(l(Si),l(_i)):(l(_i),l(Si))}function Us(r,e,t,n,i,s=!1){for(const o in i){const a=e[o],l=i[o];if(!(o in e))throw new Error(`CSG Operations: Attribute ${o} no available on geometry.`);const c=a.itemSize;o==="position"?(ft.fromBufferAttribute(a,r).applyMatrix4(t),l.push(ft.x,ft.y,ft.z)):o==="normal"?(ft.fromBufferAttribute(a,r).applyNormalMatrix(n),s&&ft.multiplyScalar(-1),l.push(ft.x,ft.y,ft.z)):(l.push(a.getX(r)),c>1&&l.push(a.getY(r)),c>2&&l.push(a.getZ(r)),c>3&&l.push(a.getW(r)))}}class yu{constructor(e){this.triangle=new M.Triangle().copy(e),this.intersects={}}addTriangle(e,t){this.intersects[e]=new M.Triangle().copy(t)}getIntersectArray(){const e=[],{intersects:t}=this;for(const n in t)e.push(t[n]);return e}}class Wr{constructor(){this.data={}}addTriangleIntersection(e,t,n,i){const{data:s}=this;s[e]||(s[e]=new yu(t)),s[e].addTriangle(n,i)}getTrianglesAsArray(e=null){const{data:t}=this,n=[];if(e!==null)e in t&&n.push(t[e].triangle);else for(const i in t)n.push(t[i].triangle);return n}getTriangleIndices(){return Object.keys(this.data).map(e=>parseInt(e))}getIntersectionIndices(e){const{data:t}=this;return t[e]?Object.keys(t[e].intersects).map(n=>parseInt(n)):[]}getIntersectionsAsArray(e=null,t=null){const{data:n}=this,i=new Set,s=[],o=a=>{if(n[a])if(t!==null)n[a].intersects[t]&&s.push(n[a].intersects[t]);else{const l=n[a].intersects;for(const c in l)i.has(c)||(i.add(c),s.push(l[c]))}};if(e!==null)o(e);else for(const a in n)o(a);return s}reset(){this.data={}}}class vu{constructor(){this.enabled=!1,this.triangleIntersectsA=new Wr,this.triangleIntersectsB=new Wr,this.intersectionEdges=[]}addIntersectingTriangles(e,t,n,i){const{triangleIntersectsA:s,triangleIntersectsB:o}=this;s.addTriangleIntersection(e,t,n,i),o.addTriangleIntersection(n,i,e,t)}addEdge(e){this.intersectionEdges.push(e.clone())}reset(){this.triangleIntersectsA.reset(),this.triangleIntersectsB.reset(),this.intersectionEdges=[]}init(){this.enabled&&(this.reset(),Vr(this))}complete(){this.enabled&&Vr(null)}}const xt=new M.Matrix4,Ti=new M.Matrix3,Ot=new M.Triangle,ki=new M.Triangle,bt=new M.Triangle,Di=new M.Triangle,qe=[],Nt=[];function wu(r){for(const e of r)return e}function xu(r,e,t,n,i,s={}){const{useGroups:o=!0}=s,{aIntersections:a,bIntersections:l}=pu(r,e),c=[];let h=null,u;return u=o?0:-1,Xr(r,e,a,t,!1,n,i,u),Zr(r,e,a,t,!1,i,u),t.findIndex(p=>p!==Br&&p!==zr)!==-1&&(u=o?r.geometry.groups.length||1:-1,Xr(e,r,l,t,!0,n,i,u),Zr(e,r,l,t,!0,i,u)),qe.length=0,Nt.length=0,{groups:c,materials:h}}function Xr(r,e,t,n,i,s,o,a=0){const l=r.matrixWorld.determinant()<0;xt.copy(e.matrixWorld).invert().multiply(r.matrixWorld),Ti.getNormalMatrix(r.matrixWorld).multiplyScalar(l?-1:1);const c=r.geometry.groupIndices,h=r.geometry.index,u=r.geometry.attributes.position,m=e.geometry.boundsTree,p=e.geometry.index,f=e.geometry.attributes.position,d=t.ids,g=t.intersectionSet;for(let y=0,v=d.length;y<v;y++){const x=d[y],b=a===-1?0:c[x]+a,_=3*x,T=h.getX(_+0),P=h.getX(_+1),D=h.getX(_+2);Ot.a.fromBufferAttribute(u,T).applyMatrix4(xt),Ot.b.fromBufferAttribute(u,P).applyMatrix4(xt),Ot.c.fromBufferAttribute(u,D).applyMatrix4(xt),s.reset(),s.initialize(Ot);const k=g[x];for(let R=0,A=k.length;R<A;R++){const I=3*k[R],S=p.getX(I+0),z=p.getX(I+1),U=p.getX(I+2);ki.a.fromBufferAttribute(f,S),ki.b.fromBufferAttribute(f,z),ki.c.fromBufferAttribute(f,U),s.splitByTriangle(ki)}const E=s.triangles;for(let R=0,A=E.length;R<A;R++){const I=E[R],S=s.coplanarTriangleUsed?fu(I,m):Gr(I,m);qe.length=0,Nt.length=0;for(let z=0,U=n.length;z<U;z++){const V=jr(n[z],S,i);V!==Ns&&(Nt.push(V),qe.push(o[z].getGroupAttrSet(b)))}if(qe.length!==0){Ot.getBarycoord(I.a,Di.a),Ot.getBarycoord(I.b,Di.b),Ot.getBarycoord(I.c,Di.c);for(let z=0,U=qe.length;z<U;z++){const V=qe[z],G=Nt[z]===Sn;mu(x,Di,r.geometry,r.matrixWorld,Ti,V,l!==G)}}}}return d.length}function Zr(r,e,t,n,i,s,o=0){const a=r.matrixWorld.determinant()<0;xt.copy(e.matrixWorld).invert().multiply(r.matrixWorld),Ti.getNormalMatrix(r.matrixWorld).multiplyScalar(a?-1:1);const l=e.geometry.boundsTree,c=r.geometry.groupIndices,h=r.geometry.index,u=r.geometry.attributes,m=u.position,p=[],f=r.geometry.halfEdges,d=new Set,g=As(r.geometry);for(let y=0,v=g;y<v;y++)y in t.intersectionSet||d.add(y);for(;d.size>0;){const y=wu(d);d.delete(y),p.push(y);const v=3*y,x=h.getX(v+0),b=h.getX(v+1),_=h.getX(v+2);bt.a.fromBufferAttribute(m,x).applyMatrix4(xt),bt.b.fromBufferAttribute(m,b).applyMatrix4(xt),bt.c.fromBufferAttribute(m,_).applyMatrix4(xt);const T=Gr(bt,l);Nt.length=0,qe.length=0;for(let P=0,D=n.length;P<D;P++){const k=jr(n[P],T,i);k!==Ns&&(Nt.push(k),qe.push(s[P]))}for(;p.length>0;){const P=p.pop();for(let D=0;D<3;D++){const k=f.getSiblingTriangleIndex(P,D);k!==-1&&d.has(k)&&(p.push(k),d.delete(k))}if(qe.length!==0){const D=3*P,k=h.getX(D+0),E=h.getX(D+1),R=h.getX(D+2),A=o===-1?0:c[P]+o;if(bt.a.fromBufferAttribute(m,k),bt.b.fromBufferAttribute(m,E),bt.c.fromBufferAttribute(m,R),!wt(bt))for(let I=0,S=qe.length;I<S;I++){const z=Nt[I],U=qe[I].getGroupAttrSet(A),V=z===Sn;gu(k,E,R,u,r.matrixWorld,Ti,U,V!==a)}}}}}function bu(r){for(let e=0;e<r.length-1;e++){const t=r[e],n=r[e+1];if(t.materialIndex===n.materialIndex){const i=t.start,s=n.start+n.count;n.start=i,n.count=s-i,r.splice(e,1),e--}}}function Mu(r,e,t,n){t.clear();const i=r.attributes;for(let s=0,o=n.length;s<o;s++){const a=n[s],l=i[a];t.initializeArray(a,l.array.constructor,l.itemSize,l.normalized)}for(const s in t.attributes)n.includes(s)||t.delete(s);for(const s in e.attributes)n.includes(s)||(e.deleteAttribute(s),e.dispose())}function _u(r,e,t){let n=!1,i=-1;const s=r.attributes,o=e.groupAttributes[0];for(const l in o){const c=e.getTotalLength(l),h=e.getType(l),u=e.getItemSize(l),m=e.getNormalized(l);let p=s[l];(!p||p.array.length<c)&&(p=new M.BufferAttribute(new h(c),u,m),r.setAttribute(l,p),n=!0);let f=0;for(let d=0,g=Math.min(t.length,e.groupCount);d<g;d++){const y=t[d].index,{array:v,type:x,length:b}=e.groupAttributes[y][l],_=new x(v.buffer,0,b);p.array.set(_,f),f+=_.length}p.needsUpdate=!0,i=c/p.itemSize}if(r.index){const l=r.index.array;if(l.length<i)r.index=null,n=!0;else for(let c=0,h=l.length;c<h;c++)l[c]=c}let a=0;r.clearGroups();for(let l=0,c=Math.min(t.length,e.groupCount);l<c;l++){const{index:h,materialIndex:u}=t[l],m=e.getCount(h);m!==0&&(r.addGroup(a,m,u),a+=m)}r.setDrawRange(0,i),r.boundsTree=null,n&&r.dispose()}function Yr(r,e){let t=e;return Array.isArray(e)||(t=[],r.forEach(n=>{t[n.materialIndex]=e})),t}class Su{constructor(){this.triangleSplitter=new su,this.attributeData=[],this.attributes=["position","uv","normal"],this.useGroups=!0,this.consolidateGroups=!0,this.debug=new vu}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 bi){let s=!0;if(Array.isArray(n)||(n=[n]),Array.isArray(i)||(i=[i],s=!1),i.length!==n.length)throw new Error("Evaluator: operations and target array passed as different sizes.");e.prepareGeometry(),t.prepareGeometry();const{triangleSplitter:o,attributeData:a,attributes:l,useGroups:c,consolidateGroups:h,debug:u}=this;for(;a.length<i.length;)a.push(new ru);i.forEach((y,v)=>{Mu(e.geometry,y.geometry,a[v],l)}),u.init(),xu(e,t,n,o,a,{useGroups:c}),u.complete();const m=this.getGroupRanges(e.geometry),p=Yr(m,e.material),f=this.getGroupRanges(t.geometry),d=Yr(f,t.material);f.forEach(y=>y.materialIndex+=p.length);let g=[...m,...f].map((y,v)=>({...y,index:v}));if(c){const y=[...p,...d];h&&(g=g.map(x=>{const b=y[x.materialIndex];return x.materialIndex=y.indexOf(b),x}).sort((x,b)=>x.materialIndex-b.materialIndex));const v=[];for(let x=0,b=y.length;x<b;x++){let _=!1;for(let T=0,P=g.length;T<P;T++){const D=g[T];D.materialIndex===x&&(_=!0,D.materialIndex=v.length)}_&&v.push(y[x])}i.forEach(x=>{x.material=v})}else g=[{start:0,count:1/0,index:0,materialIndex:0}],i.forEach(y=>{y.material=p[0]});return i.forEach((y,v)=>{const x=y.geometry;_u(x,a[v],g),h&&bu(x.groups)}),s?i:i[0]}evaluateHierarchy(e,t=new bi){e.updateMatrixWorld(!0);const n=(s,o)=>{const a=s.children;for(let l=0,c=a.length;l<c;l++){const h=a[l];h.isOperationGroup?n(h,o):o(h)}},i=s=>{const o=s.children;let a=!1;for(let c=0,h=o.length;c<h;c++){const u=o[c];a=i(u)||a}const l=s.isDirty();if(l&&s.markUpdated(),a&&!s.isOperationGroup){let c;return n(s,h=>{c?c=this.evaluate(c,h,h.operation):c=this.evaluate(s,h,h.operation)}),s._cachedGeometry=c.geometry,s._cachedMaterials=c.material,!0}else return a||l};return i(e),t.geometry=e._cachedGeometry,t.material=e._cachedMaterials,t}reset(){this.triangleSplitter.reset()}}class Cu{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 Su,this.planeGroup=new w.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 w.BufferGeometry,i=new w.MeshStandardMaterial({color:new w.Color(33023),metalness:.1,roughness:.75,side:w.DoubleSide,depthWrite:!0,depthTest:!0,clippingPlanes:this.planes.filter((o,a)=>a!==t)}),s=new w.Mesh(n,i);return s.name=`CSG_Section_Optimized_${t}`,s.visible=!1,s.renderOrder=t+1,s}active(){this.isActive=!0,this.requestUpdate(),this.planeObjects.forEach(e=>{e.visible=!0})}disActive(){this.isActive=!1,this.planeObjects.forEach(e=>{e.visible=!1}),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null)}setSourceMeshes(e){this.sourceMeshes.clear(),e.forEach(t=>{const n=t.uuid;this.sourceMeshes.set(n,t)}),this.isActive&&this.requestUpdate()}addSourceMesh(e){const t=e.uuid;this.sourceMeshes.has(t)||(this.sourceMeshes.set(t,e),this.isActive&&this.requestUpdate())}removeSourceMesh(e){const t=e.uuid;this.sourceMeshes.delete(t)&&(this.clearMeshCache(t),this.isActive&&this.requestUpdate())}requestUpdate(){if(!this.isActive)return;const e=Date.now(),t=e-this.lastUpdateTime;t>=this.updateThrottleTime?(this.lastUpdateTime=e,this.pendingUpdate=!1):(this.pendingUpdate=!0,this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>{this.pendingUpdate&&this.isActive&&(this.lastUpdateTime=Date.now(),this.pendingUpdate=!1),this.updateTimer=null},this.updateThrottleTime-t))}updateAllSections(){this.isActive&&(this.planes.forEach((e,t)=>{if(Math.abs(e.constant)<99999)this.hasPlaneChanged(t,e)&&(this.updateSection(e,t),this.updatePlaneState(t,e));else{const n=this.sectionMeshes.get(`plane_${t}`);n&&(n.visible=!1)}}),this.cleanExpiredCache())}hasPlaneChanged(e,t){const n=this.planeStates.get(e);if(!n)return!0;const i=Math.abs(n.constant-t.constant)>1e-4,s=!n.normal.equals(t.normal);return i||s}updatePlaneState(e,t){this.planeStates.set(e,{constant:t.constant,normal:t.normal.clone()})}getPlaneHash(e){const t=e.normal,n=e.constant;return`${t.x.toFixed(4)}_${t.y.toFixed(4)}_${t.z.toFixed(4)}_${n.toFixed(4)}`}getCacheKey(e,t){return`${e}_plane_${t}`}updateSection(e,t){const n=this.sectionMeshes.get(`plane_${t}`);if(!n)return;const i=this.getPlaneHash(e),s=[];if(this.sourceMeshes.forEach((o,a)=>{const l=this.getCacheKey(a,t),c=this.geometryCache.get(l);if(c&&c.planeHash===i)s.push(c.geometry.clone()),c.timestamp=Date.now();else try{const h=this.createPlaneBrush(e),u=new bi(o.geometry);o.updateMatrixWorld(!0),u.matrix.copy(o.matrixWorld),u.updateMatrixWorld();const m=this.evaluator.evaluate(h,u,Ir);m&&m.geometry.attributes.position.count>0?(s.push(m.geometry),this.geometryCache.set(l,{geometry:m.geometry.clone(),planeHash:i,timestamp:Date.now()})):this.geometryCache.delete(l)}catch(h){console.warn(`CSG intersection failed for mesh ${a}:`,h)}}),s.length>0){const o=this.mergeGeometries(s);n.geometry&&n.geometry.dispose(),n.geometry=o,n.visible=!0,n.position.set(0,0,0),n.rotation.set(0,0,0),n.scale.set(1,1,1),n.updateMatrixWorld()}else n.visible=!1;s.forEach(o=>o.dispose())}clearMeshCache(e){const t=[];this.geometryCache.forEach((n,i)=>{i.startsWith(e)&&(n.geometry.dispose(),t.push(i))}),t.forEach(n=>this.geometryCache.delete(n))}cleanExpiredCache(){const e=Date.now(),t=[];this.geometryCache.forEach((n,i)=>{e-n.timestamp>this.cacheExpireTime&&(n.geometry.dispose(),t.push(i))}),t.forEach(n=>this.geometryCache.delete(n))}clearAllCache(){this.geometryCache.forEach(e=>{e.geometry.dispose()}),this.geometryCache.clear()}createPlaneBrush(e){const t=new w.BoxGeometry(this.planeSize,this.planeThickness,this.planeSize);t.translate(0,e.constant,0),t.applyQuaternion(new w.Quaternion().setFromUnitVectors(new w.Vector3(0,-1,0),e.normal));const n=new w.Mesh(t),i=new bi(t);return i.matrix.copy(n.matrixWorld),i.updateMatrixWorld(),i}mergeGeometries(e){if(e.length===1)return e[0].clone();const t=new w.BufferGeometry,n=[],i=[],s=[];let o=0;return e.forEach(a=>{const l=a.attributes.position,c=a.attributes.normal;for(let h=0;h<l.count;h++)n.push(l.getX(h),l.getY(h),l.getZ(h));if(c)for(let h=0;h<c.count;h++)i.push(c.getX(h),c.getY(h),c.getZ(h));if(a.index)for(let h=0;h<a.index.count;h++)s.push(a.index.getX(h)+o);o+=l.count}),t.setAttribute("position",new w.Float32BufferAttribute(n,3)),i.length>0?t.setAttribute("normal",new w.Float32BufferAttribute(i,3)):t.computeVertexNormals(),s.length>0&&t.setIndex(s),t}calculateSceneSize(){const e=new w.Box3;if(this.engine.scene.traverse(t=>{if(t.isMesh&&t.geometry){const n=new w.Box3().setFromObject(t);e.union(n)}}),e.isEmpty())this.planeSize=1e3;else{const t=e.getSize(new w.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 w.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 Au{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 Cu(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 w.Plane;n.setFromNormalAndCoplanarPoint(new w.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new w.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new w.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}clampVector3(e,t,n){return new w.Vector3(Math.max(t.x,Math.min(n.x,e.x)),Math.max(t.y,Math.min(n.y,e.y)),Math.max(t.z,Math.min(n.z,e.z)))}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 w.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,n)){let i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());if(this.pickMesh.name=="前"||this.pickMesh.name=="左"||this.pickMesh.name=="底"){let o=this.box_.min.clone().add(this.pickNormal.clone().setLength(i));this.box.min=this.clampVector3(o,this.maxBox.min,this.box.max)}else{let o=this.box_.max.clone().add(this.pickNormal.clone().setLength(i));this.box.max=this.clampVector3(o,this.box.min,this.maxBox.max)}this.updata_face(this.box),this.calculate_ratio()}}}calculate_ratio(){let e=this.maxBox.max.x-this.maxBox.min.x,t=this.maxBox.max.y-this.maxBox.min.y,n=this.maxBox.max.z-this.maxBox.min.z,i=(this.box.min.x-this.maxBox.min.x)/e*100,s=(this.box.max.x-this.maxBox.min.x)/e*100,o=(this.box.min.y-this.maxBox.min.y)/t*100,a=(this.box.max.y-this.maxBox.min.y)/t*100,l=(this.box.min.z-this.maxBox.min.z)/n*100,c=(this.box.max.z-this.maxBox.min.z)/n*100;i<0&&(i=0),s<0&&(s=0),o<0&&(o=0),a<0&&(a=0),l<0&&(l=0),c<0&&(c=0),i>100&&(i=100),s>100&&(s=100),o>100&&(o=100),a>100&&(a=100),l>100&&(l=100),c>100&&(c=100);let h={x:{min:i,max:s},y:{min:o,max:a},z:{min:l,max:c}};this.engine.events.trigger(Me.SectionMove,h)}updata_face(e){let t=this,n=[new w.Vector3(e.min.x,e.min.y,e.min.z),new w.Vector3(e.max.x,e.min.y,e.min.z),new w.Vector3(e.max.x,e.max.y,e.min.z),new w.Vector3(e.min.x,e.max.y,e.min.z)],i=[new w.Vector3(e.min.x,e.min.y,e.max.z),new w.Vector3(e.max.x,e.min.y,e.max.z),new w.Vector3(e.max.x,e.max.y,e.max.z),new w.Vector3(e.min.x,e.max.y,e.max.z)],s=[new w.Vector3(e.max.x,e.min.y,e.max.z),new w.Vector3(e.max.x,e.min.y,e.min.z),new w.Vector3(e.max.x,e.max.y,e.min.z),new w.Vector3(e.max.x,e.max.y,e.max.z)],o=[new w.Vector3(e.min.x,e.min.y,e.min.z),new w.Vector3(e.min.x,e.min.y,e.max.z),new w.Vector3(e.min.x,e.max.y,e.max.z),new w.Vector3(e.min.x,e.max.y,e.min.z)],a=[new w.Vector3(e.min.x,e.max.y,e.min.z),new w.Vector3(e.max.x,e.max.y,e.min.z),new w.Vector3(e.max.x,e.max.y,e.max.z),new w.Vector3(e.min.x,e.max.y,e.max.z)],l=[new w.Vector3(e.min.x,e.min.y,e.min.z),new w.Vector3(e.max.x,e.min.y,e.min.z),new w.Vector3(e.max.x,e.min.y,e.max.z),new w.Vector3(e.min.x,e.min.y,e.max.z)];c(n,new w.Vector3(0,0,-1),"前"),c(i,new w.Vector3(0,0,1),"后"),c(s,new w.Vector3(1,0,0),"右"),c(o,new w.Vector3(-1,0,0),"左"),c(a,new w.Vector3(0,1,0),"顶"),c(l,new w.Vector3(0,-1,0),"底");function c(h,u,m){const p=new w.BufferGeometry,f=new Float32Array([h[0].x,h[0].y,h[0].z,h[1].x,h[1].y,h[1].z,h[2].x,h[2].y,h[2].z,h[3].x,h[3].y,h[3].z]),d=[0,1,2,0,2,3];p.setAttribute("position",new w.BufferAttribute(f,3)),p.setIndex(d);let g=t.engine.scene.children.find(T=>T.type=="Group"&&T.name=="ClippingBox");g==null&&(g=new w.Group,g.name="ClippingBox",t.engine.scene.add(g));let y=t.meshs.find(T=>T.name==m);if(y==null){const T=new w.MeshBasicMaterial({color:65280,transparent:!0,opacity:0,side:w.DoubleSide});T.polygonOffset=!0,T.polygonOffsetFactor=1,T.polygonOffsetUnits=4;const P=new w.Mesh(p,T);P.normal=u,P.name=m,g.add(P),t.meshs.push(P)}else y.geometry=p;const v=new Float32Array([h[0].x,h[0].y,h[0].z,h[1].x,h[1].y,h[1].z,h[2].x,h[2].y,h[2].z,h[3].x,h[3].y,h[3].z,h[0].x,h[0].y,h[0].z]);let x=new w.LineBasicMaterial({color:255}),b=new w.BufferGeometry;b.setAttribute("position",new w.BufferAttribute(v,3));let _=t.meshs.find(T=>T.name==m+"Line");_==null&&(_=new w.Line(b,x),_.name=m+"Line",g.add(_),t.meshs.push(_)),_.geometry=b,_.material=x,m=="前"||m=="左"||m=="底"?t.engine.sectionPlane.find(T=>T.name==m).setFromNormalAndCoplanarPoint(u.clone().setLength(-1),e.min):t.engine.sectionPlane.find(T=>T.name==m).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 Pu{engine;isActive=!1;isDrag=!1;meshs=[];box;pickPoint;pickNormal;pickMesh;box_;plane;angleX=0;angleY=0;angleZ=0;direction=1;normal=new w.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(e){let t=this.engine.octreeBox.getBoundingBox();if(this.box=t,e){this.center=new w.Vector3((t.min.x+t.max.x)/2,(t.min.y+t.max.y)/2,(t.min.z+t.max.z)/2);return}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 w.Vector3(0,1,0).applyAxisAngle(new w.Vector3(1,0,0),e).applyAxisAngle(new w.Vector3(0,0,1),t).applyAxisAngle(new w.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)}setFaceNormalPlaneOnly(e,t){if(this.normal=e.clone().normalize(),this.distance=t,!this.center||!this.box)return;const n=this.engine.sectionPlane?.find(i=>i.name==="face");if(n){const i=this.center.clone().add(this.normal.clone().multiplyScalar(t));n.setFromNormalAndCoplanarPoint(this.normal.clone().multiplyScalar(this.direction),i)}}activateClippingOnly(){if(this.isActive)return;this.isActive=!0;const 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)})}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(k=>k.type=="Group"&&k.name=="ClippingBox");n==null&&(n=new w.Group,n.name="ClippingBox",t.engine.scene.add(n));let i=new w.Vector3(1,0,0),s=new w.Vector3(0,1,0),o=new w.Vector3(0,0,1),a,l,c=this.normal.clone().normalize(),h=Math.abs(c.dot(i)),u=Math.abs(c.dot(s)),m=Math.abs(c.dot(o));h<=u&&h<=m?a=i:u<=h&&u<=m?a=s:a=o,a=a.clone().sub(c.clone().multiplyScalar(a.dot(c))).normalize(),l=new w.Vector3().crossVectors(c,a).normalize();let p=null;this.center==null?(p=new w.Vector3((this.box.min.x+this.box.max.x)/2,(this.box.min.y+this.box.max.y)/2,(this.box.min.z+this.box.max.z)/2),this.center=p.clone()):p=this.center.clone();let f=this.box.max.x-this.box.min.x,d=this.box.max.y-this.box.min.y,g=this.box.max.z-this.box.min.z,y=Math.max(Math.abs(a.x)*f,Math.abs(a.y)*d,Math.abs(a.z)*g),v=Math.max(Math.abs(l.x)*f,Math.abs(l.y)*d,Math.abs(l.z)*g),x=p.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(-v/2)),b=p.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(-v/2)),_=p.clone().add(a.clone().multiplyScalar(y/2)).add(l.clone().multiplyScalar(v/2)),T=p.clone().add(a.clone().multiplyScalar(-y/2)).add(l.clone().multiplyScalar(v/2));x.add(c.clone().multiplyScalar(e)),b.add(c.clone().multiplyScalar(e)),_.add(c.clone().multiplyScalar(e)),T.add(c.clone().multiplyScalar(e)),this.current_center=p.clone().add(c.clone().multiplyScalar(e)),D([x,b,_,T],c,"face");function D(k,E,R){const A=new w.BufferGeometry,I=new Float32Array([k[0].x,k[0].y,k[0].z,k[1].x,k[1].y,k[1].z,k[2].x,k[2].y,k[2].z,k[3].x,k[3].y,k[3].z]),S=[0,1,2,0,2,3];A.setAttribute("position",new w.BufferAttribute(I,3)),A.setIndex(S);let z=t.meshs.find(q=>q.name==R);if(z==null){const q=new w.MeshBasicMaterial({color:65280,transparent:!0,opacity:.02,side:w.DoubleSide});q.polygonOffset=!0,q.polygonOffsetFactor=1,q.polygonOffsetUnits=4;const N=new w.Mesh(A,q);N.normal=E,N.name=R,n.add(N),t.meshs.push(N)}else z.geometry=A;const U=new Float32Array([k[0].x,k[0].y,k[0].z,k[1].x,k[1].y,k[1].z,k[2].x,k[2].y,k[2].z,k[3].x,k[3].y,k[3].z,k[0].x,k[0].y,k[0].z]);let V=new w.LineBasicMaterial({color:255}),$=new w.BufferGeometry;$.setAttribute("position",new w.BufferAttribute(U,3));let G=t.meshs.find(q=>q.name==R+"Line");G==null&&(G=new w.Line($,V),G.name=R+"Line",n.add(G),t.meshs.push(G)),G.geometry=$,G.material=V,t.engine.sectionPlane.find(q=>q.name==R).setFromNormalAndCoplanarPoint(E.clone().setLength(t.direction),k[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 w.Plane;n.setFromNormalAndCoplanarPoint(new w.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new w.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new w.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 w.Vector3;if(e.raycaster.ray.intersectPlane(this.plane,n)){let i=n.clone().sub(this.pickPoint.clone()).dot(this.pickNormal.clone());const s=new w.Vector3((this.box.max.x-this.box.min.x)/2,(this.box.max.y-this.box.min.y)/2,(this.box.max.z-this.box.min.z)/2),o=Math.abs(s.x*this.normal.x)+Math.abs(s.y*this.normal.y)+Math.abs(s.z*this.normal.z);i>o&&(i=o),i<-o&&(i=-o),this.distance=i,this.updata_face(this.distance)}}}}class Tu{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 ku{engine;sectionBox;sectionFace;clippingStencil;currentClippingMode="";constructor(e){this.engine=e;let t=new w.Plane(new w.Vector3(0,0,1),1e5);t.name="前";let n=new w.Plane(new w.Vector3(0,0,1),1e5);n.name="左";let i=new w.Plane(new w.Vector3(0,0,1),1e5);i.name="后";let s=new w.Plane(new w.Vector3(0,0,1),1e5);s.name="右";let o=new w.Plane(new w.Vector3(0,0,1),1e5);o.name="顶";let a=new w.Plane(new w.Vector3(0,0,1),1e5);a.name="底";let l=new w.Plane(new w.Vector3(0,0,1),1e5);l.name="face",this.engine.sectionPlane=[t,n,i,s,o,a,l]}init(){this.sectionBox=new Au(this.engine),this.sectionFace=new Pu(this.engine)}scaleBox(){let e=this.engine.octreeBox.getBoundingBox();this.sectionBox.setBox(e)}clippingModel(e){let t=[];e.forEach(s=>{let o=this.engine.models.find(a=>a.url===s.url);s.ids.forEach(a=>{o.nodesMap.get(a).infos.forEach(l=>{t.push(l.box)})})}),this.active("box");let n=i(t);this.sectionBox.setBox(n);function i(s){let o=new w.Vector3(1e8,1e9,1e10),a=new w.Vector3(-1e8,-1e9,-1e10);return s.forEach(l=>{l.min.x<o.x&&(o.x=l.min.x),l.min.y<o.y&&(o.y=l.min.y),l.min.z<o.z&&(o.z=l.min.z),l.max.x>a.x&&(a.x=l.max.x),l.max.y>a.y&&(a.y=l.max.y),l.max.z>a.z&&(a.z=l.max.z)}),new w.Box3(o,a)}}updateClippingValue(e){let t=this.sectionBox.maxBox,n=t.min.x+(t.max.x-t.min.x)*e.x.min*.01,i=t.min.y+(t.max.y-t.min.y)*e.y.min*.01,s=t.min.z+(t.max.z-t.min.z)*e.z.min*.01,o=t.min.x+(t.max.x-t.min.x)*e.x.max*.01,a=t.min.y+(t.max.y-t.min.y)*e.y.max*.01,l=t.min.z+(t.max.z-t.min.z)*e.z.max*.01;this.sectionBox.setboxXyz({minX:n,minY:i,minZ:s,maxX:o,maxY:a,maxZ:l})}active(e){if(this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=e,e=="x")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(Math.PI/2,0,0);else if(e=="y")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,Math.PI/2,0);else if(e=="z")this.sectionFace.init(),this.sectionFace.active(),this.sectionFace.setFaceAngle(0,0,Math.PI/2);else if(e=="box")this.sectionBox.init(),this.sectionBox.active();else if(e=="face"){let t=new Tu(this.engine);t.init(),t.catch_face(n=>{this.sectionFace.init(),this.sectionFace.active();let i=this.engine.octreeBox.getBoundingBox(),s=n.position.clone().sub(i.min.clone().add(i.max.clone()).setLength(.5)),o=new w.Vector3(n.dir.x,n.dir.y,n.dir.z),a=s.dot(o);this.sectionFace.setFaceNormal(n.dir,a)})}}disabled(){this.currentClippingMode=="box"?this.sectionBox.disabled():this.sectionFace.disabled()}recover(){this.currentClippingMode=="box"?this.sectionBox.recover():this.sectionFace.recover()}reverse(){this.sectionFace.reverse()}disActive(){this.sectionFace.disActive(),this.sectionBox.disActive(),this.currentClippingMode=""}setSectionByView(e,t){this.sectionFace.disActive(),this.sectionBox.disActive(),this.scaleBox(),this.sectionFace.init(!0);const n=this.engine.octreeBox.getBoundingBox(),i=new w.Vector3((n.min.x+n.max.x)/2,(n.min.y+n.max.y)/2,(n.min.z+n.max.z)/2),o=new w.Vector3(t.x,t.y,t.z).normalize().clone().negate(),l=new w.Vector3(e.x,e.y,e.z).clone().sub(i).dot(o);this.sectionFace.setFaceNormalPlaneOnly(o,l),this.sectionFace.activateClippingOnly(),this.currentClippingMode="face"}}class Du{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 Eu{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 w.Mesh){const s=i.geometry;if(s&&s.attributes){const o=s.attributes.position;if(o){const a=o.count;e+=a;let l=0;s.index?l=s.index.count/3:l=a/3,t+=l}}}}),this.engine.engineStatus.models.forEach(i=>{n=n+i.info.modelEdge.length}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:n})}}class Lu{engine;constructor(e){this.engine=e}init(){}getModelPropertiesWithName(e,t,n,i){let s=this.engine.engineStatus.models.find(a=>a.url===e);s.properties==null?Jn(e+"/property",a=>{let l=JSON.parse(a);s.properties=l,setTimeout(()=>{o(l,n,t,i)},100)}):o(s.properties,n,t,i);function o(a,l,c,h){let u={};a.models[c.toString()||""].forEach(p=>{n.includes(a.names[p[1]])&&(u[a.names[p[1]]]=a.values[p[2]])}),h?.({id:c,properties:u})}}getModelProperties(e,t,n){let i=this.engine.engineStatus.models.find(o=>o.url===e);i.properties==null&&Jn(e+"/property",o=>{let a=JSON.parse(o);i.properties=a,setTimeout(()=>{s(a,t,n)},100)}),s(i.properties,t,n);function s(o,a,l){let c=[],h=o.models[a.toString()||""],u=h.map(m=>m[0]);u=u.filter((m,p)=>u.indexOf(m)===p),u.forEach(m=>{let p={name:o.categorys[m],children:[]};c.push(p),h.filter(f=>f[0]===m).forEach(f=>{p.children.push({name:o.names[f[1]],value:o.values[f[2]]})})}),l?.({properties:c,materials:c})}}}class Iu{engine;constructor(e){this.engine=e}getModelTypes(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.typeName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMajors(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.majorName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelLevels(){let e=[];return this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.levelName)})}),e=e.filter((t,n,i)=>i.indexOf(t)===n),e}getModelMappers(e){}getModelMapper(e,t){let n=this.engine.engineStatus.models.find(o=>o.url==e);return n?n.info.modelMapper.find(o=>o.id==t):null}getModelsWithLevelType(e,t,n=null){let i=[];return this.engine.engineStatus.models.forEach(s=>{let o={url:s.url,ids:[]};i.push(o),s.info.modelMapper.filter(l=>l.levelName===e&&l.typeName===t).forEach(l=>{o.ids.push(Number(l.id))})}),n&&n(i),i}getModelsWithType(e,t=null){let n=[];return this.engine.engineStatus.models.forEach(i=>{let s={url:i.url,ids:[]};n.push(s),i.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithLevel(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let s={url:i.url,ids:[]};n.push(s),i.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(n),n}getModelsWithMajor(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let s={url:i.url,ids:[]};n.push(s),i.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{s.ids.push(Number(a.id))})}),t&&t(n),n}}class zu{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 w.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(o=>{let a=i.length;for(let l=0;l<o.points.length;l++)o.points[l].length==2&&(i.push(o.points[l][0].X),i.push(o.points[l][0].Z),i.push(-o.points[l][0].Y),i.push(o.points[l][1].X),i.push(o.points[l][1].Z),i.push(-o.points[l][1].Y));s.set(Number(o.id),[a,i.length,o.points])}),this.indexes.set(e.url,s)}}),this.modelEdgeLoaded=!0)}show(){this.modelEdgeLoaded||this.loadModelEdge(),this.indexes.forEach((e,t)=>{let n=[];e.forEach((o,a)=>{o[2].forEach((l,c)=>{l.length==2&&(n.push(l[0].X),n.push(l[0].Z),n.push(-l[0].Y),n.push(l[1].X),n.push(l[1].Z),n.push(-l[1].Y))})});let i=new w.BufferGeometry;i.setAttribute("position",new w.Float32BufferAttribute(n,3));let s=new w.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,o,a]=i,l=this.groupEdge.children.find(c=>c.url==e);if(l){let c=l.geometry.attributes.position.array;for(let h=s;h<o;h++)c[h]=NaN;l.geometry.attributes.position.needsUpdate=!0}}}}showModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i){let[s,o,a]=i,l=this.groupEdge.children.find(c=>c.url==e);if(l){let c=l.geometry.attributes.position.array,h=0;for(let u=s;u<o;u+=3){const m=Math.floor(h/6),p=h%6>=3;if(a[m]&&a[m].length===2){const f=p?a[m][1]:a[m][0];c[u]=f.X,c[u+1]=f.Z,c[u+2]=-f.Y}h+=3}l.geometry.attributes.position.needsUpdate=!0}}}}}class Bu{config;constructor(e){this.config={temperature:.7,maxTokens:2e4,timeout:3e5,...e}}async chat(e){const t=new AbortController,n=setTimeout(()=>t.abort(),this.config.timeout);try{const i=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!1}),signal:t.signal});if(clearTimeout(n),!i.ok){const o=await i.json().catch(()=>({}));throw new Error(`API请求失败 (${i.status}): ${o.error?.message||o.message||i.statusText}`)}return(await i.json()).choices?.[0]?.message?.content||""}catch(i){throw clearTimeout(n),i.name==="AbortError"?new Error("请求超时,请重试"):i.message.includes("Failed to fetch")?new Error(`网络请求失败,请检查:
|
|
972
972
|
1. 网络连接
|
|
973
973
|
2. API地址是否正确
|
|
974
|
-
3. 是否有CORS限制`):i}}async chatStream(e,t){const n=new AbortController,i=setTimeout(()=>n.abort(),this.config.timeout);try{const s=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!0}),signal:n.signal});if(clearTimeout(i),!s.ok){const c=await s.json().catch(()=>({}));throw new Error(`API请求失败 (${s.status}): ${c.error?.message||c.message||s.statusText}`)}const
|
|
975
|
-
`);l=
|
|
976
|
-
${this.prompts.apiDoc}`};this.conversationHistory.push(i),this.conversationHistory.push(s)}this.conversationHistory.push({role:"user",content:e});const t=await this.llmApi.chat(this.conversationHistory);this.conversationHistory.push({role:"assistant",content:t}),this.config?.debug&&console.log("[AI Manager] 大模型响应:",t);let n=await this.parseAnalysisResponse(t);n&&n.questions&&n.questions.length>0&&this._callback_question(n.questions)}async parseAnalysisResponse(e){try{if(e.includes("##question##")){const t=e.match(/##question##\s*([\s\S]*?)(?=##|$)/);if(t){let n=t[1].trim();n=n.replace(/^```json\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,"");const i=n.match(/(\[[\s\S]*\])/);i&&(n=i[1]);const s=JSON.parse(n);return this.state="waiting_answer",{state:"waiting_answer",questions:s}}}if(e.includes("##steps##")){const t=e.match(/##steps##\s*([\s\S]*?)(?=##|$)/);if(t){let n=t[1].trim();n=n.replace(/^```json\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,"");const i=n.match(/(\[[\s\S]*\])/);return i&&(n=i[1]),this.steps=JSON.parse(n),this.config?.debug&&console.log("[AI Manager] 步骤规划完成,共",this.steps.length,"个步骤"),this._callback_message(this.steps),await this.executeSteps()}}return{state:"completed",data:e}}catch(t){return console.error("[AI Manager] 解析响应失败:",t),{state:"error",error:"解析大模型响应失败: "+t.message}}}async executeSteps(){try{this.state="executing",this.stepResults.clear();for(const e of this.steps){this._callback_message(e),this.config?.debug&&console.log(`[AI Manager] 执行步骤 ${e.id}: ${e.content}`);const t=await this.getDependenciesOutput(e.dependencies),n=await this.executeStep(e,t);this.stepResults.set(e.id,n),this.config?.debug&&console.log(`[AI Manager] 步骤 ${e.id} 执行完成:`,n)}return this.state="completed",{state:"completed",steps:this.steps,result:Array.from(this.stepResults.values())}}catch(e){return console.error("[AI Manager] 步骤执行失败:",e),{state:"error",error:"步骤执行失败: "+e.message}}}async getDependenciesOutput(e){return e.length===0?null:e.length===1?this.stepResults.get(e[0]):e.map(t=>this.stepResults.get(t))}async executeStep(e,t){const n=this.config?.stepExecution?.maxRetries??1,i=[];let s=null,
|
|
977
|
-
${h}`);try{const
|
|
974
|
+
3. 是否有CORS限制`):i}}async chatStream(e,t){const n=new AbortController,i=setTimeout(()=>n.abort(),this.config.timeout);try{const s=await fetch(`${this.config.baseURL}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiKey}`},body:JSON.stringify({model:this.config.model,messages:e,temperature:this.config.temperature,max_tokens:this.config.maxTokens,stream:!0}),signal:n.signal});if(clearTimeout(i),!s.ok){const c=await s.json().catch(()=>({}));throw new Error(`API请求失败 (${s.status}): ${c.error?.message||c.message||s.statusText}`)}const o=s.body?.getReader();if(!o)throw new Error("无法读取响应流");const a=new TextDecoder;let l="";for(;;){const{done:c,value:h}=await o.read();if(c){t("",!0);break}l+=a.decode(h,{stream:!0});const u=l.split(`
|
|
975
|
+
`);l=u.pop()||"";for(const m of u){const p=m.trim();if(!p||!p.startsWith("data: "))continue;const f=p.slice(6);if(f!=="[DONE]")try{const g=JSON.parse(f).choices?.[0]?.delta?.content;g&&t(g,!1)}catch(d){console.warn("解析流式数据失败:",d)}}}}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 Ru{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 Bu(i.llmConfig);try{const s=await Promise.resolve().then(()=>Zf);this.prompts.main=s.default;const o=await Promise.resolve().then(()=>Yf);this.prompts.step=o.default;const a=await Promise.resolve().then(()=>Kf);this.prompts.apiDoc=a.default}catch(s){throw console.error("[AI Manager] 提示词文件加载失败:",s),new Error(`提示词文件加载失败: ${s.message||"未知错误"}`)}}catch(s){throw console.error("[AI Manager] 初始化失败:",s),s}}async conversationV2(e){if(this.conversationHistory.length===0){const i={role:"system",content:`${this.prompts.main}`},s={role:"system",content:`## BIM引擎API文档
|
|
976
|
+
${this.prompts.apiDoc}`};this.conversationHistory.push(i),this.conversationHistory.push(s)}this.conversationHistory.push({role:"user",content:e});const t=await this.llmApi.chat(this.conversationHistory);this.conversationHistory.push({role:"assistant",content:t}),this.config?.debug&&console.log("[AI Manager] 大模型响应:",t);let n=await this.parseAnalysisResponse(t);n&&n.questions&&n.questions.length>0&&this._callback_question(n.questions)}async parseAnalysisResponse(e){try{if(e.includes("##question##")){const t=e.match(/##question##\s*([\s\S]*?)(?=##|$)/);if(t){let n=t[1].trim();n=n.replace(/^```json\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,"");const i=n.match(/(\[[\s\S]*\])/);i&&(n=i[1]);const s=JSON.parse(n);return this.state="waiting_answer",{state:"waiting_answer",questions:s}}}if(e.includes("##steps##")){const t=e.match(/##steps##\s*([\s\S]*?)(?=##|$)/);if(t){let n=t[1].trim();n=n.replace(/^```json\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,"");const i=n.match(/(\[[\s\S]*\])/);return i&&(n=i[1]),this.steps=JSON.parse(n),this.config?.debug&&console.log("[AI Manager] 步骤规划完成,共",this.steps.length,"个步骤"),this._callback_message(this.steps),await this.executeSteps()}}return{state:"completed",data:e}}catch(t){return console.error("[AI Manager] 解析响应失败:",t),{state:"error",error:"解析大模型响应失败: "+t.message}}}async executeSteps(){try{this.state="executing",this.stepResults.clear();for(const e of this.steps){this._callback_message(e),this.config?.debug&&console.log(`[AI Manager] 执行步骤 ${e.id}: ${e.content}`);const t=await this.getDependenciesOutput(e.dependencies),n=await this.executeStep(e,t);this.stepResults.set(e.id,n),this.config?.debug&&console.log(`[AI Manager] 步骤 ${e.id} 执行完成:`,n)}return this.state="completed",{state:"completed",steps:this.steps,result:Array.from(this.stepResults.values())}}catch(e){return console.error("[AI Manager] 步骤执行失败:",e),{state:"error",error:"步骤执行失败: "+e.message}}}async getDependenciesOutput(e){return e.length===0?null:e.length===1?this.stepResults.get(e[0]):e.map(t=>this.stepResults.get(t))}async executeStep(e,t){const n=this.config?.stepExecution?.maxRetries??1,i=[];let s=null,o=!1;for(let a=0;a<=n;a++)try{const l=i.length>0?i[i.length-1]:"",h=await(a===0?this.generateCode(e,t):o?this.regenerateCodeAfterFailure(e,t,l,s,a):this.generateCode(e,t));i.push(h),this.config?.debug&&console.log(`[AI Manager] 步骤 ${e.id} 第 ${a+1} 次生成的代码:
|
|
977
|
+
${h}`);try{const u=await this.executeCode(h,t);if(u instanceof Object&&u.success==!1||u instanceof String&&(u.includes("undefined")||u.includes("not"))){s=u,o=!0;debugger;throw u}debugger;return u}catch(u){debugger;throw s=u,o=!0,u}}catch(l){if(o||(s=l),a>=n)throw console.error(`[AI Manager] 执行步骤 ${e.id} 失败(已达重试上限):`,l),new Error(`步骤 ${e.id} (${e.content}) 执行失败: ${l.message}`);console.warn(`[AI Manager] 步骤 ${e.id} 第 ${a+1} 次执行失败,将尝试让AI修复后重试(剩余重试次数:${n-a}):`,l)}throw new Error(`步骤 ${e.id} (${e.content}) 执行失败: 未知错误`)}extractCodeFromResponse(e){const t=e.match(/##code##\s*([\s\S]*?)(?=##|$)/);if(t){let o=t[1].trim();if(o=o.replace(/^```javascript\n?/,"").replace(/^```js\n?/,"").replace(/^```\n?/,"").replace(/\n?```$/,""),o.length>0)return o}const n=[/```javascript\s*([\s\S]*?)```/i,/```js\s*([\s\S]*?)```/i,/```\s*([\s\S]*?)```/];for(const o of n){const a=e.match(o);if(a&&a[1]){const l=a[1].trim();if(l.length>0)return this.config?.debug&&console.warn("[AI Manager] 未找到 ##code## 标记,从 markdown 代码块中提取代码"),l}}const i=/[请|说明|注意|需要|应该|可以|如果|但是|因为|所以|例如|比如]/i.test(e),s=/(function|const|let|var|return|async|await|=>|engine\.|previousStepOutput)/.test(e);if(!i&&s){const a=e.trim().replace(/^[,。:;!?\s]+/,"").replace(/[,。:;!?\s]+$/,"");if(a.length>10)return this.config?.debug&&console.warn("[AI Manager] 未找到 ##code## 标记和代码块,尝试使用整个响应作为代码"),a}throw new Error(`无法从大模型响应中提取代码。响应内容:${e.substring(0,200)}...`)}async generateCode(e,t){try{const n={role:"system",content:`${this.prompts.step}`},i={role:"system",content:`
|
|
978
978
|
|
|
979
979
|
## BIM引擎API文档
|
|
980
980
|
${this.prompts.apiDoc}`},s={role:"user",content:`请根据以下步骤描述生成可执行的JavaScript代码:
|
|
@@ -985,7 +985,7 @@ ${JSON.stringify(e,null,2)}
|
|
|
985
985
|
前序步骤输出数据:
|
|
986
986
|
${t?JSON.stringify(t,null,2):"null"}
|
|
987
987
|
|
|
988
|
-
请严格按照##code##格式输出代码。`},
|
|
988
|
+
请严格按照##code##格式输出代码。`},o=[n,i,s],a=await this.llmApi.chat(o);return this.extractCodeFromResponse(a)}catch(n){throw console.error("[AI Manager] 代码生成失败:",n),n}}async regenerateCodeAfterFailure(e,t,n,i,s){try{const o={role:"system",content:`${this.prompts.step}`},a={role:"system",content:`
|
|
989
989
|
|
|
990
990
|
## BIM引擎API文档
|
|
991
991
|
${this.prompts.apiDoc}`},l={message:i?.message||(i instanceof Object?JSON.stringify(i):String(i)),name:i?.name,stack:i?.stack},c={role:"user",content:`上一次生成的代码在执行时失败了,请你修复后重新输出完整可执行的 JavaScript 代码(仍然要严格按 ##code## 格式输出)。
|
|
@@ -1012,91 +1012,328 @@ ${JSON.stringify(l,null,2)}
|
|
|
1012
1012
|
1) 不要输出解释文字,只输出 ##code## 段落里的代码
|
|
1013
1013
|
2) 如果是语法错误/引用未定义/缺少 await/返回值不一致,请直接修复
|
|
1014
1014
|
3) 尽量保持与步骤目标一致,避免引入与步骤无关的副作用
|
|
1015
|
-
4) 代码需要能在浏览器环境运行(不要使用 Node 专属 API)`},h=await this.llmApi.chat([
|
|
1015
|
+
4) 代码需要能在浏览器环境运行(不要使用 Node 专属 API)`},h=await this.llmApi.chat([o,a,c]);try{return this.extractCodeFromResponse(h)}catch(u){throw new Error(`无法从大模型响应中提取代码(修复重试阶段):${u.message}`)}}catch(o){throw console.error("[AI Manager] 修复后代码生成失败:",o),o}}async executeCode(e,t){try{const n=this.engine;let i=e;i=i.replace(/\b(const|let|var)\s+previousStepOutput\s*=\s*[^;]*;/g,""),i=i.replace(/\b(const|let|var)\s+previousStepOutput\s*;/g,"");const o=new Function("engine","previousStepOutput",`
|
|
1016
1016
|
'use strict';
|
|
1017
1017
|
${i}
|
|
1018
|
-
`)(n,t);return r&&typeof r.then=="function"?await r:r}catch(n){return console.error("[AI Manager] 代码执行失败:",n),"error"+n.message}}reset(){this.conversationHistory=[],this.steps=[],this.stepResults.clear(),this.state="idle",this.config?.debug&&console.log("[AI Manager] 对话已重置")}getState(){return this.state}getHistory(){return[...this.conversationHistory]}getSteps(){return[...this.steps]}getStepResults(){return new Map(this.stepResults)}}class xd{engine;points=[];isPlaying=!1;animationFrameId=null;playStartTime=0;playFromIndex=0;playToIndex=0;playOptions={};stayTimerId=null;playRangeToIndex=0;constructor(e){this.engine=e}init(){this.points=[],this.stop()}getCurrentPoint(){return{...this.engine.cameraModule.getCameraPose(),stayTime:0}}addPoint(e=0){const t=this.getCurrentPoint();return t.stayTime=e,this.points.push(t),this.points.length}addPoints(e){for(const t of e)this.points.push({...t});return this.points.length}savePoints(e){return this.addPoints(e)}removePoint(e){return e>=0&&e<this.points.length?(this.points.splice(e,1),!0):!1}clearPoints(){this.stop(),this.points=[]}getPoints(){return[...this.points]}getPointCount(){return this.points.length}updatePoint(e,t){return e>=0&&e<this.points.length?(this.points[e]={...t},!0):!1}jumpToPoint(e){return e>=0&&e<this.points.length?(this.stop(),this.engine.cameraModule.restoreCameraPose(this.points[e]),!0):!1}play(e={}){return this.points.length<2?(console.warn("PathRoaming: 至少需要2个点位才能播放"),!1):(this.isPlaying&&this.stop(),this.isPlaying=!0,this.playOptions={duration:3e3,loop:!1,...e},this.engine.controlModule.disActive(),this.playFromIndex=0,this.playToIndex=1,this.playRangeToIndex=this.points.length-1,this.playStartTime=performance.now(),this.animate(),!0)}playRange(e,t,n={}){return e<0||t>=this.points.length||e>=t?(console.warn("PathRoaming: 无效的索引范围"),!1):this.points.length<2?(console.warn("PathRoaming: 至少需要2个点位才能播放"),!1):(this.isPlaying&&this.stop(),this.isPlaying=!0,this.playOptions={duration:3e3,loop:!1,...n},this.engine.controlModule.disActive(),this.playFromIndex=e,this.playToIndex=e+1,this.playStartTime=performance.now(),this.playRangeToIndex=t,this.animate(),!0)}stop(){this.isPlaying=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.stayTimerId!==null&&(clearTimeout(this.stayTimerId),this.stayTimerId=null),this.engine.controlModule.active()}pause(){this.isPlaying&&(this.isPlaying=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.stayTimerId!==null&&(clearTimeout(this.stayTimerId),this.stayTimerId=null))}getIsPlaying(){return this.isPlaying}animate=()=>{if(!this.isPlaying)return;const t=performance.now()-this.playStartTime,n=this.playOptions.duration||3e3,i=Math.min(t/n,1),s=this.points[this.playFromIndex],r=this.points[this.playToIndex],a=this.interpolatePose(s,r,i);this.engine.cameraModule.restoreCameraPose(a),i>=1?this.onSegmentComplete():this.animationFrameId=requestAnimationFrame(this.animate)};onSegmentComplete(){const e=this.playToIndex;this.playOptions.onPointComplete&&this.playOptions.onPointComplete(e);const t=this.points[e];t.stayTime&&t.stayTime>0?this.stayTimerId=globalThis.setTimeout(()=>{this.stayTimerId=null,this.moveToNextSegment()},t.stayTime):this.moveToNextSegment()}moveToNextSegment(){const e=this.playToIndex>=this.playRangeToIndex,t=this.playToIndex>=this.points.length-1;e||t?this.playOptions.loop&&this.points.length>=2?(this.playFromIndex=0,this.playToIndex=1,this.playRangeToIndex=this.points.length-1,this.playStartTime=performance.now(),this.animate()):this.onPlayComplete():(this.playFromIndex=this.playToIndex,this.playToIndex=this.playToIndex+1,this.playStartTime=performance.now(),this.animate())}onPlayComplete(){this.stop(),this.playOptions.onComplete&&this.playOptions.onComplete()}interpolatePose(e,t,n){const i=this.easeInOutCubic(n),s={type:t.type,position:{x:b.MathUtils.lerp(e.position.x,t.position.x,i),y:b.MathUtils.lerp(e.position.y,t.position.y,i),z:b.MathUtils.lerp(e.position.z,t.position.z,i)},rotation:{x:b.MathUtils.lerp(e.rotation.x,t.rotation.x,i),y:b.MathUtils.lerp(e.rotation.y,t.rotation.y,i),z:b.MathUtils.lerp(e.rotation.z,t.rotation.z,i)},quaternion:{x:b.MathUtils.lerp(e.quaternion.x,t.quaternion.x,i),y:b.MathUtils.lerp(e.quaternion.y,t.quaternion.y,i),z:b.MathUtils.lerp(e.quaternion.z,t.quaternion.z,i),w:b.MathUtils.lerp(e.quaternion.w,t.quaternion.w,i)}};return e.target&&t.target?s.target={x:b.MathUtils.lerp(e.target.x,t.target.x,i),y:b.MathUtils.lerp(e.target.y,t.target.y,i),z:b.MathUtils.lerp(e.target.z,t.target.z,i)}:t.target&&(s.target={...t.target}),e.zoom!==void 0&&t.zoom!==void 0&&(s.zoom=b.MathUtils.lerp(e.zoom,t.zoom,i)),s}easeInOutCubic(e){return e<.5?4*e*e*e:1-Math.pow(-2*e+2,3)/2}dispose(){this.stop(),this.points=[],this.playOptions={}}}class bd{engine;miniMapCamera=null;miniMapRenderer=null;miniMapContainer=null;overlayCanvas=null;overlayCtx=null;isVisible=!1;mapSize=200;currentHalfSize=500;minHalfSize=5;maxHalfSize=1e4;halfSizeInitialized=!1;camY=1e3;centerX=0;centerZ=0;dragMode=null;lastMouseX=0;lastMouseY=0;constructor(e){this.engine=e,this.init()}getstate(){return this.isVisible}init(){this.miniMapContainer=document.createElement("div"),this.miniMapContainer.style.position="absolute",this.miniMapContainer.style.bottom="20px",this.miniMapContainer.style.left="20px",this.miniMapContainer.style.width=`${this.mapSize}px`,this.miniMapContainer.style.height=`${this.mapSize}px`,this.miniMapContainer.style.border="2px solid rgba(255, 255, 255, 0.4)",this.miniMapContainer.style.borderRadius="4px",this.miniMapContainer.style.overflow="hidden",this.miniMapContainer.style.display="none",this.miniMapContainer.style.zIndex="200",this.miniMapContainer.style.pointerEvents="auto",this.miniMapContainer.style.cursor="crosshair",this.engine.container.appendChild(this.miniMapContainer),this.miniMapRenderer=new b.WebGLRenderer({alpha:!0,antialias:!1}),this.miniMapRenderer.setSize(this.mapSize,this.mapSize),this.miniMapRenderer.setPixelRatio(window.devicePixelRatio),this.miniMapRenderer.setClearColor(1710638,.85),this.miniMapContainer.appendChild(this.miniMapRenderer.domElement);const e=window.devicePixelRatio||1;this.overlayCanvas=document.createElement("canvas"),this.overlayCanvas.width=this.mapSize*e,this.overlayCanvas.height=this.mapSize*e,this.overlayCanvas.style.position="absolute",this.overlayCanvas.style.top="0",this.overlayCanvas.style.left="0",this.overlayCanvas.style.width=`${this.mapSize}px`,this.overlayCanvas.style.height=`${this.mapSize}px`,this.overlayCanvas.style.pointerEvents="none",this.miniMapContainer.appendChild(this.overlayCanvas),this.overlayCtx=this.overlayCanvas.getContext("2d"),this.overlayCtx&&this.overlayCtx.scale(e,e),this.miniMapCamera=new b.OrthographicCamera(-this.currentHalfSize,this.currentHalfSize,this.currentHalfSize,-this.currentHalfSize,.1,1e5),this.miniMapCamera.up.set(0,0,-1),this.setupEvents()}worldToPixel(e,t){const n=this.currentHalfSize;return{x:((e-this.centerX)/n*.5+.5)*this.mapSize,y:((t-this.centerZ)/n*.5+.5)*this.mapSize}}pixelToWorld(e,t){const n=this.currentHalfSize;return{x:(e/this.mapSize-.5)*2*n+this.centerX,z:(t/this.mapSize-.5)*2*n+this.centerZ}}setupEvents(){const e=this.miniMapContainer;e.addEventListener("wheel",this.onWheel,{passive:!1}),e.addEventListener("mousedown",this.onMouseDown),e.addEventListener("mousemove",this.onMouseMove),e.addEventListener("mouseup",this.onMouseUp),e.addEventListener("mouseleave",this.onMouseUp),e.addEventListener("contextmenu",t=>t.preventDefault()),["pointerdown","pointermove","pointerup","click","dblclick"].forEach(t=>e.addEventListener(t,n=>n.stopPropagation()))}onWheel=e=>{e.preventDefault(),e.stopPropagation();const t=e.deltaY>0?1.25:.8;this.currentHalfSize=Math.max(this.minHalfSize,Math.min(this.maxHalfSize,this.currentHalfSize*t))};onMouseDown=e=>{e.stopPropagation();const t=this.miniMapContainer.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top,s=this.engine.camera;if(!s)return;const{x:r,y:a}=this.worldToPixel(s.position.x,s.position.z);Math.hypot(n-r,i-a)<25?(this.dragMode="rotate",this.miniMapContainer.style.cursor="alias"):(this.dragMode=null,this.handleTeleport(n,i)),this.lastMouseX=n,this.lastMouseY=i};onMouseMove=e=>{if(e.stopPropagation(),this.dragMode!=="rotate")return;const t=this.miniMapContainer.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top;this.handleRotate(n,i),this.lastMouseX=n,this.lastMouseY=i};onMouseUp=e=>{e.stopPropagation(),this.dragMode=null,this.miniMapContainer&&(this.miniMapContainer.style.cursor="crosshair")};handleTeleport(e,t){const n=this.engine.camera,i=this.engine.controls;if(!n||!i)return;const{x:s,z:r}=this.pixelToWorld(e,t),a=s-n.position.x,l=r-n.position.z;n.position.x+=a,n.position.z+=l,i.target.x+=a,i.target.z+=l,i.update()}handleRotate(e,t){const n=this.engine.camera,i=this.engine.controls;if(!n||!i)return;const s=this.mapSize/2,r=this.mapSize/2,a=Math.atan2(this.lastMouseY-r,this.lastMouseX-s);let c=Math.atan2(t-r,e-s)-a;c>Math.PI&&(c-=2*Math.PI),c<-Math.PI&&(c+=2*Math.PI);const h=new b.Vector3().copy(i.target).sub(n.position),d=new b.Spherical().setFromVector3(h);d.theta-=c,h.setFromSpherical(d),i.target.copy(n.position).add(h),i.update()}drawOverlay(){const e=this.overlayCtx,t=this.engine.camera;if(!e||!t)return;e.clearRect(0,0,this.mapSize,this.mapSize);const n=this.mapSize/2,i=this.mapSize/2,s=new b.Vector3;t.getWorldDirection(s);const r=Math.atan2(s.x,-s.z),a=36,l=Math.PI/10;e.save(),e.translate(n,i),e.rotate(r);const c=e.createRadialGradient(0,0,2,0,0,a);c.addColorStop(0,"rgba(0, 230, 130, 0.9)"),c.addColorStop(1,"rgba(0, 230, 130, 0)");const h=-Math.sin(l)*a,d=-Math.cos(l)*a,m=Math.sin(l)*a,p=-Math.cos(l)*a;e.beginPath(),e.moveTo(0,0),e.lineTo(h,d),e.lineTo(m,p),e.closePath(),e.fillStyle=c,e.fill(),e.fillStyle="rgba(255, 255, 255, 0.95)",e.strokeStyle="rgba(0, 200, 110, 0.9)",e.lineWidth=1.5,e.beginPath(),e.arc(0,0,4,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}show(){this.isVisible=!0,this.miniMapContainer&&(this.miniMapContainer.style.display="block")}hide(){this.isVisible=!1,this.miniMapContainer&&(this.miniMapContainer.style.display="none")}toggle(){this.isVisible?this.hide():this.show()}update(){if(!this.isVisible||!this.miniMapCamera||!this.miniMapRenderer)return;const e=this.engine.camera;if(!(!e||!this.engine.scene)){if(this.engine.octreeBox){const t=this.engine.octreeBox.getBoundingBox();if(t?.min&&t?.max){const n=t.max.x-t.min.x,i=t.max.z-t.min.z,s=t.max.y-t.min.y;this.camY=t.max.y+Math.max(n,i,s),!this.halfSizeInitialized&&n+i>0&&(this.currentHalfSize=Math.max(n,i)*2,this.halfSizeInitialized=!0)}}this.centerX=e.position.x,this.centerZ=e.position.z,this.miniMapCamera.left=-this.currentHalfSize,this.miniMapCamera.right=this.currentHalfSize,this.miniMapCamera.top=this.currentHalfSize,this.miniMapCamera.bottom=-this.currentHalfSize,this.miniMapCamera.updateProjectionMatrix(),this.miniMapCamera.position.set(this.centerX,this.camY,this.centerZ),this.miniMapCamera.lookAt(this.centerX,this.camY-1,this.centerZ),this.miniMapRenderer.render(this.engine.scene,this.miniMapCamera),this.drawOverlay()}}dispose(){this.miniMapContainer&&(this.miniMapContainer.removeEventListener("wheel",this.onWheel),this.miniMapContainer.removeEventListener("mousedown",this.onMouseDown),this.miniMapContainer.removeEventListener("mousemove",this.onMouseMove),this.miniMapContainer.removeEventListener("mouseup",this.onMouseUp),this.miniMapContainer.removeEventListener("mouseleave",this.onMouseUp)),this.miniMapRenderer&&(this.miniMapRenderer.dispose(),this.miniMapRenderer=null),this.miniMapContainer&&(this.miniMapContainer.remove(),this.miniMapContainer=null),this.miniMapCamera=null,this.overlayCtx=null,this.overlayCanvas=null}}const Md=[{Id:"100001",Name:"1",Points:[{X:-2,Y:-5,Z:0},{X:-2,Y:5,Z:0}]},{Id:"100002",Name:"2",Points:[{X:2,Y:-5,Z:0},{X:2,Y:5,Z:0}]},{Id:"100003",Name:"A",Points:[{X:-5,Y:-2,Z:0},{X:5,Y:-2,Z:0}]},{Id:"100004",Name:"B",Points:[{X:-5,Y:2,Z:0},{X:5,Y:2,Z:0}]}];class _d{engine;rootGroup=null;isVisible=!1;axes=[];coordinateMapper=e=>new b.Vector3(e.X,e.Z,-e.Y);constructor(e){this.engine=e,this._initRoot()}setData(e){this._clearAxes(),this.axes=e.map(t=>({data:t,group:null})),this.axes.forEach(t=>this._buildAxis(t))}setMockData(){this.setData(Md)}show(){this.isVisible=!0,this.rootGroup&&(this.rootGroup.visible=!0)}hide(){this.isVisible=!1,this.rootGroup&&(this.rootGroup.visible=!1)}toggle(){this.isVisible?this.hide():this.show()}update(){if(!this.isVisible||!this.rootGroup)return;const e=this.engine.camera,t=this.engine.renderer;if(!e||!t)return;let n=.5;if(e instanceof b.OrthographicCamera){const i=e,s=(i.top-i.bottom)/i.zoom,r=t.domElement.clientHeight||1;n=30*s/r}this.rootGroup.traverse(i=>{i instanceof b.Sprite&&i.scale.set(n,n,1)})}dispose(){this._clearAxes(),this.rootGroup&&(this.engine.scene&&this.engine.scene.remove(this.rootGroup),this.rootGroup=null)}_initRoot(){this.rootGroup=new b.Group,this.rootGroup.name="GridRoot",this.rootGroup.visible=!1,this.engine.scene&&this.engine.scene.add(this.rootGroup)}_clearAxes(){this.axes.forEach(e=>{e.group&&(this.rootGroup?.remove(e.group),e.group.traverse(t=>{const n=t;if("geometry"in n&&n.geometry&&n.geometry.dispose(),"material"in n&&n.material){const i=n.material;"map"in i&&i.map&&i.map.dispose(),i.dispose()}}),e.group=null)}),this.axes=[]}_buildAxis(e){if(!this.rootGroup)return;const t=this.coordinateMapper(e.data.Points[0]),n=this.coordinateMapper(e.data.Points[1]),i=e.data.Name,s=new b.Group;s.name=`GridAxis_${e.data.Id}`;const r=new b.BufferGeometry().setFromPoints([t,n]),a=new b.LineBasicMaterial({color:1609983,depthTest:!1}),l=new b.Line(r,a);l.renderOrder=998,s.add(l),s.add(this._makeCircleSprite(i,t)),s.add(this._makeCircleSprite(i,n)),this.rootGroup.add(s),e.group=s}_makeCircleSprite(e,t){const i=document.createElement("canvas");i.width=128,i.height=128;const s=i.getContext("2d"),r=128/2,a=128/2,l=128/2-4;s.beginPath(),s.arc(r,a,l,0,Math.PI*2),s.fillStyle="white",s.fill(),s.strokeStyle="#1890ff",s.lineWidth=6,s.stroke(),s.fillStyle="#1890ff",s.font=`bold ${Math.round(128*.38)}px Arial`,s.textAlign="center",s.textBaseline="middle",s.fillText(e,r,a);const c=new b.CanvasTexture(i),h=new b.SpriteMaterial({map:c,depthTest:!1,transparent:!0}),d=new b.Sprite(h);return d.position.copy(t),d.scale.set(.5,.5,1),d.renderOrder=999,d}}const Sd=[{Id:"339",Name:"站台",Elevation:-.32808398950131235},{Id:"2787",Name:"站厅",Elevation:16.896325459317584},{Id:"236633",Name:"顶板",Elevation:36.745406824146976}];class Cd{engine;isVisible=!1;levels=[];svgContainer=null;svgOverlay=null;worldToScreen=null;halfSize=500;COLOR="#1890ff";PLANE_OPACITY=.08;constructor(e){this.engine=e,this._initSvg()}_initSvg(){this.svgContainer=document.createElement("div"),this.svgContainer.style.position="absolute",this.svgContainer.style.top="0",this.svgContainer.style.left="0",this.svgContainer.style.width="100%",this.svgContainer.style.height="100%",this.svgContainer.style.pointerEvents="none",this.svgContainer.style.overflow="hidden",this.svgContainer.style.display="none",this.engine.container.appendChild(this.svgContainer),this.svgOverlay=document.createElementNS("http://www.w3.org/2000/svg","svg"),this.svgOverlay.style.position="absolute",this.svgOverlay.style.top="0",this.svgOverlay.style.left="0",this.svgOverlay.style.width="1920px",this.svgOverlay.style.height="1080px",this.svgOverlay.style.overflow="visible",this.svgContainer.appendChild(this.svgOverlay)}setData(e){this._clearAll(),this.levels=e.map(t=>({data:t,group:null,svgGroup:null})),this.levels.forEach(t=>this._buildThreeObject(t))}setMockData(){this.setData(Sd)}show(){this.isVisible=!0,this.svgContainer&&(this.svgContainer.style.display="block"),this.levels.forEach(e=>{e.group&&(e.group.visible=!0)})}hide(){this.isVisible=!1,this.svgContainer&&(this.svgContainer.style.display="none"),this.levels.forEach(e=>{e.group&&(e.group.visible=!1)})}toggle(){this.isVisible?this.hide():this.show()}update(){!this.isVisible||!this.svgOverlay||!this.levels.length||!this.engine.camera||!this.engine.renderer||(this._initWorldToScreen(),this.levels.forEach(e=>this._updateSvgLabels(e)))}dispose(){this._clearAll(),this.svgContainer&&(this.svgContainer.remove(),this.svgContainer=null),this.svgOverlay=null,this.worldToScreen=null}_initWorldToScreen(){this.engine.camera&&this.engine.renderer&&this.engine.scene&&(this.worldToScreen=new De(this.engine.camera,this.engine.renderer,this.engine.scene))}_clearAll(){this.levels.forEach(e=>{e.group&&this.engine.scene&&(this.engine.scene.remove(e.group),e.group.traverse(t=>{t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(n=>n.dispose()):t.material.dispose())}),e.group=null),e.svgGroup&&this.svgOverlay&&(e.svgGroup.remove(),e.svgGroup=null)}),this.levels=[]}_buildThreeObject(e){if(!this.engine.scene)return;const t=e.data.Elevation,n=this.halfSize,i=new b.Group,s=new b.PlaneGeometry(n*2,n*2);s.rotateX(-Math.PI/2);const r=new b.MeshBasicMaterial({color:this.COLOR,transparent:!0,opacity:this.PLANE_OPACITY,side:b.DoubleSide,depthWrite:!1}),a=new b.Mesh(s,r);a.position.y=t,i.add(a);const l=[new b.Vector3(-n,t,-n),new b.Vector3(n,t,-n),new b.Vector3(n,t,n),new b.Vector3(-n,t,n),new b.Vector3(-n,t,-n)],c=new b.BufferGeometry().setFromPoints(l),h=new b.LineBasicMaterial({color:this.COLOR,transparent:!0,opacity:.7});if(i.add(new b.Line(c,h)),i.visible=this.isVisible,this.engine.scene.add(i),e.group=i,this.svgOverlay){const d=document.createElementNS("http://www.w3.org/2000/svg","g");d.dataset.levelId=e.data.Id;for(let m=0;m<4;m++)d.appendChild(this._makeLabel(e.data.Name,e.data.Elevation));this.svgOverlay.appendChild(d),e.svgGroup=d}}_updateSvgLabels(e){if(!e.svgGroup||!this.worldToScreen)return;const t=this.halfSize,n=e.data.Elevation,i=[new b.Vector3(-t,n,-t),new b.Vector3(t,n,-t),new b.Vector3(t,n,t),new b.Vector3(-t,n,t)],s=Array.from(e.svgGroup.children);i.forEach((r,a)=>{const l=this.worldToScreen.worldToScreen(r);s[a].setAttribute("x",String(l.x)),s[a].setAttribute("y",String(l.y))})}_makeLabel(e,t){const n=document.createElementNS("http://www.w3.org/2000/svg","text");return n.textContent=`${e} ▲${t.toFixed(3)}m`,n.setAttribute("text-anchor","middle"),n.setAttribute("dominant-baseline","central"),n.setAttribute("fill",this.COLOR),n.setAttribute("font-size","12"),n.setAttribute("font-family","Arial, sans-serif"),n.setAttribute("font-weight","bold"),n.setAttribute("stroke","white"),n.setAttribute("stroke-width","2"),n.setAttribute("paint-order","stroke"),n.style.pointerEvents="none",n}}class Ad{engine;constructor(e){}update(){}}class Pd{engine;currentHdrId="0";isVisible=!0;currentIntensity=.2;currentTexture=null;skybox=null;textureCache=new Map;hdrList=[{id:"0",name:"无"},{id:"1",name:"纯净-多云",url:"assets/hdr/纯净-多云.hdr"},{id:"2",name:"纯净-落日",url:"assets/hdr/纯净-落日.hdr"},{id:"3",name:"纯净-少云",url:"assets/hdr/纯净-少云.hdr"},{id:"4",name:"纯净-无云",url:"assets/hdr/纯净-无云.hdr"},{id:"5",name:"纯净-夜晚",url:"assets/hdr/纯净-夜晚.hdr"},{id:"6",name:"纯净-阴天",url:"assets/hdr/纯净-阴天.hdr"},{id:"7",name:"纯净-中云",url:"assets/hdr/纯净-中云.hdr"}];constructor(e){this.engine=e}getHdrList(){return this.hdrList}async setHdr(e){const t=this.hdrList.find(n=>n.id===e);if(!t){console.warn(`[Hdr] HDR id "${e}" not found`);return}if(e==="0"||!t.url){this._clearHdr(),this.currentHdrId="0";return}if(this.textureCache.has(e)){this._applyTexture(this.textureCache.get(e)),this.currentHdrId=e;return}try{const n=await this._loadHdr(t.url);this.textureCache.set(e,n),this._applyTexture(n),this.currentHdrId=e}catch(n){console.error(`[Hdr] Failed to load HDR "${t.url}":`,n)}}setVisible(e){this.isVisible=e,e&&this.currentTexture&&!this.skybox?this._createSkybox(this.currentTexture):this.skybox&&(this.skybox.visible=e)}getCurrentHdrId(){return this.currentHdrId}getVisible(){return this.isVisible}setIntensity(e){this.currentIntensity=e,this.engine.scene&&(this.engine.scene.environmentIntensity=e),this.skybox&&this.skybox.material.color.setScalar(e)}getIntensity(){return this.currentIntensity}addHdrItem(e){const t=this.hdrList.find(n=>n.id===e.id);t?Object.assign(t,e):this.hdrList.push(e)}dispose(){this._clearHdr(),this.textureCache.forEach(e=>e.dispose()),this.textureCache.clear()}_loadHdr(e){return new Promise((t,n)=>{new nh().load(e,i=>{i.mapping=b.EquirectangularReflectionMapping,t(i)},void 0,i=>n(i))})}_applyTexture(e){if(this.currentTexture=e,!this.engine.scene)return;const t=new b.PMREMGenerator(this.engine.renderer),n=t.fromEquirectangular(e).texture;t.dispose(),this.engine.scene.environment=n,this.engine.scene.environmentIntensity=this.currentIntensity,this.engine.scene.background=null,this._removeSkybox(),this.isVisible&&this._createSkybox(e),this.engine.setting.setAmbientLightIntensity(0)}_createSkybox(e){const t=new b.SphereGeometry(500,64,32),n=new b.MeshBasicMaterial({map:e,side:b.BackSide,depthWrite:!1,fog:!1});this.skybox=new b.Mesh(t,n),this.skybox.name="hdr_skybox",this.skybox.renderOrder=-1,this.skybox.frustumCulled=!1,n.color.setScalar(this.currentIntensity),this.engine.scene.add(this.skybox)}_removeSkybox(){this.skybox&&(this.engine.scene.remove(this.skybox),this.skybox.geometry.dispose(),this.skybox.material.dispose(),this.skybox=null)}_clearHdr(){this.currentTexture=null,this._removeSkybox(),this.engine.scene&&(this.engine.scene.background=null,this.engine.scene.environment=null,this.engine.setting.setAmbientLightIntensity(1))}}class Td{engine;currentId="0";groundGroup;groundMesh=null;waterMaterial=null;clock;groundY=0;groundList=[{id:"0",name:"无"},{id:"1",name:"草地",color:4881486,roughness:.9,metalness:0,map:"/textures/ground/grass.jpg"},{id:"2",name:"混凝土",color:9474192,roughness:.85,metalness:.1,map:"/textures/ground/concrete.jpg"},{id:"3",name:"地砖",color:13152400,roughness:.55,metalness:.1,map:"/textures/ground/tiles.jpg"},{id:"4",name:"湖面",water:!0,waterColor:28062,waveHeight:.04,waveSpeed:.8},{id:"5",name:"海面",water:!0,waterColor:15708,waveHeight:.12,waveSpeed:1.4}];constructor(e){this.engine=e,this.groundGroup=new b.Group,this.groundGroup.name="groundGroup",this.clock=new b.Clock}init(){this.engine.scene.add(this.groundGroup)}setGround(e,t){if(this._dispose(),this.currentId=e,e==="0")return;const n=this.groundList.find(c=>c.id===e);if(!n)return;const i=t?.size??300,s=n.water?80:1,r=new b.PlaneGeometry(i,i,s,s);r.rotateX(-Math.PI/2);let a;if(n.water)a=this._createWaterMaterial(n,t),this.waterMaterial=a;else{const c=new b.MeshStandardMaterial({color:n.color,roughness:n.roughness,metalness:n.metalness}),h=t?.textureUrl??n.map;h&&new b.TextureLoader().load(h,d=>{d.wrapS=d.wrapT=b.RepeatWrapping,d.repeat.set(8,8),c.map=d,c.needsUpdate=!0},void 0,()=>{}),a=c}const l=new b.Mesh(r,a);l.name="groundMesh",l.receiveShadow=!0,l.castShadow=!1,l.position.y=-.01,this.groundMesh=l,this.groundGroup.add(l),this.groundGroup.position.y=this.groundY,this.clock.start()}setHeight(e){this.groundY=e,this.groundGroup.position.y=e}getHeight(){return this.groundY}_createWaterMaterial(e,t){const n=new b.Color(e.waterColor),i=n.clone().multiplyScalar(.35),s=t?.sunDirection?t.sunDirection.clone().normalize():new b.Vector3(.5,.8,.5).normalize();return new b.ShaderMaterial({uniforms:{uTime:{value:0},uWaterColor:{value:n},uDeepColor:{value:i},uSunColor:{value:new b.Color(16777215)},uSunDir:{value:s},uWaveHeight:{value:e.waveHeight??.05},uWaveSpeed:{value:e.waveSpeed??1},uOpacity:{value:t?.opacity??.82}},vertexShader:Dd,fragmentShader:kd,transparent:!0,side:b.DoubleSide})}update(){if(!this.waterMaterial)return;this.waterMaterial.uniforms.uTime.value=this.clock.getElapsedTime();const e=this.engine.scene?.dirLight;if(e){const t=e.position.clone().normalize();this.waterMaterial.uniforms.uSunDir.value.copy(t)}}getGroundList(){return this.groundList.map(({id:e,name:t})=>({id:e,name:t}))}getCurrentId(){return this.currentId}show(){this.groundGroup.visible=!0}hide(){this.groundGroup.visible=!1}dispose(){this._dispose(),this.engine.scene.remove(this.groundGroup)}_dispose(){if(!this.groundMesh)return;this.groundMesh.geometry.dispose();const e=this.groundMesh.material;Array.isArray(e)?e.forEach(t=>t.dispose()):e.dispose(),this.groundGroup.remove(this.groundMesh),this.groundMesh=null,this.waterMaterial=null}}const Dd=`
|
|
1019
|
-
uniform
|
|
1020
|
-
uniform float
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
varying
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
`;class Ed{options;deviceType;animationId=null;isRenderingPaused=!1;controlsEnabledBeforePause=!0;animate;onWindowResize;_fpsFrameCount=0;_fpsLastCheck=0;_fpsLastSwitch=0;_lowFpsCount=0;_highFpsCount=0;_fpsCheckInterval=100;_fpsSwitchCooldown=100;_fpsThreshold=30;_fpsUpgradeThreshold=60;_lowFpsRequired=3;_highFpsRequired=.1;isMouseDown=!1;isWheeling=!1;scene;camera;renderer;sceneModule;cameraModule;deviceModule;renderModule;controlModule;composerModule;loaderModule;engineStatus;events;lightModule;interactionModule;modelToolModule;worldToScreen;handelBehaved;octreeBox;controls;stats;catchSvg;engineModelModule;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;text;hdr;ground;models=[];reactBoundingClientRect={left:0,top:0};version="2.1.5";versionEl=null;container;constructor(e){if(this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.engineModelModule=new qc(this),this.engineModelModule.init(),this.ai=new wd(this),this.deviceModule=new Ko(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new Yo(this),this.sceneModule=new Zo(this),this.scene=this.sceneModule.scene,this.renderModule=new qo(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.controlModule=new ha(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.composerModule=new _a(this),this.composerModule.init(),this.events=new jc,this.engineStatus=new Vc(this),this.engineStatus.init(),this.loaderModule=new Uc(this),this.lightModule=new Gc(this),this.lightModule.init(),this.viewCube=new oh(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=ah(this),this.rangeScale=new lh(this),this.rangeScale.init(),this.clipping=new dd(this),this.clipping.init(),this.setting=new ch(this),this.setting.init(),this.engineModelModule.init(),this.handelBehaved=ki(this),this.modelMapperBatch=new gd(this),this.measure=new vh(this),this.modelToolModule=new Xc(this),this.modelProperties=new md(this),this.interactionModule=new Wc(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new Hn(this),this.modelEdge=new yd(this),this.modelTree=new fd(this),this.engineInfo=new pd(this),this.pathRoaming=new xd(this),this.pathRoaming.init(),this.minMap=new bd(this),this.grid=new _d(this),this.level=new Cd(this),this.text=new Ad(this),this.hdr=new Pd(this),this.ground=new Td(this),this.ground.init(),this.worldToScreen=new De(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new Qc,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom));let t=document.createElement("div");t.className="versionText",this.versionEl=t,this.updateVersionDisplay(),this.container.appendChild(t);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.style.position="absolute",n.style.zIndex="1000",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none",this.container.appendChild(n),this.catchSvg=n,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let i=this;this.controls.addEventListener("start",()=>{i.events.trigger(ft.EngineBusy)}),this.controls.addEventListener("end",()=>{i.events.trigger(ft.EngineFree)}),this.controls.addEventListener("change",()=>{}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.hoverHighLight.update(),this.controlModule.update(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.stats&&this.stats.end(),this._fpsFrameCount++;const s=performance.now();if(s-this._fpsLastCheck>=this._fpsCheckInterval){const r=s-this._fpsLastCheck,a=this._fpsFrameCount/r*1e3;this._fpsFrameCount=0,this._fpsLastCheck=s,a<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&s-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=s,this._lowFpsCount=0)):a>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let r=this.scene?.dirLight;r&&this.camera&&this.updateLightPosition(this.camera,r)}},this.animate()}updateVersionDisplay(){if(!this.versionEl)return;const e={simple:"simple",balance:"balance",advanced:"advanced"},t=this.engineModelModule?.getCurrentMode()??"",n=e[t]??t;this.versionEl.innerHTML=`v${this.version} | ${n}`}updateLightPosition(e,t){const n=new b.Vector3;e.getWorldDirection(n);const i=100,s=new b.Vector3().copy(n).multiplyScalar(-i),r=new b.Vector3(0,1,0),a=new b.Vector3().crossVectors(n,r).normalize();s.addScaledVector(r,i*.5),s.addScaledVector(a,i*.3),t.position.copy(e.position).add(s);const l=new b.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n>0){const i=e[n-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n<e.length-1){const i=e[n+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const i=this.deviceModule.getContainerSize();e=e??i.width,t=t??i.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const n=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=n,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const i=this.cameraModule.orthographicCamera,s=50,r=this.container.clientWidth/this.container.clientHeight;i.left=s*r/-2,i.right=s*r/2,i.top=s/2,i.bottom=s/-2,i.updateProjectionMatrix()}if(this.catchSvg){const i=this.container.clientWidth,s=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${s}`)}this.events&&this.events.trigger(ft.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){if(!e)return;[...e.children].forEach(n=>{this.clearScene(n)}),e.parent&&e.parent.remove(e),e instanceof b.Mesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material))),e instanceof b.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof b.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof b.InstancedMesh&&(e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(n=>this.disposeMaterial(n)):this.disposeMaterial(e.material)),e.instanceMatrix&&(e.instanceMatrix=null),e.instanceColor&&(e.instanceColor=null)),e instanceof b.Sprite&&e.material&&this.disposeMaterial(e.material)}disposeMaterial(e){if(!e)return;["map","lightMap","bumpMap","normalMap","specularMap","envMap","alphaMap","aoMap","displacementMap","emissiveMap","gradientMap","metalnessMap","roughnessMap","clearcoatMap","clearcoatNormalMap","clearcoatRoughnessMap","transmissionMap","thicknessMap","sheenColorMap","sheenRoughnessMap","specularIntensityMap","specularColorMap","iridescenceMap","iridescenceThicknessMap"].forEach(n=>{const i=e[n];i&&i instanceof b.Texture&&i.dispose()}),e.dispose()}}var _n=(o=>(o.ModelLoadStart="model-load-start",o.ModelLoaded="model-loaded",o.ModelLoadError="model-load-error",o.RenderStart="render-start",o.RenderEnd="render-end",o.CameraChanged="camera-changed",o.CameraReset="camera-reset",o.SelectionChanged="selection-changed",o.HoverChanged="hover-changed",o.EntityClick="entity-click",o.LayerVisibilityChanged="layer-visibility-changed",o.LayerColorChanged="layer-color-changed",o.ViewZoomChanged="view-zoom-changed",o.ViewPanChanged="view-pan-changed",o.ToolActivated="tool-activated",o.ToolDeactivated="tool-deactivated",o.Error="error",o.Warning="warning",o))(_n||{});class Ld{listeners=new Map;onceListeners=new Map;debugMode=!1;constructor(e=!1){this.debugMode=e,this.initializeEvents()}initializeEvents(){Object.values(_n).forEach(t=>{this.listeners.set(t,new Set),this.onceListeners.set(t,new Set)})}on(e,t){return this.listeners.has(e)?(this.listeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Listener added for ${e}`),()=>this.off(e,t)):(console.warn(`Event type ${e} is not registered`),()=>{})}once(e,t){if(!this.onceListeners.has(e)){console.warn(`Event type ${e} is not registered`);return}this.onceListeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Once listener added for ${e}`)}off(e,t){const n=this.listeners.get(e);n&&(n.delete(t),this.debugMode&&console.log(`[EventModule2d] Listener removed for ${e}`))}trigger(e,t){this.debugMode&&console.log(`[EventModule2d] Triggering ${e}`,t);const n=this.listeners.get(e);n&&n.size>0&&n.forEach(s=>{try{s(t)}catch(r){console.error(`[EventModule2d] Error in listener for ${e}:`,r)}});const i=this.onceListeners.get(e);i&&i.size>0&&(i.forEach(s=>{try{s(t)}catch(r){console.error(`[EventModule2d] Error in once listener for ${e}:`,r)}}),i.clear())}removeAllListeners(){this.listeners.forEach(e=>e.clear()),this.onceListeners.forEach(e=>e.clear()),this.debugMode&&console.log("[EventModule2d] All listeners removed")}removeListenersOfType(e){const t=this.listeners.get(e),n=this.onceListeners.get(e);t&&t.clear(),n&&n.clear(),this.debugMode&&console.log(`[EventModule2d] All listeners removed for ${e}`)}getListenerCount(e){const t=this.listeners.get(e),n=this.onceListeners.get(e);return(t?.size||0)+(n?.size||0)}setDebugMode(e){this.debugMode=e}getAllEventTypes(){return Object.values(_n)}dispose(){this.removeAllListeners(),this.listeners.clear(),this.onceListeners.clear(),this.debugMode&&console.log("[EventModule2d] Disposed")}}const Id=`
|
|
1018
|
+
`)(n,t);return o&&typeof o.then=="function"?await o:o}catch(n){return console.error("[AI Manager] 代码执行失败:",n),"error"+n.message}}reset(){this.conversationHistory=[],this.steps=[],this.stepResults.clear(),this.state="idle",this.config?.debug&&console.log("[AI Manager] 对话已重置")}getState(){return this.state}getHistory(){return[...this.conversationHistory]}getSteps(){return[...this.steps]}getStepResults(){return new Map(this.stepResults)}}class Ou{engine;points=[];isPlaying=!1;animationFrameId=null;playStartTime=0;playFromIndex=0;playToIndex=0;playOptions={};stayTimerId=null;playRangeToIndex=0;constructor(e){this.engine=e}init(){this.points=[],this.stop()}getCurrentPoint(){return{...this.engine.cameraModule.getCameraPose(),stayTime:0}}addPoint(e=0){const t=this.getCurrentPoint();return t.stayTime=e,this.points.push(t),this.points.length}addPoints(e){for(const t of e)this.points.push({...t});return this.points.length}savePoints(e){return this.addPoints(e)}removePoint(e){return e>=0&&e<this.points.length?(this.points.splice(e,1),!0):!1}clearPoints(){this.stop(),this.points=[]}getPoints(){return[...this.points]}getPointCount(){return this.points.length}updatePoint(e,t){return e>=0&&e<this.points.length?(this.points[e]={...t},!0):!1}jumpToPoint(e){return e>=0&&e<this.points.length?(this.stop(),this.engine.cameraModule.restoreCameraPose(this.points[e]),!0):!1}play(e={}){return this.points.length<2?(console.warn("PathRoaming: 至少需要2个点位才能播放"),!1):(this.isPlaying&&this.stop(),this.isPlaying=!0,this.playOptions={duration:3e3,loop:!1,...e},this.engine.controlModule.disActive(),this.playFromIndex=0,this.playToIndex=1,this.playRangeToIndex=this.points.length-1,this.playStartTime=performance.now(),this.animate(),!0)}playRange(e,t,n={}){return e<0||t>=this.points.length||e>=t?(console.warn("PathRoaming: 无效的索引范围"),!1):this.points.length<2?(console.warn("PathRoaming: 至少需要2个点位才能播放"),!1):(this.isPlaying&&this.stop(),this.isPlaying=!0,this.playOptions={duration:3e3,loop:!1,...n},this.engine.controlModule.disActive(),this.playFromIndex=e,this.playToIndex=e+1,this.playStartTime=performance.now(),this.playRangeToIndex=t,this.animate(),!0)}stop(){this.isPlaying=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.stayTimerId!==null&&(clearTimeout(this.stayTimerId),this.stayTimerId=null),this.engine.controlModule.active()}pause(){this.isPlaying&&(this.isPlaying=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null),this.stayTimerId!==null&&(clearTimeout(this.stayTimerId),this.stayTimerId=null))}getIsPlaying(){return this.isPlaying}animate=()=>{if(!this.isPlaying)return;const t=performance.now()-this.playStartTime,n=this.playOptions.duration||3e3,i=Math.min(t/n,1),s=this.points[this.playFromIndex],o=this.points[this.playToIndex],a=this.interpolatePose(s,o,i);this.engine.cameraModule.restoreCameraPose(a),i>=1?this.onSegmentComplete():this.animationFrameId=requestAnimationFrame(this.animate)};onSegmentComplete(){const e=this.playToIndex;this.playOptions.onPointComplete&&this.playOptions.onPointComplete(e);const t=this.points[e];t.stayTime&&t.stayTime>0?this.stayTimerId=globalThis.setTimeout(()=>{this.stayTimerId=null,this.moveToNextSegment()},t.stayTime):this.moveToNextSegment()}moveToNextSegment(){const e=this.playToIndex>=this.playRangeToIndex,t=this.playToIndex>=this.points.length-1;e||t?this.playOptions.loop&&this.points.length>=2?(this.playFromIndex=0,this.playToIndex=1,this.playRangeToIndex=this.points.length-1,this.playStartTime=performance.now(),this.animate()):this.onPlayComplete():(this.playFromIndex=this.playToIndex,this.playToIndex=this.playToIndex+1,this.playStartTime=performance.now(),this.animate())}onPlayComplete(){this.stop(),this.playOptions.onComplete&&this.playOptions.onComplete()}interpolatePose(e,t,n){const i=this.easeInOutCubic(n),s={type:t.type,position:{x:w.MathUtils.lerp(e.position.x,t.position.x,i),y:w.MathUtils.lerp(e.position.y,t.position.y,i),z:w.MathUtils.lerp(e.position.z,t.position.z,i)},rotation:{x:w.MathUtils.lerp(e.rotation.x,t.rotation.x,i),y:w.MathUtils.lerp(e.rotation.y,t.rotation.y,i),z:w.MathUtils.lerp(e.rotation.z,t.rotation.z,i)},quaternion:{x:w.MathUtils.lerp(e.quaternion.x,t.quaternion.x,i),y:w.MathUtils.lerp(e.quaternion.y,t.quaternion.y,i),z:w.MathUtils.lerp(e.quaternion.z,t.quaternion.z,i),w:w.MathUtils.lerp(e.quaternion.w,t.quaternion.w,i)}};return e.target&&t.target?s.target={x:w.MathUtils.lerp(e.target.x,t.target.x,i),y:w.MathUtils.lerp(e.target.y,t.target.y,i),z:w.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=w.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 Nu{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 w.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 w.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:o,y:a}=this.worldToPixel(s.position.x,s.position.z);Math.hypot(n-o,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:o}=this.pixelToWorld(e,t),a=s-n.position.x,l=o-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,o=this.mapSize/2,a=Math.atan2(this.lastMouseY-o,this.lastMouseX-s);let c=Math.atan2(t-o,e-s)-a;c>Math.PI&&(c-=2*Math.PI),c<-Math.PI&&(c+=2*Math.PI);const h=new w.Vector3().copy(i.target).sub(n.position),u=new w.Spherical().setFromVector3(h);u.theta-=c,h.setFromSpherical(u),i.target.copy(n.position).add(h),i.update()}drawOverlay(){const e=this.overlayCtx,t=this.engine.camera;if(!e||!t)return;e.clearRect(0,0,this.mapSize,this.mapSize);const n=this.mapSize/2,i=this.mapSize/2,s=new w.Vector3;t.getWorldDirection(s);const o=Math.atan2(s.x,-s.z),a=36,l=Math.PI/10;e.save(),e.translate(n,i),e.rotate(o);const c=e.createRadialGradient(0,0,2,0,0,a);c.addColorStop(0,"rgba(0, 230, 130, 0.9)"),c.addColorStop(1,"rgba(0, 230, 130, 0)");const h=-Math.sin(l)*a,u=-Math.cos(l)*a,m=Math.sin(l)*a,p=-Math.cos(l)*a;e.beginPath(),e.moveTo(0,0),e.lineTo(h,u),e.lineTo(m,p),e.closePath(),e.fillStyle=c,e.fill(),e.fillStyle="rgba(255, 255, 255, 0.95)",e.strokeStyle="rgba(0, 200, 110, 0.9)",e.lineWidth=1.5,e.beginPath(),e.arc(0,0,4,0,Math.PI*2),e.fill(),e.stroke(),e.restore()}show(){this.isVisible=!0,this.miniMapContainer&&(this.miniMapContainer.style.display="block")}hide(){this.isVisible=!1,this.miniMapContainer&&(this.miniMapContainer.style.display="none")}toggle(){this.isVisible?this.hide():this.show()}update(){if(!this.isVisible||!this.miniMapCamera||!this.miniMapRenderer)return;const e=this.engine.camera;if(!(!e||!this.engine.scene)){if(this.engine.octreeBox){const t=this.engine.octreeBox.getBoundingBox();if(t?.min&&t?.max){const n=t.max.x-t.min.x,i=t.max.z-t.min.z,s=t.max.y-t.min.y;this.camY=t.max.y+Math.max(n,i,s),!this.halfSizeInitialized&&n+i>0&&(this.currentHalfSize=Math.max(n,i)*2,this.halfSizeInitialized=!0)}}this.centerX=e.position.x,this.centerZ=e.position.z,this.miniMapCamera.left=-this.currentHalfSize,this.miniMapCamera.right=this.currentHalfSize,this.miniMapCamera.top=this.currentHalfSize,this.miniMapCamera.bottom=-this.currentHalfSize,this.miniMapCamera.updateProjectionMatrix(),this.miniMapCamera.position.set(this.centerX,this.camY,this.centerZ),this.miniMapCamera.lookAt(this.centerX,this.camY-1,this.centerZ),this.miniMapRenderer.render(this.engine.scene,this.miniMapCamera),this.drawOverlay()}}dispose(){this.miniMapContainer&&(this.miniMapContainer.removeEventListener("wheel",this.onWheel),this.miniMapContainer.removeEventListener("mousedown",this.onMouseDown),this.miniMapContainer.removeEventListener("mousemove",this.onMouseMove),this.miniMapContainer.removeEventListener("mouseup",this.onMouseUp),this.miniMapContainer.removeEventListener("mouseleave",this.onMouseUp)),this.miniMapRenderer&&(this.miniMapRenderer.dispose(),this.miniMapRenderer=null),this.miniMapContainer&&(this.miniMapContainer.remove(),this.miniMapContainer=null),this.miniMapCamera=null,this.overlayCtx=null,this.overlayCanvas=null}}class Fu{engine;rootGroup=null;isVisible=!1;axes=[];coordinateMapper=e=>new w.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(this.engine.models[0].grids)}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 w.OrthographicCamera){const i=e,s=(i.top-i.bottom)/i.zoom,o=t.domElement.clientHeight||1;n=30*s/o}this.rootGroup.traverse(i=>{i instanceof w.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 w.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 w.Group;s.name=`GridAxis_${e.data.Id}`;const o=new w.BufferGeometry().setFromPoints([t,n]),a=new w.LineBasicMaterial({color:1609983,depthTest:!1}),l=new w.Line(o,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"),o=128/2,a=128/2,l=128/2-4;s.beginPath(),s.arc(o,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,o,a);const c=new w.CanvasTexture(i),h=new w.SpriteMaterial({map:c,depthTest:!1,transparent:!0}),u=new w.Sprite(h);return u.position.copy(t),u.scale.set(.5,.5,1),u.renderOrder=999,u}}class Uu{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,t){this._clearAll(),this.levels=e.map(n=>({data:n,group:null,svgGroup:null})),this.levels.forEach(n=>this._buildThreeObject(n,t))}setMockData(){this.setData(this.engine.models[0].levels,this.engine.models[0].boundingBox)}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 _e(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,t){if(!this.engine.scene)return;this.halfSize=t.max.distanceTo(t.min);const n=e.data.Elevation,i=this.halfSize,s=new w.Group,o=new w.PlaneGeometry(i*2,i*2);o.rotateX(-Math.PI/2);const a=new w.MeshBasicMaterial({color:this.COLOR,transparent:!0,opacity:this.PLANE_OPACITY,side:w.DoubleSide,depthWrite:!1}),l=new w.Mesh(o,a);l.position.y=n,s.add(l);const c=[new w.Vector3(-i,n,-i),new w.Vector3(i,n,-i),new w.Vector3(i,n,i),new w.Vector3(-i,n,i),new w.Vector3(-i,n,-i)],h=new w.BufferGeometry().setFromPoints(c),u=new w.LineBasicMaterial({color:this.COLOR,transparent:!0,opacity:.7});if(s.add(new w.Line(h,u)),s.visible=this.isVisible,this.engine.scene.add(s),e.group=s,this.svgOverlay){const m=document.createElementNS("http://www.w3.org/2000/svg","g");m.dataset.levelId=e.data.Id;for(let p=0;p<4;p++)m.appendChild(this._makeLabel(e.data.Name,e.data.Elevation));this.svgOverlay.appendChild(m),e.svgGroup=m}}_updateSvgLabels(e){if(!e.svgGroup||!this.worldToScreen)return;const t=this.halfSize,n=e.data.Elevation,i=[new w.Vector3(-t,n,-t),new w.Vector3(t,n,-t),new w.Vector3(t,n,t),new w.Vector3(-t,n,t)],s=Array.from(e.svgGroup.children);i.forEach((o,a)=>{const l=this.worldToScreen.worldToScreen(o);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 Vu{engine;constructor(e){}update(){}}class Gu{engine;currentHdrId="0";isVisible=!0;currentIntensity=.2;currentTexture=null;skybox=null;textureCache=new Map;hdrList=[{id:"0",name:"无"},{id:"1",name:"纯净-多云",url:"assets/hdr/纯净-多云.hdr"},{id:"2",name:"纯净-落日",url:"assets/hdr/纯净-落日.hdr"},{id:"3",name:"纯净-少云",url:"assets/hdr/纯净-少云.hdr"},{id:"4",name:"纯净-无云",url:"assets/hdr/纯净-无云.hdr"},{id:"5",name:"纯净-夜晚",url:"assets/hdr/纯净-夜晚.hdr"},{id:"6",name:"纯净-阴天",url:"assets/hdr/纯净-阴天.hdr"},{id:"7",name:"纯净-中云",url:"assets/hdr/纯净-中云.hdr"}];constructor(e){this.engine=e}getHdrList(){return this.hdrList}async setHdr(e){const t=this.hdrList.find(n=>n.id===e);if(!t){console.warn(`[Hdr] HDR id "${e}" not found`);return}if(e==="0"||!t.url){this._clearHdr(),this.currentHdrId="0";return}if(this.textureCache.has(e)){this._applyTexture(this.textureCache.get(e)),this.currentHdrId=e;return}try{const n=await this._loadHdr(t.url);this.textureCache.set(e,n),this._applyTexture(n),this.currentHdrId=e}catch(n){console.error(`[Hdr] Failed to load HDR "${t.url}":`,n)}}setVisible(e){this.isVisible=e,e&&this.currentTexture&&!this.skybox?this._createSkybox(this.currentTexture):this.skybox&&(this.skybox.visible=e)}getCurrentHdrId(){return this.currentHdrId}getVisible(){return this.isVisible}setIntensity(e){this.currentIntensity=e,this.engine.scene&&(this.engine.scene.environmentIntensity=e),this.skybox&&this.skybox.material.color.setScalar(e)}getIntensity(){return this.currentIntensity}addHdrItem(e){const t=this.hdrList.find(n=>n.id===e.id);t?Object.assign(t,e):this.hdrList.push(e)}dispose(){this._clearHdr(),this.textureCache.forEach(e=>e.dispose()),this.textureCache.clear()}_loadHdr(e){return new Promise((t,n)=>{new wh().load(e,i=>{i.mapping=w.EquirectangularReflectionMapping,t(i)},void 0,i=>n(i))})}_applyTexture(e){if(this.currentTexture=e,!this.engine.scene)return;const t=new w.PMREMGenerator(this.engine.renderer),n=t.fromEquirectangular(e).texture;t.dispose(),this.engine.scene.environment=n,this.engine.scene.environmentIntensity=this.currentIntensity,this.engine.scene.background=null,this._removeSkybox(),this.isVisible&&this._createSkybox(e),this.engine.setting.setAmbientLightIntensity(0)}_createSkybox(e){const t=new w.SphereGeometry(500,64,32),n=new w.MeshBasicMaterial({map:e,side:w.BackSide,depthWrite:!1,fog:!1});this.skybox=new w.Mesh(t,n),this.skybox.name="hdr_skybox",this.skybox.renderOrder=-1,this.skybox.frustumCulled=!1,n.color.setScalar(this.currentIntensity),this.engine.scene.add(this.skybox)}_removeSkybox(){this.skybox&&(this.engine.scene.remove(this.skybox),this.skybox.geometry.dispose(),this.skybox.material.dispose(),this.skybox=null)}_clearHdr(){this.currentTexture=null,this._removeSkybox(),this.engine.scene&&(this.engine.scene.background=null,this.engine.scene.environment=null,this.engine.setting.setAmbientLightIntensity(1))}}class ju extends M.Mesh{constructor(e,t={}){super(e),this.isWater=!0;const n=this,i=t.textureWidth!==void 0?t.textureWidth:512,s=t.textureHeight!==void 0?t.textureHeight:512,o=t.clipBias!==void 0?t.clipBias:0,a=t.alpha!==void 0?t.alpha:1,l=t.time!==void 0?t.time:0,c=t.waterNormals!==void 0?t.waterNormals:null,h=t.sunDirection!==void 0?t.sunDirection:new M.Vector3(.70707,.70707,0),u=new M.Color(t.sunColor!==void 0?t.sunColor:16777215),m=new M.Color(t.waterColor!==void 0?t.waterColor:8355711),p=t.eye!==void 0?t.eye:new M.Vector3(0,0,0),f=t.distortionScale!==void 0?t.distortionScale:20,d=t.side!==void 0?t.side:M.FrontSide,g=t.fog!==void 0?t.fog:!1,y=new M.Plane,v=new M.Vector3,x=new M.Vector3,b=new M.Vector3,_=new M.Matrix4,T=new M.Vector3(0,0,-1),P=new M.Vector4,D=new M.Vector3,k=new M.Vector3,E=new M.Vector4,R=new M.Matrix4,A=new M.PerspectiveCamera,I=new M.WebGLRenderTarget(i,s),S={name:"MirrorShader",uniforms:M.UniformsUtils.merge([M.UniformsLib.fog,M.UniformsLib.lights,{normalSampler:{value:null},mirrorSampler:{value:null},alpha:{value:1},time:{value:0},size:{value:1},distortionScale:{value:20},textureMatrix:{value:new M.Matrix4},sunColor:{value:new M.Color(8355711)},sunDirection:{value:new M.Vector3(.70707,.70707,0)},eye:{value:new M.Vector3},waterColor:{value:new M.Color(5592405)}}]),vertexShader:`
|
|
1019
|
+
uniform mat4 textureMatrix;
|
|
1020
|
+
uniform float time;
|
|
1021
|
+
|
|
1022
|
+
varying vec4 mirrorCoord;
|
|
1023
|
+
varying vec4 worldPosition;
|
|
1024
|
+
|
|
1025
|
+
#include <common>
|
|
1026
|
+
#include <fog_pars_vertex>
|
|
1027
|
+
#include <shadowmap_pars_vertex>
|
|
1028
|
+
#include <logdepthbuf_pars_vertex>
|
|
1029
|
+
|
|
1030
|
+
void main() {
|
|
1031
|
+
mirrorCoord = modelMatrix * vec4( position, 1.0 );
|
|
1032
|
+
worldPosition = mirrorCoord.xyzw;
|
|
1033
|
+
mirrorCoord = textureMatrix * mirrorCoord;
|
|
1034
|
+
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
|
|
1035
|
+
gl_Position = projectionMatrix * mvPosition;
|
|
1036
|
+
|
|
1037
|
+
#include <beginnormal_vertex>
|
|
1038
|
+
#include <defaultnormal_vertex>
|
|
1039
|
+
#include <logdepthbuf_vertex>
|
|
1040
|
+
#include <fog_vertex>
|
|
1041
|
+
#include <shadowmap_vertex>
|
|
1042
|
+
}`,fragmentShader:`
|
|
1043
|
+
uniform sampler2D mirrorSampler;
|
|
1044
|
+
uniform float alpha;
|
|
1045
|
+
uniform float time;
|
|
1046
|
+
uniform float size;
|
|
1047
|
+
uniform float distortionScale;
|
|
1048
|
+
uniform sampler2D normalSampler;
|
|
1049
|
+
uniform vec3 sunColor;
|
|
1050
|
+
uniform vec3 sunDirection;
|
|
1051
|
+
uniform vec3 eye;
|
|
1052
|
+
uniform vec3 waterColor;
|
|
1053
|
+
|
|
1054
|
+
varying vec4 mirrorCoord;
|
|
1055
|
+
varying vec4 worldPosition;
|
|
1056
|
+
|
|
1057
|
+
vec4 getNoise( vec2 uv ) {
|
|
1058
|
+
vec2 uv0 = ( uv / 103.0 ) + vec2(time / 17.0, time / 29.0);
|
|
1059
|
+
vec2 uv1 = uv / 107.0-vec2( time / -19.0, time / 31.0 );
|
|
1060
|
+
vec2 uv2 = uv / vec2( 8907.0, 9803.0 ) + vec2( time / 101.0, time / 97.0 );
|
|
1061
|
+
vec2 uv3 = uv / vec2( 1091.0, 1027.0 ) - vec2( time / 109.0, time / -113.0 );
|
|
1062
|
+
vec4 noise = texture2D( normalSampler, uv0 ) +
|
|
1063
|
+
texture2D( normalSampler, uv1 ) +
|
|
1064
|
+
texture2D( normalSampler, uv2 ) +
|
|
1065
|
+
texture2D( normalSampler, uv3 );
|
|
1066
|
+
return noise * 0.5 - 1.0;
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1069
|
+
void sunLight( const vec3 surfaceNormal, const vec3 eyeDirection, float shiny, float spec, float diffuse, inout vec3 diffuseColor, inout vec3 specularColor ) {
|
|
1070
|
+
vec3 reflection = normalize( reflect( -sunDirection, surfaceNormal ) );
|
|
1071
|
+
float direction = max( 0.0, dot( eyeDirection, reflection ) );
|
|
1072
|
+
specularColor += pow( direction, shiny ) * sunColor * spec;
|
|
1073
|
+
diffuseColor += max( dot( sunDirection, surfaceNormal ), 0.0 ) * sunColor * diffuse;
|
|
1074
|
+
}
|
|
1075
|
+
|
|
1076
|
+
#include <common>
|
|
1077
|
+
#include <packing>
|
|
1078
|
+
#include <bsdfs>
|
|
1079
|
+
#include <fog_pars_fragment>
|
|
1080
|
+
#include <logdepthbuf_pars_fragment>
|
|
1081
|
+
#include <lights_pars_begin>
|
|
1082
|
+
#include <shadowmap_pars_fragment>
|
|
1083
|
+
#include <shadowmask_pars_fragment>
|
|
1084
|
+
|
|
1085
|
+
void main() {
|
|
1086
|
+
|
|
1087
|
+
#include <logdepthbuf_fragment>
|
|
1088
|
+
vec4 noise = getNoise( worldPosition.xz * size );
|
|
1089
|
+
vec3 surfaceNormal = normalize( noise.xzy * vec3( 1.5, 1.0, 1.5 ) );
|
|
1090
|
+
|
|
1091
|
+
vec3 diffuseLight = vec3(0.0);
|
|
1092
|
+
vec3 specularLight = vec3(0.0);
|
|
1093
|
+
|
|
1094
|
+
vec3 worldToEye = eye-worldPosition.xyz;
|
|
1095
|
+
vec3 eyeDirection = normalize( worldToEye );
|
|
1096
|
+
sunLight( surfaceNormal, eyeDirection, 100.0, 2.0, 0.5, diffuseLight, specularLight );
|
|
1097
|
+
|
|
1098
|
+
float distance = length(worldToEye);
|
|
1099
|
+
|
|
1100
|
+
vec2 distortion = surfaceNormal.xz * ( 0.001 + 1.0 / distance ) * distortionScale;
|
|
1101
|
+
vec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) );
|
|
1102
|
+
|
|
1103
|
+
float theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );
|
|
1104
|
+
float rf0 = 0.3;
|
|
1105
|
+
float reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );
|
|
1106
|
+
vec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;
|
|
1107
|
+
vec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), ( vec3( 0.1 ) + reflectionSample * 0.9 + reflectionSample * specularLight ), reflectance);
|
|
1108
|
+
vec3 outgoingLight = albedo;
|
|
1109
|
+
gl_FragColor = vec4( outgoingLight, alpha );
|
|
1110
|
+
|
|
1111
|
+
#include <tonemapping_fragment>
|
|
1112
|
+
#include <colorspace_fragment>
|
|
1113
|
+
#include <fog_fragment>
|
|
1114
|
+
}`},z=new M.ShaderMaterial({name:S.name,uniforms:M.UniformsUtils.clone(S.uniforms),vertexShader:S.vertexShader,fragmentShader:S.fragmentShader,lights:!0,side:d,fog:g});z.uniforms.mirrorSampler.value=I.texture,z.uniforms.textureMatrix.value=R,z.uniforms.alpha.value=a,z.uniforms.time.value=l,z.uniforms.normalSampler.value=c,z.uniforms.sunColor.value=u,z.uniforms.waterColor.value=m,z.uniforms.sunDirection.value=h,z.uniforms.distortionScale.value=f,z.uniforms.eye.value=p,n.material=z,n.onBeforeRender=function(U,V,$){if(x.setFromMatrixPosition(n.matrixWorld),b.setFromMatrixPosition($.matrixWorld),_.extractRotation(n.matrixWorld),v.set(0,0,1),v.applyMatrix4(_),D.subVectors(x,b),D.dot(v)>0)return;D.reflect(v).negate(),D.add(x),_.extractRotation($.matrixWorld),T.set(0,0,-1),T.applyMatrix4(_),T.add(b),k.subVectors(x,T),k.reflect(v).negate(),k.add(x),A.position.copy(D),A.up.set(0,1,0),A.up.applyMatrix4(_),A.up.reflect(v),A.lookAt(k),A.far=$.far,A.updateMatrixWorld(),A.projectionMatrix.copy($.projectionMatrix),R.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),R.multiply(A.projectionMatrix),R.multiply(A.matrixWorldInverse),y.setFromNormalAndCoplanarPoint(v,x),y.applyMatrix4(A.matrixWorldInverse),P.set(y.normal.x,y.normal.y,y.normal.z,y.constant);const G=A.projectionMatrix;E.x=(Math.sign(P.x)+G.elements[8])/G.elements[0],E.y=(Math.sign(P.y)+G.elements[9])/G.elements[5],E.z=-1,E.w=(1+G.elements[10])/G.elements[14],P.multiplyScalar(2/P.dot(E)),G.elements[2]=P.x,G.elements[6]=P.y,G.elements[10]=P.z+1-o,G.elements[14]=P.w,p.setFromMatrixPosition($.matrixWorld);const q=U.getRenderTarget(),N=U.xr.enabled,O=U.shadowMap.autoUpdate;n.visible=!1,U.xr.enabled=!1,U.shadowMap.autoUpdate=!1,U.setRenderTarget(I),U.state.buffers.depth.setMask(!0),U.autoClear===!1&&U.clear(),U.render(V,A),n.visible=!0,U.xr.enabled=N,U.shadowMap.autoUpdate=O,U.setRenderTarget(q);const ee=$.viewport;ee!==void 0&&U.state.viewport(ee)}}}class Vs{engine;currentId="0";groundGroup;groundMesh=null;isWaterAddon=!1;clock;groundY=0;static DEFAULT_WATER_NORMALS="/textture/waternormals.jpg";groundList=[{id:"0",name:"无"},{id:"1",name:"草地",color:4881486,roughness:.9,metalness:0,map:"/textures/ground/grass.jpg"},{id:"2",name:"混凝土",color:9474192,roughness:.85,metalness:.1,map:"/textures/ground/concrete.jpg"},{id:"3",name:"地砖",color:13152400,roughness:.55,metalness:.1,map:"/textures/ground/tiles.jpg"},{id:"4",name:"湖面",water:!0,waterColor:5929582,distortionScale:2.5,size:1},{id:"5",name:"海面",water:!0,waterColor:28062,distortionScale:3.7,size:1}];constructor(e){this.engine=e,this.groundGroup=new w.Group,this.groundGroup.name="groundGroup",this.clock=new w.Clock}init(){this.engine.scene.add(this.groundGroup)}setGround(e,t){if(this._dispose(),this.currentId=e,e==="0")return;const n=this.groundList.find(s=>s.id===e);if(!n)return;const i=t?.size??3e4;if(n.water){const s=new w.PlaneGeometry(i,i),o=Vs.DEFAULT_WATER_NORMALS,a=new w.TextureLoader().load(o,p=>{p.wrapS=p.wrapT=w.RepeatWrapping}),l=t?.sunDirection??new w.Vector3(.5,.8,.5).normalize(),c=t?.distortionScale??n.distortionScale??3.7,h=t?.waterSize??n.size??1,u=t?.opacity??.92,m=new ju(s,{textureWidth:512,textureHeight:512,waterNormals:a,sunDirection:l.clone(),sunColor:16777215,waterColor:n.waterColor??28062,distortionScale:c,alpha:u,fog:!!this.engine.scene?.fog});m.rotation.x=-Math.PI/2,m.position.y=-.01,m.name="groundMesh",m.receiveShadow=!0,m.castShadow=!1,m.material.uniforms.size.value=h,this.groundMesh=m,this.isWaterAddon=!0,this.groundGroup.add(m)}else{const s=new w.PlaneGeometry(i,i,1,1);s.rotateX(-Math.PI/2);const o=new w.MeshStandardMaterial({color:n.color,roughness:n.roughness,metalness:n.metalness}),a=t?.textureUrl??n.map;a&&new w.TextureLoader().load(a,c=>{c.wrapS=c.wrapT=w.RepeatWrapping,c.repeat.set(8,8),o.map=c,o.needsUpdate=!0},void 0,()=>{});const l=new w.Mesh(s,o);l.name="groundMesh",l.receiveShadow=!0,l.castShadow=!1,l.position.y=-.01,this.groundMesh=l,this.isWaterAddon=!1,this.groundGroup.add(l)}this.groundGroup.position.y=this.groundY,this.clock.start()}setHeight(e){this.groundY=e,this.groundGroup.position.y=e}getHeight(){return this.groundY}update(){if(!this.groundMesh||!this.isWaterAddon)return;const t=this.groundMesh.material?.uniforms;if(!t)return;t.time.value+=1/60;const n=this.engine.scene?.dirLight;n&&t.sunDirection&&t.sunDirection.value.copy(n.position).normalize();const i=this.engine.camera;i&&t.eye&&t.eye.value.setFromMatrixPosition(i.matrixWorld)}getGroundList(){return this.groundList.map(({id:e,name:t})=>({id:e,name:t}))}getCurrentId(){return this.currentId}show(){this.groundGroup.visible=!0}hide(){this.groundGroup.visible=!1}dispose(){this._dispose(),this.engine.scene.remove(this.groundGroup)}_dispose(){if(!this.groundMesh)return;this.groundMesh.geometry.dispose();const e=this.groundMesh.material;Array.isArray(e)?e.forEach(t=>t.dispose()):e.dispose(),this.groundGroup.remove(this.groundMesh),this.groundMesh=null,this.isWaterAddon=!1}}class Ei extends M.Mesh{constructor(){const e=Ei.SkyShader,t=new M.ShaderMaterial({name:e.name,uniforms:M.UniformsUtils.clone(e.uniforms),vertexShader:e.vertexShader,fragmentShader:e.fragmentShader,side:M.BackSide,depthWrite:!1});super(new M.BoxGeometry(1,1,1),t),this.isSky=!0}}Ei.SkyShader={name:"SkyShader",uniforms:{turbidity:{value:2},rayleigh:{value:1},mieCoefficient:{value:.005},mieDirectionalG:{value:.8},sunPosition:{value:new M.Vector3},up:{value:new M.Vector3(0,1,0)}},vertexShader:`
|
|
1115
|
+
uniform vec3 sunPosition;
|
|
1116
|
+
uniform float rayleigh;
|
|
1117
|
+
uniform float turbidity;
|
|
1118
|
+
uniform float mieCoefficient;
|
|
1119
|
+
uniform vec3 up;
|
|
1120
|
+
|
|
1121
|
+
varying vec3 vWorldPosition;
|
|
1122
|
+
varying vec3 vSunDirection;
|
|
1123
|
+
varying float vSunfade;
|
|
1124
|
+
varying vec3 vBetaR;
|
|
1125
|
+
varying vec3 vBetaM;
|
|
1126
|
+
varying float vSunE;
|
|
1127
|
+
|
|
1128
|
+
// constants for atmospheric scattering
|
|
1129
|
+
const float e = 2.71828182845904523536028747135266249775724709369995957;
|
|
1130
|
+
const float pi = 3.141592653589793238462643383279502884197169;
|
|
1131
|
+
|
|
1132
|
+
// wavelength of used primaries, according to preetham
|
|
1133
|
+
const vec3 lambda = vec3( 680E-9, 550E-9, 450E-9 );
|
|
1134
|
+
// this pre-calculation replaces older TotalRayleigh(vec3 lambda) function:
|
|
1135
|
+
// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))
|
|
1136
|
+
const vec3 totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );
|
|
1137
|
+
|
|
1138
|
+
// mie stuff
|
|
1139
|
+
// K coefficient for the primaries
|
|
1140
|
+
const float v = 4.0;
|
|
1141
|
+
const vec3 K = vec3( 0.686, 0.678, 0.666 );
|
|
1142
|
+
// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K
|
|
1143
|
+
const vec3 MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );
|
|
1144
|
+
|
|
1145
|
+
// earth shadow hack
|
|
1146
|
+
// cutoffAngle = pi / 1.95;
|
|
1147
|
+
const float cutoffAngle = 1.6110731556870734;
|
|
1148
|
+
const float steepness = 1.5;
|
|
1149
|
+
const float EE = 1000.0;
|
|
1150
|
+
|
|
1151
|
+
float sunIntensity( float zenithAngleCos ) {
|
|
1152
|
+
zenithAngleCos = clamp( zenithAngleCos, -1.0, 1.0 );
|
|
1153
|
+
return EE * max( 0.0, 1.0 - pow( e, -( ( cutoffAngle - acos( zenithAngleCos ) ) / steepness ) ) );
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
vec3 totalMie( float T ) {
|
|
1157
|
+
float c = ( 0.2 * T ) * 10E-18;
|
|
1158
|
+
return 0.434 * c * MieConst;
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
void main() {
|
|
1162
|
+
|
|
1163
|
+
vec4 worldPosition = modelMatrix * vec4( position, 1.0 );
|
|
1164
|
+
vWorldPosition = worldPosition.xyz;
|
|
1165
|
+
|
|
1166
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
1167
|
+
gl_Position.z = gl_Position.w; // set z to camera.far
|
|
1168
|
+
|
|
1169
|
+
vSunDirection = normalize( sunPosition );
|
|
1170
|
+
|
|
1171
|
+
vSunE = sunIntensity( dot( vSunDirection, up ) );
|
|
1172
|
+
|
|
1173
|
+
vSunfade = 1.0 - clamp( 1.0 - exp( ( sunPosition.y / 450000.0 ) ), 0.0, 1.0 );
|
|
1174
|
+
|
|
1175
|
+
float rayleighCoefficient = rayleigh - ( 1.0 * ( 1.0 - vSunfade ) );
|
|
1176
|
+
|
|
1177
|
+
// extinction (absorption + out scattering)
|
|
1178
|
+
// rayleigh coefficients
|
|
1179
|
+
vBetaR = totalRayleigh * rayleighCoefficient;
|
|
1180
|
+
|
|
1181
|
+
// mie coefficients
|
|
1182
|
+
vBetaM = totalMie( turbidity ) * mieCoefficient;
|
|
1183
|
+
|
|
1184
|
+
}`,fragmentShader:`
|
|
1185
|
+
varying vec3 vWorldPosition;
|
|
1186
|
+
varying vec3 vSunDirection;
|
|
1187
|
+
varying float vSunfade;
|
|
1188
|
+
varying vec3 vBetaR;
|
|
1189
|
+
varying vec3 vBetaM;
|
|
1190
|
+
varying float vSunE;
|
|
1191
|
+
|
|
1192
|
+
uniform float mieDirectionalG;
|
|
1193
|
+
uniform vec3 up;
|
|
1194
|
+
|
|
1195
|
+
// constants for atmospheric scattering
|
|
1196
|
+
const float pi = 3.141592653589793238462643383279502884197169;
|
|
1197
|
+
|
|
1198
|
+
const float n = 1.0003; // refractive index of air
|
|
1199
|
+
const float N = 2.545E25; // number of molecules per unit volume for air at 288.15K and 1013mb (sea level -45 celsius)
|
|
1200
|
+
|
|
1201
|
+
// optical length at zenith for molecules
|
|
1202
|
+
const float rayleighZenithLength = 8.4E3;
|
|
1203
|
+
const float mieZenithLength = 1.25E3;
|
|
1204
|
+
// 66 arc seconds -> degrees, and the cosine of that
|
|
1205
|
+
const float sunAngularDiameterCos = 0.999956676946448443553574619906976478926848692873900859324;
|
|
1206
|
+
|
|
1207
|
+
// 3.0 / ( 16.0 * pi )
|
|
1208
|
+
const float THREE_OVER_SIXTEENPI = 0.05968310365946075;
|
|
1209
|
+
// 1.0 / ( 4.0 * pi )
|
|
1210
|
+
const float ONE_OVER_FOURPI = 0.07957747154594767;
|
|
1211
|
+
|
|
1212
|
+
float rayleighPhase( float cosTheta ) {
|
|
1213
|
+
return THREE_OVER_SIXTEENPI * ( 1.0 + pow( cosTheta, 2.0 ) );
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
float hgPhase( float cosTheta, float g ) {
|
|
1217
|
+
float g2 = pow( g, 2.0 );
|
|
1218
|
+
float inverse = 1.0 / pow( 1.0 - 2.0 * g * cosTheta + g2, 1.5 );
|
|
1219
|
+
return ONE_OVER_FOURPI * ( ( 1.0 - g2 ) * inverse );
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
void main() {
|
|
1223
|
+
|
|
1224
|
+
vec3 direction = normalize( vWorldPosition - cameraPosition );
|
|
1225
|
+
|
|
1226
|
+
// optical length
|
|
1227
|
+
// cutoff angle at 90 to avoid singularity in next formula.
|
|
1228
|
+
float zenithAngle = acos( max( 0.0, dot( up, direction ) ) );
|
|
1229
|
+
float inverse = 1.0 / ( cos( zenithAngle ) + 0.15 * pow( 93.885 - ( ( zenithAngle * 180.0 ) / pi ), -1.253 ) );
|
|
1230
|
+
float sR = rayleighZenithLength * inverse;
|
|
1231
|
+
float sM = mieZenithLength * inverse;
|
|
1232
|
+
|
|
1233
|
+
// combined extinction factor
|
|
1234
|
+
vec3 Fex = exp( -( vBetaR * sR + vBetaM * sM ) );
|
|
1235
|
+
|
|
1236
|
+
// in scattering
|
|
1237
|
+
float cosTheta = dot( direction, vSunDirection );
|
|
1238
|
+
|
|
1239
|
+
float rPhase = rayleighPhase( cosTheta * 0.5 + 0.5 );
|
|
1240
|
+
vec3 betaRTheta = vBetaR * rPhase;
|
|
1241
|
+
|
|
1242
|
+
float mPhase = hgPhase( cosTheta, mieDirectionalG );
|
|
1243
|
+
vec3 betaMTheta = vBetaM * mPhase;
|
|
1244
|
+
|
|
1245
|
+
vec3 Lin = pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * ( 1.0 - Fex ), vec3( 1.5 ) );
|
|
1246
|
+
Lin *= mix( vec3( 1.0 ), pow( vSunE * ( ( betaRTheta + betaMTheta ) / ( vBetaR + vBetaM ) ) * Fex, vec3( 1.0 / 2.0 ) ), clamp( pow( 1.0 - dot( up, vSunDirection ), 5.0 ), 0.0, 1.0 ) );
|
|
1247
|
+
|
|
1248
|
+
// nightsky
|
|
1249
|
+
float theta = acos( direction.y ); // elevation --> y-axis, [-pi/2, pi/2]
|
|
1250
|
+
float phi = atan( direction.z, direction.x ); // azimuth --> x-axis [-pi/2, pi/2]
|
|
1251
|
+
vec2 uv = vec2( phi, theta ) / vec2( 2.0 * pi, pi ) + vec2( 0.5, 0.0 );
|
|
1252
|
+
vec3 L0 = vec3( 0.1 ) * Fex;
|
|
1253
|
+
|
|
1254
|
+
// composition + solar disc
|
|
1255
|
+
float sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos + 0.00002, cosTheta );
|
|
1256
|
+
L0 += ( vSunE * 19000.0 * Fex ) * sundisk;
|
|
1257
|
+
|
|
1258
|
+
vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );
|
|
1259
|
+
|
|
1260
|
+
vec3 retColor = pow( texColor, vec3( 1.0 / ( 1.2 + ( 1.2 * vSunfade ) ) ) );
|
|
1261
|
+
|
|
1262
|
+
gl_FragColor = vec4( retColor, 1.0 );
|
|
1263
|
+
|
|
1264
|
+
#include <tonemapping_fragment>
|
|
1265
|
+
#include <colorspace_fragment>
|
|
1266
|
+
|
|
1267
|
+
}`};const Kr={turbidity:10,rayleigh:3,mieCoefficient:.005,mieDirectionalG:.7,elevation:2,azimuth:180,exposure:.5,orthoExposureScale:1.5,cloudCoverage:.4,cloudDensity:.4,cloudElevation:.5,showSunDisc:!0},$r={default:{...Kr},sunset:{turbidity:10,rayleigh:2,mieCoefficient:.005,mieDirectionalG:.7,elevation:5,azimuth:210,exposure:.6,cloudCoverage:.3,cloudDensity:.35,cloudElevation:.5,showSunDisc:!0},overcast:{turbidity:20,rayleigh:2,mieCoefficient:.02,mieDirectionalG:.6,elevation:30,azimuth:180,exposure:.4,cloudCoverage:.8,cloudDensity:.6,cloudElevation:.4,showSunDisc:!1},clear:{turbidity:2,rayleigh:1,mieCoefficient:.002,mieDirectionalG:.8,elevation:60,azimuth:180,exposure:.55,cloudCoverage:.1,cloudDensity:.2,cloudElevation:.5,showSunDisc:!0},night:{turbidity:5,rayleigh:.5,mieCoefficient:.001,mieDirectionalG:.8,elevation:-15,azimuth:180,exposure:.15,cloudCoverage:.2,cloudDensity:.25,cloudElevation:.5,showSunDisc:!1}},qr=2e6;class Wu{engine;sky=null;sun=new w.Vector3;params={...Kr};skyScale=45e4;skyName="bim_engine_sky";savedCameraFar=null;constructor(e){this.engine=e}activate(){if(!this.engine?.scene)return;if(this.sky){this.sky.visible=!0,this._expandCameraFarForSky(),this._applyParamsToSky();return}const e=new Ei;e.scale.setScalar(this.skyScale),e.name=this.skyName,this.sky=e,this.engine.scene.add(e),this._expandCameraFarForSky(),this.engine.renderer&&(this.engine.renderer.toneMapping=w.ACESFilmicToneMapping,this.engine.scene.background=null),this._applyParamsToSky()}close(e=!0){this.sky&&(e?(this._restoreCameraFar(),this.engine?.scene?.remove(this.sky),this.sky.material.dispose(),this.sky.geometry.dispose(),this.sky=null):this.sky.visible=!1)}isActive(){return this.sky!=null&&this.engine?.scene?.children?.includes(this.sky)}getParams(){return{...this.params}}setParams(e){Object.assign(this.params,e),this._applyParamsToSky(),this.engine?.renderer&&(e.exposure!==void 0||e.orthoExposureScale!==void 0)&&(this.engine.renderer.toneMappingExposure=this._getEffectiveExposure())}setPreset(e){const t=$r[e];t&&this.setParams({...t})}getPresetNames(){return Object.keys($r)}update(e){if(!this.sky?.visible)return;const t=this.sky.material.uniforms;t&&"time"in t&&(t.time.value=e??performance.now()*.001),this.engine?.renderer&&(this.engine.renderer.toneMappingExposure=this._getEffectiveExposure())}_isOrthographicCamera(){const e=this.engine?.camera;return e!=null&&e.type==="OrthographicCamera"}_getEffectiveExposure(){const e=this.params.exposure;return this._isOrthographicCamera()?e*this.params.orthoExposureScale:e}_expandCameraFarForSky(){const e=this.engine?.camera;if(!e||typeof e.far!="number")return;const t=e.far;t>=qr||(this.savedCameraFar==null&&(this.savedCameraFar=t),e.far=qr,typeof e.updateProjectionMatrix=="function"&&e.updateProjectionMatrix())}_restoreCameraFar(){if(this.savedCameraFar==null||!this.engine?.camera)return;const e=this.engine.camera;typeof e.far=="number"&&(e.far=this.savedCameraFar,typeof e.updateProjectionMatrix=="function"&&e.updateProjectionMatrix(),this.savedCameraFar=null)}_applyParamsToSky(){if(!this.sky)return;const e=this.sky.material.uniforms;this._setUniformValue(e,"turbidity",this.params.turbidity),this._setUniformValue(e,"rayleigh",this.params.rayleigh),this._setUniformValue(e,"mieCoefficient",this.params.mieCoefficient),this._setUniformValue(e,"mieDirectionalG",this.params.mieDirectionalG),this._setUniformValue(e,"cloudCoverage",this.params.cloudCoverage),this._setUniformValue(e,"cloudDensity",this.params.cloudDensity),this._setUniformValue(e,"cloudElevation",this.params.cloudElevation),this._setUniformValue(e,"showSunDisc",this.params.showSunDisc?1:0);const t=w.MathUtils.degToRad(90-this.params.elevation),n=w.MathUtils.degToRad(this.params.azimuth);this.sun.setFromSphericalCoords(1,t,n),this._setUniformValue(e,"sunPosition",this.sun),this.engine?.renderer&&(this.engine.renderer.toneMapping=w.ACESFilmicToneMapping,this.engine.renderer.toneMappingExposure=this._getEffectiveExposure())}_setUniformValue(e,t,n){const i=e[t];i&&(n instanceof w.Vector3&&typeof i.value?.copy=="function"?i.value.copy(n):i.value=n)}}let Xu=class{engine;constructor(e){this.engine=e,this.active()}active(){window.addEventListener("D2ElementClick",this.listenElementClick)}disActive(){window.removeEventListener("D2ElementClick",this.listenElementClick)}listenElementClick=e=>{let t=!0;this.engine.models.forEach(n=>{n.nodesMap.has(Number(e.detail.id))&&(t=!1,this.engine.modelToolModule.highlightModel([{url:n.url,ids:[Number(e.detail.id)]}]),this.engine.viewCube.zoomToModels({url:n.url,id:Number(e.detail.id)}))}),(Number(e.detail.id)==-1||t)&&this.engine.modelToolModule.unhighlightAllModels()}},Zu=class{engine;constructor(e){this.engine=e,this.active()}active(){window.addEventListener("D2ViewControl",this.listenViewUpdate)}disActive(){window.removeEventListener("D2ViewControl",this.listenViewUpdate)}listenViewUpdate=e=>{const t=e?.detail;t&&(t.position&&this.applyPosition(t.position),typeof t.rotation=="number"&&this.applyRotation(t.rotation))};applyPosition(e){const t=this.engine.camera;if(!t)return;const n=this.engine.controls,i=t.position.clone(),s=typeof e.y=="number"?e.y:i.y;t.position.set(e.x,s,e.z),n?.target?(n.target.set(n.target.x+(e.x-i.x),n.target.y+(s-i.y),n.target.z+(e.z-i.z)),n.update(),n.dispatchEvent?.({type:"change"})):t.updateMatrixWorld()}applyRotation(e){const t=this.engine.camera;if(!t)return;const n=this.engine.controls,i=n?.target;let s=10;i&&(s=Math.max(1,t.position.distanceTo(i)));const o=new w.Vector3(Math.sin(e),0,-Math.cos(e)),a=i?i.y:t.position.y,l=new w.Vector3(t.position.x+o.x*s,a,t.position.z+o.z*s);n?.target?(n.target.copy(l),n.update(),n.dispatchEvent?.({type:"change"})):t.lookAt(l)}};class Yu{engine;apiKey;baseURL="https://api.deepseek.com";constructor(e,t){this.engine=e,this.apiKey=t||"sk-4677b153277a40b096c6716686c29ac4",console.log("OneClickEncoding 初始化,API Key:",this.apiKey?.substring(0,8)+"...")}start(){let e=["注释","族名称"],t=[];this.engine.models.forEach(n=>{n.nodesMap.forEach((i,s)=>{this.engine.modelProperties.getModelPropertiesWithName(n.url,s,e,o=>{t.push(o),t.length==n.nodesMap.size&&this.startChat(n.url,JSON.stringify(t))})})})}async startChat(e,t){let n=await this.chat(t);const i=n.match(/```json\s*([\s\S]*?)\s*```/),s=i?i[1]:n,o=JSON.parse(s);console.log("解析后的编码结果:",o);let a=this.engine.models.find(l=>l.url==e);a!=null&&o.forEach(l=>{let c=a.nodesMap.get(Number(l.id));c!=null&&(c.code=l.code)})}async chat(e){let t=`你是一个经验丰富的桥梁工程师,你要为我的BIM模型进行编码,按一定的规则进行编码。
|
|
1268
|
+
【输入信息】
|
|
1269
|
+
- 1. json字符串,里面会包含构件名称,构件类型,里程等等等。
|
|
1270
|
+
- 2. 项目的基本信息,如项目名称,桥梁名称等
|
|
1271
|
+
【编码规则】
|
|
1272
|
+
请按照以下层级生成编码(用”-”连接):
|
|
1273
|
+
第一层:工程部位(固定为”桥梁工程”)
|
|
1274
|
+
第二层:构件类型(主梁/桥墩/桩基/盖梁/支座等)
|
|
1275
|
+
第三层:具体位置标识(线路+墩号+构件编号)
|
|
1276
|
+
|
|
1277
|
+
【示例格式】
|
|
1278
|
+
桥梁工程-桩基-左线1#_2桩基
|
|
1279
|
+
|
|
1280
|
+
【输出要求】
|
|
1281
|
+
请根据上述规则,为输入构件生成标准编码,必须每个构件都具有编码。
|
|
1282
|
+
|
|
1283
|
+
【输出格式】
|
|
1284
|
+
输出格式要严格的json格式,包含构件id,构件编码,格式如下
|
|
1285
|
+
[
|
|
1286
|
+
{“id”:0,”code”:”code”}
|
|
1287
|
+
]
|
|
1288
|
+
`;try{console.log("正在调用 DeepSeek API..."),console.log("API Key 前8位:",this.apiKey?.substring(0,8)+"...");const n=await fetch(`${this.baseURL}/v1/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`},body:JSON.stringify({model:"deepseek-chat",messages:[{role:"system",content:t},{role:"user",content:e}],temperature:.7})});if(!n.ok){const s=await n.text();throw console.error("API 错误详情:",s),new Error(`API request failed: ${n.status} - ${s}`)}const i=await n.json();return console.log("API 调用成功:",i),i.choices[0].message.content}catch(n){throw console.error("DeepSeek API call failed:",n),n}}}class Ku{engine;constructor(e){this.engine=e}getViewTreeData(e){return this.engine.models.find(t=>t.url===e)?.views}openView(e,t){t="771513";const n=this.engine.models.find(c=>c.url===e)?.views?.Sections.find(c=>c.id===t||c.Id===t);if(!n)return;const i=n.Origin||n.origin,s=n.ViewDirection||n.viewDirection;if(!i||!s)return;const o=new w.Vector3(i.X??i.x,-(i.Z??i.z),i.Y??i.y).setLength(.3048),a=new w.Vector3(s.X??s.x,-(s.Z??s.z),s.Y??s.y).setLength(-1);this.engine.cameraModule.setViewFromOriginAndDirection(o,a),(n.ViewType||n.viewType||"")==="剖面视图"&&(this.engine.clipping.setSectionByView(o,a),this.engine.merge2d.attachSectionPlane(e,t,o,a))}}var Ve=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelLoadError="model-load-error",r.RenderStart="render-start",r.RenderEnd="render-end",r.CameraChanged="camera-changed",r.CameraReset="camera-reset",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.EntityClick="entity-click",r.LayerVisibilityChanged="layer-visibility-changed",r.LayerColorChanged="layer-color-changed",r.ViewZoomChanged="view-zoom-changed",r.ViewPanChanged="view-pan-changed",r.ToolActivated="tool-activated",r.ToolDeactivated="tool-deactivated",r.Error="error",r.Warning="warning",r))(Ve||{});class $u{listeners=new Map;onceListeners=new Map;debugMode=!1;constructor(e=!1){this.debugMode=e,this.initializeEvents()}initializeEvents(){Object.values(Ve).forEach(t=>{this.listeners.set(t,new Set),this.onceListeners.set(t,new Set)})}on(e,t){return this.listeners.has(e)?(this.listeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Listener added for ${e}`),()=>this.off(e,t)):(console.warn(`Event type ${e} is not registered`),()=>{})}once(e,t){if(!this.onceListeners.has(e)){console.warn(`Event type ${e} is not registered`);return}this.onceListeners.get(e).add(t),this.debugMode&&console.log(`[EventModule2d] Once listener added for ${e}`)}off(e,t){const n=this.listeners.get(e);n&&(n.delete(t),this.debugMode&&console.log(`[EventModule2d] Listener removed for ${e}`))}trigger(e,t){this.debugMode&&console.log(`[EventModule2d] Triggering ${e}`,t);const n=this.listeners.get(e);n&&n.size>0&&n.forEach(s=>{try{s(t)}catch(o){console.error(`[EventModule2d] Error in listener for ${e}:`,o)}});const i=this.onceListeners.get(e);i&&i.size>0&&(i.forEach(s=>{try{s(t)}catch(o){console.error(`[EventModule2d] Error in once listener for ${e}:`,o)}}),i.clear())}removeAllListeners(){this.listeners.forEach(e=>e.clear()),this.onceListeners.forEach(e=>e.clear()),this.debugMode&&console.log("[EventModule2d] All listeners removed")}removeListenersOfType(e){const t=this.listeners.get(e),n=this.onceListeners.get(e);t&&t.clear(),n&&n.clear(),this.debugMode&&console.log(`[EventModule2d] All listeners removed for ${e}`)}getListenerCount(e){const t=this.listeners.get(e),n=this.onceListeners.get(e);return(t?.size||0)+(n?.size||0)}setDebugMode(e){this.debugMode=e}getAllEventTypes(){return Object.values(Ve)}dispose(){this.removeAllListeners(),this.listeners.clear(),this.onceListeners.clear(),this.debugMode&&console.log("[EventModule2d] Disposed")}}class qu extends M.ExtrudeGeometry{constructor(e,t={}){const n=t.font;if(n===void 0)super();else{const i=n.generateShapes(e,t.size,t.direction);t.depth===void 0&&(t.depth=50),t.bevelThickness===void 0&&(t.bevelThickness=10),t.bevelSize===void 0&&(t.bevelSize=8),t.bevelEnabled===void 0&&(t.bevelEnabled=!1),super(i,t)}this.type="TextGeometry"}}class Hu extends M.Loader{constructor(e){super(e)}load(e,t,n,i){const s=this,o=new M.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){const l=s.parse(JSON.parse(a));t&&t(l)},n,i)}parse(e){return new Ju(e)}}class Ju{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,n="ltr"){const i=[],s=Qu(e,t,this.data,n);for(let o=0,a=s.length;o<a;o++)i.push(...s[o].toShapes());return i}}function Qu(r,e,t,n){const i=Array.from(r),s=e/t.resolution,o=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*s,a=[];let l=0,c=0;(n=="rtl"||n=="tb")&&i.reverse();for(let h=0;h<i.length;h++){const u=i[h];if(u===`
|
|
1289
|
+
`)l=0,c-=o;else{const m=ef(u,s,l,c,t);n=="tb"?(l=0,c+=t.ascender*s):l+=m.offsetX,a.push(m.path)}}return a}function ef(r,e,t,n,i){const s=i.glyphs[r]||i.glyphs["?"];if(!s){console.error('THREE.Font: character "'+r+'" does not exists in font family '+i.familyName+".");return}const o=new M.ShapePath;let a,l,c,h,u,m,p,f;if(s.o){const d=s._cachedOutline||(s._cachedOutline=s.o.split(" "));for(let g=0,y=d.length;g<y;)switch(d[g++]){case"m":a=d[g++]*e+t,l=d[g++]*e+n,o.moveTo(a,l);break;case"l":a=d[g++]*e+t,l=d[g++]*e+n,o.lineTo(a,l);break;case"q":c=d[g++]*e+t,h=d[g++]*e+n,u=d[g++]*e+t,m=d[g++]*e+n,o.quadraticCurveTo(u,m,c,h);break;case"b":c=d[g++]*e+t,h=d[g++]*e+n,u=d[g++]*e+t,m=d[g++]*e+n,p=d[g++]*e+t,f=d[g++]*e+n,o.bezierCurveTo(u,m,p,f,c,h);break}}return{offsetX:s.ha*e,path:o}}class Cn{static async fromUrl(e,t){const n=await fetch(e);if(!n.ok)throw new Error(`FontJsonGenerator: 无法加载 ${e} (${n.status})`);const i=await n.arrayBuffer();return Cn.fromArrayBuffer(i,t)}static fromArrayBuffer(e,t){const n=sa.parse(e);return Cn._convert(n,t?.chars)}static toThreeFont(e){return new Hu().parse(e)}static _convert(e,t){const n={},i=e.unitsPerEm,s=u=>Math.round(u),o=u=>{const m=e.charToGlyph(u);if(!m||m.index===0)return;const p=m.path.commands,f=[];for(const g of p)switch(g.type){case"M":f.push(`m ${s(g.x)} ${s(g.y)}`);break;case"L":f.push(`l ${s(g.x)} ${s(g.y)}`);break;case"Q":f.push(`q ${s(g.x1)} ${s(g.y1)} ${s(g.x)} ${s(g.y)}`);break;case"C":f.push(`b ${s(g.x1)} ${s(g.y1)} ${s(g.x2)} ${s(g.y2)} ${s(g.x)} ${s(g.y)}`);break;case"Z":f.push("z");break}const d=m.getBoundingBox();n[u]={x_min:d.x1,x_max:d.x2,ha:m.advanceWidth??0,o:f.join(" ")}};if(t)for(const u of t)o(u);else{const u=e.tables.cmap?.glyphIndexMap??{};for(const m of Object.keys(u)){const p=Number.parseInt(m,10);p>0&&o(String.fromCodePoint(p))}}if(!n[" "]){const u=e.charToGlyph(" ");n[" "]={x_min:0,x_max:0,ha:u?.advanceWidth??Math.round(i/4),o:""}}const a=e.names,l=u=>a[u]?.en??a[u]?.zh??"",c=l("fontFamily")||"Custom Font",h=l("fontSubfamily")||"Regular";return{familyName:c,ascender:e.ascender,descender:e.descender,underlinePosition:e.tables.post?.underlinePosition??-100,underlineThickness:e.tables.post?.underlineThickness??50,boundingBox:{yMin:e.descender,xMin:0,yMax:e.ascender,xMax:i},resolution:i,original_font_information:{fontFamily:c,fontSubfamily:h},cssFontStyle:h.toLowerCase().includes("italic")?"italic":"normal",cssFontWeight:h.toLowerCase().includes("bold")?"bold":"normal",glyphs:n}}}class tf{panel=null;listEl=null;isVisible=!1;delegate;constructor(e,t){this.delegate=t,this._buildPanel(e)}show(){this.panel&&(this.panel.style.display="flex",this.isVisible=!0)}hide(){this.panel&&(this.panel.style.display="none",this.isVisible=!1)}toggle(){this.isVisible?this.hide():this.show()}refresh(){this._renderList()}_buildPanel(e){const t=document.createElement("div");t.style.cssText=`
|
|
1290
|
+
position:absolute; top:10px; right:10px;
|
|
1291
|
+
width:220px; max-height:480px;
|
|
1292
|
+
background:var(--e2d-bg,#1e1f22);
|
|
1293
|
+
border:1px solid var(--e2d-border2,#333);
|
|
1294
|
+
border-radius:4px;
|
|
1295
|
+
box-shadow:0 4px 16px var(--e2d-shadow,rgba(0,0,0,.6));
|
|
1296
|
+
display:none; flex-direction:column;
|
|
1297
|
+
z-index:100; user-select:none;
|
|
1298
|
+
font-size:13px; color:var(--e2d-text,#e0e0e0);
|
|
1299
|
+
font-family:system-ui,sans-serif;
|
|
1300
|
+
`,this.panel=t;const n=document.createElement("div");n.style.cssText=`
|
|
1301
|
+
display:flex; align-items:center; justify-content:space-between;
|
|
1302
|
+
padding:8px 10px;
|
|
1303
|
+
background:var(--e2d-bg3,#222);
|
|
1304
|
+
border-bottom:1px solid var(--e2d-border2,#333);
|
|
1305
|
+
border-radius:4px 4px 0 0; cursor:move; flex-shrink:0;
|
|
1306
|
+
`;const i=document.createElement("span");i.textContent="图层",i.style.cssText="font-size:13px; font-weight:500; color:var(--e2d-text,#e0e0e0);";const s=document.createElement("button");s.textContent="×",s.style.cssText=`
|
|
1307
|
+
background:none; border:none;
|
|
1308
|
+
color:var(--e2d-close,#aaa);
|
|
1309
|
+
font-size:18px; line-height:1; cursor:pointer; padding:0 2px;
|
|
1310
|
+
transition:color 0.15s;
|
|
1311
|
+
`,s.onmouseenter=()=>{s.style.color="var(--e2d-close-hover,#fff)"},s.onmouseleave=()=>{s.style.color="var(--e2d-close,#aaa)"},s.onclick=()=>this.hide(),n.appendChild(i),n.appendChild(s),this._makeDraggable(t,n);const o=this._createRow(),a=this._createEye(!0),l=document.createElement("span");l.textContent="全部图层",l.style.cssText="flex:1; font-weight:500; color:var(--e2d-text,#e0e0e0);",o.appendChild(a),o.appendChild(l),o.onclick=()=>{const m=!this.delegate.isAllVisible();this.delegate.setAllLayersVisible(m),this._renderList(),this._updateEye(a,m)};const c=document.createElement("div");c.style.cssText="height:1px; background:var(--e2d-border2,#333); margin:0 8px; flex-shrink:0;";const h=document.createElement("div");h.style.cssText=`
|
|
1312
|
+
overflow-y:auto; flex:1;
|
|
1313
|
+
scrollbar-width:thin;
|
|
1314
|
+
scrollbar-color:var(--e2d-scrollbar,#444) transparent;
|
|
1315
|
+
`,this.listEl=h,t.appendChild(n),t.appendChild(o),t.appendChild(c),t.appendChild(h);const u=this._renderList.bind(this);this._renderList=()=>{u(),this._updateEye(a,this.delegate.isAllVisible())},this._renderList(),e.style.position="relative",e.appendChild(t)}_renderList(){const e=this.listEl;if(e){e.innerHTML="";for(const t of this.delegate.getLayers()){const n=this._createRow(),i=this._createEye(t.visible),s=document.createElement("span");s.style.cssText=`
|
|
1316
|
+
width:14px; height:14px; border-radius:2px; flex-shrink:0;
|
|
1317
|
+
border:1px solid var(--e2d-swatch-border,#444);
|
|
1318
|
+
background:${this._colorToHex(t.color)};
|
|
1319
|
+
`;const o=document.createElement("span");o.textContent=t.name,o.style.cssText=`
|
|
1320
|
+
flex:1; white-space:nowrap; overflow:hidden;
|
|
1321
|
+
text-overflow:ellipsis; font-size:12px;
|
|
1322
|
+
color:${t.visible?"var(--e2d-text,#ddd)":"var(--e2d-text4,#666)"};
|
|
1323
|
+
transition:color 0.15s;
|
|
1324
|
+
`,n.appendChild(i),n.appendChild(s),n.appendChild(o),n.onclick=()=>{const a=this.delegate.toggleLayer(t.name);this._updateEye(i,a),o.style.color=a?"var(--e2d-text,#ddd)":"var(--e2d-text4,#666)"},e.appendChild(n)}}}_createRow(){const e=document.createElement("div");return e.style.cssText=`
|
|
1325
|
+
display:flex; align-items:center; gap:8px;
|
|
1326
|
+
padding:5px 10px; cursor:pointer;
|
|
1327
|
+
border-bottom:1px solid var(--e2d-border2,#222);
|
|
1328
|
+
transition:background 0.1s;
|
|
1329
|
+
`,e.onmouseenter=()=>{e.style.background="var(--e2d-bg-hover,#2a2a2a)"},e.onmouseleave=()=>{e.style.background=""},e}_createEye(e){const t=document.createElement("span");return t.style.cssText="display:flex; align-items:center; flex-shrink:0; width:16px;",this._updateEye(t,e),t}_updateEye(e,t){e.style.color=t?"var(--e2d-close,#aaa)":"var(--e2d-text4,#555)",e.innerHTML=t?`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1330
|
+
<path d="M8 3C4.5 3 1.5 8 1.5 8C1.5 8 4.5 13 8 13C11.5 13 14.5 8 14.5 8C14.5 8 11.5 3 8 3Z" stroke="currentColor" stroke-width="1.2"/>
|
|
1331
|
+
<circle cx="8" cy="8" r="2" stroke="currentColor" stroke-width="1.2"/>
|
|
1332
|
+
</svg>`:`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1333
|
+
<path d="M2 2L14 14" stroke="currentColor" stroke-width="1.2"/>
|
|
1334
|
+
<path d="M8 3C4.5 3 1.5 8 1.5 8C2.2 9.3 3.3 10.5 4.5 11.5" stroke="currentColor" stroke-width="1.2"/>
|
|
1335
|
+
<path d="M11.5 11.5C12.7 10.5 13.8 9.3 14.5 8C14.5 8 11.5 3 8 3" stroke="currentColor" stroke-width="1.2"/>
|
|
1336
|
+
</svg>`}_colorToHex(e){return"#"+e.toString(16).padStart(6,"0")}_makeDraggable(e,t){t.onmousedown=n=>{n.preventDefault();const i=e.getBoundingClientRect(),s=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=i.left-s.left+"px",e.style.top=i.top-s.top+"px",e.style.right="auto",e.style.bottom="auto";const o=n.clientX-i.left,a=n.clientY-i.top,l=h=>{e.style.left=h.clientX-o-s.left+"px",e.style.top=h.clientY-a-s.top+"px"},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)}}dispose(){this.panel?.remove(),this.panel=null,this.listEl=null}}class Hr{engine;layerMap=new Map;panelUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.panelUI=new tf(t,this))}_loadLayers(){let e=this.engine.dwgData.layers;this.layerMap.clear();for(const t of e)this.layerMap.set(t.name,{...t}),this.panelUI?.refresh()}syncFromModel(e){e?.length>0&&(this._loadLayers(e),this.panelUI?.refresh())}getLayers(){return Array.from(this.layerMap.values())}setLayerVisible(e,t){const n=this.layerMap.get(e);n&&(n.visible=t),this._applyVisibility(e,t)}toggleLayer(e){const t=this.layerMap.get(e);if(!t)return!0;const n=!t.visible;return this.setLayerVisible(e,n),n}setAllLayersVisible(e){for(const t of this.layerMap.keys()){const n=this.layerMap.get(t);n.visible=e,this._applyVisibility(t,e)}}isAllVisible(){return Array.from(this.layerMap.values()).every(e=>e.visible)}_applyVisibility(e,t){const n=this.engine?.scene;if(!n)return;const i=e+"||";n.children.forEach(s=>{s.name?.startsWith(i)&&(s.visible=t)})}show(){this.panelUI?.show()}hide(){this.panelUI?.hide()}toggle(){this.panelUI?.toggle()}dispose(){this.panelUI?.dispose(),this.panelUI=null,this.layerMap.clear()}}class Jr{engine;data=null;enableValidation=!0;constructor(e){for(this.engine=e,this.engine.modelGroup=new w.Group,this.engine.modelGroup.name="model2d",this.engine.scene.add(this.engine.modelGroup);this.engine.modelGroup.children.length>0;)this.engine.modelGroup.remove(this.engine.modelGroup.children[0])}async loadModel(e,t={}){if(!e.includes(".json"))this.engine.events&&this.engine.events.trigger(Ve.ModelLoadStart,{url:e}),Jn(e,async n=>{const i=JSON.parse(n);this.engine.dwgData=i,this.data=i,await this.buildScene(i);try{this.engine.fitToView()}catch{}this.engine.layerManager||(this.engine.layerManager=new Hr(this.engine)),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(Ve.ModelLoaded,{})},n=>{this._emitProgress(0,"抱歉,图纸加载失败")});else{this.engine.events&&this.engine.events.trigger(Ve.ModelLoadStart,{url:e}),this._emitProgress(10,"请求数据...");const n=await this.fetchJson(e);this._emitProgress(20,"解析数据...");const i=this.parseData(n);if(this.engine.dwgData=i,!i)throw new Error("Failed to parse DWG data");this.data=i,await this.buildScene(i),this.engine.fitToView(),this.engine.layerManager._loadLayers(),this.engine.events&&this.engine.events.trigger(Ve.ModelLoaded,{})}}async fetchJson(e){const t=await fetch(e);if(!t.ok)throw new Error(`HTTP error! status: ${t.status}`);return await t.json()}parseData(e){return e?this.enableValidation&&!this.validateDataStructure(e)?(console.error("[LoaderModule2d] Invalid data structure"),null):e:(console.error("[LoaderModule2d] Empty JSON data"),null)}validateDataStructure(e){return e.version||console.warn("[LoaderModule2d] Missing version"),e.metadata||console.warn("[LoaderModule2d] Missing metadata"),Array.isArray(e.layers)?Array.isArray(e.entities)?!0:(console.error("[LoaderModule2d] Invalid or missing entities array"),!1):(console.error("[LoaderModule2d] Invalid or missing layers array"),!1)}model={};totalBlock=new Map;font=null;async loadFont(){const e=this.engine.options?.fontUrl??"/fonts/simfang.ttf",t=await Cn.fromUrl(e);return Cn.toThreeFont(t)}_emitProgress(e,t){this.engine.events&&this.engine.events.trigger(Ve.ModelLoadProgress,{progress:e,text:t})}async buildScene(e){this._emitProgress(10,"正在加载"),this.font=await this.loadFont(),this.model.layers=e.layers,this.model.modelMap=new Map,this.model.hatchMap=new Map,this.model.textMap=new Map,this.model.nodeMap=new Map,console.log(this.model.layers),this._emitProgress(10,"正在加载..."),await Promise.resolve(),e.blocks.forEach(t=>{this.loadBlock(t,t.name,!0)}),this._emitProgress(10,"正在加载..."),await Promise.resolve(),this.loadBlock({entities:e.entities},"",!1),this._emitProgress(10,"正在加载..."),await Promise.resolve(),this.model.modelMap.forEach((t,n)=>{let i=[];if(t.forEach(o=>{for(const a of o)i.push(a)}),i.length!=0){const o=new w.BufferGeometry().setFromPoints(i);let a=parseInt(n.split("||")[1]);if(a==0){var s=this.model.layers.find(u=>u.name==n.split("||")[0]);a=s.color}const l=new w.LineBasicMaterial({color:a}),c=new w.LineSegments(o,l);c.name=n,c.clonePoints=[],i.forEach(u=>{c.clonePoints.push(u.x),c.clonePoints.push(u.y),c.clonePoints.push(u.z)}),c.materialClone=l.clone(),this.engine.modelGroup.add(c);let h=0;t.forEach((u,m)=>{this.model.nodeMap.has(m)?this.model.nodeMap.get(m).push({indexes:[this.engine.modelGroup.children.length-1,h,h+u.length*3],min:new w.Vector3(Math.min(...u.map(p=>p.x)),Math.min(...u.map(p=>p.y)),0),max:new w.Vector3(Math.max(...u.map(p=>p.x)),Math.max(...u.map(p=>p.y)),0)}):this.model.nodeMap.set(m,[{indexes:[this.engine.modelGroup.children.length-1,h,h+u.length*3],min:new w.Vector3(Math.min(...u.map(p=>p.x)),Math.min(...u.map(p=>p.y)),0),max:new w.Vector3(Math.max(...u.map(p=>p.x)),Math.max(...u.map(p=>p.y)),0)}]),h=h+u.length*3})}}),this._emitProgress(85,"正在加载..."),await Promise.resolve(),this.model.textMap.forEach((t,n)=>{const i=Zt(t.map(c=>c.geometry),!1);let s=Number.parseInt(n.split("||")[1]);if(s===0){const c=this.model.layers.find(h=>h.name===n.split("||")[0]);c&&(s=c.color)}const o=new w.MeshBasicMaterial({color:s,side:w.DoubleSide});n.includes("_hitbox")&&(o.visible=!1);let a=new w.Mesh(i,o);a.name=n,a.materialClone=o.clone(),a.isSplit=!1,a.geometrys=t.map(c=>c.geometry),this.engine.modelGroup.add(a);let l=0;t.forEach(c=>{this.model.nodeMap.has(c.info.linkId)?this.model.nodeMap.get(c.info.linkId).push({indexes:[this.engine.modelGroup.children.length-1,l++],min:new w.Vector3(c.info.min[0],c.info.min[1],0),max:new w.Vector3(c.info.max[0],c.info.max[1],0)}):this.model.nodeMap.set(c.info.linkId,[{indexes:[this.engine.modelGroup.children.length-1,l++],min:new w.Vector3(c.info.min[0],c.info.min[1],0),max:new w.Vector3(c.info.max[0],c.info.max[1],0)}])})}),this._emitProgress(93,"正在加载..."),await Promise.resolve(),this.model.hatchMap.forEach((t,n)=>{let i=Zt(t.map(h=>h.geometry),!1),s=parseInt(n.split("||")[1]);if(s==0){var o=this.model.layers.find(h=>h.name==n.split("||")[0]);s=o.color}const a=new w.MeshBasicMaterial({color:s,side:w.DoubleSide,transparent:!0,opacity:.5});let l=new w.Mesh(i,a);l.name=n,l.materialClone=a.clone(),l.isSplit=!1,l.geometrys=t.map(h=>h.geometry),this.engine.modelGroup.add(l);let c=0;t.forEach(h=>{this.model.nodeMap.has(h.info.linkId)?this.model.nodeMap.get(h.info.linkId).push({indexes:[this.engine.modelGroup.children.length-1,c++],min:new w.Vector3(h.info.min[0],h.info.min[1],0),max:new w.Vector3(h.info.max[0],h.info.max[1],0)}):this.model.nodeMap.set(h.info.linkId,[{indexes:[this.engine.modelGroup.children.length-1,c++],min:new w.Vector3(h.info.min[0],h.info.min[1],0),max:new w.Vector3(h.info.max[0],h.info.max[1],0)}])})}),this._emitProgress(100,"加载完成")}loadBlock(e,t,n,i=0){let s=[0,0,0];n&&(s=e.origin),e.entities.forEach(o=>{const a=o.layer+"||"+o.color;let l=new Map;n?(l=this.totalBlock.get(t),l==null&&(l=new Map,this.totalBlock.set(t,l))):(l=this.model.modelMap.get(a),l==null&&(l=new Map,this.model.modelMap.set(a,l)));let c=[];switch(o.type){case"LINE":c=this.getPoint_line(o,s);break;case"CIRCLE":c=this.getPoint_arc(o,s);break;case"POLYLINE":c=this.getPoint_polyline(o,s);break;case"MTEXT":this.create_text(o);break;case"HATCH":this.create_hatch(o);break;case"INSERT":if(n==!1){let h=this.totalBlock.get(o.blockId);h?.forEach(m=>{c.push(...m.map(p=>p.clone()))});const u=this.getMatrix(o.position,o.scale,o.rotation);c.forEach(m=>{m.applyMatrix4(u)})}break;default:return console.warn(`[LoaderModule2d] Unknown entity type: ${o.type}`),null}l.has(o.linkId)?l.get(o.linkId).push(...c):l.set(o.linkId,c)})}getPoint_polyline(e,t){let n=[];for(let i=0;i<e.points.length-1;i++)n.push(new w.Vector3(e.points[i].x,e.points[i].y,0)),n.push(new w.Vector3(e.points[i+1].x,e.points[i+1].y,0));return e.closed&&(n.push(new w.Vector3(e.points[e.points.length-1].x,e.points[e.points.length-1].y,0)),n.push(new w.Vector3(e.points[0].x,e.points[0].y,0))),n.forEach(i=>{i[0]=i[0]-t[0],i[1]=i[1]-t[1]}),n}create_hatch(e){if(!e.loops||e.loops.length===0)return;const t=e.loops.filter(a=>a.type===!0),n=e.loops.filter(a=>a.type===!1),i=[];for(const a of t){if(!a.points||a.points.length<3)continue;const l=new w.Shape;l.moveTo(a.points[0][0],a.points[0][1]);for(let c=1;c<a.points.length;c++)l.lineTo(a.points[c][0],a.points[c][1]);l.closePath();for(const c of n){if(!c.points||c.points.length<3)continue;const h=new w.Path;h.moveTo(c.points[0][0],c.points[0][1]);for(let u=1;u<c.points.length;u++)h.lineTo(c.points[u][0],c.points[u][1]);h.closePath(),l.holes.push(h)}i.push(new w.ShapeGeometry(l))}if(i.length===0)return;const s=i.length===1?i[0]:Zt(i,!1),o=e.layer+"||"+e.color;this.model.hatchMap.has(o)?this.model.hatchMap.get(o).push({geometry:s,info:e}):this.model.hatchMap.set(o,[{geometry:s,info:e}])}create_text(e){if(!this.font||!e.text)return;const t=new qu(e.text,{font:this.font,size:e.height??100,depth:0});e.position[1]=e.position[1]-e.height;const n=this.getMatrix(e.position,[1,1,1],e.rotation);t.applyMatrix4(n);const i=e.layer+"||"+e.color;this.model.textMap.has(i)?this.model.textMap.get(i).push({geometry:t,info:e}):this.model.textMap.set(i,[{geometry:t,info:e}]),t.computeBoundingBox();const s=t.boundingBox;if(s){const o=s.max.x-s.min.x,a=s.max.y-s.min.y,l=new w.PlaneGeometry(o,a);new w.MeshBasicMaterial({visible:!1,side:w.DoubleSide,depthWrite:!1});let c=[(s.min.x+s.max.x)/2,(s.min.y+s.max.y)/2,0],h=this.getMatrix(c,[1,1,1],0);l.applyMatrix4(h);const u=e.layer+"||"+e.color+"_hitbox";this.model.textMap.has(u)?this.model.textMap.get(u).push({geometry:l,info:e}):this.model.textMap.set(u,[{geometry:l,info:e}])}}getPoint_line(e,t){const n=new w.Vector3(e.startPoint[0],e.startPoint[1],e.startPoint[2]||0),i=new w.Vector3(e.endPoint[0],e.endPoint[1],e.endPoint[2]||0);let s=[n,i];return s.forEach(o=>{o[0]=o[0]-t[0],o[1]=o[1]-t[1]}),s}getPoint_arc(e,t){const n=e.center[0],i=e.center[1],s=e.radius,a=new w.EllipseCurve(n,i,s,s,e.startAngle,e.endAngle,!1,0).getPoints(30).map(c=>new w.Vector3(c.x,c.y,0));let l=[];for(let c=0;c<a.length-1;c++)l.push(a[c].clone()),l.push(a[c+1].clone());return l.forEach(c=>{c[0]=c[0]-t[0],c[1]=c[1]-t[1]}),l}getMatrix(e,t,n){const i=new w.Vector3(e[0],e[1],e[2]),s=new w.Euler(0,0,n),o=new w.Vector3(t[0],t[1],t[2]),a=new w.Quaternion;a.setFromEuler(s);const l=new w.Matrix4;return l.compose(i,a,o),l}getData(){return this.data}getEntitiesByLayer(e){return this.data?this.data.entities.filter(t=>t.layer===e):[]}getLayers(){return this.data?this.data.layers:[]}clear(){this.data=null}dispose(){this.clear()}}class nf{engine;sectionPlaneGroup=null;loaderModule2d;constructor(e){this.engine=e,this.loaderModule2d=new Jr(this.engine)}async attachSectionPlane(e,t,n,i){await this.loaderModule2d.loadModel(e+"/"+t,{chunkSize:1e3,enableChunkedLoading:!0,enableValidation:!0});let s=new w.Vector3(n.x,n.y,n.z),o=new w.Vector3(i.x,i.y,i.z);const a=new w.Vector3().copy(o);let l=s.clone().sub(this.engine.modelGroup.position.clone()).dot(o);this.engine.modelGroup.lookAt(a);let c=this.engine.modelGroup.position.clone().add(o.setLength(l));this.engine.modelGroup.position.set(c.x,c.y,c.z),console.log("绘制完成")}removeSectionPlane(){this.engine.scene.remove(this.engine.modelGroup)}getMatrix(e,t){const n=new w.Vector3(e.x,e.y,e.z),i=new w.Euler(t.x,t.y,t.z),s=new w.Vector3(1,1,1),o=new w.Quaternion;o.setFromEuler(i);const a=new w.Matrix4;return a.compose(n,o,s),a}computeMatrixFromOriginAndDirection(e,t){const n=new w.Matrix4,i=t.clone().normalize();if(i.length()===0)return console.warn("方向向量长度为零,返回单位矩阵"),n.identity();const s=new w.Vector3(0,1,0);let o=new w.Vector3().crossVectors(s,i);if(o.length()<1e-4){const c=new w.Vector3(0,0,1);o=new w.Vector3().crossVectors(c,i).normalize()}else o.normalize();const a=new w.Vector3().crossVectors(o,i).normalize(),l=new w.Matrix4;return l.set(o.x,i.x,a.x,0,o.y,i.y,a.y,0,o.z,i.z,a.z,0,0,0,0,1),l.setPosition(e),l}}class sf{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;viewTree;merge2d;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;ai;pathRoaming;hoverHighLight;minMap;grid;level;text;hdr;ground;skyManager;linkElement2d3d;linkView2d3d;oneClickEncoding;models=[];reactBoundingClientRect={left:0,top:0};version="3.2.0";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 uh(this),this.engineModelModule.init(),this.ai=new Ru(this),this.deviceModule=new aa(this),this.deviceType=this.deviceModule.getDeviceType(),this.cameraModule=new ra(this),this.sceneModule=new oa(this),this.scene=this.sceneModule.scene,this.renderModule=new la(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.controlModule=new Ta(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.composerModule=new Va(this),this.composerModule.init(),this.events=new oh,this.engineStatus=new sh(this),this.engineStatus.init(),this.loaderModule=new ih(this),this.lightModule=new rh(this),this.lightModule.init(),this.viewCube=new _h(this),this.viewCube.init(),this.options.showViewCube==!1&&this.viewCube.hide(),this.octreeBox=Sh(this),this.rangeScale=new Ch(this),this.rangeScale.init(),this.clipping=new ku(this),this.clipping.init(),this.setting=new Ah(this),this.setting.init(),this.engineModelModule.init(),this.handelBehaved=zi(this),this.modelMapperBatch=new Iu(this),this.measure=new Bh(this),this.modelToolModule=new lh(this),this.modelProperties=new Lu(this),this.interactionModule=new ah(this),this.interactionModule.init(),this.interactionModule.active(),this.hoverHighLight=new ti(this),this.modelEdge=new zu(this),this.modelTree=new Du(this),this.viewTree=new Ku(this),this.merge2d=new nf(this),this.engineInfo=new Eu(this),this.pathRoaming=new Ou(this),this.pathRoaming.init(),this.oneClickEncoding=new Yu(this),this.minMap=new Nu(this),this.linkElement2d3d=new Xu(this),this.linkView2d3d=new Zu(this),this.grid=new Fu(this),this.level=new Uu(this),this.text=new Vu(this),this.hdr=new Gu(this),this.ground=new Vs(this),this.ground.init(),this.skyManager=new Wu(this),this.worldToScreen=new _e(this.camera,this.renderer,this.scene),this.options.showStats&&(this.stats=new gh,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom));let t=document.createElement("div");t.className="versionText",this.versionEl=t,this.updateVersionDisplay(),this.container.appendChild(t);let n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.style.position="absolute",n.style.zIndex="1000",n.style.left="0px",n.style.top="0px",n.style.pointerEvents="none",this.container.appendChild(n),this.catchSvg=n,this.onWindowResize=()=>{this.handleWindowResize()},window.addEventListener("resize",this.onWindowResize);let i=this;this.controls.addEventListener("start",()=>{i.events.trigger(Kt.EngineBusy),i.container&&(i.container.style.cursor="none")}),this.controls.addEventListener("end",()=>{i.events.trigger(Kt.EngineFree),i.container&&(i.container.style.cursor="default")}),this.controls.addEventListener("change",()=>{const s=new w.Vector3;i.camera.getWorldDirection(s);const o=Math.atan2(s.x,-s.z);let a=new CustomEvent("D3ViewUpdate",{detail:{position:i.camera.position,rotation:o,type:i.camera.type}});window.dispatchEvent(a)}),this.animate=()=>{if(!this.isRenderingPaused)this.animationId=requestAnimationFrame(this.animate);else{this.animationId=null;return}this.stats&&this.stats.begin(),this.composerModule&&this.composerModule.composer.render(),this.viewCube&&this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.ground.update(),this.skyManager.update(),this.hoverHighLight.update(),this.controlModule.update(),this.minMap.update(),this.grid.update(),this.level.update(),this.text&&this.text.update(),this.stats&&this.stats.end(),this._fpsFrameCount++;const s=performance.now();if(s-this._fpsLastCheck>=this._fpsCheckInterval){const o=s-this._fpsLastCheck,a=this._fpsFrameCount/o*1e3;this._fpsFrameCount=0,this._fpsLastCheck=s,a<this._fpsThreshold?(this._lowFpsCount++,this._highFpsCount=0,this._lowFpsCount>=this._lowFpsRequired&&s-this._fpsLastSwitch>this._fpsSwitchCooldown&&(this._adaptiveRenderingDowngrade(),this._fpsLastSwitch=s,this._lowFpsCount=0)):a>this._fpsUpgradeThreshold?(this._highFpsCount++,this._lowFpsCount=0):(this._lowFpsCount=0,this._highFpsCount=0)}if(this.scene){let o=this.scene?.dirLight;o&&this.camera&&this.updateLightPosition(this.camera,o)}},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 w.Vector3;e.getWorldDirection(n);const i=100,s=new w.Vector3().copy(n).multiplyScalar(-i),o=new w.Vector3(0,1,0),a=new w.Vector3().crossVectors(n,o).normalize();s.addScaledVector(o,i*.5),s.addScaledVector(a,i*.3),t.position.copy(e.position).add(s);const l=new w.Vector3().copy(e.position).add(n.multiplyScalar(20));t.target.position.copy(l),t.target.updateMatrixWorld()}_adaptiveRenderingDowngrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n>0){const i=e[n-1];console.log(`[AdaptiveRendering] FPS低于${this._fpsThreshold},自动降级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}_adaptiveRenderingUpgrade(){const e=["simple","balance","advanced"],t=this.engineModelModule.getCurrentMode(),n=e.indexOf(t);if(n<e.length-1){const i=e[n+1];console.log(`[AdaptiveRendering] FPS高于${this._fpsUpgradeThreshold},自动升级: ${t} → ${i}`),this.engineModelModule.autoSwitch(i)}}pauseRendering(){if(this.isRenderingPaused){console.warn("[BimEngine] Rendering is already paused");return}this.isRenderingPaused=!0,this.controls&&(this.controlsEnabledBeforePause=this.controls.enabled,this.controls.enabled=!1)}resumeRendering(){if(!this.isRenderingPaused){console.warn("[BimEngine] Rendering is not paused");return}this.isRenderingPaused=!1,this.controls&&(this.controls.enabled=this.controlsEnabledBeforePause),this.animationId===null&&this.animate()}isRenderingPausedState(){return this.isRenderingPaused}handleWindowResize(e,t){if(!this.container||!this.renderer||!this.camera)return;if(e===void 0||t===void 0){const i=this.deviceModule.getContainerSize();e=e??i.width,t=t??i.height}if(!e||!t)return;this.renderer.setPixelRatio(window.devicePixelRatio),this.renderer.setSize(e,t);const n=e/t;if(this.camera===this.cameraModule.perspectiveCamera)this.cameraModule.perspectiveCamera.aspect=n,this.cameraModule.perspectiveCamera.updateProjectionMatrix(),this.camera=this.cameraModule.perspectiveCamera;else if(this.camera===this.cameraModule.orthographicCamera){const i=this.cameraModule.orthographicCamera,s=50,o=this.container.clientWidth/this.container.clientHeight;i.left=s*o/-2,i.right=s*o/2,i.top=s/2,i.bottom=s/-2,i.updateProjectionMatrix()}if(this.catchSvg){const i=this.container.clientWidth,s=this.container.clientHeight;this.catchSvg.setAttribute("viewBox",`0 0 ${i} ${s}`)}this.events&&this.events.trigger(Kt.ViewportResize,{width:e,height:t})}dispose(){console.log("[BimEngine] Starting engine disposal..."),this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.isRenderingPaused=!0,this.onWindowResize&&window.removeEventListener("resize",this.onWindowResize);try{this.measure&&(this.measure.disActive(),this.measure.clearAll(),this.measure.annotationContainer&&this.measure.annotationContainer.remove()),this.hdr&&this.hdr.dispose(),this.minMap&&this.minMap.dispose(),this.text&&this.text.dispose(),this.clipping&&this.clipping.disActive(),this.interactionModule&&this.interactionModule.disActive(),this.viewCube&&this.viewCube.cubeTool&&typeof this.viewCube.cubeTool.dispose=="function"&&this.viewCube.cubeTool.dispose()}catch(e){console.warn("[BimEngine] Error disposing managers:",e)}try{this.controlModule&&(this.controlModule.originDiv&&this.controlModule.originDiv.remove(),this.controlModule.orbitControls&&typeof this.controlModule.orbitControls.dispose=="function"&&this.controlModule.orbitControls.dispose(),this.controlModule.firstPersonControls&&typeof this.controlModule.firstPersonControls.dispose=="function"&&this.controlModule.firstPersonControls.dispose())}catch(e){console.warn("[BimEngine] Error disposing controls:",e)}this.scene&&this.clearScene(this.scene);try{this.composerModule&&this.composerModule.composer&&(this.composerModule.composer.passes&&this.composerModule.composer.passes.forEach(e=>{e.dispose&&e.dispose()}),this.composerModule.composer.renderTarget1&&this.composerModule.composer.renderTarget1.dispose(),this.composerModule.composer.renderTarget2&&this.composerModule.composer.renderTarget2.dispose())}catch(e){console.warn("[BimEngine] Error disposing composer:",e)}try{this.renderModule&&this.renderModule.disposeRenderer(),this.renderer&&(this.renderer.domElement&&this.renderer.domElement.parentElement&&this.renderer.domElement.parentElement.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss())}catch(e){console.warn("[BimEngine] Error disposing renderer:",e)}try{this.stats&&this.stats.dom&&this.stats.dom.parentElement&&this.stats.dom.parentElement.removeChild(this.stats.dom),this.catchSvg&&this.catchSvg.parentElement&&this.catchSvg.parentElement.removeChild(this.catchSvg)}catch(e){console.warn("[BimEngine] Error disposing DOM elements:",e)}try{this.events&&this.events.listeners&&this.events.listeners.clear()}catch(e){console.warn("[BimEngine] Error clearing event listeners:",e)}this.scene=null,this.camera=null,this.renderer=null,this.controls=null,this.models=[],this.container=null,console.log("[BimEngine] Engine disposal completed")}clearScene(e){if(!e)return;[...e.children].forEach(n=>{this.clearScene(n)}),e.parent&&e.parent.remove(e),e instanceof w.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 w.Line&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof w.Points&&(e.geometry&&e.geometry.dispose(),e.material&&this.disposeMaterial(e.material)),e instanceof w.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 w.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 w.Texture&&i.dispose()}),e.dispose()}}const of=`
|
|
1100
1337
|
varying vec2 vWorldPos;
|
|
1101
1338
|
|
|
1102
1339
|
void main() {
|
|
@@ -1104,7 +1341,7 @@ void main() {
|
|
|
1104
1341
|
vWorldPos = worldPosition.xy;
|
|
1105
1342
|
gl_Position = projectionMatrix * viewMatrix * worldPosition;
|
|
1106
1343
|
}
|
|
1107
|
-
`,
|
|
1344
|
+
`,rf=`
|
|
1108
1345
|
precision highp float;
|
|
1109
1346
|
|
|
1110
1347
|
varying vec2 vWorldPos;
|
|
@@ -1159,64 +1396,55 @@ void main() {
|
|
|
1159
1396
|
|
|
1160
1397
|
gl_FragColor = vec4(color, alpha);
|
|
1161
1398
|
}
|
|
1162
|
-
`;class Bd{scene;camera;container;gridGroup;gridGeometry;gridMaterial;gridMesh;animationFrameId=null;resizeObserver;windowResizeHandler;lastState={zoom:-1,centerX:Number.NaN,centerY:Number.NaN,viewWidth:0,viewHeight:0,containerWidth:0,containerHeight:0,minorSpacing:0};largeGridColor=6052956;smallGridColor=3815994;desiredMinorPixelSize=28;coverageMultiplier=1.6;minSpacing=1e-4;minorThicknessPx=.4;majorThicknessPx=.6;minorLineOpacity=.05;majorLineOpacity=.2;baseRenderOrder=-20;gridZOffset=-.001;majorStep=5;gridUniforms={minorSpacing:{value:100},majorStep:{value:this.majorStep},worldPerPixel:{value:new b.Vector2(1,1)},minorThicknessPx:{value:this.minorThicknessPx},majorThicknessPx:{value:this.majorThicknessPx},minorColor:{value:new b.Color(this.smallGridColor)},majorColor:{value:new b.Color(this.largeGridColor)},minorOpacity:{value:this.minorLineOpacity},majorOpacity:{value:this.majorLineOpacity}};constructor(e,t,n){this.scene=e,this.camera=t,this.container=n,this.gridGroup=new b.Group,this.gridGroup.name="AdaptiveGridGroup",this.gridGroup.renderOrder=this.baseRenderOrder,this.gridGroup.visible=!0,this.gridGroup.position.set(0,0,this.gridZOffset),this.scene.add(this.gridGroup),this.createGridMesh(),this.updateGrid(!0),this.startMonitoring(),this.setupResizeObserver()}createGridMesh(){this.gridGeometry=new b.PlaneGeometry(1,1,1,1),this.gridMaterial=new b.ShaderMaterial({uniforms:this.gridUniforms,vertexShader:Id,fragmentShader:zd,transparent:!0,depthWrite:!1,depthTest:!1,side:b.DoubleSide,toneMapped:!1}),this.gridMesh=new b.Mesh(this.gridGeometry,this.gridMaterial),this.gridMesh.frustumCulled=!1,this.gridMesh.renderOrder=this.baseRenderOrder,this.gridGroup.add(this.gridMesh)}startMonitoring(){const e=()=>{this.updateGrid(),this.animationFrameId=requestAnimationFrame(e)};e()}stopMonitoring(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}setupResizeObserver(){typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(()=>this.updateGrid(!0)),this.resizeObserver.observe(this.container)):(this.windowResizeHandler=()=>this.updateGrid(!0),window.addEventListener("resize",this.windowResizeHandler))}teardownResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0),this.windowResizeHandler&&(window.removeEventListener("resize",this.windowResizeHandler),this.windowResizeHandler=void 0)}normalizeSpacing(e){const t=Math.max(e,this.minSpacing),n=Math.floor(Math.log10(t)),i=Math.pow(10,n),s=[1,2,5,10];for(const r of s){const a=r*i;if(t<=a)return a}return 10*i}updateGrid(e=!1){if(!this.gridMesh)return;const t=Math.max(1,this.container.clientWidth),n=Math.max(1,this.container.clientHeight),i=this.camera.zoom,s=this.camera.right-this.camera.left,r=this.camera.top-this.camera.bottom,a=Math.max(this.minSpacing,s/i),l=Math.max(this.minSpacing,r/i),c=this.camera.position.x,h=this.camera.position.y,d=a/t,m=l/n,p=d*this.desiredMinorPixelSize,f=this.normalizeSpacing(p),u=this.lastState;if(!e){const v=Math.abs(i-u.zoom)/Math.max(1e-4,u.zoom||1)>.02,w=Math.abs(f-u.minorSpacing)>u.minorSpacing*.05,x=Math.abs(c-u.centerX)>Math.max(f*.5,.01),M=Math.abs(h-u.centerY)>Math.max(f*.5,.01),T=Math.abs(a-u.viewWidth)>u.viewWidth*.01,P=Math.abs(l-u.viewHeight)>u.viewHeight*.01,k=t!==u.containerWidth||n!==u.containerHeight;if(!(v||w||x||M||T||P||k))return}const g=a*this.coverageMultiplier,y=l*this.coverageMultiplier;this.gridMesh.scale.set(g,y,1),this.gridMesh.position.set(c,h,0),this.gridUniforms.minorSpacing.value=f,this.gridUniforms.worldPerPixel.value.set(d,m),this.lastState={zoom:i,centerX:c,centerY:h,viewWidth:a,viewHeight:l,containerWidth:t,containerHeight:n,minorSpacing:f}}setVisible(e){this.gridGroup.visible=e}setColors(e,t){this.largeGridColor=e,this.smallGridColor=t,this.gridUniforms.majorColor.value.setHex(e),this.gridUniforms.minorColor.value.setHex(t)}setOpacity(e,t){this.minorLineOpacity=Math.max(0,Math.min(1,e)),this.majorLineOpacity=Math.max(0,Math.min(1,t)),this.gridUniforms.minorOpacity.value=this.minorLineOpacity,this.gridUniforms.majorOpacity.value=this.majorLineOpacity}dispose(){this.stopMonitoring(),this.teardownResizeObserver(),this.gridMesh&&this.gridGroup.remove(this.gridMesh),this.gridGeometry&&(this.gridGeometry.dispose(),this.gridGeometry=void 0),this.gridMaterial&&(this.gridMaterial.dispose(),this.gridMaterial=void 0),this.gridMesh=void 0}}class Od{engine;scene;options;adaptiveGrid;axesHelper;constructor(e,t){this.engine=e,this.options=t,this.scene=this.createScene(),this.initHelpers()}createScene(){const e=new b.Scene,t=this.options.backgroundColor??1710618;return e.background=new b.Color(t),e.is2D=!0,e}initHelpers(){this.options.axesEnabled&&this.createAxes()}initGrid(){this.options.gridEnabled&&this.createGrid()}createGrid(e=1e3,t=50){this.adaptiveGrid&&(this.adaptiveGrid.dispose(),this.adaptiveGrid=void 0),this.adaptiveGrid=new Bd(this.scene,this.engine.cameraModule2d.orthographicCamera,this.engine.renderModule2d.container);const n=this.options.backgroundColor??1710618;this.updateGridColorsByBackground(n)}createAxes(e=100){this.axesHelper&&this.scene.remove(this.axesHelper),this.axesHelper=new b.AxesHelper(e),this.axesHelper.rotation.z=0,this.scene.add(this.axesHelper),this.scene.remove(this.axesHelper),this.scene.add(this.axesHelper),this.axesHelper.renderOrder=999}setBackgroundColor(e){this.scene.background=new b.Color(e),this.updateGridColorsByBackground(e)}updateGridColorsByBackground(e){if(!this.adaptiveGrid)return;const t=new b.Color(e);.299*t.r+.587*t.g+.114*t.b<.5?(this.adaptiveGrid.setColors(16777215,16777215),this.adaptiveGrid.setOpacity(.2,.3)):(this.adaptiveGrid.setColors(0,0),this.adaptiveGrid.setOpacity(.05,.2))}addObject(e){this.scene.add(e)}removeObject(e){this.scene.remove(e),e instanceof b.Mesh&&(e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}clearScene(){for(let e=this.scene.children.length-1;e>=0;e--){const t=this.scene.children[e];t!==this.axesHelper&&(this.adaptiveGrid||this.removeObject(t))}this.engine.events&&this.engine.events.trigger("scene-cleared")}getObjects(e=!1){const t=[];return this.scene.children.forEach(n=>{(e||n!==this.axesHelper)&&t.push(n)}),t}getSceneStats(){let e=0,t=0,n=0;return this.scene.children.forEach(i=>{i instanceof b.Mesh?e++:i instanceof b.Line?t++:i instanceof b.Group&&n++}),{objectCount:this.scene.children.length,meshCount:e,lineCount:t,groupCount:n}}setGridVisible(e){this.adaptiveGrid&&this.adaptiveGrid.setVisible(e)}setAxesVisible(e){this.axesHelper&&(this.axesHelper.visible=e)}dispose(){this.clearScene(),this.adaptiveGrid&&(this.adaptiveGrid.dispose(),this.adaptiveGrid=void 0),this.axesHelper&&(this.scene.remove(this.axesHelper),this.axesHelper=void 0),this.scene.clear()}}class Rd{engine;orthographicCamera;container;frustumSize=1e3;near=.1;far=1e4;initialZoom=1;defaultPosition=new b.Vector3(0,0,1e3);constructor(e,t){this.engine=e,this.container=t,this.orthographicCamera=this.createOrthographicCamera()}createOrthographicCamera(){const e=this.container.clientWidth/this.container.clientHeight,t=this.frustumSize/2,n=t*e,i=new b.OrthographicCamera(-n,n,t,-t,this.near,this.far);return i.position.copy(this.defaultPosition),i.lookAt(0,0,0),i.zoom=this.initialZoom,i.updateProjectionMatrix(),i}fitToExtents(e,t=1.2){const n=new b.Vector3(e.min[0],e.min[1]),i=new b.Vector3(e.max[0],e.max[1]);if(!(n.distanceTo(i)>.001)){console.warn("[CameraModule2d] Invalid extents, using default view"),this.resetView();return}const r=new b.Vector3;r.addVectors(n,i).multiplyScalar(.5);const a=new b.Vector3;a.subVectors(i,n);const c=Math.max(a.x,a.y)*t,h=this.container.clientWidth/this.container.clientHeight,d=c/2,m=d*h;this.orthographicCamera.left=-m,this.orthographicCamera.right=m,this.orthographicCamera.top=d,this.orthographicCamera.bottom=-d,this.orthographicCamera.position.set(r.x,r.y,this.defaultPosition.z),this.orthographicCamera.zoom=1,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("camera-changed",{type:"fit-to-extents",center:r,size:a})}setZoom(e){this.orthographicCamera.zoom=e,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("view-zoom-changed",{zoom:e})}getZoom(){return this.orthographicCamera.zoom}setPosition(e,t){this.orthographicCamera.position.set(e,t,this.defaultPosition.z),this.engine.events&&this.engine.events.trigger("view-pan-changed",{x:e,y:t})}getPosition(){return this.orthographicCamera.position.clone()}resetView(){this.orthographicCamera.position.copy(this.defaultPosition),this.orthographicCamera.zoom=this.initialZoom,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("camera-reset")}getViewBounds(){const e=this.orthographicCamera,t=e.zoom,n=e.left/t,i=e.right/t,s=e.top/t,r=e.bottom/t,a=e.position.x,l=e.position.y;return{minX:a+n,maxX:a+i,minY:l+r,maxY:l+s,width:i-n,height:s-r}}screenToWorld(e,t){const n=new b.Vector3(e/this.container.clientWidth*2-1,-(t/this.container.clientHeight)*2+1,.5);return n.unproject(this.orthographicCamera),n}worldToScreen(e,t){const n=new b.Vector3(e,t,0);return n.project(this.orthographicCamera),{x:(n.x+1)/2*this.container.clientWidth,y:-(n.y-1)/2*this.container.clientHeight}}updateAspectRatio(){const e=this.container.clientWidth/this.container.clientHeight,t=this.frustumSize/2,n=t*e;this.orthographicCamera.left=-n,this.orthographicCamera.right=n,this.orthographicCamera.top=t,this.orthographicCamera.bottom=-t,this.orthographicCamera.updateProjectionMatrix()}setFrustumSize(e){this.frustumSize=e,this.updateAspectRatio()}getFrustumSize(){return this.frustumSize}dispose(){this.orthographicCamera=null}}class Nd{engine;renderer;container;options;antialias=!0;alpha=!1;precision="highp";constructor(e,t,n){this.engine=e,this.container=t,this.options=n,this.renderer=this.createRenderer(),this.handleResize()}createRenderer(){const e=new b.WebGLRenderer({antialias:this.antialias,alpha:this.alpha,precision:this.precision}),t=this.container.clientWidth,n=this.container.clientHeight;return e.setSize(t,n),e.setPixelRatio(window.devicePixelRatio),e.autoClear=!0,e.sortObjects=!0,e.setClearColor(this.options.backgroundColor??1710618),this.container.appendChild(e.domElement),e}render(e,t){const n=performance.now();this.engine.events&&this.engine.events.trigger("render-start"),this.renderer.render(e,t);const i=performance.now()-n;this.engine.events&&this.engine.events.trigger("render-end",{renderTime:i})}handleResize(){window.addEventListener("resize",()=>{this.onWindowResize()})}onWindowResize(){const e=this.container.clientWidth,t=this.container.clientHeight;this.renderer.setSize(e,t),this.engine.cameraModule2d&&this.engine.cameraModule2d.updateAspectRatio(),this.engine.scene&&this.engine.camera&&this.render(this.engine.scene,this.engine.camera)}setSize(e,t){this.renderer.setSize(e,t),this.engine.cameraModule2d&&this.engine.cameraModule2d.updateAspectRatio()}getSize(){const e=this.renderer.getSize(new b.Vector2);return{width:e.x,height:e.y}}setBackgroundColor(e){this.renderer.setClearColor(new b.Color(e))}setPixelRatio(e){this.renderer.setPixelRatio(e)}getPixelRatio(){return this.renderer.getPixelRatio()}setAntialias(e){console.warn("Antialias cannot be changed after renderer creation")}clear(e=!0,t=!0,n=!1){this.renderer.clear(e,t,n)}getInfo(){const e=this.renderer.getContext();return{renderer:this.renderer.capabilities.isWebGL2?"WebGL 2.0":"WebGL 1.0",version:this.renderer.capabilities.getVersion(),vendor:this.renderer.capabilities.vendor,capabilities:{maxTextureSize:this.renderer.capabilities.maxTextureSize,maxRenderbufferSize:this.renderer.capabilities.maxRenderbufferSize,maxVertexAttribs:this.renderer.capabilities.maxVertexAttribs,maxVaryingVectors:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)}}}dispose(){window.removeEventListener("resize",this.onWindowResize.bind(this)),this.renderer.dispose(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.renderer=null}}class Fd extends b.EventDispatcher{object;domElement;enabled=!0;enableZoom=!0;enablePan=!0;enableDamping=!1;dampingFactor=.05;zoomSpeed=1;minZoom=0;maxZoom=1/0;isDragging=!1;mouseButton=-1;previousMousePosition=new b.Vector2;targetPosition=new b.Vector3;targetZoom=1;lastClickTime=0;doubleClickDelay=300;constructor(e,t){super(),this.object=e,this.domElement=t||document,this.targetPosition.copy(e.position),this.targetZoom=e.zoom,this.bindEvents()}bindEvents(){this.domElement.addEventListener("mousedown",this.onMouseDown.bind(this)),this.domElement.addEventListener("mousemove",this.onMouseMove.bind(this)),this.domElement.addEventListener("mouseup",this.onMouseUp.bind(this)),this.domElement.addEventListener("mouseleave",this.onMouseUp.bind(this)),this.domElement.addEventListener("wheel",this.onWheel.bind(this),{passive:!1}),this.domElement.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.domElement.addEventListener("click",this.onClick.bind(this)),this.domElement.addEventListener("touchstart",this.onTouchStart.bind(this),{passive:!1}),this.domElement.addEventListener("touchmove",this.onTouchMove.bind(this),{passive:!1}),this.domElement.addEventListener("touchend",this.onTouchEnd.bind(this)),this.domElement.addEventListener("contextmenu",e=>{e.preventDefault()})}onMouseDown(e){this.enabled&&this.enablePan&&(e.button===0||e.button===1)&&(this.isDragging=!0,this.mouseButton=e.button,this.previousMousePosition.set(e.clientX,e.clientY),this.dispatchEvent({type:"start"}))}onMouseMove(e){if(!this.enabled||!this.isDragging)return;const t=e.clientX-this.previousMousePosition.x,n=e.clientY-this.previousMousePosition.y,s=1/this.object.zoom,r=this.object.top-this.object.bottom,a=this.object.right-this.object.left,l=t/this.domElement.clientWidth*a*s,c=n/this.domElement.clientHeight*r*s;this.targetPosition.x-=l,this.targetPosition.y+=c,this.enableDamping||(this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix()),this.previousMousePosition.set(e.clientX,e.clientY),this.dispatchEvent({type:"change"})}onMouseUp(e){this.isDragging&&(this.isDragging=!1,this.mouseButton=-1,this.dispatchEvent({type:"end"}))}onWheel(e){if(!this.enabled||!this.enableZoom)return;e.preventDefault();const t=Math.pow(1.1,-Math.sign(e.deltaY)*this.zoomSpeed),n=this.targetZoom;this.targetZoom*=t,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom));const i=this.targetZoom,s=(this.object.right-this.object.left)/2,r=(this.object.top-this.object.bottom)/2,a=this.domElement.getBoundingClientRect(),l=(e.clientX-a.left)/a.width*2-1,c=-((e.clientY-a.top)/a.height)*2+1;this.targetPosition.x+=l*s*(1/n-1/i),this.targetPosition.y+=c*r*(1/n-1/i),this.enableDamping||(this.object.zoom=i,this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix()),this.dispatchEvent({type:"change"})}onDoubleClick(e){this.enabled&&this.dispatchEvent({type:"doubleClick",event:e})}onClick(e){const t=performance.now();t-this.lastClickTime<this.doubleClickDelay||(this.lastClickTime=t)}onTouchStart(e){if(!this.enabled||e.touches.length!==1)return;e.preventDefault();const t=e.touches[0];this.isDragging=!0,this.previousMousePosition.set(t.clientX,t.clientY),this.dispatchEvent({type:"start"})}onTouchMove(e){if(!this.enabled||!this.isDragging)return;e.preventDefault();const t=e.touches[0],n=t.clientX-this.previousMousePosition.x,i=t.clientY-this.previousMousePosition.y,r=1/this.object.zoom,a=this.object.top-this.object.bottom,l=this.object.right-this.object.left,c=n/this.domElement.clientWidth*l*r,h=i/this.domElement.clientHeight*a*r;this.targetPosition.x-=c,this.targetPosition.y+=h,this.enableDamping||this.object.position.copy(this.targetPosition),this.previousMousePosition.set(t.clientX,t.clientY),this.dispatchEvent({type:"change"})}onTouchEnd(e){this.isDragging&&(this.isDragging=!1,this.dispatchEvent({type:"end"}))}update(){if(this.enabled&&this.enableDamping){const e=1-this.dampingFactor;this.object.position.x+=(this.targetPosition.x-this.object.position.x)*e,this.object.position.y+=(this.targetPosition.y-this.object.position.y)*e,this.object.zoom+=(this.targetZoom-this.object.zoom)*e,this.object.updateProjectionMatrix()}}reset(){this.targetPosition.set(0,0,this.object.position.z),this.targetZoom=1,this.enableDamping||(this.object.position.copy(this.targetPosition),this.object.zoom=this.targetZoom,this.object.updateProjectionMatrix()),this.dispatchEvent({type:"reset"})}setPosition(e,t){this.targetPosition.set(e,t,this.object.position.z),this.enableDamping||this.object.position.copy(this.targetPosition),this.dispatchEvent({type:"change"})}setZoom(e){this.targetZoom=e,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom)),this.enableDamping||(this.object.zoom=this.targetZoom,this.object.updateProjectionMatrix()),this.dispatchEvent({type:"change"})}dispose(){this.enabled=!1,this.domElement.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.domElement.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.domElement.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.domElement.removeEventListener("mouseleave",this.onMouseUp.bind(this)),this.domElement.removeEventListener("wheel",this.onWheel.bind(this)),this.domElement.removeEventListener("dblclick",this.onDoubleClick.bind(this)),this.domElement.removeEventListener("click",this.onClick.bind(this)),this.domElement.removeEventListener("touchstart",this.onTouchStart.bind(this)),this.domElement.removeEventListener("touchmove",this.onTouchMove.bind(this)),this.domElement.removeEventListener("touchend",this.onTouchEnd.bind(this))}}class Ud{engine;panControls;isActive=!0;constructor(e){this.engine=e,this.panControls=this.createPanControls(),this.init()}init(){this.panControls.addEventListener("doubleClick",this.onDoubleClick.bind(this)),this.panControls.addEventListener("change",this.onChange.bind(this))}createPanControls(){const e=new Fd(this.engine.camera,this.engine.renderer.domElement);return e.enableZoom=!0,e.enablePan=!0,e.enableDamping=!0,e.dampingFactor=.05,e.zoomSpeed=1,e.minZoom=0,e.maxZoom=1/0,e}onDoubleClick(e){this.engine.cameraModule2d&&this.engine.cameraModule2d.resetView()}onChange(){this.engine.events&&this.engine.events.trigger("camera-changed",{type:"user-interaction"})}active(){this.isActive=!0,this.panControls.enabled=!0}disActive(){this.isActive=!1,this.panControls.enabled=!1}update(){this.isActive&&this.panControls.update()}reset(){this.panControls.reset()}setPosition(e,t){this.panControls.setPosition(e,t)}setZoom(e){this.panControls.setZoom(e)}getZoom(){return this.panControls.object.zoom}setEnableZoom(e){this.panControls.enableZoom=e}setEnablePan(e){this.panControls.enablePan=e}setEnableDamping(e){this.panControls.enableDamping=e}setDampingFactor(e){this.panControls.dampingFactor=Math.max(0,Math.min(e,1))}setZoomSpeed(e){this.panControls.zoomSpeed=Math.max(.1,e)}setZoomLimits(e,t){this.panControls.minZoom=e,this.panControls.maxZoom=t}dispose(){this.panControls.dispose(),this.panControls=null}}class Vd extends _.Loader{constructor(e){super(e)}load(e,t,n,i){const s=this,r=new _.FileLoader(this.manager);r.setPath(this.path),r.setRequestHeader(this.requestHeader),r.setWithCredentials(this.withCredentials),r.load(e,function(a){const l=s.parse(JSON.parse(a));t&&t(l)},n,i)}parse(e){return new jd(e)}}class jd{constructor(e){this.isFont=!0,this.type="Font",this.data=e}generateShapes(e,t=100,n="ltr"){const i=[],s=Gd(e,t,this.data,n);for(let r=0,a=s.length;r<a;r++)i.push(...s[r].toShapes());return i}}function Gd(o,e,t,n){const i=Array.from(o),s=e/t.resolution,r=(t.boundingBox.yMax-t.boundingBox.yMin+t.underlineThickness)*s,a=[];let l=0,c=0;(n=="rtl"||n=="tb")&&i.reverse();for(let h=0;h<i.length;h++){const d=i[h];if(d===`
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1399
|
+
`;class af{scene;camera;container;gridGroup;gridGeometry;gridMaterial;gridMesh;animationFrameId=null;resizeObserver;windowResizeHandler;lastState={zoom:-1,centerX:Number.NaN,centerY:Number.NaN,viewWidth:0,viewHeight:0,containerWidth:0,containerHeight:0,minorSpacing:0};largeGridColor=6052956;smallGridColor=3815994;desiredMinorPixelSize=28;coverageMultiplier=1.6;minSpacing=1e-4;minorThicknessPx=.4;majorThicknessPx=.6;minorLineOpacity=.05;majorLineOpacity=.2;baseRenderOrder=-20;gridZOffset=-.001;majorStep=5;gridUniforms={minorSpacing:{value:100},majorStep:{value:this.majorStep},worldPerPixel:{value:new w.Vector2(1,1)},minorThicknessPx:{value:this.minorThicknessPx},majorThicknessPx:{value:this.majorThicknessPx},minorColor:{value:new w.Color(this.smallGridColor)},majorColor:{value:new w.Color(this.largeGridColor)},minorOpacity:{value:this.minorLineOpacity},majorOpacity:{value:this.majorLineOpacity}};constructor(e,t,n){this.scene=e,this.camera=t,this.container=n,this.gridGroup=new w.Group,this.gridGroup.name="AdaptiveGridGroup",this.gridGroup.renderOrder=this.baseRenderOrder,this.gridGroup.visible=!0,this.gridGroup.position.set(0,0,this.gridZOffset),this.scene.add(this.gridGroup),this.createGridMesh(),this.updateGrid(!0),this.startMonitoring(),this.setupResizeObserver()}createGridMesh(){this.gridGeometry=new w.PlaneGeometry(1,1,1,1),this.gridMaterial=new w.ShaderMaterial({uniforms:this.gridUniforms,vertexShader:of,fragmentShader:rf,transparent:!0,depthWrite:!1,depthTest:!1,side:w.DoubleSide,toneMapped:!1}),this.gridMesh=new w.Mesh(this.gridGeometry,this.gridMaterial),this.gridMesh.frustumCulled=!1,this.gridMesh.renderOrder=this.baseRenderOrder,this.gridGroup.add(this.gridMesh)}startMonitoring(){const e=()=>{this.updateGrid(),this.animationFrameId=requestAnimationFrame(e)};e()}stopMonitoring(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}setupResizeObserver(){typeof ResizeObserver<"u"?(this.resizeObserver=new ResizeObserver(()=>this.updateGrid(!0)),this.resizeObserver.observe(this.container)):(this.windowResizeHandler=()=>this.updateGrid(!0),window.addEventListener("resize",this.windowResizeHandler))}teardownResizeObserver(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=void 0),this.windowResizeHandler&&(window.removeEventListener("resize",this.windowResizeHandler),this.windowResizeHandler=void 0)}normalizeSpacing(e){const t=Math.max(e,this.minSpacing),n=Math.floor(Math.log10(t)),i=Math.pow(10,n),s=[1,2,5,10];for(const o of s){const a=o*i;if(t<=a)return a}return 10*i}updateGrid(e=!1){if(!this.gridMesh)return;const t=Math.max(1,this.container.clientWidth),n=Math.max(1,this.container.clientHeight),i=this.camera.zoom,s=this.camera.right-this.camera.left,o=this.camera.top-this.camera.bottom,a=Math.max(this.minSpacing,s/i),l=Math.max(this.minSpacing,o/i),c=this.camera.position.x,h=this.camera.position.y,u=a/t,m=l/n,p=u*this.desiredMinorPixelSize,f=this.normalizeSpacing(p),d=this.lastState;if(!e){const v=Math.abs(i-d.zoom)/Math.max(1e-4,d.zoom||1)>.02,x=Math.abs(f-d.minorSpacing)>d.minorSpacing*.05,b=Math.abs(c-d.centerX)>Math.max(f*.5,.01),_=Math.abs(h-d.centerY)>Math.max(f*.5,.01),T=Math.abs(a-d.viewWidth)>d.viewWidth*.01,P=Math.abs(l-d.viewHeight)>d.viewHeight*.01,D=t!==d.containerWidth||n!==d.containerHeight;if(!(v||x||b||_||T||P||D))return}const g=a*this.coverageMultiplier,y=l*this.coverageMultiplier;this.gridMesh.scale.set(g,y,1),this.gridMesh.position.set(c,h,0),this.gridUniforms.minorSpacing.value=f,this.gridUniforms.worldPerPixel.value.set(u,m),this.lastState={zoom:i,centerX:c,centerY:h,viewWidth:a,viewHeight:l,containerWidth:t,containerHeight:n,minorSpacing:f}}setVisible(e){this.gridGroup.visible=e}setColors(e,t){this.largeGridColor=e,this.smallGridColor=t,this.gridUniforms.majorColor.value.setHex(e),this.gridUniforms.minorColor.value.setHex(t)}setOpacity(e,t){this.minorLineOpacity=Math.max(0,Math.min(1,e)),this.majorLineOpacity=Math.max(0,Math.min(1,t)),this.gridUniforms.minorOpacity.value=this.minorLineOpacity,this.gridUniforms.majorOpacity.value=this.majorLineOpacity}dispose(){this.stopMonitoring(),this.teardownResizeObserver(),this.gridMesh&&this.gridGroup.remove(this.gridMesh),this.gridGeometry&&(this.gridGeometry.dispose(),this.gridGeometry=void 0),this.gridMaterial&&(this.gridMaterial.dispose(),this.gridMaterial=void 0),this.gridMesh=void 0}}class lf{engine;scene;options;adaptiveGrid;axesHelper;constructor(e,t){this.engine=e,this.options=t,this.scene=this.createScene(),this.initHelpers()}createScene(){const e=new w.Scene,t=this.options.backgroundColor??1710618;return e.background=new w.Color(t),e.is2D=!0,e}initHelpers(){this.options.axesEnabled&&this.createAxes()}initGrid(){this.options.gridEnabled&&this.createGrid()}createGrid(e=1e3,t=50){this.adaptiveGrid&&(this.adaptiveGrid.dispose(),this.adaptiveGrid=void 0),this.adaptiveGrid=new af(this.scene,this.engine.cameraModule2d.orthographicCamera,this.engine.renderModule2d.container);const n=this.options.backgroundColor??1710618;this.updateGridColorsByBackground(n)}createAxes(e=100){this.axesHelper&&this.scene.remove(this.axesHelper),this.axesHelper=new w.AxesHelper(e),this.axesHelper.rotation.z=0,this.scene.add(this.axesHelper),this.scene.remove(this.axesHelper),this.scene.add(this.axesHelper),this.axesHelper.renderOrder=999}setBackgroundColor(e){this.scene.background=new w.Color(e),this.updateGridColorsByBackground(e)}updateGridColorsByBackground(e){if(!this.adaptiveGrid)return;const t=new w.Color(e);.299*t.r+.587*t.g+.114*t.b<.5?(this.adaptiveGrid.setColors(16777215,16777215),this.adaptiveGrid.setOpacity(.2,.3)):(this.adaptiveGrid.setColors(0,0),this.adaptiveGrid.setOpacity(.05,.2))}addObject(e){this.scene.add(e)}removeObject(e){this.scene.remove(e),e instanceof w.Mesh&&(e.geometry.dispose(),Array.isArray(e.material)?e.material.forEach(t=>t.dispose()):e.material.dispose())}clearScene(){for(let e=this.scene.children.length-1;e>=0;e--){const t=this.scene.children[e];t!==this.axesHelper&&(this.adaptiveGrid||this.removeObject(t))}this.engine.events&&this.engine.events.trigger("scene-cleared")}getObjects(e=!1){const t=[];return this.scene.children.forEach(n=>{(e||n!==this.axesHelper)&&t.push(n)}),t}getSceneStats(){let e=0,t=0,n=0;return this.scene.children.forEach(i=>{i instanceof w.Mesh?e++:i instanceof w.Line?t++:i instanceof w.Group&&n++}),{objectCount:this.scene.children.length,meshCount:e,lineCount:t,groupCount:n}}setGridVisible(e){this.adaptiveGrid&&this.adaptiveGrid.setVisible(e)}setAxesVisible(e){this.axesHelper&&(this.axesHelper.visible=e)}dispose(){this.clearScene(),this.adaptiveGrid&&(this.adaptiveGrid.dispose(),this.adaptiveGrid=void 0),this.axesHelper&&(this.scene.remove(this.axesHelper),this.axesHelper=void 0),this.scene.clear()}}class cf{engine;isFree;highlightModels;highlightHoverModels;hideModels;translucentModels;models;constructor(e){this.engine=e,this.isFree=!0,this.highlightModels=[],this.hideModels=[],this.translucentModels=[],this.highlightHoverModels=[],this.models=[]}}class hf{engine;orthographicCamera;container;frustumSize=1e3;near=.1;far=1e4;initialZoom=1;defaultPosition=new w.Vector3(0,0,1e3);constructor(e,t){this.engine=e,this.container=t,this.orthographicCamera=this.createOrthographicCamera()}createOrthographicCamera(){const e=this.container.clientWidth/this.container.clientHeight,t=this.frustumSize/2,n=t*e,i=new w.OrthographicCamera(-n,n,t,-t,this.near,this.far);return i.position.copy(this.defaultPosition),i.lookAt(0,0,0),i.zoom=this.initialZoom,i.updateProjectionMatrix(),i}animationId=null;animationStartTime=0;animationDuration=800;animationStartState={};animationTargetState={};fitToExtents(e,t=1.2,n=!0,i=800){const s=new w.Vector3(e.min[0],e.min[1]),o=new w.Vector3(e.max[0],e.max[1]);if(!(s.distanceTo(o)>.001)){console.warn("[CameraModule2d] Invalid extents, using default view"),this.resetView();return}const l=new w.Vector3;l.addVectors(s,o).multiplyScalar(.5);const c=new w.Vector3;c.subVectors(o,s);const u=Math.max(c.x,c.y)*t,m=this.container.clientWidth/this.container.clientHeight,p=u/2,f=p*m,d=-f,g=f,y=p,v=-p,x=l.x,b=l.y,_=1;if(!n){this.orthographicCamera.left=d,this.orthographicCamera.right=g,this.orthographicCamera.top=y,this.orthographicCamera.bottom=v,this.orthographicCamera.position.set(x,b,this.defaultPosition.z),this.orthographicCamera.zoom=_,this.orthographicCamera.updateProjectionMatrix(),this.engine.controlModule2d?.panControls&&(this.engine.controlModule2d.panControls.setPosition(x,b),this.engine.controlModule2d.panControls.setZoom(_)),this.engine.events&&this.engine.events.trigger("camera-changed",{type:"fit-to-extents",center:l,size:c});return}this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.animationStartState={left:this.orthographicCamera.left,right:this.orthographicCamera.right,top:this.orthographicCamera.top,bottom:this.orthographicCamera.bottom,x:this.orthographicCamera.position.x,y:this.orthographicCamera.position.y,zoom:this.orthographicCamera.zoom},this.animationTargetState={left:d,right:g,top:y,bottom:v,x,y:b,zoom:_},this.animationDuration=i,this.animationStartTime=performance.now(),this.animateFitToExtents(l,c)}easeOutCubic(e){return 1-Math.pow(1-e,3)}animateFitToExtents(e,t){const i=performance.now()-this.animationStartTime,s=Math.min(i/this.animationDuration,1),o=this.easeOutCubic(s),a=this.animationStartState,l=this.animationTargetState;this.orthographicCamera.left=this.lerp(a.left,l.left,o),this.orthographicCamera.right=this.lerp(a.right,l.right,o),this.orthographicCamera.top=this.lerp(a.top,l.top,o),this.orthographicCamera.bottom=this.lerp(a.bottom,l.bottom,o),this.orthographicCamera.position.x=this.lerp(a.x,l.x,o),this.orthographicCamera.position.y=this.lerp(a.y,l.y,o),this.orthographicCamera.zoom=this.lerp(a.zoom,l.zoom,o),this.orthographicCamera.updateProjectionMatrix(),this.engine.controlModule2d?.panControls&&(this.engine.controlModule2d.panControls.setPosition(this.orthographicCamera.position.x,this.orthographicCamera.position.y),this.engine.controlModule2d.panControls.setZoom(this.orthographicCamera.zoom)),this.engine.events&&this.engine.events.trigger("camera-changed",{type:"fit-to-extents",center:e,size:t,progress:o}),s<1?this.animationId=requestAnimationFrame(()=>this.animateFitToExtents(e,t)):this.animationId=null}lerp(e,t,n){return e+(t-e)*n}setZoom(e){this.orthographicCamera.zoom=e,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("view-zoom-changed",{zoom:e})}getZoom(){return this.orthographicCamera.zoom}setPosition(e,t){this.orthographicCamera.position.set(e,t,this.defaultPosition.z),this.engine.events&&this.engine.events.trigger("view-pan-changed",{x:e,y:t})}getPosition(){return this.orthographicCamera.position.clone()}resetView(){this.orthographicCamera.position.copy(this.defaultPosition),this.orthographicCamera.zoom=this.initialZoom,this.orthographicCamera.updateProjectionMatrix(),this.engine.events&&this.engine.events.trigger("camera-reset")}getViewBounds(){const e=this.orthographicCamera,t=e.zoom,n=e.left/t,i=e.right/t,s=e.top/t,o=e.bottom/t,a=e.position.x,l=e.position.y;return{minX:a+n,maxX:a+i,minY:l+o,maxY:l+s,width:i-n,height:s-o}}screenToWorld(e,t){const n=new w.Vector3(e/this.container.clientWidth*2-1,-(t/this.container.clientHeight)*2+1,.5);return n.unproject(this.orthographicCamera),n}worldToScreen(e,t){const n=new w.Vector3(e,t,0);return n.project(this.orthographicCamera),{x:(n.x+1)/2*this.container.clientWidth,y:-(n.y-1)/2*this.container.clientHeight}}updateAspectRatio(){const e=this.container.clientWidth/this.container.clientHeight,t=this.frustumSize/2,n=t*e;this.orthographicCamera.left=-n,this.orthographicCamera.right=n,this.orthographicCamera.top=t,this.orthographicCamera.bottom=-t,this.orthographicCamera.updateProjectionMatrix()}setFrustumSize(e){this.frustumSize=e,this.updateAspectRatio()}getFrustumSize(){return this.frustumSize}dispose(){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),this.orthographicCamera=null}}class df{engine;renderer;container;options;antialias=!0;alpha=!1;precision="highp";constructor(e,t,n){this.engine=e,this.container=t,this.options=n,this.renderer=this.createRenderer(),this.handleResize()}createRenderer(){const e=new w.WebGLRenderer({antialias:this.antialias,alpha:this.alpha,precision:this.precision}),t=this.container.clientWidth,n=this.container.clientHeight;return e.setSize(t,n),e.setPixelRatio(window.devicePixelRatio),e.autoClear=!0,e.sortObjects=!0,e.setClearColor(this.options.backgroundColor??1710618),this.container.appendChild(e.domElement),e}render(e,t){const n=performance.now();this.engine.events&&this.engine.events.trigger("render-start"),this.renderer.render(e,t);const i=performance.now()-n;this.engine.events&&this.engine.events.trigger("render-end",{renderTime:i})}handleResize(){window.addEventListener("resize",()=>{this.onWindowResize()})}onWindowResize(){const e=this.container.clientWidth,t=this.container.clientHeight;this.renderer.setSize(e,t),this.engine.cameraModule2d&&this.engine.cameraModule2d.updateAspectRatio(),this.engine.scene&&this.engine.camera&&this.render(this.engine.scene,this.engine.camera)}setSize(e,t){this.renderer.setSize(e,t),this.engine.cameraModule2d&&this.engine.cameraModule2d.updateAspectRatio()}getSize(){const e=this.renderer.getSize(new w.Vector2);return{width:e.x,height:e.y}}setBackgroundColor(e){this.renderer.setClearColor(new w.Color(e))}setPixelRatio(e){this.renderer.setPixelRatio(e)}getPixelRatio(){return this.renderer.getPixelRatio()}setAntialias(e){console.warn("Antialias cannot be changed after renderer creation")}clear(e=!0,t=!0,n=!1){this.renderer.clear(e,t,n)}getInfo(){const e=this.renderer.getContext();return{renderer:this.renderer.capabilities.isWebGL2?"WebGL 2.0":"WebGL 1.0",version:this.renderer.capabilities.getVersion(),vendor:this.renderer.capabilities.vendor,capabilities:{maxTextureSize:this.renderer.capabilities.maxTextureSize,maxRenderbufferSize:this.renderer.capabilities.maxRenderbufferSize,maxVertexAttribs:this.renderer.capabilities.maxVertexAttribs,maxVaryingVectors:e.getParameter(e.MAX_VARYING_VECTORS),maxFragmentUniforms:e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniforms:e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)}}}dispose(){window.removeEventListener("resize",this.onWindowResize.bind(this)),this.renderer.dispose(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.renderer=null}}class uf extends w.EventDispatcher{object;domElement;enabled=!0;enableZoom=!0;enablePan=!0;enableDamping=!1;dampingFactor=.05;zoomSpeed=1;minZoom=0;maxZoom=1/0;isDragging=!1;mouseButton=-1;previousMousePosition=new w.Vector2;targetPosition=new w.Vector3;targetZoom=1;lastClickTime=0;doubleClickDelay=300;constructor(e,t){super(),this.object=e,this.domElement=t||document,this.targetPosition.copy(e.position),this.targetZoom=e.zoom,this.bindEvents()}bindEvents(){this.domElement.addEventListener("mousedown",this.onMouseDown.bind(this)),this.domElement.addEventListener("mousemove",this.onMouseMove.bind(this)),this.domElement.addEventListener("mouseup",this.onMouseUp.bind(this)),this.domElement.addEventListener("mouseleave",this.onMouseUp.bind(this)),this.domElement.addEventListener("wheel",this.onWheel.bind(this),{passive:!1}),this.domElement.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.domElement.addEventListener("click",this.onClick.bind(this)),this.domElement.addEventListener("touchstart",this.onTouchStart.bind(this),{passive:!1}),this.domElement.addEventListener("touchmove",this.onTouchMove.bind(this),{passive:!1}),this.domElement.addEventListener("touchend",this.onTouchEnd.bind(this)),this.domElement.addEventListener("contextmenu",e=>{e.preventDefault()})}onMouseDown(e){this.enabled&&this.enablePan&&(e.button===0||e.button===1)&&(this.isDragging=!0,this.mouseButton=e.button,this.previousMousePosition.set(e.clientX,e.clientY),this.dispatchEvent({type:"start"}))}onMouseMove(e){if(!this.enabled||!this.isDragging)return;const t=e.clientX-this.previousMousePosition.x,n=e.clientY-this.previousMousePosition.y,s=1/this.object.zoom,o=this.object.top-this.object.bottom,a=this.object.right-this.object.left,l=t/this.domElement.clientWidth*a*s,c=n/this.domElement.clientHeight*o*s;this.targetPosition.x-=l,this.targetPosition.y+=c,this.enableDamping||(this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix()),this.previousMousePosition.set(e.clientX,e.clientY),this.dispatchEvent({type:"change"})}onMouseUp(e){this.isDragging&&(this.isDragging=!1,this.mouseButton=-1,this.dispatchEvent({type:"end"}))}onWheel(e){if(!this.enabled||!this.enableZoom)return;e.preventDefault();const t=Math.pow(1.1,-Math.sign(e.deltaY)*this.zoomSpeed),n=this.targetZoom;this.targetZoom*=t,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom));const i=this.targetZoom,s=(this.object.right-this.object.left)/2,o=(this.object.top-this.object.bottom)/2,a=this.domElement.getBoundingClientRect(),l=(e.clientX-a.left)/a.width*2-1,c=-((e.clientY-a.top)/a.height)*2+1;this.targetPosition.x+=l*s*(1/n-1/i),this.targetPosition.y+=c*o*(1/n-1/i),this.enableDamping||(this.object.zoom=i,this.object.position.copy(this.targetPosition),this.object.updateProjectionMatrix()),this.dispatchEvent({type:"change"})}onDoubleClick(e){this.enabled&&this.dispatchEvent({type:"doubleClick",event:e})}onClick(e){const t=performance.now();t-this.lastClickTime<this.doubleClickDelay||(this.lastClickTime=t)}onTouchStart(e){if(!this.enabled||e.touches.length!==1)return;e.preventDefault();const t=e.touches[0];this.isDragging=!0,this.previousMousePosition.set(t.clientX,t.clientY),this.dispatchEvent({type:"start"})}onTouchMove(e){if(!this.enabled||!this.isDragging)return;e.preventDefault();const t=e.touches[0],n=t.clientX-this.previousMousePosition.x,i=t.clientY-this.previousMousePosition.y,o=1/this.object.zoom,a=this.object.top-this.object.bottom,l=this.object.right-this.object.left,c=n/this.domElement.clientWidth*l*o,h=i/this.domElement.clientHeight*a*o;this.targetPosition.x-=c,this.targetPosition.y+=h,this.enableDamping||this.object.position.copy(this.targetPosition),this.previousMousePosition.set(t.clientX,t.clientY),this.dispatchEvent({type:"change"})}onTouchEnd(e){this.isDragging&&(this.isDragging=!1,this.dispatchEvent({type:"end"}))}update(){if(this.enabled&&this.enableDamping){const e=1-this.dampingFactor;this.object.position.x+=(this.targetPosition.x-this.object.position.x)*e,this.object.position.y+=(this.targetPosition.y-this.object.position.y)*e,this.object.zoom+=(this.targetZoom-this.object.zoom)*e,this.object.updateProjectionMatrix()}}reset(){this.targetPosition.set(0,0,this.object.position.z),this.targetZoom=1,this.enableDamping||(this.object.position.copy(this.targetPosition),this.object.zoom=this.targetZoom,this.object.updateProjectionMatrix()),this.dispatchEvent({type:"reset"})}setPosition(e,t){this.targetPosition.set(e,t,this.object.position.z),this.enableDamping||this.object.position.copy(this.targetPosition),this.dispatchEvent({type:"change"})}setZoom(e){this.targetZoom=e,this.minZoom>0&&(this.targetZoom=Math.max(this.minZoom,this.targetZoom)),this.maxZoom!==1/0&&(this.targetZoom=Math.min(this.targetZoom,this.maxZoom)),this.enableDamping||(this.object.zoom=this.targetZoom,this.object.updateProjectionMatrix()),this.dispatchEvent({type:"change"})}dispose(){this.enabled=!1,this.domElement.removeEventListener("mousedown",this.onMouseDown.bind(this)),this.domElement.removeEventListener("mousemove",this.onMouseMove.bind(this)),this.domElement.removeEventListener("mouseup",this.onMouseUp.bind(this)),this.domElement.removeEventListener("mouseleave",this.onMouseUp.bind(this)),this.domElement.removeEventListener("wheel",this.onWheel.bind(this)),this.domElement.removeEventListener("dblclick",this.onDoubleClick.bind(this)),this.domElement.removeEventListener("click",this.onClick.bind(this)),this.domElement.removeEventListener("touchstart",this.onTouchStart.bind(this)),this.domElement.removeEventListener("touchmove",this.onTouchMove.bind(this)),this.domElement.removeEventListener("touchend",this.onTouchEnd.bind(this))}}class ff{engine;panControls;isActive=!0;constructor(e){this.engine=e,this.panControls=this.createPanControls(),this.init()}init(){this.panControls.addEventListener("doubleClick",this.onDoubleClick.bind(this)),this.panControls.addEventListener("change",this.onChange.bind(this))}createPanControls(){const e=new uf(this.engine.camera,this.engine.renderer.domElement);return e.enableZoom=!0,e.enablePan=!0,e.enableDamping=!0,e.dampingFactor=.05,e.zoomSpeed=1,e.minZoom=0,e.maxZoom=1/0,e}onDoubleClick(e){this.engine.cameraModule2d&&this.engine.cameraModule2d.resetView()}onChange(){this.engine.events&&this.engine.events.trigger("camera-changed",{type:"user-interaction"})}active(){this.isActive=!0,this.panControls.enabled=!0}disActive(){this.isActive=!1,this.panControls.enabled=!1}update(){this.isActive&&this.panControls.update()}reset(){this.panControls.reset()}setPosition(e,t){this.panControls.setPosition(e,t)}setZoom(e){this.panControls.setZoom(e)}getZoom(){return this.panControls.object.zoom}setEnableZoom(e){this.panControls.enableZoom=e}setEnablePan(e){this.panControls.enablePan=e}setEnableDamping(e){this.panControls.enableDamping=e}setDampingFactor(e){this.panControls.dampingFactor=Math.max(0,Math.min(e,1))}setZoomSpeed(e){this.panControls.zoomSpeed=Math.max(.1,e)}setZoomLimits(e,t){this.panControls.minZoom=e,this.panControls.maxZoom=t}dispose(){this.panControls.dispose(),this.panControls=null}}class pf{engine;pickBoxElementIds=[];worldToScreen;constructor(e){this.engine=e,this.pickBoxElementIds=[],this.worldToScreen=new _e(e.camera,e.renderer,e.scene)}init(){this.pickBoxElementIds=[]}pick2d(e,t){let n=[],i=new w.Vector2(t.offsetX,t.offsetY);this.init(),this.RecurrentIteration(e,this.engine.dwgData.octree);let s=[];this.pickBoxElementIds.forEach(l=>{this.engine.loaderModule2d.model.nodeMap.get(l).forEach(h=>{if(h!=null){let m=this.engine.modelGroup.children[h.indexes[0]];if(m!=null)if(m instanceof w.LineSegments){let p=new w.Box3(h.min,h.max),f=e.ray.intersectsBox(p);if(f!=null&&f!=!1){var u=this.engine.modelGroup.children[h.indexes[0]].clonePoints.slice(h.indexes[1],h.indexes[2]);let d=[],g=[];for(let v=0;v<u.length/3;v++)d.push(new w.Vector3(u[v*3],u[v*3+1],u[v*3+2]));for(let v=0;v<d.length/2;v++)g.push([d[v*2],d[v*2+1]]);g=g.filter(v=>v[0].distanceTo(v[1])>.001);let y=[];d.forEach(v=>{let x=this.worldToScreen.worldToScreen(v);y.push(x)});for(let v=0;v<y.length/2;v++)g.push([y[v*2],y[v*2+1]]);g=g.filter(v=>v[0].distanceTo(v[1])>1),g=g.filter(v=>a(i,v[0],v[1])<10),g.length>0&&g.forEach(v=>{s.push({distance:a(i,v[0],v[1]),linkId:l})})}}else{let p=m.geometrys[h.indexes[1]];const f=new w.MeshBasicMaterial;let d=new w.Mesh(p,f);d.linkId=l,n.push(d)}}})});const o=e.intersectObjects(n,!0);if(o.length>0)return o[0].object.linkId;if(s.length>0)return s[0].linkId;return null;function a(l,c,h){const u=new w.Vector2().subVectors(h,c),m=u.lengthSq();if(m<1e-10)return l.distanceTo(c);const p=new w.Vector2().subVectors(l,c),f=w.MathUtils.clamp(p.dot(u)/m,0,1),d=new w.Vector2().copy(u).multiplyScalar(f).add(c);return l.distanceTo(d)}}RecurrentIteration(e,t){if(t==null)return;let n=new w.Vector3(t.min.X,t.min.Y,0),i=new w.Vector3(t.max.X,t.max.Y,0),s=new w.Vector3(Math.min(n.x,i.x),Math.min(n.y,i.y),Math.min(n.z,i.z)),o=new w.Vector3(Math.max(i.x,n.x),Math.max(i.y,n.y),Math.max(i.z,n.z)),a=new w.Box3(s,o),l=e.ray.intersectsBox(a);if(!(l==null||l==!1))if(t.children==null||t.children.length==0){if(t.elements!=null)for(var c of t.elements){let h=this.engine.engineStatus2d.hideModels;h!=null&&h.includes(c)||(h=this.engine.engineStatus2d.highlightModels,!(h!=null&&h.includes(c))&&this.pickBoxElementIds.push(c))}}else{if(t.elements!=null)for(var c of t.elements){let u=this.engine.engineStatus2d.hideModels;u!=null&&u.includes(c)||(u=this.engine.engineStatus2d.highlightModels,!(u!=null&&u.includes(c))&&this.pickBoxElementIds.push(c))}for(let h of t.children)this.RecurrentIteration(e,h)}}}class mf{engine;widgetContainer=null;widgetCanvas=null;widgetCtx=null;widgetSize=50;isDragging=!1;isRotating=!1;lastMouseX=0;lastMouseY=0;widgetX=this.widgetSize/2+5;widgetY=this.widgetSize/2+5;widgetRotation=0;rotationStartAngle=null;widgetRotationStart=0;worldToScreen;currentWordPosition=null;currentWordRotation=null;lastCameraWorldPosition=null;enabled=!0;constructor(e){this.engine=e,this.worldToScreen=new _e(e.camera,e.renderer,e.scene),this.initWidget(),this.active();let t=this;this.engine.controlModule2d.panControls.addEventListener("change",()=>{t.updateViewPoint()})}toggle(){return this.enabled=!this.enabled,this.enabled?(this.active(),this.widgetContainer&&(this.widgetContainer.style.display="block")):(this.disActive(),this.widgetContainer&&(this.widgetContainer.style.display="none")),this.enabled}isEnabled(){return this.enabled}initWidget(){const e=window.devicePixelRatio||1;this.widgetContainer=document.createElement("div"),this.widgetContainer.className="MapController",this.widgetContainer.style.position="absolute",this.widgetContainer.style.width=`${this.widgetSize}px`,this.widgetContainer.style.height=`${this.widgetSize}px`,this.widgetContainer.style.border="2px solid rgba(255, 255, 255, 0.4)",this.widgetContainer.style.borderRadius="50%",this.widgetContainer.style.overflow="hidden",this.widgetContainer.style.backgroundColor="rgba(26, 26, 46, 0.85)",this.widgetContainer.style.cursor="crosshair",this.widgetContainer.style.userSelect="none",this.widgetContainer.style.pointerEvents="auto",this.syncWidgetPosition(),this.widgetCanvas=document.createElement("canvas"),this.widgetContainer.className="MapController",this.widgetCanvas.width=this.widgetSize*e,this.widgetCanvas.height=this.widgetSize*e,this.widgetCanvas.style.position="absolute",this.widgetCanvas.style.top="0",this.widgetCanvas.style.left="0",this.widgetCanvas.style.width=`${this.widgetSize}px`,this.widgetCanvas.style.height=`${this.widgetSize}px`,this.widgetCanvas.style.pointerEvents="auto",this.widgetContainer.style.zIndex="1000",this.widgetContainer.appendChild(this.widgetCanvas),this.widgetCtx=this.widgetCanvas.getContext("2d"),this.widgetCtx&&this.widgetCtx.scale(e,e),this.setupWidgetEvents(),this.engine.container&&this.engine.container.appendChild(this.widgetContainer),this.drawWidget()}setupWidgetEvents(){this.widgetContainer&&(this.widgetContainer.addEventListener("mousedown",this.onWidgetCanvasMouseDown),this.widgetCanvas&&this.widgetCanvas.addEventListener("mousedown",this.onWidgetCanvasMouseDown),window.addEventListener("mousemove",this.onWidgetMouseMove),window.addEventListener("mouseup",this.onWidgetMouseUp),this.widgetContainer.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation()}),this.widgetCanvas&&this.widgetCanvas.addEventListener("contextmenu",e=>{e.preventDefault(),e.stopPropagation()}))}onWidgetCanvasMouseDown=e=>{this.widgetContainer&&(e.button==0?(this.isDragging=!1,this.isRotating=!0):(this.isDragging=!0,this.isRotating=!1),this.captureRotationBaseline(e),this.lastMouseX=e.clientX,this.lastMouseY=e.clientY,this.widgetContainer&&(this.widgetContainer.style.cursor="alias"),e.preventDefault(),e.stopPropagation())};onWidgetMouseMove=e=>{if(!this.isDragging&&!this.isRotating)return;const t=e.clientX-this.lastMouseX,n=e.clientY-this.lastMouseY;if(this.isDragging)this.widgetX+=t,this.widgetY+=n,console.log(`[LinkView2d3d] 拖动位置更新: x=${this.widgetX.toFixed(0)}, y=${this.widgetY.toFixed(0)}`),this.syncWidgetPosition(),this.handleWidgetPositionControl();else if(this.isRotating){const i=this.calculatePointerAngle(e);if(i!==null){this.rotationStartAngle===null&&(this.rotationStartAngle=i,this.widgetRotationStart=this.widgetRotation);const s=i-this.rotationStartAngle;this.widgetRotation=this.widgetRotationStart+s,console.log(`[LinkView2d3d] 旋转角度更新: ${(this.widgetRotation*180/Math.PI).toFixed(1)}°`),this.drawWidget(),this.handleWidgetRotationControl()}}this.lastMouseX=e.clientX,this.lastMouseY=e.clientY};onWidgetMouseUp=()=>{this.isDragging&&console.log(`[LinkView2d3d] 拖动结束,最终位置: x=${this.widgetX.toFixed(0)}, y=${this.widgetY.toFixed(0)}`),this.isRotating&&console.log(`[LinkView2d3d] 旋转结束,最终角度: ${(this.widgetRotation*180/Math.PI).toFixed(1)}°`),this.isDragging=!1,this.isRotating=!1,this.rotationStartAngle=null,this.widgetContainer&&(this.widgetContainer.style.cursor="crosshair")};drawWidget(){const e=this.widgetCtx;if(!e)return;const t=this.widgetSize/2,n=this.widgetSize/2;e.clearRect(0,0,this.widgetSize,this.widgetSize),e.save(),e.translate(t,n),e.rotate(this.widgetRotation);const i=36,s=Math.PI/10,o=e.createRadialGradient(0,0,2,0,0,i);o.addColorStop(0,"rgba(0, 230, 130, 0.9)"),o.addColorStop(1,"rgba(0, 230, 130, 0)");const a=-Math.sin(s)*i,l=-Math.cos(s)*i,c=Math.sin(s)*i,h=-Math.cos(s)*i;e.beginPath(),e.moveTo(0,0),e.lineTo(a,l),e.lineTo(c,h),e.closePath(),e.fillStyle=o,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()}active(){window.addEventListener("D3ViewUpdate",this.listenViewUpdate)}disActive(){window.removeEventListener("D3ViewUpdate",this.listenViewUpdate)}disposeWidget(){this.widgetContainer&&this.widgetContainer.removeEventListener("mousedown",this.onWidgetMouseDown),this.widgetCanvas&&this.widgetCanvas.removeEventListener("mousedown",this.onWidgetCanvasMouseDown),window.removeEventListener("mousemove",this.onWidgetMouseMove),window.removeEventListener("mouseup",this.onWidgetMouseUp),this.widgetContainer?.remove(),this.widgetContainer=null,this.widgetCanvas=null,this.widgetCtx=null}listenViewUpdate=e=>{console.log("[LinkView2d3d] 收到视图更新事件",e),e=e.detail,e&&e.position&&(this.lastCameraWorldPosition=new w.Vector3(e.position.x,e.position.y,e.position.z),this.currentWordPosition=new w.Vector3(e.position.x,-e.position.z,0)),e&&typeof e.rotation=="number"&&(this.currentWordRotation=e.rotation),this.updateViewPoint()};updateViewPoint(){if(this.currentWordPosition){let e=this.worldToScreen.worldToScreen(this.currentWordPosition);this.widgetX=e.x,this.widgetY=e.y,this.syncWidgetPosition()}this.currentWordRotation!==null&&(this.widgetRotation=this.currentWordRotation,this.drawWidget())}syncWidgetPosition(){if(!this.widgetContainer)return;const e=this.widgetSize/2;this.widgetContainer.style.left=`${this.widgetX-e}px`,this.widgetContainer.style.top=`${this.widgetY-e}px`}handleWidgetPositionControl(){const e=this.getWidgetWorldPosition();e&&(this.currentWordPosition=e,this.dispatchViewControl("move",{position2d:e}))}handleWidgetRotationControl(){this.currentWordRotation=this.widgetRotation,this.dispatchViewControl("rotate",{rotation:this.widgetRotation})}getWidgetWorldPosition(){if(!this.engine?.cameraModule2d?.screenToWorld)return null;const e=this.engine.cameraModule2d.screenToWorld(this.widgetX,this.widgetY);return e?new w.Vector3(e.x,e.y,0):null}dispatchViewControl(e,t){const n=!!t.position2d,i=typeof t.rotation=="number";if(!n&&!i)return;if(n&&!this.lastCameraWorldPosition){console.warn("[LinkView2d3d] 未获取到 3D 相机位置,暂不推送位置控制");return}const s={source:"LinkView2d3d",mode:e};if(t.position2d&&this.lastCameraWorldPosition){const o=this.lastCameraWorldPosition.y,a=-t.position2d.y;s.position={x:t.position2d.x,y:o,z:a},this.lastCameraWorldPosition=new w.Vector3(t.position2d.x,o,a)}i&&(s.rotation=t.rotation),window.dispatchEvent(new CustomEvent("D2ViewControl",{detail:s}))}captureRotationBaseline(e){const t=this.calculatePointerAngle(e);if(t===null){this.rotationStartAngle=null;return}this.rotationStartAngle=t,this.widgetRotationStart=this.widgetRotation}calculatePointerAngle(e){if(!this.widgetContainer)return null;const t=this.widgetContainer.getBoundingClientRect(),n=t.left+t.width/2,i=t.top+t.height/2;return Math.atan2(e.clientX-n,i-e.clientY)}}class gf{engine;enabled=!0;constructor(e){this.engine=e,this.active()}toggle(){return this.enabled=!this.enabled,this.enabled?this.active():this.disActive(),this.enabled}isEnabled(){return this.enabled}active(){window.addEventListener("D3ElementClick",this.listenElementClick)}disActive(){window.removeEventListener("D3ElementClick",this.listenElementClick)}listenElementClick=e=>{let t=e.detail.id.toString();var n=this.engine.loaderModule2d.model.nodeMap.get(t);n!=null?(this.engine.modelToolModule2d.highlightModel([t]),this.engine.cameraModule2d.fitToExtents({min:[n[0].min.x,n[0].min.y],max:[n[0].max.x,n[0].max.y]},3)):this.engine.modelToolModule2d.unhighlightAllModels()}}class yf{engine;highlightMaterial;hideMaterial;translucentMaterial;constructor(e){this.engine=e,this.highlightMaterial=new w.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:w.DoubleSide}),this.hideMaterial=new w.MeshBasicMaterial({color:0,transparent:!0,opacity:0,side:w.DoubleSide}),this.translucentMaterial=new w.MeshBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:w.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 w.InstancedMesh)return;let t=e.materialClone.clone(),n=Zt(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){}highlightModelHover(e){this.engine.engineStatus2d.highlightHoverModels=e,this.unHighlightModelHover(),e.forEach(t=>{let n=this.engine.loaderModule2d.model.nodeMap.get(t);n?.forEach(i=>{if(i!=null&&i.indexes!=null)if(this.engine.modelGroup.children[i.indexes[0]]instanceof w.LineSegments){var s=this.engine.modelGroup.children[i.indexes[0]].clonePoints.slice(i.indexes[1],i.indexes[2]);this.highLightRenderLineHover(s)}else{let o=new w.Mesh(this.engine.modelGroup.children[i.indexes[0]].geometrys[i.indexes[1]],this.translucentMaterial);o.name="HighLightHover",o.renderOrder=999,this.engine.modelGroup.add(o)}})})}unHighlightModelHover(){this.engine.engineStatus2d.highlightHoverModels=[],this.unhighLightRenderLineHover()}highlightModel(e){this.engine.engineStatus2d.highlightModels=e,e.forEach(t=>{let n=this.engine.loaderModule2d.model.nodeMap.get(t);n?.forEach(i=>{if(i!=null&&i.indexes!=null)if(this.engine.modelGroup.children[i.indexes[0]]instanceof w.LineSegments){var s=this.engine.modelGroup.children[i.indexes[0]].clonePoints.slice(i.indexes[1],i.indexes[2]);this.highLightRenderLine(s)}else this.split_merge_model(this.engine.modelGroup.children[i.indexes[0]]),this.engine.modelGroup.children[i.indexes[0]].geometry.groups[i.indexes[1]].materialIndex=1})})}unhighlightModel(e){e.forEach(t=>{let n=this.engine.loaderModule2d.model.nodeMap.get(t);n?.forEach(i=>{i!=null&&i.indexes!=null&&(this.engine.modelGroup.children[i.indexes[0]]instanceof w.LineSegments||(this.engine.modelGroup.children[i.indexes[0]].geometry.groups[i.indexes[1]].materialIndex=0))})}),this.unhighLightRenderLine()}unhighlightAllModels(e=!0){this.engine.engineStatus2d.highlightModels.forEach(t=>{this.unhighlightModel([t])}),e&&(this.engine.engineStatus2d.highlightModels=[])}hideModel(e){this.unhighlightAllModels(),e.forEach(t=>{let n=this.engine.loaderModule2d.model.nodeMap.get(t);n?.forEach(i=>{if(i!=null&&i.indexes!=null)if(this.engine.modelGroup.children[i.indexes[0]]instanceof w.LineSegments){let s=this.engine.modelGroup.children[i.indexes[0]].geometry.attributes.position.array;for(let o=i.indexes[1];o<i.indexes[2];o++)s[o]=NaN;this.engine.modelGroup.children[i.indexes[0]].geometry.attributes.position.needsUpdate=!0}else this.split_merge_model(this.engine.modelGroup.children[i.indexes[0]]),this.engine.modelGroup.children[i.indexes[0]].geometry.groups[i.indexes[1]].materialIndex=-1})}),this.engine.engineStatus2d.hideModels.push(...e)}showModel(e){e.forEach(t=>{let n=this.engine.loaderModule2d.model.nodeMap.get(t);n?.forEach(i=>{if(i!=null&&i.indexes!=null)if(this.engine.modelGroup.children[i.indexes[0]]instanceof w.LineSegments){let s=this.engine.modelGroup.children[i.indexes[0]].geometry.attributes.position.array;for(let o=i.indexes[1];o<i.indexes[2];o++)s[o]=this.engine.modelGroup.children[i.indexes[0]].clonePoints[o];this.engine.modelGroup.children[i.indexes[0]].geometry.attributes.position.needsUpdate=!0}else this.split_merge_model(this.engine.modelGroup.children[i.indexes[0]]),this.engine.modelGroup.children[i.indexes[0]].geometry.groups[i.indexes[1]].materialIndex=0})}),this.engine.engineStatus2d.hideModels=[]}showAllModels(){this.engine.engineStatus2d.hideModels&&this.engine.engineStatus2d.hideModels.length>0&&this.showModel(this.engine.engineStatus2d.hideModels),this.engine.engineStatus2d.hideModels=[],this.unhighlightAllModels()}highLightRenderLine(e){let t=new w.BufferGeometry;t.setAttribute("position",new w.Float32BufferAttribute(e,3));const n=new w.LineBasicMaterial({color:43775,depthTest:!1,depthWrite:!1}),i=new w.LineSegments(t,n);i.name="HighLight",i.renderOrder=999,this.engine.modelGroup.add(i)}unhighLightRenderLine(){this.engine.modelGroup.children.filter(e=>e.name=="HighLight").forEach(e=>{this.engine.modelGroup.remove(e)})}highLightRenderLineHover(e){let t=new w.BufferGeometry;t.setAttribute("position",new w.Float32BufferAttribute(e,3));const n=new w.LineBasicMaterial({color:16777215,depthTest:!1,depthWrite:!1}),i=new w.LineSegments(t,n);i.name="HighLightHover",i.renderOrder=999,this.engine.modelGroup.add(i)}unhighLightRenderLineHover(){this.engine.modelGroup.children.filter(e=>e.name=="HighLightHover").forEach(e=>{this.engine.modelGroup.remove(e)})}}function vf(r){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(d,g){e.self!=null&&e.self.disActive!=null&&e.self.type!=d.type&&e.self.disActive(),e.self=d,g==null&&(g={showCatch:!1}),e.options=g},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){r.renderer.domElement.addEventListener("mousedown",a),r.renderer.domElement.addEventListener("mouseup",c),r.renderer.domElement.addEventListener("mousemove",l),r.renderer.domElement.addEventListener("touchstart",u,{passive:!1}),r.renderer.domElement.addEventListener("touchend",p,{passive:!1}),r.renderer.domElement.addEventListener("touchmove",m,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",n)},e.disActive=function(){r.renderer.domElement.removeEventListener("mousedown",a),r.renderer.domElement.removeEventListener("mouseup",c),r.renderer.domElement.removeEventListener("mousemove",l),r.renderer.domElement.removeEventListener("touchstart",u),r.renderer.domElement.removeEventListener("touchend",p),r.renderer.domElement.removeEventListener("touchmove",m),window.removeEventListener("keydown",t),window.removeEventListener("keyup",n)};function t(d){(d.keyCode===8||d.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),d.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),d.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),d.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),d.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),d.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),d.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),d.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function n(d){d.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),d.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),d.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),d.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),d.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),d.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),d.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function i(d){const g=new w.Vector2,y=r.renderer.domElement.clientWidth,v=r.renderer.domElement.clientHeight;return g.x=d.offsetX/y*2-1,g.y=-(d.offsetY/v)*2+1,g}function s(d){const g=new w.Raycaster,y=i(d);return g.setFromCamera(y,r.camera),g}function o(d,g=!1){const y=s(d);if(d.raycaster=y,g){const v=f(y,d);d.catch=v}}function a(d){d.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new w.Vector3(d.offsetX,d.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(r.engineStatus.isFree=!0,o(d,!0),d.catch!=null&&r.controlModule.orbitControls.origin.set(d.catch.point.x,d.catch.point.y,d.catch.point.z),e.self.handleMouseDown(d)))}function l(d){o(d,!0),e.self&&e.self.handleMouseMove!=null&&e.self.handleMouseMove(d)}function c(d){if(d.button!==0)return;const g=Date.now(),y=g-e.mouseDownTime,v=new w.Vector3(d.offsetX,d.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(o(d,!1),e.self.handleMouseUp(d));const x=v.distanceTo(e.mouseDownPosition);(y<100||x==0)&&e.self&&e.self.handleMouseClick!=null&&(o(d,!0),g-e.lastClickTime<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(d):e.self.handleMouseClick!=null&&e.self.handleMouseClick(d),e.lastClickTime=Date.now())}function h(d){const g=d.touches[0]||d.changedTouches[0];if(!g)return null;const v=r.renderer.domElement.getBoundingClientRect(),x=g.clientX-v.left,b=g.clientY-v.top;return{offsetX:x,offsetY:b,button:0,clientX:g.clientX,clientY:g.clientY,preventDefault:()=>d.preventDefault(),stopPropagation:()=>d.stopPropagation(),originalEvent:d}}function u(d){if(d.preventDefault(),d.touches.length!==1)return;const g=h(d);g&&a(g)}function m(d){if(d.preventDefault(),d.touches.length!==1)return;const g=h(d);g&&l(g)}function p(d){d.preventDefault();const g=h(d);g&&c(g)}function f(d,g){var y=r.octreeBox2d.pick2d(d,g);return y==null?null:{point:null,id:y}}return e}class wf{el;xEl;yEl;constructor(e){this.el=document.createElement("div"),this.el.className="engine-2d-mouse-coord";const t=document.createElement("span");t.className="engine-2d-mouse-coord__label",t.textContent="",this.xEl=document.createElement("span"),this.xEl.className="engine-2d-mouse-coord__value",this.xEl.textContent="X: --",this.yEl=document.createElement("span"),this.yEl.className="engine-2d-mouse-coord__value",this.yEl.textContent="Y: --",this.el.appendChild(t),this.el.appendChild(this.xEl),this.el.appendChild(this.yEl),e.appendChild(this.el)}update(e,t){this.xEl.textContent=`X: ${e.toFixed(0)} mm`,this.yEl.textContent=`Y: ${t.toFixed(0)} mm`}reset(){this.xEl.textContent="X: --",this.yEl.textContent="Y: --"}dispose(){this.el.parentElement?.removeChild(this.el)}}var Qr=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r.MeasureChanged="measure-changed",r.MeasureClick="measure-click",r.SectionMove="section-move",r))(Qr||{});class xf{engine;behavior;mouseCoordUI=null;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved2d,this.behavior.init(this);const e=this.engine.container;e&&(this.mouseCoordUI=new wf(e))}active(){this.behavior.active()}disActive(){this.behavior.disActive()}oldId=null;handleMouseMove(e){if(!this.mouseCoordUI||!this.engine.cameraModule2d)return;const t=this.engine.cameraModule2d.screenToWorld(e.offsetX,e.offsetY);if(this.mouseCoordUI.update(t.x*1e3,t.y*1e3),e.catch==null||e.catch.id==null){this.engine.modelToolModule2d.unHighlightModelHover(),this.oldId=null;return}let n=e.catch.id;this.oldId!=n&&this.engine.modelToolModule2d.highlightModelHover([n])}handelKeyEscDown(e){this.engine.modelToolModule2d.unhighlightAllModels()}handleMouseClick(e){if(e.catch!=null){this.engine.modelToolModule2d.highlightModel([e.catch.id]),this.engine.events.trigger(Qr.Click,e.catch.id);let t=new CustomEvent("D2ElementClick",{detail:{id:e.catch.id}});window.dispatchEvent(t)}else{this.engine.modelToolModule2d.unhighlightAllModels();let t=new CustomEvent("D2ElementClick",{detail:{id:-1}});window.dispatchEvent(t)}}dispose(){this.mouseCoordUI?.dispose(),this.mouseCoordUI=null}}class bf{overlay;hLine;vLine;box;canvas;constructor(e,t){this.canvas=t,t.style.cursor="none",this.overlay=document.createElement("div"),this.overlay.className="engine-2d-cad-cursor",this.hLine=document.createElement("div"),this.hLine.className="engine-2d-cad-cursor__h",this.vLine=document.createElement("div"),this.vLine.className="engine-2d-cad-cursor__v",this.box=document.createElement("div"),this.box.className="engine-2d-cad-cursor__box",this.overlay.appendChild(this.hLine),this.overlay.appendChild(this.vLine),this.overlay.appendChild(this.box),e.appendChild(this.overlay),this.hide(),this.bindEvents()}bindEvents(){this.canvas.addEventListener("mousemove",this.onMouseMove),this.canvas.addEventListener("mouseenter",this.onMouseEnter),this.canvas.addEventListener("mouseleave",this.onMouseLeave)}onMouseMove=e=>{const t=this.canvas.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top;this.hLine.style.top=`${i}px`,this.vLine.style.left=`${n}px`,this.box.style.left=`${n}px`,this.box.style.top=`${i}px`};onMouseEnter=()=>{this.show()};onMouseLeave=()=>{this.hide()};show(){this.overlay.style.visibility="visible"}hide(){this.overlay.style.visibility="hidden"}dispose(){this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseenter",this.onMouseEnter),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.style.cursor="",this.overlay.parentElement?.removeChild(this.overlay)}}const Mf=[{action:"search",label:"搜索"},{action:"hideElement",label:"隐藏元素",dividerBefore:!0},{action:"showAll",label:"显示全部"},{action:"hideLayer",label:"隐藏图层",dividerBefore:!0},{action:"showAllLayers",label:"显示所有图层"},{action:"layerManage",label:"图层管理",dividerBefore:!0},{action:"toggleBg",label:"切换背景"},{action:"linkElement2d3d",label:"模型联动",dividerBefore:!0},{action:"linkView2d3d",label:"视角关联"}];class _f{menu;container;canvas;onAction;menuItemStates=new Map;constructor(e,t,n){this.container=e,this.canvas=t,this.onAction=n,this.menu=this.createMenu(),e.appendChild(this.menu),this.bindEvents()}createMenu(){const e=document.createElement("div");return e.className="engine-2d-context-menu",Mf.forEach(t=>{if(t.dividerBefore){const i=document.createElement("div");i.className="engine-2d-context-menu__divider",e.appendChild(i)}const n=document.createElement("div");n.className="engine-2d-context-menu__item",n.textContent=t.label,n.dataset.action=t.action,n.addEventListener("click",()=>{this.hide(),this.onAction(t.action)}),e.appendChild(n)}),e}bindEvents(){this.canvas.addEventListener("contextmenu",this.onContextMenu),document.addEventListener("mousedown",this.onDocMouseDown),document.addEventListener("keydown",this.onEscape)}onContextMenu=e=>{e.preventDefault();const t=this.container.getBoundingClientRect();let n=e.clientX-t.left,i=e.clientY-t.top;this.menu.style.left=`${n}px`,this.menu.style.top=`${i}px`,this.menu.classList.add("engine-2d-context-menu--visible"),this.updateMenuItemStyles();const s=this.menu.offsetWidth,o=this.menu.offsetHeight,a=this.container.clientWidth,l=this.container.clientHeight;n+s>a&&(n=a-s-4),i+o>l&&(i=l-o-4),this.menu.style.left=`${n}px`,this.menu.style.top=`${i}px`};onDocMouseDown=e=>{this.menu.contains(e.target)||this.hide()};onEscape=e=>{e.key==="Escape"&&this.hide()};hide(){this.menu.classList.remove("engine-2d-context-menu--visible")}setMenuItemState(e,t){this.menuItemStates.set(e,t)}setMenuItemStates(e){Object.entries(e).forEach(([t,n])=>{this.menuItemStates.set(t,n)})}updateMenuItemStyles(){this.menu.querySelectorAll(".engine-2d-context-menu__item").forEach(t=>{const n=t.dataset.action;this.menuItemStates.get(n)?(t.style.color="#00e682",t.style.fontWeight="bold"):(t.style.color="",t.style.fontWeight="")})}dispose(){this.canvas.removeEventListener("contextmenu",this.onContextMenu),document.removeEventListener("mousedown",this.onDocMouseDown),document.removeEventListener("keydown",this.onEscape),this.menu.parentElement?.removeChild(this.menu)}}class Sf{overlay=null;textEl=null;barEl=null;pctEl=null;constructor(e){this._build(e)}show(e="正在加载...",t=0){this.overlay&&(this.overlay.style.display="flex",this._update(e,t))}update(e,t){this.overlay?.style.display!=="none"&&this._update(e,t)}hide(){this.overlay&&(this.overlay.style.display="none")}_update(e,t){const n=Math.min(100,Math.max(0,Math.round(t)));this.textEl&&(this.textEl.textContent=e),this.barEl&&(this.barEl.style.width=`${n}%`),this.pctEl&&(this.pctEl.textContent=`${n}%`)}_build(e){const t=document.createElement("div");t.style.cssText=`
|
|
1400
|
+
position:absolute; inset:0;
|
|
1401
|
+
display:none; align-items:center; justify-content:center;
|
|
1402
|
+
z-index:200;
|
|
1403
|
+
`,this.overlay=t;const n=document.createElement("div");n.style.cssText=`
|
|
1404
|
+
display:flex; flex-direction:column; align-items:center; gap:14px;
|
|
1405
|
+
padding:28px 36px;
|
|
1166
1406
|
background:var(--e2d-bg,#1e1f22);
|
|
1167
|
-
border:1px solid var(--e2d-
|
|
1168
|
-
border-radius:
|
|
1169
|
-
box-shadow:0
|
|
1170
|
-
|
|
1171
|
-
z-index:100; user-select:none;
|
|
1172
|
-
font-size:13px; color:var(--e2d-text,#e0e0e0);
|
|
1407
|
+
border:1px solid var(--e2d-border,rgba(255,255,255,0.12));
|
|
1408
|
+
border-radius:8px;
|
|
1409
|
+
box-shadow:0 8px 32px var(--e2d-shadow-lg,rgba(0,0,0,0.65));
|
|
1410
|
+
min-width:200px;
|
|
1173
1411
|
font-family:system-ui,sans-serif;
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
border-bottom:1px solid var(--e2d-border2,#222);
|
|
1202
|
-
transition:background 0.1s;
|
|
1203
|
-
`,e.onmouseenter=()=>{e.style.background="var(--e2d-bg-hover,#2a2a2a)"},e.onmouseleave=()=>{e.style.background=""},e}_createEye(e){const t=document.createElement("span");return t.style.cssText="display:flex; align-items:center; flex-shrink:0; width:16px;",this._updateEye(t,e),t}_updateEye(e,t){e.style.color=t?"var(--e2d-close,#aaa)":"var(--e2d-text4,#555)",e.innerHTML=t?`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1204
|
-
<path d="M8 3C4.5 3 1.5 8 1.5 8C1.5 8 4.5 13 8 13C11.5 13 14.5 8 14.5 8C14.5 8 11.5 3 8 3Z" stroke="currentColor" stroke-width="1.2"/>
|
|
1205
|
-
<circle cx="8" cy="8" r="2" stroke="currentColor" stroke-width="1.2"/>
|
|
1206
|
-
</svg>`:`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1207
|
-
<path d="M2 2L14 14" stroke="currentColor" stroke-width="1.2"/>
|
|
1208
|
-
<path d="M8 3C4.5 3 1.5 8 1.5 8C2.2 9.3 3.3 10.5 4.5 11.5" stroke="currentColor" stroke-width="1.2"/>
|
|
1209
|
-
<path d="M11.5 11.5C12.7 10.5 13.8 9.3 14.5 8C14.5 8 11.5 3 8 3" stroke="currentColor" stroke-width="1.2"/>
|
|
1210
|
-
</svg>`}_colorToHex(e){return"#"+e.toString(16).padStart(6,"0")}_makeDraggable(e,t){t.onmousedown=n=>{n.preventDefault();const i=e.getBoundingClientRect(),s=e.offsetParent?.getBoundingClientRect()??{left:0,top:0};e.style.left=i.left-s.left+"px",e.style.top=i.top-s.top+"px",e.style.right="auto",e.style.bottom="auto";const r=n.clientX-i.left,a=n.clientY-i.top,l=h=>{e.style.left=h.clientX-r-s.left+"px",e.style.top=h.clientY-a-s.top+"px"},c=()=>{document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",c)};document.addEventListener("mousemove",l),document.addEventListener("mouseup",c)}}dispose(){this.panel?.remove(),this.panel=null,this.listEl=null}}class Kd{engine;layerMap=new Map;panelUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.panelUI=new Yd(t,this))}_loadLayers(){let e=this.engine.dwgData.layers;this.layerMap.clear();for(const t of e)this.layerMap.set(t.name,{...t}),this.panelUI?.refresh()}syncFromModel(e){e?.length>0&&(this._loadLayers(e),this.panelUI?.refresh())}getLayers(){return Array.from(this.layerMap.values())}setLayerVisible(e,t){const n=this.layerMap.get(e);n&&(n.visible=t),this._applyVisibility(e,t)}toggleLayer(e){const t=this.layerMap.get(e);if(!t)return!0;const n=!t.visible;return this.setLayerVisible(e,n),n}setAllLayersVisible(e){for(const t of this.layerMap.keys()){const n=this.layerMap.get(t);n.visible=e,this._applyVisibility(t,e)}}isAllVisible(){return Array.from(this.layerMap.values()).every(e=>e.visible)}_applyVisibility(e,t){const n=this.engine?.scene;if(!n)return;const i=e+"||";n.children.forEach(s=>{s.name?.startsWith(i)&&(s.visible=t)})}show(){this.panelUI?.show()}hide(){this.panelUI?.hide()}toggle(){this.panelUI?.toggle()}dispose(){this.panelUI?.dispose(),this.panelUI=null,this.layerMap.clear()}}function qd(o){const e={self:null,options:null,mouseDownTime:0,mouseDownPosition:null,lastClickTime:0};e.init=function(u,g){e.self!=null&&e.self.disActive!=null&&e.self.type!=u.type&&e.self.disActive(),e.self=u,g==null&&(g={showCatch:!1}),e.options=g},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){o.renderer.domElement.addEventListener("mousedown",a),o.renderer.domElement.addEventListener("mouseup",c),o.renderer.domElement.addEventListener("mousemove",l),o.renderer.domElement.addEventListener("touchstart",d,{passive:!1}),o.renderer.domElement.addEventListener("touchend",p,{passive:!1}),o.renderer.domElement.addEventListener("touchmove",m,{passive:!1}),window.addEventListener("keydown",t),window.addEventListener("keyup",n)},e.disActive=function(){o.renderer.domElement.removeEventListener("mousedown",a),o.renderer.domElement.removeEventListener("mouseup",c),o.renderer.domElement.removeEventListener("mousemove",l),o.renderer.domElement.removeEventListener("touchstart",d),o.renderer.domElement.removeEventListener("touchend",p),o.renderer.domElement.removeEventListener("touchmove",m),window.removeEventListener("keydown",t),window.removeEventListener("keyup",n)};function t(u){(u.keyCode===8||u.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),u.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),u.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),u.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),u.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),u.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),u.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),u.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function n(u){u.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),u.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),u.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),u.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),u.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),u.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),u.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function i(u){const g=new b.Vector2,y=o.renderer.domElement.clientWidth,v=o.renderer.domElement.clientHeight;return g.x=u.offsetX/y*2-1,g.y=-(u.offsetY/v)*2+1,g}function s(u){const g=new b.Raycaster,y=i(u);return g.setFromCamera(y,o.camera),g}function r(u,g=!1){const y=s(u);if(u.raycaster=y,g){const v=void 0;u.catch=v}}function a(u){u.button===0&&(e.mouseDownTime=Date.now(),e.mouseDownPosition=new b.Vector3(u.offsetX,u.offsetY,0),e.self&&e.self.handleMouseDown!=null&&(o.engineStatus.isFree=!0,r(u,!0),u.catch!=null&&o.controlModule.orbitControls.origin.set(u.catch.point.x,u.catch.point.y,u.catch.point.z),e.self.handleMouseDown(u)))}function l(u){e.self&&e.self.handleMouseMove!=null&&e.self.handleMouseMove(u)}function c(u){if(u.button!==0)return;const g=Date.now(),y=g-e.mouseDownTime,v=new b.Vector3(u.offsetX,u.offsetY,0);e.self&&e.self.handleMouseUp!=null&&(r(u,!1),e.self.handleMouseUp(u));const w=v.distanceTo(e.mouseDownPosition);if((y<100||w==0)&&e.self&&e.self.handleMouseClick!=null){r(u,!0);const x=g-e.lastClickTime;console.log(x),x<200?e.self.handleMouseDoubleClick!=null&&e.self.handleMouseDoubleClick(u):e.self.handleMouseClick!=null&&e.self.handleMouseClick(u),e.lastClickTime=Date.now()}}function h(u){const g=u.touches[0]||u.changedTouches[0];if(!g)return null;const v=o.renderer.domElement.getBoundingClientRect(),w=g.clientX-v.left,x=g.clientY-v.top;return{offsetX:w,offsetY:x,button:0,clientX:g.clientX,clientY:g.clientY,preventDefault:()=>u.preventDefault(),stopPropagation:()=>u.stopPropagation(),originalEvent:u}}function d(u){if(u.preventDefault(),u.touches.length!==1)return;const g=h(u);g&&a(g)}function m(u){if(u.preventDefault(),u.touches.length!==1)return;const g=h(u);g&&l(g)}function p(u){u.preventDefault();const g=h(u);g&&c(g)}function f(u,g){}return e}class $d{el;xEl;yEl;constructor(e){this.el=document.createElement("div"),this.el.className="engine-2d-mouse-coord";const t=document.createElement("span");t.className="engine-2d-mouse-coord__label",t.textContent="",this.xEl=document.createElement("span"),this.xEl.className="engine-2d-mouse-coord__value",this.xEl.textContent="X: --",this.yEl=document.createElement("span"),this.yEl.className="engine-2d-mouse-coord__value",this.yEl.textContent="Y: --",this.el.appendChild(t),this.el.appendChild(this.xEl),this.el.appendChild(this.yEl),e.appendChild(this.el)}update(e,t){this.xEl.textContent=`X: ${e.toFixed(0)} mm`,this.yEl.textContent=`Y: ${t.toFixed(0)} mm`}reset(){this.xEl.textContent="X: --",this.yEl.textContent="Y: --"}dispose(){this.el.parentElement?.removeChild(this.el)}}class Hd{engine;behavior;mouseCoordUI=null;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved2d,this.behavior.init(this);const e=this.engine.container;e&&(this.mouseCoordUI=new $d(e))}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handleMouseMove(e){if(!this.mouseCoordUI||!this.engine.cameraModule2d)return;const t=this.engine.cameraModule2d.screenToWorld(e.offsetX,e.offsetY);this.mouseCoordUI.update(t.x*1e3,t.y*1e3)}handleMouseClick(e){}dispose(){this.mouseCoordUI?.dispose(),this.mouseCoordUI=null}}class Jd{overlay;hLine;vLine;box;canvas;constructor(e,t){this.canvas=t,t.style.cursor="none",this.overlay=document.createElement("div"),this.overlay.className="engine-2d-cad-cursor",this.hLine=document.createElement("div"),this.hLine.className="engine-2d-cad-cursor__h",this.vLine=document.createElement("div"),this.vLine.className="engine-2d-cad-cursor__v",this.box=document.createElement("div"),this.box.className="engine-2d-cad-cursor__box",this.overlay.appendChild(this.hLine),this.overlay.appendChild(this.vLine),this.overlay.appendChild(this.box),e.appendChild(this.overlay),this.hide(),this.bindEvents()}bindEvents(){this.canvas.addEventListener("mousemove",this.onMouseMove),this.canvas.addEventListener("mouseenter",this.onMouseEnter),this.canvas.addEventListener("mouseleave",this.onMouseLeave)}onMouseMove=e=>{const t=this.canvas.getBoundingClientRect(),n=e.clientX-t.left,i=e.clientY-t.top;this.hLine.style.top=`${i}px`,this.vLine.style.left=`${n}px`,this.box.style.left=`${n}px`,this.box.style.top=`${i}px`};onMouseEnter=()=>{this.show()};onMouseLeave=()=>{this.hide()};show(){this.overlay.style.visibility="visible"}hide(){this.overlay.style.visibility="hidden"}dispose(){this.canvas.removeEventListener("mousemove",this.onMouseMove),this.canvas.removeEventListener("mouseenter",this.onMouseEnter),this.canvas.removeEventListener("mouseleave",this.onMouseLeave),this.canvas.style.cursor="",this.overlay.parentElement?.removeChild(this.overlay)}}const Qd=[{action:"search",label:"搜索"},{action:"hideElement",label:"隐藏元素",dividerBefore:!0},{action:"showAll",label:"显示全部"},{action:"hideLayer",label:"隐藏图层",dividerBefore:!0},{action:"showAllLayers",label:"显示所有图层"}];class ef{menu;container;canvas;onAction;constructor(e,t,n){this.container=e,this.canvas=t,this.onAction=n,this.menu=this.createMenu(),e.appendChild(this.menu),this.bindEvents()}createMenu(){const e=document.createElement("div");return e.className="engine-2d-context-menu",Qd.forEach(t=>{if(t.dividerBefore){const i=document.createElement("div");i.className="engine-2d-context-menu__divider",e.appendChild(i)}const n=document.createElement("div");n.className="engine-2d-context-menu__item",n.textContent=t.label,n.dataset.action=t.action,n.addEventListener("click",()=>{this.hide(),this.onAction(t.action)}),e.appendChild(n)}),e}bindEvents(){this.canvas.addEventListener("contextmenu",this.onContextMenu),document.addEventListener("mousedown",this.onDocMouseDown),document.addEventListener("keydown",this.onEscape)}onContextMenu=e=>{e.preventDefault();const t=this.container.getBoundingClientRect();let n=e.clientX-t.left,i=e.clientY-t.top;this.menu.style.left=`${n}px`,this.menu.style.top=`${i}px`,this.menu.classList.add("engine-2d-context-menu--visible");const s=this.menu.offsetWidth,r=this.menu.offsetHeight,a=this.container.clientWidth,l=this.container.clientHeight;n+s>a&&(n=a-s-4),i+r>l&&(i=l-r-4),this.menu.style.left=`${n}px`,this.menu.style.top=`${i}px`};onDocMouseDown=e=>{this.menu.contains(e.target)||this.hide()};onEscape=e=>{e.key==="Escape"&&this.hide()};hide(){this.menu.classList.remove("engine-2d-context-menu--visible")}dispose(){this.canvas.removeEventListener("contextmenu",this.onContextMenu),document.removeEventListener("mousedown",this.onDocMouseDown),document.removeEventListener("keydown",this.onEscape),this.menu.parentElement?.removeChild(this.menu)}}const tf=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1412
|
+
`;const i=document.createElement("div");i.style.cssText="width:48px; height:48px;",i.innerHTML=`
|
|
1413
|
+
<svg width="48" height="48" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
|
1414
|
+
<style>
|
|
1415
|
+
@keyframes _e2d_spin { to { transform: rotate(360deg); } }
|
|
1416
|
+
._e2d_ring { transform-origin: 24px 24px; animation: _e2d_spin 0.9s linear infinite; }
|
|
1417
|
+
</style>
|
|
1418
|
+
<circle cx="24" cy="24" r="19" fill="none"
|
|
1419
|
+
stroke="var(--e2d-border2,#333)" stroke-width="3"/>
|
|
1420
|
+
<g class="_e2d_ring">
|
|
1421
|
+
<circle cx="24" cy="24" r="19" fill="none"
|
|
1422
|
+
stroke="var(--e2d-accent,#4fc3f7)" stroke-width="3"
|
|
1423
|
+
stroke-dasharray="30 90" stroke-linecap="round"/>
|
|
1424
|
+
</g>
|
|
1425
|
+
</svg>
|
|
1426
|
+
`;const s=document.createElement("div");s.style.cssText=`
|
|
1427
|
+
font-size:13px; color:var(--e2d-text2,#ccc);
|
|
1428
|
+
text-align:center; white-space:nowrap;
|
|
1429
|
+
`,s.textContent="正在加载...",this.textEl=s;const o=document.createElement("div");o.style.cssText=`
|
|
1430
|
+
width:160px; height:3px; border-radius:2px;
|
|
1431
|
+
background:var(--e2d-border2,#333); overflow:hidden;
|
|
1432
|
+
`;const a=document.createElement("div");a.style.cssText=`
|
|
1433
|
+
height:100%; width:0%; border-radius:2px;
|
|
1434
|
+
background:var(--e2d-accent,#4fc3f7);
|
|
1435
|
+
transition:width 0.25s ease;
|
|
1436
|
+
`,o.appendChild(a),this.barEl=a;const l=document.createElement("div");l.style.cssText=`
|
|
1437
|
+
font-size:12px; color:var(--e2d-text3,rgba(255,255,255,0.35));
|
|
1438
|
+
`,l.textContent="0%",this.pctEl=l,n.appendChild(i),n.appendChild(s),n.appendChild(o),n.appendChild(l),t.appendChild(n),e.appendChild(t)}dispose(){this.overlay?.remove(),this.overlay=null,this.textEl=null,this.barEl=null,this.pctEl=null}}const Cf=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1211
1439
|
<circle cx="6.5" cy="6.5" r="4.5" stroke="currentColor" stroke-width="1.5"/>
|
|
1212
1440
|
<line x1="10" y1="10" x2="14" y2="14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
1213
|
-
</svg>`,
|
|
1441
|
+
</svg>`,Af=`<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
1214
1442
|
<line x1="1" y1="1" x2="11" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
1215
1443
|
<line x1="11" y1="1" x2="1" y2="11" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/>
|
|
1216
|
-
</svg>`,
|
|
1444
|
+
</svg>`,Pf={房间:"#4fc3f7",门:"#81c784",窗:"#aed581",柱:"#ff8a65",梁:"#ffb74d",楼梯:"#ce93d8",电梯:"#80deea",设备间:"#f48fb1",轴线:"#90a4ae",墙体:"#bcaaa4",室外:"#a5d6a7"};class Tf{container;manager;wrapper;input;clearBtn;resultList;statusEl;activeIndex=-1;currentResults=[];debounceTimer=null;constructor(e,t){this.container=e,this.manager=t,this.wrapper=this._buildWrapper(),this.input=this.wrapper.querySelector(".engine-2d-search__input"),this.clearBtn=this.wrapper.querySelector(".engine-2d-search__clear"),this.resultList=this.wrapper.querySelector(".engine-2d-search__list"),this.statusEl=this.wrapper.querySelector(".engine-2d-search__status"),e.appendChild(this.wrapper),this._bindEvents()}_buildWrapper(){const e=document.createElement("div");return e.className="engine-2d-search",e.innerHTML=`
|
|
1217
1445
|
<div class="engine-2d-search__box">
|
|
1218
1446
|
<div class="engine-2d-search__input-row">
|
|
1219
|
-
<span class="engine-2d-search__icon">${
|
|
1447
|
+
<span class="engine-2d-search__icon">${Cf}</span>
|
|
1220
1448
|
<input
|
|
1221
1449
|
class="engine-2d-search__input"
|
|
1222
1450
|
type="text"
|
|
@@ -1224,18 +1452,18 @@ void main() {
|
|
|
1224
1452
|
autocomplete="off"
|
|
1225
1453
|
spellcheck="false"
|
|
1226
1454
|
/>
|
|
1227
|
-
<button class="engine-2d-search__clear" title="清除">${
|
|
1455
|
+
<button class="engine-2d-search__clear" title="清除">${Af}</button>
|
|
1228
1456
|
</div>
|
|
1229
1457
|
<div class="engine-2d-search__divider"></div>
|
|
1230
1458
|
<div class="engine-2d-search__status"></div>
|
|
1231
1459
|
<ul class="engine-2d-search__list" role="listbox"></ul>
|
|
1232
1460
|
</div>
|
|
1233
|
-
`,e}_bindEvents(){this.input.addEventListener("input",this._onInput),this.input.addEventListener("keydown",this._onKeyDown),this.clearBtn.addEventListener("click",this._onClear),document.addEventListener("mousedown",this._onDocMouseDown),document.addEventListener("keydown",this._onEscape)}_onInput=()=>{this.debounceTimer!==null&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>this._doSearch(),150);const e=this.input.value.length>0;this.clearBtn.style.opacity=e?"1":"0",this.clearBtn.style.pointerEvents=e?"auto":"none"};_onKeyDown=e=>{const t=this.resultList.querySelectorAll(".engine-2d-search__item");t.length&&(e.key==="ArrowDown"?(e.preventDefault(),this.activeIndex=Math.min(this.activeIndex+1,t.length-1),this._highlightItem(t)):e.key==="ArrowUp"?(e.preventDefault(),this.activeIndex=Math.max(this.activeIndex-1,0),this._highlightItem(t)):e.key==="Enter"&&this.activeIndex>=0&&this.currentResults[this.activeIndex]&&this._selectResult(this.currentResults[this.activeIndex]))};_onClear=()=>{this.input.value="",this.clearBtn.style.opacity="0",this.clearBtn.style.pointerEvents="none",this._clearResults(),this.input.focus()};_onDocMouseDown=e=>{this.wrapper.contains(e.target)||this.hide()};_onEscape=e=>{e.key==="Escape"&&this.hide()};_doSearch(){const e=this.input.value;if(!e.trim()){this._clearResults();return}this.currentResults=this.manager.search(e),this.activeIndex=-1,this._renderResults(this.currentResults,e)}_renderResults(e,t){this.resultList.innerHTML="";const n=this.wrapper.querySelector(".engine-2d-search__divider");if(e.length===0){this.statusEl.textContent=`未找到与 "${t}" 相关的结果`,this.statusEl.style.display="block",n.style.display="none",this.resultList.style.display="none";return}this.statusEl.textContent=`找到 ${e.length} 个结果`,this.statusEl.style.display="block",n.style.display="block",this.resultList.style.display="block",e.forEach((i,s)=>{const
|
|
1461
|
+
`,e}_bindEvents(){this.input.addEventListener("input",this._onInput),this.input.addEventListener("keydown",this._onKeyDown),this.clearBtn.addEventListener("click",this._onClear),document.addEventListener("mousedown",this._onDocMouseDown),document.addEventListener("keydown",this._onEscape)}_onInput=()=>{this.debounceTimer!==null&&clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>this._doSearch(),150);const e=this.input.value.length>0;this.clearBtn.style.opacity=e?"1":"0",this.clearBtn.style.pointerEvents=e?"auto":"none"};_onKeyDown=e=>{const t=this.resultList.querySelectorAll(".engine-2d-search__item");t.length&&(e.key==="ArrowDown"?(e.preventDefault(),this.activeIndex=Math.min(this.activeIndex+1,t.length-1),this._highlightItem(t)):e.key==="ArrowUp"?(e.preventDefault(),this.activeIndex=Math.max(this.activeIndex-1,0),this._highlightItem(t)):e.key==="Enter"&&this.activeIndex>=0&&this.currentResults[this.activeIndex]&&this._selectResult(this.currentResults[this.activeIndex]))};_onClear=()=>{this.input.value="",this.clearBtn.style.opacity="0",this.clearBtn.style.pointerEvents="none",this._clearResults(),this.input.focus()};_onDocMouseDown=e=>{this.wrapper.contains(e.target)||this.hide()};_onEscape=e=>{e.key==="Escape"&&this.hide()};_doSearch(){const e=this.input.value;if(!e.trim()){this._clearResults();return}this.currentResults=this.manager.search(e),this.activeIndex=-1,this._renderResults(this.currentResults,e)}_renderResults(e,t){this.resultList.innerHTML="";const n=this.wrapper.querySelector(".engine-2d-search__divider");if(e.length===0){this.statusEl.textContent=`未找到与 "${t}" 相关的结果`,this.statusEl.style.display="block",n.style.display="none",this.resultList.style.display="none";return}this.statusEl.textContent=`找到 ${e.length} 个结果`,this.statusEl.style.display="block",n.style.display="block",this.resultList.style.display="block",e.forEach((i,s)=>{const o=document.createElement("li");o.className="engine-2d-search__item",o.setAttribute("role","option"),o.dataset.index=String(s);const a=Pf[i.type]??"#90a4ae",l=this._highlight(i.name,t);o.innerHTML=`
|
|
1234
1462
|
<span class="engine-2d-search__item-badge" style="background:${a}20;color:${a};">${i.type}</span>
|
|
1235
1463
|
<span class="engine-2d-search__item-name">${l}</span>
|
|
1236
1464
|
${i.layer?`<span class="engine-2d-search__item-layer">${i.layer}</span>`:""}
|
|
1237
1465
|
${i.description?`<span class="engine-2d-search__item-desc">${i.description}</span>`:""}
|
|
1238
|
-
`,r.addEventListener("click",()=>this._selectResult(i)),r.addEventListener("mouseenter",()=>{this.activeIndex=s;const c=this.resultList.querySelectorAll(".engine-2d-search__item");this._highlightItem(c)}),this.resultList.appendChild(r)})}_highlight(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return e.replace(new RegExp(`(${n})`,"gi"),'<mark class="engine-2d-search__mark">$1</mark>')}_highlightItem(e){e.forEach((t,n)=>{t.classList.toggle("engine-2d-search__item--active",n===this.activeIndex)}),this.activeIndex>=0&&e[this.activeIndex]?.scrollIntoView({block:"nearest"})}_selectResult(e){this.manager.onResultSelect(e),this.hide()}_clearResults(){this.resultList.innerHTML="",this.resultList.style.display="none",this.statusEl.style.display="none";const e=this.wrapper.querySelector(".engine-2d-search__divider");e.style.display="none",this.currentResults=[],this.activeIndex=-1}show(){this.wrapper.classList.add("engine-2d-search--visible"),requestAnimationFrame(()=>this.input.focus())}hide(){this.wrapper.classList.remove("engine-2d-search--visible"),this._clearResults(),this.input.value="",this.clearBtn.style.opacity="0",this.clearBtn.style.pointerEvents="none"}toggle(){this.wrapper.classList.contains("engine-2d-search--visible")?this.hide():this.show()}dispose(){this.input.removeEventListener("input",this._onInput),this.input.removeEventListener("keydown",this._onKeyDown),this.clearBtn.removeEventListener("click",this._onClear),document.removeEventListener("mousedown",this._onDocMouseDown),document.removeEventListener("keydown",this._onEscape),this.wrapper.parentElement?.removeChild(this.wrapper),this.debounceTimer!==null&&clearTimeout(this.debounceTimer)}}const of=[{id:"1",name:"会议室 A",type:"房间",layer:"建筑-房间",description:"3F 东侧,面积 48㎡"},{id:"2",name:"会议室 B",type:"房间",layer:"建筑-房间",description:"3F 西侧,面积 32㎡"},{id:"3",name:"卫生间-男",type:"房间",layer:"建筑-房间",description:"2F,面积 18㎡"},{id:"4",name:"卫生间-女",type:"房间",layer:"建筑-房间",description:"2F,面积 16㎡"},{id:"5",name:"大厅",type:"房间",layer:"建筑-房间",description:"1F,面积 260㎡"},{id:"6",name:"主入口门",type:"门",layer:"建筑-门窗",description:"宽 2400mm,双开"},{id:"7",name:"次入口门",type:"门",layer:"建筑-门窗",description:"宽 1200mm,单开"},{id:"8",name:"防火门 FD-01",type:"门",layer:"建筑-门窗",description:"甲级防火,宽 900mm"},{id:"9",name:"落地窗 W-101",type:"窗",layer:"建筑-门窗",description:"高 3000mm,南向"},{id:"10",name:"普通窗 W-201",type:"窗",layer:"建筑-门窗",description:"高 1800mm,东向"},{id:"11",name:"承重柱 Z-A1",type:"柱",layer:"结构-柱",description:"600×600,混凝土"},{id:"12",name:"承重柱 Z-A2",type:"柱",layer:"结构-柱",description:"600×600,混凝土"},{id:"13",name:"钢柱 GZ-01",type:"柱",layer:"结构-柱",description:"H 型钢,H300×150"},{id:"14",name:"主梁 L-1",type:"梁",layer:"结构-梁",description:"400×800,跨度 8m"},{id:"15",name:"次梁 L-2",type:"梁",layer:"结构-梁",description:"250×500,跨度 4m"},{id:"16",name:"楼梯间 ST-1",type:"楼梯",layer:"建筑-楼梯",description:"双跑楼梯,净宽 1200mm"},{id:"17",name:"消防楼梯 ST-2",type:"楼梯",layer:"建筑-楼梯",description:"疏散楼梯,净宽 1100mm"},{id:"18",name:"电梯井 EV-1",type:"电梯",layer:"建筑-电梯",description:"客梯,井道 2000×2200"},{id:"19",name:"消防电梯 EV-2",type:"电梯",layer:"建筑-电梯",description:"消防兼客梯"},{id:"20",name:"强电竖井",type:"设备间",layer:"机电-电气",description:"1F~RF,面积 4㎡"},{id:"21",name:"弱电竖井",type:"设备间",layer:"机电-电气",description:"1F~RF,面积 2㎡"},{id:"22",name:"空调机房",type:"设备间",layer:"机电-暖通",description:"BF,面积 80㎡"},{id:"23",name:"消防控制室",type:"设备间",layer:"机电-消防",description:"1F,面积 24㎡"},{id:"24",name:"配电室",type:"设备间",layer:"机电-电气",description:"BF,面积 36㎡"},{id:"25",name:"轴线 A",type:"轴线",layer:"轴网",description:"X 向,间距 8400mm"},{id:"26",name:"轴线 1",type:"轴线",layer:"轴网",description:"Y 向,间距 7200mm"},{id:"27",name:"内墙 Q-001",type:"墙体",layer:"建筑-墙",description:"200mm 砌块"},{id:"28",name:"外墙 Q-101",type:"墙体",layer:"建筑-墙",description:"300mm 保温外墙"},{id:"29",name:"散水 SS-1",type:"室外",layer:"建筑-室外",description:"宽 900mm,坡度 3%"},{id:"30",name:"台阶 TJ-1",type:"室外",layer:"建筑-室外",description:"3 级,踏步 300×150"}];class af{engine;searchUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.searchUI=new rf(t,this))}search(e){const t=e.trim().toLowerCase();return t?of.filter(n=>n.name.toLowerCase().includes(t)||n.type.toLowerCase().includes(t)||(n.layer?.toLowerCase().includes(t)??!1)||(n.description?.toLowerCase().includes(t)??!1)):[]}onResultSelect(e){console.log("[SearchManager] 选中结果:",e)}show(){this.searchUI?.show()}hide(){this.searchUI?.hide()}toggle(){this.searchUI?.toggle()}dispose(){this.searchUI?.dispose(),this.searchUI=null}}const jo={dark:{"--e2d-bg":"#1e1f22","--e2d-bg2":"#252526","--e2d-bg3":"#222222","--e2d-bg-hover":"rgba(79,195,247,0.08)","--e2d-bg-accent":"#094771","--e2d-icon-bg":"rgba(255,255,255,0.08)","--e2d-icon-bg-hover":"rgba(255,255,255,0.16)","--e2d-border":"rgba(255,255,255,0.12)","--e2d-border2":"#333333","--e2d-text":"#e0e0e0","--e2d-text2":"#cccccc","--e2d-text3":"rgba(255,255,255,0.35)","--e2d-text4":"#666666","--e2d-text-accent":"#ffffff","--e2d-accent":"#4fc3f7","--e2d-shadow":"rgba(0,0,0,0.50)","--e2d-shadow-lg":"rgba(0,0,0,0.65)","--e2d-cursor":"rgba(255,255,255,0.85)","--e2d-scrollbar":"rgba(255,255,255,0.15)","--e2d-float-bg":"rgba(0,0,0,0.65)","--e2d-float-border":"rgba(255,255,255,0.08)","--e2d-swatch-border":"#444444","--e2d-close":"#aaaaaa","--e2d-close-hover":"#ffffff","--e2d-icon":"rgba(255,255,255,0.4)","--e2d-coord-value":"#76c8ff","--e2d-coord-label":"rgba(255,255,255,0.45)"},light:{"--e2d-bg":"#ffffff","--e2d-bg2":"#f5f5f5","--e2d-bg3":"#eeeeee","--e2d-bg-hover":"rgba(25,118,210,0.06)","--e2d-bg-accent":"#e3f2fd","--e2d-icon-bg":"rgba(0,0,0,0.06)","--e2d-icon-bg-hover":"rgba(0,0,0,0.12)","--e2d-border":"rgba(0,0,0,0.12)","--e2d-border2":"#e0e0e0","--e2d-text":"#1a1a1a","--e2d-text2":"#444444","--e2d-text3":"rgba(0,0,0,0.40)","--e2d-text4":"#aaaaaa","--e2d-text-accent":"#1565c0","--e2d-accent":"#1976d2","--e2d-shadow":"rgba(0,0,0,0.15)","--e2d-shadow-lg":"rgba(0,0,0,0.22)","--e2d-cursor":"rgba(30,30,30,0.70)","--e2d-scrollbar":"rgba(0,0,0,0.18)","--e2d-float-bg":"rgba(245,245,245,0.92)","--e2d-float-border":"rgba(0,0,0,0.10)","--e2d-swatch-border":"#cccccc","--e2d-close":"#777777","--e2d-close-hover":"#1a1a1a","--e2d-icon":"rgba(0,0,0,0.45)","--e2d-coord-value":"#1976d2","--e2d-coord-label":"rgba(0,0,0,0.50)"}};class lf{container;current;constructor(e,t="dark"){this.container=e,this.current=t,this._apply(t)}_apply(e){const t=jo[e];for(const[n,i]of Object.entries(t))this.container.style.setProperty(n,i);this.container.setAttribute("data-e2d-theme",e)}setTheme(e){this.current=e,this._apply(e)}getTheme(){return this.current}toggle(){this.setTheme(this.current==="dark"?"light":"dark")}dispose(){for(const e of Object.keys(jo[this.current]))this.container.style.removeProperty(e);this.container.removeAttribute("data-e2d-theme")}}class cf{options;container=null;animationId=null;isRendering=!1;fpsFrameCount=0;fpsLastCheck=0;currentFps=0;enablePerformanceMonitoring=!1;events;handelBehaved2d;interactionModule2d;sceneModule2d;cameraModule2d;renderModule2d;controlModule2d;loaderModule2d;layerManager;searchManager;themeManager;cadCursorUI;contextMenuUI;scene=null;camera=null;renderer=null;dwgData=null;version="1.0.0";constructor(e){if(this.options=e,this.enablePerformanceMonitoring=e.enablePerformanceMonitoring??!1,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.initialize(),this.handelBehaved2d=qd(this),this.interactionModule2d=new Hd(this),this.interactionModule2d.init(),this.interactionModule2d.active()}initialize(){this.events=new Ld(!1),this.sceneModule2d=new Od(this,this.options),this.scene=this.sceneModule2d.scene,this.cameraModule2d=new Rd(this,this.container),this.camera=this.cameraModule2d.orthographicCamera,this.renderModule2d=new Nd(this,this.container,this.options),this.renderer=this.renderModule2d.renderer,this.controlModule2d=new Ud(this),this.loaderModule2d=new Zd(this),this.themeManager=new lf(this.container),this.layerManager=new Kd(this),this.searchManager=new af(this),this.sceneModule2d.initGrid(),this.cadCursorUI=new Jd(this.container,this.renderer.domElement),this.contextMenuUI=new ef(this.container,this.renderer.domElement,e=>{e==="search"&&this.searchManager.show()}),this.startRendering(),console.log(`[EngineKernel2d] 2D Engine initialized (v${this.version})`)}startRendering(){this.isRendering||(this.isRendering=!0,this.fpsLastCheck=performance.now(),this.animate(),console.log("[EngineKernel2d] Rendering started"))}stopRendering(){this.isRendering=!1,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),console.log("[EngineKernel2d] Rendering stopped")}animate=()=>{this.isRendering&&(this.animationId=requestAnimationFrame(this.animate),this.controlModule2d.update(),this.scene&&this.camera&&this.renderer&&this.renderer.render(this.scene,this.camera),this.enablePerformanceMonitoring&&this.updatePerformanceStats())};updatePerformanceStats(){this.fpsFrameCount++;const e=performance.now();e-this.fpsLastCheck>=1e3&&(this.currentFps=this.fpsFrameCount,this.fpsFrameCount=0,this.fpsLastCheck=e,this.events.trigger(_n.RenderEnd,{fps:this.currentFps}))}async loadModel(e,t){return await this.loaderModule2d.loadModel(e,t),{}}getLayers(){return this.loaderModule2d.getLayers()}getEntitiesByLayer(e){return this.loaderModule2d.getEntitiesByLayer(e)}setLayerVisible(e,t){console.log(`[EngineKernel2d] Set layer ${e} visible: ${t}`)}setTheme(e){this.themeManager.setTheme(e)}resetView(){this.cameraModule2d&&this.cameraModule2d.resetView()}fitToView(){this.dwgData?.metadata.extents&&this.cameraModule2d.fitToExtents(this.dwgData.metadata.extents)}setZoom(e){this.cameraModule2d&&this.cameraModule2d.setZoom(e)}getZoom(){return this.cameraModule2d?this.cameraModule2d.getZoom():1}getPerformanceStats(){const e=this.sceneModule2d.getSceneStats();return{fps:this.currentFps,renderTime:0,entityCount:e.objectCount,visibleEntityCount:e.objectCount}}setBackgroundColor(e){this.sceneModule2d&&this.sceneModule2d.setBackgroundColor(e)}clearScene(){this.sceneModule2d&&this.sceneModule2d.clearScene()}resize(){if(this.renderModule2d){const e=this.container?.clientWidth??0,t=this.container?.clientHeight??0;this.renderModule2d.setSize(e,t)}}dispose(){console.log("[EngineKernel2d] Disposing engine..."),this.stopRendering(),this.cadCursorUI?.dispose(),this.contextMenuUI?.dispose(),this.searchManager?.dispose(),this.themeManager?.dispose(),this.loaderModule2d?.dispose(),this.controlModule2d?.dispose(),this.renderModule2d?.dispose(),this.cameraModule2d?.dispose(),this.sceneModule2d?.dispose(),this.events?.dispose(),this.scene=null,this.camera=null,this.renderer=null,this.dwgData=null,console.log("[EngineKernel2d] Engine disposed")}}class hf{scene;panoramaSphere=null;sphereRadius;constructor(e=500){this.sphereRadius=e,this.scene=new b.Scene,this.init()}init(){this.panoramaSphere=this.createPanoramaSphere(this.sphereRadius),this.scene.add(this.panoramaSphere)}createPanoramaSphere(e=500,t=64){const n=new b.SphereGeometry(e,t,t/2);n.scale(-1,1,1);const i=new b.MeshBasicMaterial({map:null,side:b.FrontSide,transparent:!0}),s=new b.Mesh(n,i);return s.name="panorama-sphere",s}updatePanoramaTexture(e){if(!this.panoramaSphere){console.warn("SceneModule720: Panorama sphere not initialized");return}const t=this.panoramaSphere.material;t.map&&t.map.dispose(),t.map=e,t.needsUpdate=!0}clearPanoramaTexture(){if(!this.panoramaSphere)return;const e=this.panoramaSphere.material;e.map&&(e.map.dispose(),e.map=null,e.needsUpdate=!0)}getScene(){return this.scene}getPanoramaSphere(){return this.panoramaSphere}setSphereRadius(e){if(this.sphereRadius!==e){if(this.sphereRadius=e,this.panoramaSphere){const t=this.panoramaSphere.material,n=t.map;this.scene.remove(this.panoramaSphere),this.panoramaSphere.geometry.dispose(),t.dispose(),n&&n.dispose()}this.panoramaSphere=this.createPanoramaSphere(e),this.scene.add(this.panoramaSphere)}}getSphereRadius(){return this.sphereRadius}dispose(){if(this.panoramaSphere){const e=this.panoramaSphere.material;e.map&&e.map.dispose(),e.dispose(),this.panoramaSphere.geometry.dispose(),this.scene.remove(this.panoramaSphere),this.panoramaSphere=null}this.scene.clear()}}class uf{camera;minFov;maxFov;container;currentPose;constructor(e,t=75,n=30,i=90){this.container=e,this.minFov=n,this.maxFov=i,this.currentPose={theta:0,phi:0},this.camera=this.createCamera(t),this.init()}createCamera(e){const t=this.container.clientWidth/this.container.clientHeight,n=new b.PerspectiveCamera(e,t,.1,2e3);return n.position.set(0,0,0),n}init(){this.updateCameraRotation()}updateCameraRotation(){const{theta:e,phi:t}=this.currentPose,n=new b.Euler(t,e,0,"YXZ"),i=new b.Quaternion;i.setFromEuler(n),this.camera.quaternion.copy(i)}setFov(e){const t=Math.max(this.minFov,Math.min(this.maxFov,e));this.camera.fov=t,this.camera.updateProjectionMatrix()}getFov(){return this.camera.fov}getCameraPose(){return{...this.currentPose}}setCameraPose(e,t){this.currentPose.theta=e,this.currentPose.phi=t,this.updateCameraRotation()}updatePose(e,t){this.currentPose.theta+=e,this.currentPose.phi+=t,this.currentPose.theta<0?this.currentPose.theta+=2*Math.PI:this.currentPose.theta>=2*Math.PI&&(this.currentPose.theta-=2*Math.PI),this.currentPose.phi=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,this.currentPose.phi)),this.updateCameraRotation()}getCamera(){return this.camera}updateAspectRatio(e,t){const n=e/t;this.camera.aspect=n,this.camera.updateProjectionMatrix()}dispose(){this.camera=null}}class df{renderer;container;animationId=null;isRenderingPaused=!1;fpsFrameCount=0;fpsLastTime=performance.now();currentFps=60;onBeforeRenderCallback;onAfterRenderCallback;constructor(e,t=!0){this.container=e,this.renderer=this.createRenderer(t),this.init()}createRenderer(e){const t=new b.WebGLRenderer({antialias:e,alpha:!0,preserveDrawingBuffer:!1}),n=this.container.clientWidth,i=this.container.clientHeight;return t.setSize(n,i),t.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.container.appendChild(t.domElement),t}init(){}setOnBeforeRender(e){this.onBeforeRenderCallback=e}setOnAfterRender(e){this.onAfterRenderCallback=e}render(e,t){this.onBeforeRenderCallback&&this.onBeforeRenderCallback(),this.renderer.render(e,t),this.onAfterRenderCallback&&this.onAfterRenderCallback(),this.updateFps()}startRenderLoop(e,t){if(this.animationId!==null){console.warn("RenderModule720: Render loop already running");return}this.isRenderingPaused=!1,this.animate(e,t)}animate(e,t){this.isRenderingPaused||(this.animationId=requestAnimationFrame(()=>{this.animate(e,t)}),this.render(e,t))}pauseRendering(){this.isRenderingPaused=!0,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}resumeRendering(e,t){this.isRenderingPaused&&(this.isRenderingPaused=!1,this.startRenderLoop(e,t))}isRenderingPausedState(){return this.isRenderingPaused}updateFps(){this.fpsFrameCount++;const e=performance.now();e>=this.fpsLastTime+1e3&&(this.currentFps=Math.round(this.fpsFrameCount*1e3/(e-this.fpsLastTime)),this.fpsFrameCount=0,this.fpsLastTime=e,this.currentFps<30&&console.warn("RenderModule720: Low FPS detected:",this.currentFps))}getCurrentFps(){return this.currentFps}resize(e,t){this.renderer.setSize(e,t),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2))}getDomElement(){return this.renderer.domElement}getRenderer(){return this.renderer}dispose(){this.pauseRendering(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss(),this.onBeforeRenderCallback=void 0,this.onAfterRenderCallback=void 0}}class ff{camera;domElement;cameraModule;enableZoom=!0;enableRotate=!0;minFov=30;maxFov=90;rotateSpeed=.5;zoomSpeed=1;enableDamping=!0;dampingFactor=.05;isDragging=!1;startX=0;startY=0;thetaDelta=0;phiDelta=0;isPinching=!1;pinchStartDistance=null;pinchStartFov=75;_onMouseDown;_onMouseMove;_onMouseUp;_onWheel;_onTouchStart;_onTouchMove;_onTouchEnd;onViewAngleChange;constructor(e,t){this.cameraModule=e,this.camera=e.getCamera(),this.pinchStartFov=this.camera.fov,this.domElement=t,this._onMouseDown=this.onMouseDown.bind(this),this._onMouseMove=this.onMouseMove.bind(this),this._onMouseUp=this.onMouseUp.bind(this),this._onWheel=this.onWheel.bind(this),this._onTouchStart=this.onTouchStart.bind(this),this._onTouchMove=this.onTouchMove.bind(this),this._onTouchEnd=this.onTouchEnd.bind(this),this.init()}init(){this.domElement.addEventListener("mousedown",this._onMouseDown),this.domElement.addEventListener("mousemove",this._onMouseMove),this.domElement.addEventListener("mouseup",this._onMouseUp),this.domElement.addEventListener("mouseleave",this._onMouseUp),this.domElement.addEventListener("wheel",this._onWheel,{passive:!1}),this.domElement.addEventListener("touchstart",this._onTouchStart,{passive:!1}),this.domElement.addEventListener("touchmove",this._onTouchMove,{passive:!1}),this.domElement.addEventListener("touchend",this._onTouchEnd)}onMouseDown(e){e.button===0&&(this.isDragging=!0,this.startX=e.clientX,this.startY=e.clientY)}onMouseMove(e){if(!this.isDragging||!this.enableRotate)return;const t=e.clientX-this.startX,n=e.clientY-this.startY,{horizontal:i,vertical:s}=this.getRotationFactors();this.thetaDelta+=t*i*this.rotateSpeed*.06,this.phiDelta+=n*s*this.rotateSpeed*.06,this.startX=e.clientX,this.startY=e.clientY,this.applyRotation()}onMouseUp(){this.isDragging=!1}onWheel(e){if(!this.enableZoom)return;e.preventDefault();const n=(e.deltaY>0?1:-1)*this.zoomSpeed*2;this.applyZoom(n)}onTouchStart(e){e.touches.length===1?(this.isDragging=!0,this.isPinching=!1,this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):e.touches.length===2&&(e.preventDefault(),this.isDragging=!1,this.isPinching=!0,this.pinchStartDistance=this.getTouchDistance(e.touches),this.pinchStartFov=this.cameraModule.getFov())}onTouchMove(e){if(e.touches.length===1&&this.isDragging&&this.enableRotate){const t=e.touches[0].clientX-this.startX,n=e.touches[0].clientY-this.startY,{horizontal:i,vertical:s}=this.getRotationFactors();this.thetaDelta-=t*i*this.rotateSpeed,this.phiDelta-=n*s*this.rotateSpeed,this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY,this.applyRotation()}else if(e.touches.length===2&&this.enableZoom){e.preventDefault(),this.isPinching||(this.isPinching=!0,this.pinchStartDistance=this.getTouchDistance(e.touches),this.pinchStartFov=this.cameraModule.getFov());const t=this.getTouchDistance(e.touches);if(this.pinchStartDistance&&t>0){const n=this.pinchStartDistance/t,i=b.MathUtils.clamp(this.pinchStartFov*n,this.minFov,this.maxFov);this.cameraModule.setFov(i)}}}onTouchEnd(e){e.touches&&e.touches.length>0?this.isDragging=e.touches.length===1:this.isDragging=!1,e.touches.length<2&&(this.isPinching=!1,this.pinchStartDistance=null)}applyRotation(){if(this.cameraModule.updatePose(this.thetaDelta,this.phiDelta),this.enableDamping?(this.thetaDelta*=1-this.dampingFactor,this.phiDelta*=1-this.dampingFactor):(this.thetaDelta=0,this.phiDelta=0),this.onViewAngleChange){const e=this.cameraModule.getCameraPose();this.onViewAngleChange(e.theta,e.phi)}}getRotationFactors(){const e=Math.max(1,this.domElement.clientWidth),t=Math.max(1,this.domElement.clientHeight);return{horizontal:Math.PI*2/e,vertical:Math.PI/t}}applyZoom(e){const t=this.cameraModule.getFov(),n=b.MathUtils.clamp(t+e,this.minFov,this.maxFov);this.cameraModule.setFov(n)}getTouchDistance(e){if(e.length<2)return 0;const t=e[0].clientX-e[1].clientX,n=e[0].clientY-e[1].clientY;return Math.sqrt(t*t+n*n)}update(){this.enableDamping&&(Math.abs(this.thetaDelta)>1e-4||Math.abs(this.phiDelta)>1e-4)&&this.applyRotation()}lookAt(e,t){this.thetaDelta=e,this.phiDelta=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,t)),this.cameraModule.setCameraPose(e,t),this.thetaDelta=0,this.phiDelta=0}getViewAngle(){return this.cameraModule.getCameraPose()}setOnViewAngleChange(e){this.onViewAngleChange=e}reset(){this.thetaDelta=0,this.phiDelta=0,this.lookAt(0,0)}setRotateSpeed(e){this.rotateSpeed=Math.max(.05,e)}setZoomSpeed(e){this.zoomSpeed=Math.max(.1,e)}setEnableDamping(e){this.enableDamping=e}setDampingFactor(e){this.dampingFactor=Math.max(0,Math.min(1,e))}setZoomLimits(e,t){this.minFov=e,this.maxFov=t}dispose(){this.domElement.removeEventListener("mousedown",this._onMouseDown),this.domElement.removeEventListener("mousemove",this._onMouseMove),this.domElement.removeEventListener("mouseup",this._onMouseUp),this.domElement.removeEventListener("mouseleave",this._onMouseUp),this.domElement.removeEventListener("wheel",this._onWheel),this.domElement.removeEventListener("touchstart",this._onTouchStart),this.domElement.removeEventListener("touchmove",this._onTouchMove),this.domElement.removeEventListener("touchend",this._onTouchEnd),this.onViewAngleChange=void 0}}class pf{controls;domElement;cameraModule;constructor(e,t){this.cameraModule=e,this.domElement=t,this.controls=new ff(e,t)}init(){}active(){}disActive(){this.controls.enableRotate=!1,this.controls.enableZoom=!1}enable(){this.controls.enableRotate=!0,this.controls.enableZoom=!0}update(){this.controls.update()}lookAt(e,t){this.controls.lookAt(e,t)}getViewAngle(){return this.controls.getViewAngle()}setOnViewAngleChange(e){this.controls.setOnViewAngleChange(e)}reset(){this.controls.reset()}getControls(){return this.controls}updateInteractionOptions(e){if(e.rotateSpeed!==void 0&&this.controls.setRotateSpeed(e.rotateSpeed),e.zoomSpeed!==void 0&&this.controls.setZoomSpeed(e.zoomSpeed),e.enableDamping!==void 0&&this.controls.setEnableDamping(e.enableDamping),e.dampingFactor!==void 0&&this.controls.setDampingFactor(e.dampingFactor),e.enableRotate!==void 0&&(this.controls.enableRotate=e.enableRotate),e.enableZoom!==void 0&&(this.controls.enableZoom=e.enableZoom),e.minFov!==void 0||e.maxFov!==void 0){const t=e.minFov??this.controls.minFov,n=e.maxFov??this.controls.maxFov;this.controls.setZoomLimits(t,n)}}dispose(){this.controls.dispose()}}class mf{cache=new Map;loadingPromises=new Map;loadTexture(e){if(this.cache.has(e))return Promise.resolve(this.cache.get(e));if(this.loadingPromises.has(e))return this.loadingPromises.get(e);const t=new Promise((n,i)=>{new b.TextureLoader().load(e,r=>{r.colorSpace=b.SRGBColorSpace,r.minFilter=b.LinearFilter,r.magFilter=b.LinearFilter,this.cache.set(e,r),this.loadingPromises.delete(e),n(r)},void 0,r=>{this.loadingPromises.delete(e),i(r)})});return this.loadingPromises.set(e,t),t}async preloadTextures(e){const t=e.map(n=>this.loadTexture(n));return Promise.all(t)}has(e){return this.cache.has(e)}get(e){return this.cache.get(e)}remove(e){const t=this.cache.get(e);t&&(t.dispose(),this.cache.delete(e))}clear(){this.cache.forEach(e=>e.dispose()),this.cache.clear(),this.loadingPromises.clear()}size(){return this.cache.size}dispose(){this.clear()}}class gf{textureCache;currentUrl=null;loadProgress=0;onProgressCallback;constructor(){this.textureCache=new mf}async loadTexture(e){this.currentUrl=e,this.loadProgress=0,this.onProgressCallback&&this.onProgressCallback(0);try{const t=await this.loadTextureInternal(e);return this.loadProgress=100,this.onProgressCallback&&this.onProgressCallback(100),t}catch(t){throw console.error("PanoramaLoader: Failed to load texture:",t),t}}loadTextureInternal(e){return new Promise((t,n)=>{if(this.textureCache.has(e)){const s=this.textureCache.get(e);if(s){t(s);return}}new b.TextureLoader().load(e,s=>{s.colorSpace=b.SRGBColorSpace,s.minFilter=b.LinearFilter,s.magFilter=b.LinearFilter,this.textureCache.cache.set(e,s),t(s)},s=>{s.total>0&&(this.loadProgress=s.loaded/s.total*100,this.onProgressCallback&&this.onProgressCallback(this.loadProgress))},s=>{n(s)})})}async preloadPanoramas(e){try{await this.textureCache.preloadTextures(e)}catch(t){throw console.error("PanoramaLoader: Failed to preload panoramas:",t),t}}getLoadProgress(){return this.loadProgress}setOnProgress(e){this.onProgressCallback=e}getCurrentUrl(){return this.currentUrl}isCached(e){return this.textureCache.has(e)}getCachedTexture(e){return this.textureCache.get(e)}clearCache(){this.textureCache.clear()}removeCachedTexture(e){this.textureCache.remove(e)}dispose(){this.textureCache.dispose(),this.onProgressCallback=void 0,this.currentUrl=null}}class Go{static sphericalToCartesian(e){const t=e.radius||500,{theta:n,phi:i}=e,s=t*Math.cos(i)*Math.cos(n),r=t*Math.sin(i),a=t*Math.cos(i)*Math.sin(n);return{x:s,y:r,z:a}}static cartesianToSpherical(e,t,n){const i=Math.sqrt(e*e+t*t+n*n),s=Math.asin(t/i);let r=Math.atan2(n,e);return r<0&&(r+=2*Math.PI),{theta:r,phi:s,radius:i}}static normalizeAngle(e,t=-Math.PI,n=Math.PI){const i=n-t;let s=e;for(;s<t;)s+=i;for(;s>n;)s-=i;return s}static clampPhi(e,t=-Math.PI/2+.01,n=Math.PI/2-.01){return Math.max(t,Math.min(n,e))}static sphericalDistance(e,t){const n=Math.sin(e.phi)*Math.sin(t.phi)+Math.cos(e.phi)*Math.cos(t.phi)*Math.cos(e.theta-t.theta);return Math.acos(Math.max(-1,Math.min(1,n)))}static lerpSpherical(e,t,n){let i=t.theta-e.theta;i>Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI);const s=e.theta+i*n,r=e.phi+(t.phi-e.phi)*n,a=e.radius||500,l=t.radius||500,c=a+(l-a)*n;return{theta:s,phi:r,radius:c}}}var Sn=(o=>(o.ICON="icon",o.TEXT="text",o.LINK="link",o))(Sn||{});class yf{annotations=new Map;container;annotationContainer;worldToScreen;sphereRadius;camera;renderer;onClickAnnotation;onHoverAnnotation;constructor(e,t,n,i){this.container=e,this.camera=t,this.renderer=n,this.sphereRadius=i,this.worldToScreen=new De(t,n),this.createAnnotationContainer()}createAnnotationContainer(){this.annotationContainer=document.createElement("div"),this.annotationContainer.className="panorama-annotation-container",this.annotationContainer.style.cssText=`
|
|
1466
|
+
`,o.addEventListener("click",()=>this._selectResult(i)),o.addEventListener("mouseenter",()=>{this.activeIndex=s;const c=this.resultList.querySelectorAll(".engine-2d-search__item");this._highlightItem(c)}),this.resultList.appendChild(o)})}_highlight(e,t){const n=t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return e.replace(new RegExp(`(${n})`,"gi"),'<mark class="engine-2d-search__mark">$1</mark>')}_highlightItem(e){e.forEach((t,n)=>{t.classList.toggle("engine-2d-search__item--active",n===this.activeIndex)}),this.activeIndex>=0&&e[this.activeIndex]?.scrollIntoView({block:"nearest"})}_selectResult(e){this.manager.onResultSelect(e),this.hide()}_clearResults(){this.resultList.innerHTML="",this.resultList.style.display="none",this.statusEl.style.display="none";const e=this.wrapper.querySelector(".engine-2d-search__divider");e.style.display="none",this.currentResults=[],this.activeIndex=-1}show(){this.wrapper.classList.add("engine-2d-search--visible"),requestAnimationFrame(()=>this.input.focus())}hide(){this.wrapper.classList.remove("engine-2d-search--visible"),this._clearResults(),this.input.value="",this.clearBtn.style.opacity="0",this.clearBtn.style.pointerEvents="none"}toggle(){this.wrapper.classList.contains("engine-2d-search--visible")?this.hide():this.show()}dispose(){this.input.removeEventListener("input",this._onInput),this.input.removeEventListener("keydown",this._onKeyDown),this.clearBtn.removeEventListener("click",this._onClear),document.removeEventListener("mousedown",this._onDocMouseDown),document.removeEventListener("keydown",this._onEscape),this.wrapper.parentElement?.removeChild(this.wrapper),this.debounceTimer!==null&&clearTimeout(this.debounceTimer)}}const kf=[{id:"1",name:"会议室 A",type:"房间",layer:"建筑-房间",description:"3F 东侧,面积 48㎡"},{id:"2",name:"会议室 B",type:"房间",layer:"建筑-房间",description:"3F 西侧,面积 32㎡"},{id:"3",name:"卫生间-男",type:"房间",layer:"建筑-房间",description:"2F,面积 18㎡"},{id:"4",name:"卫生间-女",type:"房间",layer:"建筑-房间",description:"2F,面积 16㎡"},{id:"5",name:"大厅",type:"房间",layer:"建筑-房间",description:"1F,面积 260㎡"},{id:"6",name:"主入口门",type:"门",layer:"建筑-门窗",description:"宽 2400mm,双开"},{id:"7",name:"次入口门",type:"门",layer:"建筑-门窗",description:"宽 1200mm,单开"},{id:"8",name:"防火门 FD-01",type:"门",layer:"建筑-门窗",description:"甲级防火,宽 900mm"},{id:"9",name:"落地窗 W-101",type:"窗",layer:"建筑-门窗",description:"高 3000mm,南向"},{id:"10",name:"普通窗 W-201",type:"窗",layer:"建筑-门窗",description:"高 1800mm,东向"},{id:"11",name:"承重柱 Z-A1",type:"柱",layer:"结构-柱",description:"600×600,混凝土"},{id:"12",name:"承重柱 Z-A2",type:"柱",layer:"结构-柱",description:"600×600,混凝土"},{id:"13",name:"钢柱 GZ-01",type:"柱",layer:"结构-柱",description:"H 型钢,H300×150"},{id:"14",name:"主梁 L-1",type:"梁",layer:"结构-梁",description:"400×800,跨度 8m"},{id:"15",name:"次梁 L-2",type:"梁",layer:"结构-梁",description:"250×500,跨度 4m"},{id:"16",name:"楼梯间 ST-1",type:"楼梯",layer:"建筑-楼梯",description:"双跑楼梯,净宽 1200mm"},{id:"17",name:"消防楼梯 ST-2",type:"楼梯",layer:"建筑-楼梯",description:"疏散楼梯,净宽 1100mm"},{id:"18",name:"电梯井 EV-1",type:"电梯",layer:"建筑-电梯",description:"客梯,井道 2000×2200"},{id:"19",name:"消防电梯 EV-2",type:"电梯",layer:"建筑-电梯",description:"消防兼客梯"},{id:"20",name:"强电竖井",type:"设备间",layer:"机电-电气",description:"1F~RF,面积 4㎡"},{id:"21",name:"弱电竖井",type:"设备间",layer:"机电-电气",description:"1F~RF,面积 2㎡"},{id:"22",name:"空调机房",type:"设备间",layer:"机电-暖通",description:"BF,面积 80㎡"},{id:"23",name:"消防控制室",type:"设备间",layer:"机电-消防",description:"1F,面积 24㎡"},{id:"24",name:"配电室",type:"设备间",layer:"机电-电气",description:"BF,面积 36㎡"},{id:"25",name:"轴线 A",type:"轴线",layer:"轴网",description:"X 向,间距 8400mm"},{id:"26",name:"轴线 1",type:"轴线",layer:"轴网",description:"Y 向,间距 7200mm"},{id:"27",name:"内墙 Q-001",type:"墙体",layer:"建筑-墙",description:"200mm 砌块"},{id:"28",name:"外墙 Q-101",type:"墙体",layer:"建筑-墙",description:"300mm 保温外墙"},{id:"29",name:"散水 SS-1",type:"室外",layer:"建筑-室外",description:"宽 900mm,坡度 3%"},{id:"30",name:"台阶 TJ-1",type:"室外",layer:"建筑-室外",description:"3 级,踏步 300×150"}];class Df{engine;searchUI=null;constructor(e){this.engine=e;const t=document.getElementById(e?.options?.containerId??"")??e?.container??null;t&&(this.searchUI=new Tf(t,this))}search(e){const t=e.trim().toLowerCase();return t?kf.filter(n=>n.name.toLowerCase().includes(t)||n.type.toLowerCase().includes(t)||(n.layer?.toLowerCase().includes(t)??!1)||(n.description?.toLowerCase().includes(t)??!1)):[]}onResultSelect(e){console.log("[SearchManager] 选中结果:",e)}show(){this.searchUI?.show()}hide(){this.searchUI?.hide()}toggle(){this.searchUI?.toggle()}dispose(){this.searchUI?.dispose(),this.searchUI=null}}const ea={dark:{"--e2d-bg":"#1e1f22","--e2d-bg2":"#252526","--e2d-bg3":"#222222","--e2d-bg-hover":"rgba(79,195,247,0.08)","--e2d-bg-accent":"#094771","--e2d-icon-bg":"rgba(255,255,255,0.08)","--e2d-icon-bg-hover":"rgba(255,255,255,0.16)","--e2d-border":"rgba(255,255,255,0.12)","--e2d-border2":"#333333","--e2d-text":"#e0e0e0","--e2d-text2":"#cccccc","--e2d-text3":"rgba(255,255,255,0.35)","--e2d-text4":"#666666","--e2d-text-accent":"#ffffff","--e2d-accent":"#4fc3f7","--e2d-shadow":"rgba(0,0,0,0.50)","--e2d-shadow-lg":"rgba(0,0,0,0.65)","--e2d-cursor":"rgba(255,255,255,0.85)","--e2d-scrollbar":"rgba(255,255,255,0.15)","--e2d-float-bg":"rgba(0,0,0,0.65)","--e2d-float-border":"rgba(255,255,255,0.08)","--e2d-swatch-border":"#444444","--e2d-close":"#aaaaaa","--e2d-close-hover":"#ffffff","--e2d-icon":"rgba(255,255,255,0.4)","--e2d-coord-value":"#76c8ff","--e2d-coord-label":"rgba(255,255,255,0.45)"},light:{"--e2d-bg":"#ffffff","--e2d-bg2":"#f5f5f5","--e2d-bg3":"#eeeeee","--e2d-bg-hover":"rgba(25,118,210,0.06)","--e2d-bg-accent":"#e3f2fd","--e2d-icon-bg":"rgba(0,0,0,0.06)","--e2d-icon-bg-hover":"rgba(0,0,0,0.12)","--e2d-border":"rgba(0,0,0,0.12)","--e2d-border2":"#e0e0e0","--e2d-text":"#1a1a1a","--e2d-text2":"#444444","--e2d-text3":"rgba(0,0,0,0.40)","--e2d-text4":"#aaaaaa","--e2d-text-accent":"#1565c0","--e2d-accent":"#1976d2","--e2d-shadow":"rgba(0,0,0,0.15)","--e2d-shadow-lg":"rgba(0,0,0,0.22)","--e2d-cursor":"rgba(30,30,30,0.70)","--e2d-scrollbar":"rgba(0,0,0,0.18)","--e2d-float-bg":"rgba(245,245,245,0.92)","--e2d-float-border":"rgba(0,0,0,0.10)","--e2d-swatch-border":"#cccccc","--e2d-close":"#777777","--e2d-close-hover":"#1a1a1a","--e2d-icon":"rgba(0,0,0,0.45)","--e2d-coord-value":"#1976d2","--e2d-coord-label":"rgba(0,0,0,0.50)"}};class Ef{container;current;constructor(e,t="dark"){this.container=e,this.current=t,this._apply(t)}_apply(e){const t=ea[e];for(const[n,i]of Object.entries(t))this.container.style.setProperty(n,i);this.container.setAttribute("data-e2d-theme",e)}setTheme(e){this.current=e,this._apply(e)}getTheme(){return this.current}toggle(){this.setTheme(this.current==="dark"?"light":"dark")}dispose(){for(const e of Object.keys(ea[this.current]))this.container.style.removeProperty(e);this.container.removeAttribute("data-e2d-theme")}}class Lf{options;container=null;animationId=null;isRendering=!1;fpsFrameCount=0;fpsLastCheck=0;currentFps=0;enablePerformanceMonitoring=!1;modelToolModule2d;engineStatus2d;octreeBox2d;events;handelBehaved2d;interactionModule2d;sceneModule2d;cameraModule2d;renderModule2d;controlModule2d;loaderModule2d;layerManager;searchManager;themeManager;cadCursorUI;contextMenuUI;loadingUI;linkView2d3d;linkElement2d3d;scene=null;camera=null;renderer=null;dwgData=null;version="1.0.0";constructor(e){if(this.options=e,this.enablePerformanceMonitoring=e.enablePerformanceMonitoring??!1,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.initialize(),this.handelBehaved2d=vf(this),this.interactionModule2d=new xf(this),this.interactionModule2d.init(),this.interactionModule2d.active()}initialize(){this.events=new $u(!1),this.sceneModule2d=new lf(this,this.options),this.scene=this.sceneModule2d.scene,this.cameraModule2d=new hf(this,this.container),this.camera=this.cameraModule2d.orthographicCamera,this.renderModule2d=new df(this,this.container,this.options),this.renderer=this.renderModule2d.renderer,this.controlModule2d=new ff(this),this.loaderModule2d=new Jr(this),this.themeManager=new Ef(this.container),this.layerManager=new Hr(this),this.searchManager=new Df(this),this.octreeBox2d=new pf(this),this.modelToolModule2d=new yf(this),this.engineStatus2d=new cf(this),this.linkView2d3d=new mf(this),this.linkElement2d3d=new gf(this),this.sceneModule2d.initGrid(),this.cadCursorUI=new bf(this.container,this.renderer.domElement),this.loadingUI=new Sf(this.container),this.events.on(Ve.ModelLoadStart,()=>this.loadingUI.show("正在加载...",0)),this.events.on(Ve.ModelLoadProgress,e=>this.loadingUI.update(e.text,e.progress)),this.events.on(Ve.ModelLoaded,()=>this.loadingUI.hide()),this.events.on(Ve.ModelLoadError,()=>this.loadingUI.hide()),this.contextMenuUI=new _f(this.container,this.renderer.domElement,e=>{if(e==="search"&&this.searchManager.show(),e==="layerManage"&&this.layerManager.toggle(),e==="hideElement"&&this.modelToolModule2d.hideModel(this.engineStatus2d.highlightModels),e==="showAll"&&this.modelToolModule2d.showModel(this.engineStatus2d.hideModels),e==="toggleBg"){this.themeManager.toggle();const t=this.themeManager.getTheme()==="dark"?1710618:15790320;this.setBackgroundColor(t)}if(e==="linkElement2d3d"){const t=this.linkElement2d3d.toggle();this.contextMenuUI.setMenuItemState("linkElement2d3d",t),console.log(`[EngineKernel2d] 二三维图元联动: ${t?"已开启":"已关闭"}`)}if(e==="linkView2d3d"){const t=this.linkView2d3d.toggle();this.contextMenuUI.setMenuItemState("linkView2d3d",t),console.log(`[EngineKernel2d] 图模关联: ${t?"已开启":"已关闭"}`)}}),this.contextMenuUI.setMenuItemStates({linkElement2d3d:this.linkElement2d3d.isEnabled(),linkView2d3d:this.linkView2d3d.isEnabled()}),this.startRendering(),console.log(`[EngineKernel2d] 2D Engine initialized (v${this.version})`)}startRendering(){this.isRendering||(this.isRendering=!0,this.fpsLastCheck=performance.now(),this.animate(),console.log("[EngineKernel2d] Rendering started"))}stopRendering(){this.isRendering=!1,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),console.log("[EngineKernel2d] Rendering stopped")}animate=()=>{this.isRendering&&(this.animationId=requestAnimationFrame(this.animate),this.controlModule2d.update(),this.scene&&this.camera&&this.renderer&&this.renderer.render(this.scene,this.camera),this.enablePerformanceMonitoring&&this.updatePerformanceStats())};updatePerformanceStats(){this.fpsFrameCount++;const e=performance.now();e-this.fpsLastCheck>=1e3&&(this.currentFps=this.fpsFrameCount,this.fpsFrameCount=0,this.fpsLastCheck=e,this.events.trigger(Ve.RenderEnd,{fps:this.currentFps}))}async loadModel(e,t){return await this.loaderModule2d.loadModel(e,t),{}}getLayers(){return this.loaderModule2d.getLayers()}getEntitiesByLayer(e){return this.loaderModule2d.getEntitiesByLayer(e)}setLayerVisible(e,t){console.log(`[EngineKernel2d] Set layer ${e} visible: ${t}`)}setTheme(e){this.themeManager.setTheme(e)}resetView(){this.cameraModule2d&&this.cameraModule2d.resetView()}fitToView(){this.dwgData?.metadata.extents&&this.cameraModule2d.fitToExtents(this.dwgData.metadata.extents)}setZoom(e){this.cameraModule2d&&this.cameraModule2d.setZoom(e)}getZoom(){return this.cameraModule2d?this.cameraModule2d.getZoom():1}getPerformanceStats(){const e=this.sceneModule2d.getSceneStats();return{fps:this.currentFps,renderTime:0,entityCount:e.objectCount,visibleEntityCount:e.objectCount}}setBackgroundColor(e){this.sceneModule2d&&this.sceneModule2d.setBackgroundColor(e)}clearScene(){this.sceneModule2d&&this.sceneModule2d.clearScene()}resize(){if(this.renderModule2d){const e=this.container?.clientWidth??0,t=this.container?.clientHeight??0;this.renderModule2d.setSize(e,t)}}captureImage(e){if(!this.renderer||!this.sceneModule2d)return console.error("[EngineKernel2d] Renderer or scene module not initialized"),null;const t=this.renderer.domElement,n=e?.format||"png",i=e?.quality||.92,s=`image/${n==="jpeg"?"jpeg":n}`,o=e?.transparent??!1,a=e?.hideGrid??!0,l=e?.hideAxes??!0,c=this.scene?.background??null;let h=!1,u=!1;this.sceneModule2d.adaptiveGrid&&(h=this.sceneModule2d.adaptiveGrid.gridGroup?.visible??!1,a&&this.sceneModule2d.adaptiveGrid.setVisible(!1)),this.sceneModule2d.axesHelper&&(u=this.sceneModule2d.axesHelper.visible??!1,l&&this.sceneModule2d.setAxesVisible(!1)),o&&this.scene&&(this.scene.background=null),this.scene&&this.camera&&this.renderer.render(this.scene,this.camera);const m=t.toDataURL(s,i);this.scene&&(this.scene.background=c),this.sceneModule2d.adaptiveGrid&&a&&this.sceneModule2d.adaptiveGrid.setVisible(h),this.sceneModule2d.axesHelper&&l&&this.sceneModule2d.setAxesVisible(u),this.scene&&this.camera&&this.renderer.render(this.scene,this.camera);const p={dataURL:m};if(e?.download){const f=e.filename||`capture-${Date.now()}.${n}`,d=document.createElement("a");d.href=m,d.download=f,d.style.display="none",document.body.appendChild(d),d.click(),d.remove(),console.log(`[EngineKernel2d] Image captured and downloaded: ${f}`)}else console.log("[EngineKernel2d] Image captured");return p}async captureImageAsync(e){if(!this.renderer||!this.sceneModule2d)return console.error("[EngineKernel2d] Renderer or scene module not initialized"),null;const t=this.renderer.domElement,n=e?.format||"png",i=e?.quality||.92,s=`image/${n==="jpeg"?"jpeg":n}`,o=e?.transparent??!1,a=e?.hideGrid??!0,l=e?.hideAxes??!0,c=this.scene?.background??null;let h=!1,u=!1;this.sceneModule2d.adaptiveGrid&&(h=this.sceneModule2d.adaptiveGrid.gridGroup?.visible??!1,a&&this.sceneModule2d.adaptiveGrid.setVisible(!1)),this.sceneModule2d.axesHelper&&(u=this.sceneModule2d.axesHelper.visible??!1,l&&this.sceneModule2d.setAxesVisible(!1)),o&&this.scene&&(this.scene.background=null),this.scene&&this.camera&&this.renderer.render(this.scene,this.camera);const m=t.toDataURL(s,i),p=await new Promise(d=>{t.toBlob(g=>{g&&d(g)},s,i)}),f=URL.createObjectURL(p);if(this.scene&&(this.scene.background=c),this.sceneModule2d.adaptiveGrid&&a&&this.sceneModule2d.adaptiveGrid.setVisible(h),this.sceneModule2d.axesHelper&&l&&this.sceneModule2d.setAxesVisible(u),this.scene&&this.camera&&this.renderer.render(this.scene,this.camera),e?.download){const d=e.filename||`capture-${Date.now()}.${n}`,g=document.createElement("a");g.href=f,g.download=d,g.style.display="none",document.body.appendChild(g),g.click(),g.remove(),console.log(`[EngineKernel2d] Image captured and downloaded: ${d}`)}else console.log("[EngineKernel2d] Image captured with Blob URL:",f);return{dataURL:m,blobURL:f,blob:p}}dispose(){console.log("[EngineKernel2d] Disposing engine..."),this.stopRendering(),this.cadCursorUI?.dispose(),this.contextMenuUI?.dispose(),this.loadingUI?.dispose(),this.searchManager?.dispose(),this.themeManager?.dispose(),this.loaderModule2d?.dispose(),this.controlModule2d?.dispose(),this.renderModule2d?.dispose(),this.cameraModule2d?.dispose(),this.sceneModule2d?.dispose(),this.events?.dispose(),this.scene=null,this.camera=null,this.renderer=null,this.dwgData=null,console.log("[EngineKernel2d] Engine disposed")}}class If{scene;panoramaSphere=null;sphereRadius;constructor(e=500){this.sphereRadius=e,this.scene=new w.Scene,this.init()}init(){this.panoramaSphere=this.createPanoramaSphere(this.sphereRadius),this.scene.add(this.panoramaSphere)}createPanoramaSphere(e=500,t=64){const n=new w.SphereGeometry(e,t,t/2);n.scale(-1,1,1);const i=new w.MeshBasicMaterial({map:null,side:w.FrontSide,transparent:!0}),s=new w.Mesh(n,i);return s.name="panorama-sphere",s}updatePanoramaTexture(e){if(!this.panoramaSphere){console.warn("SceneModule720: Panorama sphere not initialized");return}const t=this.panoramaSphere.material;t.map&&t.map.dispose(),t.map=e,t.needsUpdate=!0}clearPanoramaTexture(){if(!this.panoramaSphere)return;const e=this.panoramaSphere.material;e.map&&(e.map.dispose(),e.map=null,e.needsUpdate=!0)}getScene(){return this.scene}getPanoramaSphere(){return this.panoramaSphere}setSphereRadius(e){if(this.sphereRadius!==e){if(this.sphereRadius=e,this.panoramaSphere){const t=this.panoramaSphere.material,n=t.map;this.scene.remove(this.panoramaSphere),this.panoramaSphere.geometry.dispose(),t.dispose(),n&&n.dispose()}this.panoramaSphere=this.createPanoramaSphere(e),this.scene.add(this.panoramaSphere)}}getSphereRadius(){return this.sphereRadius}dispose(){if(this.panoramaSphere){const e=this.panoramaSphere.material;e.map&&e.map.dispose(),e.dispose(),this.panoramaSphere.geometry.dispose(),this.scene.remove(this.panoramaSphere),this.panoramaSphere=null}this.scene.clear()}}class zf{camera;minFov;maxFov;container;currentPose;constructor(e,t=75,n=30,i=90){this.container=e,this.minFov=n,this.maxFov=i,this.currentPose={theta:0,phi:0},this.camera=this.createCamera(t),this.init()}createCamera(e){const t=this.container.clientWidth/this.container.clientHeight,n=new w.PerspectiveCamera(e,t,.1,2e3);return n.position.set(0,0,0),n}init(){this.updateCameraRotation()}updateCameraRotation(){const{theta:e,phi:t}=this.currentPose,n=new w.Euler(t,e,0,"YXZ"),i=new w.Quaternion;i.setFromEuler(n),this.camera.quaternion.copy(i)}setFov(e){const t=Math.max(this.minFov,Math.min(this.maxFov,e));this.camera.fov=t,this.camera.updateProjectionMatrix()}getFov(){return this.camera.fov}getCameraPose(){return{...this.currentPose}}setCameraPose(e,t){this.currentPose.theta=e,this.currentPose.phi=t,this.updateCameraRotation()}updatePose(e,t){this.currentPose.theta+=e,this.currentPose.phi+=t,this.currentPose.theta<0?this.currentPose.theta+=2*Math.PI:this.currentPose.theta>=2*Math.PI&&(this.currentPose.theta-=2*Math.PI),this.currentPose.phi=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,this.currentPose.phi)),this.updateCameraRotation()}getCamera(){return this.camera}updateAspectRatio(e,t){const n=e/t;this.camera.aspect=n,this.camera.updateProjectionMatrix()}dispose(){this.camera=null}}class Bf{renderer;container;animationId=null;isRenderingPaused=!1;fpsFrameCount=0;fpsLastTime=performance.now();currentFps=60;onBeforeRenderCallback;onAfterRenderCallback;constructor(e,t=!0){this.container=e,this.renderer=this.createRenderer(t),this.init()}createRenderer(e){const t=new w.WebGLRenderer({antialias:e,alpha:!0,preserveDrawingBuffer:!1}),n=this.container.clientWidth,i=this.container.clientHeight;return t.setSize(n,i),t.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.container.appendChild(t.domElement),t}init(){}setOnBeforeRender(e){this.onBeforeRenderCallback=e}setOnAfterRender(e){this.onAfterRenderCallback=e}render(e,t){this.onBeforeRenderCallback&&this.onBeforeRenderCallback(),this.renderer.render(e,t),this.onAfterRenderCallback&&this.onAfterRenderCallback(),this.updateFps()}startRenderLoop(e,t){if(this.animationId!==null){console.warn("RenderModule720: Render loop already running");return}this.isRenderingPaused=!1,this.animate(e,t)}animate(e,t){this.isRenderingPaused||(this.animationId=requestAnimationFrame(()=>{this.animate(e,t)}),this.render(e,t))}pauseRendering(){this.isRenderingPaused=!0,this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}resumeRendering(e,t){this.isRenderingPaused&&(this.isRenderingPaused=!1,this.startRenderLoop(e,t))}isRenderingPausedState(){return this.isRenderingPaused}updateFps(){this.fpsFrameCount++;const e=performance.now();e>=this.fpsLastTime+1e3&&(this.currentFps=Math.round(this.fpsFrameCount*1e3/(e-this.fpsLastTime)),this.fpsFrameCount=0,this.fpsLastTime=e,this.currentFps<30&&console.warn("RenderModule720: Low FPS detected:",this.currentFps))}getCurrentFps(){return this.currentFps}resize(e,t){this.renderer.setSize(e,t),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2))}getDomElement(){return this.renderer.domElement}getRenderer(){return this.renderer}dispose(){this.pauseRendering(),this.container.contains(this.renderer.domElement)&&this.container.removeChild(this.renderer.domElement),this.renderer.dispose(),this.renderer.forceContextLoss(),this.onBeforeRenderCallback=void 0,this.onAfterRenderCallback=void 0}}class Rf{camera;domElement;cameraModule;enableZoom=!0;enableRotate=!0;minFov=30;maxFov=90;rotateSpeed=.5;zoomSpeed=1;enableDamping=!0;dampingFactor=.05;isDragging=!1;startX=0;startY=0;thetaDelta=0;phiDelta=0;isPinching=!1;pinchStartDistance=null;pinchStartFov=75;_onMouseDown;_onMouseMove;_onMouseUp;_onWheel;_onTouchStart;_onTouchMove;_onTouchEnd;onViewAngleChange;constructor(e,t){this.cameraModule=e,this.camera=e.getCamera(),this.pinchStartFov=this.camera.fov,this.domElement=t,this._onMouseDown=this.onMouseDown.bind(this),this._onMouseMove=this.onMouseMove.bind(this),this._onMouseUp=this.onMouseUp.bind(this),this._onWheel=this.onWheel.bind(this),this._onTouchStart=this.onTouchStart.bind(this),this._onTouchMove=this.onTouchMove.bind(this),this._onTouchEnd=this.onTouchEnd.bind(this),this.init()}init(){this.domElement.addEventListener("mousedown",this._onMouseDown),this.domElement.addEventListener("mousemove",this._onMouseMove),this.domElement.addEventListener("mouseup",this._onMouseUp),this.domElement.addEventListener("mouseleave",this._onMouseUp),this.domElement.addEventListener("wheel",this._onWheel,{passive:!1}),this.domElement.addEventListener("touchstart",this._onTouchStart,{passive:!1}),this.domElement.addEventListener("touchmove",this._onTouchMove,{passive:!1}),this.domElement.addEventListener("touchend",this._onTouchEnd)}onMouseDown(e){e.button===0&&(this.isDragging=!0,this.startX=e.clientX,this.startY=e.clientY)}onMouseMove(e){if(!this.isDragging||!this.enableRotate)return;const t=e.clientX-this.startX,n=e.clientY-this.startY,{horizontal:i,vertical:s}=this.getRotationFactors();this.thetaDelta+=t*i*this.rotateSpeed*.06,this.phiDelta+=n*s*this.rotateSpeed*.06,this.startX=e.clientX,this.startY=e.clientY,this.applyRotation()}onMouseUp(){this.isDragging=!1}onWheel(e){if(!this.enableZoom)return;e.preventDefault();const n=(e.deltaY>0?1:-1)*this.zoomSpeed*2;this.applyZoom(n)}onTouchStart(e){e.touches.length===1?(this.isDragging=!0,this.isPinching=!1,this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY):e.touches.length===2&&(e.preventDefault(),this.isDragging=!1,this.isPinching=!0,this.pinchStartDistance=this.getTouchDistance(e.touches),this.pinchStartFov=this.cameraModule.getFov())}onTouchMove(e){if(e.touches.length===1&&this.isDragging&&this.enableRotate){const t=e.touches[0].clientX-this.startX,n=e.touches[0].clientY-this.startY,{horizontal:i,vertical:s}=this.getRotationFactors();this.thetaDelta-=t*i*this.rotateSpeed,this.phiDelta-=n*s*this.rotateSpeed,this.startX=e.touches[0].clientX,this.startY=e.touches[0].clientY,this.applyRotation()}else if(e.touches.length===2&&this.enableZoom){e.preventDefault(),this.isPinching||(this.isPinching=!0,this.pinchStartDistance=this.getTouchDistance(e.touches),this.pinchStartFov=this.cameraModule.getFov());const t=this.getTouchDistance(e.touches);if(this.pinchStartDistance&&t>0){const n=this.pinchStartDistance/t,i=w.MathUtils.clamp(this.pinchStartFov*n,this.minFov,this.maxFov);this.cameraModule.setFov(i)}}}onTouchEnd(e){e.touches&&e.touches.length>0?this.isDragging=e.touches.length===1:this.isDragging=!1,e.touches.length<2&&(this.isPinching=!1,this.pinchStartDistance=null)}applyRotation(){if(this.cameraModule.updatePose(this.thetaDelta,this.phiDelta),this.enableDamping?(this.thetaDelta*=1-this.dampingFactor,this.phiDelta*=1-this.dampingFactor):(this.thetaDelta=0,this.phiDelta=0),this.onViewAngleChange){const e=this.cameraModule.getCameraPose();this.onViewAngleChange(e.theta,e.phi)}}getRotationFactors(){const e=Math.max(1,this.domElement.clientWidth),t=Math.max(1,this.domElement.clientHeight);return{horizontal:Math.PI*2/e,vertical:Math.PI/t}}applyZoom(e){const t=this.cameraModule.getFov(),n=w.MathUtils.clamp(t+e,this.minFov,this.maxFov);this.cameraModule.setFov(n)}getTouchDistance(e){if(e.length<2)return 0;const t=e[0].clientX-e[1].clientX,n=e[0].clientY-e[1].clientY;return Math.sqrt(t*t+n*n)}update(){this.enableDamping&&(Math.abs(this.thetaDelta)>1e-4||Math.abs(this.phiDelta)>1e-4)&&this.applyRotation()}lookAt(e,t){this.thetaDelta=e,this.phiDelta=Math.max(-Math.PI/2+.01,Math.min(Math.PI/2-.01,t)),this.cameraModule.setCameraPose(e,t),this.thetaDelta=0,this.phiDelta=0}getViewAngle(){return this.cameraModule.getCameraPose()}setOnViewAngleChange(e){this.onViewAngleChange=e}reset(){this.thetaDelta=0,this.phiDelta=0,this.lookAt(0,0)}setRotateSpeed(e){this.rotateSpeed=Math.max(.05,e)}setZoomSpeed(e){this.zoomSpeed=Math.max(.1,e)}setEnableDamping(e){this.enableDamping=e}setDampingFactor(e){this.dampingFactor=Math.max(0,Math.min(1,e))}setZoomLimits(e,t){this.minFov=e,this.maxFov=t}dispose(){this.domElement.removeEventListener("mousedown",this._onMouseDown),this.domElement.removeEventListener("mousemove",this._onMouseMove),this.domElement.removeEventListener("mouseup",this._onMouseUp),this.domElement.removeEventListener("mouseleave",this._onMouseUp),this.domElement.removeEventListener("wheel",this._onWheel),this.domElement.removeEventListener("touchstart",this._onTouchStart),this.domElement.removeEventListener("touchmove",this._onTouchMove),this.domElement.removeEventListener("touchend",this._onTouchEnd),this.onViewAngleChange=void 0}}class Of{controls;domElement;cameraModule;constructor(e,t){this.cameraModule=e,this.domElement=t,this.controls=new Rf(e,t)}init(){}active(){}disActive(){this.controls.enableRotate=!1,this.controls.enableZoom=!1}enable(){this.controls.enableRotate=!0,this.controls.enableZoom=!0}update(){this.controls.update()}lookAt(e,t){this.controls.lookAt(e,t)}getViewAngle(){return this.controls.getViewAngle()}setOnViewAngleChange(e){this.controls.setOnViewAngleChange(e)}reset(){this.controls.reset()}getControls(){return this.controls}updateInteractionOptions(e){if(e.rotateSpeed!==void 0&&this.controls.setRotateSpeed(e.rotateSpeed),e.zoomSpeed!==void 0&&this.controls.setZoomSpeed(e.zoomSpeed),e.enableDamping!==void 0&&this.controls.setEnableDamping(e.enableDamping),e.dampingFactor!==void 0&&this.controls.setDampingFactor(e.dampingFactor),e.enableRotate!==void 0&&(this.controls.enableRotate=e.enableRotate),e.enableZoom!==void 0&&(this.controls.enableZoom=e.enableZoom),e.minFov!==void 0||e.maxFov!==void 0){const t=e.minFov??this.controls.minFov,n=e.maxFov??this.controls.maxFov;this.controls.setZoomLimits(t,n)}}dispose(){this.controls.dispose()}}class Nf{cache=new Map;loadingPromises=new Map;loadTexture(e){if(this.cache.has(e))return Promise.resolve(this.cache.get(e));if(this.loadingPromises.has(e))return this.loadingPromises.get(e);const t=new Promise((n,i)=>{new w.TextureLoader().load(e,o=>{o.colorSpace=w.SRGBColorSpace,o.minFilter=w.LinearFilter,o.magFilter=w.LinearFilter,this.cache.set(e,o),this.loadingPromises.delete(e),n(o)},void 0,o=>{this.loadingPromises.delete(e),i(o)})});return this.loadingPromises.set(e,t),t}async preloadTextures(e){const t=e.map(n=>this.loadTexture(n));return Promise.all(t)}has(e){return this.cache.has(e)}get(e){return this.cache.get(e)}remove(e){const t=this.cache.get(e);t&&(t.dispose(),this.cache.delete(e))}clear(){this.cache.forEach(e=>e.dispose()),this.cache.clear(),this.loadingPromises.clear()}size(){return this.cache.size}dispose(){this.clear()}}class Ff{textureCache;currentUrl=null;loadProgress=0;onProgressCallback;constructor(){this.textureCache=new Nf}async loadTexture(e){this.currentUrl=e,this.loadProgress=0,this.onProgressCallback&&this.onProgressCallback(0);try{const t=await this.loadTextureInternal(e);return this.loadProgress=100,this.onProgressCallback&&this.onProgressCallback(100),t}catch(t){throw console.error("PanoramaLoader: Failed to load texture:",t),t}}loadTextureInternal(e){return new Promise((t,n)=>{if(this.textureCache.has(e)){const s=this.textureCache.get(e);if(s){t(s);return}}new w.TextureLoader().load(e,s=>{s.colorSpace=w.SRGBColorSpace,s.minFilter=w.LinearFilter,s.magFilter=w.LinearFilter,this.textureCache.cache.set(e,s),t(s)},s=>{s.total>0&&(this.loadProgress=s.loaded/s.total*100,this.onProgressCallback&&this.onProgressCallback(this.loadProgress))},s=>{n(s)})})}async preloadPanoramas(e){try{await this.textureCache.preloadTextures(e)}catch(t){throw console.error("PanoramaLoader: Failed to preload panoramas:",t),t}}getLoadProgress(){return this.loadProgress}setOnProgress(e){this.onProgressCallback=e}getCurrentUrl(){return this.currentUrl}isCached(e){return this.textureCache.has(e)}getCachedTexture(e){return this.textureCache.get(e)}clearCache(){this.textureCache.clear()}removeCachedTexture(e){this.textureCache.remove(e)}dispose(){this.textureCache.dispose(),this.onProgressCallback=void 0,this.currentUrl=null}}class ta{static sphericalToCartesian(e){const t=e.radius||500,{theta:n,phi:i}=e,s=t*Math.cos(i)*Math.cos(n),o=t*Math.sin(i),a=t*Math.cos(i)*Math.sin(n);return{x:s,y:o,z:a}}static cartesianToSpherical(e,t,n){const i=Math.sqrt(e*e+t*t+n*n),s=Math.asin(t/i);let o=Math.atan2(n,e);return o<0&&(o+=2*Math.PI),{theta:o,phi:s,radius:i}}static normalizeAngle(e,t=-Math.PI,n=Math.PI){const i=n-t;let s=e;for(;s<t;)s+=i;for(;s>n;)s-=i;return s}static clampPhi(e,t=-Math.PI/2+.01,n=Math.PI/2-.01){return Math.max(t,Math.min(n,e))}static sphericalDistance(e,t){const n=Math.sin(e.phi)*Math.sin(t.phi)+Math.cos(e.phi)*Math.cos(t.phi)*Math.cos(e.theta-t.theta);return Math.acos(Math.max(-1,Math.min(1,n)))}static lerpSpherical(e,t,n){let i=t.theta-e.theta;i>Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI);const s=e.theta+i*n,o=e.phi+(t.phi-e.phi)*n,a=e.radius||500,l=t.radius||500,c=a+(l-a)*n;return{theta:s,phi:o,radius:c}}}var An=(r=>(r.ICON="icon",r.TEXT="text",r.LINK="link",r))(An||{});class Uf{annotations=new Map;container;annotationContainer;worldToScreen;sphereRadius;camera;renderer;onClickAnnotation;onHoverAnnotation;constructor(e,t,n,i){this.container=e,this.camera=t,this.renderer=n,this.sphereRadius=i,this.worldToScreen=new _e(t,n),this.createAnnotationContainer()}createAnnotationContainer(){this.annotationContainer=document.createElement("div"),this.annotationContainer.className="panorama-annotation-container",this.annotationContainer.style.cssText=`
|
|
1239
1467
|
position: absolute;
|
|
1240
1468
|
top: 0;
|
|
1241
1469
|
left: 0;
|
|
@@ -1250,7 +1478,7 @@ void main() {
|
|
|
1250
1478
|
cursor: pointer;
|
|
1251
1479
|
transform: translate(-50%, -50%);
|
|
1252
1480
|
transition: opacity 0.2s ease;
|
|
1253
|
-
`,e.type){case
|
|
1481
|
+
`,e.type){case An.ICON:this.createIconAnnotation(n,e);break;case An.TEXT:this.createTextAnnotation(n,e);break;case An.LINK:this.createLinkAnnotation(n,e);break}return this.attachAnnotationEvents(n,t),n}createIconAnnotation(e,t){const n=t.size||{width:40,height:40};e.style.width=`${n.width}px`,e.style.height=`${n.height}px`;const i=document.createElement("img");i.src=t.iconUrl,i.style.cssText=`
|
|
1254
1482
|
width: 100%;
|
|
1255
1483
|
height: 100%;
|
|
1256
1484
|
object-fit: contain;
|
|
@@ -1279,423 +1507,423 @@ void main() {
|
|
|
1279
1507
|
width: 16px;
|
|
1280
1508
|
height: 16px;
|
|
1281
1509
|
display: block;
|
|
1282
|
-
`,e.appendChild(s)}const i=document.createElement("span");i.textContent=t.text||t.url,e.appendChild(i),t.tooltip&&(e.title=t.tooltip)}attachAnnotationEvents(e,t){e.addEventListener("click",n=>{n.stopPropagation();const i=this.annotations.get(t);i&&this.handleClickAnnotation(i)}),e.addEventListener("mouseenter",()=>{const n=this.annotations.get(t);n&&this.handleHoverAnnotation(n)}),e.addEventListener("mouseleave",()=>{this.onHoverAnnotation&&this.onHoverAnnotation(null)})}sphericalToCartesian(e){const t=e.radius??this.sphereRadius;return
|
|
1283
|
-
|
|
1284
|
-
##
|
|
1285
|
-
|
|
1286
|
-
你是一位资深的**AI+BIM
|
|
1287
|
-
|
|
1288
|
-
1. **深度理解BIM引擎架构**:精通BIM引擎的模块化设计、API
|
|
1289
|
-
2.
|
|
1290
|
-
3.
|
|
1291
|
-
4. **技术决策能力**:根据需求特点选择最优的API
|
|
1292
|
-
|
|
1293
|
-
你的职责是通过分析用户需求,生成结构化的执行步骤,指导代码生成模块完成BIM
|
|
1294
|
-
|
|
1295
|
-
##
|
|
1296
|
-
|
|
1297
|
-
如果存在疑问,你就不能输出最终的步骤,只有当你把所有的疑问清楚后,你才可以输出步骤,如果存在疑问,你要以bim模型为载体,不能问一下和bim
|
|
1298
|
-
|
|
1299
|
-
###
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
1.
|
|
1304
|
-
-
|
|
1305
|
-
- 识别涉及到的BIM
|
|
1306
|
-
-
|
|
1307
|
-
-
|
|
1308
|
-
|
|
1309
|
-
2.
|
|
1310
|
-
-
|
|
1311
|
-
-
|
|
1312
|
-
|
|
1313
|
-
3.
|
|
1314
|
-
-
|
|
1315
|
-
-
|
|
1316
|
-
-
|
|
1317
|
-
|
|
1318
|
-
###
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
##question##
|
|
1325
|
-
json
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
**JSON
|
|
1329
|
-
\`\`\`json
|
|
1330
|
-
[
|
|
1331
|
-
{
|
|
1332
|
-
"id": 0
|
|
1333
|
-
"question": "您是否需要设置所有的构件?"
|
|
1334
|
-
"answers": [
|
|
1335
|
-
"A. 是的,设置所有构件"
|
|
1336
|
-
"B. 只设置1F层的构件"
|
|
1337
|
-
"C. 根据特定条件筛选构件"
|
|
1338
|
-
]
|
|
1339
|
-
}
|
|
1340
|
-
{
|
|
1341
|
-
"id": 1
|
|
1342
|
-
"question": "颜色设置的优先级是什么?"
|
|
1343
|
-
"answers": [
|
|
1344
|
-
"A. 按构件类型设置"
|
|
1345
|
-
"B. 按楼层设置"
|
|
1346
|
-
"C. 按自定义属性设置"
|
|
1347
|
-
]
|
|
1348
|
-
}
|
|
1349
|
-
]
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
-
|
|
1354
|
-
-
|
|
1355
|
-
- 问题数量控制在3
|
|
1356
|
-
-
|
|
1357
|
-
-
|
|
1358
|
-
###
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
##steps##
|
|
1365
|
-
json
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
**JSON
|
|
1370
|
-
\`\`\`json
|
|
1371
|
-
[
|
|
1372
|
-
{
|
|
1373
|
-
"id": 0
|
|
1374
|
-
"content": "获取所有桩基模型"
|
|
1375
|
-
"description": "通过modelTree模块遍历模型树,筛选出类型为'桩基'的所有构件,返回构件ID数组和构件对象数组"
|
|
1376
|
-
"output": "{\\"modelIds\\": [\\"id1\\", \\"id2\\", ...], \\"models\\": [modelObject1, modelObject2, ...]}"
|
|
1377
|
-
"dependencies": []
|
|
1378
|
-
"apiModules": ["modelTree", "dataModule"]
|
|
1379
|
-
}
|
|
1380
|
-
{
|
|
1381
|
-
"id": 1
|
|
1382
|
-
"content": "设置桩基模型颜色为红色"
|
|
1383
|
-
"description": "使用modelMapperBatch模块的批量设置方法,将上一步获取的所有桩基模型的颜色属性设置为红色(RGB: 255, 0, 0)"
|
|
1384
|
-
"output": "{\\"success\\": true, \\"count\\": 10, \\"failedIds\\": []}"
|
|
1385
|
-
"dependencies": [0]
|
|
1386
|
-
"apiModules": ["modelMapperBatch"]
|
|
1387
|
-
}
|
|
1388
|
-
]
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
- \`id\`: 步骤唯一标识符,从0
|
|
1393
|
-
- \`content\`:
|
|
1394
|
-
- \`description\`:
|
|
1395
|
-
-
|
|
1396
|
-
- 使用哪些API
|
|
1397
|
-
-
|
|
1398
|
-
-
|
|
1399
|
-
- \`output\`: 步骤输出的数据格式说明(JSON Schema
|
|
1400
|
-
-
|
|
1401
|
-
-
|
|
1402
|
-
- \`dependencies\`: 依赖的步骤ID
|
|
1403
|
-
- \`apiModules\`: 此步骤涉及到的BIM引擎模块名称数组(如:modelTree, cameraModule, measure
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
1.
|
|
1407
|
-
2.
|
|
1408
|
-
3.
|
|
1409
|
-
4.
|
|
1410
|
-
5. **模块化**:合理利用BIM引擎的模块化设计,选择最合适的API
|
|
1411
|
-
6.
|
|
1412
|
-
|
|
1413
|
-
##
|
|
1414
|
-
|
|
1415
|
-
### 1.
|
|
1416
|
-
- **必须严格遵循**上述JSON
|
|
1417
|
-
- JSON
|
|
1418
|
-
- 步骤ID必须连续且从0
|
|
1419
|
-
-
|
|
1420
|
-
|
|
1421
|
-
### 2.
|
|
1422
|
-
-
|
|
1423
|
-
- **上下文感知**:结合BIM引擎的特性,理解每个需求在BIM
|
|
1424
|
-
- **技术可行性**:确保规划的步骤在BIM引擎API
|
|
1425
|
-
|
|
1426
|
-
### 3.
|
|
1427
|
-
-
|
|
1428
|
-
-
|
|
1429
|
-
-
|
|
1430
|
-
- **效率性**:优先选择高效的API
|
|
1431
|
-
|
|
1432
|
-
### 4.
|
|
1433
|
-
-
|
|
1434
|
-
-
|
|
1435
|
-
- 验证API
|
|
1436
|
-
-
|
|
1437
|
-
|
|
1438
|
-
### 5.
|
|
1439
|
-
-
|
|
1440
|
-
- 输出格式说明要具体,使用JSON Schema
|
|
1441
|
-
- 明确标注使用的API
|
|
1442
|
-
|
|
1443
|
-
##
|
|
1444
|
-
|
|
1445
|
-
1.
|
|
1446
|
-
2. **模块优先**:优先使用BIM引擎提供的功能模块,而不是底层API
|
|
1447
|
-
3.
|
|
1448
|
-
4.
|
|
1449
|
-
5.
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
''`},Symbol.toStringTag,{value:"Module"})),
|
|
1453
|
-
|
|
1454
|
-
##
|
|
1455
|
-
|
|
1456
|
-
你是一位资深的**BIM
|
|
1457
|
-
|
|
1458
|
-
1. **BIM引擎API精通**:深度掌握BIM引擎的所有模块API
|
|
1459
|
-
2. **代码生成能力**:能够根据步骤描述,生成高质量、可执行、符合规范的JavaScript
|
|
1460
|
-
3.
|
|
1461
|
-
4.
|
|
1462
|
-
5.
|
|
1463
|
-
|
|
1464
|
-
你的职责是根据步骤规划模块提供的步骤描述,生成可直接在BIM引擎环境中执行的JavaScript
|
|
1465
|
-
|
|
1466
|
-
##
|
|
1467
|
-
|
|
1468
|
-
###
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
1.
|
|
1473
|
-
- 理解步骤的\`content\`(简短描述)和\`description
|
|
1474
|
-
- 识别步骤涉及到的BIM引擎模块(\`apiModules
|
|
1475
|
-
- 理解步骤的依赖关系(\`dependencies
|
|
1476
|
-
- 明确步骤的预期输出格式(\`output
|
|
1477
|
-
|
|
1478
|
-
2.
|
|
1479
|
-
-
|
|
1480
|
-
-
|
|
1481
|
-
-
|
|
1482
|
-
|
|
1483
|
-
3.
|
|
1484
|
-
- 根据步骤描述,选择最合适的BIM引擎API
|
|
1485
|
-
-
|
|
1486
|
-
-
|
|
1487
|
-
|
|
1488
|
-
###
|
|
1489
|
-
|
|
1490
|
-
根据步骤要求生成可执行的JavaScript
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
##code
|
|
1495
|
-
[可执行的JavaScript代码]
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
1.
|
|
1501
|
-
- 代码必须是一个完整的、可执行的JavaScript
|
|
1502
|
-
- 可以是函数、立即执行函数(IIFE
|
|
1503
|
-
-
|
|
1504
|
-
|
|
1505
|
-
2.
|
|
1506
|
-
- 假设BIM引擎实例通过变量\`engine
|
|
1507
|
-
- 通过\`engine.moduleName
|
|
1508
|
-
- 例如:\`engine.modelTree\`、\`engine.cameraModule\`、\`engine.measure
|
|
1509
|
-
|
|
1510
|
-
3.
|
|
1511
|
-
-
|
|
1512
|
-
- 假设前序步骤的输出数据存储在变量\`previousStepOutput\`中(如果是第一步,则为\`null
|
|
1513
|
-
- 需要根据\`output
|
|
1514
|
-
|
|
1515
|
-
4. **API
|
|
1516
|
-
- 严格按照BIM引擎API文档使用API
|
|
1517
|
-
-
|
|
1518
|
-
- 处理API
|
|
1519
|
-
|
|
1520
|
-
5.
|
|
1521
|
-
- 代码执行后,必须返回符合步骤\`output
|
|
1522
|
-
- 使用\`return
|
|
1523
|
-
- 返回的数据必须是可序列化的(JSON
|
|
1524
|
-
|
|
1525
|
-
6.
|
|
1526
|
-
-
|
|
1527
|
-
- 使用try-catch
|
|
1528
|
-
-
|
|
1529
|
-
-
|
|
1530
|
-
|
|
1531
|
-
7.
|
|
1532
|
-
-
|
|
1533
|
-
- 变量命名要有意义,符合JavaScript
|
|
1534
|
-
-
|
|
1535
|
-
- 优先使用可读性高的写法,而不是过于"高级"
|
|
1536
|
-
|
|
1537
|
-
##
|
|
1538
|
-
|
|
1539
|
-
### 1.
|
|
1540
|
-
- **单一代码块**:输出必须且只能包含一个JavaScript
|
|
1541
|
-
-
|
|
1542
|
-
-
|
|
1543
|
-
|
|
1544
|
-
### 2.
|
|
1545
|
-
-
|
|
1546
|
-
- **输出格式**:严格按照步骤\`output
|
|
1547
|
-
-
|
|
1548
|
-
|
|
1549
|
-
### 3. API
|
|
1550
|
-
- **准确性**:API
|
|
1551
|
-
- **模块识别**:正确识别和使用BIM
|
|
1552
|
-
-
|
|
1553
|
-
|
|
1554
|
-
### 4.
|
|
1555
|
-
- **异常捕获**:所有可能抛出异常的操作都要有try-catch
|
|
1556
|
-
-
|
|
1557
|
-
-
|
|
1558
|
-
-
|
|
1559
|
-
|
|
1560
|
-
### 5.
|
|
1561
|
-
-
|
|
1562
|
-
-
|
|
1563
|
-
-
|
|
1564
|
-
-
|
|
1565
|
-
|
|
1566
|
-
##
|
|
1567
|
-
|
|
1568
|
-
### 示例1
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
\`\`\`json
|
|
1572
|
-
{
|
|
1573
|
-
"id": 0
|
|
1574
|
-
"content": "获取所有桩基模型"
|
|
1575
|
-
"description": "通过modelTree模块遍历模型树,筛选出类型为'桩基'的所有构件"
|
|
1576
|
-
"output": "{\\"modelIds\\": [\\"id1\\", \\"id2\\"], \\"models\\": [modelObject1, modelObject2]}"
|
|
1577
|
-
"dependencies": []
|
|
1578
|
-
"apiModules": ["modelTree"]
|
|
1579
|
-
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
\`\`\`javascript
|
|
1584
|
-
//
|
|
1585
|
-
try {
|
|
1586
|
-
//
|
|
1587
|
-
const modelTree = engine.modelTree
|
|
1588
|
-
if (!modelTree) {
|
|
1589
|
-
throw new Error('模型树模块未初始化')
|
|
1590
|
-
}
|
|
1591
|
-
|
|
1592
|
-
//
|
|
1593
|
-
const allModels = modelTree.getAllModels()
|
|
1594
|
-
if (!allModels || allModels.length === 0) {
|
|
1595
|
-
return {
|
|
1596
|
-
modelIds: []
|
|
1597
|
-
models: []
|
|
1598
|
-
}
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
|
-
//
|
|
1602
|
-
const pileModels = []
|
|
1603
|
-
const pileModelIds = []
|
|
1604
|
-
|
|
1605
|
-
for (let i = 0; i < allModels.length; i++) {
|
|
1606
|
-
const model = allModels[i]
|
|
1607
|
-
//
|
|
1608
|
-
const modelType = model.getProperty('类型') || model.getProperty('category')
|
|
1609
|
-
if (modelType && (modelType.includes('桩基') || modelType.includes('Pile'))) {
|
|
1610
|
-
pileModels.push(model)
|
|
1611
|
-
pileModelIds.push(model.id || model.uuid)
|
|
1612
|
-
}
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
//
|
|
1616
|
-
return {
|
|
1617
|
-
modelIds: pileModelIds
|
|
1618
|
-
models: pileModels
|
|
1619
|
-
}
|
|
1620
|
-
} catch (error) {
|
|
1621
|
-
console.error('获取桩基模型失败:', error)
|
|
1622
|
-
return {
|
|
1623
|
-
modelIds: []
|
|
1624
|
-
models: []
|
|
1625
|
-
error: error.message
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
### 示例2
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
\`\`\`json
|
|
1634
|
-
{
|
|
1635
|
-
"id": 1
|
|
1636
|
-
"content": "设置桩基模型颜色为红色"
|
|
1637
|
-
"description": "使用modelMapperBatch模块批量设置上一步获取的桩基模型颜色"
|
|
1638
|
-
"output": "{\\"success\\": true, \\"count\\": 10}"
|
|
1639
|
-
"dependencies": [0]
|
|
1640
|
-
"apiModules": ["modelMapperBatch"]
|
|
1641
|
-
}
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
\`\`\`javascript
|
|
1646
|
-
//
|
|
1647
|
-
try {
|
|
1648
|
-
//
|
|
1649
|
-
if (!previousStepOutput || !previousStepOutput.modelIds) {
|
|
1650
|
-
throw new Error('前序步骤输出数据无效,缺少modelIds字段')
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
const modelIds = previousStepOutput.modelIds
|
|
1654
|
-
if (modelIds.length === 0) {
|
|
1655
|
-
return {
|
|
1656
|
-
success: true
|
|
1657
|
-
count: 0
|
|
1658
|
-
message: '没有需要设置的模型'
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
//
|
|
1663
|
-
const modelMapperBatch = engine.modelMapperBatch
|
|
1664
|
-
if (!modelMapperBatch) {
|
|
1665
|
-
throw new Error('批量映射模块未初始化')
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
// 设置颜色为红色 (RGB: 255, 0, 0)
|
|
1669
|
-
const redColor = { r: 255, g: 0, b: 0 }
|
|
1670
|
-
|
|
1671
|
-
//
|
|
1672
|
-
const result = modelMapperBatch.setModelColor(modelIds, redColor)
|
|
1673
|
-
|
|
1674
|
-
return {
|
|
1675
|
-
success: result.success !== false
|
|
1676
|
-
count: result.count || modelIds.length
|
|
1677
|
-
failedIds: result.failedIds || []
|
|
1678
|
-
}
|
|
1679
|
-
} catch (error) {
|
|
1680
|
-
console.error('设置模型颜色失败:', error)
|
|
1681
|
-
return {
|
|
1682
|
-
success: false
|
|
1683
|
-
count: 0
|
|
1684
|
-
error: error.message
|
|
1685
|
-
}
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
##
|
|
1690
|
-
|
|
1691
|
-
1.
|
|
1692
|
-
2. **查阅API文档**:不确定的API用法,参考BIM引擎API
|
|
1693
|
-
3.
|
|
1694
|
-
4.
|
|
1695
|
-
5. **代码可读性**:优先保证代码的可读性,而不是追求"高级"
|
|
1696
|
-
6.
|
|
1697
|
-
7.
|
|
1698
|
-
8. **测试友好**:生成的代码应该便于测试和调试 `},Symbol.toStringTag,{value:"Module"})),
|
|
1510
|
+
`,e.appendChild(s)}const i=document.createElement("span");i.textContent=t.text||t.url,e.appendChild(i),t.tooltip&&(e.title=t.tooltip)}attachAnnotationEvents(e,t){e.addEventListener("click",n=>{n.stopPropagation();const i=this.annotations.get(t);i&&this.handleClickAnnotation(i)}),e.addEventListener("mouseenter",()=>{const n=this.annotations.get(t);n&&this.handleHoverAnnotation(n)}),e.addEventListener("mouseleave",()=>{this.onHoverAnnotation&&this.onHoverAnnotation(null)})}sphericalToCartesian(e){const t=e.radius??this.sphereRadius;return ta.sphericalToCartesian({...e,radius:t})}updateAnnotationPosition(e){const t=new w.Vector3(e.worldPosition.x,e.worldPosition.y,e.worldPosition.z),n=this.worldToScreen.worldToScreen(t);e.screenPosition={x:n.x,y:n.y};const i=this.isPositionInFront(t),s=this.isPositionInView(n);e.visible=i&&s,e.visible?(e.element.style.display="block",e.element.style.left=`${n.x}px`,e.element.style.top=`${n.y}px`):e.element.style.display="none"}isPositionInFront(e){const t=new w.Vector3;return this.camera.getWorldDirection(t),e.clone().normalize().dot(t)>0}isPositionInView(e){const t=this.renderer.domElement.clientWidth,n=this.renderer.domElement.clientHeight;return e.x>=0&&e.x<=t&&e.y>=0&&e.y<=n}update(){this.annotations.forEach(e=>{this.updateAnnotationPosition(e)})}handleClickAnnotation(e){if(e.config.type===An.LINK){const t=e.config;window.open(t.url,"_blank")}this.onClickAnnotation&&this.onClickAnnotation(e)}handleHoverAnnotation(e){this.onHoverAnnotation&&this.onHoverAnnotation(e)}setOnClickAnnotation(e){this.onClickAnnotation=e}setOnHoverAnnotation(e){this.onHoverAnnotation=e}removeAnnotation(e){const t=this.annotations.get(e);t&&(t.element.remove(),this.annotations.delete(e))}clearAll(){this.annotations.forEach(e=>{e.element.remove()}),this.annotations.clear()}getAnnotations(){return Array.from(this.annotations.values())}getAnnotation(e){return this.annotations.get(e)}updateCamera(e){this.camera=e,this.worldToScreen.updateCamera(e)}dispose(){this.clearAll(),this.annotationContainer.remove(),this.onClickAnnotation=void 0,this.onHoverAnnotation=void 0}generateId(){return`annotation-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}}class Vf{listeners=new Map;on(e,t){const n=String(e);this.listeners.has(n)||this.listeners.set(n,[]),this.listeners.get(n).push(t)}off(e,t){const n=String(e),i=this.listeners.get(n);if(i){const s=i.indexOf(t);s!==-1&&i.splice(s,1),i.length===0&&this.listeners.delete(n)}}trigger(e,t){const n=String(e),i=this.listeners.get(n);if(i&&i.length>0){const s=[...i];for(const o of s)try{o(t)}catch(a){console.error(`EventModule: Error in event handler for "${n}":`,a)}}}removeAllListeners(e){const t=String(e);this.listeners.delete(t)}clear(){this.listeners.clear()}listenerCount(e){const t=String(e),n=this.listeners.get(t);return n?n.length:0}dispose(){this.clear()}}var st=(r=>(r.PanoramaLoadStart="panorama-load-start",r.PanoramaLoadProgress="panorama-load-progress",r.PanoramaLoaded="panorama-loaded",r.PanoramaLoadError="panorama-load-error",r.AnnotationClick="annotation-click",r.AnnotationHover="annotation-hover",r.AnnotationAdd="annotation-add",r.AnnotationRemove="annotation-remove",r.ViewAngleChanged="view-angle-changed",r))(st||{});class Gf{sceneModule;cameraModule;renderModule;controlModule;eventModule;panoramaLoader;annotationManager;worldToScreen;isInitialized=!1;version="1.0.0";constructor(e){this.initialize(e)}initialize(e){const t={fov:75,enableZoom:!0,enableRotate:!0,minFov:30,maxFov:90,sphereRadius:500,rotateSpeed:.35,zoomSpeed:.8,enableDamping:!0,dampingFactor:.08,...e},n=document.getElementById(t.containerId);if(!n)throw new Error(`Container with id "${t.containerId}" not found`);try{this.eventModule=new Vf,this.sceneModule=new If(t.sphereRadius),this.cameraModule=new zf(n,t.fov,t.minFov,t.maxFov),this.renderModule=new Bf(n,!0),this.controlModule=new Of(this.cameraModule,this.renderModule.getDomElement());const i=this.controlModule.getControls();i.enableZoom=t.enableZoom,i.enableRotate=t.enableRotate,i.setRotateSpeed(t.rotateSpeed),i.setZoomSpeed(t.zoomSpeed),i.setEnableDamping(t.enableDamping),i.setDampingFactor(t.dampingFactor),i.setZoomLimits(t.minFov,t.maxFov),i.setOnViewAngleChange((s,o)=>{this.eventModule.trigger(st.ViewAngleChanged,{theta:s,phi:o})}),this.panoramaLoader=new Ff,this.worldToScreen=new _e(this.cameraModule.getCamera(),this.renderModule.getRenderer(),this.sceneModule.getScene()),this.annotationManager=new Uf(n,this.cameraModule.getCamera(),this.renderModule.getRenderer(),t.sphereRadius),this.annotationManager.setOnClickAnnotation(s=>{this.eventModule.trigger(st.AnnotationClick,{id:s.id,config:s.config,metadata:s.config.metadata})}),this.annotationManager.setOnHoverAnnotation(s=>{this.eventModule.trigger(st.AnnotationHover,{annotation:s?{id:s.id,config:s.config,metadata:s.config.metadata}:null})}),this.setupRenderLoop(),this.isInitialized=!0,console.log("EngineKernel720: Initialized successfully")}catch(i){throw console.error("EngineKernel720: Initialization failed",i),i}}setupRenderLoop(){this.renderModule.setOnBeforeRender(()=>{this.controlModule.update(),this.annotationManager.update()}),this.renderModule.startRenderLoop(this.sceneModule.getScene(),this.cameraModule.getCamera())}async loadPanorama(e){this.checkInitialized(),this.eventModule.trigger(st.PanoramaLoadStart,{url:e});try{this.panoramaLoader.setOnProgress(n=>{this.eventModule.trigger(st.PanoramaLoadProgress,{url:e,progress:n})});const t=await this.panoramaLoader.loadTexture(e);this.sceneModule.updatePanoramaTexture(t),this.eventModule.trigger(st.PanoramaLoaded,{url:e,progress:100}),console.log("EngineKernel720: Panorama loaded successfully")}catch(t){throw console.error("EngineKernel720: Failed to load panorama",t),this.eventModule.trigger(st.PanoramaLoadError,{url:e,error:t}),t}}async preloadPanoramas(e){this.checkInitialized();try{await this.panoramaLoader.preloadPanoramas(e),console.log(`EngineKernel720: Preloaded ${e.length} panoramas`)}catch(t){throw console.error("EngineKernel720: Failed to preload panoramas",t),t}}addAnnotation(e){this.checkInitialized();const t=this.annotationManager.addAnnotation(e);return this.eventModule.trigger(st.AnnotationAdd,{id:t,config:e}),t}addAnnotations(e){return this.checkInitialized(),e.map(t=>this.addAnnotation(t))}removeAnnotation(e){this.checkInitialized(),this.annotationManager.removeAnnotation(e),this.eventModule.trigger(st.AnnotationRemove,{id:e})}clearAnnotations(){this.checkInitialized(),this.annotationManager.clearAll()}getAnnotations(){return this.checkInitialized(),this.annotationManager.getAnnotations()}updateInteractionOptions(e){this.checkInitialized(),this.controlModule.updateInteractionOptions(e)}pickPanoramaPoint(e,t){this.checkInitialized();const i=this.renderModule.getRenderer().domElement,s=i.clientWidth,o=i.clientHeight;if(s===0||o===0)return null;const a=new w.Vector2(e/s*2-1,-(t/o*2-1)),l=this.cameraModule.getCamera(),c=new w.Vector3(a.x,a.y,.5);c.unproject(l),c.sub(l.position).normalize();const h=this.sceneModule.getSphereRadius(),u=l.position.clone().add(c.multiplyScalar(h)),m=ta.cartesianToSpherical(u.x,u.y,u.z);return{theta:m.theta,phi:m.phi,radius:h}}lookAt(e,t,n){this.checkInitialized(),n&&console.warn("EngineKernel720: Animated lookAt not implemented yet"),this.controlModule.lookAt(e,t)}getViewAngle(){return this.checkInitialized(),this.controlModule.getViewAngle()}setFov(e){this.checkInitialized(),this.cameraModule.setFov(e)}getFov(){return this.checkInitialized(),this.cameraModule.getFov()}on(e,t){this.checkInitialized(),this.eventModule.on(e,t)}off(e,t){this.checkInitialized(),this.eventModule.off(e,t)}resize(e,t){this.checkInitialized();const n=e??this.renderModule.getRenderer().domElement.clientWidth,i=t??this.renderModule.getRenderer().domElement.clientHeight;this.renderModule.resize(n,i),this.cameraModule.updateAspectRatio(n,i),console.log("EngineKernel720: Resized to",n,"x",i)}pauseRendering(){this.checkInitialized(),this.renderModule.pauseRendering()}resumeRendering(){this.checkInitialized(),this.renderModule.resumeRendering(this.sceneModule.getScene(),this.cameraModule.getCamera())}isRenderingPausedState(){return this.isInitialized?this.renderModule.isRenderingPausedState():!0}getVersion(){return this.version}dispose(){if(this.isInitialized)try{this.renderModule.pauseRendering(),this.annotationManager.dispose(),this.panoramaLoader.dispose(),this.controlModule.dispose(),this.cameraModule.dispose(),this.renderModule.dispose(),this.sceneModule.dispose(),this.eventModule.dispose(),this.isInitialized=!1,console.log("EngineKernel720: Disposed successfully")}catch(e){console.error("EngineKernel720: Error during dispose",e)}}checkInitialized(){if(!this.isInitialized)throw new Error("EngineKernel720: Not initialized")}}function jf(r){return new sf(r)}function Wf(r){return new Lf(r)}function Xf(r){return new Gf(r)}const Zf=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 需求分析与步骤规划专家
|
|
1511
|
+
|
|
1512
|
+
## 角色定位
|
|
1513
|
+
|
|
1514
|
+
你是一位资深的**AI+BIM轻量化引擎架构专家**,具备以下核心能力:
|
|
1515
|
+
|
|
1516
|
+
1. **深度理解BIM引擎架构**:精通BIM引擎的模块化设计、API体系、数据结构和交互模式
|
|
1517
|
+
2. **需求分析能力**:能够准确理解用户意图,识别模糊需求,提出精准的澄清问题
|
|
1518
|
+
3. **任务分解能力**:将复杂需求拆解为可执行的、原子化的操作步骤
|
|
1519
|
+
4. **技术决策能力**:根据需求特点选择最优的API组合和实现路径
|
|
1520
|
+
|
|
1521
|
+
你的职责是通过分析用户需求,生成结构化的执行步骤,指导代码生成模块完成BIM引擎的功能实现。
|
|
1522
|
+
|
|
1523
|
+
## 工作流程
|
|
1524
|
+
|
|
1525
|
+
如果存在疑问,你就不能输出最终的步骤,只有当你把所有的疑问清楚后,你才可以输出步骤,如果存在疑问,你要以bim模型为载体,不能问一下和bim模型不想干的问题,尽量没有或减少问题
|
|
1526
|
+
|
|
1527
|
+
### 阶段一:需求理解与分析
|
|
1528
|
+
|
|
1529
|
+
当接收到用户需求时,你需要:
|
|
1530
|
+
|
|
1531
|
+
1. **深度分析需求**:
|
|
1532
|
+
- 理解用户的核心目标
|
|
1533
|
+
- 识别涉及到的BIM引擎模块(场景、相机、模型、测量、剖切等)
|
|
1534
|
+
- 分析数据流向和依赖关系
|
|
1535
|
+
- 评估需求的复杂度和可行性
|
|
1536
|
+
|
|
1537
|
+
2. **识别模糊点**:
|
|
1538
|
+
- 检查需求中是否存在歧义、缺失信息或边界条件不明确的情况
|
|
1539
|
+
- 判断是否需要用户澄清才能继续
|
|
1540
|
+
|
|
1541
|
+
3. **决策是否需要提问**:
|
|
1542
|
+
- **仅在必要时提问**:如果需求足够清晰,直接进入步骤规划阶段
|
|
1543
|
+
- **避免过度提问**:不要为了提问而提问,不要询问可以从上下文推断的信息
|
|
1544
|
+
- **精准提问**:每个问题都应该针对关键决策点,影响后续实现路径
|
|
1545
|
+
|
|
1546
|
+
### 阶段二:需求澄清(如需要)
|
|
1547
|
+
|
|
1548
|
+
如果需要用户澄清,请按照以下格式输出:
|
|
1549
|
+
|
|
1550
|
+
**输出格式**:
|
|
1551
|
+
\`\`\`
|
|
1552
|
+
##question##
|
|
1553
|
+
json内容
|
|
1554
|
+
\`\`\`
|
|
1555
|
+
|
|
1556
|
+
**JSON格式规范**:
|
|
1557
|
+
\`\`\`json
|
|
1558
|
+
[
|
|
1559
|
+
{
|
|
1560
|
+
"id": 0,
|
|
1561
|
+
"question": "您是否需要设置所有的构件?",
|
|
1562
|
+
"answers": [
|
|
1563
|
+
"A. 是的,设置所有构件",
|
|
1564
|
+
"B. 只设置1F层的构件",
|
|
1565
|
+
"C. 根据特定条件筛选构件"
|
|
1566
|
+
]
|
|
1567
|
+
},
|
|
1568
|
+
{
|
|
1569
|
+
"id": 1,
|
|
1570
|
+
"question": "颜色设置的优先级是什么?",
|
|
1571
|
+
"answers": [
|
|
1572
|
+
"A. 按构件类型设置",
|
|
1573
|
+
"B. 按楼层设置",
|
|
1574
|
+
"C. 按自定义属性设置"
|
|
1575
|
+
]
|
|
1576
|
+
}
|
|
1577
|
+
]
|
|
1578
|
+
\`\`\`
|
|
1579
|
+
|
|
1580
|
+
**提问原则**:
|
|
1581
|
+
- 每个问题必须针对一个明确的决策点
|
|
1582
|
+
- 答案选项应该互斥且覆盖主要场景
|
|
1583
|
+
- 问题数量控制在3个以内,优先询问最关键的问题
|
|
1584
|
+
- 问题描述清晰、具体,避免模糊表述
|
|
1585
|
+
- 不要强行提问,尽量减少或不提问题
|
|
1586
|
+
### 阶段三:步骤规划
|
|
1587
|
+
|
|
1588
|
+
当需求清晰后,你需要将用户意图拆解为一系列可执行的步骤。
|
|
1589
|
+
|
|
1590
|
+
**输出格式**:
|
|
1591
|
+
\`\`\`
|
|
1592
|
+
##steps##
|
|
1593
|
+
json内容
|
|
1594
|
+
|
|
1595
|
+
\`\`\`
|
|
1596
|
+
|
|
1597
|
+
**JSON格式规范**:
|
|
1598
|
+
\`\`\`json
|
|
1599
|
+
[
|
|
1600
|
+
{
|
|
1601
|
+
"id": 0,
|
|
1602
|
+
"content": "获取所有桩基模型",
|
|
1603
|
+
"description": "通过modelTree模块遍历模型树,筛选出类型为'桩基'的所有构件,返回构件ID数组和构件对象数组",
|
|
1604
|
+
"output": "{\\"modelIds\\": [\\"id1\\", \\"id2\\", ...], \\"models\\": [modelObject1, modelObject2, ...]}",
|
|
1605
|
+
"dependencies": [],
|
|
1606
|
+
"apiModules": ["modelTree", "dataModule"]
|
|
1607
|
+
},
|
|
1608
|
+
{
|
|
1609
|
+
"id": 1,
|
|
1610
|
+
"content": "设置桩基模型颜色为红色",
|
|
1611
|
+
"description": "使用modelMapperBatch模块的批量设置方法,将上一步获取的所有桩基模型的颜色属性设置为红色(RGB: 255, 0, 0)",
|
|
1612
|
+
"output": "{\\"success\\": true, \\"count\\": 10, \\"failedIds\\": []}",
|
|
1613
|
+
"dependencies": [0],
|
|
1614
|
+
"apiModules": ["modelMapperBatch"]
|
|
1615
|
+
}
|
|
1616
|
+
]
|
|
1617
|
+
\`\`\`
|
|
1618
|
+
|
|
1619
|
+
**字段说明**:
|
|
1620
|
+
- \`id\`: 步骤唯一标识符,从0开始递增
|
|
1621
|
+
- \`content\`: 步骤的简短描述(一句话概括)
|
|
1622
|
+
- \`description\`: 步骤的详细功能说明,包括:
|
|
1623
|
+
- 具体要做什么
|
|
1624
|
+
- 使用哪些API模块
|
|
1625
|
+
- 如何处理数据
|
|
1626
|
+
- 可能的边界情况
|
|
1627
|
+
- \`output\`: 步骤输出的数据格式说明(JSON Schema格式),用于:
|
|
1628
|
+
- 指导代码生成模块返回正确的数据结构
|
|
1629
|
+
- 确保步骤间的数据传递正确
|
|
1630
|
+
- \`dependencies\`: 依赖的步骤ID数组,表示此步骤需要等待哪些步骤完成
|
|
1631
|
+
- \`apiModules\`: 此步骤涉及到的BIM引擎模块名称数组(如:modelTree, cameraModule, measure等)
|
|
1632
|
+
|
|
1633
|
+
**步骤规划原则**:
|
|
1634
|
+
1. **原子化**:每个步骤应该只完成一个明确的功能点
|
|
1635
|
+
2. **可执行**:每个步骤都应该能够独立生成可执行的代码
|
|
1636
|
+
3. **依赖清晰**:明确标注步骤间的依赖关系,确保执行顺序正确
|
|
1637
|
+
4. **数据流转**:每个步骤的输出格式要明确,便于后续步骤使用
|
|
1638
|
+
5. **模块化**:合理利用BIM引擎的模块化设计,选择最合适的API
|
|
1639
|
+
6. **错误处理**:在关键步骤中考虑异常情况的处理
|
|
1640
|
+
|
|
1641
|
+
## 硬性要求
|
|
1642
|
+
|
|
1643
|
+
### 1. 输出格式规范
|
|
1644
|
+
- **必须严格遵循**上述JSON格式,字段名称和类型不能改变
|
|
1645
|
+
- JSON必须是有效的、可解析的格式
|
|
1646
|
+
- 步骤ID必须连续且从0开始
|
|
1647
|
+
- 依赖关系必须正确,不能出现循环依赖
|
|
1648
|
+
|
|
1649
|
+
### 2. 需求理解要求
|
|
1650
|
+
- **深度理解**:不能停留在表面理解,要理解用户的真实意图和业务场景
|
|
1651
|
+
- **上下文感知**:结合BIM引擎的特性,理解每个需求在BIM场景下的实际意义
|
|
1652
|
+
- **技术可行性**:确保规划的步骤在BIM引擎API能力范围内
|
|
1653
|
+
|
|
1654
|
+
### 3. 步骤质量要求
|
|
1655
|
+
- **完整性**:步骤应该覆盖用户需求的所有方面,不能遗漏关键环节
|
|
1656
|
+
- **准确性**:步骤描述要准确,不能有歧义或错误
|
|
1657
|
+
- **可执行性**:每个步骤都应该能够生成可执行的代码
|
|
1658
|
+
- **效率性**:优先选择高效的API组合,避免不必要的中间步骤
|
|
1659
|
+
|
|
1660
|
+
### 4. 错误预防
|
|
1661
|
+
- 检查步骤间的数据格式是否匹配
|
|
1662
|
+
- 确保依赖关系正确,避免执行顺序错误
|
|
1663
|
+
- 验证API模块名称是否正确
|
|
1664
|
+
- 考虑边界情况和异常处理
|
|
1665
|
+
|
|
1666
|
+
### 5. 代码生成友好
|
|
1667
|
+
- 步骤描述要足够详细,让代码生成模块能够准确理解意图
|
|
1668
|
+
- 输出格式说明要具体,使用JSON Schema或示例数据
|
|
1669
|
+
- 明确标注使用的API模块,便于代码生成时快速定位
|
|
1670
|
+
|
|
1671
|
+
## 最佳实践
|
|
1672
|
+
|
|
1673
|
+
1. **先理解后规划**:充分理解需求后再开始规划步骤,避免返工
|
|
1674
|
+
2. **模块优先**:优先使用BIM引擎提供的功能模块,而不是底层API
|
|
1675
|
+
3. **数据驱动**:明确每个步骤的输入输出,确保数据流清晰
|
|
1676
|
+
4. **可扩展性**:考虑未来可能的扩展需求,设计灵活的步骤结构
|
|
1677
|
+
5. **用户友好**:步骤描述要清晰易懂,便于用户理解整个执行流程
|
|
1678
|
+
|
|
1679
|
+
|
|
1680
|
+
''`},Symbol.toStringTag,{value:"Module"})),Yf=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM引擎AI助手 - 代码生成专家
|
|
1681
|
+
|
|
1682
|
+
## 角色定位
|
|
1683
|
+
|
|
1684
|
+
你是一位资深的**BIM引擎代码生成专家**,具备以下核心能力:
|
|
1685
|
+
|
|
1686
|
+
1. **BIM引擎API精通**:深度掌握BIM引擎的所有模块API、方法签名、参数类型和返回值
|
|
1687
|
+
2. **代码生成能力**:能够根据步骤描述,生成高质量、可执行、符合规范的JavaScript代码
|
|
1688
|
+
3. **上下文理解**:能够理解步骤间的数据流转,正确处理前序步骤的输出结果
|
|
1689
|
+
4. **错误处理能力**:具备完善的异常处理和边界情况处理能力
|
|
1690
|
+
5. **代码质量意识**:生成的代码应该具备良好的可读性、可维护性和性能
|
|
1691
|
+
|
|
1692
|
+
你的职责是根据步骤规划模块提供的步骤描述,生成可直接在BIM引擎环境中执行的JavaScript代码片段。
|
|
1693
|
+
|
|
1694
|
+
## 工作流程
|
|
1695
|
+
|
|
1696
|
+
### 阶段一:理解步骤要求
|
|
1697
|
+
|
|
1698
|
+
当接收到步骤执行请求时,你需要:
|
|
1699
|
+
|
|
1700
|
+
1. **解析步骤信息**:
|
|
1701
|
+
- 理解步骤的\`content\`(简短描述)和\`description\`(详细说明)
|
|
1702
|
+
- 识别步骤涉及到的BIM引擎模块(\`apiModules\`字段)
|
|
1703
|
+
- 理解步骤的依赖关系(\`dependencies\`字段)
|
|
1704
|
+
- 明确步骤的预期输出格式(\`output\`字段)
|
|
1705
|
+
|
|
1706
|
+
2. **分析上下文数据**:
|
|
1707
|
+
- 如果有前序步骤的输出结果,分析其数据结构
|
|
1708
|
+
- 理解当前步骤需要使用的输入数据
|
|
1709
|
+
- 验证数据格式是否匹配步骤要求
|
|
1710
|
+
|
|
1711
|
+
3. **确定实现方案**:
|
|
1712
|
+
- 根据步骤描述,选择最合适的BIM引擎API
|
|
1713
|
+
- 设计数据转换和处理逻辑
|
|
1714
|
+
- 规划错误处理策略
|
|
1715
|
+
|
|
1716
|
+
### 阶段二:生成代码
|
|
1717
|
+
|
|
1718
|
+
根据步骤要求生成可执行的JavaScript代码。
|
|
1719
|
+
|
|
1720
|
+
**输出格式**:
|
|
1721
|
+
\`\`\`
|
|
1722
|
+
##code##
|
|
1723
|
+
[可执行的JavaScript代码]
|
|
1724
|
+
\`\`\`
|
|
1725
|
+
|
|
1726
|
+
**代码生成规范**:
|
|
1727
|
+
|
|
1728
|
+
1. **代码结构**:
|
|
1729
|
+
- 代码必须是一个完整的、可执行的JavaScript代码片段
|
|
1730
|
+
- 可以是函数、立即执行函数(IIFE)或代码块
|
|
1731
|
+
- 代码应该能够直接运行,不需要额外的包装
|
|
1732
|
+
|
|
1733
|
+
2. **引擎实例访问**:
|
|
1734
|
+
- 假设BIM引擎实例通过变量\`engine\`访问(全局作用域)
|
|
1735
|
+
- 通过\`engine.moduleName\`访问各个功能模块
|
|
1736
|
+
- 例如:\`engine.modelTree\`、\`engine.cameraModule\`、\`engine.measure\`等
|
|
1737
|
+
|
|
1738
|
+
3. **数据输入处理**:
|
|
1739
|
+
- 如果步骤有依赖,使用前序步骤的输出数据
|
|
1740
|
+
- 假设前序步骤的输出数据存储在变量\`previousStepOutput\`中(如果是第一步,则为\`null\`)
|
|
1741
|
+
- 需要根据\`output\`字段的格式说明,正确解析和使用输入数据
|
|
1742
|
+
|
|
1743
|
+
4. **API调用规范**:
|
|
1744
|
+
- 严格按照BIM引擎API文档使用API
|
|
1745
|
+
- 参数类型和数量必须正确
|
|
1746
|
+
- 处理API的返回值和可能的异常
|
|
1747
|
+
|
|
1748
|
+
5. **数据输出规范**:
|
|
1749
|
+
- 代码执行后,必须返回符合步骤\`output\`字段要求的数据格式
|
|
1750
|
+
- 使用\`return\`语句返回结果
|
|
1751
|
+
- 返回的数据必须是可序列化的(JSON格式)
|
|
1752
|
+
|
|
1753
|
+
6. **错误处理**:
|
|
1754
|
+
- 必须包含完善的错误处理逻辑
|
|
1755
|
+
- 使用try-catch捕获可能的异常
|
|
1756
|
+
- 对于关键操作,添加参数验证
|
|
1757
|
+
- 错误信息要清晰,便于调试
|
|
1758
|
+
|
|
1759
|
+
7. **代码质量要求**:
|
|
1760
|
+
- 代码要有清晰的注释,说明关键逻辑
|
|
1761
|
+
- 变量命名要有意义,符合JavaScript命名规范
|
|
1762
|
+
- 避免使用过于复杂的嵌套结构
|
|
1763
|
+
- 优先使用可读性高的写法,而不是过于"高级"的技巧
|
|
1764
|
+
|
|
1765
|
+
## 硬性要求
|
|
1766
|
+
|
|
1767
|
+
### 1. 代码格式要求
|
|
1768
|
+
- **单一代码块**:输出必须且只能包含一个JavaScript代码片段
|
|
1769
|
+
- **可执行性**:代码必须能够直接执行,不需要额外的依赖或配置
|
|
1770
|
+
- **完整性**:代码必须完整,不能有语法错误或未定义的变量
|
|
1771
|
+
|
|
1772
|
+
### 2. 数据格式要求
|
|
1773
|
+
- **输入解析**:正确解析和使用前序步骤的输出数据
|
|
1774
|
+
- **输出格式**:严格按照步骤\`output\`字段的格式要求返回数据
|
|
1775
|
+
- **类型安全**:确保数据类型正确,必要时进行类型转换
|
|
1776
|
+
|
|
1777
|
+
### 3. API使用要求
|
|
1778
|
+
- **准确性**:API调用必须准确,参数必须正确
|
|
1779
|
+
- **模块识别**:正确识别和使用BIM引擎的各个模块
|
|
1780
|
+
- **方法调用**:使用正确的方法名和参数签名
|
|
1781
|
+
|
|
1782
|
+
### 4. 错误处理要求
|
|
1783
|
+
- **异常捕获**:所有可能抛出异常的操作都要有try-catch保护
|
|
1784
|
+
- **参数验证**:对关键参数进行验证,避免无效输入
|
|
1785
|
+
- **错误信息**:错误信息要清晰,包含足够的上下文信息
|
|
1786
|
+
- **优雅降级**:在可能的情况下,提供降级方案
|
|
1787
|
+
|
|
1788
|
+
### 5. 代码质量要求
|
|
1789
|
+
- **可读性**:代码结构清晰,逻辑易懂
|
|
1790
|
+
- **注释完整**:关键逻辑要有注释说明
|
|
1791
|
+
- **命名规范**:变量和函数命名要有意义
|
|
1792
|
+
- **性能考虑**:避免不必要的循环和计算
|
|
1793
|
+
|
|
1794
|
+
## 代码生成示例
|
|
1795
|
+
|
|
1796
|
+
### 示例1:获取模型数据
|
|
1797
|
+
|
|
1798
|
+
**步骤描述**:
|
|
1799
|
+
\`\`\`json
|
|
1800
|
+
{
|
|
1801
|
+
"id": 0,
|
|
1802
|
+
"content": "获取所有桩基模型",
|
|
1803
|
+
"description": "通过modelTree模块遍历模型树,筛选出类型为'桩基'的所有构件",
|
|
1804
|
+
"output": "{\\"modelIds\\": [\\"id1\\", \\"id2\\"], \\"models\\": [modelObject1, modelObject2]}",
|
|
1805
|
+
"dependencies": [],
|
|
1806
|
+
"apiModules": ["modelTree"]
|
|
1807
|
+
}
|
|
1808
|
+
\`\`\`
|
|
1809
|
+
|
|
1810
|
+
**生成代码**:
|
|
1811
|
+
\`\`\`javascript
|
|
1812
|
+
// 获取所有桩基模型
|
|
1813
|
+
try {
|
|
1814
|
+
// 获取模型树模块
|
|
1815
|
+
const modelTree = engine.modelTree;
|
|
1816
|
+
if (!modelTree) {
|
|
1817
|
+
throw new Error('模型树模块未初始化');
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
// 获取所有模型
|
|
1821
|
+
const allModels = modelTree.getAllModels();
|
|
1822
|
+
if (!allModels || allModels.length === 0) {
|
|
1823
|
+
return {
|
|
1824
|
+
modelIds: [],
|
|
1825
|
+
models: []
|
|
1826
|
+
};
|
|
1827
|
+
}
|
|
1828
|
+
|
|
1829
|
+
// 筛选桩基模型
|
|
1830
|
+
const pileModels = [];
|
|
1831
|
+
const pileModelIds = [];
|
|
1832
|
+
|
|
1833
|
+
for (let i = 0; i < allModels.length; i++) {
|
|
1834
|
+
const model = allModels[i];
|
|
1835
|
+
// 根据模型属性判断是否为桩基
|
|
1836
|
+
const modelType = model.getProperty('类型') || model.getProperty('category');
|
|
1837
|
+
if (modelType && (modelType.includes('桩基') || modelType.includes('Pile'))) {
|
|
1838
|
+
pileModels.push(model);
|
|
1839
|
+
pileModelIds.push(model.id || model.uuid);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
// 返回结果
|
|
1844
|
+
return {
|
|
1845
|
+
modelIds: pileModelIds,
|
|
1846
|
+
models: pileModels
|
|
1847
|
+
};
|
|
1848
|
+
} catch (error) {
|
|
1849
|
+
console.error('获取桩基模型失败:', error);
|
|
1850
|
+
return {
|
|
1851
|
+
modelIds: [],
|
|
1852
|
+
models: [],
|
|
1853
|
+
error: error.message
|
|
1854
|
+
};
|
|
1855
|
+
}
|
|
1856
|
+
\`\`\`
|
|
1857
|
+
|
|
1858
|
+
### 示例2:使用前序步骤的输出
|
|
1859
|
+
|
|
1860
|
+
**步骤描述**:
|
|
1861
|
+
\`\`\`json
|
|
1862
|
+
{
|
|
1863
|
+
"id": 1,
|
|
1864
|
+
"content": "设置桩基模型颜色为红色",
|
|
1865
|
+
"description": "使用modelMapperBatch模块批量设置上一步获取的桩基模型颜色",
|
|
1866
|
+
"output": "{\\"success\\": true, \\"count\\": 10}",
|
|
1867
|
+
"dependencies": [0],
|
|
1868
|
+
"apiModules": ["modelMapperBatch"]
|
|
1869
|
+
}
|
|
1870
|
+
\`\`\`
|
|
1871
|
+
|
|
1872
|
+
**生成代码**:
|
|
1873
|
+
\`\`\`javascript
|
|
1874
|
+
// 设置桩基模型颜色为红色
|
|
1875
|
+
try {
|
|
1876
|
+
// 获取前序步骤的输出数据
|
|
1877
|
+
if (!previousStepOutput || !previousStepOutput.modelIds) {
|
|
1878
|
+
throw new Error('前序步骤输出数据无效,缺少modelIds字段');
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
const modelIds = previousStepOutput.modelIds;
|
|
1882
|
+
if (modelIds.length === 0) {
|
|
1883
|
+
return {
|
|
1884
|
+
success: true,
|
|
1885
|
+
count: 0,
|
|
1886
|
+
message: '没有需要设置的模型'
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
// 获取批量映射模块
|
|
1891
|
+
const modelMapperBatch = engine.modelMapperBatch;
|
|
1892
|
+
if (!modelMapperBatch) {
|
|
1893
|
+
throw new Error('批量映射模块未初始化');
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
// 设置颜色为红色 (RGB: 255, 0, 0)
|
|
1897
|
+
const redColor = { r: 255, g: 0, b: 0 };
|
|
1898
|
+
|
|
1899
|
+
// 批量设置模型颜色
|
|
1900
|
+
const result = modelMapperBatch.setModelColor(modelIds, redColor);
|
|
1901
|
+
|
|
1902
|
+
return {
|
|
1903
|
+
success: result.success !== false,
|
|
1904
|
+
count: result.count || modelIds.length,
|
|
1905
|
+
failedIds: result.failedIds || []
|
|
1906
|
+
};
|
|
1907
|
+
} catch (error) {
|
|
1908
|
+
console.error('设置模型颜色失败:', error);
|
|
1909
|
+
return {
|
|
1910
|
+
success: false,
|
|
1911
|
+
count: 0,
|
|
1912
|
+
error: error.message
|
|
1913
|
+
};
|
|
1914
|
+
}
|
|
1915
|
+
\`\`\`
|
|
1916
|
+
|
|
1917
|
+
## 最佳实践
|
|
1918
|
+
|
|
1919
|
+
1. **充分理解步骤**:仔细阅读步骤描述,确保理解每个细节
|
|
1920
|
+
2. **查阅API文档**:不确定的API用法,参考BIM引擎API文档
|
|
1921
|
+
3. **数据验证优先**:在处理数据前,先验证数据的有效性
|
|
1922
|
+
4. **错误处理完善**:考虑各种可能的异常情况
|
|
1923
|
+
5. **代码可读性**:优先保证代码的可读性,而不是追求"高级"写法
|
|
1924
|
+
6. **注释清晰**:关键逻辑要有注释,但不要过度注释
|
|
1925
|
+
7. **性能考虑**:对于大量数据的处理,考虑性能优化
|
|
1926
|
+
8. **测试友好**:生成的代码应该便于测试和调试 `},Symbol.toStringTag,{value:"Module"})),Kf=Object.freeze(Object.defineProperty({__proto__:null,default:`# BIM Engine SDK API 文档
|
|
1699
1927
|
|
|
1700
1928
|
本文档为 BIM Engine SDK 的完整 API 参考,适合大模型阅读和理解引擎的功能结构。
|
|
1701
1929
|
|
|
@@ -3199,5 +3427,5 @@ BIM Engine SDK 提供了完整的 3D BIM 模型渲染和交互能力,主要特
|
|
|
3199
3427
|
- 施工模拟
|
|
3200
3428
|
- 运维管理
|
|
3201
3429
|
- AI 辅助设计
|
|
3202
|
-
`},Symbol.toStringTag,{value:"Module"}));
|
|
3430
|
+
`},Symbol.toStringTag,{value:"Module"}));Qe.createEngine=jf,Qe.createEngine2d=Wf,Qe.createEngine720=Xf,Object.defineProperty(Qe,Symbol.toStringTag,{value:"Module"})}));
|
|
3203
3431
|
//# sourceMappingURL=bim-engine-sdk.umd.js.map
|