iflow-engine-base 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +2 -0
  2. package/dist/assets/bim-engine-sdk.z34pmn5f.css +1 -0
  3. package/dist/assets/hdr/001.hdr +0 -0
  4. package/dist/assets/viewcube/cn_back.png +0 -0
  5. package/dist/assets/viewcube/cn_bottom.png +0 -0
  6. package/dist/assets/viewcube/cn_front.png +0 -0
  7. package/dist/assets/viewcube/cn_left.png +0 -0
  8. package/dist/assets/viewcube/cn_right.png +0 -0
  9. package/dist/assets/viewcube/cn_top.png +0 -0
  10. package/dist/assets/viewcube/home.png +0 -0
  11. package/dist/bim-engine-sdk.es.js +13022 -0
  12. package/dist/bim-engine-sdk.es.js.map +1 -0
  13. package/dist/bim-engine-sdk.umd.js +841 -0
  14. package/dist/bim-engine-sdk.umd.js.map +1 -0
  15. package/dist/draco/DRACOLoader.js +739 -0
  16. package/dist/draco/draco_decoder.js +52 -0
  17. package/dist/draco/draco_decoder.wasm +0 -0
  18. package/dist/draco/draco_encoder.js +33 -0
  19. package/dist/draco/draco_wasm_wrapper.js +104 -0
  20. package/dist/index.d.ts +610 -0
  21. package/dist/model/gujianzhu.glb +0 -0
  22. package/dist/model/test1/lod3/nodes.json +1 -0
  23. package/dist/model/test1/lod3/primitives/0.glb +0 -0
  24. package/dist/model/test1/lod3/primitives/1.glb +0 -0
  25. package/dist/model/test1/lod4/nodes.json +1 -0
  26. package/dist/model/test1/lod4/primitives/0.glb +0 -0
  27. package/dist/model/test1/lod5/nodes.json +1 -0
  28. package/dist/model/test1/lod5/primitives/0.glb +0 -0
  29. package/dist/model/test1/lod6/nodes.json +1 -0
  30. package/dist/model/test1/lod6/primitives/0.glb +0 -0
  31. package/dist/model/test2/info.zip +0 -0
  32. package/dist/model/test2/lod0/nodes.json +1 -0
  33. package/dist/model/test2/lod0/primitives/0.glb +0 -0
  34. package/dist/model/test2/lod0/primitives/1.glb +0 -0
  35. package/dist/model/test2/lod0/primitives/10.glb +0 -0
  36. package/dist/model/test2/lod0/primitives/11.glb +0 -0
  37. package/dist/model/test2/lod0/primitives/12.glb +0 -0
  38. package/dist/model/test2/lod0/primitives/13.glb +0 -0
  39. package/dist/model/test2/lod0/primitives/14.glb +0 -0
  40. package/dist/model/test2/lod0/primitives/15.glb +0 -0
  41. package/dist/model/test2/lod0/primitives/2.glb +0 -0
  42. package/dist/model/test2/lod0/primitives/3.glb +0 -0
  43. package/dist/model/test2/lod0/primitives/4.glb +0 -0
  44. package/dist/model/test2/lod0/primitives/5.glb +0 -0
  45. package/dist/model/test2/lod0/primitives/6.glb +0 -0
  46. package/dist/model/test2/lod0/primitives/7.glb +0 -0
  47. package/dist/model/test2/lod0/primitives/8.glb +0 -0
  48. package/dist/model/test2/lod0/primitives/9.glb +0 -0
  49. package/dist/model/test2/property.zip +0 -0
  50. package/package.json +46 -0
@@ -0,0 +1,841 @@
1
+ (function(Ve,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("three")):typeof define=="function"&&define.amd?define(["exports","three"],S):(Ve=typeof globalThis<"u"?globalThis:Ve||self,S(Ve.BimEngineSDK={},Ve.THREE))})(this,(function(Ve,S){"use strict";function _i(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 x=_i(S);class wi{engine;scene;constructor(e){this.engine=e,this.scene=new x.Scene;let t=new x.Group;t.name="groupEdge",this.scene.add(t)}}class bi{engine;perspectiveCamera;orthographicCamera;constructor(e){this.engine=e,this.perspectiveCamera=new x.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 x.OrthographicCamera(t*n/-2,t*n/2,t/2,t/-2,.1,1e3)}switchCurrentCamera(){this.engine.camera===this.perspectiveCamera?this.switchToOrthographicCamera():this.switchToPerspectiveCamera()}switchToPerspectiveCamera(){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.engine.composerModule.init()}switchToOrthographicCamera(){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.engine.composerModule.init()}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 xi{engine;deviceType;constructor(e){this.engine=e,this.deviceType="PC"}getDeviceType(){return this.deviceType}getContainerSize(){return{width:this.engine.container.clientWidth,height:this.engine.container.clientHeight}}}class vi{engine;renderer;constructor(e){this.engine=e,this.renderer=null}createRenderer(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize();return this.renderer=new x.WebGLRenderer({antialias:this.engine.options.antialias??!0,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=x.PCFSoftShadowMap,this.renderer.localClippingEnabled=!0,this.renderer.outputColorSpace=x.SRGBColorSpace,this.renderer.toneMapping=x.ACESFilmicToneMapping,this.renderer.toneMappingExposure=1.5,this.engine.container.appendChild(this.renderer.domElement),this.renderer}disposeRenderer(){this.renderer?.dispose()}}const hn={type:"change"},Ft={type:"start"},un={type:"end"},mt=new S.Ray,dn=new S.Plane,Si=Math.cos(70*S.MathUtils.DEG2RAD),ye=new S.Vector3,ve=2*Math.PI,he={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6},Ut=1e-6;class Mi extends S.Controls{constructor(e,t,n=null){super(t,n),this.engine=e,this.state=he.NONE,this.target=new S.Vector3,this.cursor=new S.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minTargetRadius=0,this.maxTargetRadius=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.05,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.keyRotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.zoomToCursor=!1,this.autoRotate=!1,this.autoRotateSpeed=2,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:S.MOUSE.ROTATE,MIDDLE:S.MOUSE.DOLLY,RIGHT:S.MOUSE.PAN},this.touches={ONE:S.TOUCH.ROTATE,TWO:S.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this._domElementKeyEvents=null,this._lastPosition=new S.Vector3,this._lastQuaternion=new S.Quaternion,this._lastTargetPosition=new S.Vector3,this._quat=new S.Quaternion().setFromUnitVectors(t.up,new S.Vector3(0,1,0)),this._quatInverse=this._quat.clone().invert(),this._spherical=new S.Spherical,this._sphericalDelta=new S.Spherical,this._scale=1,this._panOffset=new S.Vector3,this._rotateStart=new S.Vector2,this._rotateEnd=new S.Vector2,this._rotateDelta=new S.Vector2,this._panStart=new S.Vector2,this._panEnd=new S.Vector2,this._panDelta=new S.Vector2,this._dollyStart=new S.Vector2,this._dollyEnd=new S.Vector2,this._dollyDelta=new S.Vector2,this._dollyDirection=new S.Vector3,this._mouse=new S.Vector2,this._performCursorZoom=!1,this._pointers=[],this._pointerPositions={},this._controlActive=!1,this._onPointerMove=Ti.bind(this),this._onPointerDown=Ai.bind(this),this._onPointerUp=Ci.bind(this),this._onContextMenu=Ni.bind(this),this._onMouseWheel=Di.bind(this),this._onKeyDown=Ei.bind(this),this._onTouchStart=Li.bind(this),this._onTouchMove=Oi.bind(this),this._onMouseDown=Pi.bind(this),this._onMouseMove=ki.bind(this),this._interceptControlDown=Ri.bind(this),this._interceptControlUp=zi.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(hn),this.update(),this.state=he.NONE}update(e=null){const t=this.object.position;ye.copy(t).sub(this.target),ye.applyQuaternion(this._quat),this._spherical.setFromVector3(ye),this.autoRotate&&this.state===he.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+=ve:n>Math.PI&&(n-=ve),i<-Math.PI?i+=ve:i>Math.PI&&(i-=ve),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 o=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const s=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),o=s!=this._spherical.radius}if(ye.setFromSpherical(this._spherical),ye.applyQuaternion(this._quatInverse),t.copy(this.target).add(ye),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let s=null;if(this.object.isPerspectiveCamera){const a=ye.length();s=this._clampDistance(a*this._scale);const l=a-s;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),o=!!l}else if(this.object.isOrthographicCamera){const a=new S.Vector3(this._mouse.x,this._mouse.y,0);a.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),o=l!==this.object.zoom;const h=new S.Vector3(this._mouse.x,this._mouse.y,0);h.unproject(this.object),this.object.position.sub(h).add(a),this.object.updateMatrixWorld(),s=ye.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;s!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(s).add(this.object.position):(mt.origin.copy(this.object.position),mt.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(mt.direction))<Si?this.object.lookAt(this.target):(dn.setFromNormalAndCoplanarPoint(this.object.up,this.target),mt.intersectPlane(dn,this.target))))}else if(this.object.isOrthographicCamera){const s=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),s!==this.object.zoom&&(this.object.updateProjectionMatrix(),o=!0)}return this._scale=1,this._performCursorZoom=!1,o||this._lastPosition.distanceToSquared(this.object.position)>Ut||8*(1-this._lastQuaternion.dot(this.object.quaternion))>Ut||this._lastTargetPosition.distanceToSquared(this.target)>Ut?(this.dispatchEvent(hn),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?ve/60*this.autoRotateSpeed*e:ve/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){ye.setFromMatrixColumn(t,0),ye.multiplyScalar(-e),this._panOffset.add(ye)}_panUp(e,t){this.screenSpacePanning===!0?ye.setFromMatrixColumn(t,1):(ye.setFromMatrixColumn(t,0),ye.crossVectors(this.object.up,ye)),ye.multiplyScalar(e),this._panOffset.add(ye)}_pan(e,t){const n=this.domElement;if(this.object.isPerspectiveCamera){const i=this.object.position;ye.copy(i).sub(this.target);let o=ye.length();o*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*o/n.clientHeight,this.object.matrix),this._panUp(2*t*o/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,o=t-n.top,s=n.width,a=n.height;this._mouse.x=i/s*2-1,this._mouse.y=-(o/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(ve*this._rotateDelta.x/t.clientHeight),this._rotateUp(ve*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(ve*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(-ve*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(ve*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(-ve*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,o=Math.sqrt(n*n+i*i);this._dollyStart.set(0,o)}_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),o=.5*(e.pageY+n.y);this._rotateEnd.set(i,o)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(ve*this._rotateDelta.x/t.clientHeight),this._rotateUp(ve*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,o=Math.sqrt(n*n+i*i);this._dollyEnd.set(0,o),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 s=(e.pageX+t.x)*.5,a=(e.pageY+t.y)*.5;this._updateZoomParameters(s,a)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId){this._pointers.splice(t,1);return}}_isTrackingPointer(e){for(let t=0;t<this._pointers.length;t++)if(this._pointers[t]==e.pointerId)return!0;return!1}_trackPointer(e){let t=this._pointerPositions[e.pointerId];t===void 0&&(t=new S.Vector2,this._pointerPositions[e.pointerId]=t),t.set(e.pageX,e.pageY)}_getSecondPointerPosition(e){const t=e.pointerId===this._pointers[0]?this._pointers[1]:this._pointers[0];return this._pointerPositions[t]}_customWheelEvent(e){const t=e.deltaMode,n={clientX:e.clientX,clientY:e.clientY,deltaY:e.deltaY};switch(t){case 1:n.deltaY*=16;break;case 2:n.deltaY*=100;break}return e.ctrlKey&&!this._controlActive&&(n.deltaY*=10),n}}function Ai(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 Ti(r){this.enabled!==!1&&(r.pointerType==="touch"?this._onTouchMove(r):this._onMouseMove(r))}function Ci(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(un),this.state=he.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 Pi(r){let e;switch(r.button){case 0:e=this.mouseButtons.LEFT;break;case 1:e=this.mouseButtons.MIDDLE;break;case 2:e=this.mouseButtons.RIGHT;break;default:e=-1}switch(e){case S.MOUSE.DOLLY:if(this.enableZoom===!1)return;this._handleMouseDownDolly(r),this.state=he.DOLLY;break;case S.MOUSE.ROTATE:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=he.PAN}else{if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=he.ROTATE}break;case S.MOUSE.PAN:if(r.ctrlKey||r.metaKey||r.shiftKey){if(this.enableRotate===!1)return;this._handleMouseDownRotate(r),this.state=he.ROTATE}else{if(this.enablePan===!1)return;this._handleMouseDownPan(r),this.state=he.PAN}break;default:this.state=he.NONE}this.state!==he.NONE&&this.dispatchEvent(Ft)}function ki(r){switch(this.state){case he.ROTATE:if(this.enableRotate===!1)return;this._handleMouseMoveRotate(r);break;case he.DOLLY:if(this.enableZoom===!1)return;this._handleMouseMoveDolly(r);break;case he.PAN:if(this.enablePan===!1)return;this._handleMouseMovePan(r);break}}function Di(r){this.enabled===!1||this.enableZoom===!1||this.state!==he.NONE||(r.preventDefault(),this.dispatchEvent(Ft),this._handleMouseWheel(this._customWheelEvent(r)),this.dispatchEvent(un))}function Ei(r){this.enabled!==!1&&this._handleKeyDown(r)}function Li(r){switch(this._trackPointer(r),this._pointers.length){case 1:switch(this.touches.ONE){case S.TOUCH.ROTATE:if(this.enableRotate===!1)return;this._handleTouchStartRotate(r),this.state=he.TOUCH_ROTATE;break;case S.TOUCH.PAN:if(this.enablePan===!1)return;this._handleTouchStartPan(r),this.state=he.TOUCH_PAN;break;default:this.state=he.NONE}break;case 2:switch(this.touches.TWO){case S.TOUCH.DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchStartDollyPan(r),this.state=he.TOUCH_DOLLY_PAN;break;case S.TOUCH.DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchStartDollyRotate(r),this.state=he.TOUCH_DOLLY_ROTATE;break;default:this.state=he.NONE}break;default:this.state=he.NONE}this.state!==he.NONE&&this.dispatchEvent(Ft)}function Oi(r){switch(this._trackPointer(r),this.state){case he.TOUCH_ROTATE:if(this.enableRotate===!1)return;this._handleTouchMoveRotate(r),this.update();break;case he.TOUCH_PAN:if(this.enablePan===!1)return;this._handleTouchMovePan(r),this.update();break;case he.TOUCH_DOLLY_PAN:if(this.enableZoom===!1&&this.enablePan===!1)return;this._handleTouchMoveDollyPan(r),this.update();break;case he.TOUCH_DOLLY_ROTATE:if(this.enableZoom===!1&&this.enableRotate===!1)return;this._handleTouchMoveDollyRotate(r),this.update();break;default:this.state=he.NONE}}function Ni(r){this.enabled!==!1&&r.preventDefault()}function Ri(r){r.key==="Control"&&(this._controlActive=!0,this.domElement.getRootNode().addEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}function zi(r){r.key==="Control"&&(this._controlActive=!1,this.domElement.getRootNode().removeEventListener("keyup",this._interceptControlUp,{passive:!0,capture:!0}))}class fn{constructor(e,t,n,i){this._Engine=e,this.camera=t,this.domElement=n,this._isEnabled=!1,this._rayOriginOffset=new x.Vector3(0,-1,0),this._camerLocalDirection=new x.Vector3,this._tmpVector=new x.Vector3,this._rayCaster=new x.Raycaster,this._fallingTime=0,this._euler=new x.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 o=this.GetEngine();o.movefirst=!0;var s=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(s)}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 o=this.GetEngine();o.movefirst=!0;var s=new CustomEvent("bimengine:camerachange",{detail:""});window.dispatchEvent(s)}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 x.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 x.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 Bi{engine;orbitControls;firstPersonControls;isActive=!0;constructor(e){this.engine=e,this.init()}init(){this.orbitControls=new Mi(this.engine,this.engine.camera,this.engine.renderer.domElement),this.firstPersonControls=new fn(this.engine,this.engine.camera,this.engine.renderer.domElement)}active(){this.isActive=!0,this.orbitControls.enabled=!0}disActive(){this.isActive=!1,this.orbitControls.enabled=!1}switchFirstPersonMode(){this.firstPersonControls=new fn(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}update(){this.firstPersonControls.enabled&&this.firstPersonControls.update()}}const je={name:"CopyShader",uniforms:{tDiffuse:{value:null},opacity:{value:1}},vertexShader:`
2
+
3
+ varying vec2 vUv;
4
+
5
+ void main() {
6
+
7
+ vUv = uv;
8
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
9
+
10
+ }`,fragmentShader:`
11
+
12
+ uniform float opacity;
13
+
14
+ uniform sampler2D tDiffuse;
15
+
16
+ varying vec2 vUv;
17
+
18
+ void main() {
19
+
20
+ vec4 texel = texture2D( tDiffuse, vUv );
21
+ gl_FragColor = opacity * texel;
22
+
23
+
24
+ }`};class Ge{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 Ii=new S.OrthographicCamera(-1,1,1,-1,0,1);class Fi extends S.BufferGeometry{constructor(){super(),this.setAttribute("position",new S.Float32BufferAttribute([-1,3,0,-1,-1,0,3,-1,0],3)),this.setAttribute("uv",new S.Float32BufferAttribute([0,2,0,0,2,0],2))}}const Ui=new Fi;class gt{constructor(e){this._mesh=new S.Mesh(Ui,e)}dispose(){this._mesh.geometry.dispose()}render(e){e.render(this._mesh,Ii)}get material(){return this._mesh.material}set material(e){this._mesh.material=e}}class yt extends Ge{constructor(e,t="tDiffuse"){super(),this.textureID=t,this.uniforms=null,this.material=null,e instanceof S.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=S.UniformsUtils.clone(e.uniforms),this.material=new S.ShaderMaterial({name:e.name!==void 0?e.name:"unspecified",defines:Object.assign({},e.defines),uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this._fsQuad=new gt(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 pn extends Ge{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(),o=e.state;o.buffers.color.setMask(!1),o.buffers.depth.setMask(!1),o.buffers.color.setLocked(!0),o.buffers.depth.setLocked(!0);let s,a;this.inverse?(s=0,a=1):(s=1,a=0),o.buffers.stencil.setTest(!0),o.buffers.stencil.setOp(i.REPLACE,i.REPLACE,i.REPLACE),o.buffers.stencil.setFunc(i.ALWAYS,s,4294967295),o.buffers.stencil.setClear(a),o.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),o.buffers.color.setLocked(!1),o.buffers.depth.setLocked(!1),o.buffers.color.setMask(!0),o.buffers.depth.setMask(!0),o.buffers.stencil.setLocked(!1),o.buffers.stencil.setFunc(i.EQUAL,1,4294967295),o.buffers.stencil.setOp(i.KEEP,i.KEEP,i.KEEP),o.buffers.stencil.setLocked(!0)}}class Vi extends Ge{constructor(){super(),this.needsSwap=!1}render(e){e.state.buffers.stencil.setLocked(!1),e.state.buffers.stencil.setTest(!1)}}class ji{constructor(e,t){if(this.renderer=e,this._pixelRatio=e.getPixelRatio(),t===void 0){const n=e.getSize(new S.Vector2);this._width=n.width,this._height=n.height,t=new S.WebGLRenderTarget(this._width*this._pixelRatio,this._height*this._pixelRatio,{type:S.HalfFloatType}),t.texture.name="EffectComposer.rt1"}else this._width=t.width,this._height=t.height;this.renderTarget1=t,this.renderTarget2=t.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.renderToScreen=!0,this.passes=[],this.copyPass=new yt(je),this.copyPass.material.blending=S.NoBlending,this.clock=new S.Clock}swapBuffers(){const e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e}addPass(e){this.passes.push(e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}insertPass(e,t){this.passes.splice(t,0,e),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}removePass(e){const t=this.passes.indexOf(e);t!==-1&&this.passes.splice(t,1)}isLastEnabledPass(e){for(let t=e+1;t<this.passes.length;t++)if(this.passes[t].enabled)return!1;return!0}render(e){e===void 0&&(e=this.clock.getDelta());const t=this.renderer.getRenderTarget();let n=!1;for(let i=0,o=this.passes.length;i<o;i++){const s=this.passes[i];if(s.enabled!==!1){if(s.renderToScreen=this.renderToScreen&&this.isLastEnabledPass(i),s.render(this.renderer,this.writeBuffer,this.readBuffer,e,n),s.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()}pn!==void 0&&(s instanceof pn?n=!0:s instanceof Vi&&(n=!1))}}this.renderer.setRenderTarget(t)}reset(e){if(e===void 0){const t=this.renderer.getSize(new S.Vector2);this._pixelRatio=this.renderer.getPixelRatio(),this._width=t.width,this._height=t.height,e=this.renderTarget1.clone(),e.setSize(this._width*this._pixelRatio,this._height*this._pixelRatio)}this.renderTarget1.dispose(),this.renderTarget2.dispose(),this.renderTarget1=e,this.renderTarget2=e.clone(),this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2}setSize(e,t){this._width=e,this._height=t;const n=this._width*this._pixelRatio,i=this._height*this._pixelRatio;this.renderTarget1.setSize(n,i),this.renderTarget2.setSize(n,i);for(let o=0;o<this.passes.length;o++)this.passes[o].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 Gi extends Ge{constructor(e,t,n=null,i=null,o=null){super(),this.scene=e,this.camera=t,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=o,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,this._oldClearColor=new S.Color}render(e,t,n){const i=e.autoClear;e.autoClear=!1;let o,s;this.overrideMaterial!==null&&(s=this.scene.overrideMaterial,this.scene.overrideMaterial=this.overrideMaterial),this.clearColor!==null&&(e.getClearColor(this._oldClearColor),e.setClearColor(this.clearColor,e.getClearAlpha())),this.clearAlpha!==null&&(o=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(o),this.overrideMaterial!==null&&(this.scene.overrideMaterial=s),e.autoClear=i}}const _t={defines:{PERSPECTIVE_CAMERA:1,SAMPLES:16,NORMAL_VECTOR_TYPE:1,DEPTH_SWIZZLING:"x",SCREEN_SPACE_RADIUS:0,SCREEN_SPACE_RADIUS_SCALE:100,SCENE_CLIP_BOX:0},uniforms:{tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new S.Vector2},cameraNear:{value:null},cameraFar:{value:null},cameraProjectionMatrix:{value:new S.Matrix4},cameraProjectionMatrixInverse:{value:new S.Matrix4},cameraWorldMatrix:{value:new S.Matrix4},radius:{value:.25},distanceExponent:{value:1},thickness:{value:1},distanceFallOff:{value:1},scale:{value:1},sceneBoxMin:{value:new S.Vector3(-1,-1,-1)},sceneBoxMax:{value:new S.Vector3(1,1,1)}},vertexShader:`
25
+
26
+ varying vec2 vUv;
27
+
28
+ void main() {
29
+ vUv = uv;
30
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
31
+ }`,fragmentShader:`
32
+ varying vec2 vUv;
33
+ uniform highp sampler2D tNormal;
34
+ uniform highp sampler2D tDepth;
35
+ uniform sampler2D tNoise;
36
+ uniform vec2 resolution;
37
+ uniform float cameraNear;
38
+ uniform float cameraFar;
39
+ uniform mat4 cameraProjectionMatrix;
40
+ uniform mat4 cameraProjectionMatrixInverse;
41
+ uniform mat4 cameraWorldMatrix;
42
+ uniform float radius;
43
+ uniform float distanceExponent;
44
+ uniform float thickness;
45
+ uniform float distanceFallOff;
46
+ uniform float scale;
47
+ #if SCENE_CLIP_BOX == 1
48
+ uniform vec3 sceneBoxMin;
49
+ uniform vec3 sceneBoxMax;
50
+ #endif
51
+
52
+ #include <common>
53
+ #include <packing>
54
+
55
+ #ifndef FRAGMENT_OUTPUT
56
+ #define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)
57
+ #endif
58
+
59
+ vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {
60
+ vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);
61
+ vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
62
+ return viewSpacePosition.xyz / viewSpacePosition.w;
63
+ }
64
+
65
+ float getDepth(const vec2 uv) {
66
+ return textureLod(tDepth, uv.xy, 0.0).DEPTH_SWIZZLING;
67
+ }
68
+
69
+ float fetchDepth(const ivec2 uv) {
70
+ return texelFetch(tDepth, uv.xy, 0).DEPTH_SWIZZLING;
71
+ }
72
+
73
+ float getViewZ(const in float depth) {
74
+ #if PERSPECTIVE_CAMERA == 1
75
+ return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);
76
+ #else
77
+ return orthographicDepthToViewZ(depth, cameraNear, cameraFar);
78
+ #endif
79
+ }
80
+
81
+ vec3 computeNormalFromDepth(const vec2 uv) {
82
+ vec2 size = vec2(textureSize(tDepth, 0));
83
+ ivec2 p = ivec2(uv * size);
84
+ float c0 = fetchDepth(p);
85
+ float l2 = fetchDepth(p - ivec2(2, 0));
86
+ float l1 = fetchDepth(p - ivec2(1, 0));
87
+ float r1 = fetchDepth(p + ivec2(1, 0));
88
+ float r2 = fetchDepth(p + ivec2(2, 0));
89
+ float b2 = fetchDepth(p - ivec2(0, 2));
90
+ float b1 = fetchDepth(p - ivec2(0, 1));
91
+ float t1 = fetchDepth(p + ivec2(0, 1));
92
+ float t2 = fetchDepth(p + ivec2(0, 2));
93
+ float dl = abs((2.0 * l1 - l2) - c0);
94
+ float dr = abs((2.0 * r1 - r2) - c0);
95
+ float db = abs((2.0 * b1 - b2) - c0);
96
+ float dt = abs((2.0 * t1 - t2) - c0);
97
+ vec3 ce = getViewPosition(uv, c0).xyz;
98
+ vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;
99
+ vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;
100
+ return normalize(cross(dpdx, dpdy));
101
+ }
102
+
103
+ vec3 getViewNormal(const vec2 uv) {
104
+ #if NORMAL_VECTOR_TYPE == 2
105
+ return normalize(textureLod(tNormal, uv, 0.).rgb);
106
+ #elif NORMAL_VECTOR_TYPE == 1
107
+ return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);
108
+ #else
109
+ return computeNormalFromDepth(uv);
110
+ #endif
111
+ }
112
+
113
+ vec3 getSceneUvAndDepth(vec3 sampleViewPos) {
114
+ vec4 sampleClipPos = cameraProjectionMatrix * vec4(sampleViewPos, 1.);
115
+ vec2 sampleUv = sampleClipPos.xy / sampleClipPos.w * 0.5 + 0.5;
116
+ float sampleSceneDepth = getDepth(sampleUv);
117
+ return vec3(sampleUv, sampleSceneDepth);
118
+ }
119
+
120
+ void main() {
121
+ float depth = getDepth(vUv.xy);
122
+ if (depth >= 1.0) {
123
+ discard;
124
+ return;
125
+ }
126
+ vec3 viewPos = getViewPosition(vUv, depth);
127
+ vec3 viewNormal = getViewNormal(vUv);
128
+
129
+ float radiusToUse = radius;
130
+ float distanceFalloffToUse = thickness;
131
+ #if SCREEN_SPACE_RADIUS == 1
132
+ float radiusScale = getViewPosition(vec2(0.5 + float(SCREEN_SPACE_RADIUS_SCALE) / resolution.x, 0.0), depth).x;
133
+ radiusToUse *= radiusScale;
134
+ distanceFalloffToUse *= radiusScale;
135
+ #endif
136
+
137
+ #if SCENE_CLIP_BOX == 1
138
+ vec3 worldPos = (cameraWorldMatrix * vec4(viewPos, 1.0)).xyz;
139
+ float boxDistance = length(max(vec3(0.0), max(sceneBoxMin - worldPos, worldPos - sceneBoxMax)));
140
+ if (boxDistance > radiusToUse) {
141
+ discard;
142
+ return;
143
+ }
144
+ #endif
145
+
146
+ vec2 noiseResolution = vec2(textureSize(tNoise, 0));
147
+ vec2 noiseUv = vUv * resolution / noiseResolution;
148
+ vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);
149
+ vec3 randomVec = noiseTexel.xyz * 2.0 - 1.0;
150
+ vec3 tangent = normalize(vec3(randomVec.xy, 0.));
151
+ vec3 bitangent = vec3(-tangent.y, tangent.x, 0.);
152
+ mat3 kernelMatrix = mat3(tangent, bitangent, vec3(0., 0., 1.));
153
+
154
+ const int DIRECTIONS = SAMPLES < 30 ? 3 : 5;
155
+ const int STEPS = (SAMPLES + DIRECTIONS - 1) / DIRECTIONS;
156
+ float ao = 0.0;
157
+ for (int i = 0; i < DIRECTIONS; ++i) {
158
+
159
+ float angle = float(i) / float(DIRECTIONS) * PI;
160
+ vec4 sampleDir = vec4(cos(angle), sin(angle), 0., 0.5 + 0.5 * noiseTexel.w);
161
+ sampleDir.xyz = normalize(kernelMatrix * sampleDir.xyz);
162
+
163
+ vec3 viewDir = normalize(-viewPos.xyz);
164
+ vec3 sliceBitangent = normalize(cross(sampleDir.xyz, viewDir));
165
+ vec3 sliceTangent = cross(sliceBitangent, viewDir);
166
+ vec3 normalInSlice = normalize(viewNormal - sliceBitangent * dot(viewNormal, sliceBitangent));
167
+
168
+ vec3 tangentToNormalInSlice = cross(normalInSlice, sliceBitangent);
169
+ vec2 cosHorizons = vec2(dot(viewDir, tangentToNormalInSlice), dot(viewDir, -tangentToNormalInSlice));
170
+
171
+ for (int j = 0; j < STEPS; ++j) {
172
+ vec3 sampleViewOffset = sampleDir.xyz * radiusToUse * sampleDir.w * pow(float(j + 1) / float(STEPS), distanceExponent);
173
+
174
+ vec3 sampleSceneUvDepth = getSceneUvAndDepth(viewPos + sampleViewOffset);
175
+ vec3 sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);
176
+ vec3 viewDelta = sampleSceneViewPos - viewPos;
177
+ if (abs(viewDelta.z) < thickness) {
178
+ float sampleCosHorizon = dot(viewDir, normalize(viewDelta));
179
+ cosHorizons.x += max(0., (sampleCosHorizon - cosHorizons.x) * mix(1., 2. / float(j + 2), distanceFallOff));
180
+ }
181
+
182
+ sampleSceneUvDepth = getSceneUvAndDepth(viewPos - sampleViewOffset);
183
+ sampleSceneViewPos = getViewPosition(sampleSceneUvDepth.xy, sampleSceneUvDepth.z);
184
+ viewDelta = sampleSceneViewPos - viewPos;
185
+ if (abs(viewDelta.z) < thickness) {
186
+ float sampleCosHorizon = dot(viewDir, normalize(viewDelta));
187
+ cosHorizons.y += max(0., (sampleCosHorizon - cosHorizons.y) * mix(1., 2. / float(j + 2), distanceFallOff));
188
+ }
189
+ }
190
+
191
+ vec2 sinHorizons = sqrt(1. - cosHorizons * cosHorizons);
192
+ float nx = dot(normalInSlice, sliceTangent);
193
+ float ny = dot(normalInSlice, viewDir);
194
+ float nxb = 1. / 2. * (acos(cosHorizons.y) - acos(cosHorizons.x) + sinHorizons.x * cosHorizons.x - sinHorizons.y * cosHorizons.y);
195
+ float nyb = 1. / 2. * (2. - cosHorizons.x * cosHorizons.x - cosHorizons.y * cosHorizons.y);
196
+ float occlusion = nx * nxb + ny * nyb;
197
+ ao += occlusion;
198
+ }
199
+
200
+ ao = clamp(ao / float(DIRECTIONS), 0., 1.);
201
+ #if SCENE_CLIP_BOX == 1
202
+ ao = mix(ao, 1., smoothstep(0., radiusToUse, boxDistance));
203
+ #endif
204
+ ao = pow(ao, scale);
205
+
206
+ gl_FragColor = FRAGMENT_OUTPUT;
207
+ }`},wt={defines:{PERSPECTIVE_CAMERA:1},uniforms:{tDepth:{value:null},cameraNear:{value:null},cameraFar:{value:null}},vertexShader:`
208
+ varying vec2 vUv;
209
+
210
+ void main() {
211
+ vUv = uv;
212
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
213
+ }`,fragmentShader:`
214
+ uniform sampler2D tDepth;
215
+ uniform float cameraNear;
216
+ uniform float cameraFar;
217
+ varying vec2 vUv;
218
+
219
+ #include <packing>
220
+
221
+ float getLinearDepth( const in vec2 screenPosition ) {
222
+ #if PERSPECTIVE_CAMERA == 1
223
+ float fragCoordZ = texture2D( tDepth, screenPosition ).x;
224
+ float viewZ = perspectiveDepthToViewZ( fragCoordZ, cameraNear, cameraFar );
225
+ return viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
226
+ #else
227
+ return texture2D( tDepth, screenPosition ).x;
228
+ #endif
229
+ }
230
+
231
+ void main() {
232
+ float depth = getLinearDepth( vUv );
233
+ gl_FragColor = vec4( vec3( 1.0 - depth ), 1.0 );
234
+
235
+ }`},Vt={uniforms:{tDiffuse:{value:null},intensity:{value:1}},vertexShader:`
236
+ varying vec2 vUv;
237
+
238
+ void main() {
239
+ vUv = uv;
240
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
241
+ }`,fragmentShader:`
242
+ uniform float intensity;
243
+ uniform sampler2D tDiffuse;
244
+ varying vec2 vUv;
245
+
246
+ void main() {
247
+ vec4 texel = texture2D( tDiffuse, vUv );
248
+ gl_FragColor = vec4(mix(vec3(1.), texel.rgb, intensity), texel.a);
249
+ }`};function Wi(r=5){const e=Math.floor(r)%2===0?Math.floor(r)+1:Math.floor(r),t=Ki(e),n=t.length,i=new Uint8Array(n*4);for(let s=0;s<n;++s){const a=t[s],l=2*Math.PI*a/n,h=new S.Vector3(Math.cos(l),Math.sin(l),0).normalize();i[s*4]=(h.x*.5+.5)*255,i[s*4+1]=(h.y*.5+.5)*255,i[s*4+2]=127,i[s*4+3]=255}const o=new S.DataTexture(i,e,e);return o.wrapS=S.RepeatWrapping,o.wrapT=S.RepeatWrapping,o.needsUpdate=!0,o}function Ki(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),o=e-1;for(let s=1;s<=t;){if(i===-1&&o===e?(o=e-2,i=0):(o===e&&(o=0),i<0&&(i=e-1)),n[i*e+o]!==0){o-=2,i++;continue}else n[i*e+o]=s++;o++,i--}return n}const bt={defines:{SAMPLES:16,SAMPLE_VECTORS:mn(16,2,1),NORMAL_VECTOR_TYPE:1,DEPTH_VALUE_SOURCE:0},uniforms:{tDiffuse:{value:null},tNormal:{value:null},tDepth:{value:null},tNoise:{value:null},resolution:{value:new S.Vector2},cameraProjectionMatrixInverse:{value:new S.Matrix4},lumaPhi:{value:5},depthPhi:{value:5},normalPhi:{value:5},radius:{value:4},index:{value:0}},vertexShader:`
250
+
251
+ varying vec2 vUv;
252
+
253
+ void main() {
254
+ vUv = uv;
255
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
256
+ }`,fragmentShader:`
257
+
258
+ varying vec2 vUv;
259
+
260
+ uniform sampler2D tDiffuse;
261
+ uniform sampler2D tNormal;
262
+ uniform sampler2D tDepth;
263
+ uniform sampler2D tNoise;
264
+ uniform vec2 resolution;
265
+ uniform mat4 cameraProjectionMatrixInverse;
266
+ uniform float lumaPhi;
267
+ uniform float depthPhi;
268
+ uniform float normalPhi;
269
+ uniform float radius;
270
+ uniform int index;
271
+
272
+ #include <common>
273
+ #include <packing>
274
+
275
+ #ifndef SAMPLE_LUMINANCE
276
+ #define SAMPLE_LUMINANCE dot(vec3(0.2125, 0.7154, 0.0721), a)
277
+ #endif
278
+
279
+ #ifndef FRAGMENT_OUTPUT
280
+ #define FRAGMENT_OUTPUT vec4(denoised, 1.)
281
+ #endif
282
+
283
+ float getLuminance(const in vec3 a) {
284
+ return SAMPLE_LUMINANCE;
285
+ }
286
+
287
+ const vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;
288
+
289
+ vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {
290
+ vec4 clipSpacePosition = vec4(vec3(screenPosition, depth) * 2.0 - 1.0, 1.0);
291
+ vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
292
+ return viewSpacePosition.xyz / viewSpacePosition.w;
293
+ }
294
+
295
+ float getDepth(const vec2 uv) {
296
+ #if DEPTH_VALUE_SOURCE == 1
297
+ return textureLod(tDepth, uv.xy, 0.0).a;
298
+ #else
299
+ return textureLod(tDepth, uv.xy, 0.0).r;
300
+ #endif
301
+ }
302
+
303
+ float fetchDepth(const ivec2 uv) {
304
+ #if DEPTH_VALUE_SOURCE == 1
305
+ return texelFetch(tDepth, uv.xy, 0).a;
306
+ #else
307
+ return texelFetch(tDepth, uv.xy, 0).r;
308
+ #endif
309
+ }
310
+
311
+ vec3 computeNormalFromDepth(const vec2 uv) {
312
+ vec2 size = vec2(textureSize(tDepth, 0));
313
+ ivec2 p = ivec2(uv * size);
314
+ float c0 = fetchDepth(p);
315
+ float l2 = fetchDepth(p - ivec2(2, 0));
316
+ float l1 = fetchDepth(p - ivec2(1, 0));
317
+ float r1 = fetchDepth(p + ivec2(1, 0));
318
+ float r2 = fetchDepth(p + ivec2(2, 0));
319
+ float b2 = fetchDepth(p - ivec2(0, 2));
320
+ float b1 = fetchDepth(p - ivec2(0, 1));
321
+ float t1 = fetchDepth(p + ivec2(0, 1));
322
+ float t2 = fetchDepth(p + ivec2(0, 2));
323
+ float dl = abs((2.0 * l1 - l2) - c0);
324
+ float dr = abs((2.0 * r1 - r2) - c0);
325
+ float db = abs((2.0 * b1 - b2) - c0);
326
+ float dt = abs((2.0 * t1 - t2) - c0);
327
+ vec3 ce = getViewPosition(uv, c0).xyz;
328
+ vec3 dpdx = (dl < dr) ? ce - getViewPosition((uv - vec2(1.0 / size.x, 0.0)), l1).xyz
329
+ : -ce + getViewPosition((uv + vec2(1.0 / size.x, 0.0)), r1).xyz;
330
+ vec3 dpdy = (db < dt) ? ce - getViewPosition((uv - vec2(0.0, 1.0 / size.y)), b1).xyz
331
+ : -ce + getViewPosition((uv + vec2(0.0, 1.0 / size.y)), t1).xyz;
332
+ return normalize(cross(dpdx, dpdy));
333
+ }
334
+
335
+ vec3 getViewNormal(const vec2 uv) {
336
+ #if NORMAL_VECTOR_TYPE == 2
337
+ return normalize(textureLod(tNormal, uv, 0.).rgb);
338
+ #elif NORMAL_VECTOR_TYPE == 1
339
+ return unpackRGBToNormal(textureLod(tNormal, uv, 0.).rgb);
340
+ #else
341
+ return computeNormalFromDepth(uv);
342
+ #endif
343
+ }
344
+
345
+ void denoiseSample(in vec3 center, in vec3 viewNormal, in vec3 viewPos, in vec2 sampleUv, inout vec3 denoised, inout float totalWeight) {
346
+ vec4 sampleTexel = textureLod(tDiffuse, sampleUv, 0.0);
347
+ float sampleDepth = getDepth(sampleUv);
348
+ vec3 sampleNormal = getViewNormal(sampleUv);
349
+ vec3 neighborColor = sampleTexel.rgb;
350
+ vec3 viewPosSample = getViewPosition(sampleUv, sampleDepth);
351
+
352
+ float normalDiff = dot(viewNormal, sampleNormal);
353
+ float normalSimilarity = pow(max(normalDiff, 0.), normalPhi);
354
+ float lumaDiff = abs(getLuminance(neighborColor) - getLuminance(center));
355
+ float lumaSimilarity = max(1.0 - lumaDiff / lumaPhi, 0.0);
356
+ float depthDiff = abs(dot(viewPos - viewPosSample, viewNormal));
357
+ float depthSimilarity = max(1. - depthDiff / depthPhi, 0.);
358
+ float w = lumaSimilarity * depthSimilarity * normalSimilarity;
359
+
360
+ denoised += w * neighborColor;
361
+ totalWeight += w;
362
+ }
363
+
364
+ void main() {
365
+ float depth = getDepth(vUv.xy);
366
+ vec3 viewNormal = getViewNormal(vUv);
367
+ if (depth == 1. || dot(viewNormal, viewNormal) == 0.) {
368
+ discard;
369
+ return;
370
+ }
371
+ vec4 texel = textureLod(tDiffuse, vUv, 0.0);
372
+ vec3 center = texel.rgb;
373
+ vec3 viewPos = getViewPosition(vUv, depth);
374
+
375
+ vec2 noiseResolution = vec2(textureSize(tNoise, 0));
376
+ vec2 noiseUv = vUv * resolution / noiseResolution;
377
+ vec4 noiseTexel = textureLod(tNoise, noiseUv, 0.0);
378
+ vec2 noiseVec = vec2(sin(noiseTexel[index % 4] * 2. * PI), cos(noiseTexel[index % 4] * 2. * PI));
379
+ mat2 rotationMatrix = mat2(noiseVec.x, -noiseVec.y, noiseVec.x, noiseVec.y);
380
+
381
+ float totalWeight = 1.0;
382
+ vec3 denoised = texel.rgb;
383
+ for (int i = 0; i < SAMPLES; i++) {
384
+ vec3 sampleDir = poissonDisk[i];
385
+ vec2 offset = rotationMatrix * (sampleDir.xy * (1. + sampleDir.z * (radius - 1.)) / resolution);
386
+ vec2 sampleUv = vUv + offset;
387
+ denoiseSample(center, viewNormal, viewPos, sampleUv, denoised, totalWeight);
388
+ }
389
+
390
+ if (totalWeight > 0.) {
391
+ denoised /= totalWeight;
392
+ }
393
+ gl_FragColor = FRAGMENT_OUTPUT;
394
+ }`};function mn(r,e,t){const n=Xi(r,e,t);let i="vec3[SAMPLES](";for(let o=0;o<r;o++){const s=n[o];i+=`vec3(${s.x}, ${s.y}, ${s.z})${o<r-1?",":")"}`}return i}function Xi(r,e,t){const n=[];for(let i=0;i<r;i++){const o=2*Math.PI*e*i/r,s=Math.pow(i/(r-1),t);n.push(new S.Vector3(Math.cos(o),Math.sin(o),s))}return n}class Zi{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,o;const s=.5*(Math.sqrt(3)-1),a=(e+t)*s,l=Math.floor(e+a),h=Math.floor(t+a),u=(3-Math.sqrt(3))/6,f=(l+h)*u,g=l-f,p=h-f,c=e-g,d=t-p;let m,y;c>d?(m=1,y=0):(m=0,y=1);const w=c-m+u,v=d-y+u,M=c-1+2*u,P=d-1+2*u,D=l&255,E=h&255,O=this.perm[D+this.perm[E]]%12,k=this.perm[D+m+this.perm[E+y]]%12,I=this.perm[D+1+this.perm[E+1]]%12;let W=.5-c*c-d*d;W<0?n=0:(W*=W,n=W*W*this._dot(this.grad3[O],c,d));let T=.5-w*w-v*v;T<0?i=0:(T*=T,i=T*T*this._dot(this.grad3[k],w,v));let B=.5-M*M-P*P;return B<0?o=0:(B*=B,o=B*B*this._dot(this.grad3[I],M,P)),70*(n+i+o)}noise3d(e,t,n){let i,o,s,a;const h=(e+t+n)*.3333333333333333,u=Math.floor(e+h),f=Math.floor(t+h),g=Math.floor(n+h),p=1/6,c=(u+f+g)*p,d=u-c,m=f-c,y=g-c,w=e-d,v=t-m,M=n-y;let P,D,E,O,k,I;w>=v?v>=M?(P=1,D=0,E=0,O=1,k=1,I=0):w>=M?(P=1,D=0,E=0,O=1,k=0,I=1):(P=0,D=0,E=1,O=1,k=0,I=1):v<M?(P=0,D=0,E=1,O=0,k=1,I=1):w<M?(P=0,D=1,E=0,O=0,k=1,I=1):(P=0,D=1,E=0,O=1,k=1,I=0);const W=w-P+p,T=v-D+p,B=M-E+p,b=w-O+2*p,V=v-k+2*p,J=M-I+2*p,X=w-1+3*p,ee=v-1+3*p,j=M-1+3*p,ne=u&255,z=f&255,N=g&255,te=this.perm[ne+this.perm[z+this.perm[N]]]%12,$=this.perm[ne+P+this.perm[z+D+this.perm[N+E]]]%12,H=this.perm[ne+O+this.perm[z+k+this.perm[N+I]]]%12,de=this.perm[ne+1+this.perm[z+1+this.perm[N+1]]]%12;let fe=.6-w*w-v*v-M*M;fe<0?i=0:(fe*=fe,i=fe*fe*this._dot3(this.grad3[te],w,v,M));let se=.6-W*W-T*T-B*B;se<0?o=0:(se*=se,o=se*se*this._dot3(this.grad3[$],W,T,B));let ae=.6-b*b-V*V-J*J;ae<0?s=0:(ae*=ae,s=ae*ae*this._dot3(this.grad3[H],b,V,J));let ue=.6-X*X-ee*ee-j*j;return ue<0?a=0:(ue*=ue,a=ue*ue*this._dot3(this.grad3[de],X,ee,j)),32*(i+o+s+a)}noise4d(e,t,n,i){const o=this.grad4,s=this.simplex,a=this.perm,l=(Math.sqrt(5)-1)/4,h=(5-Math.sqrt(5))/20;let u,f,g,p,c;const d=(e+t+n+i)*l,m=Math.floor(e+d),y=Math.floor(t+d),w=Math.floor(n+d),v=Math.floor(i+d),M=(m+y+w+v)*h,P=m-M,D=y-M,E=w-M,O=v-M,k=e-P,I=t-D,W=n-E,T=i-O,B=k>I?32:0,b=k>W?16:0,V=I>W?8:0,J=k>T?4:0,X=I>T?2:0,ee=W>T?1:0,j=B+b+V+J+X+ee,ne=s[j][0]>=3?1:0,z=s[j][1]>=3?1:0,N=s[j][2]>=3?1:0,te=s[j][3]>=3?1:0,$=s[j][0]>=2?1:0,H=s[j][1]>=2?1:0,de=s[j][2]>=2?1:0,fe=s[j][3]>=2?1:0,se=s[j][0]>=1?1:0,ae=s[j][1]>=1?1:0,ue=s[j][2]>=1?1:0,pe=s[j][3]>=1?1:0,Te=k-ne+h,xe=I-z+h,_=W-N+h,G=T-te+h,U=k-$+2*h,C=I-H+2*h,A=W-de+2*h,L=T-fe+2*h,K=k-se+3*h,Z=I-ae+3*h,R=W-ue+3*h,q=T-pe+3*h,Q=k-1+4*h,Y=I-1+4*h,ie=W-1+4*h,ce=T-1+4*h,oe=m&255,_e=y&255,De=w&255,be=v&255,qe=a[oe+a[_e+a[De+a[be]]]]%32,me=a[oe+ne+a[_e+z+a[De+N+a[be+te]]]]%32,st=a[oe+$+a[_e+H+a[De+de+a[be+fe]]]]%32,ft=a[oe+se+a[_e+ae+a[De+ue+a[be+pe]]]]%32,Ee=a[oe+1+a[_e+1+a[De+1+a[be+1]]]]%32;let Fe=.6-k*k-I*I-W*W-T*T;Fe<0?u=0:(Fe*=Fe,u=Fe*Fe*this._dot4(o[qe],k,I,W,T));let Ye=.6-Te*Te-xe*xe-_*_-G*G;Ye<0?f=0:(Ye*=Ye,f=Ye*Ye*this._dot4(o[me],Te,xe,_,G));let He=.6-U*U-C*C-A*A-L*L;He<0?g=0:(He*=He,g=He*He*this._dot4(o[st],U,C,A,L));let $e=.6-K*K-Z*Z-R*R-q*q;$e<0?p=0:($e*=$e,p=$e*$e*this._dot4(o[ft],K,Z,R,q));let Ue=.6-Q*Q-Y*Y-ie*ie-ce*ce;return Ue<0?c=0:(Ue*=Ue,c=Ue*Ue*this._dot4(o[Ee],Q,Y,ie,ce)),27*(u+f+g+p+c)}_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,o){return e[0]*t+e[1]*n+e[2]*i+e[3]*o}}class Se extends Ge{constructor(e,t,n=512,i=512,o,s,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=Wi(),this.pdNoiseTexture=this._generateNoise(),this.gtaoRenderTarget=new S.WebGLRenderTarget(this.width,this.height,{type:S.HalfFloatType}),this.pdRenderTarget=this.gtaoRenderTarget.clone(),this.gtaoMaterial=new S.ShaderMaterial({defines:Object.assign({},_t.defines),uniforms:S.UniformsUtils.clone(_t.uniforms),vertexShader:_t.vertexShader,fragmentShader:_t.fragmentShader,blending:S.NoBlending,depthTest:!1,depthWrite:!1}),this.gtaoMaterial.defines.PERSPECTIVE_CAMERA=this.camera.isPerspectiveCamera?1:0,this.gtaoMaterial.uniforms.tNoise.value=this.gtaoNoiseTexture,this.gtaoMaterial.uniforms.resolution.value.set(this.width,this.height),this.gtaoMaterial.uniforms.cameraNear.value=this.camera.near,this.gtaoMaterial.uniforms.cameraFar.value=this.camera.far,this.normalMaterial=new S.MeshNormalMaterial,this.normalMaterial.blending=S.NoBlending,this.pdMaterial=new S.ShaderMaterial({defines:Object.assign({},bt.defines),uniforms:S.UniformsUtils.clone(bt.uniforms),vertexShader:bt.vertexShader,fragmentShader:bt.fragmentShader,depthTest:!1,depthWrite:!1}),this.pdMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.pdMaterial.uniforms.tNoise.value=this.pdNoiseTexture,this.pdMaterial.uniforms.resolution.value.set(this.width,this.height),this.pdMaterial.uniforms.lumaPhi.value=10,this.pdMaterial.uniforms.depthPhi.value=2,this.pdMaterial.uniforms.normalPhi.value=3,this.pdMaterial.uniforms.radius.value=8,this.depthRenderMaterial=new S.ShaderMaterial({defines:Object.assign({},wt.defines),uniforms:S.UniformsUtils.clone(wt.uniforms),vertexShader:wt.vertexShader,fragmentShader:wt.fragmentShader,blending:S.NoBlending}),this.depthRenderMaterial.uniforms.cameraNear.value=this.camera.near,this.depthRenderMaterial.uniforms.cameraFar.value=this.camera.far,this.copyMaterial=new S.ShaderMaterial({uniforms:S.UniformsUtils.clone(je.uniforms),vertexShader:je.vertexShader,fragmentShader:je.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blendSrc:S.DstColorFactor,blendDst:S.ZeroFactor,blendEquation:S.AddEquation,blendSrcAlpha:S.DstAlphaFactor,blendDstAlpha:S.ZeroFactor,blendEquationAlpha:S.AddEquation}),this.blendMaterial=new S.ShaderMaterial({uniforms:S.UniformsUtils.clone(Vt.uniforms),vertexShader:Vt.vertexShader,fragmentShader:Vt.fragmentShader,transparent:!0,depthTest:!1,depthWrite:!1,blending:S.CustomBlending,blendSrc:S.DstColorFactor,blendDst:S.ZeroFactor,blendEquation:S.AddEquation,blendSrcAlpha:S.DstAlphaFactor,blendDstAlpha:S.ZeroFactor,blendEquationAlpha:S.AddEquation}),this._fsQuad=new gt(null),this._originalClearColor=new S.Color,this.setGBuffer(o?o.depthTexture:void 0,o?o.normalTexture:void 0),s!==void 0&&this.updateGtaoMaterial(s),a!==void 0&&this.updatePdMaterial(a)}setSize(e,t){this.width=e,this.height=t,this.gtaoRenderTarget.setSize(e,t),this.normalRenderTarget.setSize(e,t),this.pdRenderTarget.setSize(e,t),this.gtaoMaterial.uniforms.resolution.value.set(e,t),this.gtaoMaterial.uniforms.cameraProjectionMatrix.value.copy(this.camera.projectionMatrix),this.gtaoMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse),this.pdMaterial.uniforms.resolution.value.set(e,t),this.pdMaterial.uniforms.cameraProjectionMatrixInverse.value.copy(this.camera.projectionMatrixInverse)}dispose(){this.gtaoNoiseTexture.dispose(),this.pdNoiseTexture.dispose(),this.normalRenderTarget.dispose(),this.gtaoRenderTarget.dispose(),this.pdRenderTarget.dispose(),this.normalMaterial.dispose(),this.pdMaterial.dispose(),this.copyMaterial.dispose(),this.depthRenderMaterial.dispose(),this._fsQuad.dispose()}get gtaoMap(){return this.pdRenderTarget.texture}setGBuffer(e,t){e!==void 0?(this.depthTexture=e,this.normalTexture=t,this._renderGBuffer=!1):(this.depthTexture=new S.DepthTexture,this.depthTexture.format=S.DepthStencilFormat,this.depthTexture.type=S.UnsignedInt248Type,this.normalRenderTarget=new S.WebGLRenderTarget(this.width,this.height,{minFilter:S.NearestFilter,magFilter:S.NearestFilter,type:S.HalfFloatType,depthTexture:this.depthTexture}),this.normalTexture=this.normalRenderTarget.texture,this._renderGBuffer=!0);const n=this.normalTexture?1:0,i=this.depthTexture===this.normalTexture?"w":"x";this.gtaoMaterial.defines.NORMAL_VECTOR_TYPE=n,this.gtaoMaterial.defines.DEPTH_SWIZZLING=i,this.gtaoMaterial.uniforms.tNormal.value=this.normalTexture,this.gtaoMaterial.uniforms.tDepth.value=this.depthTexture,this.pdMaterial.defines.NORMAL_VECTOR_TYPE=n,this.pdMaterial.defines.DEPTH_SWIZZLING=i,this.pdMaterial.uniforms.tNormal.value=this.normalTexture,this.pdMaterial.uniforms.tDepth.value=this.depthTexture,this.depthRenderMaterial.uniforms.tDepth.value=this.normalRenderTarget.depthTexture}setSceneClipBox(e){e?(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX!==1,this.gtaoMaterial.defines.SCENE_CLIP_BOX=1,this.gtaoMaterial.uniforms.sceneBoxMin.value.copy(e.min),this.gtaoMaterial.uniforms.sceneBoxMax.value.copy(e.max)):(this.gtaoMaterial.needsUpdate=this.gtaoMaterial.defines.SCENE_CLIP_BOX===0,this.gtaoMaterial.defines.SCENE_CLIP_BOX=0)}updateGtaoMaterial(e){e.radius!==void 0&&(this.gtaoMaterial.uniforms.radius.value=e.radius),e.distanceExponent!==void 0&&(this.gtaoMaterial.uniforms.distanceExponent.value=e.distanceExponent),e.thickness!==void 0&&(this.gtaoMaterial.uniforms.thickness.value=e.thickness),e.distanceFallOff!==void 0&&(this.gtaoMaterial.uniforms.distanceFallOff.value=e.distanceFallOff,this.gtaoMaterial.needsUpdate=!0),e.scale!==void 0&&(this.gtaoMaterial.uniforms.scale.value=e.scale),e.samples!==void 0&&e.samples!==this.gtaoMaterial.defines.SAMPLES&&(this.gtaoMaterial.defines.SAMPLES=e.samples,this.gtaoMaterial.needsUpdate=!0),e.screenSpaceRadius!==void 0&&(e.screenSpaceRadius?1:0)!==this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS&&(this.gtaoMaterial.defines.SCREEN_SPACE_RADIUS=e.screenSpaceRadius?1:0,this.gtaoMaterial.needsUpdate=!0)}updatePdMaterial(e){let t=!1;e.lumaPhi!==void 0&&(this.pdMaterial.uniforms.lumaPhi.value=e.lumaPhi),e.depthPhi!==void 0&&(this.pdMaterial.uniforms.depthPhi.value=e.depthPhi),e.normalPhi!==void 0&&(this.pdMaterial.uniforms.normalPhi.value=e.normalPhi),e.radius!==void 0&&e.radius!==this.radius&&(this.pdMaterial.uniforms.radius.value=e.radius),e.radiusExponent!==void 0&&e.radiusExponent!==this.pdRadiusExponent&&(this.pdRadiusExponent=e.radiusExponent,t=!0),e.rings!==void 0&&e.rings!==this.pdRings&&(this.pdRings=e.rings,t=!0),e.samples!==void 0&&e.samples!==this.pdSamples&&(this.pdSamples=e.samples,t=!0),t&&(this.pdMaterial.defines.SAMPLES=this.pdSamples,this.pdMaterial.defines.SAMPLE_VECTORS=mn(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 Se.OUTPUT.Off:break;case Se.OUTPUT.Diffuse:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Se.OUTPUT.AO:this.copyMaterial.uniforms.tDiffuse.value=this.gtaoRenderTarget.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Se.OUTPUT.Denoise:this.copyMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Se.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 Se.OUTPUT.Normal:this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t);break;case Se.OUTPUT.Default:this.copyMaterial.uniforms.tDiffuse.value=n.texture,this.copyMaterial.blending=S.NoBlending,this._renderPass(e,this.copyMaterial,this.renderToScreen?null:t),this.blendMaterial.uniforms.intensity.value=this.blendIntensity,this.blendMaterial.uniforms.tDiffuse.value=this.pdRenderTarget.texture,this._renderPass(e,this.blendMaterial,this.renderToScreen?null:t);break;default:console.warn("THREE.GTAOPass: Unknown output type.")}}_renderPass(e,t,n,i,o){e.getClearColor(this._originalClearColor);const s=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i!=null&&(e.setClearColor(i),e.setClearAlpha(o||0),e.clear()),this._fsQuad.material=t,this._fsQuad.render(e),e.autoClear=a,e.setClearColor(this._originalClearColor),e.setClearAlpha(s)}_renderOverride(e,t,n,i,o){e.getClearColor(this._originalClearColor);const s=e.getClearAlpha(),a=e.autoClear;e.setRenderTarget(n),e.autoClear=!1,i=t.clearColor||i,o=t.clearAlpha||o,i!=null&&(e.setClearColor(i),e.setClearAlpha(o||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(s)}_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 Zi,n=e*e*4,i=new Uint8Array(n);for(let s=0;s<e;s++)for(let a=0;a<e;a++){const l=s,h=a;i[(s*e+a)*4]=(t.noise(l,h)*.5+.5)*255,i[(s*e+a)*4+1]=(t.noise(l+e,h)*.5+.5)*255,i[(s*e+a)*4+2]=(t.noise(l,h+e)*.5+.5)*255,i[(s*e+a)*4+3]=(t.noise(l+e,h+e)*.5+.5)*255}const o=new S.DataTexture(i,e,e,S.RGBAFormat,S.UnsignedByteType);return o.wrapS=S.RepeatWrapping,o.wrapT=S.RepeatWrapping,o.needsUpdate=!0,o}}Se.OUTPUT={Off:-1,Default:0,Diffuse:1,Depth:2,Normal:3,AO:4,Denoise:5};const qi={uniforms:{tDiffuse:{value:null},luminosityThreshold:{value:1},smoothWidth:{value:1},defaultColor:{value:new S.Color(0)},defaultOpacity:{value:0}},vertexShader:`
395
+
396
+ varying vec2 vUv;
397
+
398
+ void main() {
399
+
400
+ vUv = uv;
401
+
402
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
403
+
404
+ }`,fragmentShader:`
405
+
406
+ uniform sampler2D tDiffuse;
407
+ uniform vec3 defaultColor;
408
+ uniform float defaultOpacity;
409
+ uniform float luminosityThreshold;
410
+ uniform float smoothWidth;
411
+
412
+ varying vec2 vUv;
413
+
414
+ void main() {
415
+
416
+ vec4 texel = texture2D( tDiffuse, vUv );
417
+
418
+ float v = luminance( texel.xyz );
419
+
420
+ vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );
421
+
422
+ float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );
423
+
424
+ gl_FragColor = mix( outputColor, texel, alpha );
425
+
426
+ }`};class Qe extends Ge{constructor(e,t=1,n,i){super(),this.strength=t,this.radius=n,this.threshold=i,this.resolution=e!==void 0?new S.Vector2(e.x,e.y):new S.Vector2(256,256),this.clearColor=new S.Color(0,0,0),this.needsSwap=!1,this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;let o=Math.round(this.resolution.x/2),s=Math.round(this.resolution.y/2);this.renderTargetBright=new S.WebGLRenderTarget(o,s,{type:S.HalfFloatType}),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(let u=0;u<this.nMips;u++){const f=new S.WebGLRenderTarget(o,s,{type:S.HalfFloatType});f.texture.name="UnrealBloomPass.h"+u,f.texture.generateMipmaps=!1,this.renderTargetsHorizontal.push(f);const g=new S.WebGLRenderTarget(o,s,{type:S.HalfFloatType});g.texture.name="UnrealBloomPass.v"+u,g.texture.generateMipmaps=!1,this.renderTargetsVertical.push(g),o=Math.round(o/2),s=Math.round(s/2)}const a=qi;this.highPassUniforms=S.UniformsUtils.clone(a.uniforms),this.highPassUniforms.luminosityThreshold.value=i,this.highPassUniforms.smoothWidth.value=.01,this.materialHighPassFilter=new S.ShaderMaterial({uniforms:this.highPassUniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader}),this.separableBlurMaterials=[];const l=[6,10,14,18,22];o=Math.round(this.resolution.x/2),s=Math.round(this.resolution.y/2);for(let u=0;u<this.nMips;u++)this.separableBlurMaterials.push(this._getSeparableBlurMaterial(l[u])),this.separableBlurMaterials[u].uniforms.invSize.value=new S.Vector2(1/o,1/s),o=Math.round(o/2),s=Math.round(s/2);this.compositeMaterial=this._getCompositeMaterial(this.nMips),this.compositeMaterial.uniforms.blurTexture1.value=this.renderTargetsVertical[0].texture,this.compositeMaterial.uniforms.blurTexture2.value=this.renderTargetsVertical[1].texture,this.compositeMaterial.uniforms.blurTexture3.value=this.renderTargetsVertical[2].texture,this.compositeMaterial.uniforms.blurTexture4.value=this.renderTargetsVertical[3].texture,this.compositeMaterial.uniforms.blurTexture5.value=this.renderTargetsVertical[4].texture,this.compositeMaterial.uniforms.bloomStrength.value=t,this.compositeMaterial.uniforms.bloomRadius.value=.1;const h=[1,.8,.6,.4,.2];this.compositeMaterial.uniforms.bloomFactors.value=h,this.bloomTintColors=[new S.Vector3(1,1,1),new S.Vector3(1,1,1),new S.Vector3(1,1,1),new S.Vector3(1,1,1),new S.Vector3(1,1,1)],this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,this.copyUniforms=S.UniformsUtils.clone(je.uniforms),this.blendMaterial=new S.ShaderMaterial({uniforms:this.copyUniforms,vertexShader:je.vertexShader,fragmentShader:je.fragmentShader,blending:S.AdditiveBlending,depthTest:!1,depthWrite:!1,transparent:!0}),this._oldClearColor=new S.Color,this._oldClearAlpha=1,this._basic=new S.MeshBasicMaterial,this._fsQuad=new gt(null)}dispose(){for(let e=0;e<this.renderTargetsHorizontal.length;e++)this.renderTargetsHorizontal[e].dispose();for(let e=0;e<this.renderTargetsVertical.length;e++)this.renderTargetsVertical[e].dispose();this.renderTargetBright.dispose();for(let e=0;e<this.separableBlurMaterials.length;e++)this.separableBlurMaterials[e].dispose();this.compositeMaterial.dispose(),this.blendMaterial.dispose(),this._basic.dispose(),this._fsQuad.dispose()}setSize(e,t){let n=Math.round(e/2),i=Math.round(t/2);this.renderTargetBright.setSize(n,i);for(let o=0;o<this.nMips;o++)this.renderTargetsHorizontal[o].setSize(n,i),this.renderTargetsVertical[o].setSize(n,i),this.separableBlurMaterials[o].uniforms.invSize.value=new S.Vector2(1/n,1/i),n=Math.round(n/2),i=Math.round(i/2)}render(e,t,n,i,o){e.getClearColor(this._oldClearColor),this._oldClearAlpha=e.getClearAlpha();const s=e.autoClear;e.autoClear=!1,e.setClearColor(this.clearColor,0),o&&e.state.buffers.stencil.setTest(!1),this.renderToScreen&&(this._fsQuad.material=this._basic,this._basic.map=n.texture,e.setRenderTarget(null),e.clear(),this._fsQuad.render(e)),this.highPassUniforms.tDiffuse.value=n.texture,this.highPassUniforms.luminosityThreshold.value=this.threshold,this._fsQuad.material=this.materialHighPassFilter,e.setRenderTarget(this.renderTargetBright),e.clear(),this._fsQuad.render(e);let a=this.renderTargetBright;for(let l=0;l<this.nMips;l++)this._fsQuad.material=this.separableBlurMaterials[l],this.separableBlurMaterials[l].uniforms.colorTexture.value=a.texture,this.separableBlurMaterials[l].uniforms.direction.value=Qe.BlurDirectionX,e.setRenderTarget(this.renderTargetsHorizontal[l]),e.clear(),this._fsQuad.render(e),this.separableBlurMaterials[l].uniforms.colorTexture.value=this.renderTargetsHorizontal[l].texture,this.separableBlurMaterials[l].uniforms.direction.value=Qe.BlurDirectionY,e.setRenderTarget(this.renderTargetsVertical[l]),e.clear(),this._fsQuad.render(e),a=this.renderTargetsVertical[l];this._fsQuad.material=this.compositeMaterial,this.compositeMaterial.uniforms.bloomStrength.value=this.strength,this.compositeMaterial.uniforms.bloomRadius.value=this.radius,this.compositeMaterial.uniforms.bloomTintColors.value=this.bloomTintColors,e.setRenderTarget(this.renderTargetsHorizontal[0]),e.clear(),this._fsQuad.render(e),this._fsQuad.material=this.blendMaterial,this.copyUniforms.tDiffuse.value=this.renderTargetsHorizontal[0].texture,o&&e.state.buffers.stencil.setTest(!0),this.renderToScreen?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(n),this._fsQuad.render(e)),e.setClearColor(this._oldClearColor,this._oldClearAlpha),e.autoClear=s}_getSeparableBlurMaterial(e){const t=[],n=e/3;for(let i=0;i<e;i++)t.push(.39894*Math.exp(-.5*i*i/(n*n))/n);return new S.ShaderMaterial({defines:{KERNEL_RADIUS:e},uniforms:{colorTexture:{value:null},invSize:{value:new S.Vector2(.5,.5)},direction:{value:new S.Vector2(.5,.5)},gaussianCoefficients:{value:t}},vertexShader:`varying vec2 vUv;
427
+ void main() {
428
+ vUv = uv;
429
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
430
+ }`,fragmentShader:`#include <common>
431
+ varying vec2 vUv;
432
+ uniform sampler2D colorTexture;
433
+ uniform vec2 invSize;
434
+ uniform vec2 direction;
435
+ uniform float gaussianCoefficients[KERNEL_RADIUS];
436
+
437
+ void main() {
438
+ float weightSum = gaussianCoefficients[0];
439
+ vec3 diffuseSum = texture2D( colorTexture, vUv ).rgb * weightSum;
440
+ for( int i = 1; i < KERNEL_RADIUS; i ++ ) {
441
+ float x = float(i);
442
+ float w = gaussianCoefficients[i];
443
+ vec2 uvOffset = direction * invSize * x;
444
+ vec3 sample1 = texture2D( colorTexture, vUv + uvOffset ).rgb;
445
+ vec3 sample2 = texture2D( colorTexture, vUv - uvOffset ).rgb;
446
+ diffuseSum += ( sample1 + sample2 ) * w;
447
+ }
448
+ gl_FragColor = vec4( diffuseSum, 1.0 );
449
+ }`})}_getCompositeMaterial(e){return new S.ShaderMaterial({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:`varying vec2 vUv;
450
+ void main() {
451
+ vUv = uv;
452
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
453
+ }`,fragmentShader:`varying vec2 vUv;
454
+ uniform sampler2D blurTexture1;
455
+ uniform sampler2D blurTexture2;
456
+ uniform sampler2D blurTexture3;
457
+ uniform sampler2D blurTexture4;
458
+ uniform sampler2D blurTexture5;
459
+ uniform float bloomStrength;
460
+ uniform float bloomRadius;
461
+ uniform float bloomFactors[NUM_MIPS];
462
+ uniform vec3 bloomTintColors[NUM_MIPS];
463
+
464
+ float lerpBloomFactor(const in float factor) {
465
+ float mirrorFactor = 1.2 - factor;
466
+ return mix(factor, mirrorFactor, bloomRadius);
467
+ }
468
+
469
+ void main() {
470
+ gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) +
471
+ lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) +
472
+ lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) +
473
+ lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) +
474
+ lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );
475
+ }`})}}Qe.BlurDirectionX=new S.Vector2(1,0),Qe.BlurDirectionY=new S.Vector2(0,1);const xt={name:"OutputShader",uniforms:{tDiffuse:{value:null},toneMappingExposure:{value:1}},vertexShader:`
476
+ precision highp float;
477
+
478
+ uniform mat4 modelViewMatrix;
479
+ uniform mat4 projectionMatrix;
480
+
481
+ attribute vec3 position;
482
+ attribute vec2 uv;
483
+
484
+ varying vec2 vUv;
485
+
486
+ void main() {
487
+
488
+ vUv = uv;
489
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
490
+
491
+ }`,fragmentShader:`
492
+
493
+ precision highp float;
494
+
495
+ uniform sampler2D tDiffuse;
496
+
497
+ #include <tonemapping_pars_fragment>
498
+ #include <colorspace_pars_fragment>
499
+
500
+ varying vec2 vUv;
501
+
502
+ void main() {
503
+
504
+ gl_FragColor = texture2D( tDiffuse, vUv );
505
+
506
+ // tone mapping
507
+
508
+ #ifdef LINEAR_TONE_MAPPING
509
+
510
+ gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb );
511
+
512
+ #elif defined( REINHARD_TONE_MAPPING )
513
+
514
+ gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb );
515
+
516
+ #elif defined( CINEON_TONE_MAPPING )
517
+
518
+ gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb );
519
+
520
+ #elif defined( ACES_FILMIC_TONE_MAPPING )
521
+
522
+ gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb );
523
+
524
+ #elif defined( AGX_TONE_MAPPING )
525
+
526
+ gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb );
527
+
528
+ #elif defined( NEUTRAL_TONE_MAPPING )
529
+
530
+ gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb );
531
+
532
+ #elif defined( CUSTOM_TONE_MAPPING )
533
+
534
+ gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb );
535
+
536
+ #endif
537
+
538
+ // color space
539
+
540
+ #ifdef SRGB_TRANSFER
541
+
542
+ gl_FragColor = sRGBTransferOETF( gl_FragColor );
543
+
544
+ #endif
545
+
546
+ }`};class Yi extends Ge{constructor(){super(),this.uniforms=S.UniformsUtils.clone(xt.uniforms),this.material=new S.RawShaderMaterial({name:xt.name,uniforms:this.uniforms,vertexShader:xt.vertexShader,fragmentShader:xt.fragmentShader}),this._fsQuad=new gt(this.material),this._outputColorSpace=null,this._toneMapping=null}render(e,t,n){this.uniforms.tDiffuse.value=n.texture,this.uniforms.toneMappingExposure.value=e.toneMappingExposure,(this._outputColorSpace!==e.outputColorSpace||this._toneMapping!==e.toneMapping)&&(this._outputColorSpace=e.outputColorSpace,this._toneMapping=e.toneMapping,this.material.defines={},S.ColorManagement.getTransfer(this._outputColorSpace)===S.SRGBTransfer&&(this.material.defines.SRGB_TRANSFER=""),this._toneMapping===S.LinearToneMapping?this.material.defines.LINEAR_TONE_MAPPING="":this._toneMapping===S.ReinhardToneMapping?this.material.defines.REINHARD_TONE_MAPPING="":this._toneMapping===S.CineonToneMapping?this.material.defines.CINEON_TONE_MAPPING="":this._toneMapping===S.ACESFilmicToneMapping?this.material.defines.ACES_FILMIC_TONE_MAPPING="":this._toneMapping===S.AgXToneMapping?this.material.defines.AGX_TONE_MAPPING="":this._toneMapping===S.NeutralToneMapping?this.material.defines.NEUTRAL_TONE_MAPPING="":this._toneMapping===S.CustomToneMapping&&(this.material.defines.CUSTOM_TONE_MAPPING=""),this.material.needsUpdate=!0),this.renderToScreen===!0?(e.setRenderTarget(null),this._fsQuad.render(e)):(e.setRenderTarget(t),this.clear&&e.clear(e.autoClearColor,e.autoClearDepth,e.autoClearStencil),this._fsQuad.render(e))}dispose(){this.material.dispose(),this._fsQuad.dispose()}}const Hi={name:"FXAAShader",uniforms:{tDiffuse:{value:null},resolution:{value:new S.Vector2(1/1024,1/512)}},vertexShader:`
547
+
548
+ varying vec2 vUv;
549
+
550
+ void main() {
551
+
552
+ vUv = uv;
553
+ gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
554
+
555
+ }`,fragmentShader:`
556
+
557
+ uniform sampler2D tDiffuse;
558
+ uniform vec2 resolution;
559
+ varying vec2 vUv;
560
+
561
+ #define EDGE_STEP_COUNT 6
562
+ #define EDGE_GUESS 8.0
563
+ #define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0
564
+ const float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );
565
+
566
+ float _ContrastThreshold = 0.0312;
567
+ float _RelativeThreshold = 0.063;
568
+ float _SubpixelBlending = 1.0;
569
+
570
+ vec4 Sample( sampler2D tex2D, vec2 uv ) {
571
+
572
+ return texture( tex2D, uv );
573
+
574
+ }
575
+
576
+ float SampleLuminance( sampler2D tex2D, vec2 uv ) {
577
+
578
+ return dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );
579
+
580
+ }
581
+
582
+ float SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {
583
+
584
+ uv += texSize * vec2(uOffset, vOffset);
585
+ return SampleLuminance(tex2D, uv);
586
+
587
+ }
588
+
589
+ struct LuminanceData {
590
+
591
+ float m, n, e, s, w;
592
+ float ne, nw, se, sw;
593
+ float highest, lowest, contrast;
594
+
595
+ };
596
+
597
+ LuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {
598
+
599
+ LuminanceData l;
600
+ l.m = SampleLuminance( tex2D, uv );
601
+ l.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );
602
+ l.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );
603
+ l.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );
604
+ l.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );
605
+
606
+ l.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );
607
+ l.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );
608
+ l.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );
609
+ l.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );
610
+
611
+ l.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );
612
+ l.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );
613
+ l.contrast = l.highest - l.lowest;
614
+ return l;
615
+
616
+ }
617
+
618
+ bool ShouldSkipPixel( LuminanceData l ) {
619
+
620
+ float threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );
621
+ return l.contrast < threshold;
622
+
623
+ }
624
+
625
+ float DeterminePixelBlendFactor( LuminanceData l ) {
626
+
627
+ float f = 2.0 * ( l.n + l.e + l.s + l.w );
628
+ f += l.ne + l.nw + l.se + l.sw;
629
+ f *= 1.0 / 12.0;
630
+ f = abs( f - l.m );
631
+ f = clamp( f / l.contrast, 0.0, 1.0 );
632
+
633
+ float blendFactor = smoothstep( 0.0, 1.0, f );
634
+ return blendFactor * blendFactor * _SubpixelBlending;
635
+
636
+ }
637
+
638
+ struct EdgeData {
639
+
640
+ bool isHorizontal;
641
+ float pixelStep;
642
+ float oppositeLuminance, gradient;
643
+
644
+ };
645
+
646
+ EdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {
647
+
648
+ EdgeData e;
649
+ float horizontal =
650
+ abs( l.n + l.s - 2.0 * l.m ) * 2.0 +
651
+ abs( l.ne + l.se - 2.0 * l.e ) +
652
+ abs( l.nw + l.sw - 2.0 * l.w );
653
+ float vertical =
654
+ abs( l.e + l.w - 2.0 * l.m ) * 2.0 +
655
+ abs( l.ne + l.nw - 2.0 * l.n ) +
656
+ abs( l.se + l.sw - 2.0 * l.s );
657
+ e.isHorizontal = horizontal >= vertical;
658
+
659
+ float pLuminance = e.isHorizontal ? l.n : l.e;
660
+ float nLuminance = e.isHorizontal ? l.s : l.w;
661
+ float pGradient = abs( pLuminance - l.m );
662
+ float nGradient = abs( nLuminance - l.m );
663
+
664
+ e.pixelStep = e.isHorizontal ? texSize.y : texSize.x;
665
+
666
+ if (pGradient < nGradient) {
667
+
668
+ e.pixelStep = -e.pixelStep;
669
+ e.oppositeLuminance = nLuminance;
670
+ e.gradient = nGradient;
671
+
672
+ } else {
673
+
674
+ e.oppositeLuminance = pLuminance;
675
+ e.gradient = pGradient;
676
+
677
+ }
678
+
679
+ return e;
680
+
681
+ }
682
+
683
+ float DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {
684
+
685
+ vec2 uvEdge = uv;
686
+ vec2 edgeStep;
687
+ if (e.isHorizontal) {
688
+
689
+ uvEdge.y += e.pixelStep * 0.5;
690
+ edgeStep = vec2( texSize.x, 0.0 );
691
+
692
+ } else {
693
+
694
+ uvEdge.x += e.pixelStep * 0.5;
695
+ edgeStep = vec2( 0.0, texSize.y );
696
+
697
+ }
698
+
699
+ float edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;
700
+ float gradientThreshold = e.gradient * 0.25;
701
+
702
+ vec2 puv = uvEdge + edgeStep * edgeSteps[0];
703
+ float pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;
704
+ bool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;
705
+
706
+ for ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {
707
+
708
+ puv += edgeStep * edgeSteps[i];
709
+ pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;
710
+ pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;
711
+
712
+ }
713
+
714
+ if ( !pAtEnd ) {
715
+
716
+ puv += edgeStep * EDGE_GUESS;
717
+
718
+ }
719
+
720
+ vec2 nuv = uvEdge - edgeStep * edgeSteps[0];
721
+ float nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;
722
+ bool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;
723
+
724
+ for ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {
725
+
726
+ nuv -= edgeStep * edgeSteps[i];
727
+ nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;
728
+ nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;
729
+
730
+ }
731
+
732
+ if ( !nAtEnd ) {
733
+
734
+ nuv -= edgeStep * EDGE_GUESS;
735
+
736
+ }
737
+
738
+ float pDistance, nDistance;
739
+ if ( e.isHorizontal ) {
740
+
741
+ pDistance = puv.x - uv.x;
742
+ nDistance = uv.x - nuv.x;
743
+
744
+ } else {
745
+
746
+ pDistance = puv.y - uv.y;
747
+ nDistance = uv.y - nuv.y;
748
+
749
+ }
750
+
751
+ float shortestDistance;
752
+ bool deltaSign;
753
+ if ( pDistance <= nDistance ) {
754
+
755
+ shortestDistance = pDistance;
756
+ deltaSign = pLuminanceDelta >= 0.0;
757
+
758
+ } else {
759
+
760
+ shortestDistance = nDistance;
761
+ deltaSign = nLuminanceDelta >= 0.0;
762
+
763
+ }
764
+
765
+ if ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {
766
+
767
+ return 0.0;
768
+
769
+ }
770
+
771
+ return 0.5 - shortestDistance / ( pDistance + nDistance );
772
+
773
+ }
774
+
775
+ vec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {
776
+
777
+ LuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );
778
+ if ( ShouldSkipPixel( luminance ) ) {
779
+
780
+ return Sample( tex2D, uv );
781
+
782
+ }
783
+
784
+ float pixelBlend = DeterminePixelBlendFactor( luminance );
785
+ EdgeData edge = DetermineEdge( texSize, luminance );
786
+ float edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );
787
+ float finalBlend = max( pixelBlend, edgeBlend );
788
+
789
+ if (edge.isHorizontal) {
790
+
791
+ uv.y += edge.pixelStep * finalBlend;
792
+
793
+ } else {
794
+
795
+ uv.x += edge.pixelStep * finalBlend;
796
+
797
+ }
798
+
799
+ return Sample( tex2D, uv );
800
+
801
+ }
802
+
803
+ void main() {
804
+
805
+ gl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );
806
+
807
+ }`},$i={uniforms:{tDiffuse:{value:null},saturation:{value:1.2},contrast:{value:1.2}},vertexShader:`
808
+ varying vec2 vUv;
809
+ void main() {
810
+ vUv = uv;
811
+ gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
812
+ }
813
+ `,fragmentShader:`
814
+ uniform sampler2D tDiffuse;
815
+ uniform float saturation;
816
+ uniform float contrast;
817
+ varying vec2 vUv;
818
+
819
+ void main() {
820
+ vec4 color = texture2D(tDiffuse, vUv);
821
+
822
+ // 转换为灰度值用于饱和度调整
823
+ float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));
824
+
825
+ // 混合原始颜色和灰度值来调整饱和度
826
+ color.rgb = mix(vec3(gray), color.rgb, saturation);
827
+
828
+ // 调整对比度
829
+ color.rgb = (color.rgb - 0.5) * contrast + 0.5;
830
+
831
+ gl_FragColor = color;
832
+ }
833
+ `};class Qi{engine;composer;saturationPass;constructor(e){this.engine=e}resize(){const{width:e,height:t}=this.engine.deviceModule.getContainerSize(),n=e/t;if(this.composer){this.composer.setPixelRatio(n),this.composer.setSize(e,t);const i=this.composer.passes.find(o=>o instanceof yt&&o.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,o=this.engine.renderer,s=e/t,a=new x.WebGLRenderTarget(e,t,{minFilter:x.LinearFilter,magFilter:x.LinearFilter,format:x.RGBAFormat,samples:4});this.composer=new ji(o,a),this.composer.setPixelRatio(s),this.composer.setSize(e,t);const l=new Gi(n,i);this.composer.addPass(l);const h=new Se(n,i,e,t);h.output=Se.OUTPUT.Default,h.blendIntensity=.5,h.updateGtaoMaterial&&h.updateGtaoMaterial({radius:1,distanceExponent:1,thickness:1,scale:1,distanceFallOff:1,screenSpaceRadius:!0}),new Qe(new x.Vector2(e,t),.1,.1,.5),this.saturationPass=new yt($i),this.saturationPass.uniforms.saturation.value=1.3,this.saturationPass.uniforms.contrast.value=1.1,this.composer.addPass(this.saturationPass);const u=new Yi;this.composer.addPass(u);const f=new yt(Hi);f.material.uniforms.resolution.value.x=1/(e*s),f.material.uniforms.resolution.value.y=1/(t*s),this.composer.addPass(f)}}var vt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function gn(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function St(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 jt={exports:{}};var yn;function Ji(){return yn||(yn=1,(function(r,e){(function(t){r.exports=t()})(function(){return(function t(n,i,o){function s(h,u){if(!i[h]){if(!n[h]){var f=typeof St=="function"&&St;if(!u&&f)return f(h,!0);if(a)return a(h,!0);var g=new Error("Cannot find module '"+h+"'");throw g.code="MODULE_NOT_FOUND",g}var p=i[h]={exports:{}};n[h][0].call(p.exports,function(c){var d=n[h][1][c];return s(d||c)},p,p.exports,t,n,i,o)}return i[h].exports}for(var a=typeof St=="function"&&St,l=0;l<o.length;l++)s(o[l]);return s})({1:[function(t,n,i){var o=t("./utils"),s=t("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";i.encode=function(l){for(var h,u,f,g,p,c,d,m=[],y=0,w=l.length,v=w,M=o.getTypeOf(l)!=="string";y<l.length;)v=w-y,f=M?(h=l[y++],u=y<w?l[y++]:0,y<w?l[y++]:0):(h=l.charCodeAt(y++),u=y<w?l.charCodeAt(y++):0,y<w?l.charCodeAt(y++):0),g=h>>2,p=(3&h)<<4|u>>4,c=1<v?(15&u)<<2|f>>6:64,d=2<v?63&f:64,m.push(a.charAt(g)+a.charAt(p)+a.charAt(c)+a.charAt(d));return m.join("")},i.decode=function(l){var h,u,f,g,p,c,d=0,m=0,y="data:";if(l.substr(0,y.length)===y)throw new Error("Invalid base64 input, it looks like a data url.");var w,v=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&v--,l.charAt(l.length-2)===a.charAt(64)&&v--,v%1!=0)throw new Error("Invalid base64 input, bad content length.");for(w=s.uint8array?new Uint8Array(0|v):new Array(0|v);d<l.length;)h=a.indexOf(l.charAt(d++))<<2|(g=a.indexOf(l.charAt(d++)))>>4,u=(15&g)<<4|(p=a.indexOf(l.charAt(d++)))>>2,f=(3&p)<<6|(c=a.indexOf(l.charAt(d++))),w[m++]=h,p!==64&&(w[m++]=u),c!==64&&(w[m++]=f);return w}},{"./support":30,"./utils":32}],2:[function(t,n,i){var o=t("./external"),s=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function h(u,f,g,p,c){this.compressedSize=u,this.uncompressedSize=f,this.crc32=g,this.compression=p,this.compressedContent=c}h.prototype={getContentWorker:function(){var u=new s(o.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),f=this;return u.on("end",function(){if(this.streamInfo.data_length!==f.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new s(o.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},h.createWorkerFrom=function(u,f,g){return u.pipe(new a).pipe(new l("uncompressedSize")).pipe(f.compressWorker(g)).pipe(new l("compressedSize")).withStreamInfo("compression",f)},n.exports=h},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,n,i){var o=t("./stream/GenericWorker");i.STORE={magic:"\0\0",compressWorker:function(){return new o("STORE compression")},uncompressWorker:function(){return new o("STORE decompression")}},i.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,n,i){var o=t("./utils"),s=(function(){for(var a,l=[],h=0;h<256;h++){a=h;for(var u=0;u<8;u++)a=1&a?3988292384^a>>>1:a>>>1;l[h]=a}return l})();n.exports=function(a,l){return a!==void 0&&a.length?o.getTypeOf(a)!=="string"?(function(h,u,f,g){var p=s,c=g+f;h^=-1;for(var d=g;d<c;d++)h=h>>>8^p[255&(h^u[d])];return-1^h})(0|l,a,a.length,0):(function(h,u,f,g){var p=s,c=g+f;h^=-1;for(var d=g;d<c;d++)h=h>>>8^p[255&(h^u.charCodeAt(d))];return-1^h})(0|l,a,a.length,0):0}},{"./utils":32}],5:[function(t,n,i){i.base64=!1,i.binary=!1,i.dir=!1,i.createFolders=!0,i.date=null,i.compression=null,i.compressionOptions=null,i.comment=null,i.unixPermissions=null,i.dosPermissions=null},{}],6:[function(t,n,i){var o=null;o=typeof Promise<"u"?Promise:t("lie"),n.exports={Promise:o}},{lie:37}],7:[function(t,n,i){var o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),h=o?"uint8array":"array";function u(f,g){l.call(this,"FlateWorker/"+f),this._pako=null,this._pakoAction=f,this._pakoOptions=g,this.meta={}}i.magic="\b\0",a.inherits(u,l),u.prototype.processChunk=function(f){this.meta=f.meta,this._pako===null&&this._createPako(),this._pako.push(a.transformTo(h,f.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var f=this;this._pako.onData=function(g){f.push({data:g,meta:f.meta})}},i.compressWorker=function(f){return new u("Deflate",f)},i.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,n,i){function o(p,c){var d,m="";for(d=0;d<c;d++)m+=String.fromCharCode(255&p),p>>>=8;return m}function s(p,c,d,m,y,w){var v,M,P=p.file,D=p.compression,E=w!==h.utf8encode,O=a.transformTo("string",w(P.name)),k=a.transformTo("string",h.utf8encode(P.name)),I=P.comment,W=a.transformTo("string",w(I)),T=a.transformTo("string",h.utf8encode(I)),B=k.length!==P.name.length,b=T.length!==I.length,V="",J="",X="",ee=P.dir,j=P.date,ne={crc32:0,compressedSize:0,uncompressedSize:0};c&&!d||(ne.crc32=p.crc32,ne.compressedSize=p.compressedSize,ne.uncompressedSize=p.uncompressedSize);var z=0;c&&(z|=8),E||!B&&!b||(z|=2048);var N=0,te=0;ee&&(N|=16),y==="UNIX"?(te=798,N|=(function(H,de){var fe=H;return H||(fe=de?16893:33204),(65535&fe)<<16})(P.unixPermissions,ee)):(te=20,N|=(function(H){return 63&(H||0)})(P.dosPermissions)),v=j.getUTCHours(),v<<=6,v|=j.getUTCMinutes(),v<<=5,v|=j.getUTCSeconds()/2,M=j.getUTCFullYear()-1980,M<<=4,M|=j.getUTCMonth()+1,M<<=5,M|=j.getUTCDate(),B&&(J=o(1,1)+o(u(O),4)+k,V+="up"+o(J.length,2)+J),b&&(X=o(1,1)+o(u(W),4)+T,V+="uc"+o(X.length,2)+X);var $="";return $+=`
834
+ \0`,$+=o(z,2),$+=D.magic,$+=o(v,2),$+=o(M,2),$+=o(ne.crc32,4),$+=o(ne.compressedSize,4),$+=o(ne.uncompressedSize,4),$+=o(O.length,2),$+=o(V.length,2),{fileRecord:f.LOCAL_FILE_HEADER+$+O+V,dirRecord:f.CENTRAL_FILE_HEADER+o(te,2)+$+o(W.length,2)+"\0\0\0\0"+o(N,4)+o(m,4)+O+V+W}}var a=t("../utils"),l=t("../stream/GenericWorker"),h=t("../utf8"),u=t("../crc32"),f=t("../signature");function g(p,c,d,m){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=c,this.zipPlatform=d,this.encodeFileName=m,this.streamFiles=p,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(g,l),g.prototype.push=function(p){var c=p.meta.percent||0,d=this.entriesCount,m=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?(c+100*(d-m-1))/d:100}}))},g.prototype.openedSource=function(p){this.currentSourceOffset=this.bytesWritten,this.currentFile=p.file.name;var c=this.streamFiles&&!p.file.dir;if(c){var d=s(p,c,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:d.fileRecord,meta:{percent:0}})}else this.accumulate=!0},g.prototype.closedSource=function(p){this.accumulate=!1;var c=this.streamFiles&&!p.file.dir,d=s(p,c,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(d.dirRecord),c)this.push({data:(function(m){return f.DATA_DESCRIPTOR+o(m.crc32,4)+o(m.compressedSize,4)+o(m.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},g.prototype.flush=function(){for(var p=this.bytesWritten,c=0;c<this.dirRecords.length;c++)this.push({data:this.dirRecords[c],meta:{percent:100}});var d=this.bytesWritten-p,m=(function(y,w,v,M,P){var D=a.transformTo("string",P(M));return f.CENTRAL_DIRECTORY_END+"\0\0\0\0"+o(y,2)+o(y,2)+o(w,4)+o(v,4)+o(D.length,2)+D})(this.dirRecords.length,d,p,this.zipComment,this.encodeFileName);this.push({data:m,meta:{percent:100}})},g.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},g.prototype.registerPrevious=function(p){this._sources.push(p);var c=this;return p.on("data",function(d){c.processChunk(d)}),p.on("end",function(){c.closedSource(c.previous.streamInfo),c._sources.length?c.prepareNextSource():c.end()}),p.on("error",function(d){c.error(d)}),this},g.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))},g.prototype.error=function(p){var c=this._sources;if(!l.prototype.error.call(this,p))return!1;for(var d=0;d<c.length;d++)try{c[d].error(p)}catch{}return!0},g.prototype.lock=function(){l.prototype.lock.call(this);for(var p=this._sources,c=0;c<p.length;c++)p[c].lock()},n.exports=g},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,n,i){var o=t("../compressions"),s=t("./ZipFileWorker");i.generateWorker=function(a,l,h){var u=new s(l.streamFiles,h,l.platform,l.encodeFileName),f=0;try{a.forEach(function(g,p){f++;var c=(function(w,v){var M=w||v,P=o[M];if(!P)throw new Error(M+" is not a valid compression method !");return P})(p.options.compression,l.compression),d=p.options.compressionOptions||l.compressionOptions||{},m=p.dir,y=p.date;p._compressWorker(c,d).withStreamInfo("file",{name:g,dir:m,date:y,comment:p.comment||"",unixPermissions:p.unixPermissions,dosPermissions:p.dosPermissions}).pipe(u)}),u.entriesCount=f}catch(g){u.error(g)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,n,i){function o(){if(!(this instanceof o))return new o;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 s=new o;for(var a in this)typeof this[a]!="function"&&(s[a]=this[a]);return s}}(o.prototype=t("./object")).loadAsync=t("./load"),o.support=t("./support"),o.defaults=t("./defaults"),o.version="3.10.1",o.loadAsync=function(s,a){return new o().loadAsync(s,a)},o.external=t("./external"),n.exports=o},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,n,i){var o=t("./utils"),s=t("./external"),a=t("./utf8"),l=t("./zipEntries"),h=t("./stream/Crc32Probe"),u=t("./nodejsUtils");function f(g){return new s.Promise(function(p,c){var d=g.decompressed.getContentWorker().pipe(new h);d.on("error",function(m){c(m)}).on("end",function(){d.streamInfo.crc32!==g.decompressed.crc32?c(new Error("Corrupted zip : CRC32 mismatch")):p()}).resume()})}n.exports=function(g,p){var c=this;return p=o.extend(p||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),u.isNode&&u.isStream(g)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):o.prepareContent("the loaded zip file",g,!0,p.optimizedBinaryString,p.base64).then(function(d){var m=new l(p);return m.load(d),m}).then(function(d){var m=[s.Promise.resolve(d)],y=d.files;if(p.checkCRC32)for(var w=0;w<y.length;w++)m.push(f(y[w]));return s.Promise.all(m)}).then(function(d){for(var m=d.shift(),y=m.files,w=0;w<y.length;w++){var v=y[w],M=v.fileNameStr,P=o.resolve(v.fileNameStr);c.file(P,v.decompressed,{binary:!0,optimizedBinaryString:!0,date:v.date,dir:v.dir,comment:v.fileCommentStr.length?v.fileCommentStr:null,unixPermissions:v.unixPermissions,dosPermissions:v.dosPermissions,createFolders:p.createFolders}),v.dir||(c.file(P).unsafeOriginalName=M)}return m.zipComment.length&&(c.comment=m.zipComment),c})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,n,i){var o=t("../utils"),s=t("../stream/GenericWorker");function a(l,h){s.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(h)}o.inherits(a,s),a.prototype._bindStream=function(l){var h=this;(this._stream=l).pause(),l.on("data",function(u){h.push({data:u,meta:{percent:0}})}).on("error",function(u){h.isPaused?this.generatedError=u:h.error(u)}).on("end",function(){h.isPaused?h._upstreamEnded=!0:h.end()})},a.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!s.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 o=t("readable-stream").Readable;function s(a,l,h){o.call(this,l),this._helper=a;var u=this;a.on("data",function(f,g){u.push(f)||u._helper.pause(),h&&h(g)}).on("error",function(f){u.emit("error",f)}).on("end",function(){u.push(null)})}t("../utils").inherits(s,o),s.prototype._read=function(){this._helper.resume()},n.exports=s},{"../utils":32,"readable-stream":16}],14:[function(t,n,i){n.exports={isNode:typeof Buffer<"u",newBufferFrom:function(o,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(o,s);if(typeof o=="number")throw new Error('The "data" argument must not be a number');return new Buffer(o,s)},allocBuffer:function(o){if(Buffer.alloc)return Buffer.alloc(o);var s=new Buffer(o);return s.fill(0),s},isBuffer:function(o){return Buffer.isBuffer(o)},isStream:function(o){return o&&typeof o.on=="function"&&typeof o.pause=="function"&&typeof o.resume=="function"}}},{}],15:[function(t,n,i){function o(P,D,E){var O,k=a.getTypeOf(D),I=a.extend(E||{},u);I.date=I.date||new Date,I.compression!==null&&(I.compression=I.compression.toUpperCase()),typeof I.unixPermissions=="string"&&(I.unixPermissions=parseInt(I.unixPermissions,8)),I.unixPermissions&&16384&I.unixPermissions&&(I.dir=!0),I.dosPermissions&&16&I.dosPermissions&&(I.dir=!0),I.dir&&(P=y(P)),I.createFolders&&(O=m(P))&&w.call(this,O,!0);var W=k==="string"&&I.binary===!1&&I.base64===!1;E&&E.binary!==void 0||(I.binary=!W),(D instanceof f&&D.uncompressedSize===0||I.dir||!D||D.length===0)&&(I.base64=!1,I.binary=!0,D="",I.compression="STORE",k="string");var T=null;T=D instanceof f||D instanceof l?D:c.isNode&&c.isStream(D)?new d(P,D):a.prepareContent(P,D,I.binary,I.optimizedBinaryString,I.base64);var B=new g(P,T,I);this.files[P]=B}var s=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),h=t("./stream/StreamHelper"),u=t("./defaults"),f=t("./compressedObject"),g=t("./zipObject"),p=t("./generate"),c=t("./nodejsUtils"),d=t("./nodejs/NodejsStreamInputAdapter"),m=function(P){P.slice(-1)==="/"&&(P=P.substring(0,P.length-1));var D=P.lastIndexOf("/");return 0<D?P.substring(0,D):""},y=function(P){return P.slice(-1)!=="/"&&(P+="/"),P},w=function(P,D){return D=D!==void 0?D:u.createFolders,P=y(P),this.files[P]||o.call(this,P,null,{dir:!0,createFolders:D}),this.files[P]};function v(P){return Object.prototype.toString.call(P)==="[object RegExp]"}var M={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(P){var D,E,O;for(D in this.files)O=this.files[D],(E=D.slice(this.root.length,D.length))&&D.slice(0,this.root.length)===this.root&&P(E,O)},filter:function(P){var D=[];return this.forEach(function(E,O){P(E,O)&&D.push(O)}),D},file:function(P,D,E){if(arguments.length!==1)return P=this.root+P,o.call(this,P,D,E),this;if(v(P)){var O=P;return this.filter(function(I,W){return!W.dir&&O.test(I)})}var k=this.files[this.root+P];return k&&!k.dir?k:null},folder:function(P){if(!P)return this;if(v(P))return this.filter(function(k,I){return I.dir&&P.test(k)});var D=this.root+P,E=w.call(this,D),O=this.clone();return O.root=E.name,O},remove:function(P){P=this.root+P;var D=this.files[P];if(D||(P.slice(-1)!=="/"&&(P+="/"),D=this.files[P]),D&&!D.dir)delete this.files[P];else for(var E=this.filter(function(k,I){return I.name.slice(0,P.length)===P}),O=0;O<E.length;O++)delete this.files[E[O].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(P){var D,E={};try{if((E=a.extend(P||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=E.type.toLowerCase(),E.compression=E.compression.toUpperCase(),E.type==="binarystring"&&(E.type="string"),!E.type)throw new Error("No output type specified.");a.checkSupport(E.type),E.platform!=="darwin"&&E.platform!=="freebsd"&&E.platform!=="linux"&&E.platform!=="sunos"||(E.platform="UNIX"),E.platform==="win32"&&(E.platform="DOS");var O=E.comment||this.comment||"";D=p.generateWorker(this,E,O)}catch(k){(D=new l("error")).error(k)}return new h(D,E.type||"string",E.mimeType)},generateAsync:function(P,D){return this.generateInternalStream(P).accumulate(D)},generateNodeStream:function(P,D){return(P=P||{}).type||(P.type="nodebuffer"),this.generateInternalStream(P).toNodejsStream(D)}};n.exports=M},{"./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 o=t("./DataReader");function s(a){o.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}t("../utils").inherits(s,o),s.prototype.byteAt=function(a){return this.data[this.zero+a]},s.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),h=a.charCodeAt(1),u=a.charCodeAt(2),f=a.charCodeAt(3),g=this.length-4;0<=g;--g)if(this.data[g]===l&&this.data[g+1]===h&&this.data[g+2]===u&&this.data[g+3]===f)return g-this.zero;return-1},s.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),h=a.charCodeAt(1),u=a.charCodeAt(2),f=a.charCodeAt(3),g=this.readData(4);return l===g[0]&&h===g[1]&&u===g[2]&&f===g[3]},s.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=s},{"../utils":32,"./DataReader":18}],18:[function(t,n,i){var o=t("../utils");function s(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,h=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)h=(h<<8)+this.byteAt(l);return this.index+=a,h},readString:function(a){return o.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=s},{"../utils":32}],19:[function(t,n,i){var o=t("./Uint8ArrayReader");function s(a){o.call(this,a)}t("../utils").inherits(s,o),s.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=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,n,i){var o=t("./DataReader");function s(a){o.call(this,a)}t("../utils").inherits(s,o),s.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},s.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},s.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},s.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=s},{"../utils":32,"./DataReader":18}],21:[function(t,n,i){var o=t("./ArrayReader");function s(a){o.call(this,a)}t("../utils").inherits(s,o),s.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=s},{"../utils":32,"./ArrayReader":17}],22:[function(t,n,i){var o=t("../utils"),s=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),h=t("./NodeBufferReader"),u=t("./Uint8ArrayReader");n.exports=function(f){var g=o.getTypeOf(f);return o.checkSupport(g),g!=="string"||s.uint8array?g==="nodebuffer"?new h(f):s.uint8array?new u(o.transformTo("uint8array",f)):new a(o.transformTo("array",f)):new l(f)}},{"../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 o=t("./GenericWorker"),s=t("../utils");function a(l){o.call(this,"ConvertWorker to "+l),this.destType=l}s.inherits(a,o),a.prototype.processChunk=function(l){this.push({data:s.transformTo(this.destType,l.data),meta:l.meta})},n.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,n,i){var o=t("./GenericWorker"),s=t("../crc32");function a(){o.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,o),a.prototype.processChunk=function(l){this.streamInfo.crc32=s(l.data,this.streamInfo.crc32||0),this.push(l)},n.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,n,i){var o=t("../utils"),s=t("./GenericWorker");function a(l){s.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}o.inherits(a,s),a.prototype.processChunk=function(l){if(l){var h=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=h+l.data.length}s.prototype.processChunk.call(this,l)},n.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,n,i){var o=t("../utils"),s=t("./GenericWorker");function a(l){s.call(this,"DataWorker");var h=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){h.dataIsReady=!0,h.data=u,h.max=u&&u.length||0,h.type=o.getTypeOf(u),h.isPaused||h._tickAndRepeat()},function(u){h.error(u)})}o.inherits(a,s),a.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,o.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(o.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,h=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,h);break;case"uint8array":l=this.data.subarray(this.index,h);break;case"array":case"nodebuffer":l=this.data.slice(this.index,h)}return this.index=h,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},n.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(t,n,i){function o(s){this.name=s||"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}o.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,a){return this._listeners[s].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,a){if(this._listeners[s])for(var l=0;l<this._listeners[s].length;l++)this._listeners[s][l].call(this,a)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var a=this;return s.on("data",function(l){a.processChunk(l)}),s.on("end",function(){a.end()}),s.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 s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,a){return this.extraStreamInfo[s]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},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 s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},n.exports=o},{}],29:[function(t,n,i){var o=t("../utils"),s=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),h=t("../support"),u=t("../external"),f=null;if(h.nodestream)try{f=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function g(c,d){return new u.Promise(function(m,y){var w=[],v=c._internalType,M=c._outputType,P=c._mimeType;c.on("data",function(D,E){w.push(D),d&&d(E)}).on("error",function(D){w=[],y(D)}).on("end",function(){try{var D=(function(E,O,k){switch(E){case"blob":return o.newBlob(o.transformTo("arraybuffer",O),k);case"base64":return l.encode(O);default:return o.transformTo(E,O)}})(M,(function(E,O){var k,I=0,W=null,T=0;for(k=0;k<O.length;k++)T+=O[k].length;switch(E){case"string":return O.join("");case"array":return Array.prototype.concat.apply([],O);case"uint8array":for(W=new Uint8Array(T),k=0;k<O.length;k++)W.set(O[k],I),I+=O[k].length;return W;case"nodebuffer":return Buffer.concat(O);default:throw new Error("concat : unsupported type '"+E+"'")}})(v,w),P);m(D)}catch(E){y(E)}w=[]}).resume()})}function p(c,d,m){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=m,o.checkSupport(y),this._worker=c.pipe(new s(y)),c.lock()}catch(w){this._worker=new a("error"),this._worker.error(w)}}p.prototype={accumulate:function(c){return g(this,c)},on:function(c,d){var m=this;return c==="data"?this._worker.on(c,function(y){d.call(m,y.data,y.meta)}):this._worker.on(c,function(){o.delay(d,arguments,m)}),this},resume:function(){return o.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(c){if(o.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new f(this,{objectMode:this._outputType!=="nodebuffer"},c)}},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 o=new ArrayBuffer(0);try{i.blob=new Blob([o],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(o),i.blob=s.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 o=t("./utils"),s=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),h=new Array(256),u=0;u<256;u++)h[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;h[254]=h[254]=1;function f(){l.call(this,"utf-8 decode"),this.leftOver=null}function g(){l.call(this,"utf-8 encode")}i.utf8encode=function(p){return s.nodebuffer?a.newBufferFrom(p,"utf-8"):(function(c){var d,m,y,w,v,M=c.length,P=0;for(w=0;w<M;w++)(64512&(m=c.charCodeAt(w)))==55296&&w+1<M&&(64512&(y=c.charCodeAt(w+1)))==56320&&(m=65536+(m-55296<<10)+(y-56320),w++),P+=m<128?1:m<2048?2:m<65536?3:4;for(d=s.uint8array?new Uint8Array(P):new Array(P),w=v=0;v<P;w++)(64512&(m=c.charCodeAt(w)))==55296&&w+1<M&&(64512&(y=c.charCodeAt(w+1)))==56320&&(m=65536+(m-55296<<10)+(y-56320),w++),m<128?d[v++]=m:(m<2048?d[v++]=192|m>>>6:(m<65536?d[v++]=224|m>>>12:(d[v++]=240|m>>>18,d[v++]=128|m>>>12&63),d[v++]=128|m>>>6&63),d[v++]=128|63&m);return d})(p)},i.utf8decode=function(p){return s.nodebuffer?o.transformTo("nodebuffer",p).toString("utf-8"):(function(c){var d,m,y,w,v=c.length,M=new Array(2*v);for(d=m=0;d<v;)if((y=c[d++])<128)M[m++]=y;else if(4<(w=h[y]))M[m++]=65533,d+=w-1;else{for(y&=w===2?31:w===3?15:7;1<w&&d<v;)y=y<<6|63&c[d++],w--;1<w?M[m++]=65533:y<65536?M[m++]=y:(y-=65536,M[m++]=55296|y>>10&1023,M[m++]=56320|1023&y)}return M.length!==m&&(M.subarray?M=M.subarray(0,m):M.length=m),o.applyFromCharCode(M)})(p=o.transformTo(s.uint8array?"uint8array":"array",p))},o.inherits(f,l),f.prototype.processChunk=function(p){var c=o.transformTo(s.uint8array?"uint8array":"array",p.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var d=c;(c=new Uint8Array(d.length+this.leftOver.length)).set(this.leftOver,0),c.set(d,this.leftOver.length)}else c=this.leftOver.concat(c);this.leftOver=null}var m=(function(w,v){var M;for((v=v||w.length)>w.length&&(v=w.length),M=v-1;0<=M&&(192&w[M])==128;)M--;return M<0||M===0?v:M+h[w[M]]>v?M:v})(c),y=c;m!==c.length&&(s.uint8array?(y=c.subarray(0,m),this.leftOver=c.subarray(m,c.length)):(y=c.slice(0,m),this.leftOver=c.slice(m,c.length))),this.push({data:i.utf8decode(y),meta:p.meta})},f.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:i.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},i.Utf8DecodeWorker=f,o.inherits(g,l),g.prototype.processChunk=function(p){this.push({data:i.utf8encode(p.data),meta:p.meta})},i.Utf8EncodeWorker=g},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(t,n,i){var o=t("./support"),s=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function h(d){return d}function u(d,m){for(var y=0;y<d.length;++y)m[y]=255&d.charCodeAt(y);return m}t("setimmediate"),i.newBlob=function(d,m){i.checkSupport("blob");try{return new Blob([d],{type:m})}catch{try{var y=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return y.append(d),y.getBlob(m)}catch{throw new Error("Bug : can't construct the Blob.")}}};var f={stringifyByChunk:function(d,m,y){var w=[],v=0,M=d.length;if(M<=y)return String.fromCharCode.apply(null,d);for(;v<M;)m==="array"||m==="nodebuffer"?w.push(String.fromCharCode.apply(null,d.slice(v,Math.min(v+y,M)))):w.push(String.fromCharCode.apply(null,d.subarray(v,Math.min(v+y,M)))),v+=y;return w.join("")},stringifyByChar:function(d){for(var m="",y=0;y<d.length;y++)m+=String.fromCharCode(d[y]);return m},applyCanBeUsed:{uint8array:(function(){try{return o.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}})(),nodebuffer:(function(){try{return o.nodebuffer&&String.fromCharCode.apply(null,a.allocBuffer(1)).length===1}catch{return!1}})()}};function g(d){var m=65536,y=i.getTypeOf(d),w=!0;if(y==="uint8array"?w=f.applyCanBeUsed.uint8array:y==="nodebuffer"&&(w=f.applyCanBeUsed.nodebuffer),w)for(;1<m;)try{return f.stringifyByChunk(d,y,m)}catch{m=Math.floor(m/2)}return f.stringifyByChar(d)}function p(d,m){for(var y=0;y<d.length;y++)m[y]=d[y];return m}i.applyFromCharCode=g;var c={};c.string={string:h,array:function(d){return u(d,new Array(d.length))},arraybuffer:function(d){return c.string.uint8array(d).buffer},uint8array:function(d){return u(d,new Uint8Array(d.length))},nodebuffer:function(d){return u(d,a.allocBuffer(d.length))}},c.array={string:g,array:h,arraybuffer:function(d){return new Uint8Array(d).buffer},uint8array:function(d){return new Uint8Array(d)},nodebuffer:function(d){return a.newBufferFrom(d)}},c.arraybuffer={string:function(d){return g(new Uint8Array(d))},array:function(d){return p(new Uint8Array(d),new Array(d.byteLength))},arraybuffer:h,uint8array:function(d){return new Uint8Array(d)},nodebuffer:function(d){return a.newBufferFrom(new Uint8Array(d))}},c.uint8array={string:g,array:function(d){return p(d,new Array(d.length))},arraybuffer:function(d){return d.buffer},uint8array:h,nodebuffer:function(d){return a.newBufferFrom(d)}},c.nodebuffer={string:g,array:function(d){return p(d,new Array(d.length))},arraybuffer:function(d){return c.nodebuffer.uint8array(d).buffer},uint8array:function(d){return p(d,new Uint8Array(d.length))},nodebuffer:h},i.transformTo=function(d,m){if(m=m||"",!d)return m;i.checkSupport(d);var y=i.getTypeOf(m);return c[y][d](m)},i.resolve=function(d){for(var m=d.split("/"),y=[],w=0;w<m.length;w++){var v=m[w];v==="."||v===""&&w!==0&&w!==m.length-1||(v===".."?y.pop():y.push(v))}return y.join("/")},i.getTypeOf=function(d){return typeof d=="string"?"string":Object.prototype.toString.call(d)==="[object Array]"?"array":o.nodebuffer&&a.isBuffer(d)?"nodebuffer":o.uint8array&&d instanceof Uint8Array?"uint8array":o.arraybuffer&&d instanceof ArrayBuffer?"arraybuffer":void 0},i.checkSupport=function(d){if(!o[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 m,y,w="";for(y=0;y<(d||"").length;y++)w+="\\x"+((m=d.charCodeAt(y))<16?"0":"")+m.toString(16).toUpperCase();return w},i.delay=function(d,m,y){setImmediate(function(){d.apply(y||null,m||[])})},i.inherits=function(d,m){function y(){}y.prototype=m.prototype,d.prototype=new y},i.extend=function(){var d,m,y={};for(d=0;d<arguments.length;d++)for(m in arguments[d])Object.prototype.hasOwnProperty.call(arguments[d],m)&&y[m]===void 0&&(y[m]=arguments[d][m]);return y},i.prepareContent=function(d,m,y,w,v){return l.Promise.resolve(m).then(function(M){return o.blob&&(M instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(M))!==-1)&&typeof FileReader<"u"?new l.Promise(function(P,D){var E=new FileReader;E.onload=function(O){P(O.target.result)},E.onerror=function(O){D(O.target.error)},E.readAsArrayBuffer(M)}):M}).then(function(M){var P=i.getTypeOf(M);return P?(P==="arraybuffer"?M=i.transformTo("uint8array",M):P==="string"&&(v?M=s.decode(M):y&&w!==!0&&(M=(function(D){return u(D,o.uint8array?new Uint8Array(D.length):new Array(D.length))})(M))),M):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 o=t("./reader/readerFor"),s=t("./utils"),a=t("./signature"),l=t("./zipEntry"),h=t("./support");function u(f){this.files=[],this.loadOptions=f}u.prototype={checkSignature:function(f){if(!this.reader.readAndCheckSignature(f)){this.reader.index-=4;var g=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(g)+", expected "+s.pretty(f)+")")}},isSignature:function(f,g){var p=this.reader.index;this.reader.setIndex(f);var c=this.reader.readString(4)===g;return this.reader.setIndex(p),c},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 f=this.reader.readData(this.zipCommentLength),g=h.uint8array?"uint8array":"array",p=s.transformTo(g,f);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 f,g,p,c=this.zip64EndOfCentralSize-44;0<c;)f=this.reader.readInt(2),g=this.reader.readInt(4),p=this.reader.readData(g),this.zip64ExtensibleData[f]={id:f,length:g,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 f,g;for(f=0;f<this.files.length;f++)g=this.files[f],this.reader.setIndex(g.localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),g.readLocalPart(this.reader),g.handleUTF8(),g.processAttributes()},readCentralDir:function(){var f;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(f=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(f);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 f=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(f<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(f);var g=f;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(f=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(f),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 c=g-p;if(0<c)this.isSignature(g,a.CENTRAL_FILE_HEADER)||(this.reader.zero=c);else if(c<0)throw new Error("Corrupted zip: missing "+Math.abs(c)+" bytes.")},prepareReader:function(f){this.reader=o(f)},load:function(f){this.prepareReader(f),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},n.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,n,i){var o=t("./reader/readerFor"),s=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),h=t("./utf8"),u=t("./compressions"),f=t("./support");function g(p,c){this.options=p,this.loadOptions=c}g.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(p){var c,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((c=(function(m){for(var y in u)if(Object.prototype.hasOwnProperty.call(u,y)&&u[y].magic===m)return u[y];return null})(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,c,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 c=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(c),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=o(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=p.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=p.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=p.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=p.readInt(4))}},readExtraFields:function(p){var c,d,m,y=p.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});p.index+4<y;)c=p.readInt(2),d=p.readInt(2),m=p.readData(d),this.extraFields[c]={id:c,length:d,value:m};p.setIndex(y)},handleUTF8:function(){var p=f.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=h.utf8decode(this.fileName),this.fileCommentStr=h.utf8decode(this.fileComment);else{var c=this.findExtraFieldUnicodePath();if(c!==null)this.fileNameStr=c;else{var d=s.transformTo(p,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(d)}var m=this.findExtraFieldUnicodeComment();if(m!==null)this.fileCommentStr=m;else{var y=s.transformTo(p,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(y)}}},findExtraFieldUnicodePath:function(){var p=this.extraFields[28789];if(p){var c=o(p.value);return c.readInt(1)!==1||l(this.fileName)!==c.readInt(4)?null:h.utf8decode(c.readData(p.length-5))}return null},findExtraFieldUnicodeComment:function(){var p=this.extraFields[25461];if(p){var c=o(p.value);return c.readInt(1)!==1||l(this.fileComment)!==c.readInt(4)?null:h.utf8decode(c.readData(p.length-5))}return null}},n.exports=g},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(t,n,i){function o(c,d,m){this.name=c,this.dir=m.dir,this.date=m.date,this.comment=m.comment,this.unixPermissions=m.unixPermissions,this.dosPermissions=m.dosPermissions,this._data=d,this._dataBinary=m.binary,this.options={compression:m.compression,compressionOptions:m.compressionOptions}}var s=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),h=t("./compressedObject"),u=t("./stream/GenericWorker");o.prototype={internalStream:function(c){var d=null,m="string";try{if(!c)throw new Error("No output type specified.");var y=(m=c.toLowerCase())==="string"||m==="text";m!=="binarystring"&&m!=="text"||(m="string"),d=this._decompressWorker();var w=!this._dataBinary;w&&!y&&(d=d.pipe(new l.Utf8EncodeWorker)),!w&&y&&(d=d.pipe(new l.Utf8DecodeWorker))}catch(v){(d=new u("error")).error(v)}return new s(d,m,"")},async:function(c,d){return this.internalStream(c).accumulate(d)},nodeStream:function(c,d){return this.internalStream(c||"nodebuffer").toNodejsStream(d)},_compressWorker:function(c,d){if(this._data instanceof h&&this._data.compression.magic===c.magic)return this._data.getCompressedWorker();var m=this._decompressWorker();return this._dataBinary||(m=m.pipe(new l.Utf8EncodeWorker)),h.createWorkerFrom(m,c,d)},_decompressWorker:function(){return this._data instanceof h?this._data.getContentWorker():this._data instanceof u?this._data:new a(this._data)}};for(var f=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],g=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},p=0;p<f.length;p++)o.prototype[f[p]]=g;n.exports=o},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,n,i){(function(o){var s,a,l=o.MutationObserver||o.WebKitMutationObserver;if(l){var h=0,u=new l(c),f=o.document.createTextNode("");u.observe(f,{characterData:!0}),s=function(){f.data=h=++h%2}}else if(o.setImmediate||o.MessageChannel===void 0)s="document"in o&&"onreadystatechange"in o.document.createElement("script")?function(){var d=o.document.createElement("script");d.onreadystatechange=function(){c(),d.onreadystatechange=null,d.parentNode.removeChild(d),d=null},o.document.documentElement.appendChild(d)}:function(){setTimeout(c,0)};else{var g=new o.MessageChannel;g.port1.onmessage=c,s=function(){g.port2.postMessage(0)}}var p=[];function c(){var d,m;a=!0;for(var y=p.length;y;){for(m=p,p=[],d=-1;++d<y;)m[d]();y=p.length}a=!1}n.exports=function(d){p.push(d)!==1||a||s()}}).call(this,typeof vt<"u"?vt:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,n,i){var o=t("immediate");function s(){}var a={},l=["REJECTED"],h=["FULFILLED"],u=["PENDING"];function f(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,y!==s&&d(this,y)}function g(y,w,v){this.promise=y,typeof w=="function"&&(this.onFulfilled=w,this.callFulfilled=this.otherCallFulfilled),typeof v=="function"&&(this.onRejected=v,this.callRejected=this.otherCallRejected)}function p(y,w,v){o(function(){var M;try{M=w(v)}catch(P){return a.reject(y,P)}M===y?a.reject(y,new TypeError("Cannot resolve promise with itself")):a.resolve(y,M)})}function c(y){var w=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof w=="function")return function(){w.apply(y,arguments)}}function d(y,w){var v=!1;function M(E){v||(v=!0,a.reject(y,E))}function P(E){v||(v=!0,a.resolve(y,E))}var D=m(function(){w(P,M)});D.status==="error"&&M(D.value)}function m(y,w){var v={};try{v.value=y(w),v.status="success"}catch(M){v.status="error",v.value=M}return v}(n.exports=f).prototype.finally=function(y){if(typeof y!="function")return this;var w=this.constructor;return this.then(function(v){return w.resolve(y()).then(function(){return v})},function(v){return w.resolve(y()).then(function(){throw v})})},f.prototype.catch=function(y){return this.then(null,y)},f.prototype.then=function(y,w){if(typeof y!="function"&&this.state===h||typeof w!="function"&&this.state===l)return this;var v=new this.constructor(s);return this.state!==u?p(v,this.state===h?y:w,this.outcome):this.queue.push(new g(v,y,w)),v},g.prototype.callFulfilled=function(y){a.resolve(this.promise,y)},g.prototype.otherCallFulfilled=function(y){p(this.promise,this.onFulfilled,y)},g.prototype.callRejected=function(y){a.reject(this.promise,y)},g.prototype.otherCallRejected=function(y){p(this.promise,this.onRejected,y)},a.resolve=function(y,w){var v=m(c,w);if(v.status==="error")return a.reject(y,v.value);var M=v.value;if(M)d(y,M);else{y.state=h,y.outcome=w;for(var P=-1,D=y.queue.length;++P<D;)y.queue[P].callFulfilled(w)}return y},a.reject=function(y,w){y.state=l,y.outcome=w;for(var v=-1,M=y.queue.length;++v<M;)y.queue[v].callRejected(w);return y},f.resolve=function(y){return y instanceof this?y:a.resolve(new this(s),y)},f.reject=function(y){var w=new this(s);return a.reject(w,y)},f.all=function(y){var w=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var v=y.length,M=!1;if(!v)return this.resolve([]);for(var P=new Array(v),D=0,E=-1,O=new this(s);++E<v;)k(y[E],E);return O;function k(I,W){w.resolve(I).then(function(T){P[W]=T,++D!==v||M||(M=!0,a.resolve(O,P))},function(T){M||(M=!0,a.reject(O,T))})}},f.race=function(y){var w=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var v=y.length,M=!1;if(!v)return this.resolve([]);for(var P=-1,D=new this(s);++P<v;)E=y[P],w.resolve(E).then(function(O){M||(M=!0,a.resolve(D,O))},function(O){M||(M=!0,a.reject(D,O))});var E;return D}},{immediate:36}],38:[function(t,n,i){var o={};(0,t("./lib/utils/common").assign)(o,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),n.exports=o},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,n,i){var o=t("./zlib/deflate"),s=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/messages"),h=t("./zlib/zstream"),u=Object.prototype.toString,f=0,g=-1,p=0,c=8;function d(y){if(!(this instanceof d))return new d(y);this.options=s.assign({level:g,method:c,chunkSize:16384,windowBits:15,memLevel:8,strategy:p,to:""},y||{});var w=this.options;w.raw&&0<w.windowBits?w.windowBits=-w.windowBits:w.gzip&&0<w.windowBits&&w.windowBits<16&&(w.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var v=o.deflateInit2(this.strm,w.level,w.method,w.windowBits,w.memLevel,w.strategy);if(v!==f)throw new Error(l[v]);if(w.header&&o.deflateSetHeader(this.strm,w.header),w.dictionary){var M;if(M=typeof w.dictionary=="string"?a.string2buf(w.dictionary):u.call(w.dictionary)==="[object ArrayBuffer]"?new Uint8Array(w.dictionary):w.dictionary,(v=o.deflateSetDictionary(this.strm,M))!==f)throw new Error(l[v]);this._dict_set=!0}}function m(y,w){var v=new d(w);if(v.push(y,!0),v.err)throw v.msg||l[v.err];return v.result}d.prototype.push=function(y,w){var v,M,P=this.strm,D=this.options.chunkSize;if(this.ended)return!1;M=w===~~w?w:w===!0?4:0,typeof y=="string"?P.input=a.string2buf(y):u.call(y)==="[object ArrayBuffer]"?P.input=new Uint8Array(y):P.input=y,P.next_in=0,P.avail_in=P.input.length;do{if(P.avail_out===0&&(P.output=new s.Buf8(D),P.next_out=0,P.avail_out=D),(v=o.deflate(P,M))!==1&&v!==f)return this.onEnd(v),!(this.ended=!0);P.avail_out!==0&&(P.avail_in!==0||M!==4&&M!==2)||(this.options.to==="string"?this.onData(a.buf2binstring(s.shrinkBuf(P.output,P.next_out))):this.onData(s.shrinkBuf(P.output,P.next_out)))}while((0<P.avail_in||P.avail_out===0)&&v!==1);return M===4?(v=o.deflateEnd(this.strm),this.onEnd(v),this.ended=!0,v===f):M!==2||(this.onEnd(f),!(P.avail_out=0))},d.prototype.onData=function(y){this.chunks.push(y)},d.prototype.onEnd=function(y){y===f&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=y,this.msg=this.strm.msg},i.Deflate=d,i.deflate=m,i.deflateRaw=function(y,w){return(w=w||{}).raw=!0,m(y,w)},i.gzip=function(y,w){return(w=w||{}).gzip=!0,m(y,w)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,n,i){var o=t("./zlib/inflate"),s=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),h=t("./zlib/messages"),u=t("./zlib/zstream"),f=t("./zlib/gzheader"),g=Object.prototype.toString;function p(d){if(!(this instanceof p))return new p(d);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},d||{});var m=this.options;m.raw&&0<=m.windowBits&&m.windowBits<16&&(m.windowBits=-m.windowBits,m.windowBits===0&&(m.windowBits=-15)),!(0<=m.windowBits&&m.windowBits<16)||d&&d.windowBits||(m.windowBits+=32),15<m.windowBits&&m.windowBits<48&&(15&m.windowBits)==0&&(m.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var y=o.inflateInit2(this.strm,m.windowBits);if(y!==l.Z_OK)throw new Error(h[y]);this.header=new f,o.inflateGetHeader(this.strm,this.header)}function c(d,m){var y=new p(m);if(y.push(d,!0),y.err)throw y.msg||h[y.err];return y.result}p.prototype.push=function(d,m){var y,w,v,M,P,D,E=this.strm,O=this.options.chunkSize,k=this.options.dictionary,I=!1;if(this.ended)return!1;w=m===~~m?m:m===!0?l.Z_FINISH:l.Z_NO_FLUSH,typeof d=="string"?E.input=a.binstring2buf(d):g.call(d)==="[object ArrayBuffer]"?E.input=new Uint8Array(d):E.input=d,E.next_in=0,E.avail_in=E.input.length;do{if(E.avail_out===0&&(E.output=new s.Buf8(O),E.next_out=0,E.avail_out=O),(y=o.inflate(E,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&k&&(D=typeof k=="string"?a.string2buf(k):g.call(k)==="[object ArrayBuffer]"?new Uint8Array(k):k,y=o.inflateSetDictionary(this.strm,D)),y===l.Z_BUF_ERROR&&I===!0&&(y=l.Z_OK,I=!1),y!==l.Z_STREAM_END&&y!==l.Z_OK)return this.onEnd(y),!(this.ended=!0);E.next_out&&(E.avail_out!==0&&y!==l.Z_STREAM_END&&(E.avail_in!==0||w!==l.Z_FINISH&&w!==l.Z_SYNC_FLUSH)||(this.options.to==="string"?(v=a.utf8border(E.output,E.next_out),M=E.next_out-v,P=a.buf2string(E.output,v),E.next_out=M,E.avail_out=O-M,M&&s.arraySet(E.output,E.output,v,M,0),this.onData(P)):this.onData(s.shrinkBuf(E.output,E.next_out)))),E.avail_in===0&&E.avail_out===0&&(I=!0)}while((0<E.avail_in||E.avail_out===0)&&y!==l.Z_STREAM_END);return y===l.Z_STREAM_END&&(w=l.Z_FINISH),w===l.Z_FINISH?(y=o.inflateEnd(this.strm),this.onEnd(y),this.ended=!0,y===l.Z_OK):w!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(E.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=s.flattenChunks(this.chunks)),this.chunks=[],this.err=d,this.msg=this.strm.msg},i.Inflate=p,i.inflate=c,i.inflateRaw=function(d,m){return(m=m||{}).raw=!0,c(d,m)},i.ungzip=c},{"./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 o=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";i.assign=function(l){for(var h=Array.prototype.slice.call(arguments,1);h.length;){var u=h.shift();if(u){if(typeof u!="object")throw new TypeError(u+"must be non-object");for(var f in u)u.hasOwnProperty(f)&&(l[f]=u[f])}}return l},i.shrinkBuf=function(l,h){return l.length===h?l:l.subarray?l.subarray(0,h):(l.length=h,l)};var s={arraySet:function(l,h,u,f,g){if(h.subarray&&l.subarray)l.set(h.subarray(u,u+f),g);else for(var p=0;p<f;p++)l[g+p]=h[u+p]},flattenChunks:function(l){var h,u,f,g,p,c;for(h=f=0,u=l.length;h<u;h++)f+=l[h].length;for(c=new Uint8Array(f),h=g=0,u=l.length;h<u;h++)p=l[h],c.set(p,g),g+=p.length;return c}},a={arraySet:function(l,h,u,f,g){for(var p=0;p<f;p++)l[g+p]=h[u+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,s)):(i.Buf8=Array,i.Buf16=Array,i.Buf32=Array,i.assign(i,a))},i.setTyped(o)},{}],42:[function(t,n,i){var o=t("./common"),s=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new o.Buf8(256),h=0;h<256;h++)l[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;function u(f,g){if(g<65537&&(f.subarray&&a||!f.subarray&&s))return String.fromCharCode.apply(null,o.shrinkBuf(f,g));for(var p="",c=0;c<g;c++)p+=String.fromCharCode(f[c]);return p}l[254]=l[254]=1,i.string2buf=function(f){var g,p,c,d,m,y=f.length,w=0;for(d=0;d<y;d++)(64512&(p=f.charCodeAt(d)))==55296&&d+1<y&&(64512&(c=f.charCodeAt(d+1)))==56320&&(p=65536+(p-55296<<10)+(c-56320),d++),w+=p<128?1:p<2048?2:p<65536?3:4;for(g=new o.Buf8(w),d=m=0;m<w;d++)(64512&(p=f.charCodeAt(d)))==55296&&d+1<y&&(64512&(c=f.charCodeAt(d+1)))==56320&&(p=65536+(p-55296<<10)+(c-56320),d++),p<128?g[m++]=p:(p<2048?g[m++]=192|p>>>6:(p<65536?g[m++]=224|p>>>12:(g[m++]=240|p>>>18,g[m++]=128|p>>>12&63),g[m++]=128|p>>>6&63),g[m++]=128|63&p);return g},i.buf2binstring=function(f){return u(f,f.length)},i.binstring2buf=function(f){for(var g=new o.Buf8(f.length),p=0,c=g.length;p<c;p++)g[p]=f.charCodeAt(p);return g},i.buf2string=function(f,g){var p,c,d,m,y=g||f.length,w=new Array(2*y);for(p=c=0;p<y;)if((d=f[p++])<128)w[c++]=d;else if(4<(m=l[d]))w[c++]=65533,p+=m-1;else{for(d&=m===2?31:m===3?15:7;1<m&&p<y;)d=d<<6|63&f[p++],m--;1<m?w[c++]=65533:d<65536?w[c++]=d:(d-=65536,w[c++]=55296|d>>10&1023,w[c++]=56320|1023&d)}return u(w,c)},i.utf8border=function(f,g){var p;for((g=g||f.length)>f.length&&(g=f.length),p=g-1;0<=p&&(192&f[p])==128;)p--;return p<0||p===0?g:p+l[f[p]]>g?p:g}},{"./common":41}],43:[function(t,n,i){n.exports=function(o,s,a,l){for(var h=65535&o|0,u=o>>>16&65535|0,f=0;a!==0;){for(a-=f=2e3<a?2e3:a;u=u+(h=h+s[l++]|0)|0,--f;);h%=65521,u%=65521}return h|u<<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 o=(function(){for(var s,a=[],l=0;l<256;l++){s=l;for(var h=0;h<8;h++)s=1&s?3988292384^s>>>1:s>>>1;a[l]=s}return a})();n.exports=function(s,a,l,h){var u=o,f=h+l;s^=-1;for(var g=h;g<f;g++)s=s>>>8^u[255&(s^a[g])];return-1^s}},{}],46:[function(t,n,i){var o,s=t("../utils/common"),a=t("./trees"),l=t("./adler32"),h=t("./crc32"),u=t("./messages"),f=0,g=4,p=0,c=-2,d=-1,m=4,y=2,w=8,v=9,M=286,P=30,D=19,E=2*M+1,O=15,k=3,I=258,W=I+k+1,T=42,B=113,b=1,V=2,J=3,X=4;function ee(_,G){return _.msg=u[G],G}function j(_){return(_<<1)-(4<_?9:0)}function ne(_){for(var G=_.length;0<=--G;)_[G]=0}function z(_){var G=_.state,U=G.pending;U>_.avail_out&&(U=_.avail_out),U!==0&&(s.arraySet(_.output,G.pending_buf,G.pending_out,U,_.next_out),_.next_out+=U,G.pending_out+=U,_.total_out+=U,_.avail_out-=U,G.pending-=U,G.pending===0&&(G.pending_out=0))}function N(_,G){a._tr_flush_block(_,0<=_.block_start?_.block_start:-1,_.strstart-_.block_start,G),_.block_start=_.strstart,z(_.strm)}function te(_,G){_.pending_buf[_.pending++]=G}function $(_,G){_.pending_buf[_.pending++]=G>>>8&255,_.pending_buf[_.pending++]=255&G}function H(_,G){var U,C,A=_.max_chain_length,L=_.strstart,K=_.prev_length,Z=_.nice_match,R=_.strstart>_.w_size-W?_.strstart-(_.w_size-W):0,q=_.window,Q=_.w_mask,Y=_.prev,ie=_.strstart+I,ce=q[L+K-1],oe=q[L+K];_.prev_length>=_.good_match&&(A>>=2),Z>_.lookahead&&(Z=_.lookahead);do if(q[(U=G)+K]===oe&&q[U+K-1]===ce&&q[U]===q[L]&&q[++U]===q[L+1]){L+=2,U++;do;while(q[++L]===q[++U]&&q[++L]===q[++U]&&q[++L]===q[++U]&&q[++L]===q[++U]&&q[++L]===q[++U]&&q[++L]===q[++U]&&q[++L]===q[++U]&&q[++L]===q[++U]&&L<ie);if(C=I-(ie-L),L=ie-I,K<C){if(_.match_start=G,Z<=(K=C))break;ce=q[L+K-1],oe=q[L+K]}}while((G=Y[G&Q])>R&&--A!=0);return K<=_.lookahead?K:_.lookahead}function de(_){var G,U,C,A,L,K,Z,R,q,Q,Y=_.w_size;do{if(A=_.window_size-_.lookahead-_.strstart,_.strstart>=Y+(Y-W)){for(s.arraySet(_.window,_.window,Y,Y,0),_.match_start-=Y,_.strstart-=Y,_.block_start-=Y,G=U=_.hash_size;C=_.head[--G],_.head[G]=Y<=C?C-Y:0,--U;);for(G=U=Y;C=_.prev[--G],_.prev[G]=Y<=C?C-Y:0,--U;);A+=Y}if(_.strm.avail_in===0)break;if(K=_.strm,Z=_.window,R=_.strstart+_.lookahead,q=A,Q=void 0,Q=K.avail_in,q<Q&&(Q=q),U=Q===0?0:(K.avail_in-=Q,s.arraySet(Z,K.input,K.next_in,Q,R),K.state.wrap===1?K.adler=l(K.adler,Z,Q,R):K.state.wrap===2&&(K.adler=h(K.adler,Z,Q,R)),K.next_in+=Q,K.total_in+=Q,Q),_.lookahead+=U,_.lookahead+_.insert>=k)for(L=_.strstart-_.insert,_.ins_h=_.window[L],_.ins_h=(_.ins_h<<_.hash_shift^_.window[L+1])&_.hash_mask;_.insert&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[L+k-1])&_.hash_mask,_.prev[L&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=L,L++,_.insert--,!(_.lookahead+_.insert<k)););}while(_.lookahead<W&&_.strm.avail_in!==0)}function fe(_,G){for(var U,C;;){if(_.lookahead<W){if(de(_),_.lookahead<W&&G===f)return b;if(_.lookahead===0)break}if(U=0,_.lookahead>=k&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+k-1])&_.hash_mask,U=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),U!==0&&_.strstart-U<=_.w_size-W&&(_.match_length=H(_,U)),_.match_length>=k)if(C=a._tr_tally(_,_.strstart-_.match_start,_.match_length-k),_.lookahead-=_.match_length,_.match_length<=_.max_lazy_match&&_.lookahead>=k){for(_.match_length--;_.strstart++,_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+k-1])&_.hash_mask,U=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart,--_.match_length!=0;);_.strstart++}else _.strstart+=_.match_length,_.match_length=0,_.ins_h=_.window[_.strstart],_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+1])&_.hash_mask;else C=a._tr_tally(_,0,_.window[_.strstart]),_.lookahead--,_.strstart++;if(C&&(N(_,!1),_.strm.avail_out===0))return b}return _.insert=_.strstart<k-1?_.strstart:k-1,G===g?(N(_,!0),_.strm.avail_out===0?J:X):_.last_lit&&(N(_,!1),_.strm.avail_out===0)?b:V}function se(_,G){for(var U,C,A;;){if(_.lookahead<W){if(de(_),_.lookahead<W&&G===f)return b;if(_.lookahead===0)break}if(U=0,_.lookahead>=k&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+k-1])&_.hash_mask,U=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),_.prev_length=_.match_length,_.prev_match=_.match_start,_.match_length=k-1,U!==0&&_.prev_length<_.max_lazy_match&&_.strstart-U<=_.w_size-W&&(_.match_length=H(_,U),_.match_length<=5&&(_.strategy===1||_.match_length===k&&4096<_.strstart-_.match_start)&&(_.match_length=k-1)),_.prev_length>=k&&_.match_length<=_.prev_length){for(A=_.strstart+_.lookahead-k,C=a._tr_tally(_,_.strstart-1-_.prev_match,_.prev_length-k),_.lookahead-=_.prev_length-1,_.prev_length-=2;++_.strstart<=A&&(_.ins_h=(_.ins_h<<_.hash_shift^_.window[_.strstart+k-1])&_.hash_mask,U=_.prev[_.strstart&_.w_mask]=_.head[_.ins_h],_.head[_.ins_h]=_.strstart),--_.prev_length!=0;);if(_.match_available=0,_.match_length=k-1,_.strstart++,C&&(N(_,!1),_.strm.avail_out===0))return b}else if(_.match_available){if((C=a._tr_tally(_,0,_.window[_.strstart-1]))&&N(_,!1),_.strstart++,_.lookahead--,_.strm.avail_out===0)return b}else _.match_available=1,_.strstart++,_.lookahead--}return _.match_available&&(C=a._tr_tally(_,0,_.window[_.strstart-1]),_.match_available=0),_.insert=_.strstart<k-1?_.strstart:k-1,G===g?(N(_,!0),_.strm.avail_out===0?J:X):_.last_lit&&(N(_,!1),_.strm.avail_out===0)?b:V}function ae(_,G,U,C,A){this.good_length=_,this.max_lazy=G,this.nice_length=U,this.max_chain=C,this.func=A}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=w,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*E),this.dyn_dtree=new s.Buf16(2*(2*P+1)),this.bl_tree=new s.Buf16(2*(2*D+1)),ne(this.dyn_ltree),ne(this.dyn_dtree),ne(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(O+1),this.heap=new s.Buf16(2*M+1),ne(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*M+1),ne(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(_){var G;return _&&_.state?(_.total_in=_.total_out=0,_.data_type=y,(G=_.state).pending=0,G.pending_out=0,G.wrap<0&&(G.wrap=-G.wrap),G.status=G.wrap?T:B,_.adler=G.wrap===2?0:1,G.last_flush=f,a._tr_init(G),p):ee(_,c)}function Te(_){var G=pe(_);return G===p&&(function(U){U.window_size=2*U.w_size,ne(U.head),U.max_lazy_match=o[U.level].max_lazy,U.good_match=o[U.level].good_length,U.nice_match=o[U.level].nice_length,U.max_chain_length=o[U.level].max_chain,U.strstart=0,U.block_start=0,U.lookahead=0,U.insert=0,U.match_length=U.prev_length=k-1,U.match_available=0,U.ins_h=0})(_.state),G}function xe(_,G,U,C,A,L){if(!_)return c;var K=1;if(G===d&&(G=6),C<0?(K=0,C=-C):15<C&&(K=2,C-=16),A<1||v<A||U!==w||C<8||15<C||G<0||9<G||L<0||m<L)return ee(_,c);C===8&&(C=9);var Z=new ue;return(_.state=Z).strm=_,Z.wrap=K,Z.gzhead=null,Z.w_bits=C,Z.w_size=1<<Z.w_bits,Z.w_mask=Z.w_size-1,Z.hash_bits=A+7,Z.hash_size=1<<Z.hash_bits,Z.hash_mask=Z.hash_size-1,Z.hash_shift=~~((Z.hash_bits+k-1)/k),Z.window=new s.Buf8(2*Z.w_size),Z.head=new s.Buf16(Z.hash_size),Z.prev=new s.Buf16(Z.w_size),Z.lit_bufsize=1<<A+6,Z.pending_buf_size=4*Z.lit_bufsize,Z.pending_buf=new s.Buf8(Z.pending_buf_size),Z.d_buf=1*Z.lit_bufsize,Z.l_buf=3*Z.lit_bufsize,Z.level=G,Z.strategy=L,Z.method=U,Te(_)}o=[new ae(0,0,0,0,function(_,G){var U=65535;for(U>_.pending_buf_size-5&&(U=_.pending_buf_size-5);;){if(_.lookahead<=1){if(de(_),_.lookahead===0&&G===f)return b;if(_.lookahead===0)break}_.strstart+=_.lookahead,_.lookahead=0;var C=_.block_start+U;if((_.strstart===0||_.strstart>=C)&&(_.lookahead=_.strstart-C,_.strstart=C,N(_,!1),_.strm.avail_out===0)||_.strstart-_.block_start>=_.w_size-W&&(N(_,!1),_.strm.avail_out===0))return b}return _.insert=0,G===g?(N(_,!0),_.strm.avail_out===0?J:X):(_.strstart>_.block_start&&(N(_,!1),_.strm.avail_out),b)}),new ae(4,4,8,4,fe),new ae(4,5,16,8,fe),new ae(4,6,32,32,fe),new ae(4,4,16,16,se),new ae(8,16,32,32,se),new ae(8,16,128,128,se),new ae(8,32,128,256,se),new ae(32,128,258,1024,se),new ae(32,258,258,4096,se)],i.deflateInit=function(_,G){return xe(_,G,w,15,8,0)},i.deflateInit2=xe,i.deflateReset=Te,i.deflateResetKeep=pe,i.deflateSetHeader=function(_,G){return _&&_.state?_.state.wrap!==2?c:(_.state.gzhead=G,p):c},i.deflate=function(_,G){var U,C,A,L;if(!_||!_.state||5<G||G<0)return _?ee(_,c):c;if(C=_.state,!_.output||!_.input&&_.avail_in!==0||C.status===666&&G!==g)return ee(_,_.avail_out===0?-5:c);if(C.strm=_,U=C.last_flush,C.last_flush=G,C.status===T)if(C.wrap===2)_.adler=0,te(C,31),te(C,139),te(C,8),C.gzhead?(te(C,(C.gzhead.text?1:0)+(C.gzhead.hcrc?2:0)+(C.gzhead.extra?4:0)+(C.gzhead.name?8:0)+(C.gzhead.comment?16:0)),te(C,255&C.gzhead.time),te(C,C.gzhead.time>>8&255),te(C,C.gzhead.time>>16&255),te(C,C.gzhead.time>>24&255),te(C,C.level===9?2:2<=C.strategy||C.level<2?4:0),te(C,255&C.gzhead.os),C.gzhead.extra&&C.gzhead.extra.length&&(te(C,255&C.gzhead.extra.length),te(C,C.gzhead.extra.length>>8&255)),C.gzhead.hcrc&&(_.adler=h(_.adler,C.pending_buf,C.pending,0)),C.gzindex=0,C.status=69):(te(C,0),te(C,0),te(C,0),te(C,0),te(C,0),te(C,C.level===9?2:2<=C.strategy||C.level<2?4:0),te(C,3),C.status=B);else{var K=w+(C.w_bits-8<<4)<<8;K|=(2<=C.strategy||C.level<2?0:C.level<6?1:C.level===6?2:3)<<6,C.strstart!==0&&(K|=32),K+=31-K%31,C.status=B,$(C,K),C.strstart!==0&&($(C,_.adler>>>16),$(C,65535&_.adler)),_.adler=1}if(C.status===69)if(C.gzhead.extra){for(A=C.pending;C.gzindex<(65535&C.gzhead.extra.length)&&(C.pending!==C.pending_buf_size||(C.gzhead.hcrc&&C.pending>A&&(_.adler=h(_.adler,C.pending_buf,C.pending-A,A)),z(_),A=C.pending,C.pending!==C.pending_buf_size));)te(C,255&C.gzhead.extra[C.gzindex]),C.gzindex++;C.gzhead.hcrc&&C.pending>A&&(_.adler=h(_.adler,C.pending_buf,C.pending-A,A)),C.gzindex===C.gzhead.extra.length&&(C.gzindex=0,C.status=73)}else C.status=73;if(C.status===73)if(C.gzhead.name){A=C.pending;do{if(C.pending===C.pending_buf_size&&(C.gzhead.hcrc&&C.pending>A&&(_.adler=h(_.adler,C.pending_buf,C.pending-A,A)),z(_),A=C.pending,C.pending===C.pending_buf_size)){L=1;break}L=C.gzindex<C.gzhead.name.length?255&C.gzhead.name.charCodeAt(C.gzindex++):0,te(C,L)}while(L!==0);C.gzhead.hcrc&&C.pending>A&&(_.adler=h(_.adler,C.pending_buf,C.pending-A,A)),L===0&&(C.gzindex=0,C.status=91)}else C.status=91;if(C.status===91)if(C.gzhead.comment){A=C.pending;do{if(C.pending===C.pending_buf_size&&(C.gzhead.hcrc&&C.pending>A&&(_.adler=h(_.adler,C.pending_buf,C.pending-A,A)),z(_),A=C.pending,C.pending===C.pending_buf_size)){L=1;break}L=C.gzindex<C.gzhead.comment.length?255&C.gzhead.comment.charCodeAt(C.gzindex++):0,te(C,L)}while(L!==0);C.gzhead.hcrc&&C.pending>A&&(_.adler=h(_.adler,C.pending_buf,C.pending-A,A)),L===0&&(C.status=103)}else C.status=103;if(C.status===103&&(C.gzhead.hcrc?(C.pending+2>C.pending_buf_size&&z(_),C.pending+2<=C.pending_buf_size&&(te(C,255&_.adler),te(C,_.adler>>8&255),_.adler=0,C.status=B)):C.status=B),C.pending!==0){if(z(_),_.avail_out===0)return C.last_flush=-1,p}else if(_.avail_in===0&&j(G)<=j(U)&&G!==g)return ee(_,-5);if(C.status===666&&_.avail_in!==0)return ee(_,-5);if(_.avail_in!==0||C.lookahead!==0||G!==f&&C.status!==666){var Z=C.strategy===2?(function(R,q){for(var Q;;){if(R.lookahead===0&&(de(R),R.lookahead===0)){if(q===f)return b;break}if(R.match_length=0,Q=a._tr_tally(R,0,R.window[R.strstart]),R.lookahead--,R.strstart++,Q&&(N(R,!1),R.strm.avail_out===0))return b}return R.insert=0,q===g?(N(R,!0),R.strm.avail_out===0?J:X):R.last_lit&&(N(R,!1),R.strm.avail_out===0)?b:V})(C,G):C.strategy===3?(function(R,q){for(var Q,Y,ie,ce,oe=R.window;;){if(R.lookahead<=I){if(de(R),R.lookahead<=I&&q===f)return b;if(R.lookahead===0)break}if(R.match_length=0,R.lookahead>=k&&0<R.strstart&&(Y=oe[ie=R.strstart-1])===oe[++ie]&&Y===oe[++ie]&&Y===oe[++ie]){ce=R.strstart+I;do;while(Y===oe[++ie]&&Y===oe[++ie]&&Y===oe[++ie]&&Y===oe[++ie]&&Y===oe[++ie]&&Y===oe[++ie]&&Y===oe[++ie]&&Y===oe[++ie]&&ie<ce);R.match_length=I-(ce-ie),R.match_length>R.lookahead&&(R.match_length=R.lookahead)}if(R.match_length>=k?(Q=a._tr_tally(R,1,R.match_length-k),R.lookahead-=R.match_length,R.strstart+=R.match_length,R.match_length=0):(Q=a._tr_tally(R,0,R.window[R.strstart]),R.lookahead--,R.strstart++),Q&&(N(R,!1),R.strm.avail_out===0))return b}return R.insert=0,q===g?(N(R,!0),R.strm.avail_out===0?J:X):R.last_lit&&(N(R,!1),R.strm.avail_out===0)?b:V})(C,G):o[C.level].func(C,G);if(Z!==J&&Z!==X||(C.status=666),Z===b||Z===J)return _.avail_out===0&&(C.last_flush=-1),p;if(Z===V&&(G===1?a._tr_align(C):G!==5&&(a._tr_stored_block(C,0,0,!1),G===3&&(ne(C.head),C.lookahead===0&&(C.strstart=0,C.block_start=0,C.insert=0))),z(_),_.avail_out===0))return C.last_flush=-1,p}return G!==g?p:C.wrap<=0?1:(C.wrap===2?(te(C,255&_.adler),te(C,_.adler>>8&255),te(C,_.adler>>16&255),te(C,_.adler>>24&255),te(C,255&_.total_in),te(C,_.total_in>>8&255),te(C,_.total_in>>16&255),te(C,_.total_in>>24&255)):($(C,_.adler>>>16),$(C,65535&_.adler)),z(_),0<C.wrap&&(C.wrap=-C.wrap),C.pending!==0?p:1)},i.deflateEnd=function(_){var G;return _&&_.state?(G=_.state.status)!==T&&G!==69&&G!==73&&G!==91&&G!==103&&G!==B&&G!==666?ee(_,c):(_.state=null,G===B?ee(_,-3):p):c},i.deflateSetDictionary=function(_,G){var U,C,A,L,K,Z,R,q,Q=G.length;if(!_||!_.state||(L=(U=_.state).wrap)===2||L===1&&U.status!==T||U.lookahead)return c;for(L===1&&(_.adler=l(_.adler,G,Q,0)),U.wrap=0,Q>=U.w_size&&(L===0&&(ne(U.head),U.strstart=0,U.block_start=0,U.insert=0),q=new s.Buf8(U.w_size),s.arraySet(q,G,Q-U.w_size,U.w_size,0),G=q,Q=U.w_size),K=_.avail_in,Z=_.next_in,R=_.input,_.avail_in=Q,_.next_in=0,_.input=G,de(U);U.lookahead>=k;){for(C=U.strstart,A=U.lookahead-(k-1);U.ins_h=(U.ins_h<<U.hash_shift^U.window[C+k-1])&U.hash_mask,U.prev[C&U.w_mask]=U.head[U.ins_h],U.head[U.ins_h]=C,C++,--A;);U.strstart=C,U.lookahead=k-1,de(U)}return U.strstart+=U.lookahead,U.block_start=U.strstart,U.insert=U.lookahead,U.lookahead=0,U.match_length=U.prev_length=k-1,U.match_available=0,_.next_in=Z,_.input=R,_.avail_in=K,U.wrap=L,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(o,s){var a,l,h,u,f,g,p,c,d,m,y,w,v,M,P,D,E,O,k,I,W,T,B,b,V;a=o.state,l=o.next_in,b=o.input,h=l+(o.avail_in-5),u=o.next_out,V=o.output,f=u-(s-o.avail_out),g=u+(o.avail_out-257),p=a.dmax,c=a.wsize,d=a.whave,m=a.wnext,y=a.window,w=a.hold,v=a.bits,M=a.lencode,P=a.distcode,D=(1<<a.lenbits)-1,E=(1<<a.distbits)-1;e:do{v<15&&(w+=b[l++]<<v,v+=8,w+=b[l++]<<v,v+=8),O=M[w&D];t:for(;;){if(w>>>=k=O>>>24,v-=k,(k=O>>>16&255)===0)V[u++]=65535&O;else{if(!(16&k)){if((64&k)==0){O=M[(65535&O)+(w&(1<<k)-1)];continue t}if(32&k){a.mode=12;break e}o.msg="invalid literal/length code",a.mode=30;break e}I=65535&O,(k&=15)&&(v<k&&(w+=b[l++]<<v,v+=8),I+=w&(1<<k)-1,w>>>=k,v-=k),v<15&&(w+=b[l++]<<v,v+=8,w+=b[l++]<<v,v+=8),O=P[w&E];n:for(;;){if(w>>>=k=O>>>24,v-=k,!(16&(k=O>>>16&255))){if((64&k)==0){O=P[(65535&O)+(w&(1<<k)-1)];continue n}o.msg="invalid distance code",a.mode=30;break e}if(W=65535&O,v<(k&=15)&&(w+=b[l++]<<v,(v+=8)<k&&(w+=b[l++]<<v,v+=8)),p<(W+=w&(1<<k)-1)){o.msg="invalid distance too far back",a.mode=30;break e}if(w>>>=k,v-=k,(k=u-f)<W){if(d<(k=W-k)&&a.sane){o.msg="invalid distance too far back",a.mode=30;break e}if(B=y,(T=0)===m){if(T+=c-k,k<I){for(I-=k;V[u++]=y[T++],--k;);T=u-W,B=V}}else if(m<k){if(T+=c+m-k,(k-=m)<I){for(I-=k;V[u++]=y[T++],--k;);if(T=0,m<I){for(I-=k=m;V[u++]=y[T++],--k;);T=u-W,B=V}}}else if(T+=m-k,k<I){for(I-=k;V[u++]=y[T++],--k;);T=u-W,B=V}for(;2<I;)V[u++]=B[T++],V[u++]=B[T++],V[u++]=B[T++],I-=3;I&&(V[u++]=B[T++],1<I&&(V[u++]=B[T++]))}else{for(T=u-W;V[u++]=V[T++],V[u++]=V[T++],V[u++]=V[T++],2<(I-=3););I&&(V[u++]=V[T++],1<I&&(V[u++]=V[T++]))}break}}break}}while(l<h&&u<g);l-=I=v>>3,w&=(1<<(v-=I<<3))-1,o.next_in=l,o.next_out=u,o.avail_in=l<h?h-l+5:5-(l-h),o.avail_out=u<g?g-u+257:257-(u-g),a.hold=w,a.bits=v}},{}],49:[function(t,n,i){var o=t("../utils/common"),s=t("./adler32"),a=t("./crc32"),l=t("./inffast"),h=t("./inftrees"),u=1,f=2,g=0,p=-2,c=1,d=852,m=592;function y(T){return(T>>>24&255)+(T>>>8&65280)+((65280&T)<<8)+((255&T)<<24)}function w(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new o.Buf16(320),this.work=new o.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function v(T){var B;return T&&T.state?(B=T.state,T.total_in=T.total_out=B.total=0,T.msg="",B.wrap&&(T.adler=1&B.wrap),B.mode=c,B.last=0,B.havedict=0,B.dmax=32768,B.head=null,B.hold=0,B.bits=0,B.lencode=B.lendyn=new o.Buf32(d),B.distcode=B.distdyn=new o.Buf32(m),B.sane=1,B.back=-1,g):p}function M(T){var B;return T&&T.state?((B=T.state).wsize=0,B.whave=0,B.wnext=0,v(T)):p}function P(T,B){var b,V;return T&&T.state?(V=T.state,B<0?(b=0,B=-B):(b=1+(B>>4),B<48&&(B&=15)),B&&(B<8||15<B)?p:(V.window!==null&&V.wbits!==B&&(V.window=null),V.wrap=b,V.wbits=B,M(T))):p}function D(T,B){var b,V;return T?(V=new w,(T.state=V).window=null,(b=P(T,B))!==g&&(T.state=null),b):p}var E,O,k=!0;function I(T){if(k){var B;for(E=new o.Buf32(512),O=new o.Buf32(32),B=0;B<144;)T.lens[B++]=8;for(;B<256;)T.lens[B++]=9;for(;B<280;)T.lens[B++]=7;for(;B<288;)T.lens[B++]=8;for(h(u,T.lens,0,288,E,0,T.work,{bits:9}),B=0;B<32;)T.lens[B++]=5;h(f,T.lens,0,32,O,0,T.work,{bits:5}),k=!1}T.lencode=E,T.lenbits=9,T.distcode=O,T.distbits=5}function W(T,B,b,V){var J,X=T.state;return X.window===null&&(X.wsize=1<<X.wbits,X.wnext=0,X.whave=0,X.window=new o.Buf8(X.wsize)),V>=X.wsize?(o.arraySet(X.window,B,b-X.wsize,X.wsize,0),X.wnext=0,X.whave=X.wsize):(V<(J=X.wsize-X.wnext)&&(J=V),o.arraySet(X.window,B,b-V,J,X.wnext),(V-=J)?(o.arraySet(X.window,B,b-V,V,0),X.wnext=V,X.whave=X.wsize):(X.wnext+=J,X.wnext===X.wsize&&(X.wnext=0),X.whave<X.wsize&&(X.whave+=J))),0}i.inflateReset=M,i.inflateReset2=P,i.inflateResetKeep=v,i.inflateInit=function(T){return D(T,15)},i.inflateInit2=D,i.inflate=function(T,B){var b,V,J,X,ee,j,ne,z,N,te,$,H,de,fe,se,ae,ue,pe,Te,xe,_,G,U,C,A=0,L=new o.Buf8(4),K=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!T||!T.state||!T.output||!T.input&&T.avail_in!==0)return p;(b=T.state).mode===12&&(b.mode=13),ee=T.next_out,J=T.output,ne=T.avail_out,X=T.next_in,V=T.input,j=T.avail_in,z=b.hold,N=b.bits,te=j,$=ne,G=g;e:for(;;)switch(b.mode){case c:if(b.wrap===0){b.mode=13;break}for(;N<16;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}if(2&b.wrap&&z===35615){L[b.check=0]=255&z,L[1]=z>>>8&255,b.check=a(b.check,L,2,0),N=z=0,b.mode=2;break}if(b.flags=0,b.head&&(b.head.done=!1),!(1&b.wrap)||(((255&z)<<8)+(z>>8))%31){T.msg="incorrect header check",b.mode=30;break}if((15&z)!=8){T.msg="unknown compression method",b.mode=30;break}if(N-=4,_=8+(15&(z>>>=4)),b.wbits===0)b.wbits=_;else if(_>b.wbits){T.msg="invalid window size",b.mode=30;break}b.dmax=1<<_,T.adler=b.check=1,b.mode=512&z?10:12,N=z=0;break;case 2:for(;N<16;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}if(b.flags=z,(255&b.flags)!=8){T.msg="unknown compression method",b.mode=30;break}if(57344&b.flags){T.msg="unknown header flags set",b.mode=30;break}b.head&&(b.head.text=z>>8&1),512&b.flags&&(L[0]=255&z,L[1]=z>>>8&255,b.check=a(b.check,L,2,0)),N=z=0,b.mode=3;case 3:for(;N<32;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}b.head&&(b.head.time=z),512&b.flags&&(L[0]=255&z,L[1]=z>>>8&255,L[2]=z>>>16&255,L[3]=z>>>24&255,b.check=a(b.check,L,4,0)),N=z=0,b.mode=4;case 4:for(;N<16;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}b.head&&(b.head.xflags=255&z,b.head.os=z>>8),512&b.flags&&(L[0]=255&z,L[1]=z>>>8&255,b.check=a(b.check,L,2,0)),N=z=0,b.mode=5;case 5:if(1024&b.flags){for(;N<16;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}b.length=z,b.head&&(b.head.extra_len=z),512&b.flags&&(L[0]=255&z,L[1]=z>>>8&255,b.check=a(b.check,L,2,0)),N=z=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(1024&b.flags&&(j<(H=b.length)&&(H=j),H&&(b.head&&(_=b.head.extra_len-b.length,b.head.extra||(b.head.extra=new Array(b.head.extra_len)),o.arraySet(b.head.extra,V,X,H,_)),512&b.flags&&(b.check=a(b.check,V,H,X)),j-=H,X+=H,b.length-=H),b.length))break e;b.length=0,b.mode=7;case 7:if(2048&b.flags){if(j===0)break e;for(H=0;_=V[X+H++],b.head&&_&&b.length<65536&&(b.head.name+=String.fromCharCode(_)),_&&H<j;);if(512&b.flags&&(b.check=a(b.check,V,H,X)),j-=H,X+=H,_)break e}else b.head&&(b.head.name=null);b.length=0,b.mode=8;case 8:if(4096&b.flags){if(j===0)break e;for(H=0;_=V[X+H++],b.head&&_&&b.length<65536&&(b.head.comment+=String.fromCharCode(_)),_&&H<j;);if(512&b.flags&&(b.check=a(b.check,V,H,X)),j-=H,X+=H,_)break e}else b.head&&(b.head.comment=null);b.mode=9;case 9:if(512&b.flags){for(;N<16;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}if(z!==(65535&b.check)){T.msg="header crc mismatch",b.mode=30;break}N=z=0}b.head&&(b.head.hcrc=b.flags>>9&1,b.head.done=!0),T.adler=b.check=0,b.mode=12;break;case 10:for(;N<32;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}T.adler=b.check=y(z),N=z=0,b.mode=11;case 11:if(b.havedict===0)return T.next_out=ee,T.avail_out=ne,T.next_in=X,T.avail_in=j,b.hold=z,b.bits=N,2;T.adler=b.check=1,b.mode=12;case 12:if(B===5||B===6)break e;case 13:if(b.last){z>>>=7&N,N-=7&N,b.mode=27;break}for(;N<3;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}switch(b.last=1&z,N-=1,3&(z>>>=1)){case 0:b.mode=14;break;case 1:if(I(b),b.mode=20,B!==6)break;z>>>=2,N-=2;break e;case 2:b.mode=17;break;case 3:T.msg="invalid block type",b.mode=30}z>>>=2,N-=2;break;case 14:for(z>>>=7&N,N-=7&N;N<32;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}if((65535&z)!=(z>>>16^65535)){T.msg="invalid stored block lengths",b.mode=30;break}if(b.length=65535&z,N=z=0,b.mode=15,B===6)break e;case 15:b.mode=16;case 16:if(H=b.length){if(j<H&&(H=j),ne<H&&(H=ne),H===0)break e;o.arraySet(J,V,X,H,ee),j-=H,X+=H,ne-=H,ee+=H,b.length-=H;break}b.mode=12;break;case 17:for(;N<14;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}if(b.nlen=257+(31&z),z>>>=5,N-=5,b.ndist=1+(31&z),z>>>=5,N-=5,b.ncode=4+(15&z),z>>>=4,N-=4,286<b.nlen||30<b.ndist){T.msg="too many length or distance symbols",b.mode=30;break}b.have=0,b.mode=18;case 18:for(;b.have<b.ncode;){for(;N<3;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}b.lens[K[b.have++]]=7&z,z>>>=3,N-=3}for(;b.have<19;)b.lens[K[b.have++]]=0;if(b.lencode=b.lendyn,b.lenbits=7,U={bits:b.lenbits},G=h(0,b.lens,0,19,b.lencode,0,b.work,U),b.lenbits=U.bits,G){T.msg="invalid code lengths set",b.mode=30;break}b.have=0,b.mode=19;case 19:for(;b.have<b.nlen+b.ndist;){for(;ae=(A=b.lencode[z&(1<<b.lenbits)-1])>>>16&255,ue=65535&A,!((se=A>>>24)<=N);){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}if(ue<16)z>>>=se,N-=se,b.lens[b.have++]=ue;else{if(ue===16){for(C=se+2;N<C;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}if(z>>>=se,N-=se,b.have===0){T.msg="invalid bit length repeat",b.mode=30;break}_=b.lens[b.have-1],H=3+(3&z),z>>>=2,N-=2}else if(ue===17){for(C=se+3;N<C;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}N-=se,_=0,H=3+(7&(z>>>=se)),z>>>=3,N-=3}else{for(C=se+7;N<C;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}N-=se,_=0,H=11+(127&(z>>>=se)),z>>>=7,N-=7}if(b.have+H>b.nlen+b.ndist){T.msg="invalid bit length repeat",b.mode=30;break}for(;H--;)b.lens[b.have++]=_}}if(b.mode===30)break;if(b.lens[256]===0){T.msg="invalid code -- missing end-of-block",b.mode=30;break}if(b.lenbits=9,U={bits:b.lenbits},G=h(u,b.lens,0,b.nlen,b.lencode,0,b.work,U),b.lenbits=U.bits,G){T.msg="invalid literal/lengths set",b.mode=30;break}if(b.distbits=6,b.distcode=b.distdyn,U={bits:b.distbits},G=h(f,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,U),b.distbits=U.bits,G){T.msg="invalid distances set",b.mode=30;break}if(b.mode=20,B===6)break e;case 20:b.mode=21;case 21:if(6<=j&&258<=ne){T.next_out=ee,T.avail_out=ne,T.next_in=X,T.avail_in=j,b.hold=z,b.bits=N,l(T,$),ee=T.next_out,J=T.output,ne=T.avail_out,X=T.next_in,V=T.input,j=T.avail_in,z=b.hold,N=b.bits,b.mode===12&&(b.back=-1);break}for(b.back=0;ae=(A=b.lencode[z&(1<<b.lenbits)-1])>>>16&255,ue=65535&A,!((se=A>>>24)<=N);){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}if(ae&&(240&ae)==0){for(pe=se,Te=ae,xe=ue;ae=(A=b.lencode[xe+((z&(1<<pe+Te)-1)>>pe)])>>>16&255,ue=65535&A,!(pe+(se=A>>>24)<=N);){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}z>>>=pe,N-=pe,b.back+=pe}if(z>>>=se,N-=se,b.back+=se,b.length=ue,ae===0){b.mode=26;break}if(32&ae){b.back=-1,b.mode=12;break}if(64&ae){T.msg="invalid literal/length code",b.mode=30;break}b.extra=15&ae,b.mode=22;case 22:if(b.extra){for(C=b.extra;N<C;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}b.length+=z&(1<<b.extra)-1,z>>>=b.extra,N-=b.extra,b.back+=b.extra}b.was=b.length,b.mode=23;case 23:for(;ae=(A=b.distcode[z&(1<<b.distbits)-1])>>>16&255,ue=65535&A,!((se=A>>>24)<=N);){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}if((240&ae)==0){for(pe=se,Te=ae,xe=ue;ae=(A=b.distcode[xe+((z&(1<<pe+Te)-1)>>pe)])>>>16&255,ue=65535&A,!(pe+(se=A>>>24)<=N);){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}z>>>=pe,N-=pe,b.back+=pe}if(z>>>=se,N-=se,b.back+=se,64&ae){T.msg="invalid distance code",b.mode=30;break}b.offset=ue,b.extra=15&ae,b.mode=24;case 24:if(b.extra){for(C=b.extra;N<C;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}b.offset+=z&(1<<b.extra)-1,z>>>=b.extra,N-=b.extra,b.back+=b.extra}if(b.offset>b.dmax){T.msg="invalid distance too far back",b.mode=30;break}b.mode=25;case 25:if(ne===0)break e;if(H=$-ne,b.offset>H){if((H=b.offset-H)>b.whave&&b.sane){T.msg="invalid distance too far back",b.mode=30;break}de=H>b.wnext?(H-=b.wnext,b.wsize-H):b.wnext-H,H>b.length&&(H=b.length),fe=b.window}else fe=J,de=ee-b.offset,H=b.length;for(ne<H&&(H=ne),ne-=H,b.length-=H;J[ee++]=fe[de++],--H;);b.length===0&&(b.mode=21);break;case 26:if(ne===0)break e;J[ee++]=b.length,ne--,b.mode=21;break;case 27:if(b.wrap){for(;N<32;){if(j===0)break e;j--,z|=V[X++]<<N,N+=8}if($-=ne,T.total_out+=$,b.total+=$,$&&(T.adler=b.check=b.flags?a(b.check,J,$,ee-$):s(b.check,J,$,ee-$)),$=ne,(b.flags?z:y(z))!==b.check){T.msg="incorrect data check",b.mode=30;break}N=z=0}b.mode=28;case 28:if(b.wrap&&b.flags){for(;N<32;){if(j===0)break e;j--,z+=V[X++]<<N,N+=8}if(z!==(4294967295&b.total)){T.msg="incorrect length check",b.mode=30;break}N=z=0}b.mode=29;case 29:G=1;break e;case 30:G=-3;break e;case 31:return-4;case 32:default:return p}return T.next_out=ee,T.avail_out=ne,T.next_in=X,T.avail_in=j,b.hold=z,b.bits=N,(b.wsize||$!==T.avail_out&&b.mode<30&&(b.mode<27||B!==4))&&W(T,T.output,T.next_out,$-T.avail_out)?(b.mode=31,-4):(te-=T.avail_in,$-=T.avail_out,T.total_in+=te,T.total_out+=$,b.total+=$,b.wrap&&$&&(T.adler=b.check=b.flags?a(b.check,J,$,T.next_out-$):s(b.check,J,$,T.next_out-$)),T.data_type=b.bits+(b.last?64:0)+(b.mode===12?128:0)+(b.mode===20||b.mode===15?256:0),(te==0&&$===0||B===4)&&G===g&&(G=-5),G)},i.inflateEnd=function(T){if(!T||!T.state)return p;var B=T.state;return B.window&&(B.window=null),T.state=null,g},i.inflateGetHeader=function(T,B){var b;return T&&T.state?(2&(b=T.state).wrap)==0?p:((b.head=B).done=!1,g):p},i.inflateSetDictionary=function(T,B){var b,V=B.length;return T&&T.state?(b=T.state).wrap!==0&&b.mode!==11?p:b.mode===11&&s(1,B,V,0)!==b.check?-3:W(T,B,V,V)?(b.mode=31,-4):(b.havedict=1,g):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 o=t("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],h=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];n.exports=function(u,f,g,p,c,d,m,y){var w,v,M,P,D,E,O,k,I,W=y.bits,T=0,B=0,b=0,V=0,J=0,X=0,ee=0,j=0,ne=0,z=0,N=null,te=0,$=new o.Buf16(16),H=new o.Buf16(16),de=null,fe=0;for(T=0;T<=15;T++)$[T]=0;for(B=0;B<p;B++)$[f[g+B]]++;for(J=W,V=15;1<=V&&$[V]===0;V--);if(V<J&&(J=V),V===0)return c[d++]=20971520,c[d++]=20971520,y.bits=1,0;for(b=1;b<V&&$[b]===0;b++);for(J<b&&(J=b),T=j=1;T<=15;T++)if(j<<=1,(j-=$[T])<0)return-1;if(0<j&&(u===0||V!==1))return-1;for(H[1]=0,T=1;T<15;T++)H[T+1]=H[T]+$[T];for(B=0;B<p;B++)f[g+B]!==0&&(m[H[f[g+B]]++]=B);if(E=u===0?(N=de=m,19):u===1?(N=s,te-=257,de=a,fe-=257,256):(N=l,de=h,-1),T=b,D=d,ee=B=z=0,M=-1,P=(ne=1<<(X=J))-1,u===1&&852<ne||u===2&&592<ne)return 1;for(;;){for(O=T-ee,I=m[B]<E?(k=0,m[B]):m[B]>E?(k=de[fe+m[B]],N[te+m[B]]):(k=96,0),w=1<<T-ee,b=v=1<<X;c[D+(z>>ee)+(v-=w)]=O<<24|k<<16|I|0,v!==0;);for(w=1<<T-1;z&w;)w>>=1;if(w!==0?(z&=w-1,z+=w):z=0,B++,--$[T]==0){if(T===V)break;T=f[g+m[B]]}if(J<T&&(z&P)!==M){for(ee===0&&(ee=J),D+=b,j=1<<(X=T-ee);X+ee<V&&!((j-=$[X+ee])<=0);)X++,j<<=1;if(ne+=1<<X,u===1&&852<ne||u===2&&592<ne)return 1;c[M=z&P]=J<<24|X<<16|D-d|0}}return z!==0&&(c[D+z]=T-ee<<24|64<<16|0),y.bits=J,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 o=t("../utils/common"),s=0,a=1;function l(A){for(var L=A.length;0<=--L;)A[L]=0}var h=0,u=29,f=256,g=f+1+u,p=30,c=19,d=2*g+1,m=15,y=16,w=7,v=256,M=16,P=17,D=18,E=[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],O=[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],I=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],W=new Array(2*(g+2));l(W);var T=new Array(2*p);l(T);var B=new Array(512);l(B);var b=new Array(256);l(b);var V=new Array(u);l(V);var J,X,ee,j=new Array(p);function ne(A,L,K,Z,R){this.static_tree=A,this.extra_bits=L,this.extra_base=K,this.elems=Z,this.max_length=R,this.has_stree=A&&A.length}function z(A,L){this.dyn_tree=A,this.max_code=0,this.stat_desc=L}function N(A){return A<256?B[A]:B[256+(A>>>7)]}function te(A,L){A.pending_buf[A.pending++]=255&L,A.pending_buf[A.pending++]=L>>>8&255}function $(A,L,K){A.bi_valid>y-K?(A.bi_buf|=L<<A.bi_valid&65535,te(A,A.bi_buf),A.bi_buf=L>>y-A.bi_valid,A.bi_valid+=K-y):(A.bi_buf|=L<<A.bi_valid&65535,A.bi_valid+=K)}function H(A,L,K){$(A,K[2*L],K[2*L+1])}function de(A,L){for(var K=0;K|=1&A,A>>>=1,K<<=1,0<--L;);return K>>>1}function fe(A,L,K){var Z,R,q=new Array(m+1),Q=0;for(Z=1;Z<=m;Z++)q[Z]=Q=Q+K[Z-1]<<1;for(R=0;R<=L;R++){var Y=A[2*R+1];Y!==0&&(A[2*R]=de(q[Y]++,Y))}}function se(A){var L;for(L=0;L<g;L++)A.dyn_ltree[2*L]=0;for(L=0;L<p;L++)A.dyn_dtree[2*L]=0;for(L=0;L<c;L++)A.bl_tree[2*L]=0;A.dyn_ltree[2*v]=1,A.opt_len=A.static_len=0,A.last_lit=A.matches=0}function ae(A){8<A.bi_valid?te(A,A.bi_buf):0<A.bi_valid&&(A.pending_buf[A.pending++]=A.bi_buf),A.bi_buf=0,A.bi_valid=0}function ue(A,L,K,Z){var R=2*L,q=2*K;return A[R]<A[q]||A[R]===A[q]&&Z[L]<=Z[K]}function pe(A,L,K){for(var Z=A.heap[K],R=K<<1;R<=A.heap_len&&(R<A.heap_len&&ue(L,A.heap[R+1],A.heap[R],A.depth)&&R++,!ue(L,Z,A.heap[R],A.depth));)A.heap[K]=A.heap[R],K=R,R<<=1;A.heap[K]=Z}function Te(A,L,K){var Z,R,q,Q,Y=0;if(A.last_lit!==0)for(;Z=A.pending_buf[A.d_buf+2*Y]<<8|A.pending_buf[A.d_buf+2*Y+1],R=A.pending_buf[A.l_buf+Y],Y++,Z===0?H(A,R,L):(H(A,(q=b[R])+f+1,L),(Q=E[q])!==0&&$(A,R-=V[q],Q),H(A,q=N(--Z),K),(Q=O[q])!==0&&$(A,Z-=j[q],Q)),Y<A.last_lit;);H(A,v,L)}function xe(A,L){var K,Z,R,q=L.dyn_tree,Q=L.stat_desc.static_tree,Y=L.stat_desc.has_stree,ie=L.stat_desc.elems,ce=-1;for(A.heap_len=0,A.heap_max=d,K=0;K<ie;K++)q[2*K]!==0?(A.heap[++A.heap_len]=ce=K,A.depth[K]=0):q[2*K+1]=0;for(;A.heap_len<2;)q[2*(R=A.heap[++A.heap_len]=ce<2?++ce:0)]=1,A.depth[R]=0,A.opt_len--,Y&&(A.static_len-=Q[2*R+1]);for(L.max_code=ce,K=A.heap_len>>1;1<=K;K--)pe(A,q,K);for(R=ie;K=A.heap[1],A.heap[1]=A.heap[A.heap_len--],pe(A,q,1),Z=A.heap[1],A.heap[--A.heap_max]=K,A.heap[--A.heap_max]=Z,q[2*R]=q[2*K]+q[2*Z],A.depth[R]=(A.depth[K]>=A.depth[Z]?A.depth[K]:A.depth[Z])+1,q[2*K+1]=q[2*Z+1]=R,A.heap[1]=R++,pe(A,q,1),2<=A.heap_len;);A.heap[--A.heap_max]=A.heap[1],(function(oe,_e){var De,be,qe,me,st,ft,Ee=_e.dyn_tree,Fe=_e.max_code,Ye=_e.stat_desc.static_tree,He=_e.stat_desc.has_stree,$e=_e.stat_desc.extra_bits,Ue=_e.stat_desc.extra_base,pt=_e.stat_desc.max_length,It=0;for(me=0;me<=m;me++)oe.bl_count[me]=0;for(Ee[2*oe.heap[oe.heap_max]+1]=0,De=oe.heap_max+1;De<d;De++)pt<(me=Ee[2*Ee[2*(be=oe.heap[De])+1]+1]+1)&&(me=pt,It++),Ee[2*be+1]=me,Fe<be||(oe.bl_count[me]++,st=0,Ue<=be&&(st=$e[be-Ue]),ft=Ee[2*be],oe.opt_len+=ft*(me+st),He&&(oe.static_len+=ft*(Ye[2*be+1]+st)));if(It!==0){do{for(me=pt-1;oe.bl_count[me]===0;)me--;oe.bl_count[me]--,oe.bl_count[me+1]+=2,oe.bl_count[pt]--,It-=2}while(0<It);for(me=pt;me!==0;me--)for(be=oe.bl_count[me];be!==0;)Fe<(qe=oe.heap[--De])||(Ee[2*qe+1]!==me&&(oe.opt_len+=(me-Ee[2*qe+1])*Ee[2*qe],Ee[2*qe+1]=me),be--)}})(A,L),fe(q,ce,A.bl_count)}function _(A,L,K){var Z,R,q=-1,Q=L[1],Y=0,ie=7,ce=4;for(Q===0&&(ie=138,ce=3),L[2*(K+1)+1]=65535,Z=0;Z<=K;Z++)R=Q,Q=L[2*(Z+1)+1],++Y<ie&&R===Q||(Y<ce?A.bl_tree[2*R]+=Y:R!==0?(R!==q&&A.bl_tree[2*R]++,A.bl_tree[2*M]++):Y<=10?A.bl_tree[2*P]++:A.bl_tree[2*D]++,q=R,ce=(Y=0)===Q?(ie=138,3):R===Q?(ie=6,3):(ie=7,4))}function G(A,L,K){var Z,R,q=-1,Q=L[1],Y=0,ie=7,ce=4;for(Q===0&&(ie=138,ce=3),Z=0;Z<=K;Z++)if(R=Q,Q=L[2*(Z+1)+1],!(++Y<ie&&R===Q)){if(Y<ce)for(;H(A,R,A.bl_tree),--Y!=0;);else R!==0?(R!==q&&(H(A,R,A.bl_tree),Y--),H(A,M,A.bl_tree),$(A,Y-3,2)):Y<=10?(H(A,P,A.bl_tree),$(A,Y-3,3)):(H(A,D,A.bl_tree),$(A,Y-11,7));q=R,ce=(Y=0)===Q?(ie=138,3):R===Q?(ie=6,3):(ie=7,4)}}l(j);var U=!1;function C(A,L,K,Z){$(A,(h<<1)+(Z?1:0),3),(function(R,q,Q,Y){ae(R),te(R,Q),te(R,~Q),o.arraySet(R.pending_buf,R.window,q,Q,R.pending),R.pending+=Q})(A,L,K)}i._tr_init=function(A){U||((function(){var L,K,Z,R,q,Q=new Array(m+1);for(R=Z=0;R<u-1;R++)for(V[R]=Z,L=0;L<1<<E[R];L++)b[Z++]=R;for(b[Z-1]=R,R=q=0;R<16;R++)for(j[R]=q,L=0;L<1<<O[R];L++)B[q++]=R;for(q>>=7;R<p;R++)for(j[R]=q<<7,L=0;L<1<<O[R]-7;L++)B[256+q++]=R;for(K=0;K<=m;K++)Q[K]=0;for(L=0;L<=143;)W[2*L+1]=8,L++,Q[8]++;for(;L<=255;)W[2*L+1]=9,L++,Q[9]++;for(;L<=279;)W[2*L+1]=7,L++,Q[7]++;for(;L<=287;)W[2*L+1]=8,L++,Q[8]++;for(fe(W,g+1,Q),L=0;L<p;L++)T[2*L+1]=5,T[2*L]=de(L,5);J=new ne(W,E,f+1,g,m),X=new ne(T,O,0,p,m),ee=new ne(new Array(0),k,0,c,w)})(),U=!0),A.l_desc=new z(A.dyn_ltree,J),A.d_desc=new z(A.dyn_dtree,X),A.bl_desc=new z(A.bl_tree,ee),A.bi_buf=0,A.bi_valid=0,se(A)},i._tr_stored_block=C,i._tr_flush_block=function(A,L,K,Z){var R,q,Q=0;0<A.level?(A.strm.data_type===2&&(A.strm.data_type=(function(Y){var ie,ce=4093624447;for(ie=0;ie<=31;ie++,ce>>>=1)if(1&ce&&Y.dyn_ltree[2*ie]!==0)return s;if(Y.dyn_ltree[18]!==0||Y.dyn_ltree[20]!==0||Y.dyn_ltree[26]!==0)return a;for(ie=32;ie<f;ie++)if(Y.dyn_ltree[2*ie]!==0)return a;return s})(A)),xe(A,A.l_desc),xe(A,A.d_desc),Q=(function(Y){var ie;for(_(Y,Y.dyn_ltree,Y.l_desc.max_code),_(Y,Y.dyn_dtree,Y.d_desc.max_code),xe(Y,Y.bl_desc),ie=c-1;3<=ie&&Y.bl_tree[2*I[ie]+1]===0;ie--);return Y.opt_len+=3*(ie+1)+5+5+4,ie})(A),R=A.opt_len+3+7>>>3,(q=A.static_len+3+7>>>3)<=R&&(R=q)):R=q=K+5,K+4<=R&&L!==-1?C(A,L,K,Z):A.strategy===4||q===R?($(A,2+(Z?1:0),3),Te(A,W,T)):($(A,4+(Z?1:0),3),(function(Y,ie,ce,oe){var _e;for($(Y,ie-257,5),$(Y,ce-1,5),$(Y,oe-4,4),_e=0;_e<oe;_e++)$(Y,Y.bl_tree[2*I[_e]+1],3);G(Y,Y.dyn_ltree,ie-1),G(Y,Y.dyn_dtree,ce-1)})(A,A.l_desc.max_code+1,A.d_desc.max_code+1,Q+1),Te(A,A.dyn_ltree,A.dyn_dtree)),se(A),Z&&ae(A)},i._tr_tally=function(A,L,K){return A.pending_buf[A.d_buf+2*A.last_lit]=L>>>8&255,A.pending_buf[A.d_buf+2*A.last_lit+1]=255&L,A.pending_buf[A.l_buf+A.last_lit]=255&K,A.last_lit++,L===0?A.dyn_ltree[2*K]++:(A.matches++,L--,A.dyn_ltree[2*(b[K]+f+1)]++,A.dyn_dtree[2*N(L)]++),A.last_lit===A.lit_bufsize-1},i._tr_align=function(A){$(A,2,3),H(A,v,W),(function(L){L.bi_valid===16?(te(L,L.bi_buf),L.bi_buf=0,L.bi_valid=0):8<=L.bi_valid&&(L.pending_buf[L.pending++]=255&L.bi_buf,L.bi_buf>>=8,L.bi_valid-=8)})(A)}},{"../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(o){(function(s,a){if(!s.setImmediate){var l,h,u,f,g=1,p={},c=!1,d=s.document,m=Object.getPrototypeOf&&Object.getPrototypeOf(s);m=m&&m.setTimeout?m:s,l={}.toString.call(s.process)==="[object process]"?function(M){process.nextTick(function(){w(M)})}:(function(){if(s.postMessage&&!s.importScripts){var M=!0,P=s.onmessage;return s.onmessage=function(){M=!1},s.postMessage("","*"),s.onmessage=P,M}})()?(f="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",v,!1):s.attachEvent("onmessage",v),function(M){s.postMessage(f+M,"*")}):s.MessageChannel?((u=new MessageChannel).port1.onmessage=function(M){w(M.data)},function(M){u.port2.postMessage(M)}):d&&"onreadystatechange"in d.createElement("script")?(h=d.documentElement,function(M){var P=d.createElement("script");P.onreadystatechange=function(){w(M),P.onreadystatechange=null,h.removeChild(P),P=null},h.appendChild(P)}):function(M){setTimeout(w,0,M)},m.setImmediate=function(M){typeof M!="function"&&(M=new Function(""+M));for(var P=new Array(arguments.length-1),D=0;D<P.length;D++)P[D]=arguments[D+1];var E={callback:M,args:P};return p[g]=E,l(g),g++},m.clearImmediate=y}function y(M){delete p[M]}function w(M){if(c)setTimeout(w,0,M);else{var P=p[M];if(P){c=!0;try{(function(D){var E=D.callback,O=D.args;switch(O.length){case 0:E();break;case 1:E(O[0]);break;case 2:E(O[0],O[1]);break;case 3:E(O[0],O[1],O[2]);break;default:E.apply(a,O)}})(P)}finally{y(M),c=!1}}}}function v(M){M.source===s&&typeof M.data=="string"&&M.data.indexOf(f)===0&&w(+M.data.slice(f.length))}})(typeof self>"u"?o===void 0?this:o:self)}).call(this,typeof vt<"u"?vt:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(jt)),jt.exports}var es=Ji();const ts=gn(es);function _n(r,e){return function(){return r.apply(e,arguments)}}const{toString:ns}=Object.prototype,{getPrototypeOf:Gt}=Object,{iterator:Mt,toStringTag:wn}=Symbol,At=(r=>e=>{const t=ns.call(e);return r[t]||(r[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),ke=r=>(r=r.toLowerCase(),e=>At(e)===r),Tt=r=>e=>typeof e===r,{isArray:Je}=Array,et=Tt("undefined");function rt(r){return r!==null&&!et(r)&&r.constructor!==null&&!et(r.constructor)&&Me(r.constructor.isBuffer)&&r.constructor.isBuffer(r)}const bn=ke("ArrayBuffer");function is(r){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(r):e=r&&r.buffer&&bn(r.buffer),e}const ss=Tt("string"),Me=Tt("function"),xn=Tt("number"),ot=r=>r!==null&&typeof r=="object",rs=r=>r===!0||r===!1,Ct=r=>{if(At(r)!=="object")return!1;const e=Gt(r);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(wn in r)&&!(Mt in r)},os=r=>{if(!ot(r)||rt(r))return!1;try{return Object.keys(r).length===0&&Object.getPrototypeOf(r)===Object.prototype}catch{return!1}},as=ke("Date"),ls=ke("File"),cs=ke("Blob"),hs=ke("FileList"),us=r=>ot(r)&&Me(r.pipe),ds=r=>{let e;return r&&(typeof FormData=="function"&&r instanceof FormData||Me(r.append)&&((e=At(r))==="formdata"||e==="object"&&Me(r.toString)&&r.toString()==="[object FormData]"))},fs=ke("URLSearchParams"),[ps,ms,gs,ys]=["ReadableStream","Request","Response","Headers"].map(ke),_s=r=>r.trim?r.trim():r.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function at(r,e,{allOwnKeys:t=!1}={}){if(r===null||typeof r>"u")return;let n,i;if(typeof r!="object"&&(r=[r]),Je(r))for(n=0,i=r.length;n<i;n++)e.call(null,r[n],n,r);else{if(rt(r))return;const o=t?Object.getOwnPropertyNames(r):Object.keys(r),s=o.length;let a;for(n=0;n<s;n++)a=o[n],e.call(null,r[a],a,r)}}function vn(r,e){if(rt(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 We=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Sn=r=>!et(r)&&r!==We;function Wt(){const{caseless:r,skipUndefined:e}=Sn(this)&&this||{},t={},n=(i,o)=>{const s=r&&vn(t,o)||o;Ct(t[s])&&Ct(i)?t[s]=Wt(t[s],i):Ct(i)?t[s]=Wt({},i):Je(i)?t[s]=i.slice():(!e||!et(i))&&(t[s]=i)};for(let i=0,o=arguments.length;i<o;i++)arguments[i]&&at(arguments[i],n);return t}const ws=(r,e,t,{allOwnKeys:n}={})=>(at(e,(i,o)=>{t&&Me(i)?r[o]=_n(i,t):r[o]=i},{allOwnKeys:n}),r),bs=r=>(r.charCodeAt(0)===65279&&(r=r.slice(1)),r),xs=(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)},vs=(r,e,t,n)=>{let i,o,s;const a={};if(e=e||{},r==null)return e;do{for(i=Object.getOwnPropertyNames(r),o=i.length;o-- >0;)s=i[o],(!n||n(s,r,e))&&!a[s]&&(e[s]=r[s],a[s]=!0);r=t!==!1&&Gt(r)}while(r&&(!t||t(r,e))&&r!==Object.prototype);return e},Ss=(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},Ms=r=>{if(!r)return null;if(Je(r))return r;let e=r.length;if(!xn(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=r[e];return t},As=(r=>e=>r&&e instanceof r)(typeof Uint8Array<"u"&&Gt(Uint8Array)),Ts=(r,e)=>{const n=(r&&r[Mt]).call(r);let i;for(;(i=n.next())&&!i.done;){const o=i.value;e.call(r,o[0],o[1])}},Cs=(r,e)=>{let t;const n=[];for(;(t=r.exec(e))!==null;)n.push(t);return n},Ps=ke("HTMLFormElement"),ks=r=>r.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,n,i){return n.toUpperCase()+i}),Mn=(({hasOwnProperty:r})=>(e,t)=>r.call(e,t))(Object.prototype),Ds=ke("RegExp"),An=(r,e)=>{const t=Object.getOwnPropertyDescriptors(r),n={};at(t,(i,o)=>{let s;(s=e(i,o,r))!==!1&&(n[o]=s||i)}),Object.defineProperties(r,n)},Es=r=>{An(r,(e,t)=>{if(Me(r)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const n=r[t];if(Me(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+"'")})}})},Ls=(r,e)=>{const t={},n=i=>{i.forEach(o=>{t[o]=!0})};return Je(r)?n(r):n(String(r).split(e)),t},Os=()=>{},Ns=(r,e)=>r!=null&&Number.isFinite(r=+r)?r:e;function Rs(r){return!!(r&&Me(r.append)&&r[wn]==="FormData"&&r[Mt])}const zs=r=>{const e=new Array(10),t=(n,i)=>{if(ot(n)){if(e.indexOf(n)>=0)return;if(rt(n))return n;if(!("toJSON"in n)){e[i]=n;const o=Je(n)?[]:{};return at(n,(s,a)=>{const l=t(s,i+1);!et(l)&&(o[a]=l)}),e[i]=void 0,o}}return n};return t(r,0)},Bs=ke("AsyncFunction"),Is=r=>r&&(ot(r)||Me(r))&&Me(r.then)&&Me(r.catch),Tn=((r,e)=>r?setImmediate:e?((t,n)=>(We.addEventListener("message",({source:i,data:o})=>{i===We&&o===t&&n.length&&n.shift()()},!1),i=>{n.push(i),We.postMessage(t,"*")}))(`axios@${Math.random()}`,[]):t=>setTimeout(t))(typeof setImmediate=="function",Me(We.postMessage)),Fs=typeof queueMicrotask<"u"?queueMicrotask.bind(We):typeof process<"u"&&process.nextTick||Tn,F={isArray:Je,isArrayBuffer:bn,isBuffer:rt,isFormData:ds,isArrayBufferView:is,isString:ss,isNumber:xn,isBoolean:rs,isObject:ot,isPlainObject:Ct,isEmptyObject:os,isReadableStream:ps,isRequest:ms,isResponse:gs,isHeaders:ys,isUndefined:et,isDate:as,isFile:ls,isBlob:cs,isRegExp:Ds,isFunction:Me,isStream:us,isURLSearchParams:fs,isTypedArray:As,isFileList:hs,forEach:at,merge:Wt,extend:ws,trim:_s,stripBOM:bs,inherits:xs,toFlatObject:vs,kindOf:At,kindOfTest:ke,endsWith:Ss,toArray:Ms,forEachEntry:Ts,matchAll:Cs,isHTMLForm:Ps,hasOwnProperty:Mn,hasOwnProp:Mn,reduceDescriptors:An,freezeMethods:Es,toObjectSet:Ls,toCamelCase:ks,noop:Os,toFiniteNumber:Ns,findKey:vn,global:We,isContextDefined:Sn,isSpecCompliantForm:Rs,toJSONObject:zs,isAsyncFn:Bs,isThenable:Is,setImmediate:Tn,asap:Fs,isIterable:r=>r!=null&&Me(r[Mt])};function re(r,e,t,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=r,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}F.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:F.toJSONObject(this.config),code:this.code,status:this.status}}});const Cn=re.prototype,Pn={};["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=>{Pn[r]={value:r}}),Object.defineProperties(re,Pn),Object.defineProperty(Cn,"isAxiosError",{value:!0}),re.from=(r,e,t,n,i,o)=>{const s=Object.create(Cn);F.toFlatObject(r,s,function(u){return u!==Error.prototype},h=>h!=="isAxiosError");const a=r&&r.message?r.message:"Error",l=e==null&&r?r.code:e;return re.call(s,a,l,t,n,i),r&&s.cause==null&&Object.defineProperty(s,"cause",{value:r,configurable:!0}),s.name=r&&r.name||"Error",o&&Object.assign(s,o),s};const Us=null;function Kt(r){return F.isPlainObject(r)||F.isArray(r)}function kn(r){return F.endsWith(r,"[]")?r.slice(0,-2):r}function Dn(r,e,t){return r?r.concat(e).map(function(i,o){return i=kn(i),!t&&o?"["+i+"]":i}).join(t?".":""):e}function Vs(r){return F.isArray(r)&&!r.some(Kt)}const js=F.toFlatObject(F,{},null,function(e){return/^is[A-Z]/.test(e)});function Pt(r,e,t){if(!F.isObject(r))throw new TypeError("target must be an object");e=e||new FormData,t=F.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(d,m){return!F.isUndefined(m[d])});const n=t.metaTokens,i=t.visitor||u,o=t.dots,s=t.indexes,l=(t.Blob||typeof Blob<"u"&&Blob)&&F.isSpecCompliantForm(e);if(!F.isFunction(i))throw new TypeError("visitor must be a function");function h(c){if(c===null)return"";if(F.isDate(c))return c.toISOString();if(F.isBoolean(c))return c.toString();if(!l&&F.isBlob(c))throw new re("Blob is not supported. Use a Buffer instead.");return F.isArrayBuffer(c)||F.isTypedArray(c)?l&&typeof Blob=="function"?new Blob([c]):Buffer.from(c):c}function u(c,d,m){let y=c;if(c&&!m&&typeof c=="object"){if(F.endsWith(d,"{}"))d=n?d:d.slice(0,-2),c=JSON.stringify(c);else if(F.isArray(c)&&Vs(c)||(F.isFileList(c)||F.endsWith(d,"[]"))&&(y=F.toArray(c)))return d=kn(d),y.forEach(function(v,M){!(F.isUndefined(v)||v===null)&&e.append(s===!0?Dn([d],M,o):s===null?d:d+"[]",h(v))}),!1}return Kt(c)?!0:(e.append(Dn(m,d,o),h(c)),!1)}const f=[],g=Object.assign(js,{defaultVisitor:u,convertValue:h,isVisitable:Kt});function p(c,d){if(!F.isUndefined(c)){if(f.indexOf(c)!==-1)throw Error("Circular reference detected in "+d.join("."));f.push(c),F.forEach(c,function(y,w){(!(F.isUndefined(y)||y===null)&&i.call(e,y,F.isString(w)?w.trim():w,d,g))===!0&&p(y,d?d.concat(w):[w])}),f.pop()}}if(!F.isObject(r))throw new TypeError("data must be an object");return p(r),e}function En(r){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(r).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function Xt(r,e){this._pairs=[],r&&Pt(r,this,e)}const Ln=Xt.prototype;Ln.append=function(e,t){this._pairs.push([e,t])},Ln.toString=function(e){const t=e?function(n){return e.call(this,n,En)}:En;return this._pairs.map(function(i){return t(i[0])+"="+t(i[1])},"").join("&")};function Gs(r){return encodeURIComponent(r).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function On(r,e,t){if(!e)return r;const n=t&&t.encode||Gs;F.isFunction(t)&&(t={serialize:t});const i=t&&t.serialize;let o;if(i?o=i(e,t):o=F.isURLSearchParams(e)?e.toString():new Xt(e,t).toString(n),o){const s=r.indexOf("#");s!==-1&&(r=r.slice(0,s)),r+=(r.indexOf("?")===-1?"?":"&")+o}return r}class Nn{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){F.forEach(this.handlers,function(n){n!==null&&e(n)})}}const Rn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ws={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:Xt,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Zt=typeof window<"u"&&typeof document<"u",qt=typeof navigator=="object"&&navigator||void 0,Ks=Zt&&(!qt||["ReactNative","NativeScript","NS"].indexOf(qt.product)<0),Xs=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Zs=Zt&&window.location.href||"http://localhost",we={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Zt,hasStandardBrowserEnv:Ks,hasStandardBrowserWebWorkerEnv:Xs,navigator:qt,origin:Zs},Symbol.toStringTag,{value:"Module"})),...Ws};function qs(r,e){return Pt(r,new we.classes.URLSearchParams,{visitor:function(t,n,i,o){return we.isNode&&F.isBuffer(t)?(this.append(n,t.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}function Ys(r){return F.matchAll(/\w+|\[(\w*)]/g,r).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Hs(r){const e={},t=Object.keys(r);let n;const i=t.length;let o;for(n=0;n<i;n++)o=t[n],e[o]=r[o];return e}function zn(r){function e(t,n,i,o){let s=t[o++];if(s==="__proto__")return!0;const a=Number.isFinite(+s),l=o>=t.length;return s=!s&&F.isArray(i)?i.length:s,l?(F.hasOwnProp(i,s)?i[s]=[i[s],n]:i[s]=n,!a):((!i[s]||!F.isObject(i[s]))&&(i[s]=[]),e(t,n,i[s],o)&&F.isArray(i[s])&&(i[s]=Hs(i[s])),!a)}if(F.isFormData(r)&&F.isFunction(r.entries)){const t={};return F.forEachEntry(r,(n,i)=>{e(Ys(n),i,t,0)}),t}return null}function $s(r,e,t){if(F.isString(r))try{return(e||JSON.parse)(r),F.trim(r)}catch(n){if(n.name!=="SyntaxError")throw n}return(t||JSON.stringify)(r)}const lt={transitional:Rn,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const n=t.getContentType()||"",i=n.indexOf("application/json")>-1,o=F.isObject(e);if(o&&F.isHTMLForm(e)&&(e=new FormData(e)),F.isFormData(e))return i?JSON.stringify(zn(e)):e;if(F.isArrayBuffer(e)||F.isBuffer(e)||F.isStream(e)||F.isFile(e)||F.isBlob(e)||F.isReadableStream(e))return e;if(F.isArrayBufferView(e))return e.buffer;if(F.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(o){if(n.indexOf("application/x-www-form-urlencoded")>-1)return qs(e,this.formSerializer).toString();if((a=F.isFileList(e))||n.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Pt(a?{"files[]":e}:e,l&&new l,this.formSerializer)}}return o||i?(t.setContentType("application/json",!1),$s(e)):e}],transformResponse:[function(e){const t=this.transitional||lt.transitional,n=t&&t.forcedJSONParsing,i=this.responseType==="json";if(F.isResponse(e)||F.isReadableStream(e))return e;if(e&&F.isString(e)&&(n&&!this.responseType||i)){const s=!(t&&t.silentJSONParsing)&&i;try{return JSON.parse(e,this.parseReviver)}catch(a){if(s)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:we.classes.FormData,Blob:we.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};F.forEach(["delete","get","head","post","put","patch"],r=>{lt.headers[r]={}});const Qs=F.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"]),Js=r=>{const e={};let t,n,i;return r&&r.split(`
835
+ `).forEach(function(s){i=s.indexOf(":"),t=s.substring(0,i).trim().toLowerCase(),n=s.substring(i+1).trim(),!(!t||e[t]&&Qs[t])&&(t==="set-cookie"?e[t]?e[t].push(n):e[t]=[n]:e[t]=e[t]?e[t]+", "+n:n)}),e},Bn=Symbol("internals");function ct(r){return r&&String(r).trim().toLowerCase()}function kt(r){return r===!1||r==null?r:F.isArray(r)?r.map(kt):String(r)}function er(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 tr=r=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(r.trim());function Yt(r,e,t,n,i){if(F.isFunction(n))return n.call(this,e,t);if(i&&(e=t),!!F.isString(e)){if(F.isString(n))return e.indexOf(n)!==-1;if(F.isRegExp(n))return n.test(e)}}function nr(r){return r.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,n)=>t.toUpperCase()+n)}function ir(r,e){const t=F.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(r,n+t,{value:function(i,o,s){return this[n].call(this,e,i,o,s)},configurable:!0})})}let Ae=class{constructor(e){e&&this.set(e)}set(e,t,n){const i=this;function o(a,l,h){const u=ct(l);if(!u)throw new Error("header name must be a non-empty string");const f=F.findKey(i,u);(!f||i[f]===void 0||h===!0||h===void 0&&i[f]!==!1)&&(i[f||l]=kt(a))}const s=(a,l)=>F.forEach(a,(h,u)=>o(h,u,l));if(F.isPlainObject(e)||e instanceof this.constructor)s(e,t);else if(F.isString(e)&&(e=e.trim())&&!tr(e))s(Js(e),t);else if(F.isObject(e)&&F.isIterable(e)){let a={},l,h;for(const u of e){if(!F.isArray(u))throw TypeError("Object iterator must return a key-value pair");a[h=u[0]]=(l=a[h])?F.isArray(l)?[...l,u[1]]:[l,u[1]]:u[1]}s(a,t)}else e!=null&&o(t,e,n);return this}get(e,t){if(e=ct(e),e){const n=F.findKey(this,e);if(n){const i=this[n];if(!t)return i;if(t===!0)return er(i);if(F.isFunction(t))return t.call(this,i,n);if(F.isRegExp(t))return t.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=ct(e),e){const n=F.findKey(this,e);return!!(n&&this[n]!==void 0&&(!t||Yt(this,this[n],n,t)))}return!1}delete(e,t){const n=this;let i=!1;function o(s){if(s=ct(s),s){const a=F.findKey(n,s);a&&(!t||Yt(n,n[a],a,t))&&(delete n[a],i=!0)}}return F.isArray(e)?e.forEach(o):o(e),i}clear(e){const t=Object.keys(this);let n=t.length,i=!1;for(;n--;){const o=t[n];(!e||Yt(this,this[o],o,e,!0))&&(delete this[o],i=!0)}return i}normalize(e){const t=this,n={};return F.forEach(this,(i,o)=>{const s=F.findKey(n,o);if(s){t[s]=kt(i),delete t[o];return}const a=e?nr(o):String(o).trim();a!==o&&delete t[o],t[a]=kt(i),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return F.forEach(this,(n,i)=>{n!=null&&n!==!1&&(t[i]=e&&F.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(`
836
+ `)}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[Bn]=this[Bn]={accessors:{}}).accessors,i=this.prototype;function o(s){const a=ct(s);n[a]||(ir(i,s),n[a]=!0)}return F.isArray(e)?e.forEach(o):o(e),this}};Ae.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),F.reduceDescriptors(Ae.prototype,({value:r},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>r,set(n){this[t]=n}}}),F.freezeMethods(Ae);function Ht(r,e){const t=this||lt,n=e||t,i=Ae.from(n.headers);let o=n.data;return F.forEach(r,function(a){o=a.call(t,o,i.normalize(),e?e.status:void 0)}),i.normalize(),o}function In(r){return!!(r&&r.__CANCEL__)}function tt(r,e,t){re.call(this,r??"canceled",re.ERR_CANCELED,e,t),this.name="CanceledError"}F.inherits(tt,re,{__CANCEL__:!0});function Fn(r,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?r(t):e(new re("Request failed with status code "+t.status,[re.ERR_BAD_REQUEST,re.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function sr(r){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(r);return e&&e[1]||""}function rr(r,e){r=r||10;const t=new Array(r),n=new Array(r);let i=0,o=0,s;return e=e!==void 0?e:1e3,function(l){const h=Date.now(),u=n[o];s||(s=h),t[i]=l,n[i]=h;let f=o,g=0;for(;f!==i;)g+=t[f++],f=f%r;if(i=(i+1)%r,i===o&&(o=(o+1)%r),h-s<e)return;const p=u&&h-u;return p?Math.round(g*1e3/p):void 0}}function or(r,e){let t=0,n=1e3/e,i,o;const s=(h,u=Date.now())=>{t=u,i=null,o&&(clearTimeout(o),o=null),r(...h)};return[(...h)=>{const u=Date.now(),f=u-t;f>=n?s(h,u):(i=h,o||(o=setTimeout(()=>{o=null,s(i)},n-f)))},()=>i&&s(i)]}const Dt=(r,e,t=3)=>{let n=0;const i=rr(50,250);return or(o=>{const s=o.loaded,a=o.lengthComputable?o.total:void 0,l=s-n,h=i(l),u=s<=a;n=s;const f={loaded:s,total:a,progress:a?s/a:void 0,bytes:l,rate:h||void 0,estimated:h&&a&&u?(a-s)/h:void 0,event:o,lengthComputable:a!=null,[e?"download":"upload"]:!0};r(f)},t)},Un=(r,e)=>{const t=r!=null;return[n=>e[0]({lengthComputable:t,total:r,loaded:n}),e[1]]},Vn=r=>(...e)=>F.asap(()=>r(...e)),ar=we.hasStandardBrowserEnv?((r,e)=>t=>(t=new URL(t,we.origin),r.protocol===t.protocol&&r.host===t.host&&(e||r.port===t.port)))(new URL(we.origin),we.navigator&&/(msie|trident)/i.test(we.navigator.userAgent)):()=>!0,lr=we.hasStandardBrowserEnv?{write(r,e,t,n,i,o,s){if(typeof document>"u")return;const a=[`${r}=${encodeURIComponent(e)}`];F.isNumber(t)&&a.push(`expires=${new Date(t).toUTCString()}`),F.isString(n)&&a.push(`path=${n}`),F.isString(i)&&a.push(`domain=${i}`),o===!0&&a.push("secure"),F.isString(s)&&a.push(`SameSite=${s}`),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 cr(r){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(r)}function hr(r,e){return e?r.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):r}function jn(r,e,t){let n=!cr(e);return r&&(n||t==!1)?hr(r,e):e}const Gn=r=>r instanceof Ae?{...r}:r;function Ke(r,e){e=e||{};const t={};function n(h,u,f,g){return F.isPlainObject(h)&&F.isPlainObject(u)?F.merge.call({caseless:g},h,u):F.isPlainObject(u)?F.merge({},u):F.isArray(u)?u.slice():u}function i(h,u,f,g){if(F.isUndefined(u)){if(!F.isUndefined(h))return n(void 0,h,f,g)}else return n(h,u,f,g)}function o(h,u){if(!F.isUndefined(u))return n(void 0,u)}function s(h,u){if(F.isUndefined(u)){if(!F.isUndefined(h))return n(void 0,h)}else return n(void 0,u)}function a(h,u,f){if(f in e)return n(h,u);if(f in r)return n(void 0,h)}const l={url:o,method:o,data:o,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(h,u,f)=>i(Gn(h),Gn(u),f,!0)};return F.forEach(Object.keys({...r,...e}),function(u){const f=l[u]||i,g=f(r[u],e[u],u);F.isUndefined(g)&&f!==a||(t[u]=g)}),t}const Wn=r=>{const e=Ke({},r);let{data:t,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:o,headers:s,auth:a}=e;if(e.headers=s=Ae.from(s),e.url=On(jn(e.baseURL,e.url,e.allowAbsoluteUrls),r.params,r.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):""))),F.isFormData(t)){if(we.hasStandardBrowserEnv||we.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(F.isFunction(t.getHeaders)){const l=t.getHeaders(),h=["content-type","content-length"];Object.entries(l).forEach(([u,f])=>{h.includes(u.toLowerCase())&&s.set(u,f)})}}if(we.hasStandardBrowserEnv&&(n&&F.isFunction(n)&&(n=n(e)),n||n!==!1&&ar(e.url))){const l=i&&o&&lr.read(o);l&&s.set(i,l)}return e},ur=typeof XMLHttpRequest<"u"&&function(r){return new Promise(function(t,n){const i=Wn(r);let o=i.data;const s=Ae.from(i.headers).normalize();let{responseType:a,onUploadProgress:l,onDownloadProgress:h}=i,u,f,g,p,c;function d(){p&&p(),c&&c(),i.cancelToken&&i.cancelToken.unsubscribe(u),i.signal&&i.signal.removeEventListener("abort",u)}let m=new XMLHttpRequest;m.open(i.method.toUpperCase(),i.url,!0),m.timeout=i.timeout;function y(){if(!m)return;const v=Ae.from("getAllResponseHeaders"in m&&m.getAllResponseHeaders()),P={data:!a||a==="text"||a==="json"?m.responseText:m.response,status:m.status,statusText:m.statusText,headers:v,config:r,request:m};Fn(function(E){t(E),d()},function(E){n(E),d()},P),m=null}"onloadend"in m?m.onloadend=y:m.onreadystatechange=function(){!m||m.readyState!==4||m.status===0&&!(m.responseURL&&m.responseURL.indexOf("file:")===0)||setTimeout(y)},m.onabort=function(){m&&(n(new re("Request aborted",re.ECONNABORTED,r,m)),m=null)},m.onerror=function(M){const P=M&&M.message?M.message:"Network Error",D=new re(P,re.ERR_NETWORK,r,m);D.event=M||null,n(D),m=null},m.ontimeout=function(){let M=i.timeout?"timeout of "+i.timeout+"ms exceeded":"timeout exceeded";const P=i.transitional||Rn;i.timeoutErrorMessage&&(M=i.timeoutErrorMessage),n(new re(M,P.clarifyTimeoutError?re.ETIMEDOUT:re.ECONNABORTED,r,m)),m=null},o===void 0&&s.setContentType(null),"setRequestHeader"in m&&F.forEach(s.toJSON(),function(M,P){m.setRequestHeader(P,M)}),F.isUndefined(i.withCredentials)||(m.withCredentials=!!i.withCredentials),a&&a!=="json"&&(m.responseType=i.responseType),h&&([g,c]=Dt(h,!0),m.addEventListener("progress",g)),l&&m.upload&&([f,p]=Dt(l),m.upload.addEventListener("progress",f),m.upload.addEventListener("loadend",p)),(i.cancelToken||i.signal)&&(u=v=>{m&&(n(!v||v.type?new tt(null,r,m):v),m.abort(),m=null)},i.cancelToken&&i.cancelToken.subscribe(u),i.signal&&(i.signal.aborted?u():i.signal.addEventListener("abort",u)));const w=sr(i.url);if(w&&we.protocols.indexOf(w)===-1){n(new re("Unsupported protocol "+w+":",re.ERR_BAD_REQUEST,r));return}m.send(o||null)})},dr=(r,e)=>{const{length:t}=r=r?r.filter(Boolean):[];if(e||t){let n=new AbortController,i;const o=function(h){if(!i){i=!0,a();const u=h instanceof Error?h:this.reason;n.abort(u instanceof re?u:new tt(u instanceof Error?u.message:u))}};let s=e&&setTimeout(()=>{s=null,o(new re(`timeout ${e} of ms exceeded`,re.ETIMEDOUT))},e);const a=()=>{r&&(s&&clearTimeout(s),s=null,r.forEach(h=>{h.unsubscribe?h.unsubscribe(o):h.removeEventListener("abort",o)}),r=null)};r.forEach(h=>h.addEventListener("abort",o));const{signal:l}=n;return l.unsubscribe=()=>F.asap(a),l}},fr=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},pr=async function*(r,e){for await(const t of mr(r))yield*fr(t,e)},mr=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()}},Kn=(r,e,t,n)=>{const i=pr(r,e);let o=0,s,a=l=>{s||(s=!0,n&&n(l))};return new ReadableStream({async pull(l){try{const{done:h,value:u}=await i.next();if(h){a(),l.close();return}let f=u.byteLength;if(t){let g=o+=f;t(g)}l.enqueue(new Uint8Array(u))}catch(h){throw a(h),h}},cancel(l){return a(l),i.return()}},{highWaterMark:2})},Xn=64*1024,{isFunction:Et}=F,gr=(({Request:r,Response:e})=>({Request:r,Response:e}))(F.global),{ReadableStream:Zn,TextEncoder:qn}=F.global,Yn=(r,...e)=>{try{return!!r(...e)}catch{return!1}},yr=r=>{r=F.merge.call({skipUndefined:!0},gr,r);const{fetch:e,Request:t,Response:n}=r,i=e?Et(e):typeof fetch=="function",o=Et(t),s=Et(n);if(!i)return!1;const a=i&&Et(Zn),l=i&&(typeof qn=="function"?(c=>d=>c.encode(d))(new qn):async c=>new Uint8Array(await new t(c).arrayBuffer())),h=o&&a&&Yn(()=>{let c=!1;const d=new t(we.origin,{body:new Zn,method:"POST",get duplex(){return c=!0,"half"}}).headers.has("Content-Type");return c&&!d}),u=s&&a&&Yn(()=>F.isReadableStream(new n("").body)),f={stream:u&&(c=>c.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(c=>{!f[c]&&(f[c]=(d,m)=>{let y=d&&d[c];if(y)return y.call(d);throw new re(`Response type '${c}' is not supported`,re.ERR_NOT_SUPPORT,m)})});const g=async c=>{if(c==null)return 0;if(F.isBlob(c))return c.size;if(F.isSpecCompliantForm(c))return(await new t(we.origin,{method:"POST",body:c}).arrayBuffer()).byteLength;if(F.isArrayBufferView(c)||F.isArrayBuffer(c))return c.byteLength;if(F.isURLSearchParams(c)&&(c=c+""),F.isString(c))return(await l(c)).byteLength},p=async(c,d)=>{const m=F.toFiniteNumber(c.getContentLength());return m??g(d)};return async c=>{let{url:d,method:m,data:y,signal:w,cancelToken:v,timeout:M,onDownloadProgress:P,onUploadProgress:D,responseType:E,headers:O,withCredentials:k="same-origin",fetchOptions:I}=Wn(c),W=e||fetch;E=E?(E+"").toLowerCase():"text";let T=dr([w,v&&v.toAbortSignal()],M),B=null;const b=T&&T.unsubscribe&&(()=>{T.unsubscribe()});let V;try{if(D&&h&&m!=="get"&&m!=="head"&&(V=await p(O,y))!==0){let z=new t(d,{method:"POST",body:y,duplex:"half"}),N;if(F.isFormData(y)&&(N=z.headers.get("content-type"))&&O.setContentType(N),z.body){const[te,$]=Un(V,Dt(Vn(D)));y=Kn(z.body,Xn,te,$)}}F.isString(k)||(k=k?"include":"omit");const J=o&&"credentials"in t.prototype,X={...I,signal:T,method:m.toUpperCase(),headers:O.normalize().toJSON(),body:y,duplex:"half",credentials:J?k:void 0};B=o&&new t(d,X);let ee=await(o?W(B,I):W(d,X));const j=u&&(E==="stream"||E==="response");if(u&&(P||j&&b)){const z={};["status","statusText","headers"].forEach(H=>{z[H]=ee[H]});const N=F.toFiniteNumber(ee.headers.get("content-length")),[te,$]=P&&Un(N,Dt(Vn(P),!0))||[];ee=new n(Kn(ee.body,Xn,te,()=>{$&&$(),b&&b()}),z)}E=E||"text";let ne=await f[F.findKey(f,E)||"text"](ee,c);return!j&&b&&b(),await new Promise((z,N)=>{Fn(z,N,{data:ne,headers:Ae.from(ee.headers),status:ee.status,statusText:ee.statusText,config:c,request:B})})}catch(J){throw b&&b(),J&&J.name==="TypeError"&&/Load failed|fetch/i.test(J.message)?Object.assign(new re("Network Error",re.ERR_NETWORK,c,B),{cause:J.cause||J}):re.from(J,J&&J.code,c,B)}}},_r=new Map,Hn=r=>{let e=r&&r.env||{};const{fetch:t,Request:n,Response:i}=e,o=[n,i,t];let s=o.length,a=s,l,h,u=_r;for(;a--;)l=o[a],h=u.get(l),h===void 0&&u.set(l,h=a?new Map:yr(e)),u=h;return h};Hn();const $t={http:Us,xhr:ur,fetch:{get:Hn}};F.forEach($t,(r,e)=>{if(r){try{Object.defineProperty(r,"name",{value:e})}catch{}Object.defineProperty(r,"adapterName",{value:e})}});const $n=r=>`- ${r}`,wr=r=>F.isFunction(r)||r===null||r===!1;function br(r,e){r=F.isArray(r)?r:[r];const{length:t}=r;let n,i;const o={};for(let s=0;s<t;s++){n=r[s];let a;if(i=n,!wr(n)&&(i=$t[(a=String(n)).toLowerCase()],i===void 0))throw new re(`Unknown adapter '${a}'`);if(i&&(F.isFunction(i)||(i=i.get(e))))break;o[a||"#"+s]=i}if(!i){const s=Object.entries(o).map(([l,h])=>`adapter ${l} `+(h===!1?"is not supported by the environment":"is not available in the build"));let a=t?s.length>1?`since :
837
+ `+s.map($n).join(`
838
+ `):" "+$n(s[0]):"as no adapter specified";throw new re("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return i}const Qn={getAdapter:br,adapters:$t};function Qt(r){if(r.cancelToken&&r.cancelToken.throwIfRequested(),r.signal&&r.signal.aborted)throw new tt(null,r)}function Jn(r){return Qt(r),r.headers=Ae.from(r.headers),r.data=Ht.call(r,r.transformRequest),["post","put","patch"].indexOf(r.method)!==-1&&r.headers.setContentType("application/x-www-form-urlencoded",!1),Qn.getAdapter(r.adapter||lt.adapter,r)(r).then(function(n){return Qt(r),n.data=Ht.call(r,r.transformResponse,n),n.headers=Ae.from(n.headers),n},function(n){return In(n)||(Qt(r),n&&n.response&&(n.response.data=Ht.call(r,r.transformResponse,n.response),n.response.headers=Ae.from(n.response.headers))),Promise.reject(n)})}const ei="1.13.2",Lt={};["object","boolean","number","function","string","symbol"].forEach((r,e)=>{Lt[r]=function(n){return typeof n===r||"a"+(e<1?"n ":" ")+r}});const ti={};Lt.transitional=function(e,t,n){function i(o,s){return"[Axios v"+ei+"] Transitional option '"+o+"'"+s+(n?". "+n:"")}return(o,s,a)=>{if(e===!1)throw new re(i(s," has been removed"+(t?" in "+t:"")),re.ERR_DEPRECATED);return t&&!ti[s]&&(ti[s]=!0,console.warn(i(s," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(o,s,a):!0}},Lt.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function xr(r,e,t){if(typeof r!="object")throw new re("options must be an object",re.ERR_BAD_OPTION_VALUE);const n=Object.keys(r);let i=n.length;for(;i-- >0;){const o=n[i],s=e[o];if(s){const a=r[o],l=a===void 0||s(a,o,r);if(l!==!0)throw new re("option "+o+" must be "+l,re.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new re("Unknown option "+o,re.ERR_BAD_OPTION)}}const Ot={assertOptions:xr,validators:Lt},Le=Ot.validators;let Xe=class{constructor(e){this.defaults=e||{},this.interceptors={request:new Nn,response:new Nn}}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 o=i.stack?i.stack.replace(/^.+\n/,""):"";try{n.stack?o&&!String(n.stack).endsWith(o.replace(/^.+\n.+\n/,""))&&(n.stack+=`
839
+ `+o):n.stack=o}catch{}}throw n}}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Ke(this.defaults,t);const{transitional:n,paramsSerializer:i,headers:o}=t;n!==void 0&&Ot.assertOptions(n,{silentJSONParsing:Le.transitional(Le.boolean),forcedJSONParsing:Le.transitional(Le.boolean),clarifyTimeoutError:Le.transitional(Le.boolean)},!1),i!=null&&(F.isFunction(i)?t.paramsSerializer={serialize:i}:Ot.assertOptions(i,{encode:Le.function,serialize:Le.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Ot.assertOptions(t,{baseUrl:Le.spelling("baseURL"),withXsrfToken:Le.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let s=o&&F.merge(o.common,o[t.method]);o&&F.forEach(["delete","get","head","post","put","patch","common"],c=>{delete o[c]}),t.headers=Ae.concat(s,o);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 h=[];this.interceptors.response.forEach(function(d){h.push(d.fulfilled,d.rejected)});let u,f=0,g;if(!l){const c=[Jn.bind(this),void 0];for(c.unshift(...a),c.push(...h),g=c.length,u=Promise.resolve(t);f<g;)u=u.then(c[f++],c[f++]);return u}g=a.length;let p=t;for(;f<g;){const c=a[f++],d=a[f++];try{p=c(p)}catch(m){d.call(this,m);break}}try{u=Jn.call(this,p)}catch(c){return Promise.reject(c)}for(f=0,g=h.length;f<g;)u=u.then(h[f++],h[f++]);return u}getUri(e){e=Ke(this.defaults,e);const t=jn(e.baseURL,e.url,e.allowAbsoluteUrls);return On(t,e.params,e.paramsSerializer)}};F.forEach(["delete","get","head","options"],function(e){Xe.prototype[e]=function(t,n){return this.request(Ke(n||{},{method:e,url:t,data:(n||{}).data}))}}),F.forEach(["post","put","patch"],function(e){function t(n){return function(o,s,a){return this.request(Ke(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:o,data:s}))}}Xe.prototype[e]=t(),Xe.prototype[e+"Form"]=t(!0)});let vr=class yi{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(o){t=o});const n=this;this.promise.then(i=>{if(!n._listeners)return;let o=n._listeners.length;for(;o-- >0;)n._listeners[o](i);n._listeners=null}),this.promise.then=i=>{let o;const s=new Promise(a=>{n.subscribe(a),o=a}).then(i);return s.cancel=function(){n.unsubscribe(o)},s},e(function(o,s,a){n.reason||(n.reason=new tt(o,s,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 yi(function(i){e=i}),cancel:e}}};function Sr(r){return function(t){return r.apply(null,t)}}function Mr(r){return F.isObject(r)&&r.isAxiosError===!0}const Jt={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(Jt).forEach(([r,e])=>{Jt[e]=r});function ni(r){const e=new Xe(r),t=_n(Xe.prototype.request,e);return F.extend(t,Xe.prototype,e,{allOwnKeys:!0}),F.extend(t,e,null,{allOwnKeys:!0}),t.create=function(i){return ni(Ke(r,i))},t}const ge=ni(lt);ge.Axios=Xe,ge.CanceledError=tt,ge.CancelToken=vr,ge.isCancel=In,ge.VERSION=ei,ge.toFormData=Pt,ge.AxiosError=re,ge.Cancel=ge.CanceledError,ge.all=function(e){return Promise.all(e)},ge.spread=Sr,ge.isAxiosError=Mr,ge.mergeConfig=Ke,ge.AxiosHeaders=Ae,ge.formToJSON=r=>zn(F.isHTMLForm(r)?new FormData(r):r),ge.getAdapter=Qn.getAdapter,ge.HttpStatusCode=Jt,ge.default=ge;const{Axios:ca,AxiosError:ha,CanceledError:ua,isCancel:da,CancelToken:fa,VERSION:pa,all:ma,Cancel:ga,isAxiosError:ya,spread:_a,toFormData:wa,AxiosHeaders:ba,HttpStatusCode:xa,formToJSON:va,getAdapter:Sa,mergeConfig:Ma}=ge;function Ar(r,e){var t;if(window.XMLHttpRequest?t=new XMLHttpRequest:window.ActiveXObject?t=new window.ActiveXObject:alert("请升级至最新版本的浏览器"),t!=null){let n=r+"?timestamp="+new Date().getTime();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 ii(r,e){ge({method:"get",responseType:"blob",url:r+"?timestamp="+new Date().getTime()}).then(n=>{let i=new window.File([n.data],"semantics",{type:"zip"});ts.loadAsync(i).then(o=>{for(let s in o.files)o.file(o.files[s].name).async("blob").then(l=>{t(l,"utf-8",function(h,u){e(u)})})})});function t(n,i,o){var s=new FileReader,a=new Blob([n]);s.onload=function(l){o(null,l.target.result)},s.onerror=function(l){o(l.error,null)},s.readAsText(a,i)}}const en=new WeakMap;class Tr extends S.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,i){const o=new S.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,s=>{this.parse(s,t,i)},n,i)}parse(e,t,n=()=>{}){this.decodeDracoFile(e,t,null,null,S.SRGBColorSpace,n).catch(n)}decodeDracoFile(e,t,n,i,o=S.LinearSRGBColorSpace,s=()=>{}){const a={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!n,vertexColorSpace:o};return this.decodeGeometry(e,a).then(t).catch(s)}decodeGeometry(e,t){const n=JSON.stringify(t);if(en.has(e)){const l=en.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 o=this.workerNextTaskID++,s=e.byteLength,a=this._getWorker(o,s).then(l=>(i=l,new Promise((h,u)=>{i._callbacks[o]={resolve:h,reject:u},i.postMessage({type:"decode",id:o,taskConfig:t,buffer:e},[e])}))).then(l=>this._createGeometry(l.geometry));return a.catch(()=>!0).then(()=>{i&&o&&this._releaseTask(i,o)}),en.set(e,{key:n,promise:a}),a}_createGeometry(e){const t=new S.BufferGeometry;e.index&&t.setIndex(new S.BufferAttribute(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const{name:i,array:o,itemSize:s,stride:a,vertexColorSpace:l}=e.attributes[n];let h;if(s===a)h=new S.BufferAttribute(o,s);else{const u=new S.InterleavedBuffer(o,a);h=new S.InterleavedBufferAttribute(u,s,0)}i==="color"&&(this._assignVertexColorSpace(h,l),h.normalized=!(o instanceof Float32Array)),t.setAttribute(i,h)}return t}_assignVertexColorSpace(e,t){if(t!==S.SRGBColorSpace)return;const n=new S.Color;for(let i=0,o=e.count;i<o;i++)n.fromBufferAttribute(e,i),S.ColorManagement.colorSpaceToWorking(n,S.SRGBColorSpace),e.setXYZ(i,n.r,n.g,n.b)}_loadLibrary(e,t){const n=new S.FileLoader(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise((i,o)=>{n.load(e,i,void 0,o)})}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 o=Cr.toString(),s=["/* draco decoder */",i,"","/* worker */",o.substring(o.indexOf("{")+1,o.lastIndexOf("}"))].join(`
840
+ `);this.workerSourceURL=URL.createObjectURL(new Blob([s]))}),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(o){const s=o.data;switch(s.type){case"decode":i._callbacks[s.id].resolve(s);break;case"error":i._callbacks[s.id].reject(s);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+s.type+'"')}},this.workerPool.push(i)}else this.workerPool.sort(function(i,o){return i._taskLoad>o._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 Cr(){let r,e;onmessage=function(s){const a=s.data;switch(a.type){case"init":r=a.decoderConfig,e=new Promise(function(u){r.onModuleLoaded=function(f){u({draco:f})},DracoDecoderModule(r)});break;case"decode":const l=a.buffer,h=a.taskConfig;e.then(u=>{const f=u.draco,g=new f.Decoder;try{const p=t(f,g,new Int8Array(l),h),c=p.attributes.map(d=>d.array.buffer);p.index&&c.push(p.index.array.buffer),self.postMessage({type:"decode",id:a.id,geometry:p},c)}catch(p){console.error(p),self.postMessage({type:"error",id:a.id,error:p.message})}finally{f.destroy(g)}});break}};function t(s,a,l,h){const u=h.attributeIDs,f=h.attributeTypes;let g,p;const c=a.GetEncodedGeometryType(l);if(c===s.TRIANGULAR_MESH)g=new s.Mesh,p=a.DecodeArrayToMesh(l,l.byteLength,g);else if(c===s.POINT_CLOUD)g=new s.PointCloud,p=a.DecodeArrayToPointCloud(l,l.byteLength,g);else throw new Error("THREE.DRACOLoader: Unexpected geometry type.");if(!p.ok()||g.ptr===0)throw new Error("THREE.DRACOLoader: Decoding failed: "+p.error_msg());const d={index:null,attributes:[]};for(const m in u){const y=self[f[m]];let w,v;if(h.useUniqueIDs)v=u[m],w=a.GetAttributeByUniqueId(g,v);else{if(v=a.GetAttributeId(g,s[u[m]]),v===-1)continue;w=a.GetAttribute(g,v)}const M=i(s,a,g,m,y,w);m==="color"&&(M.vertexColorSpace=h.vertexColorSpace),d.attributes.push(M)}return c===s.TRIANGULAR_MESH&&(d.index=n(s,a,g)),s.destroy(g),d}function n(s,a,l){const u=l.num_faces()*3,f=u*4,g=s._malloc(f);a.GetTrianglesUInt32Array(l,f,g);const p=new Uint32Array(s.HEAPF32.buffer,g,u).slice();return s._free(g),{array:p,itemSize:1}}function i(s,a,l,h,u,f){const g=l.num_points(),p=f.num_components(),c=o(s,u),d=p*u.BYTES_PER_ELEMENT,m=Math.ceil(d/4)*4,y=m/u.BYTES_PER_ELEMENT,w=g*d,v=g*m,M=s._malloc(w);a.GetAttributeDataArrayForAllPoints(l,f,c,w,M);const P=new u(s.HEAPF32.buffer,M,w/u.BYTES_PER_ELEMENT);let D;if(d===m)D=P.slice();else{D=new u(v/u.BYTES_PER_ELEMENT);let E=0;for(let O=0,k=P.length;O<k;O++){for(let I=0;I<p;I++)D[E+I]=P[O*p+I];E+=y}}return s._free(M),{name:h,count:g,itemSize:p,array:D,stride:y}}function o(s,a){switch(a){case Float32Array:return s.DT_FLOAT32;case Int8Array:return s.DT_INT8;case Int16Array:return s.DT_INT16;case Int32Array:return s.DT_INT32;case Uint8Array:return s.DT_UINT8;case Uint16Array:return s.DT_UINT16;case Uint32Array:return s.DT_UINT32}}}var ht=(r=>(r.ModelLoadStart="model-load-start",r.ModelLoadProgress="model-load-progress",r.ModelLoaded="model-loaded",r.ModelError="model-error",r.SelectionChanged="selection-changed",r.HoverChanged="hover-changed",r.Click="click",r.MouseMove="mouse-move",r.CameraChanged="camera-changed",r.CameraIdle="camera-idle",r.EngineFree="engine-free",r.EngineBusy="engine-busy",r))(ht||{});function Pr(r,e,t,n){let i=0,o=0,s=0,a=r.models.find(p=>p.url==t),l=e.circularMeps,h=e.rectMeps.filter(p=>p.type==="风管"),u=e.rectMeps.filter(p=>p.type==="桥架"),f=e.ellipseMeps,g=r.scene;if(new x.MeshBasicMaterial,new x.BufferGeometry,Nt(g,"InstancedMesh"),l&&l.length){let p=[];for(let c of l)c.color=new x.Color(`rgb(${c.color})`),c.position={x:c.startPoint.X*.3048+i,y:c.startPoint.Z*.3048+o,z:-c.startPoint.Y*.3048+s},c.rotation={x:0,y:0,z:0},a.nodesMap.set(c.id,[c]),p.push(c);Rt("Circle",g,p,2)}if(Nt(g,"InstancedMesh"),h&&h.length){let p=[];for(let c of h)c.color=new x.Color(`rgb(${c.color})`),c.position={x:c.startPoint.X*.3048+i,y:c.startPoint.Z*.3048+o,z:-c.startPoint.Y*.3048+s},c.rotation={x:0,y:0,z:0},a.nodesMap.set(c.id,[c]),p.push(c);Rt("Rect",g,p,3)}if(Nt(g,"InstancedMesh"),f&&f.length){let p=[];for(let c of f)c.color=new x.Color(`rgb(${c.color})`),c.position={x:c.startPoint.X*.3048+i,y:c.startPoint.Z*.3048+o,z:-c.startPoint.Y*.3048+s},c.rotation={x:0,y:0,z:0},a.nodesMap.set(c.id,[c]),p.push(c);Rt("Ellipse",g,p,4)}if(Nt(g,"InstancedMesh"),u&&u.length){let p=[];for(let c of u)c.color=new x.Color(`rgb(${c.color})`),c.position={x:c.startPoint.X*.3048+i,y:c.startPoint.Z*.3048+o,z:-c.startPoint.Y*.3048+s},c.rotation={x:0,y:0,z:0},a.nodesMap.set(c.id,[c]),p.push(c);Rt("Bridge",g,p,5)}}function Nt(r,e){let t=new x.InstancedMesh(e.geometry,e.material,1);t.index=e.index,t.dataType=e.type,t.url=e.url,t.relativeIndex=e.relativeIndex,t.name="机电",r.add(t)}function Rt(r,e,t,n,i){let o,s,a={width:1,height:1,length:1,diameter:1,color:new x.Color,position:{x:0,y:0,z:0},rotation:{x:0,y:0,z:0}};switch(r){case"Rect":s=zt("Rect",a);break;case"Bridge":s=zt("Bridge",a);break;case"Circle":s=zt("Circle",a);break;case"Ellipse":s=zt("Ellipse",a);break}s&&(o=new x.InstancedMesh(s.geometry,s.material,t.length));let l=[];for(var h=0;h<t.length;h++){let g=t[h],p=new x.Vector3(g.startPoint.X,0,-g.startPoint.Y),c=new x.Vector3(g.endPoint.X,0,-g.endPoint.Y),d=new x.Vector3(g.startPoint.X,g.startPoint.Z,-g.startPoint.Y),m=new x.Vector3(g.endPoint.X,g.endPoint.Z,-g.endPoint.Y),y=0,w=0,v=0;if(Math.abs(c.clone().sub(p.clone()).z)<.01&&Math.abs(c.clone().sub(p.clone()).x)<.01){if(y=(g.startPoint.Z>g.endPoint.Z?1:-1)*Math.PI*.5,g.base_x!=null){var u=new x.Vector3(g.base_x.X,0,-g.base_x.Y);w=(u.clone().cross(new x.Vector3(0,0,1)).y<=0?1:-1)*u.angleTo(new x.Vector3(0,0,1))+Math.PI*.5}}else w=(c.clone().sub(p.clone()).cross(new x.Vector3(0,0,1)).y>0?-1:1)*c.clone().sub(p.clone()).angleTo(new x.Vector3(0,0,1)),y=(g.startPoint.Z>g.endPoint.Z?1:-1)*c.clone().sub(p.clone()).angleTo(m.clone().sub(d.clone()));let M=new x.Matrix4;const P=new x.Euler(y,w,v,"YXZ");let D=M.clone().makeRotationFromEuler(P),E,O;r==="Circle"?(E=g.diameter,O=g.diameter):(E=g.width,O=g.height);let k=M.clone().makeScale(E,O,g.length);M.multiplyMatrices(D,k),M.setPosition(g.position.x,g.position.y,g.position.z),o.setMatrixAt(h,M.clone()),o.setColorAt(h,g.color),o.geometry.computeBoundingBox();let I=o.geometry.boundingBox.min.clone().applyMatrix4(M.clone()),W=o.geometry.boundingBox.max.clone().applyMatrix4(M.clone()),T=new x.Vector3(Math.min(I.x,W.x),Math.min(I.y,W.y),Math.min(I.z,W.z)),B=new x.Vector3(Math.max(I.x,W.x),Math.max(I.y,W.y),Math.max(I.z,W.z)),b=T.clone().add(B.clone()).multiplyScalar(.5),V={name:g.name,min:T,max:B,center:b,dbid:h,materialName:s.material.name},J=null,X=null;r==="Circle"&&(J={x:g.startPoint.X*.3048,y:g.startPoint.Z*.3048,z:-g.startPoint.Y*.3048},X={x:g.endPoint.X*.3048,y:g.endPoint.Z*.3048,z:-g.endPoint.Y*.3048},V.minC=J,V.maxC=X),l.push(V)}o.castShadow=!0,o.ElementInfos=l,o.name="rootModel",o.TypeName="InstancedMesh-Pipe",o.PipeType=r,o.MeshId=null,o.realMaterial=o.material.clone(),o.originalMaterial=o.material.clone();let f=[];f={geometry:o.geometry,matrix:o.matrix,position:o.position,rotation:o.rotation},o.meshs=f,o.instanceMatrix&&o.instanceMatrix.array&&(o.cloneInstanceMatrix=Array.from(o.instanceMatrix.array)),o.index=n,o.Version="V1",e.children[n]=o}function zt(r,e,t){let n=new x.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 o(n,i,e.color,e.position,e.rotation);function o(s,a,l,h,u){let f=new x.ExtrudeGeometry(s,a),g=new x.MeshPhongMaterial({color:l,side:x.DoubleSide}),p=new x.Mesh(f,g);return p.position.set(h.x,h.y,h.z),p.rotation._order="YXZ",p.rotation.set(u.x,u.y,u.z),p}}function kr(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)),o={},s={},a=r[0].morphTargetsRelative,l=new S.BufferGeometry;let h=0;for(let u=0;u<r.length;++u){const f=r[u];let g=0;if(t!==(f.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const p in f.attributes){if(!n.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+'. All geometries must have compatible attributes; make sure "'+p+'" attribute exists among all geometries, or in none of them.'),null;o[p]===void 0&&(o[p]=[]),o[p].push(f.attributes[p]),g++}if(g!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". Make sure all geometries have the same number of attributes."),null;if(a!==f.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const p in f.morphAttributes){if(!i.has(p))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". .morphAttributes must be consistent throughout all geometries."),null;s[p]===void 0&&(s[p]=[]),s[p].push(f.morphAttributes[p])}if(e){let p;if(t)p=f.index.count;else if(f.attributes.position!==void 0)p=f.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+u+". The geometry must have either an index or a position attribute"),null;l.addGroup(h,p,u),h+=p}}if(t){let u=0;const f=[];for(let g=0;g<r.length;++g){const p=r[g].index;for(let c=0;c<p.count;++c)f.push(p.getX(c)+u);u+=r[g].attributes.position.count}l.setIndex(f)}for(const u in o){const f=si(o[u]);if(!f)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" attribute."),null;l.setAttribute(u,f)}for(const u in s){const f=s[u][0].length;if(f===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[u]=[];for(let g=0;g<f;++g){const p=[];for(let d=0;d<s[u].length;++d)p.push(s[u][d][g]);const c=si(p);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+u+" morphAttribute."),null;l.morphAttributes[u].push(c)}}return l}function si(r){let e,t,n,i=-1,o=0;for(let h=0;h<r.length;++h){const u=r[h];if(e===void 0&&(e=u.array.constructor),e!==u.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=u.itemSize),t!==u.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(n===void 0&&(n=u.normalized),n!==u.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=u.gpuType),i!==u.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;o+=u.count*t}const s=new e(o),a=new S.BufferAttribute(s,t,n);let l=0;for(let h=0;h<r.length;++h){const u=r[h];if(u.isInterleavedBufferAttribute){const f=l/t;for(let g=0,p=u.count;g<p;g++)for(let c=0;c<t;c++){const d=u.getComponent(g,c);a.setComponent(g+f,c,d)}}else s.set(u.array,l);l+=u.count*t}return i!==void 0&&(a.gpuType=i),a}function ri(r,e){if(e===S.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),r;if(e===S.TriangleFanDrawMode||e===S.TriangleStripDrawMode){let t=r.getIndex();if(t===null){const s=[],a=r.getAttribute("position");if(a!==void 0){for(let l=0;l<a.count;l++)s.push(l);r.setIndex(s),t=r.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),r}const n=t.count-2,i=[];if(e===S.TriangleFanDrawMode)for(let s=1;s<=n;s++)i.push(t.getX(0)),i.push(t.getX(s)),i.push(t.getX(s+1));else for(let s=0;s<n;s++)s%2===0?(i.push(t.getX(s)),i.push(t.getX(s+1)),i.push(t.getX(s+2))):(i.push(t.getX(s+2)),i.push(t.getX(s+1)),i.push(t.getX(s)));i.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=r.clone();return o.setIndex(i),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),r}class Dr extends S.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(t){return new Rr(t)}),this.register(function(t){return new zr(t)}),this.register(function(t){return new Kr(t)}),this.register(function(t){return new Xr(t)}),this.register(function(t){return new Zr(t)}),this.register(function(t){return new Ir(t)}),this.register(function(t){return new Fr(t)}),this.register(function(t){return new Ur(t)}),this.register(function(t){return new Vr(t)}),this.register(function(t){return new Nr(t)}),this.register(function(t){return new jr(t)}),this.register(function(t){return new Br(t)}),this.register(function(t){return new Wr(t)}),this.register(function(t){return new Gr(t)}),this.register(function(t){return new Lr(t)}),this.register(function(t){return new qr(t)}),this.register(function(t){return new Yr(t)})}load(e,t,n,i){const o=this;let s;if(this.resourcePath!=="")s=this.resourcePath;else if(this.path!==""){const h=S.LoaderUtils.extractUrlBase(e);s=S.LoaderUtils.resolveURL(h,this.path)}else s=S.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const a=function(h){i?i(h):console.error(h),o.manager.itemError(e),o.manager.itemEnd(e)},l=new S.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(h){try{o.parse(h,s,function(u){t(u),o.manager.itemEnd(e)},a)}catch(u){a(u)}},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 o;const s={},a={},l=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(l.decode(new Uint8Array(e,0,4))===oi){try{s[le.KHR_BINARY_GLTF]=new Hr(e)}catch(f){i&&i(f);return}o=JSON.parse(s[le.KHR_BINARY_GLTF].content)}else o=JSON.parse(l.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){i&&i(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const h=new co(o,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});h.fileLoader.setRequestHeader(this.requestHeader);for(let u=0;u<this.pluginCallbacks.length;u++){const f=this.pluginCallbacks[u](h);f.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),a[f.name]=f,s[f.name]=!0}if(o.extensionsUsed)for(let u=0;u<o.extensionsUsed.length;++u){const f=o.extensionsUsed[u],g=o.extensionsRequired||[];switch(f){case le.KHR_MATERIALS_UNLIT:s[f]=new Or;break;case le.KHR_DRACO_MESH_COMPRESSION:s[f]=new $r(o,this.dracoLoader);break;case le.KHR_TEXTURE_TRANSFORM:s[f]=new Qr;break;case le.KHR_MESH_QUANTIZATION:s[f]=new Jr;break;default:g.indexOf(f)>=0&&a[f]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+f+'".')}}h.setExtensions(s),h.setPlugins(a),h.parse(n,i)}parseAsync(e,t){const n=this;return new Promise(function(i,o){n.parse(e,t,i,o)})}}function Er(){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 Lr{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 o=t[n];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let i=t.cache.get(n);if(i)return i;const o=t.json,l=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let h;const u=new S.Color(16777215);l.color!==void 0&&u.setRGB(l.color[0],l.color[1],l.color[2],S.LinearSRGBColorSpace);const f=l.range!==void 0?l.range:0;switch(l.type){case"directional":h=new S.DirectionalLight(u),h.target.position.set(0,0,-1),h.add(h.target);break;case"point":h=new S.PointLight(u),h.distance=f;break;case"spot":h=new S.SpotLight(u),h.distance=f,l.spot=l.spot||{},l.spot.innerConeAngle=l.spot.innerConeAngle!==void 0?l.spot.innerConeAngle:0,l.spot.outerConeAngle=l.spot.outerConeAngle!==void 0?l.spot.outerConeAngle:Math.PI/4,h.angle=l.spot.outerConeAngle,h.penumbra=1-l.spot.innerConeAngle/l.spot.outerConeAngle,h.target.position.set(0,0,-1),h.add(h.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+l.type)}return h.position.set(0,0,0),Oe(h,l),l.intensity!==void 0&&(h.intensity=l.intensity),h.name=t.createUniqueName(l.name||"light_"+e),i=Promise.resolve(h),t.cache.add(n,i),i}getDependency(e,t){if(e==="light")return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,o=n.json.nodes[e],a=(o.extensions&&o.extensions[this.name]||{}).light;return a===void 0?null:this._loadLight(a).then(function(l){return n._getNodeRef(t.cache,a,l)})}}class Or{constructor(){this.name=le.KHR_MATERIALS_UNLIT}getMaterialType(){return S.MeshBasicMaterial}extendParams(e,t,n){const i=[];e.color=new S.Color(1,1,1),e.opacity=1;const o=t.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const s=o.baseColorFactor;e.color.setRGB(s[0],s[1],s[2],S.LinearSRGBColorSpace),e.opacity=s[3]}o.baseColorTexture!==void 0&&i.push(n.assignTexture(e,"map",o.baseColorTexture,S.SRGBColorSpace))}return Promise.all(i)}}class Nr{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 o=i.extensions[this.name].emissiveStrength;return o!==void 0&&(t.emissiveIntensity=o),Promise.resolve()}}class Rr{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],s=i.extensions[this.name];if(s.clearcoatFactor!==void 0&&(t.clearcoat=s.clearcoatFactor),s.clearcoatTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),s.clearcoatRoughnessFactor!==void 0&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),s.clearcoatRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),s.clearcoatNormalTexture!==void 0&&(o.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),s.clearcoatNormalTexture.scale!==void 0)){const a=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new S.Vector2(a,a)}return Promise.all(o)}}class zr{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_DISPERSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=i.extensions[this.name];return t.dispersion=o.dispersion!==void 0?o.dispersion:0,Promise.resolve()}}class Br{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],s=i.extensions[this.name];return s.iridescenceFactor!==void 0&&(t.iridescence=s.iridescenceFactor),s.iridescenceTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceMap",s.iridescenceTexture)),s.iridescenceIor!==void 0&&(t.iridescenceIOR=s.iridescenceIor),t.iridescenceThicknessRange===void 0&&(t.iridescenceThicknessRange=[100,400]),s.iridescenceThicknessMinimum!==void 0&&(t.iridescenceThicknessRange[0]=s.iridescenceThicknessMinimum),s.iridescenceThicknessMaximum!==void 0&&(t.iridescenceThicknessRange[1]=s.iridescenceThicknessMaximum),s.iridescenceThicknessTexture!==void 0&&o.push(n.assignTexture(t,"iridescenceThicknessMap",s.iridescenceThicknessTexture)),Promise.all(o)}}class Ir{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SHEEN}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[];t.sheenColor=new S.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=i.extensions[this.name];if(s.sheenColorFactor!==void 0){const a=s.sheenColorFactor;t.sheenColor.setRGB(a[0],a[1],a[2],S.LinearSRGBColorSpace)}return s.sheenRoughnessFactor!==void 0&&(t.sheenRoughness=s.sheenRoughnessFactor),s.sheenColorTexture!==void 0&&o.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,S.SRGBColorSpace)),s.sheenRoughnessTexture!==void 0&&o.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(o)}}class Fr{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],s=i.extensions[this.name];return s.transmissionFactor!==void 0&&(t.transmission=s.transmissionFactor),s.transmissionTexture!==void 0&&o.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(o)}}class Ur{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_VOLUME}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],s=i.extensions[this.name];t.thickness=s.thicknessFactor!==void 0?s.thicknessFactor:0,s.thicknessTexture!==void 0&&o.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;const a=s.attenuationColor||[1,1,1];return t.attenuationColor=new S.Color().setRGB(a[0],a[1],a[2],S.LinearSRGBColorSpace),Promise.all(o)}}class Vr{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_IOR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const i=this.parser.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=i.extensions[this.name];return t.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class jr{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_SPECULAR}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],s=i.extensions[this.name];t.specularIntensity=s.specularFactor!==void 0?s.specularFactor:1,s.specularTexture!==void 0&&o.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const a=s.specularColorFactor||[1,1,1];return t.specularColor=new S.Color().setRGB(a[0],a[1],a[2],S.LinearSRGBColorSpace),s.specularColorTexture!==void 0&&o.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,S.SRGBColorSpace)),Promise.all(o)}}class Gr{constructor(e){this.parser=e,this.name=le.EXT_MATERIALS_BUMP}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],s=i.extensions[this.name];return t.bumpScale=s.bumpFactor!==void 0?s.bumpFactor:1,s.bumpTexture!==void 0&&o.push(n.assignTexture(t,"bumpMap",s.bumpTexture)),Promise.all(o)}}class Wr{constructor(e){this.parser=e,this.name=le.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const n=this.parser.json.materials[e];return!n.extensions||!n.extensions[this.name]?null:S.MeshPhysicalMaterial}extendMaterialParams(e,t){const n=this.parser,i=n.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const o=[],s=i.extensions[this.name];return s.anisotropyStrength!==void 0&&(t.anisotropy=s.anisotropyStrength),s.anisotropyRotation!==void 0&&(t.anisotropyRotation=s.anisotropyRotation),s.anisotropyTexture!==void 0&&o.push(n.assignTexture(t,"anisotropyMap",s.anisotropyTexture)),Promise.all(o)}}class Kr{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 o=i.extensions[this.name],s=t.options.ktx2Loader;if(!s){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,o.source,s)}}class Xr{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,i=n.json,o=i.textures[e];if(!o.extensions||!o.extensions[t])return null;const s=o.extensions[t],a=i.images[s.source];let l=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(l=h)}return n.loadTextureImage(e,s.source,l)}}class Zr{constructor(e){this.parser=e,this.name=le.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,i=n.json,o=i.textures[e];if(!o.extensions||!o.extensions[t])return null;const s=o.extensions[t],a=i.images[s.source];let l=n.textureLoader;if(a.uri){const h=n.options.manager.getHandler(a.uri);h!==null&&(l=h)}return n.loadTextureImage(e,s.source,l)}}class qr{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],o=this.parser.getDependency("buffer",i.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.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 o.then(function(a){const l=i.byteOffset||0,h=i.byteLength||0,u=i.count,f=i.byteStride,g=new Uint8Array(a,l,h);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(u,f,g,i.mode,i.filter).then(function(p){return p.buffer}):s.ready.then(function(){const p=new ArrayBuffer(u*f);return s.decodeGltfBuffer(new Uint8Array(p),u,f,g,i.mode,i.filter),p})})}else return null}}class Yr{constructor(e){this.name=le.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||n.mesh===void 0)return null;const i=t.meshes[n.mesh];for(const h of i.primitives)if(h.mode!==Ce.TRIANGLES&&h.mode!==Ce.TRIANGLE_STRIP&&h.mode!==Ce.TRIANGLE_FAN&&h.mode!==void 0)return null;const s=n.extensions[this.name].attributes,a=[],l={};for(const h in s)a.push(this.parser.getDependency("accessor",s[h]).then(u=>(l[h]=u,l[h])));return a.length<1?null:(a.push(this.parser.createNodeMesh(e)),Promise.all(a).then(h=>{const u=h.pop(),f=u.isGroup?u.children:[u],g=h[0].count,p=[];for(const c of f){const d=new S.Matrix4,m=new S.Vector3,y=new S.Quaternion,w=new S.Vector3(1,1,1),v=new S.InstancedMesh(c.geometry,c.material,g);for(let M=0;M<g;M++)l.TRANSLATION&&m.fromBufferAttribute(l.TRANSLATION,M),l.ROTATION&&y.fromBufferAttribute(l.ROTATION,M),l.SCALE&&w.fromBufferAttribute(l.SCALE,M),v.setMatrixAt(M,d.compose(m,y,w));for(const M in l)if(M==="_COLOR_0"){const P=l[M];v.instanceColor=new S.InstancedBufferAttribute(P.array,P.itemSize,P.normalized)}else M!=="TRANSLATION"&&M!=="ROTATION"&&M!=="SCALE"&&c.geometry.setAttribute(M,l[M]);S.Object3D.prototype.copy.call(v,c),this.parser.assignFinalMaterial(v),p.push(v)}return u.isGroup?(u.clear(),u.add(...p),u):p[0]}))}}const oi="glTF",ut=12,ai={JSON:1313821514,BIN:5130562};class Hr{constructor(e){this.name=le.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,ut),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!==oi)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-ut,o=new DataView(e,ut);let s=0;for(;s<i;){const a=o.getUint32(s,!0);s+=4;const l=o.getUint32(s,!0);if(s+=4,l===ai.JSON){const h=new Uint8Array(e,ut+s,a);this.content=n.decode(h)}else if(l===ai.BIN){const h=ut+s;this.body=e.slice(h,h+a)}s+=a}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class $r{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,o=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,a={},l={},h={};for(const u in s){const f=nn[u]||u.toLowerCase();a[f]=s[u]}for(const u in e.attributes){const f=nn[u]||u.toLowerCase();if(s[u]!==void 0){const g=n.accessors[e.attributes[u]],p=nt[g.componentType];h[f]=p.name,l[f]=g.normalized===!0}}return t.getDependency("bufferView",o).then(function(u){return new Promise(function(f,g){i.decodeDracoFile(u,function(p){for(const c in p.attributes){const d=p.attributes[c],m=l[c];m!==void 0&&(d.normalized=m)}f(p)},a,h,S.LinearSRGBColorSpace,g)})})}}class Qr{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 Jr{constructor(){this.name=le.KHR_MESH_QUANTIZATION}}class li extends S.Interpolant{constructor(e,t,n,i){super(e,t,n,i)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,i=this.valueSize,o=e*i*3+i;for(let s=0;s!==i;s++)t[s]=n[o+s];return t}interpolate_(e,t,n,i){const o=this.resultBuffer,s=this.sampleValues,a=this.valueSize,l=a*2,h=a*3,u=i-t,f=(n-t)/u,g=f*f,p=g*f,c=e*h,d=c-h,m=-2*p+3*g,y=p-g,w=1-m,v=y-g+f;for(let M=0;M!==a;M++){const P=s[d+M+a],D=s[d+M+l]*u,E=s[c+M+a],O=s[c+M]*u;o[M]=w*P+v*D+m*E+y*O}return o}}const eo=new S.Quaternion;class to extends li{interpolate_(e,t,n,i){const o=super.interpolate_(e,t,n,i);return eo.fromArray(o).normalize().toArray(o),o}}const Ce={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},nt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},ci={9728:S.NearestFilter,9729:S.LinearFilter,9984:S.NearestMipmapNearestFilter,9985:S.LinearMipmapNearestFilter,9986:S.NearestMipmapLinearFilter,9987:S.LinearMipmapLinearFilter},hi={33071:S.ClampToEdgeWrapping,33648:S.MirroredRepeatWrapping,10497:S.RepeatWrapping},tn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},nn={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"},Ie={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},no={CUBICSPLINE:void 0,LINEAR:S.InterpolateLinear,STEP:S.InterpolateDiscrete},sn={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function io(r){return r.DefaultMaterial===void 0&&(r.DefaultMaterial=new S.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:S.FrontSide})),r.DefaultMaterial}function Ze(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 Oe(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 so(r,e,t){let n=!1,i=!1,o=!1;for(let h=0,u=e.length;h<u;h++){const f=e[h];if(f.POSITION!==void 0&&(n=!0),f.NORMAL!==void 0&&(i=!0),f.COLOR_0!==void 0&&(o=!0),n&&i&&o)break}if(!n&&!i&&!o)return Promise.resolve(r);const s=[],a=[],l=[];for(let h=0,u=e.length;h<u;h++){const f=e[h];if(n){const g=f.POSITION!==void 0?t.getDependency("accessor",f.POSITION):r.attributes.position;s.push(g)}if(i){const g=f.NORMAL!==void 0?t.getDependency("accessor",f.NORMAL):r.attributes.normal;a.push(g)}if(o){const g=f.COLOR_0!==void 0?t.getDependency("accessor",f.COLOR_0):r.attributes.color;l.push(g)}}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(l)]).then(function(h){const u=h[0],f=h[1],g=h[2];return n&&(r.morphAttributes.position=u),i&&(r.morphAttributes.normal=f),o&&(r.morphAttributes.color=g),r.morphTargetsRelative=!0,r})}function ro(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 oo(r){let e;const t=r.extensions&&r.extensions[le.KHR_DRACO_MESH_COMPRESSION];if(t?e="draco:"+t.bufferView+":"+t.indices+":"+rn(t.attributes):e=r.indices+":"+rn(r.attributes)+":"+r.mode,r.targets!==void 0)for(let n=0,i=r.targets.length;n<i;n++)e+=":"+rn(r.targets[n]);return e}function rn(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 on(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 ao(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 lo=new S.Matrix4;class co{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new Er,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,o=!1,s=-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,o=a.indexOf("Firefox")>-1,s=o?a.match(/Firefox\/([0-9]+)\./)[1]:-1}typeof createImageBitmap>"u"||n&&i<17||o&&s<98?this.textureLoader=new S.TextureLoader(this.options.manager):this.textureLoader=new S.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new S.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,i=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(s){return s._markDefs&&s._markDefs()}),Promise.all(this._invokeAll(function(s){return s.beforeRoot&&s.beforeRoot()})).then(function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(s){const a={scene:s[0][i.scene||0],scenes:s[0],animations:s[1],cameras:s[2],asset:i.asset,parser:n,userData:{}};return Ze(o,a,i),Oe(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,o=t.length;i<o;i++){const s=t[i].joints;for(let a=0,l=s.length;a<l;a++)e[s[a]].isBone=!0}for(let i=0,o=e.length;i<o;i++){const s=e[i];s.mesh!==void 0&&(this._addNodeRef(this.meshCache,s.mesh),s.skin!==void 0&&(n[s.mesh].isSkinnedMesh=!0)),s.camera!==void 0&&this._addNodeRef(this.cameraCache,s.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(),o=(s,a)=>{const l=this.associations.get(s);l!=null&&this.associations.set(a,l);for(const[h,u]of s.children.entries())o(u,a.children[h])};return o(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 o=e(t[i]);o&&n.push(o)}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(o){return o.loadNode&&o.loadNode(t)});break;case"mesh":i=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(t)});break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(t)});break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(t)});break;case"texture":i=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(t)});break;case"skin":i=this.loadSkin(t);break;case"animation":i=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(t)});break;case"camera":i=this.loadCamera(t);break;default:if(i=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.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(o,s){return n.getDependency(e,s)})),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(o,s){n.load(S.LoaderUtils.resolveURL(t.uri,i.path),o,void 0,function(){s(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,o=t.byteOffset||0;return n.slice(o,o+i)})}loadAccessor(e){const t=this,n=this.json,i=this.json.accessors[e];if(i.bufferView===void 0&&i.sparse===void 0){const s=tn[i.type],a=nt[i.componentType],l=i.normalized===!0,h=new a(i.count*s);return Promise.resolve(new S.BufferAttribute(h,s,l))}const o=[];return i.bufferView!==void 0?o.push(this.getDependency("bufferView",i.bufferView)):o.push(null),i.sparse!==void 0&&(o.push(this.getDependency("bufferView",i.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",i.sparse.values.bufferView))),Promise.all(o).then(function(s){const a=s[0],l=tn[i.type],h=nt[i.componentType],u=h.BYTES_PER_ELEMENT,f=u*l,g=i.byteOffset||0,p=i.bufferView!==void 0?n.bufferViews[i.bufferView].byteStride:void 0,c=i.normalized===!0;let d,m;if(p&&p!==f){const y=Math.floor(g/p),w="InterleavedBuffer:"+i.bufferView+":"+i.componentType+":"+y+":"+i.count;let v=t.cache.get(w);v||(d=new h(a,y*p,i.count*p/u),v=new S.InterleavedBuffer(d,p/u),t.cache.add(w,v)),m=new S.InterleavedBufferAttribute(v,l,g%p/u,c)}else a===null?d=new h(i.count*l):d=new h(a,g,i.count*l),m=new S.BufferAttribute(d,l,c);if(i.sparse!==void 0){const y=tn.SCALAR,w=nt[i.sparse.indices.componentType],v=i.sparse.indices.byteOffset||0,M=i.sparse.values.byteOffset||0,P=new w(s[1],v,i.sparse.count*y),D=new h(s[2],M,i.sparse.count*l);a!==null&&(m=new S.BufferAttribute(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let E=0,O=P.length;E<O;E++){const k=P[E];if(m.setX(k,D[E*l]),l>=2&&m.setY(k,D[E*l+1]),l>=3&&m.setZ(k,D[E*l+2]),l>=4&&m.setW(k,D[E*l+3]),l>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=c}return m})}loadTexture(e){const t=this.json,n=this.options,o=t.textures[e].source,s=t.images[o];let a=this.textureLoader;if(s.uri){const l=n.manager.getHandler(s.uri);l!==null&&(a=l)}return this.loadTextureImage(e,o,a)}loadTextureImage(e,t,n){const i=this,o=this.json,s=o.textures[e],a=o.images[t],l=(a.uri||a.bufferView)+":"+s.sampler;if(this.textureCache[l])return this.textureCache[l];const h=this.loadImageSource(t,n).then(function(u){u.flipY=!1,u.name=s.name||a.name||"",u.name===""&&typeof a.uri=="string"&&a.uri.startsWith("data:image/")===!1&&(u.name=a.uri);const g=(o.samplers||{})[s.sampler]||{};return u.magFilter=ci[g.magFilter]||S.LinearFilter,u.minFilter=ci[g.minFilter]||S.LinearMipmapLinearFilter,u.wrapS=hi[g.wrapS]||S.RepeatWrapping,u.wrapT=hi[g.wrapT]||S.RepeatWrapping,u.generateMipmaps=!u.isCompressedTexture&&u.minFilter!==S.NearestFilter&&u.minFilter!==S.LinearFilter,i.associations.set(u,{textures:e}),u}).catch(function(){return null});return this.textureCache[l]=h,h}loadImageSource(e,t){const n=this,i=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(f=>f.clone());const s=i.images[e],a=self.URL||self.webkitURL;let l=s.uri||"",h=!1;if(s.bufferView!==void 0)l=n.getDependency("bufferView",s.bufferView).then(function(f){h=!0;const g=new Blob([f],{type:s.mimeType});return l=a.createObjectURL(g),l});else if(s.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const u=Promise.resolve(l).then(function(f){return new Promise(function(g,p){let c=g;t.isImageBitmapLoader===!0&&(c=function(d){const m=new S.Texture(d);m.needsUpdate=!0,g(m)}),t.load(S.LoaderUtils.resolveURL(f,o.path),c,void 0,p)})}).then(function(f){return h===!0&&a.revokeObjectURL(l),Oe(f,s),f.userData.mimeType=s.mimeType||ao(s.uri),f}).catch(function(f){throw console.error("THREE.GLTFLoader: Couldn't load texture",l),f});return this.sourceCache[e]=u,u}assignTexture(e,t,n,i){const o=this;return this.getDependency("texture",n.index).then(function(s){if(!s)return null;if(n.texCoord!==void 0&&n.texCoord>0&&(s=s.clone(),s.channel=n.texCoord),o.extensions[le.KHR_TEXTURE_TRANSFORM]){const a=n.extensions!==void 0?n.extensions[le.KHR_TEXTURE_TRANSFORM]:void 0;if(a){const l=o.associations.get(s);s=o.extensions[le.KHR_TEXTURE_TRANSFORM].extendTexture(s,a),o.associations.set(s,l)}}return i!==void 0&&(s.colorSpace=i),e[t]=s,s})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const i=t.attributes.tangent===void 0,o=t.attributes.color!==void 0,s=t.attributes.normal===void 0;if(e.isPoints){const a="PointsMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new S.PointsMaterial,S.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,l.sizeAttenuation=!1,this.cache.add(a,l)),n=l}else if(e.isLine){const a="LineBasicMaterial:"+n.uuid;let l=this.cache.get(a);l||(l=new S.LineBasicMaterial,S.Material.prototype.copy.call(l,n),l.color.copy(n.color),l.map=n.map,this.cache.add(a,l)),n=l}if(i||o||s){let a="ClonedMaterial:"+n.uuid+":";i&&(a+="derivative-tangents:"),o&&(a+="vertex-colors:"),s&&(a+="flat-shading:");let l=this.cache.get(a);l||(l=n.clone(),o&&(l.vertexColors=!0),s&&(l.flatShading=!0),i&&(l.normalScale&&(l.normalScale.y*=-1),l.clearcoatNormalScale&&(l.clearcoatNormalScale.y*=-1)),this.cache.add(a,l),this.associations.set(l,this.associations.get(n))),n=l}e.material=n}getMaterialType(){return S.MeshStandardMaterial}loadMaterial(e){const t=this,n=this.json,i=this.extensions,o=n.materials[e];let s;const a={},l=o.extensions||{},h=[];if(l[le.KHR_MATERIALS_UNLIT]){const f=i[le.KHR_MATERIALS_UNLIT];s=f.getMaterialType(),h.push(f.extendParams(a,o,t))}else{const f=o.pbrMetallicRoughness||{};if(a.color=new S.Color(1,1,1),a.opacity=1,Array.isArray(f.baseColorFactor)){const g=f.baseColorFactor;a.color.setRGB(g[0],g[1],g[2],S.LinearSRGBColorSpace),a.opacity=g[3]}f.baseColorTexture!==void 0&&h.push(t.assignTexture(a,"map",f.baseColorTexture,S.SRGBColorSpace)),a.metalness=f.metallicFactor!==void 0?f.metallicFactor:1,a.roughness=f.roughnessFactor!==void 0?f.roughnessFactor:1,f.metallicRoughnessTexture!==void 0&&(h.push(t.assignTexture(a,"metalnessMap",f.metallicRoughnessTexture)),h.push(t.assignTexture(a,"roughnessMap",f.metallicRoughnessTexture))),s=this._invokeOne(function(g){return g.getMaterialType&&g.getMaterialType(e)}),h.push(Promise.all(this._invokeAll(function(g){return g.extendMaterialParams&&g.extendMaterialParams(e,a)})))}o.doubleSided===!0&&(a.side=S.DoubleSide);const u=o.alphaMode||sn.OPAQUE;if(u===sn.BLEND?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,u===sn.MASK&&(a.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&s!==S.MeshBasicMaterial&&(h.push(t.assignTexture(a,"normalMap",o.normalTexture)),a.normalScale=new S.Vector2(1,1),o.normalTexture.scale!==void 0)){const f=o.normalTexture.scale;a.normalScale.set(f,f)}if(o.occlusionTexture!==void 0&&s!==S.MeshBasicMaterial&&(h.push(t.assignTexture(a,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(a.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&s!==S.MeshBasicMaterial){const f=o.emissiveFactor;a.emissive=new S.Color().setRGB(f[0],f[1],f[2],S.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&s!==S.MeshBasicMaterial&&h.push(t.assignTexture(a,"emissiveMap",o.emissiveTexture,S.SRGBColorSpace)),Promise.all(h).then(function(){const f=new s(a);return o.name&&(f.name=o.name),Oe(f,o),t.associations.set(f,{materials:e}),o.extensions&&Ze(i,f,o),f})}createUniqueName(e){const t=S.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,i=this.primitiveCache;function o(a){return n[le.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(a,t).then(function(l){return ui(l,a,t)})}const s=[];for(let a=0,l=e.length;a<l;a++){const h=e[a],u=oo(h),f=i[u];if(f)s.push(f.promise);else{let g;h.extensions&&h.extensions[le.KHR_DRACO_MESH_COMPRESSION]?g=o(h):g=ui(new S.BufferGeometry,h,t),i[u]={primitive:h,promise:g},s.push(g)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,i=this.extensions,o=n.meshes[e],s=o.primitives,a=[];for(let l=0,h=s.length;l<h;l++){const u=s[l].material===void 0?io(this.cache):this.getDependency("material",s[l].material);a.push(u)}return a.push(t.loadGeometries(s)),Promise.all(a).then(function(l){const h=l.slice(0,l.length-1),u=l[l.length-1],f=[];for(let p=0,c=u.length;p<c;p++){const d=u[p],m=s[p];let y;const w=h[p];if(m.mode===Ce.TRIANGLES||m.mode===Ce.TRIANGLE_STRIP||m.mode===Ce.TRIANGLE_FAN||m.mode===void 0)y=o.isSkinnedMesh===!0?new S.SkinnedMesh(d,w):new S.Mesh(d,w),y.isSkinnedMesh===!0&&y.normalizeSkinWeights(),m.mode===Ce.TRIANGLE_STRIP?y.geometry=ri(y.geometry,S.TriangleStripDrawMode):m.mode===Ce.TRIANGLE_FAN&&(y.geometry=ri(y.geometry,S.TriangleFanDrawMode));else if(m.mode===Ce.LINES)y=new S.LineSegments(d,w);else if(m.mode===Ce.LINE_STRIP)y=new S.Line(d,w);else if(m.mode===Ce.LINE_LOOP)y=new S.LineLoop(d,w);else if(m.mode===Ce.POINTS)y=new S.Points(d,w);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+m.mode);Object.keys(y.geometry.morphAttributes).length>0&&ro(y,o),y.name=t.createUniqueName(o.name||"mesh_"+e),Oe(y,o),m.extensions&&Ze(i,y,m),t.assignFinalMaterial(y),f.push(y)}for(let p=0,c=f.length;p<c;p++)t.associations.set(f[p],{meshes:e,primitives:p});if(f.length===1)return o.extensions&&Ze(i,f[0],o),f[0];const g=new S.Group;o.extensions&&Ze(i,g,o),t.associations.set(g,{meshes:e});for(let p=0,c=f.length;p<c;p++)g.add(f[p]);return g})}loadCamera(e){let t;const n=this.json.cameras[e],i=n[n.type];if(!i){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return n.type==="perspective"?t=new S.PerspectiveCamera(S.MathUtils.radToDeg(i.yfov),i.aspectRatio||1,i.znear||1,i.zfar||2e6):n.type==="orthographic"&&(t=new S.OrthographicCamera(-i.xmag,i.xmag,i.ymag,-i.ymag,i.znear,i.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Oe(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let i=0,o=t.joints.length;i<o;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 o=i.pop(),s=i,a=[],l=[];for(let h=0,u=s.length;h<u;h++){const f=s[h];if(f){a.push(f);const g=new S.Matrix4;o!==null&&g.fromArray(o.array,h*16),l.push(g)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[h])}return new S.Skeleton(a,l)})}loadAnimation(e){const t=this.json,n=this,i=t.animations[e],o=i.name?i.name:"animation_"+e,s=[],a=[],l=[],h=[],u=[];for(let f=0,g=i.channels.length;f<g;f++){const p=i.channels[f],c=i.samplers[p.sampler],d=p.target,m=d.node,y=i.parameters!==void 0?i.parameters[c.input]:c.input,w=i.parameters!==void 0?i.parameters[c.output]:c.output;d.node!==void 0&&(s.push(this.getDependency("node",m)),a.push(this.getDependency("accessor",y)),l.push(this.getDependency("accessor",w)),h.push(c),u.push(d))}return Promise.all([Promise.all(s),Promise.all(a),Promise.all(l),Promise.all(h),Promise.all(u)]).then(function(f){const g=f[0],p=f[1],c=f[2],d=f[3],m=f[4],y=[];for(let v=0,M=g.length;v<M;v++){const P=g[v],D=p[v],E=c[v],O=d[v],k=m[v];if(P===void 0)continue;P.updateMatrix&&P.updateMatrix();const I=n._createAnimationTracks(P,D,E,O,k);if(I)for(let W=0;W<I.length;W++)y.push(I[W])}const w=new S.AnimationClip(o,void 0,y);return Oe(w,i),w})}createNodeMesh(e){const t=this.json,n=this,i=t.nodes[e];return i.mesh===void 0?null:n.getDependency("mesh",i.mesh).then(function(o){const s=n._getNodeRef(n.meshCache,i.mesh,o);return i.weights!==void 0&&s.traverse(function(a){if(a.isMesh)for(let l=0,h=i.weights.length;l<h;l++)a.morphTargetInfluences[l]=i.weights[l]}),s})}loadNode(e){const t=this.json,n=this,i=t.nodes[e],o=n._loadNodeShallow(e),s=[],a=i.children||[];for(let h=0,u=a.length;h<u;h++)s.push(n.getDependency("node",a[h]));const l=i.skin===void 0?Promise.resolve(null):n.getDependency("skin",i.skin);return Promise.all([o,Promise.all(s),l]).then(function(h){const u=h[0],f=h[1],g=h[2];g!==null&&u.traverse(function(p){p.isSkinnedMesh&&p.bind(g,lo)});for(let p=0,c=f.length;p<c;p++)u.add(f[p]);return u})}_loadNodeShallow(e){const t=this.json,n=this.extensions,i=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=t.nodes[e],s=o.name?i.createUniqueName(o.name):"",a=[],l=i._invokeOne(function(h){return h.createNodeMesh&&h.createNodeMesh(e)});return l&&a.push(l),o.camera!==void 0&&a.push(i.getDependency("camera",o.camera).then(function(h){return i._getNodeRef(i.cameraCache,o.camera,h)})),i._invokeAll(function(h){return h.createNodeAttachment&&h.createNodeAttachment(e)}).forEach(function(h){a.push(h)}),this.nodeCache[e]=Promise.all(a).then(function(h){let u;if(o.isBone===!0?u=new S.Bone:h.length>1?u=new S.Group:h.length===1?u=h[0]:u=new S.Object3D,u!==h[0])for(let f=0,g=h.length;f<g;f++)u.add(h[f]);if(o.name&&(u.userData.name=o.name,u.name=s),Oe(u,o),o.extensions&&Ze(n,u,o),o.matrix!==void 0){const f=new S.Matrix4;f.fromArray(o.matrix),u.applyMatrix4(f)}else o.translation!==void 0&&u.position.fromArray(o.translation),o.rotation!==void 0&&u.quaternion.fromArray(o.rotation),o.scale!==void 0&&u.scale.fromArray(o.scale);if(!i.associations.has(u))i.associations.set(u,{});else if(o.mesh!==void 0&&i.meshCache.refs[o.mesh]>1){const f=i.associations.get(u);i.associations.set(u,{...f})}return i.associations.get(u).nodes=e,u}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],i=this,o=new S.Group;n.name&&(o.name=i.createUniqueName(n.name)),Oe(o,n),n.extensions&&Ze(t,o,n);const s=n.nodes||[],a=[];for(let l=0,h=s.length;l<h;l++)a.push(i.getDependency("node",s[l]));return Promise.all(a).then(function(l){for(let u=0,f=l.length;u<f;u++)o.add(l[u]);const h=u=>{const f=new Map;for(const[g,p]of i.associations)(g instanceof S.Material||g instanceof S.Texture)&&f.set(g,p);return u.traverse(g=>{const p=i.associations.get(g);p!=null&&f.set(g,p)}),f};return i.associations=h(o),o})}_createAnimationTracks(e,t,n,i,o){const s=[],a=e.name?e.name:e.uuid,l=[];Ie[o.path]===Ie.weights?e.traverse(function(g){g.morphTargetInfluences&&l.push(g.name?g.name:g.uuid)}):l.push(a);let h;switch(Ie[o.path]){case Ie.weights:h=S.NumberKeyframeTrack;break;case Ie.rotation:h=S.QuaternionKeyframeTrack;break;case Ie.translation:case Ie.scale:h=S.VectorKeyframeTrack;break;default:switch(n.itemSize){case 1:h=S.NumberKeyframeTrack;break;case 2:case 3:default:h=S.VectorKeyframeTrack;break}break}const u=i.interpolation!==void 0?no[i.interpolation]:S.InterpolateLinear,f=this._getArrayFromAccessor(n);for(let g=0,p=l.length;g<p;g++){const c=new h(l[g]+"."+Ie[o.path],t.array,f,u);i.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(c),s.push(c)}return s}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const n=on(t.constructor),i=new Float32Array(t.length);for(let o=0,s=t.length;o<s;o++)i[o]=t[o]*n;t=i}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(n){const i=this instanceof S.QuaternionKeyframeTrack?to:li;return new i(this.times,this.values,this.getValueSize()/3,n)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ho(r,e,t){const n=e.attributes,i=new S.Box3;if(n.POSITION!==void 0){const a=t.json.accessors[n.POSITION],l=a.min,h=a.max;if(l!==void 0&&h!==void 0){if(i.set(new S.Vector3(l[0],l[1],l[2]),new S.Vector3(h[0],h[1],h[2])),a.normalized){const u=on(nt[a.componentType]);i.min.multiplyScalar(u),i.max.multiplyScalar(u)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const a=new S.Vector3,l=new S.Vector3;for(let h=0,u=o.length;h<u;h++){const f=o[h];if(f.POSITION!==void 0){const g=t.json.accessors[f.POSITION],p=g.min,c=g.max;if(p!==void 0&&c!==void 0){if(l.setX(Math.max(Math.abs(p[0]),Math.abs(c[0]))),l.setY(Math.max(Math.abs(p[1]),Math.abs(c[1]))),l.setZ(Math.max(Math.abs(p[2]),Math.abs(c[2]))),g.normalized){const d=on(nt[g.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 s=new S.Sphere;i.getCenter(s.center),s.radius=i.min.distanceTo(i.max)/2,r.boundingSphere=s}function ui(r,e,t){const n=e.attributes,i=[];function o(s,a){return t.getDependency("accessor",s).then(function(l){r.setAttribute(a,l)})}for(const s in n){const a=nn[s]||s.toLowerCase();a in r.attributes||i.push(o(n[s],a))}if(e.indices!==void 0&&!r.index){const s=t.getDependency("accessor",e.indices).then(function(a){r.setIndex(a)});i.push(s)}return S.ColorManagement.workingColorSpace!==S.LinearSRGBColorSpace&&"COLOR_0"in n&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${S.ColorManagement.workingColorSpace}" not supported.`),Oe(r,e),ho(r,e,t),Promise.all(i).then(function(){return e.targets!==void 0?so(r,e.targets,t):r})}function uo(r,e,t){let n=new x.Group;n.name=e,r.scene.add(n),ii(e+"/info.zip?v="+Date.now(),i=>{let o=JSON.parse(i);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,boundingBox:{min:new x.Vector3(o.baseInfo.min.X*.3048,o.baseInfo.min.Z*.3048,-o.baseInfo.min.Y*.3048),max:new x.Vector3(o.baseInfo.max.X*.3048,o.baseInfo.max.Z*.3048,-o.baseInfo.max.Y*.3048)}}),r.events.trigger(ht.EngineFree,null)})}function fo(r){r.engineStatus.models.forEach(e=>{e.loadStatus==null&&(e.loadStatus={mep:!1,instance:!1,normal:!1}),e.status==="loading"&&e.type==="light"&&(e.loadStatus.modelMep!=!0&&(e.loadStatus.modelMep=!0,Pr(r,e.info.modelMep,e.url)),e.loadStatus.normal!=!0&&po(r,e))})}function po(r,e){if(r.camera.position,e.size,e.info==null||e.info.lods==null)return;e.info.lods.forEach(i=>{if(i.status!=!0)if(i.glbs==null)console.log("加载GLB............."),i.glbs={},Ar(e.url+i.path+"/nodes.json?v="+Date.now(),o=>{let s=JSON.parse(o),a=new Map;r.models.find(h=>h.url==e.url).nodesMap=a;let l=0;for(let h in s){s[h].forEach(g=>{g.glb=h,a.has(g.id)==!1?a.set(g.id,{infos:[g]}):a.get(g.id).infos.push(g)});let u=new Dr;const f=new Tr;f.setDecoderPath("/static/js/draco/"),f.preload(),u.setDRACOLoader(f),u.load(e.url+i.path+h+".glb",g=>{i.glbs[h]=g.scene.children,l++,l==Object.keys(s).length&&r.engineStatus.isFree&&(r.events.trigger(ht.EngineFree,null),r.viewCube.CameraGoHome())})}});else{console.log("加载模型.............");let o=n(e,i,i.octreeBox),s=[],a=r.models.find(l=>l.url==e.url);o.forEach(l=>{a.nodesMap.has(l)&&a.nodesMap.get(l).infos.forEach(h=>{let u=i.glbs[h.glb][h.mesh];if(u!=null&&u.geometry!=null&&u.material!=null){let f=new x.Matrix4;f.elements=h.matrix;let g=new x.Mesh(u.geometry.clone().applyMatrix4(f),u.material),p=new x.Box3().setFromObject(g);h.box=p,h.mesh=g,g.name=l,g.glb=h.glb,g.url=e.url,s.push(g)}})}),console.log("加载模型数量",s.length),mo(e.url,r,s)}});function n(i,o,s){let a=[];if(s.status!=!0){if(!r.engineStatus.isFree)return a;let l=new x.Vector3(s.min.X,s.min.Z,-s.min.Y),h=new x.Vector3(s.max.X,s.max.Z,-s.max.Y);h.distanceTo(l);let u=r.camera.position,f=new x.Vector3(l.x+h.x/2,l.y+h.y/2,l.z+h.z/2);u.distanceTo(f),s.elements.forEach(g=>{a.push(g)}),s.children.forEach(g=>{a.push(...n(i,o,g))}),s.children.findIndex(g=>g.status!=!0)==-1&&(s.status=!0),s.children.length==0&&(s.status=!0)}return a}}function mo(r,e,t){let n=[];t.forEach(i=>{n.findIndex(s=>s.glb==i.glb)==-1?n.push({glb:i.glb,meshes:[i],currentIndex:i.geometry.index.count,indexes:new Map}):(n.find(s=>s.glb==i.glb).meshes.push(i),n.find(s=>s.glb==i.glb).currentIndex+=i.geometry.index.count);let o=n.find(s=>s.glb==i.glb);o.indexes.set(Number(i.name),[o.currentIndex-i.geometry.index.count,o.currentIndex])}),n.forEach(i=>{let o=e.scene.children.find(s=>s instanceof x.Mesh&&s.url==r&&s.glb==i.glb);if(o!=null)o.castShadow=!0,o.receiveShadow=!0;else{let s=new x.BufferGeometry;i.meshes.map(h=>h.material),s=kr(i.meshes.map(h=>h.geometry),!0);let a=new x.Mesh(s,i.meshes.map(h=>h.material));a.castShadow=!0,a.receiveShadow=!0,e.scene.add(a),a.index=e.scene.children.length-1,a.url=r,a.glb=i.glb,a.indexes=i.indexes,a.materialClone=i.meshes[0].material;let l=e.models.find(h=>h.url==r);if(l!=null){let h=0;i.indexes.forEach(u=>{l.nodesMap.get(Number(i.meshes[h].name)).indexes==null&&(l.nodesMap.get(Number(i.meshes[h].name)).indexes=[]),l.nodesMap.get(Number(i.meshes[h].name)).indexes.push([a.index,h++,u[0],u[1]])})}a.material instanceof Array?a.material.forEach(h=>{di(h)}):di(a.material)}})}function di(r){r.shadowSide=x.FrontSide,r.roughness=.6,r.metalness=0,r.side=x.DoubleSide,r.map!=null&&(r.map.colorSpace=x.SRGBColorSpace,r.map.needsUpdate=!0,console.log("优化贴图")),r instanceof x.MeshStandardMaterial&&(r.map&&(r.map.colorSpace=x.SRGBColorSpace,r.map.needsUpdate=!0),r.emissiveMap&&(r.emissiveMap.colorSpace=x.SRGBColorSpace,r.emissiveMap.needsUpdate=!0),r.roughnessMap&&(r.roughnessMap.colorSpace=x.LinearSRGBColorSpace,r.roughnessMap.needsUpdate=!0),r.metalnessMap&&(r.metalnessMap.colorSpace=x.LinearSRGBColorSpace,r.metalnessMap.needsUpdate=!0),r.normalMap&&(r.normalMap.colorSpace=x.LinearSRGBColorSpace,r.normalMap.needsUpdate=!0),r.aoMap&&(r.aoMap.colorSpace=x.LinearSRGBColorSpace,r.aoMap.needsUpdate=!0),r.roughness=Math.max(.1,Math.min(1,r.roughness)),r.metalness=Math.max(0,Math.min(1,r.metalness)),r.envMapIntensity=r.envMapIntensity||1,r.needsUpdate=!0),r instanceof x.MeshPhysicalMaterial&&(this.optimizeMaterial(r),r.transmissionMap&&(r.transmissionMap.colorSpace=x.LinearSRGBColorSpace,r.transmissionMap.needsUpdate=!0),r.thicknessMap&&(r.thicknessMap.colorSpace=x.LinearSRGBColorSpace,r.thicknessMap.needsUpdate=!0),r.transmission=Math.max(0,Math.min(1,r.transmission)),r.thickness=Math.max(0,Math.min(10,r.thickness))),r instanceof x.MeshBasicMaterial&&r.map&&(r.map.colorSpace=x.SRGBColorSpace,r.map.needsUpdate=!0),r instanceof x.MeshLambertMaterial&&(r.map&&(r.map.colorSpace=x.SRGBColorSpace,r.map.needsUpdate=!0),r.emissiveMap&&(r.emissiveMap.colorSpace=x.SRGBColorSpace,r.emissiveMap.needsUpdate=!0))}class go{engine;constructor(e){this.engine=e}async loadModels(e,t){for(const i of e)n(i)==="light"&&uo(this.engine,i);function n(i){const o=i.split(".").pop();return o==="glb"||o==="gltf"?"gltf":"light"}}}class yo{engine;isFree;highlightModels;hideModels;models;constructor(e){this.engine=e,this.isFree=!0,this.highlightModels=[],this.hideModels=[],this.models=[]}init(){this.engine.events.on(ht.EngineFree,()=>{this.updateFree(!0),console.log("引擎空闲"),fo(this.engine)}),this.engine.events.on(ht.EngineBusy,()=>{this.updateFree(!1),console.log("引擎繁忙")})}updateFree(e){this.isFree=e}closeAllFunction=()=>{}}class _o{listeners=new Map;on(e,t){this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t)}off(e,t){if(!this.listeners.has(e))return;const n=this.listeners.get(e),i=n.indexOf(t);i!==-1&&n.splice(i,1)}trigger(e,t){this.listeners.has(e)&&this.listeners.get(e).forEach(n=>{try{n(t)}catch(i){console.error(`Error in event listener for ${e}:`,i)}})}}class wo{engine;constructor(e){this.engine=e}init(){const e=new x.DirectionalLight(16777215,2);e.position.set(10,20,10),e.castShadow=!0,e.shadow.mapSize.width=4096,e.shadow.mapSize.height=4096,e.shadow.camera.near=.1,e.shadow.camera.far=500,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,this.engine.scene.add(e);const n=new x.AmbientLight(16777215,1);this.engine.scene.add(n)}}var Re=(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))(Re||{});class bo{engine;behavior;isCtrlDown=!1;constructor(e){this.engine=e}init(){this.behavior=this.engine.handelBehaved,this.behavior.init(this)}active(){this.behavior.active()}disActive(){this.behavior.disActive()}handelKeyCtrlUp(){this.isCtrlDown=!1}handelKeyCtrlDown(){this.isCtrlDown=!0}handleMouseClick(e){if(e.catch){const t=e.catch;t.object,this.engine.events.trigger(Re.Click,t);let n=t.object;this.isCtrlDown||this.engine.modelToolModule.unhighlightAllModels(),console.log([{url:n.url,ids:[n.name]}]),this.engine.modelToolModule.highlightModel([{url:n.url,ids:[n.name]}])}else this.engine.modelToolModule.unhighlightAllModels()}handleMouseDoubleClick(e){if(e.catch){const n=e.catch;n.object,this.engine.events.trigger(Re.Click,n);let i=n.object,a=this.engine.models.find(h=>h.url===i.url).nodesMap.get(i.name).infos.map(h=>h.box),l=t(a);this.engine.viewCube.zoomToModel(l)}function t(n){let i=new x.Vector3(1e8,1e9,1e10),o=new x.Vector3(-1e8,-1e9,-1e10);return n.forEach(s=>{s.min.x<i.x&&(i.x=s.min.x),s.min.y<i.y&&(i.y=s.min.y),s.min.z<i.z&&(i.z=s.min.z),s.max.x>o.x&&(o.x=s.max.x),s.max.y>o.y&&(o.y=s.max.y),s.max.z>o.z&&(o.z=s.max.z)}),new x.Box3(i,o)}}}class xo{engine;highlightMaterial;hideMaterial;constructor(e){this.engine=e,this.highlightMaterial=new x.MeshBasicMaterial({color:43775,depthTest:!1,depthWrite:!1,transparent:!0,opacity:.5,side:x.DoubleSide}),this.hideMaterial=new x.MeshBasicMaterial({color:0,depthTest:!1,depthWrite:!1,transparent:!0,opacity:0,side:x.DoubleSide})}highlightModel(e){e.forEach(t=>{t.ids.forEach(n=>{this.engine.models.find(o=>o.url==t.url).nodesMap.get(n).indexes.forEach(o=>{fi(this.engine.scene.children[o[0]]),this.engine.scene.children[o[0]].material[o[1]]=this.highlightMaterial})}),this.engine.engineStatus.highlightModels.push(t)})}unhighlightModel(e){e.forEach(t=>{t.ids.forEach(n=>{this.engine.models.find(o=>o.url==t.url).nodesMap.get(n).indexes.forEach(o=>{this.engine.scene.children[o[0]].material[o[1]]=this.engine.scene.children[o[0]].materialClone})})})}unhighlightAllModels(){this.engine.engineStatus.highlightModels.forEach(e=>{this.unhighlightModel([e])}),this.engine.engineStatus.highlightModels=[]}hideModel(e){e.forEach(t=>{t.ids.forEach(i=>{let o=this.engine.models.find(s=>s.url==t.url).nodesMap.get(i);this.engine.modelEdge.hideModelEdge(t.url,i),o.indexes.forEach(s=>{fi(this.engine.scene.children[s[0]]),this.engine.scene.children[s[0]].material[s[1]]=this.hideMaterial})});let n=this.engine.engineStatus.hideModels.find(i=>i.url==t.url);n!=null?n.ids.push(...t.ids):this.engine.engineStatus.hideModels.push({url:t.url,ids:t.ids}),this.engine.engineStatus.highlightModels=[]})}showModel(e){e.forEach(t=>{t.ids.forEach(n=>{let i=this.engine.models.find(o=>o.url==t.url).nodesMap.get(n);this.engine.modelEdge.showModelEdge(t.url,n),i.indexes.forEach(o=>{this.engine.scene.children[o[0]].material[o[1]]=this.engine.scene.children[o[0]].materialClone})}),this.engine.engineStatus.hideModels.push(t)})}isolateModel(e){const t=[];this.engine.models.forEach(i=>{const o=Array.from(i.nodesMap.keys());t.push({url:i.url,ids:o})});const n=[];t.forEach(i=>{const o=e.find(s=>s.url===i.url);if(o){const s=i.ids.filter(a=>!o.ids.includes(a));s.length>0&&n.push({url:i.url,ids:s})}else n.push(i)}),n.length>0&&this.hideModel(n)}showAllModels(){}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})}getModelsBox(e){new x.Box3;let t=[];return e.forEach(i=>{let o=this.engine.models.find(s=>s.url==i.url);i.ids.forEach(s=>{o.nodesMap.get(s).infos.forEach(l=>{t.push(l.box)})})}),n(t);function n(i){let o=new x.Vector3(1e8,1e9,1e10),s=new x.Vector3(-1e8,-1e9,-1e10);return i.forEach(a=>{a.min.x<o.x&&(o.x=a.min.x),a.min.y<o.y&&(o.y=a.min.y),a.min.z<o.z&&(o.z=a.min.z),a.max.x>s.x&&(s.x=a.max.x),a.max.y>s.y&&(s.y=a.max.y),a.max.z>s.z&&(s.z=a.max.z)}),new x.Box3(o,s)}}getModelDescription(e){}}function fi(r){(r.isSplit==null||r.isSplit==null||r.isSplit==!1)&&(r.isSplit=!0)}function pi(r){const e={self:null,options:null,mouseDownTime:0,lastClickTime:0};e.init=function(f,g){e.self!=null&&e.self.disActive!=null&&e.self.disActive(),e.self=f,e.options=g},e.render=function(){e.self&&e.self.render!=null&&e.self.render()},e.active=function(){r.container.addEventListener("mousedown",a),r.container.addEventListener("mouseup",h),r.container.addEventListener("mousemove",l),window.addEventListener("keydown",t),window.addEventListener("keyup",n)},e.disActive=function(){r.container.removeEventListener("mousedown",a),r.container.removeEventListener("mouseup",h),r.container.removeEventListener("mousemove",l),window.removeEventListener("keydown",t),window.removeEventListener("keyup",n)};function t(f){(f.keyCode===8||f.keyCode===46)&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),f.keyCode===27&&e.self&&e.self.handelKeyEscDown!=null&&e.self.handelKeyEscDown(),f.keyCode===13&&e.self&&e.self.handelKeyEnterDown!=null&&e.self.handelKeyEnterDown(),f.keyCode===32&&e.self&&e.self.handelKeySpaceDown!=null&&e.self.handelKeySpaceDown(),f.key==="Control"&&e.self&&e.self.handelKeyCtrlDown!=null&&e.self.handelKeyCtrlDown(),f.key==="Delete"&&e.self&&e.self.handelKeyDeleteDown!=null&&e.self.handelKeyDeleteDown(),f.key==="Shift"&&e.self&&e.self.handelKeyShiftDown!=null&&e.self.handelKeyShiftDown(),f.key==="Meta"&&e.self&&e.self.handelKeyMetaDown!=null&&e.self.handelKeyMetaDown()}function n(f){f.key==="Alt"&&e.self&&e.self.handelKeyAltUp!=null&&e.self.handelKeyAltUp(),f.key==="Tab"&&e.self&&e.self.handelKeyTabUp!=null&&e.self.handelKeyTabUp(),f.key==="Control"&&e.self&&e.self.handelKeyCtrlUp!=null&&e.self.handelKeyCtrlUp(),f.key==="Shift"&&e.self&&e.self.handelKeyShiftUp!=null&&e.self.handelKeyShiftUp(),f.key==="Meta"&&e.self&&e.self.handelKeyMetaUp!=null&&e.self.handelKeyMetaUp(),f.key==="Command"&&e.self&&e.self.handelKeyCommandUp!=null&&e.self.handelKeyCommandUp(),f.key==="Windows"&&e.self&&e.self.handelKeyWindowsUp!=null&&e.self.handelKeyWindowsUp()}function i(f){const g=new x.Vector2,p=r.renderer.domElement.clientWidth,c=r.renderer.domElement.clientHeight;return g.x=f.clientX/p*2-1,g.y=-(f.clientY/c)*2+1,g}function o(f){const g=new x.Raycaster,p=i(f);return g.setFromCamera(p,r.camera),g}function s(f,g=!1){const p=o(f);if(f.raycaster=p,g){const c=u(p,f);f.catch=c}}function a(f){f.button===0&&(e.mouseDownTime=Date.now(),e.self&&e.self.handleMouseDown!=null&&(s(f,!0),e.self.handleMouseDown(f)))}function l(f){e.self&&e.self.handleMouseMove!=null&&(s(f,!0),e.self.handleMouseMove(f))}function h(f){if(f.button!==0)return;const g=Date.now(),p=g-e.mouseDownTime;if(e.self&&e.self.handleMouseUp!=null&&(s(f,!1),e.self.handleMouseUp(f)),p<100&&e.self&&e.self.handleMouseClick!=null){s(f,!0);const c=g-e.lastClickTime;console.log(c),c<200?e.self.handleMouseDoubleClick(f):e.self.handleMouseClick(f),e.lastClickTime=Date.now()}}function u(f,g){r.catchSvg.innerHTML="";const p=r.octreeBox.rayInterationModel(f);if(p.length===0)return;let c=p[0].object.url,d=p[0].object.name,m=r.modelEdge.getModelEdge(c,d);m||(m=[0,0,[]]);let y="face",w=[],v=[],M=5;if(m[2].map(O=>O[0]).forEach(O=>{let k=new x.Vector3(O.X,O.Z,-O.Y),I=r.worldToScreen.worldToScreen(k),W=Math.sqrt(Math.pow(I.x-g.clientX,2)+Math.pow(I.y-g.clientY,2));W<M&&(M=W,w.push({point:k,distance:W,pointxy:I}))}),w.length>0?(w.sort((O,k)=>O.distance-k.distance),y="point"):(m[2].forEach(O=>{let k=new x.Vector3(O[0].X,O[0].Z,-O[0].Y),I=new x.Vector3(O[1].X,O[1].Z,-O[1].Y),W=r.worldToScreen.worldToScreen(k),T=r.worldToScreen.worldToScreen(I),B=P(new x.Vector2(g.clientX,g.clientY),W,T);if(B<M){let b=D(new x.Vector2(g.clientX,g.clientY),W,T),V=E(b,k,I);v.push({distance:B,point:V,pointxy:r.worldToScreen.worldToScreen(V),start:W,end:T})}}),v.length>0&&(v.sort((O,k)=>O.distance-k.distance),y="line")),y=="point"){const O=r.worldToScreen.worldToScreen(w[0].point);console.log("捕捉点屏幕坐标:",O.x,O.y),console.log("Canvas尺寸:",r.renderer.domElement.width,r.renderer.domElement.height),console.log("SVG尺寸:",r.catchSvg.clientWidth,r.catchSvg.clientHeight),r.catchSvg.innerHTML="";const k=document.createElementNS("http://www.w3.org/2000/svg","circle");k.setAttribute("class","catchPoint"),k.setAttribute("cx",O.x.toString()),k.setAttribute("cy",O.y.toString()),k.setAttribute("r","5"),k.setAttribute("fill","rgb(0, 255, 247)"),r.catchSvg.appendChild(k)}else if(y=="line"){const O=r.worldToScreen.worldToScreen(v[0].point),k=v[0].start,I=v[0].end;console.log("捕捉点屏幕坐标:",O.x,O.y),console.log("Canvas尺寸:",r.renderer.domElement.width,r.renderer.domElement.height),console.log("SVG尺寸:",r.catchSvg.clientWidth,r.catchSvg.clientHeight),r.catchSvg.innerHTML="";const W=document.createElementNS("http://www.w3.org/2000/svg","line");W.setAttribute("class","catchLine"),W.setAttribute("x1",k.x.toString()),W.setAttribute("y1",k.y.toString()),W.setAttribute("x2",I.x.toString()),W.setAttribute("y2",I.y.toString()),W.setAttribute("stroke","rgb(0, 255, 247)"),W.setAttribute("stroke-width","2"),r.catchSvg.appendChild(W)}else if(y=="face"){let O=p[0].point.clone(),k=p[0].normal||(p[0].face?p[0].face.normal:null);const I=(k?k.clone():new x.Vector3(0,0,1)).normalize(),W=Math.abs(I.y)<.9?new x.Vector3(0,1,0):new x.Vector3(1,0,0),T=new x.Vector3().crossVectors(I,W).normalize(),B=new x.Vector3().crossVectors(I,T).normalize(),b=.05,X=[new x.Vector3().copy(T).add(B).multiplyScalar(b),new x.Vector3().copy(T).sub(B).multiplyScalar(b),new x.Vector3().copy(T).multiplyScalar(-1).sub(B).multiplyScalar(b),new x.Vector3().copy(T).multiplyScalar(-1).add(B).multiplyScalar(b)].map(j=>new x.Vector3().copy(O).add(j)).map(j=>r.worldToScreen.worldToScreen(j));r.catchSvg.innerHTML="";const ee=document.createElementNS("http://www.w3.org/2000/svg","polygon");ee.setAttribute("class","catchFace"),ee.setAttribute("points",X.map(j=>`${j.x},${j.y}`).join(" ")),ee.setAttribute("fill","rgba(1, 238, 255, 0.2)"),ee.setAttribute("stroke","rgb(0, 255, 247)"),ee.setAttribute("stroke-width","1"),r.catchSvg.appendChild(ee)}return p[0];function P(O,k,I){const W=new x.Vector2().subVectors(I,k),T=W.lengthSq();if(T<1e-10)return O.distanceTo(k);const B=new x.Vector2().subVectors(O,k),b=x.MathUtils.clamp(B.dot(W)/T,0,1),V=new x.Vector2().copy(W).multiplyScalar(b).add(k);return O.distanceTo(V)}function D(O,k,I){const W=new x.Vector2().subVectors(I,k),T=W.lengthSq();if(T<1e-10)return 0;const B=new x.Vector2().subVectors(O,k);return x.MathUtils.clamp(B.dot(W)/T,0,1)}function E(O,k,I){const W=x.MathUtils.clamp(O,0,1);return new x.Vector3().lerpVectors(k,I,W)}}return e}class Pe{constructor(e,t,n){this.camera=e,this.renderer=t,this.scene=n,this.raycaster=new x.Raycaster}raycaster;worldToScreenNormalized(e){const t=e.clone();return t.project(this.camera),new x.Vector2(t.x,t.y)}worldToScreen(e){const t=this.worldToScreenNormalized(e),n=this.renderer.domElement.width,i=this.renderer.domElement.height,o=(t.x+1)*n/2,s=(1-t.y)*i/2;return new x.Vector2(o,s)}screenToNormalized(e,t){const n=this.renderer.domElement.width,i=this.renderer.domElement.height,o=e/n*2-1,s=-(t/i*2-1);return new x.Vector2(o,s)}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 o=n||this.scene.children,s=this.raycaster.intersectObjects(o,!0);return s.length>0?s[0].point:null}screenToWorldWithDepth(e,t,n=0){const i=this.screenToNormalized(e,t),o=new x.Vector3(i.x,i.y,n);return o.unproject(this.camera),o}updateCamera(e){this.camera=e}updateRenderer(e){this.renderer=e}updateScene(e){this.scene=e}}var Bt={exports:{}},vo=Bt.exports,mi;function So(){return mi||(mi=1,(function(r,e){(function(t,n){r.exports=n()})(vo,function(){var t=function(){function n(p){return s.appendChild(p.dom),p}function i(p){for(var c=0;c<s.children.length;c++)s.children[c].style.display=c===p?"block":"none";o=p}var o=0,s=document.createElement("div");s.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000",s.addEventListener("click",function(p){p.preventDefault(),i(++o%s.children.length)},!1);var a=(performance||Date).now(),l=a,h=0,u=n(new t.Panel("FPS","#0ff","#002")),f=n(new t.Panel("MS","#0f0","#020"));if(self.performance&&self.performance.memory)var g=n(new t.Panel("MB","#f08","#201"));return i(0),{REVISION:16,dom:s,addPanel:n,showPanel:i,begin:function(){a=(performance||Date).now()},end:function(){h++;var p=(performance||Date).now();if(f.update(p-a,200),p>l+1e3&&(u.update(1e3*h/(p-l),100),l=p,h=0,g)){var c=performance.memory;g.update(c.usedJSHeapSize/1048576,c.jsHeapSizeLimit/1048576)}return p},update:function(){a=this.end()},domElement:s,setMode:i}};return t.Panel=function(n,i,o){var s=1/0,a=0,l=Math.round,h=l(window.devicePixelRatio||1),u=80*h,f=48*h,g=3*h,p=2*h,c=3*h,d=15*h,m=74*h,y=30*h,w=document.createElement("canvas");w.width=u,w.height=f,w.style.cssText="width:80px;height:48px";var v=w.getContext("2d");return v.font="bold "+9*h+"px Helvetica,Arial,sans-serif",v.textBaseline="top",v.fillStyle=o,v.fillRect(0,0,u,f),v.fillStyle=i,v.fillText(n,g,p),v.fillRect(c,d,m,y),v.fillStyle=o,v.globalAlpha=.9,v.fillRect(c,d,m,y),{dom:w,update:function(M,P){s=Math.min(s,M),a=Math.max(a,M),v.fillStyle=o,v.globalAlpha=1,v.fillRect(0,0,u,d),v.fillStyle=i,v.fillText(l(M)+" "+n+" ("+l(s)+"-"+l(a)+")",g,p),v.drawImage(w,c+h,d,m-h,y,c,d,m-h,y),v.fillRect(c+m-h,d,h,y),v.fillStyle=o,v.globalAlpha=.9,v.fillRect(c+m-h,d,h,l((1-M/P)*y))}}},t})})(Bt)),Bt.exports}var Mo=So();const Ao=gn(Mo);var it=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-it.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?it.Bounce.In(r*2)*.5:it.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}}}}),dt=function(){return performance.now()},To=(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=dt()),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 o=this._tweens[n[i]],s=!t;o&&o.update(e,s)===!1&&!t&&delete this._tweens[n[i]]}n=Object.keys(this._tweensAddedDuringUpdate)}return!0},r})(),an={Linear:function(r,e){var t=r.length-1,n=t*e,i=Math.floor(n),o=an.Utils.Linear;return e<0?o(r[0],r[1],n):e>1?o(r[t],r[t-1],t-n):o(r[i],r[i+1>t?t:i+1],n-i)},Utils:{Linear:function(r,e,t){return(e-r)*t+r}}},gi=(function(){function r(){}return r.nextId=function(){return r._nextId++},r._nextId=0,r})(),ln=new To,Co=(function(){function r(e,t){t===void 0&&(t=ln),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=it.Linear.None,this._interpolationFunction=an.Linear,this._chainedTweens=[],this._onStartCallbackFired=!1,this._onEveryStartCallbackFired=!1,this._id=gi.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=dt()),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 o in this._valuesEnd)i[o]=this._valuesEnd[o];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,o){for(var s in n){var a=e[s],l=Array.isArray(a),h=l?"array":typeof a,u=!l&&Array.isArray(n[s]);if(!(h==="undefined"||h==="function")){if(u){var f=n[s];if(f.length===0)continue;for(var g=[a],p=0,c=f.length;p<c;p+=1){var d=this._handleRelativeValue(a,f[p]);if(isNaN(d)){u=!1,console.warn("Found invalid interpolation list. Skipping.");break}g.push(d)}u&&(n[s]=g)}if((h==="object"||l)&&a&&!u){t[s]=l?[]:{};var m=a;for(var y in m)t[s][y]=m[y];i[s]=l?[]:{};var f=n[s];if(!this._isDynamic){var w={};for(var y in f)w[y]=f[y];n[s]=f=w}this._setupProperties(m,t[s],f,i[s],o)}else(typeof t[s]>"u"||o)&&(t[s]=a),l||(t[s]*=1),u?i[s]=n[s].slice().reverse():i[s]=t[s]||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=dt()),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=dt()),!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=ln),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=it.Linear.None),this._easingFunction=e,this},r.prototype.interpolation=function(e){return e===void 0&&(e=an.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=dt()),t===void 0&&(t=!0),this._isPaused)return!0;var o,s=this._startTime+this._duration;if(!this._goToEnd&&!this._isPlaying){if(e>s)return!1;t&&this.start(e,!0)}if(this._goToEnd=!1,e<this._startTime)return!0;this._onStartCallbackFired===!1&&(this._onStartCallback&&this._onStartCallback(this._object),this._onStartCallbackFired=!0),this._onEveryStartCallbackFired===!1&&(this._onEveryStartCallback&&this._onEveryStartCallback(this._object),this._onEveryStartCallbackFired=!0);var a=e-this._startTime,l=this._duration+((i=this._repeatDelayTime)!==null&&i!==void 0?i:this._delayTime),h=this._duration+this._repeat*l,u=function(){if(n._duration===0||a>h)return 1;var m=Math.trunc(a/l),y=a-m*l,w=Math.min(y/n._duration,1);return w===0&&a===n._duration?1:w},f=u(),g=this._easingFunction(f);if(this._updateProperties(this._object,this._valuesStart,this._valuesEnd,g),this._onUpdateCallback&&this._onUpdateCallback(this._object,f),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(o in this._valuesStartRepeat)!this._yoyo&&typeof this._valuesEnd[o]=="string"&&(this._valuesStartRepeat[o]=this._valuesStartRepeat[o]+parseFloat(this._valuesEnd[o])),this._yoyo&&this._swapEndStartRepeatValues(o),this._valuesStart[o]=this._valuesStartRepeat[o];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 c=0,d=this._chainedTweens.length;c<d;c++)this._chainedTweens[c].start(this._startTime+this._duration,!1);return this._isPlaying=!1,!1}return!0},r.prototype._updateProperties=function(e,t,n,i){for(var o in n)if(t[o]!==void 0){var s=t[o]||0,a=n[o],l=Array.isArray(e[o]),h=Array.isArray(a),u=!l&&h;u?e[o]=this._interpolationFunction(a,i):typeof a=="object"&&a?this._updateProperties(e[o],s,a,i):(a=this._handleRelativeValue(s,a),typeof a=="number"&&(e[o]=s+(a-s)*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})();gi.nextId;var Ne=ln;Ne.getAll.bind(Ne),Ne.removeAll.bind(Ne),Ne.add.bind(Ne),Ne.remove.bind(Ne),Ne.update.bind(Ne);var cn={Easing:it,Tween:Co};function Po(){return new x.Scene}function ko(r,e){r.appendChild(e.domElement)}function Do(r,e,t){var n=new Object;n.visible=!0;let i=null,o,s,a=[];n.init=function(){o||(h(),u(),f())},n.Hide=function(){o.style.display="none",n.visible=!1},n.Show=function(){o.style.display="block",n.visible=!0},n.RenderScene=function(){n.camera.quaternion.copy(e.camera.quaternion);let d=new x.Vector3(0,0,-1).clone().applyMatrix4(e.camera.matrixWorld.clone()),m=e.camera.position.clone().sub(d.clone()).setLength(100);n.camera.position.copy(m),n.camera.lookAt(new x.Vector3),n.sceneOrtho.renderer.render(n.sceneOrtho,n.camera)},n.ToggleDirectionView=function(c){console.log(c);var d=new x.Vector3(0,0,0);c=="top"?d=new x.Vector3(0,1,0):c=="down"?d=new x.Vector3(0,-1,0):c=="front"?d=new x.Vector3(0,0,1):c=="left"?d=new x.Vector3(-1,0,0):c=="back"?d=new x.Vector3(0,0,-1):c=="right"?d=new x.Vector3(1,0,0):c=="top_front"?d=new x.Vector3(1,1,0):c=="top_left"?d=new x.Vector3(0,1,-1):c=="top_back"?d=new x.Vector3(-1,1,0):c=="top_right"?d=new x.Vector3(0,1,1):c=="down_front"?d=new x.Vector3(1,-1,0):c=="down_left"?d=new x.Vector3(0,-1,-1):c=="down_back"?d=new x.Vector3(-1,-1,0):c=="down_right"?d=new x.Vector3(0,-1,1):c=="front_right"?d=new x.Vector3(1,0,1):c=="right_back"?d=new x.Vector3(-1,0,1):c=="back_left"?d=new x.Vector3(-1,0,-1):c=="left_front"?d=new x.Vector3(1,0,-1):c=="top_left_front"?d=new x.Vector3(1,1,-1):c=="top_front_right"?d=new x.Vector3(1,1,1):c=="top_right_back"?d=new x.Vector3(-1,1,1):c=="top_back_left"?d=new x.Vector3(-1,1,-1):c=="button_left_front"?d=new x.Vector3(1,-1,-1):c=="button_front_right"?d=new x.Vector3(1,-1,1):c=="button_right_back"?d=new x.Vector3(-1,1,1):c=="button_back_left"&&(d=new x.Vector3(-1,-1,-1));var m=r.octreeBox.getBoundingBox(),y=m.min,w=m.max,v=y.clone().add(w.clone()).multiplyScalar(.5),M=v.clone().add(d.multiplyScalar(1*w.distanceTo(y)));l(e.camera.position,M,r.controls.target.clone(),v)},n.GetCameraPose=function(){var c=e.camera.quaternion,d=e.camera.position,m=r.controls.target,y={quaternion:c,position:d,target:m};return y},n.ReductionCameraPose=function(c,d=1e3,m){var y=new x.Quaternion(c.quaternion._x,c.quaternion._y,c.quaternion._z,c.quaternion._w),w=new x.Vector3(c.position.x,c.position.y,c.position.z),v=new x.Vector3(c.target.x,c.target.y,c.target.z);let M=!1;l(e.camera.position,w,r.controls.target.clone(),v,e.camera.quaternion,y,d,P=>{m&&(M||(m(P),M=!0))}),m&&setTimeout(()=>{M||(m(!0),M=!0)},d+10)},n.CameraGoHome=function(){var c=r.octreeBox.getBoundingBox();console.log(c.min,c.max);var d=c.min.clone().add(c.max.clone()).multiplyScalar(.5);let m=new x.Vector3(1,1,1);var y=d.clone().add(m.multiplyScalar(1*c.max.distanceTo(c.min)));l(e.camera.position,y,r.controls.target.clone(),d)},n.zoomToBox=function(c){var d=c.min.clone().add(c.max.clone()).multiplyScalar(.5);let y=e.camera.position.clone().sub(r.controls.target.clone()).normalize();var w=d.clone().add(y.multiplyScalar(1*c.max.distanceTo(c.min)));l(e.camera.position,w,r.controls.target.clone(),d)};function l(c,d,m,y,w,v,M=1e3,P){var D;w&&v?(D=new cn.Tween({x1:c.x,y1:c.y,z1:c.z,x2:m.x,y2:m.y,z2:m.z,_x:w._x,_y:w._y,_z:w._z,_w:w._w}),D.to({x1:d.x,y1:d.y,z1:d.z,x2:y.x,y2:y.y,z2:y.z,_x:v._x,_y:v._y,_z:v._z,_w:v._w},M)):(D=new cn.Tween({x1:c.x,y1:c.y,z1:c.z,x2:m.x,y2:m.y,z2:m.z}),D.to({x1:d.x,y1:d.y,z1:d.z,x2:y.x,y2:y.y,z2:y.z},M)),D.onUpdate(function(O){w&&v?(e.camera.quaternion._x=O._x,e.camera.quaternion._y=O._y,e.camera.quaternion._z=O._z,e.camera.quaternion._w=O._w):r.controls.auto=!0,e.camera.position.x=O.x1,e.camera.position.y=O.y1,e.camera.position.z=O.z1,r.controls.target.x=O.x2,r.controls.target.y=O.y2,r.controls.target.z=O.z2,r.controls.update(),n.RenderScene()}),D.onComplete(function(O){r.controls.auto=!1,n.RenderScene(),P&&P(!0),cancelAnimationFrame(i),i=null}),D.easing(cn.Easing.Cubic.InOut);function E(O){i=requestAnimationFrame(E),D.update()}D.start(),E()}function h(){o=document.createElement("div"),o.className="ViewCube",t.appendChild(o),s=document.createElement("div"),s.className="viewSettingWrapper",s.innerHTML="...",o.appendChild(s);var c=document.createElement("div");c.className="homeViewWrapper",c.addEventListener("mousedown",function(){console.log("归位"),n.CameraGoHome()}),o.appendChild(c);const d=document.createElement("div");d.className="cameraToggleWrapper",d.title="切换正交/透视视图",d.innerHTML="⊞",d.addEventListener("mousedown",function(M){M.stopPropagation(),console.log("切换视图"),n.ToggleCameraType(),w()}),o.appendChild(d);const m=document.createElement("div");m.className="screenshotWrapper",m.title="截图",m.innerHTML="📷",m.addEventListener("mousedown",function(M){M.stopPropagation(),console.log("截图"),n.TakeScreenshot(),w()}),o.appendChild(m);const y=document.createElement("div");y.className="fullscreenWrapper",y.title="全屏",y.innerHTML="⛶",y.addEventListener("mousedown",function(M){M.stopPropagation(),console.log("全屏"),n.ToggleFullscreen(),w()}),o.appendChild(y),s.addEventListener("mousedown",function(M){M.stopPropagation(),d.classList.contains("show")?(w(),console.log("隐藏功能按钮")):(v(),console.log("显示功能按钮"))});function w(){d.classList.remove("show"),m.classList.remove("show"),y.classList.remove("show")}function v(){d.classList.add("show"),m.classList.add("show"),y.classList.add("show")}}function u(){n.sceneOrtho=Po();var m=t.clientWidth,y=t.clientWidth,c=m>y?m/y:y/m,d=300;n.camera=new x.OrthographicCamera(d*c/-2,d*c/2,d/2,d/-2,.01,1e4);var m=o.clientWidth,y=o.clientHeight,w=new x.WebGLRenderer({alpha:!0});w.setSize(m,y),w.setClearAlpha(0),n.sceneOrtho.renderer=w;let v=new x.AmbientLight(16777215,.8);n.sceneOrtho.add(v),ko(o,w)}function f(){const c="/assets/viewcube/";let d=[{label:"右",icon:c+"cn_right.png"},{label:"左",icon:c+"cn_left.png"},{label:"顶",icon:c+"cn_top.png"},{label:"底",icon:c+"cn_bottom.png"},{label:"前",icon:c+"cn_front.png"},{label:"后",icon:c+"cn_back.png"}];var m=[];for(const w of d)m.push(new x.MeshBasicMaterial({color:16777215,map:new x.TextureLoader().load(w.icon)}));new x.MeshLambertMaterial({color:255});var y=new x.Mesh(new x.BoxGeometry(110,110,110),m);n.sceneOrtho.add(y),g(122),o.addEventListener("mousedown",w=>{var v={};v.x=w.offsetX/o.clientWidth*2-1,v.y=-(w.offsetY/o.clientHeight)*2+1;var M=new x.Raycaster;M.setFromCamera(v,n.camera);const P=M.intersectObjects(a,!1);P.length>0&&n.ToggleDirectionView(P[0].object.name)}),o.addEventListener("mousemove",w=>{var v={};v.x=w.offsetX/o.clientWidth*2-1,v.y=-(w.offsetY/o.clientHeight)*2+1;var M=new x.Raycaster;M.setFromCamera(v,n.camera);const P=M.intersectObjects(a,!1);for(var D of a)D.material.opacity=.01;P.length>0&&(P[0].object.material.opacity=.2)})}function g(c){for(var d=c*.5-20,m=[{name:"right",a:30,b:75,c:75,point:new x.Vector3(d,0,0)},{name:"back",a:75,b:75,c:30,point:new x.Vector3(0,0,-d)},{name:"left",a:30,b:75,c:75,point:new x.Vector3(-d,0,0)},{name:"front",a:75,b:75,c:30,point:new x.Vector3(0,0,d)},{name:"top",a:75,b:30,c:75,point:new x.Vector3(0,d,0)},{name:"button",a:75,b:30,c:75,point:new x.Vector3(0,-d,0)}],y=[{name:"top_right_back",a:30,b:30,c:30,point:new x.Vector3(-d,d,d)},{name:"button_front_right",a:30,b:30,c:30,point:new x.Vector3(-d,-d,d)},{name:"top_front_right",a:30,b:30,c:30,point:new x.Vector3(d,d,d)},{name:"button_right_back",a:30,b:30,c:30,point:new x.Vector3(d,-d,d)},{name:"top_back_left",a:30,b:30,c:30,point:new x.Vector3(-d,d,-d)},{name:"button_back_left",a:30,b:30,c:30,point:new x.Vector3(-d,-d,-d)},{name:"top_left_front",a:30,b:30,c:30,point:new x.Vector3(d,d,-d)},{name:"button_left_front",a:30,b:30,c:30,point:new x.Vector3(d,-d,-d)}],w=[{name:"top_front",a:30,b:30,c:75,point:new x.Vector3(d,d,0)},{name:"top_right",a:75,b:30,c:30,point:new x.Vector3(0,d,d)},{name:"top_back",a:30,b:30,c:75,point:new x.Vector3(-d,d,0)},{name:"top_left",a:75,b:30,c:30,point:new x.Vector3(0,d,-d)},{name:"button_front",a:30,b:30,c:75,point:new x.Vector3(d,-d,0)},{name:"button_right",a:75,b:30,c:30,point:new x.Vector3(0,-d,d)},{name:"button_back",a:30,b:30,c:75,point:new x.Vector3(-d,-d,0)},{name:"button_left",a:75,b:30,c:30,point:new x.Vector3(0,-d,-d)},{name:"front_right",a:30,b:75,c:30,point:new x.Vector3(d,0,d)},{name:"right_back",a:30,b:75,c:30,point:new x.Vector3(-d,0,d)},{name:"back_left",a:30,b:75,c:30,point:new x.Vector3(-d,0,-d)},{name:"left_front",a:30,b:75,c:30,point:new x.Vector3(d,0,-d)}],v=0;v<m.length;v++)a.push(p(m[v]));for(var v=0;v<y.length;v++)a.push(p(y[v]));for(var v=0;v<w.length;v++)a.push(p(w[v]))}function p(c){const d=new x.BoxGeometry(c.a,c.b,c.c),m=new x.MeshBasicMaterial({color:"blue",transparent:!0,opacity:.01}),y=new x.Matrix4().makeTranslation(c.point.x,c.point.y,c.point.z);let w=d.applyMatrix4(y),v=new x.Mesh(w,m);return v.name=c.name,n.sceneOrtho.add(v),v}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"),m=document.createElement("a"),y=new Date().toISOString().replaceAll(/[:.]/g,"-");m.download=`screenshot_${y}.png`,m.href=d,m.click(),console.log("截图已保存")}catch(c){console.error("截图失败:",c)}},n.ToggleFullscreen=function(){const c=t||document.documentElement;!document.fullscreenElement&&!document.webkitFullscreenElement&&!document.mozFullScreenElement&&!document.msFullscreenElement?(c.requestFullscreen?c.requestFullscreen():c.webkitRequestFullscreen?c.webkitRequestFullscreen():c.mozRequestFullScreen?c.mozRequestFullScreen():c.msRequestFullscreen&&c.msRequestFullscreen(),console.log("已进入全屏模式")):(document.exitFullscreen?document.exitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen(),console.log("已退出全屏模式"))},n}class Eo{engine;cubeTool;constructor(e){this.engine=e}init(){this.cubeTool=Do(this.engine,this.engine.scene,this.engine.container),this.cubeTool.init()}CameraGoHome(){this.cubeTool.CameraGoHome()}zoomToModel(e){this.cubeTool.zoomToBox(e)}}function Lo(r){let e=new Object;return e.getBoundingBox=function(){let t=r.models,n=new x.Vector3(1e8,1e9,1e10),i=new x.Vector3(-1e8,-1e9,-1e10);t.forEach(f=>{let g=f.boundingBox.min,p=f.boundingBox.max;g.x<n.x&&(n.x=g.x),g.y<n.y&&(n.y=g.y),g.z<n.z&&(n.z=g.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 o=Math.min(n.x,i.x),s=Math.min(n.y,i.y),a=Math.min(n.z,i.z),l=Math.max(n.x,i.x),h=Math.max(n.y,i.y),u=Math.max(n.z,i.z);return{min:new x.Vector3(o,s,a),max:new x.Vector3(l,h,u)}},e.rayInterationModel=function(t){let n=[];return r.engineStatus.models.forEach(s=>{s.info.lods.forEach(a=>{let l=a.octreeBox;o(t,l,s)})}),t.intersectObjects(n,!1);function o(s,a,l){if(a==null)return;let h=new x.Vector3(a.min.X*.3048,a.min.Z*.3048,-a.min.Y*.3048),u=new x.Vector3(a.max.X*.3048,a.max.Z*.3048,-a.max.Y*.3048),f=new x.Vector3(Math.min(h.x,u.X),Math.min(h.y,u.y),Math.min(h.z,u.z)),g=new x.Vector3(Math.max(u.x,h.x),Math.max(u.y,h.y),Math.max(u.z,h.z)),p=new x.Box3(f,g),c=s.ray.intersectsBox(p);if(!(c==null||c==!1))if(a.children==null||a.children.length==0){if(a.elements!=null)for(var d of a.elements){let m=r.engineStatus.hideModels.find(v=>v.url==l.url)?.ids;if(m!=null&&m.includes(d))continue;let w=r.models.find(v=>v.url==l.url).nodesMap.get(d);w?.infos.map(M=>M.mesh).forEach(M=>{n.push(M)})}}else{if(a.elements!=null)for(var d of a.elements){let y=r.engineStatus.hideModels.find(M=>M.url==l.url)?.ids;if(y!=null&&y.includes(d))continue;let v=r.models.find(M=>M.url==l.url).nodesMap.get(d);v?.infos.map(P=>P.mesh).forEach(P=>{n.push(P)})}for(let m of a.children)o(s,m,l)}}},e}class Oo{engine;isDrawing=!1;startPoint=new x.Vector2;endPoint=new x.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 Pe(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){if(e.button!==0)return;const t=this.engine.renderer?.domElement;if(!t)return;const n=t.getBoundingClientRect();this.startPoint.set(e.clientX-n.left,e.clientY-n.top),this.endPoint.copy(this.startPoint),this.isDrawing=!0,this.selectionBox&&(this.selectionBox.style.display="block",this.updateSelectionBoxUI()),e.preventDefault(),e.stopPropagation()}onMouseMove(e){if(!this.isDrawing)return;const t=this.engine.renderer?.domElement;if(!t)return;const n=t.getBoundingClientRect();this.endPoint.set(e.clientX-n.left,e.clientY-n.top),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)return;const e=Math.min(this.startPoint.x,this.endPoint.x),t=Math.min(this.startPoint.y,this.endPoint.y),n=Math.abs(this.endPoint.x-this.startPoint.x),i=Math.abs(this.endPoint.y-this.startPoint.y);this.selectionBox.style.left=`${e}px`,this.selectionBox.style.top=`${t}px`,this.selectionBox.style.width=`${n}px`,this.selectionBox.style.height=`${i}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),o=Math.min(this.startPoint.y,this.endPoint.y),s=Math.max(this.startPoint.y,this.endPoint.y),a=[],l=[{x:n,y:o},{x:i,y:o},{x:i,y:s},{x:n,y:s}];for(const u of l){const f=this.worldToScreen.screenToWorld(u.x,u.y);f&&a.push(f)}if(a.length<3){const u=this.engine.camera,f=this.engine.scene,g=new x.Box3;if(f.traverse(p=>{if(p.isMesh&&p.visible&&p.geometry&&(p.geometry.computeBoundingBox(),p.geometry.boundingBox)){const c=p.geometry.boundingBox.clone();c.applyMatrix4(p.matrixWorld),g.union(c)}}),g.isEmpty())for(const c of l){const d=this.worldToScreen.screenToWorldWithDepth(c.x,c.y,10);a.push(d)}else{const p=new x.Vector3;g.getCenter(p);const d=p.clone().sub(u.position).length();for(const m of l){const y=this.worldToScreen.screenToWorldWithDepth(m.x,m.y,d);a.push(y)}}}if(a.length<3){console.warn("RangeScale: 无法将屏幕区域转换为世界坐标");return}const h=new x.Box3;for(const u of a)h.expandByPoint(u);if(h.isEmpty()){console.warn("RangeScale: 计算得到的包围盒无效");return}this.fitCameraToBoundingBox(h)}fitCameraToBoundingBox(e){const t=this.engine.camera,n=this.engine.controls;if(!t||!n){console.warn("RangeScale: 相机或控制器未初始化");return}const i=new x.Vector3;e.getCenter(i);const o=new x.Vector3;e.getSize(o);const s=Math.max(o.x,o.y,o.z);if(t instanceof x.PerspectiveCamera){const a=t.fov*(Math.PI/180),h=s/(2*Math.tan(a/2))*1.2,u=new x.Vector3;t.getWorldDirection(u);const f=i.clone().sub(t.position);u.dot(f.normalize())<0&&u.negate();const p=i.clone().sub(u.multiplyScalar(h));t.position.copy(p),n.target&&n.target.copy(i),t.lookAt(i),n.update()}else if(t instanceof x.OrthographicCamera){const l=s*1.2,h=this.engine.renderer?.domElement,u=h?h.width/h.height:1;t.left=-l*u/2,t.right=l*u/2,t.top=l/2,t.bottom=-l/2,t.updateProjectionMatrix();const f=new x.Vector3;t.getWorldDirection(f);const g=s*1.5,p=i.clone().sub(f.multiplyScalar(g));t.position.copy(p),n.target&&n.target.copy(i),t.lookAt(i),n.update()}}}class No{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 x.AmbientLight);t&&(t.intensity=e)}setAmbientLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof x.AmbientLight);t&&t.color.set(e)}setDirectionalLightIntensity(e){const t=this.engine.scene.children.find(n=>n instanceof x.DirectionalLight);t&&(t.intensity=e)}setDirectionalLightColor(e){const t=this.engine.scene.children.find(n=>n instanceof x.DirectionalLight);t&&t.color.set(e)}setShadowQuality(e){const t=this.engine.scene.children.find(n=>n instanceof x.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 x.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 Se);if(e)if(n)n.enabled=!0;else{const{width:i,height:o}=this.engine.deviceModule.getContainerSize(),s=new Se(this.engine.scene,this.engine.camera,i,o);s.output=Se.OUTPUT.Default,s.blendIntensity=.5,s.updateGtaoMaterial&&s.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,s)}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,o=t?.opacity??.3,s=new x.PlaneGeometry(n,n),a=new x.MeshStandardMaterial({color:i,transparent:!0,opacity:o,side:x.DoubleSide});this.ground=new x.Mesh(s,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 ze(){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 Be{engine;handelBehaved;constructor(e){this.engine=e,this.handelBehaved=pi(e),this.handelBehaved.init(this,null)}active(){this.handelBehaved.active()}disActive(){this.handelBehaved.disActive()}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(c=>{p(c)}),this.engine.measure.annotationData.elevationAnnotation.forEach(c=>{g(c)}),this.engine.measure.annotationData.coordinateAnnotation.forEach(c=>{f(c)}),this.engine.measure.annotationData.angleAnnotation.forEach(c=>{l(c)}),this.engine.measure.annotationData.areaAnnotation.forEach(c=>{h(c)}),this.engine.measure.annotationData.slopeAnnotation.forEach(c=>{u(c)});function l(c){if(c.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">'+c.text+"</text>","</svg>"].join("");c.container=document.createElement("div"),c.container.className="angle-annotation",c.container.id=c.id,c.container.style.pointerEvents="none",c.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(c.container),c.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),c.container.getElementsByTagName("svg")[0].classList.add("Hight"),c.highlight=!0})}let d=new Pe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(c.point1),m=new Pe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(c.point2),y=new Pe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(c.point3),w=c.container;w.getElementsByTagName("circle")[0].setAttribute("cx",d.x),w.getElementsByTagName("circle")[0].setAttribute("cy",d.y),w.getElementsByTagName("circle")[1].setAttribute("cx",m.x),w.getElementsByTagName("circle")[1].setAttribute("cy",m.y),w.getElementsByTagName("circle")[2].setAttribute("cx",y.x),w.getElementsByTagName("circle")[2].setAttribute("cy",y.y),w.getElementsByTagName("polyline")[0].setAttribute("points",d.x+","+d.y+" "+m.x+","+m.y),w.getElementsByTagName("polyline")[1].setAttribute("points",m.x+","+m.y+" "+y.x+","+y.y);let v=m.x,M=m.y-30;w.getElementsByTagName("rect")[0].setAttribute("x",v-40),w.getElementsByTagName("rect")[0].setAttribute("y",M-12.5),w.getElementsByTagName("text")[0].setAttribute("x",v),w.getElementsByTagName("text")[0].setAttribute("y",M+4),w.getElementsByTagName("text")[0].innerHTML=c.text,w.style.top="0px",w.style.left="0px"}function h(c){if(c.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="80" height="25" class="measureBack" />','<text x="40" y="16" text-anchor="middle" class="measureLabel">'+c.text+"</text>","</svg>"].join("");c.container=document.createElement("div"),c.container.className="area-annotation",c.container.id=c.id,c.container.innerHTML=D,e.engine.measure.annotationContainer.appendChild(c.container),c.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),c.container.getElementsByTagName("svg")[0].classList.add("Hight"),c.highlight=!0})}if(!c.points||c.points.length<3)return;let d=[],m=0,y=0;for(let D=0;D<c.points.length;D++){let E=new Pe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(c.points[D]);d.push(E),m+=E.x,y+=E.y}m=m/d.length,y=y/d.length;let w=d.map(D=>D.x+","+D.y).join(" "),v=c.container;v.getElementsByTagName("polygon")[0].setAttribute("points",w),v.getElementsByTagName("polyline")[0].setAttribute("points",w);let M=m,P=y;v.getElementsByTagName("rect")[0].setAttribute("x",M-40),v.getElementsByTagName("rect")[0].setAttribute("y",P-12.5),v.getElementsByTagName("text")[0].setAttribute("x",M),v.getElementsByTagName("text")[0].setAttribute("y",P+4),v.getElementsByTagName("text")[0].innerHTML=c.text,v.style.top="0px",v.style.left="0px"}function u(c){if(c.container==null){let M=['<svg class="measureSvg">',"<defs>",'<marker id="slope-arrow-'+c.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-'+c.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">'+c.text+"</text>","</svg>"].join("");c.container=document.createElement("div"),c.container.className="slope-annotation",c.container.id=c.id,c.container.innerHTML=M,e.engine.measure.annotationContainer.appendChild(c.container),c.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),c.container.getElementsByTagName("svg")[0].classList.add("Hight"),c.highlight=!0})}let d=new Pe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(c.point1),m=new Pe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(c.point2),y=c.container;y.getElementsByTagName("polyline")[0].setAttribute("points",d.x+","+d.y+" "+m.x+","+m.y);let w=(d.x+m.x)/2,v=(d.y+m.y)/2-30;y.getElementsByTagName("rect")[0].setAttribute("x",w-50),y.getElementsByTagName("rect")[0].setAttribute("y",v-12.5),y.getElementsByTagName("text")[0].setAttribute("x",w),y.getElementsByTagName("text")[0].setAttribute("y",v+4),y.getElementsByTagName("text")[0].innerHTML=c.text,y.style.top="0px",y.style.left="0px"}function f(c){if(c.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">'+c.textX+"</text>",'<rect x="0" y="-10" width="100" height="25" class="measureBack" />','<text x="40" y="25" text-anchor="middle" class="measureLabel">'+c.textY+"</text>",'<rect x="0" y="10" width="100" height="25" class="measureBack" />','<text x="40" y="51" text-anchor="middle" class="measureLabel">'+c.textZ+"</text>","</svg>"].join("");c.container=document.createElement("div"),c.container.className="coordinate-annotation",c.container.id=c.id,c.container.style.position="absolute",c.container.style.pointerEvents="none",c.container.innerHTML=P,e.engine.measure.annotationContainer.appendChild(c.container),c.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),c.container.getElementsByTagName("svg")[0].classList.add("Hight"),c.highlight=!0})}let d=c.container,m=new Pe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(c.point);d.style.top="0px",d.style.left="0px";let y=d.getElementsByTagName("circle")[0];y&&(y.setAttribute("cx",m.x),y.setAttribute("cy",m.y));let w=d.getElementsByTagName("rect"),v=d.getElementsByTagName("text"),M=-55;w[0]&&(w[0].setAttribute("x",m.x+10),w[0].setAttribute("y",m.y+10+M)),v[0]&&(v[0].setAttribute("x",m.x+10+40),v[0].setAttribute("y",m.y+10+16+M)),w[1]&&(w[1].setAttribute("x",m.x+10),w[1].setAttribute("y",m.y+10+30+M)),v[1]&&(v[1].setAttribute("x",m.x+10+40),v[1].setAttribute("y",m.y+10+46+M)),w[2]&&(w[2].setAttribute("x",m.x+10),w[2].setAttribute("y",m.y+10+60+M)),v[2]&&(v[2].setAttribute("x",m.x+10+40),v[2].setAttribute("y",m.y+10+76+M)),v[0]&&(v[0].innerHTML=c.textX),v[1]&&(v[1].innerHTML=c.textY),v[2]&&(v[2].innerHTML=c.textZ)}function g(c){if(c.container==null){let y=['<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">'+c.text+"</text>",'<polyline stroke="#f99d0b" stroke-width="2" points="80,32 0,32 16,48 32,32" style="fill: none; opacity: 1;"/>',"</svg>"].join("");c.container=document.createElement("div"),c.container.className="elevation-annotation",c.container.id=c.id,c.container.style.position="absolute",c.container.style.pointerEvents="none",c.container.innerHTML=y,e.engine.measure.annotationContainer.appendChild(c.container),c.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),c.container.getElementsByTagName("svg")[0].classList.add("Hight"),c.highlight=!0})}let d=c.container,m=new Pe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(c.point);d.style.top=m.y-48+"px",d.style.left=m.x-16+"px",d.getElementsByTagName("text")[0].innerHTML=c.text}function p(c){if(c.container==null){let w=['<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">'+c.text+"</text>","</svg>"].join("");c.container=document.createElement("div"),c.container.className="normal-annotation",c.container.id=c.id,c.container.innerHTML=w,e.engine.measure.annotationContainer.appendChild(c.container),c.container.getElementsByTagName("svg")[0].addEventListener("click",function(){e.clearHighlight(),c.container.getElementsByTagName("svg")[0].classList.add("Hight"),c.highlight=!0})}let d=new Pe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(c.point1),m=new Pe(e.engine.camera,e.engine.renderer,e.engine.scene).worldToScreen(c.point2),y=c.container;y.getElementsByTagName("polyline")[0].setAttribute("points",d.x+","+d.y+" "+m.x+","+m.y),y.getElementsByTagName("circle")[0].setAttribute("cx",d.x),y.getElementsByTagName("circle")[0].setAttribute("cy",d.y),y.getElementsByTagName("circle")[1].setAttribute("cx",m.x),y.getElementsByTagName("circle")[1].setAttribute("cy",m.y),y.getElementsByTagName("rect")[0].setAttribute("x",d.x*.5+m.x*.5-40),y.getElementsByTagName("rect")[0].setAttribute("y",d.y*.5+m.y*.5-12.5),y.getElementsByTagName("text")[0].setAttribute("x",d.x*.5+m.x*.5+40-40),y.getElementsByTagName("text")[0].setAttribute("y",d.y*.5+m.y*.5+16-12.5),y.getElementsByTagName("text")[0].innerHTML=c.text,y.style.top="0px",y.style.left="0px"}}}class Ro{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Be(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.isActive=!1,this.behavior.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);t==null&&(t={text:null,id:ze(),isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new x.Raycaster(e.catch.point,new x.Vector3(0,1,0));const i=this.engine.octreeBox.rayInterationModel(n);if(i.length===0)return;let o=e.catch;t.point1=o.point,t.point2=i[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()).toFixed(2)+" m"}}class zo{engine;tools;isActive=!1;points=[];behavior;constructor(e){this.engine=e,this.tools=new Be(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.points=[],this.isActive=!1,this.behavior.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(Re.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:ze(),point1:this.points[0].clone(),point2:t.point.clone(),text:this.points[0].clone().distanceTo(t.point.clone()).toFixed(2)+" m",isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(n)),n.point2=t.point,n.text=n.point1.clone().distanceTo(n.point2.clone()).toFixed(2)+" m",console.log("距离",n.text)}}}class Bo{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Be(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.isActive=!0,this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.isActive=!1,this.behavior.disActive()}clearAllPoints(){this.points=[]}handleMouseClick(e){if(e.catch==null)return;if(this.points.length==0){this.points.push(e.catch.point);return}let t=this.engine.measure.annotationData.normalAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1)}handleMouseMove(e){if(e.catch==null||this.points.length==0)return;let t=this.engine.measure.annotationData.normalAnnotation.find(s=>s.isSelect==!0);t==null&&(t={text:null,id:ze(),isSelect:!0},this.engine.measure.annotationData.normalAnnotation.push(t));let n=new x.Raycaster(e.catch.point,e.catch.normal);const i=this.engine.octreeBox.rayInterationModel(n);if(i.length===0)return;let o=this.tools.renderCatchElement(e.catch);t.point1=o.point,t.point2=i[0].point,t.text=t.point1.clone().distanceTo(t.point2.clone()).toFixed(2)+" m"}}class Io{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Be(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0}disActive(){this.isActive=!1,this.behavior.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.elevationAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:ze(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0},this.engine.measure.annotationData.elevationAnnotation.push(t)),t.point=e.catch.point.clone(),t.text=Math.round(e.catch.point.y)+" m"}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=Math.round(e.catch.point.y)+" m",this.engine.events.trigger(Re.MeasureChanged,t))}}class Fo{engine;isActive=!1;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Be(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active(),this.isActive=!0}disActive(){this.isActive=!1,this.behavior.disActive()}clearAllPoints(){this.points=[]}handleMouseMove(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t==null&&(t={id:ze(),point:e.catch.point.clone(),text:Math.round(e.catch.point.y)+" m",isSelect:!0},this.engine.measure.annotationData.coordinateAnnotation.push(t)),t.point=e.catch.point.clone(),t.textX=Math.round(e.catch.point.x)+" m",t.textY=Math.round(e.catch.point.y)+" m",t.textZ=Math.round(e.catch.point.z)+" m"}handleMouseClick(e){if(e.catch==null)return;let t=this.engine.measure.annotationData.coordinateAnnotation.find(n=>n.isSelect==!0);t!=null&&(t.isSelect=!1,t.point=e.catch.point.clone(),t.textX=Math.round(e.catch.point.x)+" m",t.textY=Math.round(e.catch.point.y)+" m",t.textZ=Math.round(e.catch.point.z)+" m",this.engine.events.trigger(Re.MeasureChanged,t))}}class Uo{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Be(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.points=[],this.behavior.disActive()}clearAllPoints(){this.points=[]}calculateAngle(e,t,n){const i=new x.Vector3().subVectors(e,t),o=new x.Vector3().subVectors(n,t),s=i.length(),a=o.length();if(s===0||a===0)return 0;const h=i.dot(o)/(s*a),u=Math.max(-1,Math.min(1,h));return Math.acos(u)*(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,this.points=[],this.engine.events.trigger(Re.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=this.tools.renderCatchElement(e.catch);if(t!=null&&this.points.length!=1&&this.points.length==2){let n=this.engine.measure.annotationData.angleAnnotation.find(i=>i.isSelect==!0);n==null&&(n={id:ze(),point1:this.points[0].clone(),point2:this.points[1].clone(),point3:t.point.clone(),angle:0,text:"0.00°",isSelect:!0},this.engine.measure.annotationData.angleAnnotation.push(n)),n.point3=t.point.clone(),n.angle=this.calculateAngle(n.point1,n.point2,n.point3),n.text=n.angle.toFixed(2)+"°",console.log("角度",n.text)}}}class Vo{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Be(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.points=[],this.behavior.disActive()}clearAllPoints(){this.points=[]}calculateArea(e){if(e.length<3)return 0;let t=0;const n=e.length;for(let i=0;i<n;i++){const o=(i+1)%n;t+=e[i].x*e[o].z,t-=e[o].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:ze(),points:this.points.map(i=>i.clone()),area:0,text:"0.00 m²",isSelect:!0},this.engine.measure.annotationData.areaAnnotation.push(n)):n.points=this.points.map(i=>i.clone()),n.area=this.calculateArea(n.points),n.text=n.area.toFixed(2)+" m²",console.log("面积",n.text)}}handleMouseMove(e){if(e.catch==null)return;let t=this.tools.renderCatchElement(e.catch);if(t!=null&&this.points.length>=2){let n=this.engine.measure.annotationData.areaAnnotation.find(i=>i.isSelect==!0);if(n==null){if(this.points.length>=2){let i=this.points.map(o=>o.clone());i.push(t.point.clone()),i.length>=3&&(n={id:ze(),points:i,area:0,text:"0.00 m²",isSelect:!0},this.engine.measure.annotationData.areaAnnotation.push(n))}}else if(n.points.length>0){const i=n.points.length-1;n.points[i]=t.point.clone()}else n.points=this.points.map(i=>i.clone()),n.points.push(t.point.clone());n&&n.points.length>=3&&(n.area=this.calculateArea(n.points),n.text=n.area.toFixed(2)+" m²")}}finishMeasure(){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.toFixed(2)+" m²",e.isSelect=!1,this.points=[],this.engine.events.trigger(Re.MeasureChanged,e))}}class jo{engine;tools;points=[];behavior;constructor(e){this.engine=e,this.tools=new Be(e)}active(){this.engine.measure.tools.cancelCurrentSelectedAnnotation(),this.points=[],this.behavior=this.engine.handelBehaved,this.behavior.init(this),this.behavior.active()}disActive(){this.points=[],this.behavior.disActive()}clearAllPoints(){this.points=[]}calculateSlope(e,t){const n=t.y-e.y,i=t.x-e.x,o=t.z-e.z,s=Math.sqrt(i*i+o*o);if(s===0)return{percentage:0,angle:0,heightDiff:n,horizontalDist:0};const a=n/s*100,h=Math.atan(n/s)*(180/Math.PI);return{percentage:a,angle:h,heightDiff:n,horizontalDist:s}}handleMouseClick(e){if(e.catch==null)return;let t=this.tools.renderCatchElement(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(o=>o.isSelect==!0);if(n==null)return;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(Re.MeasureChanged,n)}}handleMouseMove(e){if(e.catch==null)return;let t=this.tools.renderCatchElement(e.catch);if(t!=null&&this.points.length==1){let n=this.engine.measure.annotationData.slopeAnnotation.find(o=>o.isSelect==!0);n==null&&(n={id:ze(),point1:this.points[0].clone(),point2:t.point.clone(),slopePercentage:0,slopeAngle:0,heightDiff:0,horizontalDist:0,text:"0.00% (0.00°)",isSelect:!0},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)+"°)",console.log("坡度",n.text)}}}class Go{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 Ro(e),this.distanceMeasure=new zo(e),this.clearDistanceMeasure=new Bo(e),this.elevationMeasure=new Io(e),this.pointMeasure=new Fo(e),this.angleMeasure=new Uo(e),this.areaMeasure=new Vo(e),this.slopeMeasure=new jo(e),this.tools=new Be(e),this.annotationContainer=document.createElement("div"),this.annotationContainer.className="annotation-container",e.container.parentElement.appendChild(this.annotationContainer)}active(){this.isActive=!0,this.tools.active()}disActive(){this.tools.disActive(),this.clearAll(),this.isActive=!1,this.clearHeightMeasure.disActive(),this.distanceMeasure.disActive(),this.clearDistanceMeasure.disActive(),this.elevationMeasure.disActive(),this.pointMeasure.disActive(),this.angleMeasure.disActive(),this.areaMeasure.disActive(),this.slopeMeasure.disActive(),this.engine.interactionModule.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=[]}}update(){this.isActive&&this.tools.drawNormalAnnotation()}}class Wo{engine;isActive=!1;isDrag=!1;meshs=[];box;pickPoint;pickNormal;pickMesh;box_;plane;constructor(e){this.engine=e,this.meshs=[],this.box=null}active(){if(this.isActive==!0)return;this.isActive=!0,this.init(),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=="前"),t)})}disActive(){this.isActive=!1,this.engine.handelBehaved.disActive()}init(){let e=this.engine.octreeBox.getBoundingBox();this.box=e,this.updata_face(e)}updata_face(e){let t=this,n=t.engine.scene.children.find(s=>s.type=="Group"&&s.name=="ClippingBox");n==null&&(n=new x.Group,n.name="ClippingBox",t.engine.scene.add(n));let i=[new x.Vector3(e.min.x,e.min.y,e.min.z),new x.Vector3(e.max.x,e.min.y,e.min.z),new x.Vector3(e.max.x,e.max.y,e.min.z),new x.Vector3(e.min.x,e.max.y,e.min.z)];o(i,new x.Vector3(0,0,-1),"前");function o(s,a,l){const h=new x.BufferGeometry,u=new Float32Array([s[0].x,s[0].y,s[0].z,s[1].x,s[1].y,s[1].z,s[2].x,s[2].y,s[2].z,s[3].x,s[3].y,s[3].z]),f=[0,1,2,0,2,3];h.setAttribute("position",new x.BufferAttribute(u,3)),h.setIndex(f);let g=t.meshs.find(y=>y.name==l);if(g==null){const y=new x.MeshBasicMaterial({color:65280,transparent:!0,opacity:.02,side:x.DoubleSide}),w=new x.Mesh(h,y);w.normal=a,w.name=l,n.add(w),t.meshs.push(w)}else g.geometry=h;const p=new Float32Array([s[0].x,s[0].y,s[0].z,s[1].x,s[1].y,s[1].z,s[2].x,s[2].y,s[2].z,s[3].x,s[3].y,s[3].z,s[0].x,s[0].y,s[0].z]);let c=new x.LineBasicMaterial({color:255}),d=new x.BufferGeometry;d.setAttribute("position",new x.BufferAttribute(p,3));let m=t.meshs.find(y=>y.name==l+"Line");m==null&&(m=new x.Line(d,c),m.name=l+"Line",n.add(m),t.meshs.push(m)),m.geometry=d,m.material=c,t.engine.sectionPlane.find(y=>y.name==l).setFromNormalAndCoplanarPoint(a.clone().setLength(-1),e.min)}}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 x.Plane;n.setFromNormalAndCoplanarPoint(new x.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new x.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new x.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 x.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)}}}}class Ko{engine;isActive=!1;isDrag=!1;meshs=[];box;pickPoint;pickNormal;pickMesh;box_;plane;constructor(e){this.engine=e,this.meshs=[],this.box=null}active(){this.isActive!=!0&&(this.isActive=!0,this.init(),this.engine.handelBehaved.init(this),this.engine.handelBehaved.active())}disActive(){this.isActive=!1,this.engine.handelBehaved.disActive()}init(){let e=this.engine.octreeBox.getBoundingBox();this.box=e,this.updata_face(e)}updata_face(e){let t=this,n=t.engine.scene.children.find(s=>s.type=="Group"&&s.name=="ClippingBox");n==null&&(n=new x.Group,n.name="ClippingBox",t.engine.scene.add(n));let i=[new x.Vector3(e.min.x,e.max.y,e.min.z),new x.Vector3(e.max.x,e.max.y,e.min.z),new x.Vector3(e.max.x,e.max.y,e.max.z),new x.Vector3(e.min.x,e.max.y,e.max.z)];o(i,new x.Vector3(0,1,0),"顶");function o(s,a,l){const h=new x.BufferGeometry,u=new Float32Array([s[0].x,s[0].y,s[0].z,s[1].x,s[1].y,s[1].z,s[2].x,s[2].y,s[2].z,s[3].x,s[3].y,s[3].z]),f=[0,1,2,0,2,3];h.setAttribute("position",new x.BufferAttribute(u,3)),h.setIndex(f);let g=t.meshs.find(y=>y.name==l);if(g==null){const y=new x.MeshBasicMaterial({color:65280,transparent:!0,opacity:.02,side:x.DoubleSide}),w=new x.Mesh(h,y);w.normal=a,w.name=l,n.add(w),t.meshs.push(w)}else g.geometry=h;const p=new Float32Array([s[0].x,s[0].y,s[0].z,s[1].x,s[1].y,s[1].z,s[2].x,s[2].y,s[2].z,s[3].x,s[3].y,s[3].z,s[0].x,s[0].y,s[0].z]);let c=new x.LineBasicMaterial({color:255}),d=new x.BufferGeometry;d.setAttribute("position",new x.BufferAttribute(p,3));let m=t.meshs.find(y=>y.name==l+"Line");m==null&&(m=new x.Line(d,c),m.name=l+"Line",n.add(m),t.meshs.push(m)),m.geometry=d,m.material=c,t.engine.sectionPlane.find(y=>y.name==l).setFromNormalAndCoplanarPoint(a.clone().setLength(-1),e.max),t.engine.scene.children.filter(y=>y.type=="Mesh"&&y.url).forEach(y=>{y.material&&Array.isArray(y.material)?y.material.forEach(w=>{w.clippingPlanes=t.engine.sectionPlane}):y.material.clippingPlanes=t.engine.sectionPlane})}}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 x.Plane;n.setFromNormalAndCoplanarPoint(new x.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new x.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new x.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 x.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)}}}}class Xo{engine;isActive=!1;isDrag=!1;meshs=[];box;pickPoint;pickNormal;pickMesh;box_;plane;constructor(e){this.engine=e,this.meshs=[],this.box=null}active(){this.isActive!=!0&&(this.isActive=!0,this.init(),this.engine.handelBehaved.init(this),this.engine.handelBehaved.active())}disActive(){this.isActive=!1,this.engine.handelBehaved.disActive()}init(){let e=this.engine.octreeBox.getBoundingBox();this.box=e,this.updata_face(e)}updata_face(e){let t=this,n=t.engine.scene.children.find(s=>s.type=="Group"&&s.name=="ClippingBox");n==null&&(n=new x.Group,n.name="ClippingBox",t.engine.scene.add(n));let i=[new x.Vector3(e.min.x,e.min.y,e.max.z),new x.Vector3(e.min.x,e.min.y,e.min.z),new x.Vector3(e.min.x,e.max.y,e.min.z),new x.Vector3(e.min.x,e.max.y,e.max.z)];o(i,new x.Vector3(-1,0,0),"左");function o(s,a,l){const h=new x.BufferGeometry,u=new Float32Array([s[0].x,s[0].y,s[0].z,s[1].x,s[1].y,s[1].z,s[2].x,s[2].y,s[2].z,s[3].x,s[3].y,s[3].z]),f=[0,1,2,0,2,3];h.setAttribute("position",new x.BufferAttribute(u,3)),h.setIndex(f);let g=t.meshs.find(y=>y.name==l);if(g==null){const y=new x.MeshBasicMaterial({color:65280,transparent:!0,opacity:.02,side:x.DoubleSide}),w=new x.Mesh(h,y);w.normal=a,w.name=l,n.add(w),t.meshs.push(w)}else g.geometry=h;const p=new Float32Array([s[0].x,s[0].y,s[0].z,s[1].x,s[1].y,s[1].z,s[2].x,s[2].y,s[2].z,s[3].x,s[3].y,s[3].z,s[0].x,s[0].y,s[0].z]);let c=new x.LineBasicMaterial({color:255}),d=new x.BufferGeometry;d.setAttribute("position",new x.BufferAttribute(p,3));let m=t.meshs.find(y=>y.name==l+"Line");m==null&&(m=new x.Line(d,c),m.name=l+"Line",n.add(m),t.meshs.push(m)),m.geometry=d,m.material=c,t.engine.sectionPlane.find(y=>y.name==l).setFromNormalAndCoplanarPoint(a.clone().setLength(-1),e.min),t.engine.scene.children.filter(y=>y.type=="Mesh"&&y.url).forEach(y=>{y.material&&Array.isArray(y.material)?y.material.forEach(w=>{w.clippingPlanes=t.engine.sectionPlane}):y.material.clippingPlanes=t.engine.sectionPlane})}}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 x.Plane;n.setFromNormalAndCoplanarPoint(new x.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new x.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new x.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 x.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)}}}}class Zo{engine;isActive=!1;box;pickPoint;pickNormal;pickMesh;box_;plane;meshs;isDrag=!1;constructor(e){this.engine=e,this.meshs=[]}active(){this.isActive=!0,this.init(),this.engine.handelBehaved.init(this),this.engine.handelBehaved.active()}disActive(){this.isActive=!1,this.engine.handelBehaved.disActive()}init(){let e=this.engine.octreeBox.getBoundingBox();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 x.Plane;n.setFromNormalAndCoplanarPoint(new x.Vector3(0,1,0),this.pickPoint),this.plane=n}else{let n=new x.Vector3(this.engine.camera.position.x,this.pickPoint.y,this.engine.camera.position.z);const i=new x.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 x.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)}}}updata_face(e){let t=this,n=[new x.Vector3(e.min.x,e.min.y,e.min.z),new x.Vector3(e.max.x,e.min.y,e.min.z),new x.Vector3(e.max.x,e.max.y,e.min.z),new x.Vector3(e.min.x,e.max.y,e.min.z)],i=[new x.Vector3(e.min.x,e.min.y,e.max.z),new x.Vector3(e.max.x,e.min.y,e.max.z),new x.Vector3(e.max.x,e.max.y,e.max.z),new x.Vector3(e.min.x,e.max.y,e.max.z)],o=[new x.Vector3(e.max.x,e.min.y,e.max.z),new x.Vector3(e.max.x,e.min.y,e.min.z),new x.Vector3(e.max.x,e.max.y,e.min.z),new x.Vector3(e.max.x,e.max.y,e.max.z)],s=[new x.Vector3(e.min.x,e.min.y,e.min.z),new x.Vector3(e.min.x,e.min.y,e.max.z),new x.Vector3(e.min.x,e.max.y,e.max.z),new x.Vector3(e.min.x,e.max.y,e.min.z)],a=[new x.Vector3(e.min.x,e.max.y,e.min.z),new x.Vector3(e.max.x,e.max.y,e.min.z),new x.Vector3(e.max.x,e.max.y,e.max.z),new x.Vector3(e.min.x,e.max.y,e.max.z)],l=[new x.Vector3(e.min.x,e.min.y,e.min.z),new x.Vector3(e.max.x,e.min.y,e.min.z),new x.Vector3(e.max.x,e.min.y,e.max.z),new x.Vector3(e.min.x,e.min.y,e.max.z)];h(n,new x.Vector3(0,0,-1),"前"),h(i,new x.Vector3(0,0,1),"后"),h(o,new x.Vector3(1,0,0),"右"),h(s,new x.Vector3(-1,0,0),"左"),h(a,new x.Vector3(0,1,0),"顶"),h(l,new x.Vector3(0,-1,0),"底");function h(u,f,g){const p=new x.BufferGeometry,c=new Float32Array([u[0].x,u[0].y,u[0].z,u[1].x,u[1].y,u[1].z,u[2].x,u[2].y,u[2].z,u[3].x,u[3].y,u[3].z]),d=[0,1,2,0,2,3];p.setAttribute("position",new x.BufferAttribute(c,3)),p.setIndex(d);let m=t.engine.scene.children.find(D=>D.type=="Group"&&D.name=="ClippingBox");m==null&&(m=new x.Group,m.name="ClippingBox",t.engine.scene.add(m));let y=t.meshs.find(D=>D.name==g);if(y==null){const D=new x.MeshBasicMaterial({color:65280,transparent:!0,opacity:0,side:x.DoubleSide}),E=new x.Mesh(p,D);E.normal=f,E.name=g,m.add(E),t.meshs.push(E)}else y.geometry=p;const w=new Float32Array([u[0].x,u[0].y,u[0].z,u[1].x,u[1].y,u[1].z,u[2].x,u[2].y,u[2].z,u[3].x,u[3].y,u[3].z,u[0].x,u[0].y,u[0].z]);let v=new x.LineBasicMaterial({color:255}),M=new x.BufferGeometry;M.setAttribute("position",new x.BufferAttribute(w,3));let P=t.meshs.find(D=>D.name==g+"Line");P==null&&(P=new x.Line(M,v),P.name=g+"Line",m.add(P),t.meshs.push(P)),P.geometry=M,P.material=v,g=="前"||g=="左"||g=="底"?t.engine.sectionPlane.find(D=>D.name==g).setFromNormalAndCoplanarPoint(f.clone().setLength(-1),e.min):t.engine.sectionPlane.find(D=>D.name==g).setFromNormalAndCoplanarPoint(f.clone().setLength(-1),e.max),t.engine.scene.children.filter(D=>D.type=="Mesh"&&D.url).forEach(D=>{D.material&&Array.isArray(D.material)?D.material.forEach(E=>{E.clippingPlanes=t.engine.sectionPlane}):D.material.clippingPlanes=t.engine.sectionPlane})}}}class qo{engine;planeObjects=[];planes=[];isActive=!1;planeSize=100;constructor(e){this.engine=e}init(){this.calculateSceneSize();const e=new x.PlaneGeometry(this.planeSize,this.planeSize);let t=0;this.planes.forEach(n=>{const i=new x.Group,o=new x.MeshStandardMaterial({color:new x.Color(8421504),metalness:.1,roughness:.75,clippingPlanes:this.planes.filter(a=>a!==n),stencilWrite:!0,stencilRef:0,stencilFunc:x.NotEqualStencilFunc,stencilFail:x.ReplaceStencilOp,stencilZFail:x.ReplaceStencilOp,stencilZPass:x.ReplaceStencilOp,side:x.DoubleSide,depthWrite:!0,depthTest:!0}),s=new x.Mesh(e,o);s.onAfterRender=function(a){a.clearStencil()},s.renderOrder=t+1.1,s.visible=!1,this.planeObjects.push(s),t=t+1,i.add(s),this.engine.scene.add(i)})}active(){this.isActive=!0,this.planeObjects.forEach(e=>{e.visible=!0})}disActive(){this.isActive=!1,this.planeObjects.forEach(e=>{e.visible=!1})}calculateSceneSize(){const e=new x.Box3;if(this.engine.scene.traverse(t=>{if(t.isMesh&&t.geometry){const n=new x.Box3().setFromObject(t);e.union(n)}}),e.isEmpty())this.planeSize=100;else{const t=e.getSize(new x.Vector3),n=Math.max(t.x,t.y,t.z);this.planeSize=n*2}}addMesh(e,t){const n=this.createPlaneStencilGroup(t.geometry.clone(),e,1);this.engine.scene.add(n),this.calculateSceneSize(),this.updatePlaneGeometry()}updatePlaneGeometry(){const e=new x.PlaneGeometry(this.planeSize,this.planeSize);this.planeObjects.forEach(t=>{t.geometry.dispose(),t.geometry=e})}createPlaneStencilGroup(e,t,n){const i=new x.Group,o=new x.MeshBasicMaterial;o.depthWrite=!1,o.depthTest=!1,o.colorWrite=!1,o.stencilWrite=!0,o.stencilFunc=x.AlwaysStencilFunc;const s=o.clone();s.side=x.BackSide,s.clippingPlanes=[t],s.stencilFail=x.IncrementWrapStencilOp,s.stencilZFail=x.IncrementWrapStencilOp,s.stencilZPass=x.IncrementWrapStencilOp;const a=new x.Mesh(e,s);a.renderOrder=n,i.add(a);const l=o.clone();l.side=x.FrontSide,l.clippingPlanes=[t],l.stencilFail=x.DecrementWrapStencilOp,l.stencilZFail=x.DecrementWrapStencilOp,l.stencilZPass=x.DecrementWrapStencilOp;const h=new x.Mesh(e,l);return h.renderOrder=n,i.add(h),i}updata(){if(this.isActive)for(let e=0;e<this.planeObjects.length;e++){const t=this.planes[e],n=this.planeObjects[e];Math.abs(t.constant)<99999?(n.visible=!0,t.coplanarPoint(n.position),n.lookAt(n.position.x-t.normal.x,n.position.y-t.normal.y,n.position.z-t.normal.z)):n.visible=!1}}}class Yo{engine;sectionPlaneX;sectionPlaneY;sectionPlaneZ;sectionBox;clippingStencil;constructor(e){this.engine=e,this.sectionPlaneX=new Wo(e),this.sectionPlaneY=new Ko(e),this.sectionPlaneZ=new Xo(e),this.sectionBox=new Zo(e);let t=new x.Plane(new x.Vector3(0,0,1),1e5);t.name="前";let n=new x.Plane(new x.Vector3(0,0,1),1e5);n.name="左";let i=new x.Plane(new x.Vector3(0,0,1),1e5);i.name="后";let o=new x.Plane(new x.Vector3(0,0,1),1e5);o.name="右";let s=new x.Plane(new x.Vector3(0,0,1),1e5);s.name="顶";let a=new x.Plane(new x.Vector3(0,0,1),1e5);a.name="底",this.engine.sectionPlane=[t,n,i,o,s,a],this.clippingStencil=new qo(e),this.clippingStencil.planes=[t,n,i,o,s,a],this.clippingStencil.init(),this.clippingStencil.active()}disActive(){this.sectionPlaneX.disActive(),this.sectionPlaneY.disActive(),this.sectionPlaneZ.disActive(),this.sectionBox.disActive()}}class Ho{engine;constructor(e){this.engine=e}getTreeData(){let e=[];return this.engine.engineStatus.models.forEach(t=>{e.push({children:t.info.modelTree.modelTreeLevel,name:t.info.baseInfo.name})}),e}}class $o{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 x.Mesh){const o=i.geometry;if(o&&o.attributes){const s=o.attributes.position;if(s){const a=s.count;e+=a;let l=0;o.index?l=o.index.count/3:l=a/3,t+=l,n++}}}}),{totalVertices:Math.floor(e),totalTriangles:Math.floor(t),meshCount:n})}}class Qo{engine;constructor(e){this.engine=e}init(){}getModelProperties(e,t,n){let i=this.engine.engineStatus.models.find(s=>s.url===e);i.properties==null&&ii(e+"/property.zip",s=>{let a=JSON.parse(s);i.properties=a,setTimeout(()=>{o(a,t,n)},100)}),o(i.properties,t,n);function o(s,a,l){let h=[],u=s.models[a.toString()||""],f=u.map(g=>g[0]);f=f.filter((g,p)=>f.indexOf(g)===p),f.forEach(g=>{let p={name:s.categorys[g],children:[]};h.push(p),u.filter(c=>c[0]===g).forEach(c=>{p.children.push({name:s.names[c[1]],value:s.values[c[2]]})})}),l?.({properties:h,materials:[]})}}}class Jo{engine;constructor(e){this.engine=e}getModelTypes(){let e=[];this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.typeName)})})}getModelMajors(){let e=[];this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.majorName)})})}getModelLevels(){let e=[];this.engine.engineStatus.models.forEach(t=>{t.info.modelMapper.forEach(i=>{e.push(i.levelName)})})}getModelMappers(e){}getModelMapper(e,t){let n=this.engine.engineStatus.models.find(s=>s.url==e);return n?n.info.modelMapper.find(s=>s.id==t):null}getModelSWithType(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let o={url:i.url,ids:[]};n.push(o),i.info.modelMapper.filter(a=>a.typeName===e).forEach(a=>{o.ids.push(Number(a.id))})}),t(n),n}getModelSWithLevel(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let o={url:i.url,ids:[]};n.push(o),i.info.modelMapper.filter(a=>a.levelName===e).forEach(a=>{o.ids.push(Number(a.id))})}),t(n),n}getModelsWithMajor(e,t){let n=[];return this.engine.engineStatus.models.forEach(i=>{let o={url:i.url,ids:[]};n.push(o),i.info.modelMapper.filter(a=>a.majorName===e).forEach(a=>{o.ids.push(Number(a.id))})}),t(n),n}}class ea{engine;isActive=!1;groupEdge;material;indexes=new Map;constructor(e){this.engine=e,this.groupEdge=this.engine.scene.getObjectByName("groupEdge"),this.material=new x.LineBasicMaterial({color:"#000000",depthTest:!0})}active(){this.isActive=!0,this.groupEdge.visible=!0,this.show()}disActive(){this.isActive=!1,this.groupEdge.visible=!1}show(){this.engine.engineStatus.models.forEach(e=>{if(!this.groupEdge.children.find(n=>n.url==e.url)){let n=e.info,i=[],o=new Map;n.modelEdge.forEach(l=>{let h=i.length;for(let u=0;u<l.points.length;u++)l.points[u].length==2&&(i.push(l.points[u][0].X),i.push(l.points[u][0].Z),i.push(-l.points[u][0].Y),i.push(l.points[u][1].X),i.push(l.points[u][1].Z),i.push(-l.points[u][1].Y));o.set(Number(l.id),[h,i.length,l.points])}),this.indexes.set(e.url,o);let s=new x.BufferGeometry;s.setAttribute("position",new x.Float32BufferAttribute(i,3));const a=new x.LineSegments(s,this.material);a.url=e.url,this.groupEdge.add(a)}})}getModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i)return i}return null}hideModelEdge(e,t){let n=this.indexes.get(e);if(n){let i=n.get(t);if(i){let[o,s,a]=i,l=this.groupEdge.children.find(h=>h.url==e);if(l){let h=l.geometry.attributes.position.array;for(let u=o;u<s;u++)h[u]=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[o,s,a]=i,l=this.groupEdge.children.find(h=>h.url==e);if(l){let h=l.geometry.attributes.position.array,u=0;for(let f=o;f<s;f+=3){const g=Math.floor(u/6),p=u%6>=3;if(a[g]&&a[g].length===2){const c=p?a[g][1]:a[g][0];h[f]=c.X,h[f+1]=c.Z,h[f+2]=-c.Y}u+=3}l.geometry.attributes.position.needsUpdate=!0}}}}}class ta{options;DeviceType;animationId=null;animate;scene;camera;renderer;sceneModule;cameraModule;deviceModule;renderModule;controlModule;composerModule;loaderModule;engineStatus;events;lightModule;interactionModule;modelToolModule;worldToScreen;handelBehaved;octreeBox;controls;stats;catchSvg;viewCube;rangeScale;setting;measure;clipping;modelTree;engineInfo;modelProperties;modelMapperBatch;modelEdge;models=[];container;constructor(e){if(this.options=e,this.container=document.getElementById(e.containerId),!this.container)throw new Error(`Container ${e.containerId} not found`);this.deviceModule=new xi(this),this.DeviceType=this.deviceModule.getDeviceType(),this.cameraModule=new bi(this),this.sceneModule=new wi(this),this.scene=this.sceneModule.scene,this.renderModule=new vi(this),this.renderer=this.renderModule.createRenderer(),this.camera=this.cameraModule.orthographicCamera,this.scene.camera=this.camera,this.controlModule=new Bi(this),this.controlModule.switchDefaultMode(),this.controls=this.controlModule.orbitControls,this.composerModule=new Qi(this),this.composerModule.init(),this.events=new _o,this.engineStatus=new yo(this),this.engineStatus.init(),this.loaderModule=new go(this),this.lightModule=new wo(this),this.lightModule.init(),this.viewCube=new Eo(this),this.viewCube.init(),this.octreeBox=Lo(this),this.rangeScale=new Oo(this),this.rangeScale.init(),this.clipping=new Yo(this),this.setting=new No(this),this.setting.init(),this.handelBehaved=pi(this),this.modelMapperBatch=new Jo(this),this.measure=new Go(this),this.modelToolModule=new xo(this),this.modelProperties=new Qo(this),this.interactionModule=new bo(this),this.interactionModule.init(),this.interactionModule.active(),this.modelEdge=new ea(this),this.modelTree=new Ho(this),this.engineInfo=new $o(this),this.worldToScreen=new Pe(this.camera,this.renderer,this.scene),this.stats=new Ao,this.stats.showPanel(0),this.stats.dom.style.position="absolute",this.stats.dom.style.top="0px",this.stats.dom.style.left="0px",this.stats.dom.style.zIndex="1000",this.container.appendChild(this.stats.dom);let t=document.createElementNS("http://www.w3.org/2000/svg","svg");t.style.position="absolute",t.style.width="100%",t.style.height="100%",t.style.zIndex="1000",t.style.left="0px",t.style.top="0px",t.style.pointerEvents="none";const n=this.renderer?.domElement.width||1920,i=this.renderer?.domElement.height||1080;t.setAttribute("viewBox",`0 0 ${n} ${i}`),t.setAttribute("preserveAspectRatio","none"),this.container.appendChild(t),this.catchSvg=t,this.animate=()=>{this.animationId=requestAnimationFrame(this.animate),this.stats&&this.stats.begin(),this.composerModule,this.renderer?.render(this.scene,this.camera),this.viewCube.cubeTool.RenderScene(),this.measure.update(),this.controlModule.update(),this.clipping&&this.clipping.clippingStencil&&this.clipping.clippingStencil.updata(),this.stats&&this.stats.end()},this.animate()}}function na(r){return new ta(r)}Ve.createEngine=na,Object.defineProperty(Ve,Symbol.toStringTag,{value:"Module"})}));
841
+ //# sourceMappingURL=bim-engine-sdk.umd.js.map