@qaecy/cue-ui 0.0.57 → 0.0.58

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 (75) hide show
  1. package/1051.js +1 -1
  2. package/1138.js +1 -1
  3. package/1153.js +1 -1
  4. package/1338.js +1 -1
  5. package/1520.js +1 -0
  6. package/1837.js +1 -1
  7. package/1985.js +1 -1
  8. package/2003.js +1 -0
  9. package/2014.js +1 -0
  10. package/2021.js +1 -1
  11. package/2081.js +1 -1
  12. package/2245.js +1 -1
  13. package/2283.js +1 -0
  14. package/2317.js +1 -1
  15. package/2775.js +1 -1
  16. package/2839.js +1 -1
  17. package/29.js +1 -1
  18. package/3036.js +1 -1
  19. package/3039.js +1 -1
  20. package/3288.js +1 -1
  21. package/3319.js +1 -0
  22. package/3577.js +1 -1
  23. package/3614.js +1 -1
  24. package/4098.js +1 -0
  25. package/4283.js +1 -1
  26. package/4311.js +1 -1
  27. package/4791.js +1 -0
  28. package/5277.js +1 -0
  29. package/5381.js +1 -0
  30. package/5448.js +1 -0
  31. package/5559.js +1 -1
  32. package/5649.js +1 -1
  33. package/5738.js +1 -1
  34. package/5872.js +1 -1
  35. package/5971.js +1 -0
  36. package/6027.js +1 -0
  37. package/617.js +1 -1
  38. package/6233.js +1 -1
  39. package/63.js +1 -1
  40. package/6419.js +1 -1
  41. package/6423.js +1 -1
  42. package/650.js +1 -1
  43. package/6947.js +1 -1
  44. package/7089.js +1 -0
  45. package/7154.js +1 -0
  46. package/7313.js +1 -0
  47. package/7441.js +1 -1
  48. package/7719.js +1 -1
  49. package/7802.js +1 -0
  50. package/7851.js +1 -0
  51. package/804.js +1 -1
  52. package/8194.js +1 -0
  53. package/8560.js +1 -1
  54. package/8659.js +1 -0
  55. package/880.js +1 -0
  56. package/8855.js +1 -1
  57. package/8957.js +1 -1
  58. package/928.js +1 -1
  59. package/9396.js +1 -1
  60. package/992.js +1 -0
  61. package/common.js +1 -1
  62. package/index.js +1 -1
  63. package/main.js +1 -1
  64. package/package.json +1 -1
  65. package/2399.js +0 -1
  66. package/2516.js +0 -1
  67. package/4687.js +0 -1
  68. package/4879.js +0 -1
  69. package/5041.js +0 -1
  70. package/5071.js +0 -1
  71. package/5137.js +0 -1
  72. package/7056.js +0 -1
  73. package/8336.js +0 -1
  74. package/8791.js +0 -1
  75. package/9376.js +0 -1
package/6419.js CHANGED
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[6419],{6419(Jc,vn,mt){mt.d(vn,{BIMFragmentsViewer:()=>Ag});var st=mt(5802),Tt=mt(7705),Ot=mt(2271),$i=mt(8807),G=mt(467),ot=mt(6095),p=mt(4701),bn=(mt(3973),mt(7126)),$=mt(639),ji=mt(2085);const j=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,SCREEN_PAN:4,OFFSET:8,DOLLY:16,ZOOM:32,TOUCH_ROTATE:64,TOUCH_TRUCK:128,TOUCH_SCREEN_PAN:256,TOUCH_OFFSET:512,TOUCH_DOLLY:1024,TOUCH_ZOOM:2048,TOUCH_DOLLY_TRUCK:4096,TOUCH_DOLLY_SCREEN_PAN:8192,TOUCH_DOLLY_OFFSET:16384,TOUCH_DOLLY_ROTATE:32768,TOUCH_ZOOM_TRUCK:65536,TOUCH_ZOOM_OFFSET:131072,TOUCH_ZOOM_SCREEN_PAN:262144,TOUCH_ZOOM_ROTATE:524288});function Oe(r){return r.isPerspectiveCamera}function Nt(r){return r.isOrthographicCamera}const ze=2*Math.PI,ue=Math.PI/2,Mt=Math.PI/180;function de(r,t,e){return Math.max(t,Math.min(e,r))}function It(r,t=1e-5){return Math.abs(r)<t}function Pt(r,t,e=1e-5){return It(r-t,e)}function vo(r,t){return Math.round(r/t)*t}function Hi(r){return isFinite(r)?r:r<0?-Number.MAX_VALUE:Number.MAX_VALUE}function qi(r){return Math.abs(r)<Number.MAX_VALUE?r:r*(1/0)}function _s(r,t,e,i,s=1/0,n){const o=2/(i=Math.max(1e-4,i)),a=o*n,l=1/(1+a+.48*a*a+.235*a*a*a);let c=r-t;const h=t,u=s*i;c=de(c,-u,u),t=r-c;const f=(e.value+o*c)*n;e.value=(e.value-o*f)*l;let d=t+(c+f)*l;return h-r>0==d>h&&(d=h,e.value=(d-h)/n),d}function bo(r,t,e,i,s=1/0,n,o){const a=2/(i=Math.max(1e-4,i)),l=a*n,c=1/(1+l+.48*l*l+.235*l*l*l);let h=t.x,u=t.y,f=t.z,d=r.x-h,_=r.y-u,m=r.z-f;const w=h,g=u,v=f,T=s*i,S=d*d+_*_+m*m;if(S>T*T){const N=Math.sqrt(S);d=d/N*T,_=_/N*T,m=m/N*T}h=r.x-d,u=r.y-_,f=r.z-m;const M=(e.x+a*d)*n,A=(e.y+a*_)*n,O=(e.z+a*m)*n;return e.x=(e.x-a*M)*c,e.y=(e.y-a*A)*c,e.z=(e.z-a*O)*c,o.x=h+(d+M)*c,o.y=u+(_+A)*c,o.z=f+(m+O)*c,(w-r.x)*(o.x-w)+(g-r.y)*(o.y-g)+(v-r.z)*(o.z-v)>0&&(o.x=w,o.y=g,o.z=v,e.x=(o.x-w)/n,e.y=(o.y-g)/n,e.z=(o.z-v)/n),o}function xn(r,t){t.set(0,0),r.forEach(e=>{t.x+=e.clientX,t.y+=e.clientY}),t.x/=r.length,t.y/=r.length}function Cn(r,t){return!!Nt(r)&&(console.warn(`${t} is not supported in OrthographicCamera`),!0)}class th{_listeners={};addEventListener(t,e){const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){const s=this._listeners[t];if(void 0!==s){const n=s.indexOf(e);-1!==n&&s.splice(n,1)}}removeAllEventListeners(t){t?Array.isArray(this._listeners[t])&&(this._listeners[t].length=0):this._listeners={}}dispatchEvent(t){const i=this._listeners[t.type];if(void 0!==i){t.target=this;const s=i.slice(0);for(let n=0,o=s.length;n<o;n++)s[n].call(this,t)}}}const ys=1/8,ih=/Mac/.test(globalThis?.navigator?.platform);let gt,xo,ws,Tn,ee,yt,Ct,yi,Gi,Ce,Te,ai,Co,To,ae,wi,vi,Po,Pn,So,Sn,En,vs;class Zt extends th{static install(t){gt=t.THREE,xo=Object.freeze(new gt.Vector3(0,0,0)),ws=Object.freeze(new gt.Vector3(0,1,0)),Tn=Object.freeze(new gt.Vector3(0,0,1)),ee=new gt.Vector2,yt=new gt.Vector3,Ct=new gt.Vector3,yi=new gt.Vector3,Gi=new gt.Vector3,Ce=new gt.Vector3,Te=new gt.Vector3,ai=new gt.Vector3,Co=new gt.Vector3,To=new gt.Vector3,ae=new gt.Spherical,wi=new gt.Spherical,vi=new gt.Box3,Po=new gt.Box3,Pn=new gt.Sphere,So=new gt.Quaternion,Sn=new gt.Quaternion,En=new gt.Matrix4,vs=new gt.Raycaster}static get ACTION(){return j}minPolarAngle=0;maxPolarAngle=Math.PI;minAzimuthAngle=-1/0;maxAzimuthAngle=1/0;minDistance=Number.EPSILON;maxDistance=1/0;infinityDolly=!1;minZoom=.01;maxZoom=1/0;smoothTime=.25;draggingSmoothTime=.125;maxSpeed=1/0;azimuthRotateSpeed=1;polarRotateSpeed=1;dollySpeed=1;dollyDragInverted=!1;truckSpeed=2;dollyToCursor=!1;dragToOffset=!1;boundaryFriction=0;restThreshold=.01;colliderMeshes=[];mouseButtons;touches;cancel=()=>{};lockPointer;unlockPointer;_enabled=!0;_camera;_yAxisUpSpace;_yAxisUpSpaceInverse;_state=j.NONE;_domElement;_viewport=null;_target;_targetEnd;_focalOffset;_focalOffsetEnd;_spherical;_sphericalEnd;_lastDistance;_zoom;_zoomEnd;_lastZoom;_cameraUp0;_target0;_position0;_zoom0;_focalOffset0;_dollyControlCoord;_changedDolly=0;_changedZoom=0;_nearPlaneCorners;_hasRested=!0;_boundary;_boundaryEnclosesCamera=!1;_needsUpdate=!0;_updatedLastTime=!1;_elementRect=new DOMRect;_isDragging=!1;_dragNeedsUpdate=!0;_activePointers=[];_lockedPointer=null;_interactiveArea=new DOMRect(0,0,1,1);_isUserControllingRotate=!1;_isUserControllingDolly=!1;_isUserControllingTruck=!1;_isUserControllingOffset=!1;_isUserControllingZoom=!1;_lastDollyDirection=0;_thetaVelocity={value:0};_phiVelocity={value:0};_radiusVelocity={value:0};_targetVelocity=new gt.Vector3;_focalOffsetVelocity=new gt.Vector3;_zoomVelocity={value:0};set verticalDragToForward(t){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}constructor(t,e){super(),typeof gt>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=t,this._yAxisUpSpace=(new gt.Quaternion).setFromUnitVectors(this._camera.up,ws),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=j.NONE,this._target=new gt.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new gt.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new gt.Spherical).setFromVector3(yt.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new gt.Vector3,new gt.Vector3,new gt.Vector3,new gt.Vector3],this._updateNearPlaneCorners(),this._boundary=new gt.Box3(new gt.Vector3(-1/0,-1/0,-1/0),new gt.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new gt.Vector2,this.mouseButtons={left:j.ROTATE,middle:j.DOLLY,right:j.TRUCK,wheel:Oe(this._camera)?j.DOLLY:Nt(this._camera)?j.ZOOM:j.NONE},this.touches={one:j.TOUCH_ROTATE,two:Oe(this._camera)?j.TOUCH_DOLLY_TRUCK:Nt(this._camera)?j.TOUCH_ZOOM_TRUCK:j.NONE,three:j.TOUCH_TRUCK};const i=new gt.Vector2,s=new gt.Vector2,n=new gt.Vector2,o=g=>{if(!this._enabled||!this._domElement)return;if(0!==this._interactiveArea.left||0!==this._interactiveArea.top||1!==this._interactiveArea.width||1!==this._interactiveArea.height){const C=this._domElement.getBoundingClientRect(),S=g.clientX/C.width,M=g.clientY/C.height;if(S<this._interactiveArea.left||S>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const v="mouse"!==g.pointerType?null:1&~g.buttons?4&~g.buttons?2&~g.buttons?null:2:4:1;if(null!==v){const C=this._findPointerByMouseButton(v);C&&this._disposePointer(C)}(1&~g.buttons||!this._lockedPointer)&&(this._activePointers.push({pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:v}),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),this._isDragging=!0,f(g))},a=g=>{g.cancelable&&g.preventDefault();const T=this._lockedPointer||this._findPointerById(g.pointerId);if(T){if(T.clientX=g.clientX,T.clientY=g.clientY,T.deltaX=g.movementX,T.deltaY=g.movementY,this._state=0,"touch"===g.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else(!this._isDragging&&this._lockedPointer||this._isDragging&&!(1&~g.buttons))&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&!(4&~g.buttons)&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&!(2&~g.buttons)&&(this._state=this._state|this.mouseButtons.right);d()}},l=g=>{const v=this._findPointerById(g.pointerId);if(!v||v!==this._lockedPointer){if(v&&this._disposePointer(v),"touch"===g.pointerType)switch(this._activePointers.length){case 0:this._state=j.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=j.NONE;_()}};let c=-1;const h=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===j.NONE)return;if(0!==this._interactiveArea.left||0!==this._interactiveArea.top||1!==this._interactiveArea.width||1!==this._interactiveArea.height){const A=this._domElement.getBoundingClientRect(),O=g.clientX/A.width,I=g.clientY/A.height;if(O<this._interactiveArea.left||O>this._interactiveArea.right||I<this._interactiveArea.top||I>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===j.ROTATE||this.mouseButtons.wheel===j.TRUCK){const A=performance.now();c-A<1e3&&this._getClientRect(this._elementRect),c=A}const v=ih?-1:-3,T=1!==g.deltaMode||g.ctrlKey?g.deltaY/(10*v):g.deltaY/v,C=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,S=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(g.ctrlKey?j.ZOOM:this.mouseButtons.wheel){case j.ROTATE:this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break;case j.TRUCK:this._truckInternal(g.deltaX,g.deltaY,!1,!1),this._isUserControllingTruck=!0;break;case j.SCREEN_PAN:this._truckInternal(g.deltaX,g.deltaY,!1,!0),this._isUserControllingTruck=!0;break;case j.OFFSET:this._truckInternal(g.deltaX,g.deltaY,!0,!1),this._isUserControllingOffset=!0;break;case j.DOLLY:this._dollyInternal(-T,C,S),this._isUserControllingDolly=!0;break;case j.ZOOM:this._zoomInternal(-T,C,S),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},u=g=>{if(this._domElement&&this._enabled){if(this.mouseButtons.right===Zt.ACTION.NONE){const v=g instanceof PointerEvent?g.pointerId:0,T=this._findPointerById(v);return T&&this._disposePointer(T),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),void this._domElement.ownerDocument.removeEventListener("pointerup",l)}g.preventDefault()}},f=g=>{if(this._enabled){if(xn(this._activePointers,ee),this._getClientRect(this._elementRect),i.copy(ee),s.copy(ee),this._activePointers.length>=2){const T=ee.x-this._activePointers[1].clientX,C=ee.y-this._activePointers[1].clientY,S=Math.sqrt(T*T+C*C);n.set(0,S),s.set(.5*(this._activePointers[0].clientX+this._activePointers[1].clientX),.5*(this._activePointers[0].clientY+this._activePointers[1].clientY))}if(this._state=0,g)if("pointerType"in g&&"touch"===g.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else!this._lockedPointer&&!(1&~g.buttons)&&(this._state=this._state|this.mouseButtons.left),!(4&~g.buttons)&&(this._state=this._state|this.mouseButtons.middle),!(2&~g.buttons)&&(this._state=this._state|this.mouseButtons.right);else this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);((this._state&j.ROTATE)===j.ROTATE||(this._state&j.TOUCH_ROTATE)===j.TOUCH_ROTATE||(this._state&j.TOUCH_DOLLY_ROTATE)===j.TOUCH_DOLLY_ROTATE||(this._state&j.TOUCH_ZOOM_ROTATE)===j.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&j.TRUCK)===j.TRUCK||(this._state&j.SCREEN_PAN)===j.SCREEN_PAN||(this._state&j.TOUCH_TRUCK)===j.TOUCH_TRUCK||(this._state&j.TOUCH_SCREEN_PAN)===j.TOUCH_SCREEN_PAN||(this._state&j.TOUCH_DOLLY_TRUCK)===j.TOUCH_DOLLY_TRUCK||(this._state&j.TOUCH_DOLLY_SCREEN_PAN)===j.TOUCH_DOLLY_SCREEN_PAN||(this._state&j.TOUCH_ZOOM_TRUCK)===j.TOUCH_ZOOM_TRUCK||(this._state&j.TOUCH_ZOOM_SCREEN_PAN)===j.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&j.DOLLY)===j.DOLLY||(this._state&j.TOUCH_DOLLY)===j.TOUCH_DOLLY||(this._state&j.TOUCH_DOLLY_TRUCK)===j.TOUCH_DOLLY_TRUCK||(this._state&j.TOUCH_DOLLY_SCREEN_PAN)===j.TOUCH_DOLLY_SCREEN_PAN||(this._state&j.TOUCH_DOLLY_OFFSET)===j.TOUCH_DOLLY_OFFSET||(this._state&j.TOUCH_DOLLY_ROTATE)===j.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&j.ZOOM)===j.ZOOM||(this._state&j.TOUCH_ZOOM)===j.TOUCH_ZOOM||(this._state&j.TOUCH_ZOOM_TRUCK)===j.TOUCH_ZOOM_TRUCK||(this._state&j.TOUCH_ZOOM_SCREEN_PAN)===j.TOUCH_ZOOM_SCREEN_PAN||(this._state&j.TOUCH_ZOOM_OFFSET)===j.TOUCH_ZOOM_OFFSET||(this._state&j.TOUCH_ZOOM_ROTATE)===j.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&j.OFFSET)===j.OFFSET||(this._state&j.TOUCH_OFFSET)===j.TOUCH_OFFSET||(this._state&j.TOUCH_DOLLY_OFFSET)===j.TOUCH_DOLLY_OFFSET||(this._state&j.TOUCH_ZOOM_OFFSET)===j.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})}},d=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,xn(this._activePointers,ee);const v=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,T=v?-v.deltaX:s.x-ee.x,C=v?-v.deltaY:s.y-ee.y;if(s.copy(ee),((this._state&j.ROTATE)===j.ROTATE||(this._state&j.TOUCH_ROTATE)===j.TOUCH_ROTATE||(this._state&j.TOUCH_DOLLY_ROTATE)===j.TOUCH_DOLLY_ROTATE||(this._state&j.TOUCH_ZOOM_ROTATE)===j.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(T,C),this._isUserControllingRotate=!0),(this._state&j.DOLLY)===j.DOLLY||(this._state&j.ZOOM)===j.ZOOM){const S=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,M=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0,A=this.dollyDragInverted?-1:1;(this._state&j.DOLLY)===j.DOLLY?(this._dollyInternal(A*C*ys,S,M),this._isUserControllingDolly=!0):(this._zoomInternal(A*C*ys,S,M),this._isUserControllingZoom=!0)}if((this._state&j.TOUCH_DOLLY)===j.TOUCH_DOLLY||(this._state&j.TOUCH_ZOOM)===j.TOUCH_ZOOM||(this._state&j.TOUCH_DOLLY_TRUCK)===j.TOUCH_DOLLY_TRUCK||(this._state&j.TOUCH_ZOOM_TRUCK)===j.TOUCH_ZOOM_TRUCK||(this._state&j.TOUCH_DOLLY_SCREEN_PAN)===j.TOUCH_DOLLY_SCREEN_PAN||(this._state&j.TOUCH_ZOOM_SCREEN_PAN)===j.TOUCH_ZOOM_SCREEN_PAN||(this._state&j.TOUCH_DOLLY_OFFSET)===j.TOUCH_DOLLY_OFFSET||(this._state&j.TOUCH_ZOOM_OFFSET)===j.TOUCH_ZOOM_OFFSET||(this._state&j.TOUCH_DOLLY_ROTATE)===j.TOUCH_DOLLY_ROTATE||(this._state&j.TOUCH_ZOOM_ROTATE)===j.TOUCH_ZOOM_ROTATE){const S=ee.x-this._activePointers[1].clientX,M=ee.y-this._activePointers[1].clientY,A=Math.sqrt(S*S+M*M),O=n.y-A;n.set(0,A);const I=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,D=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&j.TOUCH_DOLLY)===j.TOUCH_DOLLY||(this._state&j.TOUCH_DOLLY_ROTATE)===j.TOUCH_DOLLY_ROTATE||(this._state&j.TOUCH_DOLLY_TRUCK)===j.TOUCH_DOLLY_TRUCK||(this._state&j.TOUCH_DOLLY_SCREEN_PAN)===j.TOUCH_DOLLY_SCREEN_PAN||(this._state&j.TOUCH_DOLLY_OFFSET)===j.TOUCH_DOLLY_OFFSET?(this._dollyInternal(O*ys,I,D),this._isUserControllingDolly=!0):(this._zoomInternal(O*ys,I,D),this._isUserControllingZoom=!0)}((this._state&j.TRUCK)===j.TRUCK||(this._state&j.TOUCH_TRUCK)===j.TOUCH_TRUCK||(this._state&j.TOUCH_DOLLY_TRUCK)===j.TOUCH_DOLLY_TRUCK||(this._state&j.TOUCH_ZOOM_TRUCK)===j.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(T,C,!1,!1),this._isUserControllingTruck=!0),((this._state&j.SCREEN_PAN)===j.SCREEN_PAN||(this._state&j.TOUCH_SCREEN_PAN)===j.TOUCH_SCREEN_PAN||(this._state&j.TOUCH_DOLLY_SCREEN_PAN)===j.TOUCH_DOLLY_SCREEN_PAN||(this._state&j.TOUCH_ZOOM_SCREEN_PAN)===j.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(T,C,!1,!0),this._isUserControllingTruck=!0),((this._state&j.OFFSET)===j.OFFSET||(this._state&j.TOUCH_OFFSET)===j.TOUCH_OFFSET||(this._state&j.TOUCH_DOLLY_OFFSET)===j.TOUCH_DOLLY_OFFSET||(this._state&j.TOUCH_ZOOM_OFFSET)===j.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(T,C,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},_=()=>{xn(this._activePointers,ee),s.copy(ee),this._dragNeedsUpdate=!1,(0===this._activePointers.length||1===this._activePointers.length&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),0===this._activePointers.length&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",m),this._domElement.ownerDocument.addEventListener("pointerlockerror",w),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),f())},this.unlockPointer=()=>{null!==this._lockedPointer&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),this._domElement?.ownerDocument.exitPointerLock(),this._domElement?.ownerDocument.removeEventListener("pointerlockchange",m),this._domElement?.ownerDocument.removeEventListener("pointerlockerror",w),this.cancel()};const m=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},w=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",h,{passive:!1}),this._domElement.addEventListener("contextmenu",u)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("pointercancel",l),this._domElement.removeEventListener("wheel",h,{passive:!1}),this._domElement.removeEventListener("contextmenu",u),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",m),this._domElement.ownerDocument.removeEventListener("pointerlockerror",w))},this.cancel=()=>{this._state!==j.NONE&&(this._state=j.NONE,this._activePointers.length=0,_())},e&&this.connect(e),this.update(0)}get camera(){return this._camera}set camera(t){this._camera=t,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(t){this._enabled=t,this._domElement&&(t?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(t){this._spherical.radius===t&&this._sphericalEnd.radius===t||(this._spherical.radius=t,this._sphericalEnd.radius=t,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(t){this._spherical.theta===t&&this._sphericalEnd.theta===t||(this._spherical.theta=t,this._sphericalEnd.theta=t,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(t){this._spherical.phi===t&&this._sphericalEnd.phi===t||(this._spherical.phi=t,this._sphericalEnd.phi=t,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(t){this._boundaryEnclosesCamera=t,this._needsUpdate=!0}set interactiveArea(t){this._interactiveArea.width=de(t.width,0,1),this._interactiveArea.height=de(t.height,0,1),this._interactiveArea.x=de(t.x,0,1-this._interactiveArea.width),this._interactiveArea.y=de(t.y,0,1-this._interactiveArea.height)}addEventListener(t,e){super.addEventListener(t,e)}removeEventListener(t,e){super.removeEventListener(t,e)}rotate(t,e,i=!1){return this.rotateTo(this._sphericalEnd.theta+t,this._sphericalEnd.phi+e,i)}rotateAzimuthTo(t,e=!1){return this.rotateTo(t,this._sphericalEnd.phi,e)}rotatePolarTo(t,e=!1){return this.rotateTo(this._sphericalEnd.theta,t,e)}rotateTo(t,e,i=!1){this._isUserControllingRotate=!1;const s=de(t,this.minAzimuthAngle,this.maxAzimuthAngle),n=de(e,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=n,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,i||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!i||Pt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Pt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}dolly(t,e=!1){return this.dollyTo(this._sphericalEnd.radius-t,e)}dollyTo(t,e=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=0,this._changedDolly=0,this._dollyToNoClamp(de(t,this.minDistance,this.maxDistance),e)}_dollyToNoClamp(t,e=!1){const i=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),a=Pt(o,this._spherical.radius);if(!(i>t)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(t,o)}else this._sphericalEnd.radius=t;this._needsUpdate=!0,e||(this._spherical.radius=this._sphericalEnd.radius);const n=!e||Pt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(n)}dollyInFixed(t,e=!1){this._targetEnd.add(this._getCameraDirection(Gi).multiplyScalar(t)),e||this._target.copy(this._targetEnd);const i=!e||Pt(this._target.x,this._targetEnd.x,this.restThreshold)&&Pt(this._target.y,this._targetEnd.y,this.restThreshold)&&Pt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}zoom(t,e=!1){return this.zoomTo(this._zoomEnd+t,e)}zoomTo(t,e=!1){this._isUserControllingZoom=!1,this._zoomEnd=de(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,e||(this._zoom=this._zoomEnd);const i=!e||Pt(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(i)}pan(t,e,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(t,e,i)}truck(t,e,i=!1){this._camera.updateMatrix(),Ce.setFromMatrixColumn(this._camera.matrix,0),Te.setFromMatrixColumn(this._camera.matrix,1),Ce.multiplyScalar(t),Te.multiplyScalar(-e);const s=yt.copy(Ce).add(Te),n=Ct.copy(this._targetEnd).add(s);return this.moveTo(n.x,n.y,n.z,i)}forward(t,e=!1){yt.setFromMatrixColumn(this._camera.matrix,0),yt.crossVectors(this._camera.up,yt),yt.multiplyScalar(t);const i=Ct.copy(this._targetEnd).add(yt);return this.moveTo(i.x,i.y,i.z,e)}elevate(t,e=!1){return yt.copy(this._camera.up).multiplyScalar(t),this.moveTo(this._targetEnd.x+yt.x,this._targetEnd.y+yt.y,this._targetEnd.z+yt.z,e)}moveTo(t,e,i,s=!1){this._isUserControllingTruck=!1;const n=yt.set(t,e,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,n,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const o=!s||Pt(this._target.x,this._targetEnd.x,this.restThreshold)&&Pt(this._target.y,this._targetEnd.y,this.restThreshold)&&Pt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(t,e,i,s=!1){const a=yt.set(t,e,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,s)}fitToBox(t,e,{cover:i=!1,paddingLeft:s=0,paddingRight:n=0,paddingBottom:o=0,paddingTop:a=0}={}){const l=[],c=t.isBox3?vi.copy(t):vi.setFromObject(t);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=vo(this._sphericalEnd.theta,ue),u=vo(this._sphericalEnd.phi,ue);l.push(this.rotateTo(h,u,e));const f=yt.setFromSpherical(this._sphericalEnd).normalize(),d=So.setFromUnitVectors(f,Tn),_=Pt(Math.abs(f.y),1);_&&d.multiply(Sn.setFromAxisAngle(ws,h)),d.multiply(this._yAxisUpSpaceInverse);const m=Po.makeEmpty();Ct.copy(c.min).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.min).setX(c.max.x).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.min).setY(c.max.y).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.max).setZ(c.min.z).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.min).setZ(c.max.z).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.max).setY(c.min.y).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.max).setX(c.min.x).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.max).applyQuaternion(d),m.expandByPoint(Ct),m.min.x-=s,m.min.y-=o,m.max.x+=n,m.max.y+=a,d.setFromUnitVectors(Tn,f),_&&d.premultiply(Sn.invert()),d.premultiply(this._yAxisUpSpace);const w=m.getSize(yt),g=m.getCenter(Ct).applyQuaternion(d);if(Oe(this._camera)){const v=this.getDistanceToFitBox(w.x,w.y,w.z,i);l.push(this.moveTo(g.x,g.y,g.z,e)),l.push(this.dollyTo(v,e)),l.push(this.setFocalOffset(0,0,0,e))}else if(Nt(this._camera)){const v=this._camera,T=v.right-v.left,C=v.top-v.bottom,S=i?Math.max(T/w.x,C/w.y):Math.min(T/w.x,C/w.y);l.push(this.moveTo(g.x,g.y,g.z,e)),l.push(this.zoomTo(S,e)),l.push(this.setFocalOffset(0,0,0,e))}return Promise.all(l)}fitToSphere(t,e){const i=[],n="isObject3D"in t?Zt.createBoundingSphere(t,Pn):Pn.copy(t);if(i.push(this.moveTo(n.center.x,n.center.y,n.center.z,e)),Oe(this._camera)){const o=this.getDistanceToFitSphere(n.radius);i.push(this.dollyTo(o,e))}else if(Nt(this._camera)){const l=2*n.radius,c=Math.min((this._camera.right-this._camera.left)/l,(this._camera.top-this._camera.bottom)/l);i.push(this.zoomTo(c,e))}return i.push(this.setFocalOffset(0,0,0,e)),Promise.all(i)}setLookAt(t,e,i,s,n,o,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=0,this._changedDolly=0;const l=Ct.set(s,n,o),c=yt.set(t,e,i);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(c.sub(l).applyQuaternion(this._yAxisUpSpace)),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!a||Pt(this._target.x,this._targetEnd.x,this.restThreshold)&&Pt(this._target.y,this._targetEnd.y,this.restThreshold)&&Pt(this._target.z,this._targetEnd.z,this.restThreshold)&&Pt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Pt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Pt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerp(t,e,i,s=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=0,this._changedDolly=0;const n=yt.set(...t.target);if("spherical"in t)ae.set(...t.spherical);else{const u=Ct.set(...t.position);ae.setFromVector3(u.sub(n).applyQuaternion(this._yAxisUpSpace))}const o=yi.set(...e.target);if("spherical"in e)wi.set(...e.spherical);else{const u=Ct.set(...e.position);wi.setFromVector3(u.sub(o).applyQuaternion(this._yAxisUpSpace))}this._targetEnd.copy(n.lerp(o,i)),this._sphericalEnd.set(ae.radius+(wi.radius-ae.radius)*i,ae.phi+(wi.phi-ae.phi)*i,ae.theta+(wi.theta-ae.theta)*i),this._needsUpdate=!0,s||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!s||Pt(this._target.x,this._targetEnd.x,this.restThreshold)&&Pt(this._target.y,this._targetEnd.y,this.restThreshold)&&Pt(this._target.z,this._targetEnd.z,this.restThreshold)&&Pt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Pt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Pt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(t,e,i,s,n,o,a,l,c,h,u,f,d,_=!1){return this.lerp({position:[t,e,i],target:[s,n,o]},{position:[a,l,c],target:[h,u,f]},d,_)}setPosition(t,e,i,s=!1){return this.setLookAt(t,e,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(t,e,i,s=!1){const n=this.getPosition(yt),o=this.setLookAt(n.x,n.y,n.z,t,e,i,s);return this._sphericalEnd.phi=de(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(t,e,i,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(t,e,i),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const n=!s||Pt(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Pt(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Pt(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}setOrbitPoint(t,e,i){this._camera.updateMatrixWorld(),Ce.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Te.setFromMatrixColumn(this._camera.matrixWorldInverse,1),ai.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=yt.set(t,e,i),n=s.distanceTo(this._camera.position),o=s.sub(this._camera.position);Ce.multiplyScalar(o.x),Te.multiplyScalar(o.y),ai.multiplyScalar(o.z),yt.copy(Ce).add(Te).add(ai),yt.z=yt.z+n,this.dollyTo(n,!1),this.setFocalOffset(-yt.x,yt.y,-yt.z,!1),this.moveTo(t,e,i,!1)}setBoundary(t){if(!t)return this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),void(this._needsUpdate=!0);this._boundary.copy(t),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(t,e,i,s){null!==t?(this._viewport=this._viewport||new gt.Vector4,"number"==typeof t?this._viewport.set(t,e,i,s):this._viewport.copy(t)):this._viewport=null}getDistanceToFitBox(t,e,i,s=!1){if(Cn(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const n=t/e,o=this._camera.getEffectiveFOV()*Mt,a=this._camera.aspect;return.5*((s?n>a:n<a)?e:t/a)/Math.tan(.5*o)+.5*i}getDistanceToFitSphere(t){if(Cn(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const e=this._camera.getEffectiveFOV()*Mt,i=2*Math.atan(Math.tan(.5*e)*this._camera.aspect);return t/Math.sin(.5*(1<this._camera.aspect?e:i))}getTarget(t,e=!0){return(t&&t.isVector3?t:new gt.Vector3).copy(e?this._targetEnd:this._target)}getPosition(t,e=!0){return(t&&t.isVector3?t:new gt.Vector3).setFromSpherical(e?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(e?this._targetEnd:this._target)}getSpherical(t,e=!0){return(t||new gt.Spherical).copy(e?this._sphericalEnd:this._spherical)}getFocalOffset(t,e=!0){return(t&&t.isVector3?t:new gt.Vector3).copy(e?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){return this._sphericalEnd.theta=(this._sphericalEnd.theta%ze+ze)%ze,this._sphericalEnd.theta>Math.PI&&(this._sphericalEnd.theta-=ze),this._spherical.theta+=ze*Math.round((this._sphericalEnd.theta-this._spherical.theta)/ze),this}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(t=!1){if(!Pt(this._camera.up.x,this._cameraUp0.x)||!Pt(this._camera.up.y,this._cameraUp0.y)||!Pt(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const i=this.getPosition(yt);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}const e=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,t),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,t),this.zoomTo(this._zoom0,t)];return Promise.all(e)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,ws),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=yt.subVectors(this._target,this._camera.position).normalize(),e=Ct.crossVectors(t,this._camera.up);this._camera.up.crossVectors(e,t).normalize(),this._camera.updateMatrixWorld();const i=this.getPosition(yt);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}update(t){const e=this._sphericalEnd.theta-this._spherical.theta,i=this._sphericalEnd.phi-this._spherical.phi,s=this._sphericalEnd.radius-this._spherical.radius,n=Co.subVectors(this._targetEnd,this._target),o=To.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(It(e)?(this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta):(this._spherical.theta=_s(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime,1/0,t),this._needsUpdate=!0),It(i)?(this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi):(this._spherical.phi=_s(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime,1/0,t),this._needsUpdate=!0),It(s)?(this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius):(this._spherical.radius=_s(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,t),this._needsUpdate=!0),It(n.x)&&It(n.y)&&It(n.z)?(this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd)):(bo(this._target,this._targetEnd,this._targetVelocity,this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,t,this._target),this._needsUpdate=!0),It(o.x)&&It(o.y)&&It(o.z)?(this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd)):(bo(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,t,this._focalOffset),this._needsUpdate=!0),It(a)?(this._zoomVelocity.value=0,this._zoom=this._zoomEnd):this._zoom=_s(this._zoom,this._zoomEnd,this._zoomVelocity,this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime,1/0,t),this.dollyToCursor)if(Oe(this._camera)&&0!==this._changedDolly){const u=this._spherical.radius-this._lastDistance,f=this._camera,d=this._getCameraDirection(Gi),_=yt.copy(d).cross(f.up).normalize();0===_.lengthSq()&&(_.x=1);const m=Ct.crossVectors(_,d),w=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*Mt*.5),v=(this._sphericalEnd.radius-u-this._sphericalEnd.radius)/this._sphericalEnd.radius,T=yi.copy(this._targetEnd).add(_.multiplyScalar(this._dollyControlCoord.x*w*f.aspect)).add(m.multiplyScalar(this._dollyControlCoord.y*w)),C=yt.copy(this._targetEnd).lerp(T,v);if(this.infinityDolly&&(1===this._lastDollyDirection&&this._spherical.radius<=this.minDistance||-1===this._lastDollyDirection&&this.maxDistance<=this._spherical.radius)){this._sphericalEnd.radius-=u,this._spherical.radius-=u;const O=Ct.copy(d).multiplyScalar(-u);C.add(O)}this._boundary.clampPoint(C,C);const A=Ct.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(A),this._changedDolly-=u,It(this._changedDolly)&&(this._changedDolly=0)}else if(Nt(this._camera)&&0!==this._changedZoom){const u=this._zoom-this._lastZoom,f=this._camera,d=yt.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),_=Ct.set(0,0,-1).applyQuaternion(f.quaternion),m=yi.copy(d).add(_.multiplyScalar(-d.dot(f.up))),g=-(this._zoom-u-this._zoom)/this._zoom,v=this._getCameraDirection(Gi),T=this._targetEnd.dot(v),C=yt.copy(this._targetEnd).lerp(m,g),S=C.dot(v),M=v.multiplyScalar(S-T);C.sub(M),this._boundary.clampPoint(C,C);const A=Ct.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(A),this._changedZoom-=u,It(this._changedZoom)&&(this._changedZoom=0)}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!It(this._focalOffset.x)||!It(this._focalOffset.y)||!It(this._focalOffset.z))&&(this._camera.matrix.compose(this._camera.position,this._camera.quaternion,this._camera.scale),Ce.setFromMatrixColumn(this._camera.matrix,0),Te.setFromMatrixColumn(this._camera.matrix,1),ai.setFromMatrixColumn(this._camera.matrix,2),Ce.multiplyScalar(this._focalOffset.x),Te.multiplyScalar(-this._focalOffset.y),ai.multiplyScalar(this._focalOffset.z),yt.copy(Ce).add(Te).add(ai),this._camera.position.add(yt),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),yt.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const h=this._needsUpdate;return h&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):h?(this.dispatchEvent({type:"update"}),It(e,this.restThreshold)&&It(i,this.restThreshold)&&It(s,this.restThreshold)&&It(n.x,this.restThreshold)&&It(n.y,this.restThreshold)&&It(n.z,this.restThreshold)&&It(o.x,this.restThreshold)&&It(o.y,this.restThreshold)&&It(o.z,this.restThreshold)&&It(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!h&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=h,this._needsUpdate=!1,h}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Hi(this.maxDistance),minZoom:this.minZoom,maxZoom:Hi(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Hi(this.maxPolarAngle),minAzimuthAngle:Hi(this.minAzimuthAngle),maxAzimuthAngle:Hi(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:yt.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(t,e=!1){const i=JSON.parse(t);this.enabled=i.enabled,this.minDistance=i.minDistance,this.maxDistance=qi(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=qi(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=qi(i.maxPolarAngle),this.minAzimuthAngle=qi(i.minAzimuthAngle),this.maxAzimuthAngle=qi(i.maxAzimuthAngle),this.smoothTime=i.smoothTime,this.draggingSmoothTime=i.draggingSmoothTime,this.dollySpeed=i.dollySpeed,this.truckSpeed=i.truckSpeed,this.dollyToCursor=i.dollyToCursor,this._target0.fromArray(i.target0),this._position0.fromArray(i.position0),this._zoom0=i.zoom0,this._focalOffset0.fromArray(i.focalOffset0),this.moveTo(i.target[0],i.target[1],i.target[2],e),ae.setFromVector3(yt.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ae.theta,ae.phi,e),this.dollyTo(ae.radius,e),this.zoomTo(i.zoom,e),this.setFocalOffset(i.focalOffset[0],i.focalOffset[1],i.focalOffset[2],e),this._needsUpdate=!0}connect(t){this._domElement?console.warn("camera-controls is already connected."):(t.setAttribute("data-camera-controls-version","3.1.2"),this._addAllEventListeners(t),this._getClientRect(this._elementRect))}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(t){return t.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(t){return this._getTargetDirection(t).negate()}_findPointerById(t){return this._activePointers.find(e=>e.pointerId===t)}_findPointerByMouseButton(t){return this._activePointers.find(e=>e.mouseButton===t)}_disposePointer(t){this._activePointers.splice(this._activePointers.indexOf(t),1)}_encloseToBoundary(t,e,i){const s=e.lengthSq();if(0===s)return t;const n=Ct.copy(e).add(t),a=this._boundary.clampPoint(n,yi).sub(n),l=a.lengthSq();if(0===l)return t.add(e);if(l===s)return t;if(0===i)return t.add(e).add(a);{const c=1+i*l/e.dot(a);return t.add(Ct.copy(e).multiplyScalar(c)).add(a.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(Oe(this._camera)){const t=this._camera,e=t.near,i=t.getEffectiveFOV()*Mt,s=Math.tan(.5*i)*e,n=s*t.aspect;this._nearPlaneCorners[0].set(-n,-s,0),this._nearPlaneCorners[1].set(n,-s,0),this._nearPlaneCorners[2].set(n,s,0),this._nearPlaneCorners[3].set(-n,s,0)}else if(Nt(this._camera)){const t=this._camera,e=1/t.zoom,i=t.left*e,s=t.right*e,n=t.top*e,o=t.bottom*e;this._nearPlaneCorners[0].set(i,n,0),this._nearPlaneCorners[1].set(s,n,0),this._nearPlaneCorners[2].set(s,o,0),this._nearPlaneCorners[3].set(i,o,0)}}_truckInternal=(t,e,i,s)=>{let n,o;if(Oe(this._camera)){const a=yt.copy(this._camera.position).sub(this._target),l=this._camera.getEffectiveFOV()*Mt,c=a.length()*Math.tan(.5*l);n=this.truckSpeed*t*c/this._elementRect.height,o=this.truckSpeed*e*c/this._elementRect.height}else{if(!Nt(this._camera))return;{const a=this._camera;n=this.truckSpeed*t*(a.right-a.left)/a.zoom/this._elementRect.width,o=this.truckSpeed*e*(a.top-a.bottom)/a.zoom/this._elementRect.height}}s?(i?this.setFocalOffset(this._focalOffsetEnd.x+n,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(n,0,!0),this.forward(-o,!0)):i?this.setFocalOffset(this._focalOffsetEnd.x+n,this._focalOffsetEnd.y+o,this._focalOffsetEnd.z,!0):this.truck(n,o,!0)};_rotateInternal=(t,e)=>{this.rotate(ze*this.azimuthRotateSpeed*t/this._elementRect.height,ze*this.polarRotateSpeed*e/this._elementRect.height,!0)};_dollyInternal=(t,e,i)=>{const s=Math.pow(.95,-t*this.dollySpeed),n=this._sphericalEnd.radius,o=this._sphericalEnd.radius*s,a=de(o,this.minDistance,this.maxDistance),l=a-o;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(o,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(l,!0),this._dollyToNoClamp(a,!0)):this._dollyToNoClamp(a,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?o:a)-n,this._dollyControlCoord.set(e,i)),this._lastDollyDirection=Math.sign(-t)};_zoomInternal=(t,e,i)=>{const s=Math.pow(.95,t*this.dollySpeed),n=this._zoom,o=this._zoom*s;this.zoomTo(o,!0),this.dollyToCursor&&(this._changedZoom+=o-n,this._dollyControlCoord.set(e,i))};_collisionTest(){let t=1/0;if(!(this.colliderMeshes.length>=1)||Cn(this._camera,"_collisionTest"))return t;const i=this._getTargetDirection(Gi);En.lookAt(xo,i,this._camera.up);for(let s=0;s<4;s++){const n=Ct.copy(this._nearPlaneCorners[s]);n.applyMatrix4(En);const o=yi.addVectors(this._target,n);vs.set(o,i),vs.far=this._spherical.radius+1;const a=vs.intersectObjects(this.colliderMeshes);0!==a.length&&a[0].distance<t&&(t=a[0].distance)}return t}_getClientRect(t){if(!this._domElement)return;const e=this._domElement.getBoundingClientRect();return t.x=e.left,t.y=e.top,this._viewport?(t.x+=this._viewport.x,t.y+=e.height-this._viewport.w-this._viewport.y,t.width=this._viewport.z,t.height=this._viewport.w):(t.width=e.width,t.height=e.height),t}_createOnRestPromise(t){return t?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(e=>{const i=()=>{this.removeEventListener("rest",i),e()};this.addEventListener("rest",i)}))}_addAllEventListeners(t){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(t){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(t){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(t,e=new gt.Sphere){const i=e,s=i.center;vi.makeEmpty(),t.traverseVisible(o=>{o.isMesh&&vi.expandByObject(o)}),vi.getCenter(s);let n=0;return t.traverseVisible(o=>{if(!o.isMesh)return;const a=o;if(!a.geometry)return;const l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const h=l.attributes.position;for(let u=0,f=h.count;u<f;u++)yt.fromBufferAttribute(h,u),n=Math.max(n,s.distanceToSquared(yt))}),i.radius=Math.sqrt(n),i}}var sh=mt(8785),rh=Object.defineProperty,y=(r,t,e)=>(((r,t,e)=>{t in r?rh(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e})(r,"symbol"!=typeof t?t+"":t,e),e);class Q{constructor(){y(this,"enabled",!0),y(this,"trigger",t=>{if(!this.enabled)return;const e=this.handlers.slice(0);for(const i of e)i(t)}),y(this,"handlers",[])}add(t){this.handlers.push(t)}remove(t){this.handlers=this.handlers.filter(e=>e!==t)}reset(){this.handlers.length=0}}class An{constructor(t){y(this,"isDisposeable",()=>"dispose"in this&&"onDisposed"in this),y(this,"isResizeable",()=>"resize"in this&&"getSize"in this),y(this,"isUpdateable",()=>"onAfterUpdate"in this&&"onBeforeUpdate"in this&&"update"in this),y(this,"isHideable",()=>"visible"in this),y(this,"isConfigurable",()=>"setup"in this&&"config"in this&&"onSetup"in this),y(this,"isSerializable",()=>"import"in this&&"export"in this),this.components=t}}class At extends An{}class Mn extends An{constructor(t){super(t),y(this,"worlds",new ot.jp),y(this,"onWorldChanged",new Q),y(this,"_currentWorld",null),this.onWorldChanged.add(({world:e,action:i})=>{"removed"===i&&this.worlds.delete(e.uuid)})}set currentWorld(t){this._currentWorld=t}get currentWorld(){return this._currentWorld}}class ah extends Mn{constructor(){super(...arguments),y(this,"hasCameraControls",()=>"controls"in this)}}const Ao=class po extends At{constructor(t){super(t),y(this,"_disposedComponents",new Set),y(this,"enabled",!0),t.add(po.uuid,this)}get(){return this._disposedComponents}destroy(t,e=!0,i=!0){t.removeFromParent();const s=t;s.dispose&&s.dispose(),this.disposeGeometryAndMaterials(t,e),i&&s.children&&s.children.length&&this.disposeChildren(s),t.children.length=0}disposeGeometry(t){t.boundsTree&&t.disposeBoundsTree&&t.disposeBoundsTree(),t.dispose()}disposeGeometryAndMaterials(t,e){const i=t;i.geometry&&this.disposeGeometry(i.geometry),e&&i.material&&po.disposeMaterial(i),i.material=[],i.geometry=null}disposeChildren(t){for(const e of t.children)this.destroy(e)}static disposeMaterial(t){if(t.material)if(Array.isArray(t.material))for(const e of t.material)e.dispose();else t.material.dispose()}};y(Ao,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let bi=Ao;class ch extends Mn{constructor(t){super(t),y(this,"onDisposed",new Q),y(this,"directionalLights",new Map),y(this,"ambientLights",new Map)}dispose(){const t=this.components.get(bi);for(const e of this.three.children)e.geometry&&t.destroy(e);this.deleteAllLights(),this.three.children=[],this.onDisposed.trigger(),this.onDisposed.reset()}deleteAllLights(){for(const[,t]of this.directionalLights)t.removeFromParent(),t.target.removeFromParent(),t.dispose();this.directionalLights.clear();for(const[,t]of this.ambientLights)t.removeFromParent(),t.dispose();this.ambientLights.clear()}}Set;const In=class Gt{static create(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0;return`${Gt._lut[255&t]+Gt._lut[t>>8&255]+Gt._lut[t>>16&255]+Gt._lut[t>>24&255]}-${Gt._lut[255&e]}${Gt._lut[e>>8&255]}-${Gt._lut[e>>16&15|64]}${Gt._lut[e>>24&255]}-${Gt._lut[63&i|128]}${Gt._lut[i>>8&255]}-${Gt._lut[i>>16&255]}${Gt._lut[i>>24&255]}${Gt._lut[255&s]}${Gt._lut[s>>8&255]}${Gt._lut[s>>16&255]}${Gt._lut[s>>24&255]}`.toLowerCase()}static validate(t){if(!Gt._pattern.test(t))throw new Error(`${t} is not a valid UUID v4.\n\n- If you're the tool creator, you can take one from https://www.uuidgenerator.net/.\n\n- If you're using a platform tool, verify the uuid isn't misspelled or contact the tool creator.`)}};y(In,"_pattern",/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/),y(In,"_lut",["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"]);let ie=In;const Mo=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",dh=new RegExp("^["+Mo+"]["+Mo+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function Io(r,t){const e=[];let i=t.exec(r);for(;i;){const s=[];s.startIndex=t.lastIndex-i[0].length;const n=i.length;for(let o=0;o<n;o++)s.push(i[o]);e.push(s),i=t.exec(r)}return e}const bs=function(r){const t=dh.exec(r);return!(null===t||typeof t>"u")},On=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Oo=["__proto__","constructor","prototype"],ph={allowBooleanAttributes:!1,unpairedTags:[]};function zo(r){return" "===r||"\t"===r||"\n"===r||"\r"===r}function Do(r,t){const e=t;for(;t<r.length;t++)if("?"==r[t]||" "==r[t]){const i=r.substr(e,t-e);if(t>5&&"xml"===i)return Bt("InvalidXml","XML declaration allowed only at the start of the document.",Kt(r,t));if("?"==r[t]&&">"==r[t+1]){t++;break}continue}return t}function ko(r,t){if(r.length>t+5&&"-"===r[t+1]&&"-"===r[t+2]){for(t+=3;t<r.length;t++)if("-"===r[t]&&"-"===r[t+1]&&">"===r[t+2]){t+=2;break}}else if(r.length>t+8&&"D"===r[t+1]&&"O"===r[t+2]&&"C"===r[t+3]&&"T"===r[t+4]&&"Y"===r[t+5]&&"P"===r[t+6]&&"E"===r[t+7]){let e=1;for(t+=8;t<r.length;t++)if("<"===r[t])e++;else if(">"===r[t]&&(e--,0===e))break}else if(r.length>t+9&&"["===r[t+1]&&"C"===r[t+2]&&"D"===r[t+3]&&"A"===r[t+4]&&"T"===r[t+5]&&"A"===r[t+6]&&"["===r[t+7])for(t+=8;t<r.length;t++)if("]"===r[t]&&"]"===r[t+1]&&">"===r[t+2]){t+=2;break}return t}function yh(r,t){let e="",i="",s=!1;for(;t<r.length;t++){if('"'===r[t]||"'"===r[t])""===i?i=r[t]:i!==r[t]||(i="");else if(">"===r[t]&&""===i){s=!0;break}e+=r[t]}return""===i&&{value:e,index:t,tagClosed:s}}const wh=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function Lo(r,t){const e=Io(r,wh),i={};for(let s=0;s<e.length;s++){if(0===e[s][1].length)return Bt("InvalidAttr","Attribute '"+e[s][2]+"' has no space in starting.",Yi(e[s]));if(void 0!==e[s][3]&&void 0===e[s][4])return Bt("InvalidAttr","Attribute '"+e[s][2]+"' is without value.",Yi(e[s]));if(void 0===e[s][3]&&!t.allowBooleanAttributes)return Bt("InvalidAttr","boolean attribute '"+e[s][2]+"' is not allowed.",Yi(e[s]));const n=e[s][2];if(!xh(n))return Bt("InvalidAttr","Attribute '"+n+"' is an invalid name.",Yi(e[s]));if(Object.prototype.hasOwnProperty.call(i,n))return Bt("InvalidAttr","Attribute '"+n+"' is repeated.",Yi(e[s]));i[n]=1}return!0}function bh(r,t){if(";"===r[++t])return-1;if("#"===r[t])return function vh(r,t){let e=/\d/;for("x"===r[t]&&(t++,e=/[\da-fA-F]/);t<r.length;t++){if(";"===r[t])return t;if(!r[t].match(e))break}return-1}(r,++t);let e=0;for(;t<r.length;t++,e++)if(!(r[t].match(/\w/)&&e<20)){if(";"===r[t])break;return-1}return t}function Bt(r,t,e){return{err:{code:r,msg:t,line:e.line||e,col:e.col}}}function xh(r){return bs(r)}function Ch(r){return bs(r)}function Kt(r,t){const e=r.substring(0,t).split(/\r?\n/);return{line:e.length,col:e[e.length-1].length+1}}function Yi(r){return r.startIndex+r[1].length}const Th={cent:"\xa2",pound:"\xa3",curren:"\xa4",yen:"\xa5",euro:"\u20ac",dollar:"$",euro:"\u20ac",fnof:"\u0192",inr:"\u20b9",af:"\u060b",birr:"\u1265\u122d",peso:"\u20b1",rub:"\u20bd",won:"\u20a9",yuan:"\xa5",cedil:"\xb8"},No={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},Ph={nbsp:"\xa0",copy:"\xa9",reg:"\xae",trade:"\u2122",mdash:"\u2014",ndash:"\u2013",hellip:"\u2026",laquo:"\xab",raquo:"\xbb",lsquo:"\u2018",rsquo:"\u2019",ldquo:"\u201c",rdquo:"\u201d",bull:"\u2022",para:"\xb6",sect:"\xa7",deg:"\xb0",frac12:"\xbd",frac14:"\xbc",frac34:"\xbe"},Sh=new Set("!?\\\\/[]$%{}^&*()<>|+");function Bo(r){if("#"===r[0])throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${r}"`);for(const t of r)if(Sh.has(t))throw new Error(`[EntityReplacer] Invalid character '${t}' in entity name: "${r}"`);return r}function zn(...r){const t=Object.create(null);for(const e of r)if(e)for(const i of Object.keys(e)){const s=e[i];if("string"==typeof s)t[i]=s;else if(s&&"object"==typeof s&&void 0!==s.val){const n=s.val;"string"==typeof n&&(t[i]=n)}}return t}const li="external",xs="base",se=Object.freeze({allow:0,leave:1,remove:2,throw:3}),Ah=new Set([9,10,13]);class Ih{constructor(t={}){this._limit=t.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck="function"==typeof t.postCheck?t.postCheck:i=>i,this._limitTiers=function Eh(r){return r&&r!==li?"all"===r?new Set(["all"]):r===xs?new Set([xs]):Array.isArray(r)?new Set(r):new Set([li]):new Set([li])}(this._limit.applyLimitsTo??li),this._numericAllowed=t.numericAllowed??!0,this._baseMap=zn(No,t.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(t.remove&&Array.isArray(t.remove)?t.remove:[]),this._leaveSet=new Set(t.leave&&Array.isArray(t.leave)?t.leave:[]);const e=function Mh(r){return r?{xmlVersion:1.1===r.xmlVersion?1.1:1,onLevel:se[r.onNCR]??se.allow,nullLevel:Math.max(se[r.nullNCR]??se.remove,se.remove)}:{xmlVersion:1,onLevel:se.allow,nullLevel:se.remove}}(t.ncr);this._ncrXmlVersion=e.xmlVersion,this._ncrOnLevel=e.onLevel,this._ncrNullLevel=e.nullLevel}setExternalEntities(t){if(t)for(const e of Object.keys(t))Bo(e);this._externalMap=zn(t)}addExternalEntity(t,e){Bo(t),"string"==typeof e&&-1===e.indexOf("&")&&(this._externalMap[t]=e)}addInputEntities(t){this._totalExpansions=0,this._expandedLength=0,this._inputMap=zn(t)}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(t){this._ncrXmlVersion=1.1===t?1.1:1}decode(t){if("string"!=typeof t||0===t.length)return t;const e=t,i=[],s=t.length;let n=0,o=0;const a=this._maxTotalExpansions>0,l=this._maxExpandedLength>0,c=a||l;for(;o<s;){if(38!==t.charCodeAt(o)){o++;continue}let u=o+1;for(;u<s&&59!==t.charCodeAt(u)&&u-o<=32;)u++;if(u>=s||59!==t.charCodeAt(u)){o++;continue}const f=t.slice(o+1,u);if(0===f.length){o++;continue}let d,_;if(this._removeSet.has(f))d="",void 0===_&&(_=li);else{if(this._leaveSet.has(f)){o++;continue}if(35===f.charCodeAt(0)){const m=this._resolveNCR(f);if(void 0===m){o++;continue}d=m,_=xs}else{const m=this._resolveName(f);d=m?.value,_=m?.tier}}if(void 0!==d){if(o>n&&i.push(t.slice(n,o)),i.push(d),n=u+1,o=n,c&&this._tierCounts(_)){if(a&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(l){const m=d.length-(f.length+2);if(m>0&&(this._expandedLength+=m,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}else o++}n<s&&i.push(t.slice(n));const h=0===i.length?t:i.join("");return this._postCheck(h,e)}_tierCounts(t){return!!this._limitTiers.has("all")||this._limitTiers.has(t)}_resolveName(t){return t in this._inputMap?{value:this._inputMap[t],tier:li}:t in this._externalMap?{value:this._externalMap[t],tier:li}:t in this._baseMap?{value:this._baseMap[t],tier:xs}:void 0}_classifyNCR(t){return 0===t?this._ncrNullLevel:t>=55296&&t<=57343||1===this._ncrXmlVersion&&t>=1&&t<=31&&!Ah.has(t)?se.remove:-1}_applyNCRAction(t,e,i){switch(t){case se.allow:return String.fromCodePoint(i);case se.remove:return"";case se.leave:return;case se.throw:throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e}; (U+${i.toString(16).toUpperCase().padStart(4,"0")})`);default:return String.fromCodePoint(i)}}_resolveNCR(t){const e=t.charCodeAt(1);let i;if(i=120===e||88===e?parseInt(t.slice(2),16):parseInt(t.slice(1),10),Number.isNaN(i)||i<0||i>1114111)return;const s=this._classifyNCR(i);if(!this._numericAllowed&&s<se.remove)return;const n=-1===s?this._ncrOnLevel:Math.max(this._ncrOnLevel,s);return this._applyNCRAction(n,t,i)}}const Ro=r=>On.includes(r)?"__"+r:r,Oh={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(r,t){return t},attributeValueProcessor:function(r,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(r,t,e){return r},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:Ro};function zh(r,t){if("string"!=typeof r)return;const e=r.toLowerCase();if(On.some(i=>e===i.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${r}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Oo.some(i=>e===i.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${r}" is a reserved JavaScript keyword that could cause prototype pollution`)}function Fo(r,t){return"boolean"==typeof r?{enabled:r,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:"all"}:"object"==typeof r&&null!==r?{enabled:!1!==r.enabled,maxEntitySize:Math.max(1,r.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,r.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,r.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,r.maxExpandedLength??1e5),maxEntityCount:Math.max(1,r.maxEntityCount??1e3),allowedTags:r.allowedTags??null,tagFilter:r.tagFilter??null,appliesTo:r.appliesTo??"all"}:Fo(!0)}const Dh=function(r){const t=Object.assign({},Oh,r),e=[{value:t.attributeNamePrefix,name:"attributeNamePrefix"},{value:t.attributesGroupName,name:"attributesGroupName"},{value:t.textNodeName,name:"textNodeName"},{value:t.cdataPropName,name:"cdataPropName"},{value:t.commentPropName,name:"commentPropName"}];for(const{value:i,name:s}of e)i&&zh(i,s);return null===t.onDangerousProperty&&(t.onDangerousProperty=Ro),t.processEntities=Fo(t.processEntities),t.unpairedTagsSet=new Set(t.unpairedTags),t.stopNodes&&Array.isArray(t.stopNodes)&&(t.stopNodes=t.stopNodes.map(i=>"string"==typeof i&&i.startsWith("*.")?".."+i.substring(2):i)),t};let Cs;Cs="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class Ge{constructor(t){this.tagname=t,this.child=[],this[":@"]=Object.create(null)}add(t,e){"__proto__"===t&&(t="#__proto__"),this.child.push({[t]:e})}addChild(t,e){"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child}),void 0!==e&&(this.child[this.child.length-1][Cs]={startIndex:e})}static getMetaDataSymbol(){return Cs}}class kh{constructor(t){this.suppressValidationErr=!t,this.options=t}readDocType(t,e){const i=Object.create(null);let s=0;if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");{e+=9;let n=1,o=!1,a=!1,l="";for(;e<t.length;e++)if("<"!==t[e]||a)if(">"===t[e]){if(a?"-"===t[e-1]&&"-"===t[e-2]&&(a=!1,n--):n--,0===n)break}else"["===t[e]?o=!0:l+=t[e];else{if(o&&ci(t,"!ENTITY",e)){let c,h;if(e+=7,[c,h,e]=this.readEntityExp(t,e+1,this.suppressValidationErr),-1===h.indexOf("&")){if(!1!==this.options.enabled&&null!=this.options.maxEntityCount&&s>=this.options.maxEntityCount)throw new Error(`Entity count (${s+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);i[c]=h,s++}}else if(o&&ci(t,"!ELEMENT",e)){e+=8;const{index:c}=this.readElementExp(t,e+1);e=c}else if(o&&ci(t,"!ATTLIST",e))e+=8;else if(o&&ci(t,"!NOTATION",e)){e+=9;const{index:c}=this.readNotationExp(t,e+1,this.suppressValidationErr);e=c}else{if(!ci(t,"!--",e))throw new Error("Invalid DOCTYPE");a=!0}n++,l=""}if(0!==n)throw new Error("Unclosed DOCTYPE")}return{entities:i,i:e}}readEntityExp(t,e){const i=e=ne(t,e);for(;e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)e++;let s=t.substring(i,e);if(Zi(s),e=ne(t,e),!this.suppressValidationErr){if("SYSTEM"===t.substring(e,e+6).toUpperCase())throw new Error("External entities are not supported");if("%"===t[e])throw new Error("Parameter entities are not supported")}let n="";if([e,n]=this.readIdentifierVal(t,e,"entity"),!1!==this.options.enabled&&null!=this.options.maxEntitySize&&n.length>this.options.maxEntitySize)throw new Error(`Entity "${s}" size (${n.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[s,n,--e]}readNotationExp(t,e){const i=e=ne(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let s=t.substring(i,e);!this.suppressValidationErr&&Zi(s),e=ne(t,e);const n=t.substring(e,e+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==n&&"PUBLIC"!==n)throw new Error(`Expected SYSTEM or PUBLIC, found "${n}"`);e=ne(t,e+=n.length);let o=null,a=null;if("PUBLIC"===n)[e,o]=this.readIdentifierVal(t,e,"publicIdentifier"),('"'===t[e=ne(t,e)]||"'"===t[e])&&([e,a]=this.readIdentifierVal(t,e,"systemIdentifier"));else if("SYSTEM"===n&&([e,a]=this.readIdentifierVal(t,e,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:s,publicIdentifier:o,systemIdentifier:a,index:--e}}readIdentifierVal(t,e,i){let s="";const n=t[e];if('"'!==n&&"'"!==n)throw new Error(`Expected quoted string, found "${n}"`);const o=++e;for(;e<t.length&&t[e]!==n;)e++;if(s=t.substring(o,e),t[e]!==n)throw new Error(`Unterminated ${i} value`);return[++e,s]}readElementExp(t,e){const i=e=ne(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let s=t.substring(i,e);if(!this.suppressValidationErr&&!bs(s))throw new Error(`Invalid element name: "${s}"`);let n="";if("E"===t[e=ne(t,e)]&&ci(t,"MPTY",e))e+=4;else if("A"===t[e]&&ci(t,"NY",e))e+=2;else if("("===t[e]){const o=++e;for(;e<t.length&&")"!==t[e];)e++;if(n=t.substring(o,e),")"!==t[e])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${t[e]}"`);return{elementName:s,contentModel:n.trim(),index:e}}readAttlistExp(t,e){let i=e=ne(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let s=t.substring(i,e);for(Zi(s),i=e=ne(t,e);e<t.length&&!/\s/.test(t[e]);)e++;let n=t.substring(i,e);if(!Zi(n))throw new Error(`Invalid attribute name: "${n}"`);e=ne(t,e);let o="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(o="NOTATION","("!==t[e=ne(t,e+=8)])throw new Error(`Expected '(', found "${t[e]}"`);e++;let l=[];for(;e<t.length&&")"!==t[e];){const c=e;for(;e<t.length&&"|"!==t[e]&&")"!==t[e];)e++;let h=t.substring(c,e);if(h=h.trim(),!Zi(h))throw new Error(`Invalid notation name: "${h}"`);l.push(h),"|"===t[e]&&(e++,e=ne(t,e))}if(")"!==t[e])throw new Error("Unterminated list of notations");e++,o+=" ("+l.join("|")+")"}else{const l=e;for(;e<t.length&&!/\s/.test(t[e]);)e++;if(o+=t.substring(l,e),!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(o.toUpperCase()))throw new Error(`Invalid attribute type: "${o}"`)}e=ne(t,e);let a="";return"#REQUIRED"===t.substring(e,e+8).toUpperCase()?(a="#REQUIRED",e+=8):"#IMPLIED"===t.substring(e,e+7).toUpperCase()?(a="#IMPLIED",e+=7):[e,a]=this.readIdentifierVal(t,e,"ATTLIST"),{elementName:s,attributeName:n,attributeType:o,defaultValue:a,index:e}}}const ne=(r,t)=>{for(;t<r.length&&/\s/.test(r[t]);)t++;return t};function ci(r,t,e){for(let i=0;i<t.length;i++)if(t[i]!==r[e+i+1])return!1;return!0}function Zi(r){if(bs(r))return r;throw new Error(`Invalid entity name ${r}`)}const Lh=/^[-+]?0x[a-fA-F0-9]+$/,Nh=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Bh={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};const Fh=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;class xi{constructor(t,e={},i){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=i,this._hasDeepWildcard=this.segments.some(s=>"deep-wildcard"===s.type),this._hasAttributeCondition=this.segments.some(s=>void 0!==s.attrName),this._hasPositionSelector=this.segments.some(s=>void 0!==s.position)}_parse(t){const e=[];let i=0,s="";for(;i<t.length;)t[i]===this.separator?i+1<t.length&&t[i+1]===this.separator?(s.trim()&&(e.push(this._parseSegment(s.trim())),s=""),e.push({type:"deep-wildcard"}),i+=2):(s.trim()&&e.push(this._parseSegment(s.trim())),s="",i++):(s+=t[i],i++);return s.trim()&&e.push(this._parseSegment(s.trim())),e}_parseSegment(t){const e={type:"tag"};let i=null,s=t;const n=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(n&&(s=n[1]+n[3],n[2])){const h=n[2].slice(1,-1);h&&(i=h)}let o,a=s;if(s.includes("::")){const h=s.indexOf("::");if(o=s.substring(0,h).trim(),a=s.substring(h+2).trim(),!o)throw new Error(`Invalid namespace in pattern: ${t}`)}let l,c=null;if(a.includes(":")){const h=a.lastIndexOf(":"),u=a.substring(0,h).trim(),f=a.substring(h+1).trim();["first","last","odd","even"].includes(f)||/^nth\(\d+\)$/.test(f)?(l=u,c=f):l=a}else l=a;if(!l)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=l,o&&(e.namespace=o),i)if(i.includes("=")){const h=i.indexOf("=");e.attrName=i.substring(0,h).trim(),e.attrValue=i.substring(h+1).trim()}else e.attrName=i.trim();if(c){const h=c.match(/^nth\((\d+)\)$/);h?(e.position="nth",e.positionValue=parseInt(h[1],10)):e.position=c}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class qh{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard())return this._deepWildcards.push(t),this;const e=t.length,i=t.segments[t.segments.length-1],s=i?.tag;if(s&&"*"!==s){const n=`${e}:${s}`;this._byDepthAndTag.has(n)||this._byDepthAndTag.set(n,[]),this._byDepthAndTag.get(n).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),i=t.getCurrentTag(),n=this._byDepthAndTag.get(`${e}:${i}`);if(n)for(let a=0;a<n.length;a++)if(t.matches(n[a]))return n[a];const o=this._wildcardByDepth.get(e);if(o)for(let a=0;a<o.length;a++)if(t.matches(o[a]))return o[a];for(let a=0;a<this._deepWildcards.length;a++)if(t.matches(this._deepWildcards[a]))return this._deepWildcards[a];return null}}class Gh{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){var e;const i=this._matcher.path;if(0!==i.length)return null==(e=i[i.length-1].values)?void 0:e[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const i=e[e.length-1];return void 0!==i.values&&t in i.values}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class kn{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new Gh(this)}push(t,e=null,i=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const s=this.path.length;this.siblingStacks[s]||(this.siblingStacks[s]=new Map);const n=this.siblingStacks[s],o=i?`${i}:${t}`:t,a=n.get(o)||0;let l=0;for(const h of n.values())l+=h;n.set(o,a+1);const c={tag:t,position:l,counter:a};null!=i&&(c.namespace=i),null!=e&&(c.values=e),this.path.push(c)}pop(){if(0===this.path.length)return;this._pathStringCache=null;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){this.path.length>0&&null!=t&&(this.path[this.path.length-1].values=t)}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){var e;if(0!==this.path.length)return null==(e=this.path[this.path.length-1].values)?void 0:e[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const i=t||this.separator;if(i===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const n=this.path.map(o=>o.namespace?`${o.namespace}:${o.tag}`:o.tag).join(i);return this._pathStringCache=n,n}return this.path.map(n=>e&&n.namespace?`${n.namespace}:${n.tag}`:n.tag).join(i)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!this._matchSegment(t[e],this.path[e],e===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,i=t.length-1;for(;i>=0&&e>=0;){const s=t[i];if("deep-wildcard"===s.type){if(i--,i<0)return!0;const n=t[i];let o=!1;for(let a=e;a>=0;a--)if(this._matchSegment(n,this.path[a],a===this.path.length-1)){e=a-1,i--,o=!0;break}if(!o)return!1}else{if(!this._matchSegment(s,this.path[e],e===this.path.length-1))return!1;e--,i--}}return i<0}_matchSegment(t,e,i){if("*"!==t.tag&&t.tag!==e.tag||void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace||void 0!==t.attrName&&(!i||!e.values||!(t.attrName in e.values)||void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue)))return!1;if(void 0!==t.position){if(!i)return!1;const s=e.counter??0;if("first"===t.position&&0!==s)return!1;if("odd"===t.position&&s%2!=1)return!1;if("even"===t.position&&s%2!=0)return!1;if("nth"===t.position&&s!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this.path=t.path.map(e=>({...e})),this.siblingStacks=t.siblingStacks.map(e=>new Map(e))}readOnly(){return this._view}}function Yh(r,t){if(!r)return{};const e=t.attributesGroupName?r[t.attributesGroupName]:r;if(!e)return{};const i={};for(const s in e)s.startsWith(t.attributeNamePrefix)?i[s.substring(t.attributeNamePrefix.length)]=e[s]:i[s]=e[s];return i}function Zh(r){if(!r||"string"!=typeof r)return;const t=r.indexOf(":");if(-1!==t&&t>0){const e=r.substring(0,t);if("xmlns"!==e)return e}}class Wh{constructor(t,e){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=tu,this.parseTextData=Xh,this.resolveNameSpace=Kh,this.buildAttributesMap=Jh,this.isItStopNode=nu,this.replaceEntitiesValue=iu,this.readStopNodeData=au,this.saveTextToParentTag=su,this.addChild=eu,this.ignoreAttributesFn=function Hh(r){return"function"==typeof r?r:Array.isArray(r)?t=>{for(const e of r)if("string"==typeof e&&t===e||e instanceof RegExp&&e.test(t))return!0}:()=>!1}(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0;let i={...No};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:("object"==typeof this.options.htmlEntities?i=this.options.htmlEntities:!0===this.options.htmlEntities&&(i={...Ph,...Th}),this.entityDecoder=new Ih({namedEntities:{...i,...e},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo}})),this.matcher=new kn,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new qh;const s=this.options.stopNodes;if(s&&s.length>0){for(let n=0;n<s.length;n++){const o=s[n];"string"==typeof o?this.stopNodeExpressionsSet.add(new xi(o)):o instanceof xi&&this.stopNodeExpressionsSet.add(o)}this.stopNodeExpressionsSet.seal()}}}function Xh(r,t,e,i,s,n,o){const a=this.options;if(void 0!==r&&(a.trimValues&&!i&&(r=r.trim()),r.length>0)){o||(r=this.replaceEntitiesValue(r,t,e));const l=a.jPath?e.toString():e,c=a.tagValueProcessor(t,r,l,s,n);return null==c?r:typeof c!=typeof r||c!==r?c:a.trimValues||r.trim()===r?Nn(r,a.parseTagValue,a.numberParseOptions):r}}function Kh(r){if(this.options.removeNSPrefix){const t=r.split(":"),e="/"===r.charAt(0)?"/":"";if("xmlns"===t[0])return"";2===t.length&&(r=e+t[1])}return r}const Qh=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Jh(r,t,e,i=!1){const s=this.options;if(!0===i||!0!==s.ignoreAttributes&&"string"==typeof r){const n=Io(r,Qh),o=n.length,a={},l=new Array(o);let c=!1;const h={};for(let d=0;d<o;d++){const _=this.resolveNameSpace(n[d][1]),m=n[d][4];if(_.length&&void 0!==m){let w=m;s.trimValues&&(w=w.trim()),w=this.replaceEntitiesValue(w,e,this.readonlyMatcher),l[d]=w,h[_]=w,c=!0}}c&&"object"==typeof t&&t.updateCurrent&&t.updateCurrent(h);const u=s.jPath?t.toString():this.readonlyMatcher;let f=!1;for(let d=0;d<o;d++){const _=this.resolveNameSpace(n[d][1]);if(this.ignoreAttributesFn(_,u))continue;let m=s.attributeNamePrefix+_;if(_.length)if(s.transformAttributeName&&(m=s.transformAttributeName(m)),m=Vo(m,s),void 0!==n[d][4]){const w=l[d],g=s.attributeValueProcessor(_,w,u);a[m]=null==g?w:typeof g!=typeof w||g!==w?g:Nn(w,s.parseAttributeValue,s.numberParseOptions),f=!0}else s.allowBooleanAttributes&&(a[m]=!0,f=!0)}if(!f)return;if(s.attributesGroupName&&!s.preserveOrder){const d={};return d[s.attributesGroupName]=a,d}return a}}const tu=function(r){r=r.replace(/\r\n?/g,"\n");const t=new Ge("!xml");let e=t,i="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;const s=this.options,n=new kh(s.processEntities),o=r.length;for(let a=0;a<o;a++)if("<"===r[a]){const c=r.charCodeAt(a+1);if(47===c){const h=Ci(r,">",a,"Closing Tag is not closed.");let u=r.substring(a+2,h).trim();if(s.removeNSPrefix){const d=u.indexOf(":");-1!==d&&(u=u.substr(d+1))}u=Bn(s.transformTagName,u,"",s).tagName,e&&(i=this.saveTextToParentTag(i,e,this.readonlyMatcher));const f=this.matcher.getCurrentTag();if(u&&s.unpairedTagsSet.has(u))throw new Error(`Unpaired tag can not be used as closing tag: </${u}>`);f&&s.unpairedTagsSet.has(f)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,e=this.tagsNodeStack.pop(),i="",a=h}else if(63===c){let h=Ln(r,a,!1,"?>");if(!h)throw new Error("Pi Tag is not closed.");i=this.saveTextToParentTag(i,e,this.readonlyMatcher);const u=this.buildAttributesMap(h.tagExp,this.matcher,h.tagName,!0);if(u&&this.entityDecoder.setXmlVersion(Number(u[this.options.attributeNamePrefix+"version"])||1),!(s.ignoreDeclaration&&"?xml"===h.tagName||s.ignorePiTags)){const f=new Ge(h.tagName);f.add(s.textNodeName,""),h.tagName!==h.tagExp&&h.attrExpPresent&&!0!==s.ignoreAttributes&&(f[":@"]=u),this.addChild(e,f,this.readonlyMatcher,a)}a=h.closeIndex+1}else if(33===c&&45===r.charCodeAt(a+2)&&45===r.charCodeAt(a+3)){const h=Ci(r,"--\x3e",a+4,"Comment is not closed.");if(s.commentPropName){const u=r.substring(a+4,h-2);i=this.saveTextToParentTag(i,e,this.readonlyMatcher),e.add(s.commentPropName,[{[s.textNodeName]:u}])}a=h}else if(33===c&&68===r.charCodeAt(a+2)){const h=n.readDocType(r,a);this.entityDecoder.addInputEntities(h.entities),a=h.i}else if(33===c&&91===r.charCodeAt(a+2)){const h=Ci(r,"]]>",a,"CDATA is not closed.")-2,u=r.substring(a+9,h);i=this.saveTextToParentTag(i,e,this.readonlyMatcher);let f=this.parseTextData(u,e.tagname,this.readonlyMatcher,!0,!1,!0,!0);null==f&&(f=""),s.cdataPropName?e.add(s.cdataPropName,[{[s.textNodeName]:u}]):e.add(s.textNodeName,f),a=h+2}else{let h=Ln(r,a,s.removeNSPrefix);if(!h){const S=r.substring(Math.max(0,a-50),Math.min(o,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${S}"`)}let u=h.tagName;const f=h.rawTagName;let d=h.tagExp,_=h.attrExpPresent,m=h.closeIndex;if(({tagName:u,tagExp:d}=Bn(s.transformTagName,u,d,s)),s.strictReservedNames&&(u===s.commentPropName||u===s.cdataPropName||u===s.textNodeName||u===s.attributesGroupName))throw new Error(`Invalid tag name: ${u}`);e&&i&&"!xml"!==e.tagname&&(i=this.saveTextToParentTag(i,e,this.readonlyMatcher,!1)),e&&s.unpairedTagsSet.has(e.tagname)&&(e=this.tagsNodeStack.pop(),this.matcher.pop());let g=!1;d.length>0&&d.lastIndexOf("/")===d.length-1&&(g=!0,"/"===u[u.length-1]?(u=u.substr(0,u.length-1),d=u):d=d.substr(0,d.length-1),_=u!==d);let T,v=null;T=Zh(f),u!==t.tagname&&this.matcher.push(u,{},T),u!==d&&_&&(v=this.buildAttributesMap(d,this.matcher,u),v&&Yh(v,s)),u!==t.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());const C=a;if(this.isCurrentNodeStopNode){let S="";if(g)a=h.closeIndex;else if(s.unpairedTagsSet.has(u))a=h.closeIndex;else{const A=this.readStopNodeData(r,f,m+1);if(!A)throw new Error(`Unexpected end of ${f}`);a=A.i,S=A.tagContent}const M=new Ge(u);v&&(M[":@"]=v),M.add(s.textNodeName,S),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(e,M,this.readonlyMatcher,C)}else{if(g){({tagName:u,tagExp:d}=Bn(s.transformTagName,u,d,s));const S=new Ge(u);v&&(S[":@"]=v),this.addChild(e,S,this.readonlyMatcher,C),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(s.unpairedTagsSet.has(u)){const S=new Ge(u);v&&(S[":@"]=v),this.addChild(e,S,this.readonlyMatcher,C),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=h.closeIndex;continue}{const S=new Ge(u);if(this.tagsNodeStack.length>s.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(e),v&&(S[":@"]=v),this.addChild(e,S,this.readonlyMatcher,C),e=S}}i="",a=m}}}else i+=r[a];return t.child};function eu(r,t,e,i){this.options.captureMetaData||(i=void 0);const s=this.options.jPath?e.toString():e,n=this.options.updateTag(t.tagname,s,t[":@"]);!1===n||("string"==typeof n&&(t.tagname=n),r.addChild(t,i))}function iu(r,t,e){const i=this.options.processEntities;if(!i||!i.enabled)return r;if(i.allowedTags){const s=this.options.jPath?e.toString():e;if(!(Array.isArray(i.allowedTags)?i.allowedTags.includes(t):i.allowedTags(t,s)))return r}if(i.tagFilter){const s=this.options.jPath?e.toString():e;if(!i.tagFilter(t,s))return r}return this.entityDecoder.decode(r)}function su(r,t,e,i){return r&&(void 0===i&&(i=0===t.child.length),void 0!==(r=this.parseTextData(r,t.tagname,e,!1,!!t[":@"]&&0!==Object.keys(t[":@"]).length,i))&&""!==r&&t.add(this.options.textNodeName,r),r=""),r}function nu(){return 0!==this.stopNodeExpressionsSet.size&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function Ci(r,t,e,i){const s=r.indexOf(t,e);if(-1===s)throw new Error(i);return s+t.length-1}function ou(r,t,e,i){const s=r.indexOf(t,e);if(-1===s)throw new Error(i);return s}function Ln(r,t,e,i=">"){const s=function ru(r,t,e=">"){let i=0;const s=r.length,n=e.charCodeAt(0),o=e.length>1?e.charCodeAt(1):-1;let a="",l=t;for(let c=t;c<s;c++){const h=r.charCodeAt(c);if(i)h===i&&(i=0);else if(34===h||39===h)i=h;else if(h===n){if(-1===o)return a+=r.substring(l,c),{data:a,index:c};if(r.charCodeAt(c+1)===o)return a+=r.substring(l,c),{data:a,index:c}}else 9===h&&!i&&(a+=r.substring(l,c)+" ",l=c+1)}}(r,t+1,i);if(!s)return;let n=s.data;const o=s.index,a=n.search(/\s/);let l=n,c=!0;-1!==a&&(l=n.substring(0,a),n=n.substring(a+1).trimStart());const h=l;if(e){const u=l.indexOf(":");-1!==u&&(l=l.substr(u+1),c=l!==s.data.substr(u+1))}return{tagName:l,tagExp:n,closeIndex:o,attrExpPresent:c,rawTagName:h}}function au(r,t,e){const i=e;let s=1;const n=r.length;for(;e<n;e++)if("<"===r[e]){const o=r.charCodeAt(e+1);if(47===o){const a=ou(r,">",e,`${t} is not closed`);if(r.substring(e+2,a).trim()===t&&(s--,0===s))return{tagContent:r.substring(i,e),i:a};e=a}else if(63===o)e=Ci(r,"?>",e+1,"StopNode is not closed.");else if(33===o&&45===r.charCodeAt(e+2)&&45===r.charCodeAt(e+3))e=Ci(r,"--\x3e",e+3,"StopNode is not closed.");else if(33===o&&91===r.charCodeAt(e+2))e=Ci(r,"]]>",e,"StopNode is not closed.")-2;else{const a=Ln(r,e,">");a&&((a&&a.tagName)===t&&"/"!==a.tagExp[a.tagExp.length-1]&&s++,e=a.closeIndex)}}}function Nn(r,t,e){if(t&&"string"==typeof r){const i=r.trim();return"true"===i||"false"!==i&&function Rh(r,t={}){if(t=Object.assign({},Bh,t),!r||"string"!=typeof r)return r;let e=r.trim();if(0===e.length)return r;if(void 0!==t.skipLike&&t.skipLike.test(e))return r;if("0"===e)return 0;if(t.hex&&Lh.test(e))return function $h(r,t){if(parseInt)return parseInt(r,t);if(Number.parseInt)return Number.parseInt(r,t);if(window&&window.parseInt)return window.parseInt(r,t);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(e,16);if(isFinite(e)){if(e.includes("e")||e.includes("E"))return function Vh(r,t,e){if(!e.eNotation)return r;const i=t.match(Fh);if(i){let s=i[1]||"";const n=-1===i[3].indexOf("e")?"E":"e",o=i[2],a=s?r[o.length+1]===n:r[o.length]===n;return o.length>1&&a?r:(1!==o.length||!i[3].startsWith(`.${n}`)&&i[3][0]!==n)&&o.length>0?e.leadingZeros&&!a?(t=(i[1]||"")+i[3],Number(t)):r:Number(t)}return r}(r,e,t);{const i=Nh.exec(e);if(i){const s=i[1]||"",n=i[2];let o=function Uh(r){return r&&-1!==r.indexOf(".")&&("."===(r=r.replace(/0+$/,""))?r="0":"."===r[0]?r="0"+r:"."===r[r.length-1]&&(r=r.substring(0,r.length-1))),r}(i[3]);if(!t.leadingZeros&&(n.length>1||1===n.length&&!(s?"."===r[n.length+1]:"."===r[n.length])))return r;{const l=Number(e),c=String(l);if(0===l)return l;if(-1!==c.search(/[eE]/))return t.eNotation?l:r;if(-1!==e.indexOf("."))return"0"===c||c===o||c===`${s}${o}`?l:r;let h=n?o:e;return n?h===c||s+h===c?l:r:h===c||h===s+c?l:r}}return r}}return function jh(r,t,e){const i=t===1/0;switch(e.infinity.toLowerCase()){case"null":return null;case"infinity":return t;case"string":return i?"Infinity":"-Infinity";default:return r}}(r,Number(e),t)}(r,e)}return function fh(r){return typeof r<"u"}(r)?r:""}function Bn(r,t,e,i){if(r){const s=r(t);e===t&&(e=s),t=s}return{tagName:t=Vo(t,i),tagExp:e}}function Vo(r,t){if(Oo.includes(r))throw new Error(`[SECURITY] Invalid name: "${r}" is a reserved JavaScript keyword that could cause prototype pollution`);return On.includes(r)?t.onDangerousProperty(r):r}const Rn=Ge.getMetaDataSymbol();function lu(r,t){if(!r||"object"!=typeof r)return{};if(!t)return r;const e={};for(const i in r)i.startsWith(t)?e[i.substring(t.length)]=r[i]:e[i]=r[i];return e}function cu(r,t,e,i){return Uo(r,t,e,i)}function Uo(r,t,e,i){let s;const n={};for(let o=0;o<r.length;o++){const a=r[o],l=hu(a);if(void 0!==l&&l!==t.textNodeName){const c=lu(a[":@"]||{},t.attributeNamePrefix);e.push(l,c)}if(l===t.textNodeName)void 0===s?s=a[l]:s+=""+a[l];else{if(void 0===l)continue;if(a[l]){let c=Uo(a[l],t,e,i);const h=du(c,t);if(a[":@"]?uu(c,a[":@"],i,t):1!==Object.keys(c).length||void 0===c[t.textNodeName]||t.alwaysCreateTextNode?0===Object.keys(c).length&&(t.alwaysCreateTextNode?c[t.textNodeName]="":c=""):c=c[t.textNodeName],void 0!==a[Rn]&&"object"==typeof c&&null!==c&&(c[Rn]=a[Rn]),void 0!==n[l]&&Object.prototype.hasOwnProperty.call(n,l))Array.isArray(n[l])||(n[l]=[n[l]]),n[l].push(c);else{const u=t.jPath?i.toString():i;n[l]=t.isArray(l,u,h)?[c]:c}void 0!==l&&l!==t.textNodeName&&e.pop()}}}return"string"==typeof s?s.length>0&&(n[t.textNodeName]=s):void 0!==s&&(n[t.textNodeName]=s),n}function hu(r){const t=Object.keys(r);for(let e=0;e<t.length;e++){const i=t[e];if(":@"!==i)return i}}function uu(r,t,e,i){if(t){const s=Object.keys(t),n=s.length;for(let o=0;o<n;o++){const a=s[o],l=a.startsWith(i.attributeNamePrefix)?a.substring(i.attributeNamePrefix.length):a,c=i.jPath?e.toString()+"."+l:e;r[a]=i.isArray(a,c,!0,!0)?[t[a]]:t[a]}}}function du(r,t){const{textNodeName:e}=t,i=Object.keys(r).length;return!(0!==i&&(1!==i||!r[e]&&"boolean"!=typeof r[e]&&0!==r[e]))}class Fn{constructor(t){this.externalEntities={},this.options=Dh(t)}parse(t,e){if("string"!=typeof t&&t.toString)t=t.toString();else if("string"!=typeof t)throw new Error("XML data is accepted in String or Bytes[] form.");if(e){!0===e&&(e={});const n=function mh(r,t){t=Object.assign({},ph,t);const e=[];let i=!1,s=!1;"\ufeff"===r[0]&&(r=r.substr(1));for(let n=0;n<r.length;n++)if("<"===r[n]&&"?"===r[n+1]){if(n+=2,n=Do(r,n),n.err)return n}else{if("<"!==r[n]){if(zo(r[n]))continue;return Bt("InvalidChar","char '"+r[n]+"' is not expected.",Kt(r,n))}{let o=n;if(n++,"!"===r[n]){n=ko(r,n);continue}{let a=!1;"/"===r[n]&&(a=!0,n++);let l="";for(;n<r.length&&">"!==r[n]&&" "!==r[n]&&"\t"!==r[n]&&"\n"!==r[n]&&"\r"!==r[n];n++)l+=r[n];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),n--),!Ch(l)){let u;return u=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",Bt("InvalidTag",u,Kt(r,n))}const c=yh(r,n);if(!1===c)return Bt("InvalidAttr","Attributes for '"+l+"' have open quote.",Kt(r,n));let h=c.value;if(n=c.index,"/"===h[h.length-1]){const u=n-h.length;h=h.substring(0,h.length-1);const f=Lo(h,t);if(!0!==f)return Bt(f.err.code,f.err.msg,Kt(r,u+f.err.line));i=!0}else if(a){if(!c.tagClosed)return Bt("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Kt(r,n));if(h.trim().length>0)return Bt("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Kt(r,o));if(0===e.length)return Bt("InvalidTag","Closing tag '"+l+"' has not been opened.",Kt(r,o));{const u=e.pop();if(l!==u.tagName){let f=Kt(r,u.tagStartPos);return Bt("InvalidTag","Expected closing tag '"+u.tagName+"' (opened in line "+f.line+", col "+f.col+") instead of closing tag '"+l+"'.",Kt(r,o))}0==e.length&&(s=!0)}}else{const u=Lo(h,t);if(!0!==u)return Bt(u.err.code,u.err.msg,Kt(r,n-h.length+u.err.line));if(!0===s)return Bt("InvalidXml","Multiple possible root nodes found.",Kt(r,n));-1!==t.unpairedTags.indexOf(l)||e.push({tagName:l,tagStartPos:o}),i=!0}for(n++;n<r.length;n++)if("<"===r[n]){if("!"===r[n+1]){n++,n=ko(r,n);continue}if("?"!==r[n+1])break;if(n=Do(r,++n),n.err)return n}else if("&"===r[n]){const u=bh(r,n);if(-1==u)return Bt("InvalidChar","char '&' is not expected.",Kt(r,n));n=u}else if(!0===s&&!zo(r[n]))return Bt("InvalidXml","Extra text at the end",Kt(r,n));"<"===r[n]&&n--}}}return i?1==e.length?Bt("InvalidTag","Unclosed tag '"+e[0].tagName+"'.",Kt(r,e[0].tagStartPos)):!(e.length>0)||Bt("InvalidXml","Invalid '"+JSON.stringify(e.map(n=>n.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):Bt("InvalidXml","Start tag expected.",1)}(t,e);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const i=new Wh(this.options,this.externalEntities),s=i.parseXml(t);return this.options.preserveOrder||void 0===s?s:cu(s,this.options,i.matcher,i.readonlyMatcher)}addEntity(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e}static getMetaDataSymbol(){return Ge.getMetaDataSymbol()}}function pu(r,t){let e="";t.format&&t.indentBy.length>0&&(e="\n");const i=[];if(t.stopNodes&&Array.isArray(t.stopNodes))for(let n=0;n<t.stopNodes.length;n++){const o=t.stopNodes[n];"string"==typeof o?i.push(new xi(o)):o instanceof xi&&i.push(o)}return $o(r,t,e,new kn,i)}function $o(r,t,e,i,s){let n="",o=!1;if(t.maxNestedTags&&i.getDepth()>t.maxNestedTags)throw new Error("Maximum nested tags exceeded");if(!Array.isArray(r)){if(null!=r){let a=r.toString();return a=Vn(a,t),a}return""}for(let a=0;a<r.length;a++){const l=r[a],c=Ho(l);if(void 0===c)continue;const h=mu(l[":@"],t);i.push(c,h);const u=_u(i,s);if(c===t.textNodeName){let w=l[c];u||(w=t.tagValueProcessor(c,w),w=Vn(w,t)),o&&(n+=e),n+=w,o=!1,i.pop();continue}if(c===t.cdataPropName){o&&(n+=e),n+=`<![CDATA[${String(l[c][0][t.textNodeName]).replace(/\]\]>/g,"]]]]><![CDATA[>")}]]>`,o=!1,i.pop();continue}if(c===t.commentPropName){n+=e+`\x3c!--${String(l[c][0][t.textNodeName]).replace(/--/g,"- -").replace(/-$/,"- ")}--\x3e`,o=!0,i.pop();continue}if("?"===c[0]){const w=qo(l[":@"],t,u);let v=l[c][0][t.textNodeName];v=0!==v.length?" "+v:"",n+=("?xml"===c?"":e)+`<${c}${v}${w}?>`,o=!0,i.pop();continue}let f=e;""!==f&&(f+=t.indentBy);const _=e+`<${c}${qo(l[":@"],t,u)}`;let m;m=u?jo(l[c],t):$o(l[c],t,f,i,s),-1!==t.unpairedTags.indexOf(c)?n+=t.suppressUnpairedNode?_+">":_+"/>":m&&0!==m.length||!t.suppressEmptyNode?m&&m.endsWith(">")?n+=_+`>${m}${e}</${c}>`:(n+=_+">",m&&""!==e&&(m.includes("/>")||m.includes("</"))?n+=e+t.indentBy+m+e:n+=m,n+=`</${c}>`):n+=_+"/>",o=!0,i.pop()}return n}function mu(r,t){if(!r||t.ignoreAttributes)return null;const e={};let i=!1;for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s.startsWith(t.attributeNamePrefix)?s.substr(t.attributeNamePrefix.length):s]=r[s],i=!0);return i?e:null}function jo(r,t){if(!Array.isArray(r))return null!=r?r.toString():"";let e="";for(let i=0;i<r.length;i++){const s=r[i],n=Ho(s);if(n===t.textNodeName)e+=s[n];else if(n===t.cdataPropName)e+=s[n][0][t.textNodeName];else if(n===t.commentPropName)e+=s[n][0][t.textNodeName];else{if(n&&"?"===n[0])continue;if(n){const o=gu(s[":@"],t),a=jo(s[n],t);e+=a&&0!==a.length?`<${n}${o}>${a}</${n}>`:`<${n}${o}/>`}}}return e}function gu(r,t){let e="";if(r&&!t.ignoreAttributes)for(let i in r){if(!Object.prototype.hasOwnProperty.call(r,i))continue;let s=r[i];e+=!0===s&&t.suppressBooleanAttributes?` ${i.substr(t.attributeNamePrefix.length)}`:` ${i.substr(t.attributeNamePrefix.length)}="${s}"`}return e}function Ho(r){const t=Object.keys(r);for(let e=0;e<t.length;e++){const i=t[e];if(Object.prototype.hasOwnProperty.call(r,i)&&":@"!==i)return i}}function qo(r,t,e){let i="";if(r&&!t.ignoreAttributes)for(let s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;let n;e?n=r[s]:(n=t.attributeValueProcessor(s,r[s]),n=Vn(n,t)),i+=!0===n&&t.suppressBooleanAttributes?` ${s.substr(t.attributeNamePrefix.length)}`:` ${s.substr(t.attributeNamePrefix.length)}="${n}"`}return i}function _u(r,t){if(!t||0===t.length)return!1;for(let e=0;e<t.length;e++)if(r.matches(t[e]))return!0;return!1}function Vn(r,t){if(r&&r.length>0&&t.processEntities)for(let e=0;e<t.entities.length;e++){const i=t.entities[e];r=r.replace(i.regex,i.val)}return r}const wu={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(r,t){return t},attributeValueProcessor:function(r,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0};function fe(r){if(this.options=Object.assign({},wu,r),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(t=>"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t)),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(let t=0;t<this.options.stopNodes.length;t++){const e=this.options.stopNodes[t];"string"==typeof e?this.stopNodeExpressions.push(new xi(e)):e instanceof xi&&this.stopNodeExpressions.push(e)}!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=function yu(r){return"function"==typeof r?r:Array.isArray(r)?t=>{for(const e of r)if("string"==typeof e&&t===e||e instanceof RegExp&&e.test(t))return!0}:()=>!1}(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=xu),this.processTextOrObjNode=vu,this.options.format?(this.indentate=bu,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function vu(r,t,e,i){const s=this.extractAttributes(r);if(i.push(t,s),this.checkStopNode(i)){const a=this.buildRawContent(r),l=this.buildAttributesForStopNode(r);return i.pop(),this.buildObjectNode(a,t,l,e)}const o=this.j2x(r,e+1,i);return i.pop(),void 0!==r[this.options.textNodeName]&&1===Object.keys(r).length?this.buildTextValNode(r[this.options.textNodeName],t,o.attrStr,e,i):this.buildObjectNode(o.val,t,o.attrStr,e)}function bu(r){return this.options.indentBy.repeat(r)}function xu(r){return!(!r.startsWith(this.options.attributeNamePrefix)||r===this.options.textNodeName)&&r.substr(this.attrPrefixLen)}fe.prototype.build=function(r){if(this.options.preserveOrder)return pu(r,this.options);{Array.isArray(r)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(r={[this.options.arrayNodeName]:r});const t=new kn;return this.j2x(r,0,t).val}},fe.prototype.j2x=function(r,t,e){let i="",s="";if(this.options.maxNestedTags&&e.getDepth()>=this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");const n=this.options.jPath?e.toString():e,o=this.checkStopNode(e);for(let a in r)if(Object.prototype.hasOwnProperty.call(r,a))if(typeof r[a]>"u")this.isAttribute(a)&&(s+="");else if(null===r[a])this.isAttribute(a)||a===this.options.cdataPropName?s+="":s+="?"===a[0]?this.indentate(t)+"<"+a+"?"+this.tagEndChar:this.indentate(t)+"<"+a+"/"+this.tagEndChar;else if(r[a]instanceof Date)s+=this.buildTextValNode(r[a],a,"",t,e);else if("object"!=typeof r[a]){const l=this.isAttribute(a);if(l&&!this.ignoreAttributesFn(l,n))i+=this.buildAttrPairStr(l,""+r[a],o);else if(!l)if(a===this.options.textNodeName){let c=this.options.tagValueProcessor(a,""+r[a]);s+=this.replaceEntitiesValue(c)}else{e.push(a);const c=this.checkStopNode(e);if(e.pop(),c){const h=""+r[a];s+=""===h?this.indentate(t)+"<"+a+this.closeTag(a)+this.tagEndChar:this.indentate(t)+"<"+a+">"+h+"</"+a+this.tagEndChar}else s+=this.buildTextValNode(r[a],a,"",t,e)}}else if(Array.isArray(r[a])){const l=r[a].length;let c="",h="";for(let u=0;u<l;u++){const f=r[a][u];if(!(typeof f>"u"))if(null===f)s+="?"===a[0]?this.indentate(t)+"<"+a+"?"+this.tagEndChar:this.indentate(t)+"<"+a+"/"+this.tagEndChar;else if("object"==typeof f)if(this.options.oneListGroup){e.push(a);const d=this.j2x(f,t+1,e);e.pop(),c+=d.val,this.options.attributesGroupName&&f.hasOwnProperty(this.options.attributesGroupName)&&(h+=d.attrStr)}else c+=this.processTextOrObjNode(f,a,t,e);else if(this.options.oneListGroup){let d=this.options.tagValueProcessor(a,f);d=this.replaceEntitiesValue(d),c+=d}else{e.push(a);const d=this.checkStopNode(e);if(e.pop(),d){const _=""+f;c+=""===_?this.indentate(t)+"<"+a+this.closeTag(a)+this.tagEndChar:this.indentate(t)+"<"+a+">"+_+"</"+a+this.tagEndChar}else c+=this.buildTextValNode(f,a,"",t,e)}}this.options.oneListGroup&&(c=this.buildObjectNode(c,a,h,t)),s+=c}else if(this.options.attributesGroupName&&a===this.options.attributesGroupName){const l=Object.keys(r[a]),c=l.length;for(let h=0;h<c;h++)i+=this.buildAttrPairStr(l[h],""+r[a][l[h]],o)}else s+=this.processTextOrObjNode(r[a],a,t,e);return{attrStr:i,val:s}},fe.prototype.buildAttrPairStr=function(r,t,e){return e||(t=this.options.attributeValueProcessor(r,""+t),t=this.replaceEntitiesValue(t)),this.options.suppressBooleanAttributes&&"true"===t?" "+r:" "+r+'="'+t+'"'},fe.prototype.extractAttributes=function(r){if(!r||"object"!=typeof r)return null;const t={};let e=!1;if(this.options.attributesGroupName&&r[this.options.attributesGroupName]){const i=r[this.options.attributesGroupName];for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s.startsWith(this.options.attributeNamePrefix)?s.substring(this.options.attributeNamePrefix.length):s]=i[s],e=!0)}else for(let i in r){if(!Object.prototype.hasOwnProperty.call(r,i))continue;const s=this.isAttribute(i);s&&(t[s]=r[i],e=!0)}return e?t:null},fe.prototype.buildRawContent=function(r){if("string"==typeof r)return r;if("object"!=typeof r||null===r)return String(r);if(void 0!==r[this.options.textNodeName])return r[this.options.textNodeName];let t="";for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e)||this.isAttribute(e)||this.options.attributesGroupName&&e===this.options.attributesGroupName)continue;const i=r[e];if(e===this.options.textNodeName)t+=i;else if(Array.isArray(i)){for(let s of i)if("string"==typeof s||"number"==typeof s)t+=`<${e}>${s}</${e}>`;else if("object"==typeof s&&null!==s){const n=this.buildRawContent(s),o=this.buildAttributesForStopNode(s);t+=""===n?`<${e}${o}/>`:`<${e}${o}>${n}</${e}>`}}else if("object"==typeof i&&null!==i){const s=this.buildRawContent(i),n=this.buildAttributesForStopNode(i);t+=""===s?`<${e}${n}/>`:`<${e}${n}>${s}</${e}>`}else t+=`<${e}>${i}</${e}>`}return t},fe.prototype.buildAttributesForStopNode=function(r){if(!r||"object"!=typeof r)return"";let t="";if(this.options.attributesGroupName&&r[this.options.attributesGroupName]){const e=r[this.options.attributesGroupName];for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const s=i.startsWith(this.options.attributeNamePrefix)?i.substring(this.options.attributeNamePrefix.length):i,n=e[i];t+=!0===n&&this.options.suppressBooleanAttributes?" "+s:" "+s+'="'+n+'"'}}else for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;const i=this.isAttribute(e);if(i){const s=r[e];t+=!0===s&&this.options.suppressBooleanAttributes?" "+i:" "+i+'="'+s+'"'}}return t},fe.prototype.buildObjectNode=function(r,t,e,i){if(""===r)return"?"===t[0]?this.indentate(i)+"<"+t+e+"?"+this.tagEndChar:this.indentate(i)+"<"+t+e+this.closeTag(t)+this.tagEndChar;{let s="</"+t+this.tagEndChar,n="";return"?"===t[0]&&(n="?",s=""),!e&&""!==e||-1!==r.indexOf("<")?!1!==this.options.commentPropName&&t===this.options.commentPropName&&0===n.length?this.indentate(i)+`\x3c!--${r}--\x3e`+this.newLine:this.indentate(i)+"<"+t+e+n+this.tagEndChar+r+this.indentate(i)+s:this.indentate(i)+"<"+t+e+n+">"+r+s}},fe.prototype.closeTag=function(r){let t="";return-1!==this.options.unpairedTags.indexOf(r)?this.options.suppressUnpairedNode||(t="/"):t=this.options.suppressEmptyNode?"/":`></${r}`,t},fe.prototype.checkStopNode=function(r){if(!this.stopNodeExpressions||0===this.stopNodeExpressions.length)return!1;for(let t=0;t<this.stopNodeExpressions.length;t++)if(r.matches(this.stopNodeExpressions[t]))return!0;return!1},fe.prototype.buildTextValNode=function(r,t,e,i,s){if(!1!==this.options.cdataPropName&&t===this.options.cdataPropName){const n=String(r).replace(/\]\]>/g,"]]]]><![CDATA[>");return this.indentate(i)+`<![CDATA[${n}]]>`+this.newLine}if(!1!==this.options.commentPropName&&t===this.options.commentPropName){const n=String(r).replace(/--/g,"- -").replace(/-$/,"- ");return this.indentate(i)+`\x3c!--${n}--\x3e`+this.newLine}if("?"===t[0])return this.indentate(i)+"<"+t+e+"?"+this.tagEndChar;{let n=this.options.tagValueProcessor(t,r);return n=this.replaceEntitiesValue(n),""===n?this.indentate(i)+"<"+t+e+this.closeTag(t)+this.tagEndChar:this.indentate(i)+"<"+t+e+">"+n+"</"+t+this.tagEndChar}},fe.prototype.replaceEntitiesValue=function(r){if(r&&r.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){const e=this.options.entities[t];r=r.replace(e.regex,e.val)}return r};class Ts{}y(Ts,"parser",new Fn({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0})),y(Ts,"builder",new fe({attributeNamePrefix:"$",ignoreAttributes:!1,suppressBooleanAttributes:!1}));class Rt{static join(t){const e={};for(const i of t)for(const s in i)if(e[s])for(const n of i[s])e[s].add(n);else e[s]=new Set(i[s]);return e}static intersect(t){if(0===t.length)return{};let e=Rt.clone(t[0]);for(let i=1;i<t.length;i++){const s=t[i],n={};for(const o in e)if(s[o]){const a=new Set;for(const l of e[o])s[o].has(l)&&a.add(l);a.size>0&&(n[o]=a)}e=n}return e}static clone(t){const e={};for(const i in t)e[i]=new Set(t[i]);return e}static remove(t,e,i=!1){i&&(t=Rt.clone(t));for(const s in e)if(t[s]){for(const n of e[s])t[s].delete(n);0===t[s].size&&delete t[s]}}static add(t,e,i=!1){i&&(t=Rt.clone(t));for(const s in e)if(t[s])for(const n of e[s])t[s].add(n);else t[s]=new Set(e[s])}static append(t,e,...i){let s=t[e];s||(s=new Set,t[e]=s);for(const n of i)s.add(n)}static isEqual(t,e){const i=Object.keys(t),s=Object.keys(e);if(i.length!==s.length)return!1;for(const n of i){if(!e[n]||t[n].size!==e[n].size)return!1;for(const o of t[n])if(!e[n].has(o))return!1}return!0}static isEmpty(t){return 0===Object.values(t).reduce((i,s)=>i+s.size,0)}static toRaw(t){const e={};for(const i in t)e[i]=Array.from(t[i]);return e}static fromRaw(t){const e={};for(const i in t)e[i]=new Set(t[i]);return e}}Map;class Un{static isEntry(t){return new Set(["Boolean","Color","Text","Number","Select","Vector3","TextSet","None"]).has(t.type)}static copySchema(t,e={}){for(const i in t){const s=t[i];this.isEntry(s)?e[i]=this.copyEntry(s):(e[i]={},this.copySchema(s,e[i]))}return e}static copyEntry(t){if("Boolean"===t.type)return{type:t.type,value:t.value};if("Color"===t.type)return{type:t.type,value:t.value.clone()};if("Text"===t.type)return{type:t.type,value:t.value};if("Number"===t.type)return{type:t.type,value:t.value,min:t.min,max:t.max,interpolable:t.interpolable};if("Select"===t.type)return{type:t.type,value:t.value,multiple:t.multiple,options:new Set(t.options)};if("Vector3"===t.type)return{type:t.type,value:t.value.clone()};if("TextSet"===t.type)return{type:t.type,value:new Set(t.value)};if("None"===t.type)return{type:t.type,value:t.value};throw new Error("Invalid entry!")}}class Wi{constructor(t,e,i,s){y(this,"_component"),y(this,"name"),y(this,"uuid"),this._component=t,this.name=i,this.uuid=s??ie.create(),e.get(Ps).list.set(this.uuid,this)}get controls(){return Un.copySchema(this._config)}set(t){for(const e in t)e in this&&(this[e]=t[e].value)}export(t=this._config,e={}){for(const i in t){const s=t[i];if(Un.isEntry(s))if("Color"===s.type){const{r:o,g:a,b:l}=s.value;e[i]={...s,value:{r:o,g:a,b:l}}}else if("Vector3"===s.type){const{x:o,y:a,z:l}=s.value;e[i]={...s,value:{x:o,y:a,z:l}}}else if("TextSet"===s.type){const o=Array.from(s.value);e[i]={...s,value:o}}else if("Select"===s.type){const o=Array.from(s.options);e[i]={...s,options:o}}else e[i]={...s};else e[i]={},this.export(s,e[i])}return e}import(t,e={},i=!0){for(const s in t){const n=t[s];if(Un.isEntry(n))if("Color"===n.type){const{r:a,g:l,b:c}=n.value;e[s]={...n,value:new p.Q1f(a,l,c)}}else if("Vector3"===n.type){const{x:a,y:l,z:c}=n.value;e[s]={...n,value:new p.Pq0(a,l,c)}}else e[s]="TextSet"===n.type?{...n,value:new Set(n.value)}:"Select"===n.type?{...n,options:new Set(n.options)}:{...n};else e[s]={},this.import(n,e[s],!1)}i&&this.set(e)}}const Go=class Bc extends At{constructor(t){super(t),y(this,"list",new ot.jp),y(this,"enabled",!0),t.add(Bc.uuid,this)}};y(Go,"uuid","b8c764e0-6b24-4e77-9a32-35fa728ee5b4");let Ps=Go;class Yo{constructor(t){y(this,"_event"),y(this,"_position",new p.I9Y),y(this,"onDisposed",new Q),y(this,"updateMouseInfo",e=>{this._event=e}),this.dom=t,this.setupEvents(!0)}get position(){return this.updatePosition(!1),this._position.clone()}get rawPosition(){return this.updatePosition(!0),this._position.clone()}dispose(){this.setupEvents(!1),this.onDisposed.trigger(),this.onDisposed.reset()}updatePosition(t){if(this._event){const e=this.dom.getBoundingClientRect();this._position.x=this.getPositionX(e,this._event,t),this._position.y=this.getPositionY(e,this._event,t)}}getPositionY(t,e,i){const s=this.getDataObject(e);return i?s.clientY:-(s.clientY-t.top)/(t.bottom-t.top)*2+1}getPositionX(t,e,i){const s=this.getDataObject(e);return i?s.clientX:(s.clientX-t.left)/(t.right-t.left)*2-1}getDataObject(t){return t instanceof MouseEvent?t:t.touches[0]}setupEvents(t){t?(this.dom.addEventListener("pointermove",this.updateMouseInfo),this.dom.addEventListener("touchstart",this.updateMouseInfo)):(this.dom.removeEventListener("pointermove",this.updateMouseInfo),this.dom.removeEventListener("touchstart",this.updateMouseInfo))}}const Ss=Math.pow(2,-24),Hn=Symbol("SKIP_GENERATION"),Qo={strategy:0,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Hn]:!1};function Lt(r,t,e){return e.min.x=t[r],e.min.y=t[r+1],e.min.z=t[r+2],e.max.x=t[r+3],e.max.y=t[r+4],e.max.z=t[r+5],e}function Jo(r){let t=-1,e=-1/0;for(let i=0;i<3;i++){const s=r[i+3]-r[i];s>e&&(e=s,t=i)}return t}function ta(r,t){t.set(r)}function ea(r,t,e){let i,s;for(let n=0;n<3;n++){const o=n+3;i=r[n],s=t[n],e[n]=i<s?i:s,i=r[o],s=t[o],e[o]=i>s?i:s}}function Es(r,t,e){for(let i=0;i<3;i++){const s=t[r+2*i],n=t[r+2*i+1],o=s-n,a=s+n;o<e[i]&&(e[i]=o),a>e[i+3]&&(e[i+3]=a)}}function Xi(r){const t=r[3]-r[0],e=r[4]-r[1],i=r[5]-r[2];return 2*(t*e+e*i+i*t)}function Ut(r,t){return 65535===t[r+15]}function Xt(r,t){return t[r+6]}function Qt(r,t){return t[r+14]}function jt(r){return r+8}function Ht(r,t){return r+8*t[r+6]}function qn(r,t){return t[r+7]}function Gn(r,t,e,i,s){let n=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,h=-1/0,u=1/0,f=1/0,d=1/0,_=-1/0,m=-1/0,w=-1/0;const g=r.offset||0;for(let v=6*(t-g),T=6*(t+e-g);v<T;v+=6){const C=r[v+0],S=r[v+1],M=C-S,A=C+S;M<n&&(n=M),A>l&&(l=A),C<u&&(u=C),C>_&&(_=C);const O=r[v+2],I=r[v+3],D=O-I,B=O+I;D<o&&(o=D),B>c&&(c=B),O<f&&(f=O),O>m&&(m=O);const E=r[v+4],L=r[v+5],x=E-L,N=E+L;x<a&&(a=x),N>h&&(h=N),E<d&&(d=E),E>w&&(w=E)}i[0]=n,i[1]=o,i[2]=a,i[3]=l,i[4]=c,i[5]=h,s[0]=u,s[1]=f,s[2]=d,s[3]=_,s[4]=m,s[5]=w}const Su=(r,t)=>r.candidate-t.candidate,Ye=new Array(32).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),As=new Float32Array(6);class Yn{constructor(){this.boundingData=new Float32Array(6)}}let ia,Ms,Zn,sa;const Iu=Math.pow(2,32);function Wn(r){return"count"in r?1:1+Wn(r.left)+Wn(r.right)}function Ou(r,t,e){return ia=new Float32Array(e),Ms=new Uint32Array(e),Zn=new Uint16Array(e),sa=new Uint8Array(e),Xn(r,t)}function Xn(r,t){const e=r/4,i=r/2,s="count"in t,n=t.boundingData;for(let o=0;o<6;o++)ia[e+o]=n[o];if(s)return t.buffer?(sa.set(new Uint8Array(t.buffer),r),r+t.buffer.byteLength):(Ms[e+6]=t.offset,Zn[i+14]=t.count,Zn[i+15]=65535,r+32);{const{left:o,right:a,splitAxis:l}=t;let h=Xn(r+32,o);const d=h/32-r/32;if(d>Iu)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Ms[e+6]=d,Ms[e+7]=l,Xn(h,a)}}function Du(r,t){const e=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=r.getRootRanges(t.range),s=i[0],n=i[i.length-1],o={offset:s.offset,count:n.offset+n.count-s.offset},a=new Float32Array(6*o.count);a.offset=o.offset,r.computePrimitiveBounds(o.offset,o.count,a),r._roots=i.map(l=>{const c=function zu(r,t,e,i,s,n){const{maxDepth:o,verbose:a,maxLeafSize:l,strategy:c,onProgress:h}=s,u=r.primitiveBuffer,f=r.primitiveBufferStride,d=new Float32Array(6);let _=!1;const m=new Yn;return Gn(t,e,i,m.boundingData,d),function g(v,T,C,S=null,M=0){if(!_&&M>=o&&(_=!0,a&&console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`)),C<=l||M>=o)return w(T+C),v.offset=T,v.count=C,v;const A=function Eu(r,t,e,i,s,n){let o=-1,a=0;if(0===n)o=Jo(t),-1!==o&&(a=(t[o]+t[o+3])/2);else if(1===n)o=Jo(r),-1!==o&&(a=function Au(r,t,e,i){let s=0;const n=r.offset;for(let o=t,a=t+e;o<a;o++)s+=r[6*(o-n)+2*i];return s/e}(e,i,s,o));else if(2===n){const l=Xi(r);let c=1.25*s;const h=e.offset||0,u=6*(i-h),f=6*(i+s-h);for(let d=0;d<3;d++){const _=t[d],g=(t[d+3]-_)/32;if(s<8){const v=[...Ye];v.length=s;let T=0;for(let S=u;S<f;S+=6,T++){const M=v[T];M.candidate=e[S+2*d],M.count=0;const{bounds:A,leftCacheBounds:O,rightCacheBounds:I}=M;for(let D=0;D<3;D++)I[D]=1/0,I[D+3]=-1/0,O[D]=1/0,O[D+3]=-1/0,A[D]=1/0,A[D+3]=-1/0;Es(S,e,A)}v.sort(Su);let C=s;for(let S=0;S<C;S++){const M=v[S];for(;S+1<C&&v[S+1].candidate===M.candidate;)v.splice(S+1,1),C--}for(let S=u;S<f;S+=6){const M=e[S+2*d];for(let A=0;A<C;A++){const O=v[A];M>=O.candidate?Es(S,e,O.rightCacheBounds):(Es(S,e,O.leftCacheBounds),O.count++)}}for(let S=0;S<C;S++){const M=v[S],A=M.count,O=s-M.count,D=M.rightCacheBounds;let B=0;0!==A&&(B=Xi(M.leftCacheBounds)/l);let E=0;0!==O&&(E=Xi(D)/l);const L=1+1.25*(B*A+E*O);L<c&&(o=d,c=L,a=M.candidate)}}else{for(let C=0;C<32;C++){const S=Ye[C];S.count=0,S.candidate=_+g+C*g;const M=S.bounds;for(let A=0;A<3;A++)M[A]=1/0,M[A+3]=-1/0}for(let C=u;C<f;C+=6){let A=~~((e[C+2*d]-_)/g);A>=32&&(A=31);const O=Ye[A];O.count++,Es(C,e,O.bounds)}const v=Ye[31];ta(v.bounds,v.rightCacheBounds);for(let C=30;C>=0;C--){const S=Ye[C];ea(S.bounds,Ye[C+1].rightCacheBounds,S.rightCacheBounds)}let T=0;for(let C=0;C<31;C++){const S=Ye[C],M=S.count,A=S.bounds,I=Ye[C+1].rightCacheBounds;0!==M&&(0===T?ta(A,As):ea(A,As,As)),T+=M;let D=0,B=0;0!==T&&(D=Xi(As)/l);const E=s-T;0!==E&&(B=Xi(I)/l);const L=1+1.25*(D*T+B*E);L<c&&(o=d,c=L,a=S.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${n} used.`);return{axis:o,pos:a}}(v.boundingData,S,t,T,C,c);if(-1===A.axis)return w(T+C),v.offset=T,v.count=C,v;const O=function Mu(r,t,e,i,s,n){let o=i,a=i+s-1;const l=n.pos,c=2*n.axis,h=e.offset||0;for(;;){for(;o<=a&&e[6*(o-h)+c]<l;)o++;for(;o<=a&&e[6*(a-h)+c]>=l;)a--;if(!(o<a))return o;for(let u=0;u<t;u++){let f=r[o*t+u];r[o*t+u]=r[a*t+u],r[a*t+u]=f}for(let u=0;u<6;u++){const f=o-h,d=a-h,_=e[6*f+u];e[6*f+u]=e[6*d+u],e[6*d+u]=_}o++,a--}}(u,f,t,T,C,A);if(O===T||O===T+C)w(T+C),v.offset=T,v.count=C;else{v.splitAxis=A.axis;const I=new Yn,D=T,B=O-T;v.left=I,Gn(t,D,B,I.boundingData,d),g(I,D,B,d,M+1);const E=new Yn,L=O,x=C-B;v.right=E,Gn(t,L,x,E.boundingData,d),g(E,L,x,d,M+1)}return v}(m,e,i,d),m;function w(v){h&&h((v-n.offset)/n.count)}}(r,a,l.offset,l.count,t,o),h=Wn(c),u=new e(32*h);return Ou(0,c,u),u})}class Is{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){const t=this._primitives;return 0===t.length?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}}class ku{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=i=>{e&&t.push(e),e=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==t.length&&this.setBuffer(t.pop())}}}const Dt=new ku;let Ze,Ti;const Pi=[],Os=new Is(()=>new p.NRn);function Lu(r,t,e,i,s,n){Ze=Os.getPrimitive(),Ti=Os.getPrimitive(),Pi.push(Ze,Ti),Dt.setBuffer(r._roots[t]);const o=Kn(0,r.geometry,e,i,s,n);Dt.clearBuffer(),Os.releasePrimitive(Ze),Os.releasePrimitive(Ti),Pi.pop(),Pi.pop();const a=Pi.length;return a>0&&(Ti=Pi[a-1],Ze=Pi[a-2]),o}function Kn(r,t,e,i,s=null,n=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:c}=Dt;let h=2*r;if(Ut(h,l)){const f=Xt(r,c),d=Qt(h,l);return Lt(r,a,Ze),i(f,d,!1,o,n+r/8,Ze)}{let f=function(E){const{uint16Array:L,uint32Array:x}=Dt;let N=2*E;for(;!Ut(N,L);)N=2*(E=jt(E));return Xt(E,x)},d=function(E){const{uint16Array:L,uint32Array:x}=Dt;let N=2*E;for(;!Ut(N,L);)N=2*(E=Ht(E,x));return Xt(E,x)+Qt(N,L)};const _=jt(r),m=Ht(r,c);let v,T,C,S,w=_,g=m;if(s&&(C=Ze,S=Ti,Lt(w,a,C),Lt(g,a,S),v=s(C),T=s(S),T<v)){w=m,g=_;const E=v;v=T,T=E,C=S}C||(C=Ze,Lt(w,a,C));const A=e(C,Ut(2*w,l),v,o+1,n+w/8);let O;if(2===A){const E=f(w);O=i(E,d(w)-E,!0,o+1,n+w/8,C)}else O=A&&Kn(w,t,e,i,s,n,o+1);if(O)return!0;S=Ti,Lt(g,a,S);const D=e(S,Ut(2*g,l),T,o+1,n+g/8);let B;if(2===D){const E=f(g);B=i(E,d(g)-E,!0,o+1,n+g/8,S)}else B=D&&Kn(g,t,e,i,s,n,o+1);return!!B}}const Ki=new Dt.constructor,zs=new Dt.constructor,We=new Is(()=>new p.NRn),Si=new p.NRn,Ei=new p.NRn,Qn=new p.NRn,Jn=new p.NRn;let tr=!1;function ve(r,t,e,i,s,n=0,o=0,a=0,l=0,c=null,h=!1){let u,f;h?(u=zs,f=Ki):(u=Ki,f=zs);const d=u.float32Array,_=u.uint32Array,m=u.uint16Array,w=f.float32Array,g=f.uint32Array,v=f.uint16Array,C=2*t,S=Ut(2*r,m),M=Ut(C,v);let A=!1;if(M&&S)A=h?s(Xt(t,g),Qt(2*t,v),Xt(r,_),Qt(2*r,m),l,o+t/8,a,n+r/8):s(Xt(r,_),Qt(2*r,m),Xt(t,g),Qt(2*t,v),a,n+r/8,l,o+t/8);else if(M){const O=We.getPrimitive();Lt(t,w,O),O.applyMatrix4(e);const I=jt(r),D=Ht(r,_);Lt(I,d,Si),Lt(D,d,Ei);const B=O.intersectsBox(Si),E=O.intersectsBox(Ei);A=B&&ve(t,I,i,e,s,o,n,l,a+1,O,!h)||E&&ve(t,D,i,e,s,o,n,l,a+1,O,!h),We.releasePrimitive(O)}else{const O=jt(t),I=Ht(t,g);Lt(O,w,Qn),Lt(I,w,Jn);const D=c.intersectsBox(Qn),B=c.intersectsBox(Jn);if(D&&B)A=ve(r,O,e,i,s,n,o,a,l+1,c,h)||ve(r,I,e,i,s,n,o,a,l+1,c,h);else if(D)if(S)A=ve(r,O,e,i,s,n,o,a,l+1,c,h);else{const E=We.getPrimitive();E.copy(Qn).applyMatrix4(e);const L=jt(r),x=Ht(r,_);Lt(L,d,Si),Lt(x,d,Ei);const N=E.intersectsBox(Si),Y=E.intersectsBox(Ei);A=N&&ve(O,L,i,e,s,o,n,l,a+1,E,!h)||Y&&ve(O,x,i,e,s,o,n,l,a+1,E,!h),We.releasePrimitive(E)}else if(B)if(S)A=ve(r,I,e,i,s,n,o,a,l+1,c,h);else{const E=We.getPrimitive();E.copy(Jn).applyMatrix4(e);const L=jt(r),x=Ht(r,_);Lt(L,d,Si),Lt(x,d,Ei);const N=E.intersectsBox(Si),Y=E.intersectsBox(Ei);A=N&&ve(I,L,i,e,s,o,n,l,a+1,E,!h)||Y&&ve(I,x,i,e,s,o,n,l,a+1,E,!h),We.releasePrimitive(E)}}return A}const na=new p.NRn,Ai=new Float32Array(6);class ra{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(t){Du(this,t={...Qo,...t})}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(t,e,i,s){let n=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,h=-1/0;for(let u=t,f=t+e;u<f;u++){this.writePrimitiveBounds(u,Ai,0);const[d,_,m,w,g,v]=Ai;d<n&&(n=d),w>l&&(l=w),_<o&&(o=_),g>c&&(c=g),m<a&&(a=m),v>h&&(h=v)}return i[s+0]=n,i[s+1]=o,i[s+2]=a,i[s+3]=l,i[s+4]=c,i[s+5]=h,i}computePrimitiveBounds(t,e,i){const s=i.offset||0;for(let n=t,o=t+e;n<o;n++){this.writePrimitiveBounds(n,Ai,0);const[a,l,c,h,u,f]=Ai,d=(a+h)/2,_=(l+u)/2,m=(c+f)/2,w=(h-a)/2,g=(u-l)/2,v=(f-c)/2,T=6*(n-s);i[T+0]=d,i[T+1]=w+(Math.abs(d)+w)*Ss,i[T+2]=_,i[T+3]=g+(Math.abs(_)+g)*Ss,i[T+4]=m,i[T+5]=v+(Math.abs(m)+v)*Ss}return i}shiftPrimitiveOffsets(t){const e=this._indirectBuffer;if(e)for(let i=0,s=e.length;i<s;i++)e[i]+=t;else{const i=this._roots;for(let s=0;s<i.length;s++){const n=i[s],o=new Uint32Array(n),a=new Uint16Array(n),l=n.byteLength/32;for(let c=0;c<l;c++){const h=8*c;Ut(2*h,a)&&(o[h+6]+=t)}}}}traverse(t,e=0){const i=this._roots[e],s=new Uint32Array(i),n=new Uint16Array(i);!function o(a,l=0){const c=2*a,h=Ut(c,n);if(h){const u=s[a+6],f=n[c+14];t(l,h,new Float32Array(i,4*a,6),u,f)}else{const u=jt(a),f=Ht(a,s),d=qn(a,s);t(l,h,new Float32Array(i,4*a,6),d)||(o(u,l+1),o(f,l+1))}}(0)}refit(){const t=this._roots;for(let e=0,i=t.length;e<i;e++){const s=t[e],n=new Uint32Array(s),o=new Uint16Array(s),a=new Float32Array(s);for(let c=s.byteLength/32-1;c>=0;c--){const h=8*c,u=2*h;if(Ut(u,o)){const d=Xt(h,n),_=Qt(u,o);this.writePrimitiveRangeBounds(d,_,Ai,0),a.set(Ai,h)}else{const d=jt(h),_=Ht(h,n);for(let m=0;m<3;m++){const w=a[d+m],g=a[d+m+3],v=a[_+m],T=a[_+m+3];a[h+m]=w<v?w:v,a[h+m+3]=g>T?g:T}}}}}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(i=>{Lt(0,new Float32Array(i),na),t.union(na)}),t}shapecast(t){let{boundsTraverseOrder:e,intersectsBounds:i,intersectsRange:s,intersectsPrimitive:n,scratchPrimitive:o,iterate:a}=t;if(s&&n){const u=s;s=(f,d,_,m,w)=>!!u(f,d,_,m,w)||a(f,d,this,n,_,m,o)}else s||(s=n?(u,f,d,_)=>a(u,f,this,n,d,_,o):(u,f,d)=>d);let l=!1,c=0;const h=this._roots;for(let u=0,f=h.length;u<f;u++){const d=h[u];if(l=Lu(this,u,i,s,e,c),l)break;c+=d.byteLength/32}return l}bvhcast(t,e,i){let{intersectsRanges:s}=i;return function Nu(r,t,e,i){if(tr)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");tr=!0;const s=r._roots,n=t._roots;let o,a=0,l=0;const c=(new p.kn4).copy(e).invert();for(let h=0,u=s.length;h<u;h++){Ki.setBuffer(s[h]),l=0;const f=We.getPrimitive();Lt(0,Ki.float32Array,f),f.applyMatrix4(c);for(let d=0,_=n.length;d<_&&(zs.setBuffer(n[d]),o=ve(0,0,e,c,i,a,l,0,0,f),zs.clearBuffer(),l+=n[d].byteLength/32,!o);d++);if(We.releasePrimitive(f),Ki.clearBuffer(),a+=s[h].byteLength/32,o)break}return tr=!1,o}(this,t,e,s)}}function er(r){return r.index?r.index.count:r.attributes.position.count}function Ds(r){return er(r)/3}function oa(r,t,e){const i=function Vu(r,t,e){const i=er(r)/e,s=t||r.drawRange,o=(s.start+s.count)/e,a=Math.max(0,s.start/e),l=Math.min(i,o)-a;return{offset:Math.floor(a),count:Math.floor(l)}}(r,t,e),s=function Uu(r,t){return r.groups.map(e=>({offset:e.start/t,count:e.count/t}))}(r,e);if(!s.length)return[i];const n=[],o=i.offset,a=i.offset+i.count,l=er(r)/e,c=[];for(const f of s){const{offset:d,count:_}=f,m=d,g=d+(isFinite(_)?_:l-d);m<a&&g>o&&(c.push({pos:Math.max(o,m),isStart:!0}),c.push({pos:Math.min(a,g),isStart:!1}))}c.sort((f,d)=>f.pos!==d.pos?f.pos-d.pos:"end"===f.type?-1:1);let h=0,u=null;for(const f of c){const d=f.pos;0!==h&&d!==u&&n.push({offset:u,count:d-u}),h+=f.isStart?1:-1,u=d}return n}class aa extends ra{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(t){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(t){}constructor(t,e={}){if(!t.isBufferGeometry)throw new Error("BVH: Only BufferGeometries are supported.");if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.");if(e.useSharedArrayBuffer&&!function Bu(){return typeof SharedArrayBuffer<"u"}())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=t,this.resolvePrimitiveIndex=e.indirect?i=>this._indirectBuffer[i]:i=>i,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,(e={...Qo,...e})[Hn]||this.init(e)}init(t){const{geometry:e,primitiveStride:i}=this;if(t.indirect){const n=function $u(r,t){const e=r[r.length-1],i=e.offset+e.count>65536,s=r.reduce((c,h)=>c+h.count,0),n=i?4:2,o=t?new SharedArrayBuffer(s*n):new ArrayBuffer(s*n),a=i?new Uint32Array(o):new Uint16Array(o);let l=0;for(let c=0;c<r.length;c++){const{offset:h,count:u}=r[c];for(let f=0;f<u;f++)a[l+f]=h+f;l+=u}return a}(oa(e,t.range,i),t.useSharedArrayBuffer);this._indirectBuffer=n}else!function Fu(r,t){if(!r.index){const e=r.attributes.position.count,s=function Ru(r,t=ArrayBuffer){return r>65535?new Uint32Array(new t(4*r)):new Uint16Array(new t(2*r))}(e,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);r.setIndex(new p.THS(s,1));for(let n=0;n<e;n++)s[n]=n}}(e,t);super.init(t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new p.NRn))}getRootRanges(t){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:oa(this.geometry,t,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class ke{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let i=1/0,s=-1/0;for(let n=0,o=t.length;n<o;n++){const l=t[n][e];i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}setFromPoints(t,e){let i=1/0,s=-1/0;for(let n=0,o=e.length;n<o;n++){const l=t.dot(e[n]);i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}isSeparated(t){return this.min>t.max||t.min>this.max}}ke.prototype.setFromBox=function(){const r=new p.Pq0;return function(e,i){const s=i.min,n=i.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){r.x=s.x*l+n.x*(1-l),r.y=s.y*c+n.y*(1-c),r.z=s.z*h+n.z*(1-h);const u=e.dot(r);o=Math.min(u,o),a=Math.max(u,a)}this.min=o,this.max=a}}();const ju=function(){const r=new p.Pq0,t=new p.Pq0,e=new p.Pq0;return function(s,n,o){const l=r,h=t;e.subVectors(s.start,n.start),r.subVectors(s.end,s.start),t.subVectors(n.end,n.start);const u=e.dot(h),f=h.dot(l),d=h.dot(h),_=e.dot(l),w=l.dot(l)*d-f*f;let g,v;g=0!==w?(u*f-_*d)/w:0,v=(u+g*f)/d,o.x=g,o.y=v}}(),ir=function(){const r=new p.I9Y,t=new p.Pq0,e=new p.Pq0;return function(s,n,o,a){ju(s,n,r);let l=r.x,c=r.y;if(l>=0&&l<=1&&c>=0&&c<=1)return s.at(l,o),void n.at(c,a);if(l>=0&&l<=1)return n.at(c<0?0:1,a),void s.closestPointToPoint(a,!0,o);if(c>=0&&c<=1)return s.at(l<0?0:1,o),void n.closestPointToPoint(o,!0,a);{let h,u;h=l<0?s.start:s.end,u=c<0?n.start:n.end;const f=t,d=e;return s.closestPointToPoint(u,!0,t),n.closestPointToPoint(h,!0,e),f.distanceToSquared(u)<=d.distanceToSquared(h)?(o.copy(f),void a.copy(u)):(o.copy(h),void a.copy(d))}}}(),Hu=function(){const r=new p.Pq0,t=new p.Pq0,e=new p.Zcv,i=new p.cZY;return function(n,o){const{radius:a,center:l}=n,{a:c,b:h,c:u}=o;if(i.start=c,i.end=h,i.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(i.start=c,i.end=u,i.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(i.start=h,i.end=u,i.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;const m=o.getPlane(e);if(Math.abs(m.distanceToPoint(l))<=a){const g=m.projectPoint(l,t);if(o.containsPoint(g))return!0}return!1}}(),qu=["x","y","z"],Le=1e-15;function pe(r){return Math.abs(r)<Le}class le extends p.lMl{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new p.Pq0),this.satBounds=new Array(4).fill().map(()=>new ke),this.points=[this.a,this.b,this.c],this.plane=new p.Zcv,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new p.cZY,this.needsUpdate=!0}intersectsSphere(t){return Hu(t,this)}update(){const t=this.a,e=this.b,i=this.c,s=this.points,n=this.satAxes,o=this.satBounds,a=n[0],l=o[0];this.getNormal(a),l.setFromPoints(a,s);const c=n[1],h=o[1];c.subVectors(t,e),h.setFromPoints(c,s);const u=n[2],f=o[2];u.subVectors(e,i),f.setFromPoints(u,s);const d=n[3],_=o[3];d.subVectors(i,t),_.setFromPoints(d,s);const m=c.length(),w=u.length(),g=d.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,m<Le?w<Le||g<Le?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(i)):w<Le?g<Le?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(t)):g<Le&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(i),this.degenerateSegment.end.copy(e)),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}}le.prototype.closestPointToSegment=function(){const r=new p.Pq0,t=new p.Pq0,e=new p.cZY;return function(s,n=null,o=null){const{start:a,end:l}=s,c=this.points;let h,u=1/0;for(let f=0;f<3;f++){const d=(f+1)%3;e.start.copy(c[f]),e.end.copy(c[d]),ir(e,s,r,t),h=r.distanceToSquared(t),h<u&&(u=h,n&&n.copy(r),o&&o.copy(t))}return this.closestPointToPoint(a,r),h=a.distanceToSquared(r),h<u&&(u=h,n&&n.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),h=l.distanceToSquared(r),h<u&&(u=h,n&&n.copy(r),o&&o.copy(l)),Math.sqrt(u)}}(),le.prototype.intersectsTriangle=function(){const r=new le,t=new ke,e=new ke,i=new p.Pq0,s=new p.Pq0,n=new p.Pq0,o=new p.Pq0,a=new p.cZY,l=new p.cZY,c=new p.Pq0,h=new p.I9Y,u=new p.I9Y;function f(T,C,S,M){const A=i;A.copy(T.isDegenerateIntoPoint||T.isDegenerateIntoSegment?C.plane.normal:T.plane.normal);const O=T.satBounds,I=T.satAxes;for(let E=1;E<4;E++){const L=O[E],x=I[E];if(t.setFromPoints(x,C.points),L.isSeparated(t)||(o.copy(A).cross(x),t.setFromPoints(o,T.points),e.setFromPoints(o,C.points),t.isSeparated(e)))return!1}const D=C.satBounds,B=C.satAxes;for(let E=1;E<4;E++){const L=D[E],x=B[E];if(t.setFromPoints(x,T.points),L.isSeparated(t)||(o.crossVectors(A,x),t.setFromPoints(o,T.points),e.setFromPoints(o,C.points),t.isSeparated(e)))return!1}return S&&(M||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),S.start.set(0,0,0),S.end.set(0,0,0)),!0}function d(T,C,S,M,A,O,I,D,B,E,L){let x=I/(I-D);E.x=M+(A-M)*x,L.start.subVectors(C,T).multiplyScalar(x).add(T),x=I/(I-B),E.y=M+(O-M)*x,L.end.subVectors(S,T).multiplyScalar(x).add(T)}function _(T,C,S,M,A,O,I,D,B,E,L){if(A>0)d(T.c,T.a,T.b,M,C,S,B,I,D,E,L);else if(O>0)d(T.b,T.a,T.c,S,C,M,D,I,B,E,L);else if(D*B>0||0!=I)d(T.a,T.b,T.c,C,S,M,I,D,B,E,L);else if(0!=D)d(T.b,T.a,T.c,S,C,M,D,I,B,E,L);else{if(0==B)return!0;d(T.c,T.a,T.b,M,C,S,B,I,D,E,L)}return!1}function m(T,C,S,M){const A=C.degenerateSegment,O=T.plane.distanceToPoint(A.start),I=T.plane.distanceToPoint(A.end);return pe(O)?pe(I)?f(T,C,S,M):(S&&(S.start.copy(A.start),S.end.copy(A.start)),T.containsPoint(A.start)):pe(I)?(S&&(S.start.copy(A.end),S.end.copy(A.end)),T.containsPoint(A.end)):null!=T.plane.intersectLine(A,i)&&(S&&(S.start.copy(i),S.end.copy(i)),T.containsPoint(i))}function w(T,C,S){const M=C.a;return!(!pe(T.plane.distanceToPoint(M))||!T.containsPoint(M)||(S&&(S.start.copy(M),S.end.copy(M)),0))}function g(T,C,S){const A=C.a;return T.degenerateSegment.closestPointToPoint(A,!0,i),A.distanceToSquared(i)<1e-30&&(S&&(S.start.copy(A),S.end.copy(A)),!0)}return function(C,S=null,M=!1){this.needsUpdate&&this.update(),C.isExtendedTriangle?C.needsUpdate&&C.update():(r.copy(C),r.update(),C=r);const A=function v(T,C,S,M){if(T.isDegenerateIntoSegment){if(C.isDegenerateIntoSegment){const A=T.degenerateSegment,O=C.degenerateSegment,I=s,D=n;A.delta(I),O.delta(D);const B=i.subVectors(O.start,A.start),E=I.x*D.y-I.y*D.x;if(pe(E))return!1;const L=(B.x*D.y-B.y*D.x)/E,x=-(I.x*B.y-I.y*B.x)/E;return!(L<0||L>1||x<0||x>1||!pe(A.start.z+I.z*L-(O.start.z+D.z*x))||(S&&(S.start.copy(A.start).addScaledVector(I,L),S.end.copy(A.start).addScaledVector(I,L)),0))}return C.isDegenerateIntoPoint?g(T,C,S):m(C,T,S,M)}return T.isDegenerateIntoPoint?C.isDegenerateIntoPoint?C.a.distanceToSquared(T.a)<1e-30&&(S&&(S.start.copy(T.a),S.end.copy(T.a)),!0):C.isDegenerateIntoSegment?g(C,T,S):w(C,T,S):C.isDegenerateIntoPoint?w(T,C,S):C.isDegenerateIntoSegment?m(T,C,S,M):void 0}(this,C,S,M);if(void 0!==A)return A;const O=this.plane,I=C.plane;let D=I.distanceToPoint(this.a),B=I.distanceToPoint(this.b),E=I.distanceToPoint(this.c);pe(D)&&(D=0),pe(B)&&(B=0),pe(E)&&(E=0);const L=D*B,x=D*E;if(L>0&&x>0)return!1;let N=O.distanceToPoint(C.a),Y=O.distanceToPoint(C.b),q=O.distanceToPoint(C.c);pe(N)&&(N=0),pe(Y)&&(Y=0),pe(q)&&(q=0);const ct=N*Y,Z=N*q;if(ct>0&&Z>0)return!1;s.copy(O.normal),n.copy(I.normal);const at=s.cross(n);let F=0,V=Math.abs(at.x);const nt=Math.abs(at.y);nt>V&&(V=nt,F=1),Math.abs(at.z)>V&&(F=2);const J=qu[F],rt=C.a[J],ht=C.b[J],pt=C.c[J];if(_(this,this.a[J],this.b[J],this.c[J],L,x,D,B,E,h,a))return f(this,C,S,M);if(_(C,rt,ht,pt,ct,Z,N,Y,q,u,l))return f(this,C,S,M);if(h.y<h.x){const xt=h.y;h.y=h.x,h.x=xt,c.copy(a.start),a.start.copy(a.end),a.end.copy(c)}if(u.y<u.x){const xt=u.y;u.y=u.x,u.x=xt,c.copy(l.start),l.start.copy(l.end),l.end.copy(c)}return!(h.y<u.x||u.y<h.x||(S&&(S.start.copy(u.x>h.x?l.start:a.start),S.end.copy(u.y<h.y?l.end:a.end)),0))}}(),le.prototype.distanceToPoint=function(){const r=new p.Pq0;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),le.prototype.distanceToTriangle=function(){const r=new p.Pq0,t=new p.Pq0,e=["a","b","c"],i=new p.cZY,s=new p.cZY;return function(o,a=null,l=null){const c=a||l?i:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let h=1/0;for(let u=0;u<3;u++){let f;const d=e[u],_=o[d];this.closestPointToPoint(_,r),f=_.distanceToSquared(r),f<h&&(h=f,a&&a.copy(r),l&&l.copy(_));const m=this[d];o.closestPointToPoint(m,r),f=m.distanceToSquared(r),f<h&&(h=f,a&&a.copy(m),l&&l.copy(r))}for(let u=0;u<3;u++){i.set(this[e[u]],this[e[(u+1)%3]]);for(let _=0;_<3;_++){s.set(o[e[_]],o[e[(_+1)%3]]),ir(i,s,r,t);const g=r.distanceToSquared(t);g<h&&(h=g,a&&a.copy(r),l&&l.copy(t))}}return Math.sqrt(h)}}();class Jt{constructor(t,e,i){this.isOrientedBox=!0,this.min=new p.Pq0,this.max=new p.Pq0,this.matrix=new p.kn4,this.invMatrix=new p.kn4,this.points=new Array(8).fill().map(()=>new p.Pq0),this.satAxes=new Array(3).fill().map(()=>new p.Pq0),this.satBounds=new Array(3).fill().map(()=>new ke),this.alignedSatBounds=new Array(3).fill().map(()=>new ke),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),i&&this.matrix.copy(i)}set(t,e,i){this.min.copy(t),this.max.copy(e),this.matrix.copy(i),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}Jt.prototype.update=function(){return function(){const t=this.matrix,e=this.min,i=this.max,s=this.points;for(let c=0;c<=1;c++)for(let h=0;h<=1;h++)for(let u=0;u<=1;u++){const d=s[1*c|2*h|4*u];d.x=c?i.x:e.x,d.y=h?i.y:e.y,d.z=u?i.z:e.z,d.applyMatrix4(t)}const n=this.satBounds,o=this.satAxes,a=s[0];for(let c=0;c<3;c++){const h=o[c],u=n[c];h.subVectors(a,s[1<<c]),u.setFromPoints(h,s)}const l=this.alignedSatBounds;l[0].setFromPointsField(s,"x"),l[1].setFromPointsField(s,"y"),l[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),Jt.prototype.intersectsBox=function(){const r=new ke;return function(e){this.needsUpdate&&this.update();const i=e.min,s=e.max,n=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=i.x,r.max=s.x,a[0].isSeparated(r)||(r.min=i.y,r.max=s.y,a[1].isSeparated(r))||(r.min=i.z,r.max=s.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){const h=n[l];if(r.setFromBox(o[l],e),h.isSeparated(r))return!1}return!0}}(),Jt.prototype.intersectsTriangle=function(){const r=new le,t=new Array(3),e=new ke,i=new ke,s=new p.Pq0;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);const a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let f=0;f<3;f++){const d=a[f];if(e.setFromPoints(l[f],t),d.isSeparated(e))return!1}const c=o.satBounds,h=o.satAxes,u=this.points;for(let f=0;f<3;f++){const d=c[f];if(e.setFromPoints(h[f],u),d.isSeparated(e))return!1}for(let f=0;f<3;f++){const d=l[f];for(let _=0;_<4;_++)if(s.crossVectors(d,h[_]),e.setFromPoints(s,t),i.setFromPoints(s,u),e.isSeparated(i))return!1}return!0}}(),Jt.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}(),Jt.prototype.distanceToPoint=function(){const r=new p.Pq0;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),Jt.prototype.distanceToBox=function(){const r=["x","y","z"],t=new Array(12).fill().map(()=>new p.cZY),e=new Array(12).fill().map(()=>new p.cZY),i=new p.Pq0,s=new p.Pq0;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),l&&l.copy(i),c&&c.copy(s)),0;const h=a*a,u=o.min,f=o.max,d=this.points;let _=1/0;for(let w=0;w<8;w++){const g=d[w];s.copy(g).clamp(u,f);const v=g.distanceToSquared(s);if(v<_&&(_=v,l&&l.copy(g),c&&c.copy(s),v<h))return Math.sqrt(v)}let m=0;for(let w=0;w<3;w++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){const T=(w+1)%3,C=(w+2)%3;t[m].set(d[g<<T|v<<C],d[1<<w|g<<T|v<<C]);const D=r[w],B=r[T],E=r[C],L=e[m],x=L.start,N=L.end;x[D]=u[D],x[B]=g?u[B]:f[B],x[E]=v?u[E]:f[B],N[D]=f[D],N[B]=g?u[B]:f[B],N[E]=v?u[E]:f[B],m++}for(let w=0;w<=1;w++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){s.x=w?f.x:u.x,s.y=g?f.y:u.y,s.z=v?f.z:u.z,this.closestPointToPoint(s,i);const T=s.distanceToSquared(i);if(T<_&&(_=T,l&&l.copy(i),c&&c.copy(s),T<h))return Math.sqrt(T)}for(let w=0;w<12;w++){const g=t[w];for(let v=0;v<12;v++){ir(g,e[v],i,s);const C=i.distanceToSquared(s);if(C<_&&(_=C,l&&l.copy(i),c&&c.copy(s),C<h))return Math.sqrt(C)}}return Math.sqrt(_)}}();class Gu extends Is{constructor(){super(()=>new le)}}const me=new Gu,Qi=new p.Pq0,sr=new p.Pq0,ks=parseInt(p.sPf)>=169,Zu=parseInt(p.sPf)<=161,hi=new p.Pq0,ui=new p.Pq0,di=new p.Pq0,Ls=new p.I9Y,Ns=new p.I9Y,Bs=new p.I9Y,ca=new p.Pq0,ha=new p.Pq0,ua=new p.Pq0,Ji=new p.Pq0;function da(r,t,e,i,s,n,o,a,l,c,h){hi.fromBufferAttribute(t,n),ui.fromBufferAttribute(t,o),di.fromBufferAttribute(t,a);const u=function Wu(r,t,e,i,s,n,o,a){let l;if(l=n===p.hsX?r.intersectTriangle(i,e,t,!0,s):r.intersectTriangle(t,e,i,n!==p.$EB,s),null===l)return null;const c=r.origin.distanceTo(s);return c<o||c>a?null:{distance:c,point:s.clone()}}(r,hi,ui,di,Ji,l,c,h);if(u){if(i){Ls.fromBufferAttribute(i,n),Ns.fromBufferAttribute(i,o),Bs.fromBufferAttribute(i,a),u.uv=new p.I9Y;const d=p.lMl.getInterpolation(Ji,hi,ui,di,Ls,Ns,Bs,u.uv);ks||(u.uv=d)}if(s){Ls.fromBufferAttribute(s,n),Ns.fromBufferAttribute(s,o),Bs.fromBufferAttribute(s,a),u.uv1=new p.I9Y;const d=p.lMl.getInterpolation(Ji,hi,ui,di,Ls,Ns,Bs,u.uv1);ks||(u.uv1=d),Zu&&(u.uv2=u.uv1)}if(e){ca.fromBufferAttribute(e,n),ha.fromBufferAttribute(e,o),ua.fromBufferAttribute(e,a),u.normal=new p.Pq0;const d=p.lMl.getInterpolation(Ji,hi,ui,di,ca,ha,ua,u.normal);u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1),ks||(u.normal=d)}const f={a:n,b:o,c:a,normal:new p.Pq0,materialIndex:0};if(p.lMl.getNormal(hi,ui,di,f.normal),u.face=f,u.faceIndex=n,ks){const d=new p.Pq0;p.lMl.getBarycoord(Ji,hi,ui,di,d),u.barycoord=d}}return u}function fa(r){return r&&r.isMaterial?r.side:r}function Rs(r,t,e,i,s,n,o){const a=3*i;let l=a+0,c=a+1,h=a+2;const{index:u,groups:f}=r;r.index&&(l=u.getX(l),c=u.getX(c),h=u.getX(h));const{position:d,normal:_,uv:m,uv1:w}=r.attributes;if(Array.isArray(t)){const g=3*i;for(let v=0,T=f.length;v<T;v++){const{start:C,count:S,materialIndex:M}=f[v];if(g>=C&&g<C+S){const O=da(e,d,_,m,w,l,c,h,fa(t[M]),n,o);if(O){if(O.faceIndex=i,O.face.materialIndex=M,!s)return O;s.push(O)}}}}else{const v=da(e,d,_,m,w,l,c,h,fa(t),n,o);if(v){if(v.faceIndex=i,v.face.materialIndex=0,!s)return v;s.push(v)}}return null}function Ft(r,t,e,i){const s=r.a,n=r.b,o=r.c;let a=t,l=t+1,c=t+2;e&&(a=e.getX(a),l=e.getX(l),c=e.getX(c)),s.x=i.getX(a),s.y=i.getY(a),s.z=i.getZ(a),n.x=i.getX(l),n.y=i.getY(l),n.z=i.getZ(l),o.x=i.getX(c),o.y=i.getY(c),o.z=i.getZ(c)}function Qu(r,t,e,i,s,n,o){const{geometry:a}=e,{index:l}=a,c=a.attributes.position;for(let h=r,u=t+r;h<u;h++){let f;if(f=h,Ft(o,3*f,l,c),o.needsUpdate=!0,i(o,f,s,n))return!0}return!1}function Ju(r,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=r.geometry,i=e.index?e.index.array:null,s=e.attributes.position;let n,o,a,l,c=0;const h=r._roots;for(let f=0,d=h.length;f<d;f++)n=h[f],o=new Uint32Array(n),a=new Uint16Array(n),l=new Float32Array(n),u(0,c),c+=n.byteLength;function u(f,d,_=!1){const m=2*f;if(Ut(m,a)){const w=Xt(f,o);let v=1/0,T=1/0,C=1/0,S=-1/0,M=-1/0,A=-1/0;for(let O=3*w,I=3*(w+Qt(m,a));O<I;O++){let D=i[O];const B=s.getX(D),E=s.getY(D),L=s.getZ(D);B<v&&(v=B),B>S&&(S=B),E<T&&(T=E),E>M&&(M=E),L<C&&(C=L),L>A&&(A=L)}return(l[f+0]!==v||l[f+1]!==T||l[f+2]!==C||l[f+3]!==S||l[f+4]!==M||l[f+5]!==A)&&(l[f+0]=v,l[f+1]=T,l[f+2]=C,l[f+3]=S,l[f+4]=M,l[f+5]=A,!0)}{const w=jt(f),g=Ht(f,o);let v=_,T=!1,C=!1;if(t){if(!v){const B=g/8+d/32;T=t.has(w/8+d/32),C=t.has(B),v=!T&&!C}}else T=!0,C=!0;const M=v||C;let A=!1;(v||T)&&(A=u(w,d,v));let O=!1;M&&(O=u(g,d,v));const I=A||O;if(I)for(let D=0;D<3;D++){const B=w+D,E=g+D,L=l[B],x=l[B+3],N=l[E],Y=l[E+3];l[f+D]=L<N?L:N,l[f+D+3]=x>Y?x:Y}return I}}}function Xe(r,t,e,i,s){let n,o,a,l,c,h;const u=1/e.direction.x,f=1/e.direction.y,d=1/e.direction.z,_=e.origin.x,m=e.origin.y,w=e.origin.z;let g=t[r],v=t[r+3],T=t[r+1],C=t[r+3+1],S=t[r+2],M=t[r+3+2];return u>=0?(n=(g-_)*u,o=(v-_)*u):(n=(v-_)*u,o=(g-_)*u),f>=0?(a=(T-m)*f,l=(C-m)*f):(a=(C-m)*f,l=(T-m)*f),!(n>l||a>o||((a>n||isNaN(n))&&(n=a),(l<o||isNaN(o))&&(o=l),d>=0?(c=(S-w)*d,h=(M-w)*d):(c=(M-w)*d,h=(S-w)*d),n>h||c>o))&&((c>n||n!=n)&&(n=c),(h<o||o!=o)&&(o=h),n<=s&&o>=i)}function id(r,t,e,i,s,n,o){const{geometry:a}=e,{index:l}=a,c=a.attributes.position;for(let h=r,u=t+r;h<u;h++){let f;if(f=e.resolveTriangleIndex(h),Ft(o,3*f,l,c),o.needsUpdate=!0,i(o,f,s,n))return!0}return!1}function sd(r,t,e,i,s,n,o){Dt.setBuffer(r._roots[t]),nr(0,r,e,i,s,n,o),Dt.clearBuffer()}function nr(r,t,e,i,s,n,o){const{float32Array:a,uint16Array:l,uint32Array:c}=Dt,h=2*r;if(Ut(h,l))!function Xu(r,t,e,i,s,n,o,a){const{geometry:l}=r;for(let h=i,u=i+s;h<u;h++)Rs(l,t,e,h,n,o,a)}(t,e,i,Xt(r,c),Qt(h,l),s,n,o);else{const f=jt(r);Xe(f,a,i,n,o)&&nr(f,t,e,i,s,n,o);const d=Ht(r,c);Xe(d,a,i,n,o)&&nr(d,t,e,i,s,n,o)}}const nd=["x","y","z"];function rd(r,t,e,i,s,n){Dt.setBuffer(r._roots[t]);const o=rr(0,r,e,i,s,n);return Dt.clearBuffer(),o}function rr(r,t,e,i,s,n){const{float32Array:o,uint16Array:a,uint32Array:l}=Dt;let c=2*r;if(Ut(c,a))return function Ku(r,t,e,i,s,n,o){const{geometry:a}=r;let c=1/0,h=null;for(let u=i,f=i+s;u<f;u++){let d;d=Rs(a,t,e,u,null,n,o),d&&d.distance<c&&(h=d,c=d.distance)}return h}(t,e,i,Xt(r,l),Qt(c,a),s,n);{const u=qn(r,l),f=nd[u],_=i.direction[f]>=0;let m,w;_?(m=jt(r),w=Ht(r,l)):(m=Ht(r,l),w=jt(r));const v=Xe(m,o,i,s,n)?rr(m,t,e,i,s,n):null;if(v){const S=v.point[f];if(_?S<=o[w+u]:S>=o[w+u+3])return v}const C=Xe(w,o,i,s,n)?rr(w,t,e,i,s,n):null;return v&&C?v.distance<=C.distance?v:C:v||C||null}}const Fs=new p.NRn,Mi=new le,Ii=new le,ts=new p.kn4,pa=new Jt,Vs=new Jt;function od(r,t,e,i){Dt.setBuffer(r._roots[t]);const s=or(0,r,e,i);return Dt.clearBuffer(),s}function or(r,t,e,i,s=null){const{float32Array:n,uint16Array:o,uint32Array:a}=Dt;let l=2*r;if(null===s&&(e.boundingBox||e.computeBoundingBox(),pa.set(e.boundingBox.min,e.boundingBox.max,i),s=pa),!Ut(l,o)){const h=jt(r),u=Ht(r,a);return Lt(h,n,Fs),!!(s.intersectsBox(Fs)&&or(h,t,e,i,s)||(Lt(u,n,Fs),s.intersectsBox(Fs)&&or(u,t,e,i,s)))}{const h=t.geometry,u=h.index,f=h.attributes.position,d=e.index,_=e.attributes.position,m=Xt(r,a),w=Qt(l,o);if(ts.copy(i).invert(),e.boundsTree)return Lt(r,n,Vs),Vs.matrix.copy(ts),Vs.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:v=>Vs.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(i),v.b.applyMatrix4(i),v.c.applyMatrix4(i),v.needsUpdate=!0;for(let T=3*m,C=3*(w+m);T<C;T+=3)if(Ft(Ii,T,u,f),Ii.needsUpdate=!0,v.intersectsTriangle(Ii))return!0;return!1}});{const g=Ds(e);for(let v=3*m,T=3*(w+m);v<T;v+=3){Ft(Mi,v,u,f),Mi.a.applyMatrix4(ts),Mi.b.applyMatrix4(ts),Mi.c.applyMatrix4(ts),Mi.needsUpdate=!0;for(let C=0,S=3*g;C<S;C+=3)if(Ft(Ii,C,d,_),Ii.needsUpdate=!0,Mi.intersectsTriangle(Ii))return!0}}}}const Us=new p.kn4,ar=new Jt,es=new Jt,ad=new p.Pq0,ld=new p.Pq0,cd=new p.Pq0,hd=new p.Pq0;function ud(r,t,e,i={},s={},n=0,o=1/0){t.boundingBox||t.computeBoundingBox(),ar.set(t.boundingBox.min,t.boundingBox.max,e),ar.needsUpdate=!0;const a=r.geometry,l=a.attributes.position,c=a.index,h=t.attributes.position,u=t.index,f=me.getPrimitive(),d=me.getPrimitive();let _=ad,m=ld,w=null,g=null;s&&(w=cd,g=hd);let v=1/0,T=null,C=null;return Us.copy(e).invert(),es.matrix.copy(Us),r.shapecast({boundsTraverseOrder:S=>ar.distanceToBox(S),intersectsBounds:(S,M,A)=>A<v&&A<o&&(M&&(es.min.copy(S.min),es.max.copy(S.max),es.needsUpdate=!0),!0),intersectsRange:(S,M)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:O=>es.distanceToBox(O),intersectsBounds:(O,I,D)=>D<v&&D<o,intersectsRange:(O,I)=>{for(let D=O,B=O+I;D<B;D++){Ft(d,3*D,u,h),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let E=S,L=S+M;E<L;E++){Ft(f,3*E,c,l),f.needsUpdate=!0;const x=f.distanceToTriangle(d,_,w);if(x<v&&(m.copy(_),g&&g.copy(w),v=x,T=E,C=D),x<n)return!0}}}});for(let O=0,I=Ds(t);O<I;O++){Ft(d,3*O,u,h),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let D=S,B=S+M;D<B;D++){Ft(f,3*D,c,l),f.needsUpdate=!0;const E=f.distanceToTriangle(d,_,w);if(E<v&&(m.copy(_),g&&g.copy(w),v=E,T=D,C=O),E<n)return!0}}}}),me.releasePrimitive(f),me.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(m):i.point=m.clone(),i.distance=v,i.faceIndex=T,s&&(s.point?s.point.copy(g):s.point=g.clone(),s.point.applyMatrix4(Us),m.applyMatrix4(Us),s.distance=m.sub(s.point).length(),s.faceIndex=C),i)}function dd(r,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=r.geometry,i=e.index?e.index.array:null,s=e.attributes.position;let n,o,a,l,c=0;const h=r._roots;for(let f=0,d=h.length;f<d;f++)n=h[f],o=new Uint32Array(n),a=new Uint16Array(n),l=new Float32Array(n),u(0,c),c+=n.byteLength;function u(f,d,_=!1){const m=2*f;if(Ut(m,a)){const w=Xt(f,o);let v=1/0,T=1/0,C=1/0,S=-1/0,M=-1/0,A=-1/0;for(let O=w,I=w+Qt(m,a);O<I;O++){const D=3*r.resolveTriangleIndex(O);for(let B=0;B<3;B++){let E=D+B;E=i?i[E]:E;const L=s.getX(E),x=s.getY(E),N=s.getZ(E);L<v&&(v=L),L>S&&(S=L),x<T&&(T=x),x>M&&(M=x),N<C&&(C=N),N>A&&(A=N)}}return(l[f+0]!==v||l[f+1]!==T||l[f+2]!==C||l[f+3]!==S||l[f+4]!==M||l[f+5]!==A)&&(l[f+0]=v,l[f+1]=T,l[f+2]=C,l[f+3]=S,l[f+4]=M,l[f+5]=A,!0)}{const w=jt(f),g=Ht(f,o);let v=_,T=!1,C=!1;if(t){if(!v){const B=g/8+d/32;T=t.has(w/8+d/32),C=t.has(B),v=!T&&!C}}else T=!0,C=!0;const M=v||C;let A=!1;(v||T)&&(A=u(w,d,v));let O=!1;M&&(O=u(g,d,v));const I=A||O;if(I)for(let D=0;D<3;D++){const B=w+D,E=g+D,L=l[B],x=l[B+3],N=l[E],Y=l[E+3];l[f+D]=L<N?L:N,l[f+D+3]=x>Y?x:Y}return I}}}function fd(r,t,e,i,s,n,o){Dt.setBuffer(r._roots[t]),lr(0,r,e,i,s,n,o),Dt.clearBuffer()}function lr(r,t,e,i,s,n,o){const{float32Array:a,uint16Array:l,uint32Array:c}=Dt,h=2*r;if(Ut(h,l))!function td(r,t,e,i,s,n,o,a){const{geometry:l,_indirectBuffer:c}=r;for(let h=i,u=i+s;h<u;h++)Rs(l,t,e,c?c[h]:h,n,o,a)}(t,e,i,Xt(r,c),Qt(h,l),s,n,o);else{const f=jt(r);Xe(f,a,i,n,o)&&lr(f,t,e,i,s,n,o);const d=Ht(r,c);Xe(d,a,i,n,o)&&lr(d,t,e,i,s,n,o)}}const pd=["x","y","z"];function md(r,t,e,i,s,n){Dt.setBuffer(r._roots[t]);const o=cr(0,r,e,i,s,n);return Dt.clearBuffer(),o}function cr(r,t,e,i,s,n){const{float32Array:o,uint16Array:a,uint32Array:l}=Dt;let c=2*r;if(Ut(c,a))return function ed(r,t,e,i,s,n,o){const{geometry:a,_indirectBuffer:l}=r;let c=1/0,h=null;for(let u=i,f=i+s;u<f;u++){let d;d=Rs(a,t,e,l?l[u]:u,null,n,o),d&&d.distance<c&&(h=d,c=d.distance)}return h}(t,e,i,Xt(r,l),Qt(c,a),s,n);{const u=qn(r,l),f=pd[u],_=i.direction[f]>=0;let m,w;_?(m=jt(r),w=Ht(r,l)):(m=Ht(r,l),w=jt(r));const v=Xe(m,o,i,s,n)?cr(m,t,e,i,s,n):null;if(v){const S=v.point[f];if(_?S<=o[w+u]:S>=o[w+u+3])return v}const C=Xe(w,o,i,s,n)?cr(w,t,e,i,s,n):null;return v&&C?v.distance<=C.distance?v:C:v||C||null}}const $s=new p.NRn,Oi=new le,zi=new le,is=new p.kn4,ma=new Jt,js=new Jt;function gd(r,t,e,i){Dt.setBuffer(r._roots[t]);const s=hr(0,r,e,i);return Dt.clearBuffer(),s}function hr(r,t,e,i,s=null){const{float32Array:n,uint16Array:o,uint32Array:a}=Dt;let l=2*r;if(null===s&&(e.boundingBox||e.computeBoundingBox(),ma.set(e.boundingBox.min,e.boundingBox.max,i),s=ma),!Ut(l,o)){const h=jt(r),u=Ht(r,a);return Lt(h,n,$s),!!(s.intersectsBox($s)&&hr(h,t,e,i,s)||(Lt(u,n,$s),s.intersectsBox($s)&&hr(u,t,e,i,s)))}{const h=t.geometry,u=h.index,f=h.attributes.position,d=e.index,_=e.attributes.position,m=Xt(r,a),w=Qt(l,o);if(is.copy(i).invert(),e.boundsTree)return Lt(r,n,js),js.matrix.copy(is),js.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:v=>js.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(i),v.b.applyMatrix4(i),v.c.applyMatrix4(i),v.needsUpdate=!0;for(let T=m,C=w+m;T<C;T++)if(Ft(zi,3*t.resolveTriangleIndex(T),u,f),zi.needsUpdate=!0,v.intersectsTriangle(zi))return!0;return!1}});{const g=Ds(e);for(let v=m,T=w+m;v<T;v++){const C=t.resolveTriangleIndex(v);Ft(Oi,3*C,u,f),Oi.a.applyMatrix4(is),Oi.b.applyMatrix4(is),Oi.c.applyMatrix4(is),Oi.needsUpdate=!0;for(let S=0,M=3*g;S<M;S+=3)if(Ft(zi,S,d,_),zi.needsUpdate=!0,Oi.intersectsTriangle(zi))return!0}}}}const Hs=new p.kn4,ur=new Jt,ss=new Jt,_d=new p.Pq0,yd=new p.Pq0,wd=new p.Pq0,vd=new p.Pq0;function bd(r,t,e,i={},s={},n=0,o=1/0){t.boundingBox||t.computeBoundingBox(),ur.set(t.boundingBox.min,t.boundingBox.max,e),ur.needsUpdate=!0;const a=r.geometry,l=a.attributes.position,c=a.index,h=t.attributes.position,u=t.index,f=me.getPrimitive(),d=me.getPrimitive();let _=_d,m=yd,w=null,g=null;s&&(w=wd,g=vd);let v=1/0,T=null,C=null;return Hs.copy(e).invert(),ss.matrix.copy(Hs),r.shapecast({boundsTraverseOrder:S=>ur.distanceToBox(S),intersectsBounds:(S,M,A)=>A<v&&A<o&&(M&&(ss.min.copy(S.min),ss.max.copy(S.max),ss.needsUpdate=!0),!0),intersectsRange:(S,M)=>{if(t.boundsTree){const A=t.boundsTree;return A.shapecast({boundsTraverseOrder:O=>ss.distanceToBox(O),intersectsBounds:(O,I,D)=>D<v&&D<o,intersectsRange:(O,I)=>{for(let D=O,B=O+I;D<B;D++){const E=A.resolveTriangleIndex(D);Ft(d,3*E,u,h),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let L=S,x=S+M;L<x;L++){const N=r.resolveTriangleIndex(L);Ft(f,3*N,c,l),f.needsUpdate=!0;const Y=f.distanceToTriangle(d,_,w);if(Y<v&&(m.copy(_),g&&g.copy(w),v=Y,T=L,C=D),Y<n)return!0}}}})}for(let O=0,I=Ds(t);O<I;O++){Ft(d,3*O,u,h),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let D=S,B=S+M;D<B;D++){const E=r.resolveTriangleIndex(D);Ft(f,3*E,c,l),f.needsUpdate=!0;const L=f.distanceToTriangle(d,_,w);if(L<v&&(m.copy(_),g&&g.copy(w),v=L,T=D,C=O),L<n)return!0}}}}),me.releasePrimitive(f),me.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(m):i.point=m.clone(),i.distance=v,i.faceIndex=T,s&&(s.point?s.point.copy(g):s.point=g.clone(),s.point.applyMatrix4(Hs),m.applyMatrix4(Hs),s.distance=m.sub(s.point).length(),s.faceIndex=C),i)}function ga(r,t,e){return null===r?null:(r.point.applyMatrix4(t.matrixWorld),r.distance=r.point.distanceTo(e.ray.origin),r.object=t,r)}const qs=new Jt,Gs=new p.RlV,_a=new p.Pq0,ya=new p.kn4,wa=new p.Pq0,dr=["getX","getY","getZ"];class Ke extends aa{static serialize(t,e={}){e={cloneBuffers:!0,...e};const s=t._roots,n=t._indirectBuffer,o=t.geometry.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return e.cloneBuffers?(a.roots=s.map(l=>l.slice()),a.index=o?o.array.slice():null,a.indirectBuffer=n?n.slice():null):(a.roots=s,a.index=o?o.array:null,a.indirectBuffer=n),a}static deserialize(t,e,i={}){i={setIndex:!0,indirect:!!t.indirectBuffer,...i};const{index:s,roots:n,indirectBuffer:o}=t;t.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),function l(c){for(let h=0;h<c.length;h++){const u=c[h],f=new Uint32Array(u),d=new Uint16Array(u);for(let _=0,m=u.byteLength/32;_<m;_++){const w=8*_;Ut(2*w,d)||(f[w+6]=f[w+6]/8-_)}}}(n));const a=new Ke(e,{...i,[Hn]:!0});if(a._roots=n,a._indirectBuffer=o||null,i.setIndex){const c=e.getIndex();if(null===c){const h=new p.THS(t.index,1,!1);e.setIndex(h)}else c.array!==s&&(c.array.set(s),c.needsUpdate=!0)}return a}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(t,e={}){e.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'),e={...e,maxLeafSize:e.maxLeafTris}),super(t,e)}shiftTriangleOffsets(t){return super.shiftPrimitiveOffsets(t)}writePrimitiveBounds(t,e,i){const s=this.geometry,n=this._indirectBuffer,o=s.attributes.position,a=s.index?s.index.array:null,c=3*(n?n[t]:t);let h=c+0,u=c+1,f=c+2;a&&(h=a[h],u=a[u],f=a[f]);for(let d=0;d<3;d++){const _=o[dr[d]](h),m=o[dr[d]](u),w=o[dr[d]](f);let g=_;m<g&&(g=m),w<g&&(g=w);let v=_;m>v&&(v=m),w>v&&(v=w),e[i+d]=g,e[i+d+3]=v}return e}computePrimitiveBounds(t,e,i){const s=this.geometry,n=this._indirectBuffer,o=s.attributes.position,a=s.index?s.index.array:null,l=o.normalized;if(t<0||e+t-i.offset>i.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const c=o.array,h=o.offset||0;let u=3;o.isInterleavedBufferAttribute&&(u=o.data.stride);const f=["getX","getY","getZ"],d=i.offset;for(let _=t,m=t+e;_<m;_++){const g=3*(n?n[_]:_),v=6*(_-d);let T=g+0,C=g+1,S=g+2;a&&(T=a[T],C=a[C],S=a[S]),l||(T=T*u+h,C=C*u+h,S=S*u+h);for(let M=0;M<3;M++){let A,O,I;l?(A=o[f[M]](T),O=o[f[M]](C),I=o[f[M]](S)):(A=c[T+M],O=c[C+M],I=c[S+M]);let D=A;O<D&&(D=O),I<D&&(D=I);let B=A;O>B&&(B=O),I>B&&(B=I);const E=(B-D)/2,L=2*M;i[v+L+0]=D+E,i[v+L+1]=E+(Math.abs(D)+E)*Ss}}return i}raycastObject3D(t,e,i=[]){const{material:s}=t;if(void 0===s)return;ya.copy(t.matrixWorld).invert(),Gs.copy(e.ray).applyMatrix4(ya),wa.setFromMatrixScale(t.matrixWorld),_a.copy(Gs.direction).multiply(wa);const n=_a.length(),o=e.near/n,a=e.far/n;if(!0===e.firstHitOnly){let l=this.raycastFirst(Gs,s,o,a);l=ga(l,t,e),l&&i.push(l)}else{const l=this.raycast(Gs,s,o,a);for(let c=0,h=l.length;c<h;c++){const u=ga(l[c],t,e);u&&i.push(u)}}return i}refit(t=null){return(this.indirect?dd:Ju)(this,t)}raycast(t,e=p.hB5,i=0,s=1/0){const o=[],a=this.indirect?fd:sd;for(let l=0,c=this._roots.length;l<c;l++)a(this,l,e,t,o,i,s);return o}raycastFirst(t,e=p.hB5,i=0,s=1/0){let o=null;const a=this.indirect?md:rd;for(let l=0,c=this._roots.length;l<c;l++){const h=a(this,l,e,t,i,s);null!=h&&(null==o||h.distance<o.distance)&&(o=h)}return o}intersectsGeometry(t,e){let i=!1;const n=this.indirect?gd:od;for(let o=0,a=this._roots.length;o<a&&(i=n(this,o,t,e),!i);o++);return i}shapecast(t){const e=me.getPrimitive(),i=super.shapecast({...t,intersectsPrimitive:t.intersectsTriangle,scratchPrimitive:e,iterate:this.indirect?id:Qu});return me.releasePrimitive(e),i}bvhcast(t,e,i){let{intersectsRanges:s,intersectsTriangles:n}=i;const o=me.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?_=>{const m=this.resolveTriangleIndex(_);Ft(o,3*m,a,l)}:_=>{Ft(o,3*_,a,l)},h=me.getPrimitive(),u=t.geometry.index,f=t.geometry.attributes.position,d=t.indirect?_=>{const m=t.resolveTriangleIndex(_);Ft(h,3*m,u,f)}:_=>{Ft(h,3*_,u,f)};if(n){if(!(t instanceof Ke))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const _=(m,w,g,v,T,C,S,M)=>{for(let A=g,O=g+v;A<O;A++){d(A),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let I=m,D=m+w;I<D;I++)if(c(I),o.needsUpdate=!0,n(o,h,I,A,T,C,S,M))return!0}return!1};if(s){const m=s;s=function(w,g,v,T,C,S,M,A){return!!m(w,g,v,T,C,S,M,A)||_(w,g,v,T,C,S,M,A)}}else s=_}return super.bvhcast(t,e,{intersectsRanges:s})}intersectsBox(t,e){return qs.set(t.min,t.max,e),qs.needsUpdate=!0,this.shapecast({intersectsBounds:i=>qs.intersectsBox(i),intersectsTriangle:i=>qs.intersectsTriangle(i)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,i={},s={},n=0,o=1/0){return(this.indirect?bd:ud)(this,t,e,i,s,n,o)}closestPointToPoint(t,e={},i=0,s=1/0){return function Yu(r,t,e={},i=0,s=1/0){const n=i*i,o=s*s;let a=1/0,l=null;if(r.shapecast({boundsTraverseOrder:h=>(Qi.copy(t).clamp(h.min,h.max),Qi.distanceToSquared(t)),intersectsBounds:(h,u,f)=>f<a&&f<o,intersectsTriangle:(h,u)=>{h.closestPointToPoint(t,Qi);const f=t.distanceToSquared(Qi);return f<a&&(sr.copy(Qi),a=f,l=u),f<n}}),a===1/0)return null;const c=Math.sqrt(a);return e.point?e.point.copy(sr):e.point=sr.clone(),e.distance=c,e.faceIndex=l,e}(this,t,e,i,s)}}const va=new p.kn4,Ys=new p.RlV,ba=new Is(()=>new p.cZY),fr=new p.Pq0,xa=new p.Pq0,Ca=new p.NRn,Ta=["getX","getY","getZ"];class xd extends aa{get primitiveStride(){return 2}writePrimitiveBounds(t,e,i){const s=this._indirectBuffer,{geometry:n,primitiveStride:o}=this,a=n.attributes.position,l=n.index;let u=(s?s[t]:t)*o,f=(u+1)%(l?l.count:a.count);l&&(u=l.getX(u),f=l.getX(f));for(let d=0;d<3;d++){const _=a[Ta[d]](u),m=a[Ta[d]](f),g=_>m?_:m;e[i+d]=_<m?_:m,e[i+d+3]=g}return e}shapecast(t){const e=ba.getPrimitive(),i=super.shapecast({...t,intersectsPrimitive:t.intersectsLine,scratchPrimitive:e,iterate:Cd});return ba.releasePrimitive(e),i}raycastObject3D(t,e,i=[]){const{matrixWorld:s}=t,{firstHitOnly:n}=e;va.copy(s).invert(),Ys.copy(e.ray).applyMatrix4(va);const a=e.params.Line.threshold/((t.scale.x+t.scale.y+t.scale.z)/3),l=a*a;let c=null,h=1/0;return this.shapecast({boundsTraverseOrder:u=>u.distanceToPoint(Ys.origin),intersectsBounds:u=>(Ca.copy(u).expandByScalar(Math.abs(a)),Ys.intersectsBox(Ca)?1:0),intersectsLine:(u,f)=>{if(Ys.distanceSqToSegment(u.start,u.end,fr,xa)>l)return;fr.applyMatrix4(t.matrixWorld);const _=e.ray.origin.distanceTo(fr);_<e.near||_>e.far||n&&_>=h||(h=_,f=this.resolvePrimitiveIndex(f),c={distance:_,point:xa.clone().applyMatrix4(s),index:f*this.primitiveStride,face:null,faceIndex:null,barycoord:null,object:t},n||i.push(c))}}),n&&c&&i.push(c),i}}function Cd(r,t,e,i,s,n,o){const{geometry:a,primitiveStride:l}=e,{index:c}=a,h=a.attributes.position,u=c?c.count:h.count;for(let f=r,d=t+r;f<d;f++){let m=e.resolvePrimitiveIndex(f)*l,w=(m+1)%u;if(c&&(m=c.getX(m),w=c.getX(w)),o.start.fromBufferAttribute(h,m),o.end.fromBufferAttribute(h,w),i(o,f,s,n))return!0}return!1}const Di={Mesh:p.eaF.prototype.raycast,Line:p.N1A.prototype.raycast,LineSegments:p.DXC.prototype.raycast,LineLoop:p.FCc.prototype.raycast,Points:p.ONl.prototype.raycast,BatchedMesh:p.$Ed.prototype.raycast},Yt=new p.eaF,Zs=[];function Pa(r,t){if(this.isBatchedMesh)Td.call(this,r,t);else{const{geometry:e}=this;if(e.boundsTree)e.boundsTree.raycastObject3D(this,r,t);else{let i;if(this instanceof p.eaF)i=Di.Mesh;else if(this instanceof p.DXC)i=Di.LineSegments;else if(this instanceof p.FCc)i=Di.LineLoop;else if(this instanceof p.N1A)i=Di.Line;else{if(!(this instanceof p.ONl))throw new Error("BVH: Fallback raycast function not found.");i=Di.Points}i.call(this,r,t)}}}function Td(r,t){if(this.boundsTrees){const e=this.boundsTrees,i=this._drawInfo||this._instanceInfo,s=this._drawRanges||this._geometryInfo,n=this.matrixWorld;Yt.material=this.material,Yt.geometry=this.geometry;const o=Yt.geometry.boundsTree,a=Yt.geometry.drawRange;null===Yt.geometry.boundingSphere&&(Yt.geometry.boundingSphere=new p.iyt);for(let l=0,c=i.length;l<c;l++){if(!this.getVisibleAt(l))continue;const h=i[l].geometryIndex;if(Yt.geometry.boundsTree=e[h],this.getMatrixAt(l,Yt.matrixWorld).premultiply(n),!Yt.geometry.boundsTree){this.getBoundingBoxAt(h,Yt.geometry.boundingBox),this.getBoundingSphereAt(h,Yt.geometry.boundingSphere);const u=s[h];Yt.geometry.setDrawRange(u.start,u.count)}Yt.raycast(r,Zs);for(let u=0,f=Zs.length;u<f;u++){const d=Zs[u];d.object=this,d.batchId=l,t.push(d)}Zs.length=0}Yt.geometry.boundsTree=o,Yt.geometry.drawRange=a,Yt.material=null,Yt.geometry=null}else Di.BatchedMesh.call(this,r,t)}function Pd(r={}){const{type:t=Ke}=r;return this.boundsTree=new t(this,r),this.boundsTree}function Sd(){this.boundsTree=null}const Sa=class Rc extends At{constructor(t){super(t),y(this,"onDisposed",new Q),y(this,"onBeforeDispose",new Q),y(this,"onFragmentsLoaded",new Q),y(this,"baseCoordinationModel",""),y(this,"baseCoordinationMatrix",new p.kn4),y(this,"enabled",!0),y(this,"_core"),this.components.add(Rc.uuid,this)}static getWorker(){return ot._i.getWorker()}get initialized(){return!!this._core}get list(){return this.core.models.list}get core(){if(!this._core)throw new Error("FragmentsManager not initialized. Call init() first.");return this._core}get _hasCoordinationModel(){return""!==this.baseCoordinationModel}dispose(){this.onBeforeDispose.trigger(),this._core&&(this.core.dispose(),this._core=void 0),this.baseCoordinationModel="",this.onFragmentsLoaded.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}init(t,e){var i=this;this._core=new ot._i(t,e),this.core.onModelLoaded.add((0,G.A)(function*(){if(i._hasCoordinationModel)return;const s=[...i.list.values()][0];s&&(i.baseCoordinationModel=s.modelId,i.baseCoordinationMatrix=yield s.getCoordinationMatrix())})),this.list.onItemDeleted.add(()=>{this.list.size>0||(this.baseCoordinationModel="",this.baseCoordinationMatrix=new p.kn4)})}raycast(t){var e=this;return(0,G.A)(function*(){const i=[];for(const o of e.core.models.list.values())if(t.snappingClasses&&t.snappingClasses.length>0){const a=yield o.raycastWithSnapping(t);if(a&&a.length>0)i.push(a[0]);else{const l=yield o.raycast(t);l&&i.push(l)}}else{const a=yield o.raycast(t);a&&i.push(a)}if(yield Promise.all(i),0===i.length)return;let s=i[0],n=s.distance;for(let o=1;o<i.length;o++)i[o].distance<n&&(n=i[o].distance,s=i[o]);return s})()}getPositions(t){var e=this;return(0,G.A)(function*(){const i=[],s=function(){var o=(0,G.A)(function*(a,l){const c=yield a.getPositions(l);for(const h of c)i.push(h)});return function(l,c){return o.apply(this,arguments)}}(),n=[];for(const o in t){const a=e.core.models.list.get(o);a&&n.push(s(a,Array.from(t[o])))}return yield Promise.all(n),i})()}getBBoxes(t){var e=this;return(0,G.A)(function*(){const i=[],s=function(){var o=(0,G.A)(function*(a,l){const c=yield a.getBoxes(l);if(c)for(const h of c)i.push(h)});return function(l,c){return o.apply(this,arguments)}}(),n=[];for(const o in t){const a=e.core.models.list.get(o);a&&n.push(s(a,Array.from(t[o])))}return yield Promise.all(n),i})()}highlight(t,e){var i=this;return(0,G.A)(function*(){yield i.forEachModel(e,"highlight",t)})()}getData(t,e){var i=this;return(0,G.A)(function*(){const s={};for(const[n,o]of Object.entries(t)){const a=i.list.get(n);if(!a)continue;if(0===o.size){s[n]=[];continue}const l=yield a.getItemsData([...o],e);s[n]=l}return s})()}resetHighlight(t){var e=this;return(0,G.A)(function*(){yield e.forEachModel(t,"resetHighlight")})()}forEachModel(t,e,...i){var s=this;return(0,G.A)(function*(){const n={};if(t)for(const a in t)n[a]=Array.from(t[a]);else for(const a of s.core.models.list.keys())n[a]=void 0;const o=[];for(const a in n){const l=s.core.models.list.get(a);if(l){const h=l[e](n[a],...i);o.push(h)}}yield Promise.all(o)})()}guidsToModelIdMap(t){var e=this;return(0,G.A)(function*(){const i={};for(const[s,n]of e.list){const o=(yield n.getLocalIdsByGuids([...t])).filter(a=>null!==a);i[s]=new Set(o)}return i})()}modelIdMapToGuids(t){var e=this;return(0,G.A)(function*(){const i=[];for(const[s,n]of Object.entries(t)){const o=e.list.get(s);if(!o)continue;const a=(yield o.getGuidsByLocalIds([...n])).filter(l=>null!==l);i.push(...a)}return i})()}applyBaseCoordinateSystem(t,e){const i=new p.kn4;return e&&i.copy(e.clone()).invert(),i.multiply(this.baseCoordinationMatrix),t.applyMatrix4(i),i}};y(Sa,"uuid","fef46874-46a3-461b-8c44-2922ab77c806");let ft=Sa;function Ad(r,t){return r[t]|r[t+1]<<8|r[t+2]<<16}class Id{constructor(t,e={}){const{pixelsPerMeter:i=.1}=e;this.pixelsPerMeter=i,this.renderer=t}cull(t){var e=this;return(0,G.A)(function*(){t=function Md(r){const t=new Set;return r.traverse(e=>{e.isMesh&&t.add(e)}),Array.from(t)}(t);const{renderer:i,pixelsPerMeter:s}=e,n=new p.Pq0,o=new p.qUd,a=new p.NRn,l=new p.nWS(1,1);a.makeEmpty(),t.forEach(D=>{a.expandByObject(D)}),a.getSize(n);const c=Math.min(i.capabilities.maxTextureSize,8192),h=Math.ceil(n.x/s),u=Math.ceil(n.z/s),f=Math.ceil(h/c),d=Math.ceil(u/c);l.setSize(Math.ceil(h/f),Math.ceil(u/d)),o.rotation.x=-Math.PI/2,o.far=a.max.y-a.min.y+o.near,o.position.y=a.max.y+o.near;const _=new p.Z58,m=new Map,w=new Map,g=[];for(let D=0;D<t.length;D++){const B=t[D];m.set(B,B.material),w.set(B,B.parent);const E=new Od;E.objectId=D,g.push(E),B.material=E,_.add(B)}const v=i.getClearColor(new p.Q1f),T=i.getClearAlpha(),C=i.getRenderTarget(),S=i.autoClear;i.autoClear=!0,i.setClearColor(0,0),i.setRenderTarget(l);const M=new Uint8Array(l.width*l.height*4),A=new Set,O=n.x/f,I=n.z/d;for(let D=0;D<f;D++)for(let B=0;B<d;B++){const E=a.min.x+O*D,x=a.min.z+I*B;o.position.set((E+(E+O))/2,a.max.y,(x+(x+I))/2);const ct=O/2,Z=I/2;o.left=-ct,o.right=ct,o.top=Z,o.bottom=-Z,o.updateProjectionMatrix(),i.render(_,o);const at=yield i.readRenderTargetPixelsAsync(l,0,0,l.width,l.height,M);for(let F=0,V=at.length;F<V;F+=4){if(0===at[F+3])continue;const nt=Ad(at,F);A.add(t[nt])}}for(const D of t){D.material=m.get(D);const B=w.get(D);B?B.add(D):_.remove(D)}i.setClearColor(v,T),i.setRenderTarget(C),i.autoClear=S;for(const D of g)D.dispose();return l.dispose(),Array.from(A)})()}}class Od extends p.BKk{get objectId(){return this._objectId}set objectId(t){this._objectId=t,function Ed(r,t){t.x=(255&r)/255,t.y=(r>>8&255)/255,t.z=(r>>16&255)/255,t.w=1}(t,this.uniforms.objectId.value)}constructor(t){super({glslVersion:p.Wdf,blending:p.XIg,uniforms:{objectId:{value:new p.IUQ}},vertexShader:"\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\t\t\t\tlayout(location = 0) out vec4 out_id;\n\t\t\t\tuniform vec4 objectId;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tout_id = objectId;\n\n\t\t\t\t}\n\t\t\t"}),this._objectId=0,this.setValues(t)}}const zd=new p.Pq0(0,1,0),Ea=new p.Pq0;function Aa(r){return r.delta(Ea).normalize(),Math.abs(Ea.dot(zd))>=1-1e-16}function mr(r,t){const{start:e,end:i}=t,s=r.points;let n=!1,o=!1;for(let a=0;a<3;a++){const l=s[a];if(!n&&e.distanceToSquared(l)<=1e-16&&(n=!0),!o&&i.distanceToSquared(l)<=1e-16&&(o=!0),n&&o)return!0}return n&&o}const Qe=new p.cZY;function Ma(r,t,e=!1,i=[]){let s=[[0,1]];for(let n=0,o=t.length;n<o;n++){const l=t[n];s[n][1]=l[0],s.push([l[1],1])}e&&([t,s]=[s,t]);for(let n=0,o=s.length;n<o;n++){const{start:a,end:l}=r;Qe.start.lerpVectors(a,l,s[n][0]),Qe.end.lerpVectors(a,l,s[n][1]),i.push(new Float32Array([Qe.start.x,Qe.start.y,Qe.start.z,Qe.end.x,Qe.end.y,Qe.end.z]))}return i}const Dd=new p.Pq0(0,1,0),Oa=new p.Pq0,za=new p.Pq0,Ws=new p.Pq0,Xs=new p.lMl;function*Da(r,t=[],e={}){const{projectionDirection:i=Dd,thresholdAngle:s=1,iterationTime:n=30}=e,a=Math.pow(10,4),l=Math.cos(p.cj9.DEG2RAD*s),c=r.getIndex(),h=r.getAttribute("position"),u=c?c.count:h.count,f=[0,0,0],d=["a","b","c"],_=new Array(3),m={};let w=performance.now();for(let g=0;g<u;g+=3){performance.now()-w>n&&(yield,w=performance.now()),c?(f[0]=c.getX(g),f[1]=c.getX(g+1),f[2]=c.getX(g+2)):(f[0]=g,f[1]=g+1,f[2]=g+2);const{a:v,b:T,c:C}=Xs;if(v.fromBufferAttribute(h,f[0]),T.fromBufferAttribute(h,f[1]),C.fromBufferAttribute(h,f[2]),Xs.getNormal(Ws),_[0]=`${Math.round(v.x*a)},${Math.round(v.y*a)},${Math.round(v.z*a)}`,_[1]=`${Math.round(T.x*a)},${Math.round(T.y*a)},${Math.round(T.z*a)}`,_[2]=`${Math.round(C.x*a)},${Math.round(C.y*a)},${Math.round(C.z*a)}`,_[0]!==_[1]&&_[1]!==_[2]&&_[2]!==_[0])for(let S=0;S<3;S++){const M=(S+1)%3,A=_[S],O=_[M],I=Xs[d[S]],D=Xs[d[M]],B=`${A}_${O}`,E=`${O}_${A}`;if(E in m&&m[E]){const L=m[E].normal,x=Ws.dot(L)<=l;let N=!1;if(null!==i){let Y=i.dot(Ws);Y=Math.abs(Y)<1e-10?0:Y;let q=i.dot(L);q=Math.abs(q)<1e-10?0:q,N=Math.sign(Y)!==Math.sign(q)}if(x||N){const Y=new p.cZY;Y.start.copy(I),Y.end.copy(D),t.push(Y)}m[E]=null}else B in m||(m[B]={index0:f[S],index1:f[M],normal:Ws.clone()})}}for(const g in m)if(m[g]){const{index0:v,index1:T}=m[g];Oa.fromBufferAttribute(h,v),za.fromBufferAttribute(h,T);const C=new p.cZY;C.start.copy(Oa),C.end.copy(za),t.push(C)}return t}const Ks=new p.cZY;function ka(r,t,e,i=[]){return r.bvhcast(t,e,{intersectsTriangles:(s,n)=>{if(function Ld(r,t){const e=["a","b","c"];let i=0;for(let s=0;s<3;s++)for(let n=0;n<3;n++)kd(r[e[s]],t[e[n]])&&i++;return i>=2}(s,n)||(s.needsUpdate&&s.update(),n.needsUpdate&&n.update(),Math.abs(s.plane.normal.dot(n.plane.normal))>.999999))return!1;s.intersectsTriangle(n,Ks,!0)&&!mr(s,Ks)&&!mr(n,Ks)&&i.push(Ks.clone())}}),i}function kd(r,t){return r.distanceTo(t)<1e-10}function gr(r){La(r);let t=[];return r.traverse(e=>{e.geometry&&e.visible&&t.push(e)}),t}const La=r=>{if(void 0===r)return;const t=[...r.children];for(const e of t)void 0===e?r.children.splice(r.children.indexOf(e),1):La(e)},Qs=new p.kn4,Na=new p.kn4;class Nd{constructor(){this.projectionDirection=new p.Pq0(0,1,0),this.thresholdAngle=50,this.iterationTime=30}getEdges(...t){const e=this.iterationTime;this.iterationTime=1/0;const i=this.getEdgesGenerator(...t).next().value;return this.iterationTime=e,i}*getEdgesGenerator(t,e=[],i=null){const{projectionDirection:s,thresholdAngle:n,iterationTime:o}=this;if(t.isObject3D){const a=gr(t);let l=null;s&&(l=new p.Pq0);let c=performance.now();for(let h=0;h<a.length;h++){c-performance.now()>o&&(yield);const u=a[h];l&&(Na.copy(u.matrixWorld).invert(),l.copy(s).transformDirection(Na).normalize());const f=yield*Da(u.geometry,[],{projectionDirection:l,thresholdAngle:n,iterationTime:o});Ba(f,u.matrixWorld);for(let d=0;d<f.length;d++)e.push(f[d]);if(null!==i)for(let d=0;d<f.length;d++)i.push(u)}return e}return yield*Da(t,e,{projectionDirection:s,thresholdAngle:n,iterationTime:o})}getIntersectionEdges(...t){const e=this.iterationTime;this.iterationTime=1/0;const i=this.getIntersectionEdgesGenerator(...t).next().value;return this.iterationTime=e,i}*getIntersectionEdgesGenerator(t,e=[],i=null){const{iterationTime:s}=this;if(t.isObject3D){const n=gr(t),o=new Map;let a=performance.now();for(let l=0;l<n.length;l++){performance.now()-a>s&&(yield,a=performance.now());const h=n[l].geometry;if(!o.has(h)){const u=h.boundsTree||new Ke(h,{maxLeafSize:1});o.set(h,u)}}a=performance.now();for(let l=0;l<n.length;l++)for(let c=l;c<n.length;c++){performance.now()-a>s&&(yield,a=performance.now());const h=n[l],u=n[c],f=o.get(h.geometry),d=o.get(u.geometry);Qs.copy(h.matrixWorld).invert().multiply(u.matrixWorld);const _=ka(f,d,Qs,[]);Ba(_,h.matrixWorld);for(let m=0;m<_.length;m++)e.push(_[m]);if(null!==i)for(let m=0;m<_.length;m++)i.push(h)}return e}{let n;return t.isBufferGeometry?n=t.boundsTree||new Ke(t,{maxLeafSize:1}):(n=t,t=n.geometry),Qs.identity(),ka(n,n,Qs,e)}}}function Ba(r,t,e=1e-6){for(let i=0;i<r.length;i++){const s=r[i];s.applyMatrix4(t),s.start.y+=e,s.end.y+=e}}class Bd extends ra{get lines(){return this.primitiveBuffer}constructor(t,e){super(e),this.primitiveBuffer=t,this.primitiveBufferStride=1,this.heightOffset=e.heightOffset??1e3,this.init(e)}writePrimitiveBounds(t,e,i){const{primitiveBuffer:s,heightOffset:n}=this,{start:o,end:a}=s[t];e[i+0]=Math.min(o.x,a.x),e[i+1]=Math.min(o.y,a.y),e[i+2]=Math.min(o.z,a.z),e[i+3]=Math.max(o.x,a.x),e[i+4]=Math.max(o.y,a.y)+n,e[i+5]=Math.max(o.z,a.z)}getRootRanges(){return[{offset:0,count:this.primitiveBuffer.length}]}}const Rd=new p.Pq0(0,1,0),fi=new p.Zcv,_r=new p.Pq0,Fa=new p.Pq0;function Fd(r,t,e){r.needsUpdate&&r.update(),fi.copy(r.plane),fi.normal.dot(Rd)<0&&(fi.normal.multiplyScalar(-1),fi.constant*=-1);const i=fi.distanceToPoint(t.start),s=fi.distanceToPoint(t.end),n=Math.abs(i)<1e-16,o=i<0,a=s<0;if(t.delta(Fa).normalize(),Math.abs(fi.normal.dot(Fa))<1e-16)return!(n||!o||(e.copy(t),0));if(o&&a)return e.copy(t),!0;if(!o&&!a)return!1;{const l=p.cj9.mapLinear(0,i,s,0,1);if(t.at(l,_r),o)return e.start.copy(t.start),e.end.copy(_r),!0;if(a)return e.end.copy(t.end),e.start.copy(_r),!0}return!1}const yr=new p.Zcv,Js=new p.Pq0,wr=new p.Pq0,Je=new le,Pe=new p.cZY,Ne=new p.cZY,ki=new p.Pq0,Ua=new p.Pq0,$a=new p.Pq0;function Ud(r,t,e=new p.cZY){if(Je.copy(t),Je.a.y=0,Je.b.y=0,Je.c.y=0,Je.update(),Pe.copy(r),Pe.start.y=0,Pe.end.y=0,Je.getArea()<=1e-16)return null;const i=Pe.distance();Pe.delta(ki).divideScalar(i),Ua.copy(ki).cross(Je.plane.normal).normalize(),yr.setFromNormalAndCoplanarPoint(Ua,Pe.start);let s=0;const{points:n}=Je;for(let o=0;o<3;o++){const a=n[o],l=n[(o+1)%3],c=yr.distanceToPoint(a),h=yr.distanceToPoint(l),u=Math.abs(c)<1e-16,f=Math.abs(h)<1e-16;let d=!1;if(!u&&!f&&c*h<0&&(Js.lerpVectors(a,l,c/(c-h)),d=!0),(d&&!f||u)&&(u&&!d&&Js.copy(a),0===s?Ne.start.copy(Js):Ne.end.copy(Js),s++,2===s))break}if(2===s){if(Ne.delta($a).normalize(),ki.dot($a)<0){const f=Ne.start;Ne.start=Ne.end,Ne.end=f}const o=0,a=wr.subVectors(Pe.end,Pe.start).dot(ki),l=wr.subVectors(Ne.start,Pe.start).dot(ki),c=wr.subVectors(Ne.end,Pe.start).dot(ki);return a<=l||c<=o?null:(r.at(Math.max(o,l)/i,e.start),r.at(Math.min(a,c)/i,e.end),e)}return null}const ja=new p.Pq0,Ha=new p.Pq0,qa=new p.Pq0;function jd(r,t,e){const i=function Hd(r,t){r.delta(ja),Ha.subVectors(t.start,r.start),qa.subVectors(t.end,r.start);const e=ja.length();let i=Ha.length()/e,s=qa.length()/e;return i=Math.min(Math.max(i,0),1),s=Math.min(Math.max(s,0),1),Math.abs(i-s)<=1e-16?null:[i,s]}(r,t);return!!i&&(Ga(i,e),!0)}function Ga(r,t){let[e,i]=r,s=0,n=t.length;for(;s<n;){const l=s+n>>>1;t[l][0]<=e?s=l+1:n=l}let o=Math.max(0,s-1),a=0;for(let l=o,c=t.length;l<c;l++){const[h,u]=t[l];if(e<=u&&i>=h)e=Math.min(h,e),i=Math.max(u,i),a++;else{if(!(e>=h))break;o=l+1}}t.splice(o,a,[e,i])}const qd=new p.Pq0(0,1,0),tn=new p.cZY,Ya=new p.cZY,ge=new le;function Yd(r,t,e,i,s=null){const{geometry:n,matrixWorld:o,material:a}=e,l=a.side,c=o.determinant()<0,h=r.lines;r.bvhcast(t,o,{intersectsRanges:(u,f,d,_)=>{s&&(s.candidates+=f*_);for(let m=d,w=_+d;m<w;m++){let g=3*m+0,v=3*m+1,T=3*m+2;n.index&&(g=n.index.getX(g),v=n.index.getX(v),T=n.index.getX(T));const{a:C,b:S,c:M}=ge;if(C.fromBufferAttribute(n.attributes.position,g).applyMatrix4(o),S.fromBufferAttribute(n.attributes.position,v).applyMatrix4(o),M.fromBufferAttribute(n.attributes.position,T).applyMatrix4(o),ge.needsUpdate=!0,ge.update(),l!==p.$EB&&ge.plane.normal.dot(qd)!==c==(l===p.hsX)){s&&(s.backFaceCulled+=f);continue}const A=Math.max(C.y,S.y,M.y),O=Math.min(C.y,S.y,M.y),I=ge.plane.normal;let D=I.x,B=I.y,E=I.z,L=ge.plane.constant;B<0&&(D=-D,B=-B,E=-E,L=-L);for(let x=u,N=f+u;x<N;x++){const Y=h[x],q=Math.min(Y.start.y,Y.end.y),ct=Math.max(Y.start.y,Y.end.y);if(A<=q){s&&s.yBoundsCulled++;continue}const Z=Y.end.x-Y.start.x,at=Y.end.z-Y.start.z,F=Z*Z+at*at;if(F>1e-20){const it=1/Math.sqrt(F),J=Z*it,_t=at*it,St=-_t,dt=J,rt=C.x-Y.start.x,ht=C.z-Y.start.z,pt=S.x-Y.start.x,xt=S.z-Y.start.z,Et=M.x-Y.start.x,P=M.z-Y.start.z,W=rt*J+ht*_t,H=pt*J+xt*_t,k=Et*J+P*_t,z=1/it,R=Math.min(W,H,k);if(Math.max(W,H,k)<0||R>z){s&&s.xzBoundsCulled++;continue}const K=rt*St+ht*dt,U=pt*St+xt*dt,tt=Et*St+P*dt,lt=Math.min(K,U,tt),et=Math.max(K,U,tt);if(lt>0||et<0){s&&s.xzBoundsCulled++;continue}}if(D*Y.start.x+B*Y.start.y+E*Y.start.z+L>=0&&D*Y.end.x+B*Y.end.y+E*Y.end.z+L>=0)s&&s.planeTrimCulled++;else if(mr(ge,Y))s&&s.triangleEdgeCulled++;else{if(ct<O)tn.copy(Y);else if(!Fd(ge,Y,tn)){s&&s.planeTrimCulled++;continue}tn.distance()<1e-10?s&&s.distThresholdCulled++:Ud(tn,ge,Ya)?(s&&s.used++,jd(Y,Ya,i[x])):s&&s.noOverlapCulled++}}}}})}ge.update=()=>{ge.plane.setFromCoplanarPoints(...ge.points)};let Li=!1;const en={},ns={};let pi=null,vr=0,br=0;const bt={get enabled(){return Li},set enabled(r){Li=r},reset(){for(const r in en)delete en[r];for(const r in ns)delete ns[r];pi=null,vr=0,br=0},setStat(r,t){ns[r]=t},startTotal(){Li&&(br=performance.now())},startStep(r){Li&&(null!==pi&&this.endStep(),pi=r,vr=performance.now())},endStep(){if(!Li||null===pi)return;const r=performance.now()-vr;en[pi]=r,pi=null},printSummary(){if(!Li)return;null!==pi&&this.endStep();const r=performance.now()-br;console.log("\n=== Projection Summary ==="),console.log(`Total time: ${r.toFixed(1)}ms\n`);for(const[t,e]of Object.entries(en)){const i=(e/r*100).toFixed(1);console.log(` ${t}: ${e.toFixed(1)}ms (${i}%)`)}if(Object.keys(ns).length>0){console.log("\n--- Stats ---");for(const[t,e]of Object.entries(ns))console.log(` ${t}: ${e}`)}console.log("")}},be=1e-5,sn=1e-16,nn=1e-16;function Wd(r,t,e,i,s){r.bvhcast(t,e.matrixWorld,{intersectsRanges:(n,o,a,l)=>{i._edgeOffsets.push(n),i._edgeCounts.push(o),i._meshOffsets.push(a),i._meshCounts.push(l),i._meshIndex.push(s),i.groupCount++}})}let rs=null;function Tr(){return(Tr=(0,G.A)(function*(){return null===rs&&(rs=new bn.uV1,yield rs.init()),rs})).apply(this,arguments)}function Pr(){return Pr=(0,G.A)(function*(r,t,e,i,s=null){const n=yield function Jd(){return Tr.apply(this,arguments)}();r._edgeOffsets&&(r.edgeOffsets=new Uint32Array(r._edgeOffsets),r.edgeCounts=new Uint32Array(r._edgeCounts),r.meshOffsets=new Uint32Array(r._meshOffsets),r.meshCounts=new Uint32Array(r._meshCounts),r.meshIndex=new Uint32Array(r._meshIndex),r._edgeOffsets=null,r._edgeCounts=null,r._meshOffsets=null,r._meshCounts=null,r._meshIndex=null);const o=(0,$.$_z)(function Zd(r){const t=new Float32Array(6*r.length);for(let e=0;e<r.length;e++){const i=r[e];t[6*e+0]=i.start.x,t[6*e+1]=i.start.y,t[6*e+2]=i.start.z,t[6*e+3]=i.end.x,t[6*e+4]=i.end.y,t[6*e+5]=i.end.z}return t}(e.lines),"float");bt.enabled&&console.log("Number of meshes:",t.length),bt.enabled&&console.log("Group count:",r.groupCount);const a=[];{let _=0;for(;_<t.length;){let m=_,w=0;for(;m<t.length;){const g=t[m].geometry,v=g.index?g.index.count/3:g.attributes.position.count/3;if(m>_&&(m-_>=1e3||w+v>1e5))break;w+=v,m++}a.push({start:_,end:m}),_=m}}bt.enabled&&console.log(`Split ${t.length} meshes into ${a.length} batches`);let l=0,c=0,h=0,u=0,f=0;for(let _=0;_<a.length;_++){const{start:m,end:w}=a[_],g=w-m;bt.enabled&&console.log(`Processing batch ${_+1}/${a.length} (meshes ${m}-${w-1})`);let v=0,T=0;const C=[];for(let rt=m;rt<w;rt++){const ht=t[rt].geometry;C.push(T/3),v+=ht.attributes.position.array.length,T+=ht.index.array.length}const S=new Float32Array(v),M=new Uint32Array(T);let A=0,O=0,I=0;for(let rt=m;rt<w;rt++){const ht=t[rt].geometry,pt=ht.attributes.position.array,xt=ht.index.array;S.set(pt,A),A+=pt.length;for(let Et=0;Et<xt.length;Et++)M[O+Et]=xt[Et]+I;O+=xt.length,I+=ht.attributes.position.count}const D=new Float32Array(16*g);for(let rt=m;rt<w;rt++)D.set(t[rt].matrixWorld.elements,16*(rt-m));const B=[];for(let rt=0;rt<r.groupCount;rt++){const ht=r.meshIndex[rt];if(ht>=m&&ht<w){const pt=ht-m;B.push({edgeOffset:r.edgeOffsets[rt],edgeCount:r.edgeCounts[rt],triOffset:C[pt]+r.meshOffsets[rt],triCount:r.meshCounts[rt],meshIdx:pt})}}if(0===B.length){bt.enabled&&console.log(` Batch ${_+1}: no groups, skipping`);continue}const E=new Uint32Array(5*B.length);for(let rt=0;rt<B.length;rt++){const ht=B[rt],pt=5*rt;E[pt+0]=ht.edgeOffset,E[pt+1]=ht.edgeCount,E[pt+2]=ht.triOffset,E[pt+3]=ht.triCount,E[pt+4]=ht.meshIdx}let L=0;for(let rt=0;rt<B.length;rt++)L+=B[rt].edgeCount*B[rt].triCount;s&&(s.candidates+=L);let x=Math.min(Math.ceil(.1*L),2e6),N=Math.max(x,1e4);bt.enabled&&console.log(` Batch ${_+1}: ${B.length} groups, ${v/3} vertices, ${T/3} triangles, ${L} pairs, buffer for ${N} overlaps`);const Y=performance.now(),q=(0,$.$_z)(S,"float"),ct=(0,$.$_z)(M,"uint"),Z=(0,$.$_z)(D,"float"),at=(0,$.$_z)(E,"uint");let F=(0,$.$_z)(new Uint32Array([0]),"uint").toAtomic(),V=(0,$.$_z)(new Float32Array(3*N),"float");u+=performance.now()-Y;const nt=performance.now(),it=(0,$.Fn)(()=>{const ht=$.cGD.mul(5),pt=at.element(ht),xt=at.element(ht.add(1)),Et=at.element(ht.add(2)),P=at.element(ht.add(3)),H=at.element(ht.add(4)).mul(16),k=(0,$.pBV)(Z.element(H),Z.element(H.add(1)),Z.element(H.add(2)),Z.element(H.add(3)),Z.element(H.add(4)),Z.element(H.add(5)),Z.element(H.add(6)),Z.element(H.add(7)),Z.element(H.add(8)),Z.element(H.add(9)),Z.element(H.add(10)),Z.element(H.add(11)),Z.element(H.add(12)),Z.element(H.add(13)),Z.element(H.add(14)),Z.element(H.add(15)));(0,$.FZF)({start:(0,$.Whr)(0),end:P.toInt(),type:"int",condition:"<",name:"triIdx"},({triIdx:z})=>{const X=Et.add(z.toUint()).mul(3),K=ct.element(X),U=ct.element(X.add(1)),tt=ct.element(X.add(2)),lt=(0,$.eR5)(q.element(K.mul(3)),q.element(K.mul(3).add(1)),q.element(K.mul(3).add(2))),et=(0,$.eR5)(q.element(U.mul(3)),q.element(U.mul(3).add(1)),q.element(U.mul(3).add(2))),ut=(0,$.eR5)(q.element(tt.mul(3)),q.element(tt.mul(3).add(1)),q.element(tt.mul(3).add(2))),vt=k.mul((0,$.lnd)(lt,(0,$.fVC)(1))).xyz,wt=k.mul((0,$.lnd)(et,(0,$.fVC)(1))).xyz,$t=k.mul((0,$.lnd)(ut,(0,$.fVC)(1))).xyz,mi=wt.sub(vt),ye=$t.sub(vt),Ee=(0,$.$An)(mi,ye),kt=Ee.dot(Ee);(0,$.If)(kt.lessThan((0,$.fVC)(4*sn*sn)),()=>{(0,$.wPH)()}),(0,$.If)(Ee.y.lessThan(0),()=>{(0,$.wPH)()});const Fi=(0,$.T9B)(vt.y,(0,$.T9B)(wt.y,$t.y));(0,$.FZF)({start:(0,$.Whr)(0),end:xt.toInt(),type:"int",condition:"<",name:"edgeIdx"},({edgeIdx:ds})=>{const we=pt.add(ds.toUint()),Ve=we.mul(6),ce=(0,$.eR5)(o.element(Ve),o.element(Ve.add(1)),o.element(Ve.add(2))),he=(0,$.eR5)(o.element(Ve.add(3)),o.element(Ve.add(4)),o.element(Ve.add(5))),Jr=(0,$.jkA)(ce.y,he.y);(0,$.If)(Fi.lessThanEqual(Jr),()=>{(0,$.wPH)()});const gi=(0,$.S86)(Ee),ei=gi.dot(vt).negate(),_i=gi.y.lessThan(0),cc=(0,$.Ltv)(_i,gi.negate(),gi),hc=(0,$.Ltv)(_i,ei.negate(),ei),fn=cc.dot(ce).add(hc),uc=cc.dot(he).add(hc),fs=fn.lessThan(0),pn=uc.lessThan(0),Mg=(0,$.tnl)(fn).lessThan((0,$.fVC)(be)),Ig=fs.not().and(pn.not()),dc=uc.sub(fn),ii=(0,$.tnl)(dc).lessThan((0,$.fVC)(be)),Og=ii.and(Mg.or(fs.not()));(0,$.If)(Og,()=>{(0,$.wPH)()}),(0,$.If)(Ig.and(ii.not()),()=>{(0,$.wPH)()});const zg=fn.negate().div(dc),Vi=(0,$.jhA)(ce,he,zg),to=(0,$.eR5)((0,$.Ltv)(ii.or(fs),ce.x,Vi.x),(0,$.Ltv)(ii.or(fs),ce.y,Vi.y),(0,$.Ltv)(ii.or(fs),ce.z,Vi.z)),eo=(0,$.eR5)((0,$.Ltv)(ii.or(pn),he.x,Vi.x),(0,$.Ltv)(ii.or(pn),he.y,Vi.y),(0,$.Ltv)(ii.or(pn),he.z,Vi.z)),fc=eo.sub(to),Dg=fc.dot(fc);(0,$.If)(Dg.lessThan((0,$.fVC)(be)),()=>{(0,$.wPH)()});const pc=ce.sub(vt),mc=ce.sub(wt),gc=ce.sub($t),_c=he.sub(vt),yc=he.sub(wt),wc=he.sub($t),kg=pc.dot(pc).lessThanEqual((0,$.fVC)(be)),Lg=mc.dot(mc).lessThanEqual((0,$.fVC)(be)),Ng=gc.dot(gc).lessThanEqual((0,$.fVC)(be)),Bg=_c.dot(_c).lessThanEqual((0,$.fVC)(be)),Rg=yc.dot(yc).lessThanEqual((0,$.fVC)(be)),Fg=wc.dot(wc).lessThanEqual((0,$.fVC)(be)),Vg=kg.or(Lg).or(Ng),Ug=Bg.or(Rg).or(Fg),$g=Vg.and(Ug);(0,$.If)($g,()=>{(0,$.wPH)()});const xe=(0,$.eR5)(vt.x,(0,$.fVC)(0),vt.z),Ae=(0,$.eR5)(wt.x,(0,$.fVC)(0),wt.z),Me=(0,$.eR5)($t.x,(0,$.fVC)(0),$t.z),si=(0,$.eR5)(to.x,(0,$.fVC)(0),to.z),jg=(0,$.eR5)(eo.x,(0,$.fVC)(0),eo.z),io=(0,$.eR5)(ce.x,(0,$.fVC)(0),ce.z),so=(0,$.eR5)(he.x,(0,$.fVC)(0),he.z).sub(io),vc=so.dot(so);(0,$.If)(vc.lessThan((0,$.fVC)(be)),()=>{(0,$.wPH)()});const no=vc.sqrt(),Hg=Ae.sub(xe),qg=Me.sub(xe),ro=(0,$.$An)(Hg,qg),Gg=ro.dot(ro);(0,$.If)(Gg.lessThanEqual((0,$.fVC)(4*sn*sn)),()=>{(0,$.wPH)()});const oo=jg.sub(si),bc=oo.dot(oo);(0,$.If)(bc.lessThan((0,$.fVC)(be)),()=>{(0,$.wPH)()});const xc=bc.sqrt(),Ui=oo.div(xc),Cc=so.div(no),Yg=(0,$.S86)(ro),ao=(0,$.$An)(Ui,Yg),Ue=(0,$.fVC)(0).toVar(),$e=(0,$.fVC)(0).toVar(),je=(0,$.fVC)(0).toVar(),He=(0,$.fVC)(0).toVar(),te=(0,$.Hdr)(0).toVar(),ps=ao.dot(xe.sub(si)),mn=ao.dot(Ae.sub(si)),gn=(0,$.tnl)(ps).lessThan((0,$.fVC)(nn)),Tc=(0,$.tnl)(mn).lessThan((0,$.fVC)(nn)),Pc=gn.not().and(Tc.not()).and(ps.mul(mn).lessThan(0));(0,$.If)(Pc,()=>{const re=ps.div(ps.sub(mn)),Ie=(0,$.jhA)(xe.x,Ae.x,re),ni=(0,$.jhA)(xe.z,Ae.z,re);(0,$.If)(te.equal(0),()=>{Ue.assign(Ie),$e.assign(ni)}).Else(()=>{je.assign(Ie),He.assign(ni)}),te.addAssign(1)}).ElseIf(gn,()=>{(0,$.If)(te.equal(0),()=>{Ue.assign(xe.x),$e.assign(xe.z)}).Else(()=>{je.assign(xe.x),He.assign(xe.z)}),te.addAssign(1)});const lo=mn,_n=ao.dot(Me.sub(si)),co=Tc,Sc=(0,$.tnl)(_n).lessThan((0,$.fVC)(nn)),Ec=co.not().and(Sc.not()).and(lo.mul(_n).lessThan(0));(0,$.If)(te.lessThan(2),()=>{(0,$.If)(Ec,()=>{const re=lo.div(lo.sub(_n)),Ie=(0,$.jhA)(Ae.x,Me.x,re),ni=(0,$.jhA)(Ae.z,Me.z,re);(0,$.If)(te.equal(0),()=>{Ue.assign(Ie),$e.assign(ni)}).Else(()=>{je.assign(Ie),He.assign(ni)}),te.addAssign(1)}).ElseIf(co.and(Pc.not()).and(gn.not()),()=>{(0,$.If)(te.equal(0),()=>{Ue.assign(Ae.x),$e.assign(Ae.z)}).Else(()=>{je.assign(Ae.x),He.assign(Ae.z)}),te.addAssign(1)})});const ho=_n,Ac=ps,Mc=Sc,Zg=gn,Wg=Mc.not().and(Zg.not()).and(ho.mul(Ac).lessThan(0));(0,$.If)(te.lessThan(2),()=>{(0,$.If)(Wg,()=>{const re=ho.div(ho.sub(Ac)),Ie=(0,$.jhA)(Me.x,xe.x,re),ni=(0,$.jhA)(Me.z,xe.z,re);(0,$.If)(te.equal(0),()=>{Ue.assign(Ie),$e.assign(ni)}).Else(()=>{je.assign(Ie),He.assign(ni)}),te.addAssign(1)}).ElseIf(Mc.and(Ec.not()).and(co.not()),()=>{(0,$.If)(te.equal(0),()=>{Ue.assign(Me.x),$e.assign(Me.z)}).Else(()=>{je.assign(Me.x),He.assign(Me.z)}),te.addAssign(1)})}),(0,$.If)(te.notEqual(2),()=>{(0,$.wPH)()});const Xg=(0,$.eR5)(Ue,(0,$.fVC)(0),$e),Kg=(0,$.eR5)(je,(0,$.fVC)(0),He).sub(Xg).dot(Ui),uo=(0,$.eR5)(Ue,(0,$.fVC)(0),$e).toVar(),fo=(0,$.eR5)(je,(0,$.fVC)(0),He).toVar();(0,$.If)(Kg.lessThan(0),()=>{const re=Ue,Ie=$e;uo.x.assign(je),uo.z.assign(He),fo.x.assign(re),fo.z.assign(Ie)});const Ic=(0,$.fVC)(0),Oc=xc,zc=uo.sub(si).dot(Ui),Dc=fo.sub(si).dot(Ui),Qg=Oc.lessThanEqual(zc).or(Dc.lessThanEqual(Ic));(0,$.If)(Qg,()=>{(0,$.wPH)()});const Jg=(0,$.T9B)(Ic,zc),t_=(0,$.jkA)(Oc,Dc),e_=si.add(Ui.mul(Jg)),i_=si.add(Ui.mul(t_)),s_=e_.sub(io).dot(Cc).div(no),n_=i_.sub(io).dot(Cc).div(no),kc=(0,$.T9B)((0,$.fVC)(0),(0,$.jkA)((0,$.fVC)(1),s_)),Lc=(0,$.T9B)((0,$.fVC)(0),(0,$.jkA)((0,$.fVC)(1),n_)),r_=(0,$.tnl)(Lc.sub(kc));(0,$.If)(r_.lessThanEqual((0,$.fVC)(nn)),()=>{(0,$.wPH)()});const Nc=(0,$.Rnb)(F.element(0),1);(0,$.If)(Nc.lessThan((0,$.Hdr)(N)),()=>{const re=Nc.mul(3);V.element(re).assign(we.toFloat()),V.element(re.add(1)).assign(kc),V.element(re.add(2)).assign(Lc)})})})})().compute(B.length);f+=performance.now()-nt;const J=performance.now();yield n.computeAsync(it),l+=performance.now()-J;const _t=performance.now(),St=yield n.getArrayBufferAsync(F.value),dt=new Uint32Array(St)[0];if(s&&(s.used+=Math.min(dt,N)),bt.enabled&&console.log(` Batch ${_+1}: ${dt} overlaps found (capacity: ${N})`),dt>N&&bt.enabled&&console.warn(` WARNING: Overlap buffer overflow! ${dt} > ${N}. Some occlusion data lost.`),dt>0){const rt=yield n.getArrayBufferAsync(V.value),ht=new Float32Array(rt);c+=performance.now()-_t;const pt=performance.now(),xt=Math.min(dt,N);for(let Et=0;Et<xt;Et++){const P=3*Et,W=Math.round(ht[P]);Ga([ht[P+1],ht[P+2]],i[W])}h+=performance.now()-pt,bt.enabled&&console.log(` Processed ${xt} overlaps into hiddenOverlapMap`)}else c+=performance.now()-_t}n.dispose(),rs=null,bt.enabled&&(console.log(`WebGPU timing breakdown (total: ${(u+f+l+c+h).toFixed(1)}ms):`),console.log(` Buffer creation: ${u.toFixed(1)}ms`),console.log(` Shader build: ${f.toFixed(1)}ms`),console.log(` GPU compute: ${l.toFixed(1)}ms`),console.log(` Readback: ${c.toFixed(1)}ms`),console.log(` CPU merge: ${h.toFixed(1)}ms`))}),Pr.apply(this,arguments)}const ef=new p.Pq0(0,1,0);function Za(r,t=null){const e=new Float32Array(6*r.length);let i=0;for(let o=0,a=r.length;o<a;o++){const l=r[o];e[i++]=l[0],e[i++]=0,e[i++]=l[2],e[i++]=l[3],e[i++]=0,e[i++]=l[5]}const s=new p.LoY,n=new p.THS(e,3,!0);if(s.setAttribute("position",n),t){const o=new Float32Array(2*r.length);for(let a=0,l=t.length;a<l;a++)o[2*a]=t[a],o[2*a+1]=t[a];s.setAttribute("group",new p.THS(o,1))}return s}class sf{constructor(t,e=!0){this.meshes=gr(t),this.bvhs=new Map,this.visibleEdges=[],this.hiddenEdges=[],this.visibleGroupIndices=[],this.hiddenGroupIndices=[],this.groupKeyToIndex=null,this.hasGroups=!1,this.iterationTime=30,this.useWebGPU=e}reset(){this.visibleEdges.length=0,this.hiddenEdges.length=0,this.visibleGroupIndices.length=0,this.hiddenGroupIndices.length=0,this.groupKeyToIndex=null,this.hasGroups=!1}getVisibleLineGeometry(){return Za(this.visibleEdges,this.groupKeyToIndex?this.visibleGroupIndices:null)}getHiddenLineGeometry(){return Za(this.hiddenEdges,this.groupKeyToIndex?this.hiddenGroupIndices:null)}getGroupKeys(){return this.groupKeyToIndex?Object.fromEntries(this.groupKeyToIndex):{}}addEdges(...t){const e=this.iterationTime;this.iterationTime=1/0;const i=this.addEdgesGenerator(...t).next().value;return this.iterationTime=e,i}*addEdgesGenerator(t,e={}){const{meshes:i,bvhs:s,visibleEdges:n,hiddenEdges:o,iterationTime:a}=this;let l=performance.now();bt.startStep("Building mesh BVH");for(let g=0;g<i.length;g++){performance.now()-l>a&&(yield,l=performance.now());const T=i[g].geometry;if(!s.has(T)){const C=T.boundsTree||new Ke(T);s.set(T,C)}}let c=0;for(let g=0;g<i.length;g++){const v=i[g].geometry;c+=v.index?v.index.count/3:v.attributes.position.count/3}const h={};for(let g=0;g<t.length;g++)h[g]=[];bt.startStep("Building line BVH");const u=new Bd(t,{maxLeafSize:2,strategy:2});bt.startStep("BVHcast overlaps"),l=performance.now();const f={candidates:0,backFaceCulled:0,yBoundsCulled:0,xzBoundsCulled:0,triangleEdgeCulled:0,planeTrimCulled:0,distThresholdCulled:0,noOverlapCulled:0,used:0,totalEdges:t.length,totalTriangles:c},d=this.useWebGPU,_={};d&&(_._edgeOffsets=[],_._edgeCounts=[],_._meshOffsets=[],_._meshCounts=[],_._meshIndex=[],_.groupCount=0);for(let g=0;g<i.length;g++){performance.now()-l>a&&(e.onProgress&&e.onProgress(g,i.length),yield,l=performance.now());const v=i[g];d?Wd(u,s.get(v.geometry),v,_,g):Yd(u,s.get(v.geometry),v,h,f)}if(d){let g=!1;for(function tf(r,t,e,i){return Pr.apply(this,arguments)}(_,i,u,h,f).then(()=>{g=!0});!g;)yield}const m=f.totalEdges*f.totalTriangles;if(bt.setStat("Total edges",f.totalEdges.toLocaleString()),bt.setStat("Total triangles",f.totalTriangles.toLocaleString()),bt.setStat("Brute-force pairs (edges \xd7 triangles)",m.toLocaleString()),bt.setStat("BVH candidate pairs",f.candidates.toLocaleString()),m>0&&bt.setStat("BVH reduction",(f.candidates/m*100).toFixed(3)+"% of brute-force"),f.candidates>0){const g=f.candidates,v=T=>(T/g*100).toFixed(2)+"%";d||(bt.setStat("Rejected: back-face culling",f.backFaceCulled.toLocaleString()+" ("+v(f.backFaceCulled)+")"),bt.setStat("Rejected: Y-bounds (tri below edge)",f.yBoundsCulled.toLocaleString()+" ("+v(f.yBoundsCulled)+")"),bt.setStat("Rejected: XZ-bounds (no 2D overlap)",f.xzBoundsCulled.toLocaleString()+" ("+v(f.xzBoundsCulled)+")"),bt.setStat("Rejected: edge lies on triangle",f.triangleEdgeCulled.toLocaleString()+" ("+v(f.triangleEdgeCulled)+")"),bt.setStat("Rejected: line above tri plane",f.planeTrimCulled.toLocaleString()+" ("+v(f.planeTrimCulled)+")"),bt.setStat("Rejected: trimmed edge too small",f.distThresholdCulled.toLocaleString()+" ("+v(f.distThresholdCulled)+")"),bt.setStat("Rejected: no projected overlap",f.noOverlapCulled.toLocaleString()+" ("+v(f.noOverlapCulled)+")")),bt.setStat("Producing overlaps",f.used.toLocaleString()+" ("+v(f.used)+")")}bt.startStep("Converting overlaps to lines");const w=this.hasGroups;for(let g=0;g<t.length;g++){performance.now()-l>a&&(yield,l=performance.now());const v=t[g],T=h[g],C=n.length,S=o.length;if(Ma(v,T,!1,n),Ma(v,T,!0,o),w){const M=v.groupIndex;for(let A=C;A<n.length;A++)this.visibleGroupIndices.push(M);for(let A=S;A<o.length;A++)this.hiddenGroupIndices.push(M)}}}}class nf{constructor(){this.iterationTime=30,this.angleThreshold=50,this.includeIntersectionEdges=!0,this.useWebGPU=!0}generateAsync(t,e={}){return new Promise((i,s)=>{const{signal:n}=e,o=this.generate(t,e);!function a(){if(n&&n.aborted)return void s(new Error("ProjectionGenerator: Process aborted via AbortSignal."));const l=o.next();l.done?i(l.value):requestAnimationFrame(a)}()})}*generate(t,e){const{iterationTime:i,angleThreshold:s,includeIntersectionEdges:n}=this,{onProgress:o=()=>{},visibilityCuller:a=null,groupFn:l=null}=e;if(bt.reset(),bt.startTotal(),t.isBufferGeometry&&(t=new p.eaF(t)),a){bt.startStep("Visibility culling");let d=!1;for(a.cull(t).then(_=>{(t=new p.Z58).children=_,d=!0});!d;)yield}const c=new Nd;c.iterationTime=i,c.thresholdAngle=s,c.projectionDirection.copy(ef),bt.startStep("Generating candidate edges"),o("Generating candidate edges");let h=[],u=l?[]:null;if(yield*c.getEdgesGenerator(t,h,u),n&&(bt.startStep("Generating intersection edges"),o("Generating intersection edges"),yield*c.getIntersectionEdgesGenerator(t,h,u)),bt.startStep("Pre-filtering edges"),o("Pre-filtering edges"),u){const d=[],_=[];for(let m=0;m<h.length;m++)Aa(h[m])||(d.push(h[m]),_.push(u[m]));h=d,u=_}else h=h.filter(d=>!Aa(d));yield;const f=new sf(t,this.useWebGPU);if(f.iterationTime=i,l&&u){const d=new Map;for(let _=0;_<h.length;_++){const m=l(u[_]);d.has(m)||d.set(m,d.size),h[_].groupIndex=d.get(m)}f.groupKeyToIndex=d,f.hasGroups=!0}return o("Building BVH & computing overlaps"),yield*f.addEdgesGenerator(h,{onProgress:o?(d,_)=>{o("Building BVH & computing overlaps",d/_,f)}:null}),bt.printSummary(),f}}new p.cZY,new p.cZY,new p.Pq0;const Wa=class mo extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"onDisposed",new Q),y(this,"generator",new nf),y(this,"cullerPixelsPerMeter",.05),y(this,"projectionDirection",new p.Pq0(0,-1,0)),y(this,"nearPlane",-1/0),y(this,"farPlane",1/0),this.components.add(mo.uuid,this),this.generator.includeIntersectionEdges=!1}get(t,e,i){var s=this;return(0,G.A)(function*(){const n=s.components.get(ft),o=new p.YJl,a=new Map;for(const[S,M]of Object.entries(t)){const A=n.list.get(S);if(!A)continue;const I=(yield A.getItemsIdsWithGeometry()).filter(B=>M.has(B));if(0===I.length)continue;const D=yield A.getItemsGeometry(I);for(const B in D){const E=D[B];for(const L of E){if(!(L.positions&&L.indices&&L.transform&&L.representationId))continue;const x=L.representationId;if(!a.has(x)){const q=new p.LoY;q.setAttribute("position",new p.qtW(L.positions,3)),L.normals&&q.setAttribute("normal",new p.qtW(L.normals,3)),q.setIndex(Array.from(L.indices)),a.set(x,q)}const N=a.get(x),Y=new p.eaF(N);Y.applyMatrix4(L.transform),Y.applyMatrix4(A.object.matrixWorld),Y.updateWorldMatrix(!0,!0),Y.userData._edgeProjectorModelId=S,Y.userData._edgeProjectorLocalId=L.localId,o.add(Y)}}}const l=s.projectionDirection.clone().normalize(),c=new p.Pq0(0,-1,0),h=(new p.PTz).setFromUnitVectors(l,c),u=(new p.kn4).makeRotationFromQuaternion(h),f=u.clone().invert();for(const S of o.children)S.applyMatrix4(u),S.updateWorldMatrix(!1,!1);if(o.traverse(S=>{const M=S;if(M.geometry&&!M.geometry.boundsTree){const A=M.geometry.index?M.geometry.index.count:M.geometry.attributes.position.count;M.geometry.groups.forEach(O=>{O.count===1/0&&(O.count=A-O.start)}),M.geometry.boundsTree=new Ke(M.geometry,{maxLeafSize:1,strategy:2})}}),s.nearPlane!==-1/0||s.farPlane!==1/0){const S=new p.NRn,M=[];for(const A of o.children){const O=A;O.geometry&&(S.setFromObject(O),(S.max.y<s.nearPlane||S.min.y>s.farPlane)&&M.push(O))}for(const A of M)o.remove(A)}const m=new Id(e.renderer.three,{pixelsPerMeter:s.cullerPixelsPerMeter}),w=yield s.generator.generateAsync(o,{visibilityCuller:m,groupFn:S=>`${S.userData._edgeProjectorModelId??"unknown"}:${S.userData._edgeProjectorLocalId??0}`,onProgress:i?.onProgress}),g=w.getVisibleLineGeometry(),v=w.getHiddenLineGeometry();g.applyMatrix4(f),v.applyMatrix4(f);const T=w.getGroupKeys(),C={};for(const[S,M]of Object.entries(T)){const A=S.lastIndexOf(":"),O=S.substring(0,A),I=Number(S.substring(A+1));C[M]={modelId:O,localId:I}}for(const S of a.values())S.dispose();return{visible:g,hidden:v,groups:C}})()}dispose(){this.onDisposed.trigger(mo.uuid),this.onDisposed.reset()}};y(Wa,"uuid","f2e76c3a-8b1d-4d5e-9a3f-7c6b2d4e8f1a");let rf=Wa;class of{constructor(){y(this,"wasm",{path:"",absolute:!1,logLevel:ji.LogLevel.LOG_LEVEL_OFF}),y(this,"webIfc",{COORDINATE_TO_ORIGIN:!0}),y(this,"autoSetWasm",!0),y(this,"customLocateFileHandler",null)}}y(class go extends At{constructor(t){super(t),y(this,"onDisposed",new Q),y(this,"onIfcStartedLoading",new Q),y(this,"onIfcImporterInitialized",new Q),y(this,"onSetup",new Q),y(this,"settings",new of),y(this,"webIfc",new ji.IfcAPI),y(this,"enabled",!0),this.components.add(go.uuid,this)}dispose(){this.webIfc=null,this.onDisposed.trigger(go.uuid),this.onDisposed.reset()}setup(t){var e=this;return(0,G.A)(function*(){e.settings={...e.settings,...t},e.settings.autoSetWasm&&(yield e.autoSetWasm()),e.onSetup.trigger()})()}load(t,e,i,s){var n=this;return(0,G.A)(function*(){const o=n.components.get(ft);if(!o.initialized)throw new Error("You need to initialize fragments first.");n.settings.autoSetWasm&&(yield n.autoSetWasm()),o.core.settings.autoCoordinate=e;const a=new ot.$X;a.wasm.path=n.settings.wasm.path,a.wasm.absolute=n.settings.wasm.absolute,a.webIfcSettings=n.settings.webIfc,n.onIfcImporterInitialized.trigger(a),s?.instanceCallback&&s.instanceCallback(a);const l=yield a.process({...s?.processData,bytes:t});return yield o.core.load(l,{modelId:i,userData:s?.userData})})()}readIfcFile(t){var e=this;return(0,G.A)(function*(){const{path:i,absolute:s,logLevel:n}=e.settings.wasm;return e.webIfc.SetWasmPath(i,s),yield e.webIfc.Init(e.settings.customLocateFileHandler||void 0),n&&e.webIfc.SetLogLevel(n),e.webIfc.OpenModel(t,e.settings.webIfc)})()}cleanUp(){try{this.webIfc.Dispose()}catch{console.log("Web-ifc wasn't disposed.")}this.webIfc=null,this.webIfc=new ji.IfcAPI}autoSetWasm(){var t=this;return(0,G.A)(function*(){const e=yield fetch(`https://unpkg.com/@thatopen/components@${Ar.release}/package.json`);if(!e.ok)return void console.warn("Couldn't get openbim-components package.json. Set wasm settings manually.");const i=yield e.json();"web-ifc"in i.peerDependencies?(t.settings.wasm.path=`https://unpkg.com/web-ifc@${i.peerDependencies["web-ifc"]}/`,t.settings.wasm.absolute=!0):console.warn("Couldn't get web-ifc from peer dependencies in openbim-components. Set wasm settings manually.")})()}},"uuid","a659add7-1418-4771-a0d6-7d4d438e4624");const Xa=class Fc extends At{constructor(t){super(t),y(this,"enabled",!0),this.components.add(Fc.uuid,this)}set(t,e){var i=this;return(0,G.A)(function*(){const s=i.components.get(ft),n=[];if(e)for(const[o,a]of Object.entries(e)){const l=s.list.get(o);l&&n.push(l.setVisible([...a],t))}else for(const o of s.list.values())n.push(o.setVisible(void 0,t));yield Promise.all(n),yield s.core.update(!0)})()}isolate(t){var e=this;return(0,G.A)(function*(){yield Promise.all([e.set(!1),e.set(!0,t)])})()}toggle(t){var e=this;return(0,G.A)(function*(){const i=[],s=e.components.get(ft);for(const[n,o]of Object.entries(t)){const a=s.list.get(n);a&&i.push(a.toggleVisible([...o]))}yield Promise.all(i),yield s.core.update(!0)})()}getVisibilityMap(t,e){var i=this;return(0,G.A)(function*(){const s=[],n=[],o=i.components.get(ft);if(e)for(const c of e){const h=o.list.get(c);h&&(s.push(h.modelId),n.push(h.getItemsByVisibility(t)))}else for(const c of o.list.values())s.push(c.modelId),n.push(c.getItemsByVisibility(t));const a=yield Promise.all(n),l={};for(const[c,h]of s.entries())l[h]=a[c];return l})()}};y(Xa,"uuid","dd9ccf2d-8a21-4821-b7f6-2949add16a29");let af=Xa;const Ka=class _o extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"onDisposed",new Q),y(this,"list",new ot.PG),this.components.add(_o.uuid,this)}dispose(t=!0){this.list.clear(),this.onDisposed.trigger(_o.uuid),t&&(this.onDisposed.reset(),this.list.eventsEnabled=!1,this.list.dispose())}get(){const t=new p.NRn;for(const e of this.list)t.union(e);return t}addFromModelIdMap(t){var e=this;return(0,G.A)(function*(){const i=e.components.get(ft),s=new p.NRn;for(const[n,o]of Object.entries(t)){const a=i.list.get(n);if(!a)continue;const l=yield a.getMergedBox([...o]);s.union(l)}e.list.add(s)})()}addFromModels(t){const e=this.components.get(ft);for(const[i,s]of e.list)t&&!t.some(n=>n.test(i))||this.list.add(s.box)}getCenter(t){var e=this;return(0,G.A)(function*(){e.list.clear(),yield e.addFromModelIdMap(t);const i=e.get();e.list.clear();const s=new p.Pq0;return i.getCenter(s),s})()}getCameraOrientation(t){var e=this;return(0,G.A)(function*(i,s=1){const n=e.components.get(ft);e.list.clear();for(const[u,f]of n.list)e.list.add(f.box);const o=e.get();e.list.clear();const a=new p.Pq0;o.getCenter(a);const l=new p.Pq0;o.getSize(l);const c=Math.max(l.x,l.y,l.z)*s,h=new p.Pq0;switch(i){case"front":default:h.set(a.x,a.y,a.z+c);break;case"back":h.set(a.x,a.y,a.z-c);break;case"left":h.set(a.x-c,a.y,a.z);break;case"right":h.set(a.x+c,a.y,a.z);break;case"top":h.set(a.x,a.y+c,a.z);break;case"bottom":h.set(a.x,a.y-c,a.z)}return{position:h,target:a}}).apply(this,arguments)}};y(Ka,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let Qa=Ka;class lf{constructor(t,e){y(this,"name","Query"),y(this,"customData",{}),y(this,"_components"),y(this,"_queries",[]),y(this,"_aggregation","exclusive"),y(this,"result",null),y(this,"cache",!0),y(this,"serializeQueryParameters",i=>{var s;return{categories:null==(s=i.categories)?void 0:s.map(o=>o.source),attributes:i.attributes?{aggregation:i.attributes.aggregation,queries:i.attributes.queries.map(this.serializeAttributeQuery)}:void 0,relation:i.relation?{name:i.relation.name,query:i.relation.query?this.serializeQueryParameters(i.relation.query):void 0}:void 0}}),y(this,"deserializeQueryParameters",i=>{var s;return{categories:null==(s=i.categories)?void 0:s.map(o=>new RegExp(o)),attributes:i.attributes?{aggregation:i.attributes.aggregation,queries:i.attributes.queries.map(this.deserializeAttributeQuery)}:void 0,relation:i.relation?{name:i.relation.name,query:i.relation.query?this.deserializeQueryParameters(i.relation.query):void 0}:void 0}}),this._components=t,this.queries=e}set queries(t){this._queries=t,this.clearCache()}get queries(){return this._queries}set aggregation(t){t!==this._aggregation&&this.clearCache(),this._aggregation=t}get aggregation(){return this._aggregation}test(t){var e=this;return(0,G.A)(function*(){const{modelIds:i,force:s}={force:!1,...t};if(e.result&&!s)return e.result;const o=yield e._components.get(os).getItems(e.queries,{modelIds:i,aggregation:e.aggregation});return e.cache&&(e.result=o),o})()}clearCache(){this.result=null}serializeAttributeQuery(t){let e;return e=Array.isArray(t.value)?t.value.map(s=>s.source):t.value instanceof RegExp?t.value.source:t.value,{name:t.name.source,value:e,type:t.type instanceof RegExp?t.type.source:t.type,negate:t.negate,itemIds:t.itemIds}}toJSON(){return{guid:this._components.get(os).list.getKey(this)??ie.create(),name:this.name,customData:this.customData,queries:this.queries.map(this.serializeQueryParameters),aggregation:this.aggregation,cache:this.cache}}deserializeAttributeQuery(t){let e;return e=Array.isArray(t.value)?t.value.map(s=>new RegExp(s)):"string"==typeof t.value?new RegExp(t.value):t.value,{name:new RegExp(t.name),value:e,type:t.type?new RegExp(t.type):void 0,negate:t.negate,itemIds:t.itemIds}}fromJSON(t){return this.name=t.name,this.customData=t.customData,this.aggregation=t.aggregation,this.cache=t.cache,this.queries=t.queries.map(this.deserializeQueryParameters),this}}const Ja=class Vc extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"list",new ot.jp),t.add(Vc.uuid,this)}getItems(t,e){var i=this;return(0,G.A)(function*(){let s;if(e){const{modelIds:c,items:h}=e;if(h){const u=Object.keys(h);u.length>0&&(s=u.map(f=>new RegExp(`^${f}$`)))}else c&&(s=c)}const n=e?.aggregation??"exclusive",o=i.components.get(ft),a=yield Promise.all(t.map(function(){var c=(0,G.A)(function*(h){const u={};return yield Promise.all(Array.from(o.list).map(function(){var f=(0,G.A)(function*([d,_]){var m;if(s&&!s.some(v=>v.test(d)))return;const w=null==(m=e?.items)?void 0:m[d],g=yield _.getItemsByQuery(h,{localIds:w?[...w]:void 0});u[d]=new Set(g)});return function(d){return f.apply(this,arguments)}}())),u});return function(h){return c.apply(this,arguments)}}()));return"inclusive"===n?Rt.join(a):Rt.intersect(a)})()}create(t,e){const i=new lf(this.components,e);return this.list.set(t,i),i}addFromCategories(t){var e=this;return(0,G.A)(function*(){const i=new Set,s=e.components.get(ft);for(const[n,o]of s.list){if(t&&!t.some(c=>c.test(n)))continue;const a=(yield o.getItemsWithGeometryCategories()).filter(c=>null!==c),l=new Set(a);for(const c of l)e.list.has(c)||(e.create(c,[{categories:[new RegExp(`^${c}$`)]}]),i.add(c))}return[...i]})()}import(t){const{data:e}=t,i=[];if(!e)return i;for(const s of e){const n=this.create(s.guid,[]);n.fromJSON(s),i.push(n)}return i}export(){const t=[];for(const[e,i]of this.list.entries()){const n={...i.toJSON(),name:e};t.push(n)}return{data:t}}};y(Ja,"uuid","0da7ad77-f734-42ca-942f-a074adfd1e3a");let os=Ja;y(class Uc extends At{constructor(t){var e;super(t),e=this,y(this,"enabled",!0),y(this,"onDisposed",new Q),y(this,"list",new ot.jp),y(this,"defaultSaveFunction",s=>"value"in s.Name?s.Name.value:null),y(this,"onBeforeFragmentsDispose",function(){var s=(0,G.A)(function*(n){const{key:o,value:a}=n,l=yield a.getLocalIds(),c={[o]:new Set(l)};e.removeItems(c)});return function(n){return s.apply(this,arguments)}}()),t.add(Uc.uuid,this),this.setupEvents(),t.get(ft).list.onBeforeDelete.add(this.onBeforeFragmentsDispose)}setupEvents(){this.list.onBeforeDelete.add(({value:t})=>t.dispose())}getClassificationGroups(t){let e=this.list.get(t);return e||(e=new ot.jp,this.list.set(t,e)),e}getModelItems(t,e,i){const{map:s}=this.getGroupData(t,e);let n=s[i];return n||(n=new Set,s[i]=n),n}getGroupData(t,e){const i=this.components.get(os),s=this.getClassificationGroups(t);let n=s.get(e);return n||(n={map:{},get:()=>new Promise(o=>{if(n)if(n.query){const{name:a,config:l}=n.query,c=i.list.get(a);if(!c)throw new Error("Classifier: the query name associated with the group doesn't exist in the ItemsFinder component");c.test(l).then(h=>{if(!n)return void o({});const u=Rt.join([h,n.map]);o(u)})}else o(n.map);else o({})})},s.set(e,n)),n}aggregateItems(t,e,i){var s=this;return(0,G.A)(function*(){const n=i?.data??void 0,o=i?.aggregationCallback??s.defaultSaveFunction,a=s.components.get(ft),c=yield s.components.get(os).getItems([e],{modelIds:i?.modelIds});for(const[h,u]of Object.entries(c)){const f=a.list.get(h);if(!f)continue;const d=(m,...w)=>{const g=s.getModelItems(t,m,h);for(const v of w)g.add(v)},_=yield f.getItemsData([...u],n);for(const m of _)o(m,d)}})()}addGroupItems(t,e,i){const{map:s}=this.getGroupData(t,e);Rt.add(s,i)}setGroupQuery(t,e,i){this.getGroupData(t,e).query=i}find(t){var e=this;return(0,G.A)(function*(){const i=[];for(const[n,o]of Object.entries(t)){const a=[],l=e.list.get(n);if(!l)continue;for(const h of o){const u=l.get(h);if(!u)continue;const f=yield u.get();a.push(f)}const c=Rt.join(a);i.push(c)}return Rt.intersect(i)})()}aggregateItemRelations(t,e,i,s){var n=this;return(0,G.A)(function*(){const o=s?.attribute??"Name",a={relations:{[i]:{attributes:!0,relations:!1}}};yield n.aggregateItems(t,e,{modelIds:s?.modelIds,data:a,aggregationCallback:(l,c)=>{if(!l?.[o])return;const h=l[o];if(!("value"in h))return;const u=l[i];if(Array.isArray(u))for(const f of u)"value"in f._localId&&c(h.value,f._localId.value)}})})()}byIfcBuildingStorey(t){var e=this;return(0,G.A)(function*(){yield e.aggregateItemRelations(t?.classificationName??"Storeys",{categories:[/BUILDINGSTOREY/]},"ContainsElements",{modelIds:t?.modelIds})})()}byCategory(t){var e=this;return(0,G.A)(function*(){const s=yield e.components.get(os).addFromCategories(t?.modelIds);for(const n of s)e.setGroupQuery(t?.classificationName??"Categories",n,{name:n})})()}dispose(){this.list.clear(),this.components.get(ft).list.onBeforeDelete.remove(this.onBeforeFragmentsDispose),this.onDisposed.trigger()}removeItems(t,e){if(e&&e.classificationName){const i=this.list.get(e.classificationName);if(!i||e.groupName&&!i.get(e.groupName))return;for(const[,s]of i)Rt.remove(s.map,t);return}for(const[,i]of this.list.entries())for(const[,s]of i)Rt.remove(s.map,t)}byModel(t){var e=this;return(0,G.A)(function*(){const i=e.components.get(ft),s=t?.classificationName??"Models";for(const[n,o]of i.list){if(t&&t.modelIds&&!t.modelIds.some(c=>c.test(n)))continue;const a=yield o.getItemsIdsWithGeometry(),l={[n]:new Set(a)};e.getGroupData(s,n),e.addGroupItems(s,n,l)}})()}},"uuid","e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7");const tl=class $c{constructor(t,e){if(y(this,"enabled",!0),y(this,"components"),y(this,"onDisposed",new Q),y(this,"mouse"),y(this,"world"),y(this,"debugMode",!1),y(this,"_renderTarget"),y(this,"_renderTargetSize",new p.I9Y),y(this,"_debugCanvas"),y(this,"_debugContainer"),y(this,"_idMaterial"),y(this,"_depthMaterial"),y(this,"_normalMaterial"),y(this,"_originalMaterials",new Map),y(this,"_hiddenLods",[]),!e.renderer)throw new Error("A renderer is needed for the FastModelPicker to work!");this.world=e,this.mouse=new Yo(e.renderer.three.domElement),this.components=t,this._idMaterial=this.buildIdMaterial(),this._depthMaterial=this.buildDepthMaterial(),this._normalMaterial=this.buildNormalMaterial(),this.setupRenderTarget()}getModelAt(t){var e=this;return(0,G.A)(function*(){const i=yield e.runIdPass(t);return i?i.modelId:null})()}getItemAt(t){var e=this;return(0,G.A)(function*(){const i=yield e.runIdPass(t);if(!i)return null;const n=e.components.get(ft).list.get(i.modelId);if(!n)return null;const o=yield n.getLocalIdsFromItemIds([i.itemId]),a=o?.[0];return null==a?null:{modelId:i.modelId,localId:a,itemId:i.itemId}})()}getPointAt(t){var e=this;return(0,G.A)(function*(){if(!e.enabled||!e._renderTarget||!e.world.renderer)return null;const i=e.components.get(ft);if(!i.initialized||0===i.list.size)return null;e.renderDepthPass();const s=t??e.mouse.position,n=e.readPixelAt(s);if(!n||0===n[0]&&0===n[1]&&0===n[2]&&0===n[3])return null;const o=function hf(r){return 255/256*(r[0]/255/16777216+r[1]/255/65536+r[2]/255/256+r[3]/255)}(n);return o>=.999999?null:function uf(r,t,e){const i=new p.Pq0(r.x,r.y,2*t-1);return i.unproject(e),i}(s,o,e.world.camera.three)})()}getNormalAt(t){var e=this;return(0,G.A)(function*(){if(!e.enabled||!e._renderTarget||!e.world.renderer)return null;const i=e.components.get(ft);if(!i.initialized||0===i.list.size)return null;e.renderNormalPass();const n=e.readPixelAt(t??e.mouse.position);if(!n||0===n[3])return null;const c=new p.Pq0(n[0]/255*2-1,n[1]/255*2-1,n[2]/255*2-1);return c.lengthSq()<1e-8?null:c.normalize()})()}getFullPick(t){var e=this;return(0,G.A)(function*(){const i=yield e.getItemAt(t);if(!i)return null;const s=yield e.getPointAt(t);if(!s)return null;const n=yield e.getNormalAt(t),o=s.distanceTo(e.world.camera.three.position);return{...i,point:s,normal:n,distance:o}})()}setDebugMode(t){this.debugMode=t,t?this.setupDebugCanvas():this.removeDebugCanvas()}dispose(){this.mouse.dispose(),this.removeDebugCanvas(),this._idMaterial.dispose(),this._depthMaterial.dispose(),this._normalMaterial.dispose(),this._renderTarget&&this._renderTarget.dispose(),this._renderTarget=void 0,this._originalMaterials.clear(),this._hiddenLods.length=0,this.onDisposed.trigger(),this.onDisposed.reset()}runIdPass(t){var e=this;return(0,G.A)(function*(){if(!e.enabled||!e._renderTarget||!e.world.renderer)return null;const i=e.components.get(ft);if(!i.initialized||0===i.list.size)return null;const s=e.applyIdMaterial();if(0===s.size)return e.restoreOriginalMaterials(),null;const n=t??e.mouse.position;e.renderIdPass(s,n),e.restoreOriginalMaterials(),e.debugMode&&e._debugCanvas&&e.updateDebugCanvas();const o=e.readPixelAt(e._renderTarget,n);if(!o)return null;const a=o[0];if(0===a)return null;const l=s.get(a);if(!l)return null;const c=o[1]<<16|o[2]<<8|o[3];return 0===c?null:{modelId:l,itemId:c-1}})()}applyIdMaterial(){const t=this.components.get(ft),e=new Map;let i=1;for(const[s,n]of t.list){if(i>$c.MAX_MODELS)break;const o=i;i+=1;let a=!1;n.object.traverse(l=>{if(!(l instanceof p.eaF))return;const c=l.geometry;if(!c)return;if(!c.attributes||!c.attributes.id)return void(l.visible&&(this._hiddenLods.push(l),l.visible=!1));this._originalMaterials.set(l,l.material);const h=l.material,u=Array.isArray(h)?h.length:1;l.material=new Array(u).fill(this._idMaterial),a=!0}),a&&e.set(o,s)}return e}renderIdPass(t,e){this.renderPickPass(t,this._renderTarget,this._idMaterial,e)}renderPickPass(t,e,i,s){const n=this.world.renderer.three,o=this.world.scene.three,a=this.world.camera.three,l=this.components.get(ft),c=n.clippingPlanes??[];i.clippingPlanes=c,i.clipping=c.length>0;const h=n.getRenderTarget(),u=n.autoClear,f=n.getClearColor(new p.Q1f),d=n.getClearAlpha(),_=n.getScissorTest(),m=n.getScissor(new p.IUQ);n.setRenderTarget(e),n.setClearColor(0,0),n.autoClear=!1,n.setScissorTest(!1),n.clear(!0,!0,!1);const g=e.width,v=e.height,T=Math.floor(.5*(s.x+1)*g),C=Math.floor(.5*(s.y+1)*(v-1)),M=Math.max(0,Math.min(g-4,T-2)),A=Math.max(0,Math.min(v-4,C-2)),O=n.getPixelRatio();n.setScissor(M/O,A/O,4/O,4/O),n.setScissorTest(!0);const I=new Map;for(const[x,N]of l.list)I.set(x,N.object);const D=new Set(I.values()),B=new Map;o.traverse(x=>{x!==o&&x.isMesh&&((x=>{let N=x;for(;N;){if(D.has(N))return!0;N=N.parent}return!1})(x)||(B.set(x,x.visible),x.visible=!1))});const L=new Map;for(const x of I.values())L.set(x,x.visible),x.visible=!1;for(const[x,N]of t){const Y=I.get(N);Y&&(Y.visible=!0,i.uniforms.modelByte.value=x,n.render(o,a),Y.visible=!1)}for(const[x,N]of L)x.visible=N;for(const[x,N]of B)x.visible=N;n.setScissorTest(_),n.setScissor(m),n.setRenderTarget(h),n.autoClear=u,n.setClearColor(f,d)}renderWithTileMaterial(t){const e=this.world.renderer.three,i=this.world.scene.three,s=this.world.camera.three,n=this.components.get(ft),o=e.clippingPlanes??[];t.clippingPlanes=o,t.clipping=o.length>0;const a=e.getRenderTarget(),l=e.autoClear,c=e.getClearColor(new p.Q1f),h=e.getClearAlpha(),u=new Map,f=[];for(const[,w]of n.list)w.object.traverse(g=>{if(!(g instanceof p.eaF))return;const v=g.geometry;if(!v)return;if(!v.attributes||!v.attributes.id)return void(g.visible&&(f.push(g),g.visible=!1));if(!g.visible)return;u.set(g,g.material);const T=g.material,C=Array.isArray(T)?T.length:1;g.material=new Array(C).fill(t)});const d=new Set;for(const[,w]of n.list)d.add(w.object);const m=new Map;i.traverse(w=>{w!==i&&w.isMesh&&((w=>{let g=w;for(;g;){if(d.has(g))return!0;g=g.parent}return!1})(w)||(m.set(w,w.visible),w.visible=!1))}),e.setRenderTarget(this._renderTarget),e.setClearColor(0,0),e.autoClear=!1,e.clear(!0,!0,!1),e.render(i,s);for(const[w,g]of u)w.material=g;for(const w of f)w.visible=!0;for(const[w,g]of m)w.visible=g;e.setRenderTarget(a),e.autoClear=l,e.setClearColor(c,h)}renderDepthPass(){this.renderWithTileMaterial(this._depthMaterial)}renderNormalPass(){this.renderWithTileMaterial(this._normalMaterial)}restoreOriginalMaterials(){for(const[t,e]of this._originalMaterials)t.material=e;this._originalMaterials.clear();for(const t of this._hiddenLods)t.visible=!0;this._hiddenLods.length=0}readPixelAt(t,e){let i,s;t instanceof p.nWS?(i=t,s=e):(i=this._renderTarget,s=t);const n=this.world.renderer.three,o=this._renderTargetSize,a=Math.floor(.5*(s.x+1)*o.x),l=Math.floor(.5*(s.y+1)*(o.y-1)),c=Math.max(0,Math.min(o.x-1,a)),h=Math.max(0,Math.min(o.y-1,l)),u=new Uint8Array(4);return n.readRenderTargetPixels(i,c,h,1,1,u),u}buildIdMaterial(){return new p.BKk({uniforms:{modelByte:{value:1}},vertexShader:"\n attribute vec4 id;\n varying vec4 vId;\n #if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n #endif\n void main() {\n vId = id;\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n #if NUM_CLIPPING_PLANES > 0\n vClipPosition = -mvPosition.xyz;\n #endif\n gl_Position = projectionMatrix * mvPosition;\n }\n ",fragmentShader:"\n precision highp float;\n uniform float modelByte;\n varying vec4 vId;\n #if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];\n #endif\n void main() {\n #if NUM_CLIPPING_PLANES > 0\n for (int i = 0; i < NUM_CLIPPING_PLANES; i++) {\n vec4 plane = clippingPlanes[i];\n if (dot(vClipPosition, plane.xyz) > plane.w) discard;\n }\n #endif\n gl_FragColor = vec4(modelByte / 255.0, vId.y / 255.0, vId.z / 255.0, vId.w / 255.0);\n }\n ",side:p.$EB})}buildDepthMaterial(){return new p.BKk({uniforms:{},vertexShader:"\n #if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n #endif\n void main() {\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n #if NUM_CLIPPING_PLANES > 0\n vClipPosition = -mvPosition.xyz;\n #endif\n gl_Position = projectionMatrix * mvPosition;\n }\n ",fragmentShader:"\n #if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];\n #endif\n void main() {\n #if NUM_CLIPPING_PLANES > 0\n for (int i = 0; i < NUM_CLIPPING_PLANES; i++) {\n vec4 plane = clippingPlanes[i];\n if (dot(vClipPosition, plane.xyz) > plane.w) discard;\n }\n #endif\n float v = gl_FragCoord.z;\n vec4 r = vec4(\n fract(v * 16777216.0),\n fract(v * 65536.0),\n fract(v * 256.0),\n v\n );\n r.yzw -= r.xyz * (1.0 / 256.0);\n gl_FragColor = r * (256.0 / 255.0);\n }\n ",side:p.$EB})}buildNormalMaterial(){return new p.BKk({uniforms:{},vertexShader:"\n varying vec3 vWorldNormal;\n #if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n #endif\n void main() {\n vWorldNormal = normalize(\n (modelMatrix * vec4(normal, 0.0)).xyz\n );\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n #if NUM_CLIPPING_PLANES > 0\n vClipPosition = -mvPosition.xyz;\n #endif\n gl_Position = projectionMatrix * mvPosition;\n }\n ",fragmentShader:"\n varying vec3 vWorldNormal;\n #if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];\n #endif\n void main() {\n #if NUM_CLIPPING_PLANES > 0\n for (int i = 0; i < NUM_CLIPPING_PLANES; i++) {\n vec4 plane = clippingPlanes[i];\n if (dot(vClipPosition, plane.xyz) > plane.w) discard;\n }\n #endif\n vec3 n = normalize(vWorldNormal);\n if (!gl_FrontFacing) n = -n;\n gl_FragColor = vec4(n * 0.5 + 0.5, 1.0);\n }\n ",side:p.$EB})}setupRenderTarget(){const e=this.world.renderer.three.getSize(new p.I9Y);this._renderTargetSize.copy(e),this._renderTarget=new p.nWS(e.x,e.y,{format:p.GWd,type:p.OUM,minFilter:p.hxR,magFilter:p.hxR,depthBuffer:!0}),this.debugMode&&this.setupDebugCanvas(),this.world.renderer.onResize.add(s=>{this._renderTargetSize.copy(s),this._renderTarget.setSize(s.x,s.y),this._debugCanvas&&(this._debugCanvas.width=s.x,this._debugCanvas.height=s.y)})}setupDebugCanvas(){if(this._debugCanvas)return;const t=this.world.renderer.three.getSize(new p.I9Y);this._debugContainer=document.createElement("div"),this._debugContainer.style.position="fixed",this._debugContainer.style.top="10px",this._debugContainer.style.right="10px",this._debugContainer.style.width="300px",this._debugContainer.style.height="300px",this._debugContainer.style.border="2px solid #fff",this._debugContainer.style.backgroundColor="#000",this._debugContainer.style.zIndex="10000",this._debugContainer.style.pointerEvents="none",this._debugCanvas=document.createElement("canvas"),this._debugCanvas.width=t.x,this._debugCanvas.height=t.y,this._debugCanvas.style.width="100%",this._debugCanvas.style.height="100%",this._debugCanvas.style.imageRendering="pixelated",this._debugContainer.appendChild(this._debugCanvas),document.body.appendChild(this._debugContainer)}removeDebugCanvas(){this._debugContainer&&(this._debugContainer.remove(),this._debugContainer=void 0,this._debugCanvas=void 0)}updateDebugCanvas(){if(!this._debugCanvas||!this._renderTarget||!this.world.renderer)return;const t=this.world.renderer.three,e=this._renderTargetSize,i=new Uint8Array(e.x*e.y*4);t.readRenderTargetPixels(this._renderTarget,0,0,e.x,e.y,i);const s=this._debugCanvas.getContext("2d");if(!s)return;const n=s.createImageData(e.x,e.y),o=4*e.x;for(let a=0;a<e.y;a++){const h=a*o,u=(e.y-1-a)*o;n.data.set(i.subarray(h,h+o),u)}s.putImageData(n,0,0)}};y(tl,"MAX_MODELS",254);let cf=tl;const el=class jc extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"list",new Map),y(this,"onDisposed",new Q),t.add(jc.uuid,this)}get(t){if(this.list.has(t.uuid))return this.list.get(t.uuid);const e=new cf(this.components,t);return this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)}),e}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}};y(el,"uuid","4a82430c-7ff2-49ea-9401-60807502dad6");let df=el;class as{constructor(t){y(this,"onDisposed",new Q),y(this,"maxDistance",1),y(this,"maxCacheSize",1e3),y(this,"components"),y(this,"cache",new Map),this.components=t}dispose(){this.cache.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}resolve(t,e,i,s){var n=this;return(0,G.A)(function*(){const o=as.keyOf(e,i);let a=n.cache.get(o);if(a)n.cache.delete(o),n.cache.set(o,a);else{if(a=yield n.fetchItemSnapData(e,i),!a)return null;n.storeWithLRU(o,a)}const l=n.snap(t,a,2),c=new Set(s),h=[0,1,2];let u=null;for(const f of h){if(!c.has(f))continue;const d=n.snap(t,a,f);if(d){u=d.result;break}}if(!u)return l?l.result:null;if(l&&2!==u.snappingClass){const f=l.result;!u.normal&&f.normal&&(u.normal=f.normal),!u.facePoints&&f.facePoints&&(u.facePoints=f.facePoints),!u.faceIndices&&f.faceIndices&&(u.faceIndices=f.faceIndices)}return u})()}prefetch(t,e){var i=this;return(0,G.A)(function*(){const s=as.keyOf(t,e);if(i.cache.has(s))return;const n=yield i.fetchItemSnapData(t,e);n&&i.storeWithLRU(s,n)})()}invalidate(t,e){const i=as.keyOf(t,e);this.cache.delete(i)}clear(){this.cache.clear()}static keyOf(t,e){return`${t}:${e}`}storeWithLRU(t,e){for(this.cache.set(t,e);this.cache.size>this.maxCacheSize;){const i=this.cache.keys().next().value;if(void 0===i)break;this.cache.delete(i)}}fetchItemSnapData(t,e){var i=this;return(0,G.A)(function*(){const n=i.components.get(ft).list.get(t);if(!n)return null;const o=yield n._getItemSnapData(e);if(!o)return null;const a=n.object.matrixWorld,l=[];for(const u of Object.keys(o.samples??{})){const f=o.samples[Number(u)],d=o.representations[f.representation];if(!d||1!==d.representationClass)continue;const _=d.geometry;if(!_)continue;const g=mf(a,o.globalTransforms[f.item],o.localTransforms[f.localTransform]);i.collectPolygonsFromShell(_,g,l)}if(0===l.length)return null;const c=function yf(r){const t=new Set,e=[];for(const i of r){const s=i.points,n=s.length/3;for(let o=0;o<n;o++){const a=(o+1)%n,l=s[3*o],c=s[3*o+1],h=s[3*o+2],u=s[3*a],f=s[3*a+1],d=s[3*a+2],_=vf(l,c,h,u,f,d);t.has(_)||(t.add(_),e.push(l,c,h,u,f,d))}}return new Float32Array(e)}(l),h=function wf(r){const t=new Set,e=[];for(const i of r){const s=i.points,n=s.length/3;for(let o=0;o<n;o++){const a=s[3*o],l=s[3*o+1],c=s[3*o+2],h=Er(a,l,c);t.has(h)||(t.add(h),e.push(a,l,c))}}return new Float32Array(e)}(l);return{faces:l,edges:c,vertices:h}})()}collectPolygonsFromShell(t,e,i){const s=t.points,n=t.profiles??new Map,o=t.bigProfiles??new Map,a=new p.Pq0,l=c=>{if(c.length<3)return;const h=new Float32Array(3*c.length);for(let d=0;d<c.length;d++){const _=s[c[d]];a.set(_[0],_[1],_[2]).applyMatrix4(e),h[3*d]=a.x,h[3*d+1]=a.y,h[3*d+2]=a.z}const u=function gf(r){const t=new p.Pq0,e=r.length/3;for(let s=0;s<e;s++){const n=(s+1)%e,o=r[3*s],a=r[3*s+1],l=r[3*s+2],c=r[3*n],h=r[3*n+1],u=r[3*n+2];t.x+=(a-h)*(l+u),t.y+=(l-u)*(o+c),t.z+=(o-c)*(a+h)}const i=t.length();return i<1e-10?null:t.divideScalar(i)}(h);u&&i.push({points:h,normal:u,d:u.x*h[0]+u.y*h[1]+u.z*h[2]})};for(const c of n.values())l(c);for(const c of o.values())l(c)}snap(t,e,i){return 0===i?this.snapToPoint(t,e):1===i?this.snapToLine(t,e):2===i?this.snapToFace(t,e):null}snapToPoint(t,e){const i=e.vertices;if(0===i.length)return null;const s=this.maxDistance*this.maxDistance;let n=-1,o=1/0;for(let a=0;a<i.length;a+=3){const l=i[a]-t.x,c=i[a+1]-t.y,h=i[a+2]-t.z,u=l*l+c*c+h*h;u<=s&&u<o&&(o=u,n=a)}return n<0?null:{result:{point:new p.Pq0(i[n],i[n+1],i[n+2]),snappingClass:0}}}snapToLine(t,e){const i=e.edges;if(0===i.length)return null;const s=this.maxDistance*this.maxDistance,n=new p.Pq0,o=new p.Pq0;let a=1/0,l=-1;for(let c=0;c<i.length;c+=6){const h=bf(t,i[c],i[c+1],i[c+2],i[c+3],i[c+4],i[c+5],o);h<=s&&h<a&&(a=h,l=c,n.copy(o))}return l<0?null:{result:{point:n.clone(),snappingClass:1,snappedEdgeP1:new p.Pq0(i[l],i[l+1],i[l+2]),snappedEdgeP2:new p.Pq0(i[l+3],i[l+4],i[l+5])}}}snapToFace(t,e){const i=e.faces;if(0===i.length)return null;let s=null,n=1/0;for(const a of i){const c=Math.abs(a.normal.x*t.x+a.normal.y*t.y+a.normal.z*t.z-a.d);c<=this.maxDistance&&c<n&&(n=c,s=a)}return s?{result:{point:t.clone().sub(s.normal.clone().multiplyScalar(s.normal.x*t.x+s.normal.y*t.y+s.normal.z*t.z-s.d)),normal:s.normal.clone(),snappingClass:2,facePoints:s.points,faceIndices:_f(s.points.length/3)}}:null}}const pf=new p.kn4,ls=new p.Pq0,cs=new p.Pq0,rn=new p.Pq0;function il(r,t){if(!r)return t.identity();const e=r.position[0],i=r.position[1],s=r.position[2];return ls.set(r.xDirection[0],r.xDirection[1],r.xDirection[2]),cs.set(r.yDirection[0],r.yDirection[1],r.yDirection[2]),rn.crossVectors(ls,cs),t.set(ls.x,cs.x,rn.x,e,ls.y,cs.y,rn.y,i,ls.z,cs.z,rn.z,s,0,0,0,1),t}const sl=new p.kn4,nl=new p.kn4;function mf(r,t,e){return il(t,sl),il(e,nl),pf.copy(r).multiply(sl).multiply(nl).clone()}function _f(r){if(r<3)return new Uint32Array(0);const t=r-2,e=new Uint32Array(3*t);for(let i=0;i<t;i++)e[3*i]=0,e[3*i+1]=i+1,e[3*i+2]=i+2;return e}function Er(r,t,e){return`${Math.round(1e3*r)},${Math.round(1e3*t)},${Math.round(1e3*e)}`}function vf(r,t,e,i,s,n){const o=Er(r,t,e),a=Er(i,s,n);return o<a?`${o}|${a}`:`${a}|${o}`}function bf(r,t,e,i,s,n,o,a){const l=s-t,c=n-e,h=o-i,u=l*l+c*c+h*h;let f=0;u>0&&(f=((r.x-t)*l+(r.y-e)*c+(r.z-i)*h)/u,f<0?f=0:f>1&&(f=1));const d=t+f*l,_=e+f*c,m=i+f*h;a.set(d,_,m);const w=r.x-d,g=r.y-_,v=r.z-m;return w*w+g*g+v*v}const rl=class Hc extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"onDisposed",new Q),y(this,"_resolver"),t.add(Hc.uuid,this),this._resolver=new as(t)}get(){return this._resolver}dispose(){this._resolver.dispose(),this.onDisposed.trigger()}};y(rl,"uuid","be9b8e6c-7f5b-4a36-8e7e-3a1f5e2a6c9d");let xf=rl;class Cf{constructor(t,e){y(this,"enabled",!0),y(this,"components"),y(this,"onDisposed",new Q),y(this,"mouse"),y(this,"three",new p.tBo),y(this,"world");const i=e.renderer;if(!i)throw new Error("A renderer is needed for the raycaster to work!");this.world=e,this.mouse=new Yo(i.three.domElement),this.components=t}dispose(){this.mouse.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}castRayToObjects(t=Array.from(this.world.meshes),e=this.mouse.position){if(!this.world)throw new Error("A world is needed to cast rays!");return this.three.setFromCamera(e,this.world.camera.three),this.intersect(t)}castRay(t){var e=this;return(0,G.A)(function*(){const i=t?.snappingClasses,s=t?.items??Array.from(e.world.meshes),n=t?.position??e.mouse.position;if(!e.world)throw new Error("A world is needed to cast rays!");const o=e.world.camera.three,a=e.components.get(ft);let l=null;if(a.initialized){const f=yield e.components.get(df).get(e.world).getFullPick(n);if(f){const d=a.list.get(f.modelId);if(l={localId:f.localId,point:f.point,normal:f.normal,distance:f.distance,fragments:d,object:d?.object,ray:void 0,frustum:void 0},i&&i.length>0){const _=yield e.components.get(xf).get().resolve(f.point,f.modelId,f.itemId,i);_&&(l.point=_.point,_.normal&&(l.normal=_.normal),l.snappingClass=_.snappingClass,_.facePoints&&(l.facePoints=_.facePoints),_.faceIndices&&(l.faceIndices=_.faceIndices),_.snappedEdgeP1&&(l.snappedEdgeP1=_.snappedEdgeP1),_.snappedEdgeP2&&(l.snappedEdgeP2=_.snappedEdgeP2),l.distance=_.point.distanceTo(o.position))}}if(0===s.length)return l}e.three.setFromCamera(n,o);const c=e.intersect(s);return l?c&&c.distance<l.distance?c:l:c})()}castRayFromVector(t,e,i=Array.from(this.world.meshes)){return this.three.set(t,e),this.intersect(i)}intersect(t=Array.from(this.world.meshes)){const e=this.three.intersectObjects(t),i=this.filterClippingPlanes(e);return i.length>0?i[0]:null}filterClippingPlanes(t){if(!this.world.renderer)throw new Error("Renderer not found!");const e=this.world.renderer.three;if(!e.clippingPlanes)return t;const i=e.clippingPlanes;return t.length<=0||!i||i?.length<=0?t:t.filter(s=>i.every(n=>n.distanceToPoint(s.point)>0))}}const ol=class qc extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"list",new Map),y(this,"onDisposed",new Q),t.add(qc.uuid,this)}get(t){if(this.list.has(t.uuid))return this.list.get(t.uuid);const e=new Cf(this.components,t);return this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)}),e}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}};y(ol,"uuid","d5d8bdf0-db25-4952-b951-b643af207ace");let on=ol;class Tf extends An{constructor(){var t;super(...arguments),t=this,y(this,"onCameraChanged",new Q),y(this,"meshes",new Set),y(this,"onAfterUpdate",new Q),y(this,"onBeforeUpdate",new Q),y(this,"onDisposed",new Q),y(this,"isDisposing",!1),y(this,"enabled",!0),y(this,"_dynamicAnchor",!1),y(this,"uuid",ie.create()),y(this,"name"),y(this,"_scene"),y(this,"_camera"),y(this,"_renderer",null),y(this,"onPointerDown",function(){var e=(0,G.A)(function*(i){if(!t.camera.hasCameraControls())throw new Error("World: can't set dynamic anchor if the camera doesn't have controls.");const n=yield t.components.get(on).get(t).castRay();n&&n.point&&0===i.button&&t.camera.controls.setOrbitPoint(n.point.x,n.point.y,n.point.z)});return function(i){return e.apply(this,arguments)}}()),y(this,"_defaultCamera")}set dynamicAnchor(t){var e;const i=null==(e=this.renderer)?void 0:e.three.domElement.parentElement;if(!i)throw new Error("World: the renderer must have a parentElement to set dynamic anchoring.");t?(this.camera.controls&&(this.camera.controls.minDistance=.01),i.addEventListener("pointerdown",this.onPointerDown)):i.removeEventListener("pointerdown",this.onPointerDown)}get dynamicAnchor(){return this._dynamicAnchor}get defaultCamera(){if(!this._defaultCamera)throw new Error("World: there is no default camera defined.");return this._defaultCamera}set defaultCamera(t){this._defaultCamera=t}get scene(){if(!this._scene)throw new Error("No scene initialized!");return this._scene}set scene(t){this._scene=t,t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"})}get camera(){if(!this._camera)throw new Error("No camera initialized!");return this._camera}set camera(t){this._camera||(this.defaultCamera=t),this._camera=t,t.currentWorld=this,this.onCameraChanged.trigger(t)}get renderer(){return this._renderer}set renderer(t){this._renderer=t,t&&(t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"}))}useDefaultCamera(){this.camera=this.defaultCamera}update(t){this.enabled&&(!this._scene||!this._camera||(this.scene.currentWorld=this,this.camera.currentWorld=this,this.renderer&&(this.renderer.currentWorld=this),this.onBeforeUpdate.trigger(),this.scene.isUpdateable()&&this.scene.update(t),this.camera.isUpdateable()&&this.camera.update(t),this.renderer&&this.renderer.update(t),this.onAfterUpdate.trigger()))}dispose(t=!0){if(this.enabled=!1,this.isDisposing=!0,this.scene.onWorldChanged.trigger({world:this,action:"removed"}),this.camera.onWorldChanged.trigger({world:this,action:"removed"}),this.renderer&&this.renderer.onWorldChanged.trigger({world:this,action:"removed"}),t){const i=this.components.get(bi);this.scene.dispose(),this.camera.isDisposeable()&&this.camera.dispose(),this.renderer&&this.renderer.dispose();for(const s of this.meshes)i.destroy(s);this.meshes.clear()}this._scene=null,this._camera=null,this._renderer=null,this.components.get(an).list.delete(this.uuid),this.onDisposed.trigger(),this.onDisposed.reset()}}class Pf{constructor(t,e){y(this,"_list"),y(this,"_scene"),this._list=t,this._scene=e}get color(){return this._list.directionalLight.color.value}set color(t){this._list.directionalLight.color.value=t;for(const[,e]of this._scene.directionalLights)e.color.copy(t)}get intensity(){return this._list.directionalLight.intensity.value}set intensity(t){this._list.directionalLight.intensity.value=t;for(const[,e]of this._scene.directionalLights)e.intensity=t}get position(){return this._list.directionalLight.position.value.clone()}set position(t){this._list.directionalLight.position.value=t;for(const[,e]of this._scene.directionalLights)e.position.copy(t)}}class Sf{constructor(t,e){y(this,"_list"),y(this,"_scene"),this._list=t,this._scene=e}get color(){return this._list.ambientLight.color.value}set color(t){this._list.ambientLight.color.value=t;for(const[,e]of this._scene.ambientLights)e.color.copy(t)}get intensity(){return this._list.ambientLight.intensity.value}set intensity(t){this._list.ambientLight.intensity.value=t;for(const[,e]of this._scene.ambientLights)e.intensity=t}}class Ef extends Wi{constructor(){super(...arguments),y(this,"_config",{backgroundColor:{value:new p.Q1f,type:"Color"},ambientLight:{color:{type:"Color",value:new p.Q1f},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2}},directionalLight:{color:{type:"Color",value:new p.Q1f},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2},position:{type:"Vector3",value:new p.Pq0}}}),y(this,"ambientLight",new Sf(this._config,this._component)),y(this,"directionalLight",new Pf(this._config,this._component))}get backgroundColor(){return this._config.backgroundColor.value}set backgroundColor(t){this._config.backgroundColor.value=t,this._component.three.background=t}}class al extends ch{constructor(t){super(t),y(this,"onSetup",new Q),y(this,"isSetup",!1),y(this,"three"),y(this,"config",new Ef(this,this.components,"Scene")),y(this,"_defaultConfig",{backgroundColor:new p.Q1f(2107698),directionalLight:{color:new p.Q1f("white"),intensity:1.5,position:new p.Pq0(5,10,3)},ambientLight:{color:new p.Q1f("white"),intensity:1}}),this.three=new p.Z58,this.three.background=new p.Q1f(2107698)}setup(t){const e={...this._defaultConfig,...t};this.config.backgroundColor=e.backgroundColor;const i=e.ambientLight;this.config.ambientLight.color=i.color,this.config.ambientLight.intensity=i.intensity;const s=e.directionalLight;this.config.directionalLight.color=s.color,this.config.directionalLight.intensity=s.intensity,this.config.directionalLight.position=s.position,this.deleteAllLights();const{color:n,intensity:o}=this.config.directionalLight,a=new p.ZyN(n,o);a.position.copy(s.position);const{color:l,intensity:c}=this.config.directionalLight,h=new p.$p8(l,c);this.three.add(a,h),this.directionalLights.set(a.uuid,a),this.ambientLights.set(h.uuid,h),this.isSetup=!0,this.onSetup.trigger()}dispose(){super.dispose(),this.components.get(Ps).list.delete(this.config.uuid)}}'\n<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 40" fill="none" aria-label="That Open Company">\n<path d="M42.2856 19.6517V8.4048H38.8676V7.14978H46.998V8.40976H43.6131V19.6566L42.2856 19.6517Z" fill="#BCF124"/>\n<path d="M48.459 19.6516V7.14978H49.7032V12.404L49.4204 12.3371C49.6285 11.7727 50.0095 11.2904 50.5078 10.9607C51.0285 10.6201 51.638 10.4449 52.2578 10.4577C52.853 10.4483 53.44 10.5988 53.9589 10.8938C54.456 11.1789 54.8687 11.5934 55.1541 12.0943C55.449 12.6164 55.6 13.2089 55.5913 13.8102V19.6516H54.3495V14.2958C54.3637 13.8139 54.2611 13.3359 54.0507 12.9033C53.8646 12.537 53.5797 12.2315 53.229 12.0224C52.8685 11.8121 52.4584 11.7046 52.0423 11.7115C51.624 11.7054 51.2117 11.8128 50.8483 12.0224C50.4912 12.2324 50.2006 12.541 50.0106 12.912C49.7956 13.3401 49.6899 13.8158 49.7032 14.2958V19.6516H48.459Z" fill="#BCF124"/>\n<path d="M60.5388 19.8524C60.0174 19.8619 59.5007 19.75 59.0289 19.5253C58.6071 19.3259 58.2459 19.0157 57.983 18.6271C57.7263 18.2403 57.593 17.7833 57.6009 17.3175C57.5959 16.8715 57.6984 16.4309 57.8997 16.034C58.1173 15.6285 58.4383 15.2892 58.8292 15.0516C59.3232 14.7561 59.8701 14.5624 60.4384 14.4817L63.9188 13.8932V15.0355L60.7348 15.5744C60.0931 15.6867 59.6314 15.8932 59.3497 16.1938C59.0735 16.4811 58.9212 16.8673 58.926 17.268C58.9244 17.4635 58.9661 17.657 59.0481 17.8341C59.1301 18.0112 59.2503 18.1674 59.3999 18.2913C59.7416 18.5818 60.1787 18.7318 60.6246 18.7113C61.1803 18.7244 61.7296 18.5884 62.2166 18.3173C62.6597 18.066 63.0268 17.6972 63.2784 17.2506C63.535 16.7959 63.6669 16.2801 63.6604 15.7565V13.4744C63.6679 13.2259 63.6196 12.979 63.519 12.7521C63.4185 12.5253 63.2684 12.3245 63.08 12.1649C62.693 11.8287 62.1897 11.6607 61.57 11.6607C61.0801 11.6502 60.5978 11.7845 60.1822 12.047C59.7665 12.3095 59.4355 12.6888 59.2297 13.1387L58.1018 12.5192C58.2839 12.117 58.553 11.7614 58.8892 11.4785C59.2572 11.162 59.6754 10.9107 60.1261 10.7352C60.5858 10.5517 61.0758 10.4579 61.57 10.4589C62.1703 10.4448 62.7654 10.5748 63.3065 10.838C63.7888 11.077 64.1965 11.4462 64.4846 11.9047C64.7683 12.3771 64.912 12.9219 64.8986 13.4744V19.6517H63.658V17.8552L63.8405 18.0398C63.6702 18.3954 63.4238 18.7081 63.1191 18.9554C62.7772 19.238 62.3899 19.4593 61.9741 19.6095C61.5136 19.7756 61.0277 19.8578 60.5388 19.8524Z" fill="#BCF124"/>\n<path d="M70.6935 19.752C69.8975 19.752 69.2852 19.517 68.8566 19.0471C68.428 18.5771 68.2108 17.9056 68.2051 17.0326V11.9122H66.5616V10.6534H66.9804C67.1477 10.662 67.3148 10.6332 67.4697 10.5689C67.6247 10.5047 67.7637 10.4066 67.8769 10.2818C68.1017 10.0195 68.2202 9.68094 68.2088 9.33398V8.57825H69.453V10.6596H71.4124V11.9184H69.453V17.0388C69.4478 17.3107 69.4926 17.5813 69.5853 17.8366C69.6729 18.065 69.8337 18.2569 70.042 18.3818C70.3083 18.5292 70.6096 18.5991 70.9128 18.5837C71.0009 18.5837 71.1063 18.5775 71.2287 18.5664C71.3512 18.5552 71.4553 18.5441 71.5434 18.5329V19.6578C71.396 19.6937 71.2462 19.7189 71.0952 19.7334C70.9262 19.7433 70.7927 19.752 70.6935 19.752Z" fill="#BCF124"/>\n<path d="M82.2003 19.8523C81.3145 19.8603 80.4355 19.6954 79.6114 19.3666C78.4307 18.8928 77.4197 18.068 76.7118 17.001C76.0038 15.9341 75.6323 14.6751 75.646 13.3901C75.6376 12.5147 75.8043 11.6466 76.1359 10.838C76.453 10.0681 76.9213 9.37141 77.5123 8.79004C78.1118 8.20273 78.819 7.73977 79.5942 7.42723C81.2715 6.778 83.1266 6.778 84.8039 7.42723C85.5794 7.73911 86.2867 8.20215 86.8857 8.79004C87.4768 9.3717 87.9454 10.0683 88.2635 10.838C88.5945 11.6468 88.7611 12.5148 88.7533 13.3901C88.7674 14.6752 88.396 15.9343 87.688 17.0013C86.98 18.0683 85.9688 18.8931 84.7879 19.3666C83.9642 19.6952 83.0857 19.8601 82.2003 19.8523ZM82.2003 17.4984C82.7378 17.5032 83.2709 17.4005 83.769 17.1961C84.2425 16.9994 84.6735 16.7111 85.0378 16.3474C85.4069 15.9786 85.6952 15.5354 85.884 15.0465C86.0882 14.5173 86.1896 13.9532 86.1828 13.3852C86.1898 12.8203 86.0883 12.2594 85.884 11.7337C85.6922 11.2464 85.4043 10.8038 85.0378 10.4328C84.6764 10.0659 84.2446 9.77748 83.769 9.58542C82.7594 9.19396 81.6424 9.19396 80.6327 9.58542C80.1568 9.77745 79.7246 10.0658 79.3628 10.4328C78.9967 10.8041 78.7088 11.2467 78.5166 11.7337C78.3119 12.2602 78.2104 12.8219 78.2177 13.3876C78.2109 13.9557 78.3123 14.5198 78.5166 15.049C78.7058 15.5377 78.994 15.9808 79.3628 16.3499C79.7275 16.7136 80.1589 17.0019 80.6327 17.1985C81.1302 17.4038 81.663 17.5074 82.2003 17.5033V17.4984Z" fill="#BCF124"/>\n<path d="M90.398 23.2209V10.4861H92.7248V12.2293L92.5081 11.7251C92.8117 11.2627 93.2354 10.8941 93.7327 10.6596C94.2857 10.3994 94.8901 10.2702 95.4999 10.2817C96.3233 10.271 97.1335 10.4919 97.8401 10.9198C98.5312 11.3384 99.1029 11.9314 99.4995 12.6406C99.9126 13.38 100.124 14.2172 100.112 15.0664C100.122 15.9116 99.913 16.7448 99.5069 17.4835C99.1168 18.1988 98.5469 18.7971 97.8548 19.218C97.1376 19.6483 96.3164 19.8688 95.4827 19.8548C94.894 19.8605 94.3104 19.7437 93.7682 19.5116C93.2614 19.2967 92.8226 18.9454 92.4995 18.4957L92.8975 17.9754V23.2234L90.398 23.2209ZM95.1741 17.5863C95.6033 17.5949 96.0268 17.4848 96.3987 17.268C96.7521 17.0559 97.0394 16.7477 97.2278 16.3784C97.4328 15.9736 97.5355 15.5237 97.5266 15.0689C97.5364 14.6168 97.4337 14.1694 97.2278 13.768C97.0366 13.4007 96.7499 13.0932 96.3987 12.8785C96.0288 12.6556 95.6046 12.5419 95.1741 12.5502C94.7569 12.5434 94.3461 12.6541 93.9874 12.8698C93.6387 13.0826 93.3568 13.391 93.1743 13.7593C92.9832 14.1688 92.8841 14.6161 92.8841 15.0689C92.8841 15.5217 92.9832 15.9689 93.1743 16.3784C93.3571 16.7465 93.639 17.0548 93.9874 17.268C94.3469 17.4837 94.7586 17.594 95.1766 17.5863H95.1741Z" fill="#BCF124"/>\n<path d="M105.924 19.8524C104.961 19.8524 104.126 19.6372 103.418 19.2069C102.724 18.7915 102.156 18.1916 101.776 17.4724C101.384 16.7291 101.184 15.8977 101.194 15.0553C101.179 14.1986 101.388 13.3532 101.801 12.6047C102.189 11.9046 102.753 11.3198 103.434 10.9087C104.139 10.4899 104.944 10.2756 105.761 10.2892C106.414 10.277 107.062 10.394 107.67 10.6336C108.202 10.8483 108.68 11.1777 109.073 11.5987C109.454 12.0141 109.75 12.5023 109.943 13.0346C110.147 13.6019 110.248 14.2016 110.242 14.805C110.242 14.9847 110.234 15.1606 110.218 15.334C110.205 15.4855 110.174 15.6349 110.126 15.7788H103.34V13.9266H108.716L107.538 14.8001C107.65 14.3786 107.645 13.9339 107.522 13.5153C107.411 13.1561 107.186 12.8437 106.883 12.6258C106.553 12.4 106.161 12.2855 105.762 12.2987C105.368 12.2877 104.981 12.3993 104.652 12.6184C104.327 12.8492 104.083 13.1779 103.955 13.5574C103.79 14.0428 103.728 14.5577 103.772 15.0689C103.719 15.5315 103.782 16.0001 103.955 16.4317C104.108 16.81 104.375 17.1302 104.718 17.3473C105.08 17.5514 105.486 17.6634 105.901 17.6736C106.316 17.6837 106.727 17.5917 107.098 17.4055C107.407 17.2317 107.661 16.9743 107.833 16.6622L109.824 17.6186C109.643 18.0737 109.355 18.4776 108.986 18.7956C108.59 19.1398 108.132 19.4046 107.638 19.5761C107.087 19.766 106.507 19.8594 105.924 19.8524Z" fill="#BCF124"/>\n<path d="M111.703 19.6516V10.4837H114.03V12.2962L113.898 11.8935C114.081 11.3764 114.443 10.944 114.918 10.6769C115.425 10.404 115.994 10.2679 116.569 10.2817C117.196 10.2676 117.816 10.4179 118.369 10.7178C118.875 11.0011 119.293 11.4232 119.573 11.9357C119.87 12.4948 120.018 13.1223 120.004 13.7569V19.6491H117.515V14.2958C117.524 13.9753 117.452 13.6579 117.307 13.3728C117.173 13.1206 116.972 12.9112 116.727 12.7682C116.459 12.625 116.162 12.5502 115.859 12.5502C115.557 12.5502 115.26 12.625 114.992 12.7682C114.743 12.9091 114.539 13.1188 114.403 13.3728C114.259 13.658 114.188 13.9754 114.196 14.2958V19.6516H111.703Z" fill="#BCF124"/>\n<path d="M45.7329 35.9372C44.8875 35.9451 44.0493 35.7794 43.269 35.4503C42.525 35.134 41.851 34.6707 41.2863 34.0875C40.7178 33.4992 40.2696 32.8033 39.9673 32.0396C39.6453 31.2229 39.4843 30.3504 39.4934 29.4713C39.4848 28.5902 39.6427 27.7155 39.9588 26.8943C40.2511 26.1324 40.6939 25.4388 41.2601 24.8558C41.8262 24.2727 42.504 23.8126 43.2518 23.5034C44.039 23.178 44.8826 23.015 45.7329 23.024C46.5598 23.0107 47.3809 23.1649 48.1479 23.4774C48.8259 23.756 49.443 24.1669 49.9641 24.6866C50.4412 25.1559 50.8045 25.7304 51.0258 26.3653L48.7529 27.4729C48.5362 26.8433 48.1263 26.3001 47.5831 25.9226C47.0399 25.5451 46.3917 25.3529 45.7329 25.3742C45.0556 25.3604 44.3882 25.5408 43.8078 25.8945C43.2553 26.2426 42.8099 26.74 42.5219 27.3304C42.2056 27.9978 42.0495 28.7313 42.0664 29.4713C42.0503 30.2135 42.2063 30.9493 42.5219 31.6196C42.8077 32.2136 43.2534 32.7139 43.8078 33.0629C44.3879 33.4172 45.0555 33.5976 45.7329 33.5832C46.3917 33.6045 47.0399 33.4124 47.5831 33.0348C48.1263 32.6573 48.5362 32.1142 48.7529 31.4845L51.0258 32.5933C50.8056 33.2316 50.4422 33.8096 49.9641 34.282C49.4426 34.8009 48.8256 35.2113 48.1479 35.4899C47.3805 35.8004 46.5594 35.9524 45.7329 35.9372Z" fill="#BCF124"/>\n<path d="M56.8159 35.9372C55.9603 35.9485 55.1164 35.735 54.3667 35.3177C53.6426 34.9153 53.0357 34.3274 52.6069 33.613C52.1777 32.8648 51.9517 32.0151 51.9517 31.15C51.9517 30.285 52.1777 29.4353 52.6069 28.6871C53.0376 27.9762 53.6442 27.3911 54.3667 26.9898C55.118 26.5823 55.9573 26.3691 56.8098 26.3691C57.6623 26.3691 58.5016 26.5823 59.253 26.9898C59.9716 27.3928 60.5749 27.9771 61.0042 28.6858C61.4334 29.4341 61.6594 30.2837 61.6594 31.1488C61.6594 32.0139 61.4334 32.8635 61.0042 33.6118C60.577 34.3244 59.9733 34.912 59.253 35.3165C58.5078 35.7343 57.6678 35.9482 56.8159 35.9372ZM56.8159 33.6712C57.2335 33.681 57.6451 33.5701 58.0026 33.3516C58.3443 33.1354 58.6199 32.8274 58.7986 32.462C58.9985 32.0556 59.0985 31.6064 59.0901 31.1525C59.099 30.7014 58.9989 30.2548 58.7986 29.8517C58.6161 29.4889 58.3414 29.1818 58.0026 28.9621C57.6468 28.739 57.2345 28.6254 56.8159 28.635C56.3952 28.6261 55.9807 28.7396 55.6219 28.9621C55.2792 29.18 55.0008 29.4873 54.8161 29.8517C54.6162 30.2549 54.5166 30.7015 54.5259 31.1525C54.517 31.6063 54.6166 32.0555 54.8161 32.462C54.997 32.8291 55.2762 33.1373 55.6219 33.3516C55.9824 33.5695 56.3962 33.6803 56.8159 33.6712Z" fill="#BCF124"/>\n<path d="M63.1228 35.7364V26.5685H65.4496V28.7985L65.2047 28.4269C65.337 27.7223 65.6574 27.202 66.1661 26.8658C66.7124 26.5198 67.3477 26.3448 67.992 26.3628C68.6955 26.3487 69.3867 26.5504 69.9747 26.9414C70.2455 27.1163 70.4794 27.3435 70.6631 27.6102C70.8468 27.8768 70.9766 28.1775 71.045 28.495L70.3311 28.5619C70.6299 27.8128 71.056 27.2586 71.6096 26.8993C72.1912 26.5332 72.8658 26.3468 73.5506 26.3628C74.1566 26.3506 74.755 26.5011 75.2847 26.7989C75.7839 27.0856 76.1947 27.5068 76.4714 28.0155C76.7686 28.5772 76.9163 29.2073 76.9 29.8442V35.7364H74.4067V30.3806C74.4151 30.0621 74.3496 29.746 74.2156 29.4576C74.0956 29.2086 73.9084 28.999 73.6756 28.853C73.4175 28.71 73.1279 28.635 72.8336 28.635C72.5393 28.635 72.2498 28.71 71.9917 28.853C71.7556 28.9972 71.5655 29.2071 71.4443 29.4576C71.3103 29.746 71.2448 30.0621 71.2532 30.3806V35.7364H68.7648V30.3806C68.7731 30.0621 68.7077 29.746 68.5737 29.4576C68.4538 29.2089 68.267 28.9994 68.0349 28.853C67.7765 28.71 67.4868 28.635 67.1923 28.635C66.8978 28.635 66.6081 28.71 66.3498 28.853C66.1137 28.9972 65.9236 29.2071 65.8023 29.4576C65.6683 29.746 65.6029 30.0621 65.6113 30.3806V35.7364H63.1228Z" fill="#BCF124"/>\n<path d="M78.5374 39.3107V26.5697H80.8642V28.3166L80.6486 27.8123C80.9522 27.35 81.376 26.9813 81.8733 26.7469C82.4266 26.4883 83.0311 26.3611 83.6404 26.3752C84.464 26.3639 85.2743 26.5848 85.9807 27.0132C86.6715 27.4323 87.2431 28.0251 87.6401 28.7341C88.0532 29.473 88.2645 30.3098 88.2524 31.1586C88.2623 32.0044 88.0533 32.8381 87.6462 33.577C87.2571 34.2926 86.6875 34.8911 85.9954 35.3115C85.2785 35.7427 84.4572 35.9636 83.6233 35.9495C83.0345 35.9548 82.4509 35.8376 81.9088 35.6051C81.4019 35.391 80.963 35.04 80.6401 34.5904L81.0381 34.0701V39.3231L78.5374 39.3107ZM83.3134 33.6712C83.7428 33.6796 84.1663 33.5691 84.5381 33.3515C84.892 33.1399 85.1798 32.8316 85.3684 32.462C85.573 32.057 85.6757 31.6072 85.6672 31.1524C85.6761 30.7004 85.5734 30.2533 85.3684 29.8516C85.176 29.4847 84.8891 29.1774 84.5381 28.962C84.1679 28.7398 83.7438 28.6266 83.3134 28.635C82.8964 28.6281 82.4856 28.7383 82.1268 28.9534C81.778 29.1666 81.496 29.4755 81.3136 29.8442C81.1225 30.2534 81.0233 30.7004 81.0233 31.1531C81.0233 31.6057 81.1225 32.0527 81.3136 32.462C81.4954 32.8308 81.7775 33.1394 82.1268 33.3515C82.4863 33.5682 82.8986 33.679 83.3171 33.6712H83.3134Z" fill="#BCF124"/>\n<path d="M92.5093 35.9371C91.9294 35.9511 91.353 35.8427 90.8168 35.6187C90.3699 35.4306 89.9887 35.1118 89.722 34.7032C89.4607 34.2804 89.3278 33.7893 89.3399 33.2908C89.3319 32.8129 89.4525 32.3418 89.689 31.928C89.9498 31.5033 90.3197 31.1581 90.7593 30.9295C91.3217 30.6339 91.931 30.4406 92.5595 30.3583L95.3296 29.9049V31.7521L93.0028 32.1708C92.7069 32.2127 92.4268 32.3314 92.1897 32.5153C92.0938 32.6024 92.0186 32.7102 91.9696 32.8307C91.9207 32.9513 91.8992 33.0814 91.9068 33.2115C91.9015 33.3387 91.9277 33.4652 91.9828 33.5796C92.038 33.6941 92.1204 33.7928 92.2227 33.8669C92.4503 34.0296 92.7243 34.1123 93.0028 34.1023C93.3792 34.1101 93.7509 34.0174 94.0805 33.8335C94.3832 33.6617 94.6332 33.4087 94.803 33.1025C94.9751 32.7929 95.0638 32.443 95.0602 32.0878V29.698C95.062 29.5308 95.0264 29.3654 94.956 29.2141C94.8855 29.0628 94.7822 28.9296 94.6536 28.8245C94.3818 28.5891 94.0144 28.4714 93.5515 28.4714C93.1318 28.4645 92.7212 28.5949 92.3807 28.8431C92.0467 29.0873 91.7912 29.4256 91.6459 29.8157L89.6547 28.8592C89.826 28.354 90.1169 27.8989 90.5021 27.5336C90.9038 27.1547 91.3782 26.8634 91.8958 26.6775C92.4648 26.471 93.0657 26.3686 93.6702 26.3752C94.3679 26.3612 95.0599 26.5046 95.6958 26.7952C96.2502 27.0473 96.724 27.4511 97.0637 27.961C97.3951 28.4765 97.5658 29.0807 97.5536 29.6955V35.7389H95.2268V34.2584L95.7913 34.1581C95.5497 34.5339 95.2533 34.8706 94.912 35.1566C94.5921 35.4193 94.2261 35.6185 93.8331 35.7439C93.4044 35.877 92.9578 35.9422 92.5093 35.9371Z" fill="#BCF124"/>\n<path d="M99.3795 35.7365V26.5685H101.706V28.3823L101.573 27.9796C101.757 27.4626 102.119 27.0301 102.593 26.7618C103.101 26.4898 103.67 26.3542 104.245 26.3678C104.872 26.3532 105.493 26.5034 106.045 26.8039C106.551 27.0867 106.968 27.5085 107.248 28.0205C107.545 28.5801 107.693 29.208 107.679 29.8429V35.7352H105.189V30.3806C105.197 30.0603 105.126 29.743 104.982 29.4576C104.848 29.2051 104.646 28.9957 104.401 28.8531C104.135 28.7035 103.834 28.6282 103.53 28.635C103.23 28.6314 102.935 28.7065 102.673 28.8531C102.423 28.9936 102.219 29.2034 102.084 29.4576C101.939 29.7428 101.868 30.0603 101.877 30.3806V35.7365H99.3795Z" fill="#BCF124"/>\n<path d="M110.563 39.4631C110.304 39.4633 110.046 39.4405 109.791 39.3949C109.563 39.3571 109.342 39.2835 109.136 39.1769V37.1128C109.316 37.1628 109.499 37.2017 109.684 37.2293C109.875 37.2621 110.07 37.2791 110.264 37.2801C110.754 37.2801 111.099 37.1562 111.31 36.9282C111.522 36.6884 111.696 36.4162 111.824 36.1217L112.437 34.6945L112.404 36.7932L108.421 26.5697H111.093L113.731 33.8384H112.735L115.373 26.5697H118.048L114.165 36.5925C113.955 37.1702 113.652 37.7089 113.269 38.187C112.942 38.5905 112.531 38.9169 112.066 39.1434C111.594 39.3617 111.081 39.4709 110.563 39.4631Z" fill="#BCF124"/>\n<path d="M7.00861 16.1097H0C0.00583172 11.8399 1.68502 7.74676 4.66939 4.7276C7.65377 1.70844 11.6998 0.00968387 15.9203 0.00378418V7.09408C13.558 7.09801 11.2935 8.04913 9.62308 9.73902C7.95266 11.4289 7.0125 13.7198 7.00861 16.1097Z" fill="#BCF124"/>\n<path d="M15.9243 39.3094C11.7037 39.3035 7.65771 37.6047 4.67333 34.5856C1.68896 31.5664 0.00976849 27.4732 0.00393677 23.2035H7.01255C7.01255 24.9874 7.53543 26.7311 8.51506 28.2144C9.4947 29.6976 10.8871 30.8536 12.5162 31.5362C14.1452 32.2189 15.9378 32.3975 17.6672 32.0495C19.3966 31.7015 20.9852 30.8425 22.2321 29.5811C23.4789 28.3197 24.328 26.7127 24.672 24.9631C25.016 23.2135 24.8394 21.4 24.1647 19.752C23.4899 18.1039 22.3472 16.6953 20.881 15.7042C19.4149 14.7132 17.6912 14.1842 15.9279 14.1842V7.09021C20.1512 7.09021 24.2016 8.78747 27.1879 11.8086C30.1742 14.8297 31.8519 18.9273 31.8519 23.1998C31.8519 27.4723 30.1742 31.5699 27.1879 34.591C24.2016 37.6121 20.1512 39.3094 15.9279 39.3094H15.9243Z" fill="#BCF124"/>\n</svg>\n'.trim();class hs extends ah{constructor(t){super(t),y(this,"onBeforeUpdate",new Q),y(this,"onAfterUpdate",new Q),y(this,"onAspectUpdated",new Q),y(this,"onDisposed",new Q),y(this,"three"),y(this,"_resizeObserver",null),y(this,"_allControls",new Map),y(this,"updateAspect",()=>{var e;if(this.currentWorld&&this.currentWorld.renderer){if(this.three instanceof p.qUd)return void this.onAspectUpdated.trigger();if(null!=(e=this.currentWorld.renderer)&&e.isResizeable()){const i=this.currentWorld.renderer.getSize();this.three.aspect=i.width/i.height,this.three.updateProjectionMatrix(),this.onAspectUpdated.trigger()}}}),this.three=this.setupCamera(),this.worlds.onItemSet.add(({value:e})=>{const i=this.newCameraControls();this.setupEvents(!0),this._allControls.set(e.uuid,i)}),this.worlds.onBeforeDelete.add(({value:e})=>{var i;const s=this._allControls.get(e.uuid);s&&(s.dispose(),this._allControls.delete(e.uuid)),null==(i=this._resizeObserver)||i.disconnect()})}get controls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");const t=this._allControls.get(this.currentWorld.uuid);if(!t)throw new Error("Controls not found!");return t}get enabled(){return null!==this.currentWorld&&this.controls.enabled}set enabled(t){null!==this.currentWorld&&(this.controls.enabled=t)}set currentWorld(t){super.currentWorld=t,t&&(this.worlds.get(t.uuid)||this.worlds.set(t.uuid,t))}get currentWorld(){return this._currentWorld}dispose(){this.setupEvents(!1),this.onAspectUpdated.reset(),this.onBeforeUpdate.reset(),this.onAfterUpdate.reset(),this.three.removeFromParent(),this.onDisposed.trigger(),this.onDisposed.reset();for(const[t,e]of this._allControls)e.dispose();this.worlds.clear()}fitToItems(t){var e=this;return(0,G.A)(function*(){const i=yield e.getItemsBounding(t);yield e.controls.fitToSphere(i,!0)})()}setOrbitToItems(t){var e=this;return(0,G.A)(function*(){const i=yield e.getItemsBounding(t);e.controls.setOrbitPoint(i.center.x,i.center.y,i.center.z)})()}update(t){this.enabled&&(this.onBeforeUpdate.trigger(this),this.controls.update(t),this.onAfterUpdate.trigger(this))}getItemsBounding(t){var e=this;return(0,G.A)(function*(){const i=e.components.get(ft),s=e.components.get(Qa);s.list.clear();const n=new p.iyt;if(t)yield s.addFromModelIdMap(t);else for(const[,o]of i.list)s.list.add(o.box);return s.get().getBoundingSphere(n),s.list.clear(),n})()}setupCamera(){const t=window.innerWidth/window.innerHeight,e=new p.ubm(60,t,1,1e3);return e.position.set(50,50,50),e.lookAt(new p.Pq0(0,0,0)),e}newCameraControls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");if(!this.currentWorld.renderer)throw new Error("This camera needs a renderer to work!");Zt.install({THREE:hs.getSubsetOfThree()});const{domElement:t}=this.currentWorld.renderer.three,e=new Zt(this.three,t);return e.smoothTime=.2,e.dollyToCursor=!0,e.infinityDolly=!0,e.minDistance=6,e}setupEvents(t){if(this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),t){if(!this.currentWorld)throw new Error("This camera needs a world to work!");if(!this.currentWorld.renderer)throw new Error("This camera needs a renderer to work!");const{domElement:e}=this.currentWorld.renderer.three;this._resizeObserver=new ResizeObserver(this.updateAspect),this._resizeObserver.observe(e)}}static getSubsetOfThree(){return{MOUSE:p.kBv,Vector2:p.I9Y,Vector3:p.Pq0,Vector4:p.IUQ,Quaternion:p.PTz,Matrix4:p.kn4,Spherical:p.YHV,Box3:p.NRn,Sphere:p.iyt,Raycaster:p.tBo,MathUtils:p.cj9}}}const ll=class Gc extends At{constructor(t){super(t),y(this,"onAfterUpdate",new Q),y(this,"onBeforeUpdate",new Q),y(this,"onDisposed",new Q),y(this,"list",new ot.jp),y(this,"enabled",!0),t.add(Gc.uuid,this)}create(){const t=new Tf(this.components),e=t.uuid;if(this.list.has(e))throw new Error("There is already a world with this name!");return this.list.set(e,t),t}delete(t){if(!this.list.has(t.uuid))throw new Error("The provided world is not found in the list!");this.list.delete(t.uuid),t.dispose()}dispose(){this.enabled=!1;for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}update(t){if(this.enabled)for(const[e,i]of this.list)i.update(t)}};y(ll,"uuid","fdb61dc4-2ec1-4966-b83d-54ea795fad4a");let an=ll;class Of extends Wi{constructor(){super(...arguments),y(this,"_config",{visible:{value:!0,type:"Boolean"},color:{value:new p.Q1f,type:"Color"},primarySize:{type:"Number",interpolable:!0,value:1,min:0,max:1e3},secondarySize:{type:"Number",interpolable:!0,value:10,min:0,max:1e3},distance:{type:"Number",interpolable:!0,value:500,min:0,max:500}})}get visible(){return this._config.visible.value}set visible(t){this._config.visible.value=t,this._component.visible=t}get color(){return this._config.color.value}set color(t){this._config.color.value=t,this._component.material.uniforms.uColor.value=t,this._component.material.uniformsNeedUpdate=!0}get primarySize(){return this._config.primarySize.value}set primarySize(t){this._config.primarySize.value=t,this._component.material.uniforms.uSize1.value=t,this._component.material.uniformsNeedUpdate=!0}get secondarySize(){return this._config.secondarySize.value}set secondarySize(t){this._config.secondarySize.value=t,this._component.material.uniforms.uSize2.value=t,this._component.material.uniformsNeedUpdate=!0}get distance(){return this._config.distance.value}set distance(t){this._config.distance.value=t,this._component.material.uniforms.uDistance.value=t,this._component.material.uniformsNeedUpdate=!0}}class zf{constructor(t,e){y(this,"onDisposed",new Q),y(this,"onSetup",new Q),y(this,"isSetup",!1),y(this,"world"),y(this,"components"),y(this,"config"),y(this,"_defaultConfig",{visible:!0,color:new p.Q1f(12303291),primarySize:1,secondarySize:10,distance:500}),y(this,"three"),y(this,"_fade",3),y(this,"updateZoom",()=>{this.world.camera instanceof hs&&(this.material.uniforms.uZoom.value=this.world.camera.three.zoom)}),this.world=e;const{color:i,primarySize:s,secondarySize:n,distance:o}=this._defaultConfig;this.components=t,this.config=new Of(this,this.components,"Grid");const a=new p.bdM(2,2,1,1),l=new p.BKk({side:p.$EB,uniforms:{uSize1:{value:s},uSize2:{value:n},uColor:{value:i},uDistance:{value:o},uFade:{value:this._fade},uZoom:{value:1}},transparent:!0,vertexShader:"\n \n varying vec3 worldPosition;\n \n uniform float uDistance;\n \n void main() {\n \n vec3 pos = position.xzy * uDistance;\n pos.xz += cameraPosition.xz;\n \n worldPosition = pos;\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n \n }\n ",fragmentShader:"\n \n varying vec3 worldPosition;\n \n uniform float uZoom;\n uniform float uFade;\n uniform float uSize1;\n uniform float uSize2;\n uniform vec3 uColor;\n uniform float uDistance;\n \n \n \n float getGrid(float size) {\n \n vec2 r = worldPosition.xz / size;\n \n \n vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);\n float line = min(grid.x, grid.y);\n \n \n return 1.0 - min(line, 1.0);\n }\n \n void main() {\n \n \n float d = 1.0 - min(distance(cameraPosition.xz, worldPosition.xz) / uDistance, 1.0);\n \n float g1 = getGrid(uSize1);\n float g2 = getGrid(uSize2);\n \n // Ortho camera fades the grid away when zooming out\n float minZoom = step(0.2, uZoom);\n float zoomFactor = pow(min(uZoom, 1.), 2.) * minZoom;\n \n gl_FragColor = vec4(uColor.rgb, mix(g2, g1, g1) * pow(d, uFade));\n gl_FragColor.a = mix(0.5 * gl_FragColor.a, gl_FragColor.a, g2) * zoomFactor;\n \n if ( gl_FragColor.a <= 0.0 ) discard;\n \n \n }\n \n ",extensions:{derivatives:!0}});this.three=new p.eaF(a,l),this.three.frustumCulled=!1,e.scene.three.add(this.three),this.setupEvents(!0)}get visible(){return this.three.visible}set visible(t){this.three.visible=t,t?this.world.scene.three.add(this.three):this.three.removeFromParent()}get material(){return this.three.material}get fade(){return 3===this._fade}set fade(t){this._fade=t?3:0,this.material.uniforms.uFade.value=this._fade}setup(t){const e={...this._defaultConfig,...t};this.config.visible=!0,this.config.color=e.color,this.config.primarySize=e.primarySize,this.config.secondarySize=e.secondarySize,this.config.distance=e.distance,this.isSetup=!0,this.onSetup.trigger()}dispose(){this.setupEvents(!1),this.components.get(Ps).list.delete(this.config.uuid),this.components.get(bi).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset(),this.world=null,this.components=null}setupEvents(t){if(this.world.isDisposing||!(this.world.camera instanceof hs))return;const e=this.world.camera.controls;t?e.addEventListener("update",this.updateZoom):e.removeEventListener("update",this.updateZoom)}}y(class Yc extends At{constructor(t){super(t),y(this,"list",new Map),y(this,"onDisposed",new Q),y(this,"enabled",!0),t.add(Yc.uuid,this)}create(t){if(this.list.has(t.uuid))throw new Error("This world already has a grid!");const e=new zf(this.components,t);return this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)}),e}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}},"uuid","d1e814d5-b81c-4452-87a2-f039375e0489");const cl=class Zc{constructor(){y(this,"onDisposed",new Q),y(this,"list",new ot.jp),y(this,"enabled",!1),y(this,"_timer"),y(this,"onInit",new Q),y(this,"update",()=>{if(!this.enabled)return;this._timer.update();const t=this._timer.getDelta();for(const[e,i]of this.list)i.enabled&&i.isUpdateable()&&i.update(t);requestAnimationFrame(this.update)}),this._timer=new p.M4G,Zc.setupBVH()}add(t,e){if(this.list.has(t))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");ie.validate(t),this.list.set(t,e)}get(t){var e;const i=t.uuid;if(!this.list.has(i)){const s=new t(this);return null!=(e=s.isDisposeable)&&e.call(s)&&s.onDisposed.add(()=>this.list.delete(i)),this.list.has(i)||this.add(i,s),s}return this.list.get(i)}init(){this.enabled=!0;for(const[t,e]of this.list.entries())e.enabled=!0;this._timer.reset(),this.update(),this.onInit.trigger()}dispose(){let t;this.enabled=!1;for(const[e,i]of this.list)i.enabled=!1,e!==ft.uuid?i.isDisposeable()&&i.dispose():t=i;t?.dispose(),this._timer.dispose(),this.onDisposed.trigger()}static setupBVH(){p.LoY.prototype.computeBoundsTree=Pd,p.LoY.prototype.disposeBoundsTree=Sd,p.eaF.prototype.raycast=Pa,p.DXC.prototype.raycast=Pa}};y(cl,"release","2.4.3");let Ar=cl;class Df{constructor(t){y(this,"enabled",!1),y(this,"id","FirstPerson"),this.camera=t}set(t){if(this.enabled=t,t){if("Perspective"!==this.camera.projection.current)return void this.camera.set("Orbit");this.setupFirstPersonCamera()}}setupFirstPersonCamera(){const t=this.camera.controls,e=new p.Pq0;t.distance--,t.getPosition(e),t.minDistance=1,t.maxDistance=1,t.distance=1,t.moveTo(e.x,e.y,e.z),t.truckSpeed=50,t.mouseButtons.wheel=Zt.ACTION.DOLLY,t.touches.two=Zt.ACTION.TOUCH_ZOOM_TRUCK}}class kf{constructor(t){y(this,"enabled",!0),y(this,"id","Orbit"),this.camera=t,this.activateOrbitControls()}set(t){this.enabled=t,t&&this.activateOrbitControls()}activateOrbitControls(){const t=this.camera.controls;t.minDistance=1,t.maxDistance=300;const e=new p.Pq0;t.getPosition(e);const i=e.length();t.distance=i,t.truckSpeed=2;const{rotation:s}=this.camera.three,n=new p.Pq0(0,0,-1).applyEuler(s),o=e.addScaledVector(n,i);t.moveTo(o.x,o.y,o.z)}}class Lf{constructor(t){y(this,"enabled",!1),y(this,"id","Plan"),y(this,"mouseAction1"),y(this,"mouseAction2"),y(this,"mouseInitialized",!1),y(this,"defaultAzimuthSpeed"),y(this,"defaultPolarSpeed"),this.camera=t,this.defaultAzimuthSpeed=t.controls.azimuthRotateSpeed,this.defaultPolarSpeed=t.controls.polarRotateSpeed}set(t){this.enabled=t;const e=this.camera.controls;e.azimuthRotateSpeed=t?0:this.defaultAzimuthSpeed,e.polarRotateSpeed=t?0:this.defaultPolarSpeed,this.mouseInitialized||(this.mouseAction1=e.touches.one,this.mouseAction2=e.touches.two,this.mouseInitialized=!0),t?(e.mouseButtons.left=Zt.ACTION.TRUCK,e.touches.one=Zt.ACTION.TOUCH_TRUCK,e.touches.two=Zt.ACTION.TOUCH_ZOOM):(e.mouseButtons.left=Zt.ACTION.ROTATE,e.touches.one=this.mouseAction1,e.touches.two=this.mouseAction2)}}class Nf{constructor(t){y(this,"onChanged",new Q),y(this,"current","Perspective"),y(this,"camera"),y(this,"matchOrthoDistanceEnabled",!1),y(this,"_component"),y(this,"_previousDistance",-1),this._component=t,this.camera=t.three}set(t){var e=this;return(0,G.A)(function*(){e.current!==t&&("Orthographic"===t?e.setOrthoCamera():yield e.setPerspectiveCamera(),e.onChanged.trigger(e.camera))})()}toggle(){var t=this;return(0,G.A)(function*(){const i="Perspective"===t.current?"Orthographic":"Perspective";yield t.set(i)})()}setOrthoCamera(){if(null===this._component.mode||"FirstPerson"===this._component.mode.id)return;this._previousDistance=this._component.controls.distance,this._component.controls.distance=200;const t=this.getPerspectiveDims();if(!t)return;const{width:e,height:i}=t;this.setupOrthoCamera(i,e),this.camera=this._component.threeOrtho,this.current="Orthographic"}getPerspectiveDims(){const t=this._component.currentWorld;if(!t||!t.renderer)return null;const e=new p.Pq0;this._component.threePersp.getWorldDirection(e);const i=new p.Pq0;this._component.controls.getTarget(i);const n=i.clone().sub(this._component.threePersp.position).dot(e),o=t.renderer.getSize(),a=o.x/o.y,c=2*n*Math.atan(this._component.threePersp.fov*(Math.PI/180)/2);return{width:c*a,height:c}}setupOrthoCamera(t,e){this._component.controls.mouseButtons.wheel=Zt.ACTION.ZOOM,this._component.controls.mouseButtons.middle=Zt.ACTION.ZOOM;const i=this._component.threePersp,s=this._component.threeOrtho;s.zoom=1,s.left=e/-2,s.right=e/2,s.top=t/2,s.bottom=t/-2,s.updateProjectionMatrix(),s.position.copy(i.position),s.quaternion.copy(i.quaternion),this._component.controls.camera=s}getDistance(){const e=this._component.threeOrtho;return(e.top-e.bottom)/e.zoom/(2*Math.atan(this._component.threePersp.fov*(Math.PI/180)/2))}setPerspectiveCamera(){var t=this;return(0,G.A)(function*(){t._component.controls.mouseButtons.wheel=Zt.ACTION.DOLLY,t._component.controls.mouseButtons.middle=Zt.ACTION.DOLLY;const e=t._component.threePersp,i=t._component.threeOrtho;e.position.copy(i.position),e.quaternion.copy(i.quaternion),t._component.controls.mouseButtons.wheel=Zt.ACTION.DOLLY,t._component.controls.distance=t.matchOrthoDistanceEnabled?t.getDistance():t._previousDistance,yield t._component.controls.zoomTo(1),e.updateProjectionMatrix(),t._component.controls.camera=e,t.camera=e,t.current="Perspective"})()}}class ln extends hs{constructor(t){super(t),y(this,"projection"),y(this,"threeOrtho"),y(this,"threePersp"),y(this,"_userInputButtons",{}),y(this,"_frustumSize",50),y(this,"_navigationModes",new Map),y(this,"_mode",null),y(this,"previousSize",null),this.threePersp=this.three,this.threeOrtho=this.newOrthoCamera(),this.projection=new Nf(this),this.onAspectUpdated.add(()=>{this.setOrthoPerspCameraAspect()}),this.projection.onChanged.add(e=>{this.three=e,this.updateAspect()}),this.worlds.onItemSet.add(()=>{this._navigationModes.clear(),this._navigationModes.set("Orbit",new kf(this)),this._navigationModes.set("FirstPerson",new Df(this)),this._navigationModes.set("Plan",new Lf(this)),this._mode=this._navigationModes.get("Orbit"),this.mode.set(!0,{preventTargetAdjustment:!0}),this.currentWorld&&this.currentWorld.renderer&&(this.previousSize=this.currentWorld.renderer.getSize().clone())}),this.worlds.onItemDeleted.add(()=>{this._navigationModes.clear()})}get mode(){if(!this._mode)throw new Error("Mode not found, camera not initialized");return this._mode}dispose(){super.dispose(),this.threeOrtho.removeFromParent()}set(t){if(null!==this.mode&&this.mode.id!==t){if(this.mode.set(!1),!this._navigationModes.has(t))throw new Error("The specified mode does not exist!");this._mode=this._navigationModes.get(t),this.mode.set(!0)}}fit(t){var e=this;return(0,G.A)(function*(i,s=1.5){if(!e.enabled)return;const n=Number.MAX_VALUE,o=Number.MIN_VALUE,a=new p.Pq0(n,n,n),l=new p.Pq0(o,o,o);for(const m of i){const w=(new p.NRn).setFromObject(m);w.min.x<a.x&&(a.x=w.min.x),w.min.y<a.y&&(a.y=w.min.y),w.min.z<a.z&&(a.z=w.min.z),w.max.x>l.x&&(l.x=w.max.x),w.max.y>l.y&&(l.y=w.max.y),w.max.z>l.z&&(l.z=w.max.z)}const c=new p.NRn(a,l),h=e.components.get(ft);if(h.initialized)for(const[,m]of h.list){const w=m.box;w.min.x<a.x&&(a.x=w.min.x),w.min.y<a.y&&(a.y=w.min.y),w.min.z<a.z&&(a.z=w.min.z),w.max.x>l.x&&(l.x=w.max.x),w.max.y>l.y&&(l.y=w.max.y),w.max.z>l.z&&(l.z=w.max.z)}const u=new p.Pq0;c.getSize(u);const f=new p.Pq0;c.getCenter(f);const d=Math.max(u.x,u.y,u.z)*s,_=new p.iyt(f,d);yield e.controls.fitToSphere(_,!0)}).apply(this,arguments)}setUserInput(t){t?this.enableUserInput():this.disableUserInput()}addCustomNavigationMode(t){this._navigationModes.set(t.id,t)}disableUserInput(){this._userInputButtons.left=this.controls.mouseButtons.left,this._userInputButtons.right=this.controls.mouseButtons.right,this._userInputButtons.middle=this.controls.mouseButtons.middle,this._userInputButtons.wheel=this.controls.mouseButtons.wheel,this.controls.mouseButtons.left=0,this.controls.mouseButtons.right=0,this.controls.mouseButtons.middle=0,this.controls.mouseButtons.wheel=0}enableUserInput(){0!==Object.keys(this._userInputButtons).length&&(this.controls.mouseButtons.left=this._userInputButtons.left,this.controls.mouseButtons.right=this._userInputButtons.right,this.controls.mouseButtons.middle=this._userInputButtons.middle,this.controls.mouseButtons.wheel=this._userInputButtons.wheel)}newOrthoCamera(){const t=window.innerWidth/window.innerHeight;return new p.qUd(this._frustumSize*t/-2,this._frustumSize*t/2,this._frustumSize/2,this._frustumSize/-2,.1,1e3)}setOrthoPerspCameraAspect(){if(!this.currentWorld||!this.currentWorld.renderer||!this.previousSize)return;const t=this.currentWorld.renderer.getSize(),o=this.threeOrtho.top*(t.y/this.previousSize.y),a=this.threeOrtho.right*(t.x/this.previousSize.x);this.threeOrtho.left=-a,this.threeOrtho.right=a,this.threeOrtho.top=o,this.threeOrtho.bottom=-o,this.threeOrtho.updateProjectionMatrix(),this.previousSize.copy(t)}}var cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function hn(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 hl={exports:{}};hl.exports=function e(i,s,n){function o(c,h){if(!s[c]){if(!i[c]){if(!h&&hn)return hn(c);if(a)return a(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var d=s[c]={exports:{}};i[c][0].call(d.exports,function(_){return o(i[c][1][_]||_)},d,d.exports,e,i,s,n)}return s[c].exports}for(var a=hn,l=0;l<n.length;l++)o(n[l]);return o}({1:[function(e,i,s){var n=e("./utils"),o=e("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.encode=function(l){for(var c,h,u,d,_,m,w=[],g=0,v=l.length,T=v,C="string"!==n.getTypeOf(l);g<l.length;)T=v-g,u=C?(c=l[g++],h=g<v?l[g++]:0,g<v?l[g++]:0):(c=l.charCodeAt(g++),h=g<v?l.charCodeAt(g++):0,g<v?l.charCodeAt(g++):0),d=(3&c)<<4|h>>4,_=1<T?(15&h)<<2|u>>6:64,m=2<T?63&u:64,w.push(a.charAt(c>>2)+a.charAt(d)+a.charAt(_)+a.charAt(m));return w.join("")},s.decode=function(l){var c,h,u,f,d,_,m=0,w=0,g="data:";if(l.substr(0,5)===g)throw new Error("Invalid base64 input, it looks like a data url.");var v,T=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&T--,l.charAt(l.length-2)===a.charAt(64)&&T--,T%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=o.uint8array?new Uint8Array(0|T):new Array(0|T);m<l.length;)c=a.indexOf(l.charAt(m++))<<2|(f=a.indexOf(l.charAt(m++)))>>4,h=(15&f)<<4|(d=a.indexOf(l.charAt(m++)))>>2,u=(3&d)<<6|(_=a.indexOf(l.charAt(m++))),v[w++]=c,64!==d&&(v[w++]=h),64!==_&&(v[w++]=u);return v}},{"./support":30,"./utils":32}],2:[function(e,i,s){var n=e("./external"),o=e("./stream/DataWorker"),a=e("./stream/Crc32Probe"),l=e("./stream/DataLengthProbe");function c(h,u,f,d,_){this.compressedSize=h,this.uncompressedSize=u,this.crc32=f,this.compression=d,this.compressedContent=_}c.prototype={getContentWorker:function(){var h=new o(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),u=this;return h.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),h},getCompressedWorker:function(){return new o(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(h,u,f){return h.pipe(new a).pipe(new l("uncompressedSize")).pipe(u.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression",u)},i.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,i,s){var n=e("./stream/GenericWorker");s.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},s.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,i,s){var n=e("./utils"),o=function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var h=0;h<8;h++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l}();i.exports=function(a,l){return void 0!==a&&a.length?"string"!==n.getTypeOf(a)?function(c,h,u){var d=o,_=0+u;c^=-1;for(var m=0;m<_;m++)c=c>>>8^d[255&(c^h[m])];return-1^c}(0|l,a,a.length):function(c,h,u){var d=o,_=0+u;c^=-1;for(var m=0;m<_;m++)c=c>>>8^d[255&(c^h.charCodeAt(m))];return-1^c}(0|l,a,a.length):0}},{"./utils":32}],5:[function(e,i,s){s.base64=!1,s.binary=!1,s.dir=!1,s.createFolders=!0,s.date=null,s.compression=null,s.compressionOptions=null,s.comment=null,s.unixPermissions=null,s.dosPermissions=null},{}],6:[function(e,i,s){var n;n=typeof Promise<"u"?Promise:e("lie"),i.exports={Promise:n}},{lie:37}],7:[function(e,i,s){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=e("pako"),a=e("./utils"),l=e("./stream/GenericWorker"),c=n?"uint8array":"array";function h(u,f){l.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=f,this.meta={}}s.magic="\b\0",a.inherits(h,l),h.prototype.processChunk=function(u){this.meta=u.meta,null===this._pako&&this._createPako(),this._pako.push(a.transformTo(c,u.data),!1)},h.prototype.flush=function(){l.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(f){u.push({data:f,meta:u.meta})}},s.compressWorker=function(u){return new h("Deflate",u)},s.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,i,s){function n(d,_){var m,w="";for(m=0;m<_;m++)w+=String.fromCharCode(255&d),d>>>=8;return w}function o(d,_,m,w,g,v){var T,C,S=d.file,M=d.compression,A=v!==c.utf8encode,O=a.transformTo("string",v(S.name)),I=a.transformTo("string",c.utf8encode(S.name)),D=S.comment,B=a.transformTo("string",v(D)),E=a.transformTo("string",c.utf8encode(D)),L=I.length!==S.name.length,x=E.length!==D.length,N="",Y="",q="",ct=S.dir,Z=S.date,at={crc32:0,compressedSize:0,uncompressedSize:0};_&&!m||(at.crc32=d.crc32,at.compressedSize=d.compressedSize,at.uncompressedSize=d.uncompressedSize);var F=0;_&&(F|=8),A||!L&&!x||(F|=2048);var J,St,V=0,nt=0;ct&&(V|=16),"UNIX"===g?(nt=798,V|=(St=J=S.unixPermissions,J||(St=ct?16893:33204),(65535&St)<<16)):(nt=20,V|=function(J){return 63&(J||0)}(S.dosPermissions)),T=Z.getUTCHours(),T<<=6,T|=Z.getUTCMinutes(),T<<=5,T|=Z.getUTCSeconds()/2,C=Z.getUTCFullYear()-1980,C<<=4,C|=Z.getUTCMonth()+1,C<<=5,C|=Z.getUTCDate(),L&&(Y=n(1,1)+n(h(O),4)+I,N+="up"+n(Y.length,2)+Y),x&&(q=n(1,1)+n(h(B),4)+E,N+="uc"+n(q.length,2)+q);var it="";return it+="\n\0",it+=n(F,2),it+=M.magic,it+=n(T,2),it+=n(C,2),it+=n(at.crc32,4),it+=n(at.compressedSize,4),it+=n(at.uncompressedSize,4),it+=n(O.length,2),it+=n(N.length,2),{fileRecord:u.LOCAL_FILE_HEADER+it+O+N,dirRecord:u.CENTRAL_FILE_HEADER+n(nt,2)+it+n(B.length,2)+"\0\0\0\0"+n(V,4)+n(w,4)+O+N+B}}var a=e("../utils"),l=e("../stream/GenericWorker"),c=e("../utf8"),h=e("../crc32"),u=e("../signature");function f(d,_,m,w){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=m,this.encodeFileName=w,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(f,l),f.prototype.push=function(d){var _=d.meta.percent||0,m=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,l.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:m?(_+100*(m-w-1))/m:100}}))},f.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var _=this.streamFiles&&!d.file.dir;if(_){var m=o(d,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(d){this.accumulate=!1;var w,_=this.streamFiles&&!d.file.dir,m=o(d,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),_)this.push({data:(w=d,u.DATA_DESCRIPTOR+n(w.crc32,4)+n(w.compressedSize,4)+n(w.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var d=this.bytesWritten,_=0;_<this.dirRecords.length;_++)this.push({data:this.dirRecords[_],meta:{percent:100}});var g,v,T,M,w=(g=this.dirRecords.length,v=this.bytesWritten-d,T=d,M=a.transformTo("string",(0,this.encodeFileName)(this.zipComment)),u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+n(g,2)+n(g,2)+n(v,4)+n(T,4)+n(M.length,2)+M);this.push({data:w,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(d){this._sources.push(d);var _=this;return d.on("data",function(m){_.processChunk(m)}),d.on("end",function(){_.closedSource(_.previous.streamInfo),_._sources.length?_.prepareNextSource():_.end()}),d.on("error",function(m){_.error(m)}),this},f.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},f.prototype.error=function(d){var _=this._sources;if(!l.prototype.error.call(this,d))return!1;for(var m=0;m<_.length;m++)try{_[m].error(d)}catch{}return!0},f.prototype.lock=function(){l.prototype.lock.call(this);for(var d=this._sources,_=0;_<d.length;_++)d[_].lock()},i.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,i,s){var n=e("../compressions"),o=e("./ZipFileWorker");s.generateWorker=function(a,l,c){var h=new o(l.streamFiles,c,l.platform,l.encodeFileName),u=0;try{a.forEach(function(f,d){u++;var _=function(v,T){var C=v||T,S=n[C];if(!S)throw new Error(C+" is not a valid compression method !");return S}(d.options.compression,l.compression),w=d.dir,g=d.date;d._compressWorker(_,d.options.compressionOptions||l.compressionOptions||{}).withStreamInfo("file",{name:f,dir:w,date:g,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(h)}),h.entriesCount=u}catch(f){h.error(f)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,i,s){function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new n;for(var a in this)"function"!=typeof this[a]&&(o[a]=this[a]);return o}}(n.prototype=e("./object")).loadAsync=e("./load"),n.support=e("./support"),n.defaults=e("./defaults"),n.version="3.10.1",n.loadAsync=function(o,a){return(new n).loadAsync(o,a)},n.external=e("./external"),i.exports=n},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,i,s){var n=e("./utils"),o=e("./external"),a=e("./utf8"),l=e("./zipEntries"),c=e("./stream/Crc32Probe"),h=e("./nodejsUtils");function u(f){return new o.Promise(function(d,_){var m=f.decompressed.getContentWorker().pipe(new c);m.on("error",function(w){_(w)}).on("end",function(){m.streamInfo.crc32!==f.decompressed.crc32?_(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(f,d){var _=this;return d=n.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),h.isNode&&h.isStream(f)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):n.prepareContent("the loaded zip file",f,!0,d.optimizedBinaryString,d.base64).then(function(m){var w=new l(d);return w.load(m),w}).then(function(m){var w=[o.Promise.resolve(m)],g=m.files;if(d.checkCRC32)for(var v=0;v<g.length;v++)w.push(u(g[v]));return o.Promise.all(w)}).then(function(m){for(var w=m.shift(),g=w.files,v=0;v<g.length;v++){var T=g[v],C=T.fileNameStr,S=n.resolve(T.fileNameStr);_.file(S,T.decompressed,{binary:!0,optimizedBinaryString:!0,date:T.date,dir:T.dir,comment:T.fileCommentStr.length?T.fileCommentStr:null,unixPermissions:T.unixPermissions,dosPermissions:T.dosPermissions,createFolders:d.createFolders}),T.dir||(_.file(S).unsafeOriginalName=C)}return w.zipComment.length&&(_.comment=w.zipComment),_})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,i,s){var n=e("../utils"),o=e("../stream/GenericWorker");function a(l,c){o.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}n.inherits(a,o),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(h){c.push({data:h,meta:{percent:0}})}).on("error",function(h){c.isPaused?this.generatedError=h:c.error(h)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,i,s){var n=e("readable-stream").Readable;function o(a,l,c){n.call(this,l),this._helper=a;var h=this;a.on("data",function(u,f){h.push(u)||h._helper.pause(),c&&c(f)}).on("error",function(u){h.emit("error",u)}).on("end",function(){h.push(null)})}e("../utils").inherits(o,n),o.prototype._read=function(){this._helper.resume()},i.exports=o},{"../utils":32,"readable-stream":16}],14:[function(e,i,s){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(n,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(n,o);if("number"==typeof n)throw new Error('The "data" argument must not be a number');return new Buffer(n,o)},allocBuffer:function(n){if(Buffer.alloc)return Buffer.alloc(n);var o=new Buffer(n);return o.fill(0),o},isBuffer:function(n){return Buffer.isBuffer(n)},isStream:function(n){return n&&"function"==typeof n.on&&"function"==typeof n.pause&&"function"==typeof n.resume}}},{}],15:[function(e,i,s){function n(S,M,A){var O,I=a.getTypeOf(M),D=a.extend(A||{},h);D.date=D.date||new Date,null!==D.compression&&(D.compression=D.compression.toUpperCase()),"string"==typeof D.unixPermissions&&(D.unixPermissions=parseInt(D.unixPermissions,8)),D.unixPermissions&&16384&D.unixPermissions&&(D.dir=!0),D.dosPermissions&&16&D.dosPermissions&&(D.dir=!0),D.dir&&(S=g(S)),D.createFolders&&(O=w(S))&&v.call(this,O,!0),A&&void 0!==A.binary||(D.binary=!("string"===I&&!1===D.binary&&!1===D.base64)),(M instanceof u&&0===M.uncompressedSize||D.dir||!M||0===M.length)&&(D.base64=!1,D.binary=!0,M="",D.compression="STORE",I="string");var E;E=M instanceof u||M instanceof l?M:_.isNode&&_.isStream(M)?new m(S,M):a.prepareContent(S,M,D.binary,D.optimizedBinaryString,D.base64);var L=new f(S,E,D);this.files[S]=L}var o=e("./utf8"),a=e("./utils"),l=e("./stream/GenericWorker"),c=e("./stream/StreamHelper"),h=e("./defaults"),u=e("./compressedObject"),f=e("./zipObject"),d=e("./generate"),_=e("./nodejsUtils"),m=e("./nodejs/NodejsStreamInputAdapter"),w=function(S){"/"===S.slice(-1)&&(S=S.substring(0,S.length-1));var M=S.lastIndexOf("/");return 0<M?S.substring(0,M):""},g=function(S){return"/"!==S.slice(-1)&&(S+="/"),S},v=function(S,M){return M=void 0!==M?M:h.createFolders,S=g(S),this.files[S]||n.call(this,S,null,{dir:!0,createFolders:M}),this.files[S]};function T(S){return"[object RegExp]"===Object.prototype.toString.call(S)}var C={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(S){var M,A,O;for(M in this.files)O=this.files[M],(A=M.slice(this.root.length,M.length))&&M.slice(0,this.root.length)===this.root&&S(A,O)},filter:function(S){var M=[];return this.forEach(function(A,O){S(A,O)&&M.push(O)}),M},file:function(S,M,A){if(1!==arguments.length)return n.call(this,S=this.root+S,M,A),this;if(T(S)){var O=S;return this.filter(function(D,B){return!B.dir&&O.test(D)})}var I=this.files[this.root+S];return I&&!I.dir?I:null},folder:function(S){if(!S)return this;if(T(S))return this.filter(function(I,D){return D.dir&&S.test(I)});var A=v.call(this,this.root+S),O=this.clone();return O.root=A.name,O},remove:function(S){var M=this.files[S=this.root+S];if(M||("/"!==S.slice(-1)&&(S+="/"),M=this.files[S]),M&&!M.dir)delete this.files[S];else for(var A=this.filter(function(I,D){return D.name.slice(0,S.length)===S}),O=0;O<A.length;O++)delete this.files[A[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(S){var M,A={};try{if((A=a.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=A.type.toLowerCase(),A.compression=A.compression.toUpperCase(),"binarystring"===A.type&&(A.type="string"),!A.type)throw new Error("No output type specified.");a.checkSupport(A.type),"darwin"!==A.platform&&"freebsd"!==A.platform&&"linux"!==A.platform&&"sunos"!==A.platform||(A.platform="UNIX"),"win32"===A.platform&&(A.platform="DOS"),M=d.generateWorker(this,A,A.comment||this.comment||"")}catch(I){(M=new l("error")).error(I)}return new c(M,A.type||"string",A.mimeType)},generateAsync:function(S,M){return this.generateInternalStream(S).accumulate(M)},generateNodeStream:function(S,M){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(M)}};i.exports=C},{"./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(e,i,s){i.exports=e("stream")},{stream:void 0}],17:[function(e,i,s){var n=e("./DataReader");function o(a){n.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}e("../utils").inherits(o,n),o.prototype.byteAt=function(a){return this.data[this.zero+a]},o.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),u=a.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===l&&this.data[f+1]===c&&this.data[f+2]===h&&this.data[f+3]===u)return f-this.zero;return-1},o.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),u=a.charCodeAt(3),f=this.readData(4);return l===f[0]&&c===f[1]&&h===f[2]&&u===f[3]},o.prototype.readData=function(a){if(this.checkOffset(a),0===a)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=o},{"../utils":32,"./DataReader":18}],18:[function(e,i,s){var n=e("../utils");function o(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return n.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))}},i.exports=o},{"../utils":32}],19:[function(e,i,s){var n=e("./Uint8ArrayReader");function o(a){n.call(this,a)}e("../utils").inherits(o,n),o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,i,s){var n=e("./DataReader");function o(a){n.call(this,a)}e("../utils").inherits(o,n),o.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},o.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},o.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=o},{"../utils":32,"./DataReader":18}],21:[function(e,i,s){var n=e("./ArrayReader");function o(a){n.call(this,a)}e("../utils").inherits(o,n),o.prototype.readData=function(a){if(this.checkOffset(a),0===a)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(e,i,s){var n=e("../utils"),o=e("../support"),a=e("./ArrayReader"),l=e("./StringReader"),c=e("./NodeBufferReader"),h=e("./Uint8ArrayReader");i.exports=function(u){var f=n.getTypeOf(u);return n.checkSupport(f),"string"!==f||o.uint8array?"nodebuffer"===f?new c(u):o.uint8array?new h(n.transformTo("uint8array",u)):new a(n.transformTo("array",u)):new l(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,i,s){s.LOCAL_FILE_HEADER="PK\x03\x04",s.CENTRAL_FILE_HEADER="PK\x01\x02",s.CENTRAL_DIRECTORY_END="PK\x05\x06",s.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x06\x07",s.ZIP64_CENTRAL_DIRECTORY_END="PK\x06\x06",s.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,i,s){var n=e("./GenericWorker"),o=e("../utils");function a(l){n.call(this,"ConvertWorker to "+l),this.destType=l}o.inherits(a,n),a.prototype.processChunk=function(l){this.push({data:o.transformTo(this.destType,l.data),meta:l.meta})},i.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(e,i,s){var n=e("./GenericWorker"),o=e("../crc32");function a(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(a,n),a.prototype.processChunk=function(l){this.streamInfo.crc32=o(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,i,s){var n=e("../utils"),o=e("./GenericWorker");function a(l){o.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}n.inherits(a,o),a.prototype.processChunk=function(l){l&&(this.streamInfo[this.propName]=(this.streamInfo[this.propName]||0)+l.data.length),o.prototype.processChunk.call(this,l)},i.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(e,i,s){var n=e("../utils"),o=e("./GenericWorker");function a(l){o.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(h){c.dataIsReady=!0,c.data=h,c.max=h&&h.length||0,c.type=n.getTypeOf(h),c.isPaused||c._tickAndRepeat()},function(h){c.error(h)})}n.inherits(a,o),a.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(e,i,s){function n(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,a){return this._listeners[o].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,a){if(this._listeners[o])for(var l=0;l<this._listeners[o].length;l++)this._listeners[o][l].call(this,a)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var a=this;return o.on("data",function(l){a.processChunk(l)}),o.on("end",function(){a.end()}),o.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,a){return this.extraStreamInfo[o]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},i.exports=n},{}],29:[function(e,i,s){var n=e("../utils"),o=e("./ConvertWorker"),a=e("./GenericWorker"),l=e("../base64"),c=e("../support"),h=e("../external"),u=null;if(c.nodestream)try{u=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function d(_,m,w){var g=m;switch(m){case"blob":case"arraybuffer":g="uint8array";break;case"base64":g="string"}try{this._internalType=g,this._outputType=m,this._mimeType=w,n.checkSupport(g),this._worker=_.pipe(new o(g)),_.lock()}catch(v){this._worker=new a("error"),this._worker.error(v)}}d.prototype={accumulate:function(_){return function f(_,m){return new h.Promise(function(w,g){var v=[],T=_._internalType,C=_._outputType,S=_._mimeType;_.on("data",function(M,A){v.push(M),m&&m(A)}).on("error",function(M){v=[],g(M)}).on("end",function(){try{var M=function(A,O,I){switch(A){case"blob":return n.newBlob(n.transformTo("arraybuffer",O),I);case"base64":return l.encode(O);default:return n.transformTo(A,O)}}(C,function(A,O){var I,D=0,B=null,E=0;for(I=0;I<O.length;I++)E+=O[I].length;switch(A){case"string":return O.join("");case"array":return Array.prototype.concat.apply([],O);case"uint8array":for(B=new Uint8Array(E),I=0;I<O.length;I++)B.set(O[I],D),D+=O[I].length;return B;case"nodebuffer":return Buffer.concat(O);default:throw new Error("concat : unsupported type '"+A+"'")}}(T,v),S);w(M)}catch(A){g(A)}v=[]}).resume()})}(this,_)},on:function(_,m){var w=this;return this._worker.on(_,"data"===_?function(g){m.call(w,g.data,g.meta)}:function(){n.delay(m,arguments,w)}),this},resume:function(){return n.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(_){if(n.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:"nodebuffer"!==this._outputType},_)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,i,s){if(s.base64=!0,s.array=!0,s.string=!0,s.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",s.nodebuffer=typeof Buffer<"u",s.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")s.blob=!1;else{var n=new ArrayBuffer(0);try{s.blob=0===new Blob([n],{type:"application/zip"}).size}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(n),s.blob=0===o.getBlob("application/zip").size}catch{s.blob=!1}}}try{s.nodestream=!!e("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(e,i,s){for(var n=e("./utils"),o=e("./support"),a=e("./nodejsUtils"),l=e("./stream/GenericWorker"),c=new Array(256),h=0;h<256;h++)c[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;function u(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}c[254]=c[254]=1,s.utf8encode=function(d){return o.nodebuffer?a.newBufferFrom(d,"utf-8"):function(_){var m,w,g,v,T,C=_.length,S=0;for(v=0;v<C;v++)55296==(64512&(w=_.charCodeAt(v)))&&v+1<C&&56320==(64512&(g=_.charCodeAt(v+1)))&&(w=65536+(w-55296<<10)+(g-56320),v++),S+=w<128?1:w<2048?2:w<65536?3:4;for(m=o.uint8array?new Uint8Array(S):new Array(S),v=T=0;T<S;v++)55296==(64512&(w=_.charCodeAt(v)))&&v+1<C&&56320==(64512&(g=_.charCodeAt(v+1)))&&(w=65536+(w-55296<<10)+(g-56320),v++),w<128?m[T++]=w:(w<2048?m[T++]=192|w>>>6:(w<65536?m[T++]=224|w>>>12:(m[T++]=240|w>>>18,m[T++]=128|w>>>12&63),m[T++]=128|w>>>6&63),m[T++]=128|63&w);return m}(d)},s.utf8decode=function(d){return o.nodebuffer?n.transformTo("nodebuffer",d).toString("utf-8"):function(_){var m,w,g,v,T=_.length,C=new Array(2*T);for(m=w=0;m<T;)if((g=_[m++])<128)C[w++]=g;else if(4<(v=c[g]))C[w++]=65533,m+=v-1;else{for(g&=2===v?31:3===v?15:7;1<v&&m<T;)g=g<<6|63&_[m++],v--;1<v?C[w++]=65533:g<65536?C[w++]=g:(C[w++]=55296|(g-=65536)>>10&1023,C[w++]=56320|1023&g)}return C.length!==w&&(C.subarray?C=C.subarray(0,w):C.length=w),n.applyFromCharCode(C)}(d=n.transformTo(o.uint8array?"uint8array":"array",d))},n.inherits(u,l),u.prototype.processChunk=function(d){var _=n.transformTo(o.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var m=_;(_=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),_.set(m,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var w=function(v,T){var C;for((T=T||v.length)>v.length&&(T=v.length),C=T-1;0<=C&&128==(192&v[C]);)C--;return C<0||0===C?T:C+c[v[C]]>T?C:T}(_),g=_;w!==_.length&&(o.uint8array?(g=_.subarray(0,w),this.leftOver=_.subarray(w,_.length)):(g=_.slice(0,w),this.leftOver=_.slice(w,_.length))),this.push({data:s.utf8decode(g),meta:d.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=u,n.inherits(f,l),f.prototype.processChunk=function(d){this.push({data:s.utf8encode(d.data),meta:d.meta})},s.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,i,s){var n=e("./support"),o=e("./base64"),a=e("./nodejsUtils"),l=e("./external");function c(m){return m}function h(m,w){for(var g=0;g<m.length;++g)w[g]=255&m.charCodeAt(g);return w}e("setimmediate"),s.newBlob=function(m,w){s.checkSupport("blob");try{return new Blob([m],{type:w})}catch{try{var g=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return g.append(m),g.getBlob(w)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(m,w,g){var v=[],T=0,C=m.length;if(C<=g)return String.fromCharCode.apply(null,m);for(;T<C;)v.push(String.fromCharCode.apply(null,"array"===w||"nodebuffer"===w?m.slice(T,Math.min(T+g,C)):m.subarray(T,Math.min(T+g,C)))),T+=g;return v.join("")},stringifyByChar:function(m){for(var w="",g=0;g<m.length;g++)w+=String.fromCharCode(m[g]);return w},applyCanBeUsed:{uint8array:function(){try{return n.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch{return!1}}(),nodebuffer:function(){try{return n.nodebuffer&&1===String.fromCharCode.apply(null,a.allocBuffer(1)).length}catch{return!1}}()}};function f(m){var w=65536,g=s.getTypeOf(m),v=!0;if("uint8array"===g?v=u.applyCanBeUsed.uint8array:"nodebuffer"===g&&(v=u.applyCanBeUsed.nodebuffer),v)for(;1<w;)try{return u.stringifyByChunk(m,g,w)}catch{w=Math.floor(w/2)}return u.stringifyByChar(m)}function d(m,w){for(var g=0;g<m.length;g++)w[g]=m[g];return w}s.applyFromCharCode=f;var _={};_.string={string:c,array:function(m){return h(m,new Array(m.length))},arraybuffer:function(m){return _.string.uint8array(m).buffer},uint8array:function(m){return h(m,new Uint8Array(m.length))},nodebuffer:function(m){return h(m,a.allocBuffer(m.length))}},_.array={string:f,array:c,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},_.arraybuffer={string:function(m){return f(new Uint8Array(m))},array:function(m){return d(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:c,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},_.uint8array={string:f,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:c,nodebuffer:function(m){return a.newBufferFrom(m)}},_.nodebuffer={string:f,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return _.nodebuffer.uint8array(m).buffer},uint8array:function(m){return d(m,new Uint8Array(m.length))},nodebuffer:c},s.transformTo=function(m,w){if(w=w||"",!m)return w;s.checkSupport(m);var g=s.getTypeOf(w);return _[g][m](w)},s.resolve=function(m){for(var w=m.split("/"),g=[],v=0;v<w.length;v++){var T=w[v];"."===T||""===T&&0!==v&&v!==w.length-1||(".."===T?g.pop():g.push(T))}return g.join("/")},s.getTypeOf=function(m){return"string"==typeof m?"string":"[object Array]"===Object.prototype.toString.call(m)?"array":n.nodebuffer&&a.isBuffer(m)?"nodebuffer":n.uint8array&&m instanceof Uint8Array?"uint8array":n.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},s.checkSupport=function(m){if(!n[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},s.MAX_VALUE_16BITS=65535,s.MAX_VALUE_32BITS=-1,s.pretty=function(m){var w,g,v="";for(g=0;g<(m||"").length;g++)v+="\\x"+((w=m.charCodeAt(g))<16?"0":"")+w.toString(16).toUpperCase();return v},s.delay=function(m,w,g){setImmediate(function(){m.apply(g||null,w||[])})},s.inherits=function(m,w){function g(){}g.prototype=w.prototype,m.prototype=new g},s.extend=function(){var m,w,g={};for(m=0;m<arguments.length;m++)for(w in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],w)&&void 0===g[w]&&(g[w]=arguments[m][w]);return g},s.prepareContent=function(m,w,g,v,T){return l.Promise.resolve(w).then(function(C){return n.blob&&(C instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(C)))&&typeof FileReader<"u"?new l.Promise(function(S,M){var A=new FileReader;A.onload=function(O){S(O.target.result)},A.onerror=function(O){M(O.target.error)},A.readAsArrayBuffer(C)}):C}).then(function(C){var M,S=s.getTypeOf(C);return S?("arraybuffer"===S?C=s.transformTo("uint8array",C):"string"===S&&(T?C=o.decode(C):g&&!0!==v&&(C=h(M=C,n.uint8array?new Uint8Array(M.length):new Array(M.length)))),C):l.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,i,s){var n=e("./reader/readerFor"),o=e("./utils"),a=e("./signature"),l=e("./zipEntry"),c=e("./support");function h(u){this.files=[],this.loadOptions=u}h.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(f)+", expected "+o.pretty(u)+")")}},isSignature:function(u,f){var d=this.reader.index;this.reader.setIndex(u);var _=this.reader.readString(4)===f;return this.reader.setIndex(d),_},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var u=this.reader.readData(this.zipCommentLength),d=o.transformTo(c.uint8array?"uint8array":"array",u);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,f,d,_=this.zip64EndOfCentralSize-44;0<_;)u=this.reader.readInt(2),f=this.reader.readInt(4),d=this.reader.readData(f),this.zip64ExtensibleData[u]={id:u,length:f,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,f;for(u=0;u<this.files.length;u++)this.reader.setIndex((f=this.files[u]).localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(u=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var u=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(u);var f=u;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(u=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var _=f-d;if(0<_)this.isSignature(f,a.CENTRAL_FILE_HEADER)||(this.reader.zero=_);else if(_<0)throw new Error("Corrupted zip: missing "+Math.abs(_)+" bytes.")},prepareReader:function(u){this.reader=n(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,i,s){var n=e("./reader/readerFor"),o=e("./utils"),a=e("./compressedObject"),l=e("./crc32"),c=e("./utf8"),h=e("./compressions"),u=e("./support");function f(d,_){this.options=d,this.loadOptions=_}f.prototype={isEncrypted:function(){return!(1&~this.bitFlag)},useUTF8:function(){return!(2048&~this.bitFlag)},readLocalPart:function(d){var _,m;if(d.skip(22),this.fileNameLength=d.readInt(2),m=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(m),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(_=function(w){for(var g in h)if(Object.prototype.hasOwnProperty.call(h,g)&&h[g].magic===w)return h[g];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,_,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var _=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(_),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==d&&(this.dosPermissions=63&this.externalFileAttributes),3==d&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=n(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var _,m,w,g=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<g;)_=d.readInt(2),m=d.readInt(2),w=d.readData(m),this.extraFields[_]={id:_,length:m,value:w};d.setIndex(g)},handleUTF8:function(){var d=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var _=this.findExtraFieldUnicodePath();if(null!==_)this.fileNameStr=_;else{var m=o.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var w=this.findExtraFieldUnicodeComment();if(null!==w)this.fileCommentStr=w;else{var g=o.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(g)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var _=n(d.value);return 1!==_.readInt(1)||l(this.fileName)!==_.readInt(4)?null:c.utf8decode(_.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var _=n(d.value);return 1!==_.readInt(1)||l(this.fileComment)!==_.readInt(4)?null:c.utf8decode(_.readData(d.length-5))}return null}},i.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,i,s){function n(_,m,w){this.name=_,this.dir=w.dir,this.date=w.date,this.comment=w.comment,this.unixPermissions=w.unixPermissions,this.dosPermissions=w.dosPermissions,this._data=m,this._dataBinary=w.binary,this.options={compression:w.compression,compressionOptions:w.compressionOptions}}var o=e("./stream/StreamHelper"),a=e("./stream/DataWorker"),l=e("./utf8"),c=e("./compressedObject"),h=e("./stream/GenericWorker");n.prototype={internalStream:function(_){var m=null,w="string";try{if(!_)throw new Error("No output type specified.");var g="string"===(w=_.toLowerCase())||"text"===w;"binarystring"!==w&&"text"!==w||(w="string"),m=this._decompressWorker();var v=!this._dataBinary;v&&!g&&(m=m.pipe(new l.Utf8EncodeWorker)),!v&&g&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(T){(m=new h("error")).error(T)}return new o(m,w,"")},async:function(_,m){return this.internalStream(_).accumulate(m)},nodeStream:function(_,m){return this.internalStream(_||"nodebuffer").toNodejsStream(m)},_compressWorker:function(_,m){if(this._data instanceof c&&this._data.compression.magic===_.magic)return this._data.getCompressedWorker();var w=this._decompressWorker();return this._dataBinary||(w=w.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(w,_,m)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof h?this._data:new a(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<u.length;d++)n.prototype[u[d]]=f;i.exports=n},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,i,s){(function(n){var o,a,l=n.MutationObserver||n.WebKitMutationObserver;if(l){var c=0,h=new l(_),u=n.document.createTextNode("");h.observe(u,{characterData:!0}),o=function(){u.data=c=++c%2}}else if(n.setImmediate||void 0===n.MessageChannel)o="document"in n&&"onreadystatechange"in n.document.createElement("script")?function(){var m=n.document.createElement("script");m.onreadystatechange=function(){_(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},n.document.documentElement.appendChild(m)}:function(){setTimeout(_,0)};else{var f=new n.MessageChannel;f.port1.onmessage=_,o=function(){f.port2.postMessage(0)}}var d=[];function _(){var m,w;a=!0;for(var g=d.length;g;){for(w=d,d=[],m=-1;++m<g;)w[m]();g=d.length}a=!1}i.exports=function(m){1!==d.push(m)||a||o()}}).call(this,typeof cn<"u"?cn:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(e,i,s){var n=e("immediate");function o(){}var a={},l=["REJECTED"],c=["FULFILLED"],h=["PENDING"];function u(g){if("function"!=typeof g)throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,g!==o&&m(this,g)}function f(g,v,T){this.promise=g,"function"==typeof v&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),"function"==typeof T&&(this.onRejected=T,this.callRejected=this.otherCallRejected)}function d(g,v,T){n(function(){var C;try{C=v(T)}catch(S){return a.reject(g,S)}C===g?a.reject(g,new TypeError("Cannot resolve promise with itself")):a.resolve(g,C)})}function _(g){var v=g&&g.then;if(g&&("object"==typeof g||"function"==typeof g)&&"function"==typeof v)return function(){v.apply(g,arguments)}}function m(g,v){var T=!1;function C(A){T||(T=!0,a.reject(g,A))}function S(A){T||(T=!0,a.resolve(g,A))}var M=w(function(){v(S,C)});"error"===M.status&&C(M.value)}function w(g,v){var T={};try{T.value=g(v),T.status="success"}catch(C){T.status="error",T.value=C}return T}(i.exports=u).prototype.finally=function(g){if("function"!=typeof g)return this;var v=this.constructor;return this.then(function(T){return v.resolve(g()).then(function(){return T})},function(T){return v.resolve(g()).then(function(){throw T})})},u.prototype.catch=function(g){return this.then(null,g)},u.prototype.then=function(g,v){if("function"!=typeof g&&this.state===c||"function"!=typeof v&&this.state===l)return this;var T=new this.constructor(o);return this.state!==h?d(T,this.state===c?g:v,this.outcome):this.queue.push(new f(T,g,v)),T},f.prototype.callFulfilled=function(g){a.resolve(this.promise,g)},f.prototype.otherCallFulfilled=function(g){d(this.promise,this.onFulfilled,g)},f.prototype.callRejected=function(g){a.reject(this.promise,g)},f.prototype.otherCallRejected=function(g){d(this.promise,this.onRejected,g)},a.resolve=function(g,v){var T=w(_,v);if("error"===T.status)return a.reject(g,T.value);var C=T.value;if(C)m(g,C);else{g.state=c,g.outcome=v;for(var S=-1,M=g.queue.length;++S<M;)g.queue[S].callFulfilled(v)}return g},a.reject=function(g,v){g.state=l,g.outcome=v;for(var T=-1,C=g.queue.length;++T<C;)g.queue[T].callRejected(v);return g},u.resolve=function(g){return g instanceof this?g:a.resolve(new this(o),g)},u.reject=function(g){var v=new this(o);return a.reject(v,g)},u.all=function(g){var v=this;if("[object Array]"!==Object.prototype.toString.call(g))return this.reject(new TypeError("must be an array"));var T=g.length,C=!1;if(!T)return this.resolve([]);for(var S=new Array(T),M=0,A=-1,O=new this(o);++A<T;)I(g[A],A);return O;function I(D,B){v.resolve(D).then(function(E){S[B]=E,++M!==T||C||(C=!0,a.resolve(O,S))},function(E){C||(C=!0,a.reject(O,E))})}},u.race=function(g){if("[object Array]"!==Object.prototype.toString.call(g))return this.reject(new TypeError("must be an array"));var T=g.length,C=!1;if(!T)return this.resolve([]);for(var S=-1,M=new this(o);++S<T;)this.resolve(g[S]).then(function(O){C||(C=!0,a.resolve(M,O))},function(O){C||(C=!0,a.reject(M,O))});return M}},{immediate:36}],38:[function(e,i,s){var n={};(0,e("./lib/utils/common").assign)(n,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),i.exports=n},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,i,s){var n=e("./zlib/deflate"),o=e("./utils/common"),a=e("./utils/strings"),l=e("./zlib/messages"),c=e("./zlib/zstream"),h=Object.prototype.toString;function m(g){if(!(this instanceof m))return new m(g);this.options=o.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},g||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var T=n.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(0!==T)throw new Error(l[T]);if(v.header&&n.deflateSetHeader(this.strm,v.header),v.dictionary){var C;if(C="string"==typeof v.dictionary?a.string2buf(v.dictionary):"[object ArrayBuffer]"===h.call(v.dictionary)?new Uint8Array(v.dictionary):v.dictionary,0!==(T=n.deflateSetDictionary(this.strm,C)))throw new Error(l[T]);this._dict_set=!0}}function w(g,v){var T=new m(v);if(T.push(g,!0),T.err)throw T.msg||l[T.err];return T.result}m.prototype.push=function(g,v){var T,C,S=this.strm,M=this.options.chunkSize;if(this.ended)return!1;C=v===~~v?v:!0===v?4:0,S.input="string"==typeof g?a.string2buf(g):"[object ArrayBuffer]"===h.call(g)?new Uint8Array(g):g,S.next_in=0,S.avail_in=S.input.length;do{if(0===S.avail_out&&(S.output=new o.Buf8(M),S.next_out=0,S.avail_out=M),1!==(T=n.deflate(S,C))&&0!==T)return this.onEnd(T),!(this.ended=!0);0!==S.avail_out&&(0!==S.avail_in||4!==C&&2!==C)||this.onData("string"===this.options.to?a.buf2binstring(o.shrinkBuf(S.output,S.next_out)):o.shrinkBuf(S.output,S.next_out))}while((0<S.avail_in||0===S.avail_out)&&1!==T);return 4===C?(T=n.deflateEnd(this.strm),this.onEnd(T),this.ended=!0,0===T):2!==C||(this.onEnd(0),!(S.avail_out=0))},m.prototype.onData=function(g){this.chunks.push(g)},m.prototype.onEnd=function(g){0===g&&(this.result="string"===this.options.to?this.chunks.join(""):o.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},s.Deflate=m,s.deflate=w,s.deflateRaw=function(g,v){return(v=v||{}).raw=!0,w(g,v)},s.gzip=function(g,v){return(v=v||{}).gzip=!0,w(g,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,i,s){var n=e("./zlib/inflate"),o=e("./utils/common"),a=e("./utils/strings"),l=e("./zlib/constants"),c=e("./zlib/messages"),h=e("./zlib/zstream"),u=e("./zlib/gzheader"),f=Object.prototype.toString;function d(m){if(!(this instanceof d))return new d(m);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},m||{});var w=this.options;w.raw&&0<=w.windowBits&&w.windowBits<16&&(w.windowBits=-w.windowBits,0===w.windowBits&&(w.windowBits=-15)),!(0<=w.windowBits&&w.windowBits<16)||m&&m.windowBits||(w.windowBits+=32),15<w.windowBits&&w.windowBits<48&&!(15&w.windowBits)&&(w.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var g=n.inflateInit2(this.strm,w.windowBits);if(g!==l.Z_OK)throw new Error(c[g]);this.header=new u,n.inflateGetHeader(this.strm,this.header)}function _(m,w){var g=new d(w);if(g.push(m,!0),g.err)throw g.msg||c[g.err];return g.result}d.prototype.push=function(m,w){var g,v,T,C,S,M,A=this.strm,O=this.options.chunkSize,I=this.options.dictionary,D=!1;if(this.ended)return!1;v=w===~~w?w:!0===w?l.Z_FINISH:l.Z_NO_FLUSH,A.input="string"==typeof m?a.binstring2buf(m):"[object ArrayBuffer]"===f.call(m)?new Uint8Array(m):m,A.next_in=0,A.avail_in=A.input.length;do{if(0===A.avail_out&&(A.output=new o.Buf8(O),A.next_out=0,A.avail_out=O),(g=n.inflate(A,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&I&&(M="string"==typeof I?a.string2buf(I):"[object ArrayBuffer]"===f.call(I)?new Uint8Array(I):I,g=n.inflateSetDictionary(this.strm,M)),g===l.Z_BUF_ERROR&&!0===D&&(g=l.Z_OK,D=!1),g!==l.Z_STREAM_END&&g!==l.Z_OK)return this.onEnd(g),!(this.ended=!0);A.next_out&&(0!==A.avail_out&&g!==l.Z_STREAM_END&&(0!==A.avail_in||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||("string"===this.options.to?(T=a.utf8border(A.output,A.next_out),C=A.next_out-T,S=a.buf2string(A.output,T),A.next_out=C,A.avail_out=O-C,C&&o.arraySet(A.output,A.output,T,C,0),this.onData(S)):this.onData(o.shrinkBuf(A.output,A.next_out)))),0===A.avail_in&&0===A.avail_out&&(D=!0)}while((0<A.avail_in||0===A.avail_out)&&g!==l.Z_STREAM_END);return g===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(g=n.inflateEnd(this.strm),this.onEnd(g),this.ended=!0,g===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(A.avail_out=0))},d.prototype.onData=function(m){this.chunks.push(m)},d.prototype.onEnd=function(m){m===l.Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):o.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},s.Inflate=d,s.inflate=_,s.inflateRaw=function(m,w){return(w=w||{}).raw=!0,_(m,w)},s.ungzip=_},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,i,s){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";s.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var h=c.shift();if(h){if("object"!=typeof h)throw new TypeError(h+"must be non-object");for(var u in h)h.hasOwnProperty(u)&&(l[u]=h[u])}}return l},s.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var o={arraySet:function(l,c,h,u,f){if(c.subarray&&l.subarray)l.set(c.subarray(h,h+u),f);else for(var d=0;d<u;d++)l[f+d]=c[h+d]},flattenChunks:function(l){var c,h,u,f,d,_;for(c=u=0,h=l.length;c<h;c++)u+=l[c].length;for(_=new Uint8Array(u),c=f=0,h=l.length;c<h;c++)_.set(d=l[c],f),f+=d.length;return _}},a={arraySet:function(l,c,h,u,f){for(var d=0;d<u;d++)l[f+d]=c[h+d]},flattenChunks:function(l){return[].concat.apply([],l)}};s.setTyped=function(l){l?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,o)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,a))},s.setTyped(n)},{}],42:[function(e,i,s){var n=e("./common"),o=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new n.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function h(u,f){if(f<65537&&(u.subarray&&a||!u.subarray&&o))return String.fromCharCode.apply(null,n.shrinkBuf(u,f));for(var d="",_=0;_<f;_++)d+=String.fromCharCode(u[_]);return d}l[254]=l[254]=1,s.string2buf=function(u){var f,d,_,m,w,g=u.length,v=0;for(m=0;m<g;m++)55296==(64512&(d=u.charCodeAt(m)))&&m+1<g&&56320==(64512&(_=u.charCodeAt(m+1)))&&(d=65536+(d-55296<<10)+(_-56320),m++),v+=d<128?1:d<2048?2:d<65536?3:4;for(f=new n.Buf8(v),m=w=0;w<v;m++)55296==(64512&(d=u.charCodeAt(m)))&&m+1<g&&56320==(64512&(_=u.charCodeAt(m+1)))&&(d=65536+(d-55296<<10)+(_-56320),m++),d<128?f[w++]=d:(d<2048?f[w++]=192|d>>>6:(d<65536?f[w++]=224|d>>>12:(f[w++]=240|d>>>18,f[w++]=128|d>>>12&63),f[w++]=128|d>>>6&63),f[w++]=128|63&d);return f},s.buf2binstring=function(u){return h(u,u.length)},s.binstring2buf=function(u){for(var f=new n.Buf8(u.length),d=0,_=f.length;d<_;d++)f[d]=u.charCodeAt(d);return f},s.buf2string=function(u,f){var d,_,m,w,g=f||u.length,v=new Array(2*g);for(d=_=0;d<g;)if((m=u[d++])<128)v[_++]=m;else if(4<(w=l[m]))v[_++]=65533,d+=w-1;else{for(m&=2===w?31:3===w?15:7;1<w&&d<g;)m=m<<6|63&u[d++],w--;1<w?v[_++]=65533:m<65536?v[_++]=m:(v[_++]=55296|(m-=65536)>>10&1023,v[_++]=56320|1023&m)}return h(v,_)},s.utf8border=function(u,f){var d;for((f=f||u.length)>u.length&&(f=u.length),d=f-1;0<=d&&128==(192&u[d]);)d--;return d<0||0===d?f:d+l[u[d]]>f?d:f}},{"./common":41}],43:[function(e,i,s){i.exports=function(n,o,a,l){for(var c=65535&n,h=n>>>16&65535,u=0;0!==a;){for(a-=u=2e3<a?2e3:a;h=h+(c=c+o[l++]|0)|0,--u;);c%=65521,h%=65521}return c|h<<16}},{}],44:[function(e,i,s){i.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(e,i,s){var n=function(){for(var o,a=[],l=0;l<256;l++){o=l;for(var c=0;c<8;c++)o=1&o?3988292384^o>>>1:o>>>1;a[l]=o}return a}();i.exports=function(o,a,l,c){var h=n,u=c+l;o^=-1;for(var f=c;f<u;f++)o=o>>>8^h[255&(o^a[f])];return-1^o}},{}],46:[function(e,i,s){var n,o=e("../utils/common"),a=e("./trees"),l=e("./adler32"),c=e("./crc32"),h=e("./messages"),_=-2,D=258,B=262,L=113;function ct(P,W){return P.msg=h[W],W}function Z(P){return(P<<1)-(4<P?9:0)}function at(P){for(var W=P.length;0<=--W;)P[W]=0}function F(P){var W=P.state,H=W.pending;H>P.avail_out&&(H=P.avail_out),0!==H&&(o.arraySet(P.output,W.pending_buf,W.pending_out,H,P.next_out),P.next_out+=H,W.pending_out+=H,P.total_out+=H,P.avail_out-=H,W.pending-=H,0===W.pending&&(W.pending_out=0))}function V(P,W){a._tr_flush_block(P,0<=P.block_start?P.block_start:-1,P.strstart-P.block_start,W),P.block_start=P.strstart,F(P.strm)}function nt(P,W){P.pending_buf[P.pending++]=W}function it(P,W){P.pending_buf[P.pending++]=W>>>8&255,P.pending_buf[P.pending++]=255&W}function J(P,W){var H,k,z=P.max_chain_length,R=P.strstart,X=P.prev_length,K=P.nice_match,U=P.strstart>P.w_size-B?P.strstart-(P.w_size-B):0,tt=P.window,lt=P.w_mask,et=P.prev,ut=P.strstart+D,vt=tt[R+X-1],wt=tt[R+X];P.prev_length>=P.good_match&&(z>>=2),K>P.lookahead&&(K=P.lookahead);do{if(tt[(H=W)+X]===wt&&tt[H+X-1]===vt&&tt[H]===tt[R]&&tt[++H]===tt[R+1]){R+=2,H++;do{}while(tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&R<ut);if(k=D-(ut-R),R=ut-D,X<k){if(P.match_start=W,K<=(X=k))break;vt=tt[R+X-1],wt=tt[R+X]}}}while((W=et[W&lt])>U&&0!=--z);return X<=P.lookahead?X:P.lookahead}function _t(P){var W,H,k,z,R,X,K,U,tt,lt,et=P.w_size;do{if(z=P.window_size-P.lookahead-P.strstart,P.strstart>=et+(et-B)){for(o.arraySet(P.window,P.window,et,et,0),P.match_start-=et,P.strstart-=et,P.block_start-=et,W=H=P.hash_size;k=P.head[--W],P.head[W]=et<=k?k-et:0,--H;);for(W=H=et;k=P.prev[--W],P.prev[W]=et<=k?k-et:0,--H;);z+=et}if(0===P.strm.avail_in)break;if(K=P.window,U=P.strstart+P.lookahead,lt=void 0,(tt=z)<(lt=(X=P.strm).avail_in)&&(lt=tt),H=0===lt?0:(X.avail_in-=lt,o.arraySet(K,X.input,X.next_in,lt,U),1===X.state.wrap?X.adler=l(X.adler,K,lt,U):2===X.state.wrap&&(X.adler=c(X.adler,K,lt,U)),X.next_in+=lt,X.total_in+=lt,lt),P.lookahead+=H,P.lookahead+P.insert>=3)for(P.ins_h=P.window[R=P.strstart-P.insert],P.ins_h=(P.ins_h<<P.hash_shift^P.window[R+1])&P.hash_mask;P.insert&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[R+3-1])&P.hash_mask,P.prev[R&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=R,R++,P.insert--,!(P.lookahead+P.insert<3)););}while(P.lookahead<B&&0!==P.strm.avail_in)}function St(P,W){for(var H,k;;){if(P.lookahead<B){if(_t(P),P.lookahead<B&&0===W)return 1;if(0===P.lookahead)break}if(H=0,P.lookahead>=3&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+3-1])&P.hash_mask,H=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),0!==H&&P.strstart-H<=P.w_size-B&&(P.match_length=J(P,H)),P.match_length>=3)if(k=a._tr_tally(P,P.strstart-P.match_start,P.match_length-3),P.lookahead-=P.match_length,P.match_length<=P.max_lazy_match&&P.lookahead>=3){for(P.match_length--;P.strstart++,P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+3-1])&P.hash_mask,H=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart,0!=--P.match_length;);P.strstart++}else P.strstart+=P.match_length,P.match_length=0,P.ins_h=P.window[P.strstart],P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+1])&P.hash_mask;else k=a._tr_tally(P,0,P.window[P.strstart]),P.lookahead--,P.strstart++;if(k&&(V(P,!1),0===P.strm.avail_out))return 1}return P.insert=P.strstart<2?P.strstart:2,4===W?(V(P,!0),0===P.strm.avail_out?3:4):P.last_lit&&(V(P,!1),0===P.strm.avail_out)?1:2}function dt(P,W){for(var H,k,z;;){if(P.lookahead<B){if(_t(P),P.lookahead<B&&0===W)return 1;if(0===P.lookahead)break}if(H=0,P.lookahead>=3&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+3-1])&P.hash_mask,H=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),P.prev_length=P.match_length,P.prev_match=P.match_start,P.match_length=2,0!==H&&P.prev_length<P.max_lazy_match&&P.strstart-H<=P.w_size-B&&(P.match_length=J(P,H),P.match_length<=5&&(1===P.strategy||3===P.match_length&&4096<P.strstart-P.match_start)&&(P.match_length=2)),P.prev_length>=3&&P.match_length<=P.prev_length){for(z=P.strstart+P.lookahead-3,k=a._tr_tally(P,P.strstart-1-P.prev_match,P.prev_length-3),P.lookahead-=P.prev_length-1,P.prev_length-=2;++P.strstart<=z&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+3-1])&P.hash_mask,H=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),0!=--P.prev_length;);if(P.match_available=0,P.match_length=2,P.strstart++,k&&(V(P,!1),0===P.strm.avail_out))return 1}else if(P.match_available){if((k=a._tr_tally(P,0,P.window[P.strstart-1]))&&V(P,!1),P.strstart++,P.lookahead--,0===P.strm.avail_out)return 1}else P.match_available=1,P.strstart++,P.lookahead--}return P.match_available&&(k=a._tr_tally(P,0,P.window[P.strstart-1]),P.match_available=0),P.insert=P.strstart<2?P.strstart:2,4===W?(V(P,!0),0===P.strm.avail_out?3:4):P.last_lit&&(V(P,!1),0===P.strm.avail_out)?1:2}function rt(P,W,H,k,z){this.good_length=P,this.max_lazy=W,this.nice_length=H,this.max_chain=k,this.func=z}function ht(){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=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(1146),this.dyn_dtree=new o.Buf16(122),this.bl_tree=new o.Buf16(78),at(this.dyn_ltree),at(this.dyn_dtree),at(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(16),this.heap=new o.Buf16(573),at(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(573),at(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 pt(P){var W;return P&&P.state?(P.total_in=P.total_out=0,P.data_type=2,(W=P.state).pending=0,W.pending_out=0,W.wrap<0&&(W.wrap=-W.wrap),W.status=W.wrap?42:L,P.adler=2===W.wrap?0:1,W.last_flush=0,a._tr_init(W),0):ct(P,_)}function xt(P){var H,W=pt(P);return 0===W&&((H=P.state).window_size=2*H.w_size,at(H.head),H.max_lazy_match=n[H.level].max_lazy,H.good_match=n[H.level].good_length,H.nice_match=n[H.level].nice_length,H.max_chain_length=n[H.level].max_chain,H.strstart=0,H.block_start=0,H.lookahead=0,H.insert=0,H.match_length=H.prev_length=2,H.match_available=0,H.ins_h=0),W}function Et(P,W,H,k,z,R){if(!P)return _;var X=1;if(-1===W&&(W=6),k<0?(X=0,k=-k):15<k&&(X=2,k-=16),z<1||9<z||8!==H||k<8||15<k||W<0||9<W||R<0||4<R)return ct(P,_);8===k&&(k=9);var K=new ht;return(P.state=K).strm=P,K.wrap=X,K.gzhead=null,K.w_bits=k,K.w_size=1<<K.w_bits,K.w_mask=K.w_size-1,K.hash_bits=z+7,K.hash_size=1<<K.hash_bits,K.hash_mask=K.hash_size-1,K.hash_shift=~~((K.hash_bits+3-1)/3),K.window=new o.Buf8(2*K.w_size),K.head=new o.Buf16(K.hash_size),K.prev=new o.Buf16(K.w_size),K.lit_bufsize=1<<z+6,K.pending_buf_size=4*K.lit_bufsize,K.pending_buf=new o.Buf8(K.pending_buf_size),K.d_buf=1*K.lit_bufsize,K.l_buf=3*K.lit_bufsize,K.level=W,K.strategy=R,K.method=H,xt(P)}n=[new rt(0,0,0,0,function(P,W){var H=65535;for(H>P.pending_buf_size-5&&(H=P.pending_buf_size-5);;){if(P.lookahead<=1){if(_t(P),0===P.lookahead&&0===W)return 1;if(0===P.lookahead)break}P.strstart+=P.lookahead,P.lookahead=0;var k=P.block_start+H;if((0===P.strstart||P.strstart>=k)&&(P.lookahead=P.strstart-k,P.strstart=k,V(P,!1),0===P.strm.avail_out)||P.strstart-P.block_start>=P.w_size-B&&(V(P,!1),0===P.strm.avail_out))return 1}return P.insert=0,4===W?(V(P,!0),0===P.strm.avail_out?3:4):(P.strstart>P.block_start&&V(P,!1),1)}),new rt(4,4,8,4,St),new rt(4,5,16,8,St),new rt(4,6,32,32,St),new rt(4,4,16,16,dt),new rt(8,16,32,32,dt),new rt(8,16,128,128,dt),new rt(8,32,128,256,dt),new rt(32,128,258,1024,dt),new rt(32,258,258,4096,dt)],s.deflateInit=function(P,W){return Et(P,W,8,15,8,0)},s.deflateInit2=Et,s.deflateReset=xt,s.deflateResetKeep=pt,s.deflateSetHeader=function(P,W){return P&&P.state?2!==P.state.wrap?_:(P.state.gzhead=W,0):_},s.deflate=function(P,W){var H,k,z,R;if(!P||!P.state||5<W||W<0)return P?ct(P,_):_;if(k=P.state,!P.output||!P.input&&0!==P.avail_in||666===k.status&&4!==W)return ct(P,0===P.avail_out?-5:_);if(k.strm=P,H=k.last_flush,k.last_flush=W,42===k.status)if(2===k.wrap)P.adler=0,nt(k,31),nt(k,139),nt(k,8),k.gzhead?(nt(k,(k.gzhead.text?1:0)+(k.gzhead.hcrc?2:0)+(k.gzhead.extra?4:0)+(k.gzhead.name?8:0)+(k.gzhead.comment?16:0)),nt(k,255&k.gzhead.time),nt(k,k.gzhead.time>>8&255),nt(k,k.gzhead.time>>16&255),nt(k,k.gzhead.time>>24&255),nt(k,9===k.level?2:2<=k.strategy||k.level<2?4:0),nt(k,255&k.gzhead.os),k.gzhead.extra&&k.gzhead.extra.length&&(nt(k,255&k.gzhead.extra.length),nt(k,k.gzhead.extra.length>>8&255)),k.gzhead.hcrc&&(P.adler=c(P.adler,k.pending_buf,k.pending,0)),k.gzindex=0,k.status=69):(nt(k,0),nt(k,0),nt(k,0),nt(k,0),nt(k,0),nt(k,9===k.level?2:2<=k.strategy||k.level<2?4:0),nt(k,3),k.status=L);else{var X=8+(k.w_bits-8<<4)<<8;X|=(2<=k.strategy||k.level<2?0:k.level<6?1:6===k.level?2:3)<<6,0!==k.strstart&&(X|=32),X+=31-X%31,k.status=L,it(k,X),0!==k.strstart&&(it(k,P.adler>>>16),it(k,65535&P.adler)),P.adler=1}if(69===k.status)if(k.gzhead.extra){for(z=k.pending;k.gzindex<(65535&k.gzhead.extra.length)&&(k.pending!==k.pending_buf_size||(k.gzhead.hcrc&&k.pending>z&&(P.adler=c(P.adler,k.pending_buf,k.pending-z,z)),F(P),z=k.pending,k.pending!==k.pending_buf_size));)nt(k,255&k.gzhead.extra[k.gzindex]),k.gzindex++;k.gzhead.hcrc&&k.pending>z&&(P.adler=c(P.adler,k.pending_buf,k.pending-z,z)),k.gzindex===k.gzhead.extra.length&&(k.gzindex=0,k.status=73)}else k.status=73;if(73===k.status)if(k.gzhead.name){z=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>z&&(P.adler=c(P.adler,k.pending_buf,k.pending-z,z)),F(P),z=k.pending,k.pending===k.pending_buf_size)){R=1;break}R=k.gzindex<k.gzhead.name.length?255&k.gzhead.name.charCodeAt(k.gzindex++):0,nt(k,R)}while(0!==R);k.gzhead.hcrc&&k.pending>z&&(P.adler=c(P.adler,k.pending_buf,k.pending-z,z)),0===R&&(k.gzindex=0,k.status=91)}else k.status=91;if(91===k.status)if(k.gzhead.comment){z=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>z&&(P.adler=c(P.adler,k.pending_buf,k.pending-z,z)),F(P),z=k.pending,k.pending===k.pending_buf_size)){R=1;break}R=k.gzindex<k.gzhead.comment.length?255&k.gzhead.comment.charCodeAt(k.gzindex++):0,nt(k,R)}while(0!==R);k.gzhead.hcrc&&k.pending>z&&(P.adler=c(P.adler,k.pending_buf,k.pending-z,z)),0===R&&(k.status=103)}else k.status=103;if(103===k.status&&(k.gzhead.hcrc?(k.pending+2>k.pending_buf_size&&F(P),k.pending+2<=k.pending_buf_size&&(nt(k,255&P.adler),nt(k,P.adler>>8&255),P.adler=0,k.status=L)):k.status=L),0!==k.pending){if(F(P),0===P.avail_out)return k.last_flush=-1,0}else if(0===P.avail_in&&Z(W)<=Z(H)&&4!==W)return ct(P,-5);if(666===k.status&&0!==P.avail_in)return ct(P,-5);if(0!==P.avail_in||0!==k.lookahead||0!==W&&666!==k.status){var K=2===k.strategy?function(U,tt){for(var lt;;){if(0===U.lookahead&&(_t(U),0===U.lookahead)){if(0===tt)return 1;break}if(U.match_length=0,lt=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++,lt&&(V(U,!1),0===U.strm.avail_out))return 1}return U.insert=0,4===tt?(V(U,!0),0===U.strm.avail_out?3:4):U.last_lit&&(V(U,!1),0===U.strm.avail_out)?1:2}(k,W):3===k.strategy?function(U,tt){for(var lt,et,ut,vt,wt=U.window;;){if(U.lookahead<=D){if(_t(U),U.lookahead<=D&&0===tt)return 1;if(0===U.lookahead)break}if(U.match_length=0,U.lookahead>=3&&0<U.strstart&&(et=wt[ut=U.strstart-1])===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]){vt=U.strstart+D;do{}while(et===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]&&ut<vt);U.match_length=D-(vt-ut),U.match_length>U.lookahead&&(U.match_length=U.lookahead)}if(U.match_length>=3?(lt=a._tr_tally(U,1,U.match_length-3),U.lookahead-=U.match_length,U.strstart+=U.match_length,U.match_length=0):(lt=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++),lt&&(V(U,!1),0===U.strm.avail_out))return 1}return U.insert=0,4===tt?(V(U,!0),0===U.strm.avail_out?3:4):U.last_lit&&(V(U,!1),0===U.strm.avail_out)?1:2}(k,W):n[k.level].func(k,W);if(3!==K&&4!==K||(k.status=666),1===K||3===K)return 0===P.avail_out&&(k.last_flush=-1),0;if(2===K&&(1===W?a._tr_align(k):5!==W&&(a._tr_stored_block(k,0,0,!1),3===W&&(at(k.head),0===k.lookahead&&(k.strstart=0,k.block_start=0,k.insert=0))),F(P),0===P.avail_out))return k.last_flush=-1,0}return 4!==W?0:k.wrap<=0?1:(2===k.wrap?(nt(k,255&P.adler),nt(k,P.adler>>8&255),nt(k,P.adler>>16&255),nt(k,P.adler>>24&255),nt(k,255&P.total_in),nt(k,P.total_in>>8&255),nt(k,P.total_in>>16&255),nt(k,P.total_in>>24&255)):(it(k,P.adler>>>16),it(k,65535&P.adler)),F(P),0<k.wrap&&(k.wrap=-k.wrap),0!==k.pending?0:1)},s.deflateEnd=function(P){var W;return P&&P.state?42!==(W=P.state.status)&&69!==W&&73!==W&&91!==W&&103!==W&&W!==L&&666!==W?ct(P,_):(P.state=null,W===L?ct(P,-3):0):_},s.deflateSetDictionary=function(P,W){var H,k,z,R,X,K,U,tt,lt=W.length;if(!P||!P.state||2===(R=(H=P.state).wrap)||1===R&&42!==H.status||H.lookahead)return _;for(1===R&&(P.adler=l(P.adler,W,lt,0)),H.wrap=0,lt>=H.w_size&&(0===R&&(at(H.head),H.strstart=0,H.block_start=0,H.insert=0),tt=new o.Buf8(H.w_size),o.arraySet(tt,W,lt-H.w_size,H.w_size,0),W=tt,lt=H.w_size),X=P.avail_in,K=P.next_in,U=P.input,P.avail_in=lt,P.next_in=0,P.input=W,_t(H);H.lookahead>=3;){for(k=H.strstart,z=H.lookahead-2;H.ins_h=(H.ins_h<<H.hash_shift^H.window[k+3-1])&H.hash_mask,H.prev[k&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=k,k++,--z;);H.strstart=k,H.lookahead=2,_t(H)}return H.strstart+=H.lookahead,H.block_start=H.strstart,H.insert=H.lookahead,H.lookahead=0,H.match_length=H.prev_length=2,H.match_available=0,P.next_in=K,P.input=U,P.avail_in=X,H.wrap=R,0},s.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,i,s){i.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(e,i,s){i.exports=function(n,o){var a,l,c,h,u,f,d,_,m,w,g,v,T,C,S,M,A,O,I,D,B,E,L,x,N;x=n.input,c=(l=n.next_in)+(n.avail_in-5),N=n.output,u=(h=n.next_out)-(o-n.avail_out),f=h+(n.avail_out-257),d=(a=n.state).dmax,_=a.wsize,m=a.whave,w=a.wnext,g=a.window,v=a.hold,T=a.bits,C=a.lencode,S=a.distcode,M=(1<<a.lenbits)-1,A=(1<<a.distbits)-1;t:do{T<15&&(v+=x[l++]<<T,v+=x[l++]<<(T+=8),T+=8),O=C[v&M];e:for(;;){if(v>>>=I=O>>>24,T-=I,0==(I=O>>>16&255))N[h++]=65535&O;else{if(!(16&I)){if(!(64&I)){O=C[(65535&O)+(v&(1<<I)-1)];continue e}if(32&I){a.mode=12;break t}n.msg="invalid literal/length code",a.mode=30;break t}D=65535&O,(I&=15)&&(T<I&&(v+=x[l++]<<T,T+=8),D+=v&(1<<I)-1,v>>>=I,T-=I),T<15&&(v+=x[l++]<<T,v+=x[l++]<<(T+=8),T+=8),O=S[v&A];i:for(;;){if(v>>>=I=O>>>24,T-=I,!(16&(I=O>>>16&255))){if(!(64&I)){O=S[(65535&O)+(v&(1<<I)-1)];continue i}n.msg="invalid distance code",a.mode=30;break t}if(B=65535&O,T<(I&=15)&&(v+=x[l++]<<T,(T+=8)<I&&(v+=x[l++]<<T,T+=8)),d<(B+=v&(1<<I)-1)){n.msg="invalid distance too far back",a.mode=30;break t}if(v>>>=I,T-=I,(I=h-u)<B){if(m<(I=B-I)&&a.sane){n.msg="invalid distance too far back",a.mode=30;break t}if(L=g,(E=0)===w){if(E+=_-I,I<D){for(D-=I;N[h++]=g[E++],--I;);E=h-B,L=N}}else if(w<I){if(E+=_+w-I,(I-=w)<D){for(D-=I;N[h++]=g[E++],--I;);if(E=0,w<D){for(D-=I=w;N[h++]=g[E++],--I;);E=h-B,L=N}}}else if(E+=w-I,I<D){for(D-=I;N[h++]=g[E++],--I;);E=h-B,L=N}for(;2<D;)N[h++]=L[E++],N[h++]=L[E++],N[h++]=L[E++],D-=3;D&&(N[h++]=L[E++],1<D&&(N[h++]=L[E++]))}else{for(E=h-B;N[h++]=N[E++],N[h++]=N[E++],N[h++]=N[E++],2<(D-=3););D&&(N[h++]=N[E++],1<D&&(N[h++]=N[E++]))}break}}break}}while(l<c&&h<f);l-=D=T>>3,v&=(1<<(T-=D<<3))-1,n.next_in=l,n.next_out=h,n.avail_in=l<c?c-l+5:5-(l-c),n.avail_out=h<f?f-h+257:257-(h-f),a.hold=v,a.bits=T}},{}],49:[function(e,i,s){var n=e("../utils/common"),o=e("./adler32"),a=e("./crc32"),l=e("./inffast"),c=e("./inftrees"),d=-2;function g(E){return(E>>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function T(E){var L;return E&&E.state?(E.total_in=E.total_out=(L=E.state).total=0,E.msg="",L.wrap&&(E.adler=1&L.wrap),L.mode=1,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new n.Buf32(852),L.distcode=L.distdyn=new n.Buf32(592),L.sane=1,L.back=-1,0):d}function C(E){var L;return E&&E.state?((L=E.state).wsize=0,L.whave=0,L.wnext=0,T(E)):d}function S(E,L){var x,N;return E&&E.state?(N=E.state,L<0?(x=0,L=-L):(x=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15<L)?d:(null!==N.window&&N.wbits!==L&&(N.window=null),N.wrap=x,N.wbits=L,C(E))):d}function M(E,L){var x,N;return E?(N=new v,(E.state=N).window=null,0!==(x=S(E,L))&&(E.state=null),x):d}var A,O,I=!0;function D(E){if(I){var L;for(A=new n.Buf32(512),O=new n.Buf32(32),L=0;L<144;)E.lens[L++]=8;for(;L<256;)E.lens[L++]=9;for(;L<280;)E.lens[L++]=7;for(;L<288;)E.lens[L++]=8;for(c(1,E.lens,0,288,A,0,E.work,{bits:9}),L=0;L<32;)E.lens[L++]=5;c(2,E.lens,0,32,O,0,E.work,{bits:5}),I=!1}E.lencode=A,E.lenbits=9,E.distcode=O,E.distbits=5}function B(E,L,x,N){var Y,q=E.state;return null===q.window&&(q.wsize=1<<q.wbits,q.wnext=0,q.whave=0,q.window=new n.Buf8(q.wsize)),N>=q.wsize?(n.arraySet(q.window,L,x-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(N<(Y=q.wsize-q.wnext)&&(Y=N),n.arraySet(q.window,L,x-N,Y,q.wnext),(N-=Y)?(n.arraySet(q.window,L,x-N,N,0),q.wnext=N,q.whave=q.wsize):(q.wnext+=Y,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=Y))),0}s.inflateReset=C,s.inflateReset2=S,s.inflateResetKeep=T,s.inflateInit=function(E){return M(E,15)},s.inflateInit2=M,s.inflate=function(E,L){var x,N,Y,q,ct,Z,at,F,V,nt,it,J,_t,St,dt,rt,ht,pt,xt,Et,P,W,H,k,z=0,R=new n.Buf8(4),X=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!E||!E.state||!E.output||!E.input&&0!==E.avail_in)return d;12===(x=E.state).mode&&(x.mode=13),ct=E.next_out,Y=E.output,q=E.next_in,N=E.input,F=x.hold,V=x.bits,nt=Z=E.avail_in,it=at=E.avail_out,W=0;t:for(;;)switch(x.mode){case 1:if(0===x.wrap){x.mode=13;break}for(;V<16;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(2&x.wrap&&35615===F){R[x.check=0]=255&F,R[1]=F>>>8&255,x.check=a(x.check,R,2,0),V=F=0,x.mode=2;break}if(x.flags=0,x.head&&(x.head.done=!1),!(1&x.wrap)||(((255&F)<<8)+(F>>8))%31){E.msg="incorrect header check",x.mode=30;break}if(8!=(15&F)){E.msg="unknown compression method",x.mode=30;break}if(V-=4,P=8+(15&(F>>>=4)),0===x.wbits)x.wbits=P;else if(P>x.wbits){E.msg="invalid window size",x.mode=30;break}x.dmax=1<<P,E.adler=x.check=1,x.mode=512&F?10:12,V=F=0;break;case 2:for(;V<16;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(x.flags=F,8!=(255&x.flags)){E.msg="unknown compression method",x.mode=30;break}if(57344&x.flags){E.msg="unknown header flags set",x.mode=30;break}x.head&&(x.head.text=F>>8&1),512&x.flags&&(R[0]=255&F,R[1]=F>>>8&255,x.check=a(x.check,R,2,0)),V=F=0,x.mode=3;case 3:for(;V<32;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}x.head&&(x.head.time=F),512&x.flags&&(R[0]=255&F,R[1]=F>>>8&255,R[2]=F>>>16&255,R[3]=F>>>24&255,x.check=a(x.check,R,4,0)),V=F=0,x.mode=4;case 4:for(;V<16;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}x.head&&(x.head.xflags=255&F,x.head.os=F>>8),512&x.flags&&(R[0]=255&F,R[1]=F>>>8&255,x.check=a(x.check,R,2,0)),V=F=0,x.mode=5;case 5:if(1024&x.flags){for(;V<16;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}x.length=F,x.head&&(x.head.extra_len=F),512&x.flags&&(R[0]=255&F,R[1]=F>>>8&255,x.check=a(x.check,R,2,0)),V=F=0}else x.head&&(x.head.extra=null);x.mode=6;case 6:if(1024&x.flags&&(Z<(J=x.length)&&(J=Z),J&&(x.head&&(P=x.head.extra_len-x.length,x.head.extra||(x.head.extra=new Array(x.head.extra_len)),n.arraySet(x.head.extra,N,q,J,P)),512&x.flags&&(x.check=a(x.check,N,J,q)),Z-=J,q+=J,x.length-=J),x.length))break t;x.length=0,x.mode=7;case 7:if(2048&x.flags){if(0===Z)break t;for(J=0;P=N[q+J++],x.head&&P&&x.length<65536&&(x.head.name+=String.fromCharCode(P)),P&&J<Z;);if(512&x.flags&&(x.check=a(x.check,N,J,q)),Z-=J,q+=J,P)break t}else x.head&&(x.head.name=null);x.length=0,x.mode=8;case 8:if(4096&x.flags){if(0===Z)break t;for(J=0;P=N[q+J++],x.head&&P&&x.length<65536&&(x.head.comment+=String.fromCharCode(P)),P&&J<Z;);if(512&x.flags&&(x.check=a(x.check,N,J,q)),Z-=J,q+=J,P)break t}else x.head&&(x.head.comment=null);x.mode=9;case 9:if(512&x.flags){for(;V<16;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(F!==(65535&x.check)){E.msg="header crc mismatch",x.mode=30;break}V=F=0}x.head&&(x.head.hcrc=x.flags>>9&1,x.head.done=!0),E.adler=x.check=0,x.mode=12;break;case 10:for(;V<32;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}E.adler=x.check=g(F),V=F=0,x.mode=11;case 11:if(0===x.havedict)return E.next_out=ct,E.avail_out=at,E.next_in=q,E.avail_in=Z,x.hold=F,x.bits=V,2;E.adler=x.check=1,x.mode=12;case 12:if(5===L||6===L)break t;case 13:if(x.last){F>>>=7&V,V-=7&V,x.mode=27;break}for(;V<3;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}switch(x.last=1&F,V-=1,3&(F>>>=1)){case 0:x.mode=14;break;case 1:if(D(x),x.mode=20,6!==L)break;F>>>=2,V-=2;break t;case 2:x.mode=17;break;case 3:E.msg="invalid block type",x.mode=30}F>>>=2,V-=2;break;case 14:for(F>>>=7&V,V-=7&V;V<32;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if((65535&F)!=(F>>>16^65535)){E.msg="invalid stored block lengths",x.mode=30;break}if(x.length=65535&F,V=F=0,x.mode=15,6===L)break t;case 15:x.mode=16;case 16:if(J=x.length){if(Z<J&&(J=Z),at<J&&(J=at),0===J)break t;n.arraySet(Y,N,q,J,ct),Z-=J,q+=J,at-=J,ct+=J,x.length-=J;break}x.mode=12;break;case 17:for(;V<14;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(x.nlen=257+(31&F),V-=5,x.ndist=1+(31&(F>>>=5)),V-=5,x.ncode=4+(15&(F>>>=5)),F>>>=4,V-=4,286<x.nlen||30<x.ndist){E.msg="too many length or distance symbols",x.mode=30;break}x.have=0,x.mode=18;case 18:for(;x.have<x.ncode;){for(;V<3;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}x.lens[X[x.have++]]=7&F,F>>>=3,V-=3}for(;x.have<19;)x.lens[X[x.have++]]=0;if(x.lencode=x.lendyn,x.lenbits=7,W=c(0,x.lens,0,19,x.lencode,0,x.work,H={bits:x.lenbits}),x.lenbits=H.bits,W){E.msg="invalid code lengths set",x.mode=30;break}x.have=0,x.mode=19;case 19:for(;x.have<x.nlen+x.ndist;){for(;rt=(z=x.lencode[F&(1<<x.lenbits)-1])>>>16&255,ht=65535&z,!((dt=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(ht<16)F>>>=dt,V-=dt,x.lens[x.have++]=ht;else{if(16===ht){for(k=dt+2;V<k;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(F>>>=dt,V-=dt,0===x.have){E.msg="invalid bit length repeat",x.mode=30;break}P=x.lens[x.have-1],J=3+(3&F),F>>>=2,V-=2}else if(17===ht){for(k=dt+3;V<k;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}V-=dt,P=0,J=3+(7&(F>>>=dt)),F>>>=3,V-=3}else{for(k=dt+7;V<k;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}V-=dt,P=0,J=11+(127&(F>>>=dt)),F>>>=7,V-=7}if(x.have+J>x.nlen+x.ndist){E.msg="invalid bit length repeat",x.mode=30;break}for(;J--;)x.lens[x.have++]=P}}if(30===x.mode)break;if(0===x.lens[256]){E.msg="invalid code -- missing end-of-block",x.mode=30;break}if(x.lenbits=9,W=c(1,x.lens,0,x.nlen,x.lencode,0,x.work,H={bits:x.lenbits}),x.lenbits=H.bits,W){E.msg="invalid literal/lengths set",x.mode=30;break}if(x.distbits=6,x.distcode=x.distdyn,W=c(2,x.lens,x.nlen,x.ndist,x.distcode,0,x.work,H={bits:x.distbits}),x.distbits=H.bits,W){E.msg="invalid distances set",x.mode=30;break}if(x.mode=20,6===L)break t;case 20:x.mode=21;case 21:if(6<=Z&&258<=at){E.next_out=ct,E.avail_out=at,E.next_in=q,E.avail_in=Z,x.hold=F,x.bits=V,l(E,it),ct=E.next_out,Y=E.output,at=E.avail_out,q=E.next_in,N=E.input,Z=E.avail_in,F=x.hold,V=x.bits,12===x.mode&&(x.back=-1);break}for(x.back=0;rt=(z=x.lencode[F&(1<<x.lenbits)-1])>>>16&255,ht=65535&z,!((dt=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(rt&&!(240&rt)){for(pt=dt,xt=rt,Et=ht;rt=(z=x.lencode[Et+((F&(1<<pt+xt)-1)>>pt)])>>>16&255,ht=65535&z,!(pt+(dt=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}F>>>=pt,V-=pt,x.back+=pt}if(F>>>=dt,V-=dt,x.back+=dt,x.length=ht,0===rt){x.mode=26;break}if(32&rt){x.back=-1,x.mode=12;break}if(64&rt){E.msg="invalid literal/length code",x.mode=30;break}x.extra=15&rt,x.mode=22;case 22:if(x.extra){for(k=x.extra;V<k;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}x.length+=F&(1<<x.extra)-1,F>>>=x.extra,V-=x.extra,x.back+=x.extra}x.was=x.length,x.mode=23;case 23:for(;rt=(z=x.distcode[F&(1<<x.distbits)-1])>>>16&255,ht=65535&z,!((dt=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(!(240&rt)){for(pt=dt,xt=rt,Et=ht;rt=(z=x.distcode[Et+((F&(1<<pt+xt)-1)>>pt)])>>>16&255,ht=65535&z,!(pt+(dt=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}F>>>=pt,V-=pt,x.back+=pt}if(F>>>=dt,V-=dt,x.back+=dt,64&rt){E.msg="invalid distance code",x.mode=30;break}x.offset=ht,x.extra=15&rt,x.mode=24;case 24:if(x.extra){for(k=x.extra;V<k;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}x.offset+=F&(1<<x.extra)-1,F>>>=x.extra,V-=x.extra,x.back+=x.extra}if(x.offset>x.dmax){E.msg="invalid distance too far back",x.mode=30;break}x.mode=25;case 25:if(0===at)break t;if(x.offset>(J=it-at)){if((J=x.offset-J)>x.whave&&x.sane){E.msg="invalid distance too far back",x.mode=30;break}_t=J>x.wnext?x.wsize-(J-=x.wnext):x.wnext-J,J>x.length&&(J=x.length),St=x.window}else St=Y,_t=ct-x.offset,J=x.length;for(at<J&&(J=at),at-=J,x.length-=J;Y[ct++]=St[_t++],--J;);0===x.length&&(x.mode=21);break;case 26:if(0===at)break t;Y[ct++]=x.length,at--,x.mode=21;break;case 27:if(x.wrap){for(;V<32;){if(0===Z)break t;Z--,F|=N[q++]<<V,V+=8}if(E.total_out+=it-=at,x.total+=it,it&&(E.adler=x.check=x.flags?a(x.check,Y,it,ct-it):o(x.check,Y,it,ct-it)),it=at,(x.flags?F:g(F))!==x.check){E.msg="incorrect data check",x.mode=30;break}V=F=0}x.mode=28;case 28:if(x.wrap&&x.flags){for(;V<32;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(F!==(4294967295&x.total)){E.msg="incorrect length check",x.mode=30;break}V=F=0}x.mode=29;case 29:W=1;break t;case 30:W=-3;break t;case 31:return-4;default:return d}return E.next_out=ct,E.avail_out=at,E.next_in=q,E.avail_in=Z,x.hold=F,x.bits=V,(x.wsize||it!==E.avail_out&&x.mode<30&&(x.mode<27||4!==L))&&B(E,E.output,E.next_out,it-E.avail_out)?(x.mode=31,-4):(it-=E.avail_out,E.total_in+=nt-=E.avail_in,E.total_out+=it,x.total+=it,x.wrap&&it&&(E.adler=x.check=x.flags?a(x.check,Y,it,E.next_out-it):o(x.check,Y,it,E.next_out-it)),E.data_type=x.bits+(x.last?64:0)+(12===x.mode?128:0)+(20===x.mode||15===x.mode?256:0),(0==nt&&0===it||4===L)&&0===W&&(W=-5),W)},s.inflateEnd=function(E){if(!E||!E.state)return d;var L=E.state;return L.window&&(L.window=null),E.state=null,0},s.inflateGetHeader=function(E,L){var x;return E&&E.state&&2&(x=E.state).wrap?((x.head=L).done=!1,0):d},s.inflateSetDictionary=function(E,L){var x,N=L.length;return E&&E.state?0!==(x=E.state).wrap&&11!==x.mode?d:11===x.mode&&o(1,L,N,0)!==x.check?-3:B(E,L,N,N)?(x.mode=31,-4):(x.havedict=1,0):d},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,i,s){var n=e("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(h,u,f,d,_,m,w,g){var v,T,C,S,M,A,O,I,D,B=g.bits,E=0,L=0,x=0,N=0,Y=0,q=0,ct=0,Z=0,at=0,F=0,V=null,nt=0,it=new n.Buf16(16),J=new n.Buf16(16),_t=null,St=0;for(E=0;E<=15;E++)it[E]=0;for(L=0;L<d;L++)it[u[f+L]]++;for(Y=B,N=15;1<=N&&0===it[N];N--);if(N<Y&&(Y=N),0===N)return _[m++]=20971520,_[m++]=20971520,g.bits=1,0;for(x=1;x<N&&0===it[x];x++);for(Y<x&&(Y=x),E=Z=1;E<=15;E++)if(Z<<=1,(Z-=it[E])<0)return-1;if(0<Z&&(0===h||1!==N))return-1;for(J[1]=0,E=1;E<15;E++)J[E+1]=J[E]+it[E];for(L=0;L<d;L++)0!==u[f+L]&&(w[J[u[f+L]]++]=L);if(A=0===h?(V=_t=w,19):1===h?(V=o,nt-=257,_t=a,St-=257,256):(V=l,_t=c,-1),E=x,M=m,ct=L=F=0,C=-1,S=(at=1<<(q=Y))-1,1===h&&852<at||2===h&&592<at)return 1;for(;;){for(O=E-ct,D=w[L]<A?(I=0,w[L]):w[L]>A?(I=_t[St+w[L]],V[nt+w[L]]):(I=96,0),v=1<<E-ct,x=T=1<<q;_[M+(F>>ct)+(T-=v)]=O<<24|I<<16|D,0!==T;);for(v=1<<E-1;F&v;)v>>=1;if(0!==v?(F&=v-1,F+=v):F=0,L++,0==--it[E]){if(E===N)break;E=u[f+w[L]]}if(Y<E&&(F&S)!==C){for(0===ct&&(ct=Y),M+=x,Z=1<<(q=E-ct);q+ct<N&&!((Z-=it[q+ct])<=0);)q++,Z<<=1;if(at+=1<<q,1===h&&852<at||2===h&&592<at)return 1;_[C=F&S]=Y<<24|q<<16|M-m}}return 0!==F&&(_[M+F]=E-ct<<24|64<<16),g.bits=Y,0}},{"../utils/common":41}],51:[function(e,i,s){i.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(e,i,s){var n=e("../utils/common");function l(z){for(var R=z.length;0<=--R;)z[R]=0}var u=256,f=286,d=30,w=15,A=[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],I=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],B=new Array(576);l(B);var E=new Array(60);l(E);var L=new Array(512);l(L);var x=new Array(256);l(x);var N=new Array(29);l(N);var Y,q,ct,Z=new Array(d);function at(z,R,X,K,U){this.static_tree=z,this.extra_bits=R,this.extra_base=X,this.elems=K,this.max_length=U,this.has_stree=z&&z.length}function F(z,R){this.dyn_tree=z,this.max_code=0,this.stat_desc=R}function V(z){return z<256?L[z]:L[256+(z>>>7)]}function nt(z,R){z.pending_buf[z.pending++]=255&R,z.pending_buf[z.pending++]=R>>>8&255}function it(z,R,X){z.bi_valid>16-X?(z.bi_buf|=R<<z.bi_valid&65535,nt(z,z.bi_buf),z.bi_buf=R>>16-z.bi_valid,z.bi_valid+=X-16):(z.bi_buf|=R<<z.bi_valid&65535,z.bi_valid+=X)}function J(z,R,X){it(z,X[2*R],X[2*R+1])}function _t(z,R){for(var X=0;X|=1&z,z>>>=1,X<<=1,0<--R;);return X>>>1}function St(z,R,X){var K,U,tt=new Array(16),lt=0;for(K=1;K<=w;K++)tt[K]=lt=lt+X[K-1]<<1;for(U=0;U<=R;U++){var et=z[2*U+1];0!==et&&(z[2*U]=_t(tt[et]++,et))}}function dt(z){var R;for(R=0;R<f;R++)z.dyn_ltree[2*R]=0;for(R=0;R<d;R++)z.dyn_dtree[2*R]=0;for(R=0;R<19;R++)z.bl_tree[2*R]=0;z.dyn_ltree[512]=1,z.opt_len=z.static_len=0,z.last_lit=z.matches=0}function rt(z){8<z.bi_valid?nt(z,z.bi_buf):0<z.bi_valid&&(z.pending_buf[z.pending++]=z.bi_buf),z.bi_buf=0,z.bi_valid=0}function ht(z,R,X,K){var U=2*R,tt=2*X;return z[U]<z[tt]||z[U]===z[tt]&&K[R]<=K[X]}function pt(z,R,X){for(var K=z.heap[X],U=X<<1;U<=z.heap_len&&(U<z.heap_len&&ht(R,z.heap[U+1],z.heap[U],z.depth)&&U++,!ht(R,K,z.heap[U],z.depth));)z.heap[X]=z.heap[U],X=U,U<<=1;z.heap[X]=K}function xt(z,R,X){var K,U,tt,lt,et=0;if(0!==z.last_lit)for(;K=z.pending_buf[z.d_buf+2*et]<<8|z.pending_buf[z.d_buf+2*et+1],U=z.pending_buf[z.l_buf+et],et++,0===K?J(z,U,R):(J(z,(tt=x[U])+u+1,R),0!==(lt=A[tt])&&it(z,U-=N[tt],lt),J(z,tt=V(--K),X),0!==(lt=O[tt])&&it(z,K-=Z[tt],lt)),et<z.last_lit;);J(z,256,R)}function Et(z,R){var X,K,U,tt=R.dyn_tree,lt=R.stat_desc.static_tree,et=R.stat_desc.has_stree,ut=R.stat_desc.elems,vt=-1;for(z.heap_len=0,z.heap_max=573,X=0;X<ut;X++)0!==tt[2*X]?(z.heap[++z.heap_len]=vt=X,z.depth[X]=0):tt[2*X+1]=0;for(;z.heap_len<2;)tt[2*(U=z.heap[++z.heap_len]=vt<2?++vt:0)]=1,z.depth[U]=0,z.opt_len--,et&&(z.static_len-=lt[2*U+1]);for(R.max_code=vt,X=z.heap_len>>1;1<=X;X--)pt(z,tt,X);for(U=ut;X=z.heap[1],z.heap[1]=z.heap[z.heap_len--],pt(z,tt,1),K=z.heap[1],z.heap[--z.heap_max]=X,z.heap[--z.heap_max]=K,tt[2*U]=tt[2*X]+tt[2*K],z.depth[U]=(z.depth[X]>=z.depth[K]?z.depth[X]:z.depth[K])+1,tt[2*X+1]=tt[2*K+1]=U,z.heap[1]=U++,pt(z,tt,1),2<=z.heap_len;);z.heap[--z.heap_max]=z.heap[1],function(wt,$t){var mi,ye,Ee,kt,Fi,ds,we=$t.dyn_tree,Ve=$t.max_code,ce=$t.stat_desc.static_tree,he=$t.stat_desc.has_stree,Jr=$t.stat_desc.extra_bits,gi=$t.stat_desc.extra_base,ei=$t.stat_desc.max_length,_i=0;for(kt=0;kt<=w;kt++)wt.bl_count[kt]=0;for(we[2*wt.heap[wt.heap_max]+1]=0,mi=wt.heap_max+1;mi<573;mi++)ei<(kt=we[2*we[2*(ye=wt.heap[mi])+1]+1]+1)&&(kt=ei,_i++),we[2*ye+1]=kt,Ve<ye||(wt.bl_count[kt]++,Fi=0,gi<=ye&&(Fi=Jr[ye-gi]),wt.opt_len+=(ds=we[2*ye])*(kt+Fi),he&&(wt.static_len+=ds*(ce[2*ye+1]+Fi)));if(0!==_i){do{for(kt=ei-1;0===wt.bl_count[kt];)kt--;wt.bl_count[kt]--,wt.bl_count[kt+1]+=2,wt.bl_count[ei]--,_i-=2}while(0<_i);for(kt=ei;0!==kt;kt--)for(ye=wt.bl_count[kt];0!==ye;)Ve<(Ee=wt.heap[--mi])||(we[2*Ee+1]!==kt&&(wt.opt_len+=(kt-we[2*Ee+1])*we[2*Ee],we[2*Ee+1]=kt),ye--)}}(z,R),St(tt,vt,z.bl_count)}function P(z,R,X){var K,U,tt=-1,lt=R[1],et=0,ut=7,vt=4;for(0===lt&&(ut=138,vt=3),R[2*(X+1)+1]=65535,K=0;K<=X;K++)U=lt,lt=R[2*(K+1)+1],++et<ut&&U===lt||(et<vt?z.bl_tree[2*U]+=et:0!==U?(U!==tt&&z.bl_tree[2*U]++,z.bl_tree[32]++):et<=10?z.bl_tree[34]++:z.bl_tree[36]++,tt=U,vt=(et=0)===lt?(ut=138,3):U===lt?(ut=6,3):(ut=7,4))}function W(z,R,X){var K,U,tt=-1,lt=R[1],et=0,ut=7,vt=4;for(0===lt&&(ut=138,vt=3),K=0;K<=X;K++)if(U=lt,lt=R[2*(K+1)+1],!(++et<ut&&U===lt)){if(et<vt)for(;J(z,U,z.bl_tree),0!=--et;);else 0!==U?(U!==tt&&(J(z,U,z.bl_tree),et--),J(z,16,z.bl_tree),it(z,et-3,2)):et<=10?(J(z,17,z.bl_tree),it(z,et-3,3)):(J(z,18,z.bl_tree),it(z,et-11,7));tt=U,vt=(et=0)===lt?(ut=138,3):U===lt?(ut=6,3):(ut=7,4)}}l(Z);var H=!1;function k(z,R,X,K){var U,tt,lt;it(z,0+(K?1:0),3),tt=R,lt=X,rt(U=z),nt(U,lt),nt(U,~lt),n.arraySet(U.pending_buf,U.window,tt,lt,U.pending),U.pending+=lt}s._tr_init=function(z){H||(function(){var R,X,K,U,tt,lt=new Array(16);for(U=K=0;U<28;U++)for(N[U]=K,R=0;R<1<<A[U];R++)x[K++]=U;for(x[K-1]=U,U=tt=0;U<16;U++)for(Z[U]=tt,R=0;R<1<<O[U];R++)L[tt++]=U;for(tt>>=7;U<d;U++)for(Z[U]=tt<<7,R=0;R<1<<O[U]-7;R++)L[256+tt++]=U;for(X=0;X<=w;X++)lt[X]=0;for(R=0;R<=143;)B[2*R+1]=8,R++,lt[8]++;for(;R<=255;)B[2*R+1]=9,R++,lt[9]++;for(;R<=279;)B[2*R+1]=7,R++,lt[7]++;for(;R<=287;)B[2*R+1]=8,R++,lt[8]++;for(St(B,287,lt),R=0;R<d;R++)E[2*R+1]=5,E[2*R]=_t(R,5);Y=new at(B,A,257,f,w),q=new at(E,O,0,d,w),ct=new at(new Array(0),I,0,19,7)}(),H=!0),z.l_desc=new F(z.dyn_ltree,Y),z.d_desc=new F(z.dyn_dtree,q),z.bl_desc=new F(z.bl_tree,ct),z.bi_buf=0,z.bi_valid=0,dt(z)},s._tr_stored_block=k,s._tr_flush_block=function(z,R,X,K){var U,tt,lt=0;0<z.level?(2===z.strm.data_type&&(z.strm.data_type=function(et){var ut,vt=4093624447;for(ut=0;ut<=31;ut++,vt>>>=1)if(1&vt&&0!==et.dyn_ltree[2*ut])return 0;if(0!==et.dyn_ltree[18]||0!==et.dyn_ltree[20]||0!==et.dyn_ltree[26])return 1;for(ut=32;ut<u;ut++)if(0!==et.dyn_ltree[2*ut])return 1;return 0}(z)),Et(z,z.l_desc),Et(z,z.d_desc),lt=function(et){var ut;for(P(et,et.dyn_ltree,et.l_desc.max_code),P(et,et.dyn_dtree,et.d_desc.max_code),Et(et,et.bl_desc),ut=18;3<=ut&&0===et.bl_tree[2*D[ut]+1];ut--);return et.opt_len+=3*(ut+1)+5+5+4,ut}(z),(tt=z.static_len+3+7>>>3)<=(U=z.opt_len+3+7>>>3)&&(U=tt)):U=tt=X+5,X+4<=U&&-1!==R?k(z,R,X,K):4===z.strategy||tt===U?(it(z,2+(K?1:0),3),xt(z,B,E)):(it(z,4+(K?1:0),3),function(et,ut,vt,wt){var $t;for(it(et,ut-257,5),it(et,vt-1,5),it(et,wt-4,4),$t=0;$t<wt;$t++)it(et,et.bl_tree[2*D[$t]+1],3);W(et,et.dyn_ltree,ut-1),W(et,et.dyn_dtree,vt-1)}(z,z.l_desc.max_code+1,z.d_desc.max_code+1,lt+1),xt(z,z.dyn_ltree,z.dyn_dtree)),dt(z),K&&rt(z)},s._tr_tally=function(z,R,X){return z.pending_buf[z.d_buf+2*z.last_lit]=R>>>8&255,z.pending_buf[z.d_buf+2*z.last_lit+1]=255&R,z.pending_buf[z.l_buf+z.last_lit]=255&X,z.last_lit++,0===R?z.dyn_ltree[2*X]++:(z.matches++,R--,z.dyn_ltree[2*(x[X]+u+1)]++,z.dyn_dtree[2*V(R)]++),z.last_lit===z.lit_bufsize-1},s._tr_align=function(z){var R;it(z,2,3),J(z,256,B),16===(R=z).bi_valid?(nt(R,R.bi_buf),R.bi_buf=0,R.bi_valid=0):8<=R.bi_valid&&(R.pending_buf[R.pending++]=255&R.bi_buf,R.bi_buf>>=8,R.bi_valid-=8)}},{"../utils/common":41}],53:[function(e,i,s){i.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(e,i,s){(function(n){!function(o){if(!o.setImmediate){var l,c,h,u,f=1,d={},_=!1,m=o.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(o);w=w&&w.setTimeout?w:o,l="[object process]"==={}.toString.call(o.process)?function(C){process.nextTick(function(){v(C)})}:function(){if(o.postMessage&&!o.importScripts){var C=!0,S=o.onmessage;return o.onmessage=function(){C=!1},o.postMessage("","*"),o.onmessage=S,C}}()?(u="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",T,!1):o.attachEvent("onmessage",T),function(C){o.postMessage(u+C,"*")}):o.MessageChannel?((h=new MessageChannel).port1.onmessage=function(C){v(C.data)},function(C){h.port2.postMessage(C)}):m&&"onreadystatechange"in m.createElement("script")?(c=m.documentElement,function(C){var S=m.createElement("script");S.onreadystatechange=function(){v(C),S.onreadystatechange=null,c.removeChild(S),S=null},c.appendChild(S)}):function(C){setTimeout(v,0,C)},w.setImmediate=function(C){"function"!=typeof C&&(C=new Function(""+C));for(var S=new Array(arguments.length-1),M=0;M<S.length;M++)S[M]=arguments[M+1];return d[f]={callback:C,args:S},l(f),f++},w.clearImmediate=g}function g(C){delete d[C]}function v(C){if(_)setTimeout(v,0,C);else{var S=d[C];if(S){_=!0;try{!function(M){var A=M.callback,O=M.args;switch(O.length){case 0:A();break;case 1:A(O[0]);break;case 2:A(O[0],O[1]);break;case 3:A(O[0],O[1],O[2]);break;default:A.apply(void 0,O)}}(S)}finally{g(C),_=!1}}}}function T(C){C.source===o&&"string"==typeof C.data&&0===C.data.indexOf(u)&&v(+C.data.slice(u.length))}}(typeof self>"u"?void 0===n?this:n:self)}).call(this,typeof cn<"u"?cn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10);const ul=Bf(hl.exports);class Mr{constructor(t,e){y(this,"date",new Date),y(this,"author"),y(this,"guid",ie.create()),y(this,"viewpoint"),y(this,"modifiedAuthor"),y(this,"modifiedDate"),y(this,"topic"),y(this,"_components"),y(this,"_comment",""),this._components=t,this._comment=e;const i=this._components.get(qt);this.author=i.config.author}set comment(t){var e;const i=this._components.get(qt);this._comment=t,this.modifiedDate=new Date,this.modifiedAuthor=i.config.author,null==(e=this.topic)||e.comments.set(this.guid,this)}get comment(){return this._comment}toJSON(){var t,e;const i={guid:this.guid,date:this.date.toISOString(),author:this.author,comment:this.comment,topic_guid:null==(t=this.topic)?void 0:t.guid,viewpoint_guid:this.viewpoint,modified_date:null==(e=this.modifiedDate)?void 0:e.toISOString(),modified_author:this.modifiedAuthor};for(const[s,n]of Object.entries(i))void 0===n&&delete i[s];return i}}const dl=class ri{constructor(t){y(this,"guid",ie.create()),y(this,"title",ri.default.title),y(this,"creationDate",new Date),y(this,"creationAuthor",""),y(this,"viewpoints",new ot.PG),y(this,"relatedTopics",new ot.PG),y(this,"comments",new ot.jp),y(this,"documentReferences",new ot.PG),y(this,"customData",{}),y(this,"description"),y(this,"serverAssignedId"),y(this,"dueDate"),y(this,"modifiedAuthor"),y(this,"modifiedDate"),y(this,"index"),y(this,"_type",ri.default.type),y(this,"_status",ri.default.status),y(this,"_priority",ri.default.priority),y(this,"_stage",ri.default.stage),y(this,"_assignedTo",ri.default.assignedTo),y(this,"_labels",ri.default.labels??new Set),y(this,"_components"),this._components=t;const e=t.get(qt);this.creationAuthor=e.config.author,this.relatedTopics.guard=i=>i!==this.guid}set type(t){const e=this._components.get(qt),{strict:i,types:s}=e.config;(!i||s.has(t))&&(this._type=t)}get type(){return this._type}set status(t){const e=this._components.get(qt),{strict:i,statuses:s}=e.config;(!i||s.has(t))&&(this._status=t)}get status(){return this._status}set priority(t){const e=this._components.get(qt);if(t){const{strict:i,priorities:s}=e.config;if(i&&!s.has(t))return;this._priority=t}else this._priority=t}get priority(){return this._priority}set stage(t){const e=this._components.get(qt);if(t){const{strict:i,stages:s}=e.config;if(i&&!s.has(t))return;this._stage=t}else this._stage=t}get stage(){return this._stage}set assignedTo(t){const e=this._components.get(qt);if(t){const{strict:i,users:s}=e.config;if(i&&!s.has(t))return;this._assignedTo=t}else this._assignedTo=t}get assignedTo(){return this._assignedTo}set labels(t){const e=this._components.get(qt),{strict:i,labels:s}=e.config;if(i){const n=new Set;for(const o of t)(!i||s.has(o))&&n.add(o);this._labels=n}else this._labels=t}get labels(){return this._labels}get _managerVersion(){return this._components.get(qt).config.version}set(t){const e=t,i=this;for(const n in t)"guid"!==n&&n in this&&(i[n]=e[n]);return this._components.get(qt).list.set(this.guid,this),this}createComment(t,e){const i=new Mr(this._components,t);return i.viewpoint=e,i.topic=this,this.comments.set(i.guid,i),i}createLabelTags(){const t=[...this.labels];if(this._components.get(qt).config.exportCustomDataAsLabels)for(const i in this.customData){const s=this.customData[i];"string"==typeof s&&t.push(s)}return t}createCommentTags(){return[...this.comments.values()].map(t=>{var e;return{$Guid:t.guid,Date:t.date.toISOString(),Author:t.author,Comment:t.comment,ModifiedAuthor:t.modifiedAuthor,ModifiedDate:null==(e=t.modifiedDate)?void 0:e.toISOString(),Viewpoint:t.viewpoint?{$Guid:t.viewpoint}:void 0}})}createViewpointTags(){const t=this._components.get(Be);return[...this.viewpoints].map(i=>t.list.get(i)).filter(i=>i).map(i=>{const s={$Guid:i.guid,Viewpoint:`${i.title??i.guid}.bcfv`};if(t.snapshots.get(i.snapshot)){const o=t.getSnapshotExtension(i.snapshot);s.Snapshot=`${i.snapshot}.${o}`}return s})}createRelatedTopicTags(){return[...this.relatedTopics].map(t=>({$Guid:t}))}createDocumentReferencesTag(t=this._managerVersion){const e=[];if("3"!==t&&"2.1"!==t)return e;const i=this._components.get(qt);for(const s of this.documentReferences){const n=i.documents.get(s);if(!n)continue;let o={$Guid:ie.create(),Description:n.description};"2.1"===t&&(o={...o,$isExternal:"external"===n.type||void 0,ReferencedDocument:"external"===n.type?n.url:`../${n.fileName}`}),"3"===t&&(o={...o,DocumentGuid:"internal"===n.type?s:void 0,Url:"external"===n.type?n.url:void 0}),Object.keys(o).length>0&&e.push(o)}return e}toJSON(){var t,e;const i={guid:this.guid,server_assigned_id:this.serverAssignedId,topic_type:this.type,topic_status:this.status,title:this.title,priority:this.priority,index:this.index,labels:[...this.labels],creation_date:this.creationDate.toISOString(),creation_author:this.creationAuthor,modified_date:null==(t=this.modifiedDate)?void 0:t.toISOString(),modified_author:this.modifiedAuthor,assigned_to:this.assignedTo,stage:this.stage,description:this.description,due_date:null==(e=this.dueDate)?void 0:e.toISOString(),comments:[...this.comments].map(([o,a])=>a.toJSON()),relatedTopics:[...this.relatedTopics].map(o=>({related_topic_guid:o}))},s=this._components.get(Be);for(const o of this.viewpoints){const a=s.list.get(o);a&&(i.viewpoints||(i.viewpoints=[]),i.viewpoints.push(a.toJSON()))}const n=this._components.get(qt);for(const o of this.documentReferences){const a=n.documents.get(o);a&&(i.document_references||(i.document_references=[]),i.document_references.push("external"===a.type?{guid:ie.create(),description:a.description,url:a.url}:{guid:ie.create(),description:a.description,document_guid:o}))}for(const[o,a]of Object.entries(i))(void 0===a||Array.isArray(a)&&0===a.length)&&delete i[o];return i}serialize(){var t,e;const i=this._managerVersion,s={$Guid:this.guid,$TopicType:this.type,$TopicStatus:this.status,$ServerAssignedId:this.serverAssignedId,Title:this.title,CreationAuthor:this.creationAuthor,CreationDate:this.creationDate.toISOString(),Priority:this.priority,Index:"2.1"===i?this.index:void 0,ModifiedDate:null==(t=this.modifiedDate)?void 0:t.toISOString(),ModifiedAuthor:this.modifiedAuthor,DueDate:null==(e=this.dueDate)?void 0:e.toISOString(),AssignedTo:this.assignedTo,Description:this.description,Stage:this.stage,DocumentReferences:"3"===i?{DocumentReference:this.createDocumentReferencesTag(i)}:void 0,RelatedTopics:"3"===i?{RelatedTopic:this.createRelatedTopicTags()}:void 0,RelatedTopic:"2.1"===i?this.createRelatedTopicTags():void 0,Labels:"3"===i?{Label:this.createLabelTags()}:void 0,Viewpoints:"3"===i?{ViewPoint:this.createViewpointTags()}:void 0,Comments:"3"===i?{Comment:this.createCommentTags()}:void 0};"2.1"===i&&(s.Labels=this.createLabelTags(),s.DocumentReference=this.createDocumentReferencesTag(i));const n={Markup:{Topic:s}};return"2.1"===i&&(n.Markup.Viewpoints=this.createViewpointTags(),n.Markup.Comment=this.createCommentTags()),`<?xml version="1.0" encoding="UTF-8"?>\n ${Ts.builder.build(n)}`}};y(dl,"default",{title:"BCF Topic",type:"Issue",status:"Active"});let fl=dl;class Vf extends Wi{constructor(){super(...arguments),y(this,"_config",{version:{type:"Select",options:new Set(["2.1","3"]),multiple:!1,value:""},author:{type:"Text",value:""},types:{type:"TextSet",value:new Set},statuses:{type:"TextSet",value:new Set},priorities:{type:"TextSet",value:new Set},labels:{type:"TextSet",value:new Set},stages:{type:"TextSet",value:new Set},users:{type:"TextSet",value:new Set},includeSelectionTag:{type:"Boolean",value:!1},updateExtensionsOnImport:{type:"Boolean",value:!1},strict:{type:"Boolean",value:!1},includeAllExtensionsOnExport:{type:"Boolean",value:!1},fallbackVersionOnImport:{type:"Select",multiple:!1,options:new Set(["2.1","3"]),value:""},ignoreIncompleteTopicsOnImport:{type:"Boolean",value:!1},exportCustomDataAsLabels:{type:"Boolean",value:!1}})}get version(){return this._config.version.value}set version(t){this._config.version.value=t}get author(){return this._config.author.value}set author(t){this._config.author.value=t}get types(){return this._config.types.value}set types(t){this._config.types.value=t}get statuses(){return this._config.statuses.value}set statuses(t){this._config.statuses.value=t}get priorities(){return this._config.priorities.value}set priorities(t){this._config.priorities.value=t}get labels(){return this._config.labels.value}set labels(t){this._config.labels.value=t}get stages(){return this._config.stages.value}set stages(t){this._config.stages.value=t}get users(){return this._config.users.value}set users(t){this._config.users.value=t}get includeSelectionTag(){return this._config.includeSelectionTag.value}set includeSelectionTag(t){this._config.includeSelectionTag.value=t}get updateExtensionsOnImport(){return this._config.updateExtensionsOnImport.value}set updateExtensionsOnImport(t){this._config.updateExtensionsOnImport.value=t}get strict(){return this._config.strict.value}set strict(t){this._config.strict.value=t}get includeAllExtensionsOnExport(){return this._config.includeAllExtensionsOnExport.value}set includeAllExtensionsOnExport(t){this._config.includeAllExtensionsOnExport.value=t}get fallbackVersionOnImport(){return this._config.fallbackVersionOnImport.value}set fallbackVersionOnImport(t){this._config.fallbackVersionOnImport.value=t}get ignoreIncompleteTopicsOnImport(){return this._config.ignoreIncompleteTopicsOnImport.value}set ignoreIncompleteTopicsOnImport(t){this._config.ignoreIncompleteTopicsOnImport.value=t}get exportCustomDataAsLabels(){return this._config.exportCustomDataAsLabels.value}set exportCustomDataAsLabels(t){this._config.exportCustomDataAsLabels.value=t}}const Ir=class ms extends At{constructor(){super(...arguments),y(this,"enabled",!1),y(this,"_defaultConfig",{author:"jhon.doe@example.com",version:"2.1",types:new Set(["Clash","Failure","Fault","Inquiry","Issue","Remark","Request"]),statuses:new Set(["Active","In Progress","Done","In Review","Closed"]),priorities:new Set(["On hold","Minor","Normal","Major","Critical"]),labels:new Set,stages:new Set,users:new Set,includeSelectionTag:!1,updateExtensionsOnImport:!0,strict:!1,includeAllExtensionsOnExport:!0,fallbackVersionOnImport:"2.1",ignoreIncompleteTopicsOnImport:!1,exportCustomDataAsLabels:!1}),y(this,"config",new Vf(this,this.components,"BCF Topics",ms.uuid)),y(this,"list",new ot.jp),y(this,"documents",new ot.jp),y(this,"onSetup",new Q),y(this,"isSetup",!1),y(this,"onBCFImported",new Q),y(this,"onDisposed",new Q)}setup(t){if(this.isSetup)return;const e={...this._defaultConfig,...t};this.config.version=e.version,this.config.author=e.author,this.config.types=e.types,this.config.statuses=e.statuses,this.config.priorities=e.priorities,this.config.labels=e.labels,this.config.stages=e.stages,this.config.users=e.users,this.config.includeSelectionTag=e.includeSelectionTag,this.config.updateExtensionsOnImport=e.updateExtensionsOnImport,this.config.strict=e.strict,this.config.includeAllExtensionsOnExport=e.includeAllExtensionsOnExport,this.config.fallbackVersionOnImport=e.fallbackVersionOnImport||"",this.config.ignoreIncompleteTopicsOnImport=e.ignoreIncompleteTopicsOnImport,this.isSetup=!0,this.enabled=!0,this.onSetup.trigger()}create(t){const e=new fl(this.components);return t?(e.guid=t.guid??e.guid,e.set(t)):this.list.set(e.guid,e),e}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}get usedTypes(){const t=[...this.list].map(([e,i])=>i.type);return new Set(t)}get usedStatuses(){const t=[...this.list].map(([e,i])=>i.status);return new Set(t)}get usedPriorities(){const t=[...this.list].map(([e,i])=>i.priority).filter(e=>e);return new Set(t)}get usedStages(){const t=[...this.list].map(([e,i])=>i.stage).filter(e=>e);return new Set(t)}get usedUsers(){const t=[];for(const[e,i]of this.list){t.push(i.creationAuthor),i.assignedTo&&t.push(i.assignedTo),i.modifiedAuthor&&t.push(i.modifiedAuthor);for(const[s,n]of i.comments)t.push(n.author),n.modifiedAuthor&&t.push(n.modifiedAuthor)}return new Set(t)}get usedLabels(){const t=[];for(const[e,i]of this.list)t.push(...i.labels);return new Set(t)}updateExtensions(){for(const[t,e]of this.list){for(const i of e.labels)this.config.labels.add(i);this.config.types.add(e.type),e.priority&&this.config.priorities.add(e.priority),e.stage&&this.config.stages.add(e.stage),this.config.statuses.add(e.status),this.config.users.add(e.creationAuthor),e.assignedTo&&this.config.users.add(e.assignedTo),e.modifiedAuthor&&this.config.users.add(e.modifiedAuthor);for(const[i,s]of e.comments)this.config.users.add(s.author),s.modifiedAuthor&&this.config.users.add(s.modifiedAuthor)}}updateViewpointReferences(){const t=this.components.get(Be);for(const[e,i]of this.list)for(const s of i.viewpoints)t.list.has(s)||i.viewpoints.delete(s)}export(){var t=this;return(0,G.A)(function*(e=t.list.values()){const i=new ul;i.file("bcf.version",`<?xml version="1.0" encoding="UTF-8"?>\n <Version VersionId="${t.config.version}" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/buildingSMART/BCF-XML/release_3_0/Schemas/version.xsd"\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n </Version>`);for(const[o,a]of t.documents.entries())"external"!==a.type&&i.file("2.1"===t.config.version?a.fileName:`documents/${o}`,a.data);if("3"===t.config.version){const o=[];for(const[a,l]of t.documents.entries()){const{type:c,description:h}=l;"external"!==c&&o.push(`<Document Guid="${a}">\n <Filename>${l.fileName}</Filename>\n ${h?`<Description>${h}</Description>`:""}\n </Document>`)}o.length>0&&i.file("documents.xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n <DocumentInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="documents.xsd">\n <Documents>\n ${o.join("\n")}\n </Documents>\n </DocumentInfo>`)}i.file("bcf.extensions",t.serializeExtensions());const s=t.components.get(Be);for(const o of e){const a=i.folder(o.guid);a.file("markup.bcf",o.serialize());for(const l of o.viewpoints){const c=s.list.get(l);if(!c)continue;a.file(`${c.title??c.guid}.bcfv`,yield c.serialize());const u=s.snapshots.get(c.snapshot);if(!u)continue;const f=u?c.snapshot:c.guid,d=s.getSnapshotExtension(c.snapshot);a.file(`${f}.${d}`,u,{binary:!0})}}return yield i.generateAsync({type:"blob"})}).apply(this,arguments)}serializeExtensions(){const t=[...this.config.types].map(a=>`<TopicType>${a}</TopicType>`).join("\n"),e=[...this.config.statuses].map(a=>`<TopicStatus>${a}</TopicStatus>`).join("\n"),i=[...this.config.priorities].map(a=>`<Priority>${a}</Priority>`).join("\n"),s=[...this.config.labels].map(a=>`<TopicLabel>${a}</TopicLabel>`).join("\n"),n=[...this.config.stages].map(a=>`<Stage>${a}</Stage>`).join("\n"),o=[...this.config.users].map(a=>`<User>${a}</User>`).join("\n");return`\n <?xml version="1.0" encoding="UTF-8"?>\n <Extensions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="your-schema-location.xsd">\n ${0!==t.length?`<TopicTypes>\n${t}\n</TopicTypes>`:""}\n ${0!==e.length?`<TopicStatuses>\n${e}\n</TopicStatuses>`:""}\n ${0!==i.length?`<Priorities>\n${i}\n</Priorities>`:""}\n ${0!==s.length?`<TopicLabels>\n${s}\n</TopicLabels>`:""}\n ${0!==n.length?`<Stages>\n${n}\n</Stages>`:""}\n ${0!==o.length?`<Users>\n${o}\n</Users>`:""}\n </Extensions>\n `}processMarkupComment(t){const{Guid:e,Date:i,Author:s,Comment:n,Viewpoint:o}=t;if(!(e&&i&&s&&Mr))return null;const a=new Mr(this.components,n??"");return a.guid=e,a.date=new Date(i),a.author=s,a.viewpoint=o?.Guid,a.modifiedAuthor=t.ModifiedAuthor,a.modifiedDate=t.ModifiedDate?new Date(t.ModifiedDate):void 0,a}getMarkupComments(t,e){var i;let s;if("2.1"===e&&(s=t.Comment),"3"===e&&(s=null==(i=t.Topic.Comments)?void 0:i.Comment),!s)return[];s=Array.isArray(s)?s:[s];const n=s.map(a=>this.processMarkupComment(a)).filter(a=>a);return Array.isArray(n)?n:[n]}getMarkupLabels(t,e){var i;let s;return"2.1"===e&&(s=t.Topic.Labels),"3"===e&&(s=null==(i=t.Topic.Labels)?void 0:i.Label),s?Array.isArray(s)?s:[s]:[]}getMarkupViewpoints(t,e){var i;let s;return"2.1"===e&&(s=t.Viewpoints),"3"===e&&(s=null==(i=t.Topic.Viewpoints)?void 0:i.ViewPoint),s?(s=Array.isArray(s)?s:[s],s):[]}getMarkupRelatedTopics(t,e){var i;let s;return"2.1"===e&&(s=t.Topic.RelatedTopic),"3"===e&&(s=null==(i=t.Topic.RelatedTopics)?void 0:i.RelatedTopic),s?(Array.isArray(s)?s:[s]).map(o=>o.Guid):[]}getMarkupDocumentReferences(t,e){var i;let s;return"2.1"===e&&(s=t.Topic.DocumentReference),"3"===e&&(s=null==(i=t.Topic.DocumentReferences)?void 0:i.DocumentReference),s?Array.isArray(s)?s:[s]:[]}load(t){var e=this;return(0,G.A)(function*(){var i,s,n;const{fallbackVersionOnImport:o,ignoreIncompleteTopicsOnImport:a,updateExtensionsOnImport:l}=e.config,c=new ul;yield c.loadAsync(t);const h=Object.values(c.files);let u=o;const f=h.find(C=>C.name.endsWith(".version"));if(f){const C=yield f.async("string"),S=ms.xmlParser.parse(C).Version.VersionId;u=String(S)}if(!u||"2.1"!==u&&"3"!==u)throw new Error(`BCFTopics: ${u} is not supported.`);const d=h.find(C=>C.name.endsWith(".extensions"));if(l&&d){const C=yield d.async("string");((r,t)=>{if(""===t.trim())return;const e=qt.xmlParser.parse(t).Extensions;if(!e)return;const{Priorities:i,TopicStatuses:s,TopicTypes:n,Users:o}=e;if(i&&i.Priority){const a=Array.isArray(i.Priority)?i.Priority:[i.Priority];for(const l of a)r.config.priorities.add(l)}if(s&&s.TopicStatus){const a=Array.isArray(s.TopicStatus)?s.TopicStatus:[s.TopicStatus];for(const l of a)r.config.statuses.add(l)}if(n&&n.TopicType){const a=Array.isArray(n.TopicType)?n.TopicType:[n.TopicType];for(const l of a)r.config.types.add(l)}if(o&&o.User){const a=Array.isArray(o.User)?o.User:[o.User];for(const l of a)r.config.users.add(l)}})(e,C)}const _=[],m=e.components.get(Be),w=h.filter(C=>C.name.endsWith(".bcfv"));for(const C of w){const S=yield C.async("string"),M=ms.xmlParser.parse(S).VisualizationInfo;if(!M){console.warn("Missing VisualizationInfo in Viewpoint");continue}const A={},{Guid:O,ClippingPlanes:I,Components:D,OrthogonalCamera:B,PerspectiveCamera:E}=M;if(O&&(A.guid=O),D){const x={selection:[],coloring:[],visibility:{default_visibility:!1,exceptions:[],view_setup_hints:{spaces_visible:!1,space_boundaries_visible:!1,openings_visible:!1}}};A.components=x;const{Selection:N,Visibility:Y}=D;if(N&&N.Component){const Z=Array.isArray(N.Component)?N.Component:[N.Component];x.selection=Z.map(at=>at.IfcGuid?{ifc_guid:at.IfcGuid}:null).filter(at=>null!==at)}if(Y&&"DefaultVisibility"in Y&&(x.visibility.default_visibility=Y.DefaultVisibility),Y&&Y.Exceptions&&"Component"in Y.Exceptions){const{Component:Z}=Y.Exceptions,at=Array.isArray(Z)?Z:[Z];x.visibility.exceptions=at.map(F=>F.IfcGuid?{ifc_guid:F.IfcGuid}:null).filter(F=>null!==F)}let q;"2.1"===u&&(q=D.ViewSetupHints),"3"===u&&(q=null==(i=D.Visibility)?void 0:i.ViewSetupHints),q&&("OpeningsVisible"in q&&(x.visibility.view_setup_hints.openings_visible=q.OpeningsVisible),"SpacesVisible"in q&&(x.visibility.view_setup_hints.spaces_visible=q.SpacesVisible),"SpaceBoundariesVisible"in q&&(x.visibility.view_setup_hints.space_boundaries_visible=q.SpaceBoundariesVisible));const{Coloring:ct}=D;if(ct&&ct.Color){const Z=Array.isArray(ct.Color)?ct.Color:[ct.Color];for(const at of Z){const{Color:F,Component:V}=at;if(6!==F.length&&8!==F.length)continue;const nt=6===F.length?F:F.slice(2),J=(Array.isArray(V)?V:[V]).map(_t=>_t.IfcGuid?{ifc_guid:_t.IfcGuid}:null).filter(_t=>null!==_t);x.coloring.push({color:nt,components:J})}}}if(B||E){const x=M.PerspectiveCamera??M.OrthogonalCamera,{CameraViewPoint:N,CameraDirection:Y}=x,q=new p.Pq0(Number(N.X),Number(N.Z),Number(-N.Y)),ct=new p.Pq0(Number(Y.X),Number(Y.Z),Number(-Y.Y)),Z={camera_view_point:{x:q.x,y:q.y,z:q.z},camera_direction:{x:ct.x,y:ct.y,z:ct.z},aspect_ratio:"AspectRatio"in x?x.AspectRatio:1,camera_up_vector:{x:0,y:0,z:0}};"ViewToWorldScale"in x&&(A.orthogonal_camera={...Z,view_to_world_scale:x.ViewToWorldScale}),"FieldOfView"in x&&(A.perspective_camera={...Z,field_of_view:x.FieldOfView})}if(I){const N=(Array.isArray(I.ClippingPlane)?I.ClippingPlane:[I.ClippingPlane]).map(({Location:Y,Direction:q})=>({location:{x:Y.x,y:Y.y,z:Y.z},direction:{x:q.x,y:q.y,z:q.z}}));A.clipping_planes=N}const L=new ml(e.components,A);_.push(L)}const g={},v=[],T=h.filter(C=>C.name.endsWith(".bcf"));for(const C of T){const S=yield C.async("string"),M=ms.xmlParser.parse(S).Markup,A=M.Topic,{Guid:O,TopicType:I,TopicStatus:D,Title:B,CreationDate:E,CreationAuthor:L}=A;if(a&&!(O&&I&&D&&B&&E&&L))continue;const x=new fl(e.components);x.guid=O??x.guid;const N=e.getMarkupRelatedTopics(M,u);g[x.guid]=new Set(N),x.type=I??x.type,x.status=D??x.status,x.title=B??x.title,x.creationDate=E?new Date(E):x.creationDate,x.creationAuthor=L??x.creationAuthor,x.serverAssignedId=A.ServerAssignedId,x.priority=A.Priority,x.index=A.Index,x.modifiedDate=A.ModifiedDate?new Date(A.ModifiedDate):void 0,x.modifiedAuthor=A.ModifiedAuthor,x.dueDate=A.DueDate?new Date(A.DueDate):void 0,x.assignedTo=A.AssignedTo,x.description=A.Description,x.stage=A.Stage;const Y=e.getMarkupLabels(M,u);for(const nt of Y)x.labels.add(nt);const q=e.getMarkupComments(M,u);for(const nt of q)x.comments.set(nt.guid,nt);const ct=e.getMarkupViewpoints(M,u);for(const nt of ct){if(!nt||!nt.Guid)continue;const it=m.list.get(nt.Guid);if(!it)continue;x.viewpoints.add(it.guid);const J=`${x.guid}/${nt.Snapshot}`,_t=h.find(({name:St})=>St===J);if(_t){const St=yield _t.async("arraybuffer"),dt=new Uint8Array(St);m.snapshots.set(it.guid,dt),it.snapshot=it.guid??null}}const Z=e.getMarkupDocumentReferences(M,u),at=h.find(nt=>"documents.xml"===nt.name);let F=[];const V=yield at?.async("string");if(V){const nt=null==(n=null==(s=Ts.parser.parse(V).DocumentInfo)?void 0:s.Documents)?void 0:n.Document;F=Array.isArray(nt)?nt:[nt]}for(const nt of Z){const{Description:it,DocumentGuid:J,Url:_t,isExternal:St,ReferencedDocument:dt}=nt;if(J&&F.length>0){const rt=F.find(({Guid:P})=>P===J),ht=h.find(P=>P.name.endsWith(J)),pt=yield ht?.async("uint8array");if(!rt||!pt)continue;const{Description:xt,Filename:Et}=rt;e.documents.set(J,{type:"internal",fileName:Et,description:xt,data:pt}),x.documentReferences.add(J)}if(_t){const rt=e.documents.add({type:"external",url:_t,description:it});x.documentReferences.add(rt)}if(dt){let rt=null;if(St)rt=e.documents.add({type:"external",url:dt,description:it});else{const ht=dt.split("/"),pt=ht[ht.length-1],xt=h.find(P=>P.name.endsWith(pt)),Et=yield xt?.async("uint8array");if(!Et)continue;rt=e.documents.add({type:"internal",fileName:pt,data:Et,description:it})}x.documentReferences.add(rt)}}e.list.set(x.guid,x),v.push(x)}for(const C in g){const S=e.list.get(C);if(!S)continue;const M=g[C];for(const A of M)S.relatedTopics.add(A)}return e.onBCFImported.trigger(v),{viewpoints:_,topics:v}})()}};y(Ir,"uuid","de977976-e4f6-4e4f-a01a-204727839802"),y(Ir,"xmlParser",new Fn({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0}));let qt=Ir;class Or{constructor(t,e,i,s,n,o=5,a=!0){var l;if(y(this,"onDraggingStarted",new Q),y(this,"onDraggingEnded",new Q),y(this,"onDisposed",new Q),y(this,"normal"),y(this,"origin"),y(this,"three",new p.Zcv),y(this,"components"),y(this,"world"),y(this,"type","default"),y(this,"_title","Clipping Plane"),y(this,"_helper"),y(this,"_visible",!0),y(this,"_enabled",!0),y(this,"_controlsActive",!1),y(this,"_arrowBoundBox",new p.eaF),y(this,"_planeMesh"),y(this,"_controls"),y(this,"_hiddenMaterial",new p.V9B({visible:!1})),y(this,"_sizeMultiplier",5),y(this,"_autoScale",!0),y(this,"_visibilityBeforeDisabled",!0),y(this,"notifyManager",()=>{const h=this.components.get(ti),u=h.list.getKey(this);u&&h.list.set(u,this)}),y(this,"update",()=>{this._enabled&&(this.three.setFromNormalAndCoplanarPoint(this.normal,this._helper.position),this.updateScale())}),y(this,"updateScale",()=>{var h;if(!this.autoScale)return;const u=null==(h=this.world.camera)?void 0:h.three;if(!(u&&u instanceof p.ubm))return;const f=new p.Pq0;u.getWorldPosition(f);const _=f.distanceTo(this._helper.position)/7*this._sizeMultiplier;this._planeMesh.scale.set(_,_,_)}),y(this,"changeDrag",h=>{this._visible=!h.value,this.preventCameraMovement(),this.notifyDraggingChanged(h)}),this.components=t,this.world=e,!e.renderer)throw new Error("The given world must have a renderer!");this.normal=s,this.origin=i,this._sizeMultiplier=o;const c=t.get(ti);e.renderer.setPlane(!0,this.three,c.localClippingPlanes),this._planeMesh=Or.newPlaneMesh(o,n),this._helper=this.newHelper(),this._controls=this.newTransformControls(),this.three.setFromNormalAndCoplanarPoint(s,i),a&&this.toggleControls(!0),this.updateScale(),null!=(l=e.camera)&&l.controls&&e.camera.controls.addEventListener("update",this.updateScale)}set title(t){this._title=t,this.notifyManager()}get title(){return this._title}get autoScale(){return this._autoScale}set autoScale(t){this._autoScale=t,t&&this.updateScale()}get enabled(){return this._enabled}set enabled(t){if(this.world.isDisposing)return;if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");this._enabled=t,t?this.visible=this._visibilityBeforeDisabled:(this._visibilityBeforeDisabled=this.visible,this.visible=!1);const e=this.components.get(ti);this.world.renderer.setPlane(t,this.three,e.localClippingPlanes),this.notifyManager()}get visible(){return this._visible}set visible(t){this._visible=t,this._controls.getHelper().visible=t,this._helper.visible=t,this.toggleControls(t),this.notifyManager()}get meshes(){return[this._planeMesh,this._arrowBoundBox]}get planeMaterial(){return this._planeMesh.material}set planeMaterial(t){this._planeMesh.material=t}get size(){return this._sizeMultiplier}set size(t){this._sizeMultiplier=t,this.autoScale?this.updateScale():this._planeMesh.scale.set(t,t,t)}get helper(){return this._helper}get controls(){return this._controls}setFromNormalAndCoplanarPoint(t,e){this.reset(),this.normal.equals(t)||(this.normal.copy(t),this._helper.lookAt(t)),this.origin.copy(e),this._helper.position.copy(e),this._helper.updateMatrix(),this.update()}dispose(){var t;this._enabled=!1,null!=(t=this.world.camera)&&t.controls&&this.world.camera.controls.removeEventListener("update",this.updateScale),this.onDraggingStarted.reset(),this.onDraggingEnded.reset(),this._helper.removeFromParent(),this.world.renderer&&this.world.renderer.setPlane(!1,this.three),this._arrowBoundBox.removeFromParent(),this._arrowBoundBox.geometry.dispose(),this._planeMesh.geometry.dispose(),this._controls.getHelper().removeFromParent(),this._controls.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}reset(){const t=new p.Pq0(1,0,0),e=new p.Pq0;this.normal.equals(t)||(this.normal.copy(t),this._helper.lookAt(t)),this.origin.copy(e),this._helper.position.copy(e),this._helper.updateMatrix()}toggleControls(t){if(t){if(this._controlsActive)return;this._controls.addEventListener("change",this.update),this._controls.addEventListener("dragging-changed",this.changeDrag)}else this._controls.removeEventListener("change",this.update),this._controls.removeEventListener("dragging-changed",this.changeDrag);this._controlsActive=t}newTransformControls(){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");const i=new sh.ZU(this.world.camera.three,this.world.renderer.three.domElement);return this.initializeControls(i),this.world.scene.three.add(i.getHelper()),i}initializeControls(t){t.attach(this._helper),t.showX=!1,t.showY=!1,t.setSpace("local"),this.createArrowBoundingBox(),t.getHelper().children[0].children[0].add(this._arrowBoundBox)}createArrowBoundingBox(){this._arrowBoundBox.geometry=new p.Ho_(.18,.18,1.2),this._arrowBoundBox.material=this._hiddenMaterial,this._arrowBoundBox.rotateX(Math.PI/2),this._arrowBoundBox.updateMatrix(),this._arrowBoundBox.geometry.applyMatrix4(this._arrowBoundBox.matrix)}notifyDraggingChanged(t){t.value?this.onDraggingStarted.trigger():this.onDraggingEnded.trigger()}preventCameraMovement(){this.world.camera.enabled=this._visible}newHelper(){const t=new p.B69;return t.lookAt(this.normal),t.position.copy(this.origin),this._planeMesh.position.z+=.01,t.add(this._planeMesh),this.world.scene.three.add(t),t}static newPlaneMesh(t,e){const i=new p.bdM(1),s=new p.eaF(i,e);return s.scale.set(t,t,t),s}}class Uf extends Wi{constructor(){super(...arguments),y(this,"_config",{enabled:{value:!0,type:"Boolean"},visible:{value:!0,type:"Boolean"},color:{value:new p.Q1f,type:"Color"},opacity:{type:"Number",interpolable:!0,value:1,min:0,max:1},size:{type:"Number",interpolable:!0,value:2,min:0,max:100}})}get enabled(){return this._config.enabled.value}set enabled(t){this._config.enabled.value=t,this._component.enabled=t}get visible(){return this._config.visible.value}set visible(t){this._config.visible.value=t,this._component.visible=t}get color(){return this._config.color.value}set color(t){this._config.color.value=t,this._component.material.color.copy(t)}get opacity(){return this._config.opacity.value}set opacity(t){this._config.opacity.value=t,this._component.material.opacity=t}get size(){return this._config.size.value}set size(t){this._config.size.value=t,this._component.size=t}}const pl=class yn extends At{constructor(t){super(t),y(this,"onSetup",new Q),y(this,"onBeforeDrag",new Q),y(this,"onAfterDrag",new Q),y(this,"onBeforeCreate",new Q),y(this,"onBeforeCancel",new Q),y(this,"onAfterCancel",new Q),y(this,"onBeforeDelete",new Q),y(this,"onAfterCreate",new Q),y(this,"onAfterDelete",new Q),y(this,"onDisposed",new Q),y(this,"isSetup",!1),y(this,"orthogonalY",!1),y(this,"toleranceOrthogonalY",.7),y(this,"autoScalePlanes",!0),y(this,"localClippingPlanes",!1),y(this,"Type",Or),y(this,"list",new ot.jp),y(this,"config",new Uf(this,this.components,"Clipper",yn.uuid)),y(this,"_defaultConfig",{color:new p.Q1f(12255487),opacity:.2,size:2}),y(this,"_material",new p.V9B({color:12255487,side:p.$EB,transparent:!0,opacity:.2})),y(this,"_size",5),y(this,"_enabled",!1),y(this,"_visible",!0),y(this,"onStateChanged",new Q),this.components.add(yn.uuid,this),this.setEvents()}get enabled(){return this._enabled}set enabled(t){this._enabled=t,this.onStateChanged.trigger(["enabled"])}get visible(){return this._visible}set visible(t){this._visible=t;for(const[e,i]of this.list)i.visible=t;this.onStateChanged.trigger(["visibility"])}get material(){return this._material}set material(t){this._material=t;for(const[e,i]of this.list)i.planeMaterial=t;this.onStateChanged.trigger(["material"])}get size(){return this._size}set size(t){this._size=t;for(const[e,i]of this.list)i.size=t;this.onStateChanged.trigger(["size"])}setEvents(){this.list.onBeforeDelete.add(({value:e})=>{if(!e.world.renderer)throw new Error("Renderer not found for this plane's world!");e.world.renderer.setPlane(!1,e.three),e.dispose(),this.updateMaterialsAndPlanes(),this.onAfterDelete.trigger(e)});const t=this.components.get(ft);if(t.initialized)this.subscribeToFragmentMaterials();else{const e=()=>{t.onFragmentsLoaded.remove(e),this.subscribeToFragmentMaterials()};t.onFragmentsLoaded.add(e)}}subscribeToFragmentMaterials(){const t=this.components.get(ft);for(const[,e]of t.core.models.materials.list)this.applyClippingToFragmentMaterial(e);t.core.models.materials.list.onItemSet.add(({value:e})=>{this.applyClippingToFragmentMaterial(e)})}applyClippingToFragmentMaterial(t){if(!this.localClippingPlanes)return;const e=this.components.get(an);for(const[,i]of e.list)if(i.renderer)return void(t.clippingPlanes=i.renderer.clippingPlanes)}dispose(){this._enabled=!1,this.components.get(Ps).list.delete(this.config.uuid),this.list.clear(),this._material.dispose(),this.onBeforeCreate.reset(),this.onBeforeCancel.reset(),this.onBeforeDelete.reset(),this.onBeforeDrag.reset(),this.onAfterCreate.reset(),this.onAfterCancel.reset(),this.onAfterDelete.reset(),this.onAfterDrag.reset(),this.onDisposed.trigger(yn.uuid),this.onDisposed.reset()}create(t){var e=this;return(0,G.A)(function*(){const n=yield e.components.get(on).get(t).castRay();return n?e.createPlaneFromIntersection(t,n):null})()}createFromNormalAndCoplanarPoint(t,e,i){const s=this.newPlane(t,i,e);return this.updateMaterialsAndPlanes(),s}delete(t,e){var i=this;return(0,G.A)(function*(){if(!e){const s=yield i.pickPlane(t);if(!s)return;e=i.list.getKey(s)}e&&i.list.delete(e)})()}deleteAll(t){for(const[e,i]of this.list)(!t||t.has(i.type))&&this.list.delete(e)}setup(t){const e={...this._defaultConfig,...t};this.config.color=e.color,this.config.opacity=e.opacity,this.config.size=e.size,this.isSetup=!0,this.onSetup.trigger()}pickPlane(t){const i=this.components.get(on).get(t),s=this.getAllPlaneMeshes(),n=i.castRayToObjects(s);if(n){const o=n.object;return[...this.list.values()].find(a=>a.meshes.includes(o))}}getAllPlaneMeshes(){const t=[];for(const[e,i]of this.list)t.push(...i.meshes);return t}createPlaneFromIntersection(t,e){var i;if(!t.renderer)throw new Error("The given world must have a renderer!");const s=e.point.distanceTo(new p.Pq0(0,0,0)),n=e.normal||(null==(i=e.face)?void 0:i.normal);if(!s||!n)return null;const o=this.getWorldNormal(e,n),a=this.newPlane(t,e.point,o.negate()),l=this.list.get(a);return l.visible=this._visible,l.size=this._size,t.renderer.setPlane(!0,l.three,this.localClippingPlanes),this.updateMaterialsAndPlanes(),l}getWorldNormal(t,e){const i=t.object;let s=t.object.matrixWorld.clone();if(i instanceof p.ZLX&&void 0!==t.instanceId){const l=new p.kn4;i.getMatrixAt(t.instanceId,l),s=l.multiply(s)}const o=(new p.dwI).getNormalMatrix(s),a=e.clone().applyMatrix3(o).normalize();return this.normalizePlaneDirectionY(a),a}normalizePlaneDirectionY(t){this.orthogonalY&&(t.y>this.toleranceOrthogonalY&&(t.x=0,t.y=1,t.z=0),t.y<-this.toleranceOrthogonalY&&(t.x=0,t.y=-1,t.z=0))}newPlane(t,e,i){const s=new this.Type(this.components,t,e,i,this._material);s.autoScale=this.autoScalePlanes,s.onDraggingStarted.add(()=>this.onBeforeDrag.trigger(s)),s.onDraggingEnded.add(()=>this.onAfterDrag.trigger(s));const n=ie.create();return this.list.set(n,s),this.onAfterCreate.trigger(s),n}updateMaterialsAndPlanes(){const t=this.components.get(an);for(const[e,i]of t.list){if(!i.renderer)continue;i.renderer.updateClippingPlanes();const{clippingPlanes:s}=i.renderer;for(const n of i.meshes)if(n.material)if(Array.isArray(n.material))for(const o of n.material)o.clippingPlanes=s;else n.material.clippingPlanes=s}}};y(pl,"uuid","66290bc5-18c4-4cd1-9379-2e17a0617611");let ti=pl;class ml{constructor(t,e){y(this,"title"),y(this,"guid",ie.create()),y(this,"clippingPlanes",new ot.PG),y(this,"camera",{aspect_ratio:1,field_of_view:60,camera_direction:{x:0,y:0,z:0},camera_view_point:{x:0,y:0,z:0},camera_up_vector:{x:0,y:1,z:0}}),y(this,"customData",{}),y(this,"exceptionComponents",new ot.PG),y(this,"selectionComponents",new ot.PG),y(this,"componentColors",new ot.jp),y(this,"spacesVisible",!1),y(this,"spaceBoundariesVisible",!1),y(this,"openingsVisible",!1),y(this,"defaultVisibility",!0),y(this,"snapshot",this.guid),y(this,"_components"),y(this,"_world",null),y(this,"notifyUpdate",()=>{this._components.get(Be).list.set(this.guid,this)}),this._components=t,e&&(this.guid=e.guid??this.guid,this.set(e)),this.setEvents()}getSelectionMap(){var t=this;return(0,G.A)(function*(){return yield t._components.get(ft).guidsToModelIdMap([...t.selectionComponents])})()}getExceptionMap(){var t=this;return(0,G.A)(function*(){return yield t._components.get(ft).guidsToModelIdMap([...t.exceptionComponents])})()}get projection(){return"field_of_view"in this.camera?"Perspective":"Orthographic"}get position(){const t=this._components.get(ft),{camera_view_point:e}=this.camera,{x:i,y:s,z:n}=e,o=new p.Pq0(i,s,n);return t.applyBaseCoordinateSystem(o,new p.kn4),o}set position(t){const e=t.clone(),i=this._components.get(ft);t.clone().applyMatrix4(i.baseCoordinationMatrix.clone().invert()),this.camera.camera_view_point={x:e.x,y:e.y,z:e.z}}get direction(){const{camera_direction:t}=this.camera,{x:e,y:i,z:s}=t;return new p.Pq0(e,i,s)}set world(t){this._world=t}get world(){return this._world}get _managerVersion(){return this._components.get(qt).config.version}get topics(){return[...this._components.get(qt).list.values()].filter(s=>s.viewpoints.has(this.guid))}setEvents(){this.selectionComponents.onUpdated.add(this.notifyUpdate),this.exceptionComponents.onUpdated.add(this.notifyUpdate),this.clippingPlanes.onUpdated.add(this.notifyUpdate),this.componentColors.onItemSet.add(this.notifyUpdate),this.componentColors.onItemDeleted.add(this.notifyUpdate),this.componentColors.onItemUpdated.add(this.notifyUpdate),this.componentColors.onCleared.add(this.notifyUpdate)}set(t){this.title=t.title;const{components:e,perspective_camera:i,orthogonal_camera:s,clipping_planes:n}=t;if(e){const{selection:o,visibility:a,coloring:l}=e;if(o){this.selectionComponents.clear();for(const{ifc_guid:c}of o)c&&this.selectionComponents.add(c)}if(a){const{default_visibility:c,exceptions:h,view_setup_hints:u}=a;if(void 0!==c&&(this.defaultVisibility=c),h){this.exceptionComponents.clear();for(const{ifc_guid:f}of h)f&&this.exceptionComponents.add(f)}if(u){const{spaces_visible:f,space_boundaries_visible:d,openings_visible:_}=u;void 0!==f&&(this.spacesVisible=f),void 0!==d&&(this.spaceBoundariesVisible=d),void 0!==_&&(this.openingsVisible=_)}}if(l){this.componentColors.clear();for(const c of l){const{color:h,components:u}=c,f=u.map(d=>d.ifc_guid).filter(d=>null!==d);this.componentColors.set(h,f)}}}if((i||s)&&(this.camera=i??s),n&&this.world){const o=this._components.get(ti);for(const a of n){const{location:l,direction:c}=a,h=new p.Pq0(l.x,l.z,-l.y),u=new p.Pq0(c.x,c.z,-c.y),f=o.createFromNormalAndCoplanarPoint(this.world,u,h);this.clippingPlanes.add(f),o.list.get(f).enabled=!1,o.list.get(f).visible=!1}}this.notifyUpdate()}go(t){var e=this;return(0,G.A)(function*(){if(!e.world)return;const{camera:i}=e.world;if(!(i instanceof ln))throw new Error("Viewpoint: the world's camera component must be of type OrthoPerspectiveCamera to switch between perspective and orthographic projections.");const{transition:s,applyClippings:n,applyVisibility:o,clippingsVisibility:a}={transition:!0,applyClippings:!0,applyVisibility:!0,clippingsVisibility:!0,...t};i.projection.set(e.projection);const l=new p.Pq0(e.camera.camera_view_point.x,e.camera.camera_view_point.y,e.camera.camera_view_point.z),c=new p.Pq0(e.camera.camera_direction.x,e.camera.camera_direction.y,e.camera.camera_direction.z);if(l.equals(new p.Pq0)&&c.equals(new p.Pq0))return;const h=e.position,u=e.direction,d={x:h.x+80*u.x,y:h.y+80*u.y,z:h.z+80*u.z},_=[];n&&e.setClippingState(!0),o&&_.push(e.applyVisibility()),e.setClippingVisibility(a),_.push(i.controls.setLookAt(h.x,h.y,h.z,d.x,d.y,d.z,s)),yield Promise.all(_)})()}updateCamera(){var t=this;return(0,G.A)(function*(e=!0){return new Promise(i=>{if(!t.world)return void i(!1);const{camera:s,renderer:n}=t.world;if(!n)throw new Error("Viewpoint: the world needs to have a renderer!");if(!s.hasCameraControls())throw new Error("Viewpoint: world's camera need camera controls!");const o=s.three,a=o.getWorldPosition(new p.Pq0),l=o.getWorldDirection(new p.Pq0),{width:c,height:h}=n.getSize();let u=c/h;Number.isNaN(u)&&(u=1);const f=t._components.get(ft);a.applyMatrix4(f.baseCoordinationMatrix.clone().invert());const d={aspect_ratio:u,camera_view_point:{x:a.x,y:a.y,z:a.z},camera_direction:{x:l.x,y:l.y,z:l.z},camera_up_vector:{x:0,y:1,z:0}};if(o instanceof p.ubm?t.camera={...d,field_of_view:o.fov}:o instanceof p.qUd&&(t.camera={...d,view_to_world_scale:o.top-o.bottom}),e){const _=t._components.get(Be),m=n.three.domElement;n.three.render(t.world.scene.three,s.three),m.toBlob(function(){var w=(0,G.A)(function*(g){if(g){const v=yield g.arrayBuffer(),T=new Uint8Array(v);_.snapshots.set(t.guid,T)}t.notifyUpdate(),i(!0)});return function(g){return w.apply(this,arguments)}}())}else t.notifyUpdate(),i(!0)})}).apply(this,arguments)}takeSnapshot(){var t=this;return new Promise(e=>{if(!this.world)return void e(!1);const{camera:i,renderer:s}=this.world;if(!s)throw new Error("Viewpoint: the world needs to have a renderer!");const n=this._components.get(Be),o=s.three.domElement;s.three.render(this.world.scene.three,i.three),o.toBlob(function(){var a=(0,G.A)(function*(l){if(l){const c=yield l.arrayBuffer(),h=new Uint8Array(c);n.snapshots.set(t.guid,h)}t.notifyUpdate(),e(!0)});return function(l){return a.apply(this,arguments)}}())})}updateClippingPlanes(){this.clippingPlanes.clear();const t=this._components.get(ti);for(const[e,i]of t.list)i.enabled&&this.clippingPlanes.add(e)}applyVisibility(){var t=this;return(0,G.A)(function*(){const e=t._components.get(af);e.set(t.defaultVisibility);const i=yield t.getExceptionMap();e.set(!t.defaultVisibility,i);const s=yield t.getSelectionMap();e.set(!0,s)})()}setColorizationState(t){var e=this;return(0,G.A)(function*(){const i=e._components.get(ft),s=[];if(t)for(const[n,o]of e.componentColors){const a=`#${n}`,l=yield i.guidsToModelIdMap(o);for(const[c,h]of Object.entries(l)){const u=i.list.get(c);u&&s.push(u.highlight([...h],{customId:a,color:new p.Q1f(a),renderedFaces:ot.eB.ONE,opacity:1,transparent:!1}))}}else for(const[n,o]of e.componentColors){const a=yield i.guidsToModelIdMap(o);for(const[l,c]of Object.entries(a)){const h=i.list.get(l);h&&s.push(h.resetHighlight([...c]))}}s.push(i.core.update(!0)),yield Promise.all(s)})()}setClippingState(t){const e=this._components.get(ti);for(const[i,s]of e.list)s.enabled=t&&this.clippingPlanes.has(i)}setClippingVisibility(t){const e=this._components.get(ti);for(const i of this.clippingPlanes){const s=e.list.get(i);s&&(s.visible=t)}}createComponentTags(t){var e=this;return(0,G.A)(function*(){var i;const s=e._components.get(ft);let o="";if(e._components.get(qt).config.includeSelectionTag){const a="selection"===t?yield e.getSelectionMap():yield e.getExceptionMap();for(const l in a){const c=s.list.get(l);if(!c)continue;const h=a[l];for(const u of h){const f=c.getItem(u),d=yield f.getGuid();if(!d)continue;const _=null==(i=yield f.getAttributes())?void 0:i.getValue("Tag");let m=null;_&&(m=`AuthoringToolId="${_}"`),o+=`\n<Component IfcGuid="${d}" ${m??""} />`}}}else o=[...e.selectionComponents].map(a=>`<Component IfcGuid="${a}" />`).join("\n");return o})()}createColorTags(){let t="";for(const[e,i]of this.componentColors.entries())t+=`<Color Color="${e}">\n${i.map(n=>`\n<Component IfcGuid="${n}" />`).join("\n")}\n</Color>`;return 0!==t.length?`<Coloring>\n${t}\n</Coloring>`:"<Coloring />"}toJSON(){const t=this._components.get(ti),e={guid:this.guid,components:{selection:[...this.selectionComponents].map(n=>({ifc_guid:n,authoring_tool_id:null})),coloring:[...this.componentColors].map(([n,o])=>({color:n,components:o.map(a=>({ifc_guid:a,authoring_tool_id:null}))})),visibility:{default_visibility:this.defaultVisibility,exceptions:[...this.exceptionComponents].map(n=>({ifc_guid:n,authoring_tool_id:null})),view_setup_hints:{spaces_visible:this.spacesVisible,space_boundaries_visible:this.spaceBoundariesVisible,openings_visible:this.openingsVisible}}},clipping_planes:[...this.clippingPlanes].map(n=>{const o=t.list.get(n);if(!o)return null;const a=o._controls.worldPosition??o.origin,{normal:l}=o;return{location:{x:a.x,y:-a.z,z:a.y},direction:{x:l.x,y:-l.z,z:l.y}}}).filter(n=>null!==n)};"field_of_view"in this.camera?e.perspective_camera=this.camera:e.orthogonal_camera=this.camera;const i=this._components.get(Be),s=i.snapshots.get(this.snapshot);if(s){const n=s.toString(),o=btoa(n),a=i.getSnapshotExtension(this.snapshot);e.snapshot={snapshot_type:a,snapshot_data:o}}return e}serialize(){var t=this;return(0,G.A)(function*(e=t._managerVersion){const i=t._components.get(ft),s=t.position;s.applyMatrix4(i.baseCoordinationMatrix.clone().invert());const n=t.direction;n.normalize();const o=(new p.kn4).makeRotationX(Math.PI/2),a=n.clone().applyMatrix4(o);a.normalize();const l=`<CameraViewPoint>\n <X>${s.x}</X>\n <Y>${-s.z}</Y>\n <Z>${s.y}</Z>\n </CameraViewPoint>`,c=`<CameraDirection>\n <X>${n.x}</X>\n <Y>${-n.z}</Y>\n <Z>${n.y}</Z>\n </CameraDirection>`,h=`<CameraUpVector>\n <X>${a.x}</X>\n <Y>${-a.z}</Y>\n <Z>${a.y}</Z>\n </CameraUpVector>`,u=`<AspectRatio>${t.camera.aspect_ratio}</AspectRatio>`;let f="";"view_to_world_scale"in t.camera?f=`<OrthogonalCamera>\n ${l}\n ${c}\n ${h}\n ${u}\n <ViewToWorldScale>${t.camera.view_to_world_scale}</ViewToWorldScale>\n </OrthogonalCamera>`:"field_of_view"in t.camera&&(f=`<PerspectiveCamera>\n ${l}\n ${c}\n ${h}\n ${u}\n <FieldOfView>${t.camera.field_of_view}</FieldOfView>\n </PerspectiveCamera>`);const d=`<ViewSetupHints SpacesVisible="${t.spacesVisible??!1}" SpaceBoundariesVisible="${t.spaceBoundariesVisible??!1}" OpeningsVisible="${t.openingsVisible??!1}" />`,_=(yield t.createComponentTags("selection")).trim(),m=(yield t.createComponentTags("exception")).trim(),w=t.createColorTags();return`<?xml version="1.0" encoding="UTF-8"?>\n <VisualizationInfo Guid="${t.guid}">\n <Components>\n ${"2.1"===e?d:""}\n ${0!==_.length?`<Selection>${_}</Selection>`:""}\n <Visibility DefaultVisibility="${t.defaultVisibility}">\n ${"3"===e?d:""}\n ${0!==m.length?`<Exceptions>${m}</Exceptions>`:""}\n </Visibility>\n ${w}\n </Components>\n ${f}\n </VisualizationInfo>`}).apply(this,arguments)}}class $f extends Wi{constructor(){super(...arguments),y(this,"_config",{overwriteColors:{value:!1,type:"Boolean"}})}get overwriteColors(){return this._config.overwriteColors.value}set overwriteColors(t){this._config.overwriteColors.value=t}}const gl=class yo extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"world",null),y(this,"list",new ot.jp),y(this,"snapshots",new ot.jp),y(this,"isSetup",!1),y(this,"onSetup",new Q),y(this,"config",new $f(this,this.components,"Viewpoints",yo.uuid)),y(this,"onDisposed",new Q),t.add(yo.uuid,this)}create(t){const e=new ml(this.components,t);return e.world=this.world,t||this.list.set(e.guid,e),e}getSnapshotExtension(t){let e="jpeg";const i=this.snapshots.get(t);if(!i)return e;const s=i.subarray(0,4);let n="";for(let o=0;o<s.length;o++)n+=s[o].toString(16);return n.startsWith("89504e47")&&(e="png"),n.startsWith("ffd8ffe")&&(e="jpeg"),e}setup(){}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}};y(gl,"uuid","ee867824-a796-408d-8aa0-4e5962a83c66");let Be=gl;class _l{constructor(t,e){y(this,"_components"),y(this,"_cameraOffset",10),y(this,"_planeHelper"),y(this,"_farPlaneHelper"),y(this,"_cameraHelper"),y(this,"onStateChanged",new Q),y(this,"onUpdated",new Q),y(this,"onDisposed",new Q),y(this,"camera"),y(this,"plane",new p.Zcv),y(this,"farPlane",new p.Zcv),y(this,"id",ie.create()),y(this,"_open",!1),y(this,"_range",jf.defaultRange),y(this,"_world",null),y(this,"_helpersVisible",!1),y(this,"_planesEnabled",!1),this._components=t,this.camera=new ln(this._components);const{threeOrtho:i}=this.camera;if(e?.id&&(this.id=e.id),e?.normal&&e?.point){const{normal:s,point:n}=e;this.plane.setFromNormalAndCoplanarPoint(s,n)}this._cameraHelper=new p.WTh(i),this._planeHelper=new p.ZM4(this.plane,50),this._farPlaneHelper=new p.ZM4(this.farPlane,50),this.farPlaneHelperColor=new p.Q1f("blue"),this.update()}get _planeNormalOpposite(){return this.plane.normal.clone().negate()}get _planePosition(){return this.plane.normal.clone().multiplyScalar(-this.plane.constant)}get _cameraPosition(){return this._planePosition.addScaledVector(this._planeNormalOpposite,this._cameraOffset)}set open(t){this._open=t,this.onStateChanged.trigger(["open"])}get open(){return this._open}set planeHelperColor(t){!Array.isArray(this._planeHelper.material)&&"color"in this._planeHelper.material&&this._planeHelper.material.color instanceof p.Q1f&&(this._planeHelper.material.color=t)}set farPlaneHelperColor(t){!Array.isArray(this._farPlaneHelper.material)&&"color"in this._farPlaneHelper.material&&this._farPlaneHelper.material.color instanceof p.Q1f&&(this._farPlaneHelper.material.color=t)}set range(t){this._range=t,this.update()}get range(){return this._range}set distance(t){this.plane.constant=t,this.update()}get distance(){return this.plane.constant}set world(t){this._world=t,this.camera.currentWorld=t,t&&(this.camera.projection.set("Orthographic"),this.camera.set("Plan"),this.camera.controls.dollySpeed=6,this.camera.controls.restThreshold=.005,this.update())}get world(){return this._world}set helpersVisible(t){if(!t)return this._helpersVisible=t,this._planeHelper.removeFromParent(),this._farPlaneHelper.removeFromParent(),void this._cameraHelper.removeFromParent();this.world&&(this._helpersVisible=t,this.world.scene.three.add(this._planeHelper,this._farPlaneHelper))}get helpersVisible(){return this._helpersVisible}set planesEnabled(t){const{world:e}=this;if(!e)return;const{renderer:i}=e;i&&(i.setPlane(t,this.plane),i.setPlane(t,this.farPlane),this._planesEnabled=t)}get planesEnabled(){return this._planesEnabled}dispose(){this.helpersVisible=!1;const t=this._components.get(bi);t.destroy(this._planeHelper),t.destroy(this._farPlaneHelper),t.destroy(this._cameraHelper),this.camera.dispose(),this.onDisposed.trigger()}update(){if(this.world){const t=this._cameraPosition,e=this._planePosition;this.camera.controls.setLookAt(t.x,t.y,t.z,e.x,e.y,e.z,!1)}this.farPlane.normal.copy(this._planeNormalOpposite),this.farPlane.constant=this.range-this.plane.constant,this.onUpdated.trigger()}flip(){this.plane.normal.negate(),this.update()}}const zr=class Wc extends At{constructor(t){super(t),y(this,"list",new ot.jp),y(this,"enabled",!0),y(this,"world",null),y(this,"_fragmentsUpdateEvent",()=>{this.components.get(ft).core.update(!0)}),y(this,"restoreCameraOnClose",!0),y(this,"_restoreState",null),t.add(Wc.uuid,this),this.setupEvents()}get hasOpenViews(){return[...this.list.values()].some(t=>t.open)}setupEvents(){this.list.onBeforeDelete.add(({key:t,value:e})=>{e.open&&this.close(t),e.dispose()})}create(t,e,i){const s=new _l(this.components,{id:i?.id,normal:t,point:e});return s.world=i?.world??this.world,this.list.set(s.id,s),s}createFromPlane(t,e){const i=new _l(this.components,{id:e?.id});return i.plane.copy(t),i.update(),i.world=e?.world??this.world,this.list.set(i.id,i),i}createFromIfcStoreys(t){var e=this;return(0,G.A)(function*(){const i=[],s=e.components.get(ft),n=void 0===t?.offset?.25:t.offset;for(const[o,a]of s.list){if(t&&t.modelIds&&!t.modelIds.some(f=>f.test(o)))continue;const l=Object.values(yield a.getItemsOfCategories([/BUILDINGSTOREY/])).flat();if(0===l.length)continue;const c=yield a.getItemsData(l),[,h]=yield a.getCoordinates(),u=new p.Pq0(0,-1,0);for(const f of c){if(!("value"in f.Name)||!("value"in f.Elevation))continue;const{value:d}=f.Name;if(t?.storeyNames&&!t.storeyNames.some(g=>g.test(d)))continue;const m=new p.Zcv(u,f.Elevation.value+h+n),w=e.createFromPlane(m,{id:d,world:t?.world});i.push(w)}}return i})()}createElevations(t){const e=[],i=this.components.get(ft),s=void 0!==t?.combine&&t.combine,n=t?.namingCallback??(a=>({front:s?"Front":`${a}: Front`,back:s?"Back":`${a}: Back`,left:s?"Left":`${a}: Left`,right:s?"Right":`${a}: Right`}));let o=[];for(const[a,l]of i.list)t&&t.modelIds&&!t.modelIds.some(c=>c.test(a))||o.push({id:a,box:l.box});if(0===o.length)return e;if(s){const a=this.components.get(Qa);a.list.clear(),a.list.add(...o.map(c=>c.box)),o=[{id:"combined",box:a.get()}]}for(const{id:a,box:l}of o){const{min:c,max:h}=l,u=Math.abs(h.x-c.x),f=Math.abs(h.z-c.z),d=new p.Pq0;l.getCenter(d);const _=new p.Zcv(new p.Pq0(0,0,-1),h.z),m=new p.Zcv(new p.Pq0(0,0,1),-c.z),w=new p.Zcv(new p.Pq0(-1,0,0),h.x),g=new p.Zcv(new p.Pq0(1,0,0),-c.x),{front:v,back:T,left:C,right:S}=n(a),M=this.createFromPlane(_,{id:v,world:t?.world});M.range=f;const A=this.createFromPlane(m,{id:T,world:t?.world});A.range=f;const O=this.createFromPlane(w,{id:C,world:t?.world});O.range=u;const I=this.createFromPlane(g,{id:S,world:t?.world});I.range=u,e.push(M,A,O,I)}return e}open(t){const e=this.list.get(t);if(!e)throw new Error(`Views: the view with id ${t} doesn't exist.`);if(e.open)return;const{world:i}=e;if(!i)throw new Error(`Views: no world found for view with id ${t}.`);const{renderer:s}=i;if(!s)throw new Error(`Views: no renderer found for world with id ${i.uuid}.`);for(const[,n]of this.list)n.world===i&&this.close(n.id);this.restoreCameraOnClose&&i.camera!==e.camera&&!this._restoreState&&i.camera.controls&&(this._restoreState={camera:i.camera,json:i.camera.controls.toJSON()}),s.setPlane(!0,e.plane),s.setPlane(!0,e.farPlane),this.setOnlyEnabledControls(i,e),e.camera.controls.addEventListener("rest",this._fragmentsUpdateEvent),i.camera=e.camera,e.open=!0}close(t){let e;if(e=t?this.list.get(t):[...this.list.values()].find(n=>n.open),t&&!e)throw new Error(`Views: the view with id ${t} doesn't exist.`);if(!e||!e.open)return;const{world:i}=e;if(!i)throw new Error(`Views: no world found for view with id ${t}.`);const{renderer:s}=i;if(!s)throw new Error(`Views: no renderer found for world with id ${i.uuid}.`);if(s.setPlane(!1,e.plane),s.setPlane(!1,e.farPlane),e.camera.controls.removeEventListener("rest",this._fragmentsUpdateEvent),i.useDefaultCamera(),e.open=!1,this.setOnlyEnabledControls(i,null),this.restoreCameraOnClose&&this._restoreState){const{camera:n,json:o}=this._restoreState;n===i.camera&&n.controls&&n.controls.fromJSON(o,!1),this._restoreState=null}}setOnlyEnabledControls(t,e){const i=e?e.camera:t.defaultCamera,s=(n,o)=>{n.controls&&(n.controls.enabled=o)};s(i,!0),i!==t.defaultCamera&&s(t.defaultCamera,!1);for(const[,n]of this.list)n.world===t&&n.camera!==i&&s(n.camera,!1)}};y(zr,"uuid","fb22f1f5-6598-4664-a11d-de8963ae420f"),y(zr,"defaultRange",15);let jf=zr;class Ni{constructor(t){y(this,"cardinality","required"),y(this,"instructions"),y(this,"evalRequirement",(e,i,s,n)=>{const o={parameter:s,currentValue:e,requiredValue:i,pass:!1};n&&this.addCheckResult(o,n);let a=!1;if("simple"===i.type&&(a=e===i.parameter),"enumeration"===i.type&&(a=i.parameter.includes(e)),"pattern"===i.type&&(a=new RegExp(i.parameter).test(String(e))),"length"===i.type){const{min:l,length:c,max:h}=i.parameter;void 0!==c&&(a=String(e).length===c),void 0!==l&&(a=String(e).length>=l),void 0!==h&&(a=String(e).length<=h)}if("bounds"===i.type&&"number"==typeof e){const{min:l,minInclusive:c,max:h,maxInclusive:u}=i.parameter;let f=!0,d=!0;void 0!==l&&(f=c?e>=l:e>l),void 0!==h&&(d=u?e<=h:e<h),a=f&&d}return"prohibited"===this.cardinality&&(a=!a),"optional"===this.cardinality&&(a=!0),o.pass=a,o.pass}),this._components=t}addCheckResult(t,e){const i=e.findIndex(({parameter:s})=>s===t.parameter);-1!==i?e[i]=t:e.push(t)}getItemChecks(t,e,i,s){if(!("value"in i._localId)||"number"!=typeof i._localId.value)return null;let n=t.get(e);n||(n=new ot.jp,t.set(e,n));let o=n.get(i._localId.value);if(o&&s&&!o.pass)return null;if(!o){const c=[];o={guid:Array.isArray(i._guid)?void 0:i._guid.value,pass:!1,checks:c},Object.defineProperty(o,"pass",{get:()=>c.every(({pass:h})=>h)}),n.set(i._localId.value,o)}const a=[],l={facetType:this.facetType,cardinality:this.cardinality,checks:a,pass:!1};return Object.defineProperty(l,"pass",{get:()=>a.every(({pass:c})=>c)}),o.checks.push(l),l.checks}}const Se=(r,t)=>{let e="";if(!t)return e;if("simple"===t.type&&(e=`<simpleValue>${t.parameter}</simpleValue>`),"enumeration"===t.type&&(e=`<xs:restriction base="xs:string">\n ${t.parameter.map(n=>`<xs:enumeration value="${n}" />`).join("\n")}\n </xs:restriction>`),"pattern"===t.type&&(e=`<xs:restriction base="xs:string">\n <xs:pattern value="${t.parameter}" />\n </xs:restriction>`),"bounds"===t.type){const{min:s,minInclusive:n,max:o,maxInclusive:a}=t.parameter;let l="";void 0!==s&&(l=`<xs:min${n?"Inclusive":"Exclusive"} value="${s}">`);let c="";void 0!==o&&(c=`<xs:max${a?"Inclusive":"Exclusive"} value="${o}">`),e=`<xs:restriction base="xs:double">\n ${l}\n ${c}\n </xs:restriction>`}if("length"===t.type){const{length:s,min:n,max:o}=t.parameter;let a="";void 0!==s&&void 0===n&&void 0===o&&(a=`<xs:length value="${s}" />`);let l="";void 0!==n&&void 0===s&&(l=`<xs:minLength value="${n}" />`);let c="";void 0!==o&&void 0===s&&(c=`<xs:maxLength value="${o}" />`),e=`<xs:restriction base="xs:string">\n ${a}\n ${l}\n ${c}\n </xs:restriction>`}return`<${r[0].toLowerCase()+r.slice(1)}>\n ${e}\n </${r[0].toLowerCase()+r.slice(1)}>`};class Zf extends Ni{constructor(t,e){super(t),y(this,"facetType","Attribute"),y(this,"name"),y(this,"value"),this.name=e}serialize(t){const e=Se("Name",this.name),i=Se("Value",this.value);let s="";return"requirement"===t&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<attribute ${s}>\n ${e}\n ${i}\n</attribute>`}getEntities(){return(0,G.A)(function*(){})()}test(t,e){var i=this;return(0,G.A)(function*(s,n,o={skipIfFails:!0}){const a=i._components.get(ft);for(const[l,c]of Object.entries(s)){const h=a.list.get(l);if(!h)continue;const u=yield h.getItemsData([...c]);for(const f of u){const d=i.getItemChecks(n,l,f,o.skipIfFails);if(!d)continue;const m=Object.keys(f).filter(g=>{const v=i.evalRequirement(g,i.name,"Name");if(!v)return!1;const T=f[g];return!!Array.isArray(T)||(null===T||null===T.value?"optional"===i.cardinality||"prohibited"===i.cardinality:!(Array.isArray(T.value)&&0===T.value.length||"string"==typeof T.value&&""===T.value.trim())&&v)}),w=m.length>0;if(d.push({parameter:"Name",currentValue:w?m[0]:null,requiredValue:i.name,pass:"prohibited"===i.cardinality?!w:w}),i.value)if(m[0]){const g=f[m[0]];Array.isArray(g)||Array.isArray(g.value)?d.push({parameter:"Value",currentValue:null,requiredValue:i.value,pass:"prohibited"===i.cardinality}):i.evalRequirement(g.value,i.value,"Value",d)}else d.push({parameter:"Value",currentValue:null,requiredValue:i.value,pass:"prohibited"===i.cardinality})}}}).apply(this,arguments)}}class Wf extends Ni{constructor(t,e){super(t),y(this,"facetType","Classification"),y(this,"system"),y(this,"value"),y(this,"uri"),this.system=e}serialize(t){const e=Se("System",this.system),i=Se("Value",this.value);let s="";return"requirement"===t&&(s+=`cardinality="${this.cardinality}"`,s+=this.uri?`uri=${this.uri}`:"",s+=this.instructions?`instructions="${this.instructions}"`:""),`<classification ${s}>\n ${e}\n ${i}\n</classification>`}getEntities(t,e){return(0,G.A)(function*(){})()}test(t,e){return(0,G.A)(function*(){})()}}class Lr extends Ni{constructor(t,e){super(t),y(this,"facetType","Entity"),y(this,"name"),y(this,"predefinedType"),this.name=e}serialize(t){const e=Se("Name",this.name),i=Se("Name",this.predefinedType);let s="";return"requirement"===t&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<entity ${s}>\n ${e}\n ${i}\n</entity>`}getEntities(t,e){var i=this;return(0,G.A)(function*(){const s=i._components.get(ft),n=new Map;for(const[a,l]of s.list){if(!t.find(u=>u.test(a)))continue;const h=yield l.getCategories();for(const u of h){if(!(yield i.evalName(u)))continue;let d=n.get(a);d||(d=[],n.set(a,d)),d.push(u)}}const o={};if(yield Promise.all(Array.from(n.entries()).map(function(){var a=(0,G.A)(function*([l,c]){const h=s.list.get(l);if(!h)return;const u=c.map(_=>new RegExp(`^${_}$`)),f=yield h.getItemsOfCategories(u),d=Object.values(f).flat();o[l]=new Set(d)});return function(l){return a.apply(this,arguments)}}())),i.predefinedType)for(const[a,l]of Object.entries(o)){const c=s.list.get(a);if(!c)continue;const h=yield c.getItemsData([...l]);for(const u of h)"value"in u._localId&&(yield i.evalPredefinedType(a,u))&&Rt.append(e,a,u._localId.value)}else Rt.add(e,o)})()}test(t,e,i){var s=this;return(0,G.A)(function*(){const n=s._components.get(ft);for(const[o,a]of Object.entries(t)){const l=n.list.get(o);if(!l)continue;const c=yield l.getItemsData([...a]);for(const h of c){if(!("value"in h._category))continue;const u=s.getItemChecks(e,o,h,i.skipIfFails);u&&(yield s.evalName(h._category.value,u),yield s.evalPredefinedType(o,h,u))}}})()}evalName(t,e){var i=this;return(0,G.A)(function*(){return i.evalRequirement(t,i.name,"Name",e)})()}evalPredefinedType(t,e,i){var s=this;return(0,G.A)(function*(){if(!s.predefinedType||!("value"in e.PredefinedType))return null;const n="string"==typeof s.predefinedType.parameter&&"USERDEFINED"===s.predefinedType.parameter;let o=e.PredefinedType.value;if("USERDEFINED"===o&&!n){const c=Object.keys(e).find(h=>/^((?!Predefined).)*Type$/.test(h));if(c){const h=e[c];"value"in h&&(o=h.value)}else o="USERDEFINED"}if(!o){const c=s._components.get(ft).list.get(t);if(c&&"value"in e._localId){const[h]=yield c.getItemsData([e._localId.value],{relations:{IsTypedBy:{attributes:!0,relations:!1}}});if(Array.isArray(h.IsTypedBy)){const u=h.IsTypedBy[0];if(u&&"value"in u.PredefinedType&&(o=u.PredefinedType.value,"USERDEFINED"===o&&!n)){const d=Object.keys(u).find(_=>/^((?!Predefined).)*Type$/.test(_));if(d){const _=u[d];"value"in _&&(o=_.value)}else o="USERDEFINED"}}}}return s.evalRequirement(o,s.predefinedType,"PredefinedType",i)})()}}class Xf extends Ni{constructor(t,e,i){super(t),y(this,"facetType","Property"),y(this,"propertySet"),y(this,"baseName"),y(this,"value"),y(this,"dataType"),y(this,"uri"),y(this,"_unsupportedTypes",["IFCCOMPLEXPROPERTY","IFCPHYSICALCOMPLEXQUANTITY"]),this.propertySet=e,this.baseName=i}serialize(t){const e=Se("PropertySet",this.propertySet),i=Se("BaseName",this.baseName),s=Se("Value",this.value);let o="";return"requirement"===t&&(o+=`cardinality="${this.cardinality}"`,o+=this.uri?`uri=${this.uri}`:"",o+=this.instructions?`instructions="${this.instructions}"`:""),`<property ${this.dataType?`dataType=${this.dataType}`:""} ${o}>\n ${e}\n ${i}\n ${s}\n</property>`}getEntities(t,e){var i=this;return(0,G.A)(function*(){const s=i._components.get(ft);for(const[n,o]of s.list){if(!t.find(u=>u.test(n)))continue;const l=yield o.getItemsOfCategories([/PROPERTYSET/,/ELEMENTQUANTITY/]),c=Object.values(l).flat();if(0===c.length)continue;const h=yield o.getItemsData(c,{relations:{HasProperties:{attributes:!0,relations:!1},DefinesOcurrence:{attributes:!0,relations:!1}}});for(const u of h){if(!("value"in u._localId&&"value"in u._category&&"value"in u.Name&&Array.isArray(u.DefinesOcurrence)&&i.evalRequirement(u.Name.value,i.propertySet,"PropertySet")))continue;let d;if("IFCPROPERTYSET"===u._category.value&&(d="HasProperties"),"IFCELEMENTQUANTITY"===u._category.value&&(d="Quantities"),!d)continue;const _=u[d];if(Array.isArray(_))for(const m of _){const w=Object.keys(m),g=w.find(S=>/Name/.test(S));if(!g||!("value"in m[g]))continue;const v=m[g];if(!("value"in v)||!i.evalRequirement(v.value,i.baseName,"BaseName"))continue;if(i.value){const S=w.find(O=>/Value/.test(O));if(!S)continue;const M=m[S];if(!("value"in M)||!i.evalRequirement(M.value,i.value,"Value"))continue}const C=u.DefinesOcurrence.map(S=>"value"in S._localId&&"number"==typeof S._localId.value?S._localId.value:null).filter(S=>null!==S);Rt.append(e,n,...C)}}}})()}test(t,e){var i=this;return(0,G.A)(function*(s,n,o={skipIfFails:!0}){const a=i._components.get(ft);for(const[l,c]of Object.entries(s)){const h=a.list.get(l);if(!h)continue;const u=yield h.getItemsData([...c],{relations:{IsDefinedBy:{attributes:!0,relations:!0},IsTypedBy:{attributes:!0,relations:!1},HasPropertySets:{attributes:!0,relations:!0},DefinesOcurrence:{attributes:!1,relations:!1}}});for(const f of u){const d=i.getItemChecks(n,l,f,o.skipIfFails);if(!d)continue;const m=(yield i.getPsets(f)).filter(w=>!(!("value"in w.Name)||!i.evalRequirement(w.Name.value,i.propertySet,"PropertySet")||(d.push({currentValue:w.Name.value,parameter:"PropertySet",pass:!0,requiredValue:i.propertySet}),0)));if(0!==m.length)for(const w of m){const g=i.getPropertyListName(w);if(!g)continue;const v=w[g];if(!Array.isArray(v)){d.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:i.baseName});continue}const T=v.filter(C=>!(!("value"in C._category)||!("value"in C.Name)||i._unsupportedTypes.includes(C._category.value)||!i.evalRequirement(C.Name.value,i.baseName,"BaseName")||(d.push({currentValue:C.Name.value,parameter:"BaseName",pass:!0,requiredValue:i.baseName}),0)));if(0!==T.length)for(const C of T)i.evalValue(C,d),i.evalDataType(C,d),i.evalURI();else d.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:i.baseName})}else d.push({currentValue:null,parameter:"PropertySet",pass:!1,requiredValue:i.propertySet})}}}).apply(this,arguments)}getPropertyListName(t){let e;return"value"in t._category&&("IFCPROPERTYSET"===t._category.value&&(e="HasProperties"),"IFCELEMENTQUANTITY"===t._category.value&&(e="Quantities")),e}getValueKey(t){return Object.keys(t).find(e=>/Value/.test(e)||/Values/.test(e))}getTypePsets(t){if(!Array.isArray(t.IsTypedBy))return[];const[e]=t.IsTypedBy;return e&&Array.isArray(e.HasPropertySets)?e.HasPropertySets:[]}getPsets(t){var e=this;return(0,G.A)(function*(){const i=e.getTypePsets(t);if(!Array.isArray(t.IsDefinedBy))return i;const s=[];for(const n of t.IsDefinedBy){if(!("value"in n.Name))continue;const o=n.Name.value,a=e.getPropertyListName(n);if(!o||!a)continue;const l=i.find(c=>"value"in c.Name&&c.Name.value===o);if(l&&Array.isArray(l.HasProperties)&&Array.isArray(n.HasProperties))for(const c of l.HasProperties){if(!("value"in c.Name))continue;const h=c.Name.value;n.HasProperties.find(f=>"value"in f.Name&&f.Name.value===h)||n.HasProperties.push(c)}s.push(n)}return s})()}evalValue(t,e){const i=this.getValueKey(t),s=t[i];if(!("value"in s))return!1;if(this.value){if(!i)return e?.push({parameter:"Value",currentValue:null,pass:!1,requiredValue:this.value}),!1;const n=structuredClone(this.value);return"IFCLABEL"===s.type&&"simple"===n.type&&(n.parameter=String(n.parameter)),this.evalRequirement(s.value,n,"Value",e)}return!i||"string"!=typeof s.value||""!==s.value.trim()||(e?.push({parameter:"Value",currentValue:"",pass:!1,requiredValue:this.value}),!1)}evalDataType(t,e){if(!this.dataType)return!0;const i=this.getValueKey(t);return i&&"value"in t[i]?this.evalRequirement(t[i].type??null,{type:"simple",parameter:this.dataType},"DataType",e):(e?.push({parameter:"DataType",currentValue:null,pass:!1,requiredValue:this.dataType}),!1)}evalURI(){return!0}}class Kf extends Ni{constructor(){super(...arguments),y(this,"_ifcMaterialEntities",[/^IFCMATERIALLAYERSETUSAGE$/,/^IFCMATERIALCONSTITUENTSET$/,/^IFCMATERIAL$/,/^IFCMATERIALLIST$/]),y(this,"facetType","Material"),y(this,"value"),y(this,"uri")}serialize(t){if(!this.value||!this.uri)return"<material />";const e=Se("Value",this.value);let i="";return"requirement"===t&&(i+=`cardinality="${this.cardinality}"`,i+=this.uri?`uri=${this.uri}`:"",i+=this.instructions?`instructions="${this.instructions}"`:""),`<material ${i}>\n ${e}\n</material>`}getEntities(t,e){var i=this;return(0,G.A)(function*(){const s=i._components.get(ft);for(const[n,o]of s.list){if(!t.find(u=>u.test(n)))continue;const l=yield o.getItemsOfCategories(i._ifcMaterialEntities),c=Object.values(l).flat();if(0===c.length)continue;const h=yield o.getItemsData(c,{relations:{AssociatedTo:{attributes:!0,relations:!1},MaterialConstituents:{attributes:!0,relations:!0},ForLayerSet:{attributes:!0,relations:!0},MaterialLayers:{attributes:!0,relations:!0},Materials:{attributes:!0,relations:!1}}});for(const u of h){if(!("value"in u._localId&&"value"in u._category&&Array.isArray(u.AssociatedTo)&&i.hasValidMaterial(u)))continue;const d=u.AssociatedTo.map(_=>"value"in _._localId&&_._localId.value?_._localId.value:null).filter(_=>null!==_);Rt.append(e,n,...d)}}})()}test(t,e){var i=this;return(0,G.A)(function*(s,n,o={skipIfFails:!0}){const a=i._components.get(ft);for(const[l,c]of Object.entries(s)){const h=a.list.get(l);if(!h)continue;const u=yield h.getItemsData([[...c][0]],{relations:{AssociatedTo:{attributes:!1,relations:!1},HasAssociations:{attributes:!0,relations:!0},MaterialConstituents:{attributes:!0,relations:!0},ForLayerSet:{attributes:!0,relations:!0},MaterialLayers:{attributes:!0,relations:!0},Materials:{attributes:!0,relations:!1}}});for(const f of u){const d=i.getItemChecks(n,l,f,o.skipIfFails);if(d){if(!Array.isArray(f.HasAssociations)){d.push({parameter:null,currentValue:null,requiredValue:i.value,pass:!1});continue}for(const _ of f.HasAssociations)if(i._ifcMaterialEntities.some(w=>"value"in _._category&&w.test(_._category.value))&&i.hasValidMaterial(_,d))break}}}}).apply(this,arguments)}hasValidMaterial(t,e){let i=!1;if("value"in t._category&&"IFCMATERIAL"===t._category.value)this.evalValue(t,e)&&(i=!0);else for(const[s,n]of Object.entries(t))if(["ForLayerSet","MaterialLayers","Material","MaterialConstituents","Materials"].includes(s)&&Array.isArray(n))for(const o of n)if("value"in o._category&&"IFCMATERIAL"===o._category.value){if(this.evalValue(o,e)){i=!0;break}}else if(this.hasValidMaterial(o)){i=!0;break}return i}evalValue(t,e){if(!this.value)return e?.push({parameter:null,currentValue:t.Name&&"value"in t.Name?t.Name.value:null,pass:!0}),!0;if(!("value"in t._category)||"IFCMATERIAL"!==t._category.value)return null;let i=!1;return t.Name&&"value"in t.Name&&(i=this.evalRequirement(t.Name.value,this.value,"Value",e)),i||(t.Category&&"value"in t.Category&&(i=this.evalRequirement(t.Category.value,this.value,"Value",e)),i)}}class Qf extends Ni{constructor(t,e){super(t),y(this,"facetType","PartOf"),y(this,"_entityFacet"),y(this,"_entity"),y(this,"relation"),y(this,"cardinality","required"),this._entity=e,this._entityFacet=new Lr(t,e.name),this._entityFacet.predefinedType=e.predefinedType}set entity(t){this._entity=t;const{name:e,predefinedType:i}=t;this._entityFacet=new Lr(this._components,e),this._entityFacet.predefinedType=i}get entity(){return this._entity}serialize(){return""}getEntities(t,e){return(0,G.A)(function*(){})()}test(t){return(0,G.A)(function*(){})()}}class Jf{constructor(t,e,i){y(this,"name"),y(this,"ifcVersion",new Set),y(this,"identifier",ie.create()),y(this,"description"),y(this,"instructions"),y(this,"requirementsDescription"),y(this,"applicability",new ot.PG),y(this,"requirements",new ot.PG),y(this,"components"),this.components=t,this.name=e;for(const s of i)this.ifcVersion.add(s)}set(t){const e=t,i=this;for(const n in t)"identifier"!==n&&n in this&&(i[n]=e[n]);return this.components.get(tp).list.set(this.identifier,this),this}test(t){var e=this;return(0,G.A)(function*(i,s={skipIfFails:!0}){const n=new ot.jp;if(0===e.requirements.size)return n;const o={},a=[];for(const c of e.applicability)a.push(c.getEntities(i,o));yield Promise.all(a);const l=[];for(const c of e.requirements)l.push(c.test(o,n,s));return yield Promise.all(l),n}).apply(this,arguments)}serialize(){const t=`name="${this.name}"`,e=this.identifier?`identifier="${this.identifier}"`:"",i=this.description?`description="${this.description}"`:"",s=this.instructions?`instructions="${this.instructions}"`:"";return`<specification ifcVersion="${[...this.ifcVersion].join(" ")}" ${t} ${e} ${i} ${s}>\n <applicability minOccurs="1" maxOccurs="unbounded">\n ${[...this.applicability].map(o=>o.serialize("applicability")).join("\n")}\n </applicability>\n <requirements>\n ${[...this.requirements].map(o=>o.serialize("requirement")).join("\n")}\n </requirements>\n </specification>`}}const _e=r=>{if(!r)return;const t={};if("simpleValue"in r&&(t.type="simple",t.parameter=r.simpleValue),"restriction"in r){const e=r.restriction,i=Object.keys(e);if("pattern"in e&&(t.type="pattern",t.parameter=e.pattern.value),"enumeration"in e){t.type="enumeration";const s=e.enumeration.map(({value:n})=>e.base.includes("string")?String(n):e.base.includes("integer")||e.base.includes("double")?Number(n):n);t.parameter=s}if(i.some(s=>["minInclusive","minExclusive","maxInclusive","maxExclusive"].includes(s))){t.type="bounds";const s={},n=i.find(a=>a.includes("min")),o=i.find(a=>a.includes("max"));n&&(s.minInclusive="minInclusive"===n,s.min=e[n].value),o&&(s.maxInclusive="maxInclusive"===o,s.max=e[o].value),t.parameter=s}if(i.some(s=>["minLength","length","maxLength"].includes(s))){t.type="length";const s={};void 0!==e.length&&(s.length=e.length.value),void 0!==e.minLength&&(s.min=e.minLength.value),void 0!==e.maxLength&&(s.max=e.maxLength.value),t.parameter=s}}return void 0!==t.parameter?t:void 0},yl=(r,t)=>{const e=[];for(const i of t){const n=_e(i.name);if(!n)continue;const o=new Lr(r,n);i.cardinality&&(o.cardinality=i.cardinality),o.predefinedType=_e(i.predefinedType),o.instructions=i.instructions,e.push(o)}return e},wl=(r,t)=>{const e=[];for(const i of t){const n=_e(i.name);if(!n)continue;const o=new Zf(r,n);i.cardinality&&(o.cardinality=i.cardinality),o.value=_e(i.value),o.instructions=i.instructions,e.push(o)}return e},vl=(r,t)=>{const e=[];for(const i of t){const s=new Kf(r);i.cardinality&&(s.cardinality=i.cardinality);const n=_e(i.value);"enumeration"===n?.type&&Array.isArray(n.parameter)&&(n.parameter=n.parameter.map(String)),s.value=n,s.uri=i.uri,s.instructions=i.instructions,e.push(s)}return e},bl=(r,t)=>{const e=[];for(const i of t){const n=i.baseName,o=_e(i.propertySet),a=_e(n);if(!a||!o)continue;const l=new Xf(r,o,a);i.cardinality&&(l.cardinality=i.cardinality);const c=_e(i.value);l.value=c,l.dataType=i.dataType,l.uri=i.uri,l.instructions=i.instructions,e.push(l)}return e},xl=(r,t)=>{const e=[];for(const i of t){const n=_e(i.system);if(!n)continue;const o=new Wf(r,n);i.cardinality&&(o.cardinality=i.cardinality);const a=_e(i.value);"simple"===a?.type&&(a.parameter=String(a.parameter)),"enumeration"===a?.type&&Array.isArray(a.parameter)&&(a.parameter=a.parameter.map(String)),o.value=a,o.uri=i.uri,o.instructions=i.instructions,e.push(o)}return e},Cl=(r,t)=>{const e=[];for(const i of t){const s=_e(i.entity.name);if(!s)continue;const n=_e(i.entity.predefinedType),o=new Qf(r,{name:s,predefinedType:n});o.relation=i.relation,i.cardinality&&(o.cardinality=i.cardinality),o.instructions=i.instructions,e.push(o)}return e},Nr=class wo extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"IDSInfo"),y(this,"list",new ot.jp),t.add(wo.uuid,this)}getModelIdMap(t){const e={},i={};for(const[s,n]of t){const a=[...n].filter(([,h])=>h.pass).map(([h])=>h);Rt.append(e,s,...a);const c=[...n].filter(([,h])=>!h.pass).map(([h])=>h);Rt.append(i,s,...c)}return{pass:e,fail:i}}create(t,e,i){const s=new Jf(this.components,t,e);return i&&(s.identifier=i),this.list.set(s.identifier,s),s}load(t){const e=[],i=wo.xmlParser.parse(t).ids,{specifications:s,info:n}=i;if(this.IDSInfo={...n},s&&s.specification){const o=Array.isArray(s.specification)?s.specification:[s.specification];for(const a of o){const{name:l,ifcVersion:c,description:h,instructions:u,identifier:f}=a;if(!l||!c)continue;const d=[],_=[],{applicability:m,requirements:w}=a;if(m){const{maxOccurs:T,...C}=m,S=Array.isArray(C)?C:[C];for(const M of S)for(const A in M){const O=Array.isArray(M[A])?M[A]:[M[A]];if("entity"===A){const I=yl(this.components,O);d.push(...I)}if("attribute"===A){const I=wl(this.components,O);d.push(...I)}if("material"===A){const I=vl(this.components,O);d.push(...I)}if("classification"===A){const I=xl(this.components,O);d.push(...I)}if("property"===A){const I=bl(this.components,O);d.push(...I)}if("partOf"===A){const I=Cl(this.components,O);d.push(...I)}}}let g;if(w){const{maxOccurs:T,...C}=w;g=w.description;const S=Array.isArray(C)?C:[C];for(const M of S)for(const A in M){const O=Array.isArray(M[A])?M[A]:[M[A]];if("entity"===A){const I=yl(this.components,O);_.push(...I)}if("attribute"===A){const I=wl(this.components,O);_.push(...I)}if("material"===A){const I=vl(this.components,O);_.push(...I)}if("classification"===A){const I=xl(this.components,O);_.push(...I)}if("property"===A){const I=bl(this.components,O);_.push(...I)}if("partOf"===A){const I=Cl(this.components,O);_.push(...I)}}}const v=this.create(l,c.split(/\s+/),f);v.description=h,v.instructions=u,v.requirementsDescription=g,v.applicability.add(...d),v.requirements.add(..._),e.push(v)}}return e}export(t,e=this.list.values()){const i=e??this.list;return`<ids xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://standards.buildingsmart.org/IDS http://standards.buildingsmart.org/IDS/1.0/ids.xsd" xmlns:ids="http://standards.buildingsmart.org/IDS">\n \x3c!-- Made with That Open Engine ${Ar.release} (https://github.com/thatopen/engine_components) --\x3e\n <info>\n <title>${t.title}</title>\n ${t.copyright?`<copyright>${t.copyright}</copyright>`:""}\n ${t.version?`<version>${t.version}</version>`:""}\n ${t.description?`<description>${t.description}</description>`:""}\n ${t.author?`<author>${t.author}</author>`:""}\n ${t.date?`<date>${t.date.toISOString().split("T")[0]}</date>`:""}\n ${t.purpose?`<purpose>${t.purpose}</purpose>`:""}\n ${t.milestone?`<milestone>${t.milestone}</milestone>`:""}\n </info>\n <specifications>\n ${[...i].map(n=>n.serialize()).join("\n")}\n </specifications>\n</ids>`}};y(Nr,"uuid","9f0b9f78-9b2e-481a-b766-2fbfd01f342c"),y(Nr,"xmlParser",new Fn({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0}));let tp=Nr;y(class Xc extends At{constructor(t){super(t),y(this,"enabled",!0),t.add(Xc.uuid,this)}static distanceFromPointToLine(t,e,i,s=!1){const n=new p.cZY,o=new p.Pq0;return n.set(e,i),n.closestPointToPoint(t,s,o),o.distanceTo(t)}round(t){t.x=Math.trunc(1e3*t.x)/1e3,t.y=Math.trunc(1e3*t.y)/1e3,t.z=Math.trunc(1e3*t.z)/1e3}getVolumeFromFragments(t){var e=this;return(0,G.A)(function*(){return console.warn("getVolumeFromFragments is deprecated. Use getItemsVolume instead."),e.getItemsVolume(t)})()}getItemsVolume(t){var e=this;return(0,G.A)(function*(){let i=0;const s=e.components.get(ft);for(const[n,o]of Object.entries(t)){const a=s.list.get(n);a&&(i+=(yield a.getItemsVolume([...o])))}return i})()}static convertUnits(t,e,i,s=2){const n={m:1,cm:.01,mm:.001,km:1e3,m2:1,cm2:1e-4,mm2:1e-6,km2:1e6,m3:1,cm3:1e-6,mm3:1e-9,km3:1e9};if(!n[e]||!n[i])throw new Error("Invalid units provided for conversion.");if(!Number.isInteger(s)||s<0||s>5)throw new Error("Precision must be an integer between 0 and 5.");const l=10**s;return Math.round(t*(n[e]/n[i])*l)/l}},"uuid","267ca032-672f-4cb0-afa9-d24e904f39d6");const Tl=(r,t,e)=>{const i=new p.Pq0(-t.z,0,t.x),s=new p.Pq0(t.x+i.x,0,t.z+i.z).normalize().multiplyScalar(e/2);return[r.x+s.x,r.y,r.z+s.z,r.x-s.x,r.y,r.z-s.z]},Pl=(r,t,e)=>{const i=new p.Pq0(-t.z,0,t.x);return[r.x,r.y,r.z,r.x-t.x*e+i.x*e*.4,r.y,r.z-t.z*e+i.z*e*.4,r.x,r.y,r.z,r.x-t.x*e-i.x*e*.4,r.y,r.z-t.z*e-i.z*e*.4]},ep=()=>[],ip=(r,t,e)=>{const i=new p.Pq0(-t.z,0,t.x),s=r.clone().addScaledVector(t,-e),n=s.clone().addScaledVector(i,.4*e),o=s.clone().addScaledVector(i,.4*-e);return[r.x,r.y,r.z,n.x,n.y,n.z,o.x,o.y,o.z]};class sp extends ot.jp{constructor(){super()}getBySystem(t){const e=new Map;for(const[i,s]of this)s.system===t&&e.set(i,s.data);return e}}class np extends ot.jp{constructor(t){super(),y(this,"_container"),this._container=t,this.deleteGuard=e=>"0"!==e,this.set("0",{name:"0",visible:!0,material:new p.mrM({color:0})})}create(t,e){if(!this.has(t)){const i={name:t,visible:e?.visible??!0,material:e?.material??new p.mrM({color:0})};this.set(t,i)}return this.get(t)}setColor(t,e){const i=this.get(t);i&&(i.material.color.setHex(e),this.set(t,i))}setMaterial(t,e){const i=this.get(t);if(!i)return;const s=i.material;i.material=e,this._container.traverse(n=>{n.userData.layer===t&&(n.userData.isDimension||n.isLineSegments&&(n.material=e))}),s.dispose(),this.set(t,i)}setVisibility(t,e){const i=this.get(t);i&&(i.visible=e,this._container.traverse(s=>{s.userData.layer===t&&(s.visible=e)}),this.set(t,i))}assign(t,e){const i=this.get(e);i&&(t.userData.layer=e,i.visible||(t.visible=!1),t.isLineSegments&&(t.material=i.material))}resolveColor(t){const e=this.get(t);if(e)return e.material.color.getHex()}}const us=class qe extends p.YJl{constructor(t){super(),y(this,"_viewport"),y(this,"_border"),y(this,"_handles",[]),y(this,"_raycaster",new p.tBo),y(this,"_resizable",!1),y(this,"_movable",!1),y(this,"_dragHandle",null),y(this,"_dragConstraints",[]),y(this,"_hoveredHandle",null),y(this,"_moveDrag",null),y(this,"_hoveringBorder",!1),y(this,"_normalMat"),y(this,"_hoverMat"),y(this,"_borderMat"),this._viewport=t,this._borderMat=new p.mrM({color:qe._BORDER_COLOR,depthTest:!1});const e=new p.LoY;e.setAttribute("position",new p.THS(new Float32Array(24),3)),this._border=new p.DXC(e,this._borderMat),this._border.renderOrder=999,this._border.frustumCulled=!1,this._border.userData.isDimension=!0,this.add(this._border),this._normalMat=new p.V9B({color:qe._BORDER_COLOR}),this._hoverMat=new p.V9B({color:qe._BORDER_HOVER_COLOR});const i=new p.Gu$(.05,8,6);for(const s of qe._HANDLE_DEFS){const n=new p.eaF(i,this._normalMat);n.renderOrder=1e3,n.visible=!1,n.userData.constraints=s.constraints,n.userData.isDimension=!0,this.add(n),this._handles.push(n)}this.update()}get resizable(){return this._resizable}set resizable(t){this._resizable=t;for(const e of this._handles)e.visible=t;t||(this._hoveredHandle&&(this._hoveredHandle.material=this._normalMat,this._hoveredHandle=null),this._dragHandle=null,this._dragConstraints=[])}get movable(){return this._movable}set movable(t){this._movable=t,t||(this._moveDrag=null,this._setBorderHover(!1))}get isDragging(){return null!==this._dragHandle||null!==this._moveDrag}update(){const t=this._viewport,e=t.left,i=t.right,s=-t.top,n=-t.bottom,o=.005,a=this._border.geometry.attributes.position;a.setXYZ(0,e,o,s),a.setXYZ(1,i,o,s),a.setXYZ(2,i,o,s),a.setXYZ(3,i,o,n),a.setXYZ(4,i,o,n),a.setXYZ(5,e,o,n),a.setXYZ(6,e,o,n),a.setXYZ(7,e,o,s),a.needsUpdate=!0,this._border.geometry.computeBoundingSphere();const l=(e+i)/2,c=(s+n)/2,h=.01,u=[[e,h,s],[i,h,s],[i,h,n],[e,h,n],[l,h,s],[i,h,c],[l,h,n],[e,h,c]];for(let f=0;f<this._handles.length;f++)this._handles[f].position.set(...u[f])}onPointerMove(t){if(this._dragHandle){const i=this._projectToLocal(t);if(!i)return;for(const s of this._dragConstraints)switch(s){case"left":this._viewport.left=i.x;break;case"right":this._viewport.right=i.x;break;case"top":this._viewport.top=-i.z;break;case"bottom":this._viewport.bottom=-i.z}return this._viewport.right<this._viewport.left&&([this._viewport.left,this._viewport.right]=[this._viewport.right,this._viewport.left],this._dragConstraints=this._dragConstraints.map(s=>"right"===s?"left":"left"===s?"right":s)),this._viewport.top<this._viewport.bottom&&([this._viewport.top,this._viewport.bottom]=[this._viewport.bottom,this._viewport.top],this._dragConstraints=this._dragConstraints.map(s=>"top"===s?"bottom":"bottom"===s?"top":s)),void this.update()}if(this._moveDrag){const i=this._projectToLocal(t);if(!i)return;const s=i.x-this._moveDrag.origin.x,n=i.z-this._moveDrag.origin.z;return this._viewport.left=this._moveDrag.left0+s,this._viewport.right=this._moveDrag.right0+s,this._viewport.top=this._moveDrag.top0-n,this._viewport.bottom=this._moveDrag.bottom0-n,void this.update()}if(!this._resizable&&!this._movable)return;this._raycaster.set(t.origin,t.direction);let e=null;if(this._resizable){const i=this._handles.filter(n=>n.visible),s=this._raycaster.intersectObjects(i,!1);e=s.length>0?s[0].object:null}if(e!==this._hoveredHandle&&(this._hoveredHandle&&(this._hoveredHandle.material=this._normalMat),e&&(e.material=this._hoverMat),this._hoveredHandle=e),this._movable&&!this._hoveredHandle){this._raycaster.params.Line={threshold:qe._LINE_THRESHOLD};const i=this._raycaster.intersectObject(this._border,!1).length>0;this._setBorderHover(i)}else this._setBorderHover(!1)}onPointerDown(t){if(this._resizable||this._movable){if(this._raycaster.set(t.origin,t.direction),this._resizable){const e=this._handles.filter(s=>s.visible),i=this._raycaster.intersectObjects(e,!1);if(i.length>0)return this._dragHandle=i[0].object,void(this._dragConstraints=[...this._dragHandle.userData.constraints])}if(this._movable&&(this._raycaster.params.Line={threshold:qe._LINE_THRESHOLD},this._raycaster.intersectObject(this._border,!1).length>0)){const i=this._projectToLocal(t);if(!i)return;this._moveDrag={origin:i,left0:this._viewport.left,right0:this._viewport.right,top0:this._viewport.top,bottom0:this._viewport.bottom}}}}onPointerUp(){this._dragHandle=null,this._dragConstraints=[],this._moveDrag=null}dispose(){this._border.geometry.dispose(),this._borderMat.dispose(),this._normalMat.dispose(),this._hoverMat.dispose(),this._handles.length>0&&this._handles[0].geometry.dispose(),this.removeFromParent()}_projectToLocal(t){this.updateWorldMatrix(!0,!1);const e=new p.Pq0(0,1,0).transformDirection(this.matrixWorld),i=(new p.Pq0).setFromMatrixPosition(this.matrixWorld),s=(new p.Zcv).setFromNormalAndCoplanarPoint(e,i),n=new p.Pq0;return t.intersectPlane(s,n)?this.worldToLocal(n):null}_setBorderHover(t){t!==this._hoveringBorder&&(this._hoveringBorder=t,this._borderMat.color.setHex(t?qe._BORDER_HOVER_COLOR:qe._BORDER_COLOR))}};y(us,"_BORDER_COLOR",22015),y(us,"_BORDER_HOVER_COLOR",16746496),y(us,"_LINE_THRESHOLD",.06),y(us,"_HANDLE_DEFS",[{constraints:["left","top"]},{constraints:["right","top"]},{constraints:["right","bottom"]},{constraints:["left","bottom"]},{constraints:["top"]},{constraints:["right"]},{constraints:["bottom"]},{constraints:["left"]}]);let rp=us;class op{constructor(t){y(this,"uuid",p.cj9.generateUUID()),y(this,"name"),y(this,"camera"),y(this,"onDisposed",new Q),y(this,"_left"),y(this,"_right"),y(this,"_top"),y(this,"_bottom"),y(this,"_drawingScale"),y(this,"_container",null),y(this,"_helper",null),y(this,"_helperVisible",!1),this._left=t.left,this._right=t.right,this._top=t.top,this._bottom=t.bottom,this._drawingScale=t.scale??100,this.name=t.name??"Drawing Viewport",this.camera=new p.qUd(this._left,this._right,this._top,this._bottom,.1,30),this.camera.up.set(0,0,-1),this.camera.position.set(0,10,0),this.camera.lookAt(0,0,0),this.camera.layers.set(1)}get left(){return this._left}set left(t){var e;this._left=t,this.camera.left=t,this.camera.updateProjectionMatrix(),null==(e=this._helper)||e.update()}get right(){return this._right}set right(t){var e;this._right=t,this.camera.right=t,this.camera.updateProjectionMatrix(),null==(e=this._helper)||e.update()}get top(){return this._top}set top(t){var e;this._top=t,this.camera.top=t,this.camera.updateProjectionMatrix(),null==(e=this._helper)||e.update()}get bottom(){return this._bottom}set bottom(t){var e;this._bottom=t,this.camera.bottom=t,this.camera.updateProjectionMatrix(),null==(e=this._helper)||e.update()}get drawingScale(){return this._drawingScale}set drawingScale(t){this._drawingScale=t}get helper(){return this._helper||(this._helper=new rp(this)),this._helper}get helperVisible(){return this._helperVisible}set helperVisible(t){var e,i;this._helperVisible=t,t?null==(e=this._container)||e.add(this.helper):null==(i=this._helper)||i.removeFromParent()}get bbox(){const t=new p.Pq0(this._left,0,-this._top),e=new p.Pq0(this._right,0,-this._bottom);return new p.NRn(t,e)}get size(){const t=new p.Pq0;return this.bbox.getSize(t),new p.I9Y(1e3*t.x,1e3*t.z)}get localXAxis(){return new p.Pq0(1,0,0)}get localYAxis(){return new p.Pq0(0,0,-1)}get normal(){return new p.Pq0(0,1,0)}setContainer(t){this._container=t,this._helperVisible&&this._helper&&t.add(this._helper)}clipLine(t){const e=this.bbox,{start:i,end:s}=t,n=e.containsPoint(i),o=e.containsPoint(s);if(n&&o)return t;if(!n&&!o){const l=this.getPlaneIntersections(t);return l.length<2?null:new p.cZY(l[0],l[1])}const a=this.getPlaneIntersections(t);return 0===a.length?null:n?new p.cZY(i,a[0]):new p.cZY(a[0],s)}dispose(){var t;null==(t=this._helper)||t.dispose(),this._helper=null,this.onDisposed.trigger(),this.onDisposed.reset()}get bboxPlanes(){const t=this.bbox;return[new p.Zcv(new p.Pq0(1,0,0),-t.min.x),new p.Zcv(new p.Pq0(-1,0,0),t.max.x),new p.Zcv(new p.Pq0(0,0,1),-t.min.z),new p.Zcv(new p.Pq0(0,0,-1),t.max.z)]}getPlaneIntersections(t){const e=[];for(const i of this.bboxPlanes){const s=new p.Pq0;i.intersectLine(t,s)&&this.bbox.containsPoint(s)&&e.push(s)}return e}}class ap extends ot.jp{constructor(t){super(),y(this,"_container"),this._container=t,this.onBeforeDelete.add(({value:e})=>{this._container.remove(e.camera),e.dispose()})}create(t){const e=new op(t);return this._container.add(e.camera),e.setContainer(this._container),this.set(e.uuid,e),e}}const Sl=class wn extends p.YJl{constructor(t){super(),y(this,"_drawing"),y(this,"_topFrame"),y(this,"_pillars"),y(this,"_bottomFrame"),y(this,"_topPlane"),y(this,"_bottomPlane"),y(this,"_frameMat"),y(this,"_depthMat"),y(this,"_planeMat"),y(this,"width",10),y(this,"height",10),y(this,"farHandle",new p.B69),y(this,"widthHandle",new p.B69),y(this,"heightHandle",new p.B69),this._drawing=t,this._frameMat=new p.mrM({color:wn._FRAME_COLOR,depthTest:!1}),this._depthMat=new p.mrM({color:wn._DEPTH_COLOR,depthTest:!1,transparent:!0,opacity:.4}),this._planeMat=new p.V9B({color:wn._FRAME_COLOR,transparent:!0,opacity:.07,side:p.$EB,depthTest:!1});const e=()=>{const o=new p.LoY;return o.setAttribute("position",new p.THS(new Float32Array(12),3)),o.setIndex([0,1,2,0,2,3]),o};this._topPlane=new p.eaF(e(),this._planeMat),this._topPlane.renderOrder=998,this._topPlane.frustumCulled=!1,this._topPlane.userData.isDimension=!0,this._bottomPlane=new p.eaF(e(),this._planeMat),this._bottomPlane.renderOrder=998,this._bottomPlane.frustumCulled=!1,this._bottomPlane.userData.isDimension=!0;const i=new p.LoY;i.setAttribute("position",new p.THS(new Float32Array(24),3)),this._topFrame=new p.DXC(i,this._frameMat),this._topFrame.renderOrder=999,this._topFrame.frustumCulled=!1,this._topFrame.userData.isDimension=!0;const s=new p.LoY;s.setAttribute("position",new p.THS(new Float32Array(24),3)),this._pillars=new p.DXC(s,this._depthMat),this._pillars.renderOrder=999,this._pillars.frustumCulled=!1,this._pillars.userData.isDimension=!0;const n=new p.LoY;n.setAttribute("position",new p.THS(new Float32Array(24),3)),this._bottomFrame=new p.DXC(n,this._depthMat),this._bottomFrame.renderOrder=999,this._bottomFrame.frustumCulled=!1,this._bottomFrame.userData.isDimension=!0,this.add(this._topPlane,this._bottomPlane),this.add(this._topFrame,this._pillars,this._bottomFrame),this.add(this.farHandle,this.widthHandle,this.heightHandle),this.farHandle.rotation.x=Math.PI,this.update()}update(){const t=this.width/2,e=this.height/2,i=-this._drawing.far,s=.005,n=-t,o=t,a=-e,l=e,c=this._topFrame.geometry.attributes.position;c.setXYZ(0,n,s,a),c.setXYZ(1,o,s,a),c.setXYZ(2,o,s,a),c.setXYZ(3,o,s,l),c.setXYZ(4,o,s,l),c.setXYZ(5,n,s,l),c.setXYZ(6,n,s,l),c.setXYZ(7,n,s,a),c.needsUpdate=!0,this._topFrame.geometry.computeBoundingSphere();const h=this._pillars.geometry.attributes.position;h.setXYZ(0,n,s,a),h.setXYZ(1,n,i,a),h.setXYZ(2,o,s,a),h.setXYZ(3,o,i,a),h.setXYZ(4,o,s,l),h.setXYZ(5,o,i,l),h.setXYZ(6,n,s,l),h.setXYZ(7,n,i,l),h.needsUpdate=!0,this._pillars.geometry.computeBoundingSphere();const u=this._bottomFrame.geometry.attributes.position;u.setXYZ(0,n,i,a),u.setXYZ(1,o,i,a),u.setXYZ(2,o,i,a),u.setXYZ(3,o,i,l),u.setXYZ(4,o,i,l),u.setXYZ(5,n,i,l),u.setXYZ(6,n,i,l),u.setXYZ(7,n,i,a),u.needsUpdate=!0,this._bottomFrame.geometry.computeBoundingSphere();const f=(d,_)=>{const m=d.geometry.attributes.position;m.setXYZ(0,n,_,a),m.setXYZ(1,o,_,a),m.setXYZ(2,o,_,l),m.setXYZ(3,n,_,l),m.needsUpdate=!0,d.geometry.computeBoundingSphere()};f(this._topPlane,s),f(this._bottomPlane,i),this.farHandle.position.set(0,i,0),this.widthHandle.position.set(o,s,0),this.heightHandle.position.set(0,s,l)}attachFarGizmo(t){t.attach(this.farHandle),t.setSpace("local"),t.showX=!1,t.showZ=!1,t.addEventListener("objectChange",()=>{this.farHandle.position.x=0,this.farHandle.position.z=0;const e=Math.max(.1,-this.farHandle.position.y);this._drawing.far=e,this.farHandle.position.y=-e,this.update()})}attachWidthGizmo(t){t.attach(this.widthHandle),t.setSpace("local"),t.showY=!1,t.showZ=!1,t.addEventListener("objectChange",()=>{this.widthHandle.position.y=.005,this.widthHandle.position.z=0,this.width=Math.max(.1,2*this.widthHandle.position.x),this.widthHandle.position.x=this.width/2,this.update()})}attachHeightGizmo(t){t.attach(this.heightHandle),t.setSpace("local"),t.showX=!1,t.showY=!1,t.addEventListener("objectChange",()=>{this.heightHandle.position.x=0,this.heightHandle.position.y=.005,this.height=Math.max(.1,2*this.heightHandle.position.z),this.heightHandle.position.z=this.height/2,this.update()})}dispose(){this._topPlane.geometry.dispose(),this._bottomPlane.geometry.dispose(),this._topFrame.geometry.dispose(),this._pillars.geometry.dispose(),this._bottomFrame.geometry.dispose(),this._planeMat.dispose(),this._frameMat.dispose(),this._depthMat.dispose(),this.removeFromParent()}};y(Sl,"_FRAME_COLOR",22015),y(Sl,"_DEPTH_COLOR",22015);class Br{constructor(t){y(this,"uuid",p.cj9.generateUUID()),y(this,"_raycaster",new p.tBo),y(this,"_components"),y(this,"world",null),y(this,"three",new p.YJl),y(this,"annotations",new sp),y(this,"layers",new np(this.three)),y(this,"activeLayer","0"),y(this,"far",10),y(this,"viewports",new ap(this.three)),y(this,"onDisposed",new Q),this._components=t}raycast(t,e=null){this._raycaster.set(t.origin,t.direction),this._raycaster.layers.set(1),this._raycaster.params.Line&&(this._raycaster.params.Line.threshold=.1);const i=[];this.three.traverse(l=>{l instanceof p.DXC&&!l.userData.isDimension&&i.push(l)});const s=this._raycaster.intersectObjects(i,!1);if(0===s.length)return null;const n=s[0],o=this.three.worldToLocal(n.point.clone());let a=null;if(n.object instanceof p.DXC&&void 0!==n.index){const l=n.object.geometry.attributes.position,c=n.index,h=new p.Pq0(l.getX(c),l.getY(c),l.getZ(c)),u=new p.Pq0(l.getX(c+1),l.getY(c+1),l.getZ(c+1));h.applyMatrix4(n.object.matrixWorld),this.three.worldToLocal(h),u.applyMatrix4(n.object.matrixWorld),this.three.worldToLocal(u),a=new p.cZY(h,u)}return{point:o,object:n.object,viewport:e,line:a}}alignTo(t,e){(function lp(r,t){if(3!==r.length||3!==t.length)throw new Error("computeAlignmentMatrix requires exactly 3 point pairs.");const e=(d,_)=>{const m=(new p.Pq0).subVectors(d[1],d[0]),w=(new p.Pq0).subVectors(d[2],d[0]);if((new p.Pq0).crossVectors(m,w).length()<1e-6)throw new Error(`${_} points are collinear \u2014 three non-collinear points are required to define a plane.`)};e(r,"Drawing"),e(t,"World");const i=(d,_,m)=>{const w=(new p.Pq0).subVectors(_,d),g=(new p.Pq0).subVectors(m,d),v=w.clone().normalize(),T=(new p.Pq0).crossVectors(w,g).normalize(),C=(new p.Pq0).crossVectors(v,T).normalize();return(new p.kn4).makeBasis(v,T,C)},s=i(r[0],r[1],r[2]),o=i(t[0],t[1],t[2]).clone().multiply(s.clone().invert()),a=r[0].distanceTo(r[1]);if(a<1e-10)throw new Error("The first two drawing points are coincident \u2014 cannot compute scale.");const l=t[0].distanceTo(t[1])/a,c=r[0].clone().multiplyScalar(l).applyMatrix4(o),h=(new p.Pq0).subVectors(t[0],c),u=(new p.PTz).setFromRotationMatrix(o),f=new p.kn4;return f.compose(h,u,new p.Pq0(l,l,l)),f})(t,e).decompose(this.three.position,this.three.quaternion,this.three.scale)}static toDrawingSpace(t,e){t.updateWorldMatrix(!0,!1),e.three.updateWorldMatrix(!0,!1);const i=(new p.kn4).copy(e.three.matrixWorld).invert().multiply(t.matrixWorld),s=t.geometry.attributes.position,n=s.count,o=new Float32Array(3*n),a=new p.Pq0;for(let c=0;c<n;c++)a.fromBufferAttribute(s,c).applyMatrix4(i),o[3*c]=a.x,o[3*c+1]=0,o[3*c+2]=a.z;const l=new p.LoY;return l.setAttribute("position",new p.THS(o,3)),new p.DXC(l)}addProjectionLines(t,e="0"){return this.layers.has(e)||(console.warn(`[TechnicalDrawing] Layer "${e}" does not exist. Falling back to "0".`),e="0"),this.layers.assign(t,e),t.layers.set(1),t.material instanceof p.Fvt&&t.computeLineDistances(),t.geometry.computeBoundsTree({strategy:0,indirect:!0,type:xd}),this.three.add(t),t}addProjectionFromItems(t,e){var i=this;return(0,G.A)(function*(){if(!i.world)return void console.warn("[TechnicalDrawing] addProjectionFromItems: drawing has no world assigned.");for(const l of[e.layers.visible,e.layers.hidden])if(!i.layers.has(l))return void console.warn(`[TechnicalDrawing] Layer "${l}" does not exist \u2014 create it before calling addProjectionFromItems.`);const s=i._components.get(rf),n=s.projectionDirection.clone(),o=s.nearPlane,a=s.farPlane;try{i.three.updateWorldMatrix(!0,!1);const l=new p.Pq0(0,-1,0).transformDirection(i.three.matrixWorld).normalize();s.projectionDirection.copy(l);const c=(new p.kn4).makeRotationFromQuaternion((new p.PTz).setFromUnitVectors(l,new p.Pq0(0,-1,0))),h=(new p.Pq0).setFromMatrixPosition(i.three.matrixWorld).applyMatrix4(c).y;s.farPlane=h,s.nearPlane=h-i.far;const u=yield s.get(t,i.world,{onProgress:e.onProgress}),f=d=>Br.toDrawingSpace(new p.DXC(d),i);i.addProjectionLines(f(u.visible),e.layers.visible),i.addProjectionLines(f(u.hidden),e.layers.hidden)}finally{s.projectionDirection.copy(n),s.nearPlane=o,s.farPlane=a}})()}orientTo(t){const e=t.clone().normalize(),i=Math.SQRT1_2;e.x>.999?this.three.quaternion.set(.5,-.5,.5,.5):e.x<-.999?this.three.quaternion.set(.5,.5,-.5,.5):e.y>.999?this.three.quaternion.set(0,0,1,0):e.y<-.999?this.three.quaternion.set(0,0,0,1):e.z>.999?this.three.quaternion.set(0,i,-i,0):e.z<-.999?this.three.quaternion.set(i,0,0,i):console.warn("[TechnicalDrawing] orientTo: direction does not match any of the 6 standard axes.")}dispose(){this.viewports.clear(),this.layers.clear(),this.annotations.clear(),this._components.get(bi).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset()}}class Bi{constructor(t){y(this,"styles",new ot.jp),y(this,"activeStyle","default"),y(this,"onCommit",new Q),y(this,"onUpdate",new Q),y(this,"onDelete",new Q),y(this,"onDisposed",new Q),y(this,"_knownDrawings",new Set),y(this,"_previewMaterial",new p.mrM({color:16737894,depthTest:!1})),y(this,"_previewObject",null),y(this,"_previewDrawing",null),y(this,"_materialCache",new ot.jp),y(this,"_meshMaterialCache",new ot.jp),y(this,"_ownsChildGeometry",!0),this._components=t,this.styles.onItemUpdated.add(({key:e})=>{const i=this._materialCache.get(e);i&&i.color.setHex(this._resolveStyle(e).color);const s=this._meshMaterialCache.get(e);s&&s.color.setHex(this._resolveStyle(e).color);const n=this._components.get(Re),o=n?[...n.list.values()]:[...this._knownDrawings];for(const a of o){const l=[...a.annotations.getBySystem(this)].filter(([,c])=>c.style===e).map(([c])=>c);l.length>0&&this.update(a,l,{})}})}_onAfterPersist(t,e){}_onDispose(){}_updatePreview(){}get(t){const e=new ot.jp;for(const i of t)for(const[s,n]of i.annotations.getBySystem(this))e.set(s,{drawingUuid:i.uuid,item:n});return e}add(t,e){const i={uuid:p.cj9.generateUUID(),style:this.activeStyle,...e},s=this._persist(t,i);return this.onCommit.trigger([s]),i}update(t,e,i){for(const s of e){const n=t.annotations.get(s);if(!n||n.system!==this)continue;const o=n.data;Object.assign(o,i),this._redraw(o,n.three),this.onUpdate.trigger({item:o,group:n.three})}}pick(t,e=.05){const i=new p.tBo;i.ray.copy(t),i.params.Line={threshold:e},i.params.LineSegments={threshold:e};const s=p.N1A.prototype.raycast;let n=null,o=1/0;for(const a of this._knownDrawings)for(const[l,c]of a.annotations){if(c.system!==this)continue;const h=c.three;h.updateWorldMatrix(!0,!0),h.traverse(u=>{if(u===h)return;const f=[];if(u instanceof p.DXC&&u.userData.isDimension)s.call(u,i,f),f.length>0&&f[0].distance<o&&(o=f[0].distance,n=l);else if(u instanceof p.eaF){const d=(new p.NRn).setFromObject(u),_=new p.Pq0;if(i.ray.intersectBox(d,_)){const m=i.ray.origin.distanceTo(_);m<o&&(o=m,n=l)}}})}return n}delete(t,e){const i=[];for(const s of e){const n=t.annotations.get(s);!n||n.system!==this||(this._disposeGroup(n.three),t.annotations.delete(s),i.push(s))}i.length&&this.onDelete.trigger(i)}clear(t){const e=t??[...this._knownDrawings];for(const i of e){const s=[];for(const[n,o]of i.annotations)o.system===this&&s.push(n);for(const n of s){const o=i.annotations.get(n);this._disposeGroup(o.three),i.annotations.delete(n)}}}dispose(){this._clearPreview(),this._onDispose(),this.clear();for(const t of this._materialCache.values())t.dispose();this._materialCache.clear();for(const t of this._meshMaterialCache.values())t.dispose();this._meshMaterialCache.clear(),this._previewMaterial.dispose(),this.onCommit.reset(),this.onUpdate.reset(),this.onDelete.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}_trackDrawing(t){this._knownDrawings.has(t)||(this._knownDrawings.add(t),t.onDisposed.add(()=>this._knownDrawings.delete(t)))}_resolveStyle(t){return this.styles.get(t)??this.styles.get("default")}_getMaterial(t){const e=this._materialCache.get(t);if(e)return e;const i=new p.mrM({color:this._resolveStyle(t).color});return this._materialCache.set(t,i),i}_getMeshMaterial(t){const e=this._meshMaterialCache.get(t);if(e)return e;const i=new p.V9B({color:this._resolveStyle(t).color,side:p.$EB});return this._meshMaterialCache.set(t,i),i}_disposeGroup(t){if(t.removeFromParent(),this._ownsChildGeometry)t.traverse(e=>{e.geometry instanceof p.LoY&&e.geometry.dispose()});else for(;t.children.length>0;)t.remove(t.children[0])}_clearPreview(){this._previewObject&&(this._previewObject.removeFromParent(),this._previewObject.geometry.dispose(),this._previewObject=null)}_persist(t,e){this._trackDrawing(t);const i=this._resolveStyle(e.style),s=this._buildGroup(e,i);return s.userData.isDimension=!0,s.userData.annotationUuid=e.uuid,s.userData.layer=t.activeLayer,t.three.add(s),t.annotations.set(e.uuid,{system:this,data:e,three:s}),this._onAfterPersist(e,s),{drawing:t,item:e,group:s}}_redraw(t,e){for(;e.children.length>0;){const n=e.children[0];this._ownsChildGeometry&&n.geometry instanceof p.LoY&&n.geometry.dispose(),e.remove(n)}const i=this._resolveStyle(t.style),s=this._buildGroup(t,i);for(;s.children.length>0;)e.add(s.children[0]);this._onAfterPersist(t,e)}}function El(r,t){const e=r[0],i=r[r.length-1],s=(new p.Pq0).subVectors(i,e);if(s.lengthSq()<1e-10)return 0;s.normalize();const n=new p.Pq0(-s.z,0,s.x);return t.clone().sub(e).dot(n)}function dp(r,t){const e=[];for(let i=0;i<r.length-1;i++)e.push({uuid:p.cj9.generateUUID(),pointA:r[i].clone(),pointB:r[i+1].clone(),offset:t,style:""});return e}function Al(r){const{pointA:t,pointB:e,offset:i}=r,s=(new p.Pq0).subVectors(e,t),n=new p.Pq0(-s.z,0,s.x).normalize(),o=t.clone().addScaledVector(n,i),a=e.clone().addScaledVector(n,i),l=(new p.Pq0).subVectors(a,o).normalize();return[{tip:o,dir:l},{tip:a,dir:l.clone().negate()}]}function Rr(r,t){const{pointA:e,pointB:i,offset:s}=r,n=(new p.Pq0).subVectors(i,e),o=new p.Pq0(-n.z,0,n.x).normalize(),a=s>=0?1:-1,l=Math.abs(s),c=e.clone().addScaledVector(o,t.extensionGap*a),h=e.clone().addScaledVector(o,(l+t.extensionOvershoot)*a),u=i.clone().addScaledVector(o,t.extensionGap*a),f=i.clone().addScaledVector(o,(l+t.extensionOvershoot)*a),d=e.clone().addScaledVector(o,s),_=i.clone().addScaledVector(o,s),m=(new p.Pq0).subVectors(_,d).normalize(),w=t.lineTick(d,m,t.tickSize),g=t.lineTick(_,m.clone().negate(),t.tickSize);return[c.x,c.y,c.z,h.x,h.y,h.z,u.x,u.y,u.z,f.x,f.y,f.z,d.x,d.y,d.z,_.x,_.y,_.z,...w,...g]}class mp extends Bi{constructor(t){super(t),y(this,"enabled",!0),y(this,"machineState",{kind:"awaitingFirstPoint"}),y(this,"onMachineStateChanged",new Q),this.styles.set("default",{lineTick:Tl,tickSize:.4,extensionGap:.05,extensionOvershoot:.2,color:0,textOffset:.4,fontSize:.45})}pickHandle(t,e,i=.1){const s=(new p.kn4).copy(t.three.matrixWorld).invert(),n=e.origin.clone().applyMatrix4(s),o=e.direction.clone().transformDirection(s).normalize(),a=new p.RlV(n,o),l=new p.Zcv(new p.Pq0(0,1,0),0),c=a.intersectPlane(l,new p.Pq0);if(!c)return null;let h=null,u=i;for(const[f,d]of t.annotations.getBySystem(this)){const _=(new p.Pq0).subVectors(d.pointB,d.pointA),m=new p.Pq0(-_.z,0,_.x).normalize(),w=(new p.Pq0).addVectors(d.pointA,d.pointB).multiplyScalar(.5).addScaledVector(m,d.offset);for(const[g,v]of[["pointA",d.pointA],["pointB",d.pointB],["offset",w]]){const T=Math.hypot(c.x-v.x,c.z-v.z);T<u&&(u=T,h={uuid:f,handle:g})}}return h}sendMachineEvent(t){const e=t.drawing??null;e&&(this._previewDrawing=e);const i=function fp(r,t){switch(r.kind){case"awaitingFirstPoint":if("CLICK"===t.type){if(!t.line)return r;const e=(new p.Pq0).subVectors(t.line.end,t.line.start).normalize();return{kind:"placingPoints",points:[t.point.clone()],cursor:null,lineDir:e,firstLine:t.line.clone()}}return"SELECT_LINE"===t.type?{kind:"positioningOffset",points:[t.line.start.clone(),t.line.end.clone()],cursor:null}:r;case"placingPoints":if("MOUSE_MOVE"===t.type){const e=new p.Pq0(-r.lineDir.z,0,r.lineDir.x),i=r.points[r.points.length-1],s=t.point.clone().sub(i).dot(e),n=i.clone().addScaledVector(e,s);return{...r,cursor:n}}if("CLICK"===t.type){if(!t.line||function up(r,t){return r.start.distanceTo(t.start)<1e-6&&r.end.distanceTo(t.end)<1e-6||r.start.distanceTo(t.end)<1e-6&&r.end.distanceTo(t.start)<1e-6}(t.line,r.firstLine))return r;if(!function hp(r,t){return Math.abs(r.dot(t))>.999}((new p.Pq0).subVectors(t.line.end,t.line.start).normalize(),r.lineDir))return r;const i=function cp(r,t,e){const i=r.clone().sub(t.start).dot(e);return t.start.clone().addScaledVector(e,i)}(r.points[0],t.line,r.lineDir),s=[...r.points,i];return{...r,points:s,cursor:r.cursor}}return"CONFIRM"===t.type&&r.points.length>=2?{kind:"positioningOffset",points:r.points,cursor:null}:"ESCAPE"===t.type?{kind:"awaitingFirstPoint"}:r;case"positioningOffset":if("MOUSE_MOVE"===t.type)return{...r,cursor:t.point.clone()};if("CLICK"===t.type){const e=El(r.points,t.point);return{kind:"committed",dimensions:dp(r.points,e)}}return"ESCAPE"===t.type?{kind:"awaitingFirstPoint"}:r;case"committed":return"ESCAPE"===t.type?{kind:"awaitingFirstPoint"}:r}}(this.machineState,t);if(i!==this.machineState){if(this.machineState=i,this._updatePreview(),"committed"===i.kind){if(!this._previewDrawing)return console.warn("LinearAnnotations: no drawing context \u2014 send a CLICK or SELECT_LINE with `drawing` first. Skipping."),void this._resetMachine();for(const n of i.dimensions)n.style=this.activeStyle;const s=i.dimensions.map(n=>this._persist(this._previewDrawing,n));this.onCommit.trigger(s)}this.onMachineStateChanged.trigger(this.machineState),"committed"===i.kind&&this._resetMachine()}}_buildGroup(t,e){const i=new p.YJl,s=Rr(t,e),n=new p.LoY;n.setAttribute("position",new p.THS(new Float32Array(s),3));const o=new p.DXC(n,this._getMaterial(t.style));if(o.layers.set(1),o.userData.isDimension=!0,i.add(o),e.meshTick)for(const{tip:a,dir:l}of Al(t)){const c=e.meshTick(a,l,e.tickSize),h=new p.LoY;h.setAttribute("position",new p.THS(new Float32Array(c),3));const u=new p.eaF(h,this._getMeshMaterial(t.style));u.layers.set(1),u.userData.isMeshTick=!0,i.add(u)}return i}_updatePreview(){const t=this.machineState;if("placingPoints"!==t.kind&&"positioningOffset"!==t.kind)return void this._clearPreview();if(!this._previewDrawing)return void this._clearPreview();const e=this._resolveStyle(this.activeStyle);this._previewMaterial.color.setHex(e.color);const i=function pp(r,t,e,i){if("placingPoints"===r){const o=[];for(let a=0;a<t.length-1;a++){const l=t[a],c=t[a+1];o.push(l.x,l.y,l.z,c.x,c.y,c.z)}if(e){const a=t[t.length-1];o.push(a.x,a.y,a.z,e.x,e.y,e.z)}return o}if(!e||t.length<2)return[];const s=El(t,e),n=[];for(let o=0;o<t.length-1;o++)n.push(...Rr({uuid:"",pointA:t[o],pointB:t[o+1],offset:s,style:""},i));return n}(t.kind,t.points,t.cursor,e);if(0!==i.length)if(this._previewObject&&this._previewObject.geometry.attributes.position.count===i.length/3){const o=this._previewObject.geometry.attributes.position;o.set(i),o.needsUpdate=!0}else{this._clearPreview();const o=new p.LoY;o.setAttribute("position",new p.THS(new Float32Array(i),3)),this._previewObject=new p.DXC(o,this._previewMaterial),this._previewObject.layers.set(1),this._previewObject.renderOrder=1,this._previewObject.userData.isDimension=!0,this._previewDrawing.three.add(this._previewObject)}else this._clearPreview()}_resetMachine(){this.machineState={kind:"awaitingFirstPoint"},this._previewDrawing=null,this._updatePreview(),this.onMachineStateChanged.trigger(this.machineState)}}const gp=Math.PI/180;function Ml(r,t,e,i){const s=function yp(r,t,e){const i=(new p.Pq0).subVectors(r,t).normalize(),s=(new p.Pq0).subVectors(e,t).normalize();return(new p.Pq0).addVectors(i,s).normalize()}(r,t,e);return(new p.Pq0).subVectors(i,t).setY(0).dot(s)}function Il(r,t,e,i){return Ml(r,t,e,i)<0}function Ol(r){const t=(new p.Pq0).subVectors(r.pointA,r.vertex).normalize(),e=(new p.Pq0).subVectors(r.pointB,r.vertex).normalize(),i=Math.atan2(t.z,t.x);let s=Math.atan2(e.z,e.x)-i;for(;s>Math.PI;)s-=2*Math.PI;for(;s<-Math.PI;)s+=2*Math.PI;r.flipped&&(s-=2*Math.sign(s)*Math.PI);const n=new p.Pq0(r.vertex.x+Math.cos(i)*r.arcRadius,0,r.vertex.z+Math.sin(i)*r.arcRadius),o=i+s,a=new p.Pq0(r.vertex.x+Math.cos(o)*r.arcRadius,0,r.vertex.z+Math.sin(o)*r.arcRadius),l=Math.sign(s);return[{tip:n,dir:new p.Pq0(-Math.sin(i)*l,0,Math.cos(i)*l)},{tip:a,dir:new p.Pq0(Math.sin(o)*l,0,-Math.cos(o)*l)}]}function vp(r){const t=(new p.Pq0).subVectors(r.pointA,r.vertex).normalize(),e=(new p.Pq0).subVectors(r.pointB,r.vertex).normalize(),i=Math.acos(p.cj9.clamp(t.dot(e),-1,1));return r.flipped?2*Math.PI-i:i}function bp(r){const t=(new p.Pq0).subVectors(r.pointA,r.vertex).normalize(),e=(new p.Pq0).subVectors(r.pointB,r.vertex).normalize(),i=Math.atan2(t.z,t.x);let s=Math.atan2(e.z,e.x)-i;for(;s>Math.PI;)s-=2*Math.PI;for(;s<-Math.PI;)s+=2*Math.PI;const n=i+s/2;return r.flipped?n+Math.PI:n}function zl(r,t,e,i,s,n=!1){const o=Math.atan2(t.z,t.x);let a=Math.atan2(e.z,e.x)-o;for(;a>Math.PI;)a-=2*Math.PI;for(;a<-Math.PI;)a+=2*Math.PI;n&&(a-=2*Math.sign(a)*Math.PI);const l=[];for(let v=0;v<8;v++){const T=o+a*(v/8),C=o+a*((v+1)/8);l.push(r.x+Math.cos(T)*i,0,r.z+Math.sin(T)*i,r.x+Math.cos(C)*i,0,r.z+Math.sin(C)*i)}const h=new p.Pq0(r.x+Math.cos(o)*i,0,r.z+Math.sin(o)*i),u=new p.Pq0(r.x+Math.cos(o+a)*i,0,r.z+Math.sin(o+a)*i),f=r.clone().addScaledVector(t,s.extensionGap),d=r.clone().addScaledVector(e,s.extensionGap);l.push(f.x,f.y,f.z,h.x,h.y,h.z,d.x,d.y,d.z,u.x,u.y,u.z);const _=Math.sign(a),m=new p.Pq0(-Math.sin(o)*_,0,Math.cos(o)*_),w=o+a,g=new p.Pq0(Math.sin(w)*_,0,-Math.cos(w)*_);return l.push(...s.lineTick(h,m,s.tickSize),...s.lineTick(u,g,s.tickSize)),l}function Dl(r,t){const e=(new p.Pq0).subVectors(r.pointA,r.vertex).normalize(),i=(new p.Pq0).subVectors(r.pointB,r.vertex).normalize();return zl(r.vertex,e,i,r.arcRadius,t,r.flipped??!1)}function kl(r,t,e,i,s,n=!1){if(!i)return[];const o=Math.max(.05,(new p.Pq0).subVectors(i,t).setY(0).length());return zl(t,(new p.Pq0).subVectors(r,t).normalize(),(new p.Pq0).subVectors(e,t).normalize(),o,s,n)}class xp extends Bi{constructor(t){super(t),y(this,"enabled",!0),y(this,"machineState",{kind:"awaitingFirstLine"}),y(this,"onMachineStateChanged",new Q),y(this,"_secondLinePreviewObject",null),this.styles.set("default",{lineTick:Tl,tickSize:.4,extensionGap:.05,color:0,textOffset:.25,fontSize:.45})}pickHandle(t,e,i){return null}sendMachineEvent(t){const e=t.drawing??null;if("awaitingSecondLine"===this.machineState.kind&&"MOUSE_MOVE"===t.type)return e&&(this._previewDrawing=e),void this._updateSecondLinePreview(t.point,t.line??null);const i=function wp(r,t){switch(r.kind){case"awaitingFirstLine":return"CLICK"===t.type&&t.line?{kind:"awaitingSecondLine",line1:t.line.clone(),pointA:t.point.clone()}:r;case"awaitingSecondLine":if("CLICK"===t.type&&t.line){const e=(new p.Pq0).subVectors(r.line1.end,r.line1.start).normalize(),i=(new p.Pq0).subVectors(t.line.end,t.line.start).normalize();if(Math.abs(e.dot(i))>Math.cos(gp))return r;const n=function _p(r,t,e,i){const s=t.x*i.z-t.z*i.x;if(Math.abs(s)<1e-10)return null;const n=(new p.Pq0).subVectors(e,r),o=(n.x*i.z-n.z*i.x)/s;return new p.Pq0(r.x+t.x*o,0,r.z+t.z*o)}(r.line1.start,e,t.line.start,i);return n?{kind:"positioningArc",pointA:r.pointA.clone(),vertex:n,pointB:t.point.clone(),cursor:null,flipped:!1}:r}return"ESCAPE"===t.type?{kind:"awaitingFirstLine"}:r;case"positioningArc":if("MOUSE_MOVE"===t.type){const e=Il(r.pointA,r.vertex,r.pointB,t.point);return{...r,cursor:t.point.clone(),flipped:e}}if("CLICK"===t.type){const e=Il(r.pointA,r.vertex,r.pointB,t.point),i=Math.max(.05,Math.abs(Ml(r.pointA,r.vertex,r.pointB,t.point)));return{kind:"committed",dimension:{uuid:p.cj9.generateUUID(),pointA:r.pointA.clone(),vertex:r.vertex.clone(),pointB:r.pointB.clone(),arcRadius:i,flipped:e,style:""}}}return"ESCAPE"===t.type?{kind:"awaitingFirstLine"}:r;case"committed":return"ESCAPE"===t.type?{kind:"awaitingFirstLine"}:r}}(this.machineState,t);if(i!==this.machineState){if("awaitingSecondLine"===this.machineState.kind&&this._clearSecondLinePreview(),this.machineState=i,e&&(this._previewDrawing=e),this._updatePreview(),"committed"===i.kind){if(!this._previewDrawing)return console.warn("AngleAnnotations: CLICK that commits must include `drawing`. Skipping."),void this._resetMachine();i.dimension.style=this.activeStyle;const s=this._persist(this._previewDrawing,i.dimension);this.onCommit.trigger([s])}this.onMachineStateChanged.trigger(this.machineState),"committed"===i.kind&&this._resetMachine()}}_buildGroup(t,e){const i=new p.YJl,s=Dl(t,e),n=new p.LoY;n.setAttribute("position",new p.THS(new Float32Array(s),3));const o=new p.DXC(n,this._getMaterial(t.style));if(o.layers.set(1),o.userData.isDimension=!0,i.add(o),e.meshTick)for(const{tip:a,dir:l}of Ol(t)){const c=e.meshTick(a,l,e.tickSize),h=new p.LoY;h.setAttribute("position",new p.THS(new Float32Array(c),3));const u=new p.eaF(h,this._getMeshMaterial(t.style));u.layers.set(1),u.userData.isMeshTick=!0,i.add(u)}return i}_updatePreview(){const t=this.machineState;if("positioningArc"!==t.kind)return void this._clearPreview();if(!this._previewDrawing)return void this._clearPreview();const e=this._resolveStyle(this.activeStyle),i=kl(t.pointA,t.vertex,t.pointB,t.cursor,e,t.flipped);if(0!==i.length)if(this._previewObject&&this._previewObject.geometry.attributes.position.count===i.length/3){const o=this._previewObject.geometry.attributes.position;o.set(i),o.needsUpdate=!0}else{this._clearPreview();const o=new p.LoY;o.setAttribute("position",new p.THS(new Float32Array(i),3)),this._previewObject=new p.DXC(o,this._previewMaterial),this._previewObject.layers.set(1),this._previewObject.renderOrder=1,this._previewObject.userData.isDimension=!0,this._previewDrawing.three.add(this._previewObject)}else this._clearPreview()}_onDispose(){this._clearSecondLinePreview()}_resetMachine(){this.machineState={kind:"awaitingFirstLine"},this._previewDrawing=null,this._updatePreview(),this.onMachineStateChanged.trigger(this.machineState)}_clearSecondLinePreview(){this._secondLinePreviewObject&&(this._secondLinePreviewObject.removeFromParent(),this._secondLinePreviewObject.geometry.dispose(),this._secondLinePreviewObject=null)}_updateSecondLinePreview(t,e){if("awaitingSecondLine"!==this.machineState.kind)return void this._clearSecondLinePreview();if(!this._previewDrawing)return void this._clearSecondLinePreview();const i=this.machineState,s=(new p.Pq0).subVectors(i.line1.end,i.line1.start).normalize();if(!e)return void this._clearSecondLinePreview();const n=(new p.Pq0).subVectors(e.end,e.start).normalize(),o=function Cp(r,t,e,i){const s=t.x*i.z-t.z*i.x;if(Math.abs(s)<1e-6)return null;const a=((e.x-r.x)*i.z-(e.z-r.z)*i.x)/s;return new p.Pq0(r.x+a*t.x,0,r.z+a*t.z)}(i.line1.start,s,e.start,n);if(!o)return void this._clearSecondLinePreview();const a=t.clone(),l=(new p.Pq0).subVectors(a,o).setY(0);if(l.length()<.01)return void this._clearSecondLinePreview();const c=(new p.Pq0).subVectors(i.pointA,o).normalize(),h=l.normalize(),u=Math.atan2(c.z,c.x);let f=Math.atan2(h.z,h.x)-u;for(;f>Math.PI;)f-=2*Math.PI;for(;f<-Math.PI;)f+=2*Math.PI;const d=u+f/2,_=Math.max(.1,.4*Math.min(i.pointA.distanceTo(o),a.distanceTo(o))),m=new p.Pq0(o.x+Math.cos(d)*_,0,o.z+Math.sin(d)*_),w=this._resolveStyle(this.activeStyle),g=kl(i.pointA,o,a,m,w);if(0!==g.length)if(this._secondLinePreviewObject&&this._secondLinePreviewObject.geometry.attributes.position.count===g.length/3){const C=this._secondLinePreviewObject.geometry.attributes.position;C.set(g),C.needsUpdate=!0}else{this._clearSecondLinePreview();const C=new p.LoY;C.setAttribute("position",new p.THS(new Float32Array(g),3)),this._secondLinePreviewObject=new p.DXC(C,this._previewMaterial),this._secondLinePreviewObject.layers.set(1),this._secondLinePreviewObject.renderOrder=1,this._secondLinePreviewObject.userData.isDimension=!0,this._previewDrawing.three.add(this._secondLinePreviewObject)}else this._clearSecondLinePreview()}}function Ll(r,t){const e=t.x-r.x,i=t.z-r.z,s=Math.sqrt(e*e+i*i);if(0===s)return r.clone();const n=Math.atan2(i,e),o=Math.round(n/(Math.PI/4))*(Math.PI/4);return new p.Pq0(r.x+Math.cos(o)*s,0,r.z+Math.sin(o)*s)}function Fr(r,t,e,i){return"curved"===i.leaderShape?function Ep(r,t,e,i){const n=new p.CV9(r,t,e).getPoints(24),o=[];for(let a=0;a<n.length-1;a++){const l=n[a],c=n[a+1];o.push(l.x,l.y,l.z,c.x,c.y,c.z)}if(i.lineTick){const a=(new p.Pq0).subVectors(r,t);a.lengthSq()>1e-10&&o.push(...i.lineTick(r,a.normalize(),i.tickSize))}return o}(r,t,e,i):function Sp(r,t,e,i){const s=[r.x,r.y,r.z,t.x,t.y,t.z,t.x,t.y,t.z,e.x,e.y,e.z];if(i.lineTick){const n=(new p.Pq0).subVectors(r,t);n.lengthSq()>1e-10&&s.push(...i.lineTick(r,n.normalize(),i.tickSize))}return s}(r,t,e,i)}function Nl(r,t){return Fr(r.arrowTip,r.elbow,r.extensionEnd,t)}function Bl(r,t,e,i,s){return i?Fr(t,"placingElbow"===r?i:e,i,s):[]}class Ap extends Bi{constructor(t){super(t),y(this,"enabled",!0),y(this,"machineState",{kind:"awaitingArrowTip"}),y(this,"onMachineStateChanged",new Q),y(this,"_previewMeshMaterial",new p.V9B({color:16737894,side:p.$EB,depthTest:!1})),y(this,"_previewMeshObject",null),this.styles.set("default",{tickSize:.4,color:0,textOffset:.1,fontSize:.45,lineTick:Pl})}pickHandle(t,e,i=.1){const s=(new p.kn4).copy(t.three.matrixWorld).invert(),n=e.origin.clone().applyMatrix4(s),o=e.direction.clone().transformDirection(s).normalize(),a=new p.RlV(n,o),l=new p.Zcv(new p.Pq0(0,1,0),0),c=a.intersectPlane(l,new p.Pq0);if(!c)return null;let h=null,u=i;for(const[f,d]of t.annotations.getBySystem(this))for(const[_,m]of[["elbow",d.elbow],["extensionEnd",d.extensionEnd]]){const w=Math.hypot(c.x-m.x,c.z-m.z);w<u&&(u=w,h={uuid:f,handle:_})}return h}sendMachineEvent(t){const e=t.drawing??null;e&&(this._previewDrawing=e);const i=function Tp(r,t){switch(r.kind){case"awaitingArrowTip":return"CLICK"===t.type?{kind:"placingElbow",arrowTip:t.point.clone(),cursor:null}:r;case"placingElbow":return"MOUSE_MOVE"===t.type?{...r,cursor:t.point.clone()}:"CLICK"===t.type?{kind:"placingExtension",arrowTip:r.arrowTip,elbow:t.point.clone(),cursor:null}:"ESCAPE"===t.type?{kind:"awaitingArrowTip"}:r;case"placingExtension":return"MOUSE_MOVE"===t.type?{...r,cursor:Ll(r.elbow,t.point)}:"CLICK"===t.type?{kind:"enteringText",arrowTip:r.arrowTip,elbow:r.elbow,extensionEnd:Ll(r.elbow,t.point)}:"ESCAPE"===t.type?{kind:"awaitingArrowTip"}:r;case"enteringText":return"SUBMIT_TEXT"===t.type&&t.text.trim().length>0?{kind:"committed",annotation:{uuid:p.cj9.generateUUID(),arrowTip:r.arrowTip.clone(),elbow:r.elbow.clone(),extensionEnd:r.extensionEnd.clone(),text:t.text.trim(),style:""}}:"ESCAPE"===t.type?{kind:"awaitingArrowTip"}:r;case"committed":return"ESCAPE"===t.type?{kind:"awaitingArrowTip"}:r}}(this.machineState,t);if(i!==this.machineState){if(this.machineState=i,this._updatePreview(),"committed"===i.kind){if(!this._previewDrawing)return console.warn("LeaderAnnotations: commit requires a drawing. Skipping."),void this._resetMachine();i.annotation.style=this.activeStyle;const s=this._persist(this._previewDrawing,i.annotation);this.onCommit.trigger([s])}this.onMachineStateChanged.trigger(this.machineState),"committed"===i.kind&&this._resetMachine()}}_buildGroup(t,e){const i=new p.YJl,s=Nl(t,e),n=new p.LoY;n.setAttribute("position",new p.THS(new Float32Array(s),3));const o=new p.DXC(n,this._getMaterial(t.style));if(o.layers.set(1),o.userData.isDimension=!0,i.add(o),e.meshTick){const a=(new p.Pq0).subVectors(t.arrowTip,t.elbow);if(a.lengthSq()>1e-10){a.normalize();const l=e.meshTick(t.arrowTip,a,e.tickSize),c=new p.LoY;c.setAttribute("position",new p.THS(new Float32Array(l),3));const h=new p.eaF(c,this._getMeshMaterial(t.style));h.layers.set(1),h.userData.isMeshArrow=!0,i.add(h)}}return i}_updatePreview(){const t=this.machineState;if("placingElbow"!==t.kind&&"placingExtension"!==t.kind)return void this._clearPreview();if(!this._previewDrawing)return void this._clearPreview();const e=this._resolveStyle(this.activeStyle),i="placingElbow"===t.kind?Bl("placingElbow",t.arrowTip,null,t.cursor,e):Bl("placingExtension",t.arrowTip,t.elbow,t.cursor,e);if(0!==i.length){if(this._previewObject&&this._previewObject.geometry.attributes.position.count===i.length/3){const o=this._previewObject.geometry.attributes.position;o.set(i),o.needsUpdate=!0}else{this._clearPreview();const o=new p.LoY;o.setAttribute("position",new p.THS(new Float32Array(i),3)),this._previewObject=new p.DXC(o,this._previewMaterial),this._previewObject.layers.set(1),this._previewObject.renderOrder=1,this._previewObject.frustumCulled=!1,this._previewObject.userData.isDimension=!0,this._previewDrawing.three.add(this._previewObject)}if(e.meshTick){const o="placingElbow"===t.kind?t.cursor:t.elbow,a=o?(new p.Pq0).subVectors(t.arrowTip,o):null;if(a&&a.lengthSq()>1e-10){a.normalize();const l=e.meshTick(t.arrowTip,a,e.tickSize);if(this._previewMeshObject){const c=this._previewMeshObject.geometry.attributes.position;c.set(l),c.needsUpdate=!0}else{const c=new p.LoY;c.setAttribute("position",new p.THS(new Float32Array(l),3)),this._previewMeshObject=new p.eaF(c,this._previewMeshMaterial),this._previewMeshObject.layers.set(1),this._previewMeshObject.renderOrder=1,this._previewMeshObject.frustumCulled=!1,this._previewDrawing.three.add(this._previewMeshObject)}}else this._clearPreviewMesh()}else this._clearPreviewMesh()}else this._clearPreview()}_clearPreview(){super._clearPreview(),this._clearPreviewMesh()}_onDispose(){this._clearPreviewMesh(),this._previewMeshMaterial.dispose()}_resetMachine(){this.machineState={kind:"awaitingArrowTip"},this._previewDrawing=null,this._updatePreview(),this.onMachineStateChanged.trigger(this.machineState)}_clearPreviewMesh(){this._previewMeshObject&&(this._previewMeshObject.removeFromParent(),this._previewMeshObject.geometry.dispose(),this._previewMeshObject=null)}}class Rl extends Bi{constructor(t){super(t),y(this,"enabled",!0),y(this,"_ownsChildGeometry",!1),y(this,"definitions",new ot.jp),this.styles.set("default",{color:0,textOffset:0,fontSize:0})}pickHandle(t,e,i){return null}pick(t,e=.05){const i=new p.tBo;i.ray.copy(t),i.params.Line={threshold:e},i.params.LineSegments={threshold:e};let s=null,n=1/0;for(const o of this._knownDrawings)for(const[a,l]of o.annotations){if(l.system!==this)continue;const c=l.three;c.updateWorldMatrix(!0,!0),c.traverse(h=>{if(h===c||!(h instanceof p.DXC))return;const u=[];h.raycast(i,u),u.length>0&&u[0].distance<n&&(n=u[0].distance,s=a)})}return s}define(t,e){this.definitions.set(t,e)}_buildGroup(t,e){const i=this.definitions.get(t.blockName);if(!i)throw new Error(`BlockAnnotations: block "${t.blockName}" is not defined.`);const s=new p.YJl;if(i.lines){const n=new p.DXC(i.lines,this._getMaterial(t.style));n.layers.set(1),n.userData.isDimension=!0,s.add(n)}if(i.mesh){const n=new p.eaF(i.mesh,this._getMeshMaterial(t.style));n.layers.set(1),n.userData.isBlockMesh=!0,s.add(n)}return s}_onAfterPersist(t,e){e.position.set(t.position.x,0,t.position.z),e.rotation.set(0,t.rotation,0),e.scale.setScalar(t.scale)}_onDispose(){var t,e;for(const i of this.definitions.values())null==(t=i.lines)||t.dispose(),null==(e=i.mesh)||e.dispose();this.definitions.clear()}}function Fl(r,t){const{position:e,direction:i}=r,{length:s}=t,n=new p.Pq0(e.x+i.x*s,0,e.z+i.z*s),o=new p.Pq0(i.x,0,i.z),a=t.lineTick(n,o,t.tickSize);return new Float32Array([e.x,0,e.z,n.x,0,n.z,...a])}function Vl(r,t){return new p.Pq0(r.position.x+r.direction.x*t,0,r.position.z+r.direction.z*t)}function Mp(r,t){switch(t){case"percentage":return`${(100*r).toFixed(2)} %`;case"ratio":return 0===r?"1:\u221e":`1:${(1/r).toFixed(2)}`;case"degrees":return`${(180*Math.atan(r)/Math.PI).toFixed(2)}\xb0`}}class Ip extends Bi{constructor(t){super(t),y(this,"enabled",!0),this.styles.set("default",{lineTick:ep,meshTick:ip,tickSize:.4,length:3,color:0,textOffset:.1,fontSize:.45,format:"percentage"})}pickHandle(t,e,i){return null}_buildGroup(t,e){const i=new p.YJl,s=Fl(t,e),n=new p.LoY;n.setAttribute("position",new p.THS(s,3));const o=new p.DXC(n,this._getMaterial(t.style));if(o.layers.set(1),o.userData.isDimension=!0,i.add(o),e.meshTick){const a=Vl(t,e.length),l=e.meshTick(a,t.direction,e.tickSize),c=new p.LoY;c.setAttribute("position",new p.THS(new Float32Array(l),3));const h=new p.eaF(c,this._getMeshMaterial(t.style));h.layers.set(1),h.userData.isDimension=!0,i.add(h)}return i}}function Ul(r,t){const e=t.x-r.x,i=t.z-r.z,s=Math.sqrt(e*e+i*i);if(0===s)return r.clone();const n=Math.atan2(i,e),o=Math.round(n/(Math.PI/4))*(Math.PI/4);return new p.Pq0(r.x+Math.cos(o)*s,0,r.z+Math.sin(o)*s)}function $l(r,t){const e=[];e.push(...t.enclosure.buildGeometry(r.center,r.halfW,r.halfH));const i=(new p.Pq0).subVectors(r.elbow,r.center),s=i.lengthSq()>1e-10?i.clone().normalize():new p.Pq0(1,0,0),n=t.enclosure.getAttachmentPoint(r.center,r.halfW,r.halfH,s);if(e.push(n.x,n.y,n.z,r.elbow.x,r.elbow.y,r.elbow.z,r.elbow.x,r.elbow.y,r.elbow.z,r.extensionEnd.x,r.extensionEnd.y,r.extensionEnd.z),t.lineTick){const o=(new p.Pq0).subVectors(r.extensionEnd,r.elbow);o.lengthSq()>1e-10&&e.push(...t.lineTick(r.extensionEnd,o.normalize(),t.tickSize))}return e}function Vr(r,t,e,i,s,n,o){const a="awaitingRadius"===r?n?Math.max(.05,Math.abs(n.x-t.x)):0:e,l="awaitingRadius"===r?n?Math.max(.05,Math.abs(n.z-t.z)):0:i;if(a<1e-10||l<1e-10)return[];const c=[];if(c.push(...o.enclosure.buildGeometry(t,a,l)),"awaitingRadius"===r)return c;const h="awaitingElbow"===r?n:s;if(!h)return c;const u=(new p.Pq0).subVectors(h,t),f=u.lengthSq()>1e-10?u.clone().normalize():new p.Pq0(1,0,0),d=o.enclosure.getAttachmentPoint(t,a,l,f);return"awaitingElbow"===r?(c.push(d.x,0,d.z,h.x,0,h.z),c):(n&&c.push(d.x,0,d.z,s.x,0,s.z,s.x,0,s.z,n.x,0,n.z),c)}const zp={buildGeometry(r,t,e){const i=.25*Math.min(t,e),s=new p.Pq0(r.x-t,0,r.z-e),n=new p.Pq0(r.x+t,0,r.z-e),o=new p.Pq0(r.x+t,0,r.z+e),a=new p.Pq0(r.x-t,0,r.z+e),l=[[s,n,new p.Pq0(0,0,-1)],[n,o,new p.Pq0(1,0,0)],[o,a,new p.Pq0(0,0,1)],[a,s,new p.Pq0(-1,0,0)]],c=[];for(const[h,u,f]of l){const d=h.distanceTo(u),_=Math.max(1,Math.round(d/(2*i))),m=d/_,w=m/2,g=(new p.Pq0).subVectors(u,h).normalize();for(let v=0;v<_;v++){const T=h.clone().addScaledVector(g,(v+.5)*m),C=h.clone().addScaledVector(g,v*m),S=(new p.Pq0).subVectors(C,T);let M=C.clone();for(let A=1;A<=8;A++){const O=A/8*Math.PI,I=T.x+S.x*Math.cos(O)+f.x*w*Math.sin(O),D=T.z+S.z*Math.cos(O)+f.z*w*Math.sin(O),B=new p.Pq0(I,0,D);c.push(M.x,0,M.z,B.x,0,B.z),M=B}}}return c},getAttachmentPoint(r,t,e,i){const s=Math.abs(i.x)>1e-10?t/Math.abs(i.x):1/0,n=Math.abs(i.z)>1e-10?e/Math.abs(i.z):1/0,o=Math.min(s,n);return new p.Pq0(r.x+i.x*o,0,r.z+i.z*o)}};class Dp extends Bi{constructor(t){super(t),y(this,"enabled",!0),y(this,"machineState",{kind:"awaitingCenter"}),y(this,"onMachineStateChanged",new Q),this.styles.set("default",{enclosure:zp,lineTick:Pl,tickSize:.4,color:22015,textOffset:.1,fontSize:.45})}pickHandle(t,e,i){return null}sendMachineEvent(t){const e=t.drawing??null;e&&(this._previewDrawing=e);const i=function Op(r,t){switch(r.kind){case"awaitingCenter":return"CLICK"===t.type?{kind:"awaitingRadius",center:t.point.clone(),cursor:null}:r;case"awaitingRadius":if("MOUSE_MOVE"===t.type)return{...r,cursor:t.point.clone()};if("CLICK"===t.type){const e=Math.max(.1,Math.abs(t.point.x-r.center.x)),i=Math.max(.1,Math.abs(t.point.z-r.center.z));return{kind:"awaitingElbow",center:r.center,halfW:e,halfH:i,cursor:null}}return"ESCAPE"===t.type?{kind:"awaitingCenter"}:r;case"awaitingElbow":return"MOUSE_MOVE"===t.type?{...r,cursor:t.point.clone()}:"CLICK"===t.type?{kind:"awaitingExtension",center:r.center,halfW:r.halfW,halfH:r.halfH,elbow:t.point.clone(),cursor:null}:"ESCAPE"===t.type?{kind:"awaitingCenter"}:r;case"awaitingExtension":return"MOUSE_MOVE"===t.type?{...r,cursor:Ul(r.elbow,t.point)}:"CLICK"===t.type?{kind:"enteringText",center:r.center,halfW:r.halfW,halfH:r.halfH,elbow:r.elbow,extensionEnd:Ul(r.elbow,t.point)}:"ESCAPE"===t.type?{kind:"awaitingCenter"}:r;case"enteringText":return"SUBMIT_TEXT"===t.type&&t.text.trim().length>0?{kind:"committed",annotation:{uuid:p.cj9.generateUUID(),center:r.center.clone(),halfW:r.halfW,halfH:r.halfH,elbow:r.elbow.clone(),extensionEnd:r.extensionEnd.clone(),text:t.text.trim(),style:""}}:"ESCAPE"===t.type?{kind:"awaitingCenter"}:r;case"committed":return"ESCAPE"===t.type?{kind:"awaitingCenter"}:r}}(this.machineState,t);if(i!==this.machineState){if(this.machineState=i,this._updatePreview(),"committed"===i.kind){if(!this._previewDrawing)return console.warn("CalloutAnnotations: commit requires a drawing. Pass `drawing` on the first CLICK."),void this._resetMachine();i.annotation.style=this.activeStyle;const s=this._persist(this._previewDrawing,i.annotation);this.onCommit.trigger([s])}this.onMachineStateChanged.trigger(this.machineState),"committed"===i.kind&&this._resetMachine()}}_buildGroup(t,e){const i=new p.YJl,s=$l(t,e),n=new p.LoY;n.setAttribute("position",new p.THS(new Float32Array(s),3));const o=new p.DXC(n,this._getMaterial(t.style));if(o.layers.set(1),o.userData.isDimension=!0,i.add(o),e.meshTick){const a=(new p.Pq0).subVectors(t.extensionEnd,t.elbow);if(a.lengthSq()>1e-10){a.normalize();const l=e.meshTick(t.extensionEnd,a,e.tickSize),c=new p.LoY;c.setAttribute("position",new p.THS(new Float32Array(l),3));const h=new p.eaF(c,this._getMeshMaterial(t.style));h.layers.set(1),h.userData.isMeshArrow=!0,i.add(h)}}return i}_updatePreview(){const t=this.machineState;if("awaitingRadius"!==t.kind&&"awaitingElbow"!==t.kind&&"awaitingExtension"!==t.kind)return void this._clearPreview();if(!this._previewDrawing)return;const e=this._resolveStyle(this.activeStyle),i=(()=>{switch(t.kind){case"awaitingRadius":return Vr("awaitingRadius",t.center,0,0,null,t.cursor,e);case"awaitingElbow":return Vr("awaitingElbow",t.center,t.halfW,t.halfH,null,t.cursor,e);case"awaitingExtension":return Vr("awaitingExtension",t.center,t.halfW,t.halfH,t.elbow,t.cursor,e)}})();if(0!==i.length)if(this._previewObject&&this._previewObject.geometry.attributes.position.count===i.length/3){const o=this._previewObject.geometry.attributes.position;o.set(i),o.needsUpdate=!0}else{this._clearPreview();const o=new p.LoY;o.setAttribute("position",new p.THS(new Float32Array(i),3)),this._previewObject=new p.DXC(o,this._previewMaterial),this._previewObject.layers.set(1),this._previewObject.renderOrder=1,this._previewObject.frustumCulled=!1,this._previewObject.userData.isDimension=!0,this._previewDrawing.three.add(this._previewObject)}else this._clearPreview()}_resetMachine(){this.machineState={kind:"awaitingCenter"},this._clearPreview(),this._previewDrawing=null,this.onMachineStateChanged.trigger(this.machineState)}}const Hl=class Kc extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"list",new ot.jp),y(this,"systems",new ot.jp),y(this,"onDisposed",new Q),t.add(Kc.uuid,this),this.list.onBeforeDelete.add(({value:e})=>e.dispose()),this.systems.onBeforeDelete.add(({value:e})=>e.dispose())}use(t){if(this.systems.has(t))return this.systems.get(t);const e=new t(this.components);return this.systems.set(t,e),e}create(t){const e=new Br(this.components);e.world=t,t.scene.three.add(e.three),t.onDisposed.add(()=>this.list.delete(e.uuid));const i=t.camera;return i.three.layers.enable(1),i instanceof ln&&(i.threePersp.layers.enable(1),i.threeOrtho.layers.enable(1)),this.list.set(e.uuid,e),e}dispose(){this.list.clear(),this.systems.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}};y(Hl,"uuid","5c7d3b9a-4e8f-4a2b-9c1d-0e3f2a5b7c8d");let Re=Hl;const kp=[[16711680,1],[16776960,2],[65280,3],[65535,4],[255,5],[16711935,6],[16777215,7],[0,7]];function Fe(r){const t=r>>16&255,e=r>>8&255,i=255&r;let s=7,n=1/0;for(const[o,a]of kp){const l=(t-(o>>16&255))**2+(e-(o>>8&255))**2+(i-(255&o))**2;l<n&&(n=l,s=a)}return s}const ql="\0HANDSEED\0";class Lp{constructor(){y(this,"_lines",[]),y(this,"_handleCounter",1)}p(t,e){return this._lines.push(String(t),String(e)),this}n(t,e,i=6){return this._lines.push(String(t),e.toFixed(i)),this}handle(){return(this._handleCounter++).toString(16).toUpperCase()}entityHeader(t,e,i){return this._lines.push("0",t,"5",this.handle(),"100","AcDbEntity","8",e,"62",String(i)),this}symbolTable(t,e){return this._lines.push("0","TABLE","2",t,"5",this.handle(),"100","AcDbSymbolTable","70",String(e)),this}symbolRecord(t,e){return this._lines.push("0",t,"5",this.handle(),"100","AcDbSymbolTableRecord","100",e),this}writeHandSeed(){return this._lines.push("9","$HANDSEED","5",ql),this}build(){return(this._lines.join("\n")+"\n").replace(ql,this._handleCounter.toString(16).toUpperCase())}}class Np{constructor(t){y(this,"precision",2),y(this,"config",{trueColor:!1}),y(this,"_viewport",null),y(this,"_paperSlot",null),y(this,"_annotationLayers",new Map),y(this,"_systemExporters",new Map),this._components=t}registerSystemExporter(t,e){this._systemExporters.set(t,e)}export(t,e){const i=!!e,s=new Lp,n=new Map;for(const h of t)for(const u of h.drawing.layers.values())n.has(u.name)||n.set(u.name,u);const o=[...n.values()],l=this._components.get(Re).systems.get(Rl),c=l?[...l.definitions.keys()]:[];this._writeHeader(s,i),this._writeTables(s,o,c),this._writeBlocks(s,l??null),s.p(0,"SECTION").p(2,"ENTITIES"),i&&e&&this._writePaperBorders(s,e);for(const h of t){h.drawing.three.traverse(u=>{u.userData.isDimension&&u.userData.annotationUuid&&this._annotationLayers.set(u.userData.annotationUuid,u.userData.layer??"0")});for(const u of h.viewports){if(this._viewport=u.viewport??null,i&&u.viewport){const f=u.viewport;this._paperSlot={x:u.x??0,y:e.heightMm-2*e.margin-(u.y??0),mmPerUnit:1e3/f.drawingScale,vpLeft:f.left,vpTop:f.top}}else this._paperSlot=null;this._writeViewportBorder(s),this._writeRawLines(s,h.drawing),this._writeLinearAnnotations(s,h.drawing),this._writeAngleAnnotations(s,h.drawing),this._writeLeaderAnnotations(s,h.drawing),this._writeSlopeAnnotations(s,h.drawing),this._writeCalloutAnnotations(s,h.drawing),this._writeBlockInsertions(s,h.drawing),this._writeCustomSystems(s,h.drawing)}this._annotationLayers.clear()}return s.p(0,"ENDSEC"),this._writeObjects(s),s.p(0,"EOF"),this._viewport=null,this._paperSlot=null,s.build()}_writeHeader(t,e){t.p(0,"SECTION").p(2,"HEADER"),t.p(9,"$ACADVER").p(1,this.config.trueColor?"AC1018":"AC1015"),t.p(9,"$DWGCODEPAGE").p(3,"ANSI_1252"),t.p(9,"$INSUNITS").p(70,e?4:6),t.writeHandSeed(),t.p(0,"ENDSEC")}_writeTables(t,e,i){t.p(0,"SECTION").p(2,"TABLES"),t.symbolTable("VPORT",0).p(0,"ENDTAB"),t.symbolTable("LTYPE",1),t.symbolRecord("LTYPE","AcDbLinetypeTableRecord").p(2,"CONTINUOUS").p(70,0).p(3,"Solid line").p(72,65).p(73,0).n(40,0),t.p(0,"ENDTAB"),t.symbolTable("LAYER",e.length);for(const n of e){const o=Fe(n.material.color.getHex());t.symbolRecord("LAYER","AcDbLayerTableRecord").p(2,n.name).p(70,0).p(62,o).p(6,"CONTINUOUS")}t.p(0,"ENDTAB"),t.symbolTable("STYLE",1),t.symbolRecord("STYLE","AcDbTextStyleTableRecord").p(2,"STANDARD").p(70,0).n(40,0).n(41,1).n(50,0).p(71,0).n(42,.2).p(3,"txt").p(4,""),t.p(0,"ENDTAB"),t.symbolTable("VIEW",0).p(0,"ENDTAB"),t.symbolTable("UCS",0).p(0,"ENDTAB"),t.symbolTable("APPID",1),t.symbolRecord("APPID","AcDbRegAppTableRecord").p(2,"ACAD").p(70,0),t.p(0,"ENDTAB"),t.symbolTable("DIMSTYLE",0).p(0,"ENDTAB");const s=["*Model_Space","*Paper_Space",...i];t.symbolTable("BLOCK_RECORD",s.length);for(const n of s)t.symbolRecord("BLOCK_RECORD","AcDbBlockTableRecord").p(2,n);t.p(0,"ENDTAB"),t.p(0,"ENDSEC")}_writeBlocks(t,e){if(t.p(0,"SECTION").p(2,"BLOCKS"),this._writeBlock(t,"*Model_Space",null),this._writeBlock(t,"*Paper_Space",null),e)for(const[i,s]of e.definitions)this._writeBlock(t,i,s.lines??null);t.p(0,"ENDSEC")}_writeBlock(t,e,i){if(t.p(0,"BLOCK").p(5,t.handle()).p(100,"AcDbEntity").p(8,"0").p(100,"AcDbBlockBegin").p(2,e).p(70,0).n(10,0).n(20,0).n(30,0).p(3,e).p(1,""),i){const s=this._viewport,n=this._paperSlot;this._viewport=null,this._paperSlot=null,this._writeGeoAsLines(t,i,"0"),this._viewport=s,this._paperSlot=n}t.p(0,"ENDBLK").p(5,t.handle()).p(100,"AcDbEntity").p(8,"0").p(100,"AcDbBlockEnd")}_writeViewportBorder(t){if(!this._viewport)return;const e=this._viewport,i=this._tx(e.left),s=this._tx(e.right),n=this._ty(-e.bottom),o=this._ty(-e.top);this._writeRawLine(t,i,n,s,n,"0",7),this._writeRawLine(t,s,n,s,o,"0",7),this._writeRawLine(t,s,o,i,o,"0",7),this._writeRawLine(t,i,o,i,n,"0",7)}_writePaperBorders(t,e){const{margin:i,widthMm:s,heightMm:n}=e,o=s-2*i,a=n-2*i;this._writeRawLine(t,0,0,o,0,"0",7),this._writeRawLine(t,o,0,o,a,"0",7),this._writeRawLine(t,o,a,0,a,"0",7),this._writeRawLine(t,0,a,0,0,"0",7),this._writeRawLine(t,-i,-i,o+i,-i,"0",7),this._writeRawLine(t,o+i,-i,o+i,a+i,"0",7),this._writeRawLine(t,o+i,a+i,-i,a+i,"0",7),this._writeRawLine(t,-i,a+i,-i,-i,"0",7)}_writeObjects(t){t.p(0,"SECTION").p(2,"OBJECTS"),t.p(0,"DICTIONARY").p(5,t.handle()).p(330,0).p(100,"AcDbDictionary").p(281,1),t.p(0,"ENDSEC")}_writeRawLines(t,e){e.three.traverse(i=>{var s;if(!(i instanceof p.DXC)||i.userData.isDimension||null!=(s=i.parent)&&s.userData.blockUuid||!i.visible)return;const n=i.userData.layer??"0",o=i.material.color.getHex();this._writeGeoAsLines(t,i.geometry,n,Fe(o),o)})}_writeLinearAnnotations(t,e){var i;const s=this._components.get(Re).systems.get(mp);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=Fe(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=Rr(n,o);if(!this._fullyInViewport(this._bboxFromPositions(c)))continue;if(this._writePairsAsLines(t,c,l,a,o.color),o.meshTick)for(const{tip:v,dir:T}of Al(n))this._writeMeshTriangles(t,o.meshTick(v,T,o.tickSize),l,a,o.color);const h=(new p.Pq0).subVectors(n.pointB,n.pointA),u=new p.Pq0(-h.z,0,h.x).normalize(),f=n.offset>=0?1:-1,d=n.pointA.clone().addScaledVector(u,n.offset),_=n.pointB.clone().addScaledVector(u,n.offset),m=d.clone().add(_).multiplyScalar(.5).addScaledVector(u,(o.textOffset+.5*o.fontSize)*f),w=o.unit??{factor:1,suffix:"m"},g=`${(n.pointA.distanceTo(n.pointB)*w.factor).toFixed(this.precision)} ${w.suffix}`;this._writeText(t,g,m.x,m.z,o.fontSize,l,a,this._textAngle(h.x,h.z),1,2,o.color)}}_writeAngleAnnotations(t,e){var i;const s=this._components.get(Re).systems.get(xp);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=Fe(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=Dl(n,o);if(!this._fullyInViewport(this._bboxFromPositions(c)))continue;if(this._writePairsAsLines(t,c,l,a,o.color),o.meshTick)for(const{tip:m,dir:w}of Ol(n))this._writeMeshTriangles(t,o.meshTick(m,w,o.tickSize),l,a,o.color);const h=bp(n),u=n.arcRadius+o.textOffset,f=n.vertex.x+Math.cos(h)*u,d=n.vertex.z+Math.sin(h)*u,_=p.cj9.radToDeg(vp(n));this._writeText(t,`${_.toFixed(this.precision)}\xb0`,f,d,o.fontSize,l,a,0,1,0,o.color)}}_writeLeaderAnnotations(t,e){var i;const s=this._components.get(Re).systems.get(Ap);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=Fe(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=Nl(n,o);if(!this._fullyInViewport(this._bboxFromPositions(c)))continue;if(this._writePairsAsLines(t,c,l,a,o.color),o.meshTick){const _=(new p.Pq0).subVectors(n.arrowTip,n.elbow);_.lengthSq()>1e-10&&this._writeMeshTriangles(t,o.meshTick(n.arrowTip,_.normalize(),o.tickSize),l,a,o.color)}const h=(new p.Pq0).subVectors(n.extensionEnd,n.elbow).setY(0).normalize(),u=h.x<-.1?2:h.x>.1?0:1,f=1===u?.5*o.fontSize:0,d=n.extensionEnd.clone().addScaledVector(h,o.textOffset+f);this._writeText(t,n.text,d.x,d.z,o.fontSize,l,a,0,u,2,o.color)}}_writeSlopeAnnotations(t,e){var i;const s=this._components.get(Re).systems.get(Ip);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=Fe(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=Fl(n,o);if(!this._fullyInViewport(this._bboxFromPositions(c)))continue;if(this._writePairsAsLines(t,c,l,a,o.color),o.meshTick){const f=Vl(n,o.length);this._writeMeshTriangles(t,o.meshTick(f,n.direction,o.tickSize),l,a,o.color)}const h=new p.Pq0(n.position.x+n.direction.x*o.length,0,n.position.z+n.direction.z*o.length),u=n.position.clone().add(h).multiplyScalar(.5).addScaledVector(new p.Pq0(-n.direction.z,0,n.direction.x),o.textOffset+o.fontSize);this._writeText(t,Mp(n.slope,o.format),u.x,u.z,o.fontSize,l,a,this._textAngle(n.direction.x,n.direction.z),1,0,o.color)}}_writeCalloutAnnotations(t,e){var i;const s=this._components.get(Re).systems.get(Dp);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=Fe(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=$l(n,o);if(!this._fullyInViewport(this._bboxFromPositions(c)))continue;if(this._writePairsAsLines(t,c,l,a,o.color),o.meshTick){const _=(new p.Pq0).subVectors(n.extensionEnd,n.elbow);_.lengthSq()>1e-10&&this._writeMeshTriangles(t,o.meshTick(n.extensionEnd,_.normalize(),o.tickSize),l,a,o.color)}const h=(new p.Pq0).subVectors(n.extensionEnd,n.elbow).setY(0).normalize(),u=h.x<-.1?2:h.x>.1?0:1,f=1===u?.5*o.fontSize:0,d=n.extensionEnd.clone().addScaledVector(h,o.textOffset+f);this._writeText(t,n.text,d.x,d.z,o.fontSize,l,a,0,u,2,o.color)}}_writeBlockInsertions(t,e){const i=this._components.get(Re).systems.get(Rl);if(i)for(const[,s]of e.annotations.getBySystem(i)){if(!this._inViewport(s.position.x,s.position.z))continue;const n=i.styles.get(s.style)??i.styles.get("default"),o=Fe(n.color),a=-p.cj9.radToDeg(s.rotation),l=s.scale*this._scale();t.entityHeader("INSERT","0",o),this._emitTrueColor(t,n.color),t.p(100,"AcDbBlockReference").p(2,s.blockName).n(10,this._tx(s.position.x)).n(20,this._ty(s.position.z)).n(30,0).n(41,l).n(42,l).n(43,l).n(50,a)}}_writeGeoAsLines(t,e,i,s=7,n){const o=e.attributes.position;if(o)for(let a=0;a+1<o.count;a+=2){const l=this._clipSegment(new p.Pq0(o.getX(a),0,o.getZ(a)),new p.Pq0(o.getX(a+1),0,o.getZ(a+1)));l&&this._writeLine(t,l.start.x,l.start.z,l.end.x,l.end.z,i,s,n)}}_writePairsAsLines(t,e,i,s=7,n){for(let o=0;o+5<e.length;o+=6){const a=this._clipSegment(new p.Pq0(e[o],0,e[o+2]),new p.Pq0(e[o+3],0,e[o+5]));a&&this._writeLine(t,a.start.x,a.start.z,a.end.x,a.end.z,i,s,n)}}_emitTrueColor(t,e){this.config.trueColor&&void 0!==e&&t.p(420,e)}_writeLine(t,e,i,s,n,o,a,l){t.entityHeader("LINE",o,a),this._emitTrueColor(t,l),t.p(100,"AcDbLine").n(10,this._tx(e)).n(20,this._ty(i)).n(30,0).n(11,this._tx(s)).n(21,this._ty(n)).n(31,0)}_writeRawLine(t,e,i,s,n,o,a){t.entityHeader("LINE",o,a).p(100,"AcDbLine").n(10,e).n(20,i).n(30,0).n(11,s).n(21,n).n(31,0)}_writeSolid(t,e,i,s,n,o,a,l,c,h){t.entityHeader("SOLID",l,c),this._emitTrueColor(t,h),t.p(100,"AcDbTrace").n(10,this._tx(e)).n(20,this._ty(i)).n(30,0).n(11,this._tx(s)).n(21,this._ty(n)).n(31,0).n(12,this._tx(o)).n(22,this._ty(a)).n(32,0).n(13,this._tx(o)).n(23,this._ty(a)).n(33,0)}_writeMeshTriangles(t,e,i,s,n){for(let o=0;o+8<e.length;o+=9)this._writeSolid(t,e[o],e[o+2],e[o+3],e[o+5],e[o+6],e[o+8],i,s,n)}_writeText(t,e,i,s,n,o,a,l=0,c=0,h=0,u){const f=this._tx(i),d=this._ty(s);t.entityHeader("TEXT",o,a),this._emitTrueColor(t,u),t.p(100,"AcDbText").n(10,f).n(20,d).n(30,0).n(40,n*this._scale()).n(50,l).p(1,e),(0!==c||0!==h)&&(0!==c&&t.p(72,c),0!==h&&t.p(73,h),t.n(11,f).n(21,d).n(31,0))}_tx(t){return this._paperSlot?this._paperSlot.x+(t-this._paperSlot.vpLeft)*this._paperSlot.mmPerUnit:this._viewport?t-this._viewport.left:t}_ty(t){return this._paperSlot?this._paperSlot.y-(t+this._paperSlot.vpTop)*this._paperSlot.mmPerUnit:this._viewport?-t-this._viewport.bottom:-t}_scale(){return this._paperSlot?this._paperSlot.mmPerUnit:1}_clipSegment(t,e){return this._viewport?this._viewport.clipLine(new p.cZY(t,e)):new p.cZY(t,e)}_inViewport(t,e){return!this._viewport||this._viewport.bbox.containsPoint(new p.Pq0(t,0,e))}_bboxFromPositions(t){const e=new p.NRn;for(let i=0;i+2<t.length;i+=3)e.expandByPoint(new p.Pq0(t[i],0,t[i+2]));return e}_fullyInViewport(t){return!this._viewport||this._viewport.bbox.containsBox(t)}_textAngle(t,e){let i=Math.atan2(-e,t);return(i>Math.PI/2||i<=-Math.PI/2)&&(i+=Math.PI),p.cj9.radToDeg(i)}_writeCustomSystems(t,e){if(0===this._systemExporters.size)return;const i=this._makeContext(t);for(const[s,n]of this._systemExporters){const o=this._components.get(Re).systems.get(s);o&&n(o,i)}}_makeContext(t){return{writeLine:(e,i,s,n,o="0",a=7)=>{this._writeLine(t,e,i,s,n,o,a)},writePairs:(e,i="0",s=7)=>{this._writePairsAsLines(t,e,i,s)},writeMeshTriangles:(e,i="0",s=7)=>{this._writeMeshTriangles(t,e,i,s)},writeText:(e,i,s,n,o={})=>{this._writeText(t,e,i,s,n,o.layer??"0",o.aciColor??7,o.rotDeg??0,o.hAlign??0)},hexToAci:Fe,textAngle:(e,i)=>this._textAngle(e,i)}}}y(class Qc extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"exporter",new Np(this.components)),t.add(Qc.uuid,this)}},"uuid","e9a2c3d4-5f67-4b89-a012-1c3d5e7f9b2a");let Gl=(()=>{class r extends At{static uuid="ab45d0a7-feea-4afc-927c-80832dae76dd";enabled=!0;_fragments=null;set fragments(e){this._fragments=e}geometries=new ot.jp;get(e,i){var s=this;return(0,G.A)(function*(){const{material:n,coordinate:o,applyTransformation:a}={coordinate:!0,applyTransformation:!0,...i},l=new ot.jp;for(const[c,h]of Object.entries(e)){const u=s._fragments.models.list.get(c);if(!u)continue;const f=s.getModelMeshes(c);for(const d of h){let _=l.get(c);_||(_=new ot.jp,l.set(c,_));let m=f.get(d);if(m&&m.length>0){const v=[];for(const[,{geometry:T}]of m.entries()){const C=yield s.createMesh(u,T,{material:n,applyTransformation:a,coordinate:o});v.push(C)}_.set(d,v);continue}m=[],f.set(d,m);const[w]=yield u.getItemsGeometry([d]);if(!w)continue;const g=[];for(const v of w){const T=s.createGeometry(v);if(!T)continue;const{geometry:C}=T;m.push(T);const S=yield s.createMesh(u,C,{material:n,applyTransformation:a,coordinate:o});g.push(S)}_.set(d,g)}}return l})()}getModelMeshes(e){let i=this.geometries.get(e);return i||(i=new ot.jp,this.geometries.set(e,i)),i}remove(e=[...this.geometries.keys()]){for(const i of e){const s=this.geometries.get(i);if(s){for(const[,n]of s)for(const{geometry:o}of n)o.dispose();this.geometries.delete(i)}}}onDisposed=new Q;dispose(e=!0){this.remove(),e&&this.geometries.dispose(),this.onDisposed.trigger(r.uuid)}getMeshesFromResult(e){const i=[];for(const s of e.values())for(const n of s.values())i.push(...n);return i}createGeometry(e){const{positions:i,indices:s,normals:n,transform:o}=e;if(!(i&&s&&n))return null;const a=new p.LoY;return a.setAttribute("position",new p.THS(i,3)),a.setAttribute("normal",new p.THS(n,3,!0)),a.setIndex(new p.THS(s,1)),a.applyMatrix4(o),{geometry:a,transform:o}}createMesh(e,i,s){var n=this;return(0,G.A)(function*(){const{material:o,applyTransformation:a,coordinate:l}={applyTransformation:!0,coordinate:!0,...s},c=n.components.get(ft),h=new p.eaF(i,o);if(h.applyMatrix4(e.object.matrixWorld),a||h.position.set(0,0,0),l&&c.baseCoordinationModel!==e.modelId){const u=yield e.getCoordinationMatrix();c.applyBaseCoordinateSystem(h,u)}return h})()}}return r})(),Ur=(()=>{class r extends At{static uuid="2695289f-e6c1-4980-919e-88b7591d7ea3";enabled=!0;originalColors=new Map;_ghostColor=new p.Q1f("white");_ghostedMaterials=[];set ghostColor(e){this._ghostColor=e}_ghostApplied=!1;get ghostApplied(){return this._ghostApplied}_world;set world(e){this._world=e,this._initEventListeners()}get ghostedMaterials(){return this._ghostedMaterials}_fragments;set fragments(e){this._fragments=e,this._initEventListeners()}onDisposed=new Q;constructor(e){super(e)}dispose(){this.onDisposed.trigger(r.uuid),this._ghostedMaterials=[]}setModelTransparent(e){const i=[...e.models.materials.list.values()];for(const s of i){if(s.userData.customId)continue;let n;n="color"in s?s.color.getHex():s.lodColor.getHex(),this.originalColors.set(s,{color:n,transparent:s.transparent,opacity:s.opacity}),s.transparent=!0,s.opacity=.05,s.needsUpdate=!0,"color"in s?s.color=this._ghostColor:s.lodColor=this._ghostColor,this._ghostedMaterials.push(s)}this._ghostApplied=!0}restoreModelMaterials(){for(const[e,i]of this.originalColors){const{color:s,transparent:n,opacity:o}=i;e.transparent=n,e.opacity=o,"color"in e?e.color.setHex(s):e.lodColor.setHex(s),e.needsUpdate=!0}this.originalColors.clear(),this._ghostedMaterials=[],this._ghostApplied=!1}toggleGhost(e){this.originalColors.size?this.restoreModelMaterials():this.setModelTransparent(e)}_initEventListeners(){void 0!==this._world&&void 0!==this._fragments&&(this._world.camera.controls.addEventListener("rest",()=>{this.enabled?this.setModelTransparent(this._fragments):this.restoreModelMaterials()}),this._fragments.models.list.onItemSet.add(({value:e})=>{console.log(`Model ${e.modelId} is ready`),setTimeout(()=>{this.enabled?(console.log("GHOST"),this.setModelTransparent(this._fragments)):this.restoreModelMaterials()},1500)}))}}return r})(),Yl=(()=>{class r extends At{static uuid="3abd8228-7bff-4ff6-ac30-53f97bdc8ae6";enabled=!0;_fragments;_isolated={};_hidden={};_colorOverrides={};_overrides={};onDisposed=new Q;constructor(e){super(e)}set fragments(e){this._fragments=e}_world;set world(e){this._world=e}get colorOverrides(){return this._colorOverrides}applyModelOverrides(e,i){var s=this;return(0,G.A)(function*(){s._overrides[e.modelId]=i,yield s._applyModelOverrides(e)})()}update(e){var i=this;return(0,G.A)(function*(){(void 0===e?i.fragments.models.list:[e]).forEach(n=>{i._appendOnModel(n)})})()}setNonColoredVisibility(e){var i=this;return(0,G.A)(function*(){if(void 0===i._fragments)return;const s=i._colorOverrides;console.log(s);for(const n of Object.keys(s)){const o=i._fragments.models.list.get(n);if(void 0===o)return;e?yield i._setVisibilityAll(o,!0):(yield i._setVisibilityAll(o,!1),o.setVisible([...s[n]],!0))}})()}dispose(){this.onDisposed.trigger(r.uuid)}_getLocalIdsByType(e,i){var s=this;return(0,G.A)(function*(){if(void 0===s._fragments)return null;const n=yield e.getItemsOfCategories(i);return new Set([...Object.values(n).flat()])})()}_applyModelOverrides(e){var i=this;return(0,G.A)(function*(){if(void 0!==i._fragments&&void 0!==i._overrides[e.modelId]){try{yield Promise.all([i._updateIsolatedMap(e),i._updateHiddenMap(e),i._updateColorOverrides(e)])}catch(n){console.log(n)}e&&i._appendOnModel(e)}})()}_appendOnModel(e){var i=this;return(0,G.A)(function*(){const s=i._overrides[e.modelId];if(void 0===s)return;const n=i._isolated[e.modelId],o=i._hidden[e.modelId];n?.size?(yield i._setVisibilityAll(e,!1),e?.setVisible([...n],!0)):o?.size&&e?.setVisible([...o],!1);for(const a of s.colorOverrides){const l={color:new p.Q1f(a.color),renderedFaces:ot.eB.TWO,opacity:a.opacity,transparent:!1,customId:`${e.modelId}_${a.color}`};yield e.highlight(a.ids,l)}})()}_updateIsolatedMap(e){var i=this;return(0,G.A)(function*(){const s=e.modelId,n=i._overrides[s];if(i._isolated[s]=new Set,n.isolatedTypes.length){const o=yield i._getLocalIdsByType(e,n.isolatedTypes);o&&o.forEach(a=>i._isolated[s].add(a))}n.isolated.length&&n.isolated.forEach(o=>i._isolated[s].add(o))})()}_updateHiddenMap(e){var i=this;return(0,G.A)(function*(){const s=e.modelId,n=i._overrides[s];if(i._hidden[s]=new Set,n.hiddenTypes.length){const o=yield i._getLocalIdsByType(e,n.hiddenTypes);o&&o.forEach(a=>i._hidden[s].add(a))}n.hidden.length&&n.hidden.forEach(o=>i._hidden[s].add(o))})()}_updateColorOverrides(e){var i=this;return(0,G.A)(function*(){const s=e.modelId;i._colorOverrides[e.modelId]=new Set,i._overrides[s].colorOverrides.forEach(o=>{o.ids.forEach(a=>i._colorOverrides[e.modelId].add(a))})})()}_setVisibilityAll=function(){var e=(0,G.A)(function*(i,s){const o=(yield i.getItemsWithGeometry()).map(l=>l.getLocalId()),a=(yield Promise.all(o)).filter(l=>null!==l);yield i.setVisible(a,s)});return function(i,s){return e.apply(this,arguments)}}()}return r})();const Zl=(r,t)=>{const e={...r};return Object.keys(t).forEach(i=>{e[i]=new Set([...e[i]||[],...t[i]])}),e},Wl=function(){var r=(0,G.A)(function*(t,e,i,s={}){const n=[];for(const[,l]of e.models.list){const c=yield l.raycast(i);if(c){const h={};h[l.modelId]=new Set,h[l.modelId].add(c.localId),n.push({...c,idMap:h})}}if(0===n.length)return Xl(e,s,!0),null;let o=n[0],a=o.distance;for(let l=1;l<n.length;l++)n[l].distance<a&&(a=n[l].distance,console.log(a),o=n[l]);return t.get(Ur).ghostApplied&&!((r,t)=>{if(null===t)return!1;let e=!1;return Object.keys(r).forEach(i=>{t[i].forEach(s=>{r[i].has(s)&&(e=!0)})}),e})(t.get(Yl).colorOverrides,o.idMap)?(Xl(e,s=Zl(s,o.idMap),!1),Wl(t,e,i,s)):o});return function(e,i,s){return r.apply(this,arguments)}}();function Xl(r,t,e){for(const i of Object.keys(t))r.models.list.get(i)?.setVisible([...t[i]],e)}class Vp{hoveredElement=new Q}let $r=(()=>{class r extends At{static uuid="26fbd870-b1b2-4b71-b747-4063d484de1b";HOVERER_OPACITY_KEY="_maxHoverOpacity";_hoverTimeout=null;_meshes=new ot.PG;_localId=null;_fadeAnimation=null;_world=null;_fragments=null;set world(e){if(e){this._world=e,this.setupEvents(!0);for(const i of this._meshes)e.scene.three.add(i)}else{this.setupEvents(!1),this._world=null;for(const i of this._meshes)i.removeFromParent()}}get world(){return this._world}events=new Vp;set fragments(e){this._fragments=e}_enabled=!1;set enabled(e){this.setupEvents(e),this._enabled=e}get enabled(){return this._enabled}_material=new p.V9B({color:16777215,transparent:!0,opacity:.5,depthTest:!1,userData:{[this.HOVERER_OPACITY_KEY]:.5}});set material(e){e.userData[this.HOVERER_OPACITY_KEY]=e.opacity;for(const i of this._meshes)i.material=e;this._material.dispose(),this._material=e}get material(){return this._material}onDisposed=new Q;duration=200;animation=!0;constructor(e){super(e),e.add(r.uuid,this),this._meshes.onBeforeDelete.add(i=>{i.removeFromParent(),i.geometry.dispose(),this._setCursor(!1)}),this._meshes.onItemAdded.add(i=>{this.world&&(this._setCursor(!0),this.world.scene.three.add(i))}),this._meshes.onCleared.add(()=>{this._localId=null,this._hoverTimeout&&(clearTimeout(this._hoverTimeout),this._hoverTimeout=null)})}setupEvents(e){if(!this.world||this.world.isDisposing)return;if(!this.world.renderer)throw new Error("The given world doesn't have a renderer!");const i=this.world.renderer.three.domElement;i.removeEventListener("mousemove",this.onMouseMove),i.removeEventListener("mouseleave",this.onMouseMove),e&&(i.addEventListener("mousemove",this.onMouseMove),i.addEventListener("mouseleave",this.onMouseLeave))}mouseStopTimeout=null;onMouseMove=e=>{null!==this.mouseStopTimeout&&clearTimeout(this.mouseStopTimeout),this.mouseStopTimeout=window.setTimeout(()=>this.hover(e),50)};onMouseLeave=()=>{this._meshes.clear()};animate=()=>{if(!(this._fadeAnimation&&this.animation&&this.material.transparent))return;const{startTime:e,duration:i,fadeIn:s}=this._fadeAnimation,n=Date.now()-e,o=Math.min(n/i,1),l=this.material.userData[this.HOVERER_OPACITY_KEY];this.material.opacity=(s?o:1-o)*(void 0!==l?l:1),o<1?requestAnimationFrame(this.animate):(s||this._meshes.clear(),this._fadeAnimation=null)};hover(e){var i=this;return(0,G.A)(function*(){if(!i.enabled||!i.world||!i._fragments)return;const s=new p.I9Y(e.clientX,e.clientY),n=yield Wl(i.components,i._fragments,{camera:i.world.camera.three,mouse:s,dom:i.world.renderer.three.domElement});if(!n)return i._meshes.clear(),void i.events.hoveredElement.trigger(null);if(i.components.get(Ur).ghostApplied&&!(yield n.fragments.getHighlightItemIds()).includes(n.localId))return console.log("Not a highlighted object!"),void i.events.hoveredElement.trigger(null);i.events.hoveredElement.trigger(n);const{fragments:o,localId:a}=n;i._localId!==a&&(i._meshes.clear(),i._localId=a,i._hoverTimeout=window.setTimeout((0,G.A)(function*(){const l={[o.modelId]:new Set([a])},c=i.components.get(Gl);c.fragments=i._fragments;const h=yield c.get(l);for(const[,u]of h.entries()){const f=[...u.values()].flat();for(const d of f)d.material=i.material,d.position.set(0,0,0),d.rotation.set(0,0,0),d.scale.set(1,1,1),d.applyMatrix4(o.object.matrixWorld),i._meshes.add(d)}i._fadeAnimation={startTime:Date.now(),duration:i.duration,fadeIn:!0},i.animate()}),100))})()}_setCursor(e){const i=this._world.renderer?.three.domElement;i&&(i.style.cursor=e?"pointer":"default")}clear(){this._meshes.clear()}dispose(){this._enabled=!1,this._meshes.clear(),this._fadeAnimation=null,this._hoverTimeout=null,this.onDisposed.trigger()}}return r})();var Up=mt(9595);const $p=function(){var r=(0,G.A)(function*(t,e){const i=Object.keys(e)[0];if(i&&t.models.list.get(i)){const s=t.models.list.get(i),[n]=yield s.getItemsData([...e[i]],{attributesDefault:!1,attributes:["Name","NominalValue"],relations:{IsDefinedBy:{attributes:!0,relations:!0},DefinesOcurrence:{attributes:!1,relations:!1}}});return n||null}return null});return function(e,i){return r.apply(this,arguments)}}();var jr=mt(7850);class jp{clickedElement=new Q;clickedCanvas=new Q;selection=new Q}let Kl=(()=>{class r extends At{static uuid="b7e0b697-172f-43db-b530-d775a2a34d55";HIGHLIGHT_ID="cue_selection";enabled=!0;multiSelect=!1;resetOnCanvasClick=!0;_fragments=null;set fragments(e){this._fragments=e}hoveredElement=null;selectedElements=null;set styles(e){const i=this.components.get(jr.TF);i.fillOpacity=e.fillOpacity,i.fillColor=e.fillColor,i.color=e.outlineColor}onDisposed=new Q;events=new jp;constructor(e){super(e),this._initEventListeners()}dispose(){this.hoveredElement=null,this.selectedElements=null,this.onDisposed.trigger(r.uuid)}_initEventListeners(){var e=this;this.components.get($r).events.hoveredElement.add(function(){var n=(0,G.A)(function*(o){if(!o)return void(e.hoveredElement=null);const a=o.localId,l=o.fragments.modelId;e.hoveredElement={[l]:new Set([a])}});return function(o){return n.apply(this,arguments)}}()),Up.B.getInstance().events.addListener("shortPressedLeft",(0,G.A)(function*(){if(!e.enabled)return;const n=e.components.get(jr.TF);n.clean();const o=e.hoveredElement;if(!o)return e.resetOnCanvasClick&&(e.selectedElements=null,e.events.selection.trigger(null),n.clean()),void e.events.clickedCanvas.trigger();const a=yield $p(e._fragments,o);a&&e.events.clickedElement.trigger(a);const l=Object.keys(o)[0],c=[...o[l]][0];let h=e.selectedElements?Object.assign({},e.selectedElements):null;h=e.multiSelect?h?e.resetOnCanvasClick&&h&&h[l]?.has(c)?((r,t)=>{const e={...r};return Object.keys(t).forEach(i=>{const s=t[i];e[i]&&(e[i]=new Set([...e[i]||[]].filter(n=>!s.has(n))),0===e[i].size&&delete e[i])}),0===Object.keys(e).length?null:e})(h,o):Zl(h,o):o:e.resetOnCanvasClick&&h&&h[l]?.has(c)?null:o,e.selectedElements=h,e.events.selection.trigger(h),h?n.addItems(h):n.clean()}))}}return r})(),Hp=(()=>{class r extends At{_world;_fragments;set world(e){this._world=e,e&&this.getRenderer().postproduction.excludedObjectsPass.addExcludedMaterial(this._points.material)}get world(){return this._world}set fragments(e){this._fragments=e}styles=new ot.PG;outlinePositions=!1;_mesh=null;get _points(){return this._mesh||(this._mesh=new p.ONl(new p.LoY,new p.BH$({size:10,sizeAttenuation:!1,depthTest:!1}))),this._mesh}get enabled(){return!(!this.world||this.world.isDisposing)&&this.getRenderer().postproduction.outlinesEnabled}set enabled(e){this.world&&!this.world.isDisposing&&(this.getRenderer().postproduction.outlinesEnabled=e,this.outlinePositions&&(this._points.material.color=this.color,this.world.scene.three.add(this._points)))}get color(){return this.getRenderer().postproduction.outlinePass.outlineColor}set color(e){this.getRenderer().postproduction.outlinePass.outlineColor.copy(e),this._points.material.color.copy(e)}get thickness(){return this.getRenderer().postproduction.outlinePass.thickness}set thickness(e){this.getRenderer().postproduction.outlinePass.thickness=e}get fillColor(){return this.getRenderer().postproduction.outlinePass.fillColor}set fillColor(e){this.getRenderer().postproduction.outlinePass.fillColor.copy(e)}get fillOpacity(){return this.getRenderer().postproduction.outlinePass.fillOpacity}set fillOpacity(e){this.getRenderer().postproduction.outlinePass.fillOpacity=e}onDisposed=new Q;static uuid="2fd3bcc5-b3b6-4ded-9f64-f47a02854a10";_meshes=[];_map={};_activeStyles=new Set;constructor(e){super(e),e.add(r.uuid,this)}update(){var e=this;return(0,G.A)(function*(i=e._map){if(i===e._map&&e.cleanMeshes(),e.outlinePositions&&e.updatePoints(),0===Object.keys(i).length)return;const n=e.getRenderer().postproduction.outlinePass,a=yield e.components.get(Gl).get(i);for(const l of Object.keys(i)){const c=e._fragments?.models.list.get(l);if(c)for(const[,h]of a.entries()){const u=[...h.values()].flat();for(const f of u)f.position.set(0,0,0),f.rotation.set(0,0,0),f.scale.set(1,1,1),f.applyMatrix4(c.object.matrixWorld),e._meshes.push(f),n.scene.add(f)}}}).apply(this,arguments)}addItems(e){var i=this;return(0,G.A)(function*(){Rt.add(i._map,e),yield i.update(e)})()}removeItems(e){var i=this;return(0,G.A)(function*(){Rt.remove(i._map,e),yield i.update()})()}clean(){this._map={},this._activeStyles.clear(),this.cleanMeshes(),this._mesh&&this.components.get(bi).destroy(this._mesh,!0,!0),this._mesh=null}dispose(){this.styles.clear(),this.clean(),this.onDisposed.trigger(r.uuid)}cleanMeshes(){for(const e of this._meshes)e.removeFromParent();this._meshes=[]}updatePoints(){var e=this;return(0,G.A)(function*(){let i=0;for(const[,o]of Object.entries(e._map))i+=o.size;e._points.geometry.setAttribute("position",new p.qtW(new Float32Array(3*i),3));const n=yield e.components.get(ft).getPositions(e._map);for(let o=0;o<n.length;o++){const{x:a,y:l,z:c}=n[o];e._points.geometry.attributes.position.array[3*o]=a,e._points.geometry.attributes.position.array[3*o+1]=l,e._points.geometry.attributes.position.array[3*o+2]=c}e._points.geometry.attributes.position.needsUpdate=!0})()}getRenderer(){if(!this.world)throw new Error("You must set a world to use the outliner!");const e=this.world.renderer;if(!e.postproduction)throw new Error("The world given to the outliner must use the postproduction renderer.");return e}}return r})();var Yp=mt(893);function Zp(r){return Hr.apply(this,arguments)}function Hr(){return(Hr=(0,G.A)(function*(r){console.warn("Set double sided is not implemented"),console.log(r)})).apply(this,arguments)}function qr(){return(qr=(0,G.A)(function*(r){try{const t=new URL(r,window.location.href);if(t.origin===window.location.origin)return r;const e=yield fetch(t.href);if(!e.ok)throw new Error(`HTTP ${e.status}`);const i=yield e.text(),s=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(s)}catch(t){return console.warn("[BIM] Could not fetch worker as blob, using direct URL:",t),r}})).apply(this,arguments)}const Xp=(r,t,e="./js/worker.mjs")=>{const i=new ot._i(e),s=r.get(Yl);return s.fragments=i,s.world=t,t.camera.controls.addEventListener("rest",()=>i.update(!0)),t.camera.controls.addEventListener("update",()=>i.update()),i.models.list.onItemSet.add(function(){var n=(0,G.A)(function*({value:o}){const a=o.object.userData.overrides;o.useCamera(t.camera.three),t.scene.three.add(o.object),ec(a)&&(o.object.visible=!1,yield Qp(1),yield s.applyModelOverrides(o,a),o.object.visible=!0),yield i.update(!0),o.object.visible=!0,ec(a)||(yield s.applyModelOverrides(o,a),yield i.update(!0)),yield i.update(!0)});return function(o){return n.apply(this,arguments)}}()),t.onCameraChanged.add(n=>{for(const[,o]of i.models.list)o.useCamera(n.three);i.update(!0)}),i},Kp=function(){var r=(0,G.A)(function*(t,e,i){void 0===i&&(i=tc(t));const s=e.map(a=>a.id),n=e.filter(a=>!i.includes(a.id)).filter(a=>!0===a.visible),o=i.filter(a=>!s.includes(a));return n.length&&(console.info(`Loading ${n.length} model(s)`),yield Ql(t,n)),o.length&&(console.info(`Disposing ${n.length} model(s)`),yield Jl(t,o)),[...t.models.list.values()]});return function(e,i,s){return r.apply(this,arguments)}}(),Ql=function(){var r=(0,G.A)(function*(t,e){const i=[];for(const s of e)try{console.info(`Loading ${s.name} (${s.id})...`);const o=yield(yield fetch(s.fileURL)).arrayBuffer();console.info("Got model buffer...");const a=yield t.load(o,{modelId:s.id,userData:{overrides:s.overrides}});console.info("Model loaded into fragments..."),s.makeAllMaterialsDoubleSided&&(yield Zp(a)),yield t.update(),i.push(a),s.visible=!0,console.info(`\u2705 ${s.name} (${s.id}) loaded`)}catch(n){console.error(`\u274c Error loading model ${s.name} (${s.id}): `,n)}return i});return function(e,i){return r.apply(this,arguments)}}(),Jl=function(){var r=(0,G.A)(function*(t,e){void 0===e&&(e=tc(t));const i=[];for(const s of e)i.push(t.disposeModel(s));yield Promise.all(i)});return function(e,i){return r.apply(this,arguments)}}(),tc=r=>[...r.models?.list.values()].map(i=>i.modelId),ec=r=>!(!r.isolated.length&&!r.isolatedTypes.length),Qp=function(){var r=(0,G.A)(function*(t){return new Promise(e=>setTimeout(()=>e(),t))});return function(e){return r.apply(this,arguments)}}(),Jp={"#e2f552":"accent","#2859e1":"primary","#1744c2":"secondary","#ffffff":"default","#8394b0":"fade"},tm={accent:new p.Q1f("#2859e1"),primary:new p.Q1f("#1744c2"),secondary:new p.Q1f("#2859e1"),default:new p.Q1f("#e2f552"),fade:new p.Q1f("#e2f552")},em={accent:new p.Q1f("#e2f552"),primary:new p.Q1f("#1744c2"),secondary:new p.Q1f("#1744c2"),default:new p.Q1f("#1744c2"),fade:new p.Q1f("#1744c2")},im={accent:new p.Q1f("#2859e1"),primary:new p.Q1f("#e2f552"),secondary:new p.Q1f("#e2f552"),default:new p.Q1f("#e2f552"),fade:new p.Q1f("#e2f552")},nm=r=>{const t=new p.Q1f(r),i=.299*t.r+.587*t.g+.114*t.b>.5?.75:1.25;return new p.Q1f(Math.min(t.r*i,1),Math.min(t.g*i,1),Math.min(t.b*i,1))};function rm(r){let t="";return t=r.LongName?.value?r.LongName.value:r.Name?.value?r.Name.value:r.type||"(no name)",`${t} [${r._category.value}]`}function ic(r,t,e){return Gr.apply(this,arguments)}function Gr(){return(Gr=(0,G.A)(function*(r,t,e){console.log(t);const i=yield r.getItemsData(t,{relations:{Decomposes:{attributes:!0,relations:!0}}});console.log(i),void 0===e.children&&(e.children=[]);for(const s of i){const n=[];for(const o of s.Decomposes||[]){const a=o._localId.value,l=yield r.getItemsData([a],{relations:{IsDecomposedBy:{attributes:!0,relations:!0}}});console.log(l);const c={id:a,label:rm(o)};yield ic(r,[a],c),n.push(c)}e.children.push(...n)}})).apply(this,arguments)}function Yr(){return(Yr=(0,G.A)(function*(r,t){const e=yield r.getItemsOfCategories([/IFCSITE/]),i={label:t,children:[]};yield ic(r,e.IFCSITE,i),console.log(i)})).apply(this,arguments)}let Zr=(()=>{class r{_workerUrl=(0,st.WQX)(Yp.g);_resolvedWorkerUrl=(0,st.vPA)(void 0);_container=(0,st.vPA)(void 0);modelsAreLoading=(0,st.vPA)(!1);settings=(0,st.vPA)(new $i.R_);_previousHighlights=null;raycastResult=(0,st.vPA)(null);hoveredElement=(0,Ot.EW)(()=>{const e=this.raycastResult()?.localId??null,i=this.raycastResult()?.fragments.modelId??null;return i&&e?{[i]:new Set([e])}:null},{equal:(e,i)=>((r,t)=>{if(!r&&!t)return!0;if(!r||!t)return!1;const e=Object.keys(r),i=Object.keys(t);if(e.length!==i.length||e[0]!==i[0])return!1;const s=r[e[0]],n=t[i[0]];if(s.size!==n.size)return!1;const o=Array.from(s.values()),a=Array.from(n.values());return o[0]===a[0]})(e,i)});clickedElement=(0,st.vPA)(null);selectedElements=(0,st.vPA)(null);init(e){this._container.set(e)}_colorDef=(0,Ot.EW)(()=>{const e=this._container();if(e)return(r=>{const e=window.getComputedStyle(r).getPropertyValue("--background-color"),i=Jp[e];return{hoverColor:tm[i]??new p.Q1f("#e2f552"),selectionColor:em[i]??new p.Q1f("#1744c2"),selectionOutlineColor:im[i]??new p.Q1f("#e2f552"),ghostColor:nm(e)}})(e)});_loadedModels=(0,st.vPA)([]);_components=(0,Ot.EW)(()=>{if(void 0!==this._container())return console.info("Building components..."),new Ar});_world=(0,Ot.EW)(()=>{const e=this._components(),i=this._container();if(void 0!==e&&void 0!==i)return console.info("Setting up scene..."),((r,t)=>{const i=r.get(an).create();i.scene=new al(r),i.scene.setup(),i.scene.three.background=null,i.renderer=new jr.Hs(r,t);const{postproduction:s}=i.renderer;return i.camera=new ln(r),r.init(),i.scene.setup(),s.enabled=!0,i.scene.three.background=null,i.camera.controls.restThreshold=.25,i})(e,i)});_fragments=(0,Ot.EW)(()=>{const e=this._world();if(void 0===e)return;const i=this._components();if(void 0===i)return;const s=this._resolvedWorkerUrl();return void 0!==s?(console.info("Setting up fragments..."),Xp(i,e,s)):void 0});viewerReady=(0,Ot.EW)(()=>!(void 0===this._components()||void 0===this._world()||void 0===this._fragments()));get loadedModels(){return this._loadedModels}constructor(){(function Wp(r){return qr.apply(this,arguments)})(this._workerUrl).then(e=>this._resolvedWorkerUrl.set(e)),(0,st.QZP)(()=>{this.viewerReady()&&(console.info("Initializing event listeners..."),this._initEventListeners(),console.info("BIM Fragments Viewer is ready"))}),(0,st.QZP)(()=>{const e=this.settings(),i=this._world(),s=this._components(),n=this._fragments(),o=this._colorDef();void 0===e||void 0===i||void 0===s||void 0===n||void 0===o||this.viewerReady()&&(((r,t,e,i,s)=>{e.dynamicAnchor=r.dynamicAnchor;const n=e.renderer?.postproduction;if(n&&(n.enabled=r.postProductionSettings.enabled,n.style=r.postProductionSettings.style),r.clickEnabled){const o=t.get($r);o.world=e,o.fragments=i,o.enabled=!0,o.material=new p.V9B({color:s.hoverColor,transparent:!0,opacity:.5,depthTest:!1});const a=t.get(Hp);a.world=e,a.fragments=i,a.enabled=!0;const l=t.get(Kl);l.enabled=!0,l.fragments=i,l.multiSelect=r.multiSelect,l.styles={fillColor:s.selectionColor,outlineColor:s.selectionOutlineColor,fillOpacity:.5}}if(r.applyGhosting){const o=t.get(Ur);o.enabled=!0,o.ghostColor=s.ghostColor,o.fragments=i,o.world=e}console.info("Settings updated")})(e,s,i,n,o),console.info("Settings updated"))})}dispose(){var e=this;return(0,G.A)(function*(){yield e.disposeModels()})()}loadFragmentFiles(e){var i=this;return(0,G.A)(function*(){console.log("LOAD FRAGMENTS");const s=i._fragments();if(void 0===s)throw new Error("Fragments not available");i.modelsAreLoading.set(!0);const n=yield Ql(s,e);i._loadedModels.update(()=>[...n]),console.log("YYY"),console.log(n),i.modelsAreLoading.set(!1)})()}disposeModels(e){var i=this;return(0,G.A)(function*(){const s=e?e.map(o=>o.id):void 0,n=i._fragments();if(void 0===n)throw new Error("Fragments not available");yield Jl(n,s),void 0!==e&&e.forEach(o=>o.visible=!1)})()}updateModels(e){var i=this;return(0,G.A)(function*(){const s=i._fragments();if(void 0===s)throw new Error("Fragments not available");const n=yield Kp(s,e);i._loadedModels.update(()=>[...n])})()}getSpatialStructure(e){var i=this;return(0,G.A)(function*(){const s=i._fragments()?.models.list.get(e.id);return void 0!==s&&function om(r,t){Yr.apply(this,arguments)}(s,e.name),s?.getSpatialStructure()})()}updateAspectRatio(){this._world()?.renderer?.resize(),this._world()?.camera.updateAspect()}_initEventListeners(){var e=this;const i=this._components().get(Kl);i.events.clickedElement.add(n=>{const o=this.hoveredElement();null!==o&&this.clickedElement.update(()=>({itemData:n,element:o}))}),i.events.clickedCanvas.add(()=>{this.clickedElement.update(()=>null)}),i.events.selection.add(n=>{this.selectedElements.update(()=>n)}),this._components().get($r).events.hoveredElement.add(function(){var n=(0,G.A)(function*(o){e.raycastResult.update(()=>o)});return function(o){return n.apply(this,arguments)}}()),this._fragments().models.list.onItemSet.add(()=>{})}static \u0275fac=function(i){return new(i||r)};static \u0275prov=st.jDH({token:r,factory:r.\u0275fac,providedIn:"root"})}return r})();var am=mt(7023),lm=mt(5970),Ri=mt(5381),Wr=mt(5187),un=mt(5971),Xr=mt(3319),b=mt(5547);function cm(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-flexcontainer",3)(1,"cue-button",5),b.bIt("click",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.zoomOut())}),b.nrm(2,"cue-button-icon",6),b.k0s(),b.j41(3,"cue-button",5),b.bIt("click",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.zoomIn())}),b.nrm(4,"cue-button-icon",7),b.k0s(),b.j41(5,"cue-button",5),b.bIt("click",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.zoomFit())}),b.nrm(6,"cue-button-icon",8),b.k0s()()}}function hm(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-button",5),b.bIt("click",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.toggleLayersVisible())}),b.nrm(1,"cue-button-icon",9),b.k0s()}if(2&r){const e=b.XpG();b.AVh("border-left",e.options().displayZoom&&e.displayDecompositionTree())}}let um=(()=>{class r{settings=(0,Tt.hFB)(new $i.R_);options=(0,Ot.EW)(()=>this.settings().toolbar);selectMenuPositions=(0,Ot.EW)(()=>"top"===this.options().position?"bottomleft":"topleft");displayDecompositionTree=(0,Ot.EW)(()=>void 0!==this.options().displayDecompositionTree);zoomIn(){}zoomOut(){}zoomFit(){}toggleLayersVisible(){}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-bim-fragments-toolbar"]],inputs:{settings:[1,"settings"]},decls:5,vars:3,consts:[["align","center",1,"container"],[1,"toolbar",3,"padded"],["align","center"],["align","center","gap","s"],["size","xs","variant","tertiary",3,"border-left"],["size","xs","variant","tertiary",3,"click"],["icon","zoom-out"],["icon","zoom-in"],["icon","zoom-fit"],["icon","tree"]],template:function(i,s){1&i&&(b.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),b.nVh(3,cm,7,0,"cue-flexcontainer",3),b.nVh(4,hm,2,2,"cue-button",4),b.k0s()()()),2&i&&(b.R7$(),b.Y8G("padded",!1),b.R7$(2),b.vxM(s.options().displayZoom?3:-1),b.R7$(),b.vxM(s.displayDecompositionTree()?4:-1))},dependencies:[Ri.n,Wr.Card,un.$,Xr.a],styles:[".container[_ngcontent-%COMP%]{height:100%;pointer-events:none}.toolbar[_ngcontent-%COMP%]{pointer-events:all;padding:5px 10px}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return r})();var dm=mt(9421),fm=mt(1024),dn=mt(2245);function pm(r,t){if(1&r&&b.nrm(0,"cue-key-val",3),2&r){const e=b.XpG();b.Y8G("val",e.name)}}function mm(r,t){if(1&r&&b.nrm(0,"cue-key-val",5),2&r){const e=t.$implicit;b.Y8G("key",e.label)("val",e.value)}}function gm(r,t){if(1&r&&(b.j41(0,"cue-typography",4),b.EFF(1),b.k0s(),b.j41(2,"cue-key-val-list"),b.Z7z(3,mm,1,2,"cue-key-val",5,b.Vm6),b.k0s()),2&r){const e=t.$implicit;b.R7$(),b.JRh(e.psetName),b.R7$(2),b.Dyx(e.props)}}function _m(r,t){if(1&r&&b.Z7z(0,gm,5,1,null,null,b.Vm6),2&r){const e=b.XpG();b.Dyx(e.psets)}}function ym(r,t){if(1&r&&(b.nVh(0,pm,1,1,"cue-key-val",3),b.nVh(1,_m,2,0)),2&r){const e=t;b.vxM(e.name?0:-1),b.R7$(),b.vxM(e.psets.length>0?1:-1)}}function wm(r,t){if(1&r&&(b.j41(0,"cue-card",1)(1,"cue-flexcontainer",2),b.nVh(2,ym,2,2),b.k0s()()),2&r){let e;const i=b.XpG();b.Y8G("padded",!1)("scrollable",!0),b.R7$(2),b.vxM((e=i.props())?2:-1,e)}}function vm(r,t){if(1&r&&b.nrm(0,"cue-key-val",3),2&r){const e=b.XpG();b.Y8G("val",e.name)}}function bm(r,t){if(1&r&&b.nrm(0,"cue-key-val",5),2&r){const e=t.$implicit;b.Y8G("key",e.label)("val",e.value)}}function xm(r,t){if(1&r&&(b.j41(0,"cue-typography",4),b.EFF(1),b.k0s(),b.j41(2,"cue-key-val-list"),b.Z7z(3,bm,1,2,"cue-key-val",5,b.Vm6),b.k0s()),2&r){const e=t.$implicit;b.R7$(),b.JRh(e.psetName),b.R7$(2),b.Dyx(e.props)}}function Cm(r,t){if(1&r&&b.Z7z(0,xm,5,1,null,null,b.Vm6),2&r){const e=b.XpG();b.Dyx(e.psets)}}function Tm(r,t){if(1&r&&(b.nVh(0,vm,1,1,"cue-key-val",3),b.nVh(1,Cm,2,0)),2&r){const e=t;b.vxM(e.name?0:-1),b.R7$(),b.vxM(e.psets.length>0?1:-1)}}function Pm(r,t){if(1&r&&(b.j41(0,"cue-flexcontainer",2),b.nVh(1,Tm,2,2),b.k0s()),2&r){let e;const i=b.XpG();b.R7$(),b.vxM((e=i.props())?1:-1,e)}}let Sm=(()=>{class r{element=Tt.hFB.required();wrapInCard=(0,Tt.hFB)(!0);props=(0,Ot.EW)(()=>{const e=this.element().itemData,i=this.formatItemPsets(e.IsDefinedBy||[]);return{name:e.Name?.value||"No name",psets:i}});formatItemPsets(e){const i=[];for(const[,s]of e.entries()){const{Name:n,HasProperties:o}=s;if(!("value"in n)||!Array.isArray(o))continue;const a=[];for(const[,l]of o.entries()){const{Name:c,NominalValue:h}=l;if(!("value"in c)||!("value"in h))continue;const u=c.value,f=h.value;u&&void 0!==f&&a.push({label:u,value:f.toString()})}i.push({psetName:n.value,props:a})}return i}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-bim-fragments-props-viewer"]],inputs:{element:[1,"element"],wrapInCard:[1,"wrapInCard"]},decls:3,vars:1,consts:[["direction","column","justify","start",1,"container"],[1,"card",3,"padded","scrollable"],["align","start","direction","column"],["key","Name",3,"val"],["size","s","weight","semibold"],[3,"key","val"]],template:function(i,s){1&i&&(b.j41(0,"cue-flexcontainer",0),b.nVh(1,wm,3,3,"cue-card",1)(2,Pm,2,1,"cue-flexcontainer",2),b.k0s()),2&i&&(b.R7$(),b.vxM(s.wrapInCard()?1:2))},dependencies:[Ri.n,Wr.Card,dm.F,fm.p,dn.Typography],styles:[".container[_ngcontent-%COMP%]{height:100%;pointer-events:none}.card[_ngcontent-%COMP%]{pointer-events:all;max-height:100%;width:300px;flex:1 1}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return r})();var sc=mt(9769);let Em=(()=>{class r{selectedItem=(0,st.vPA)(void 0);static \u0275fac=function(i){return new(i||r)};static \u0275prov=st.jDH({token:r,factory:r.\u0275fac,providedIn:"root"})}return r})();var nc=mt(7089),Am=mt(5448),rc=mt(6117),Kr=mt(356),Qr=mt(6279);const oc=(r,t)=>t.path;function Mm(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-menu-item",7),b.bIt("click",function(s){const n=st.eBV(e).$implicit,o=b.XpG(2);return st.Njj(o.navigateTo(s,n.path))}),b.EFF(1),b.k0s()}if(2&r){const e=t.$implicit;b.R7$(),b.SpI(" ",e.name," ")}}function Im(r,t){if(1&r&&(b.j41(0,"cue-flexcontainer",2)(1,"cue-menu")(2,"cue-button",4,0)(4,"cue-button-label"),b.EFF(5,"..."),b.k0s()(),b.j41(6,"cue-menu-wrap",5),b.Z7z(7,Mm,2,1,"cue-menu-item",null,oc),b.k0s()(),b.j41(9,"cue-typography",6),b.EFF(10," \u203a "),b.k0s()()),2&r){const e=b.XpG();b.R7$(2),b.Y8G("size",e.buttonSize())("cueTooltip",e.hiddenPartsTooltip()),b.R7$(5),b.Dyx(e.hidddenParts()),b.R7$(2),b.Y8G("size",e.size())}}function Om(r,t){if(1&r&&(b.j41(0,"cue-typography",6),b.EFF(1," \u203a "),b.k0s()),2&r){const e=b.XpG(2);b.Y8G("size",e.size())}}function zm(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-flexcontainer",8),b.bIt("click",function(s){const n=st.eBV(e),o=n.$implicit,a=n.$index,l=n.$count,c=b.XpG();return st.Njj(a!==l-1&&!c.buttonMode()&&c.navigateTo(s,o.path))}),b.j41(1,"cue-typography",9),b.EFF(2),b.k0s(),b.nVh(3,Om,2,1,"cue-typography",6),b.k0s()}if(2&r){const e=t.$implicit,i=t.$index,s=t.$count,n=b.XpG();b.AVh("clickable",i!==s-1&&n.updatePathOnClick()&&!n.buttonMode()),b.R7$(),b.AVh("full-length",n.nameFullLength()),b.Y8G("size",n.size())("weight",i===s-1?"medium":"regular")("title",e.name),b.R7$(),b.SpI(" ",e.name," "),b.R7$(),b.vxM(i!==s-1?3:-1)}}let Dm=(()=>{class r{path=Tt.geq.required();size=(0,Tt.hFB)("xs");rootName=(0,Tt.hFB)(null);maxVisibleParts=(0,Tt.hFB)(3);nameFullLength=(0,Tt.hFB)(!1);updatePathOnClick=(0,Tt.hFB)(!0);buttonMode=(0,Tt.hFB)(!1);buttonSize=(0,Ot.EW)(()=>{switch(this.size()){case"xs":case"s":default:return"s";case"m":case"l":case"xl":return"m"}});get sizeAttribute(){return this.size()}get buttonModeClass(){return this.buttonMode()}onHostClick(e){this.buttonMode()&&(e.stopPropagation(),this.clickedPath.emit(this.path()))}pathChange=(0,Tt.CGW)();clickedPath=(0,Tt.CGW)();allBreadcrumbParts=(0,Ot.EW)(()=>{const e=this.path().split("/").filter(o=>""!==o),i=[],s=this.rootName();null!==s&&i.push({name:s,path:"/"});let n="";for(const o of e)n+=`/${o}`,i.push({name:o,path:n.endsWith("/")?n:`${n}/`});return i});shouldShowEllipsis=(0,Ot.EW)(()=>this.allBreadcrumbParts().length>this.maxVisibleParts());visibleBreadcrumbParts=(0,Ot.EW)(()=>{const e=this.allBreadcrumbParts(),i=this.maxVisibleParts();return e.length<=i?e:e.slice(-i)});hidddenParts=(0,Ot.EW)(()=>{const e=this.allBreadcrumbParts(),i=this.maxVisibleParts();return e.length<=i?[]:e.slice(0,-i)});hiddenPartsTooltip=(0,Ot.EW)(()=>{const e=this.hidddenParts();return 0===e.length?"":`${e.map(i=>i.name).join(" \u203a ")}`});navigateTo(e,i){console.log("Navigating to:",i),e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault(),this.clickedPath.emit(i),this.updatePathOnClick()&&(this.path.set(i),this.pathChange.emit(i))}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-breadcrumb"]],hostVars:3,hostBindings:function(i,s){1&i&&b.bIt("click",function(o){return s.onHostClick(o)}),2&i&&(b.BMQ("size",s.sizeAttribute),b.AVh("button-mode",s.buttonModeClass))},inputs:{path:[1,"path"],size:[1,"size"],rootName:[1,"rootName"],maxVisibleParts:[1,"maxVisibleParts"],nameFullLength:[1,"nameFullLength"],updatePathOnClick:[1,"updatePathOnClick"],buttonMode:[1,"buttonMode"]},outputs:{path:"pathChange",pathChange:"pathChange",clickedPath:"clickedPath"},decls:4,vars:1,consts:[["trigger",""],["direction","row","gap","s","align","center"],["direction","row","gap","s","align","center",1,"ellipsis-container"],["direction","row","gap","s",3,"clickable"],["trigger","","variant","ghost",3,"size","cueTooltip"],["menu",""],["weight","semibold",3,"size"],[3,"click"],["direction","row","gap","s",3,"click"],[1,"breadcrumb-text",3,"size","weight","title"]],template:function(i,s){1&i&&(b.j41(0,"cue-flexcontainer",1),b.nVh(1,Im,11,3,"cue-flexcontainer",2),b.Z7z(2,zm,4,9,"cue-flexcontainer",3,oc),b.k0s()),2&i&&(b.R7$(),b.vxM(s.shouldShowEllipsis()?1:-1),b.R7$(),b.Dyx(s.visibleBreadcrumbParts()))},dependencies:[sc.MD,dn.Typography,Ri.n,un.$,Am.L,nc.d,rc.W,Kr.M,Qr.D],styles:['.clickable[_ngcontent-%COMP%]{cursor:pointer}.clickable[_ngcontent-%COMP%]:hover{text-decoration:underline}.separator[_ngcontent-%COMP%]{color:#666;padding:0 4px}.full-length[_ngcontent-%COMP%]{max-width:none!important}.full-length[_ngcontent-%COMP%] > div[_ngcontent-%COMP%]{max-width:none!important;overflow:visible!important;text-overflow:unset!important;white-space:normal!important}.breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block}.breadcrumb-text[_ngcontent-%COMP%]:not(.full-length) > div[_ngcontent-%COMP%]{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ellipsis-container[_ngcontent-%COMP%]{cursor:default;display:flex;align-items:center}.ellipsis-text[_ngcontent-%COMP%]{color:#666;font-style:italic;line-height:1;display:flex;align-items:center;text-align:center;vertical-align:middle;justify-content:center;height:100%;min-height:1em}.ellipsis-text[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{display:inline-block!important}.ellipsis-text[_ngcontent-%COMP%] *{display:flex!important;align-items:center!important;justify-content:center!important;height:100%!important;line-height:1!important}.button-mode[_nghost-%COMP%]{cursor:pointer}[size="xs"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:70px}[size="s"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:80px}[size="m"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:100px}[size="l"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:120px}[size="xl"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:150px}']})}return r})();var km=mt(29);const Lm=()=>[],Nm=()=>({}),Bm=(r,t)=>t.label;function Rm(r,t){if(1&r&&b.nrm(0,"cue-svg-icon",17),2&r){const e=b.XpG().$implicit;b.Y8G("name",e.icon)}}function Fm(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-menu-item",16),b.bIt("click",function(){const s=st.eBV(e).$implicit;return st.Njj(s.action())}),b.nVh(1,Rm,1,1,"cue-svg-icon",17),b.EFF(2),b.k0s()}if(2&r){const e=t.$implicit;b.Y8G("tooltip",e.tooltip??""),b.R7$(),b.vxM(e.icon?1:-1),b.R7$(),b.SpI(" ",e.label," ")}}function Vm(r,t){if(1&r&&(b.j41(0,"cue-menu",11),b.bIt("click",function(i){return i.stopPropagation()}),b.j41(1,"cue-button",12),b.nrm(2,"cue-button-icon",13),b.k0s(),b.j41(3,"cue-menu-wrap",14),b.Z7z(4,Fm,3,3,"cue-menu-item",15,Bm),b.k0s()()),2&r){const e=b.XpG().$implicit;b.R7$(),b.Y8G("cueTooltip",e.tooltip??""),b.R7$(),b.Y8G("icon",e.icon),b.R7$(2),b.Dyx(e.menuItems)}}function Um(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-button",18),b.bIt("click",function(s){return st.eBV(e),b.XpG().$implicit.action(),st.Njj(s.stopPropagation())}),b.nrm(1,"cue-button-icon",13),b.k0s()}if(2&r){const e=b.XpG().$implicit;b.Y8G("cueTooltip",e.tooltip??""),b.R7$(),b.Y8G("icon",e.icon)}}function $m(r,t){if(1&r&&b.nVh(0,Vm,6,2,"cue-menu")(1,Um,2,2,"cue-button",10),2&r){const e=t.$implicit;b.vxM(null!=e.menuItems&&e.menuItems.length?0:e.action?1:-1)}}function jm(r,t){if(1&r&&(b.j41(0,"cue-flexcontainer",3),b.Z7z(1,$m,2,1,null,null,b.Vm6),b.k0s()),2&r){const e=b.XpG().$implicit;b.R7$(),b.Dyx(e.buttons)}}function Hm(r,t){if(1&r&&(b.j41(0,"span",22),b.EFF(1),b.k0s()),2&r){const e=b.XpG(2).$implicit,i=b.XpG();b.AVh("checked",i.isSelected(e)),b.R7$(),b.SpI(" ",i.isSelected(e)?"\u2611":"\u2610"," ")}}function qm(r,t){if(1&r&&(b.j41(0,"cue-typography",21),b.EFF(1),b.k0s()),2&r){const e=b.XpG(2).$implicit;b.R7$(),b.JRh(e.subLabel)}}function Gm(r,t){if(1&r&&(b.j41(0,"div",4),b.nVh(1,Hm,2,3,"span",19),b.j41(2,"cue-typography",20),b.EFF(3),b.k0s(),b.nVh(4,qm,2,1,"cue-typography",21),b.k0s()),2&r){const e=b.XpG().$implicit,i=b.XpG();b.R7$(),b.vxM(i.multiSelect()&&!i.hasChildren(e)?1:-1),b.R7$(),b.Y8G("weight",i.isSelected(e)?"semibold":"regular")("size",i.size()),b.R7$(),b.JRh(e.label),b.R7$(),b.vxM(e.subLabel?4:-1)}}function Ym(r,t){if(1&r&&b.nrm(0,"cue-breadcrumb",6),2&r){const e=b.XpG().$implicit,i=b.XpG();b.Y8G("maxVisibleParts",5)("path",e.label)("size",i.size())("nameFullLength",!0)("updatePathOnClick",!1)}}function Zm(r,t){if(1&r&&b.nrm(0,"cue-svg-icon",23),2&r){const e=b.XpG().$implicit,i=b.XpG();b.AVh("expanded",i.isExpanded(e))}}function Wm(r,t){if(1&r&&(b.j41(0,"div",8),b.nrm(1,"cue-tree-menu",24),b.k0s()),2&r){const e=b.XpG().$implicit,i=b.XpG();b.R7$(),b.Y8G("items",e.children||b.lJ4(2,Lm))("size",i.size())}}function Xm(r,t){if(1&r&&(b.j41(0,"div",25),b.bIt("click",function(i){return i.stopPropagation()}),b.eu8(1,26),b.k0s()),2&r){const e=b.XpG().$implicit;b.R7$(),b.Y8G("ngTemplateOutlet",e.contentTemplate)("ngTemplateOutletContext",e.templateContext??b.lJ4(2,Nm))}}function Km(r,t){if(1&r){const e=b.RV6();b.j41(0,"li",1)(1,"cue-flexcontainer",2),b.bIt("click",function(){const s=st.eBV(e).$implicit,n=b.XpG();return st.Njj(n.handleItemClick(s))}),b.nVh(2,jm,3,0,"cue-flexcontainer",3),b.nVh(3,Gm,5,5,"div",4),b.nrm(4,"span",5),b.nVh(5,Ym,1,5,"cue-breadcrumb",6),b.nVh(6,Zm,1,2,"cue-svg-icon",7),b.k0s(),b.nVh(7,Wm,2,3,"div",8),b.nVh(8,Xm,2,3,"div",9),b.k0s()}if(2&r){const e=t.$implicit,i=b.XpG();b.R7$(),b.AVh("has-children",i.hasChildren(e)),b.R7$(),b.vxM(null!=e.buttons&&e.buttons.length?2:-1),b.R7$(),b.vxM(void 0===e.type||"text"===e.type?3:-1),b.R7$(2),b.vxM("breadcrumb"===e.type?5:-1),b.R7$(),b.vxM(i.hasChildren(e)?6:-1),b.R7$(),b.vxM(i.hasChildren(e)&&i.isExpanded(e)?7:-1),b.R7$(),b.vxM(e.contentTemplate?8:-1)}}let Qm=(()=>{class r{_service=(0,st.WQX)(Em);items=(0,Tt.geq)([]);size=(0,Tt.hFB)("m");collapseOnSelect=(0,Tt.hFB)(!1);initialExpandDepth=(0,Tt.hFB)(-1);multiSelect=(0,Tt.hFB)(!1);expandedItems=new Set;_multiSelectedIds=(0,st.vPA)(new Set);selectionChanged=(0,Tt.CGW)();multiSelectionChanged=(0,Tt.CGW)();onItemsChange=(0,st.QZP)(()=>{this.multiSelect()?(this._syncMultiSelectedFromItems(),this._doInitialExpand()):this.collapseOnSelect()||this._initialExpandSelected()});onSelectionChange=(0,st.QZP)(()=>{const e=this._service.selectedItem();void 0!==e&&this.selectionChanged.emit(e)});ngOnDestroy(){this.items.update(()=>[])}handleItemClick(e){if(this.hasChildren(e)){const i=e.id??e.label;if(this.expandedItems.has(i)?this.expandedItems.delete(i):this.expandedItems.add(i),!this.multiSelect()){const s=this._service.selectedItem();void 0!==s&&(s.selected=!1),e.selected=!0,this._service.selectedItem.set(e)}}else if(this.multiSelect()){const i=e.id??e.label;this._multiSelectedIds.update(s=>{const n=new Set(s);return n.has(i)?n.delete(i):n.add(i),n}),this.multiSelectionChanged.emit([...this._multiSelectedIds()])}else this._setSelected(e),this._update()}hasChildren(e){return!!e.children&&e.children.length>0}isExpanded(e){return this.expandedItems.has(e.id??e.label)}isSelected(e){return this.multiSelect()?this._multiSelectedIds().has(e.id??e.label):e.selected}_setSelected(e){const i=this._service.selectedItem();void 0!==i&&(i.selected=!1),e.selected=!0}_update(){this.items.update(()=>[...this.items()])}_syncMultiSelectedFromItems(){const e=new Set,i=s=>{for(const n of s)n.selected&&e.add(n.id??n.label),n.children?.length&&i(n.children)};i(this.items()??[]),this._multiSelectedIds.set(e)}_doInitialExpand(){this.expandedItems.clear();const e=this.initialExpandDepth(),i=(s,n=0)=>{for(const o of s)e>=0&&n<=e&&this.hasChildren(o)&&this.expandedItems.add(o.id??o.label),o.children?.length&&i(o.children,n+1)};i(this.items()??[])}_initialExpandSelected(){this.expandedItems.clear();const e=this.initialExpandDepth(),i=(s,n=[],o=0)=>{for(const a of s){if(e>=0&&o<=e&&this.hasChildren(a)&&this.expandedItems.add(a.id??a.label),a.selected){this._service.selectedItem.set(a);for(const l of n)this.expandedItems.add(l.id??l.label)}a.children&&a.children.length>0&&i(a.children,[...n,a],o+1)}};i(this.items()??[])}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-tree-menu"]],inputs:{items:[1,"items"],size:[1,"size"],collapseOnSelect:[1,"collapseOnSelect"],initialExpandDepth:[1,"initialExpandDepth"],multiSelect:[1,"multiSelect"]},outputs:{items:"itemsChange",selectionChanged:"selectionChanged",multiSelectionChanged:"multiSelectionChanged"},decls:3,vars:0,consts:[[1,"menu"],[1,"menu-item"],["justify","start","align","center","gap","s",1,"menu-item-header",3,"click"],["gap","s","align","center"],[2,"display","flex","flex-direction","row","align-items","baseline","gap","6px"],[2,"flex","1"],[3,"maxVisibleParts","path","size","nameFullLength","updatePathOnClick"],["name","arrow-dropdown",1,"menu-item-arrow",3,"expanded"],[1,"submenu"],[1,"menu-item-content"],["size","xs","variant","ghost","tooltipPlacement","right",3,"cueTooltip"],[3,"click"],["trigger","","size","xs","variant","ghost","tooltipPlacement","right",3,"cueTooltip"],[3,"icon"],["menu",""],[3,"tooltip"],[3,"click","tooltip"],["before","",3,"name"],["size","xs","variant","ghost","tooltipPlacement","right",3,"click","cueTooltip"],[1,"multi-check",3,"checked"],[3,"weight","size"],["size","xs",2,"opacity","0.6"],[1,"multi-check"],["name","arrow-dropdown",1,"menu-item-arrow"],[3,"items","size"],[1,"menu-item-content",3,"click"],[3,"ngTemplateOutlet","ngTemplateOutletContext"]],template:function(i,s){1&i&&(b.j41(0,"ul",0),b.Z7z(1,Km,9,8,"li",1,b.Vm6),b.k0s()),2&i&&(b.R7$(),b.Dyx(s.items()))},dependencies:[r,dn.Typography,Ri.n,Dm,un.$,Xr.a,km.A,nc.d,sc.T3,rc.W,Qr.D,Kr.M],styles:[".menu[_ngcontent-%COMP%]{list-style:none;padding:0;margin:0}.menu-item[_ngcontent-%COMP%]{cursor:pointer;-webkit-user-select:none;user-select:none}.menu-item-header[_ngcontent-%COMP%]{padding:8px 16px;transition:background-color .2s}.menu-item-header[_ngcontent-%COMP%]:hover{background-color:var(--cue-color-green);color:var(--cue-color-black)}.menu-item-header[_ngcontent-%COMP%]:hover *{color:var(--cue-color-black);fill:var(--cue-color-black)}.menu-item-header.has-children[_ngcontent-%COMP%]{font-weight:700}.menu-item-arrow[_ngcontent-%COMP%]{transition:transform .2s;flex-shrink:0}.menu-item-arrow.expanded[_ngcontent-%COMP%]{transform:rotate(180deg)}.submenu[_ngcontent-%COMP%]{padding-left:16px;border-left:1px solid}.multi-check[_ngcontent-%COMP%]{font-size:14px;line-height:1;color:var(--cue-defaultContrast);opacity:.5;flex-shrink:0}.multi-check.checked[_ngcontent-%COMP%]{opacity:1;color:var(--cue-accent, #4f7fff)}"]})}return r})(),Jm=(()=>{class r{_service=(0,st.WQX)(Zr);type=(0,Tt.hFB)("spatial");models=Tt.geq.required();treeItems=(0,st.vPA)([]);constructor(){var e=this;(0,st.QZP)((0,G.A)(function*(){if(!e._service.loadedModels().length)return;console.log(e._service.loadedModels());const i=yield Promise.all(e.models().map(n=>e.getSpatialStructure(n)));console.log("Model Trees:",i);const s=[];e.models().forEach(n=>{s.push({label:n.name,buttons:[{icon:n.visible?"view-inactive":"view-active",action:()=>e.toggleVisibility(n)}]})}),e.treeItems.update(()=>[...s])}))}toggleVisibility(e){var i=this;return(0,G.A)(function*(){e.visible?(yield i._service.disposeModels([e]),console.log(`Model ${e.name} (${e.id}) disposed`)):yield i._service.loadFragmentFiles([e]),i.models.update(()=>[...i.models()])})()}getSpatialStructure(e){var i=this;return(0,G.A)(function*(){const s=yield i._service.getSpatialStructure(e);if(s)return{label:s.category,children:s.children?.map(n=>({label:n.name,children:n.children?.map(o=>({label:o.name}))}))}})()}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-bim-fragments-tree-viewer"]],inputs:{type:[1,"type"],models:[1,"models"]},outputs:{models:"modelsChange"},decls:1,vars:1,consts:[["size","s",3,"items"]],template:function(i,s){1&i&&b.nrm(0,"cue-tree-menu",0),2&i&&b.Y8G("items",s.treeItems())},dependencies:[Qm],styles:[".container[_ngcontent-%COMP%]{height:100%;pointer-events:none}.card[_ngcontent-%COMP%]{pointer-events:all;max-height:100%;width:300px;flex:1 1}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return r})();var tg=mt(6034),eg=mt(4613);const ac=(r,t)=>t.id;function ig(r,t){1&r&&b.nrm(0,"cue-logo",4),2&r&&b.Y8G("active",!0)("continuous",!0)}function sg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-typography",6),b.EFF(1),b.k0s(),b.j41(2,"cue-button",7),b.bIt("click",function(){const s=st.eBV(e).$implicit,n=b.XpG(3);return st.Njj(n.toggleVisibility(s))}),b.nrm(3,"cue-button-icon",8),b.k0s()}if(2&r){const e=t.$implicit;b.R7$(),b.JRh(e.name),b.R7$(2),b.Y8G("icon",e.visible?"view-inactive":"view-active")}}function ng(r,t){if(1&r&&(b.j41(0,"cue-flexcontainer",5),b.Z7z(1,sg,4,2,null,null,ac),b.k0s()),2&r){const e=b.XpG(2);b.R7$(),b.Dyx(e.models())}}function rg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-typography",3),b.EFF(1),b.k0s(),b.j41(2,"cue-bim-fragments-tree-viewer",9),b.mxI("modelsChange",function(s){st.eBV(e);const n=b.XpG(2);return b.DH7(n.models,s)||(n.models=s),st.Njj(s)}),b.k0s()}if(2&r){const e=b.XpG(2);b.R7$(),b.JRh(e.treeLabel()),b.R7$(),b.R50("models",e.models)}}function og(r,t){if(1&r&&(b.j41(0,"cue-draggable-card",0)(1,"cue-flexcontainer",1)(2,"cue-flexcontainer",2)(3,"cue-typography",3),b.EFF(4,"Models"),b.k0s(),b.nVh(5,ig,1,2,"cue-logo",4)(6,ng,3,0,"cue-flexcontainer",5),b.k0s(),b.nVh(7,rg,3,2),b.k0s()()),2&r){const e=b.XpG();b.Y8G("padded",!1),b.R7$(5),b.vxM(e.modelsAreLoading()?5:6),b.R7$(2),b.vxM(e.displayDecompositionTree()?7:-1)}}function ag(r,t){1&r&&b.nrm(0,"cue-logo",4),2&r&&b.Y8G("active",!0)("continuous",!0)}function lg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-typography",6),b.EFF(1),b.k0s(),b.j41(2,"cue-button",7),b.bIt("click",function(){const s=st.eBV(e).$implicit,n=b.XpG(3);return st.Njj(n.toggleVisibility(s))}),b.nrm(3,"cue-button-icon",8),b.k0s()}if(2&r){const e=t.$implicit;b.R7$(),b.JRh(e.name),b.R7$(2),b.Y8G("icon",e.visible?"view-inactive":"view-active")}}function cg(r,t){if(1&r&&(b.j41(0,"cue-flexcontainer",5),b.Z7z(1,lg,4,2,null,null,ac),b.k0s()),2&r){const e=b.XpG(2);b.R7$(),b.Dyx(e.models())}}function hg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-typography",3),b.EFF(1),b.k0s(),b.j41(2,"cue-bim-fragments-tree-viewer",9),b.mxI("modelsChange",function(s){st.eBV(e);const n=b.XpG(2);return b.DH7(n.models,s)||(n.models=s),st.Njj(s)}),b.k0s()}if(2&r){const e=b.XpG(2);b.R7$(),b.JRh(e.treeLabel()),b.R7$(),b.R50("models",e.models)}}function ug(r,t){if(1&r&&(b.j41(0,"cue-flexcontainer",1)(1,"cue-flexcontainer",2)(2,"cue-typography",3),b.EFF(3,"Models"),b.k0s(),b.nVh(4,ag,1,2,"cue-logo",4)(5,cg,3,0,"cue-flexcontainer",5),b.k0s(),b.nVh(6,hg,3,2),b.k0s()),2&r){const e=b.XpG();b.R7$(4),b.vxM(e.modelsAreLoading()?4:5),b.R7$(2),b.vxM(e.displayDecompositionTree()?6:-1)}}let dg=(()=>{class r{_service=(0,st.WQX)(Zr);models=Tt.geq.required();draggable=(0,Tt.hFB)(!0);modelsAreLoading=this._service.modelsAreLoading;displayDecompositionTree=(0,Ot.EW)(()=>void 0!==this._service.settings().toolbar.displayDecompositionTree);treeLabel=(0,Ot.EW)(()=>"spatial"===this._service.settings().toolbar.displayDecompositionTree?"Spatial Decomposition":"System Decomposition");toggleVisibility(e){var i=this;return(0,G.A)(function*(){console.log("TOGGLE VISIBILITY",e),e.visible?(yield i._service.disposeModels([e]),console.log(`Model ${e.name} (${e.id}) disposed`)):yield i._service.loadFragmentFiles([e]),i.models.update(()=>[...i.models()])})()}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-bim-fragments-visibility-menu"]],inputs:{models:[1,"models"],draggable:[1,"draggable"]},outputs:{models:"modelsChange"},decls:2,vars:1,consts:[["margin","0",1,"draggable",3,"padded"],["direction","column","gap","l",2,"padding","0 10px 10px 10px"],["align","start","direction","column",2,"width","100%"],["size","s","weight","semibold"],["size","xs",3,"active","continuous"],["direction","row","justify","space-between","align","center",2,"width","100%"],["size","s"],["size","xs",3,"click"],[3,"icon"],[3,"modelsChange","models"]],template:function(i,s){1&i&&b.nVh(0,og,8,3,"cue-draggable-card",0)(1,ug,7,2,"cue-flexcontainer",1),2&i&&b.vxM(s.draggable()?0:1)},dependencies:[tg.y,dn.Typography,Ri.n,un.$,Xr.a,Jm,eg.Logo],styles:[".draggable[_ngcontent-%COMP%]{z-index:101}"],changeDetection:0})}return r})();var fg=mt(7851);const pg=["bimViewer"],lc=()=>({position:"bottomleft"}),mg=(r,t)=>t.label;function gg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-menu-item",4),b.bIt("click",function(){const s=st.eBV(e).$implicit;return st.Njj(s.action())}),b.EFF(1),b.k0s()}if(2&r){const e=t.$implicit;b.R7$(),b.JRh(e.label)}}function _g(r,t){if(1&r&&(b.j41(0,"cue-menu-wrap"),b.Z7z(1,gg,2,1,"cue-menu-item",null,mg),b.k0s()),2&r){const e=b.XpG();b.R7$(),b.Dyx(e.contextMenuItems())}}function yg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-bim-fragments-visibility-menu",13),b.mxI("modelsChange",function(s){st.eBV(e);const n=b.XpG(2);return b.DH7(n.models,s)||(n.models=s),st.Njj(s)}),b.k0s()}if(2&r){const e=b.XpG(2);b.R50("models",e.models),b.Y8G("draggable",!1)}}function wg(r,t){if(1&r&&b.nrm(0,"cue-bim-fragments-toolbar",15),2&r){const e=b.XpG(3),i=b.r8f(3);b.Aen(e.toolbarStyle()),b.Y8G("settings",i)}}function vg(r,t){1&r&&b.nVh(0,wg,1,3,"cue-bim-fragments-toolbar",14),2&r&&b.vxM(t.hidden?-1:0)}function bg(r,t){if(1&r&&(b.j41(0,"cue-card",16),b.nrm(1,"cue-bim-fragments-props-viewer",17),b.k0s()),2&r){const e=b.XpG(2);b.AVh("hidden",null===e.$clickedElement()),b.R7$(),b.Y8G("element",t)("wrapInCard",!1)}}function xg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-card",5),b.nVh(1,yg,1,2,"cue-bim-fragments-visibility-menu",6),b.k0s(),b.j41(2,"div",7)(3,"cue-card",8)(4,"div",9,1),b.bIt("resized",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.onResized())})("windowResized",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.onResized())}),b.k0s(),b.nVh(6,vg,1,1),b.k0s(),b.j41(7,"a",10),b.EFF(8,"Powered by "),b.j41(9,"span",11),b.EFF(10,"ThatOpen"),b.k0s()()(),b.nVh(11,bg,2,4,"cue-card",12)}if(2&r){let e,i;const s=b.XpG(),n=b.sdS(1),o=b.r8f(3);b.R7$(),b.vxM(o.showModelList&&s.models().length?1:-1),b.R7$(3),b.Y8G("cueLogoLoader",s.isLoading())("cueContextMenu",n)("contextMenuData",b.lJ4(7,lc))("cueContextEnabled",null!==s.$hoveredElement()),b.R7$(2),b.vxM((e=o.toolbar)?6:-1,e),b.R7$(5),b.vxM((i=s.$clickedElement())?11:-1,i)}}function Cg(r,t){if(1&r&&b.nrm(0,"cue-bim-fragments-toolbar",15),2&r){const e=b.XpG(3),i=b.r8f(3);b.Aen(e.toolbarStyle()),b.Y8G("settings",i)}}function Tg(r,t){1&r&&b.nVh(0,Cg,1,3,"cue-bim-fragments-toolbar",14),2&r&&b.vxM(t.hidden?-1:0)}function Pg(r,t){1&r&&(b.j41(0,"div",19),b.nrm(1,"cue-bim-fragments-props-viewer",21),b.k0s()),2&r&&(b.R7$(),b.Y8G("element",t))}function Sg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-bim-fragments-visibility-menu",22),b.mxI("modelsChange",function(s){st.eBV(e);const n=b.XpG(2);return b.DH7(n.models,s)||(n.models=s),st.Njj(s)}),b.k0s()}if(2&r){const e=b.XpG(2);b.R50("models",e.models)}}function Eg(r,t){if(1&r){const e=b.RV6();b.j41(0,"div",18,1),b.bIt("resized",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.onResized())}),b.nVh(2,Tg,1,1),b.nVh(3,Pg,2,1,"div",19),b.nVh(4,Sg,1,1,"cue-bim-fragments-visibility-menu",20),b.j41(5,"a",10),b.EFF(6,"Powered by "),b.j41(7,"span",11),b.EFF(8,"ThatOpen"),b.k0s()()()}if(2&r){let e,i;const s=b.XpG(),n=b.sdS(1),o=b.r8f(3);b.Y8G("cueLogoLoader",s.isLoading())("cueContextMenu",n)("contextMenuData",b.lJ4(7,lc))("cueContextEnabled",null!==s.$hoveredElement()),b.R7$(2),b.vxM((e=o.toolbar)?2:-1,e),b.R7$(),b.vxM((i=s.$clickedElement())?3:-1,i),b.R7$(),b.vxM(o.showModelList&&s.models().length?4:-1)}}let Ag=(()=>{class r{_service=(0,st.WQX)(Zr);data=(0,Tt.hFB)(void 0);settings=(0,Tt.hFB)(new $i.R_);clickedElement=(0,Tt.CGW)();hoveredElement=(0,Tt.CGW)();selectedElements=(0,Tt.CGW)();$hoveredElement=(0,st.vPA)(null);$clickedElement=(0,st.vPA)(null);_cachedClickedElement=(0,st.vPA)(null);_modelLoading=(0,st.vPA)(!0);isLoading=(0,Ot.EW)(()=>!this.viewerReady()||this._modelLoading());models=(0,Ot.uu)(()=>this.data()?.models??[]);detailedView=(0,Ot.EW)(()=>!0===this.settings().detailedViewEnabled);toolbarStyle=(0,Ot.EW)(()=>{const e=this.settings().toolbar;return{position:"absolute",left:e.margin,right:e.margin,["top"===e.position?"top":"bottom"]:e.margin,"z-index":"10",display:"flex","justify-content":"center"}});contextMenuItems=(0,Ot.EW)(()=>{const e=[];return this.settings().showPropertiesOnClick&&(console.log("ADDING PROPERTIES MENU ITEM"),e.push({label:"Show Properties",action:()=>{this.$clickedElement.set(this._cachedClickedElement())}})),this.settings().elementClickOptions&&e.push(...this.settings().elementClickOptions),e});viewerReady=this._service.viewerReady;onClickElement=(0,st.QZP)(()=>{const e=this._service.clickedElement();e&&this._cachedClickedElement.set(e),e||this.$clickedElement.set(null),this.clickedElement.emit(e)});onHoverElement=(0,st.QZP)(()=>{this.$hoveredElement.set(this._service.hoveredElement()),this.hoveredElement.emit(this._service.hoveredElement())});onSelectionChange=(0,st.QZP)(()=>{this.selectedElements.emit(this._service.selectedElements())});set bimViewer(e){e&&this._service.init(e.nativeElement)}loadFilesOnData=(0,st.QZP)(()=>{const e=this.models();console.log(e),this.viewerReady()&&e.length&&(console.info("Loading models:",e),this._modelLoading.set(!0),this._service.updateModels(e).then(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>this._modelLoading.set(!1))})}))});setSettings=(0,st.QZP)(()=>this._service.settings.update(()=>Object.assign({},this.settings())));ngOnDestroy(){this._service.dispose()}onResized(){this._service.updateAspectRatio()}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-bim-fragments-viewer"]],viewQuery:function(i,s){if(1&i&&b.GBs(pg,5),2&i){let n;b.mGM(n=b.lsd())&&(s.bimViewer=n.first)}},inputs:{data:[1,"data"],settings:[1,"settings"]},outputs:{clickedElement:"clickedElement",hoveredElement:"hoveredElement",selectedElements:"selectedElements"},decls:6,vars:2,consts:[["hoveringElement",""],["bimViewer",""],["direction","row",2,"flex","1 1","height","100%"],["cueResized","","trigger","leftclick",2,"height","100%","width","100%","position","relative",3,"cueLogoLoader","cueContextMenu","contextMenuData","cueContextEnabled"],[3,"click"],["variant","primary",2,"flex","0 0 250px","min-width","0","display","flex","flex-direction","column","gap","0.5rem","padding","0.5rem"],[3,"models","draggable"],[2,"flex","1 1 0","min-width","0","min-height","0","position","relative","display","flex"],[2,"flex","1 1 0","min-width","0","display","flex"],["cueResized","","trigger","leftclick",2,"height","100%","width","100%","min-width","0","min-height","0","flex","1 1 0",3,"resized","windowResized","cueLogoLoader","cueContextMenu","contextMenuData","cueContextEnabled"],["href","https://thatopen.com","target","_blank","rel","noopener noreferrer",1,"bim-viewer-credits"],[2,"font-weight","800"],["variant","accent",2,"flex","0 0 250px","min-width","0","display","flex","flex-direction","column","gap","0.5rem","padding","0.5rem",3,"hidden"],[3,"modelsChange","models","draggable"],[3,"settings","style"],[3,"settings"],["variant","accent",2,"flex","0 0 250px","min-width","0","display","flex","flex-direction","column","gap","0.5rem","padding","0.5rem"],[2,"flex","1 1","min-height","0",3,"element","wrapInCard"],["cueResized","","trigger","leftclick",2,"height","100%","width","100%","position","relative",3,"resized","cueLogoLoader","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"viewer-popup","props-popup"],[3,"models"],[3,"element"],[3,"modelsChange","models"]],template:function(i,s){1&i&&(b.DNE(0,_g,3,0,"ng-template",null,0,b.C5r),b.j41(2,"cue-flexcontainer",2),b.SS7(3),b.nVh(4,xg,12,8)(5,Eg,9,8,"div",3),b.k0s()),2&i&&(b.R7$(3),b.bH3(s.settings()),b.R7$(),b.vxM(s.detailedView()?4:5))},dependencies:[lm.C,Kr.M,Qr.D,Ri.n,Wr.Card,am.Q,um,Sm,dg,fg.k],styles:['@import"https://fonts.googleapis.com/css2?family=Sora:wght@400;700;800&display=swap";[_nghost-%COMP%]{display:contents}.viewer-popup[_ngcontent-%COMP%]{position:absolute;z-index:100}.props-popup[_ngcontent-%COMP%]{top:8px;right:8px;bottom:8px;width:300px}.hidden[_ngcontent-%COMP%]{display:none;color:red}.bim-viewer-credits[_ngcontent-%COMP%]{position:absolute;bottom:0;left:0;font-family:Sora,sans-serif;font-size:10px;line-height:1;color:#000000bf;background:#ffffffbf;padding:2px 5px;border-radius:3px;text-decoration:none;z-index:1000;pointer-events:auto}.bim-viewer-credits[_ngcontent-%COMP%]:hover{color:#000;background:#ffffffe6}'],changeDetection:0})}return r})()},6034(Jc,vn,mt){mt.d(vn,{y:()=>Oe});var st=mt(7705),Tt=mt(7598),Ot=mt(9769),$i=mt(5187),G=mt(2271),ot=mt(5547);const p=["*"];let gs=(()=>{class Nt{style=(0,st.hFB)("");gap=(0,st.hFB)("m");columns=(0,st.hFB)(1);getStyles=(0,G.EW)(()=>`\n grid-template-columns: repeat(${this.columns()}, minmax(0, 1fr));\n gap: var(--cue-grid-gap-${this.gap()});\n ${this.style()}\n `);static \u0275fac=function(oe){return new(oe||Nt)};static \u0275cmp=ot.VBU({type:Nt,selectors:[["cue-grid"]],hostVars:2,hostBindings:function(oe,Mt){2&oe&&ot.Aen(Mt.getStyles())},inputs:{style:[1,"style"],gap:[1,"gap"],columns:[1,"columns"]},ngContentSelectors:p,decls:1,vars:0,template:function(oe,Mt){1&oe&&(ot.NAR(),ot.SdG(0))},styles:["[_nghost-%COMP%]{display:grid}"]})}return Nt})();var bn=mt(2245),$=mt(5381),ji=mt(29);const zt=["*"];function j(Nt,ze){if(1&Nt&&(ot.j41(0,"cue-typography",2),ot.EFF(1),ot.k0s()),2&Nt){const ue=ot.XpG();ot.R7$(),ot.SpI(" ",ue.label()," ")}}let Oe=(()=>{class Nt{label=(0,st.hFB)("");variant=(0,st.hFB)("default");shadow=(0,st.hFB)(!1);padded=(0,st.hFB)(!0);showCloseBtn=(0,st.hFB)(!0);position=(0,st.hFB)("top-left");clickedClose=(0,st.CGW)();margin=(0,st.hFB)("0.5rem");close(ue){ue.stopPropagation(),ue.stopImmediatePropagation(),this.clickedClose.emit()}static \u0275fac=function(oe){return new(oe||Nt)};static \u0275cmp=ot.VBU({type:Nt,selectors:[["cue-draggable-card"]],inputs:{label:[1,"label"],variant:[1,"variant"],shadow:[1,"shadow"],padded:[1,"padded"],showCloseBtn:[1,"showCloseBtn"],position:[1,"position"],margin:[1,"margin"]},outputs:{clickedClose:"clickedClose"},ngContentSelectors:zt,decls:8,vars:14,consts:[["cdkDrag","",1,"panel",3,"variant","shadow","padded"],["justify","end"],["size","l"],[2,"width","100%"],["name","close",2,"cursor","pointer",3,"click"]],template:function(oe,Mt){1&oe&&(ot.NAR(),ot.j41(0,"cue-card",0)(1,"cue-typography")(2,"cue-grid")(3,"cue-flexcontainer",1),ot.nVh(4,j,2,1,"cue-typography",2),ot.nrm(5,"span",3),ot.j41(6,"cue-svg-icon",4),ot.bIt("click",function(It){return Mt.close(It)}),ot.k0s()(),ot.SdG(7),ot.k0s()()()),2&oe&&(ot.xc7("top","top-left"===Mt.position()||"top-right"===Mt.position()?Mt.margin():"null")("bottom","bottom-left"===Mt.position()||"bottom-right"===Mt.position()?Mt.margin():"null")("left","top-left"===Mt.position()||"bottom-left"===Mt.position()?Mt.margin():"null")("right","top-right"===Mt.position()||"bottom-right"===Mt.position()?Mt.margin():"null"),ot.Y8G("variant",Mt.variant())("shadow",Mt.shadow())("padded",Mt.padded()),ot.R7$(3),ot.xc7("padding",Mt.padded()?"0":"10px"),ot.R7$(),ot.vxM(Mt.label()&&"undefined"!==Mt.label()?4:-1))},dependencies:[Ot.MD,$i.Card,gs,bn.Typography,$.n,ji.A,Tt.T1],styles:[".panel[_ngcontent-%COMP%]{position:absolute;width:fit-content;z-index:100}"]})}return Nt})()}}]);
1
+ "use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[6419],{6419(Jc,vn,mt){mt.d(vn,{BIMFragmentsViewer:()=>Ag});var st=mt(5802),Tt=mt(7705),Ot=mt(2271),$i=mt(8807),G=mt(467),ot=mt(6095),p=mt(4701),bn=(mt(3973),mt(7126)),$=mt(639),ji=mt(2085);const j=Object.freeze({NONE:0,ROTATE:1,TRUCK:2,SCREEN_PAN:4,OFFSET:8,DOLLY:16,ZOOM:32,TOUCH_ROTATE:64,TOUCH_TRUCK:128,TOUCH_SCREEN_PAN:256,TOUCH_OFFSET:512,TOUCH_DOLLY:1024,TOUCH_ZOOM:2048,TOUCH_DOLLY_TRUCK:4096,TOUCH_DOLLY_SCREEN_PAN:8192,TOUCH_DOLLY_OFFSET:16384,TOUCH_DOLLY_ROTATE:32768,TOUCH_ZOOM_TRUCK:65536,TOUCH_ZOOM_OFFSET:131072,TOUCH_ZOOM_SCREEN_PAN:262144,TOUCH_ZOOM_ROTATE:524288});function Oe(r){return r.isPerspectiveCamera}function Nt(r){return r.isOrthographicCamera}const ze=2*Math.PI,ue=Math.PI/2,Mt=Math.PI/180;function de(r,t,e){return Math.max(t,Math.min(e,r))}function It(r,t=1e-5){return Math.abs(r)<t}function Pt(r,t,e=1e-5){return It(r-t,e)}function vo(r,t){return Math.round(r/t)*t}function Hi(r){return isFinite(r)?r:r<0?-Number.MAX_VALUE:Number.MAX_VALUE}function qi(r){return Math.abs(r)<Number.MAX_VALUE?r:r*(1/0)}function _s(r,t,e,i,s=1/0,n){const o=2/(i=Math.max(1e-4,i)),a=o*n,l=1/(1+a+.48*a*a+.235*a*a*a);let c=r-t;const h=t,u=s*i;c=de(c,-u,u),t=r-c;const f=(e.value+o*c)*n;e.value=(e.value-o*f)*l;let d=t+(c+f)*l;return h-r>0==d>h&&(d=h,e.value=(d-h)/n),d}function bo(r,t,e,i,s=1/0,n,o){const a=2/(i=Math.max(1e-4,i)),l=a*n,c=1/(1+l+.48*l*l+.235*l*l*l);let h=t.x,u=t.y,f=t.z,d=r.x-h,_=r.y-u,m=r.z-f;const w=h,g=u,v=f,T=s*i,S=d*d+_*_+m*m;if(S>T*T){const N=Math.sqrt(S);d=d/N*T,_=_/N*T,m=m/N*T}h=r.x-d,u=r.y-_,f=r.z-m;const M=(e.x+a*d)*n,A=(e.y+a*_)*n,O=(e.z+a*m)*n;return e.x=(e.x-a*M)*c,e.y=(e.y-a*A)*c,e.z=(e.z-a*O)*c,o.x=h+(d+M)*c,o.y=u+(_+A)*c,o.z=f+(m+O)*c,(w-r.x)*(o.x-w)+(g-r.y)*(o.y-g)+(v-r.z)*(o.z-v)>0&&(o.x=w,o.y=g,o.z=v,e.x=(o.x-w)/n,e.y=(o.y-g)/n,e.z=(o.z-v)/n),o}function xn(r,t){t.set(0,0),r.forEach(e=>{t.x+=e.clientX,t.y+=e.clientY}),t.x/=r.length,t.y/=r.length}function Cn(r,t){return!!Nt(r)&&(console.warn(`${t} is not supported in OrthographicCamera`),!0)}class th{_listeners={};addEventListener(t,e){const i=this._listeners;void 0===i[t]&&(i[t]=[]),-1===i[t].indexOf(e)&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return void 0!==i[t]&&-1!==i[t].indexOf(e)}removeEventListener(t,e){const s=this._listeners[t];if(void 0!==s){const n=s.indexOf(e);-1!==n&&s.splice(n,1)}}removeAllEventListeners(t){t?Array.isArray(this._listeners[t])&&(this._listeners[t].length=0):this._listeners={}}dispatchEvent(t){const i=this._listeners[t.type];if(void 0!==i){t.target=this;const s=i.slice(0);for(let n=0,o=s.length;n<o;n++)s[n].call(this,t)}}}const ys=1/8,ih=/Mac/.test(globalThis?.navigator?.platform);let gt,xo,ws,Tn,ee,yt,Ct,yi,Gi,Ce,Te,ai,Co,To,ae,wi,vi,Po,Pn,So,Sn,En,vs;class Zt extends th{static install(t){gt=t.THREE,xo=Object.freeze(new gt.Vector3(0,0,0)),ws=Object.freeze(new gt.Vector3(0,1,0)),Tn=Object.freeze(new gt.Vector3(0,0,1)),ee=new gt.Vector2,yt=new gt.Vector3,Ct=new gt.Vector3,yi=new gt.Vector3,Gi=new gt.Vector3,Ce=new gt.Vector3,Te=new gt.Vector3,ai=new gt.Vector3,Co=new gt.Vector3,To=new gt.Vector3,ae=new gt.Spherical,wi=new gt.Spherical,vi=new gt.Box3,Po=new gt.Box3,Pn=new gt.Sphere,So=new gt.Quaternion,Sn=new gt.Quaternion,En=new gt.Matrix4,vs=new gt.Raycaster}static get ACTION(){return j}minPolarAngle=0;maxPolarAngle=Math.PI;minAzimuthAngle=-1/0;maxAzimuthAngle=1/0;minDistance=Number.EPSILON;maxDistance=1/0;infinityDolly=!1;minZoom=.01;maxZoom=1/0;smoothTime=.25;draggingSmoothTime=.125;maxSpeed=1/0;azimuthRotateSpeed=1;polarRotateSpeed=1;dollySpeed=1;dollyDragInverted=!1;truckSpeed=2;dollyToCursor=!1;dragToOffset=!1;boundaryFriction=0;restThreshold=.01;colliderMeshes=[];mouseButtons;touches;cancel=()=>{};lockPointer;unlockPointer;_enabled=!0;_camera;_yAxisUpSpace;_yAxisUpSpaceInverse;_state=j.NONE;_domElement;_viewport=null;_target;_targetEnd;_focalOffset;_focalOffsetEnd;_spherical;_sphericalEnd;_lastDistance;_zoom;_zoomEnd;_lastZoom;_cameraUp0;_target0;_position0;_zoom0;_focalOffset0;_dollyControlCoord;_changedDolly=0;_changedZoom=0;_nearPlaneCorners;_hasRested=!0;_boundary;_boundaryEnclosesCamera=!1;_needsUpdate=!0;_updatedLastTime=!1;_elementRect=new DOMRect;_isDragging=!1;_dragNeedsUpdate=!0;_activePointers=[];_lockedPointer=null;_interactiveArea=new DOMRect(0,0,1,1);_isUserControllingRotate=!1;_isUserControllingDolly=!1;_isUserControllingTruck=!1;_isUserControllingOffset=!1;_isUserControllingZoom=!1;_lastDollyDirection=0;_thetaVelocity={value:0};_phiVelocity={value:0};_radiusVelocity={value:0};_targetVelocity=new gt.Vector3;_focalOffsetVelocity=new gt.Vector3;_zoomVelocity={value:0};set verticalDragToForward(t){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}constructor(t,e){super(),typeof gt>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=t,this._yAxisUpSpace=(new gt.Quaternion).setFromUnitVectors(this._camera.up,ws),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=j.NONE,this._target=new gt.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new gt.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new gt.Spherical).setFromVector3(yt.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)),this._sphericalEnd=this._spherical.clone(),this._lastDistance=this._spherical.radius,this._zoom=this._camera.zoom,this._zoomEnd=this._zoom,this._lastZoom=this._zoom,this._nearPlaneCorners=[new gt.Vector3,new gt.Vector3,new gt.Vector3,new gt.Vector3],this._updateNearPlaneCorners(),this._boundary=new gt.Box3(new gt.Vector3(-1/0,-1/0,-1/0),new gt.Vector3(1/0,1/0,1/0)),this._cameraUp0=this._camera.up.clone(),this._target0=this._target.clone(),this._position0=this._camera.position.clone(),this._zoom0=this._zoom,this._focalOffset0=this._focalOffset.clone(),this._dollyControlCoord=new gt.Vector2,this.mouseButtons={left:j.ROTATE,middle:j.DOLLY,right:j.TRUCK,wheel:Oe(this._camera)?j.DOLLY:Nt(this._camera)?j.ZOOM:j.NONE},this.touches={one:j.TOUCH_ROTATE,two:Oe(this._camera)?j.TOUCH_DOLLY_TRUCK:Nt(this._camera)?j.TOUCH_ZOOM_TRUCK:j.NONE,three:j.TOUCH_TRUCK};const i=new gt.Vector2,s=new gt.Vector2,n=new gt.Vector2,o=g=>{if(!this._enabled||!this._domElement)return;if(0!==this._interactiveArea.left||0!==this._interactiveArea.top||1!==this._interactiveArea.width||1!==this._interactiveArea.height){const C=this._domElement.getBoundingClientRect(),S=g.clientX/C.width,M=g.clientY/C.height;if(S<this._interactiveArea.left||S>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const v="mouse"!==g.pointerType?null:1&~g.buttons?4&~g.buttons?2&~g.buttons?null:2:4:1;if(null!==v){const C=this._findPointerByMouseButton(v);C&&this._disposePointer(C)}(1&~g.buttons||!this._lockedPointer)&&(this._activePointers.push({pointerId:g.pointerId,clientX:g.clientX,clientY:g.clientY,deltaX:0,deltaY:0,mouseButton:v}),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),this._isDragging=!0,f(g))},a=g=>{g.cancelable&&g.preventDefault();const T=this._lockedPointer||this._findPointerById(g.pointerId);if(T){if(T.clientX=g.clientX,T.clientY=g.clientY,T.deltaX=g.movementX,T.deltaY=g.movementY,this._state=0,"touch"===g.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else(!this._isDragging&&this._lockedPointer||this._isDragging&&!(1&~g.buttons))&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&!(4&~g.buttons)&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&!(2&~g.buttons)&&(this._state=this._state|this.mouseButtons.right);d()}},l=g=>{const v=this._findPointerById(g.pointerId);if(!v||v!==this._lockedPointer){if(v&&this._disposePointer(v),"touch"===g.pointerType)switch(this._activePointers.length){case 0:this._state=j.NONE;break;case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else this._state=j.NONE;_()}};let c=-1;const h=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===j.NONE)return;if(0!==this._interactiveArea.left||0!==this._interactiveArea.top||1!==this._interactiveArea.width||1!==this._interactiveArea.height){const A=this._domElement.getBoundingClientRect(),O=g.clientX/A.width,I=g.clientY/A.height;if(O<this._interactiveArea.left||O>this._interactiveArea.right||I<this._interactiveArea.top||I>this._interactiveArea.bottom)return}if(g.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===j.ROTATE||this.mouseButtons.wheel===j.TRUCK){const A=performance.now();c-A<1e3&&this._getClientRect(this._elementRect),c=A}const v=ih?-1:-3,T=1!==g.deltaMode||g.ctrlKey?g.deltaY/(10*v):g.deltaY/v,C=this.dollyToCursor?(g.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,S=this.dollyToCursor?(g.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(g.ctrlKey?j.ZOOM:this.mouseButtons.wheel){case j.ROTATE:this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break;case j.TRUCK:this._truckInternal(g.deltaX,g.deltaY,!1,!1),this._isUserControllingTruck=!0;break;case j.SCREEN_PAN:this._truckInternal(g.deltaX,g.deltaY,!1,!0),this._isUserControllingTruck=!0;break;case j.OFFSET:this._truckInternal(g.deltaX,g.deltaY,!0,!1),this._isUserControllingOffset=!0;break;case j.DOLLY:this._dollyInternal(-T,C,S),this._isUserControllingDolly=!0;break;case j.ZOOM:this._zoomInternal(-T,C,S),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},u=g=>{if(this._domElement&&this._enabled){if(this.mouseButtons.right===Zt.ACTION.NONE){const v=g instanceof PointerEvent?g.pointerId:0,T=this._findPointerById(v);return T&&this._disposePointer(T),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),void this._domElement.ownerDocument.removeEventListener("pointerup",l)}g.preventDefault()}},f=g=>{if(this._enabled){if(xn(this._activePointers,ee),this._getClientRect(this._elementRect),i.copy(ee),s.copy(ee),this._activePointers.length>=2){const T=ee.x-this._activePointers[1].clientX,C=ee.y-this._activePointers[1].clientY,S=Math.sqrt(T*T+C*C);n.set(0,S),s.set(.5*(this._activePointers[0].clientX+this._activePointers[1].clientX),.5*(this._activePointers[0].clientY+this._activePointers[1].clientY))}if(this._state=0,g)if("pointerType"in g&&"touch"===g.pointerType)switch(this._activePointers.length){case 1:this._state=this.touches.one;break;case 2:this._state=this.touches.two;break;case 3:this._state=this.touches.three}else!this._lockedPointer&&!(1&~g.buttons)&&(this._state=this._state|this.mouseButtons.left),!(4&~g.buttons)&&(this._state=this._state|this.mouseButtons.middle),!(2&~g.buttons)&&(this._state=this._state|this.mouseButtons.right);else this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);((this._state&j.ROTATE)===j.ROTATE||(this._state&j.TOUCH_ROTATE)===j.TOUCH_ROTATE||(this._state&j.TOUCH_DOLLY_ROTATE)===j.TOUCH_DOLLY_ROTATE||(this._state&j.TOUCH_ZOOM_ROTATE)===j.TOUCH_ZOOM_ROTATE)&&(this._sphericalEnd.theta=this._spherical.theta,this._sphericalEnd.phi=this._spherical.phi,this._thetaVelocity.value=0,this._phiVelocity.value=0),((this._state&j.TRUCK)===j.TRUCK||(this._state&j.SCREEN_PAN)===j.SCREEN_PAN||(this._state&j.TOUCH_TRUCK)===j.TOUCH_TRUCK||(this._state&j.TOUCH_SCREEN_PAN)===j.TOUCH_SCREEN_PAN||(this._state&j.TOUCH_DOLLY_TRUCK)===j.TOUCH_DOLLY_TRUCK||(this._state&j.TOUCH_DOLLY_SCREEN_PAN)===j.TOUCH_DOLLY_SCREEN_PAN||(this._state&j.TOUCH_ZOOM_TRUCK)===j.TOUCH_ZOOM_TRUCK||(this._state&j.TOUCH_ZOOM_SCREEN_PAN)===j.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&j.DOLLY)===j.DOLLY||(this._state&j.TOUCH_DOLLY)===j.TOUCH_DOLLY||(this._state&j.TOUCH_DOLLY_TRUCK)===j.TOUCH_DOLLY_TRUCK||(this._state&j.TOUCH_DOLLY_SCREEN_PAN)===j.TOUCH_DOLLY_SCREEN_PAN||(this._state&j.TOUCH_DOLLY_OFFSET)===j.TOUCH_DOLLY_OFFSET||(this._state&j.TOUCH_DOLLY_ROTATE)===j.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&j.ZOOM)===j.ZOOM||(this._state&j.TOUCH_ZOOM)===j.TOUCH_ZOOM||(this._state&j.TOUCH_ZOOM_TRUCK)===j.TOUCH_ZOOM_TRUCK||(this._state&j.TOUCH_ZOOM_SCREEN_PAN)===j.TOUCH_ZOOM_SCREEN_PAN||(this._state&j.TOUCH_ZOOM_OFFSET)===j.TOUCH_ZOOM_OFFSET||(this._state&j.TOUCH_ZOOM_ROTATE)===j.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&j.OFFSET)===j.OFFSET||(this._state&j.TOUCH_OFFSET)===j.TOUCH_OFFSET||(this._state&j.TOUCH_DOLLY_OFFSET)===j.TOUCH_DOLLY_OFFSET||(this._state&j.TOUCH_ZOOM_OFFSET)===j.TOUCH_ZOOM_OFFSET)&&(this._focalOffsetEnd.copy(this._focalOffset),this._focalOffsetVelocity.set(0,0,0)),this.dispatchEvent({type:"controlstart"})}},d=()=>{if(!this._enabled||!this._dragNeedsUpdate)return;this._dragNeedsUpdate=!1,xn(this._activePointers,ee);const v=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,T=v?-v.deltaX:s.x-ee.x,C=v?-v.deltaY:s.y-ee.y;if(s.copy(ee),((this._state&j.ROTATE)===j.ROTATE||(this._state&j.TOUCH_ROTATE)===j.TOUCH_ROTATE||(this._state&j.TOUCH_DOLLY_ROTATE)===j.TOUCH_DOLLY_ROTATE||(this._state&j.TOUCH_ZOOM_ROTATE)===j.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(T,C),this._isUserControllingRotate=!0),(this._state&j.DOLLY)===j.DOLLY||(this._state&j.ZOOM)===j.ZOOM){const S=this.dollyToCursor?(i.x-this._elementRect.x)/this._elementRect.width*2-1:0,M=this.dollyToCursor?(i.y-this._elementRect.y)/this._elementRect.height*-2+1:0,A=this.dollyDragInverted?-1:1;(this._state&j.DOLLY)===j.DOLLY?(this._dollyInternal(A*C*ys,S,M),this._isUserControllingDolly=!0):(this._zoomInternal(A*C*ys,S,M),this._isUserControllingZoom=!0)}if((this._state&j.TOUCH_DOLLY)===j.TOUCH_DOLLY||(this._state&j.TOUCH_ZOOM)===j.TOUCH_ZOOM||(this._state&j.TOUCH_DOLLY_TRUCK)===j.TOUCH_DOLLY_TRUCK||(this._state&j.TOUCH_ZOOM_TRUCK)===j.TOUCH_ZOOM_TRUCK||(this._state&j.TOUCH_DOLLY_SCREEN_PAN)===j.TOUCH_DOLLY_SCREEN_PAN||(this._state&j.TOUCH_ZOOM_SCREEN_PAN)===j.TOUCH_ZOOM_SCREEN_PAN||(this._state&j.TOUCH_DOLLY_OFFSET)===j.TOUCH_DOLLY_OFFSET||(this._state&j.TOUCH_ZOOM_OFFSET)===j.TOUCH_ZOOM_OFFSET||(this._state&j.TOUCH_DOLLY_ROTATE)===j.TOUCH_DOLLY_ROTATE||(this._state&j.TOUCH_ZOOM_ROTATE)===j.TOUCH_ZOOM_ROTATE){const S=ee.x-this._activePointers[1].clientX,M=ee.y-this._activePointers[1].clientY,A=Math.sqrt(S*S+M*M),O=n.y-A;n.set(0,A);const I=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,D=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&j.TOUCH_DOLLY)===j.TOUCH_DOLLY||(this._state&j.TOUCH_DOLLY_ROTATE)===j.TOUCH_DOLLY_ROTATE||(this._state&j.TOUCH_DOLLY_TRUCK)===j.TOUCH_DOLLY_TRUCK||(this._state&j.TOUCH_DOLLY_SCREEN_PAN)===j.TOUCH_DOLLY_SCREEN_PAN||(this._state&j.TOUCH_DOLLY_OFFSET)===j.TOUCH_DOLLY_OFFSET?(this._dollyInternal(O*ys,I,D),this._isUserControllingDolly=!0):(this._zoomInternal(O*ys,I,D),this._isUserControllingZoom=!0)}((this._state&j.TRUCK)===j.TRUCK||(this._state&j.TOUCH_TRUCK)===j.TOUCH_TRUCK||(this._state&j.TOUCH_DOLLY_TRUCK)===j.TOUCH_DOLLY_TRUCK||(this._state&j.TOUCH_ZOOM_TRUCK)===j.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(T,C,!1,!1),this._isUserControllingTruck=!0),((this._state&j.SCREEN_PAN)===j.SCREEN_PAN||(this._state&j.TOUCH_SCREEN_PAN)===j.TOUCH_SCREEN_PAN||(this._state&j.TOUCH_DOLLY_SCREEN_PAN)===j.TOUCH_DOLLY_SCREEN_PAN||(this._state&j.TOUCH_ZOOM_SCREEN_PAN)===j.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(T,C,!1,!0),this._isUserControllingTruck=!0),((this._state&j.OFFSET)===j.OFFSET||(this._state&j.TOUCH_OFFSET)===j.TOUCH_OFFSET||(this._state&j.TOUCH_DOLLY_OFFSET)===j.TOUCH_DOLLY_OFFSET||(this._state&j.TOUCH_ZOOM_OFFSET)===j.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(T,C,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},_=()=>{xn(this._activePointers,ee),s.copy(ee),this._dragNeedsUpdate=!1,(0===this._activePointers.length||1===this._activePointers.length&&this._activePointers[0]===this._lockedPointer)&&(this._isDragging=!1),0===this._activePointers.length&&this._domElement&&(this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this.dispatchEvent({type:"controlend"}))};this.lockPointer=()=>{!this._enabled||!this._domElement||(this.cancel(),this._lockedPointer={pointerId:-1,clientX:0,clientY:0,deltaX:0,deltaY:0,mouseButton:null},this._activePointers.push(this._lockedPointer),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.requestPointerLock(),this._domElement.ownerDocument.addEventListener("pointerlockchange",m),this._domElement.ownerDocument.addEventListener("pointerlockerror",w),this._domElement.ownerDocument.addEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.addEventListener("pointerup",l),f())},this.unlockPointer=()=>{null!==this._lockedPointer&&(this._disposePointer(this._lockedPointer),this._lockedPointer=null),this._domElement?.ownerDocument.exitPointerLock(),this._domElement?.ownerDocument.removeEventListener("pointerlockchange",m),this._domElement?.ownerDocument.removeEventListener("pointerlockerror",w),this.cancel()};const m=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},w=()=>{this.unlockPointer()};this._addAllEventListeners=g=>{this._domElement=g,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",o),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",h,{passive:!1}),this._domElement.addEventListener("contextmenu",u)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",o),this._domElement.removeEventListener("pointercancel",l),this._domElement.removeEventListener("wheel",h,{passive:!1}),this._domElement.removeEventListener("contextmenu",u),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",m),this._domElement.ownerDocument.removeEventListener("pointerlockerror",w))},this.cancel=()=>{this._state!==j.NONE&&(this._state=j.NONE,this._activePointers.length=0,_())},e&&this.connect(e),this.update(0)}get camera(){return this._camera}set camera(t){this._camera=t,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(t){this._enabled=t,this._domElement&&(t?(this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none"):(this.cancel(),this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect=""))}get active(){return!this._hasRested}get currentAction(){return this._state}get distance(){return this._spherical.radius}set distance(t){this._spherical.radius===t&&this._sphericalEnd.radius===t||(this._spherical.radius=t,this._sphericalEnd.radius=t,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(t){this._spherical.theta===t&&this._sphericalEnd.theta===t||(this._spherical.theta=t,this._sphericalEnd.theta=t,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(t){this._spherical.phi===t&&this._sphericalEnd.phi===t||(this._spherical.phi=t,this._sphericalEnd.phi=t,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(t){this._boundaryEnclosesCamera=t,this._needsUpdate=!0}set interactiveArea(t){this._interactiveArea.width=de(t.width,0,1),this._interactiveArea.height=de(t.height,0,1),this._interactiveArea.x=de(t.x,0,1-this._interactiveArea.width),this._interactiveArea.y=de(t.y,0,1-this._interactiveArea.height)}addEventListener(t,e){super.addEventListener(t,e)}removeEventListener(t,e){super.removeEventListener(t,e)}rotate(t,e,i=!1){return this.rotateTo(this._sphericalEnd.theta+t,this._sphericalEnd.phi+e,i)}rotateAzimuthTo(t,e=!1){return this.rotateTo(t,this._sphericalEnd.phi,e)}rotatePolarTo(t,e=!1){return this.rotateTo(this._sphericalEnd.theta,t,e)}rotateTo(t,e,i=!1){this._isUserControllingRotate=!1;const s=de(t,this.minAzimuthAngle,this.maxAzimuthAngle),n=de(e,this.minPolarAngle,this.maxPolarAngle);this._sphericalEnd.theta=s,this._sphericalEnd.phi=n,this._sphericalEnd.makeSafe(),this._needsUpdate=!0,i||(this._spherical.theta=this._sphericalEnd.theta,this._spherical.phi=this._sphericalEnd.phi);const o=!i||Pt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Pt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(o)}dolly(t,e=!1){return this.dollyTo(this._sphericalEnd.radius-t,e)}dollyTo(t,e=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=0,this._changedDolly=0,this._dollyToNoClamp(de(t,this.minDistance,this.maxDistance),e)}_dollyToNoClamp(t,e=!1){const i=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const o=this._collisionTest(),a=Pt(o,this._spherical.radius);if(!(i>t)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(t,o)}else this._sphericalEnd.radius=t;this._needsUpdate=!0,e||(this._spherical.radius=this._sphericalEnd.radius);const n=!e||Pt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(n)}dollyInFixed(t,e=!1){this._targetEnd.add(this._getCameraDirection(Gi).multiplyScalar(t)),e||this._target.copy(this._targetEnd);const i=!e||Pt(this._target.x,this._targetEnd.x,this.restThreshold)&&Pt(this._target.y,this._targetEnd.y,this.restThreshold)&&Pt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}zoom(t,e=!1){return this.zoomTo(this._zoomEnd+t,e)}zoomTo(t,e=!1){this._isUserControllingZoom=!1,this._zoomEnd=de(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,e||(this._zoom=this._zoomEnd);const i=!e||Pt(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(i)}pan(t,e,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(t,e,i)}truck(t,e,i=!1){this._camera.updateMatrix(),Ce.setFromMatrixColumn(this._camera.matrix,0),Te.setFromMatrixColumn(this._camera.matrix,1),Ce.multiplyScalar(t),Te.multiplyScalar(-e);const s=yt.copy(Ce).add(Te),n=Ct.copy(this._targetEnd).add(s);return this.moveTo(n.x,n.y,n.z,i)}forward(t,e=!1){yt.setFromMatrixColumn(this._camera.matrix,0),yt.crossVectors(this._camera.up,yt),yt.multiplyScalar(t);const i=Ct.copy(this._targetEnd).add(yt);return this.moveTo(i.x,i.y,i.z,e)}elevate(t,e=!1){return yt.copy(this._camera.up).multiplyScalar(t),this.moveTo(this._targetEnd.x+yt.x,this._targetEnd.y+yt.y,this._targetEnd.z+yt.z,e)}moveTo(t,e,i,s=!1){this._isUserControllingTruck=!1;const n=yt.set(t,e,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,n,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const o=!s||Pt(this._target.x,this._targetEnd.x,this.restThreshold)&&Pt(this._target.y,this._targetEnd.y,this.restThreshold)&&Pt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(t,e,i,s=!1){const a=yt.set(t,e,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,s)}fitToBox(t,e,{cover:i=!1,paddingLeft:s=0,paddingRight:n=0,paddingBottom:o=0,paddingTop:a=0}={}){const l=[],c=t.isBox3?vi.copy(t):vi.setFromObject(t);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=vo(this._sphericalEnd.theta,ue),u=vo(this._sphericalEnd.phi,ue);l.push(this.rotateTo(h,u,e));const f=yt.setFromSpherical(this._sphericalEnd).normalize(),d=So.setFromUnitVectors(f,Tn),_=Pt(Math.abs(f.y),1);_&&d.multiply(Sn.setFromAxisAngle(ws,h)),d.multiply(this._yAxisUpSpaceInverse);const m=Po.makeEmpty();Ct.copy(c.min).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.min).setX(c.max.x).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.min).setY(c.max.y).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.max).setZ(c.min.z).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.min).setZ(c.max.z).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.max).setY(c.min.y).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.max).setX(c.min.x).applyQuaternion(d),m.expandByPoint(Ct),Ct.copy(c.max).applyQuaternion(d),m.expandByPoint(Ct),m.min.x-=s,m.min.y-=o,m.max.x+=n,m.max.y+=a,d.setFromUnitVectors(Tn,f),_&&d.premultiply(Sn.invert()),d.premultiply(this._yAxisUpSpace);const w=m.getSize(yt),g=m.getCenter(Ct).applyQuaternion(d);if(Oe(this._camera)){const v=this.getDistanceToFitBox(w.x,w.y,w.z,i);l.push(this.moveTo(g.x,g.y,g.z,e)),l.push(this.dollyTo(v,e)),l.push(this.setFocalOffset(0,0,0,e))}else if(Nt(this._camera)){const v=this._camera,T=v.right-v.left,C=v.top-v.bottom,S=i?Math.max(T/w.x,C/w.y):Math.min(T/w.x,C/w.y);l.push(this.moveTo(g.x,g.y,g.z,e)),l.push(this.zoomTo(S,e)),l.push(this.setFocalOffset(0,0,0,e))}return Promise.all(l)}fitToSphere(t,e){const i=[],n="isObject3D"in t?Zt.createBoundingSphere(t,Pn):Pn.copy(t);if(i.push(this.moveTo(n.center.x,n.center.y,n.center.z,e)),Oe(this._camera)){const o=this.getDistanceToFitSphere(n.radius);i.push(this.dollyTo(o,e))}else if(Nt(this._camera)){const l=2*n.radius,c=Math.min((this._camera.right-this._camera.left)/l,(this._camera.top-this._camera.bottom)/l);i.push(this.zoomTo(c,e))}return i.push(this.setFocalOffset(0,0,0,e)),Promise.all(i)}setLookAt(t,e,i,s,n,o,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=0,this._changedDolly=0;const l=Ct.set(s,n,o),c=yt.set(t,e,i);this._targetEnd.copy(l),this._sphericalEnd.setFromVector3(c.sub(l).applyQuaternion(this._yAxisUpSpace)),this._needsUpdate=!0,a||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!a||Pt(this._target.x,this._targetEnd.x,this.restThreshold)&&Pt(this._target.y,this._targetEnd.y,this.restThreshold)&&Pt(this._target.z,this._targetEnd.z,this.restThreshold)&&Pt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Pt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Pt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerp(t,e,i,s=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=0,this._changedDolly=0;const n=yt.set(...t.target);if("spherical"in t)ae.set(...t.spherical);else{const u=Ct.set(...t.position);ae.setFromVector3(u.sub(n).applyQuaternion(this._yAxisUpSpace))}const o=yi.set(...e.target);if("spherical"in e)wi.set(...e.spherical);else{const u=Ct.set(...e.position);wi.setFromVector3(u.sub(o).applyQuaternion(this._yAxisUpSpace))}this._targetEnd.copy(n.lerp(o,i)),this._sphericalEnd.set(ae.radius+(wi.radius-ae.radius)*i,ae.phi+(wi.phi-ae.phi)*i,ae.theta+(wi.theta-ae.theta)*i),this._needsUpdate=!0,s||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!s||Pt(this._target.x,this._targetEnd.x,this.restThreshold)&&Pt(this._target.y,this._targetEnd.y,this.restThreshold)&&Pt(this._target.z,this._targetEnd.z,this.restThreshold)&&Pt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Pt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Pt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(h)}lerpLookAt(t,e,i,s,n,o,a,l,c,h,u,f,d,_=!1){return this.lerp({position:[t,e,i],target:[s,n,o]},{position:[a,l,c],target:[h,u,f]},d,_)}setPosition(t,e,i,s=!1){return this.setLookAt(t,e,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(t,e,i,s=!1){const n=this.getPosition(yt),o=this.setLookAt(n.x,n.y,n.z,t,e,i,s);return this._sphericalEnd.phi=de(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),o}setFocalOffset(t,e,i,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(t,e,i),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const n=!s||Pt(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Pt(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Pt(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}setOrbitPoint(t,e,i){this._camera.updateMatrixWorld(),Ce.setFromMatrixColumn(this._camera.matrixWorldInverse,0),Te.setFromMatrixColumn(this._camera.matrixWorldInverse,1),ai.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=yt.set(t,e,i),n=s.distanceTo(this._camera.position),o=s.sub(this._camera.position);Ce.multiplyScalar(o.x),Te.multiplyScalar(o.y),ai.multiplyScalar(o.z),yt.copy(Ce).add(Te).add(ai),yt.z=yt.z+n,this.dollyTo(n,!1),this.setFocalOffset(-yt.x,yt.y,-yt.z,!1),this.moveTo(t,e,i,!1)}setBoundary(t){if(!t)return this._boundary.min.set(-1/0,-1/0,-1/0),this._boundary.max.set(1/0,1/0,1/0),void(this._needsUpdate=!0);this._boundary.copy(t),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(t,e,i,s){null!==t?(this._viewport=this._viewport||new gt.Vector4,"number"==typeof t?this._viewport.set(t,e,i,s):this._viewport.copy(t)):this._viewport=null}getDistanceToFitBox(t,e,i,s=!1){if(Cn(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const n=t/e,o=this._camera.getEffectiveFOV()*Mt,a=this._camera.aspect;return.5*((s?n>a:n<a)?e:t/a)/Math.tan(.5*o)+.5*i}getDistanceToFitSphere(t){if(Cn(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const e=this._camera.getEffectiveFOV()*Mt,i=2*Math.atan(Math.tan(.5*e)*this._camera.aspect);return t/Math.sin(.5*(1<this._camera.aspect?e:i))}getTarget(t,e=!0){return(t&&t.isVector3?t:new gt.Vector3).copy(e?this._targetEnd:this._target)}getPosition(t,e=!0){return(t&&t.isVector3?t:new gt.Vector3).setFromSpherical(e?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(e?this._targetEnd:this._target)}getSpherical(t,e=!0){return(t||new gt.Spherical).copy(e?this._sphericalEnd:this._spherical)}getFocalOffset(t,e=!0){return(t&&t.isVector3?t:new gt.Vector3).copy(e?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){return this._sphericalEnd.theta=(this._sphericalEnd.theta%ze+ze)%ze,this._sphericalEnd.theta>Math.PI&&(this._sphericalEnd.theta-=ze),this._spherical.theta+=ze*Math.round((this._sphericalEnd.theta-this._spherical.theta)/ze),this}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(t=!1){if(!Pt(this._camera.up.x,this._cameraUp0.x)||!Pt(this._camera.up.y,this._cameraUp0.y)||!Pt(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const i=this.getPosition(yt);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}const e=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,t),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,t),this.zoomTo(this._zoom0,t)];return Promise.all(e)}saveState(){this._cameraUp0.copy(this._camera.up),this.getTarget(this._target0),this.getPosition(this._position0),this._zoom0=this._zoom,this._focalOffset0.copy(this._focalOffset)}updateCameraUp(){this._yAxisUpSpace.setFromUnitVectors(this._camera.up,ws),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=yt.subVectors(this._target,this._camera.position).normalize(),e=Ct.crossVectors(t,this._camera.up);this._camera.up.crossVectors(e,t).normalize(),this._camera.updateMatrixWorld();const i=this.getPosition(yt);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}update(t){const e=this._sphericalEnd.theta-this._spherical.theta,i=this._sphericalEnd.phi-this._spherical.phi,s=this._sphericalEnd.radius-this._spherical.radius,n=Co.subVectors(this._targetEnd,this._target),o=To.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(It(e)?(this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta):(this._spherical.theta=_s(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime,1/0,t),this._needsUpdate=!0),It(i)?(this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi):(this._spherical.phi=_s(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime,1/0,t),this._needsUpdate=!0),It(s)?(this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius):(this._spherical.radius=_s(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,t),this._needsUpdate=!0),It(n.x)&&It(n.y)&&It(n.z)?(this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd)):(bo(this._target,this._targetEnd,this._targetVelocity,this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,t,this._target),this._needsUpdate=!0),It(o.x)&&It(o.y)&&It(o.z)?(this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd)):(bo(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,t,this._focalOffset),this._needsUpdate=!0),It(a)?(this._zoomVelocity.value=0,this._zoom=this._zoomEnd):this._zoom=_s(this._zoom,this._zoomEnd,this._zoomVelocity,this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime,1/0,t),this.dollyToCursor)if(Oe(this._camera)&&0!==this._changedDolly){const u=this._spherical.radius-this._lastDistance,f=this._camera,d=this._getCameraDirection(Gi),_=yt.copy(d).cross(f.up).normalize();0===_.lengthSq()&&(_.x=1);const m=Ct.crossVectors(_,d),w=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*Mt*.5),v=(this._sphericalEnd.radius-u-this._sphericalEnd.radius)/this._sphericalEnd.radius,T=yi.copy(this._targetEnd).add(_.multiplyScalar(this._dollyControlCoord.x*w*f.aspect)).add(m.multiplyScalar(this._dollyControlCoord.y*w)),C=yt.copy(this._targetEnd).lerp(T,v);if(this.infinityDolly&&(1===this._lastDollyDirection&&this._spherical.radius<=this.minDistance||-1===this._lastDollyDirection&&this.maxDistance<=this._spherical.radius)){this._sphericalEnd.radius-=u,this._spherical.radius-=u;const O=Ct.copy(d).multiplyScalar(-u);C.add(O)}this._boundary.clampPoint(C,C);const A=Ct.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(A),this._changedDolly-=u,It(this._changedDolly)&&(this._changedDolly=0)}else if(Nt(this._camera)&&0!==this._changedZoom){const u=this._zoom-this._lastZoom,f=this._camera,d=yt.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),_=Ct.set(0,0,-1).applyQuaternion(f.quaternion),m=yi.copy(d).add(_.multiplyScalar(-d.dot(f.up))),g=-(this._zoom-u-this._zoom)/this._zoom,v=this._getCameraDirection(Gi),T=this._targetEnd.dot(v),C=yt.copy(this._targetEnd).lerp(m,g),S=C.dot(v),M=v.multiplyScalar(S-T);C.sub(M),this._boundary.clampPoint(C,C);const A=Ct.subVectors(C,this._targetEnd);this._targetEnd.copy(C),this._target.add(A),this._changedZoom-=u,It(this._changedZoom)&&(this._changedZoom=0)}this._camera.zoom!==this._zoom&&(this._camera.zoom=this._zoom,this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0),this._dragNeedsUpdate=!0;const l=this._collisionTest();this._spherical.radius=Math.min(this._spherical.radius,l),this._spherical.makeSafe(),this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target),this._camera.lookAt(this._target),(!It(this._focalOffset.x)||!It(this._focalOffset.y)||!It(this._focalOffset.z))&&(this._camera.matrix.compose(this._camera.position,this._camera.quaternion,this._camera.scale),Ce.setFromMatrixColumn(this._camera.matrix,0),Te.setFromMatrixColumn(this._camera.matrix,1),ai.setFromMatrixColumn(this._camera.matrix,2),Ce.multiplyScalar(this._focalOffset.x),Te.multiplyScalar(-this._focalOffset.y),ai.multiplyScalar(this._focalOffset.z),yt.copy(Ce).add(Te).add(ai),this._camera.position.add(yt),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),yt.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const h=this._needsUpdate;return h&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):h?(this.dispatchEvent({type:"update"}),It(e,this.restThreshold)&&It(i,this.restThreshold)&&It(s,this.restThreshold)&&It(n.x,this.restThreshold)&&It(n.y,this.restThreshold)&&It(n.z,this.restThreshold)&&It(o.x,this.restThreshold)&&It(o.y,this.restThreshold)&&It(o.z,this.restThreshold)&&It(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!h&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=h,this._needsUpdate=!1,h}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Hi(this.maxDistance),minZoom:this.minZoom,maxZoom:Hi(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Hi(this.maxPolarAngle),minAzimuthAngle:Hi(this.minAzimuthAngle),maxAzimuthAngle:Hi(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:yt.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),zoom:this._zoomEnd,focalOffset:this._focalOffsetEnd.toArray(),target0:this._target0.toArray(),position0:this._position0.toArray(),zoom0:this._zoom0,focalOffset0:this._focalOffset0.toArray()})}fromJSON(t,e=!1){const i=JSON.parse(t);this.enabled=i.enabled,this.minDistance=i.minDistance,this.maxDistance=qi(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=qi(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=qi(i.maxPolarAngle),this.minAzimuthAngle=qi(i.minAzimuthAngle),this.maxAzimuthAngle=qi(i.maxAzimuthAngle),this.smoothTime=i.smoothTime,this.draggingSmoothTime=i.draggingSmoothTime,this.dollySpeed=i.dollySpeed,this.truckSpeed=i.truckSpeed,this.dollyToCursor=i.dollyToCursor,this._target0.fromArray(i.target0),this._position0.fromArray(i.position0),this._zoom0=i.zoom0,this._focalOffset0.fromArray(i.focalOffset0),this.moveTo(i.target[0],i.target[1],i.target[2],e),ae.setFromVector3(yt.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ae.theta,ae.phi,e),this.dollyTo(ae.radius,e),this.zoomTo(i.zoom,e),this.setFocalOffset(i.focalOffset[0],i.focalOffset[1],i.focalOffset[2],e),this._needsUpdate=!0}connect(t){this._domElement?console.warn("camera-controls is already connected."):(t.setAttribute("data-camera-controls-version","3.1.2"),this._addAllEventListeners(t),this._getClientRect(this._elementRect))}disconnect(){this.cancel(),this._removeAllEventListeners(),this._domElement&&(this._domElement.removeAttribute("data-camera-controls-version"),this._domElement=void 0)}dispose(){this.removeAllEventListeners(),this.disconnect()}_getTargetDirection(t){return t.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(t){return this._getTargetDirection(t).negate()}_findPointerById(t){return this._activePointers.find(e=>e.pointerId===t)}_findPointerByMouseButton(t){return this._activePointers.find(e=>e.mouseButton===t)}_disposePointer(t){this._activePointers.splice(this._activePointers.indexOf(t),1)}_encloseToBoundary(t,e,i){const s=e.lengthSq();if(0===s)return t;const n=Ct.copy(e).add(t),a=this._boundary.clampPoint(n,yi).sub(n),l=a.lengthSq();if(0===l)return t.add(e);if(l===s)return t;if(0===i)return t.add(e).add(a);{const c=1+i*l/e.dot(a);return t.add(Ct.copy(e).multiplyScalar(c)).add(a.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(Oe(this._camera)){const t=this._camera,e=t.near,i=t.getEffectiveFOV()*Mt,s=Math.tan(.5*i)*e,n=s*t.aspect;this._nearPlaneCorners[0].set(-n,-s,0),this._nearPlaneCorners[1].set(n,-s,0),this._nearPlaneCorners[2].set(n,s,0),this._nearPlaneCorners[3].set(-n,s,0)}else if(Nt(this._camera)){const t=this._camera,e=1/t.zoom,i=t.left*e,s=t.right*e,n=t.top*e,o=t.bottom*e;this._nearPlaneCorners[0].set(i,n,0),this._nearPlaneCorners[1].set(s,n,0),this._nearPlaneCorners[2].set(s,o,0),this._nearPlaneCorners[3].set(i,o,0)}}_truckInternal=(t,e,i,s)=>{let n,o;if(Oe(this._camera)){const a=yt.copy(this._camera.position).sub(this._target),l=this._camera.getEffectiveFOV()*Mt,c=a.length()*Math.tan(.5*l);n=this.truckSpeed*t*c/this._elementRect.height,o=this.truckSpeed*e*c/this._elementRect.height}else{if(!Nt(this._camera))return;{const a=this._camera;n=this.truckSpeed*t*(a.right-a.left)/a.zoom/this._elementRect.width,o=this.truckSpeed*e*(a.top-a.bottom)/a.zoom/this._elementRect.height}}s?(i?this.setFocalOffset(this._focalOffsetEnd.x+n,this._focalOffsetEnd.y,this._focalOffsetEnd.z,!0):this.truck(n,0,!0),this.forward(-o,!0)):i?this.setFocalOffset(this._focalOffsetEnd.x+n,this._focalOffsetEnd.y+o,this._focalOffsetEnd.z,!0):this.truck(n,o,!0)};_rotateInternal=(t,e)=>{this.rotate(ze*this.azimuthRotateSpeed*t/this._elementRect.height,ze*this.polarRotateSpeed*e/this._elementRect.height,!0)};_dollyInternal=(t,e,i)=>{const s=Math.pow(.95,-t*this.dollySpeed),n=this._sphericalEnd.radius,o=this._sphericalEnd.radius*s,a=de(o,this.minDistance,this.maxDistance),l=a-o;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(o,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(l,!0),this._dollyToNoClamp(a,!0)):this._dollyToNoClamp(a,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?o:a)-n,this._dollyControlCoord.set(e,i)),this._lastDollyDirection=Math.sign(-t)};_zoomInternal=(t,e,i)=>{const s=Math.pow(.95,t*this.dollySpeed),n=this._zoom,o=this._zoom*s;this.zoomTo(o,!0),this.dollyToCursor&&(this._changedZoom+=o-n,this._dollyControlCoord.set(e,i))};_collisionTest(){let t=1/0;if(!(this.colliderMeshes.length>=1)||Cn(this._camera,"_collisionTest"))return t;const i=this._getTargetDirection(Gi);En.lookAt(xo,i,this._camera.up);for(let s=0;s<4;s++){const n=Ct.copy(this._nearPlaneCorners[s]);n.applyMatrix4(En);const o=yi.addVectors(this._target,n);vs.set(o,i),vs.far=this._spherical.radius+1;const a=vs.intersectObjects(this.colliderMeshes);0!==a.length&&a[0].distance<t&&(t=a[0].distance)}return t}_getClientRect(t){if(!this._domElement)return;const e=this._domElement.getBoundingClientRect();return t.x=e.left,t.y=e.top,this._viewport?(t.x+=this._viewport.x,t.y+=e.height-this._viewport.w-this._viewport.y,t.width=this._viewport.z,t.height=this._viewport.w):(t.width=e.width,t.height=e.height),t}_createOnRestPromise(t){return t?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(e=>{const i=()=>{this.removeEventListener("rest",i),e()};this.addEventListener("rest",i)}))}_addAllEventListeners(t){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(t){console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.")}get draggingDampingFactor(){return console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead."),0}set draggingDampingFactor(t){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(t,e=new gt.Sphere){const i=e,s=i.center;vi.makeEmpty(),t.traverseVisible(o=>{o.isMesh&&vi.expandByObject(o)}),vi.getCenter(s);let n=0;return t.traverseVisible(o=>{if(!o.isMesh)return;const a=o;if(!a.geometry)return;const l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const h=l.attributes.position;for(let u=0,f=h.count;u<f;u++)yt.fromBufferAttribute(h,u),n=Math.max(n,s.distanceToSquared(yt))}),i.radius=Math.sqrt(n),i}}var sh=mt(8785),rh=Object.defineProperty,y=(r,t,e)=>(((r,t,e)=>{t in r?rh(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e})(r,"symbol"!=typeof t?t+"":t,e),e);class Q{constructor(){y(this,"enabled",!0),y(this,"trigger",t=>{if(!this.enabled)return;const e=this.handlers.slice(0);for(const i of e)i(t)}),y(this,"handlers",[])}add(t){this.handlers.push(t)}remove(t){this.handlers=this.handlers.filter(e=>e!==t)}reset(){this.handlers.length=0}}class An{constructor(t){y(this,"isDisposeable",()=>"dispose"in this&&"onDisposed"in this),y(this,"isResizeable",()=>"resize"in this&&"getSize"in this),y(this,"isUpdateable",()=>"onAfterUpdate"in this&&"onBeforeUpdate"in this&&"update"in this),y(this,"isHideable",()=>"visible"in this),y(this,"isConfigurable",()=>"setup"in this&&"config"in this&&"onSetup"in this),y(this,"isSerializable",()=>"import"in this&&"export"in this),this.components=t}}class At extends An{}class Mn extends An{constructor(t){super(t),y(this,"worlds",new ot.jp),y(this,"onWorldChanged",new Q),y(this,"_currentWorld",null),this.onWorldChanged.add(({world:e,action:i})=>{"removed"===i&&this.worlds.delete(e.uuid)})}set currentWorld(t){this._currentWorld=t}get currentWorld(){return this._currentWorld}}class ah extends Mn{constructor(){super(...arguments),y(this,"hasCameraControls",()=>"controls"in this)}}const Ao=class po extends At{constructor(t){super(t),y(this,"_disposedComponents",new Set),y(this,"enabled",!0),t.add(po.uuid,this)}get(){return this._disposedComponents}destroy(t,e=!0,i=!0){t.removeFromParent();const s=t;s.dispose&&s.dispose(),this.disposeGeometryAndMaterials(t,e),i&&s.children&&s.children.length&&this.disposeChildren(s),t.children.length=0}disposeGeometry(t){t.boundsTree&&t.disposeBoundsTree&&t.disposeBoundsTree(),t.dispose()}disposeGeometryAndMaterials(t,e){const i=t;i.geometry&&this.disposeGeometry(i.geometry),e&&i.material&&po.disposeMaterial(i),i.material=[],i.geometry=null}disposeChildren(t){for(const e of t.children)this.destroy(e)}static disposeMaterial(t){if(t.material)if(Array.isArray(t.material))for(const e of t.material)e.dispose();else t.material.dispose()}};y(Ao,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let bi=Ao;class ch extends Mn{constructor(t){super(t),y(this,"onDisposed",new Q),y(this,"directionalLights",new Map),y(this,"ambientLights",new Map)}dispose(){const t=this.components.get(bi);for(const e of this.three.children)e.geometry&&t.destroy(e);this.deleteAllLights(),this.three.children=[],this.onDisposed.trigger(),this.onDisposed.reset()}deleteAllLights(){for(const[,t]of this.directionalLights)t.removeFromParent(),t.target.removeFromParent(),t.dispose();this.directionalLights.clear();for(const[,t]of this.ambientLights)t.removeFromParent(),t.dispose();this.ambientLights.clear()}}Set;const In=class Gt{static create(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0;return`${Gt._lut[255&t]+Gt._lut[t>>8&255]+Gt._lut[t>>16&255]+Gt._lut[t>>24&255]}-${Gt._lut[255&e]}${Gt._lut[e>>8&255]}-${Gt._lut[e>>16&15|64]}${Gt._lut[e>>24&255]}-${Gt._lut[63&i|128]}${Gt._lut[i>>8&255]}-${Gt._lut[i>>16&255]}${Gt._lut[i>>24&255]}${Gt._lut[255&s]}${Gt._lut[s>>8&255]}${Gt._lut[s>>16&255]}${Gt._lut[s>>24&255]}`.toLowerCase()}static validate(t){if(!Gt._pattern.test(t))throw new Error(`${t} is not a valid UUID v4.\n\n- If you're the tool creator, you can take one from https://www.uuidgenerator.net/.\n\n- If you're using a platform tool, verify the uuid isn't misspelled or contact the tool creator.`)}};y(In,"_pattern",/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/),y(In,"_lut",["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"]);let ie=In;const Mo=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",dh=new RegExp("^["+Mo+"]["+Mo+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function Io(r,t){const e=[];let i=t.exec(r);for(;i;){const s=[];s.startIndex=t.lastIndex-i[0].length;const n=i.length;for(let o=0;o<n;o++)s.push(i[o]);e.push(s),i=t.exec(r)}return e}const bs=function(r){const t=dh.exec(r);return!(null===t||typeof t>"u")},On=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Oo=["__proto__","constructor","prototype"],ph={allowBooleanAttributes:!1,unpairedTags:[]};function zo(r){return" "===r||"\t"===r||"\n"===r||"\r"===r}function Do(r,t){const e=t;for(;t<r.length;t++)if("?"==r[t]||" "==r[t]){const i=r.substr(e,t-e);if(t>5&&"xml"===i)return Bt("InvalidXml","XML declaration allowed only at the start of the document.",Kt(r,t));if("?"==r[t]&&">"==r[t+1]){t++;break}continue}return t}function ko(r,t){if(r.length>t+5&&"-"===r[t+1]&&"-"===r[t+2]){for(t+=3;t<r.length;t++)if("-"===r[t]&&"-"===r[t+1]&&">"===r[t+2]){t+=2;break}}else if(r.length>t+8&&"D"===r[t+1]&&"O"===r[t+2]&&"C"===r[t+3]&&"T"===r[t+4]&&"Y"===r[t+5]&&"P"===r[t+6]&&"E"===r[t+7]){let e=1;for(t+=8;t<r.length;t++)if("<"===r[t])e++;else if(">"===r[t]&&(e--,0===e))break}else if(r.length>t+9&&"["===r[t+1]&&"C"===r[t+2]&&"D"===r[t+3]&&"A"===r[t+4]&&"T"===r[t+5]&&"A"===r[t+6]&&"["===r[t+7])for(t+=8;t<r.length;t++)if("]"===r[t]&&"]"===r[t+1]&&">"===r[t+2]){t+=2;break}return t}function yh(r,t){let e="",i="",s=!1;for(;t<r.length;t++){if('"'===r[t]||"'"===r[t])""===i?i=r[t]:i!==r[t]||(i="");else if(">"===r[t]&&""===i){s=!0;break}e+=r[t]}return""===i&&{value:e,index:t,tagClosed:s}}const wh=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function Lo(r,t){const e=Io(r,wh),i={};for(let s=0;s<e.length;s++){if(0===e[s][1].length)return Bt("InvalidAttr","Attribute '"+e[s][2]+"' has no space in starting.",Yi(e[s]));if(void 0!==e[s][3]&&void 0===e[s][4])return Bt("InvalidAttr","Attribute '"+e[s][2]+"' is without value.",Yi(e[s]));if(void 0===e[s][3]&&!t.allowBooleanAttributes)return Bt("InvalidAttr","boolean attribute '"+e[s][2]+"' is not allowed.",Yi(e[s]));const n=e[s][2];if(!xh(n))return Bt("InvalidAttr","Attribute '"+n+"' is an invalid name.",Yi(e[s]));if(Object.prototype.hasOwnProperty.call(i,n))return Bt("InvalidAttr","Attribute '"+n+"' is repeated.",Yi(e[s]));i[n]=1}return!0}function bh(r,t){if(";"===r[++t])return-1;if("#"===r[t])return function vh(r,t){let e=/\d/;for("x"===r[t]&&(t++,e=/[\da-fA-F]/);t<r.length;t++){if(";"===r[t])return t;if(!r[t].match(e))break}return-1}(r,++t);let e=0;for(;t<r.length;t++,e++)if(!(r[t].match(/\w/)&&e<20)){if(";"===r[t])break;return-1}return t}function Bt(r,t,e){return{err:{code:r,msg:t,line:e.line||e,col:e.col}}}function xh(r){return bs(r)}function Ch(r){return bs(r)}function Kt(r,t){const e=r.substring(0,t).split(/\r?\n/);return{line:e.length,col:e[e.length-1].length+1}}function Yi(r){return r.startIndex+r[1].length}const Th={cent:"\xa2",pound:"\xa3",curren:"\xa4",yen:"\xa5",euro:"\u20ac",dollar:"$",euro:"\u20ac",fnof:"\u0192",inr:"\u20b9",af:"\u060b",birr:"\u1265\u122d",peso:"\u20b1",rub:"\u20bd",won:"\u20a9",yuan:"\xa5",cedil:"\xb8"},No={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},Ph={nbsp:"\xa0",copy:"\xa9",reg:"\xae",trade:"\u2122",mdash:"\u2014",ndash:"\u2013",hellip:"\u2026",laquo:"\xab",raquo:"\xbb",lsquo:"\u2018",rsquo:"\u2019",ldquo:"\u201c",rdquo:"\u201d",bull:"\u2022",para:"\xb6",sect:"\xa7",deg:"\xb0",frac12:"\xbd",frac14:"\xbc",frac34:"\xbe"},Sh=new Set("!?\\\\/[]$%{}^&*()<>|+");function Bo(r){if("#"===r[0])throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${r}"`);for(const t of r)if(Sh.has(t))throw new Error(`[EntityReplacer] Invalid character '${t}' in entity name: "${r}"`);return r}function zn(...r){const t=Object.create(null);for(const e of r)if(e)for(const i of Object.keys(e)){const s=e[i];if("string"==typeof s)t[i]=s;else if(s&&"object"==typeof s&&void 0!==s.val){const n=s.val;"string"==typeof n&&(t[i]=n)}}return t}const li="external",xs="base",se=Object.freeze({allow:0,leave:1,remove:2,throw:3}),Ah=new Set([9,10,13]);class Ih{constructor(t={}){this._limit=t.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck="function"==typeof t.postCheck?t.postCheck:i=>i,this._limitTiers=function Eh(r){return r&&r!==li?"all"===r?new Set(["all"]):r===xs?new Set([xs]):Array.isArray(r)?new Set(r):new Set([li]):new Set([li])}(this._limit.applyLimitsTo??li),this._numericAllowed=t.numericAllowed??!0,this._baseMap=zn(No,t.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(t.remove&&Array.isArray(t.remove)?t.remove:[]),this._leaveSet=new Set(t.leave&&Array.isArray(t.leave)?t.leave:[]);const e=function Mh(r){return r?{xmlVersion:1.1===r.xmlVersion?1.1:1,onLevel:se[r.onNCR]??se.allow,nullLevel:Math.max(se[r.nullNCR]??se.remove,se.remove)}:{xmlVersion:1,onLevel:se.allow,nullLevel:se.remove}}(t.ncr);this._ncrXmlVersion=e.xmlVersion,this._ncrOnLevel=e.onLevel,this._ncrNullLevel=e.nullLevel}setExternalEntities(t){if(t)for(const e of Object.keys(t))Bo(e);this._externalMap=zn(t)}addExternalEntity(t,e){Bo(t),"string"==typeof e&&-1===e.indexOf("&")&&(this._externalMap[t]=e)}addInputEntities(t){this._totalExpansions=0,this._expandedLength=0,this._inputMap=zn(t)}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(t){this._ncrXmlVersion=1.1===t?1.1:1}decode(t){if("string"!=typeof t||0===t.length)return t;const e=t,i=[],s=t.length;let n=0,o=0;const a=this._maxTotalExpansions>0,l=this._maxExpandedLength>0,c=a||l;for(;o<s;){if(38!==t.charCodeAt(o)){o++;continue}let u=o+1;for(;u<s&&59!==t.charCodeAt(u)&&u-o<=32;)u++;if(u>=s||59!==t.charCodeAt(u)){o++;continue}const f=t.slice(o+1,u);if(0===f.length){o++;continue}let d,_;if(this._removeSet.has(f))d="",void 0===_&&(_=li);else{if(this._leaveSet.has(f)){o++;continue}if(35===f.charCodeAt(0)){const m=this._resolveNCR(f);if(void 0===m){o++;continue}d=m,_=xs}else{const m=this._resolveName(f);d=m?.value,_=m?.tier}}if(void 0!==d){if(o>n&&i.push(t.slice(n,o)),i.push(d),n=u+1,o=n,c&&this._tierCounts(_)){if(a&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(l){const m=d.length-(f.length+2);if(m>0&&(this._expandedLength+=m,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}else o++}n<s&&i.push(t.slice(n));const h=0===i.length?t:i.join("");return this._postCheck(h,e)}_tierCounts(t){return!!this._limitTiers.has("all")||this._limitTiers.has(t)}_resolveName(t){return t in this._inputMap?{value:this._inputMap[t],tier:li}:t in this._externalMap?{value:this._externalMap[t],tier:li}:t in this._baseMap?{value:this._baseMap[t],tier:xs}:void 0}_classifyNCR(t){return 0===t?this._ncrNullLevel:t>=55296&&t<=57343||1===this._ncrXmlVersion&&t>=1&&t<=31&&!Ah.has(t)?se.remove:-1}_applyNCRAction(t,e,i){switch(t){case se.allow:return String.fromCodePoint(i);case se.remove:return"";case se.leave:return;case se.throw:throw new Error(`[EntityDecoder] Prohibited numeric character reference &${e}; (U+${i.toString(16).toUpperCase().padStart(4,"0")})`);default:return String.fromCodePoint(i)}}_resolveNCR(t){const e=t.charCodeAt(1);let i;if(i=120===e||88===e?parseInt(t.slice(2),16):parseInt(t.slice(1),10),Number.isNaN(i)||i<0||i>1114111)return;const s=this._classifyNCR(i);if(!this._numericAllowed&&s<se.remove)return;const n=-1===s?this._ncrOnLevel:Math.max(this._ncrOnLevel,s);return this._applyNCRAction(n,t,i)}}const Ro=r=>On.includes(r)?"__"+r:r,Oh={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(r,t){return t},attributeValueProcessor:function(r,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(r,t,e){return r},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:Ro};function zh(r,t){if("string"!=typeof r)return;const e=r.toLowerCase();if(On.some(i=>e===i.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${r}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Oo.some(i=>e===i.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${r}" is a reserved JavaScript keyword that could cause prototype pollution`)}function Fo(r,t){return"boolean"==typeof r?{enabled:r,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:"all"}:"object"==typeof r&&null!==r?{enabled:!1!==r.enabled,maxEntitySize:Math.max(1,r.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,r.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,r.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,r.maxExpandedLength??1e5),maxEntityCount:Math.max(1,r.maxEntityCount??1e3),allowedTags:r.allowedTags??null,tagFilter:r.tagFilter??null,appliesTo:r.appliesTo??"all"}:Fo(!0)}const Dh=function(r){const t=Object.assign({},Oh,r),e=[{value:t.attributeNamePrefix,name:"attributeNamePrefix"},{value:t.attributesGroupName,name:"attributesGroupName"},{value:t.textNodeName,name:"textNodeName"},{value:t.cdataPropName,name:"cdataPropName"},{value:t.commentPropName,name:"commentPropName"}];for(const{value:i,name:s}of e)i&&zh(i,s);return null===t.onDangerousProperty&&(t.onDangerousProperty=Ro),t.processEntities=Fo(t.processEntities),t.unpairedTagsSet=new Set(t.unpairedTags),t.stopNodes&&Array.isArray(t.stopNodes)&&(t.stopNodes=t.stopNodes.map(i=>"string"==typeof i&&i.startsWith("*.")?".."+i.substring(2):i)),t};let Cs;Cs="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class Ge{constructor(t){this.tagname=t,this.child=[],this[":@"]=Object.create(null)}add(t,e){"__proto__"===t&&(t="#__proto__"),this.child.push({[t]:e})}addChild(t,e){"__proto__"===t.tagname&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,":@":t[":@"]}):this.child.push({[t.tagname]:t.child}),void 0!==e&&(this.child[this.child.length-1][Cs]={startIndex:e})}static getMetaDataSymbol(){return Cs}}class kh{constructor(t){this.suppressValidationErr=!t,this.options=t}readDocType(t,e){const i=Object.create(null);let s=0;if("O"!==t[e+3]||"C"!==t[e+4]||"T"!==t[e+5]||"Y"!==t[e+6]||"P"!==t[e+7]||"E"!==t[e+8])throw new Error("Invalid Tag instead of DOCTYPE");{e+=9;let n=1,o=!1,a=!1,l="";for(;e<t.length;e++)if("<"!==t[e]||a)if(">"===t[e]){if(a?"-"===t[e-1]&&"-"===t[e-2]&&(a=!1,n--):n--,0===n)break}else"["===t[e]?o=!0:l+=t[e];else{if(o&&ci(t,"!ENTITY",e)){let c,h;if(e+=7,[c,h,e]=this.readEntityExp(t,e+1,this.suppressValidationErr),-1===h.indexOf("&")){if(!1!==this.options.enabled&&null!=this.options.maxEntityCount&&s>=this.options.maxEntityCount)throw new Error(`Entity count (${s+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);i[c]=h,s++}}else if(o&&ci(t,"!ELEMENT",e)){e+=8;const{index:c}=this.readElementExp(t,e+1);e=c}else if(o&&ci(t,"!ATTLIST",e))e+=8;else if(o&&ci(t,"!NOTATION",e)){e+=9;const{index:c}=this.readNotationExp(t,e+1,this.suppressValidationErr);e=c}else{if(!ci(t,"!--",e))throw new Error("Invalid DOCTYPE");a=!0}n++,l=""}if(0!==n)throw new Error("Unclosed DOCTYPE")}return{entities:i,i:e}}readEntityExp(t,e){const i=e=ne(t,e);for(;e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)e++;let s=t.substring(i,e);if(Zi(s),e=ne(t,e),!this.suppressValidationErr){if("SYSTEM"===t.substring(e,e+6).toUpperCase())throw new Error("External entities are not supported");if("%"===t[e])throw new Error("Parameter entities are not supported")}let n="";if([e,n]=this.readIdentifierVal(t,e,"entity"),!1!==this.options.enabled&&null!=this.options.maxEntitySize&&n.length>this.options.maxEntitySize)throw new Error(`Entity "${s}" size (${n.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[s,n,--e]}readNotationExp(t,e){const i=e=ne(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let s=t.substring(i,e);!this.suppressValidationErr&&Zi(s),e=ne(t,e);const n=t.substring(e,e+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==n&&"PUBLIC"!==n)throw new Error(`Expected SYSTEM or PUBLIC, found "${n}"`);e=ne(t,e+=n.length);let o=null,a=null;if("PUBLIC"===n)[e,o]=this.readIdentifierVal(t,e,"publicIdentifier"),('"'===t[e=ne(t,e)]||"'"===t[e])&&([e,a]=this.readIdentifierVal(t,e,"systemIdentifier"));else if("SYSTEM"===n&&([e,a]=this.readIdentifierVal(t,e,"systemIdentifier"),!this.suppressValidationErr&&!a))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:s,publicIdentifier:o,systemIdentifier:a,index:--e}}readIdentifierVal(t,e,i){let s="";const n=t[e];if('"'!==n&&"'"!==n)throw new Error(`Expected quoted string, found "${n}"`);const o=++e;for(;e<t.length&&t[e]!==n;)e++;if(s=t.substring(o,e),t[e]!==n)throw new Error(`Unterminated ${i} value`);return[++e,s]}readElementExp(t,e){const i=e=ne(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let s=t.substring(i,e);if(!this.suppressValidationErr&&!bs(s))throw new Error(`Invalid element name: "${s}"`);let n="";if("E"===t[e=ne(t,e)]&&ci(t,"MPTY",e))e+=4;else if("A"===t[e]&&ci(t,"NY",e))e+=2;else if("("===t[e]){const o=++e;for(;e<t.length&&")"!==t[e];)e++;if(n=t.substring(o,e),")"!==t[e])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${t[e]}"`);return{elementName:s,contentModel:n.trim(),index:e}}readAttlistExp(t,e){let i=e=ne(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let s=t.substring(i,e);for(Zi(s),i=e=ne(t,e);e<t.length&&!/\s/.test(t[e]);)e++;let n=t.substring(i,e);if(!Zi(n))throw new Error(`Invalid attribute name: "${n}"`);e=ne(t,e);let o="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(o="NOTATION","("!==t[e=ne(t,e+=8)])throw new Error(`Expected '(', found "${t[e]}"`);e++;let l=[];for(;e<t.length&&")"!==t[e];){const c=e;for(;e<t.length&&"|"!==t[e]&&")"!==t[e];)e++;let h=t.substring(c,e);if(h=h.trim(),!Zi(h))throw new Error(`Invalid notation name: "${h}"`);l.push(h),"|"===t[e]&&(e++,e=ne(t,e))}if(")"!==t[e])throw new Error("Unterminated list of notations");e++,o+=" ("+l.join("|")+")"}else{const l=e;for(;e<t.length&&!/\s/.test(t[e]);)e++;if(o+=t.substring(l,e),!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(o.toUpperCase()))throw new Error(`Invalid attribute type: "${o}"`)}e=ne(t,e);let a="";return"#REQUIRED"===t.substring(e,e+8).toUpperCase()?(a="#REQUIRED",e+=8):"#IMPLIED"===t.substring(e,e+7).toUpperCase()?(a="#IMPLIED",e+=7):[e,a]=this.readIdentifierVal(t,e,"ATTLIST"),{elementName:s,attributeName:n,attributeType:o,defaultValue:a,index:e}}}const ne=(r,t)=>{for(;t<r.length&&/\s/.test(r[t]);)t++;return t};function ci(r,t,e){for(let i=0;i<t.length;i++)if(t[i]!==r[e+i+1])return!1;return!0}function Zi(r){if(bs(r))return r;throw new Error(`Invalid entity name ${r}`)}const Lh=/^[-+]?0x[a-fA-F0-9]+$/,Nh=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Bh={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};const Fh=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;class xi{constructor(t,e={},i){this.pattern=t,this.separator=e.separator||".",this.segments=this._parse(t),this.data=i,this._hasDeepWildcard=this.segments.some(s=>"deep-wildcard"===s.type),this._hasAttributeCondition=this.segments.some(s=>void 0!==s.attrName),this._hasPositionSelector=this.segments.some(s=>void 0!==s.position)}_parse(t){const e=[];let i=0,s="";for(;i<t.length;)t[i]===this.separator?i+1<t.length&&t[i+1]===this.separator?(s.trim()&&(e.push(this._parseSegment(s.trim())),s=""),e.push({type:"deep-wildcard"}),i+=2):(s.trim()&&e.push(this._parseSegment(s.trim())),s="",i++):(s+=t[i],i++);return s.trim()&&e.push(this._parseSegment(s.trim())),e}_parseSegment(t){const e={type:"tag"};let i=null,s=t;const n=t.match(/^([^\[]+)(\[[^\]]*\])(.*)$/);if(n&&(s=n[1]+n[3],n[2])){const h=n[2].slice(1,-1);h&&(i=h)}let o,a=s;if(s.includes("::")){const h=s.indexOf("::");if(o=s.substring(0,h).trim(),a=s.substring(h+2).trim(),!o)throw new Error(`Invalid namespace in pattern: ${t}`)}let l,c=null;if(a.includes(":")){const h=a.lastIndexOf(":"),u=a.substring(0,h).trim(),f=a.substring(h+1).trim();["first","last","odd","even"].includes(f)||/^nth\(\d+\)$/.test(f)?(l=u,c=f):l=a}else l=a;if(!l)throw new Error(`Invalid segment pattern: ${t}`);if(e.tag=l,o&&(e.namespace=o),i)if(i.includes("=")){const h=i.indexOf("=");e.attrName=i.substring(0,h).trim(),e.attrValue=i.substring(h+1).trim()}else e.attrName=i.trim();if(c){const h=c.match(/^nth\((\d+)\)$/);h?(e.position="nth",e.positionValue=parseInt(h[1],10)):e.position=c}return e}get length(){return this.segments.length}hasDeepWildcard(){return this._hasDeepWildcard}hasAttributeCondition(){return this._hasAttributeCondition}hasPositionSelector(){return this._hasPositionSelector}toString(){return this.pattern}}class qh{constructor(){this._byDepthAndTag=new Map,this._wildcardByDepth=new Map,this._deepWildcards=[],this._patterns=new Set,this._sealed=!1}add(t){if(this._sealed)throw new TypeError("ExpressionSet is sealed. Create a new ExpressionSet to add more expressions.");if(this._patterns.has(t.pattern))return this;if(this._patterns.add(t.pattern),t.hasDeepWildcard())return this._deepWildcards.push(t),this;const e=t.length,i=t.segments[t.segments.length-1],s=i?.tag;if(s&&"*"!==s){const n=`${e}:${s}`;this._byDepthAndTag.has(n)||this._byDepthAndTag.set(n,[]),this._byDepthAndTag.get(n).push(t)}else this._wildcardByDepth.has(e)||this._wildcardByDepth.set(e,[]),this._wildcardByDepth.get(e).push(t);return this}addAll(t){for(const e of t)this.add(e);return this}has(t){return this._patterns.has(t.pattern)}get size(){return this._patterns.size}seal(){return this._sealed=!0,this}get isSealed(){return this._sealed}matchesAny(t){return null!==this.findMatch(t)}findMatch(t){const e=t.getDepth(),i=t.getCurrentTag(),n=this._byDepthAndTag.get(`${e}:${i}`);if(n)for(let a=0;a<n.length;a++)if(t.matches(n[a]))return n[a];const o=this._wildcardByDepth.get(e);if(o)for(let a=0;a<o.length;a++)if(t.matches(o[a]))return o[a];for(let a=0;a<this._deepWildcards.length;a++)if(t.matches(this._deepWildcards[a]))return this._deepWildcards[a];return null}}class Gh{constructor(t){this._matcher=t}get separator(){return this._matcher.separator}getCurrentTag(){const t=this._matcher.path;return t.length>0?t[t.length-1].tag:void 0}getCurrentNamespace(){const t=this._matcher.path;return t.length>0?t[t.length-1].namespace:void 0}getAttrValue(t){var e;const i=this._matcher.path;if(0!==i.length)return null==(e=i[i.length-1].values)?void 0:e[t]}hasAttr(t){const e=this._matcher.path;if(0===e.length)return!1;const i=e[e.length-1];return void 0!==i.values&&t in i.values}getPosition(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].position??0}getCounter(){const t=this._matcher.path;return 0===t.length?-1:t[t.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(t,e=!0){return this._matcher.toString(t,e)}toArray(){return this._matcher.path.map(t=>t.tag)}matches(t){return this._matcher.matches(t)}matchesAny(t){return t.matchesAny(this._matcher)}}class kn{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new Gh(this)}push(t,e=null,i=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);const s=this.path.length;this.siblingStacks[s]||(this.siblingStacks[s]=new Map);const n=this.siblingStacks[s],o=i?`${i}:${t}`:t,a=n.get(o)||0;let l=0;for(const h of n.values())l+=h;n.set(o,a+1);const c={tag:t,position:l,counter:a};null!=i&&(c.namespace=i),null!=e&&(c.values=e),this.path.push(c)}pop(){if(0===this.path.length)return;this._pathStringCache=null;const t=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),t}updateCurrent(t){this.path.length>0&&null!=t&&(this.path[this.path.length-1].values=t)}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(t){var e;if(0!==this.path.length)return null==(e=this.path[this.path.length-1].values)?void 0:e[t]}hasAttr(t){if(0===this.path.length)return!1;const e=this.path[this.path.length-1];return void 0!==e.values&&t in e.values}getPosition(){return 0===this.path.length?-1:this.path[this.path.length-1].position??0}getCounter(){return 0===this.path.length?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(t,e=!0){const i=t||this.separator;if(i===this.separator&&!0===e){if(null!==this._pathStringCache)return this._pathStringCache;const n=this.path.map(o=>o.namespace?`${o.namespace}:${o.tag}`:o.tag).join(i);return this._pathStringCache=n,n}return this.path.map(n=>e&&n.namespace?`${n.namespace}:${n.tag}`:n.tag).join(i)}toArray(){return this.path.map(t=>t.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[]}matches(t){const e=t.segments;return 0!==e.length&&(t.hasDeepWildcard()?this._matchWithDeepWildcard(e):this._matchSimple(e))}_matchSimple(t){if(this.path.length!==t.length)return!1;for(let e=0;e<t.length;e++)if(!this._matchSegment(t[e],this.path[e],e===this.path.length-1))return!1;return!0}_matchWithDeepWildcard(t){let e=this.path.length-1,i=t.length-1;for(;i>=0&&e>=0;){const s=t[i];if("deep-wildcard"===s.type){if(i--,i<0)return!0;const n=t[i];let o=!1;for(let a=e;a>=0;a--)if(this._matchSegment(n,this.path[a],a===this.path.length-1)){e=a-1,i--,o=!0;break}if(!o)return!1}else{if(!this._matchSegment(s,this.path[e],e===this.path.length-1))return!1;e--,i--}}return i<0}_matchSegment(t,e,i){if("*"!==t.tag&&t.tag!==e.tag||void 0!==t.namespace&&"*"!==t.namespace&&t.namespace!==e.namespace||void 0!==t.attrName&&(!i||!e.values||!(t.attrName in e.values)||void 0!==t.attrValue&&String(e.values[t.attrName])!==String(t.attrValue)))return!1;if(void 0!==t.position){if(!i)return!1;const s=e.counter??0;if("first"===t.position&&0!==s)return!1;if("odd"===t.position&&s%2!=1)return!1;if("even"===t.position&&s%2!=0)return!1;if("nth"===t.position&&s!==t.positionValue)return!1}return!0}matchesAny(t){return t.matchesAny(this)}snapshot(){return{path:this.path.map(t=>({...t})),siblingStacks:this.siblingStacks.map(t=>new Map(t))}}restore(t){this._pathStringCache=null,this.path=t.path.map(e=>({...e})),this.siblingStacks=t.siblingStacks.map(e=>new Map(e))}readOnly(){return this._view}}function Yh(r,t){if(!r)return{};const e=t.attributesGroupName?r[t.attributesGroupName]:r;if(!e)return{};const i={};for(const s in e)s.startsWith(t.attributeNamePrefix)?i[s.substring(t.attributeNamePrefix.length)]=e[s]:i[s]=e[s];return i}function Zh(r){if(!r||"string"!=typeof r)return;const t=r.indexOf(":");if(-1!==t&&t>0){const e=r.substring(0,t);if("xmlns"!==e)return e}}class Wh{constructor(t,e){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=tu,this.parseTextData=Xh,this.resolveNameSpace=Kh,this.buildAttributesMap=Jh,this.isItStopNode=nu,this.replaceEntitiesValue=iu,this.readStopNodeData=au,this.saveTextToParentTag=su,this.addChild=eu,this.ignoreAttributesFn=function Hh(r){return"function"==typeof r?r:Array.isArray(r)?t=>{for(const e of r)if("string"==typeof e&&t===e||e instanceof RegExp&&e.test(t))return!0}:()=>!1}(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0;let i={...No};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:("object"==typeof this.options.htmlEntities?i=this.options.htmlEntities:!0===this.options.htmlEntities&&(i={...Ph,...Th}),this.entityDecoder=new Ih({namedEntities:{...i,...e},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo}})),this.matcher=new kn,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new qh;const s=this.options.stopNodes;if(s&&s.length>0){for(let n=0;n<s.length;n++){const o=s[n];"string"==typeof o?this.stopNodeExpressionsSet.add(new xi(o)):o instanceof xi&&this.stopNodeExpressionsSet.add(o)}this.stopNodeExpressionsSet.seal()}}}function Xh(r,t,e,i,s,n,o){const a=this.options;if(void 0!==r&&(a.trimValues&&!i&&(r=r.trim()),r.length>0)){o||(r=this.replaceEntitiesValue(r,t,e));const l=a.jPath?e.toString():e,c=a.tagValueProcessor(t,r,l,s,n);return null==c?r:typeof c!=typeof r||c!==r?c:a.trimValues||r.trim()===r?Nn(r,a.parseTagValue,a.numberParseOptions):r}}function Kh(r){if(this.options.removeNSPrefix){const t=r.split(":"),e="/"===r.charAt(0)?"/":"";if("xmlns"===t[0])return"";2===t.length&&(r=e+t[1])}return r}const Qh=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Jh(r,t,e,i=!1){const s=this.options;if(!0===i||!0!==s.ignoreAttributes&&"string"==typeof r){const n=Io(r,Qh),o=n.length,a={},l=new Array(o);let c=!1;const h={};for(let d=0;d<o;d++){const _=this.resolveNameSpace(n[d][1]),m=n[d][4];if(_.length&&void 0!==m){let w=m;s.trimValues&&(w=w.trim()),w=this.replaceEntitiesValue(w,e,this.readonlyMatcher),l[d]=w,h[_]=w,c=!0}}c&&"object"==typeof t&&t.updateCurrent&&t.updateCurrent(h);const u=s.jPath?t.toString():this.readonlyMatcher;let f=!1;for(let d=0;d<o;d++){const _=this.resolveNameSpace(n[d][1]);if(this.ignoreAttributesFn(_,u))continue;let m=s.attributeNamePrefix+_;if(_.length)if(s.transformAttributeName&&(m=s.transformAttributeName(m)),m=Vo(m,s),void 0!==n[d][4]){const w=l[d],g=s.attributeValueProcessor(_,w,u);a[m]=null==g?w:typeof g!=typeof w||g!==w?g:Nn(w,s.parseAttributeValue,s.numberParseOptions),f=!0}else s.allowBooleanAttributes&&(a[m]=!0,f=!0)}if(!f)return;if(s.attributesGroupName&&!s.preserveOrder){const d={};return d[s.attributesGroupName]=a,d}return a}}const tu=function(r){r=r.replace(/\r\n?/g,"\n");const t=new Ge("!xml");let e=t,i="";this.matcher.reset(),this.entityDecoder.reset(),this.entityExpansionCount=0,this.currentExpandedLength=0;const s=this.options,n=new kh(s.processEntities),o=r.length;for(let a=0;a<o;a++)if("<"===r[a]){const c=r.charCodeAt(a+1);if(47===c){const h=Ci(r,">",a,"Closing Tag is not closed.");let u=r.substring(a+2,h).trim();if(s.removeNSPrefix){const d=u.indexOf(":");-1!==d&&(u=u.substr(d+1))}u=Bn(s.transformTagName,u,"",s).tagName,e&&(i=this.saveTextToParentTag(i,e,this.readonlyMatcher));const f=this.matcher.getCurrentTag();if(u&&s.unpairedTagsSet.has(u))throw new Error(`Unpaired tag can not be used as closing tag: </${u}>`);f&&s.unpairedTagsSet.has(f)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,e=this.tagsNodeStack.pop(),i="",a=h}else if(63===c){let h=Ln(r,a,!1,"?>");if(!h)throw new Error("Pi Tag is not closed.");i=this.saveTextToParentTag(i,e,this.readonlyMatcher);const u=this.buildAttributesMap(h.tagExp,this.matcher,h.tagName,!0);if(u&&this.entityDecoder.setXmlVersion(Number(u[this.options.attributeNamePrefix+"version"])||1),!(s.ignoreDeclaration&&"?xml"===h.tagName||s.ignorePiTags)){const f=new Ge(h.tagName);f.add(s.textNodeName,""),h.tagName!==h.tagExp&&h.attrExpPresent&&!0!==s.ignoreAttributes&&(f[":@"]=u),this.addChild(e,f,this.readonlyMatcher,a)}a=h.closeIndex+1}else if(33===c&&45===r.charCodeAt(a+2)&&45===r.charCodeAt(a+3)){const h=Ci(r,"--\x3e",a+4,"Comment is not closed.");if(s.commentPropName){const u=r.substring(a+4,h-2);i=this.saveTextToParentTag(i,e,this.readonlyMatcher),e.add(s.commentPropName,[{[s.textNodeName]:u}])}a=h}else if(33===c&&68===r.charCodeAt(a+2)){const h=n.readDocType(r,a);this.entityDecoder.addInputEntities(h.entities),a=h.i}else if(33===c&&91===r.charCodeAt(a+2)){const h=Ci(r,"]]>",a,"CDATA is not closed.")-2,u=r.substring(a+9,h);i=this.saveTextToParentTag(i,e,this.readonlyMatcher);let f=this.parseTextData(u,e.tagname,this.readonlyMatcher,!0,!1,!0,!0);null==f&&(f=""),s.cdataPropName?e.add(s.cdataPropName,[{[s.textNodeName]:u}]):e.add(s.textNodeName,f),a=h+2}else{let h=Ln(r,a,s.removeNSPrefix);if(!h){const S=r.substring(Math.max(0,a-50),Math.min(o,a+50));throw new Error(`readTagExp returned undefined at position ${a}. Context: "${S}"`)}let u=h.tagName;const f=h.rawTagName;let d=h.tagExp,_=h.attrExpPresent,m=h.closeIndex;if(({tagName:u,tagExp:d}=Bn(s.transformTagName,u,d,s)),s.strictReservedNames&&(u===s.commentPropName||u===s.cdataPropName||u===s.textNodeName||u===s.attributesGroupName))throw new Error(`Invalid tag name: ${u}`);e&&i&&"!xml"!==e.tagname&&(i=this.saveTextToParentTag(i,e,this.readonlyMatcher,!1)),e&&s.unpairedTagsSet.has(e.tagname)&&(e=this.tagsNodeStack.pop(),this.matcher.pop());let g=!1;d.length>0&&d.lastIndexOf("/")===d.length-1&&(g=!0,"/"===u[u.length-1]?(u=u.substr(0,u.length-1),d=u):d=d.substr(0,d.length-1),_=u!==d);let T,v=null;T=Zh(f),u!==t.tagname&&this.matcher.push(u,{},T),u!==d&&_&&(v=this.buildAttributesMap(d,this.matcher,u),v&&Yh(v,s)),u!==t.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());const C=a;if(this.isCurrentNodeStopNode){let S="";if(g)a=h.closeIndex;else if(s.unpairedTagsSet.has(u))a=h.closeIndex;else{const A=this.readStopNodeData(r,f,m+1);if(!A)throw new Error(`Unexpected end of ${f}`);a=A.i,S=A.tagContent}const M=new Ge(u);v&&(M[":@"]=v),M.add(s.textNodeName,S),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(e,M,this.readonlyMatcher,C)}else{if(g){({tagName:u,tagExp:d}=Bn(s.transformTagName,u,d,s));const S=new Ge(u);v&&(S[":@"]=v),this.addChild(e,S,this.readonlyMatcher,C),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(s.unpairedTagsSet.has(u)){const S=new Ge(u);v&&(S[":@"]=v),this.addChild(e,S,this.readonlyMatcher,C),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=h.closeIndex;continue}{const S=new Ge(u);if(this.tagsNodeStack.length>s.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(e),v&&(S[":@"]=v),this.addChild(e,S,this.readonlyMatcher,C),e=S}}i="",a=m}}}else i+=r[a];return t.child};function eu(r,t,e,i){this.options.captureMetaData||(i=void 0);const s=this.options.jPath?e.toString():e,n=this.options.updateTag(t.tagname,s,t[":@"]);!1===n||("string"==typeof n&&(t.tagname=n),r.addChild(t,i))}function iu(r,t,e){const i=this.options.processEntities;if(!i||!i.enabled)return r;if(i.allowedTags){const s=this.options.jPath?e.toString():e;if(!(Array.isArray(i.allowedTags)?i.allowedTags.includes(t):i.allowedTags(t,s)))return r}if(i.tagFilter){const s=this.options.jPath?e.toString():e;if(!i.tagFilter(t,s))return r}return this.entityDecoder.decode(r)}function su(r,t,e,i){return r&&(void 0===i&&(i=0===t.child.length),void 0!==(r=this.parseTextData(r,t.tagname,e,!1,!!t[":@"]&&0!==Object.keys(t[":@"]).length,i))&&""!==r&&t.add(this.options.textNodeName,r),r=""),r}function nu(){return 0!==this.stopNodeExpressionsSet.size&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function Ci(r,t,e,i){const s=r.indexOf(t,e);if(-1===s)throw new Error(i);return s+t.length-1}function ou(r,t,e,i){const s=r.indexOf(t,e);if(-1===s)throw new Error(i);return s}function Ln(r,t,e,i=">"){const s=function ru(r,t,e=">"){let i=0;const s=r.length,n=e.charCodeAt(0),o=e.length>1?e.charCodeAt(1):-1;let a="",l=t;for(let c=t;c<s;c++){const h=r.charCodeAt(c);if(i)h===i&&(i=0);else if(34===h||39===h)i=h;else if(h===n){if(-1===o)return a+=r.substring(l,c),{data:a,index:c};if(r.charCodeAt(c+1)===o)return a+=r.substring(l,c),{data:a,index:c}}else 9===h&&!i&&(a+=r.substring(l,c)+" ",l=c+1)}}(r,t+1,i);if(!s)return;let n=s.data;const o=s.index,a=n.search(/\s/);let l=n,c=!0;-1!==a&&(l=n.substring(0,a),n=n.substring(a+1).trimStart());const h=l;if(e){const u=l.indexOf(":");-1!==u&&(l=l.substr(u+1),c=l!==s.data.substr(u+1))}return{tagName:l,tagExp:n,closeIndex:o,attrExpPresent:c,rawTagName:h}}function au(r,t,e){const i=e;let s=1;const n=r.length;for(;e<n;e++)if("<"===r[e]){const o=r.charCodeAt(e+1);if(47===o){const a=ou(r,">",e,`${t} is not closed`);if(r.substring(e+2,a).trim()===t&&(s--,0===s))return{tagContent:r.substring(i,e),i:a};e=a}else if(63===o)e=Ci(r,"?>",e+1,"StopNode is not closed.");else if(33===o&&45===r.charCodeAt(e+2)&&45===r.charCodeAt(e+3))e=Ci(r,"--\x3e",e+3,"StopNode is not closed.");else if(33===o&&91===r.charCodeAt(e+2))e=Ci(r,"]]>",e,"StopNode is not closed.")-2;else{const a=Ln(r,e,">");a&&((a&&a.tagName)===t&&"/"!==a.tagExp[a.tagExp.length-1]&&s++,e=a.closeIndex)}}}function Nn(r,t,e){if(t&&"string"==typeof r){const i=r.trim();return"true"===i||"false"!==i&&function Rh(r,t={}){if(t=Object.assign({},Bh,t),!r||"string"!=typeof r)return r;let e=r.trim();if(0===e.length)return r;if(void 0!==t.skipLike&&t.skipLike.test(e))return r;if("0"===e)return 0;if(t.hex&&Lh.test(e))return function $h(r,t){if(parseInt)return parseInt(r,t);if(Number.parseInt)return Number.parseInt(r,t);if(window&&window.parseInt)return window.parseInt(r,t);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(e,16);if(isFinite(e)){if(e.includes("e")||e.includes("E"))return function Vh(r,t,e){if(!e.eNotation)return r;const i=t.match(Fh);if(i){let s=i[1]||"";const n=-1===i[3].indexOf("e")?"E":"e",o=i[2],a=s?r[o.length+1]===n:r[o.length]===n;return o.length>1&&a?r:(1!==o.length||!i[3].startsWith(`.${n}`)&&i[3][0]!==n)&&o.length>0?e.leadingZeros&&!a?(t=(i[1]||"")+i[3],Number(t)):r:Number(t)}return r}(r,e,t);{const i=Nh.exec(e);if(i){const s=i[1]||"",n=i[2];let o=function Uh(r){return r&&-1!==r.indexOf(".")&&("."===(r=r.replace(/0+$/,""))?r="0":"."===r[0]?r="0"+r:"."===r[r.length-1]&&(r=r.substring(0,r.length-1))),r}(i[3]);if(!t.leadingZeros&&(n.length>1||1===n.length&&!(s?"."===r[n.length+1]:"."===r[n.length])))return r;{const l=Number(e),c=String(l);if(0===l)return l;if(-1!==c.search(/[eE]/))return t.eNotation?l:r;if(-1!==e.indexOf("."))return"0"===c||c===o||c===`${s}${o}`?l:r;let h=n?o:e;return n?h===c||s+h===c?l:r:h===c||h===s+c?l:r}}return r}}return function jh(r,t,e){const i=t===1/0;switch(e.infinity.toLowerCase()){case"null":return null;case"infinity":return t;case"string":return i?"Infinity":"-Infinity";default:return r}}(r,Number(e),t)}(r,e)}return function fh(r){return typeof r<"u"}(r)?r:""}function Bn(r,t,e,i){if(r){const s=r(t);e===t&&(e=s),t=s}return{tagName:t=Vo(t,i),tagExp:e}}function Vo(r,t){if(Oo.includes(r))throw new Error(`[SECURITY] Invalid name: "${r}" is a reserved JavaScript keyword that could cause prototype pollution`);return On.includes(r)?t.onDangerousProperty(r):r}const Rn=Ge.getMetaDataSymbol();function lu(r,t){if(!r||"object"!=typeof r)return{};if(!t)return r;const e={};for(const i in r)i.startsWith(t)?e[i.substring(t.length)]=r[i]:e[i]=r[i];return e}function cu(r,t,e,i){return Uo(r,t,e,i)}function Uo(r,t,e,i){let s;const n={};for(let o=0;o<r.length;o++){const a=r[o],l=hu(a);if(void 0!==l&&l!==t.textNodeName){const c=lu(a[":@"]||{},t.attributeNamePrefix);e.push(l,c)}if(l===t.textNodeName)void 0===s?s=a[l]:s+=""+a[l];else{if(void 0===l)continue;if(a[l]){let c=Uo(a[l],t,e,i);const h=du(c,t);if(a[":@"]?uu(c,a[":@"],i,t):1!==Object.keys(c).length||void 0===c[t.textNodeName]||t.alwaysCreateTextNode?0===Object.keys(c).length&&(t.alwaysCreateTextNode?c[t.textNodeName]="":c=""):c=c[t.textNodeName],void 0!==a[Rn]&&"object"==typeof c&&null!==c&&(c[Rn]=a[Rn]),void 0!==n[l]&&Object.prototype.hasOwnProperty.call(n,l))Array.isArray(n[l])||(n[l]=[n[l]]),n[l].push(c);else{const u=t.jPath?i.toString():i;n[l]=t.isArray(l,u,h)?[c]:c}void 0!==l&&l!==t.textNodeName&&e.pop()}}}return"string"==typeof s?s.length>0&&(n[t.textNodeName]=s):void 0!==s&&(n[t.textNodeName]=s),n}function hu(r){const t=Object.keys(r);for(let e=0;e<t.length;e++){const i=t[e];if(":@"!==i)return i}}function uu(r,t,e,i){if(t){const s=Object.keys(t),n=s.length;for(let o=0;o<n;o++){const a=s[o],l=a.startsWith(i.attributeNamePrefix)?a.substring(i.attributeNamePrefix.length):a,c=i.jPath?e.toString()+"."+l:e;r[a]=i.isArray(a,c,!0,!0)?[t[a]]:t[a]}}}function du(r,t){const{textNodeName:e}=t,i=Object.keys(r).length;return!(0!==i&&(1!==i||!r[e]&&"boolean"!=typeof r[e]&&0!==r[e]))}class Fn{constructor(t){this.externalEntities={},this.options=Dh(t)}parse(t,e){if("string"!=typeof t&&t.toString)t=t.toString();else if("string"!=typeof t)throw new Error("XML data is accepted in String or Bytes[] form.");if(e){!0===e&&(e={});const n=function mh(r,t){t=Object.assign({},ph,t);const e=[];let i=!1,s=!1;"\ufeff"===r[0]&&(r=r.substr(1));for(let n=0;n<r.length;n++)if("<"===r[n]&&"?"===r[n+1]){if(n+=2,n=Do(r,n),n.err)return n}else{if("<"!==r[n]){if(zo(r[n]))continue;return Bt("InvalidChar","char '"+r[n]+"' is not expected.",Kt(r,n))}{let o=n;if(n++,"!"===r[n]){n=ko(r,n);continue}{let a=!1;"/"===r[n]&&(a=!0,n++);let l="";for(;n<r.length&&">"!==r[n]&&" "!==r[n]&&"\t"!==r[n]&&"\n"!==r[n]&&"\r"!==r[n];n++)l+=r[n];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),n--),!Ch(l)){let u;return u=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",Bt("InvalidTag",u,Kt(r,n))}const c=yh(r,n);if(!1===c)return Bt("InvalidAttr","Attributes for '"+l+"' have open quote.",Kt(r,n));let h=c.value;if(n=c.index,"/"===h[h.length-1]){const u=n-h.length;h=h.substring(0,h.length-1);const f=Lo(h,t);if(!0!==f)return Bt(f.err.code,f.err.msg,Kt(r,u+f.err.line));i=!0}else if(a){if(!c.tagClosed)return Bt("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Kt(r,n));if(h.trim().length>0)return Bt("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Kt(r,o));if(0===e.length)return Bt("InvalidTag","Closing tag '"+l+"' has not been opened.",Kt(r,o));{const u=e.pop();if(l!==u.tagName){let f=Kt(r,u.tagStartPos);return Bt("InvalidTag","Expected closing tag '"+u.tagName+"' (opened in line "+f.line+", col "+f.col+") instead of closing tag '"+l+"'.",Kt(r,o))}0==e.length&&(s=!0)}}else{const u=Lo(h,t);if(!0!==u)return Bt(u.err.code,u.err.msg,Kt(r,n-h.length+u.err.line));if(!0===s)return Bt("InvalidXml","Multiple possible root nodes found.",Kt(r,n));-1!==t.unpairedTags.indexOf(l)||e.push({tagName:l,tagStartPos:o}),i=!0}for(n++;n<r.length;n++)if("<"===r[n]){if("!"===r[n+1]){n++,n=ko(r,n);continue}if("?"!==r[n+1])break;if(n=Do(r,++n),n.err)return n}else if("&"===r[n]){const u=bh(r,n);if(-1==u)return Bt("InvalidChar","char '&' is not expected.",Kt(r,n));n=u}else if(!0===s&&!zo(r[n]))return Bt("InvalidXml","Extra text at the end",Kt(r,n));"<"===r[n]&&n--}}}return i?1==e.length?Bt("InvalidTag","Unclosed tag '"+e[0].tagName+"'.",Kt(r,e[0].tagStartPos)):!(e.length>0)||Bt("InvalidXml","Invalid '"+JSON.stringify(e.map(n=>n.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):Bt("InvalidXml","Start tag expected.",1)}(t,e);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const i=new Wh(this.options,this.externalEntities),s=i.parseXml(t);return this.options.preserveOrder||void 0===s?s:cu(s,this.options,i.matcher,i.readonlyMatcher)}addEntity(t,e){if(-1!==e.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==t.indexOf("&")||-1!==t.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e}static getMetaDataSymbol(){return Ge.getMetaDataSymbol()}}function pu(r,t){let e="";t.format&&t.indentBy.length>0&&(e="\n");const i=[];if(t.stopNodes&&Array.isArray(t.stopNodes))for(let n=0;n<t.stopNodes.length;n++){const o=t.stopNodes[n];"string"==typeof o?i.push(new xi(o)):o instanceof xi&&i.push(o)}return $o(r,t,e,new kn,i)}function $o(r,t,e,i,s){let n="",o=!1;if(t.maxNestedTags&&i.getDepth()>t.maxNestedTags)throw new Error("Maximum nested tags exceeded");if(!Array.isArray(r)){if(null!=r){let a=r.toString();return a=Vn(a,t),a}return""}for(let a=0;a<r.length;a++){const l=r[a],c=Ho(l);if(void 0===c)continue;const h=mu(l[":@"],t);i.push(c,h);const u=_u(i,s);if(c===t.textNodeName){let w=l[c];u||(w=t.tagValueProcessor(c,w),w=Vn(w,t)),o&&(n+=e),n+=w,o=!1,i.pop();continue}if(c===t.cdataPropName){o&&(n+=e),n+=`<![CDATA[${String(l[c][0][t.textNodeName]).replace(/\]\]>/g,"]]]]><![CDATA[>")}]]>`,o=!1,i.pop();continue}if(c===t.commentPropName){n+=e+`\x3c!--${String(l[c][0][t.textNodeName]).replace(/--/g,"- -").replace(/-$/,"- ")}--\x3e`,o=!0,i.pop();continue}if("?"===c[0]){const w=qo(l[":@"],t,u);let v=l[c][0][t.textNodeName];v=0!==v.length?" "+v:"",n+=("?xml"===c?"":e)+`<${c}${v}${w}?>`,o=!0,i.pop();continue}let f=e;""!==f&&(f+=t.indentBy);const _=e+`<${c}${qo(l[":@"],t,u)}`;let m;m=u?jo(l[c],t):$o(l[c],t,f,i,s),-1!==t.unpairedTags.indexOf(c)?n+=t.suppressUnpairedNode?_+">":_+"/>":m&&0!==m.length||!t.suppressEmptyNode?m&&m.endsWith(">")?n+=_+`>${m}${e}</${c}>`:(n+=_+">",m&&""!==e&&(m.includes("/>")||m.includes("</"))?n+=e+t.indentBy+m+e:n+=m,n+=`</${c}>`):n+=_+"/>",o=!0,i.pop()}return n}function mu(r,t){if(!r||t.ignoreAttributes)return null;const e={};let i=!1;for(let s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s.startsWith(t.attributeNamePrefix)?s.substr(t.attributeNamePrefix.length):s]=r[s],i=!0);return i?e:null}function jo(r,t){if(!Array.isArray(r))return null!=r?r.toString():"";let e="";for(let i=0;i<r.length;i++){const s=r[i],n=Ho(s);if(n===t.textNodeName)e+=s[n];else if(n===t.cdataPropName)e+=s[n][0][t.textNodeName];else if(n===t.commentPropName)e+=s[n][0][t.textNodeName];else{if(n&&"?"===n[0])continue;if(n){const o=gu(s[":@"],t),a=jo(s[n],t);e+=a&&0!==a.length?`<${n}${o}>${a}</${n}>`:`<${n}${o}/>`}}}return e}function gu(r,t){let e="";if(r&&!t.ignoreAttributes)for(let i in r){if(!Object.prototype.hasOwnProperty.call(r,i))continue;let s=r[i];e+=!0===s&&t.suppressBooleanAttributes?` ${i.substr(t.attributeNamePrefix.length)}`:` ${i.substr(t.attributeNamePrefix.length)}="${s}"`}return e}function Ho(r){const t=Object.keys(r);for(let e=0;e<t.length;e++){const i=t[e];if(Object.prototype.hasOwnProperty.call(r,i)&&":@"!==i)return i}}function qo(r,t,e){let i="";if(r&&!t.ignoreAttributes)for(let s in r){if(!Object.prototype.hasOwnProperty.call(r,s))continue;let n;e?n=r[s]:(n=t.attributeValueProcessor(s,r[s]),n=Vn(n,t)),i+=!0===n&&t.suppressBooleanAttributes?` ${s.substr(t.attributeNamePrefix.length)}`:` ${s.substr(t.attributeNamePrefix.length)}="${n}"`}return i}function _u(r,t){if(!t||0===t.length)return!1;for(let e=0;e<t.length;e++)if(r.matches(t[e]))return!0;return!1}function Vn(r,t){if(r&&r.length>0&&t.processEntities)for(let e=0;e<t.entities.length;e++){const i=t.entities[e];r=r.replace(i.regex,i.val)}return r}const wu={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(r,t){return t},attributeValueProcessor:function(r,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0};function fe(r){if(this.options=Object.assign({},wu,r),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(t=>"string"==typeof t&&t.startsWith("*.")?".."+t.substring(2):t)),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(let t=0;t<this.options.stopNodes.length;t++){const e=this.options.stopNodes[t];"string"==typeof e?this.stopNodeExpressions.push(new xi(e)):e instanceof xi&&this.stopNodeExpressions.push(e)}!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=function yu(r){return"function"==typeof r?r:Array.isArray(r)?t=>{for(const e of r)if("string"==typeof e&&t===e||e instanceof RegExp&&e.test(t))return!0}:()=>!1}(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=xu),this.processTextOrObjNode=vu,this.options.format?(this.indentate=bu,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function vu(r,t,e,i){const s=this.extractAttributes(r);if(i.push(t,s),this.checkStopNode(i)){const a=this.buildRawContent(r),l=this.buildAttributesForStopNode(r);return i.pop(),this.buildObjectNode(a,t,l,e)}const o=this.j2x(r,e+1,i);return i.pop(),void 0!==r[this.options.textNodeName]&&1===Object.keys(r).length?this.buildTextValNode(r[this.options.textNodeName],t,o.attrStr,e,i):this.buildObjectNode(o.val,t,o.attrStr,e)}function bu(r){return this.options.indentBy.repeat(r)}function xu(r){return!(!r.startsWith(this.options.attributeNamePrefix)||r===this.options.textNodeName)&&r.substr(this.attrPrefixLen)}fe.prototype.build=function(r){if(this.options.preserveOrder)return pu(r,this.options);{Array.isArray(r)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(r={[this.options.arrayNodeName]:r});const t=new kn;return this.j2x(r,0,t).val}},fe.prototype.j2x=function(r,t,e){let i="",s="";if(this.options.maxNestedTags&&e.getDepth()>=this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");const n=this.options.jPath?e.toString():e,o=this.checkStopNode(e);for(let a in r)if(Object.prototype.hasOwnProperty.call(r,a))if(typeof r[a]>"u")this.isAttribute(a)&&(s+="");else if(null===r[a])this.isAttribute(a)||a===this.options.cdataPropName?s+="":s+="?"===a[0]?this.indentate(t)+"<"+a+"?"+this.tagEndChar:this.indentate(t)+"<"+a+"/"+this.tagEndChar;else if(r[a]instanceof Date)s+=this.buildTextValNode(r[a],a,"",t,e);else if("object"!=typeof r[a]){const l=this.isAttribute(a);if(l&&!this.ignoreAttributesFn(l,n))i+=this.buildAttrPairStr(l,""+r[a],o);else if(!l)if(a===this.options.textNodeName){let c=this.options.tagValueProcessor(a,""+r[a]);s+=this.replaceEntitiesValue(c)}else{e.push(a);const c=this.checkStopNode(e);if(e.pop(),c){const h=""+r[a];s+=""===h?this.indentate(t)+"<"+a+this.closeTag(a)+this.tagEndChar:this.indentate(t)+"<"+a+">"+h+"</"+a+this.tagEndChar}else s+=this.buildTextValNode(r[a],a,"",t,e)}}else if(Array.isArray(r[a])){const l=r[a].length;let c="",h="";for(let u=0;u<l;u++){const f=r[a][u];if(!(typeof f>"u"))if(null===f)s+="?"===a[0]?this.indentate(t)+"<"+a+"?"+this.tagEndChar:this.indentate(t)+"<"+a+"/"+this.tagEndChar;else if("object"==typeof f)if(this.options.oneListGroup){e.push(a);const d=this.j2x(f,t+1,e);e.pop(),c+=d.val,this.options.attributesGroupName&&f.hasOwnProperty(this.options.attributesGroupName)&&(h+=d.attrStr)}else c+=this.processTextOrObjNode(f,a,t,e);else if(this.options.oneListGroup){let d=this.options.tagValueProcessor(a,f);d=this.replaceEntitiesValue(d),c+=d}else{e.push(a);const d=this.checkStopNode(e);if(e.pop(),d){const _=""+f;c+=""===_?this.indentate(t)+"<"+a+this.closeTag(a)+this.tagEndChar:this.indentate(t)+"<"+a+">"+_+"</"+a+this.tagEndChar}else c+=this.buildTextValNode(f,a,"",t,e)}}this.options.oneListGroup&&(c=this.buildObjectNode(c,a,h,t)),s+=c}else if(this.options.attributesGroupName&&a===this.options.attributesGroupName){const l=Object.keys(r[a]),c=l.length;for(let h=0;h<c;h++)i+=this.buildAttrPairStr(l[h],""+r[a][l[h]],o)}else s+=this.processTextOrObjNode(r[a],a,t,e);return{attrStr:i,val:s}},fe.prototype.buildAttrPairStr=function(r,t,e){return e||(t=this.options.attributeValueProcessor(r,""+t),t=this.replaceEntitiesValue(t)),this.options.suppressBooleanAttributes&&"true"===t?" "+r:" "+r+'="'+t+'"'},fe.prototype.extractAttributes=function(r){if(!r||"object"!=typeof r)return null;const t={};let e=!1;if(this.options.attributesGroupName&&r[this.options.attributesGroupName]){const i=r[this.options.attributesGroupName];for(let s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s.startsWith(this.options.attributeNamePrefix)?s.substring(this.options.attributeNamePrefix.length):s]=i[s],e=!0)}else for(let i in r){if(!Object.prototype.hasOwnProperty.call(r,i))continue;const s=this.isAttribute(i);s&&(t[s]=r[i],e=!0)}return e?t:null},fe.prototype.buildRawContent=function(r){if("string"==typeof r)return r;if("object"!=typeof r||null===r)return String(r);if(void 0!==r[this.options.textNodeName])return r[this.options.textNodeName];let t="";for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e)||this.isAttribute(e)||this.options.attributesGroupName&&e===this.options.attributesGroupName)continue;const i=r[e];if(e===this.options.textNodeName)t+=i;else if(Array.isArray(i)){for(let s of i)if("string"==typeof s||"number"==typeof s)t+=`<${e}>${s}</${e}>`;else if("object"==typeof s&&null!==s){const n=this.buildRawContent(s),o=this.buildAttributesForStopNode(s);t+=""===n?`<${e}${o}/>`:`<${e}${o}>${n}</${e}>`}}else if("object"==typeof i&&null!==i){const s=this.buildRawContent(i),n=this.buildAttributesForStopNode(i);t+=""===s?`<${e}${n}/>`:`<${e}${n}>${s}</${e}>`}else t+=`<${e}>${i}</${e}>`}return t},fe.prototype.buildAttributesForStopNode=function(r){if(!r||"object"!=typeof r)return"";let t="";if(this.options.attributesGroupName&&r[this.options.attributesGroupName]){const e=r[this.options.attributesGroupName];for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;const s=i.startsWith(this.options.attributeNamePrefix)?i.substring(this.options.attributeNamePrefix.length):i,n=e[i];t+=!0===n&&this.options.suppressBooleanAttributes?" "+s:" "+s+'="'+n+'"'}}else for(let e in r){if(!Object.prototype.hasOwnProperty.call(r,e))continue;const i=this.isAttribute(e);if(i){const s=r[e];t+=!0===s&&this.options.suppressBooleanAttributes?" "+i:" "+i+'="'+s+'"'}}return t},fe.prototype.buildObjectNode=function(r,t,e,i){if(""===r)return"?"===t[0]?this.indentate(i)+"<"+t+e+"?"+this.tagEndChar:this.indentate(i)+"<"+t+e+this.closeTag(t)+this.tagEndChar;{let s="</"+t+this.tagEndChar,n="";return"?"===t[0]&&(n="?",s=""),!e&&""!==e||-1!==r.indexOf("<")?!1!==this.options.commentPropName&&t===this.options.commentPropName&&0===n.length?this.indentate(i)+`\x3c!--${r}--\x3e`+this.newLine:this.indentate(i)+"<"+t+e+n+this.tagEndChar+r+this.indentate(i)+s:this.indentate(i)+"<"+t+e+n+">"+r+s}},fe.prototype.closeTag=function(r){let t="";return-1!==this.options.unpairedTags.indexOf(r)?this.options.suppressUnpairedNode||(t="/"):t=this.options.suppressEmptyNode?"/":`></${r}`,t},fe.prototype.checkStopNode=function(r){if(!this.stopNodeExpressions||0===this.stopNodeExpressions.length)return!1;for(let t=0;t<this.stopNodeExpressions.length;t++)if(r.matches(this.stopNodeExpressions[t]))return!0;return!1},fe.prototype.buildTextValNode=function(r,t,e,i,s){if(!1!==this.options.cdataPropName&&t===this.options.cdataPropName){const n=String(r).replace(/\]\]>/g,"]]]]><![CDATA[>");return this.indentate(i)+`<![CDATA[${n}]]>`+this.newLine}if(!1!==this.options.commentPropName&&t===this.options.commentPropName){const n=String(r).replace(/--/g,"- -").replace(/-$/,"- ");return this.indentate(i)+`\x3c!--${n}--\x3e`+this.newLine}if("?"===t[0])return this.indentate(i)+"<"+t+e+"?"+this.tagEndChar;{let n=this.options.tagValueProcessor(t,r);return n=this.replaceEntitiesValue(n),""===n?this.indentate(i)+"<"+t+e+this.closeTag(t)+this.tagEndChar:this.indentate(i)+"<"+t+e+">"+n+"</"+t+this.tagEndChar}},fe.prototype.replaceEntitiesValue=function(r){if(r&&r.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){const e=this.options.entities[t];r=r.replace(e.regex,e.val)}return r};class Ts{}y(Ts,"parser",new Fn({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0})),y(Ts,"builder",new fe({attributeNamePrefix:"$",ignoreAttributes:!1,suppressBooleanAttributes:!1}));class Rt{static join(t){const e={};for(const i of t)for(const s in i)if(e[s])for(const n of i[s])e[s].add(n);else e[s]=new Set(i[s]);return e}static intersect(t){if(0===t.length)return{};let e=Rt.clone(t[0]);for(let i=1;i<t.length;i++){const s=t[i],n={};for(const o in e)if(s[o]){const a=new Set;for(const l of e[o])s[o].has(l)&&a.add(l);a.size>0&&(n[o]=a)}e=n}return e}static clone(t){const e={};for(const i in t)e[i]=new Set(t[i]);return e}static remove(t,e,i=!1){i&&(t=Rt.clone(t));for(const s in e)if(t[s]){for(const n of e[s])t[s].delete(n);0===t[s].size&&delete t[s]}}static add(t,e,i=!1){i&&(t=Rt.clone(t));for(const s in e)if(t[s])for(const n of e[s])t[s].add(n);else t[s]=new Set(e[s])}static append(t,e,...i){let s=t[e];s||(s=new Set,t[e]=s);for(const n of i)s.add(n)}static isEqual(t,e){const i=Object.keys(t),s=Object.keys(e);if(i.length!==s.length)return!1;for(const n of i){if(!e[n]||t[n].size!==e[n].size)return!1;for(const o of t[n])if(!e[n].has(o))return!1}return!0}static isEmpty(t){return 0===Object.values(t).reduce((i,s)=>i+s.size,0)}static toRaw(t){const e={};for(const i in t)e[i]=Array.from(t[i]);return e}static fromRaw(t){const e={};for(const i in t)e[i]=new Set(t[i]);return e}}Map;class Un{static isEntry(t){return new Set(["Boolean","Color","Text","Number","Select","Vector3","TextSet","None"]).has(t.type)}static copySchema(t,e={}){for(const i in t){const s=t[i];this.isEntry(s)?e[i]=this.copyEntry(s):(e[i]={},this.copySchema(s,e[i]))}return e}static copyEntry(t){if("Boolean"===t.type)return{type:t.type,value:t.value};if("Color"===t.type)return{type:t.type,value:t.value.clone()};if("Text"===t.type)return{type:t.type,value:t.value};if("Number"===t.type)return{type:t.type,value:t.value,min:t.min,max:t.max,interpolable:t.interpolable};if("Select"===t.type)return{type:t.type,value:t.value,multiple:t.multiple,options:new Set(t.options)};if("Vector3"===t.type)return{type:t.type,value:t.value.clone()};if("TextSet"===t.type)return{type:t.type,value:new Set(t.value)};if("None"===t.type)return{type:t.type,value:t.value};throw new Error("Invalid entry!")}}class Wi{constructor(t,e,i,s){y(this,"_component"),y(this,"name"),y(this,"uuid"),this._component=t,this.name=i,this.uuid=s??ie.create(),e.get(Ps).list.set(this.uuid,this)}get controls(){return Un.copySchema(this._config)}set(t){for(const e in t)e in this&&(this[e]=t[e].value)}export(t=this._config,e={}){for(const i in t){const s=t[i];if(Un.isEntry(s))if("Color"===s.type){const{r:o,g:a,b:l}=s.value;e[i]={...s,value:{r:o,g:a,b:l}}}else if("Vector3"===s.type){const{x:o,y:a,z:l}=s.value;e[i]={...s,value:{x:o,y:a,z:l}}}else if("TextSet"===s.type){const o=Array.from(s.value);e[i]={...s,value:o}}else if("Select"===s.type){const o=Array.from(s.options);e[i]={...s,options:o}}else e[i]={...s};else e[i]={},this.export(s,e[i])}return e}import(t,e={},i=!0){for(const s in t){const n=t[s];if(Un.isEntry(n))if("Color"===n.type){const{r:a,g:l,b:c}=n.value;e[s]={...n,value:new p.Q1f(a,l,c)}}else if("Vector3"===n.type){const{x:a,y:l,z:c}=n.value;e[s]={...n,value:new p.Pq0(a,l,c)}}else e[s]="TextSet"===n.type?{...n,value:new Set(n.value)}:"Select"===n.type?{...n,options:new Set(n.options)}:{...n};else e[s]={},this.import(n,e[s],!1)}i&&this.set(e)}}const Go=class Bc extends At{constructor(t){super(t),y(this,"list",new ot.jp),y(this,"enabled",!0),t.add(Bc.uuid,this)}};y(Go,"uuid","b8c764e0-6b24-4e77-9a32-35fa728ee5b4");let Ps=Go;class Yo{constructor(t){y(this,"_event"),y(this,"_position",new p.I9Y),y(this,"onDisposed",new Q),y(this,"updateMouseInfo",e=>{this._event=e}),this.dom=t,this.setupEvents(!0)}get position(){return this.updatePosition(!1),this._position.clone()}get rawPosition(){return this.updatePosition(!0),this._position.clone()}dispose(){this.setupEvents(!1),this.onDisposed.trigger(),this.onDisposed.reset()}updatePosition(t){if(this._event){const e=this.dom.getBoundingClientRect();this._position.x=this.getPositionX(e,this._event,t),this._position.y=this.getPositionY(e,this._event,t)}}getPositionY(t,e,i){const s=this.getDataObject(e);return i?s.clientY:-(s.clientY-t.top)/(t.bottom-t.top)*2+1}getPositionX(t,e,i){const s=this.getDataObject(e);return i?s.clientX:(s.clientX-t.left)/(t.right-t.left)*2-1}getDataObject(t){return t instanceof MouseEvent?t:t.touches[0]}setupEvents(t){t?(this.dom.addEventListener("pointermove",this.updateMouseInfo),this.dom.addEventListener("touchstart",this.updateMouseInfo)):(this.dom.removeEventListener("pointermove",this.updateMouseInfo),this.dom.removeEventListener("touchstart",this.updateMouseInfo))}}const Ss=Math.pow(2,-24),Hn=Symbol("SKIP_GENERATION"),Qo={strategy:0,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Hn]:!1};function Lt(r,t,e){return e.min.x=t[r],e.min.y=t[r+1],e.min.z=t[r+2],e.max.x=t[r+3],e.max.y=t[r+4],e.max.z=t[r+5],e}function Jo(r){let t=-1,e=-1/0;for(let i=0;i<3;i++){const s=r[i+3]-r[i];s>e&&(e=s,t=i)}return t}function ta(r,t){t.set(r)}function ea(r,t,e){let i,s;for(let n=0;n<3;n++){const o=n+3;i=r[n],s=t[n],e[n]=i<s?i:s,i=r[o],s=t[o],e[o]=i>s?i:s}}function Es(r,t,e){for(let i=0;i<3;i++){const s=t[r+2*i],n=t[r+2*i+1],o=s-n,a=s+n;o<e[i]&&(e[i]=o),a>e[i+3]&&(e[i+3]=a)}}function Xi(r){const t=r[3]-r[0],e=r[4]-r[1],i=r[5]-r[2];return 2*(t*e+e*i+i*t)}function Ut(r,t){return 65535===t[r+15]}function Xt(r,t){return t[r+6]}function Qt(r,t){return t[r+14]}function jt(r){return r+8}function Ht(r,t){return r+8*t[r+6]}function qn(r,t){return t[r+7]}function Gn(r,t,e,i,s){let n=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,h=-1/0,u=1/0,f=1/0,d=1/0,_=-1/0,m=-1/0,w=-1/0;const g=r.offset||0;for(let v=6*(t-g),T=6*(t+e-g);v<T;v+=6){const C=r[v+0],S=r[v+1],M=C-S,A=C+S;M<n&&(n=M),A>l&&(l=A),C<u&&(u=C),C>_&&(_=C);const O=r[v+2],I=r[v+3],D=O-I,B=O+I;D<o&&(o=D),B>c&&(c=B),O<f&&(f=O),O>m&&(m=O);const E=r[v+4],L=r[v+5],x=E-L,N=E+L;x<a&&(a=x),N>h&&(h=N),E<d&&(d=E),E>w&&(w=E)}i[0]=n,i[1]=o,i[2]=a,i[3]=l,i[4]=c,i[5]=h,s[0]=u,s[1]=f,s[2]=d,s[3]=_,s[4]=m,s[5]=w}const Su=(r,t)=>r.candidate-t.candidate,Ye=new Array(32).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),As=new Float32Array(6);class Yn{constructor(){this.boundingData=new Float32Array(6)}}let ia,Ms,Zn,sa;const Iu=Math.pow(2,32);function Wn(r){return"count"in r?1:1+Wn(r.left)+Wn(r.right)}function Ou(r,t,e){return ia=new Float32Array(e),Ms=new Uint32Array(e),Zn=new Uint16Array(e),sa=new Uint8Array(e),Xn(r,t)}function Xn(r,t){const e=r/4,i=r/2,s="count"in t,n=t.boundingData;for(let o=0;o<6;o++)ia[e+o]=n[o];if(s)return t.buffer?(sa.set(new Uint8Array(t.buffer),r),r+t.buffer.byteLength):(Ms[e+6]=t.offset,Zn[i+14]=t.count,Zn[i+15]=65535,r+32);{const{left:o,right:a,splitAxis:l}=t;let h=Xn(r+32,o);const d=h/32-r/32;if(d>Iu)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Ms[e+6]=d,Ms[e+7]=l,Xn(h,a)}}function Du(r,t){const e=t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer,i=r.getRootRanges(t.range),s=i[0],n=i[i.length-1],o={offset:s.offset,count:n.offset+n.count-s.offset},a=new Float32Array(6*o.count);a.offset=o.offset,r.computePrimitiveBounds(o.offset,o.count,a),r._roots=i.map(l=>{const c=function zu(r,t,e,i,s,n){const{maxDepth:o,verbose:a,maxLeafSize:l,strategy:c,onProgress:h}=s,u=r.primitiveBuffer,f=r.primitiveBufferStride,d=new Float32Array(6);let _=!1;const m=new Yn;return Gn(t,e,i,m.boundingData,d),function g(v,T,C,S=null,M=0){if(!_&&M>=o&&(_=!0,a&&console.warn(`BVH: Max depth of ${o} reached when generating BVH. Consider increasing maxDepth.`)),C<=l||M>=o)return w(T+C),v.offset=T,v.count=C,v;const A=function Eu(r,t,e,i,s,n){let o=-1,a=0;if(0===n)o=Jo(t),-1!==o&&(a=(t[o]+t[o+3])/2);else if(1===n)o=Jo(r),-1!==o&&(a=function Au(r,t,e,i){let s=0;const n=r.offset;for(let o=t,a=t+e;o<a;o++)s+=r[6*(o-n)+2*i];return s/e}(e,i,s,o));else if(2===n){const l=Xi(r);let c=1.25*s;const h=e.offset||0,u=6*(i-h),f=6*(i+s-h);for(let d=0;d<3;d++){const _=t[d],g=(t[d+3]-_)/32;if(s<8){const v=[...Ye];v.length=s;let T=0;for(let S=u;S<f;S+=6,T++){const M=v[T];M.candidate=e[S+2*d],M.count=0;const{bounds:A,leftCacheBounds:O,rightCacheBounds:I}=M;for(let D=0;D<3;D++)I[D]=1/0,I[D+3]=-1/0,O[D]=1/0,O[D+3]=-1/0,A[D]=1/0,A[D+3]=-1/0;Es(S,e,A)}v.sort(Su);let C=s;for(let S=0;S<C;S++){const M=v[S];for(;S+1<C&&v[S+1].candidate===M.candidate;)v.splice(S+1,1),C--}for(let S=u;S<f;S+=6){const M=e[S+2*d];for(let A=0;A<C;A++){const O=v[A];M>=O.candidate?Es(S,e,O.rightCacheBounds):(Es(S,e,O.leftCacheBounds),O.count++)}}for(let S=0;S<C;S++){const M=v[S],A=M.count,O=s-M.count,D=M.rightCacheBounds;let B=0;0!==A&&(B=Xi(M.leftCacheBounds)/l);let E=0;0!==O&&(E=Xi(D)/l);const L=1+1.25*(B*A+E*O);L<c&&(o=d,c=L,a=M.candidate)}}else{for(let C=0;C<32;C++){const S=Ye[C];S.count=0,S.candidate=_+g+C*g;const M=S.bounds;for(let A=0;A<3;A++)M[A]=1/0,M[A+3]=-1/0}for(let C=u;C<f;C+=6){let A=~~((e[C+2*d]-_)/g);A>=32&&(A=31);const O=Ye[A];O.count++,Es(C,e,O.bounds)}const v=Ye[31];ta(v.bounds,v.rightCacheBounds);for(let C=30;C>=0;C--){const S=Ye[C];ea(S.bounds,Ye[C+1].rightCacheBounds,S.rightCacheBounds)}let T=0;for(let C=0;C<31;C++){const S=Ye[C],M=S.count,A=S.bounds,I=Ye[C+1].rightCacheBounds;0!==M&&(0===T?ta(A,As):ea(A,As,As)),T+=M;let D=0,B=0;0!==T&&(D=Xi(As)/l);const E=s-T;0!==E&&(B=Xi(I)/l);const L=1+1.25*(D*T+B*E);L<c&&(o=d,c=L,a=S.candidate)}}}}else console.warn(`BVH: Invalid build strategy value ${n} used.`);return{axis:o,pos:a}}(v.boundingData,S,t,T,C,c);if(-1===A.axis)return w(T+C),v.offset=T,v.count=C,v;const O=function Mu(r,t,e,i,s,n){let o=i,a=i+s-1;const l=n.pos,c=2*n.axis,h=e.offset||0;for(;;){for(;o<=a&&e[6*(o-h)+c]<l;)o++;for(;o<=a&&e[6*(a-h)+c]>=l;)a--;if(!(o<a))return o;for(let u=0;u<t;u++){let f=r[o*t+u];r[o*t+u]=r[a*t+u],r[a*t+u]=f}for(let u=0;u<6;u++){const f=o-h,d=a-h,_=e[6*f+u];e[6*f+u]=e[6*d+u],e[6*d+u]=_}o++,a--}}(u,f,t,T,C,A);if(O===T||O===T+C)w(T+C),v.offset=T,v.count=C;else{v.splitAxis=A.axis;const I=new Yn,D=T,B=O-T;v.left=I,Gn(t,D,B,I.boundingData,d),g(I,D,B,d,M+1);const E=new Yn,L=O,x=C-B;v.right=E,Gn(t,L,x,E.boundingData,d),g(E,L,x,d,M+1)}return v}(m,e,i,d),m;function w(v){h&&h((v-n.offset)/n.count)}}(r,a,l.offset,l.count,t,o),h=Wn(c),u=new e(32*h);return Ou(0,c,u),u})}class Is{constructor(t){this._getNewPrimitive=t,this._primitives=[]}getPrimitive(){const t=this._primitives;return 0===t.length?this._getNewPrimitive():t.pop()}releasePrimitive(t){this._primitives.push(t)}}class ku{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const t=[];let e=null;this.setBuffer=i=>{e&&t.push(e),e=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{e=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==t.length&&this.setBuffer(t.pop())}}}const Dt=new ku;let Ze,Ti;const Pi=[],Os=new Is(()=>new p.NRn);function Lu(r,t,e,i,s,n){Ze=Os.getPrimitive(),Ti=Os.getPrimitive(),Pi.push(Ze,Ti),Dt.setBuffer(r._roots[t]);const o=Kn(0,r.geometry,e,i,s,n);Dt.clearBuffer(),Os.releasePrimitive(Ze),Os.releasePrimitive(Ti),Pi.pop(),Pi.pop();const a=Pi.length;return a>0&&(Ti=Pi[a-1],Ze=Pi[a-2]),o}function Kn(r,t,e,i,s=null,n=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:c}=Dt;let h=2*r;if(Ut(h,l)){const f=Xt(r,c),d=Qt(h,l);return Lt(r,a,Ze),i(f,d,!1,o,n+r/8,Ze)}{let f=function(E){const{uint16Array:L,uint32Array:x}=Dt;let N=2*E;for(;!Ut(N,L);)N=2*(E=jt(E));return Xt(E,x)},d=function(E){const{uint16Array:L,uint32Array:x}=Dt;let N=2*E;for(;!Ut(N,L);)N=2*(E=Ht(E,x));return Xt(E,x)+Qt(N,L)};const _=jt(r),m=Ht(r,c);let v,T,C,S,w=_,g=m;if(s&&(C=Ze,S=Ti,Lt(w,a,C),Lt(g,a,S),v=s(C),T=s(S),T<v)){w=m,g=_;const E=v;v=T,T=E,C=S}C||(C=Ze,Lt(w,a,C));const A=e(C,Ut(2*w,l),v,o+1,n+w/8);let O;if(2===A){const E=f(w);O=i(E,d(w)-E,!0,o+1,n+w/8,C)}else O=A&&Kn(w,t,e,i,s,n,o+1);if(O)return!0;S=Ti,Lt(g,a,S);const D=e(S,Ut(2*g,l),T,o+1,n+g/8);let B;if(2===D){const E=f(g);B=i(E,d(g)-E,!0,o+1,n+g/8,S)}else B=D&&Kn(g,t,e,i,s,n,o+1);return!!B}}const Ki=new Dt.constructor,zs=new Dt.constructor,We=new Is(()=>new p.NRn),Si=new p.NRn,Ei=new p.NRn,Qn=new p.NRn,Jn=new p.NRn;let tr=!1;function ve(r,t,e,i,s,n=0,o=0,a=0,l=0,c=null,h=!1){let u,f;h?(u=zs,f=Ki):(u=Ki,f=zs);const d=u.float32Array,_=u.uint32Array,m=u.uint16Array,w=f.float32Array,g=f.uint32Array,v=f.uint16Array,C=2*t,S=Ut(2*r,m),M=Ut(C,v);let A=!1;if(M&&S)A=h?s(Xt(t,g),Qt(2*t,v),Xt(r,_),Qt(2*r,m),l,o+t/8,a,n+r/8):s(Xt(r,_),Qt(2*r,m),Xt(t,g),Qt(2*t,v),a,n+r/8,l,o+t/8);else if(M){const O=We.getPrimitive();Lt(t,w,O),O.applyMatrix4(e);const I=jt(r),D=Ht(r,_);Lt(I,d,Si),Lt(D,d,Ei);const B=O.intersectsBox(Si),E=O.intersectsBox(Ei);A=B&&ve(t,I,i,e,s,o,n,l,a+1,O,!h)||E&&ve(t,D,i,e,s,o,n,l,a+1,O,!h),We.releasePrimitive(O)}else{const O=jt(t),I=Ht(t,g);Lt(O,w,Qn),Lt(I,w,Jn);const D=c.intersectsBox(Qn),B=c.intersectsBox(Jn);if(D&&B)A=ve(r,O,e,i,s,n,o,a,l+1,c,h)||ve(r,I,e,i,s,n,o,a,l+1,c,h);else if(D)if(S)A=ve(r,O,e,i,s,n,o,a,l+1,c,h);else{const E=We.getPrimitive();E.copy(Qn).applyMatrix4(e);const L=jt(r),x=Ht(r,_);Lt(L,d,Si),Lt(x,d,Ei);const N=E.intersectsBox(Si),Y=E.intersectsBox(Ei);A=N&&ve(O,L,i,e,s,o,n,l,a+1,E,!h)||Y&&ve(O,x,i,e,s,o,n,l,a+1,E,!h),We.releasePrimitive(E)}else if(B)if(S)A=ve(r,I,e,i,s,n,o,a,l+1,c,h);else{const E=We.getPrimitive();E.copy(Jn).applyMatrix4(e);const L=jt(r),x=Ht(r,_);Lt(L,d,Si),Lt(x,d,Ei);const N=E.intersectsBox(Si),Y=E.intersectsBox(Ei);A=N&&ve(I,L,i,e,s,o,n,l,a+1,E,!h)||Y&&ve(I,x,i,e,s,o,n,l,a+1,E,!h),We.releasePrimitive(E)}}return A}const na=new p.NRn,Ai=new Float32Array(6);class ra{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(t){Du(this,t={...Qo,...t})}getRootRanges(){throw new Error("BVH: getRootRanges() not implemented")}writePrimitiveBounds(){throw new Error("BVH: writePrimitiveBounds() not implemented")}writePrimitiveRangeBounds(t,e,i,s){let n=1/0,o=1/0,a=1/0,l=-1/0,c=-1/0,h=-1/0;for(let u=t,f=t+e;u<f;u++){this.writePrimitiveBounds(u,Ai,0);const[d,_,m,w,g,v]=Ai;d<n&&(n=d),w>l&&(l=w),_<o&&(o=_),g>c&&(c=g),m<a&&(a=m),v>h&&(h=v)}return i[s+0]=n,i[s+1]=o,i[s+2]=a,i[s+3]=l,i[s+4]=c,i[s+5]=h,i}computePrimitiveBounds(t,e,i){const s=i.offset||0;for(let n=t,o=t+e;n<o;n++){this.writePrimitiveBounds(n,Ai,0);const[a,l,c,h,u,f]=Ai,d=(a+h)/2,_=(l+u)/2,m=(c+f)/2,w=(h-a)/2,g=(u-l)/2,v=(f-c)/2,T=6*(n-s);i[T+0]=d,i[T+1]=w+(Math.abs(d)+w)*Ss,i[T+2]=_,i[T+3]=g+(Math.abs(_)+g)*Ss,i[T+4]=m,i[T+5]=v+(Math.abs(m)+v)*Ss}return i}shiftPrimitiveOffsets(t){const e=this._indirectBuffer;if(e)for(let i=0,s=e.length;i<s;i++)e[i]+=t;else{const i=this._roots;for(let s=0;s<i.length;s++){const n=i[s],o=new Uint32Array(n),a=new Uint16Array(n),l=n.byteLength/32;for(let c=0;c<l;c++){const h=8*c;Ut(2*h,a)&&(o[h+6]+=t)}}}}traverse(t,e=0){const i=this._roots[e],s=new Uint32Array(i),n=new Uint16Array(i);!function o(a,l=0){const c=2*a,h=Ut(c,n);if(h){const u=s[a+6],f=n[c+14];t(l,h,new Float32Array(i,4*a,6),u,f)}else{const u=jt(a),f=Ht(a,s),d=qn(a,s);t(l,h,new Float32Array(i,4*a,6),d)||(o(u,l+1),o(f,l+1))}}(0)}refit(){const t=this._roots;for(let e=0,i=t.length;e<i;e++){const s=t[e],n=new Uint32Array(s),o=new Uint16Array(s),a=new Float32Array(s);for(let c=s.byteLength/32-1;c>=0;c--){const h=8*c,u=2*h;if(Ut(u,o)){const d=Xt(h,n),_=Qt(u,o);this.writePrimitiveRangeBounds(d,_,Ai,0),a.set(Ai,h)}else{const d=jt(h),_=Ht(h,n);for(let m=0;m<3;m++){const w=a[d+m],g=a[d+m+3],v=a[_+m],T=a[_+m+3];a[h+m]=w<v?w:v,a[h+m+3]=g>T?g:T}}}}}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(i=>{Lt(0,new Float32Array(i),na),t.union(na)}),t}shapecast(t){let{boundsTraverseOrder:e,intersectsBounds:i,intersectsRange:s,intersectsPrimitive:n,scratchPrimitive:o,iterate:a}=t;if(s&&n){const u=s;s=(f,d,_,m,w)=>!!u(f,d,_,m,w)||a(f,d,this,n,_,m,o)}else s||(s=n?(u,f,d,_)=>a(u,f,this,n,d,_,o):(u,f,d)=>d);let l=!1,c=0;const h=this._roots;for(let u=0,f=h.length;u<f;u++){const d=h[u];if(l=Lu(this,u,i,s,e,c),l)break;c+=d.byteLength/32}return l}bvhcast(t,e,i){let{intersectsRanges:s}=i;return function Nu(r,t,e,i){if(tr)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");tr=!0;const s=r._roots,n=t._roots;let o,a=0,l=0;const c=(new p.kn4).copy(e).invert();for(let h=0,u=s.length;h<u;h++){Ki.setBuffer(s[h]),l=0;const f=We.getPrimitive();Lt(0,Ki.float32Array,f),f.applyMatrix4(c);for(let d=0,_=n.length;d<_&&(zs.setBuffer(n[d]),o=ve(0,0,e,c,i,a,l,0,0,f),zs.clearBuffer(),l+=n[d].byteLength/32,!o);d++);if(We.releasePrimitive(f),Ki.clearBuffer(),a+=s[h].byteLength/32,o)break}return tr=!1,o}(this,t,e,s)}}function er(r){return r.index?r.index.count:r.attributes.position.count}function Ds(r){return er(r)/3}function oa(r,t,e){const i=function Vu(r,t,e){const i=er(r)/e,s=t||r.drawRange,o=(s.start+s.count)/e,a=Math.max(0,s.start/e),l=Math.min(i,o)-a;return{offset:Math.floor(a),count:Math.floor(l)}}(r,t,e),s=function Uu(r,t){return r.groups.map(e=>({offset:e.start/t,count:e.count/t}))}(r,e);if(!s.length)return[i];const n=[],o=i.offset,a=i.offset+i.count,l=er(r)/e,c=[];for(const f of s){const{offset:d,count:_}=f,m=d,g=d+(isFinite(_)?_:l-d);m<a&&g>o&&(c.push({pos:Math.max(o,m),isStart:!0}),c.push({pos:Math.min(a,g),isStart:!1}))}c.sort((f,d)=>f.pos!==d.pos?f.pos-d.pos:"end"===f.type?-1:1);let h=0,u=null;for(const f of c){const d=f.pos;0!==h&&d!==u&&n.push({offset:u,count:d-u}),h+=f.isStart?1:-1,u=d}return n}class aa extends ra{get indirect(){return!!this._indirectBuffer}get primitiveStride(){return null}get primitiveBufferStride(){return this.indirect?1:this.primitiveStride}set primitiveBufferStride(t){}get primitiveBuffer(){return this.indirect?this._indirectBuffer:this.geometry.index.array}set primitiveBuffer(t){}constructor(t,e={}){if(!t.isBufferGeometry)throw new Error("BVH: Only BufferGeometries are supported.");if(t.index&&t.index.isInterleavedBufferAttribute)throw new Error("BVH: InterleavedBufferAttribute is not supported for the index attribute.");if(e.useSharedArrayBuffer&&!function Bu(){return typeof SharedArrayBuffer<"u"}())throw new Error("BVH: SharedArrayBuffer is not available.");super(),this.geometry=t,this.resolvePrimitiveIndex=e.indirect?i=>this._indirectBuffer[i]:i=>i,this.primitiveBuffer=null,this.primitiveBufferStride=null,this._indirectBuffer=null,(e={...Qo,...e})[Hn]||this.init(e)}init(t){const{geometry:e,primitiveStride:i}=this;if(t.indirect){const n=function $u(r,t){const e=r[r.length-1],i=e.offset+e.count>65536,s=r.reduce((c,h)=>c+h.count,0),n=i?4:2,o=t?new SharedArrayBuffer(s*n):new ArrayBuffer(s*n),a=i?new Uint32Array(o):new Uint16Array(o);let l=0;for(let c=0;c<r.length;c++){const{offset:h,count:u}=r[c];for(let f=0;f<u;f++)a[l+f]=h+f;l+=u}return a}(oa(e,t.range,i),t.useSharedArrayBuffer);this._indirectBuffer=n}else!function Fu(r,t){if(!r.index){const e=r.attributes.position.count,s=function Ru(r,t=ArrayBuffer){return r>65535?new Uint32Array(new t(4*r)):new Uint16Array(new t(2*r))}(e,t.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);r.setIndex(new p.THS(s,1));for(let n=0;n<e;n++)s[n]=n}}(e,t);super.init(t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new p.NRn))}getRootRanges(t){return this.indirect?[{offset:0,count:this._indirectBuffer.length}]:oa(this.geometry,t,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class ke{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(t,e){let i=1/0,s=-1/0;for(let n=0,o=t.length;n<o;n++){const l=t[n][e];i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}setFromPoints(t,e){let i=1/0,s=-1/0;for(let n=0,o=e.length;n<o;n++){const l=t.dot(e[n]);i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}isSeparated(t){return this.min>t.max||t.min>this.max}}ke.prototype.setFromBox=function(){const r=new p.Pq0;return function(e,i){const s=i.min,n=i.max;let o=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let h=0;h<=1;h++){r.x=s.x*l+n.x*(1-l),r.y=s.y*c+n.y*(1-c),r.z=s.z*h+n.z*(1-h);const u=e.dot(r);o=Math.min(u,o),a=Math.max(u,a)}this.min=o,this.max=a}}();const ju=function(){const r=new p.Pq0,t=new p.Pq0,e=new p.Pq0;return function(s,n,o){const l=r,h=t;e.subVectors(s.start,n.start),r.subVectors(s.end,s.start),t.subVectors(n.end,n.start);const u=e.dot(h),f=h.dot(l),d=h.dot(h),_=e.dot(l),w=l.dot(l)*d-f*f;let g,v;g=0!==w?(u*f-_*d)/w:0,v=(u+g*f)/d,o.x=g,o.y=v}}(),ir=function(){const r=new p.I9Y,t=new p.Pq0,e=new p.Pq0;return function(s,n,o,a){ju(s,n,r);let l=r.x,c=r.y;if(l>=0&&l<=1&&c>=0&&c<=1)return s.at(l,o),void n.at(c,a);if(l>=0&&l<=1)return n.at(c<0?0:1,a),void s.closestPointToPoint(a,!0,o);if(c>=0&&c<=1)return s.at(l<0?0:1,o),void n.closestPointToPoint(o,!0,a);{let h,u;h=l<0?s.start:s.end,u=c<0?n.start:n.end;const f=t,d=e;return s.closestPointToPoint(u,!0,t),n.closestPointToPoint(h,!0,e),f.distanceToSquared(u)<=d.distanceToSquared(h)?(o.copy(f),void a.copy(u)):(o.copy(h),void a.copy(d))}}}(),Hu=function(){const r=new p.Pq0,t=new p.Pq0,e=new p.Zcv,i=new p.cZY;return function(n,o){const{radius:a,center:l}=n,{a:c,b:h,c:u}=o;if(i.start=c,i.end=h,i.closestPointToPoint(l,!0,r).distanceTo(l)<=a||(i.start=c,i.end=u,i.closestPointToPoint(l,!0,r).distanceTo(l)<=a)||(i.start=h,i.end=u,i.closestPointToPoint(l,!0,r).distanceTo(l)<=a))return!0;const m=o.getPlane(e);if(Math.abs(m.distanceToPoint(l))<=a){const g=m.projectPoint(l,t);if(o.containsPoint(g))return!0}return!1}}(),qu=["x","y","z"],Le=1e-15;function pe(r){return Math.abs(r)<Le}class le extends p.lMl{constructor(...t){super(...t),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new p.Pq0),this.satBounds=new Array(4).fill().map(()=>new ke),this.points=[this.a,this.b,this.c],this.plane=new p.Zcv,this.isDegenerateIntoSegment=!1,this.isDegenerateIntoPoint=!1,this.degenerateSegment=new p.cZY,this.needsUpdate=!0}intersectsSphere(t){return Hu(t,this)}update(){const t=this.a,e=this.b,i=this.c,s=this.points,n=this.satAxes,o=this.satBounds,a=n[0],l=o[0];this.getNormal(a),l.setFromPoints(a,s);const c=n[1],h=o[1];c.subVectors(t,e),h.setFromPoints(c,s);const u=n[2],f=o[2];u.subVectors(e,i),f.setFromPoints(u,s);const d=n[3],_=o[3];d.subVectors(i,t),_.setFromPoints(d,s);const m=c.length(),w=u.length(),g=d.length();this.isDegenerateIntoPoint=!1,this.isDegenerateIntoSegment=!1,m<Le?w<Le||g<Le?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(i)):w<Le?g<Le?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(t)):g<Le&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(i),this.degenerateSegment.end.copy(e)),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}}le.prototype.closestPointToSegment=function(){const r=new p.Pq0,t=new p.Pq0,e=new p.cZY;return function(s,n=null,o=null){const{start:a,end:l}=s,c=this.points;let h,u=1/0;for(let f=0;f<3;f++){const d=(f+1)%3;e.start.copy(c[f]),e.end.copy(c[d]),ir(e,s,r,t),h=r.distanceToSquared(t),h<u&&(u=h,n&&n.copy(r),o&&o.copy(t))}return this.closestPointToPoint(a,r),h=a.distanceToSquared(r),h<u&&(u=h,n&&n.copy(r),o&&o.copy(a)),this.closestPointToPoint(l,r),h=l.distanceToSquared(r),h<u&&(u=h,n&&n.copy(r),o&&o.copy(l)),Math.sqrt(u)}}(),le.prototype.intersectsTriangle=function(){const r=new le,t=new ke,e=new ke,i=new p.Pq0,s=new p.Pq0,n=new p.Pq0,o=new p.Pq0,a=new p.cZY,l=new p.cZY,c=new p.Pq0,h=new p.I9Y,u=new p.I9Y;function f(T,C,S,M){const A=i;A.copy(T.isDegenerateIntoPoint||T.isDegenerateIntoSegment?C.plane.normal:T.plane.normal);const O=T.satBounds,I=T.satAxes;for(let E=1;E<4;E++){const L=O[E],x=I[E];if(t.setFromPoints(x,C.points),L.isSeparated(t)||(o.copy(A).cross(x),t.setFromPoints(o,T.points),e.setFromPoints(o,C.points),t.isSeparated(e)))return!1}const D=C.satBounds,B=C.satAxes;for(let E=1;E<4;E++){const L=D[E],x=B[E];if(t.setFromPoints(x,T.points),L.isSeparated(t)||(o.crossVectors(A,x),t.setFromPoints(o,T.points),e.setFromPoints(o,C.points),t.isSeparated(e)))return!1}return S&&(M||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),S.start.set(0,0,0),S.end.set(0,0,0)),!0}function d(T,C,S,M,A,O,I,D,B,E,L){let x=I/(I-D);E.x=M+(A-M)*x,L.start.subVectors(C,T).multiplyScalar(x).add(T),x=I/(I-B),E.y=M+(O-M)*x,L.end.subVectors(S,T).multiplyScalar(x).add(T)}function _(T,C,S,M,A,O,I,D,B,E,L){if(A>0)d(T.c,T.a,T.b,M,C,S,B,I,D,E,L);else if(O>0)d(T.b,T.a,T.c,S,C,M,D,I,B,E,L);else if(D*B>0||0!=I)d(T.a,T.b,T.c,C,S,M,I,D,B,E,L);else if(0!=D)d(T.b,T.a,T.c,S,C,M,D,I,B,E,L);else{if(0==B)return!0;d(T.c,T.a,T.b,M,C,S,B,I,D,E,L)}return!1}function m(T,C,S,M){const A=C.degenerateSegment,O=T.plane.distanceToPoint(A.start),I=T.plane.distanceToPoint(A.end);return pe(O)?pe(I)?f(T,C,S,M):(S&&(S.start.copy(A.start),S.end.copy(A.start)),T.containsPoint(A.start)):pe(I)?(S&&(S.start.copy(A.end),S.end.copy(A.end)),T.containsPoint(A.end)):null!=T.plane.intersectLine(A,i)&&(S&&(S.start.copy(i),S.end.copy(i)),T.containsPoint(i))}function w(T,C,S){const M=C.a;return!(!pe(T.plane.distanceToPoint(M))||!T.containsPoint(M)||(S&&(S.start.copy(M),S.end.copy(M)),0))}function g(T,C,S){const A=C.a;return T.degenerateSegment.closestPointToPoint(A,!0,i),A.distanceToSquared(i)<1e-30&&(S&&(S.start.copy(A),S.end.copy(A)),!0)}return function(C,S=null,M=!1){this.needsUpdate&&this.update(),C.isExtendedTriangle?C.needsUpdate&&C.update():(r.copy(C),r.update(),C=r);const A=function v(T,C,S,M){if(T.isDegenerateIntoSegment){if(C.isDegenerateIntoSegment){const A=T.degenerateSegment,O=C.degenerateSegment,I=s,D=n;A.delta(I),O.delta(D);const B=i.subVectors(O.start,A.start),E=I.x*D.y-I.y*D.x;if(pe(E))return!1;const L=(B.x*D.y-B.y*D.x)/E,x=-(I.x*B.y-I.y*B.x)/E;return!(L<0||L>1||x<0||x>1||!pe(A.start.z+I.z*L-(O.start.z+D.z*x))||(S&&(S.start.copy(A.start).addScaledVector(I,L),S.end.copy(A.start).addScaledVector(I,L)),0))}return C.isDegenerateIntoPoint?g(T,C,S):m(C,T,S,M)}return T.isDegenerateIntoPoint?C.isDegenerateIntoPoint?C.a.distanceToSquared(T.a)<1e-30&&(S&&(S.start.copy(T.a),S.end.copy(T.a)),!0):C.isDegenerateIntoSegment?g(C,T,S):w(C,T,S):C.isDegenerateIntoPoint?w(T,C,S):C.isDegenerateIntoSegment?m(T,C,S,M):void 0}(this,C,S,M);if(void 0!==A)return A;const O=this.plane,I=C.plane;let D=I.distanceToPoint(this.a),B=I.distanceToPoint(this.b),E=I.distanceToPoint(this.c);pe(D)&&(D=0),pe(B)&&(B=0),pe(E)&&(E=0);const L=D*B,x=D*E;if(L>0&&x>0)return!1;let N=O.distanceToPoint(C.a),Y=O.distanceToPoint(C.b),q=O.distanceToPoint(C.c);pe(N)&&(N=0),pe(Y)&&(Y=0),pe(q)&&(q=0);const ct=N*Y,Z=N*q;if(ct>0&&Z>0)return!1;s.copy(O.normal),n.copy(I.normal);const at=s.cross(n);let F=0,V=Math.abs(at.x);const nt=Math.abs(at.y);nt>V&&(V=nt,F=1),Math.abs(at.z)>V&&(F=2);const J=qu[F],rt=C.a[J],ht=C.b[J],pt=C.c[J];if(_(this,this.a[J],this.b[J],this.c[J],L,x,D,B,E,h,a))return f(this,C,S,M);if(_(C,rt,ht,pt,ct,Z,N,Y,q,u,l))return f(this,C,S,M);if(h.y<h.x){const xt=h.y;h.y=h.x,h.x=xt,c.copy(a.start),a.start.copy(a.end),a.end.copy(c)}if(u.y<u.x){const xt=u.y;u.y=u.x,u.x=xt,c.copy(l.start),l.start.copy(l.end),l.end.copy(c)}return!(h.y<u.x||u.y<h.x||(S&&(S.start.copy(u.x>h.x?l.start:a.start),S.end.copy(u.y<h.y?l.end:a.end)),0))}}(),le.prototype.distanceToPoint=function(){const r=new p.Pq0;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),le.prototype.distanceToTriangle=function(){const r=new p.Pq0,t=new p.Pq0,e=["a","b","c"],i=new p.cZY,s=new p.cZY;return function(o,a=null,l=null){const c=a||l?i:null;if(this.intersectsTriangle(o,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let h=1/0;for(let u=0;u<3;u++){let f;const d=e[u],_=o[d];this.closestPointToPoint(_,r),f=_.distanceToSquared(r),f<h&&(h=f,a&&a.copy(r),l&&l.copy(_));const m=this[d];o.closestPointToPoint(m,r),f=m.distanceToSquared(r),f<h&&(h=f,a&&a.copy(m),l&&l.copy(r))}for(let u=0;u<3;u++){i.set(this[e[u]],this[e[(u+1)%3]]);for(let _=0;_<3;_++){s.set(o[e[_]],o[e[(_+1)%3]]),ir(i,s,r,t);const g=r.distanceToSquared(t);g<h&&(h=g,a&&a.copy(r),l&&l.copy(t))}}return Math.sqrt(h)}}();class Jt{constructor(t,e,i){this.isOrientedBox=!0,this.min=new p.Pq0,this.max=new p.Pq0,this.matrix=new p.kn4,this.invMatrix=new p.kn4,this.points=new Array(8).fill().map(()=>new p.Pq0),this.satAxes=new Array(3).fill().map(()=>new p.Pq0),this.satBounds=new Array(3).fill().map(()=>new ke),this.alignedSatBounds=new Array(3).fill().map(()=>new ke),this.needsUpdate=!1,t&&this.min.copy(t),e&&this.max.copy(e),i&&this.matrix.copy(i)}set(t,e,i){this.min.copy(t),this.max.copy(e),this.matrix.copy(i),this.needsUpdate=!0}copy(t){this.min.copy(t.min),this.max.copy(t.max),this.matrix.copy(t.matrix),this.needsUpdate=!0}}Jt.prototype.update=function(){return function(){const t=this.matrix,e=this.min,i=this.max,s=this.points;for(let c=0;c<=1;c++)for(let h=0;h<=1;h++)for(let u=0;u<=1;u++){const d=s[1*c|2*h|4*u];d.x=c?i.x:e.x,d.y=h?i.y:e.y,d.z=u?i.z:e.z,d.applyMatrix4(t)}const n=this.satBounds,o=this.satAxes,a=s[0];for(let c=0;c<3;c++){const h=o[c],u=n[c];h.subVectors(a,s[1<<c]),u.setFromPoints(h,s)}const l=this.alignedSatBounds;l[0].setFromPointsField(s,"x"),l[1].setFromPointsField(s,"y"),l[2].setFromPointsField(s,"z"),this.invMatrix.copy(this.matrix).invert(),this.needsUpdate=!1}}(),Jt.prototype.intersectsBox=function(){const r=new ke;return function(e){this.needsUpdate&&this.update();const i=e.min,s=e.max,n=this.satBounds,o=this.satAxes,a=this.alignedSatBounds;if(r.min=i.x,r.max=s.x,a[0].isSeparated(r)||(r.min=i.y,r.max=s.y,a[1].isSeparated(r))||(r.min=i.z,r.max=s.z,a[2].isSeparated(r)))return!1;for(let l=0;l<3;l++){const h=n[l];if(r.setFromBox(o[l],e),h.isSeparated(r))return!1}return!0}}(),Jt.prototype.intersectsTriangle=function(){const r=new le,t=new Array(3),e=new ke,i=new ke,s=new p.Pq0;return function(o){this.needsUpdate&&this.update(),o.isExtendedTriangle?o.needsUpdate&&o.update():(r.copy(o),r.update(),o=r);const a=this.satBounds,l=this.satAxes;t[0]=o.a,t[1]=o.b,t[2]=o.c;for(let f=0;f<3;f++){const d=a[f];if(e.setFromPoints(l[f],t),d.isSeparated(e))return!1}const c=o.satBounds,h=o.satAxes,u=this.points;for(let f=0;f<3;f++){const d=c[f];if(e.setFromPoints(h[f],u),d.isSeparated(e))return!1}for(let f=0;f<3;f++){const d=l[f];for(let _=0;_<4;_++)if(s.crossVectors(d,h[_]),e.setFromPoints(s,t),i.setFromPoints(s,u),e.isSeparated(i))return!1}return!0}}(),Jt.prototype.closestPointToPoint=function(){return function(t,e){return this.needsUpdate&&this.update(),e.copy(t).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),e}}(),Jt.prototype.distanceToPoint=function(){const r=new p.Pq0;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),Jt.prototype.distanceToBox=function(){const r=["x","y","z"],t=new Array(12).fill().map(()=>new p.cZY),e=new Array(12).fill().map(()=>new p.cZY),i=new p.Pq0,s=new p.Pq0;return function(o,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(o))return(l||c)&&(o.getCenter(s),this.closestPointToPoint(s,i),o.closestPointToPoint(i,s),l&&l.copy(i),c&&c.copy(s)),0;const h=a*a,u=o.min,f=o.max,d=this.points;let _=1/0;for(let w=0;w<8;w++){const g=d[w];s.copy(g).clamp(u,f);const v=g.distanceToSquared(s);if(v<_&&(_=v,l&&l.copy(g),c&&c.copy(s),v<h))return Math.sqrt(v)}let m=0;for(let w=0;w<3;w++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){const T=(w+1)%3,C=(w+2)%3;t[m].set(d[g<<T|v<<C],d[1<<w|g<<T|v<<C]);const D=r[w],B=r[T],E=r[C],L=e[m],x=L.start,N=L.end;x[D]=u[D],x[B]=g?u[B]:f[B],x[E]=v?u[E]:f[B],N[D]=f[D],N[B]=g?u[B]:f[B],N[E]=v?u[E]:f[B],m++}for(let w=0;w<=1;w++)for(let g=0;g<=1;g++)for(let v=0;v<=1;v++){s.x=w?f.x:u.x,s.y=g?f.y:u.y,s.z=v?f.z:u.z,this.closestPointToPoint(s,i);const T=s.distanceToSquared(i);if(T<_&&(_=T,l&&l.copy(i),c&&c.copy(s),T<h))return Math.sqrt(T)}for(let w=0;w<12;w++){const g=t[w];for(let v=0;v<12;v++){ir(g,e[v],i,s);const C=i.distanceToSquared(s);if(C<_&&(_=C,l&&l.copy(i),c&&c.copy(s),C<h))return Math.sqrt(C)}}return Math.sqrt(_)}}();class Gu extends Is{constructor(){super(()=>new le)}}const me=new Gu,Qi=new p.Pq0,sr=new p.Pq0,ks=parseInt(p.sPf)>=169,Zu=parseInt(p.sPf)<=161,hi=new p.Pq0,ui=new p.Pq0,di=new p.Pq0,Ls=new p.I9Y,Ns=new p.I9Y,Bs=new p.I9Y,ca=new p.Pq0,ha=new p.Pq0,ua=new p.Pq0,Ji=new p.Pq0;function da(r,t,e,i,s,n,o,a,l,c,h){hi.fromBufferAttribute(t,n),ui.fromBufferAttribute(t,o),di.fromBufferAttribute(t,a);const u=function Wu(r,t,e,i,s,n,o,a){let l;if(l=n===p.hsX?r.intersectTriangle(i,e,t,!0,s):r.intersectTriangle(t,e,i,n!==p.$EB,s),null===l)return null;const c=r.origin.distanceTo(s);return c<o||c>a?null:{distance:c,point:s.clone()}}(r,hi,ui,di,Ji,l,c,h);if(u){if(i){Ls.fromBufferAttribute(i,n),Ns.fromBufferAttribute(i,o),Bs.fromBufferAttribute(i,a),u.uv=new p.I9Y;const d=p.lMl.getInterpolation(Ji,hi,ui,di,Ls,Ns,Bs,u.uv);ks||(u.uv=d)}if(s){Ls.fromBufferAttribute(s,n),Ns.fromBufferAttribute(s,o),Bs.fromBufferAttribute(s,a),u.uv1=new p.I9Y;const d=p.lMl.getInterpolation(Ji,hi,ui,di,Ls,Ns,Bs,u.uv1);ks||(u.uv1=d),Zu&&(u.uv2=u.uv1)}if(e){ca.fromBufferAttribute(e,n),ha.fromBufferAttribute(e,o),ua.fromBufferAttribute(e,a),u.normal=new p.Pq0;const d=p.lMl.getInterpolation(Ji,hi,ui,di,ca,ha,ua,u.normal);u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1),ks||(u.normal=d)}const f={a:n,b:o,c:a,normal:new p.Pq0,materialIndex:0};if(p.lMl.getNormal(hi,ui,di,f.normal),u.face=f,u.faceIndex=n,ks){const d=new p.Pq0;p.lMl.getBarycoord(Ji,hi,ui,di,d),u.barycoord=d}}return u}function fa(r){return r&&r.isMaterial?r.side:r}function Rs(r,t,e,i,s,n,o){const a=3*i;let l=a+0,c=a+1,h=a+2;const{index:u,groups:f}=r;r.index&&(l=u.getX(l),c=u.getX(c),h=u.getX(h));const{position:d,normal:_,uv:m,uv1:w}=r.attributes;if(Array.isArray(t)){const g=3*i;for(let v=0,T=f.length;v<T;v++){const{start:C,count:S,materialIndex:M}=f[v];if(g>=C&&g<C+S){const O=da(e,d,_,m,w,l,c,h,fa(t[M]),n,o);if(O){if(O.faceIndex=i,O.face.materialIndex=M,!s)return O;s.push(O)}}}}else{const v=da(e,d,_,m,w,l,c,h,fa(t),n,o);if(v){if(v.faceIndex=i,v.face.materialIndex=0,!s)return v;s.push(v)}}return null}function Ft(r,t,e,i){const s=r.a,n=r.b,o=r.c;let a=t,l=t+1,c=t+2;e&&(a=e.getX(a),l=e.getX(l),c=e.getX(c)),s.x=i.getX(a),s.y=i.getY(a),s.z=i.getZ(a),n.x=i.getX(l),n.y=i.getY(l),n.z=i.getZ(l),o.x=i.getX(c),o.y=i.getY(c),o.z=i.getZ(c)}function Qu(r,t,e,i,s,n,o){const{geometry:a}=e,{index:l}=a,c=a.attributes.position;for(let h=r,u=t+r;h<u;h++){let f;if(f=h,Ft(o,3*f,l,c),o.needsUpdate=!0,i(o,f,s,n))return!0}return!1}function Ju(r,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=r.geometry,i=e.index?e.index.array:null,s=e.attributes.position;let n,o,a,l,c=0;const h=r._roots;for(let f=0,d=h.length;f<d;f++)n=h[f],o=new Uint32Array(n),a=new Uint16Array(n),l=new Float32Array(n),u(0,c),c+=n.byteLength;function u(f,d,_=!1){const m=2*f;if(Ut(m,a)){const w=Xt(f,o);let v=1/0,T=1/0,C=1/0,S=-1/0,M=-1/0,A=-1/0;for(let O=3*w,I=3*(w+Qt(m,a));O<I;O++){let D=i[O];const B=s.getX(D),E=s.getY(D),L=s.getZ(D);B<v&&(v=B),B>S&&(S=B),E<T&&(T=E),E>M&&(M=E),L<C&&(C=L),L>A&&(A=L)}return(l[f+0]!==v||l[f+1]!==T||l[f+2]!==C||l[f+3]!==S||l[f+4]!==M||l[f+5]!==A)&&(l[f+0]=v,l[f+1]=T,l[f+2]=C,l[f+3]=S,l[f+4]=M,l[f+5]=A,!0)}{const w=jt(f),g=Ht(f,o);let v=_,T=!1,C=!1;if(t){if(!v){const B=g/8+d/32;T=t.has(w/8+d/32),C=t.has(B),v=!T&&!C}}else T=!0,C=!0;const M=v||C;let A=!1;(v||T)&&(A=u(w,d,v));let O=!1;M&&(O=u(g,d,v));const I=A||O;if(I)for(let D=0;D<3;D++){const B=w+D,E=g+D,L=l[B],x=l[B+3],N=l[E],Y=l[E+3];l[f+D]=L<N?L:N,l[f+D+3]=x>Y?x:Y}return I}}}function Xe(r,t,e,i,s){let n,o,a,l,c,h;const u=1/e.direction.x,f=1/e.direction.y,d=1/e.direction.z,_=e.origin.x,m=e.origin.y,w=e.origin.z;let g=t[r],v=t[r+3],T=t[r+1],C=t[r+3+1],S=t[r+2],M=t[r+3+2];return u>=0?(n=(g-_)*u,o=(v-_)*u):(n=(v-_)*u,o=(g-_)*u),f>=0?(a=(T-m)*f,l=(C-m)*f):(a=(C-m)*f,l=(T-m)*f),!(n>l||a>o||((a>n||isNaN(n))&&(n=a),(l<o||isNaN(o))&&(o=l),d>=0?(c=(S-w)*d,h=(M-w)*d):(c=(M-w)*d,h=(S-w)*d),n>h||c>o))&&((c>n||n!=n)&&(n=c),(h<o||o!=o)&&(o=h),n<=s&&o>=i)}function id(r,t,e,i,s,n,o){const{geometry:a}=e,{index:l}=a,c=a.attributes.position;for(let h=r,u=t+r;h<u;h++){let f;if(f=e.resolveTriangleIndex(h),Ft(o,3*f,l,c),o.needsUpdate=!0,i(o,f,s,n))return!0}return!1}function sd(r,t,e,i,s,n,o){Dt.setBuffer(r._roots[t]),nr(0,r,e,i,s,n,o),Dt.clearBuffer()}function nr(r,t,e,i,s,n,o){const{float32Array:a,uint16Array:l,uint32Array:c}=Dt,h=2*r;if(Ut(h,l))!function Xu(r,t,e,i,s,n,o,a){const{geometry:l}=r;for(let h=i,u=i+s;h<u;h++)Rs(l,t,e,h,n,o,a)}(t,e,i,Xt(r,c),Qt(h,l),s,n,o);else{const f=jt(r);Xe(f,a,i,n,o)&&nr(f,t,e,i,s,n,o);const d=Ht(r,c);Xe(d,a,i,n,o)&&nr(d,t,e,i,s,n,o)}}const nd=["x","y","z"];function rd(r,t,e,i,s,n){Dt.setBuffer(r._roots[t]);const o=rr(0,r,e,i,s,n);return Dt.clearBuffer(),o}function rr(r,t,e,i,s,n){const{float32Array:o,uint16Array:a,uint32Array:l}=Dt;let c=2*r;if(Ut(c,a))return function Ku(r,t,e,i,s,n,o){const{geometry:a}=r;let c=1/0,h=null;for(let u=i,f=i+s;u<f;u++){let d;d=Rs(a,t,e,u,null,n,o),d&&d.distance<c&&(h=d,c=d.distance)}return h}(t,e,i,Xt(r,l),Qt(c,a),s,n);{const u=qn(r,l),f=nd[u],_=i.direction[f]>=0;let m,w;_?(m=jt(r),w=Ht(r,l)):(m=Ht(r,l),w=jt(r));const v=Xe(m,o,i,s,n)?rr(m,t,e,i,s,n):null;if(v){const S=v.point[f];if(_?S<=o[w+u]:S>=o[w+u+3])return v}const C=Xe(w,o,i,s,n)?rr(w,t,e,i,s,n):null;return v&&C?v.distance<=C.distance?v:C:v||C||null}}const Fs=new p.NRn,Mi=new le,Ii=new le,ts=new p.kn4,pa=new Jt,Vs=new Jt;function od(r,t,e,i){Dt.setBuffer(r._roots[t]);const s=or(0,r,e,i);return Dt.clearBuffer(),s}function or(r,t,e,i,s=null){const{float32Array:n,uint16Array:o,uint32Array:a}=Dt;let l=2*r;if(null===s&&(e.boundingBox||e.computeBoundingBox(),pa.set(e.boundingBox.min,e.boundingBox.max,i),s=pa),!Ut(l,o)){const h=jt(r),u=Ht(r,a);return Lt(h,n,Fs),!!(s.intersectsBox(Fs)&&or(h,t,e,i,s)||(Lt(u,n,Fs),s.intersectsBox(Fs)&&or(u,t,e,i,s)))}{const h=t.geometry,u=h.index,f=h.attributes.position,d=e.index,_=e.attributes.position,m=Xt(r,a),w=Qt(l,o);if(ts.copy(i).invert(),e.boundsTree)return Lt(r,n,Vs),Vs.matrix.copy(ts),Vs.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:v=>Vs.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(i),v.b.applyMatrix4(i),v.c.applyMatrix4(i),v.needsUpdate=!0;for(let T=3*m,C=3*(w+m);T<C;T+=3)if(Ft(Ii,T,u,f),Ii.needsUpdate=!0,v.intersectsTriangle(Ii))return!0;return!1}});{const g=Ds(e);for(let v=3*m,T=3*(w+m);v<T;v+=3){Ft(Mi,v,u,f),Mi.a.applyMatrix4(ts),Mi.b.applyMatrix4(ts),Mi.c.applyMatrix4(ts),Mi.needsUpdate=!0;for(let C=0,S=3*g;C<S;C+=3)if(Ft(Ii,C,d,_),Ii.needsUpdate=!0,Mi.intersectsTriangle(Ii))return!0}}}}const Us=new p.kn4,ar=new Jt,es=new Jt,ad=new p.Pq0,ld=new p.Pq0,cd=new p.Pq0,hd=new p.Pq0;function ud(r,t,e,i={},s={},n=0,o=1/0){t.boundingBox||t.computeBoundingBox(),ar.set(t.boundingBox.min,t.boundingBox.max,e),ar.needsUpdate=!0;const a=r.geometry,l=a.attributes.position,c=a.index,h=t.attributes.position,u=t.index,f=me.getPrimitive(),d=me.getPrimitive();let _=ad,m=ld,w=null,g=null;s&&(w=cd,g=hd);let v=1/0,T=null,C=null;return Us.copy(e).invert(),es.matrix.copy(Us),r.shapecast({boundsTraverseOrder:S=>ar.distanceToBox(S),intersectsBounds:(S,M,A)=>A<v&&A<o&&(M&&(es.min.copy(S.min),es.max.copy(S.max),es.needsUpdate=!0),!0),intersectsRange:(S,M)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:O=>es.distanceToBox(O),intersectsBounds:(O,I,D)=>D<v&&D<o,intersectsRange:(O,I)=>{for(let D=O,B=O+I;D<B;D++){Ft(d,3*D,u,h),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let E=S,L=S+M;E<L;E++){Ft(f,3*E,c,l),f.needsUpdate=!0;const x=f.distanceToTriangle(d,_,w);if(x<v&&(m.copy(_),g&&g.copy(w),v=x,T=E,C=D),x<n)return!0}}}});for(let O=0,I=Ds(t);O<I;O++){Ft(d,3*O,u,h),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let D=S,B=S+M;D<B;D++){Ft(f,3*D,c,l),f.needsUpdate=!0;const E=f.distanceToTriangle(d,_,w);if(E<v&&(m.copy(_),g&&g.copy(w),v=E,T=D,C=O),E<n)return!0}}}}),me.releasePrimitive(f),me.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(m):i.point=m.clone(),i.distance=v,i.faceIndex=T,s&&(s.point?s.point.copy(g):s.point=g.clone(),s.point.applyMatrix4(Us),m.applyMatrix4(Us),s.distance=m.sub(s.point).length(),s.faceIndex=C),i)}function dd(r,t=null){t&&Array.isArray(t)&&(t=new Set(t));const e=r.geometry,i=e.index?e.index.array:null,s=e.attributes.position;let n,o,a,l,c=0;const h=r._roots;for(let f=0,d=h.length;f<d;f++)n=h[f],o=new Uint32Array(n),a=new Uint16Array(n),l=new Float32Array(n),u(0,c),c+=n.byteLength;function u(f,d,_=!1){const m=2*f;if(Ut(m,a)){const w=Xt(f,o);let v=1/0,T=1/0,C=1/0,S=-1/0,M=-1/0,A=-1/0;for(let O=w,I=w+Qt(m,a);O<I;O++){const D=3*r.resolveTriangleIndex(O);for(let B=0;B<3;B++){let E=D+B;E=i?i[E]:E;const L=s.getX(E),x=s.getY(E),N=s.getZ(E);L<v&&(v=L),L>S&&(S=L),x<T&&(T=x),x>M&&(M=x),N<C&&(C=N),N>A&&(A=N)}}return(l[f+0]!==v||l[f+1]!==T||l[f+2]!==C||l[f+3]!==S||l[f+4]!==M||l[f+5]!==A)&&(l[f+0]=v,l[f+1]=T,l[f+2]=C,l[f+3]=S,l[f+4]=M,l[f+5]=A,!0)}{const w=jt(f),g=Ht(f,o);let v=_,T=!1,C=!1;if(t){if(!v){const B=g/8+d/32;T=t.has(w/8+d/32),C=t.has(B),v=!T&&!C}}else T=!0,C=!0;const M=v||C;let A=!1;(v||T)&&(A=u(w,d,v));let O=!1;M&&(O=u(g,d,v));const I=A||O;if(I)for(let D=0;D<3;D++){const B=w+D,E=g+D,L=l[B],x=l[B+3],N=l[E],Y=l[E+3];l[f+D]=L<N?L:N,l[f+D+3]=x>Y?x:Y}return I}}}function fd(r,t,e,i,s,n,o){Dt.setBuffer(r._roots[t]),lr(0,r,e,i,s,n,o),Dt.clearBuffer()}function lr(r,t,e,i,s,n,o){const{float32Array:a,uint16Array:l,uint32Array:c}=Dt,h=2*r;if(Ut(h,l))!function td(r,t,e,i,s,n,o,a){const{geometry:l,_indirectBuffer:c}=r;for(let h=i,u=i+s;h<u;h++)Rs(l,t,e,c?c[h]:h,n,o,a)}(t,e,i,Xt(r,c),Qt(h,l),s,n,o);else{const f=jt(r);Xe(f,a,i,n,o)&&lr(f,t,e,i,s,n,o);const d=Ht(r,c);Xe(d,a,i,n,o)&&lr(d,t,e,i,s,n,o)}}const pd=["x","y","z"];function md(r,t,e,i,s,n){Dt.setBuffer(r._roots[t]);const o=cr(0,r,e,i,s,n);return Dt.clearBuffer(),o}function cr(r,t,e,i,s,n){const{float32Array:o,uint16Array:a,uint32Array:l}=Dt;let c=2*r;if(Ut(c,a))return function ed(r,t,e,i,s,n,o){const{geometry:a,_indirectBuffer:l}=r;let c=1/0,h=null;for(let u=i,f=i+s;u<f;u++){let d;d=Rs(a,t,e,l?l[u]:u,null,n,o),d&&d.distance<c&&(h=d,c=d.distance)}return h}(t,e,i,Xt(r,l),Qt(c,a),s,n);{const u=qn(r,l),f=pd[u],_=i.direction[f]>=0;let m,w;_?(m=jt(r),w=Ht(r,l)):(m=Ht(r,l),w=jt(r));const v=Xe(m,o,i,s,n)?cr(m,t,e,i,s,n):null;if(v){const S=v.point[f];if(_?S<=o[w+u]:S>=o[w+u+3])return v}const C=Xe(w,o,i,s,n)?cr(w,t,e,i,s,n):null;return v&&C?v.distance<=C.distance?v:C:v||C||null}}const $s=new p.NRn,Oi=new le,zi=new le,is=new p.kn4,ma=new Jt,js=new Jt;function gd(r,t,e,i){Dt.setBuffer(r._roots[t]);const s=hr(0,r,e,i);return Dt.clearBuffer(),s}function hr(r,t,e,i,s=null){const{float32Array:n,uint16Array:o,uint32Array:a}=Dt;let l=2*r;if(null===s&&(e.boundingBox||e.computeBoundingBox(),ma.set(e.boundingBox.min,e.boundingBox.max,i),s=ma),!Ut(l,o)){const h=jt(r),u=Ht(r,a);return Lt(h,n,$s),!!(s.intersectsBox($s)&&hr(h,t,e,i,s)||(Lt(u,n,$s),s.intersectsBox($s)&&hr(u,t,e,i,s)))}{const h=t.geometry,u=h.index,f=h.attributes.position,d=e.index,_=e.attributes.position,m=Xt(r,a),w=Qt(l,o);if(is.copy(i).invert(),e.boundsTree)return Lt(r,n,js),js.matrix.copy(is),js.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:v=>js.intersectsBox(v),intersectsTriangle:v=>{v.a.applyMatrix4(i),v.b.applyMatrix4(i),v.c.applyMatrix4(i),v.needsUpdate=!0;for(let T=m,C=w+m;T<C;T++)if(Ft(zi,3*t.resolveTriangleIndex(T),u,f),zi.needsUpdate=!0,v.intersectsTriangle(zi))return!0;return!1}});{const g=Ds(e);for(let v=m,T=w+m;v<T;v++){const C=t.resolveTriangleIndex(v);Ft(Oi,3*C,u,f),Oi.a.applyMatrix4(is),Oi.b.applyMatrix4(is),Oi.c.applyMatrix4(is),Oi.needsUpdate=!0;for(let S=0,M=3*g;S<M;S+=3)if(Ft(zi,S,d,_),zi.needsUpdate=!0,Oi.intersectsTriangle(zi))return!0}}}}const Hs=new p.kn4,ur=new Jt,ss=new Jt,_d=new p.Pq0,yd=new p.Pq0,wd=new p.Pq0,vd=new p.Pq0;function bd(r,t,e,i={},s={},n=0,o=1/0){t.boundingBox||t.computeBoundingBox(),ur.set(t.boundingBox.min,t.boundingBox.max,e),ur.needsUpdate=!0;const a=r.geometry,l=a.attributes.position,c=a.index,h=t.attributes.position,u=t.index,f=me.getPrimitive(),d=me.getPrimitive();let _=_d,m=yd,w=null,g=null;s&&(w=wd,g=vd);let v=1/0,T=null,C=null;return Hs.copy(e).invert(),ss.matrix.copy(Hs),r.shapecast({boundsTraverseOrder:S=>ur.distanceToBox(S),intersectsBounds:(S,M,A)=>A<v&&A<o&&(M&&(ss.min.copy(S.min),ss.max.copy(S.max),ss.needsUpdate=!0),!0),intersectsRange:(S,M)=>{if(t.boundsTree){const A=t.boundsTree;return A.shapecast({boundsTraverseOrder:O=>ss.distanceToBox(O),intersectsBounds:(O,I,D)=>D<v&&D<o,intersectsRange:(O,I)=>{for(let D=O,B=O+I;D<B;D++){const E=A.resolveTriangleIndex(D);Ft(d,3*E,u,h),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let L=S,x=S+M;L<x;L++){const N=r.resolveTriangleIndex(L);Ft(f,3*N,c,l),f.needsUpdate=!0;const Y=f.distanceToTriangle(d,_,w);if(Y<v&&(m.copy(_),g&&g.copy(w),v=Y,T=L,C=D),Y<n)return!0}}}})}for(let O=0,I=Ds(t);O<I;O++){Ft(d,3*O,u,h),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let D=S,B=S+M;D<B;D++){const E=r.resolveTriangleIndex(D);Ft(f,3*E,c,l),f.needsUpdate=!0;const L=f.distanceToTriangle(d,_,w);if(L<v&&(m.copy(_),g&&g.copy(w),v=L,T=D,C=O),L<n)return!0}}}}),me.releasePrimitive(f),me.releasePrimitive(d),v===1/0?null:(i.point?i.point.copy(m):i.point=m.clone(),i.distance=v,i.faceIndex=T,s&&(s.point?s.point.copy(g):s.point=g.clone(),s.point.applyMatrix4(Hs),m.applyMatrix4(Hs),s.distance=m.sub(s.point).length(),s.faceIndex=C),i)}function ga(r,t,e){return null===r?null:(r.point.applyMatrix4(t.matrixWorld),r.distance=r.point.distanceTo(e.ray.origin),r.object=t,r)}const qs=new Jt,Gs=new p.RlV,_a=new p.Pq0,ya=new p.kn4,wa=new p.Pq0,dr=["getX","getY","getZ"];class Ke extends aa{static serialize(t,e={}){e={cloneBuffers:!0,...e};const s=t._roots,n=t._indirectBuffer,o=t.geometry.getIndex(),a={version:1,roots:null,index:null,indirectBuffer:null};return e.cloneBuffers?(a.roots=s.map(l=>l.slice()),a.index=o?o.array.slice():null,a.indirectBuffer=n?n.slice():null):(a.roots=s,a.index=o?o.array:null,a.indirectBuffer=n),a}static deserialize(t,e,i={}){i={setIndex:!0,indirect:!!t.indirectBuffer,...i};const{index:s,roots:n,indirectBuffer:o}=t;t.version||(console.warn("MeshBVH.deserialize: Serialization format has been changed and will be fixed up. It is recommended to regenerate any stored serialized data."),function l(c){for(let h=0;h<c.length;h++){const u=c[h],f=new Uint32Array(u),d=new Uint16Array(u);for(let _=0,m=u.byteLength/32;_<m;_++){const w=8*_;Ut(2*w,d)||(f[w+6]=f[w+6]/8-_)}}}(n));const a=new Ke(e,{...i,[Hn]:!0});if(a._roots=n,a._indirectBuffer=o||null,i.setIndex){const c=e.getIndex();if(null===c){const h=new p.THS(t.index,1,!1);e.setIndex(h)}else c.array!==s&&(c.array.set(s),c.needsUpdate=!0)}return a}get primitiveStride(){return 3}get resolveTriangleIndex(){return this.resolvePrimitiveIndex}constructor(t,e={}){e.maxLeafTris&&(console.warn('MeshBVH: "maxLeafTris" option has been deprecated. Use maxLeafSize, instead.'),e={...e,maxLeafSize:e.maxLeafTris}),super(t,e)}shiftTriangleOffsets(t){return super.shiftPrimitiveOffsets(t)}writePrimitiveBounds(t,e,i){const s=this.geometry,n=this._indirectBuffer,o=s.attributes.position,a=s.index?s.index.array:null,c=3*(n?n[t]:t);let h=c+0,u=c+1,f=c+2;a&&(h=a[h],u=a[u],f=a[f]);for(let d=0;d<3;d++){const _=o[dr[d]](h),m=o[dr[d]](u),w=o[dr[d]](f);let g=_;m<g&&(g=m),w<g&&(g=w);let v=_;m>v&&(v=m),w>v&&(v=w),e[i+d]=g,e[i+d+3]=v}return e}computePrimitiveBounds(t,e,i){const s=this.geometry,n=this._indirectBuffer,o=s.attributes.position,a=s.index?s.index.array:null,l=o.normalized;if(t<0||e+t-i.offset>i.length/6)throw new Error("MeshBVH: compute triangle bounds range is invalid.");const c=o.array,h=o.offset||0;let u=3;o.isInterleavedBufferAttribute&&(u=o.data.stride);const f=["getX","getY","getZ"],d=i.offset;for(let _=t,m=t+e;_<m;_++){const g=3*(n?n[_]:_),v=6*(_-d);let T=g+0,C=g+1,S=g+2;a&&(T=a[T],C=a[C],S=a[S]),l||(T=T*u+h,C=C*u+h,S=S*u+h);for(let M=0;M<3;M++){let A,O,I;l?(A=o[f[M]](T),O=o[f[M]](C),I=o[f[M]](S)):(A=c[T+M],O=c[C+M],I=c[S+M]);let D=A;O<D&&(D=O),I<D&&(D=I);let B=A;O>B&&(B=O),I>B&&(B=I);const E=(B-D)/2,L=2*M;i[v+L+0]=D+E,i[v+L+1]=E+(Math.abs(D)+E)*Ss}}return i}raycastObject3D(t,e,i=[]){const{material:s}=t;if(void 0===s)return;ya.copy(t.matrixWorld).invert(),Gs.copy(e.ray).applyMatrix4(ya),wa.setFromMatrixScale(t.matrixWorld),_a.copy(Gs.direction).multiply(wa);const n=_a.length(),o=e.near/n,a=e.far/n;if(!0===e.firstHitOnly){let l=this.raycastFirst(Gs,s,o,a);l=ga(l,t,e),l&&i.push(l)}else{const l=this.raycast(Gs,s,o,a);for(let c=0,h=l.length;c<h;c++){const u=ga(l[c],t,e);u&&i.push(u)}}return i}refit(t=null){return(this.indirect?dd:Ju)(this,t)}raycast(t,e=p.hB5,i=0,s=1/0){const o=[],a=this.indirect?fd:sd;for(let l=0,c=this._roots.length;l<c;l++)a(this,l,e,t,o,i,s);return o}raycastFirst(t,e=p.hB5,i=0,s=1/0){let o=null;const a=this.indirect?md:rd;for(let l=0,c=this._roots.length;l<c;l++){const h=a(this,l,e,t,i,s);null!=h&&(null==o||h.distance<o.distance)&&(o=h)}return o}intersectsGeometry(t,e){let i=!1;const n=this.indirect?gd:od;for(let o=0,a=this._roots.length;o<a&&(i=n(this,o,t,e),!i);o++);return i}shapecast(t){const e=me.getPrimitive(),i=super.shapecast({...t,intersectsPrimitive:t.intersectsTriangle,scratchPrimitive:e,iterate:this.indirect?id:Qu});return me.releasePrimitive(e),i}bvhcast(t,e,i){let{intersectsRanges:s,intersectsTriangles:n}=i;const o=me.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?_=>{const m=this.resolveTriangleIndex(_);Ft(o,3*m,a,l)}:_=>{Ft(o,3*_,a,l)},h=me.getPrimitive(),u=t.geometry.index,f=t.geometry.attributes.position,d=t.indirect?_=>{const m=t.resolveTriangleIndex(_);Ft(h,3*m,u,f)}:_=>{Ft(h,3*_,u,f)};if(n){if(!(t instanceof Ke))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const _=(m,w,g,v,T,C,S,M)=>{for(let A=g,O=g+v;A<O;A++){d(A),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let I=m,D=m+w;I<D;I++)if(c(I),o.needsUpdate=!0,n(o,h,I,A,T,C,S,M))return!0}return!1};if(s){const m=s;s=function(w,g,v,T,C,S,M,A){return!!m(w,g,v,T,C,S,M,A)||_(w,g,v,T,C,S,M,A)}}else s=_}return super.bvhcast(t,e,{intersectsRanges:s})}intersectsBox(t,e){return qs.set(t.min,t.max,e),qs.needsUpdate=!0,this.shapecast({intersectsBounds:i=>qs.intersectsBox(i),intersectsTriangle:i=>qs.intersectsTriangle(i)})}intersectsSphere(t){return this.shapecast({intersectsBounds:e=>t.intersectsBox(e),intersectsTriangle:e=>e.intersectsSphere(t)})}closestPointToGeometry(t,e,i={},s={},n=0,o=1/0){return(this.indirect?bd:ud)(this,t,e,i,s,n,o)}closestPointToPoint(t,e={},i=0,s=1/0){return function Yu(r,t,e={},i=0,s=1/0){const n=i*i,o=s*s;let a=1/0,l=null;if(r.shapecast({boundsTraverseOrder:h=>(Qi.copy(t).clamp(h.min,h.max),Qi.distanceToSquared(t)),intersectsBounds:(h,u,f)=>f<a&&f<o,intersectsTriangle:(h,u)=>{h.closestPointToPoint(t,Qi);const f=t.distanceToSquared(Qi);return f<a&&(sr.copy(Qi),a=f,l=u),f<n}}),a===1/0)return null;const c=Math.sqrt(a);return e.point?e.point.copy(sr):e.point=sr.clone(),e.distance=c,e.faceIndex=l,e}(this,t,e,i,s)}}const va=new p.kn4,Ys=new p.RlV,ba=new Is(()=>new p.cZY),fr=new p.Pq0,xa=new p.Pq0,Ca=new p.NRn,Ta=["getX","getY","getZ"];class xd extends aa{get primitiveStride(){return 2}writePrimitiveBounds(t,e,i){const s=this._indirectBuffer,{geometry:n,primitiveStride:o}=this,a=n.attributes.position,l=n.index;let u=(s?s[t]:t)*o,f=(u+1)%(l?l.count:a.count);l&&(u=l.getX(u),f=l.getX(f));for(let d=0;d<3;d++){const _=a[Ta[d]](u),m=a[Ta[d]](f),g=_>m?_:m;e[i+d]=_<m?_:m,e[i+d+3]=g}return e}shapecast(t){const e=ba.getPrimitive(),i=super.shapecast({...t,intersectsPrimitive:t.intersectsLine,scratchPrimitive:e,iterate:Cd});return ba.releasePrimitive(e),i}raycastObject3D(t,e,i=[]){const{matrixWorld:s}=t,{firstHitOnly:n}=e;va.copy(s).invert(),Ys.copy(e.ray).applyMatrix4(va);const a=e.params.Line.threshold/((t.scale.x+t.scale.y+t.scale.z)/3),l=a*a;let c=null,h=1/0;return this.shapecast({boundsTraverseOrder:u=>u.distanceToPoint(Ys.origin),intersectsBounds:u=>(Ca.copy(u).expandByScalar(Math.abs(a)),Ys.intersectsBox(Ca)?1:0),intersectsLine:(u,f)=>{if(Ys.distanceSqToSegment(u.start,u.end,fr,xa)>l)return;fr.applyMatrix4(t.matrixWorld);const _=e.ray.origin.distanceTo(fr);_<e.near||_>e.far||n&&_>=h||(h=_,f=this.resolvePrimitiveIndex(f),c={distance:_,point:xa.clone().applyMatrix4(s),index:f*this.primitiveStride,face:null,faceIndex:null,barycoord:null,object:t},n||i.push(c))}}),n&&c&&i.push(c),i}}function Cd(r,t,e,i,s,n,o){const{geometry:a,primitiveStride:l}=e,{index:c}=a,h=a.attributes.position,u=c?c.count:h.count;for(let f=r,d=t+r;f<d;f++){let m=e.resolvePrimitiveIndex(f)*l,w=(m+1)%u;if(c&&(m=c.getX(m),w=c.getX(w)),o.start.fromBufferAttribute(h,m),o.end.fromBufferAttribute(h,w),i(o,f,s,n))return!0}return!1}const Di={Mesh:p.eaF.prototype.raycast,Line:p.N1A.prototype.raycast,LineSegments:p.DXC.prototype.raycast,LineLoop:p.FCc.prototype.raycast,Points:p.ONl.prototype.raycast,BatchedMesh:p.$Ed.prototype.raycast},Yt=new p.eaF,Zs=[];function Pa(r,t){if(this.isBatchedMesh)Td.call(this,r,t);else{const{geometry:e}=this;if(e.boundsTree)e.boundsTree.raycastObject3D(this,r,t);else{let i;if(this instanceof p.eaF)i=Di.Mesh;else if(this instanceof p.DXC)i=Di.LineSegments;else if(this instanceof p.FCc)i=Di.LineLoop;else if(this instanceof p.N1A)i=Di.Line;else{if(!(this instanceof p.ONl))throw new Error("BVH: Fallback raycast function not found.");i=Di.Points}i.call(this,r,t)}}}function Td(r,t){if(this.boundsTrees){const e=this.boundsTrees,i=this._drawInfo||this._instanceInfo,s=this._drawRanges||this._geometryInfo,n=this.matrixWorld;Yt.material=this.material,Yt.geometry=this.geometry;const o=Yt.geometry.boundsTree,a=Yt.geometry.drawRange;null===Yt.geometry.boundingSphere&&(Yt.geometry.boundingSphere=new p.iyt);for(let l=0,c=i.length;l<c;l++){if(!this.getVisibleAt(l))continue;const h=i[l].geometryIndex;if(Yt.geometry.boundsTree=e[h],this.getMatrixAt(l,Yt.matrixWorld).premultiply(n),!Yt.geometry.boundsTree){this.getBoundingBoxAt(h,Yt.geometry.boundingBox),this.getBoundingSphereAt(h,Yt.geometry.boundingSphere);const u=s[h];Yt.geometry.setDrawRange(u.start,u.count)}Yt.raycast(r,Zs);for(let u=0,f=Zs.length;u<f;u++){const d=Zs[u];d.object=this,d.batchId=l,t.push(d)}Zs.length=0}Yt.geometry.boundsTree=o,Yt.geometry.drawRange=a,Yt.material=null,Yt.geometry=null}else Di.BatchedMesh.call(this,r,t)}function Pd(r={}){const{type:t=Ke}=r;return this.boundsTree=new t(this,r),this.boundsTree}function Sd(){this.boundsTree=null}const Sa=class Rc extends At{constructor(t){super(t),y(this,"onDisposed",new Q),y(this,"onBeforeDispose",new Q),y(this,"onFragmentsLoaded",new Q),y(this,"baseCoordinationModel",""),y(this,"baseCoordinationMatrix",new p.kn4),y(this,"enabled",!0),y(this,"_core"),this.components.add(Rc.uuid,this)}static getWorker(){return ot._i.getWorker()}get initialized(){return!!this._core}get list(){return this.core.models.list}get core(){if(!this._core)throw new Error("FragmentsManager not initialized. Call init() first.");return this._core}get _hasCoordinationModel(){return""!==this.baseCoordinationModel}dispose(){this.onBeforeDispose.trigger(),this._core&&(this.core.dispose(),this._core=void 0),this.baseCoordinationModel="",this.onFragmentsLoaded.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}init(t,e){var i=this;this._core=new ot._i(t,e),this.core.onModelLoaded.add((0,G.A)(function*(){if(i._hasCoordinationModel)return;const s=[...i.list.values()][0];s&&(i.baseCoordinationModel=s.modelId,i.baseCoordinationMatrix=yield s.getCoordinationMatrix())})),this.list.onItemDeleted.add(()=>{this.list.size>0||(this.baseCoordinationModel="",this.baseCoordinationMatrix=new p.kn4)})}raycast(t){var e=this;return(0,G.A)(function*(){const i=[];for(const o of e.core.models.list.values())if(t.snappingClasses&&t.snappingClasses.length>0){const a=yield o.raycastWithSnapping(t);if(a&&a.length>0)i.push(a[0]);else{const l=yield o.raycast(t);l&&i.push(l)}}else{const a=yield o.raycast(t);a&&i.push(a)}if(yield Promise.all(i),0===i.length)return;let s=i[0],n=s.distance;for(let o=1;o<i.length;o++)i[o].distance<n&&(n=i[o].distance,s=i[o]);return s})()}getPositions(t){var e=this;return(0,G.A)(function*(){const i=[],s=function(){var o=(0,G.A)(function*(a,l){const c=yield a.getPositions(l);for(const h of c)i.push(h)});return function(l,c){return o.apply(this,arguments)}}(),n=[];for(const o in t){const a=e.core.models.list.get(o);a&&n.push(s(a,Array.from(t[o])))}return yield Promise.all(n),i})()}getBBoxes(t){var e=this;return(0,G.A)(function*(){const i=[],s=function(){var o=(0,G.A)(function*(a,l){const c=yield a.getBoxes(l);if(c)for(const h of c)i.push(h)});return function(l,c){return o.apply(this,arguments)}}(),n=[];for(const o in t){const a=e.core.models.list.get(o);a&&n.push(s(a,Array.from(t[o])))}return yield Promise.all(n),i})()}highlight(t,e){var i=this;return(0,G.A)(function*(){yield i.forEachModel(e,"highlight",t)})()}getData(t,e){var i=this;return(0,G.A)(function*(){const s={};for(const[n,o]of Object.entries(t)){const a=i.list.get(n);if(!a)continue;if(0===o.size){s[n]=[];continue}const l=yield a.getItemsData([...o],e);s[n]=l}return s})()}resetHighlight(t){var e=this;return(0,G.A)(function*(){yield e.forEachModel(t,"resetHighlight")})()}forEachModel(t,e,...i){var s=this;return(0,G.A)(function*(){const n={};if(t)for(const a in t)n[a]=Array.from(t[a]);else for(const a of s.core.models.list.keys())n[a]=void 0;const o=[];for(const a in n){const l=s.core.models.list.get(a);if(l){const h=l[e](n[a],...i);o.push(h)}}yield Promise.all(o)})()}guidsToModelIdMap(t){var e=this;return(0,G.A)(function*(){const i={};for(const[s,n]of e.list){const o=(yield n.getLocalIdsByGuids([...t])).filter(a=>null!==a);i[s]=new Set(o)}return i})()}modelIdMapToGuids(t){var e=this;return(0,G.A)(function*(){const i=[];for(const[s,n]of Object.entries(t)){const o=e.list.get(s);if(!o)continue;const a=(yield o.getGuidsByLocalIds([...n])).filter(l=>null!==l);i.push(...a)}return i})()}applyBaseCoordinateSystem(t,e){const i=new p.kn4;return e&&i.copy(e.clone()).invert(),i.multiply(this.baseCoordinationMatrix),t.applyMatrix4(i),i}};y(Sa,"uuid","fef46874-46a3-461b-8c44-2922ab77c806");let ft=Sa;function Ad(r,t){return r[t]|r[t+1]<<8|r[t+2]<<16}class Id{constructor(t,e={}){const{pixelsPerMeter:i=.1}=e;this.pixelsPerMeter=i,this.renderer=t}cull(t){var e=this;return(0,G.A)(function*(){t=function Md(r){const t=new Set;return r.traverse(e=>{e.isMesh&&t.add(e)}),Array.from(t)}(t);const{renderer:i,pixelsPerMeter:s}=e,n=new p.Pq0,o=new p.qUd,a=new p.NRn,l=new p.nWS(1,1);a.makeEmpty(),t.forEach(D=>{a.expandByObject(D)}),a.getSize(n);const c=Math.min(i.capabilities.maxTextureSize,8192),h=Math.ceil(n.x/s),u=Math.ceil(n.z/s),f=Math.ceil(h/c),d=Math.ceil(u/c);l.setSize(Math.ceil(h/f),Math.ceil(u/d)),o.rotation.x=-Math.PI/2,o.far=a.max.y-a.min.y+o.near,o.position.y=a.max.y+o.near;const _=new p.Z58,m=new Map,w=new Map,g=[];for(let D=0;D<t.length;D++){const B=t[D];m.set(B,B.material),w.set(B,B.parent);const E=new Od;E.objectId=D,g.push(E),B.material=E,_.add(B)}const v=i.getClearColor(new p.Q1f),T=i.getClearAlpha(),C=i.getRenderTarget(),S=i.autoClear;i.autoClear=!0,i.setClearColor(0,0),i.setRenderTarget(l);const M=new Uint8Array(l.width*l.height*4),A=new Set,O=n.x/f,I=n.z/d;for(let D=0;D<f;D++)for(let B=0;B<d;B++){const E=a.min.x+O*D,x=a.min.z+I*B;o.position.set((E+(E+O))/2,a.max.y,(x+(x+I))/2);const ct=O/2,Z=I/2;o.left=-ct,o.right=ct,o.top=Z,o.bottom=-Z,o.updateProjectionMatrix(),i.render(_,o);const at=yield i.readRenderTargetPixelsAsync(l,0,0,l.width,l.height,M);for(let F=0,V=at.length;F<V;F+=4){if(0===at[F+3])continue;const nt=Ad(at,F);A.add(t[nt])}}for(const D of t){D.material=m.get(D);const B=w.get(D);B?B.add(D):_.remove(D)}i.setClearColor(v,T),i.setRenderTarget(C),i.autoClear=S;for(const D of g)D.dispose();return l.dispose(),Array.from(A)})()}}class Od extends p.BKk{get objectId(){return this._objectId}set objectId(t){this._objectId=t,function Ed(r,t){t.x=(255&r)/255,t.y=(r>>8&255)/255,t.z=(r>>16&255)/255,t.w=1}(t,this.uniforms.objectId.value)}constructor(t){super({glslVersion:p.Wdf,blending:p.XIg,uniforms:{objectId:{value:new p.IUQ}},vertexShader:"\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t\t\t}\n\t\t\t",fragmentShader:"\n\t\t\t\tlayout(location = 0) out vec4 out_id;\n\t\t\t\tuniform vec4 objectId;\n\n\t\t\t\tvoid main() {\n\n\t\t\t\t\tout_id = objectId;\n\n\t\t\t\t}\n\t\t\t"}),this._objectId=0,this.setValues(t)}}const zd=new p.Pq0(0,1,0),Ea=new p.Pq0;function Aa(r){return r.delta(Ea).normalize(),Math.abs(Ea.dot(zd))>=1-1e-16}function mr(r,t){const{start:e,end:i}=t,s=r.points;let n=!1,o=!1;for(let a=0;a<3;a++){const l=s[a];if(!n&&e.distanceToSquared(l)<=1e-16&&(n=!0),!o&&i.distanceToSquared(l)<=1e-16&&(o=!0),n&&o)return!0}return n&&o}const Qe=new p.cZY;function Ma(r,t,e=!1,i=[]){let s=[[0,1]];for(let n=0,o=t.length;n<o;n++){const l=t[n];s[n][1]=l[0],s.push([l[1],1])}e&&([t,s]=[s,t]);for(let n=0,o=s.length;n<o;n++){const{start:a,end:l}=r;Qe.start.lerpVectors(a,l,s[n][0]),Qe.end.lerpVectors(a,l,s[n][1]),i.push(new Float32Array([Qe.start.x,Qe.start.y,Qe.start.z,Qe.end.x,Qe.end.y,Qe.end.z]))}return i}const Dd=new p.Pq0(0,1,0),Oa=new p.Pq0,za=new p.Pq0,Ws=new p.Pq0,Xs=new p.lMl;function*Da(r,t=[],e={}){const{projectionDirection:i=Dd,thresholdAngle:s=1,iterationTime:n=30}=e,a=Math.pow(10,4),l=Math.cos(p.cj9.DEG2RAD*s),c=r.getIndex(),h=r.getAttribute("position"),u=c?c.count:h.count,f=[0,0,0],d=["a","b","c"],_=new Array(3),m={};let w=performance.now();for(let g=0;g<u;g+=3){performance.now()-w>n&&(yield,w=performance.now()),c?(f[0]=c.getX(g),f[1]=c.getX(g+1),f[2]=c.getX(g+2)):(f[0]=g,f[1]=g+1,f[2]=g+2);const{a:v,b:T,c:C}=Xs;if(v.fromBufferAttribute(h,f[0]),T.fromBufferAttribute(h,f[1]),C.fromBufferAttribute(h,f[2]),Xs.getNormal(Ws),_[0]=`${Math.round(v.x*a)},${Math.round(v.y*a)},${Math.round(v.z*a)}`,_[1]=`${Math.round(T.x*a)},${Math.round(T.y*a)},${Math.round(T.z*a)}`,_[2]=`${Math.round(C.x*a)},${Math.round(C.y*a)},${Math.round(C.z*a)}`,_[0]!==_[1]&&_[1]!==_[2]&&_[2]!==_[0])for(let S=0;S<3;S++){const M=(S+1)%3,A=_[S],O=_[M],I=Xs[d[S]],D=Xs[d[M]],B=`${A}_${O}`,E=`${O}_${A}`;if(E in m&&m[E]){const L=m[E].normal,x=Ws.dot(L)<=l;let N=!1;if(null!==i){let Y=i.dot(Ws);Y=Math.abs(Y)<1e-10?0:Y;let q=i.dot(L);q=Math.abs(q)<1e-10?0:q,N=Math.sign(Y)!==Math.sign(q)}if(x||N){const Y=new p.cZY;Y.start.copy(I),Y.end.copy(D),t.push(Y)}m[E]=null}else B in m||(m[B]={index0:f[S],index1:f[M],normal:Ws.clone()})}}for(const g in m)if(m[g]){const{index0:v,index1:T}=m[g];Oa.fromBufferAttribute(h,v),za.fromBufferAttribute(h,T);const C=new p.cZY;C.start.copy(Oa),C.end.copy(za),t.push(C)}return t}const Ks=new p.cZY;function ka(r,t,e,i=[]){return r.bvhcast(t,e,{intersectsTriangles:(s,n)=>{if(function Ld(r,t){const e=["a","b","c"];let i=0;for(let s=0;s<3;s++)for(let n=0;n<3;n++)kd(r[e[s]],t[e[n]])&&i++;return i>=2}(s,n)||(s.needsUpdate&&s.update(),n.needsUpdate&&n.update(),Math.abs(s.plane.normal.dot(n.plane.normal))>.999999))return!1;s.intersectsTriangle(n,Ks,!0)&&!mr(s,Ks)&&!mr(n,Ks)&&i.push(Ks.clone())}}),i}function kd(r,t){return r.distanceTo(t)<1e-10}function gr(r){La(r);let t=[];return r.traverse(e=>{e.geometry&&e.visible&&t.push(e)}),t}const La=r=>{if(void 0===r)return;const t=[...r.children];for(const e of t)void 0===e?r.children.splice(r.children.indexOf(e),1):La(e)},Qs=new p.kn4,Na=new p.kn4;class Nd{constructor(){this.projectionDirection=new p.Pq0(0,1,0),this.thresholdAngle=50,this.iterationTime=30}getEdges(...t){const e=this.iterationTime;this.iterationTime=1/0;const i=this.getEdgesGenerator(...t).next().value;return this.iterationTime=e,i}*getEdgesGenerator(t,e=[],i=null){const{projectionDirection:s,thresholdAngle:n,iterationTime:o}=this;if(t.isObject3D){const a=gr(t);let l=null;s&&(l=new p.Pq0);let c=performance.now();for(let h=0;h<a.length;h++){c-performance.now()>o&&(yield);const u=a[h];l&&(Na.copy(u.matrixWorld).invert(),l.copy(s).transformDirection(Na).normalize());const f=yield*Da(u.geometry,[],{projectionDirection:l,thresholdAngle:n,iterationTime:o});Ba(f,u.matrixWorld);for(let d=0;d<f.length;d++)e.push(f[d]);if(null!==i)for(let d=0;d<f.length;d++)i.push(u)}return e}return yield*Da(t,e,{projectionDirection:s,thresholdAngle:n,iterationTime:o})}getIntersectionEdges(...t){const e=this.iterationTime;this.iterationTime=1/0;const i=this.getIntersectionEdgesGenerator(...t).next().value;return this.iterationTime=e,i}*getIntersectionEdgesGenerator(t,e=[],i=null){const{iterationTime:s}=this;if(t.isObject3D){const n=gr(t),o=new Map;let a=performance.now();for(let l=0;l<n.length;l++){performance.now()-a>s&&(yield,a=performance.now());const h=n[l].geometry;if(!o.has(h)){const u=h.boundsTree||new Ke(h,{maxLeafSize:1});o.set(h,u)}}a=performance.now();for(let l=0;l<n.length;l++)for(let c=l;c<n.length;c++){performance.now()-a>s&&(yield,a=performance.now());const h=n[l],u=n[c],f=o.get(h.geometry),d=o.get(u.geometry);Qs.copy(h.matrixWorld).invert().multiply(u.matrixWorld);const _=ka(f,d,Qs,[]);Ba(_,h.matrixWorld);for(let m=0;m<_.length;m++)e.push(_[m]);if(null!==i)for(let m=0;m<_.length;m++)i.push(h)}return e}{let n;return t.isBufferGeometry?n=t.boundsTree||new Ke(t,{maxLeafSize:1}):(n=t,t=n.geometry),Qs.identity(),ka(n,n,Qs,e)}}}function Ba(r,t,e=1e-6){for(let i=0;i<r.length;i++){const s=r[i];s.applyMatrix4(t),s.start.y+=e,s.end.y+=e}}class Bd extends ra{get lines(){return this.primitiveBuffer}constructor(t,e){super(e),this.primitiveBuffer=t,this.primitiveBufferStride=1,this.heightOffset=e.heightOffset??1e3,this.init(e)}writePrimitiveBounds(t,e,i){const{primitiveBuffer:s,heightOffset:n}=this,{start:o,end:a}=s[t];e[i+0]=Math.min(o.x,a.x),e[i+1]=Math.min(o.y,a.y),e[i+2]=Math.min(o.z,a.z),e[i+3]=Math.max(o.x,a.x),e[i+4]=Math.max(o.y,a.y)+n,e[i+5]=Math.max(o.z,a.z)}getRootRanges(){return[{offset:0,count:this.primitiveBuffer.length}]}}const Rd=new p.Pq0(0,1,0),fi=new p.Zcv,_r=new p.Pq0,Fa=new p.Pq0;function Fd(r,t,e){r.needsUpdate&&r.update(),fi.copy(r.plane),fi.normal.dot(Rd)<0&&(fi.normal.multiplyScalar(-1),fi.constant*=-1);const i=fi.distanceToPoint(t.start),s=fi.distanceToPoint(t.end),n=Math.abs(i)<1e-16,o=i<0,a=s<0;if(t.delta(Fa).normalize(),Math.abs(fi.normal.dot(Fa))<1e-16)return!(n||!o||(e.copy(t),0));if(o&&a)return e.copy(t),!0;if(!o&&!a)return!1;{const l=p.cj9.mapLinear(0,i,s,0,1);if(t.at(l,_r),o)return e.start.copy(t.start),e.end.copy(_r),!0;if(a)return e.end.copy(t.end),e.start.copy(_r),!0}return!1}const yr=new p.Zcv,Js=new p.Pq0,wr=new p.Pq0,Je=new le,Pe=new p.cZY,Ne=new p.cZY,ki=new p.Pq0,Ua=new p.Pq0,$a=new p.Pq0;function Ud(r,t,e=new p.cZY){if(Je.copy(t),Je.a.y=0,Je.b.y=0,Je.c.y=0,Je.update(),Pe.copy(r),Pe.start.y=0,Pe.end.y=0,Je.getArea()<=1e-16)return null;const i=Pe.distance();Pe.delta(ki).divideScalar(i),Ua.copy(ki).cross(Je.plane.normal).normalize(),yr.setFromNormalAndCoplanarPoint(Ua,Pe.start);let s=0;const{points:n}=Je;for(let o=0;o<3;o++){const a=n[o],l=n[(o+1)%3],c=yr.distanceToPoint(a),h=yr.distanceToPoint(l),u=Math.abs(c)<1e-16,f=Math.abs(h)<1e-16;let d=!1;if(!u&&!f&&c*h<0&&(Js.lerpVectors(a,l,c/(c-h)),d=!0),(d&&!f||u)&&(u&&!d&&Js.copy(a),0===s?Ne.start.copy(Js):Ne.end.copy(Js),s++,2===s))break}if(2===s){if(Ne.delta($a).normalize(),ki.dot($a)<0){const f=Ne.start;Ne.start=Ne.end,Ne.end=f}const o=0,a=wr.subVectors(Pe.end,Pe.start).dot(ki),l=wr.subVectors(Ne.start,Pe.start).dot(ki),c=wr.subVectors(Ne.end,Pe.start).dot(ki);return a<=l||c<=o?null:(r.at(Math.max(o,l)/i,e.start),r.at(Math.min(a,c)/i,e.end),e)}return null}const ja=new p.Pq0,Ha=new p.Pq0,qa=new p.Pq0;function jd(r,t,e){const i=function Hd(r,t){r.delta(ja),Ha.subVectors(t.start,r.start),qa.subVectors(t.end,r.start);const e=ja.length();let i=Ha.length()/e,s=qa.length()/e;return i=Math.min(Math.max(i,0),1),s=Math.min(Math.max(s,0),1),Math.abs(i-s)<=1e-16?null:[i,s]}(r,t);return!!i&&(Ga(i,e),!0)}function Ga(r,t){let[e,i]=r,s=0,n=t.length;for(;s<n;){const l=s+n>>>1;t[l][0]<=e?s=l+1:n=l}let o=Math.max(0,s-1),a=0;for(let l=o,c=t.length;l<c;l++){const[h,u]=t[l];if(e<=u&&i>=h)e=Math.min(h,e),i=Math.max(u,i),a++;else{if(!(e>=h))break;o=l+1}}t.splice(o,a,[e,i])}const qd=new p.Pq0(0,1,0),tn=new p.cZY,Ya=new p.cZY,ge=new le;function Yd(r,t,e,i,s=null){const{geometry:n,matrixWorld:o,material:a}=e,l=a.side,c=o.determinant()<0,h=r.lines;r.bvhcast(t,o,{intersectsRanges:(u,f,d,_)=>{s&&(s.candidates+=f*_);for(let m=d,w=_+d;m<w;m++){let g=3*m+0,v=3*m+1,T=3*m+2;n.index&&(g=n.index.getX(g),v=n.index.getX(v),T=n.index.getX(T));const{a:C,b:S,c:M}=ge;if(C.fromBufferAttribute(n.attributes.position,g).applyMatrix4(o),S.fromBufferAttribute(n.attributes.position,v).applyMatrix4(o),M.fromBufferAttribute(n.attributes.position,T).applyMatrix4(o),ge.needsUpdate=!0,ge.update(),l!==p.$EB&&ge.plane.normal.dot(qd)!==c==(l===p.hsX)){s&&(s.backFaceCulled+=f);continue}const A=Math.max(C.y,S.y,M.y),O=Math.min(C.y,S.y,M.y),I=ge.plane.normal;let D=I.x,B=I.y,E=I.z,L=ge.plane.constant;B<0&&(D=-D,B=-B,E=-E,L=-L);for(let x=u,N=f+u;x<N;x++){const Y=h[x],q=Math.min(Y.start.y,Y.end.y),ct=Math.max(Y.start.y,Y.end.y);if(A<=q){s&&s.yBoundsCulled++;continue}const Z=Y.end.x-Y.start.x,at=Y.end.z-Y.start.z,F=Z*Z+at*at;if(F>1e-20){const it=1/Math.sqrt(F),J=Z*it,_t=at*it,St=-_t,dt=J,rt=C.x-Y.start.x,ht=C.z-Y.start.z,pt=S.x-Y.start.x,xt=S.z-Y.start.z,Et=M.x-Y.start.x,P=M.z-Y.start.z,W=rt*J+ht*_t,H=pt*J+xt*_t,k=Et*J+P*_t,z=1/it,R=Math.min(W,H,k);if(Math.max(W,H,k)<0||R>z){s&&s.xzBoundsCulled++;continue}const K=rt*St+ht*dt,U=pt*St+xt*dt,tt=Et*St+P*dt,lt=Math.min(K,U,tt),et=Math.max(K,U,tt);if(lt>0||et<0){s&&s.xzBoundsCulled++;continue}}if(D*Y.start.x+B*Y.start.y+E*Y.start.z+L>=0&&D*Y.end.x+B*Y.end.y+E*Y.end.z+L>=0)s&&s.planeTrimCulled++;else if(mr(ge,Y))s&&s.triangleEdgeCulled++;else{if(ct<O)tn.copy(Y);else if(!Fd(ge,Y,tn)){s&&s.planeTrimCulled++;continue}tn.distance()<1e-10?s&&s.distThresholdCulled++:Ud(tn,ge,Ya)?(s&&s.used++,jd(Y,Ya,i[x])):s&&s.noOverlapCulled++}}}}})}ge.update=()=>{ge.plane.setFromCoplanarPoints(...ge.points)};let Li=!1;const en={},ns={};let pi=null,vr=0,br=0;const bt={get enabled(){return Li},set enabled(r){Li=r},reset(){for(const r in en)delete en[r];for(const r in ns)delete ns[r];pi=null,vr=0,br=0},setStat(r,t){ns[r]=t},startTotal(){Li&&(br=performance.now())},startStep(r){Li&&(null!==pi&&this.endStep(),pi=r,vr=performance.now())},endStep(){if(!Li||null===pi)return;const r=performance.now()-vr;en[pi]=r,pi=null},printSummary(){if(!Li)return;null!==pi&&this.endStep();const r=performance.now()-br;console.log("\n=== Projection Summary ==="),console.log(`Total time: ${r.toFixed(1)}ms\n`);for(const[t,e]of Object.entries(en)){const i=(e/r*100).toFixed(1);console.log(` ${t}: ${e.toFixed(1)}ms (${i}%)`)}if(Object.keys(ns).length>0){console.log("\n--- Stats ---");for(const[t,e]of Object.entries(ns))console.log(` ${t}: ${e}`)}console.log("")}},be=1e-5,sn=1e-16,nn=1e-16;function Wd(r,t,e,i,s){r.bvhcast(t,e.matrixWorld,{intersectsRanges:(n,o,a,l)=>{i._edgeOffsets.push(n),i._edgeCounts.push(o),i._meshOffsets.push(a),i._meshCounts.push(l),i._meshIndex.push(s),i.groupCount++}})}let rs=null;function Tr(){return(Tr=(0,G.A)(function*(){return null===rs&&(rs=new bn.uV1,yield rs.init()),rs})).apply(this,arguments)}function Pr(){return Pr=(0,G.A)(function*(r,t,e,i,s=null){const n=yield function Jd(){return Tr.apply(this,arguments)}();r._edgeOffsets&&(r.edgeOffsets=new Uint32Array(r._edgeOffsets),r.edgeCounts=new Uint32Array(r._edgeCounts),r.meshOffsets=new Uint32Array(r._meshOffsets),r.meshCounts=new Uint32Array(r._meshCounts),r.meshIndex=new Uint32Array(r._meshIndex),r._edgeOffsets=null,r._edgeCounts=null,r._meshOffsets=null,r._meshCounts=null,r._meshIndex=null);const o=(0,$.$_z)(function Zd(r){const t=new Float32Array(6*r.length);for(let e=0;e<r.length;e++){const i=r[e];t[6*e+0]=i.start.x,t[6*e+1]=i.start.y,t[6*e+2]=i.start.z,t[6*e+3]=i.end.x,t[6*e+4]=i.end.y,t[6*e+5]=i.end.z}return t}(e.lines),"float");bt.enabled&&console.log("Number of meshes:",t.length),bt.enabled&&console.log("Group count:",r.groupCount);const a=[];{let _=0;for(;_<t.length;){let m=_,w=0;for(;m<t.length;){const g=t[m].geometry,v=g.index?g.index.count/3:g.attributes.position.count/3;if(m>_&&(m-_>=1e3||w+v>1e5))break;w+=v,m++}a.push({start:_,end:m}),_=m}}bt.enabled&&console.log(`Split ${t.length} meshes into ${a.length} batches`);let l=0,c=0,h=0,u=0,f=0;for(let _=0;_<a.length;_++){const{start:m,end:w}=a[_],g=w-m;bt.enabled&&console.log(`Processing batch ${_+1}/${a.length} (meshes ${m}-${w-1})`);let v=0,T=0;const C=[];for(let rt=m;rt<w;rt++){const ht=t[rt].geometry;C.push(T/3),v+=ht.attributes.position.array.length,T+=ht.index.array.length}const S=new Float32Array(v),M=new Uint32Array(T);let A=0,O=0,I=0;for(let rt=m;rt<w;rt++){const ht=t[rt].geometry,pt=ht.attributes.position.array,xt=ht.index.array;S.set(pt,A),A+=pt.length;for(let Et=0;Et<xt.length;Et++)M[O+Et]=xt[Et]+I;O+=xt.length,I+=ht.attributes.position.count}const D=new Float32Array(16*g);for(let rt=m;rt<w;rt++)D.set(t[rt].matrixWorld.elements,16*(rt-m));const B=[];for(let rt=0;rt<r.groupCount;rt++){const ht=r.meshIndex[rt];if(ht>=m&&ht<w){const pt=ht-m;B.push({edgeOffset:r.edgeOffsets[rt],edgeCount:r.edgeCounts[rt],triOffset:C[pt]+r.meshOffsets[rt],triCount:r.meshCounts[rt],meshIdx:pt})}}if(0===B.length){bt.enabled&&console.log(` Batch ${_+1}: no groups, skipping`);continue}const E=new Uint32Array(5*B.length);for(let rt=0;rt<B.length;rt++){const ht=B[rt],pt=5*rt;E[pt+0]=ht.edgeOffset,E[pt+1]=ht.edgeCount,E[pt+2]=ht.triOffset,E[pt+3]=ht.triCount,E[pt+4]=ht.meshIdx}let L=0;for(let rt=0;rt<B.length;rt++)L+=B[rt].edgeCount*B[rt].triCount;s&&(s.candidates+=L);let x=Math.min(Math.ceil(.1*L),2e6),N=Math.max(x,1e4);bt.enabled&&console.log(` Batch ${_+1}: ${B.length} groups, ${v/3} vertices, ${T/3} triangles, ${L} pairs, buffer for ${N} overlaps`);const Y=performance.now(),q=(0,$.$_z)(S,"float"),ct=(0,$.$_z)(M,"uint"),Z=(0,$.$_z)(D,"float"),at=(0,$.$_z)(E,"uint");let F=(0,$.$_z)(new Uint32Array([0]),"uint").toAtomic(),V=(0,$.$_z)(new Float32Array(3*N),"float");u+=performance.now()-Y;const nt=performance.now(),it=(0,$.Fn)(()=>{const ht=$.cGD.mul(5),pt=at.element(ht),xt=at.element(ht.add(1)),Et=at.element(ht.add(2)),P=at.element(ht.add(3)),H=at.element(ht.add(4)).mul(16),k=(0,$.pBV)(Z.element(H),Z.element(H.add(1)),Z.element(H.add(2)),Z.element(H.add(3)),Z.element(H.add(4)),Z.element(H.add(5)),Z.element(H.add(6)),Z.element(H.add(7)),Z.element(H.add(8)),Z.element(H.add(9)),Z.element(H.add(10)),Z.element(H.add(11)),Z.element(H.add(12)),Z.element(H.add(13)),Z.element(H.add(14)),Z.element(H.add(15)));(0,$.FZF)({start:(0,$.Whr)(0),end:P.toInt(),type:"int",condition:"<",name:"triIdx"},({triIdx:z})=>{const X=Et.add(z.toUint()).mul(3),K=ct.element(X),U=ct.element(X.add(1)),tt=ct.element(X.add(2)),lt=(0,$.eR5)(q.element(K.mul(3)),q.element(K.mul(3).add(1)),q.element(K.mul(3).add(2))),et=(0,$.eR5)(q.element(U.mul(3)),q.element(U.mul(3).add(1)),q.element(U.mul(3).add(2))),ut=(0,$.eR5)(q.element(tt.mul(3)),q.element(tt.mul(3).add(1)),q.element(tt.mul(3).add(2))),vt=k.mul((0,$.lnd)(lt,(0,$.fVC)(1))).xyz,wt=k.mul((0,$.lnd)(et,(0,$.fVC)(1))).xyz,$t=k.mul((0,$.lnd)(ut,(0,$.fVC)(1))).xyz,mi=wt.sub(vt),ye=$t.sub(vt),Ee=(0,$.$An)(mi,ye),kt=Ee.dot(Ee);(0,$.If)(kt.lessThan((0,$.fVC)(4*sn*sn)),()=>{(0,$.wPH)()}),(0,$.If)(Ee.y.lessThan(0),()=>{(0,$.wPH)()});const Fi=(0,$.T9B)(vt.y,(0,$.T9B)(wt.y,$t.y));(0,$.FZF)({start:(0,$.Whr)(0),end:xt.toInt(),type:"int",condition:"<",name:"edgeIdx"},({edgeIdx:ds})=>{const we=pt.add(ds.toUint()),Ve=we.mul(6),ce=(0,$.eR5)(o.element(Ve),o.element(Ve.add(1)),o.element(Ve.add(2))),he=(0,$.eR5)(o.element(Ve.add(3)),o.element(Ve.add(4)),o.element(Ve.add(5))),Jr=(0,$.jkA)(ce.y,he.y);(0,$.If)(Fi.lessThanEqual(Jr),()=>{(0,$.wPH)()});const gi=(0,$.S86)(Ee),ei=gi.dot(vt).negate(),_i=gi.y.lessThan(0),cc=(0,$.Ltv)(_i,gi.negate(),gi),hc=(0,$.Ltv)(_i,ei.negate(),ei),fn=cc.dot(ce).add(hc),uc=cc.dot(he).add(hc),fs=fn.lessThan(0),pn=uc.lessThan(0),Mg=(0,$.tnl)(fn).lessThan((0,$.fVC)(be)),Ig=fs.not().and(pn.not()),dc=uc.sub(fn),ii=(0,$.tnl)(dc).lessThan((0,$.fVC)(be)),Og=ii.and(Mg.or(fs.not()));(0,$.If)(Og,()=>{(0,$.wPH)()}),(0,$.If)(Ig.and(ii.not()),()=>{(0,$.wPH)()});const zg=fn.negate().div(dc),Vi=(0,$.jhA)(ce,he,zg),to=(0,$.eR5)((0,$.Ltv)(ii.or(fs),ce.x,Vi.x),(0,$.Ltv)(ii.or(fs),ce.y,Vi.y),(0,$.Ltv)(ii.or(fs),ce.z,Vi.z)),eo=(0,$.eR5)((0,$.Ltv)(ii.or(pn),he.x,Vi.x),(0,$.Ltv)(ii.or(pn),he.y,Vi.y),(0,$.Ltv)(ii.or(pn),he.z,Vi.z)),fc=eo.sub(to),Dg=fc.dot(fc);(0,$.If)(Dg.lessThan((0,$.fVC)(be)),()=>{(0,$.wPH)()});const pc=ce.sub(vt),mc=ce.sub(wt),gc=ce.sub($t),_c=he.sub(vt),yc=he.sub(wt),wc=he.sub($t),kg=pc.dot(pc).lessThanEqual((0,$.fVC)(be)),Lg=mc.dot(mc).lessThanEqual((0,$.fVC)(be)),Ng=gc.dot(gc).lessThanEqual((0,$.fVC)(be)),Bg=_c.dot(_c).lessThanEqual((0,$.fVC)(be)),Rg=yc.dot(yc).lessThanEqual((0,$.fVC)(be)),Fg=wc.dot(wc).lessThanEqual((0,$.fVC)(be)),Vg=kg.or(Lg).or(Ng),Ug=Bg.or(Rg).or(Fg),$g=Vg.and(Ug);(0,$.If)($g,()=>{(0,$.wPH)()});const xe=(0,$.eR5)(vt.x,(0,$.fVC)(0),vt.z),Ae=(0,$.eR5)(wt.x,(0,$.fVC)(0),wt.z),Me=(0,$.eR5)($t.x,(0,$.fVC)(0),$t.z),si=(0,$.eR5)(to.x,(0,$.fVC)(0),to.z),jg=(0,$.eR5)(eo.x,(0,$.fVC)(0),eo.z),io=(0,$.eR5)(ce.x,(0,$.fVC)(0),ce.z),so=(0,$.eR5)(he.x,(0,$.fVC)(0),he.z).sub(io),vc=so.dot(so);(0,$.If)(vc.lessThan((0,$.fVC)(be)),()=>{(0,$.wPH)()});const no=vc.sqrt(),Hg=Ae.sub(xe),qg=Me.sub(xe),ro=(0,$.$An)(Hg,qg),Gg=ro.dot(ro);(0,$.If)(Gg.lessThanEqual((0,$.fVC)(4*sn*sn)),()=>{(0,$.wPH)()});const oo=jg.sub(si),bc=oo.dot(oo);(0,$.If)(bc.lessThan((0,$.fVC)(be)),()=>{(0,$.wPH)()});const xc=bc.sqrt(),Ui=oo.div(xc),Cc=so.div(no),Yg=(0,$.S86)(ro),ao=(0,$.$An)(Ui,Yg),Ue=(0,$.fVC)(0).toVar(),$e=(0,$.fVC)(0).toVar(),je=(0,$.fVC)(0).toVar(),He=(0,$.fVC)(0).toVar(),te=(0,$.Hdr)(0).toVar(),ps=ao.dot(xe.sub(si)),mn=ao.dot(Ae.sub(si)),gn=(0,$.tnl)(ps).lessThan((0,$.fVC)(nn)),Tc=(0,$.tnl)(mn).lessThan((0,$.fVC)(nn)),Pc=gn.not().and(Tc.not()).and(ps.mul(mn).lessThan(0));(0,$.If)(Pc,()=>{const re=ps.div(ps.sub(mn)),Ie=(0,$.jhA)(xe.x,Ae.x,re),ni=(0,$.jhA)(xe.z,Ae.z,re);(0,$.If)(te.equal(0),()=>{Ue.assign(Ie),$e.assign(ni)}).Else(()=>{je.assign(Ie),He.assign(ni)}),te.addAssign(1)}).ElseIf(gn,()=>{(0,$.If)(te.equal(0),()=>{Ue.assign(xe.x),$e.assign(xe.z)}).Else(()=>{je.assign(xe.x),He.assign(xe.z)}),te.addAssign(1)});const lo=mn,_n=ao.dot(Me.sub(si)),co=Tc,Sc=(0,$.tnl)(_n).lessThan((0,$.fVC)(nn)),Ec=co.not().and(Sc.not()).and(lo.mul(_n).lessThan(0));(0,$.If)(te.lessThan(2),()=>{(0,$.If)(Ec,()=>{const re=lo.div(lo.sub(_n)),Ie=(0,$.jhA)(Ae.x,Me.x,re),ni=(0,$.jhA)(Ae.z,Me.z,re);(0,$.If)(te.equal(0),()=>{Ue.assign(Ie),$e.assign(ni)}).Else(()=>{je.assign(Ie),He.assign(ni)}),te.addAssign(1)}).ElseIf(co.and(Pc.not()).and(gn.not()),()=>{(0,$.If)(te.equal(0),()=>{Ue.assign(Ae.x),$e.assign(Ae.z)}).Else(()=>{je.assign(Ae.x),He.assign(Ae.z)}),te.addAssign(1)})});const ho=_n,Ac=ps,Mc=Sc,Zg=gn,Wg=Mc.not().and(Zg.not()).and(ho.mul(Ac).lessThan(0));(0,$.If)(te.lessThan(2),()=>{(0,$.If)(Wg,()=>{const re=ho.div(ho.sub(Ac)),Ie=(0,$.jhA)(Me.x,xe.x,re),ni=(0,$.jhA)(Me.z,xe.z,re);(0,$.If)(te.equal(0),()=>{Ue.assign(Ie),$e.assign(ni)}).Else(()=>{je.assign(Ie),He.assign(ni)}),te.addAssign(1)}).ElseIf(Mc.and(Ec.not()).and(co.not()),()=>{(0,$.If)(te.equal(0),()=>{Ue.assign(Me.x),$e.assign(Me.z)}).Else(()=>{je.assign(Me.x),He.assign(Me.z)}),te.addAssign(1)})}),(0,$.If)(te.notEqual(2),()=>{(0,$.wPH)()});const Xg=(0,$.eR5)(Ue,(0,$.fVC)(0),$e),Kg=(0,$.eR5)(je,(0,$.fVC)(0),He).sub(Xg).dot(Ui),uo=(0,$.eR5)(Ue,(0,$.fVC)(0),$e).toVar(),fo=(0,$.eR5)(je,(0,$.fVC)(0),He).toVar();(0,$.If)(Kg.lessThan(0),()=>{const re=Ue,Ie=$e;uo.x.assign(je),uo.z.assign(He),fo.x.assign(re),fo.z.assign(Ie)});const Ic=(0,$.fVC)(0),Oc=xc,zc=uo.sub(si).dot(Ui),Dc=fo.sub(si).dot(Ui),Qg=Oc.lessThanEqual(zc).or(Dc.lessThanEqual(Ic));(0,$.If)(Qg,()=>{(0,$.wPH)()});const Jg=(0,$.T9B)(Ic,zc),t_=(0,$.jkA)(Oc,Dc),e_=si.add(Ui.mul(Jg)),i_=si.add(Ui.mul(t_)),s_=e_.sub(io).dot(Cc).div(no),n_=i_.sub(io).dot(Cc).div(no),kc=(0,$.T9B)((0,$.fVC)(0),(0,$.jkA)((0,$.fVC)(1),s_)),Lc=(0,$.T9B)((0,$.fVC)(0),(0,$.jkA)((0,$.fVC)(1),n_)),r_=(0,$.tnl)(Lc.sub(kc));(0,$.If)(r_.lessThanEqual((0,$.fVC)(nn)),()=>{(0,$.wPH)()});const Nc=(0,$.Rnb)(F.element(0),1);(0,$.If)(Nc.lessThan((0,$.Hdr)(N)),()=>{const re=Nc.mul(3);V.element(re).assign(we.toFloat()),V.element(re.add(1)).assign(kc),V.element(re.add(2)).assign(Lc)})})})})().compute(B.length);f+=performance.now()-nt;const J=performance.now();yield n.computeAsync(it),l+=performance.now()-J;const _t=performance.now(),St=yield n.getArrayBufferAsync(F.value),dt=new Uint32Array(St)[0];if(s&&(s.used+=Math.min(dt,N)),bt.enabled&&console.log(` Batch ${_+1}: ${dt} overlaps found (capacity: ${N})`),dt>N&&bt.enabled&&console.warn(` WARNING: Overlap buffer overflow! ${dt} > ${N}. Some occlusion data lost.`),dt>0){const rt=yield n.getArrayBufferAsync(V.value),ht=new Float32Array(rt);c+=performance.now()-_t;const pt=performance.now(),xt=Math.min(dt,N);for(let Et=0;Et<xt;Et++){const P=3*Et,W=Math.round(ht[P]);Ga([ht[P+1],ht[P+2]],i[W])}h+=performance.now()-pt,bt.enabled&&console.log(` Processed ${xt} overlaps into hiddenOverlapMap`)}else c+=performance.now()-_t}n.dispose(),rs=null,bt.enabled&&(console.log(`WebGPU timing breakdown (total: ${(u+f+l+c+h).toFixed(1)}ms):`),console.log(` Buffer creation: ${u.toFixed(1)}ms`),console.log(` Shader build: ${f.toFixed(1)}ms`),console.log(` GPU compute: ${l.toFixed(1)}ms`),console.log(` Readback: ${c.toFixed(1)}ms`),console.log(` CPU merge: ${h.toFixed(1)}ms`))}),Pr.apply(this,arguments)}const ef=new p.Pq0(0,1,0);function Za(r,t=null){const e=new Float32Array(6*r.length);let i=0;for(let o=0,a=r.length;o<a;o++){const l=r[o];e[i++]=l[0],e[i++]=0,e[i++]=l[2],e[i++]=l[3],e[i++]=0,e[i++]=l[5]}const s=new p.LoY,n=new p.THS(e,3,!0);if(s.setAttribute("position",n),t){const o=new Float32Array(2*r.length);for(let a=0,l=t.length;a<l;a++)o[2*a]=t[a],o[2*a+1]=t[a];s.setAttribute("group",new p.THS(o,1))}return s}class sf{constructor(t,e=!0){this.meshes=gr(t),this.bvhs=new Map,this.visibleEdges=[],this.hiddenEdges=[],this.visibleGroupIndices=[],this.hiddenGroupIndices=[],this.groupKeyToIndex=null,this.hasGroups=!1,this.iterationTime=30,this.useWebGPU=e}reset(){this.visibleEdges.length=0,this.hiddenEdges.length=0,this.visibleGroupIndices.length=0,this.hiddenGroupIndices.length=0,this.groupKeyToIndex=null,this.hasGroups=!1}getVisibleLineGeometry(){return Za(this.visibleEdges,this.groupKeyToIndex?this.visibleGroupIndices:null)}getHiddenLineGeometry(){return Za(this.hiddenEdges,this.groupKeyToIndex?this.hiddenGroupIndices:null)}getGroupKeys(){return this.groupKeyToIndex?Object.fromEntries(this.groupKeyToIndex):{}}addEdges(...t){const e=this.iterationTime;this.iterationTime=1/0;const i=this.addEdgesGenerator(...t).next().value;return this.iterationTime=e,i}*addEdgesGenerator(t,e={}){const{meshes:i,bvhs:s,visibleEdges:n,hiddenEdges:o,iterationTime:a}=this;let l=performance.now();bt.startStep("Building mesh BVH");for(let g=0;g<i.length;g++){performance.now()-l>a&&(yield,l=performance.now());const T=i[g].geometry;if(!s.has(T)){const C=T.boundsTree||new Ke(T);s.set(T,C)}}let c=0;for(let g=0;g<i.length;g++){const v=i[g].geometry;c+=v.index?v.index.count/3:v.attributes.position.count/3}const h={};for(let g=0;g<t.length;g++)h[g]=[];bt.startStep("Building line BVH");const u=new Bd(t,{maxLeafSize:2,strategy:2});bt.startStep("BVHcast overlaps"),l=performance.now();const f={candidates:0,backFaceCulled:0,yBoundsCulled:0,xzBoundsCulled:0,triangleEdgeCulled:0,planeTrimCulled:0,distThresholdCulled:0,noOverlapCulled:0,used:0,totalEdges:t.length,totalTriangles:c},d=this.useWebGPU,_={};d&&(_._edgeOffsets=[],_._edgeCounts=[],_._meshOffsets=[],_._meshCounts=[],_._meshIndex=[],_.groupCount=0);for(let g=0;g<i.length;g++){performance.now()-l>a&&(e.onProgress&&e.onProgress(g,i.length),yield,l=performance.now());const v=i[g];d?Wd(u,s.get(v.geometry),v,_,g):Yd(u,s.get(v.geometry),v,h,f)}if(d){let g=!1;for(function tf(r,t,e,i){return Pr.apply(this,arguments)}(_,i,u,h,f).then(()=>{g=!0});!g;)yield}const m=f.totalEdges*f.totalTriangles;if(bt.setStat("Total edges",f.totalEdges.toLocaleString()),bt.setStat("Total triangles",f.totalTriangles.toLocaleString()),bt.setStat("Brute-force pairs (edges \xd7 triangles)",m.toLocaleString()),bt.setStat("BVH candidate pairs",f.candidates.toLocaleString()),m>0&&bt.setStat("BVH reduction",(f.candidates/m*100).toFixed(3)+"% of brute-force"),f.candidates>0){const g=f.candidates,v=T=>(T/g*100).toFixed(2)+"%";d||(bt.setStat("Rejected: back-face culling",f.backFaceCulled.toLocaleString()+" ("+v(f.backFaceCulled)+")"),bt.setStat("Rejected: Y-bounds (tri below edge)",f.yBoundsCulled.toLocaleString()+" ("+v(f.yBoundsCulled)+")"),bt.setStat("Rejected: XZ-bounds (no 2D overlap)",f.xzBoundsCulled.toLocaleString()+" ("+v(f.xzBoundsCulled)+")"),bt.setStat("Rejected: edge lies on triangle",f.triangleEdgeCulled.toLocaleString()+" ("+v(f.triangleEdgeCulled)+")"),bt.setStat("Rejected: line above tri plane",f.planeTrimCulled.toLocaleString()+" ("+v(f.planeTrimCulled)+")"),bt.setStat("Rejected: trimmed edge too small",f.distThresholdCulled.toLocaleString()+" ("+v(f.distThresholdCulled)+")"),bt.setStat("Rejected: no projected overlap",f.noOverlapCulled.toLocaleString()+" ("+v(f.noOverlapCulled)+")")),bt.setStat("Producing overlaps",f.used.toLocaleString()+" ("+v(f.used)+")")}bt.startStep("Converting overlaps to lines");const w=this.hasGroups;for(let g=0;g<t.length;g++){performance.now()-l>a&&(yield,l=performance.now());const v=t[g],T=h[g],C=n.length,S=o.length;if(Ma(v,T,!1,n),Ma(v,T,!0,o),w){const M=v.groupIndex;for(let A=C;A<n.length;A++)this.visibleGroupIndices.push(M);for(let A=S;A<o.length;A++)this.hiddenGroupIndices.push(M)}}}}class nf{constructor(){this.iterationTime=30,this.angleThreshold=50,this.includeIntersectionEdges=!0,this.useWebGPU=!0}generateAsync(t,e={}){return new Promise((i,s)=>{const{signal:n}=e,o=this.generate(t,e);!function a(){if(n&&n.aborted)return void s(new Error("ProjectionGenerator: Process aborted via AbortSignal."));const l=o.next();l.done?i(l.value):requestAnimationFrame(a)}()})}*generate(t,e){const{iterationTime:i,angleThreshold:s,includeIntersectionEdges:n}=this,{onProgress:o=()=>{},visibilityCuller:a=null,groupFn:l=null}=e;if(bt.reset(),bt.startTotal(),t.isBufferGeometry&&(t=new p.eaF(t)),a){bt.startStep("Visibility culling");let d=!1;for(a.cull(t).then(_=>{(t=new p.Z58).children=_,d=!0});!d;)yield}const c=new Nd;c.iterationTime=i,c.thresholdAngle=s,c.projectionDirection.copy(ef),bt.startStep("Generating candidate edges"),o("Generating candidate edges");let h=[],u=l?[]:null;if(yield*c.getEdgesGenerator(t,h,u),n&&(bt.startStep("Generating intersection edges"),o("Generating intersection edges"),yield*c.getIntersectionEdgesGenerator(t,h,u)),bt.startStep("Pre-filtering edges"),o("Pre-filtering edges"),u){const d=[],_=[];for(let m=0;m<h.length;m++)Aa(h[m])||(d.push(h[m]),_.push(u[m]));h=d,u=_}else h=h.filter(d=>!Aa(d));yield;const f=new sf(t,this.useWebGPU);if(f.iterationTime=i,l&&u){const d=new Map;for(let _=0;_<h.length;_++){const m=l(u[_]);d.has(m)||d.set(m,d.size),h[_].groupIndex=d.get(m)}f.groupKeyToIndex=d,f.hasGroups=!0}return o("Building BVH & computing overlaps"),yield*f.addEdgesGenerator(h,{onProgress:o?(d,_)=>{o("Building BVH & computing overlaps",d/_,f)}:null}),bt.printSummary(),f}}new p.cZY,new p.cZY,new p.Pq0;const Wa=class mo extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"onDisposed",new Q),y(this,"generator",new nf),y(this,"cullerPixelsPerMeter",.05),y(this,"projectionDirection",new p.Pq0(0,-1,0)),y(this,"nearPlane",-1/0),y(this,"farPlane",1/0),this.components.add(mo.uuid,this),this.generator.includeIntersectionEdges=!1}get(t,e,i){var s=this;return(0,G.A)(function*(){const n=s.components.get(ft),o=new p.YJl,a=new Map;for(const[S,M]of Object.entries(t)){const A=n.list.get(S);if(!A)continue;const I=(yield A.getItemsIdsWithGeometry()).filter(B=>M.has(B));if(0===I.length)continue;const D=yield A.getItemsGeometry(I);for(const B in D){const E=D[B];for(const L of E){if(!(L.positions&&L.indices&&L.transform&&L.representationId))continue;const x=L.representationId;if(!a.has(x)){const q=new p.LoY;q.setAttribute("position",new p.qtW(L.positions,3)),L.normals&&q.setAttribute("normal",new p.qtW(L.normals,3)),q.setIndex(Array.from(L.indices)),a.set(x,q)}const N=a.get(x),Y=new p.eaF(N);Y.applyMatrix4(L.transform),Y.applyMatrix4(A.object.matrixWorld),Y.updateWorldMatrix(!0,!0),Y.userData._edgeProjectorModelId=S,Y.userData._edgeProjectorLocalId=L.localId,o.add(Y)}}}const l=s.projectionDirection.clone().normalize(),c=new p.Pq0(0,-1,0),h=(new p.PTz).setFromUnitVectors(l,c),u=(new p.kn4).makeRotationFromQuaternion(h),f=u.clone().invert();for(const S of o.children)S.applyMatrix4(u),S.updateWorldMatrix(!1,!1);if(o.traverse(S=>{const M=S;if(M.geometry&&!M.geometry.boundsTree){const A=M.geometry.index?M.geometry.index.count:M.geometry.attributes.position.count;M.geometry.groups.forEach(O=>{O.count===1/0&&(O.count=A-O.start)}),M.geometry.boundsTree=new Ke(M.geometry,{maxLeafSize:1,strategy:2})}}),s.nearPlane!==-1/0||s.farPlane!==1/0){const S=new p.NRn,M=[];for(const A of o.children){const O=A;O.geometry&&(S.setFromObject(O),(S.max.y<s.nearPlane||S.min.y>s.farPlane)&&M.push(O))}for(const A of M)o.remove(A)}const m=new Id(e.renderer.three,{pixelsPerMeter:s.cullerPixelsPerMeter}),w=yield s.generator.generateAsync(o,{visibilityCuller:m,groupFn:S=>`${S.userData._edgeProjectorModelId??"unknown"}:${S.userData._edgeProjectorLocalId??0}`,onProgress:i?.onProgress}),g=w.getVisibleLineGeometry(),v=w.getHiddenLineGeometry();g.applyMatrix4(f),v.applyMatrix4(f);const T=w.getGroupKeys(),C={};for(const[S,M]of Object.entries(T)){const A=S.lastIndexOf(":"),O=S.substring(0,A),I=Number(S.substring(A+1));C[M]={modelId:O,localId:I}}for(const S of a.values())S.dispose();return{visible:g,hidden:v,groups:C}})()}dispose(){this.onDisposed.trigger(mo.uuid),this.onDisposed.reset()}};y(Wa,"uuid","f2e76c3a-8b1d-4d5e-9a3f-7c6b2d4e8f1a");let rf=Wa;class of{constructor(){y(this,"wasm",{path:"",absolute:!1,logLevel:ji.LogLevel.LOG_LEVEL_OFF}),y(this,"webIfc",{COORDINATE_TO_ORIGIN:!0}),y(this,"autoSetWasm",!0),y(this,"customLocateFileHandler",null)}}y(class go extends At{constructor(t){super(t),y(this,"onDisposed",new Q),y(this,"onIfcStartedLoading",new Q),y(this,"onIfcImporterInitialized",new Q),y(this,"onSetup",new Q),y(this,"settings",new of),y(this,"webIfc",new ji.IfcAPI),y(this,"enabled",!0),this.components.add(go.uuid,this)}dispose(){this.webIfc=null,this.onDisposed.trigger(go.uuid),this.onDisposed.reset()}setup(t){var e=this;return(0,G.A)(function*(){e.settings={...e.settings,...t},e.settings.autoSetWasm&&(yield e.autoSetWasm()),e.onSetup.trigger()})()}load(t,e,i,s){var n=this;return(0,G.A)(function*(){const o=n.components.get(ft);if(!o.initialized)throw new Error("You need to initialize fragments first.");n.settings.autoSetWasm&&(yield n.autoSetWasm()),o.core.settings.autoCoordinate=e;const a=new ot.$X;a.wasm.path=n.settings.wasm.path,a.wasm.absolute=n.settings.wasm.absolute,a.webIfcSettings=n.settings.webIfc,n.onIfcImporterInitialized.trigger(a),s?.instanceCallback&&s.instanceCallback(a);const l=yield a.process({...s?.processData,bytes:t});return yield o.core.load(l,{modelId:i,userData:s?.userData})})()}readIfcFile(t){var e=this;return(0,G.A)(function*(){const{path:i,absolute:s,logLevel:n}=e.settings.wasm;return e.webIfc.SetWasmPath(i,s),yield e.webIfc.Init(e.settings.customLocateFileHandler||void 0),n&&e.webIfc.SetLogLevel(n),e.webIfc.OpenModel(t,e.settings.webIfc)})()}cleanUp(){try{this.webIfc.Dispose()}catch{console.log("Web-ifc wasn't disposed.")}this.webIfc=null,this.webIfc=new ji.IfcAPI}autoSetWasm(){var t=this;return(0,G.A)(function*(){const e=yield fetch(`https://unpkg.com/@thatopen/components@${Ar.release}/package.json`);if(!e.ok)return void console.warn("Couldn't get openbim-components package.json. Set wasm settings manually.");const i=yield e.json();"web-ifc"in i.peerDependencies?(t.settings.wasm.path=`https://unpkg.com/web-ifc@${i.peerDependencies["web-ifc"]}/`,t.settings.wasm.absolute=!0):console.warn("Couldn't get web-ifc from peer dependencies in openbim-components. Set wasm settings manually.")})()}},"uuid","a659add7-1418-4771-a0d6-7d4d438e4624");const Xa=class Fc extends At{constructor(t){super(t),y(this,"enabled",!0),this.components.add(Fc.uuid,this)}set(t,e){var i=this;return(0,G.A)(function*(){const s=i.components.get(ft),n=[];if(e)for(const[o,a]of Object.entries(e)){const l=s.list.get(o);l&&n.push(l.setVisible([...a],t))}else for(const o of s.list.values())n.push(o.setVisible(void 0,t));yield Promise.all(n),yield s.core.update(!0)})()}isolate(t){var e=this;return(0,G.A)(function*(){yield Promise.all([e.set(!1),e.set(!0,t)])})()}toggle(t){var e=this;return(0,G.A)(function*(){const i=[],s=e.components.get(ft);for(const[n,o]of Object.entries(t)){const a=s.list.get(n);a&&i.push(a.toggleVisible([...o]))}yield Promise.all(i),yield s.core.update(!0)})()}getVisibilityMap(t,e){var i=this;return(0,G.A)(function*(){const s=[],n=[],o=i.components.get(ft);if(e)for(const c of e){const h=o.list.get(c);h&&(s.push(h.modelId),n.push(h.getItemsByVisibility(t)))}else for(const c of o.list.values())s.push(c.modelId),n.push(c.getItemsByVisibility(t));const a=yield Promise.all(n),l={};for(const[c,h]of s.entries())l[h]=a[c];return l})()}};y(Xa,"uuid","dd9ccf2d-8a21-4821-b7f6-2949add16a29");let af=Xa;const Ka=class _o extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"onDisposed",new Q),y(this,"list",new ot.PG),this.components.add(_o.uuid,this)}dispose(t=!0){this.list.clear(),this.onDisposed.trigger(_o.uuid),t&&(this.onDisposed.reset(),this.list.eventsEnabled=!1,this.list.dispose())}get(){const t=new p.NRn;for(const e of this.list)t.union(e);return t}addFromModelIdMap(t){var e=this;return(0,G.A)(function*(){const i=e.components.get(ft),s=new p.NRn;for(const[n,o]of Object.entries(t)){const a=i.list.get(n);if(!a)continue;const l=yield a.getMergedBox([...o]);s.union(l)}e.list.add(s)})()}addFromModels(t){const e=this.components.get(ft);for(const[i,s]of e.list)t&&!t.some(n=>n.test(i))||this.list.add(s.box)}getCenter(t){var e=this;return(0,G.A)(function*(){e.list.clear(),yield e.addFromModelIdMap(t);const i=e.get();e.list.clear();const s=new p.Pq0;return i.getCenter(s),s})()}getCameraOrientation(t){var e=this;return(0,G.A)(function*(i,s=1){const n=e.components.get(ft);e.list.clear();for(const[u,f]of n.list)e.list.add(f.box);const o=e.get();e.list.clear();const a=new p.Pq0;o.getCenter(a);const l=new p.Pq0;o.getSize(l);const c=Math.max(l.x,l.y,l.z)*s,h=new p.Pq0;switch(i){case"front":default:h.set(a.x,a.y,a.z+c);break;case"back":h.set(a.x,a.y,a.z-c);break;case"left":h.set(a.x-c,a.y,a.z);break;case"right":h.set(a.x+c,a.y,a.z);break;case"top":h.set(a.x,a.y+c,a.z);break;case"bottom":h.set(a.x,a.y-c,a.z)}return{position:h,target:a}}).apply(this,arguments)}};y(Ka,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let Qa=Ka;class lf{constructor(t,e){y(this,"name","Query"),y(this,"customData",{}),y(this,"_components"),y(this,"_queries",[]),y(this,"_aggregation","exclusive"),y(this,"result",null),y(this,"cache",!0),y(this,"serializeQueryParameters",i=>{var s;return{categories:null==(s=i.categories)?void 0:s.map(o=>o.source),attributes:i.attributes?{aggregation:i.attributes.aggregation,queries:i.attributes.queries.map(this.serializeAttributeQuery)}:void 0,relation:i.relation?{name:i.relation.name,query:i.relation.query?this.serializeQueryParameters(i.relation.query):void 0}:void 0}}),y(this,"deserializeQueryParameters",i=>{var s;return{categories:null==(s=i.categories)?void 0:s.map(o=>new RegExp(o)),attributes:i.attributes?{aggregation:i.attributes.aggregation,queries:i.attributes.queries.map(this.deserializeAttributeQuery)}:void 0,relation:i.relation?{name:i.relation.name,query:i.relation.query?this.deserializeQueryParameters(i.relation.query):void 0}:void 0}}),this._components=t,this.queries=e}set queries(t){this._queries=t,this.clearCache()}get queries(){return this._queries}set aggregation(t){t!==this._aggregation&&this.clearCache(),this._aggregation=t}get aggregation(){return this._aggregation}test(t){var e=this;return(0,G.A)(function*(){const{modelIds:i,force:s}={force:!1,...t};if(e.result&&!s)return e.result;const o=yield e._components.get(os).getItems(e.queries,{modelIds:i,aggregation:e.aggregation});return e.cache&&(e.result=o),o})()}clearCache(){this.result=null}serializeAttributeQuery(t){let e;return e=Array.isArray(t.value)?t.value.map(s=>s.source):t.value instanceof RegExp?t.value.source:t.value,{name:t.name.source,value:e,type:t.type instanceof RegExp?t.type.source:t.type,negate:t.negate,itemIds:t.itemIds}}toJSON(){return{guid:this._components.get(os).list.getKey(this)??ie.create(),name:this.name,customData:this.customData,queries:this.queries.map(this.serializeQueryParameters),aggregation:this.aggregation,cache:this.cache}}deserializeAttributeQuery(t){let e;return e=Array.isArray(t.value)?t.value.map(s=>new RegExp(s)):"string"==typeof t.value?new RegExp(t.value):t.value,{name:new RegExp(t.name),value:e,type:t.type?new RegExp(t.type):void 0,negate:t.negate,itemIds:t.itemIds}}fromJSON(t){return this.name=t.name,this.customData=t.customData,this.aggregation=t.aggregation,this.cache=t.cache,this.queries=t.queries.map(this.deserializeQueryParameters),this}}const Ja=class Vc extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"list",new ot.jp),t.add(Vc.uuid,this)}getItems(t,e){var i=this;return(0,G.A)(function*(){let s;if(e){const{modelIds:c,items:h}=e;if(h){const u=Object.keys(h);u.length>0&&(s=u.map(f=>new RegExp(`^${f}$`)))}else c&&(s=c)}const n=e?.aggregation??"exclusive",o=i.components.get(ft),a=yield Promise.all(t.map(function(){var c=(0,G.A)(function*(h){const u={};return yield Promise.all(Array.from(o.list).map(function(){var f=(0,G.A)(function*([d,_]){var m;if(s&&!s.some(v=>v.test(d)))return;const w=null==(m=e?.items)?void 0:m[d],g=yield _.getItemsByQuery(h,{localIds:w?[...w]:void 0});u[d]=new Set(g)});return function(d){return f.apply(this,arguments)}}())),u});return function(h){return c.apply(this,arguments)}}()));return"inclusive"===n?Rt.join(a):Rt.intersect(a)})()}create(t,e){const i=new lf(this.components,e);return this.list.set(t,i),i}addFromCategories(t){var e=this;return(0,G.A)(function*(){const i=new Set,s=e.components.get(ft);for(const[n,o]of s.list){if(t&&!t.some(c=>c.test(n)))continue;const a=(yield o.getItemsWithGeometryCategories()).filter(c=>null!==c),l=new Set(a);for(const c of l)e.list.has(c)||(e.create(c,[{categories:[new RegExp(`^${c}$`)]}]),i.add(c))}return[...i]})()}import(t){const{data:e}=t,i=[];if(!e)return i;for(const s of e){const n=this.create(s.guid,[]);n.fromJSON(s),i.push(n)}return i}export(){const t=[];for(const[e,i]of this.list.entries()){const n={...i.toJSON(),name:e};t.push(n)}return{data:t}}};y(Ja,"uuid","0da7ad77-f734-42ca-942f-a074adfd1e3a");let os=Ja;y(class Uc extends At{constructor(t){var e;super(t),e=this,y(this,"enabled",!0),y(this,"onDisposed",new Q),y(this,"list",new ot.jp),y(this,"defaultSaveFunction",s=>"value"in s.Name?s.Name.value:null),y(this,"onBeforeFragmentsDispose",function(){var s=(0,G.A)(function*(n){const{key:o,value:a}=n,l=yield a.getLocalIds(),c={[o]:new Set(l)};e.removeItems(c)});return function(n){return s.apply(this,arguments)}}()),t.add(Uc.uuid,this),this.setupEvents(),t.get(ft).list.onBeforeDelete.add(this.onBeforeFragmentsDispose)}setupEvents(){this.list.onBeforeDelete.add(({value:t})=>t.dispose())}getClassificationGroups(t){let e=this.list.get(t);return e||(e=new ot.jp,this.list.set(t,e)),e}getModelItems(t,e,i){const{map:s}=this.getGroupData(t,e);let n=s[i];return n||(n=new Set,s[i]=n),n}getGroupData(t,e){const i=this.components.get(os),s=this.getClassificationGroups(t);let n=s.get(e);return n||(n={map:{},get:()=>new Promise(o=>{if(n)if(n.query){const{name:a,config:l}=n.query,c=i.list.get(a);if(!c)throw new Error("Classifier: the query name associated with the group doesn't exist in the ItemsFinder component");c.test(l).then(h=>{if(!n)return void o({});const u=Rt.join([h,n.map]);o(u)})}else o(n.map);else o({})})},s.set(e,n)),n}aggregateItems(t,e,i){var s=this;return(0,G.A)(function*(){const n=i?.data??void 0,o=i?.aggregationCallback??s.defaultSaveFunction,a=s.components.get(ft),c=yield s.components.get(os).getItems([e],{modelIds:i?.modelIds});for(const[h,u]of Object.entries(c)){const f=a.list.get(h);if(!f)continue;const d=(m,...w)=>{const g=s.getModelItems(t,m,h);for(const v of w)g.add(v)},_=yield f.getItemsData([...u],n);for(const m of _)o(m,d)}})()}addGroupItems(t,e,i){const{map:s}=this.getGroupData(t,e);Rt.add(s,i)}setGroupQuery(t,e,i){this.getGroupData(t,e).query=i}find(t){var e=this;return(0,G.A)(function*(){const i=[];for(const[n,o]of Object.entries(t)){const a=[],l=e.list.get(n);if(!l)continue;for(const h of o){const u=l.get(h);if(!u)continue;const f=yield u.get();a.push(f)}const c=Rt.join(a);i.push(c)}return Rt.intersect(i)})()}aggregateItemRelations(t,e,i,s){var n=this;return(0,G.A)(function*(){const o=s?.attribute??"Name",a={relations:{[i]:{attributes:!0,relations:!1}}};yield n.aggregateItems(t,e,{modelIds:s?.modelIds,data:a,aggregationCallback:(l,c)=>{if(!l?.[o])return;const h=l[o];if(!("value"in h))return;const u=l[i];if(Array.isArray(u))for(const f of u)"value"in f._localId&&c(h.value,f._localId.value)}})})()}byIfcBuildingStorey(t){var e=this;return(0,G.A)(function*(){yield e.aggregateItemRelations(t?.classificationName??"Storeys",{categories:[/BUILDINGSTOREY/]},"ContainsElements",{modelIds:t?.modelIds})})()}byCategory(t){var e=this;return(0,G.A)(function*(){const s=yield e.components.get(os).addFromCategories(t?.modelIds);for(const n of s)e.setGroupQuery(t?.classificationName??"Categories",n,{name:n})})()}dispose(){this.list.clear(),this.components.get(ft).list.onBeforeDelete.remove(this.onBeforeFragmentsDispose),this.onDisposed.trigger()}removeItems(t,e){if(e&&e.classificationName){const i=this.list.get(e.classificationName);if(!i||e.groupName&&!i.get(e.groupName))return;for(const[,s]of i)Rt.remove(s.map,t);return}for(const[,i]of this.list.entries())for(const[,s]of i)Rt.remove(s.map,t)}byModel(t){var e=this;return(0,G.A)(function*(){const i=e.components.get(ft),s=t?.classificationName??"Models";for(const[n,o]of i.list){if(t&&t.modelIds&&!t.modelIds.some(c=>c.test(n)))continue;const a=yield o.getItemsIdsWithGeometry(),l={[n]:new Set(a)};e.getGroupData(s,n),e.addGroupItems(s,n,l)}})()}},"uuid","e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7");const tl=class $c{constructor(t,e){if(y(this,"enabled",!0),y(this,"components"),y(this,"onDisposed",new Q),y(this,"mouse"),y(this,"world"),y(this,"debugMode",!1),y(this,"_renderTarget"),y(this,"_renderTargetSize",new p.I9Y),y(this,"_debugCanvas"),y(this,"_debugContainer"),y(this,"_idMaterial"),y(this,"_depthMaterial"),y(this,"_normalMaterial"),y(this,"_originalMaterials",new Map),y(this,"_hiddenLods",[]),!e.renderer)throw new Error("A renderer is needed for the FastModelPicker to work!");this.world=e,this.mouse=new Yo(e.renderer.three.domElement),this.components=t,this._idMaterial=this.buildIdMaterial(),this._depthMaterial=this.buildDepthMaterial(),this._normalMaterial=this.buildNormalMaterial(),this.setupRenderTarget()}getModelAt(t){var e=this;return(0,G.A)(function*(){const i=yield e.runIdPass(t);return i?i.modelId:null})()}getItemAt(t){var e=this;return(0,G.A)(function*(){const i=yield e.runIdPass(t);if(!i)return null;const n=e.components.get(ft).list.get(i.modelId);if(!n)return null;const o=yield n.getLocalIdsFromItemIds([i.itemId]),a=o?.[0];return null==a?null:{modelId:i.modelId,localId:a,itemId:i.itemId}})()}getPointAt(t){var e=this;return(0,G.A)(function*(){if(!e.enabled||!e._renderTarget||!e.world.renderer)return null;const i=e.components.get(ft);if(!i.initialized||0===i.list.size)return null;e.renderDepthPass();const s=t??e.mouse.position,n=e.readPixelAt(s);if(!n||0===n[0]&&0===n[1]&&0===n[2]&&0===n[3])return null;const o=function hf(r){return 255/256*(r[0]/255/16777216+r[1]/255/65536+r[2]/255/256+r[3]/255)}(n);return o>=.999999?null:function uf(r,t,e){const i=new p.Pq0(r.x,r.y,2*t-1);return i.unproject(e),i}(s,o,e.world.camera.three)})()}getNormalAt(t){var e=this;return(0,G.A)(function*(){if(!e.enabled||!e._renderTarget||!e.world.renderer)return null;const i=e.components.get(ft);if(!i.initialized||0===i.list.size)return null;e.renderNormalPass();const n=e.readPixelAt(t??e.mouse.position);if(!n||0===n[3])return null;const c=new p.Pq0(n[0]/255*2-1,n[1]/255*2-1,n[2]/255*2-1);return c.lengthSq()<1e-8?null:c.normalize()})()}getFullPick(t){var e=this;return(0,G.A)(function*(){const i=yield e.getItemAt(t);if(!i)return null;const s=yield e.getPointAt(t);if(!s)return null;const n=yield e.getNormalAt(t),o=s.distanceTo(e.world.camera.three.position);return{...i,point:s,normal:n,distance:o}})()}setDebugMode(t){this.debugMode=t,t?this.setupDebugCanvas():this.removeDebugCanvas()}dispose(){this.mouse.dispose(),this.removeDebugCanvas(),this._idMaterial.dispose(),this._depthMaterial.dispose(),this._normalMaterial.dispose(),this._renderTarget&&this._renderTarget.dispose(),this._renderTarget=void 0,this._originalMaterials.clear(),this._hiddenLods.length=0,this.onDisposed.trigger(),this.onDisposed.reset()}runIdPass(t){var e=this;return(0,G.A)(function*(){if(!e.enabled||!e._renderTarget||!e.world.renderer)return null;const i=e.components.get(ft);if(!i.initialized||0===i.list.size)return null;const s=e.applyIdMaterial();if(0===s.size)return e.restoreOriginalMaterials(),null;const n=t??e.mouse.position;e.renderIdPass(s,n),e.restoreOriginalMaterials(),e.debugMode&&e._debugCanvas&&e.updateDebugCanvas();const o=e.readPixelAt(e._renderTarget,n);if(!o)return null;const a=o[0];if(0===a)return null;const l=s.get(a);if(!l)return null;const c=o[1]<<16|o[2]<<8|o[3];return 0===c?null:{modelId:l,itemId:c-1}})()}applyIdMaterial(){const t=this.components.get(ft),e=new Map;let i=1;for(const[s,n]of t.list){if(i>$c.MAX_MODELS)break;const o=i;i+=1;let a=!1;n.object.traverse(l=>{if(!(l instanceof p.eaF))return;const c=l.geometry;if(!c)return;if(!c.attributes||!c.attributes.id)return void(l.visible&&(this._hiddenLods.push(l),l.visible=!1));this._originalMaterials.set(l,l.material);const h=l.material,u=Array.isArray(h)?h.length:1;l.material=new Array(u).fill(this._idMaterial),a=!0}),a&&e.set(o,s)}return e}renderIdPass(t,e){this.renderPickPass(t,this._renderTarget,this._idMaterial,e)}renderPickPass(t,e,i,s){const n=this.world.renderer.three,o=this.world.scene.three,a=this.world.camera.three,l=this.components.get(ft),c=n.clippingPlanes??[];i.clippingPlanes=c,i.clipping=c.length>0;const h=n.getRenderTarget(),u=n.autoClear,f=n.getClearColor(new p.Q1f),d=n.getClearAlpha(),_=n.getScissorTest(),m=n.getScissor(new p.IUQ);n.setRenderTarget(e),n.setClearColor(0,0),n.autoClear=!1,n.setScissorTest(!1),n.clear(!0,!0,!1);const g=e.width,v=e.height,T=Math.floor(.5*(s.x+1)*g),C=Math.floor(.5*(s.y+1)*(v-1)),M=Math.max(0,Math.min(g-4,T-2)),A=Math.max(0,Math.min(v-4,C-2)),O=n.getPixelRatio();n.setScissor(M/O,A/O,4/O,4/O),n.setScissorTest(!0);const I=new Map;for(const[x,N]of l.list)I.set(x,N.object);const D=new Set(I.values()),B=new Map;o.traverse(x=>{x!==o&&x.isMesh&&((x=>{let N=x;for(;N;){if(D.has(N))return!0;N=N.parent}return!1})(x)||(B.set(x,x.visible),x.visible=!1))});const L=new Map;for(const x of I.values())L.set(x,x.visible),x.visible=!1;for(const[x,N]of t){const Y=I.get(N);Y&&(Y.visible=!0,i.uniforms.modelByte.value=x,n.render(o,a),Y.visible=!1)}for(const[x,N]of L)x.visible=N;for(const[x,N]of B)x.visible=N;n.setScissorTest(_),n.setScissor(m),n.setRenderTarget(h),n.autoClear=u,n.setClearColor(f,d)}renderWithTileMaterial(t){const e=this.world.renderer.three,i=this.world.scene.three,s=this.world.camera.three,n=this.components.get(ft),o=e.clippingPlanes??[];t.clippingPlanes=o,t.clipping=o.length>0;const a=e.getRenderTarget(),l=e.autoClear,c=e.getClearColor(new p.Q1f),h=e.getClearAlpha(),u=new Map,f=[];for(const[,w]of n.list)w.object.traverse(g=>{if(!(g instanceof p.eaF))return;const v=g.geometry;if(!v)return;if(!v.attributes||!v.attributes.id)return void(g.visible&&(f.push(g),g.visible=!1));if(!g.visible)return;u.set(g,g.material);const T=g.material,C=Array.isArray(T)?T.length:1;g.material=new Array(C).fill(t)});const d=new Set;for(const[,w]of n.list)d.add(w.object);const m=new Map;i.traverse(w=>{w!==i&&w.isMesh&&((w=>{let g=w;for(;g;){if(d.has(g))return!0;g=g.parent}return!1})(w)||(m.set(w,w.visible),w.visible=!1))}),e.setRenderTarget(this._renderTarget),e.setClearColor(0,0),e.autoClear=!1,e.clear(!0,!0,!1),e.render(i,s);for(const[w,g]of u)w.material=g;for(const w of f)w.visible=!0;for(const[w,g]of m)w.visible=g;e.setRenderTarget(a),e.autoClear=l,e.setClearColor(c,h)}renderDepthPass(){this.renderWithTileMaterial(this._depthMaterial)}renderNormalPass(){this.renderWithTileMaterial(this._normalMaterial)}restoreOriginalMaterials(){for(const[t,e]of this._originalMaterials)t.material=e;this._originalMaterials.clear();for(const t of this._hiddenLods)t.visible=!0;this._hiddenLods.length=0}readPixelAt(t,e){let i,s;t instanceof p.nWS?(i=t,s=e):(i=this._renderTarget,s=t);const n=this.world.renderer.three,o=this._renderTargetSize,a=Math.floor(.5*(s.x+1)*o.x),l=Math.floor(.5*(s.y+1)*(o.y-1)),c=Math.max(0,Math.min(o.x-1,a)),h=Math.max(0,Math.min(o.y-1,l)),u=new Uint8Array(4);return n.readRenderTargetPixels(i,c,h,1,1,u),u}buildIdMaterial(){return new p.BKk({uniforms:{modelByte:{value:1}},vertexShader:"\n attribute vec4 id;\n varying vec4 vId;\n #if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n #endif\n void main() {\n vId = id;\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n #if NUM_CLIPPING_PLANES > 0\n vClipPosition = -mvPosition.xyz;\n #endif\n gl_Position = projectionMatrix * mvPosition;\n }\n ",fragmentShader:"\n precision highp float;\n uniform float modelByte;\n varying vec4 vId;\n #if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];\n #endif\n void main() {\n #if NUM_CLIPPING_PLANES > 0\n for (int i = 0; i < NUM_CLIPPING_PLANES; i++) {\n vec4 plane = clippingPlanes[i];\n if (dot(vClipPosition, plane.xyz) > plane.w) discard;\n }\n #endif\n gl_FragColor = vec4(modelByte / 255.0, vId.y / 255.0, vId.z / 255.0, vId.w / 255.0);\n }\n ",side:p.$EB})}buildDepthMaterial(){return new p.BKk({uniforms:{},vertexShader:"\n #if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n #endif\n void main() {\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n #if NUM_CLIPPING_PLANES > 0\n vClipPosition = -mvPosition.xyz;\n #endif\n gl_Position = projectionMatrix * mvPosition;\n }\n ",fragmentShader:"\n #if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];\n #endif\n void main() {\n #if NUM_CLIPPING_PLANES > 0\n for (int i = 0; i < NUM_CLIPPING_PLANES; i++) {\n vec4 plane = clippingPlanes[i];\n if (dot(vClipPosition, plane.xyz) > plane.w) discard;\n }\n #endif\n float v = gl_FragCoord.z;\n vec4 r = vec4(\n fract(v * 16777216.0),\n fract(v * 65536.0),\n fract(v * 256.0),\n v\n );\n r.yzw -= r.xyz * (1.0 / 256.0);\n gl_FragColor = r * (256.0 / 255.0);\n }\n ",side:p.$EB})}buildNormalMaterial(){return new p.BKk({uniforms:{},vertexShader:"\n varying vec3 vWorldNormal;\n #if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n #endif\n void main() {\n vWorldNormal = normalize(\n (modelMatrix * vec4(normal, 0.0)).xyz\n );\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n #if NUM_CLIPPING_PLANES > 0\n vClipPosition = -mvPosition.xyz;\n #endif\n gl_Position = projectionMatrix * mvPosition;\n }\n ",fragmentShader:"\n varying vec3 vWorldNormal;\n #if NUM_CLIPPING_PLANES > 0\n varying vec3 vClipPosition;\n uniform vec4 clippingPlanes[NUM_CLIPPING_PLANES];\n #endif\n void main() {\n #if NUM_CLIPPING_PLANES > 0\n for (int i = 0; i < NUM_CLIPPING_PLANES; i++) {\n vec4 plane = clippingPlanes[i];\n if (dot(vClipPosition, plane.xyz) > plane.w) discard;\n }\n #endif\n vec3 n = normalize(vWorldNormal);\n if (!gl_FrontFacing) n = -n;\n gl_FragColor = vec4(n * 0.5 + 0.5, 1.0);\n }\n ",side:p.$EB})}setupRenderTarget(){const e=this.world.renderer.three.getSize(new p.I9Y);this._renderTargetSize.copy(e),this._renderTarget=new p.nWS(e.x,e.y,{format:p.GWd,type:p.OUM,minFilter:p.hxR,magFilter:p.hxR,depthBuffer:!0}),this.debugMode&&this.setupDebugCanvas(),this.world.renderer.onResize.add(s=>{this._renderTargetSize.copy(s),this._renderTarget.setSize(s.x,s.y),this._debugCanvas&&(this._debugCanvas.width=s.x,this._debugCanvas.height=s.y)})}setupDebugCanvas(){if(this._debugCanvas)return;const t=this.world.renderer.three.getSize(new p.I9Y);this._debugContainer=document.createElement("div"),this._debugContainer.style.position="fixed",this._debugContainer.style.top="10px",this._debugContainer.style.right="10px",this._debugContainer.style.width="300px",this._debugContainer.style.height="300px",this._debugContainer.style.border="2px solid #fff",this._debugContainer.style.backgroundColor="#000",this._debugContainer.style.zIndex="10000",this._debugContainer.style.pointerEvents="none",this._debugCanvas=document.createElement("canvas"),this._debugCanvas.width=t.x,this._debugCanvas.height=t.y,this._debugCanvas.style.width="100%",this._debugCanvas.style.height="100%",this._debugCanvas.style.imageRendering="pixelated",this._debugContainer.appendChild(this._debugCanvas),document.body.appendChild(this._debugContainer)}removeDebugCanvas(){this._debugContainer&&(this._debugContainer.remove(),this._debugContainer=void 0,this._debugCanvas=void 0)}updateDebugCanvas(){if(!this._debugCanvas||!this._renderTarget||!this.world.renderer)return;const t=this.world.renderer.three,e=this._renderTargetSize,i=new Uint8Array(e.x*e.y*4);t.readRenderTargetPixels(this._renderTarget,0,0,e.x,e.y,i);const s=this._debugCanvas.getContext("2d");if(!s)return;const n=s.createImageData(e.x,e.y),o=4*e.x;for(let a=0;a<e.y;a++){const h=a*o,u=(e.y-1-a)*o;n.data.set(i.subarray(h,h+o),u)}s.putImageData(n,0,0)}};y(tl,"MAX_MODELS",254);let cf=tl;const el=class jc extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"list",new Map),y(this,"onDisposed",new Q),t.add(jc.uuid,this)}get(t){if(this.list.has(t.uuid))return this.list.get(t.uuid);const e=new cf(this.components,t);return this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)}),e}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}};y(el,"uuid","4a82430c-7ff2-49ea-9401-60807502dad6");let df=el;class as{constructor(t){y(this,"onDisposed",new Q),y(this,"maxDistance",1),y(this,"maxCacheSize",1e3),y(this,"components"),y(this,"cache",new Map),this.components=t}dispose(){this.cache.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}resolve(t,e,i,s){var n=this;return(0,G.A)(function*(){const o=as.keyOf(e,i);let a=n.cache.get(o);if(a)n.cache.delete(o),n.cache.set(o,a);else{if(a=yield n.fetchItemSnapData(e,i),!a)return null;n.storeWithLRU(o,a)}const l=n.snap(t,a,2),c=new Set(s),h=[0,1,2];let u=null;for(const f of h){if(!c.has(f))continue;const d=n.snap(t,a,f);if(d){u=d.result;break}}if(!u)return l?l.result:null;if(l&&2!==u.snappingClass){const f=l.result;!u.normal&&f.normal&&(u.normal=f.normal),!u.facePoints&&f.facePoints&&(u.facePoints=f.facePoints),!u.faceIndices&&f.faceIndices&&(u.faceIndices=f.faceIndices)}return u})()}prefetch(t,e){var i=this;return(0,G.A)(function*(){const s=as.keyOf(t,e);if(i.cache.has(s))return;const n=yield i.fetchItemSnapData(t,e);n&&i.storeWithLRU(s,n)})()}invalidate(t,e){const i=as.keyOf(t,e);this.cache.delete(i)}clear(){this.cache.clear()}static keyOf(t,e){return`${t}:${e}`}storeWithLRU(t,e){for(this.cache.set(t,e);this.cache.size>this.maxCacheSize;){const i=this.cache.keys().next().value;if(void 0===i)break;this.cache.delete(i)}}fetchItemSnapData(t,e){var i=this;return(0,G.A)(function*(){const n=i.components.get(ft).list.get(t);if(!n)return null;const o=yield n._getItemSnapData(e);if(!o)return null;const a=n.object.matrixWorld,l=[];for(const u of Object.keys(o.samples??{})){const f=o.samples[Number(u)],d=o.representations[f.representation];if(!d||1!==d.representationClass)continue;const _=d.geometry;if(!_)continue;const g=mf(a,o.globalTransforms[f.item],o.localTransforms[f.localTransform]);i.collectPolygonsFromShell(_,g,l)}if(0===l.length)return null;const c=function yf(r){const t=new Set,e=[];for(const i of r){const s=i.points,n=s.length/3;for(let o=0;o<n;o++){const a=(o+1)%n,l=s[3*o],c=s[3*o+1],h=s[3*o+2],u=s[3*a],f=s[3*a+1],d=s[3*a+2],_=vf(l,c,h,u,f,d);t.has(_)||(t.add(_),e.push(l,c,h,u,f,d))}}return new Float32Array(e)}(l),h=function wf(r){const t=new Set,e=[];for(const i of r){const s=i.points,n=s.length/3;for(let o=0;o<n;o++){const a=s[3*o],l=s[3*o+1],c=s[3*o+2],h=Er(a,l,c);t.has(h)||(t.add(h),e.push(a,l,c))}}return new Float32Array(e)}(l);return{faces:l,edges:c,vertices:h}})()}collectPolygonsFromShell(t,e,i){const s=t.points,n=t.profiles??new Map,o=t.bigProfiles??new Map,a=new p.Pq0,l=c=>{if(c.length<3)return;const h=new Float32Array(3*c.length);for(let d=0;d<c.length;d++){const _=s[c[d]];a.set(_[0],_[1],_[2]).applyMatrix4(e),h[3*d]=a.x,h[3*d+1]=a.y,h[3*d+2]=a.z}const u=function gf(r){const t=new p.Pq0,e=r.length/3;for(let s=0;s<e;s++){const n=(s+1)%e,o=r[3*s],a=r[3*s+1],l=r[3*s+2],c=r[3*n],h=r[3*n+1],u=r[3*n+2];t.x+=(a-h)*(l+u),t.y+=(l-u)*(o+c),t.z+=(o-c)*(a+h)}const i=t.length();return i<1e-10?null:t.divideScalar(i)}(h);u&&i.push({points:h,normal:u,d:u.x*h[0]+u.y*h[1]+u.z*h[2]})};for(const c of n.values())l(c);for(const c of o.values())l(c)}snap(t,e,i){return 0===i?this.snapToPoint(t,e):1===i?this.snapToLine(t,e):2===i?this.snapToFace(t,e):null}snapToPoint(t,e){const i=e.vertices;if(0===i.length)return null;const s=this.maxDistance*this.maxDistance;let n=-1,o=1/0;for(let a=0;a<i.length;a+=3){const l=i[a]-t.x,c=i[a+1]-t.y,h=i[a+2]-t.z,u=l*l+c*c+h*h;u<=s&&u<o&&(o=u,n=a)}return n<0?null:{result:{point:new p.Pq0(i[n],i[n+1],i[n+2]),snappingClass:0}}}snapToLine(t,e){const i=e.edges;if(0===i.length)return null;const s=this.maxDistance*this.maxDistance,n=new p.Pq0,o=new p.Pq0;let a=1/0,l=-1;for(let c=0;c<i.length;c+=6){const h=bf(t,i[c],i[c+1],i[c+2],i[c+3],i[c+4],i[c+5],o);h<=s&&h<a&&(a=h,l=c,n.copy(o))}return l<0?null:{result:{point:n.clone(),snappingClass:1,snappedEdgeP1:new p.Pq0(i[l],i[l+1],i[l+2]),snappedEdgeP2:new p.Pq0(i[l+3],i[l+4],i[l+5])}}}snapToFace(t,e){const i=e.faces;if(0===i.length)return null;let s=null,n=1/0;for(const a of i){const c=Math.abs(a.normal.x*t.x+a.normal.y*t.y+a.normal.z*t.z-a.d);c<=this.maxDistance&&c<n&&(n=c,s=a)}return s?{result:{point:t.clone().sub(s.normal.clone().multiplyScalar(s.normal.x*t.x+s.normal.y*t.y+s.normal.z*t.z-s.d)),normal:s.normal.clone(),snappingClass:2,facePoints:s.points,faceIndices:_f(s.points.length/3)}}:null}}const pf=new p.kn4,ls=new p.Pq0,cs=new p.Pq0,rn=new p.Pq0;function il(r,t){if(!r)return t.identity();const e=r.position[0],i=r.position[1],s=r.position[2];return ls.set(r.xDirection[0],r.xDirection[1],r.xDirection[2]),cs.set(r.yDirection[0],r.yDirection[1],r.yDirection[2]),rn.crossVectors(ls,cs),t.set(ls.x,cs.x,rn.x,e,ls.y,cs.y,rn.y,i,ls.z,cs.z,rn.z,s,0,0,0,1),t}const sl=new p.kn4,nl=new p.kn4;function mf(r,t,e){return il(t,sl),il(e,nl),pf.copy(r).multiply(sl).multiply(nl).clone()}function _f(r){if(r<3)return new Uint32Array(0);const t=r-2,e=new Uint32Array(3*t);for(let i=0;i<t;i++)e[3*i]=0,e[3*i+1]=i+1,e[3*i+2]=i+2;return e}function Er(r,t,e){return`${Math.round(1e3*r)},${Math.round(1e3*t)},${Math.round(1e3*e)}`}function vf(r,t,e,i,s,n){const o=Er(r,t,e),a=Er(i,s,n);return o<a?`${o}|${a}`:`${a}|${o}`}function bf(r,t,e,i,s,n,o,a){const l=s-t,c=n-e,h=o-i,u=l*l+c*c+h*h;let f=0;u>0&&(f=((r.x-t)*l+(r.y-e)*c+(r.z-i)*h)/u,f<0?f=0:f>1&&(f=1));const d=t+f*l,_=e+f*c,m=i+f*h;a.set(d,_,m);const w=r.x-d,g=r.y-_,v=r.z-m;return w*w+g*g+v*v}const rl=class Hc extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"onDisposed",new Q),y(this,"_resolver"),t.add(Hc.uuid,this),this._resolver=new as(t)}get(){return this._resolver}dispose(){this._resolver.dispose(),this.onDisposed.trigger()}};y(rl,"uuid","be9b8e6c-7f5b-4a36-8e7e-3a1f5e2a6c9d");let xf=rl;class Cf{constructor(t,e){y(this,"enabled",!0),y(this,"components"),y(this,"onDisposed",new Q),y(this,"mouse"),y(this,"three",new p.tBo),y(this,"world");const i=e.renderer;if(!i)throw new Error("A renderer is needed for the raycaster to work!");this.world=e,this.mouse=new Yo(i.three.domElement),this.components=t}dispose(){this.mouse.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}castRayToObjects(t=Array.from(this.world.meshes),e=this.mouse.position){if(!this.world)throw new Error("A world is needed to cast rays!");return this.three.setFromCamera(e,this.world.camera.three),this.intersect(t)}castRay(t){var e=this;return(0,G.A)(function*(){const i=t?.snappingClasses,s=t?.items??Array.from(e.world.meshes),n=t?.position??e.mouse.position;if(!e.world)throw new Error("A world is needed to cast rays!");const o=e.world.camera.three,a=e.components.get(ft);let l=null;if(a.initialized){const f=yield e.components.get(df).get(e.world).getFullPick(n);if(f){const d=a.list.get(f.modelId);if(l={localId:f.localId,point:f.point,normal:f.normal,distance:f.distance,fragments:d,object:d?.object,ray:void 0,frustum:void 0},i&&i.length>0){const _=yield e.components.get(xf).get().resolve(f.point,f.modelId,f.itemId,i);_&&(l.point=_.point,_.normal&&(l.normal=_.normal),l.snappingClass=_.snappingClass,_.facePoints&&(l.facePoints=_.facePoints),_.faceIndices&&(l.faceIndices=_.faceIndices),_.snappedEdgeP1&&(l.snappedEdgeP1=_.snappedEdgeP1),_.snappedEdgeP2&&(l.snappedEdgeP2=_.snappedEdgeP2),l.distance=_.point.distanceTo(o.position))}}if(0===s.length)return l}e.three.setFromCamera(n,o);const c=e.intersect(s);return l?c&&c.distance<l.distance?c:l:c})()}castRayFromVector(t,e,i=Array.from(this.world.meshes)){return this.three.set(t,e),this.intersect(i)}intersect(t=Array.from(this.world.meshes)){const e=this.three.intersectObjects(t),i=this.filterClippingPlanes(e);return i.length>0?i[0]:null}filterClippingPlanes(t){if(!this.world.renderer)throw new Error("Renderer not found!");const e=this.world.renderer.three;if(!e.clippingPlanes)return t;const i=e.clippingPlanes;return t.length<=0||!i||i?.length<=0?t:t.filter(s=>i.every(n=>n.distanceToPoint(s.point)>0))}}const ol=class qc extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"list",new Map),y(this,"onDisposed",new Q),t.add(qc.uuid,this)}get(t){if(this.list.has(t.uuid))return this.list.get(t.uuid);const e=new Cf(this.components,t);return this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)}),e}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}};y(ol,"uuid","d5d8bdf0-db25-4952-b951-b643af207ace");let on=ol;class Tf extends An{constructor(){var t;super(...arguments),t=this,y(this,"onCameraChanged",new Q),y(this,"meshes",new Set),y(this,"onAfterUpdate",new Q),y(this,"onBeforeUpdate",new Q),y(this,"onDisposed",new Q),y(this,"isDisposing",!1),y(this,"enabled",!0),y(this,"_dynamicAnchor",!1),y(this,"uuid",ie.create()),y(this,"name"),y(this,"_scene"),y(this,"_camera"),y(this,"_renderer",null),y(this,"onPointerDown",function(){var e=(0,G.A)(function*(i){if(!t.camera.hasCameraControls())throw new Error("World: can't set dynamic anchor if the camera doesn't have controls.");const n=yield t.components.get(on).get(t).castRay();n&&n.point&&0===i.button&&t.camera.controls.setOrbitPoint(n.point.x,n.point.y,n.point.z)});return function(i){return e.apply(this,arguments)}}()),y(this,"_defaultCamera")}set dynamicAnchor(t){var e;const i=null==(e=this.renderer)?void 0:e.three.domElement.parentElement;if(!i)throw new Error("World: the renderer must have a parentElement to set dynamic anchoring.");t?(this.camera.controls&&(this.camera.controls.minDistance=.01),i.addEventListener("pointerdown",this.onPointerDown)):i.removeEventListener("pointerdown",this.onPointerDown)}get dynamicAnchor(){return this._dynamicAnchor}get defaultCamera(){if(!this._defaultCamera)throw new Error("World: there is no default camera defined.");return this._defaultCamera}set defaultCamera(t){this._defaultCamera=t}get scene(){if(!this._scene)throw new Error("No scene initialized!");return this._scene}set scene(t){this._scene=t,t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"})}get camera(){if(!this._camera)throw new Error("No camera initialized!");return this._camera}set camera(t){this._camera||(this.defaultCamera=t),this._camera=t,t.currentWorld=this,this.onCameraChanged.trigger(t)}get renderer(){return this._renderer}set renderer(t){this._renderer=t,t&&(t.worlds.set(this.uuid,this),t.currentWorld=this,t.onWorldChanged.trigger({world:this,action:"added"}))}useDefaultCamera(){this.camera=this.defaultCamera}update(t){this.enabled&&(!this._scene||!this._camera||(this.scene.currentWorld=this,this.camera.currentWorld=this,this.renderer&&(this.renderer.currentWorld=this),this.onBeforeUpdate.trigger(),this.scene.isUpdateable()&&this.scene.update(t),this.camera.isUpdateable()&&this.camera.update(t),this.renderer&&this.renderer.update(t),this.onAfterUpdate.trigger()))}dispose(t=!0){if(this.enabled=!1,this.isDisposing=!0,this.scene.onWorldChanged.trigger({world:this,action:"removed"}),this.camera.onWorldChanged.trigger({world:this,action:"removed"}),this.renderer&&this.renderer.onWorldChanged.trigger({world:this,action:"removed"}),t){const i=this.components.get(bi);this.scene.dispose(),this.camera.isDisposeable()&&this.camera.dispose(),this.renderer&&this.renderer.dispose();for(const s of this.meshes)i.destroy(s);this.meshes.clear()}this._scene=null,this._camera=null,this._renderer=null,this.components.get(an).list.delete(this.uuid),this.onDisposed.trigger(),this.onDisposed.reset()}}class Pf{constructor(t,e){y(this,"_list"),y(this,"_scene"),this._list=t,this._scene=e}get color(){return this._list.directionalLight.color.value}set color(t){this._list.directionalLight.color.value=t;for(const[,e]of this._scene.directionalLights)e.color.copy(t)}get intensity(){return this._list.directionalLight.intensity.value}set intensity(t){this._list.directionalLight.intensity.value=t;for(const[,e]of this._scene.directionalLights)e.intensity=t}get position(){return this._list.directionalLight.position.value.clone()}set position(t){this._list.directionalLight.position.value=t;for(const[,e]of this._scene.directionalLights)e.position.copy(t)}}class Sf{constructor(t,e){y(this,"_list"),y(this,"_scene"),this._list=t,this._scene=e}get color(){return this._list.ambientLight.color.value}set color(t){this._list.ambientLight.color.value=t;for(const[,e]of this._scene.ambientLights)e.color.copy(t)}get intensity(){return this._list.ambientLight.intensity.value}set intensity(t){this._list.ambientLight.intensity.value=t;for(const[,e]of this._scene.ambientLights)e.intensity=t}}class Ef extends Wi{constructor(){super(...arguments),y(this,"_config",{backgroundColor:{value:new p.Q1f,type:"Color"},ambientLight:{color:{type:"Color",value:new p.Q1f},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2}},directionalLight:{color:{type:"Color",value:new p.Q1f},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2},position:{type:"Vector3",value:new p.Pq0}}}),y(this,"ambientLight",new Sf(this._config,this._component)),y(this,"directionalLight",new Pf(this._config,this._component))}get backgroundColor(){return this._config.backgroundColor.value}set backgroundColor(t){this._config.backgroundColor.value=t,this._component.three.background=t}}class al extends ch{constructor(t){super(t),y(this,"onSetup",new Q),y(this,"isSetup",!1),y(this,"three"),y(this,"config",new Ef(this,this.components,"Scene")),y(this,"_defaultConfig",{backgroundColor:new p.Q1f(2107698),directionalLight:{color:new p.Q1f("white"),intensity:1.5,position:new p.Pq0(5,10,3)},ambientLight:{color:new p.Q1f("white"),intensity:1}}),this.three=new p.Z58,this.three.background=new p.Q1f(2107698)}setup(t){const e={...this._defaultConfig,...t};this.config.backgroundColor=e.backgroundColor;const i=e.ambientLight;this.config.ambientLight.color=i.color,this.config.ambientLight.intensity=i.intensity;const s=e.directionalLight;this.config.directionalLight.color=s.color,this.config.directionalLight.intensity=s.intensity,this.config.directionalLight.position=s.position,this.deleteAllLights();const{color:n,intensity:o}=this.config.directionalLight,a=new p.ZyN(n,o);a.position.copy(s.position);const{color:l,intensity:c}=this.config.directionalLight,h=new p.$p8(l,c);this.three.add(a,h),this.directionalLights.set(a.uuid,a),this.ambientLights.set(h.uuid,h),this.isSetup=!0,this.onSetup.trigger()}dispose(){super.dispose(),this.components.get(Ps).list.delete(this.config.uuid)}}'\n<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 40" fill="none" aria-label="That Open Company">\n<path d="M42.2856 19.6517V8.4048H38.8676V7.14978H46.998V8.40976H43.6131V19.6566L42.2856 19.6517Z" fill="#BCF124"/>\n<path d="M48.459 19.6516V7.14978H49.7032V12.404L49.4204 12.3371C49.6285 11.7727 50.0095 11.2904 50.5078 10.9607C51.0285 10.6201 51.638 10.4449 52.2578 10.4577C52.853 10.4483 53.44 10.5988 53.9589 10.8938C54.456 11.1789 54.8687 11.5934 55.1541 12.0943C55.449 12.6164 55.6 13.2089 55.5913 13.8102V19.6516H54.3495V14.2958C54.3637 13.8139 54.2611 13.3359 54.0507 12.9033C53.8646 12.537 53.5797 12.2315 53.229 12.0224C52.8685 11.8121 52.4584 11.7046 52.0423 11.7115C51.624 11.7054 51.2117 11.8128 50.8483 12.0224C50.4912 12.2324 50.2006 12.541 50.0106 12.912C49.7956 13.3401 49.6899 13.8158 49.7032 14.2958V19.6516H48.459Z" fill="#BCF124"/>\n<path d="M60.5388 19.8524C60.0174 19.8619 59.5007 19.75 59.0289 19.5253C58.6071 19.3259 58.2459 19.0157 57.983 18.6271C57.7263 18.2403 57.593 17.7833 57.6009 17.3175C57.5959 16.8715 57.6984 16.4309 57.8997 16.034C58.1173 15.6285 58.4383 15.2892 58.8292 15.0516C59.3232 14.7561 59.8701 14.5624 60.4384 14.4817L63.9188 13.8932V15.0355L60.7348 15.5744C60.0931 15.6867 59.6314 15.8932 59.3497 16.1938C59.0735 16.4811 58.9212 16.8673 58.926 17.268C58.9244 17.4635 58.9661 17.657 59.0481 17.8341C59.1301 18.0112 59.2503 18.1674 59.3999 18.2913C59.7416 18.5818 60.1787 18.7318 60.6246 18.7113C61.1803 18.7244 61.7296 18.5884 62.2166 18.3173C62.6597 18.066 63.0268 17.6972 63.2784 17.2506C63.535 16.7959 63.6669 16.2801 63.6604 15.7565V13.4744C63.6679 13.2259 63.6196 12.979 63.519 12.7521C63.4185 12.5253 63.2684 12.3245 63.08 12.1649C62.693 11.8287 62.1897 11.6607 61.57 11.6607C61.0801 11.6502 60.5978 11.7845 60.1822 12.047C59.7665 12.3095 59.4355 12.6888 59.2297 13.1387L58.1018 12.5192C58.2839 12.117 58.553 11.7614 58.8892 11.4785C59.2572 11.162 59.6754 10.9107 60.1261 10.7352C60.5858 10.5517 61.0758 10.4579 61.57 10.4589C62.1703 10.4448 62.7654 10.5748 63.3065 10.838C63.7888 11.077 64.1965 11.4462 64.4846 11.9047C64.7683 12.3771 64.912 12.9219 64.8986 13.4744V19.6517H63.658V17.8552L63.8405 18.0398C63.6702 18.3954 63.4238 18.7081 63.1191 18.9554C62.7772 19.238 62.3899 19.4593 61.9741 19.6095C61.5136 19.7756 61.0277 19.8578 60.5388 19.8524Z" fill="#BCF124"/>\n<path d="M70.6935 19.752C69.8975 19.752 69.2852 19.517 68.8566 19.0471C68.428 18.5771 68.2108 17.9056 68.2051 17.0326V11.9122H66.5616V10.6534H66.9804C67.1477 10.662 67.3148 10.6332 67.4697 10.5689C67.6247 10.5047 67.7637 10.4066 67.8769 10.2818C68.1017 10.0195 68.2202 9.68094 68.2088 9.33398V8.57825H69.453V10.6596H71.4124V11.9184H69.453V17.0388C69.4478 17.3107 69.4926 17.5813 69.5853 17.8366C69.6729 18.065 69.8337 18.2569 70.042 18.3818C70.3083 18.5292 70.6096 18.5991 70.9128 18.5837C71.0009 18.5837 71.1063 18.5775 71.2287 18.5664C71.3512 18.5552 71.4553 18.5441 71.5434 18.5329V19.6578C71.396 19.6937 71.2462 19.7189 71.0952 19.7334C70.9262 19.7433 70.7927 19.752 70.6935 19.752Z" fill="#BCF124"/>\n<path d="M82.2003 19.8523C81.3145 19.8603 80.4355 19.6954 79.6114 19.3666C78.4307 18.8928 77.4197 18.068 76.7118 17.001C76.0038 15.9341 75.6323 14.6751 75.646 13.3901C75.6376 12.5147 75.8043 11.6466 76.1359 10.838C76.453 10.0681 76.9213 9.37141 77.5123 8.79004C78.1118 8.20273 78.819 7.73977 79.5942 7.42723C81.2715 6.778 83.1266 6.778 84.8039 7.42723C85.5794 7.73911 86.2867 8.20215 86.8857 8.79004C87.4768 9.3717 87.9454 10.0683 88.2635 10.838C88.5945 11.6468 88.7611 12.5148 88.7533 13.3901C88.7674 14.6752 88.396 15.9343 87.688 17.0013C86.98 18.0683 85.9688 18.8931 84.7879 19.3666C83.9642 19.6952 83.0857 19.8601 82.2003 19.8523ZM82.2003 17.4984C82.7378 17.5032 83.2709 17.4005 83.769 17.1961C84.2425 16.9994 84.6735 16.7111 85.0378 16.3474C85.4069 15.9786 85.6952 15.5354 85.884 15.0465C86.0882 14.5173 86.1896 13.9532 86.1828 13.3852C86.1898 12.8203 86.0883 12.2594 85.884 11.7337C85.6922 11.2464 85.4043 10.8038 85.0378 10.4328C84.6764 10.0659 84.2446 9.77748 83.769 9.58542C82.7594 9.19396 81.6424 9.19396 80.6327 9.58542C80.1568 9.77745 79.7246 10.0658 79.3628 10.4328C78.9967 10.8041 78.7088 11.2467 78.5166 11.7337C78.3119 12.2602 78.2104 12.8219 78.2177 13.3876C78.2109 13.9557 78.3123 14.5198 78.5166 15.049C78.7058 15.5377 78.994 15.9808 79.3628 16.3499C79.7275 16.7136 80.1589 17.0019 80.6327 17.1985C81.1302 17.4038 81.663 17.5074 82.2003 17.5033V17.4984Z" fill="#BCF124"/>\n<path d="M90.398 23.2209V10.4861H92.7248V12.2293L92.5081 11.7251C92.8117 11.2627 93.2354 10.8941 93.7327 10.6596C94.2857 10.3994 94.8901 10.2702 95.4999 10.2817C96.3233 10.271 97.1335 10.4919 97.8401 10.9198C98.5312 11.3384 99.1029 11.9314 99.4995 12.6406C99.9126 13.38 100.124 14.2172 100.112 15.0664C100.122 15.9116 99.913 16.7448 99.5069 17.4835C99.1168 18.1988 98.5469 18.7971 97.8548 19.218C97.1376 19.6483 96.3164 19.8688 95.4827 19.8548C94.894 19.8605 94.3104 19.7437 93.7682 19.5116C93.2614 19.2967 92.8226 18.9454 92.4995 18.4957L92.8975 17.9754V23.2234L90.398 23.2209ZM95.1741 17.5863C95.6033 17.5949 96.0268 17.4848 96.3987 17.268C96.7521 17.0559 97.0394 16.7477 97.2278 16.3784C97.4328 15.9736 97.5355 15.5237 97.5266 15.0689C97.5364 14.6168 97.4337 14.1694 97.2278 13.768C97.0366 13.4007 96.7499 13.0932 96.3987 12.8785C96.0288 12.6556 95.6046 12.5419 95.1741 12.5502C94.7569 12.5434 94.3461 12.6541 93.9874 12.8698C93.6387 13.0826 93.3568 13.391 93.1743 13.7593C92.9832 14.1688 92.8841 14.6161 92.8841 15.0689C92.8841 15.5217 92.9832 15.9689 93.1743 16.3784C93.3571 16.7465 93.639 17.0548 93.9874 17.268C94.3469 17.4837 94.7586 17.594 95.1766 17.5863H95.1741Z" fill="#BCF124"/>\n<path d="M105.924 19.8524C104.961 19.8524 104.126 19.6372 103.418 19.2069C102.724 18.7915 102.156 18.1916 101.776 17.4724C101.384 16.7291 101.184 15.8977 101.194 15.0553C101.179 14.1986 101.388 13.3532 101.801 12.6047C102.189 11.9046 102.753 11.3198 103.434 10.9087C104.139 10.4899 104.944 10.2756 105.761 10.2892C106.414 10.277 107.062 10.394 107.67 10.6336C108.202 10.8483 108.68 11.1777 109.073 11.5987C109.454 12.0141 109.75 12.5023 109.943 13.0346C110.147 13.6019 110.248 14.2016 110.242 14.805C110.242 14.9847 110.234 15.1606 110.218 15.334C110.205 15.4855 110.174 15.6349 110.126 15.7788H103.34V13.9266H108.716L107.538 14.8001C107.65 14.3786 107.645 13.9339 107.522 13.5153C107.411 13.1561 107.186 12.8437 106.883 12.6258C106.553 12.4 106.161 12.2855 105.762 12.2987C105.368 12.2877 104.981 12.3993 104.652 12.6184C104.327 12.8492 104.083 13.1779 103.955 13.5574C103.79 14.0428 103.728 14.5577 103.772 15.0689C103.719 15.5315 103.782 16.0001 103.955 16.4317C104.108 16.81 104.375 17.1302 104.718 17.3473C105.08 17.5514 105.486 17.6634 105.901 17.6736C106.316 17.6837 106.727 17.5917 107.098 17.4055C107.407 17.2317 107.661 16.9743 107.833 16.6622L109.824 17.6186C109.643 18.0737 109.355 18.4776 108.986 18.7956C108.59 19.1398 108.132 19.4046 107.638 19.5761C107.087 19.766 106.507 19.8594 105.924 19.8524Z" fill="#BCF124"/>\n<path d="M111.703 19.6516V10.4837H114.03V12.2962L113.898 11.8935C114.081 11.3764 114.443 10.944 114.918 10.6769C115.425 10.404 115.994 10.2679 116.569 10.2817C117.196 10.2676 117.816 10.4179 118.369 10.7178C118.875 11.0011 119.293 11.4232 119.573 11.9357C119.87 12.4948 120.018 13.1223 120.004 13.7569V19.6491H117.515V14.2958C117.524 13.9753 117.452 13.6579 117.307 13.3728C117.173 13.1206 116.972 12.9112 116.727 12.7682C116.459 12.625 116.162 12.5502 115.859 12.5502C115.557 12.5502 115.26 12.625 114.992 12.7682C114.743 12.9091 114.539 13.1188 114.403 13.3728C114.259 13.658 114.188 13.9754 114.196 14.2958V19.6516H111.703Z" fill="#BCF124"/>\n<path d="M45.7329 35.9372C44.8875 35.9451 44.0493 35.7794 43.269 35.4503C42.525 35.134 41.851 34.6707 41.2863 34.0875C40.7178 33.4992 40.2696 32.8033 39.9673 32.0396C39.6453 31.2229 39.4843 30.3504 39.4934 29.4713C39.4848 28.5902 39.6427 27.7155 39.9588 26.8943C40.2511 26.1324 40.6939 25.4388 41.2601 24.8558C41.8262 24.2727 42.504 23.8126 43.2518 23.5034C44.039 23.178 44.8826 23.015 45.7329 23.024C46.5598 23.0107 47.3809 23.1649 48.1479 23.4774C48.8259 23.756 49.443 24.1669 49.9641 24.6866C50.4412 25.1559 50.8045 25.7304 51.0258 26.3653L48.7529 27.4729C48.5362 26.8433 48.1263 26.3001 47.5831 25.9226C47.0399 25.5451 46.3917 25.3529 45.7329 25.3742C45.0556 25.3604 44.3882 25.5408 43.8078 25.8945C43.2553 26.2426 42.8099 26.74 42.5219 27.3304C42.2056 27.9978 42.0495 28.7313 42.0664 29.4713C42.0503 30.2135 42.2063 30.9493 42.5219 31.6196C42.8077 32.2136 43.2534 32.7139 43.8078 33.0629C44.3879 33.4172 45.0555 33.5976 45.7329 33.5832C46.3917 33.6045 47.0399 33.4124 47.5831 33.0348C48.1263 32.6573 48.5362 32.1142 48.7529 31.4845L51.0258 32.5933C50.8056 33.2316 50.4422 33.8096 49.9641 34.282C49.4426 34.8009 48.8256 35.2113 48.1479 35.4899C47.3805 35.8004 46.5594 35.9524 45.7329 35.9372Z" fill="#BCF124"/>\n<path d="M56.8159 35.9372C55.9603 35.9485 55.1164 35.735 54.3667 35.3177C53.6426 34.9153 53.0357 34.3274 52.6069 33.613C52.1777 32.8648 51.9517 32.0151 51.9517 31.15C51.9517 30.285 52.1777 29.4353 52.6069 28.6871C53.0376 27.9762 53.6442 27.3911 54.3667 26.9898C55.118 26.5823 55.9573 26.3691 56.8098 26.3691C57.6623 26.3691 58.5016 26.5823 59.253 26.9898C59.9716 27.3928 60.5749 27.9771 61.0042 28.6858C61.4334 29.4341 61.6594 30.2837 61.6594 31.1488C61.6594 32.0139 61.4334 32.8635 61.0042 33.6118C60.577 34.3244 59.9733 34.912 59.253 35.3165C58.5078 35.7343 57.6678 35.9482 56.8159 35.9372ZM56.8159 33.6712C57.2335 33.681 57.6451 33.5701 58.0026 33.3516C58.3443 33.1354 58.6199 32.8274 58.7986 32.462C58.9985 32.0556 59.0985 31.6064 59.0901 31.1525C59.099 30.7014 58.9989 30.2548 58.7986 29.8517C58.6161 29.4889 58.3414 29.1818 58.0026 28.9621C57.6468 28.739 57.2345 28.6254 56.8159 28.635C56.3952 28.6261 55.9807 28.7396 55.6219 28.9621C55.2792 29.18 55.0008 29.4873 54.8161 29.8517C54.6162 30.2549 54.5166 30.7015 54.5259 31.1525C54.517 31.6063 54.6166 32.0555 54.8161 32.462C54.997 32.8291 55.2762 33.1373 55.6219 33.3516C55.9824 33.5695 56.3962 33.6803 56.8159 33.6712Z" fill="#BCF124"/>\n<path d="M63.1228 35.7364V26.5685H65.4496V28.7985L65.2047 28.4269C65.337 27.7223 65.6574 27.202 66.1661 26.8658C66.7124 26.5198 67.3477 26.3448 67.992 26.3628C68.6955 26.3487 69.3867 26.5504 69.9747 26.9414C70.2455 27.1163 70.4794 27.3435 70.6631 27.6102C70.8468 27.8768 70.9766 28.1775 71.045 28.495L70.3311 28.5619C70.6299 27.8128 71.056 27.2586 71.6096 26.8993C72.1912 26.5332 72.8658 26.3468 73.5506 26.3628C74.1566 26.3506 74.755 26.5011 75.2847 26.7989C75.7839 27.0856 76.1947 27.5068 76.4714 28.0155C76.7686 28.5772 76.9163 29.2073 76.9 29.8442V35.7364H74.4067V30.3806C74.4151 30.0621 74.3496 29.746 74.2156 29.4576C74.0956 29.2086 73.9084 28.999 73.6756 28.853C73.4175 28.71 73.1279 28.635 72.8336 28.635C72.5393 28.635 72.2498 28.71 71.9917 28.853C71.7556 28.9972 71.5655 29.2071 71.4443 29.4576C71.3103 29.746 71.2448 30.0621 71.2532 30.3806V35.7364H68.7648V30.3806C68.7731 30.0621 68.7077 29.746 68.5737 29.4576C68.4538 29.2089 68.267 28.9994 68.0349 28.853C67.7765 28.71 67.4868 28.635 67.1923 28.635C66.8978 28.635 66.6081 28.71 66.3498 28.853C66.1137 28.9972 65.9236 29.2071 65.8023 29.4576C65.6683 29.746 65.6029 30.0621 65.6113 30.3806V35.7364H63.1228Z" fill="#BCF124"/>\n<path d="M78.5374 39.3107V26.5697H80.8642V28.3166L80.6486 27.8123C80.9522 27.35 81.376 26.9813 81.8733 26.7469C82.4266 26.4883 83.0311 26.3611 83.6404 26.3752C84.464 26.3639 85.2743 26.5848 85.9807 27.0132C86.6715 27.4323 87.2431 28.0251 87.6401 28.7341C88.0532 29.473 88.2645 30.3098 88.2524 31.1586C88.2623 32.0044 88.0533 32.8381 87.6462 33.577C87.2571 34.2926 86.6875 34.8911 85.9954 35.3115C85.2785 35.7427 84.4572 35.9636 83.6233 35.9495C83.0345 35.9548 82.4509 35.8376 81.9088 35.6051C81.4019 35.391 80.963 35.04 80.6401 34.5904L81.0381 34.0701V39.3231L78.5374 39.3107ZM83.3134 33.6712C83.7428 33.6796 84.1663 33.5691 84.5381 33.3515C84.892 33.1399 85.1798 32.8316 85.3684 32.462C85.573 32.057 85.6757 31.6072 85.6672 31.1524C85.6761 30.7004 85.5734 30.2533 85.3684 29.8516C85.176 29.4847 84.8891 29.1774 84.5381 28.962C84.1679 28.7398 83.7438 28.6266 83.3134 28.635C82.8964 28.6281 82.4856 28.7383 82.1268 28.9534C81.778 29.1666 81.496 29.4755 81.3136 29.8442C81.1225 30.2534 81.0233 30.7004 81.0233 31.1531C81.0233 31.6057 81.1225 32.0527 81.3136 32.462C81.4954 32.8308 81.7775 33.1394 82.1268 33.3515C82.4863 33.5682 82.8986 33.679 83.3171 33.6712H83.3134Z" fill="#BCF124"/>\n<path d="M92.5093 35.9371C91.9294 35.9511 91.353 35.8427 90.8168 35.6187C90.3699 35.4306 89.9887 35.1118 89.722 34.7032C89.4607 34.2804 89.3278 33.7893 89.3399 33.2908C89.3319 32.8129 89.4525 32.3418 89.689 31.928C89.9498 31.5033 90.3197 31.1581 90.7593 30.9295C91.3217 30.6339 91.931 30.4406 92.5595 30.3583L95.3296 29.9049V31.7521L93.0028 32.1708C92.7069 32.2127 92.4268 32.3314 92.1897 32.5153C92.0938 32.6024 92.0186 32.7102 91.9696 32.8307C91.9207 32.9513 91.8992 33.0814 91.9068 33.2115C91.9015 33.3387 91.9277 33.4652 91.9828 33.5796C92.038 33.6941 92.1204 33.7928 92.2227 33.8669C92.4503 34.0296 92.7243 34.1123 93.0028 34.1023C93.3792 34.1101 93.7509 34.0174 94.0805 33.8335C94.3832 33.6617 94.6332 33.4087 94.803 33.1025C94.9751 32.7929 95.0638 32.443 95.0602 32.0878V29.698C95.062 29.5308 95.0264 29.3654 94.956 29.2141C94.8855 29.0628 94.7822 28.9296 94.6536 28.8245C94.3818 28.5891 94.0144 28.4714 93.5515 28.4714C93.1318 28.4645 92.7212 28.5949 92.3807 28.8431C92.0467 29.0873 91.7912 29.4256 91.6459 29.8157L89.6547 28.8592C89.826 28.354 90.1169 27.8989 90.5021 27.5336C90.9038 27.1547 91.3782 26.8634 91.8958 26.6775C92.4648 26.471 93.0657 26.3686 93.6702 26.3752C94.3679 26.3612 95.0599 26.5046 95.6958 26.7952C96.2502 27.0473 96.724 27.4511 97.0637 27.961C97.3951 28.4765 97.5658 29.0807 97.5536 29.6955V35.7389H95.2268V34.2584L95.7913 34.1581C95.5497 34.5339 95.2533 34.8706 94.912 35.1566C94.5921 35.4193 94.2261 35.6185 93.8331 35.7439C93.4044 35.877 92.9578 35.9422 92.5093 35.9371Z" fill="#BCF124"/>\n<path d="M99.3795 35.7365V26.5685H101.706V28.3823L101.573 27.9796C101.757 27.4626 102.119 27.0301 102.593 26.7618C103.101 26.4898 103.67 26.3542 104.245 26.3678C104.872 26.3532 105.493 26.5034 106.045 26.8039C106.551 27.0867 106.968 27.5085 107.248 28.0205C107.545 28.5801 107.693 29.208 107.679 29.8429V35.7352H105.189V30.3806C105.197 30.0603 105.126 29.743 104.982 29.4576C104.848 29.2051 104.646 28.9957 104.401 28.8531C104.135 28.7035 103.834 28.6282 103.53 28.635C103.23 28.6314 102.935 28.7065 102.673 28.8531C102.423 28.9936 102.219 29.2034 102.084 29.4576C101.939 29.7428 101.868 30.0603 101.877 30.3806V35.7365H99.3795Z" fill="#BCF124"/>\n<path d="M110.563 39.4631C110.304 39.4633 110.046 39.4405 109.791 39.3949C109.563 39.3571 109.342 39.2835 109.136 39.1769V37.1128C109.316 37.1628 109.499 37.2017 109.684 37.2293C109.875 37.2621 110.07 37.2791 110.264 37.2801C110.754 37.2801 111.099 37.1562 111.31 36.9282C111.522 36.6884 111.696 36.4162 111.824 36.1217L112.437 34.6945L112.404 36.7932L108.421 26.5697H111.093L113.731 33.8384H112.735L115.373 26.5697H118.048L114.165 36.5925C113.955 37.1702 113.652 37.7089 113.269 38.187C112.942 38.5905 112.531 38.9169 112.066 39.1434C111.594 39.3617 111.081 39.4709 110.563 39.4631Z" fill="#BCF124"/>\n<path d="M7.00861 16.1097H0C0.00583172 11.8399 1.68502 7.74676 4.66939 4.7276C7.65377 1.70844 11.6998 0.00968387 15.9203 0.00378418V7.09408C13.558 7.09801 11.2935 8.04913 9.62308 9.73902C7.95266 11.4289 7.0125 13.7198 7.00861 16.1097Z" fill="#BCF124"/>\n<path d="M15.9243 39.3094C11.7037 39.3035 7.65771 37.6047 4.67333 34.5856C1.68896 31.5664 0.00976849 27.4732 0.00393677 23.2035H7.01255C7.01255 24.9874 7.53543 26.7311 8.51506 28.2144C9.4947 29.6976 10.8871 30.8536 12.5162 31.5362C14.1452 32.2189 15.9378 32.3975 17.6672 32.0495C19.3966 31.7015 20.9852 30.8425 22.2321 29.5811C23.4789 28.3197 24.328 26.7127 24.672 24.9631C25.016 23.2135 24.8394 21.4 24.1647 19.752C23.4899 18.1039 22.3472 16.6953 20.881 15.7042C19.4149 14.7132 17.6912 14.1842 15.9279 14.1842V7.09021C20.1512 7.09021 24.2016 8.78747 27.1879 11.8086C30.1742 14.8297 31.8519 18.9273 31.8519 23.1998C31.8519 27.4723 30.1742 31.5699 27.1879 34.591C24.2016 37.6121 20.1512 39.3094 15.9279 39.3094H15.9243Z" fill="#BCF124"/>\n</svg>\n'.trim();class hs extends ah{constructor(t){super(t),y(this,"onBeforeUpdate",new Q),y(this,"onAfterUpdate",new Q),y(this,"onAspectUpdated",new Q),y(this,"onDisposed",new Q),y(this,"three"),y(this,"_resizeObserver",null),y(this,"_allControls",new Map),y(this,"updateAspect",()=>{var e;if(this.currentWorld&&this.currentWorld.renderer){if(this.three instanceof p.qUd)return void this.onAspectUpdated.trigger();if(null!=(e=this.currentWorld.renderer)&&e.isResizeable()){const i=this.currentWorld.renderer.getSize();this.three.aspect=i.width/i.height,this.three.updateProjectionMatrix(),this.onAspectUpdated.trigger()}}}),this.three=this.setupCamera(),this.worlds.onItemSet.add(({value:e})=>{const i=this.newCameraControls();this.setupEvents(!0),this._allControls.set(e.uuid,i)}),this.worlds.onBeforeDelete.add(({value:e})=>{var i;const s=this._allControls.get(e.uuid);s&&(s.dispose(),this._allControls.delete(e.uuid)),null==(i=this._resizeObserver)||i.disconnect()})}get controls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");const t=this._allControls.get(this.currentWorld.uuid);if(!t)throw new Error("Controls not found!");return t}get enabled(){return null!==this.currentWorld&&this.controls.enabled}set enabled(t){null!==this.currentWorld&&(this.controls.enabled=t)}set currentWorld(t){super.currentWorld=t,t&&(this.worlds.get(t.uuid)||this.worlds.set(t.uuid,t))}get currentWorld(){return this._currentWorld}dispose(){this.setupEvents(!1),this.onAspectUpdated.reset(),this.onBeforeUpdate.reset(),this.onAfterUpdate.reset(),this.three.removeFromParent(),this.onDisposed.trigger(),this.onDisposed.reset();for(const[t,e]of this._allControls)e.dispose();this.worlds.clear()}fitToItems(t){var e=this;return(0,G.A)(function*(){const i=yield e.getItemsBounding(t);yield e.controls.fitToSphere(i,!0)})()}setOrbitToItems(t){var e=this;return(0,G.A)(function*(){const i=yield e.getItemsBounding(t);e.controls.setOrbitPoint(i.center.x,i.center.y,i.center.z)})()}update(t){this.enabled&&(this.onBeforeUpdate.trigger(this),this.controls.update(t),this.onAfterUpdate.trigger(this))}getItemsBounding(t){var e=this;return(0,G.A)(function*(){const i=e.components.get(ft),s=e.components.get(Qa);s.list.clear();const n=new p.iyt;if(t)yield s.addFromModelIdMap(t);else for(const[,o]of i.list)s.list.add(o.box);return s.get().getBoundingSphere(n),s.list.clear(),n})()}setupCamera(){const t=window.innerWidth/window.innerHeight,e=new p.ubm(60,t,1,1e3);return e.position.set(50,50,50),e.lookAt(new p.Pq0(0,0,0)),e}newCameraControls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");if(!this.currentWorld.renderer)throw new Error("This camera needs a renderer to work!");Zt.install({THREE:hs.getSubsetOfThree()});const{domElement:t}=this.currentWorld.renderer.three,e=new Zt(this.three,t);return e.smoothTime=.2,e.dollyToCursor=!0,e.infinityDolly=!0,e.minDistance=6,e}setupEvents(t){if(this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),t){if(!this.currentWorld)throw new Error("This camera needs a world to work!");if(!this.currentWorld.renderer)throw new Error("This camera needs a renderer to work!");const{domElement:e}=this.currentWorld.renderer.three;this._resizeObserver=new ResizeObserver(this.updateAspect),this._resizeObserver.observe(e)}}static getSubsetOfThree(){return{MOUSE:p.kBv,Vector2:p.I9Y,Vector3:p.Pq0,Vector4:p.IUQ,Quaternion:p.PTz,Matrix4:p.kn4,Spherical:p.YHV,Box3:p.NRn,Sphere:p.iyt,Raycaster:p.tBo,MathUtils:p.cj9}}}const ll=class Gc extends At{constructor(t){super(t),y(this,"onAfterUpdate",new Q),y(this,"onBeforeUpdate",new Q),y(this,"onDisposed",new Q),y(this,"list",new ot.jp),y(this,"enabled",!0),t.add(Gc.uuid,this)}create(){const t=new Tf(this.components),e=t.uuid;if(this.list.has(e))throw new Error("There is already a world with this name!");return this.list.set(e,t),t}delete(t){if(!this.list.has(t.uuid))throw new Error("The provided world is not found in the list!");this.list.delete(t.uuid),t.dispose()}dispose(){this.enabled=!1;for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger()}update(t){if(this.enabled)for(const[e,i]of this.list)i.update(t)}};y(ll,"uuid","fdb61dc4-2ec1-4966-b83d-54ea795fad4a");let an=ll;class Of extends Wi{constructor(){super(...arguments),y(this,"_config",{visible:{value:!0,type:"Boolean"},color:{value:new p.Q1f,type:"Color"},primarySize:{type:"Number",interpolable:!0,value:1,min:0,max:1e3},secondarySize:{type:"Number",interpolable:!0,value:10,min:0,max:1e3},distance:{type:"Number",interpolable:!0,value:500,min:0,max:500}})}get visible(){return this._config.visible.value}set visible(t){this._config.visible.value=t,this._component.visible=t}get color(){return this._config.color.value}set color(t){this._config.color.value=t,this._component.material.uniforms.uColor.value=t,this._component.material.uniformsNeedUpdate=!0}get primarySize(){return this._config.primarySize.value}set primarySize(t){this._config.primarySize.value=t,this._component.material.uniforms.uSize1.value=t,this._component.material.uniformsNeedUpdate=!0}get secondarySize(){return this._config.secondarySize.value}set secondarySize(t){this._config.secondarySize.value=t,this._component.material.uniforms.uSize2.value=t,this._component.material.uniformsNeedUpdate=!0}get distance(){return this._config.distance.value}set distance(t){this._config.distance.value=t,this._component.material.uniforms.uDistance.value=t,this._component.material.uniformsNeedUpdate=!0}}class zf{constructor(t,e){y(this,"onDisposed",new Q),y(this,"onSetup",new Q),y(this,"isSetup",!1),y(this,"world"),y(this,"components"),y(this,"config"),y(this,"_defaultConfig",{visible:!0,color:new p.Q1f(12303291),primarySize:1,secondarySize:10,distance:500}),y(this,"three"),y(this,"_fade",3),y(this,"updateZoom",()=>{this.world.camera instanceof hs&&(this.material.uniforms.uZoom.value=this.world.camera.three.zoom)}),this.world=e;const{color:i,primarySize:s,secondarySize:n,distance:o}=this._defaultConfig;this.components=t,this.config=new Of(this,this.components,"Grid");const a=new p.bdM(2,2,1,1),l=new p.BKk({side:p.$EB,uniforms:{uSize1:{value:s},uSize2:{value:n},uColor:{value:i},uDistance:{value:o},uFade:{value:this._fade},uZoom:{value:1}},transparent:!0,vertexShader:"\n \n varying vec3 worldPosition;\n \n uniform float uDistance;\n \n void main() {\n \n vec3 pos = position.xzy * uDistance;\n pos.xz += cameraPosition.xz;\n \n worldPosition = pos;\n \n gl_Position = projectionMatrix * modelViewMatrix * vec4(pos, 1.0);\n \n }\n ",fragmentShader:"\n \n varying vec3 worldPosition;\n \n uniform float uZoom;\n uniform float uFade;\n uniform float uSize1;\n uniform float uSize2;\n uniform vec3 uColor;\n uniform float uDistance;\n \n \n \n float getGrid(float size) {\n \n vec2 r = worldPosition.xz / size;\n \n \n vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);\n float line = min(grid.x, grid.y);\n \n \n return 1.0 - min(line, 1.0);\n }\n \n void main() {\n \n \n float d = 1.0 - min(distance(cameraPosition.xz, worldPosition.xz) / uDistance, 1.0);\n \n float g1 = getGrid(uSize1);\n float g2 = getGrid(uSize2);\n \n // Ortho camera fades the grid away when zooming out\n float minZoom = step(0.2, uZoom);\n float zoomFactor = pow(min(uZoom, 1.), 2.) * minZoom;\n \n gl_FragColor = vec4(uColor.rgb, mix(g2, g1, g1) * pow(d, uFade));\n gl_FragColor.a = mix(0.5 * gl_FragColor.a, gl_FragColor.a, g2) * zoomFactor;\n \n if ( gl_FragColor.a <= 0.0 ) discard;\n \n \n }\n \n ",extensions:{derivatives:!0}});this.three=new p.eaF(a,l),this.three.frustumCulled=!1,e.scene.three.add(this.three),this.setupEvents(!0)}get visible(){return this.three.visible}set visible(t){this.three.visible=t,t?this.world.scene.three.add(this.three):this.three.removeFromParent()}get material(){return this.three.material}get fade(){return 3===this._fade}set fade(t){this._fade=t?3:0,this.material.uniforms.uFade.value=this._fade}setup(t){const e={...this._defaultConfig,...t};this.config.visible=!0,this.config.color=e.color,this.config.primarySize=e.primarySize,this.config.secondarySize=e.secondarySize,this.config.distance=e.distance,this.isSetup=!0,this.onSetup.trigger()}dispose(){this.setupEvents(!1),this.components.get(Ps).list.delete(this.config.uuid),this.components.get(bi).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset(),this.world=null,this.components=null}setupEvents(t){if(this.world.isDisposing||!(this.world.camera instanceof hs))return;const e=this.world.camera.controls;t?e.addEventListener("update",this.updateZoom):e.removeEventListener("update",this.updateZoom)}}y(class Yc extends At{constructor(t){super(t),y(this,"list",new Map),y(this,"onDisposed",new Q),y(this,"enabled",!0),t.add(Yc.uuid,this)}create(t){if(this.list.has(t.uuid))throw new Error("This world already has a grid!");const e=new zf(this.components,t);return this.list.set(t.uuid,e),t.onDisposed.add(()=>{this.delete(t)}),e}delete(t){const e=this.list.get(t.uuid);e&&e.dispose(),this.list.delete(t.uuid)}dispose(){for(const[t,e]of this.list)e.dispose();this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}},"uuid","d1e814d5-b81c-4452-87a2-f039375e0489");const cl=class Zc{constructor(){y(this,"onDisposed",new Q),y(this,"list",new ot.jp),y(this,"enabled",!1),y(this,"_timer"),y(this,"onInit",new Q),y(this,"update",()=>{if(!this.enabled)return;this._timer.update();const t=this._timer.getDelta();for(const[e,i]of this.list)i.enabled&&i.isUpdateable()&&i.update(t);requestAnimationFrame(this.update)}),this._timer=new p.M4G,Zc.setupBVH()}add(t,e){if(this.list.has(t))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");ie.validate(t),this.list.set(t,e)}get(t){var e;const i=t.uuid;if(!this.list.has(i)){const s=new t(this);return null!=(e=s.isDisposeable)&&e.call(s)&&s.onDisposed.add(()=>this.list.delete(i)),this.list.has(i)||this.add(i,s),s}return this.list.get(i)}init(){this.enabled=!0;for(const[t,e]of this.list.entries())e.enabled=!0;this._timer.reset(),this.update(),this.onInit.trigger()}dispose(){let t;this.enabled=!1;for(const[e,i]of this.list)i.enabled=!1,e!==ft.uuid?i.isDisposeable()&&i.dispose():t=i;t?.dispose(),this._timer.dispose(),this.onDisposed.trigger()}static setupBVH(){p.LoY.prototype.computeBoundsTree=Pd,p.LoY.prototype.disposeBoundsTree=Sd,p.eaF.prototype.raycast=Pa,p.DXC.prototype.raycast=Pa}};y(cl,"release","2.4.3");let Ar=cl;class Df{constructor(t){y(this,"enabled",!1),y(this,"id","FirstPerson"),this.camera=t}set(t){if(this.enabled=t,t){if("Perspective"!==this.camera.projection.current)return void this.camera.set("Orbit");this.setupFirstPersonCamera()}}setupFirstPersonCamera(){const t=this.camera.controls,e=new p.Pq0;t.distance--,t.getPosition(e),t.minDistance=1,t.maxDistance=1,t.distance=1,t.moveTo(e.x,e.y,e.z),t.truckSpeed=50,t.mouseButtons.wheel=Zt.ACTION.DOLLY,t.touches.two=Zt.ACTION.TOUCH_ZOOM_TRUCK}}class kf{constructor(t){y(this,"enabled",!0),y(this,"id","Orbit"),this.camera=t,this.activateOrbitControls()}set(t){this.enabled=t,t&&this.activateOrbitControls()}activateOrbitControls(){const t=this.camera.controls;t.minDistance=1,t.maxDistance=300;const e=new p.Pq0;t.getPosition(e);const i=e.length();t.distance=i,t.truckSpeed=2;const{rotation:s}=this.camera.three,n=new p.Pq0(0,0,-1).applyEuler(s),o=e.addScaledVector(n,i);t.moveTo(o.x,o.y,o.z)}}class Lf{constructor(t){y(this,"enabled",!1),y(this,"id","Plan"),y(this,"mouseAction1"),y(this,"mouseAction2"),y(this,"mouseInitialized",!1),y(this,"defaultAzimuthSpeed"),y(this,"defaultPolarSpeed"),this.camera=t,this.defaultAzimuthSpeed=t.controls.azimuthRotateSpeed,this.defaultPolarSpeed=t.controls.polarRotateSpeed}set(t){this.enabled=t;const e=this.camera.controls;e.azimuthRotateSpeed=t?0:this.defaultAzimuthSpeed,e.polarRotateSpeed=t?0:this.defaultPolarSpeed,this.mouseInitialized||(this.mouseAction1=e.touches.one,this.mouseAction2=e.touches.two,this.mouseInitialized=!0),t?(e.mouseButtons.left=Zt.ACTION.TRUCK,e.touches.one=Zt.ACTION.TOUCH_TRUCK,e.touches.two=Zt.ACTION.TOUCH_ZOOM):(e.mouseButtons.left=Zt.ACTION.ROTATE,e.touches.one=this.mouseAction1,e.touches.two=this.mouseAction2)}}class Nf{constructor(t){y(this,"onChanged",new Q),y(this,"current","Perspective"),y(this,"camera"),y(this,"matchOrthoDistanceEnabled",!1),y(this,"_component"),y(this,"_previousDistance",-1),this._component=t,this.camera=t.three}set(t){var e=this;return(0,G.A)(function*(){e.current!==t&&("Orthographic"===t?e.setOrthoCamera():yield e.setPerspectiveCamera(),e.onChanged.trigger(e.camera))})()}toggle(){var t=this;return(0,G.A)(function*(){const i="Perspective"===t.current?"Orthographic":"Perspective";yield t.set(i)})()}setOrthoCamera(){if(null===this._component.mode||"FirstPerson"===this._component.mode.id)return;this._previousDistance=this._component.controls.distance,this._component.controls.distance=200;const t=this.getPerspectiveDims();if(!t)return;const{width:e,height:i}=t;this.setupOrthoCamera(i,e),this.camera=this._component.threeOrtho,this.current="Orthographic"}getPerspectiveDims(){const t=this._component.currentWorld;if(!t||!t.renderer)return null;const e=new p.Pq0;this._component.threePersp.getWorldDirection(e);const i=new p.Pq0;this._component.controls.getTarget(i);const n=i.clone().sub(this._component.threePersp.position).dot(e),o=t.renderer.getSize(),a=o.x/o.y,c=2*n*Math.atan(this._component.threePersp.fov*(Math.PI/180)/2);return{width:c*a,height:c}}setupOrthoCamera(t,e){this._component.controls.mouseButtons.wheel=Zt.ACTION.ZOOM,this._component.controls.mouseButtons.middle=Zt.ACTION.ZOOM;const i=this._component.threePersp,s=this._component.threeOrtho;s.zoom=1,s.left=e/-2,s.right=e/2,s.top=t/2,s.bottom=t/-2,s.updateProjectionMatrix(),s.position.copy(i.position),s.quaternion.copy(i.quaternion),this._component.controls.camera=s}getDistance(){const e=this._component.threeOrtho;return(e.top-e.bottom)/e.zoom/(2*Math.atan(this._component.threePersp.fov*(Math.PI/180)/2))}setPerspectiveCamera(){var t=this;return(0,G.A)(function*(){t._component.controls.mouseButtons.wheel=Zt.ACTION.DOLLY,t._component.controls.mouseButtons.middle=Zt.ACTION.DOLLY;const e=t._component.threePersp,i=t._component.threeOrtho;e.position.copy(i.position),e.quaternion.copy(i.quaternion),t._component.controls.mouseButtons.wheel=Zt.ACTION.DOLLY,t._component.controls.distance=t.matchOrthoDistanceEnabled?t.getDistance():t._previousDistance,yield t._component.controls.zoomTo(1),e.updateProjectionMatrix(),t._component.controls.camera=e,t.camera=e,t.current="Perspective"})()}}class ln extends hs{constructor(t){super(t),y(this,"projection"),y(this,"threeOrtho"),y(this,"threePersp"),y(this,"_userInputButtons",{}),y(this,"_frustumSize",50),y(this,"_navigationModes",new Map),y(this,"_mode",null),y(this,"previousSize",null),this.threePersp=this.three,this.threeOrtho=this.newOrthoCamera(),this.projection=new Nf(this),this.onAspectUpdated.add(()=>{this.setOrthoPerspCameraAspect()}),this.projection.onChanged.add(e=>{this.three=e,this.updateAspect()}),this.worlds.onItemSet.add(()=>{this._navigationModes.clear(),this._navigationModes.set("Orbit",new kf(this)),this._navigationModes.set("FirstPerson",new Df(this)),this._navigationModes.set("Plan",new Lf(this)),this._mode=this._navigationModes.get("Orbit"),this.mode.set(!0,{preventTargetAdjustment:!0}),this.currentWorld&&this.currentWorld.renderer&&(this.previousSize=this.currentWorld.renderer.getSize().clone())}),this.worlds.onItemDeleted.add(()=>{this._navigationModes.clear()})}get mode(){if(!this._mode)throw new Error("Mode not found, camera not initialized");return this._mode}dispose(){super.dispose(),this.threeOrtho.removeFromParent()}set(t){if(null!==this.mode&&this.mode.id!==t){if(this.mode.set(!1),!this._navigationModes.has(t))throw new Error("The specified mode does not exist!");this._mode=this._navigationModes.get(t),this.mode.set(!0)}}fit(t){var e=this;return(0,G.A)(function*(i,s=1.5){if(!e.enabled)return;const n=Number.MAX_VALUE,o=Number.MIN_VALUE,a=new p.Pq0(n,n,n),l=new p.Pq0(o,o,o);for(const m of i){const w=(new p.NRn).setFromObject(m);w.min.x<a.x&&(a.x=w.min.x),w.min.y<a.y&&(a.y=w.min.y),w.min.z<a.z&&(a.z=w.min.z),w.max.x>l.x&&(l.x=w.max.x),w.max.y>l.y&&(l.y=w.max.y),w.max.z>l.z&&(l.z=w.max.z)}const c=new p.NRn(a,l),h=e.components.get(ft);if(h.initialized)for(const[,m]of h.list){const w=m.box;w.min.x<a.x&&(a.x=w.min.x),w.min.y<a.y&&(a.y=w.min.y),w.min.z<a.z&&(a.z=w.min.z),w.max.x>l.x&&(l.x=w.max.x),w.max.y>l.y&&(l.y=w.max.y),w.max.z>l.z&&(l.z=w.max.z)}const u=new p.Pq0;c.getSize(u);const f=new p.Pq0;c.getCenter(f);const d=Math.max(u.x,u.y,u.z)*s,_=new p.iyt(f,d);yield e.controls.fitToSphere(_,!0)}).apply(this,arguments)}setUserInput(t){t?this.enableUserInput():this.disableUserInput()}addCustomNavigationMode(t){this._navigationModes.set(t.id,t)}disableUserInput(){this._userInputButtons.left=this.controls.mouseButtons.left,this._userInputButtons.right=this.controls.mouseButtons.right,this._userInputButtons.middle=this.controls.mouseButtons.middle,this._userInputButtons.wheel=this.controls.mouseButtons.wheel,this.controls.mouseButtons.left=0,this.controls.mouseButtons.right=0,this.controls.mouseButtons.middle=0,this.controls.mouseButtons.wheel=0}enableUserInput(){0!==Object.keys(this._userInputButtons).length&&(this.controls.mouseButtons.left=this._userInputButtons.left,this.controls.mouseButtons.right=this._userInputButtons.right,this.controls.mouseButtons.middle=this._userInputButtons.middle,this.controls.mouseButtons.wheel=this._userInputButtons.wheel)}newOrthoCamera(){const t=window.innerWidth/window.innerHeight;return new p.qUd(this._frustumSize*t/-2,this._frustumSize*t/2,this._frustumSize/2,this._frustumSize/-2,.1,1e3)}setOrthoPerspCameraAspect(){if(!this.currentWorld||!this.currentWorld.renderer||!this.previousSize)return;const t=this.currentWorld.renderer.getSize(),o=this.threeOrtho.top*(t.y/this.previousSize.y),a=this.threeOrtho.right*(t.x/this.previousSize.x);this.threeOrtho.left=-a,this.threeOrtho.right=a,this.threeOrtho.top=o,this.threeOrtho.bottom=-o,this.threeOrtho.updateProjectionMatrix(),this.previousSize.copy(t)}}var cn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Bf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function hn(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 hl={exports:{}};hl.exports=function e(i,s,n){function o(c,h){if(!s[c]){if(!i[c]){if(!h&&hn)return hn(c);if(a)return a(c,!0);var f=new Error("Cannot find module '"+c+"'");throw f.code="MODULE_NOT_FOUND",f}var d=s[c]={exports:{}};i[c][0].call(d.exports,function(_){return o(i[c][1][_]||_)},d,d.exports,e,i,s,n)}return s[c].exports}for(var a=hn,l=0;l<n.length;l++)o(n[l]);return o}({1:[function(e,i,s){var n=e("./utils"),o=e("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.encode=function(l){for(var c,h,u,d,_,m,w=[],g=0,v=l.length,T=v,C="string"!==n.getTypeOf(l);g<l.length;)T=v-g,u=C?(c=l[g++],h=g<v?l[g++]:0,g<v?l[g++]:0):(c=l.charCodeAt(g++),h=g<v?l.charCodeAt(g++):0,g<v?l.charCodeAt(g++):0),d=(3&c)<<4|h>>4,_=1<T?(15&h)<<2|u>>6:64,m=2<T?63&u:64,w.push(a.charAt(c>>2)+a.charAt(d)+a.charAt(_)+a.charAt(m));return w.join("")},s.decode=function(l){var c,h,u,f,d,_,m=0,w=0,g="data:";if(l.substr(0,5)===g)throw new Error("Invalid base64 input, it looks like a data url.");var v,T=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&T--,l.charAt(l.length-2)===a.charAt(64)&&T--,T%1!=0)throw new Error("Invalid base64 input, bad content length.");for(v=o.uint8array?new Uint8Array(0|T):new Array(0|T);m<l.length;)c=a.indexOf(l.charAt(m++))<<2|(f=a.indexOf(l.charAt(m++)))>>4,h=(15&f)<<4|(d=a.indexOf(l.charAt(m++)))>>2,u=(3&d)<<6|(_=a.indexOf(l.charAt(m++))),v[w++]=c,64!==d&&(v[w++]=h),64!==_&&(v[w++]=u);return v}},{"./support":30,"./utils":32}],2:[function(e,i,s){var n=e("./external"),o=e("./stream/DataWorker"),a=e("./stream/Crc32Probe"),l=e("./stream/DataLengthProbe");function c(h,u,f,d,_){this.compressedSize=h,this.uncompressedSize=u,this.crc32=f,this.compression=d,this.compressedContent=_}c.prototype={getContentWorker:function(){var h=new o(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),u=this;return h.on("end",function(){if(this.streamInfo.data_length!==u.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),h},getCompressedWorker:function(){return new o(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(h,u,f){return h.pipe(new a).pipe(new l("uncompressedSize")).pipe(u.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression",u)},i.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(e,i,s){var n=e("./stream/GenericWorker");s.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},s.DEFLATE=e("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(e,i,s){var n=e("./utils"),o=function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var h=0;h<8;h++)a=1&a?3988292384^a>>>1:a>>>1;l[c]=a}return l}();i.exports=function(a,l){return void 0!==a&&a.length?"string"!==n.getTypeOf(a)?function(c,h,u){var d=o,_=0+u;c^=-1;for(var m=0;m<_;m++)c=c>>>8^d[255&(c^h[m])];return-1^c}(0|l,a,a.length):function(c,h,u){var d=o,_=0+u;c^=-1;for(var m=0;m<_;m++)c=c>>>8^d[255&(c^h.charCodeAt(m))];return-1^c}(0|l,a,a.length):0}},{"./utils":32}],5:[function(e,i,s){s.base64=!1,s.binary=!1,s.dir=!1,s.createFolders=!0,s.date=null,s.compression=null,s.compressionOptions=null,s.comment=null,s.unixPermissions=null,s.dosPermissions=null},{}],6:[function(e,i,s){var n;n=typeof Promise<"u"?Promise:e("lie"),i.exports={Promise:n}},{lie:37}],7:[function(e,i,s){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",o=e("pako"),a=e("./utils"),l=e("./stream/GenericWorker"),c=n?"uint8array":"array";function h(u,f){l.call(this,"FlateWorker/"+u),this._pako=null,this._pakoAction=u,this._pakoOptions=f,this.meta={}}s.magic="\b\0",a.inherits(h,l),h.prototype.processChunk=function(u){this.meta=u.meta,null===this._pako&&this._createPako(),this._pako.push(a.transformTo(c,u.data),!1)},h.prototype.flush=function(){l.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new o[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var u=this;this._pako.onData=function(f){u.push({data:f,meta:u.meta})}},s.compressWorker=function(u){return new h("Deflate",u)},s.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(e,i,s){function n(d,_){var m,w="";for(m=0;m<_;m++)w+=String.fromCharCode(255&d),d>>>=8;return w}function o(d,_,m,w,g,v){var T,C,S=d.file,M=d.compression,A=v!==c.utf8encode,O=a.transformTo("string",v(S.name)),I=a.transformTo("string",c.utf8encode(S.name)),D=S.comment,B=a.transformTo("string",v(D)),E=a.transformTo("string",c.utf8encode(D)),L=I.length!==S.name.length,x=E.length!==D.length,N="",Y="",q="",ct=S.dir,Z=S.date,at={crc32:0,compressedSize:0,uncompressedSize:0};_&&!m||(at.crc32=d.crc32,at.compressedSize=d.compressedSize,at.uncompressedSize=d.uncompressedSize);var F=0;_&&(F|=8),A||!L&&!x||(F|=2048);var J,St,V=0,nt=0;ct&&(V|=16),"UNIX"===g?(nt=798,V|=(St=J=S.unixPermissions,J||(St=ct?16893:33204),(65535&St)<<16)):(nt=20,V|=function(J){return 63&(J||0)}(S.dosPermissions)),T=Z.getUTCHours(),T<<=6,T|=Z.getUTCMinutes(),T<<=5,T|=Z.getUTCSeconds()/2,C=Z.getUTCFullYear()-1980,C<<=4,C|=Z.getUTCMonth()+1,C<<=5,C|=Z.getUTCDate(),L&&(Y=n(1,1)+n(h(O),4)+I,N+="up"+n(Y.length,2)+Y),x&&(q=n(1,1)+n(h(B),4)+E,N+="uc"+n(q.length,2)+q);var it="";return it+="\n\0",it+=n(F,2),it+=M.magic,it+=n(T,2),it+=n(C,2),it+=n(at.crc32,4),it+=n(at.compressedSize,4),it+=n(at.uncompressedSize,4),it+=n(O.length,2),it+=n(N.length,2),{fileRecord:u.LOCAL_FILE_HEADER+it+O+N,dirRecord:u.CENTRAL_FILE_HEADER+n(nt,2)+it+n(B.length,2)+"\0\0\0\0"+n(V,4)+n(w,4)+O+N+B}}var a=e("../utils"),l=e("../stream/GenericWorker"),c=e("../utf8"),h=e("../crc32"),u=e("../signature");function f(d,_,m,w){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=_,this.zipPlatform=m,this.encodeFileName=w,this.streamFiles=d,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}a.inherits(f,l),f.prototype.push=function(d){var _=d.meta.percent||0,m=this.entriesCount,w=this._sources.length;this.accumulate?this.contentBuffer.push(d):(this.bytesWritten+=d.data.length,l.prototype.push.call(this,{data:d.data,meta:{currentFile:this.currentFile,percent:m?(_+100*(m-w-1))/m:100}}))},f.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var _=this.streamFiles&&!d.file.dir;if(_){var m=o(d,_,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:m.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(d){this.accumulate=!1;var w,_=this.streamFiles&&!d.file.dir,m=o(d,_,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(m.dirRecord),_)this.push({data:(w=d,u.DATA_DESCRIPTOR+n(w.crc32,4)+n(w.compressedSize,4)+n(w.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:m.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var d=this.bytesWritten,_=0;_<this.dirRecords.length;_++)this.push({data:this.dirRecords[_],meta:{percent:100}});var g,v,T,M,w=(g=this.dirRecords.length,v=this.bytesWritten-d,T=d,M=a.transformTo("string",(0,this.encodeFileName)(this.zipComment)),u.CENTRAL_DIRECTORY_END+"\0\0\0\0"+n(g,2)+n(g,2)+n(v,4)+n(T,4)+n(M.length,2)+M);this.push({data:w,meta:{percent:100}})},f.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},f.prototype.registerPrevious=function(d){this._sources.push(d);var _=this;return d.on("data",function(m){_.processChunk(m)}),d.on("end",function(){_.closedSource(_.previous.streamInfo),_._sources.length?_.prepareNextSource():_.end()}),d.on("error",function(m){_.error(m)}),this},f.prototype.resume=function(){return!!l.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},f.prototype.error=function(d){var _=this._sources;if(!l.prototype.error.call(this,d))return!1;for(var m=0;m<_.length;m++)try{_[m].error(d)}catch{}return!0},f.prototype.lock=function(){l.prototype.lock.call(this);for(var d=this._sources,_=0;_<d.length;_++)d[_].lock()},i.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(e,i,s){var n=e("../compressions"),o=e("./ZipFileWorker");s.generateWorker=function(a,l,c){var h=new o(l.streamFiles,c,l.platform,l.encodeFileName),u=0;try{a.forEach(function(f,d){u++;var _=function(v,T){var C=v||T,S=n[C];if(!S)throw new Error(C+" is not a valid compression method !");return S}(d.options.compression,l.compression),w=d.dir,g=d.date;d._compressWorker(_,d.options.compressionOptions||l.compressionOptions||{}).withStreamInfo("file",{name:f,dir:w,date:g,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(h)}),h.entriesCount=u}catch(f){h.error(f)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(e,i,s){function n(){if(!(this instanceof n))return new n;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var o=new n;for(var a in this)"function"!=typeof this[a]&&(o[a]=this[a]);return o}}(n.prototype=e("./object")).loadAsync=e("./load"),n.support=e("./support"),n.defaults=e("./defaults"),n.version="3.10.1",n.loadAsync=function(o,a){return(new n).loadAsync(o,a)},n.external=e("./external"),i.exports=n},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(e,i,s){var n=e("./utils"),o=e("./external"),a=e("./utf8"),l=e("./zipEntries"),c=e("./stream/Crc32Probe"),h=e("./nodejsUtils");function u(f){return new o.Promise(function(d,_){var m=f.decompressed.getContentWorker().pipe(new c);m.on("error",function(w){_(w)}).on("end",function(){m.streamInfo.crc32!==f.decompressed.crc32?_(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(f,d){var _=this;return d=n.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),h.isNode&&h.isStream(f)?o.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):n.prepareContent("the loaded zip file",f,!0,d.optimizedBinaryString,d.base64).then(function(m){var w=new l(d);return w.load(m),w}).then(function(m){var w=[o.Promise.resolve(m)],g=m.files;if(d.checkCRC32)for(var v=0;v<g.length;v++)w.push(u(g[v]));return o.Promise.all(w)}).then(function(m){for(var w=m.shift(),g=w.files,v=0;v<g.length;v++){var T=g[v],C=T.fileNameStr,S=n.resolve(T.fileNameStr);_.file(S,T.decompressed,{binary:!0,optimizedBinaryString:!0,date:T.date,dir:T.dir,comment:T.fileCommentStr.length?T.fileCommentStr:null,unixPermissions:T.unixPermissions,dosPermissions:T.dosPermissions,createFolders:d.createFolders}),T.dir||(_.file(S).unsafeOriginalName=C)}return w.zipComment.length&&(_.comment=w.zipComment),_})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(e,i,s){var n=e("../utils"),o=e("../stream/GenericWorker");function a(l,c){o.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}n.inherits(a,o),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(h){c.push({data:h,meta:{percent:0}})}).on("error",function(h){c.isPaused?this.generatedError=h:c.error(h)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!o.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(e,i,s){var n=e("readable-stream").Readable;function o(a,l,c){n.call(this,l),this._helper=a;var h=this;a.on("data",function(u,f){h.push(u)||h._helper.pause(),c&&c(f)}).on("error",function(u){h.emit("error",u)}).on("end",function(){h.push(null)})}e("../utils").inherits(o,n),o.prototype._read=function(){this._helper.resume()},i.exports=o},{"../utils":32,"readable-stream":16}],14:[function(e,i,s){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(n,o){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(n,o);if("number"==typeof n)throw new Error('The "data" argument must not be a number');return new Buffer(n,o)},allocBuffer:function(n){if(Buffer.alloc)return Buffer.alloc(n);var o=new Buffer(n);return o.fill(0),o},isBuffer:function(n){return Buffer.isBuffer(n)},isStream:function(n){return n&&"function"==typeof n.on&&"function"==typeof n.pause&&"function"==typeof n.resume}}},{}],15:[function(e,i,s){function n(S,M,A){var O,I=a.getTypeOf(M),D=a.extend(A||{},h);D.date=D.date||new Date,null!==D.compression&&(D.compression=D.compression.toUpperCase()),"string"==typeof D.unixPermissions&&(D.unixPermissions=parseInt(D.unixPermissions,8)),D.unixPermissions&&16384&D.unixPermissions&&(D.dir=!0),D.dosPermissions&&16&D.dosPermissions&&(D.dir=!0),D.dir&&(S=g(S)),D.createFolders&&(O=w(S))&&v.call(this,O,!0),A&&void 0!==A.binary||(D.binary=!("string"===I&&!1===D.binary&&!1===D.base64)),(M instanceof u&&0===M.uncompressedSize||D.dir||!M||0===M.length)&&(D.base64=!1,D.binary=!0,M="",D.compression="STORE",I="string");var E;E=M instanceof u||M instanceof l?M:_.isNode&&_.isStream(M)?new m(S,M):a.prepareContent(S,M,D.binary,D.optimizedBinaryString,D.base64);var L=new f(S,E,D);this.files[S]=L}var o=e("./utf8"),a=e("./utils"),l=e("./stream/GenericWorker"),c=e("./stream/StreamHelper"),h=e("./defaults"),u=e("./compressedObject"),f=e("./zipObject"),d=e("./generate"),_=e("./nodejsUtils"),m=e("./nodejs/NodejsStreamInputAdapter"),w=function(S){"/"===S.slice(-1)&&(S=S.substring(0,S.length-1));var M=S.lastIndexOf("/");return 0<M?S.substring(0,M):""},g=function(S){return"/"!==S.slice(-1)&&(S+="/"),S},v=function(S,M){return M=void 0!==M?M:h.createFolders,S=g(S),this.files[S]||n.call(this,S,null,{dir:!0,createFolders:M}),this.files[S]};function T(S){return"[object RegExp]"===Object.prototype.toString.call(S)}var C={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(S){var M,A,O;for(M in this.files)O=this.files[M],(A=M.slice(this.root.length,M.length))&&M.slice(0,this.root.length)===this.root&&S(A,O)},filter:function(S){var M=[];return this.forEach(function(A,O){S(A,O)&&M.push(O)}),M},file:function(S,M,A){if(1!==arguments.length)return n.call(this,S=this.root+S,M,A),this;if(T(S)){var O=S;return this.filter(function(D,B){return!B.dir&&O.test(D)})}var I=this.files[this.root+S];return I&&!I.dir?I:null},folder:function(S){if(!S)return this;if(T(S))return this.filter(function(I,D){return D.dir&&S.test(I)});var A=v.call(this,this.root+S),O=this.clone();return O.root=A.name,O},remove:function(S){var M=this.files[S=this.root+S];if(M||("/"!==S.slice(-1)&&(S+="/"),M=this.files[S]),M&&!M.dir)delete this.files[S];else for(var A=this.filter(function(I,D){return D.name.slice(0,S.length)===S}),O=0;O<A.length;O++)delete this.files[A[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(S){var M,A={};try{if((A=a.extend(S||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:o.utf8encode})).type=A.type.toLowerCase(),A.compression=A.compression.toUpperCase(),"binarystring"===A.type&&(A.type="string"),!A.type)throw new Error("No output type specified.");a.checkSupport(A.type),"darwin"!==A.platform&&"freebsd"!==A.platform&&"linux"!==A.platform&&"sunos"!==A.platform||(A.platform="UNIX"),"win32"===A.platform&&(A.platform="DOS"),M=d.generateWorker(this,A,A.comment||this.comment||"")}catch(I){(M=new l("error")).error(I)}return new c(M,A.type||"string",A.mimeType)},generateAsync:function(S,M){return this.generateInternalStream(S).accumulate(M)},generateNodeStream:function(S,M){return(S=S||{}).type||(S.type="nodebuffer"),this.generateInternalStream(S).toNodejsStream(M)}};i.exports=C},{"./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(e,i,s){i.exports=e("stream")},{stream:void 0}],17:[function(e,i,s){var n=e("./DataReader");function o(a){n.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}e("../utils").inherits(o,n),o.prototype.byteAt=function(a){return this.data[this.zero+a]},o.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),u=a.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===l&&this.data[f+1]===c&&this.data[f+2]===h&&this.data[f+3]===u)return f-this.zero;return-1},o.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),h=a.charCodeAt(2),u=a.charCodeAt(3),f=this.readData(4);return l===f[0]&&c===f[1]&&h===f[2]&&u===f[3]},o.prototype.readData=function(a){if(this.checkOffset(a),0===a)return[];var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=o},{"../utils":32,"./DataReader":18}],18:[function(e,i,s){var n=e("../utils");function o(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}o.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return n.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))}},i.exports=o},{"../utils":32}],19:[function(e,i,s){var n=e("./Uint8ArrayReader");function o(a){n.call(this,a)}e("../utils").inherits(o,n),o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=o},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(e,i,s){var n=e("./DataReader");function o(a){n.call(this,a)}e("../utils").inherits(o,n),o.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},o.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},o.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},o.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=o},{"../utils":32,"./DataReader":18}],21:[function(e,i,s){var n=e("./ArrayReader");function o(a){n.call(this,a)}e("../utils").inherits(o,n),o.prototype.readData=function(a){if(this.checkOffset(a),0===a)return new Uint8Array(0);var l=this.data.subarray(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=o},{"../utils":32,"./ArrayReader":17}],22:[function(e,i,s){var n=e("../utils"),o=e("../support"),a=e("./ArrayReader"),l=e("./StringReader"),c=e("./NodeBufferReader"),h=e("./Uint8ArrayReader");i.exports=function(u){var f=n.getTypeOf(u);return n.checkSupport(f),"string"!==f||o.uint8array?"nodebuffer"===f?new c(u):o.uint8array?new h(n.transformTo("uint8array",u)):new a(n.transformTo("array",u)):new l(u)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(e,i,s){s.LOCAL_FILE_HEADER="PK\x03\x04",s.CENTRAL_FILE_HEADER="PK\x01\x02",s.CENTRAL_DIRECTORY_END="PK\x05\x06",s.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x06\x07",s.ZIP64_CENTRAL_DIRECTORY_END="PK\x06\x06",s.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(e,i,s){var n=e("./GenericWorker"),o=e("../utils");function a(l){n.call(this,"ConvertWorker to "+l),this.destType=l}o.inherits(a,n),a.prototype.processChunk=function(l){this.push({data:o.transformTo(this.destType,l.data),meta:l.meta})},i.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(e,i,s){var n=e("./GenericWorker"),o=e("../crc32");function a(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}e("../utils").inherits(a,n),a.prototype.processChunk=function(l){this.streamInfo.crc32=o(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(e,i,s){var n=e("../utils"),o=e("./GenericWorker");function a(l){o.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}n.inherits(a,o),a.prototype.processChunk=function(l){l&&(this.streamInfo[this.propName]=(this.streamInfo[this.propName]||0)+l.data.length),o.prototype.processChunk.call(this,l)},i.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(e,i,s){var n=e("../utils"),o=e("./GenericWorker");function a(l){o.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(h){c.dataIsReady=!0,c.data=h,c.max=h&&h.length||0,c.type=n.getTypeOf(h),c.isPaused||c._tickAndRepeat()},function(h){c.error(h)})}n.inherits(a,o),a.prototype.cleanUp=function(){o.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!o.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,n.delay(this._tickAndRepeat,[],this)),!0)},a.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(n.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},a.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var l=null,c=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":l=this.data.substring(this.index,c);break;case"uint8array":l=this.data.subarray(this.index,c);break;case"array":case"nodebuffer":l=this.data.slice(this.index,c)}return this.index=c,this.push({data:l,meta:{percent:this.max?this.index/this.max*100:0}})},i.exports=a},{"../utils":32,"./GenericWorker":28}],28:[function(e,i,s){function n(o){this.name=o||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(o){this.emit("data",o)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(o){this.emit("error",o)}return!0},error:function(o){return!this.isFinished&&(this.isPaused?this.generatedError=o:(this.isFinished=!0,this.emit("error",o),this.previous&&this.previous.error(o),this.cleanUp()),!0)},on:function(o,a){return this._listeners[o].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(o,a){if(this._listeners[o])for(var l=0;l<this._listeners[o].length;l++)this._listeners[o][l].call(this,a)},pipe:function(o){return o.registerPrevious(this)},registerPrevious:function(o){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=o.streamInfo,this.mergeStreamInfo(),this.previous=o;var a=this;return o.on("data",function(l){a.processChunk(l)}),o.on("end",function(){a.end()}),o.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var o=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),o=!0),this.previous&&this.previous.resume(),!o},flush:function(){},processChunk:function(o){this.push(o)},withStreamInfo:function(o,a){return this.extraStreamInfo[o]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var o in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,o)&&(this.streamInfo[o]=this.extraStreamInfo[o])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var o="Worker "+this.name;return this.previous?this.previous+" -> "+o:o}},i.exports=n},{}],29:[function(e,i,s){var n=e("../utils"),o=e("./ConvertWorker"),a=e("./GenericWorker"),l=e("../base64"),c=e("../support"),h=e("../external"),u=null;if(c.nodestream)try{u=e("../nodejs/NodejsStreamOutputAdapter")}catch{}function d(_,m,w){var g=m;switch(m){case"blob":case"arraybuffer":g="uint8array";break;case"base64":g="string"}try{this._internalType=g,this._outputType=m,this._mimeType=w,n.checkSupport(g),this._worker=_.pipe(new o(g)),_.lock()}catch(v){this._worker=new a("error"),this._worker.error(v)}}d.prototype={accumulate:function(_){return function f(_,m){return new h.Promise(function(w,g){var v=[],T=_._internalType,C=_._outputType,S=_._mimeType;_.on("data",function(M,A){v.push(M),m&&m(A)}).on("error",function(M){v=[],g(M)}).on("end",function(){try{var M=function(A,O,I){switch(A){case"blob":return n.newBlob(n.transformTo("arraybuffer",O),I);case"base64":return l.encode(O);default:return n.transformTo(A,O)}}(C,function(A,O){var I,D=0,B=null,E=0;for(I=0;I<O.length;I++)E+=O[I].length;switch(A){case"string":return O.join("");case"array":return Array.prototype.concat.apply([],O);case"uint8array":for(B=new Uint8Array(E),I=0;I<O.length;I++)B.set(O[I],D),D+=O[I].length;return B;case"nodebuffer":return Buffer.concat(O);default:throw new Error("concat : unsupported type '"+A+"'")}}(T,v),S);w(M)}catch(A){g(A)}v=[]}).resume()})}(this,_)},on:function(_,m){var w=this;return this._worker.on(_,"data"===_?function(g){m.call(w,g.data,g.meta)}:function(){n.delay(m,arguments,w)}),this},resume:function(){return n.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(_){if(n.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new u(this,{objectMode:"nodebuffer"!==this._outputType},_)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(e,i,s){if(s.base64=!0,s.array=!0,s.string=!0,s.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",s.nodebuffer=typeof Buffer<"u",s.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")s.blob=!1;else{var n=new ArrayBuffer(0);try{s.blob=0===new Blob([n],{type:"application/zip"}).size}catch{try{var o=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);o.append(n),s.blob=0===o.getBlob("application/zip").size}catch{s.blob=!1}}}try{s.nodestream=!!e("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(e,i,s){for(var n=e("./utils"),o=e("./support"),a=e("./nodejsUtils"),l=e("./stream/GenericWorker"),c=new Array(256),h=0;h<256;h++)c[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;function u(){l.call(this,"utf-8 decode"),this.leftOver=null}function f(){l.call(this,"utf-8 encode")}c[254]=c[254]=1,s.utf8encode=function(d){return o.nodebuffer?a.newBufferFrom(d,"utf-8"):function(_){var m,w,g,v,T,C=_.length,S=0;for(v=0;v<C;v++)55296==(64512&(w=_.charCodeAt(v)))&&v+1<C&&56320==(64512&(g=_.charCodeAt(v+1)))&&(w=65536+(w-55296<<10)+(g-56320),v++),S+=w<128?1:w<2048?2:w<65536?3:4;for(m=o.uint8array?new Uint8Array(S):new Array(S),v=T=0;T<S;v++)55296==(64512&(w=_.charCodeAt(v)))&&v+1<C&&56320==(64512&(g=_.charCodeAt(v+1)))&&(w=65536+(w-55296<<10)+(g-56320),v++),w<128?m[T++]=w:(w<2048?m[T++]=192|w>>>6:(w<65536?m[T++]=224|w>>>12:(m[T++]=240|w>>>18,m[T++]=128|w>>>12&63),m[T++]=128|w>>>6&63),m[T++]=128|63&w);return m}(d)},s.utf8decode=function(d){return o.nodebuffer?n.transformTo("nodebuffer",d).toString("utf-8"):function(_){var m,w,g,v,T=_.length,C=new Array(2*T);for(m=w=0;m<T;)if((g=_[m++])<128)C[w++]=g;else if(4<(v=c[g]))C[w++]=65533,m+=v-1;else{for(g&=2===v?31:3===v?15:7;1<v&&m<T;)g=g<<6|63&_[m++],v--;1<v?C[w++]=65533:g<65536?C[w++]=g:(C[w++]=55296|(g-=65536)>>10&1023,C[w++]=56320|1023&g)}return C.length!==w&&(C.subarray?C=C.subarray(0,w):C.length=w),n.applyFromCharCode(C)}(d=n.transformTo(o.uint8array?"uint8array":"array",d))},n.inherits(u,l),u.prototype.processChunk=function(d){var _=n.transformTo(o.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(o.uint8array){var m=_;(_=new Uint8Array(m.length+this.leftOver.length)).set(this.leftOver,0),_.set(m,this.leftOver.length)}else _=this.leftOver.concat(_);this.leftOver=null}var w=function(v,T){var C;for((T=T||v.length)>v.length&&(T=v.length),C=T-1;0<=C&&128==(192&v[C]);)C--;return C<0||0===C?T:C+c[v[C]]>T?C:T}(_),g=_;w!==_.length&&(o.uint8array?(g=_.subarray(0,w),this.leftOver=_.subarray(w,_.length)):(g=_.slice(0,w),this.leftOver=_.slice(w,_.length))),this.push({data:s.utf8decode(g),meta:d.meta})},u.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=u,n.inherits(f,l),f.prototype.processChunk=function(d){this.push({data:s.utf8encode(d.data),meta:d.meta})},s.Utf8EncodeWorker=f},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(e,i,s){var n=e("./support"),o=e("./base64"),a=e("./nodejsUtils"),l=e("./external");function c(m){return m}function h(m,w){for(var g=0;g<m.length;++g)w[g]=255&m.charCodeAt(g);return w}e("setimmediate"),s.newBlob=function(m,w){s.checkSupport("blob");try{return new Blob([m],{type:w})}catch{try{var g=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return g.append(m),g.getBlob(w)}catch{throw new Error("Bug : can't construct the Blob.")}}};var u={stringifyByChunk:function(m,w,g){var v=[],T=0,C=m.length;if(C<=g)return String.fromCharCode.apply(null,m);for(;T<C;)v.push(String.fromCharCode.apply(null,"array"===w||"nodebuffer"===w?m.slice(T,Math.min(T+g,C)):m.subarray(T,Math.min(T+g,C)))),T+=g;return v.join("")},stringifyByChar:function(m){for(var w="",g=0;g<m.length;g++)w+=String.fromCharCode(m[g]);return w},applyCanBeUsed:{uint8array:function(){try{return n.uint8array&&1===String.fromCharCode.apply(null,new Uint8Array(1)).length}catch{return!1}}(),nodebuffer:function(){try{return n.nodebuffer&&1===String.fromCharCode.apply(null,a.allocBuffer(1)).length}catch{return!1}}()}};function f(m){var w=65536,g=s.getTypeOf(m),v=!0;if("uint8array"===g?v=u.applyCanBeUsed.uint8array:"nodebuffer"===g&&(v=u.applyCanBeUsed.nodebuffer),v)for(;1<w;)try{return u.stringifyByChunk(m,g,w)}catch{w=Math.floor(w/2)}return u.stringifyByChar(m)}function d(m,w){for(var g=0;g<m.length;g++)w[g]=m[g];return w}s.applyFromCharCode=f;var _={};_.string={string:c,array:function(m){return h(m,new Array(m.length))},arraybuffer:function(m){return _.string.uint8array(m).buffer},uint8array:function(m){return h(m,new Uint8Array(m.length))},nodebuffer:function(m){return h(m,a.allocBuffer(m.length))}},_.array={string:f,array:c,arraybuffer:function(m){return new Uint8Array(m).buffer},uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(m)}},_.arraybuffer={string:function(m){return f(new Uint8Array(m))},array:function(m){return d(new Uint8Array(m),new Array(m.byteLength))},arraybuffer:c,uint8array:function(m){return new Uint8Array(m)},nodebuffer:function(m){return a.newBufferFrom(new Uint8Array(m))}},_.uint8array={string:f,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return m.buffer},uint8array:c,nodebuffer:function(m){return a.newBufferFrom(m)}},_.nodebuffer={string:f,array:function(m){return d(m,new Array(m.length))},arraybuffer:function(m){return _.nodebuffer.uint8array(m).buffer},uint8array:function(m){return d(m,new Uint8Array(m.length))},nodebuffer:c},s.transformTo=function(m,w){if(w=w||"",!m)return w;s.checkSupport(m);var g=s.getTypeOf(w);return _[g][m](w)},s.resolve=function(m){for(var w=m.split("/"),g=[],v=0;v<w.length;v++){var T=w[v];"."===T||""===T&&0!==v&&v!==w.length-1||(".."===T?g.pop():g.push(T))}return g.join("/")},s.getTypeOf=function(m){return"string"==typeof m?"string":"[object Array]"===Object.prototype.toString.call(m)?"array":n.nodebuffer&&a.isBuffer(m)?"nodebuffer":n.uint8array&&m instanceof Uint8Array?"uint8array":n.arraybuffer&&m instanceof ArrayBuffer?"arraybuffer":void 0},s.checkSupport=function(m){if(!n[m.toLowerCase()])throw new Error(m+" is not supported by this platform")},s.MAX_VALUE_16BITS=65535,s.MAX_VALUE_32BITS=-1,s.pretty=function(m){var w,g,v="";for(g=0;g<(m||"").length;g++)v+="\\x"+((w=m.charCodeAt(g))<16?"0":"")+w.toString(16).toUpperCase();return v},s.delay=function(m,w,g){setImmediate(function(){m.apply(g||null,w||[])})},s.inherits=function(m,w){function g(){}g.prototype=w.prototype,m.prototype=new g},s.extend=function(){var m,w,g={};for(m=0;m<arguments.length;m++)for(w in arguments[m])Object.prototype.hasOwnProperty.call(arguments[m],w)&&void 0===g[w]&&(g[w]=arguments[m][w]);return g},s.prepareContent=function(m,w,g,v,T){return l.Promise.resolve(w).then(function(C){return n.blob&&(C instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(C)))&&typeof FileReader<"u"?new l.Promise(function(S,M){var A=new FileReader;A.onload=function(O){S(O.target.result)},A.onerror=function(O){M(O.target.error)},A.readAsArrayBuffer(C)}):C}).then(function(C){var M,S=s.getTypeOf(C);return S?("arraybuffer"===S?C=s.transformTo("uint8array",C):"string"===S&&(T?C=o.decode(C):g&&!0!==v&&(C=h(M=C,n.uint8array?new Uint8Array(M.length):new Array(M.length)))),C):l.Promise.reject(new Error("Can't read the data of '"+m+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(e,i,s){var n=e("./reader/readerFor"),o=e("./utils"),a=e("./signature"),l=e("./zipEntry"),c=e("./support");function h(u){this.files=[],this.loadOptions=u}h.prototype={checkSignature:function(u){if(!this.reader.readAndCheckSignature(u)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+o.pretty(f)+", expected "+o.pretty(u)+")")}},isSignature:function(u,f){var d=this.reader.index;this.reader.setIndex(u);var _=this.reader.readString(4)===f;return this.reader.setIndex(d),_},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var u=this.reader.readData(this.zipCommentLength),d=o.transformTo(c.uint8array?"uint8array":"array",u);this.zipComment=this.loadOptions.decodeFileName(d)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var u,f,d,_=this.zip64EndOfCentralSize-44;0<_;)u=this.reader.readInt(2),f=this.reader.readInt(4),d=this.reader.readData(f),this.zip64ExtensibleData[u]={id:u,length:f,value:d}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var u,f;for(u=0;u<this.files.length;u++)this.reader.setIndex((f=this.files[u]).localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var u;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(u=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(u);if(this.centralDirRecords!==this.files.length&&0!==this.centralDirRecords&&0===this.files.length)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var u=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(u<0)throw this.isSignature(0,a.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(u);var f=u;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===o.MAX_VALUE_16BITS||this.diskWithCentralDirStart===o.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===o.MAX_VALUE_16BITS||this.centralDirRecords===o.MAX_VALUE_16BITS||this.centralDirSize===o.MAX_VALUE_32BITS||this.centralDirOffset===o.MAX_VALUE_32BITS){if(this.zip64=!0,(u=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(u),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,a.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(a.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var d=this.centralDirOffset+this.centralDirSize;this.zip64&&(d+=20,d+=12+this.zip64EndOfCentralSize);var _=f-d;if(0<_)this.isSignature(f,a.CENTRAL_FILE_HEADER)||(this.reader.zero=_);else if(_<0)throw new Error("Corrupted zip: missing "+Math.abs(_)+" bytes.")},prepareReader:function(u){this.reader=n(u)},load:function(u){this.prepareReader(u),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(e,i,s){var n=e("./reader/readerFor"),o=e("./utils"),a=e("./compressedObject"),l=e("./crc32"),c=e("./utf8"),h=e("./compressions"),u=e("./support");function f(d,_){this.options=d,this.loadOptions=_}f.prototype={isEncrypted:function(){return!(1&~this.bitFlag)},useUTF8:function(){return!(2048&~this.bitFlag)},readLocalPart:function(d){var _,m;if(d.skip(22),this.fileNameLength=d.readInt(2),m=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(m),-1===this.compressedSize||-1===this.uncompressedSize)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if(null===(_=function(w){for(var g in h)if(Object.prototype.hasOwnProperty.call(h,g)&&h[g].magic===w)return h[g];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+o.pretty(this.compressionMethod)+" unknown (inner file : "+o.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,_,d.readData(this.compressedSize))},readCentralPart:function(d){this.versionMadeBy=d.readInt(2),d.skip(2),this.bitFlag=d.readInt(2),this.compressionMethod=d.readString(2),this.date=d.readDate(),this.crc32=d.readInt(4),this.compressedSize=d.readInt(4),this.uncompressedSize=d.readInt(4);var _=d.readInt(2);if(this.extraFieldsLength=d.readInt(2),this.fileCommentLength=d.readInt(2),this.diskNumberStart=d.readInt(2),this.internalFileAttributes=d.readInt(2),this.externalFileAttributes=d.readInt(4),this.localHeaderOffset=d.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");d.skip(_),this.readExtraFields(d),this.parseZIP64ExtraField(d),this.fileComment=d.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var d=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),0==d&&(this.dosPermissions=63&this.externalFileAttributes),3==d&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileNameStr.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var d=n(this.extraFields[1].value);this.uncompressedSize===o.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===o.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===o.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===o.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var _,m,w,g=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<g;)_=d.readInt(2),m=d.readInt(2),w=d.readData(m),this.extraFields[_]={id:_,length:m,value:w};d.setIndex(g)},handleUTF8:function(){var d=u.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var _=this.findExtraFieldUnicodePath();if(null!==_)this.fileNameStr=_;else{var m=o.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(m)}var w=this.findExtraFieldUnicodeComment();if(null!==w)this.fileCommentStr=w;else{var g=o.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(g)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var _=n(d.value);return 1!==_.readInt(1)||l(this.fileName)!==_.readInt(4)?null:c.utf8decode(_.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var _=n(d.value);return 1!==_.readInt(1)||l(this.fileComment)!==_.readInt(4)?null:c.utf8decode(_.readData(d.length-5))}return null}},i.exports=f},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(e,i,s){function n(_,m,w){this.name=_,this.dir=w.dir,this.date=w.date,this.comment=w.comment,this.unixPermissions=w.unixPermissions,this.dosPermissions=w.dosPermissions,this._data=m,this._dataBinary=w.binary,this.options={compression:w.compression,compressionOptions:w.compressionOptions}}var o=e("./stream/StreamHelper"),a=e("./stream/DataWorker"),l=e("./utf8"),c=e("./compressedObject"),h=e("./stream/GenericWorker");n.prototype={internalStream:function(_){var m=null,w="string";try{if(!_)throw new Error("No output type specified.");var g="string"===(w=_.toLowerCase())||"text"===w;"binarystring"!==w&&"text"!==w||(w="string"),m=this._decompressWorker();var v=!this._dataBinary;v&&!g&&(m=m.pipe(new l.Utf8EncodeWorker)),!v&&g&&(m=m.pipe(new l.Utf8DecodeWorker))}catch(T){(m=new h("error")).error(T)}return new o(m,w,"")},async:function(_,m){return this.internalStream(_).accumulate(m)},nodeStream:function(_,m){return this.internalStream(_||"nodebuffer").toNodejsStream(m)},_compressWorker:function(_,m){if(this._data instanceof c&&this._data.compression.magic===_.magic)return this._data.getCompressedWorker();var w=this._decompressWorker();return this._dataBinary||(w=w.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(w,_,m)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof h?this._data:new a(this._data)}};for(var u=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],f=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},d=0;d<u.length;d++)n.prototype[u[d]]=f;i.exports=n},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(e,i,s){(function(n){var o,a,l=n.MutationObserver||n.WebKitMutationObserver;if(l){var c=0,h=new l(_),u=n.document.createTextNode("");h.observe(u,{characterData:!0}),o=function(){u.data=c=++c%2}}else if(n.setImmediate||void 0===n.MessageChannel)o="document"in n&&"onreadystatechange"in n.document.createElement("script")?function(){var m=n.document.createElement("script");m.onreadystatechange=function(){_(),m.onreadystatechange=null,m.parentNode.removeChild(m),m=null},n.document.documentElement.appendChild(m)}:function(){setTimeout(_,0)};else{var f=new n.MessageChannel;f.port1.onmessage=_,o=function(){f.port2.postMessage(0)}}var d=[];function _(){var m,w;a=!0;for(var g=d.length;g;){for(w=d,d=[],m=-1;++m<g;)w[m]();g=d.length}a=!1}i.exports=function(m){1!==d.push(m)||a||o()}}).call(this,typeof cn<"u"?cn:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(e,i,s){var n=e("immediate");function o(){}var a={},l=["REJECTED"],c=["FULFILLED"],h=["PENDING"];function u(g){if("function"!=typeof g)throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,g!==o&&m(this,g)}function f(g,v,T){this.promise=g,"function"==typeof v&&(this.onFulfilled=v,this.callFulfilled=this.otherCallFulfilled),"function"==typeof T&&(this.onRejected=T,this.callRejected=this.otherCallRejected)}function d(g,v,T){n(function(){var C;try{C=v(T)}catch(S){return a.reject(g,S)}C===g?a.reject(g,new TypeError("Cannot resolve promise with itself")):a.resolve(g,C)})}function _(g){var v=g&&g.then;if(g&&("object"==typeof g||"function"==typeof g)&&"function"==typeof v)return function(){v.apply(g,arguments)}}function m(g,v){var T=!1;function C(A){T||(T=!0,a.reject(g,A))}function S(A){T||(T=!0,a.resolve(g,A))}var M=w(function(){v(S,C)});"error"===M.status&&C(M.value)}function w(g,v){var T={};try{T.value=g(v),T.status="success"}catch(C){T.status="error",T.value=C}return T}(i.exports=u).prototype.finally=function(g){if("function"!=typeof g)return this;var v=this.constructor;return this.then(function(T){return v.resolve(g()).then(function(){return T})},function(T){return v.resolve(g()).then(function(){throw T})})},u.prototype.catch=function(g){return this.then(null,g)},u.prototype.then=function(g,v){if("function"!=typeof g&&this.state===c||"function"!=typeof v&&this.state===l)return this;var T=new this.constructor(o);return this.state!==h?d(T,this.state===c?g:v,this.outcome):this.queue.push(new f(T,g,v)),T},f.prototype.callFulfilled=function(g){a.resolve(this.promise,g)},f.prototype.otherCallFulfilled=function(g){d(this.promise,this.onFulfilled,g)},f.prototype.callRejected=function(g){a.reject(this.promise,g)},f.prototype.otherCallRejected=function(g){d(this.promise,this.onRejected,g)},a.resolve=function(g,v){var T=w(_,v);if("error"===T.status)return a.reject(g,T.value);var C=T.value;if(C)m(g,C);else{g.state=c,g.outcome=v;for(var S=-1,M=g.queue.length;++S<M;)g.queue[S].callFulfilled(v)}return g},a.reject=function(g,v){g.state=l,g.outcome=v;for(var T=-1,C=g.queue.length;++T<C;)g.queue[T].callRejected(v);return g},u.resolve=function(g){return g instanceof this?g:a.resolve(new this(o),g)},u.reject=function(g){var v=new this(o);return a.reject(v,g)},u.all=function(g){var v=this;if("[object Array]"!==Object.prototype.toString.call(g))return this.reject(new TypeError("must be an array"));var T=g.length,C=!1;if(!T)return this.resolve([]);for(var S=new Array(T),M=0,A=-1,O=new this(o);++A<T;)I(g[A],A);return O;function I(D,B){v.resolve(D).then(function(E){S[B]=E,++M!==T||C||(C=!0,a.resolve(O,S))},function(E){C||(C=!0,a.reject(O,E))})}},u.race=function(g){if("[object Array]"!==Object.prototype.toString.call(g))return this.reject(new TypeError("must be an array"));var T=g.length,C=!1;if(!T)return this.resolve([]);for(var S=-1,M=new this(o);++S<T;)this.resolve(g[S]).then(function(O){C||(C=!0,a.resolve(M,O))},function(O){C||(C=!0,a.reject(M,O))});return M}},{immediate:36}],38:[function(e,i,s){var n={};(0,e("./lib/utils/common").assign)(n,e("./lib/deflate"),e("./lib/inflate"),e("./lib/zlib/constants")),i.exports=n},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(e,i,s){var n=e("./zlib/deflate"),o=e("./utils/common"),a=e("./utils/strings"),l=e("./zlib/messages"),c=e("./zlib/zstream"),h=Object.prototype.toString;function m(g){if(!(this instanceof m))return new m(g);this.options=o.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},g||{});var v=this.options;v.raw&&0<v.windowBits?v.windowBits=-v.windowBits:v.gzip&&0<v.windowBits&&v.windowBits<16&&(v.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var T=n.deflateInit2(this.strm,v.level,v.method,v.windowBits,v.memLevel,v.strategy);if(0!==T)throw new Error(l[T]);if(v.header&&n.deflateSetHeader(this.strm,v.header),v.dictionary){var C;if(C="string"==typeof v.dictionary?a.string2buf(v.dictionary):"[object ArrayBuffer]"===h.call(v.dictionary)?new Uint8Array(v.dictionary):v.dictionary,0!==(T=n.deflateSetDictionary(this.strm,C)))throw new Error(l[T]);this._dict_set=!0}}function w(g,v){var T=new m(v);if(T.push(g,!0),T.err)throw T.msg||l[T.err];return T.result}m.prototype.push=function(g,v){var T,C,S=this.strm,M=this.options.chunkSize;if(this.ended)return!1;C=v===~~v?v:!0===v?4:0,S.input="string"==typeof g?a.string2buf(g):"[object ArrayBuffer]"===h.call(g)?new Uint8Array(g):g,S.next_in=0,S.avail_in=S.input.length;do{if(0===S.avail_out&&(S.output=new o.Buf8(M),S.next_out=0,S.avail_out=M),1!==(T=n.deflate(S,C))&&0!==T)return this.onEnd(T),!(this.ended=!0);0!==S.avail_out&&(0!==S.avail_in||4!==C&&2!==C)||this.onData("string"===this.options.to?a.buf2binstring(o.shrinkBuf(S.output,S.next_out)):o.shrinkBuf(S.output,S.next_out))}while((0<S.avail_in||0===S.avail_out)&&1!==T);return 4===C?(T=n.deflateEnd(this.strm),this.onEnd(T),this.ended=!0,0===T):2!==C||(this.onEnd(0),!(S.avail_out=0))},m.prototype.onData=function(g){this.chunks.push(g)},m.prototype.onEnd=function(g){0===g&&(this.result="string"===this.options.to?this.chunks.join(""):o.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},s.Deflate=m,s.deflate=w,s.deflateRaw=function(g,v){return(v=v||{}).raw=!0,w(g,v)},s.gzip=function(g,v){return(v=v||{}).gzip=!0,w(g,v)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(e,i,s){var n=e("./zlib/inflate"),o=e("./utils/common"),a=e("./utils/strings"),l=e("./zlib/constants"),c=e("./zlib/messages"),h=e("./zlib/zstream"),u=e("./zlib/gzheader"),f=Object.prototype.toString;function d(m){if(!(this instanceof d))return new d(m);this.options=o.assign({chunkSize:16384,windowBits:0,to:""},m||{});var w=this.options;w.raw&&0<=w.windowBits&&w.windowBits<16&&(w.windowBits=-w.windowBits,0===w.windowBits&&(w.windowBits=-15)),!(0<=w.windowBits&&w.windowBits<16)||m&&m.windowBits||(w.windowBits+=32),15<w.windowBits&&w.windowBits<48&&!(15&w.windowBits)&&(w.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var g=n.inflateInit2(this.strm,w.windowBits);if(g!==l.Z_OK)throw new Error(c[g]);this.header=new u,n.inflateGetHeader(this.strm,this.header)}function _(m,w){var g=new d(w);if(g.push(m,!0),g.err)throw g.msg||c[g.err];return g.result}d.prototype.push=function(m,w){var g,v,T,C,S,M,A=this.strm,O=this.options.chunkSize,I=this.options.dictionary,D=!1;if(this.ended)return!1;v=w===~~w?w:!0===w?l.Z_FINISH:l.Z_NO_FLUSH,A.input="string"==typeof m?a.binstring2buf(m):"[object ArrayBuffer]"===f.call(m)?new Uint8Array(m):m,A.next_in=0,A.avail_in=A.input.length;do{if(0===A.avail_out&&(A.output=new o.Buf8(O),A.next_out=0,A.avail_out=O),(g=n.inflate(A,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&I&&(M="string"==typeof I?a.string2buf(I):"[object ArrayBuffer]"===f.call(I)?new Uint8Array(I):I,g=n.inflateSetDictionary(this.strm,M)),g===l.Z_BUF_ERROR&&!0===D&&(g=l.Z_OK,D=!1),g!==l.Z_STREAM_END&&g!==l.Z_OK)return this.onEnd(g),!(this.ended=!0);A.next_out&&(0!==A.avail_out&&g!==l.Z_STREAM_END&&(0!==A.avail_in||v!==l.Z_FINISH&&v!==l.Z_SYNC_FLUSH)||("string"===this.options.to?(T=a.utf8border(A.output,A.next_out),C=A.next_out-T,S=a.buf2string(A.output,T),A.next_out=C,A.avail_out=O-C,C&&o.arraySet(A.output,A.output,T,C,0),this.onData(S)):this.onData(o.shrinkBuf(A.output,A.next_out)))),0===A.avail_in&&0===A.avail_out&&(D=!0)}while((0<A.avail_in||0===A.avail_out)&&g!==l.Z_STREAM_END);return g===l.Z_STREAM_END&&(v=l.Z_FINISH),v===l.Z_FINISH?(g=n.inflateEnd(this.strm),this.onEnd(g),this.ended=!0,g===l.Z_OK):v!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(A.avail_out=0))},d.prototype.onData=function(m){this.chunks.push(m)},d.prototype.onEnd=function(m){m===l.Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):o.flattenChunks(this.chunks)),this.chunks=[],this.err=m,this.msg=this.strm.msg},s.Inflate=d,s.inflate=_,s.inflateRaw=function(m,w){return(w=w||{}).raw=!0,_(m,w)},s.ungzip=_},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(e,i,s){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";s.assign=function(l){for(var c=Array.prototype.slice.call(arguments,1);c.length;){var h=c.shift();if(h){if("object"!=typeof h)throw new TypeError(h+"must be non-object");for(var u in h)h.hasOwnProperty(u)&&(l[u]=h[u])}}return l},s.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var o={arraySet:function(l,c,h,u,f){if(c.subarray&&l.subarray)l.set(c.subarray(h,h+u),f);else for(var d=0;d<u;d++)l[f+d]=c[h+d]},flattenChunks:function(l){var c,h,u,f,d,_;for(c=u=0,h=l.length;c<h;c++)u+=l[c].length;for(_=new Uint8Array(u),c=f=0,h=l.length;c<h;c++)_.set(d=l[c],f),f+=d.length;return _}},a={arraySet:function(l,c,h,u,f){for(var d=0;d<u;d++)l[f+d]=c[h+d]},flattenChunks:function(l){return[].concat.apply([],l)}};s.setTyped=function(l){l?(s.Buf8=Uint8Array,s.Buf16=Uint16Array,s.Buf32=Int32Array,s.assign(s,o)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,a))},s.setTyped(n)},{}],42:[function(e,i,s){var n=e("./common"),o=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{o=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new n.Buf8(256),c=0;c<256;c++)l[c]=252<=c?6:248<=c?5:240<=c?4:224<=c?3:192<=c?2:1;function h(u,f){if(f<65537&&(u.subarray&&a||!u.subarray&&o))return String.fromCharCode.apply(null,n.shrinkBuf(u,f));for(var d="",_=0;_<f;_++)d+=String.fromCharCode(u[_]);return d}l[254]=l[254]=1,s.string2buf=function(u){var f,d,_,m,w,g=u.length,v=0;for(m=0;m<g;m++)55296==(64512&(d=u.charCodeAt(m)))&&m+1<g&&56320==(64512&(_=u.charCodeAt(m+1)))&&(d=65536+(d-55296<<10)+(_-56320),m++),v+=d<128?1:d<2048?2:d<65536?3:4;for(f=new n.Buf8(v),m=w=0;w<v;m++)55296==(64512&(d=u.charCodeAt(m)))&&m+1<g&&56320==(64512&(_=u.charCodeAt(m+1)))&&(d=65536+(d-55296<<10)+(_-56320),m++),d<128?f[w++]=d:(d<2048?f[w++]=192|d>>>6:(d<65536?f[w++]=224|d>>>12:(f[w++]=240|d>>>18,f[w++]=128|d>>>12&63),f[w++]=128|d>>>6&63),f[w++]=128|63&d);return f},s.buf2binstring=function(u){return h(u,u.length)},s.binstring2buf=function(u){for(var f=new n.Buf8(u.length),d=0,_=f.length;d<_;d++)f[d]=u.charCodeAt(d);return f},s.buf2string=function(u,f){var d,_,m,w,g=f||u.length,v=new Array(2*g);for(d=_=0;d<g;)if((m=u[d++])<128)v[_++]=m;else if(4<(w=l[m]))v[_++]=65533,d+=w-1;else{for(m&=2===w?31:3===w?15:7;1<w&&d<g;)m=m<<6|63&u[d++],w--;1<w?v[_++]=65533:m<65536?v[_++]=m:(v[_++]=55296|(m-=65536)>>10&1023,v[_++]=56320|1023&m)}return h(v,_)},s.utf8border=function(u,f){var d;for((f=f||u.length)>u.length&&(f=u.length),d=f-1;0<=d&&128==(192&u[d]);)d--;return d<0||0===d?f:d+l[u[d]]>f?d:f}},{"./common":41}],43:[function(e,i,s){i.exports=function(n,o,a,l){for(var c=65535&n,h=n>>>16&65535,u=0;0!==a;){for(a-=u=2e3<a?2e3:a;h=h+(c=c+o[l++]|0)|0,--u;);c%=65521,h%=65521}return c|h<<16}},{}],44:[function(e,i,s){i.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(e,i,s){var n=function(){for(var o,a=[],l=0;l<256;l++){o=l;for(var c=0;c<8;c++)o=1&o?3988292384^o>>>1:o>>>1;a[l]=o}return a}();i.exports=function(o,a,l,c){var h=n,u=c+l;o^=-1;for(var f=c;f<u;f++)o=o>>>8^h[255&(o^a[f])];return-1^o}},{}],46:[function(e,i,s){var n,o=e("../utils/common"),a=e("./trees"),l=e("./adler32"),c=e("./crc32"),h=e("./messages"),_=-2,D=258,B=262,L=113;function ct(P,W){return P.msg=h[W],W}function Z(P){return(P<<1)-(4<P?9:0)}function at(P){for(var W=P.length;0<=--W;)P[W]=0}function F(P){var W=P.state,H=W.pending;H>P.avail_out&&(H=P.avail_out),0!==H&&(o.arraySet(P.output,W.pending_buf,W.pending_out,H,P.next_out),P.next_out+=H,W.pending_out+=H,P.total_out+=H,P.avail_out-=H,W.pending-=H,0===W.pending&&(W.pending_out=0))}function V(P,W){a._tr_flush_block(P,0<=P.block_start?P.block_start:-1,P.strstart-P.block_start,W),P.block_start=P.strstart,F(P.strm)}function nt(P,W){P.pending_buf[P.pending++]=W}function it(P,W){P.pending_buf[P.pending++]=W>>>8&255,P.pending_buf[P.pending++]=255&W}function J(P,W){var H,k,z=P.max_chain_length,R=P.strstart,X=P.prev_length,K=P.nice_match,U=P.strstart>P.w_size-B?P.strstart-(P.w_size-B):0,tt=P.window,lt=P.w_mask,et=P.prev,ut=P.strstart+D,vt=tt[R+X-1],wt=tt[R+X];P.prev_length>=P.good_match&&(z>>=2),K>P.lookahead&&(K=P.lookahead);do{if(tt[(H=W)+X]===wt&&tt[H+X-1]===vt&&tt[H]===tt[R]&&tt[++H]===tt[R+1]){R+=2,H++;do{}while(tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&tt[++R]===tt[++H]&&R<ut);if(k=D-(ut-R),R=ut-D,X<k){if(P.match_start=W,K<=(X=k))break;vt=tt[R+X-1],wt=tt[R+X]}}}while((W=et[W&lt])>U&&0!=--z);return X<=P.lookahead?X:P.lookahead}function _t(P){var W,H,k,z,R,X,K,U,tt,lt,et=P.w_size;do{if(z=P.window_size-P.lookahead-P.strstart,P.strstart>=et+(et-B)){for(o.arraySet(P.window,P.window,et,et,0),P.match_start-=et,P.strstart-=et,P.block_start-=et,W=H=P.hash_size;k=P.head[--W],P.head[W]=et<=k?k-et:0,--H;);for(W=H=et;k=P.prev[--W],P.prev[W]=et<=k?k-et:0,--H;);z+=et}if(0===P.strm.avail_in)break;if(K=P.window,U=P.strstart+P.lookahead,lt=void 0,(tt=z)<(lt=(X=P.strm).avail_in)&&(lt=tt),H=0===lt?0:(X.avail_in-=lt,o.arraySet(K,X.input,X.next_in,lt,U),1===X.state.wrap?X.adler=l(X.adler,K,lt,U):2===X.state.wrap&&(X.adler=c(X.adler,K,lt,U)),X.next_in+=lt,X.total_in+=lt,lt),P.lookahead+=H,P.lookahead+P.insert>=3)for(P.ins_h=P.window[R=P.strstart-P.insert],P.ins_h=(P.ins_h<<P.hash_shift^P.window[R+1])&P.hash_mask;P.insert&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[R+3-1])&P.hash_mask,P.prev[R&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=R,R++,P.insert--,!(P.lookahead+P.insert<3)););}while(P.lookahead<B&&0!==P.strm.avail_in)}function St(P,W){for(var H,k;;){if(P.lookahead<B){if(_t(P),P.lookahead<B&&0===W)return 1;if(0===P.lookahead)break}if(H=0,P.lookahead>=3&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+3-1])&P.hash_mask,H=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),0!==H&&P.strstart-H<=P.w_size-B&&(P.match_length=J(P,H)),P.match_length>=3)if(k=a._tr_tally(P,P.strstart-P.match_start,P.match_length-3),P.lookahead-=P.match_length,P.match_length<=P.max_lazy_match&&P.lookahead>=3){for(P.match_length--;P.strstart++,P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+3-1])&P.hash_mask,H=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart,0!=--P.match_length;);P.strstart++}else P.strstart+=P.match_length,P.match_length=0,P.ins_h=P.window[P.strstart],P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+1])&P.hash_mask;else k=a._tr_tally(P,0,P.window[P.strstart]),P.lookahead--,P.strstart++;if(k&&(V(P,!1),0===P.strm.avail_out))return 1}return P.insert=P.strstart<2?P.strstart:2,4===W?(V(P,!0),0===P.strm.avail_out?3:4):P.last_lit&&(V(P,!1),0===P.strm.avail_out)?1:2}function dt(P,W){for(var H,k,z;;){if(P.lookahead<B){if(_t(P),P.lookahead<B&&0===W)return 1;if(0===P.lookahead)break}if(H=0,P.lookahead>=3&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+3-1])&P.hash_mask,H=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),P.prev_length=P.match_length,P.prev_match=P.match_start,P.match_length=2,0!==H&&P.prev_length<P.max_lazy_match&&P.strstart-H<=P.w_size-B&&(P.match_length=J(P,H),P.match_length<=5&&(1===P.strategy||3===P.match_length&&4096<P.strstart-P.match_start)&&(P.match_length=2)),P.prev_length>=3&&P.match_length<=P.prev_length){for(z=P.strstart+P.lookahead-3,k=a._tr_tally(P,P.strstart-1-P.prev_match,P.prev_length-3),P.lookahead-=P.prev_length-1,P.prev_length-=2;++P.strstart<=z&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+3-1])&P.hash_mask,H=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),0!=--P.prev_length;);if(P.match_available=0,P.match_length=2,P.strstart++,k&&(V(P,!1),0===P.strm.avail_out))return 1}else if(P.match_available){if((k=a._tr_tally(P,0,P.window[P.strstart-1]))&&V(P,!1),P.strstart++,P.lookahead--,0===P.strm.avail_out)return 1}else P.match_available=1,P.strstart++,P.lookahead--}return P.match_available&&(k=a._tr_tally(P,0,P.window[P.strstart-1]),P.match_available=0),P.insert=P.strstart<2?P.strstart:2,4===W?(V(P,!0),0===P.strm.avail_out?3:4):P.last_lit&&(V(P,!1),0===P.strm.avail_out)?1:2}function rt(P,W,H,k,z){this.good_length=P,this.max_lazy=W,this.nice_length=H,this.max_chain=k,this.func=z}function ht(){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=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new o.Buf16(1146),this.dyn_dtree=new o.Buf16(122),this.bl_tree=new o.Buf16(78),at(this.dyn_ltree),at(this.dyn_dtree),at(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new o.Buf16(16),this.heap=new o.Buf16(573),at(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(573),at(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 pt(P){var W;return P&&P.state?(P.total_in=P.total_out=0,P.data_type=2,(W=P.state).pending=0,W.pending_out=0,W.wrap<0&&(W.wrap=-W.wrap),W.status=W.wrap?42:L,P.adler=2===W.wrap?0:1,W.last_flush=0,a._tr_init(W),0):ct(P,_)}function xt(P){var H,W=pt(P);return 0===W&&((H=P.state).window_size=2*H.w_size,at(H.head),H.max_lazy_match=n[H.level].max_lazy,H.good_match=n[H.level].good_length,H.nice_match=n[H.level].nice_length,H.max_chain_length=n[H.level].max_chain,H.strstart=0,H.block_start=0,H.lookahead=0,H.insert=0,H.match_length=H.prev_length=2,H.match_available=0,H.ins_h=0),W}function Et(P,W,H,k,z,R){if(!P)return _;var X=1;if(-1===W&&(W=6),k<0?(X=0,k=-k):15<k&&(X=2,k-=16),z<1||9<z||8!==H||k<8||15<k||W<0||9<W||R<0||4<R)return ct(P,_);8===k&&(k=9);var K=new ht;return(P.state=K).strm=P,K.wrap=X,K.gzhead=null,K.w_bits=k,K.w_size=1<<K.w_bits,K.w_mask=K.w_size-1,K.hash_bits=z+7,K.hash_size=1<<K.hash_bits,K.hash_mask=K.hash_size-1,K.hash_shift=~~((K.hash_bits+3-1)/3),K.window=new o.Buf8(2*K.w_size),K.head=new o.Buf16(K.hash_size),K.prev=new o.Buf16(K.w_size),K.lit_bufsize=1<<z+6,K.pending_buf_size=4*K.lit_bufsize,K.pending_buf=new o.Buf8(K.pending_buf_size),K.d_buf=1*K.lit_bufsize,K.l_buf=3*K.lit_bufsize,K.level=W,K.strategy=R,K.method=H,xt(P)}n=[new rt(0,0,0,0,function(P,W){var H=65535;for(H>P.pending_buf_size-5&&(H=P.pending_buf_size-5);;){if(P.lookahead<=1){if(_t(P),0===P.lookahead&&0===W)return 1;if(0===P.lookahead)break}P.strstart+=P.lookahead,P.lookahead=0;var k=P.block_start+H;if((0===P.strstart||P.strstart>=k)&&(P.lookahead=P.strstart-k,P.strstart=k,V(P,!1),0===P.strm.avail_out)||P.strstart-P.block_start>=P.w_size-B&&(V(P,!1),0===P.strm.avail_out))return 1}return P.insert=0,4===W?(V(P,!0),0===P.strm.avail_out?3:4):(P.strstart>P.block_start&&V(P,!1),1)}),new rt(4,4,8,4,St),new rt(4,5,16,8,St),new rt(4,6,32,32,St),new rt(4,4,16,16,dt),new rt(8,16,32,32,dt),new rt(8,16,128,128,dt),new rt(8,32,128,256,dt),new rt(32,128,258,1024,dt),new rt(32,258,258,4096,dt)],s.deflateInit=function(P,W){return Et(P,W,8,15,8,0)},s.deflateInit2=Et,s.deflateReset=xt,s.deflateResetKeep=pt,s.deflateSetHeader=function(P,W){return P&&P.state?2!==P.state.wrap?_:(P.state.gzhead=W,0):_},s.deflate=function(P,W){var H,k,z,R;if(!P||!P.state||5<W||W<0)return P?ct(P,_):_;if(k=P.state,!P.output||!P.input&&0!==P.avail_in||666===k.status&&4!==W)return ct(P,0===P.avail_out?-5:_);if(k.strm=P,H=k.last_flush,k.last_flush=W,42===k.status)if(2===k.wrap)P.adler=0,nt(k,31),nt(k,139),nt(k,8),k.gzhead?(nt(k,(k.gzhead.text?1:0)+(k.gzhead.hcrc?2:0)+(k.gzhead.extra?4:0)+(k.gzhead.name?8:0)+(k.gzhead.comment?16:0)),nt(k,255&k.gzhead.time),nt(k,k.gzhead.time>>8&255),nt(k,k.gzhead.time>>16&255),nt(k,k.gzhead.time>>24&255),nt(k,9===k.level?2:2<=k.strategy||k.level<2?4:0),nt(k,255&k.gzhead.os),k.gzhead.extra&&k.gzhead.extra.length&&(nt(k,255&k.gzhead.extra.length),nt(k,k.gzhead.extra.length>>8&255)),k.gzhead.hcrc&&(P.adler=c(P.adler,k.pending_buf,k.pending,0)),k.gzindex=0,k.status=69):(nt(k,0),nt(k,0),nt(k,0),nt(k,0),nt(k,0),nt(k,9===k.level?2:2<=k.strategy||k.level<2?4:0),nt(k,3),k.status=L);else{var X=8+(k.w_bits-8<<4)<<8;X|=(2<=k.strategy||k.level<2?0:k.level<6?1:6===k.level?2:3)<<6,0!==k.strstart&&(X|=32),X+=31-X%31,k.status=L,it(k,X),0!==k.strstart&&(it(k,P.adler>>>16),it(k,65535&P.adler)),P.adler=1}if(69===k.status)if(k.gzhead.extra){for(z=k.pending;k.gzindex<(65535&k.gzhead.extra.length)&&(k.pending!==k.pending_buf_size||(k.gzhead.hcrc&&k.pending>z&&(P.adler=c(P.adler,k.pending_buf,k.pending-z,z)),F(P),z=k.pending,k.pending!==k.pending_buf_size));)nt(k,255&k.gzhead.extra[k.gzindex]),k.gzindex++;k.gzhead.hcrc&&k.pending>z&&(P.adler=c(P.adler,k.pending_buf,k.pending-z,z)),k.gzindex===k.gzhead.extra.length&&(k.gzindex=0,k.status=73)}else k.status=73;if(73===k.status)if(k.gzhead.name){z=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>z&&(P.adler=c(P.adler,k.pending_buf,k.pending-z,z)),F(P),z=k.pending,k.pending===k.pending_buf_size)){R=1;break}R=k.gzindex<k.gzhead.name.length?255&k.gzhead.name.charCodeAt(k.gzindex++):0,nt(k,R)}while(0!==R);k.gzhead.hcrc&&k.pending>z&&(P.adler=c(P.adler,k.pending_buf,k.pending-z,z)),0===R&&(k.gzindex=0,k.status=91)}else k.status=91;if(91===k.status)if(k.gzhead.comment){z=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>z&&(P.adler=c(P.adler,k.pending_buf,k.pending-z,z)),F(P),z=k.pending,k.pending===k.pending_buf_size)){R=1;break}R=k.gzindex<k.gzhead.comment.length?255&k.gzhead.comment.charCodeAt(k.gzindex++):0,nt(k,R)}while(0!==R);k.gzhead.hcrc&&k.pending>z&&(P.adler=c(P.adler,k.pending_buf,k.pending-z,z)),0===R&&(k.status=103)}else k.status=103;if(103===k.status&&(k.gzhead.hcrc?(k.pending+2>k.pending_buf_size&&F(P),k.pending+2<=k.pending_buf_size&&(nt(k,255&P.adler),nt(k,P.adler>>8&255),P.adler=0,k.status=L)):k.status=L),0!==k.pending){if(F(P),0===P.avail_out)return k.last_flush=-1,0}else if(0===P.avail_in&&Z(W)<=Z(H)&&4!==W)return ct(P,-5);if(666===k.status&&0!==P.avail_in)return ct(P,-5);if(0!==P.avail_in||0!==k.lookahead||0!==W&&666!==k.status){var K=2===k.strategy?function(U,tt){for(var lt;;){if(0===U.lookahead&&(_t(U),0===U.lookahead)){if(0===tt)return 1;break}if(U.match_length=0,lt=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++,lt&&(V(U,!1),0===U.strm.avail_out))return 1}return U.insert=0,4===tt?(V(U,!0),0===U.strm.avail_out?3:4):U.last_lit&&(V(U,!1),0===U.strm.avail_out)?1:2}(k,W):3===k.strategy?function(U,tt){for(var lt,et,ut,vt,wt=U.window;;){if(U.lookahead<=D){if(_t(U),U.lookahead<=D&&0===tt)return 1;if(0===U.lookahead)break}if(U.match_length=0,U.lookahead>=3&&0<U.strstart&&(et=wt[ut=U.strstart-1])===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]){vt=U.strstart+D;do{}while(et===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]&&et===wt[++ut]&&ut<vt);U.match_length=D-(vt-ut),U.match_length>U.lookahead&&(U.match_length=U.lookahead)}if(U.match_length>=3?(lt=a._tr_tally(U,1,U.match_length-3),U.lookahead-=U.match_length,U.strstart+=U.match_length,U.match_length=0):(lt=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++),lt&&(V(U,!1),0===U.strm.avail_out))return 1}return U.insert=0,4===tt?(V(U,!0),0===U.strm.avail_out?3:4):U.last_lit&&(V(U,!1),0===U.strm.avail_out)?1:2}(k,W):n[k.level].func(k,W);if(3!==K&&4!==K||(k.status=666),1===K||3===K)return 0===P.avail_out&&(k.last_flush=-1),0;if(2===K&&(1===W?a._tr_align(k):5!==W&&(a._tr_stored_block(k,0,0,!1),3===W&&(at(k.head),0===k.lookahead&&(k.strstart=0,k.block_start=0,k.insert=0))),F(P),0===P.avail_out))return k.last_flush=-1,0}return 4!==W?0:k.wrap<=0?1:(2===k.wrap?(nt(k,255&P.adler),nt(k,P.adler>>8&255),nt(k,P.adler>>16&255),nt(k,P.adler>>24&255),nt(k,255&P.total_in),nt(k,P.total_in>>8&255),nt(k,P.total_in>>16&255),nt(k,P.total_in>>24&255)):(it(k,P.adler>>>16),it(k,65535&P.adler)),F(P),0<k.wrap&&(k.wrap=-k.wrap),0!==k.pending?0:1)},s.deflateEnd=function(P){var W;return P&&P.state?42!==(W=P.state.status)&&69!==W&&73!==W&&91!==W&&103!==W&&W!==L&&666!==W?ct(P,_):(P.state=null,W===L?ct(P,-3):0):_},s.deflateSetDictionary=function(P,W){var H,k,z,R,X,K,U,tt,lt=W.length;if(!P||!P.state||2===(R=(H=P.state).wrap)||1===R&&42!==H.status||H.lookahead)return _;for(1===R&&(P.adler=l(P.adler,W,lt,0)),H.wrap=0,lt>=H.w_size&&(0===R&&(at(H.head),H.strstart=0,H.block_start=0,H.insert=0),tt=new o.Buf8(H.w_size),o.arraySet(tt,W,lt-H.w_size,H.w_size,0),W=tt,lt=H.w_size),X=P.avail_in,K=P.next_in,U=P.input,P.avail_in=lt,P.next_in=0,P.input=W,_t(H);H.lookahead>=3;){for(k=H.strstart,z=H.lookahead-2;H.ins_h=(H.ins_h<<H.hash_shift^H.window[k+3-1])&H.hash_mask,H.prev[k&H.w_mask]=H.head[H.ins_h],H.head[H.ins_h]=k,k++,--z;);H.strstart=k,H.lookahead=2,_t(H)}return H.strstart+=H.lookahead,H.block_start=H.strstart,H.insert=H.lookahead,H.lookahead=0,H.match_length=H.prev_length=2,H.match_available=0,P.next_in=K,P.input=U,P.avail_in=X,H.wrap=R,0},s.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(e,i,s){i.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(e,i,s){i.exports=function(n,o){var a,l,c,h,u,f,d,_,m,w,g,v,T,C,S,M,A,O,I,D,B,E,L,x,N;x=n.input,c=(l=n.next_in)+(n.avail_in-5),N=n.output,u=(h=n.next_out)-(o-n.avail_out),f=h+(n.avail_out-257),d=(a=n.state).dmax,_=a.wsize,m=a.whave,w=a.wnext,g=a.window,v=a.hold,T=a.bits,C=a.lencode,S=a.distcode,M=(1<<a.lenbits)-1,A=(1<<a.distbits)-1;t:do{T<15&&(v+=x[l++]<<T,v+=x[l++]<<(T+=8),T+=8),O=C[v&M];e:for(;;){if(v>>>=I=O>>>24,T-=I,0==(I=O>>>16&255))N[h++]=65535&O;else{if(!(16&I)){if(!(64&I)){O=C[(65535&O)+(v&(1<<I)-1)];continue e}if(32&I){a.mode=12;break t}n.msg="invalid literal/length code",a.mode=30;break t}D=65535&O,(I&=15)&&(T<I&&(v+=x[l++]<<T,T+=8),D+=v&(1<<I)-1,v>>>=I,T-=I),T<15&&(v+=x[l++]<<T,v+=x[l++]<<(T+=8),T+=8),O=S[v&A];i:for(;;){if(v>>>=I=O>>>24,T-=I,!(16&(I=O>>>16&255))){if(!(64&I)){O=S[(65535&O)+(v&(1<<I)-1)];continue i}n.msg="invalid distance code",a.mode=30;break t}if(B=65535&O,T<(I&=15)&&(v+=x[l++]<<T,(T+=8)<I&&(v+=x[l++]<<T,T+=8)),d<(B+=v&(1<<I)-1)){n.msg="invalid distance too far back",a.mode=30;break t}if(v>>>=I,T-=I,(I=h-u)<B){if(m<(I=B-I)&&a.sane){n.msg="invalid distance too far back",a.mode=30;break t}if(L=g,(E=0)===w){if(E+=_-I,I<D){for(D-=I;N[h++]=g[E++],--I;);E=h-B,L=N}}else if(w<I){if(E+=_+w-I,(I-=w)<D){for(D-=I;N[h++]=g[E++],--I;);if(E=0,w<D){for(D-=I=w;N[h++]=g[E++],--I;);E=h-B,L=N}}}else if(E+=w-I,I<D){for(D-=I;N[h++]=g[E++],--I;);E=h-B,L=N}for(;2<D;)N[h++]=L[E++],N[h++]=L[E++],N[h++]=L[E++],D-=3;D&&(N[h++]=L[E++],1<D&&(N[h++]=L[E++]))}else{for(E=h-B;N[h++]=N[E++],N[h++]=N[E++],N[h++]=N[E++],2<(D-=3););D&&(N[h++]=N[E++],1<D&&(N[h++]=N[E++]))}break}}break}}while(l<c&&h<f);l-=D=T>>3,v&=(1<<(T-=D<<3))-1,n.next_in=l,n.next_out=h,n.avail_in=l<c?c-l+5:5-(l-c),n.avail_out=h<f?f-h+257:257-(h-f),a.hold=v,a.bits=T}},{}],49:[function(e,i,s){var n=e("../utils/common"),o=e("./adler32"),a=e("./crc32"),l=e("./inffast"),c=e("./inftrees"),d=-2;function g(E){return(E>>>24&255)+(E>>>8&65280)+((65280&E)<<8)+((255&E)<<24)}function v(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function T(E){var L;return E&&E.state?(E.total_in=E.total_out=(L=E.state).total=0,E.msg="",L.wrap&&(E.adler=1&L.wrap),L.mode=1,L.last=0,L.havedict=0,L.dmax=32768,L.head=null,L.hold=0,L.bits=0,L.lencode=L.lendyn=new n.Buf32(852),L.distcode=L.distdyn=new n.Buf32(592),L.sane=1,L.back=-1,0):d}function C(E){var L;return E&&E.state?((L=E.state).wsize=0,L.whave=0,L.wnext=0,T(E)):d}function S(E,L){var x,N;return E&&E.state?(N=E.state,L<0?(x=0,L=-L):(x=1+(L>>4),L<48&&(L&=15)),L&&(L<8||15<L)?d:(null!==N.window&&N.wbits!==L&&(N.window=null),N.wrap=x,N.wbits=L,C(E))):d}function M(E,L){var x,N;return E?(N=new v,(E.state=N).window=null,0!==(x=S(E,L))&&(E.state=null),x):d}var A,O,I=!0;function D(E){if(I){var L;for(A=new n.Buf32(512),O=new n.Buf32(32),L=0;L<144;)E.lens[L++]=8;for(;L<256;)E.lens[L++]=9;for(;L<280;)E.lens[L++]=7;for(;L<288;)E.lens[L++]=8;for(c(1,E.lens,0,288,A,0,E.work,{bits:9}),L=0;L<32;)E.lens[L++]=5;c(2,E.lens,0,32,O,0,E.work,{bits:5}),I=!1}E.lencode=A,E.lenbits=9,E.distcode=O,E.distbits=5}function B(E,L,x,N){var Y,q=E.state;return null===q.window&&(q.wsize=1<<q.wbits,q.wnext=0,q.whave=0,q.window=new n.Buf8(q.wsize)),N>=q.wsize?(n.arraySet(q.window,L,x-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(N<(Y=q.wsize-q.wnext)&&(Y=N),n.arraySet(q.window,L,x-N,Y,q.wnext),(N-=Y)?(n.arraySet(q.window,L,x-N,N,0),q.wnext=N,q.whave=q.wsize):(q.wnext+=Y,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=Y))),0}s.inflateReset=C,s.inflateReset2=S,s.inflateResetKeep=T,s.inflateInit=function(E){return M(E,15)},s.inflateInit2=M,s.inflate=function(E,L){var x,N,Y,q,ct,Z,at,F,V,nt,it,J,_t,St,dt,rt,ht,pt,xt,Et,P,W,H,k,z=0,R=new n.Buf8(4),X=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!E||!E.state||!E.output||!E.input&&0!==E.avail_in)return d;12===(x=E.state).mode&&(x.mode=13),ct=E.next_out,Y=E.output,q=E.next_in,N=E.input,F=x.hold,V=x.bits,nt=Z=E.avail_in,it=at=E.avail_out,W=0;t:for(;;)switch(x.mode){case 1:if(0===x.wrap){x.mode=13;break}for(;V<16;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(2&x.wrap&&35615===F){R[x.check=0]=255&F,R[1]=F>>>8&255,x.check=a(x.check,R,2,0),V=F=0,x.mode=2;break}if(x.flags=0,x.head&&(x.head.done=!1),!(1&x.wrap)||(((255&F)<<8)+(F>>8))%31){E.msg="incorrect header check",x.mode=30;break}if(8!=(15&F)){E.msg="unknown compression method",x.mode=30;break}if(V-=4,P=8+(15&(F>>>=4)),0===x.wbits)x.wbits=P;else if(P>x.wbits){E.msg="invalid window size",x.mode=30;break}x.dmax=1<<P,E.adler=x.check=1,x.mode=512&F?10:12,V=F=0;break;case 2:for(;V<16;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(x.flags=F,8!=(255&x.flags)){E.msg="unknown compression method",x.mode=30;break}if(57344&x.flags){E.msg="unknown header flags set",x.mode=30;break}x.head&&(x.head.text=F>>8&1),512&x.flags&&(R[0]=255&F,R[1]=F>>>8&255,x.check=a(x.check,R,2,0)),V=F=0,x.mode=3;case 3:for(;V<32;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}x.head&&(x.head.time=F),512&x.flags&&(R[0]=255&F,R[1]=F>>>8&255,R[2]=F>>>16&255,R[3]=F>>>24&255,x.check=a(x.check,R,4,0)),V=F=0,x.mode=4;case 4:for(;V<16;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}x.head&&(x.head.xflags=255&F,x.head.os=F>>8),512&x.flags&&(R[0]=255&F,R[1]=F>>>8&255,x.check=a(x.check,R,2,0)),V=F=0,x.mode=5;case 5:if(1024&x.flags){for(;V<16;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}x.length=F,x.head&&(x.head.extra_len=F),512&x.flags&&(R[0]=255&F,R[1]=F>>>8&255,x.check=a(x.check,R,2,0)),V=F=0}else x.head&&(x.head.extra=null);x.mode=6;case 6:if(1024&x.flags&&(Z<(J=x.length)&&(J=Z),J&&(x.head&&(P=x.head.extra_len-x.length,x.head.extra||(x.head.extra=new Array(x.head.extra_len)),n.arraySet(x.head.extra,N,q,J,P)),512&x.flags&&(x.check=a(x.check,N,J,q)),Z-=J,q+=J,x.length-=J),x.length))break t;x.length=0,x.mode=7;case 7:if(2048&x.flags){if(0===Z)break t;for(J=0;P=N[q+J++],x.head&&P&&x.length<65536&&(x.head.name+=String.fromCharCode(P)),P&&J<Z;);if(512&x.flags&&(x.check=a(x.check,N,J,q)),Z-=J,q+=J,P)break t}else x.head&&(x.head.name=null);x.length=0,x.mode=8;case 8:if(4096&x.flags){if(0===Z)break t;for(J=0;P=N[q+J++],x.head&&P&&x.length<65536&&(x.head.comment+=String.fromCharCode(P)),P&&J<Z;);if(512&x.flags&&(x.check=a(x.check,N,J,q)),Z-=J,q+=J,P)break t}else x.head&&(x.head.comment=null);x.mode=9;case 9:if(512&x.flags){for(;V<16;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(F!==(65535&x.check)){E.msg="header crc mismatch",x.mode=30;break}V=F=0}x.head&&(x.head.hcrc=x.flags>>9&1,x.head.done=!0),E.adler=x.check=0,x.mode=12;break;case 10:for(;V<32;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}E.adler=x.check=g(F),V=F=0,x.mode=11;case 11:if(0===x.havedict)return E.next_out=ct,E.avail_out=at,E.next_in=q,E.avail_in=Z,x.hold=F,x.bits=V,2;E.adler=x.check=1,x.mode=12;case 12:if(5===L||6===L)break t;case 13:if(x.last){F>>>=7&V,V-=7&V,x.mode=27;break}for(;V<3;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}switch(x.last=1&F,V-=1,3&(F>>>=1)){case 0:x.mode=14;break;case 1:if(D(x),x.mode=20,6!==L)break;F>>>=2,V-=2;break t;case 2:x.mode=17;break;case 3:E.msg="invalid block type",x.mode=30}F>>>=2,V-=2;break;case 14:for(F>>>=7&V,V-=7&V;V<32;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if((65535&F)!=(F>>>16^65535)){E.msg="invalid stored block lengths",x.mode=30;break}if(x.length=65535&F,V=F=0,x.mode=15,6===L)break t;case 15:x.mode=16;case 16:if(J=x.length){if(Z<J&&(J=Z),at<J&&(J=at),0===J)break t;n.arraySet(Y,N,q,J,ct),Z-=J,q+=J,at-=J,ct+=J,x.length-=J;break}x.mode=12;break;case 17:for(;V<14;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(x.nlen=257+(31&F),V-=5,x.ndist=1+(31&(F>>>=5)),V-=5,x.ncode=4+(15&(F>>>=5)),F>>>=4,V-=4,286<x.nlen||30<x.ndist){E.msg="too many length or distance symbols",x.mode=30;break}x.have=0,x.mode=18;case 18:for(;x.have<x.ncode;){for(;V<3;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}x.lens[X[x.have++]]=7&F,F>>>=3,V-=3}for(;x.have<19;)x.lens[X[x.have++]]=0;if(x.lencode=x.lendyn,x.lenbits=7,W=c(0,x.lens,0,19,x.lencode,0,x.work,H={bits:x.lenbits}),x.lenbits=H.bits,W){E.msg="invalid code lengths set",x.mode=30;break}x.have=0,x.mode=19;case 19:for(;x.have<x.nlen+x.ndist;){for(;rt=(z=x.lencode[F&(1<<x.lenbits)-1])>>>16&255,ht=65535&z,!((dt=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(ht<16)F>>>=dt,V-=dt,x.lens[x.have++]=ht;else{if(16===ht){for(k=dt+2;V<k;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(F>>>=dt,V-=dt,0===x.have){E.msg="invalid bit length repeat",x.mode=30;break}P=x.lens[x.have-1],J=3+(3&F),F>>>=2,V-=2}else if(17===ht){for(k=dt+3;V<k;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}V-=dt,P=0,J=3+(7&(F>>>=dt)),F>>>=3,V-=3}else{for(k=dt+7;V<k;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}V-=dt,P=0,J=11+(127&(F>>>=dt)),F>>>=7,V-=7}if(x.have+J>x.nlen+x.ndist){E.msg="invalid bit length repeat",x.mode=30;break}for(;J--;)x.lens[x.have++]=P}}if(30===x.mode)break;if(0===x.lens[256]){E.msg="invalid code -- missing end-of-block",x.mode=30;break}if(x.lenbits=9,W=c(1,x.lens,0,x.nlen,x.lencode,0,x.work,H={bits:x.lenbits}),x.lenbits=H.bits,W){E.msg="invalid literal/lengths set",x.mode=30;break}if(x.distbits=6,x.distcode=x.distdyn,W=c(2,x.lens,x.nlen,x.ndist,x.distcode,0,x.work,H={bits:x.distbits}),x.distbits=H.bits,W){E.msg="invalid distances set",x.mode=30;break}if(x.mode=20,6===L)break t;case 20:x.mode=21;case 21:if(6<=Z&&258<=at){E.next_out=ct,E.avail_out=at,E.next_in=q,E.avail_in=Z,x.hold=F,x.bits=V,l(E,it),ct=E.next_out,Y=E.output,at=E.avail_out,q=E.next_in,N=E.input,Z=E.avail_in,F=x.hold,V=x.bits,12===x.mode&&(x.back=-1);break}for(x.back=0;rt=(z=x.lencode[F&(1<<x.lenbits)-1])>>>16&255,ht=65535&z,!((dt=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(rt&&!(240&rt)){for(pt=dt,xt=rt,Et=ht;rt=(z=x.lencode[Et+((F&(1<<pt+xt)-1)>>pt)])>>>16&255,ht=65535&z,!(pt+(dt=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}F>>>=pt,V-=pt,x.back+=pt}if(F>>>=dt,V-=dt,x.back+=dt,x.length=ht,0===rt){x.mode=26;break}if(32&rt){x.back=-1,x.mode=12;break}if(64&rt){E.msg="invalid literal/length code",x.mode=30;break}x.extra=15&rt,x.mode=22;case 22:if(x.extra){for(k=x.extra;V<k;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}x.length+=F&(1<<x.extra)-1,F>>>=x.extra,V-=x.extra,x.back+=x.extra}x.was=x.length,x.mode=23;case 23:for(;rt=(z=x.distcode[F&(1<<x.distbits)-1])>>>16&255,ht=65535&z,!((dt=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(!(240&rt)){for(pt=dt,xt=rt,Et=ht;rt=(z=x.distcode[Et+((F&(1<<pt+xt)-1)>>pt)])>>>16&255,ht=65535&z,!(pt+(dt=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}F>>>=pt,V-=pt,x.back+=pt}if(F>>>=dt,V-=dt,x.back+=dt,64&rt){E.msg="invalid distance code",x.mode=30;break}x.offset=ht,x.extra=15&rt,x.mode=24;case 24:if(x.extra){for(k=x.extra;V<k;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}x.offset+=F&(1<<x.extra)-1,F>>>=x.extra,V-=x.extra,x.back+=x.extra}if(x.offset>x.dmax){E.msg="invalid distance too far back",x.mode=30;break}x.mode=25;case 25:if(0===at)break t;if(x.offset>(J=it-at)){if((J=x.offset-J)>x.whave&&x.sane){E.msg="invalid distance too far back",x.mode=30;break}_t=J>x.wnext?x.wsize-(J-=x.wnext):x.wnext-J,J>x.length&&(J=x.length),St=x.window}else St=Y,_t=ct-x.offset,J=x.length;for(at<J&&(J=at),at-=J,x.length-=J;Y[ct++]=St[_t++],--J;);0===x.length&&(x.mode=21);break;case 26:if(0===at)break t;Y[ct++]=x.length,at--,x.mode=21;break;case 27:if(x.wrap){for(;V<32;){if(0===Z)break t;Z--,F|=N[q++]<<V,V+=8}if(E.total_out+=it-=at,x.total+=it,it&&(E.adler=x.check=x.flags?a(x.check,Y,it,ct-it):o(x.check,Y,it,ct-it)),it=at,(x.flags?F:g(F))!==x.check){E.msg="incorrect data check",x.mode=30;break}V=F=0}x.mode=28;case 28:if(x.wrap&&x.flags){for(;V<32;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(F!==(4294967295&x.total)){E.msg="incorrect length check",x.mode=30;break}V=F=0}x.mode=29;case 29:W=1;break t;case 30:W=-3;break t;case 31:return-4;default:return d}return E.next_out=ct,E.avail_out=at,E.next_in=q,E.avail_in=Z,x.hold=F,x.bits=V,(x.wsize||it!==E.avail_out&&x.mode<30&&(x.mode<27||4!==L))&&B(E,E.output,E.next_out,it-E.avail_out)?(x.mode=31,-4):(it-=E.avail_out,E.total_in+=nt-=E.avail_in,E.total_out+=it,x.total+=it,x.wrap&&it&&(E.adler=x.check=x.flags?a(x.check,Y,it,E.next_out-it):o(x.check,Y,it,E.next_out-it)),E.data_type=x.bits+(x.last?64:0)+(12===x.mode?128:0)+(20===x.mode||15===x.mode?256:0),(0==nt&&0===it||4===L)&&0===W&&(W=-5),W)},s.inflateEnd=function(E){if(!E||!E.state)return d;var L=E.state;return L.window&&(L.window=null),E.state=null,0},s.inflateGetHeader=function(E,L){var x;return E&&E.state&&2&(x=E.state).wrap?((x.head=L).done=!1,0):d},s.inflateSetDictionary=function(E,L){var x,N=L.length;return E&&E.state?0!==(x=E.state).wrap&&11!==x.mode?d:11===x.mode&&o(1,L,N,0)!==x.check?-3:B(E,L,N,N)?(x.mode=31,-4):(x.havedict=1,0):d},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(e,i,s){var n=e("../utils/common"),o=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(h,u,f,d,_,m,w,g){var v,T,C,S,M,A,O,I,D,B=g.bits,E=0,L=0,x=0,N=0,Y=0,q=0,ct=0,Z=0,at=0,F=0,V=null,nt=0,it=new n.Buf16(16),J=new n.Buf16(16),_t=null,St=0;for(E=0;E<=15;E++)it[E]=0;for(L=0;L<d;L++)it[u[f+L]]++;for(Y=B,N=15;1<=N&&0===it[N];N--);if(N<Y&&(Y=N),0===N)return _[m++]=20971520,_[m++]=20971520,g.bits=1,0;for(x=1;x<N&&0===it[x];x++);for(Y<x&&(Y=x),E=Z=1;E<=15;E++)if(Z<<=1,(Z-=it[E])<0)return-1;if(0<Z&&(0===h||1!==N))return-1;for(J[1]=0,E=1;E<15;E++)J[E+1]=J[E]+it[E];for(L=0;L<d;L++)0!==u[f+L]&&(w[J[u[f+L]]++]=L);if(A=0===h?(V=_t=w,19):1===h?(V=o,nt-=257,_t=a,St-=257,256):(V=l,_t=c,-1),E=x,M=m,ct=L=F=0,C=-1,S=(at=1<<(q=Y))-1,1===h&&852<at||2===h&&592<at)return 1;for(;;){for(O=E-ct,D=w[L]<A?(I=0,w[L]):w[L]>A?(I=_t[St+w[L]],V[nt+w[L]]):(I=96,0),v=1<<E-ct,x=T=1<<q;_[M+(F>>ct)+(T-=v)]=O<<24|I<<16|D,0!==T;);for(v=1<<E-1;F&v;)v>>=1;if(0!==v?(F&=v-1,F+=v):F=0,L++,0==--it[E]){if(E===N)break;E=u[f+w[L]]}if(Y<E&&(F&S)!==C){for(0===ct&&(ct=Y),M+=x,Z=1<<(q=E-ct);q+ct<N&&!((Z-=it[q+ct])<=0);)q++,Z<<=1;if(at+=1<<q,1===h&&852<at||2===h&&592<at)return 1;_[C=F&S]=Y<<24|q<<16|M-m}}return 0!==F&&(_[M+F]=E-ct<<24|64<<16),g.bits=Y,0}},{"../utils/common":41}],51:[function(e,i,s){i.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(e,i,s){var n=e("../utils/common");function l(z){for(var R=z.length;0<=--R;)z[R]=0}var u=256,f=286,d=30,w=15,A=[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],I=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],D=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],B=new Array(576);l(B);var E=new Array(60);l(E);var L=new Array(512);l(L);var x=new Array(256);l(x);var N=new Array(29);l(N);var Y,q,ct,Z=new Array(d);function at(z,R,X,K,U){this.static_tree=z,this.extra_bits=R,this.extra_base=X,this.elems=K,this.max_length=U,this.has_stree=z&&z.length}function F(z,R){this.dyn_tree=z,this.max_code=0,this.stat_desc=R}function V(z){return z<256?L[z]:L[256+(z>>>7)]}function nt(z,R){z.pending_buf[z.pending++]=255&R,z.pending_buf[z.pending++]=R>>>8&255}function it(z,R,X){z.bi_valid>16-X?(z.bi_buf|=R<<z.bi_valid&65535,nt(z,z.bi_buf),z.bi_buf=R>>16-z.bi_valid,z.bi_valid+=X-16):(z.bi_buf|=R<<z.bi_valid&65535,z.bi_valid+=X)}function J(z,R,X){it(z,X[2*R],X[2*R+1])}function _t(z,R){for(var X=0;X|=1&z,z>>>=1,X<<=1,0<--R;);return X>>>1}function St(z,R,X){var K,U,tt=new Array(16),lt=0;for(K=1;K<=w;K++)tt[K]=lt=lt+X[K-1]<<1;for(U=0;U<=R;U++){var et=z[2*U+1];0!==et&&(z[2*U]=_t(tt[et]++,et))}}function dt(z){var R;for(R=0;R<f;R++)z.dyn_ltree[2*R]=0;for(R=0;R<d;R++)z.dyn_dtree[2*R]=0;for(R=0;R<19;R++)z.bl_tree[2*R]=0;z.dyn_ltree[512]=1,z.opt_len=z.static_len=0,z.last_lit=z.matches=0}function rt(z){8<z.bi_valid?nt(z,z.bi_buf):0<z.bi_valid&&(z.pending_buf[z.pending++]=z.bi_buf),z.bi_buf=0,z.bi_valid=0}function ht(z,R,X,K){var U=2*R,tt=2*X;return z[U]<z[tt]||z[U]===z[tt]&&K[R]<=K[X]}function pt(z,R,X){for(var K=z.heap[X],U=X<<1;U<=z.heap_len&&(U<z.heap_len&&ht(R,z.heap[U+1],z.heap[U],z.depth)&&U++,!ht(R,K,z.heap[U],z.depth));)z.heap[X]=z.heap[U],X=U,U<<=1;z.heap[X]=K}function xt(z,R,X){var K,U,tt,lt,et=0;if(0!==z.last_lit)for(;K=z.pending_buf[z.d_buf+2*et]<<8|z.pending_buf[z.d_buf+2*et+1],U=z.pending_buf[z.l_buf+et],et++,0===K?J(z,U,R):(J(z,(tt=x[U])+u+1,R),0!==(lt=A[tt])&&it(z,U-=N[tt],lt),J(z,tt=V(--K),X),0!==(lt=O[tt])&&it(z,K-=Z[tt],lt)),et<z.last_lit;);J(z,256,R)}function Et(z,R){var X,K,U,tt=R.dyn_tree,lt=R.stat_desc.static_tree,et=R.stat_desc.has_stree,ut=R.stat_desc.elems,vt=-1;for(z.heap_len=0,z.heap_max=573,X=0;X<ut;X++)0!==tt[2*X]?(z.heap[++z.heap_len]=vt=X,z.depth[X]=0):tt[2*X+1]=0;for(;z.heap_len<2;)tt[2*(U=z.heap[++z.heap_len]=vt<2?++vt:0)]=1,z.depth[U]=0,z.opt_len--,et&&(z.static_len-=lt[2*U+1]);for(R.max_code=vt,X=z.heap_len>>1;1<=X;X--)pt(z,tt,X);for(U=ut;X=z.heap[1],z.heap[1]=z.heap[z.heap_len--],pt(z,tt,1),K=z.heap[1],z.heap[--z.heap_max]=X,z.heap[--z.heap_max]=K,tt[2*U]=tt[2*X]+tt[2*K],z.depth[U]=(z.depth[X]>=z.depth[K]?z.depth[X]:z.depth[K])+1,tt[2*X+1]=tt[2*K+1]=U,z.heap[1]=U++,pt(z,tt,1),2<=z.heap_len;);z.heap[--z.heap_max]=z.heap[1],function(wt,$t){var mi,ye,Ee,kt,Fi,ds,we=$t.dyn_tree,Ve=$t.max_code,ce=$t.stat_desc.static_tree,he=$t.stat_desc.has_stree,Jr=$t.stat_desc.extra_bits,gi=$t.stat_desc.extra_base,ei=$t.stat_desc.max_length,_i=0;for(kt=0;kt<=w;kt++)wt.bl_count[kt]=0;for(we[2*wt.heap[wt.heap_max]+1]=0,mi=wt.heap_max+1;mi<573;mi++)ei<(kt=we[2*we[2*(ye=wt.heap[mi])+1]+1]+1)&&(kt=ei,_i++),we[2*ye+1]=kt,Ve<ye||(wt.bl_count[kt]++,Fi=0,gi<=ye&&(Fi=Jr[ye-gi]),wt.opt_len+=(ds=we[2*ye])*(kt+Fi),he&&(wt.static_len+=ds*(ce[2*ye+1]+Fi)));if(0!==_i){do{for(kt=ei-1;0===wt.bl_count[kt];)kt--;wt.bl_count[kt]--,wt.bl_count[kt+1]+=2,wt.bl_count[ei]--,_i-=2}while(0<_i);for(kt=ei;0!==kt;kt--)for(ye=wt.bl_count[kt];0!==ye;)Ve<(Ee=wt.heap[--mi])||(we[2*Ee+1]!==kt&&(wt.opt_len+=(kt-we[2*Ee+1])*we[2*Ee],we[2*Ee+1]=kt),ye--)}}(z,R),St(tt,vt,z.bl_count)}function P(z,R,X){var K,U,tt=-1,lt=R[1],et=0,ut=7,vt=4;for(0===lt&&(ut=138,vt=3),R[2*(X+1)+1]=65535,K=0;K<=X;K++)U=lt,lt=R[2*(K+1)+1],++et<ut&&U===lt||(et<vt?z.bl_tree[2*U]+=et:0!==U?(U!==tt&&z.bl_tree[2*U]++,z.bl_tree[32]++):et<=10?z.bl_tree[34]++:z.bl_tree[36]++,tt=U,vt=(et=0)===lt?(ut=138,3):U===lt?(ut=6,3):(ut=7,4))}function W(z,R,X){var K,U,tt=-1,lt=R[1],et=0,ut=7,vt=4;for(0===lt&&(ut=138,vt=3),K=0;K<=X;K++)if(U=lt,lt=R[2*(K+1)+1],!(++et<ut&&U===lt)){if(et<vt)for(;J(z,U,z.bl_tree),0!=--et;);else 0!==U?(U!==tt&&(J(z,U,z.bl_tree),et--),J(z,16,z.bl_tree),it(z,et-3,2)):et<=10?(J(z,17,z.bl_tree),it(z,et-3,3)):(J(z,18,z.bl_tree),it(z,et-11,7));tt=U,vt=(et=0)===lt?(ut=138,3):U===lt?(ut=6,3):(ut=7,4)}}l(Z);var H=!1;function k(z,R,X,K){var U,tt,lt;it(z,0+(K?1:0),3),tt=R,lt=X,rt(U=z),nt(U,lt),nt(U,~lt),n.arraySet(U.pending_buf,U.window,tt,lt,U.pending),U.pending+=lt}s._tr_init=function(z){H||(function(){var R,X,K,U,tt,lt=new Array(16);for(U=K=0;U<28;U++)for(N[U]=K,R=0;R<1<<A[U];R++)x[K++]=U;for(x[K-1]=U,U=tt=0;U<16;U++)for(Z[U]=tt,R=0;R<1<<O[U];R++)L[tt++]=U;for(tt>>=7;U<d;U++)for(Z[U]=tt<<7,R=0;R<1<<O[U]-7;R++)L[256+tt++]=U;for(X=0;X<=w;X++)lt[X]=0;for(R=0;R<=143;)B[2*R+1]=8,R++,lt[8]++;for(;R<=255;)B[2*R+1]=9,R++,lt[9]++;for(;R<=279;)B[2*R+1]=7,R++,lt[7]++;for(;R<=287;)B[2*R+1]=8,R++,lt[8]++;for(St(B,287,lt),R=0;R<d;R++)E[2*R+1]=5,E[2*R]=_t(R,5);Y=new at(B,A,257,f,w),q=new at(E,O,0,d,w),ct=new at(new Array(0),I,0,19,7)}(),H=!0),z.l_desc=new F(z.dyn_ltree,Y),z.d_desc=new F(z.dyn_dtree,q),z.bl_desc=new F(z.bl_tree,ct),z.bi_buf=0,z.bi_valid=0,dt(z)},s._tr_stored_block=k,s._tr_flush_block=function(z,R,X,K){var U,tt,lt=0;0<z.level?(2===z.strm.data_type&&(z.strm.data_type=function(et){var ut,vt=4093624447;for(ut=0;ut<=31;ut++,vt>>>=1)if(1&vt&&0!==et.dyn_ltree[2*ut])return 0;if(0!==et.dyn_ltree[18]||0!==et.dyn_ltree[20]||0!==et.dyn_ltree[26])return 1;for(ut=32;ut<u;ut++)if(0!==et.dyn_ltree[2*ut])return 1;return 0}(z)),Et(z,z.l_desc),Et(z,z.d_desc),lt=function(et){var ut;for(P(et,et.dyn_ltree,et.l_desc.max_code),P(et,et.dyn_dtree,et.d_desc.max_code),Et(et,et.bl_desc),ut=18;3<=ut&&0===et.bl_tree[2*D[ut]+1];ut--);return et.opt_len+=3*(ut+1)+5+5+4,ut}(z),(tt=z.static_len+3+7>>>3)<=(U=z.opt_len+3+7>>>3)&&(U=tt)):U=tt=X+5,X+4<=U&&-1!==R?k(z,R,X,K):4===z.strategy||tt===U?(it(z,2+(K?1:0),3),xt(z,B,E)):(it(z,4+(K?1:0),3),function(et,ut,vt,wt){var $t;for(it(et,ut-257,5),it(et,vt-1,5),it(et,wt-4,4),$t=0;$t<wt;$t++)it(et,et.bl_tree[2*D[$t]+1],3);W(et,et.dyn_ltree,ut-1),W(et,et.dyn_dtree,vt-1)}(z,z.l_desc.max_code+1,z.d_desc.max_code+1,lt+1),xt(z,z.dyn_ltree,z.dyn_dtree)),dt(z),K&&rt(z)},s._tr_tally=function(z,R,X){return z.pending_buf[z.d_buf+2*z.last_lit]=R>>>8&255,z.pending_buf[z.d_buf+2*z.last_lit+1]=255&R,z.pending_buf[z.l_buf+z.last_lit]=255&X,z.last_lit++,0===R?z.dyn_ltree[2*X]++:(z.matches++,R--,z.dyn_ltree[2*(x[X]+u+1)]++,z.dyn_dtree[2*V(R)]++),z.last_lit===z.lit_bufsize-1},s._tr_align=function(z){var R;it(z,2,3),J(z,256,B),16===(R=z).bi_valid?(nt(R,R.bi_buf),R.bi_buf=0,R.bi_valid=0):8<=R.bi_valid&&(R.pending_buf[R.pending++]=255&R.bi_buf,R.bi_buf>>=8,R.bi_valid-=8)}},{"../utils/common":41}],53:[function(e,i,s){i.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(e,i,s){(function(n){!function(o){if(!o.setImmediate){var l,c,h,u,f=1,d={},_=!1,m=o.document,w=Object.getPrototypeOf&&Object.getPrototypeOf(o);w=w&&w.setTimeout?w:o,l="[object process]"==={}.toString.call(o.process)?function(C){process.nextTick(function(){v(C)})}:function(){if(o.postMessage&&!o.importScripts){var C=!0,S=o.onmessage;return o.onmessage=function(){C=!1},o.postMessage("","*"),o.onmessage=S,C}}()?(u="setImmediate$"+Math.random()+"$",o.addEventListener?o.addEventListener("message",T,!1):o.attachEvent("onmessage",T),function(C){o.postMessage(u+C,"*")}):o.MessageChannel?((h=new MessageChannel).port1.onmessage=function(C){v(C.data)},function(C){h.port2.postMessage(C)}):m&&"onreadystatechange"in m.createElement("script")?(c=m.documentElement,function(C){var S=m.createElement("script");S.onreadystatechange=function(){v(C),S.onreadystatechange=null,c.removeChild(S),S=null},c.appendChild(S)}):function(C){setTimeout(v,0,C)},w.setImmediate=function(C){"function"!=typeof C&&(C=new Function(""+C));for(var S=new Array(arguments.length-1),M=0;M<S.length;M++)S[M]=arguments[M+1];return d[f]={callback:C,args:S},l(f),f++},w.clearImmediate=g}function g(C){delete d[C]}function v(C){if(_)setTimeout(v,0,C);else{var S=d[C];if(S){_=!0;try{!function(M){var A=M.callback,O=M.args;switch(O.length){case 0:A();break;case 1:A(O[0]);break;case 2:A(O[0],O[1]);break;case 3:A(O[0],O[1],O[2]);break;default:A.apply(void 0,O)}}(S)}finally{g(C),_=!1}}}}function T(C){C.source===o&&"string"==typeof C.data&&0===C.data.indexOf(u)&&v(+C.data.slice(u.length))}}(typeof self>"u"?void 0===n?this:n:self)}).call(this,typeof cn<"u"?cn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10);const ul=Bf(hl.exports);class Mr{constructor(t,e){y(this,"date",new Date),y(this,"author"),y(this,"guid",ie.create()),y(this,"viewpoint"),y(this,"modifiedAuthor"),y(this,"modifiedDate"),y(this,"topic"),y(this,"_components"),y(this,"_comment",""),this._components=t,this._comment=e;const i=this._components.get(qt);this.author=i.config.author}set comment(t){var e;const i=this._components.get(qt);this._comment=t,this.modifiedDate=new Date,this.modifiedAuthor=i.config.author,null==(e=this.topic)||e.comments.set(this.guid,this)}get comment(){return this._comment}toJSON(){var t,e;const i={guid:this.guid,date:this.date.toISOString(),author:this.author,comment:this.comment,topic_guid:null==(t=this.topic)?void 0:t.guid,viewpoint_guid:this.viewpoint,modified_date:null==(e=this.modifiedDate)?void 0:e.toISOString(),modified_author:this.modifiedAuthor};for(const[s,n]of Object.entries(i))void 0===n&&delete i[s];return i}}const dl=class ri{constructor(t){y(this,"guid",ie.create()),y(this,"title",ri.default.title),y(this,"creationDate",new Date),y(this,"creationAuthor",""),y(this,"viewpoints",new ot.PG),y(this,"relatedTopics",new ot.PG),y(this,"comments",new ot.jp),y(this,"documentReferences",new ot.PG),y(this,"customData",{}),y(this,"description"),y(this,"serverAssignedId"),y(this,"dueDate"),y(this,"modifiedAuthor"),y(this,"modifiedDate"),y(this,"index"),y(this,"_type",ri.default.type),y(this,"_status",ri.default.status),y(this,"_priority",ri.default.priority),y(this,"_stage",ri.default.stage),y(this,"_assignedTo",ri.default.assignedTo),y(this,"_labels",ri.default.labels??new Set),y(this,"_components"),this._components=t;const e=t.get(qt);this.creationAuthor=e.config.author,this.relatedTopics.guard=i=>i!==this.guid}set type(t){const e=this._components.get(qt),{strict:i,types:s}=e.config;(!i||s.has(t))&&(this._type=t)}get type(){return this._type}set status(t){const e=this._components.get(qt),{strict:i,statuses:s}=e.config;(!i||s.has(t))&&(this._status=t)}get status(){return this._status}set priority(t){const e=this._components.get(qt);if(t){const{strict:i,priorities:s}=e.config;if(i&&!s.has(t))return;this._priority=t}else this._priority=t}get priority(){return this._priority}set stage(t){const e=this._components.get(qt);if(t){const{strict:i,stages:s}=e.config;if(i&&!s.has(t))return;this._stage=t}else this._stage=t}get stage(){return this._stage}set assignedTo(t){const e=this._components.get(qt);if(t){const{strict:i,users:s}=e.config;if(i&&!s.has(t))return;this._assignedTo=t}else this._assignedTo=t}get assignedTo(){return this._assignedTo}set labels(t){const e=this._components.get(qt),{strict:i,labels:s}=e.config;if(i){const n=new Set;for(const o of t)(!i||s.has(o))&&n.add(o);this._labels=n}else this._labels=t}get labels(){return this._labels}get _managerVersion(){return this._components.get(qt).config.version}set(t){const e=t,i=this;for(const n in t)"guid"!==n&&n in this&&(i[n]=e[n]);return this._components.get(qt).list.set(this.guid,this),this}createComment(t,e){const i=new Mr(this._components,t);return i.viewpoint=e,i.topic=this,this.comments.set(i.guid,i),i}createLabelTags(){const t=[...this.labels];if(this._components.get(qt).config.exportCustomDataAsLabels)for(const i in this.customData){const s=this.customData[i];"string"==typeof s&&t.push(s)}return t}createCommentTags(){return[...this.comments.values()].map(t=>{var e;return{$Guid:t.guid,Date:t.date.toISOString(),Author:t.author,Comment:t.comment,ModifiedAuthor:t.modifiedAuthor,ModifiedDate:null==(e=t.modifiedDate)?void 0:e.toISOString(),Viewpoint:t.viewpoint?{$Guid:t.viewpoint}:void 0}})}createViewpointTags(){const t=this._components.get(Be);return[...this.viewpoints].map(i=>t.list.get(i)).filter(i=>i).map(i=>{const s={$Guid:i.guid,Viewpoint:`${i.title??i.guid}.bcfv`};if(t.snapshots.get(i.snapshot)){const o=t.getSnapshotExtension(i.snapshot);s.Snapshot=`${i.snapshot}.${o}`}return s})}createRelatedTopicTags(){return[...this.relatedTopics].map(t=>({$Guid:t}))}createDocumentReferencesTag(t=this._managerVersion){const e=[];if("3"!==t&&"2.1"!==t)return e;const i=this._components.get(qt);for(const s of this.documentReferences){const n=i.documents.get(s);if(!n)continue;let o={$Guid:ie.create(),Description:n.description};"2.1"===t&&(o={...o,$isExternal:"external"===n.type||void 0,ReferencedDocument:"external"===n.type?n.url:`../${n.fileName}`}),"3"===t&&(o={...o,DocumentGuid:"internal"===n.type?s:void 0,Url:"external"===n.type?n.url:void 0}),Object.keys(o).length>0&&e.push(o)}return e}toJSON(){var t,e;const i={guid:this.guid,server_assigned_id:this.serverAssignedId,topic_type:this.type,topic_status:this.status,title:this.title,priority:this.priority,index:this.index,labels:[...this.labels],creation_date:this.creationDate.toISOString(),creation_author:this.creationAuthor,modified_date:null==(t=this.modifiedDate)?void 0:t.toISOString(),modified_author:this.modifiedAuthor,assigned_to:this.assignedTo,stage:this.stage,description:this.description,due_date:null==(e=this.dueDate)?void 0:e.toISOString(),comments:[...this.comments].map(([o,a])=>a.toJSON()),relatedTopics:[...this.relatedTopics].map(o=>({related_topic_guid:o}))},s=this._components.get(Be);for(const o of this.viewpoints){const a=s.list.get(o);a&&(i.viewpoints||(i.viewpoints=[]),i.viewpoints.push(a.toJSON()))}const n=this._components.get(qt);for(const o of this.documentReferences){const a=n.documents.get(o);a&&(i.document_references||(i.document_references=[]),i.document_references.push("external"===a.type?{guid:ie.create(),description:a.description,url:a.url}:{guid:ie.create(),description:a.description,document_guid:o}))}for(const[o,a]of Object.entries(i))(void 0===a||Array.isArray(a)&&0===a.length)&&delete i[o];return i}serialize(){var t,e;const i=this._managerVersion,s={$Guid:this.guid,$TopicType:this.type,$TopicStatus:this.status,$ServerAssignedId:this.serverAssignedId,Title:this.title,CreationAuthor:this.creationAuthor,CreationDate:this.creationDate.toISOString(),Priority:this.priority,Index:"2.1"===i?this.index:void 0,ModifiedDate:null==(t=this.modifiedDate)?void 0:t.toISOString(),ModifiedAuthor:this.modifiedAuthor,DueDate:null==(e=this.dueDate)?void 0:e.toISOString(),AssignedTo:this.assignedTo,Description:this.description,Stage:this.stage,DocumentReferences:"3"===i?{DocumentReference:this.createDocumentReferencesTag(i)}:void 0,RelatedTopics:"3"===i?{RelatedTopic:this.createRelatedTopicTags()}:void 0,RelatedTopic:"2.1"===i?this.createRelatedTopicTags():void 0,Labels:"3"===i?{Label:this.createLabelTags()}:void 0,Viewpoints:"3"===i?{ViewPoint:this.createViewpointTags()}:void 0,Comments:"3"===i?{Comment:this.createCommentTags()}:void 0};"2.1"===i&&(s.Labels=this.createLabelTags(),s.DocumentReference=this.createDocumentReferencesTag(i));const n={Markup:{Topic:s}};return"2.1"===i&&(n.Markup.Viewpoints=this.createViewpointTags(),n.Markup.Comment=this.createCommentTags()),`<?xml version="1.0" encoding="UTF-8"?>\n ${Ts.builder.build(n)}`}};y(dl,"default",{title:"BCF Topic",type:"Issue",status:"Active"});let fl=dl;class Vf extends Wi{constructor(){super(...arguments),y(this,"_config",{version:{type:"Select",options:new Set(["2.1","3"]),multiple:!1,value:""},author:{type:"Text",value:""},types:{type:"TextSet",value:new Set},statuses:{type:"TextSet",value:new Set},priorities:{type:"TextSet",value:new Set},labels:{type:"TextSet",value:new Set},stages:{type:"TextSet",value:new Set},users:{type:"TextSet",value:new Set},includeSelectionTag:{type:"Boolean",value:!1},updateExtensionsOnImport:{type:"Boolean",value:!1},strict:{type:"Boolean",value:!1},includeAllExtensionsOnExport:{type:"Boolean",value:!1},fallbackVersionOnImport:{type:"Select",multiple:!1,options:new Set(["2.1","3"]),value:""},ignoreIncompleteTopicsOnImport:{type:"Boolean",value:!1},exportCustomDataAsLabels:{type:"Boolean",value:!1}})}get version(){return this._config.version.value}set version(t){this._config.version.value=t}get author(){return this._config.author.value}set author(t){this._config.author.value=t}get types(){return this._config.types.value}set types(t){this._config.types.value=t}get statuses(){return this._config.statuses.value}set statuses(t){this._config.statuses.value=t}get priorities(){return this._config.priorities.value}set priorities(t){this._config.priorities.value=t}get labels(){return this._config.labels.value}set labels(t){this._config.labels.value=t}get stages(){return this._config.stages.value}set stages(t){this._config.stages.value=t}get users(){return this._config.users.value}set users(t){this._config.users.value=t}get includeSelectionTag(){return this._config.includeSelectionTag.value}set includeSelectionTag(t){this._config.includeSelectionTag.value=t}get updateExtensionsOnImport(){return this._config.updateExtensionsOnImport.value}set updateExtensionsOnImport(t){this._config.updateExtensionsOnImport.value=t}get strict(){return this._config.strict.value}set strict(t){this._config.strict.value=t}get includeAllExtensionsOnExport(){return this._config.includeAllExtensionsOnExport.value}set includeAllExtensionsOnExport(t){this._config.includeAllExtensionsOnExport.value=t}get fallbackVersionOnImport(){return this._config.fallbackVersionOnImport.value}set fallbackVersionOnImport(t){this._config.fallbackVersionOnImport.value=t}get ignoreIncompleteTopicsOnImport(){return this._config.ignoreIncompleteTopicsOnImport.value}set ignoreIncompleteTopicsOnImport(t){this._config.ignoreIncompleteTopicsOnImport.value=t}get exportCustomDataAsLabels(){return this._config.exportCustomDataAsLabels.value}set exportCustomDataAsLabels(t){this._config.exportCustomDataAsLabels.value=t}}const Ir=class ms extends At{constructor(){super(...arguments),y(this,"enabled",!1),y(this,"_defaultConfig",{author:"jhon.doe@example.com",version:"2.1",types:new Set(["Clash","Failure","Fault","Inquiry","Issue","Remark","Request"]),statuses:new Set(["Active","In Progress","Done","In Review","Closed"]),priorities:new Set(["On hold","Minor","Normal","Major","Critical"]),labels:new Set,stages:new Set,users:new Set,includeSelectionTag:!1,updateExtensionsOnImport:!0,strict:!1,includeAllExtensionsOnExport:!0,fallbackVersionOnImport:"2.1",ignoreIncompleteTopicsOnImport:!1,exportCustomDataAsLabels:!1}),y(this,"config",new Vf(this,this.components,"BCF Topics",ms.uuid)),y(this,"list",new ot.jp),y(this,"documents",new ot.jp),y(this,"onSetup",new Q),y(this,"isSetup",!1),y(this,"onBCFImported",new Q),y(this,"onDisposed",new Q)}setup(t){if(this.isSetup)return;const e={...this._defaultConfig,...t};this.config.version=e.version,this.config.author=e.author,this.config.types=e.types,this.config.statuses=e.statuses,this.config.priorities=e.priorities,this.config.labels=e.labels,this.config.stages=e.stages,this.config.users=e.users,this.config.includeSelectionTag=e.includeSelectionTag,this.config.updateExtensionsOnImport=e.updateExtensionsOnImport,this.config.strict=e.strict,this.config.includeAllExtensionsOnExport=e.includeAllExtensionsOnExport,this.config.fallbackVersionOnImport=e.fallbackVersionOnImport||"",this.config.ignoreIncompleteTopicsOnImport=e.ignoreIncompleteTopicsOnImport,this.isSetup=!0,this.enabled=!0,this.onSetup.trigger()}create(t){const e=new fl(this.components);return t?(e.guid=t.guid??e.guid,e.set(t)):this.list.set(e.guid,e),e}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}get usedTypes(){const t=[...this.list].map(([e,i])=>i.type);return new Set(t)}get usedStatuses(){const t=[...this.list].map(([e,i])=>i.status);return new Set(t)}get usedPriorities(){const t=[...this.list].map(([e,i])=>i.priority).filter(e=>e);return new Set(t)}get usedStages(){const t=[...this.list].map(([e,i])=>i.stage).filter(e=>e);return new Set(t)}get usedUsers(){const t=[];for(const[e,i]of this.list){t.push(i.creationAuthor),i.assignedTo&&t.push(i.assignedTo),i.modifiedAuthor&&t.push(i.modifiedAuthor);for(const[s,n]of i.comments)t.push(n.author),n.modifiedAuthor&&t.push(n.modifiedAuthor)}return new Set(t)}get usedLabels(){const t=[];for(const[e,i]of this.list)t.push(...i.labels);return new Set(t)}updateExtensions(){for(const[t,e]of this.list){for(const i of e.labels)this.config.labels.add(i);this.config.types.add(e.type),e.priority&&this.config.priorities.add(e.priority),e.stage&&this.config.stages.add(e.stage),this.config.statuses.add(e.status),this.config.users.add(e.creationAuthor),e.assignedTo&&this.config.users.add(e.assignedTo),e.modifiedAuthor&&this.config.users.add(e.modifiedAuthor);for(const[i,s]of e.comments)this.config.users.add(s.author),s.modifiedAuthor&&this.config.users.add(s.modifiedAuthor)}}updateViewpointReferences(){const t=this.components.get(Be);for(const[e,i]of this.list)for(const s of i.viewpoints)t.list.has(s)||i.viewpoints.delete(s)}export(){var t=this;return(0,G.A)(function*(e=t.list.values()){const i=new ul;i.file("bcf.version",`<?xml version="1.0" encoding="UTF-8"?>\n <Version VersionId="${t.config.version}" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/buildingSMART/BCF-XML/release_3_0/Schemas/version.xsd"\n xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n </Version>`);for(const[o,a]of t.documents.entries())"external"!==a.type&&i.file("2.1"===t.config.version?a.fileName:`documents/${o}`,a.data);if("3"===t.config.version){const o=[];for(const[a,l]of t.documents.entries()){const{type:c,description:h}=l;"external"!==c&&o.push(`<Document Guid="${a}">\n <Filename>${l.fileName}</Filename>\n ${h?`<Description>${h}</Description>`:""}\n </Document>`)}o.length>0&&i.file("documents.xml",`<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n <DocumentInfo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="documents.xsd">\n <Documents>\n ${o.join("\n")}\n </Documents>\n </DocumentInfo>`)}i.file("bcf.extensions",t.serializeExtensions());const s=t.components.get(Be);for(const o of e){const a=i.folder(o.guid);a.file("markup.bcf",o.serialize());for(const l of o.viewpoints){const c=s.list.get(l);if(!c)continue;a.file(`${c.title??c.guid}.bcfv`,yield c.serialize());const u=s.snapshots.get(c.snapshot);if(!u)continue;const f=u?c.snapshot:c.guid,d=s.getSnapshotExtension(c.snapshot);a.file(`${f}.${d}`,u,{binary:!0})}}return yield i.generateAsync({type:"blob"})}).apply(this,arguments)}serializeExtensions(){const t=[...this.config.types].map(a=>`<TopicType>${a}</TopicType>`).join("\n"),e=[...this.config.statuses].map(a=>`<TopicStatus>${a}</TopicStatus>`).join("\n"),i=[...this.config.priorities].map(a=>`<Priority>${a}</Priority>`).join("\n"),s=[...this.config.labels].map(a=>`<TopicLabel>${a}</TopicLabel>`).join("\n"),n=[...this.config.stages].map(a=>`<Stage>${a}</Stage>`).join("\n"),o=[...this.config.users].map(a=>`<User>${a}</User>`).join("\n");return`\n <?xml version="1.0" encoding="UTF-8"?>\n <Extensions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="your-schema-location.xsd">\n ${0!==t.length?`<TopicTypes>\n${t}\n</TopicTypes>`:""}\n ${0!==e.length?`<TopicStatuses>\n${e}\n</TopicStatuses>`:""}\n ${0!==i.length?`<Priorities>\n${i}\n</Priorities>`:""}\n ${0!==s.length?`<TopicLabels>\n${s}\n</TopicLabels>`:""}\n ${0!==n.length?`<Stages>\n${n}\n</Stages>`:""}\n ${0!==o.length?`<Users>\n${o}\n</Users>`:""}\n </Extensions>\n `}processMarkupComment(t){const{Guid:e,Date:i,Author:s,Comment:n,Viewpoint:o}=t;if(!(e&&i&&s&&Mr))return null;const a=new Mr(this.components,n??"");return a.guid=e,a.date=new Date(i),a.author=s,a.viewpoint=o?.Guid,a.modifiedAuthor=t.ModifiedAuthor,a.modifiedDate=t.ModifiedDate?new Date(t.ModifiedDate):void 0,a}getMarkupComments(t,e){var i;let s;if("2.1"===e&&(s=t.Comment),"3"===e&&(s=null==(i=t.Topic.Comments)?void 0:i.Comment),!s)return[];s=Array.isArray(s)?s:[s];const n=s.map(a=>this.processMarkupComment(a)).filter(a=>a);return Array.isArray(n)?n:[n]}getMarkupLabels(t,e){var i;let s;return"2.1"===e&&(s=t.Topic.Labels),"3"===e&&(s=null==(i=t.Topic.Labels)?void 0:i.Label),s?Array.isArray(s)?s:[s]:[]}getMarkupViewpoints(t,e){var i;let s;return"2.1"===e&&(s=t.Viewpoints),"3"===e&&(s=null==(i=t.Topic.Viewpoints)?void 0:i.ViewPoint),s?(s=Array.isArray(s)?s:[s],s):[]}getMarkupRelatedTopics(t,e){var i;let s;return"2.1"===e&&(s=t.Topic.RelatedTopic),"3"===e&&(s=null==(i=t.Topic.RelatedTopics)?void 0:i.RelatedTopic),s?(Array.isArray(s)?s:[s]).map(o=>o.Guid):[]}getMarkupDocumentReferences(t,e){var i;let s;return"2.1"===e&&(s=t.Topic.DocumentReference),"3"===e&&(s=null==(i=t.Topic.DocumentReferences)?void 0:i.DocumentReference),s?Array.isArray(s)?s:[s]:[]}load(t){var e=this;return(0,G.A)(function*(){var i,s,n;const{fallbackVersionOnImport:o,ignoreIncompleteTopicsOnImport:a,updateExtensionsOnImport:l}=e.config,c=new ul;yield c.loadAsync(t);const h=Object.values(c.files);let u=o;const f=h.find(C=>C.name.endsWith(".version"));if(f){const C=yield f.async("string"),S=ms.xmlParser.parse(C).Version.VersionId;u=String(S)}if(!u||"2.1"!==u&&"3"!==u)throw new Error(`BCFTopics: ${u} is not supported.`);const d=h.find(C=>C.name.endsWith(".extensions"));if(l&&d){const C=yield d.async("string");((r,t)=>{if(""===t.trim())return;const e=qt.xmlParser.parse(t).Extensions;if(!e)return;const{Priorities:i,TopicStatuses:s,TopicTypes:n,Users:o}=e;if(i&&i.Priority){const a=Array.isArray(i.Priority)?i.Priority:[i.Priority];for(const l of a)r.config.priorities.add(l)}if(s&&s.TopicStatus){const a=Array.isArray(s.TopicStatus)?s.TopicStatus:[s.TopicStatus];for(const l of a)r.config.statuses.add(l)}if(n&&n.TopicType){const a=Array.isArray(n.TopicType)?n.TopicType:[n.TopicType];for(const l of a)r.config.types.add(l)}if(o&&o.User){const a=Array.isArray(o.User)?o.User:[o.User];for(const l of a)r.config.users.add(l)}})(e,C)}const _=[],m=e.components.get(Be),w=h.filter(C=>C.name.endsWith(".bcfv"));for(const C of w){const S=yield C.async("string"),M=ms.xmlParser.parse(S).VisualizationInfo;if(!M){console.warn("Missing VisualizationInfo in Viewpoint");continue}const A={},{Guid:O,ClippingPlanes:I,Components:D,OrthogonalCamera:B,PerspectiveCamera:E}=M;if(O&&(A.guid=O),D){const x={selection:[],coloring:[],visibility:{default_visibility:!1,exceptions:[],view_setup_hints:{spaces_visible:!1,space_boundaries_visible:!1,openings_visible:!1}}};A.components=x;const{Selection:N,Visibility:Y}=D;if(N&&N.Component){const Z=Array.isArray(N.Component)?N.Component:[N.Component];x.selection=Z.map(at=>at.IfcGuid?{ifc_guid:at.IfcGuid}:null).filter(at=>null!==at)}if(Y&&"DefaultVisibility"in Y&&(x.visibility.default_visibility=Y.DefaultVisibility),Y&&Y.Exceptions&&"Component"in Y.Exceptions){const{Component:Z}=Y.Exceptions,at=Array.isArray(Z)?Z:[Z];x.visibility.exceptions=at.map(F=>F.IfcGuid?{ifc_guid:F.IfcGuid}:null).filter(F=>null!==F)}let q;"2.1"===u&&(q=D.ViewSetupHints),"3"===u&&(q=null==(i=D.Visibility)?void 0:i.ViewSetupHints),q&&("OpeningsVisible"in q&&(x.visibility.view_setup_hints.openings_visible=q.OpeningsVisible),"SpacesVisible"in q&&(x.visibility.view_setup_hints.spaces_visible=q.SpacesVisible),"SpaceBoundariesVisible"in q&&(x.visibility.view_setup_hints.space_boundaries_visible=q.SpaceBoundariesVisible));const{Coloring:ct}=D;if(ct&&ct.Color){const Z=Array.isArray(ct.Color)?ct.Color:[ct.Color];for(const at of Z){const{Color:F,Component:V}=at;if(6!==F.length&&8!==F.length)continue;const nt=6===F.length?F:F.slice(2),J=(Array.isArray(V)?V:[V]).map(_t=>_t.IfcGuid?{ifc_guid:_t.IfcGuid}:null).filter(_t=>null!==_t);x.coloring.push({color:nt,components:J})}}}if(B||E){const x=M.PerspectiveCamera??M.OrthogonalCamera,{CameraViewPoint:N,CameraDirection:Y}=x,q=new p.Pq0(Number(N.X),Number(N.Z),Number(-N.Y)),ct=new p.Pq0(Number(Y.X),Number(Y.Z),Number(-Y.Y)),Z={camera_view_point:{x:q.x,y:q.y,z:q.z},camera_direction:{x:ct.x,y:ct.y,z:ct.z},aspect_ratio:"AspectRatio"in x?x.AspectRatio:1,camera_up_vector:{x:0,y:0,z:0}};"ViewToWorldScale"in x&&(A.orthogonal_camera={...Z,view_to_world_scale:x.ViewToWorldScale}),"FieldOfView"in x&&(A.perspective_camera={...Z,field_of_view:x.FieldOfView})}if(I){const N=(Array.isArray(I.ClippingPlane)?I.ClippingPlane:[I.ClippingPlane]).map(({Location:Y,Direction:q})=>({location:{x:Y.x,y:Y.y,z:Y.z},direction:{x:q.x,y:q.y,z:q.z}}));A.clipping_planes=N}const L=new ml(e.components,A);_.push(L)}const g={},v=[],T=h.filter(C=>C.name.endsWith(".bcf"));for(const C of T){const S=yield C.async("string"),M=ms.xmlParser.parse(S).Markup,A=M.Topic,{Guid:O,TopicType:I,TopicStatus:D,Title:B,CreationDate:E,CreationAuthor:L}=A;if(a&&!(O&&I&&D&&B&&E&&L))continue;const x=new fl(e.components);x.guid=O??x.guid;const N=e.getMarkupRelatedTopics(M,u);g[x.guid]=new Set(N),x.type=I??x.type,x.status=D??x.status,x.title=B??x.title,x.creationDate=E?new Date(E):x.creationDate,x.creationAuthor=L??x.creationAuthor,x.serverAssignedId=A.ServerAssignedId,x.priority=A.Priority,x.index=A.Index,x.modifiedDate=A.ModifiedDate?new Date(A.ModifiedDate):void 0,x.modifiedAuthor=A.ModifiedAuthor,x.dueDate=A.DueDate?new Date(A.DueDate):void 0,x.assignedTo=A.AssignedTo,x.description=A.Description,x.stage=A.Stage;const Y=e.getMarkupLabels(M,u);for(const nt of Y)x.labels.add(nt);const q=e.getMarkupComments(M,u);for(const nt of q)x.comments.set(nt.guid,nt);const ct=e.getMarkupViewpoints(M,u);for(const nt of ct){if(!nt||!nt.Guid)continue;const it=m.list.get(nt.Guid);if(!it)continue;x.viewpoints.add(it.guid);const J=`${x.guid}/${nt.Snapshot}`,_t=h.find(({name:St})=>St===J);if(_t){const St=yield _t.async("arraybuffer"),dt=new Uint8Array(St);m.snapshots.set(it.guid,dt),it.snapshot=it.guid??null}}const Z=e.getMarkupDocumentReferences(M,u),at=h.find(nt=>"documents.xml"===nt.name);let F=[];const V=yield at?.async("string");if(V){const nt=null==(n=null==(s=Ts.parser.parse(V).DocumentInfo)?void 0:s.Documents)?void 0:n.Document;F=Array.isArray(nt)?nt:[nt]}for(const nt of Z){const{Description:it,DocumentGuid:J,Url:_t,isExternal:St,ReferencedDocument:dt}=nt;if(J&&F.length>0){const rt=F.find(({Guid:P})=>P===J),ht=h.find(P=>P.name.endsWith(J)),pt=yield ht?.async("uint8array");if(!rt||!pt)continue;const{Description:xt,Filename:Et}=rt;e.documents.set(J,{type:"internal",fileName:Et,description:xt,data:pt}),x.documentReferences.add(J)}if(_t){const rt=e.documents.add({type:"external",url:_t,description:it});x.documentReferences.add(rt)}if(dt){let rt=null;if(St)rt=e.documents.add({type:"external",url:dt,description:it});else{const ht=dt.split("/"),pt=ht[ht.length-1],xt=h.find(P=>P.name.endsWith(pt)),Et=yield xt?.async("uint8array");if(!Et)continue;rt=e.documents.add({type:"internal",fileName:pt,data:Et,description:it})}x.documentReferences.add(rt)}}e.list.set(x.guid,x),v.push(x)}for(const C in g){const S=e.list.get(C);if(!S)continue;const M=g[C];for(const A of M)S.relatedTopics.add(A)}return e.onBCFImported.trigger(v),{viewpoints:_,topics:v}})()}};y(Ir,"uuid","de977976-e4f6-4e4f-a01a-204727839802"),y(Ir,"xmlParser",new Fn({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0}));let qt=Ir;class Or{constructor(t,e,i,s,n,o=5,a=!0){var l;if(y(this,"onDraggingStarted",new Q),y(this,"onDraggingEnded",new Q),y(this,"onDisposed",new Q),y(this,"normal"),y(this,"origin"),y(this,"three",new p.Zcv),y(this,"components"),y(this,"world"),y(this,"type","default"),y(this,"_title","Clipping Plane"),y(this,"_helper"),y(this,"_visible",!0),y(this,"_enabled",!0),y(this,"_controlsActive",!1),y(this,"_arrowBoundBox",new p.eaF),y(this,"_planeMesh"),y(this,"_controls"),y(this,"_hiddenMaterial",new p.V9B({visible:!1})),y(this,"_sizeMultiplier",5),y(this,"_autoScale",!0),y(this,"_visibilityBeforeDisabled",!0),y(this,"notifyManager",()=>{const h=this.components.get(ti),u=h.list.getKey(this);u&&h.list.set(u,this)}),y(this,"update",()=>{this._enabled&&(this.three.setFromNormalAndCoplanarPoint(this.normal,this._helper.position),this.updateScale())}),y(this,"updateScale",()=>{var h;if(!this.autoScale)return;const u=null==(h=this.world.camera)?void 0:h.three;if(!(u&&u instanceof p.ubm))return;const f=new p.Pq0;u.getWorldPosition(f);const _=f.distanceTo(this._helper.position)/7*this._sizeMultiplier;this._planeMesh.scale.set(_,_,_)}),y(this,"changeDrag",h=>{this._visible=!h.value,this.preventCameraMovement(),this.notifyDraggingChanged(h)}),this.components=t,this.world=e,!e.renderer)throw new Error("The given world must have a renderer!");this.normal=s,this.origin=i,this._sizeMultiplier=o;const c=t.get(ti);e.renderer.setPlane(!0,this.three,c.localClippingPlanes),this._planeMesh=Or.newPlaneMesh(o,n),this._helper=this.newHelper(),this._controls=this.newTransformControls(),this.three.setFromNormalAndCoplanarPoint(s,i),a&&this.toggleControls(!0),this.updateScale(),null!=(l=e.camera)&&l.controls&&e.camera.controls.addEventListener("update",this.updateScale)}set title(t){this._title=t,this.notifyManager()}get title(){return this._title}get autoScale(){return this._autoScale}set autoScale(t){this._autoScale=t,t&&this.updateScale()}get enabled(){return this._enabled}set enabled(t){if(this.world.isDisposing)return;if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");this._enabled=t,t?this.visible=this._visibilityBeforeDisabled:(this._visibilityBeforeDisabled=this.visible,this.visible=!1);const e=this.components.get(ti);this.world.renderer.setPlane(t,this.three,e.localClippingPlanes),this.notifyManager()}get visible(){return this._visible}set visible(t){this._visible=t,this._controls.getHelper().visible=t,this._helper.visible=t,this.toggleControls(t),this.notifyManager()}get meshes(){return[this._planeMesh,this._arrowBoundBox]}get planeMaterial(){return this._planeMesh.material}set planeMaterial(t){this._planeMesh.material=t}get size(){return this._sizeMultiplier}set size(t){this._sizeMultiplier=t,this.autoScale?this.updateScale():this._planeMesh.scale.set(t,t,t)}get helper(){return this._helper}get controls(){return this._controls}setFromNormalAndCoplanarPoint(t,e){this.reset(),this.normal.equals(t)||(this.normal.copy(t),this._helper.lookAt(t)),this.origin.copy(e),this._helper.position.copy(e),this._helper.updateMatrix(),this.update()}dispose(){var t;this._enabled=!1,null!=(t=this.world.camera)&&t.controls&&this.world.camera.controls.removeEventListener("update",this.updateScale),this.onDraggingStarted.reset(),this.onDraggingEnded.reset(),this._helper.removeFromParent(),this.world.renderer&&this.world.renderer.setPlane(!1,this.three),this._arrowBoundBox.removeFromParent(),this._arrowBoundBox.geometry.dispose(),this._planeMesh.geometry.dispose(),this._controls.getHelper().removeFromParent(),this._controls.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}reset(){const t=new p.Pq0(1,0,0),e=new p.Pq0;this.normal.equals(t)||(this.normal.copy(t),this._helper.lookAt(t)),this.origin.copy(e),this._helper.position.copy(e),this._helper.updateMatrix()}toggleControls(t){if(t){if(this._controlsActive)return;this._controls.addEventListener("change",this.update),this._controls.addEventListener("dragging-changed",this.changeDrag)}else this._controls.removeEventListener("change",this.update),this._controls.removeEventListener("dragging-changed",this.changeDrag);this._controlsActive=t}newTransformControls(){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");const i=new sh.ZU(this.world.camera.three,this.world.renderer.three.domElement);return this.initializeControls(i),this.world.scene.three.add(i.getHelper()),i}initializeControls(t){t.attach(this._helper),t.showX=!1,t.showY=!1,t.setSpace("local"),this.createArrowBoundingBox(),t.getHelper().children[0].children[0].add(this._arrowBoundBox)}createArrowBoundingBox(){this._arrowBoundBox.geometry=new p.Ho_(.18,.18,1.2),this._arrowBoundBox.material=this._hiddenMaterial,this._arrowBoundBox.rotateX(Math.PI/2),this._arrowBoundBox.updateMatrix(),this._arrowBoundBox.geometry.applyMatrix4(this._arrowBoundBox.matrix)}notifyDraggingChanged(t){t.value?this.onDraggingStarted.trigger():this.onDraggingEnded.trigger()}preventCameraMovement(){this.world.camera.enabled=this._visible}newHelper(){const t=new p.B69;return t.lookAt(this.normal),t.position.copy(this.origin),this._planeMesh.position.z+=.01,t.add(this._planeMesh),this.world.scene.three.add(t),t}static newPlaneMesh(t,e){const i=new p.bdM(1),s=new p.eaF(i,e);return s.scale.set(t,t,t),s}}class Uf extends Wi{constructor(){super(...arguments),y(this,"_config",{enabled:{value:!0,type:"Boolean"},visible:{value:!0,type:"Boolean"},color:{value:new p.Q1f,type:"Color"},opacity:{type:"Number",interpolable:!0,value:1,min:0,max:1},size:{type:"Number",interpolable:!0,value:2,min:0,max:100}})}get enabled(){return this._config.enabled.value}set enabled(t){this._config.enabled.value=t,this._component.enabled=t}get visible(){return this._config.visible.value}set visible(t){this._config.visible.value=t,this._component.visible=t}get color(){return this._config.color.value}set color(t){this._config.color.value=t,this._component.material.color.copy(t)}get opacity(){return this._config.opacity.value}set opacity(t){this._config.opacity.value=t,this._component.material.opacity=t}get size(){return this._config.size.value}set size(t){this._config.size.value=t,this._component.size=t}}const pl=class yn extends At{constructor(t){super(t),y(this,"onSetup",new Q),y(this,"onBeforeDrag",new Q),y(this,"onAfterDrag",new Q),y(this,"onBeforeCreate",new Q),y(this,"onBeforeCancel",new Q),y(this,"onAfterCancel",new Q),y(this,"onBeforeDelete",new Q),y(this,"onAfterCreate",new Q),y(this,"onAfterDelete",new Q),y(this,"onDisposed",new Q),y(this,"isSetup",!1),y(this,"orthogonalY",!1),y(this,"toleranceOrthogonalY",.7),y(this,"autoScalePlanes",!0),y(this,"localClippingPlanes",!1),y(this,"Type",Or),y(this,"list",new ot.jp),y(this,"config",new Uf(this,this.components,"Clipper",yn.uuid)),y(this,"_defaultConfig",{color:new p.Q1f(12255487),opacity:.2,size:2}),y(this,"_material",new p.V9B({color:12255487,side:p.$EB,transparent:!0,opacity:.2})),y(this,"_size",5),y(this,"_enabled",!1),y(this,"_visible",!0),y(this,"onStateChanged",new Q),this.components.add(yn.uuid,this),this.setEvents()}get enabled(){return this._enabled}set enabled(t){this._enabled=t,this.onStateChanged.trigger(["enabled"])}get visible(){return this._visible}set visible(t){this._visible=t;for(const[e,i]of this.list)i.visible=t;this.onStateChanged.trigger(["visibility"])}get material(){return this._material}set material(t){this._material=t;for(const[e,i]of this.list)i.planeMaterial=t;this.onStateChanged.trigger(["material"])}get size(){return this._size}set size(t){this._size=t;for(const[e,i]of this.list)i.size=t;this.onStateChanged.trigger(["size"])}setEvents(){this.list.onBeforeDelete.add(({value:e})=>{if(!e.world.renderer)throw new Error("Renderer not found for this plane's world!");e.world.renderer.setPlane(!1,e.three),e.dispose(),this.updateMaterialsAndPlanes(),this.onAfterDelete.trigger(e)});const t=this.components.get(ft);if(t.initialized)this.subscribeToFragmentMaterials();else{const e=()=>{t.onFragmentsLoaded.remove(e),this.subscribeToFragmentMaterials()};t.onFragmentsLoaded.add(e)}}subscribeToFragmentMaterials(){const t=this.components.get(ft);for(const[,e]of t.core.models.materials.list)this.applyClippingToFragmentMaterial(e);t.core.models.materials.list.onItemSet.add(({value:e})=>{this.applyClippingToFragmentMaterial(e)})}applyClippingToFragmentMaterial(t){if(!this.localClippingPlanes)return;const e=this.components.get(an);for(const[,i]of e.list)if(i.renderer)return void(t.clippingPlanes=i.renderer.clippingPlanes)}dispose(){this._enabled=!1,this.components.get(Ps).list.delete(this.config.uuid),this.list.clear(),this._material.dispose(),this.onBeforeCreate.reset(),this.onBeforeCancel.reset(),this.onBeforeDelete.reset(),this.onBeforeDrag.reset(),this.onAfterCreate.reset(),this.onAfterCancel.reset(),this.onAfterDelete.reset(),this.onAfterDrag.reset(),this.onDisposed.trigger(yn.uuid),this.onDisposed.reset()}create(t){var e=this;return(0,G.A)(function*(){const n=yield e.components.get(on).get(t).castRay();return n?e.createPlaneFromIntersection(t,n):null})()}createFromNormalAndCoplanarPoint(t,e,i){const s=this.newPlane(t,i,e);return this.updateMaterialsAndPlanes(),s}delete(t,e){var i=this;return(0,G.A)(function*(){if(!e){const s=yield i.pickPlane(t);if(!s)return;e=i.list.getKey(s)}e&&i.list.delete(e)})()}deleteAll(t){for(const[e,i]of this.list)(!t||t.has(i.type))&&this.list.delete(e)}setup(t){const e={...this._defaultConfig,...t};this.config.color=e.color,this.config.opacity=e.opacity,this.config.size=e.size,this.isSetup=!0,this.onSetup.trigger()}pickPlane(t){const i=this.components.get(on).get(t),s=this.getAllPlaneMeshes(),n=i.castRayToObjects(s);if(n){const o=n.object;return[...this.list.values()].find(a=>a.meshes.includes(o))}}getAllPlaneMeshes(){const t=[];for(const[e,i]of this.list)t.push(...i.meshes);return t}createPlaneFromIntersection(t,e){var i;if(!t.renderer)throw new Error("The given world must have a renderer!");const s=e.point.distanceTo(new p.Pq0(0,0,0)),n=e.normal||(null==(i=e.face)?void 0:i.normal);if(!s||!n)return null;const o=this.getWorldNormal(e,n),a=this.newPlane(t,e.point,o.negate()),l=this.list.get(a);return l.visible=this._visible,l.size=this._size,t.renderer.setPlane(!0,l.three,this.localClippingPlanes),this.updateMaterialsAndPlanes(),l}getWorldNormal(t,e){const i=t.object;let s=t.object.matrixWorld.clone();if(i instanceof p.ZLX&&void 0!==t.instanceId){const l=new p.kn4;i.getMatrixAt(t.instanceId,l),s=l.multiply(s)}const o=(new p.dwI).getNormalMatrix(s),a=e.clone().applyMatrix3(o).normalize();return this.normalizePlaneDirectionY(a),a}normalizePlaneDirectionY(t){this.orthogonalY&&(t.y>this.toleranceOrthogonalY&&(t.x=0,t.y=1,t.z=0),t.y<-this.toleranceOrthogonalY&&(t.x=0,t.y=-1,t.z=0))}newPlane(t,e,i){const s=new this.Type(this.components,t,e,i,this._material);s.autoScale=this.autoScalePlanes,s.onDraggingStarted.add(()=>this.onBeforeDrag.trigger(s)),s.onDraggingEnded.add(()=>this.onAfterDrag.trigger(s));const n=ie.create();return this.list.set(n,s),this.onAfterCreate.trigger(s),n}updateMaterialsAndPlanes(){const t=this.components.get(an);for(const[e,i]of t.list){if(!i.renderer)continue;i.renderer.updateClippingPlanes();const{clippingPlanes:s}=i.renderer;for(const n of i.meshes)if(n.material)if(Array.isArray(n.material))for(const o of n.material)o.clippingPlanes=s;else n.material.clippingPlanes=s}}};y(pl,"uuid","66290bc5-18c4-4cd1-9379-2e17a0617611");let ti=pl;class ml{constructor(t,e){y(this,"title"),y(this,"guid",ie.create()),y(this,"clippingPlanes",new ot.PG),y(this,"camera",{aspect_ratio:1,field_of_view:60,camera_direction:{x:0,y:0,z:0},camera_view_point:{x:0,y:0,z:0},camera_up_vector:{x:0,y:1,z:0}}),y(this,"customData",{}),y(this,"exceptionComponents",new ot.PG),y(this,"selectionComponents",new ot.PG),y(this,"componentColors",new ot.jp),y(this,"spacesVisible",!1),y(this,"spaceBoundariesVisible",!1),y(this,"openingsVisible",!1),y(this,"defaultVisibility",!0),y(this,"snapshot",this.guid),y(this,"_components"),y(this,"_world",null),y(this,"notifyUpdate",()=>{this._components.get(Be).list.set(this.guid,this)}),this._components=t,e&&(this.guid=e.guid??this.guid,this.set(e)),this.setEvents()}getSelectionMap(){var t=this;return(0,G.A)(function*(){return yield t._components.get(ft).guidsToModelIdMap([...t.selectionComponents])})()}getExceptionMap(){var t=this;return(0,G.A)(function*(){return yield t._components.get(ft).guidsToModelIdMap([...t.exceptionComponents])})()}get projection(){return"field_of_view"in this.camera?"Perspective":"Orthographic"}get position(){const t=this._components.get(ft),{camera_view_point:e}=this.camera,{x:i,y:s,z:n}=e,o=new p.Pq0(i,s,n);return t.applyBaseCoordinateSystem(o,new p.kn4),o}set position(t){const e=t.clone(),i=this._components.get(ft);t.clone().applyMatrix4(i.baseCoordinationMatrix.clone().invert()),this.camera.camera_view_point={x:e.x,y:e.y,z:e.z}}get direction(){const{camera_direction:t}=this.camera,{x:e,y:i,z:s}=t;return new p.Pq0(e,i,s)}set world(t){this._world=t}get world(){return this._world}get _managerVersion(){return this._components.get(qt).config.version}get topics(){return[...this._components.get(qt).list.values()].filter(s=>s.viewpoints.has(this.guid))}setEvents(){this.selectionComponents.onUpdated.add(this.notifyUpdate),this.exceptionComponents.onUpdated.add(this.notifyUpdate),this.clippingPlanes.onUpdated.add(this.notifyUpdate),this.componentColors.onItemSet.add(this.notifyUpdate),this.componentColors.onItemDeleted.add(this.notifyUpdate),this.componentColors.onItemUpdated.add(this.notifyUpdate),this.componentColors.onCleared.add(this.notifyUpdate)}set(t){this.title=t.title;const{components:e,perspective_camera:i,orthogonal_camera:s,clipping_planes:n}=t;if(e){const{selection:o,visibility:a,coloring:l}=e;if(o){this.selectionComponents.clear();for(const{ifc_guid:c}of o)c&&this.selectionComponents.add(c)}if(a){const{default_visibility:c,exceptions:h,view_setup_hints:u}=a;if(void 0!==c&&(this.defaultVisibility=c),h){this.exceptionComponents.clear();for(const{ifc_guid:f}of h)f&&this.exceptionComponents.add(f)}if(u){const{spaces_visible:f,space_boundaries_visible:d,openings_visible:_}=u;void 0!==f&&(this.spacesVisible=f),void 0!==d&&(this.spaceBoundariesVisible=d),void 0!==_&&(this.openingsVisible=_)}}if(l){this.componentColors.clear();for(const c of l){const{color:h,components:u}=c,f=u.map(d=>d.ifc_guid).filter(d=>null!==d);this.componentColors.set(h,f)}}}if((i||s)&&(this.camera=i??s),n&&this.world){const o=this._components.get(ti);for(const a of n){const{location:l,direction:c}=a,h=new p.Pq0(l.x,l.z,-l.y),u=new p.Pq0(c.x,c.z,-c.y),f=o.createFromNormalAndCoplanarPoint(this.world,u,h);this.clippingPlanes.add(f),o.list.get(f).enabled=!1,o.list.get(f).visible=!1}}this.notifyUpdate()}go(t){var e=this;return(0,G.A)(function*(){if(!e.world)return;const{camera:i}=e.world;if(!(i instanceof ln))throw new Error("Viewpoint: the world's camera component must be of type OrthoPerspectiveCamera to switch between perspective and orthographic projections.");const{transition:s,applyClippings:n,applyVisibility:o,clippingsVisibility:a}={transition:!0,applyClippings:!0,applyVisibility:!0,clippingsVisibility:!0,...t};i.projection.set(e.projection);const l=new p.Pq0(e.camera.camera_view_point.x,e.camera.camera_view_point.y,e.camera.camera_view_point.z),c=new p.Pq0(e.camera.camera_direction.x,e.camera.camera_direction.y,e.camera.camera_direction.z);if(l.equals(new p.Pq0)&&c.equals(new p.Pq0))return;const h=e.position,u=e.direction,d={x:h.x+80*u.x,y:h.y+80*u.y,z:h.z+80*u.z},_=[];n&&e.setClippingState(!0),o&&_.push(e.applyVisibility()),e.setClippingVisibility(a),_.push(i.controls.setLookAt(h.x,h.y,h.z,d.x,d.y,d.z,s)),yield Promise.all(_)})()}updateCamera(){var t=this;return(0,G.A)(function*(e=!0){return new Promise(i=>{if(!t.world)return void i(!1);const{camera:s,renderer:n}=t.world;if(!n)throw new Error("Viewpoint: the world needs to have a renderer!");if(!s.hasCameraControls())throw new Error("Viewpoint: world's camera need camera controls!");const o=s.three,a=o.getWorldPosition(new p.Pq0),l=o.getWorldDirection(new p.Pq0),{width:c,height:h}=n.getSize();let u=c/h;Number.isNaN(u)&&(u=1);const f=t._components.get(ft);a.applyMatrix4(f.baseCoordinationMatrix.clone().invert());const d={aspect_ratio:u,camera_view_point:{x:a.x,y:a.y,z:a.z},camera_direction:{x:l.x,y:l.y,z:l.z},camera_up_vector:{x:0,y:1,z:0}};if(o instanceof p.ubm?t.camera={...d,field_of_view:o.fov}:o instanceof p.qUd&&(t.camera={...d,view_to_world_scale:o.top-o.bottom}),e){const _=t._components.get(Be),m=n.three.domElement;n.three.render(t.world.scene.three,s.three),m.toBlob(function(){var w=(0,G.A)(function*(g){if(g){const v=yield g.arrayBuffer(),T=new Uint8Array(v);_.snapshots.set(t.guid,T)}t.notifyUpdate(),i(!0)});return function(g){return w.apply(this,arguments)}}())}else t.notifyUpdate(),i(!0)})}).apply(this,arguments)}takeSnapshot(){var t=this;return new Promise(e=>{if(!this.world)return void e(!1);const{camera:i,renderer:s}=this.world;if(!s)throw new Error("Viewpoint: the world needs to have a renderer!");const n=this._components.get(Be),o=s.three.domElement;s.three.render(this.world.scene.three,i.three),o.toBlob(function(){var a=(0,G.A)(function*(l){if(l){const c=yield l.arrayBuffer(),h=new Uint8Array(c);n.snapshots.set(t.guid,h)}t.notifyUpdate(),e(!0)});return function(l){return a.apply(this,arguments)}}())})}updateClippingPlanes(){this.clippingPlanes.clear();const t=this._components.get(ti);for(const[e,i]of t.list)i.enabled&&this.clippingPlanes.add(e)}applyVisibility(){var t=this;return(0,G.A)(function*(){const e=t._components.get(af);e.set(t.defaultVisibility);const i=yield t.getExceptionMap();e.set(!t.defaultVisibility,i);const s=yield t.getSelectionMap();e.set(!0,s)})()}setColorizationState(t){var e=this;return(0,G.A)(function*(){const i=e._components.get(ft),s=[];if(t)for(const[n,o]of e.componentColors){const a=`#${n}`,l=yield i.guidsToModelIdMap(o);for(const[c,h]of Object.entries(l)){const u=i.list.get(c);u&&s.push(u.highlight([...h],{customId:a,color:new p.Q1f(a),renderedFaces:ot.eB.ONE,opacity:1,transparent:!1}))}}else for(const[n,o]of e.componentColors){const a=yield i.guidsToModelIdMap(o);for(const[l,c]of Object.entries(a)){const h=i.list.get(l);h&&s.push(h.resetHighlight([...c]))}}s.push(i.core.update(!0)),yield Promise.all(s)})()}setClippingState(t){const e=this._components.get(ti);for(const[i,s]of e.list)s.enabled=t&&this.clippingPlanes.has(i)}setClippingVisibility(t){const e=this._components.get(ti);for(const i of this.clippingPlanes){const s=e.list.get(i);s&&(s.visible=t)}}createComponentTags(t){var e=this;return(0,G.A)(function*(){var i;const s=e._components.get(ft);let o="";if(e._components.get(qt).config.includeSelectionTag){const a="selection"===t?yield e.getSelectionMap():yield e.getExceptionMap();for(const l in a){const c=s.list.get(l);if(!c)continue;const h=a[l];for(const u of h){const f=c.getItem(u),d=yield f.getGuid();if(!d)continue;const _=null==(i=yield f.getAttributes())?void 0:i.getValue("Tag");let m=null;_&&(m=`AuthoringToolId="${_}"`),o+=`\n<Component IfcGuid="${d}" ${m??""} />`}}}else o=[...e.selectionComponents].map(a=>`<Component IfcGuid="${a}" />`).join("\n");return o})()}createColorTags(){let t="";for(const[e,i]of this.componentColors.entries())t+=`<Color Color="${e}">\n${i.map(n=>`\n<Component IfcGuid="${n}" />`).join("\n")}\n</Color>`;return 0!==t.length?`<Coloring>\n${t}\n</Coloring>`:"<Coloring />"}toJSON(){const t=this._components.get(ti),e={guid:this.guid,components:{selection:[...this.selectionComponents].map(n=>({ifc_guid:n,authoring_tool_id:null})),coloring:[...this.componentColors].map(([n,o])=>({color:n,components:o.map(a=>({ifc_guid:a,authoring_tool_id:null}))})),visibility:{default_visibility:this.defaultVisibility,exceptions:[...this.exceptionComponents].map(n=>({ifc_guid:n,authoring_tool_id:null})),view_setup_hints:{spaces_visible:this.spacesVisible,space_boundaries_visible:this.spaceBoundariesVisible,openings_visible:this.openingsVisible}}},clipping_planes:[...this.clippingPlanes].map(n=>{const o=t.list.get(n);if(!o)return null;const a=o._controls.worldPosition??o.origin,{normal:l}=o;return{location:{x:a.x,y:-a.z,z:a.y},direction:{x:l.x,y:-l.z,z:l.y}}}).filter(n=>null!==n)};"field_of_view"in this.camera?e.perspective_camera=this.camera:e.orthogonal_camera=this.camera;const i=this._components.get(Be),s=i.snapshots.get(this.snapshot);if(s){const n=s.toString(),o=btoa(n),a=i.getSnapshotExtension(this.snapshot);e.snapshot={snapshot_type:a,snapshot_data:o}}return e}serialize(){var t=this;return(0,G.A)(function*(e=t._managerVersion){const i=t._components.get(ft),s=t.position;s.applyMatrix4(i.baseCoordinationMatrix.clone().invert());const n=t.direction;n.normalize();const o=(new p.kn4).makeRotationX(Math.PI/2),a=n.clone().applyMatrix4(o);a.normalize();const l=`<CameraViewPoint>\n <X>${s.x}</X>\n <Y>${-s.z}</Y>\n <Z>${s.y}</Z>\n </CameraViewPoint>`,c=`<CameraDirection>\n <X>${n.x}</X>\n <Y>${-n.z}</Y>\n <Z>${n.y}</Z>\n </CameraDirection>`,h=`<CameraUpVector>\n <X>${a.x}</X>\n <Y>${-a.z}</Y>\n <Z>${a.y}</Z>\n </CameraUpVector>`,u=`<AspectRatio>${t.camera.aspect_ratio}</AspectRatio>`;let f="";"view_to_world_scale"in t.camera?f=`<OrthogonalCamera>\n ${l}\n ${c}\n ${h}\n ${u}\n <ViewToWorldScale>${t.camera.view_to_world_scale}</ViewToWorldScale>\n </OrthogonalCamera>`:"field_of_view"in t.camera&&(f=`<PerspectiveCamera>\n ${l}\n ${c}\n ${h}\n ${u}\n <FieldOfView>${t.camera.field_of_view}</FieldOfView>\n </PerspectiveCamera>`);const d=`<ViewSetupHints SpacesVisible="${t.spacesVisible??!1}" SpaceBoundariesVisible="${t.spaceBoundariesVisible??!1}" OpeningsVisible="${t.openingsVisible??!1}" />`,_=(yield t.createComponentTags("selection")).trim(),m=(yield t.createComponentTags("exception")).trim(),w=t.createColorTags();return`<?xml version="1.0" encoding="UTF-8"?>\n <VisualizationInfo Guid="${t.guid}">\n <Components>\n ${"2.1"===e?d:""}\n ${0!==_.length?`<Selection>${_}</Selection>`:""}\n <Visibility DefaultVisibility="${t.defaultVisibility}">\n ${"3"===e?d:""}\n ${0!==m.length?`<Exceptions>${m}</Exceptions>`:""}\n </Visibility>\n ${w}\n </Components>\n ${f}\n </VisualizationInfo>`}).apply(this,arguments)}}class $f extends Wi{constructor(){super(...arguments),y(this,"_config",{overwriteColors:{value:!1,type:"Boolean"}})}get overwriteColors(){return this._config.overwriteColors.value}set overwriteColors(t){this._config.overwriteColors.value=t}}const gl=class yo extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"world",null),y(this,"list",new ot.jp),y(this,"snapshots",new ot.jp),y(this,"isSetup",!1),y(this,"onSetup",new Q),y(this,"config",new $f(this,this.components,"Viewpoints",yo.uuid)),y(this,"onDisposed",new Q),t.add(yo.uuid,this)}create(t){const e=new ml(this.components,t);return e.world=this.world,t||this.list.set(e.guid,e),e}getSnapshotExtension(t){let e="jpeg";const i=this.snapshots.get(t);if(!i)return e;const s=i.subarray(0,4);let n="";for(let o=0;o<s.length;o++)n+=s[o].toString(16);return n.startsWith("89504e47")&&(e="png"),n.startsWith("ffd8ffe")&&(e="jpeg"),e}setup(){}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}};y(gl,"uuid","ee867824-a796-408d-8aa0-4e5962a83c66");let Be=gl;class _l{constructor(t,e){y(this,"_components"),y(this,"_cameraOffset",10),y(this,"_planeHelper"),y(this,"_farPlaneHelper"),y(this,"_cameraHelper"),y(this,"onStateChanged",new Q),y(this,"onUpdated",new Q),y(this,"onDisposed",new Q),y(this,"camera"),y(this,"plane",new p.Zcv),y(this,"farPlane",new p.Zcv),y(this,"id",ie.create()),y(this,"_open",!1),y(this,"_range",jf.defaultRange),y(this,"_world",null),y(this,"_helpersVisible",!1),y(this,"_planesEnabled",!1),this._components=t,this.camera=new ln(this._components);const{threeOrtho:i}=this.camera;if(e?.id&&(this.id=e.id),e?.normal&&e?.point){const{normal:s,point:n}=e;this.plane.setFromNormalAndCoplanarPoint(s,n)}this._cameraHelper=new p.WTh(i),this._planeHelper=new p.ZM4(this.plane,50),this._farPlaneHelper=new p.ZM4(this.farPlane,50),this.farPlaneHelperColor=new p.Q1f("blue"),this.update()}get _planeNormalOpposite(){return this.plane.normal.clone().negate()}get _planePosition(){return this.plane.normal.clone().multiplyScalar(-this.plane.constant)}get _cameraPosition(){return this._planePosition.addScaledVector(this._planeNormalOpposite,this._cameraOffset)}set open(t){this._open=t,this.onStateChanged.trigger(["open"])}get open(){return this._open}set planeHelperColor(t){!Array.isArray(this._planeHelper.material)&&"color"in this._planeHelper.material&&this._planeHelper.material.color instanceof p.Q1f&&(this._planeHelper.material.color=t)}set farPlaneHelperColor(t){!Array.isArray(this._farPlaneHelper.material)&&"color"in this._farPlaneHelper.material&&this._farPlaneHelper.material.color instanceof p.Q1f&&(this._farPlaneHelper.material.color=t)}set range(t){this._range=t,this.update()}get range(){return this._range}set distance(t){this.plane.constant=t,this.update()}get distance(){return this.plane.constant}set world(t){this._world=t,this.camera.currentWorld=t,t&&(this.camera.projection.set("Orthographic"),this.camera.set("Plan"),this.camera.controls.dollySpeed=6,this.camera.controls.restThreshold=.005,this.update())}get world(){return this._world}set helpersVisible(t){if(!t)return this._helpersVisible=t,this._planeHelper.removeFromParent(),this._farPlaneHelper.removeFromParent(),void this._cameraHelper.removeFromParent();this.world&&(this._helpersVisible=t,this.world.scene.three.add(this._planeHelper,this._farPlaneHelper))}get helpersVisible(){return this._helpersVisible}set planesEnabled(t){const{world:e}=this;if(!e)return;const{renderer:i}=e;i&&(i.setPlane(t,this.plane),i.setPlane(t,this.farPlane),this._planesEnabled=t)}get planesEnabled(){return this._planesEnabled}dispose(){this.helpersVisible=!1;const t=this._components.get(bi);t.destroy(this._planeHelper),t.destroy(this._farPlaneHelper),t.destroy(this._cameraHelper),this.camera.dispose(),this.onDisposed.trigger()}update(){if(this.world){const t=this._cameraPosition,e=this._planePosition;this.camera.controls.setLookAt(t.x,t.y,t.z,e.x,e.y,e.z,!1)}this.farPlane.normal.copy(this._planeNormalOpposite),this.farPlane.constant=this.range-this.plane.constant,this.onUpdated.trigger()}flip(){this.plane.normal.negate(),this.update()}}const zr=class Wc extends At{constructor(t){super(t),y(this,"list",new ot.jp),y(this,"enabled",!0),y(this,"world",null),y(this,"_fragmentsUpdateEvent",()=>{this.components.get(ft).core.update(!0)}),y(this,"restoreCameraOnClose",!0),y(this,"_restoreState",null),t.add(Wc.uuid,this),this.setupEvents()}get hasOpenViews(){return[...this.list.values()].some(t=>t.open)}setupEvents(){this.list.onBeforeDelete.add(({key:t,value:e})=>{e.open&&this.close(t),e.dispose()})}create(t,e,i){const s=new _l(this.components,{id:i?.id,normal:t,point:e});return s.world=i?.world??this.world,this.list.set(s.id,s),s}createFromPlane(t,e){const i=new _l(this.components,{id:e?.id});return i.plane.copy(t),i.update(),i.world=e?.world??this.world,this.list.set(i.id,i),i}createFromIfcStoreys(t){var e=this;return(0,G.A)(function*(){const i=[],s=e.components.get(ft),n=void 0===t?.offset?.25:t.offset;for(const[o,a]of s.list){if(t&&t.modelIds&&!t.modelIds.some(f=>f.test(o)))continue;const l=Object.values(yield a.getItemsOfCategories([/BUILDINGSTOREY/])).flat();if(0===l.length)continue;const c=yield a.getItemsData(l),[,h]=yield a.getCoordinates(),u=new p.Pq0(0,-1,0);for(const f of c){if(!("value"in f.Name)||!("value"in f.Elevation))continue;const{value:d}=f.Name;if(t?.storeyNames&&!t.storeyNames.some(g=>g.test(d)))continue;const m=new p.Zcv(u,f.Elevation.value+h+n),w=e.createFromPlane(m,{id:d,world:t?.world});i.push(w)}}return i})()}createElevations(t){const e=[],i=this.components.get(ft),s=void 0!==t?.combine&&t.combine,n=t?.namingCallback??(a=>({front:s?"Front":`${a}: Front`,back:s?"Back":`${a}: Back`,left:s?"Left":`${a}: Left`,right:s?"Right":`${a}: Right`}));let o=[];for(const[a,l]of i.list)t&&t.modelIds&&!t.modelIds.some(c=>c.test(a))||o.push({id:a,box:l.box});if(0===o.length)return e;if(s){const a=this.components.get(Qa);a.list.clear(),a.list.add(...o.map(c=>c.box)),o=[{id:"combined",box:a.get()}]}for(const{id:a,box:l}of o){const{min:c,max:h}=l,u=Math.abs(h.x-c.x),f=Math.abs(h.z-c.z),d=new p.Pq0;l.getCenter(d);const _=new p.Zcv(new p.Pq0(0,0,-1),h.z),m=new p.Zcv(new p.Pq0(0,0,1),-c.z),w=new p.Zcv(new p.Pq0(-1,0,0),h.x),g=new p.Zcv(new p.Pq0(1,0,0),-c.x),{front:v,back:T,left:C,right:S}=n(a),M=this.createFromPlane(_,{id:v,world:t?.world});M.range=f;const A=this.createFromPlane(m,{id:T,world:t?.world});A.range=f;const O=this.createFromPlane(w,{id:C,world:t?.world});O.range=u;const I=this.createFromPlane(g,{id:S,world:t?.world});I.range=u,e.push(M,A,O,I)}return e}open(t){const e=this.list.get(t);if(!e)throw new Error(`Views: the view with id ${t} doesn't exist.`);if(e.open)return;const{world:i}=e;if(!i)throw new Error(`Views: no world found for view with id ${t}.`);const{renderer:s}=i;if(!s)throw new Error(`Views: no renderer found for world with id ${i.uuid}.`);for(const[,n]of this.list)n.world===i&&this.close(n.id);this.restoreCameraOnClose&&i.camera!==e.camera&&!this._restoreState&&i.camera.controls&&(this._restoreState={camera:i.camera,json:i.camera.controls.toJSON()}),s.setPlane(!0,e.plane),s.setPlane(!0,e.farPlane),this.setOnlyEnabledControls(i,e),e.camera.controls.addEventListener("rest",this._fragmentsUpdateEvent),i.camera=e.camera,e.open=!0}close(t){let e;if(e=t?this.list.get(t):[...this.list.values()].find(n=>n.open),t&&!e)throw new Error(`Views: the view with id ${t} doesn't exist.`);if(!e||!e.open)return;const{world:i}=e;if(!i)throw new Error(`Views: no world found for view with id ${t}.`);const{renderer:s}=i;if(!s)throw new Error(`Views: no renderer found for world with id ${i.uuid}.`);if(s.setPlane(!1,e.plane),s.setPlane(!1,e.farPlane),e.camera.controls.removeEventListener("rest",this._fragmentsUpdateEvent),i.useDefaultCamera(),e.open=!1,this.setOnlyEnabledControls(i,null),this.restoreCameraOnClose&&this._restoreState){const{camera:n,json:o}=this._restoreState;n===i.camera&&n.controls&&n.controls.fromJSON(o,!1),this._restoreState=null}}setOnlyEnabledControls(t,e){const i=e?e.camera:t.defaultCamera,s=(n,o)=>{n.controls&&(n.controls.enabled=o)};s(i,!0),i!==t.defaultCamera&&s(t.defaultCamera,!1);for(const[,n]of this.list)n.world===t&&n.camera!==i&&s(n.camera,!1)}};y(zr,"uuid","fb22f1f5-6598-4664-a11d-de8963ae420f"),y(zr,"defaultRange",15);let jf=zr;class Ni{constructor(t){y(this,"cardinality","required"),y(this,"instructions"),y(this,"evalRequirement",(e,i,s,n)=>{const o={parameter:s,currentValue:e,requiredValue:i,pass:!1};n&&this.addCheckResult(o,n);let a=!1;if("simple"===i.type&&(a=e===i.parameter),"enumeration"===i.type&&(a=i.parameter.includes(e)),"pattern"===i.type&&(a=new RegExp(i.parameter).test(String(e))),"length"===i.type){const{min:l,length:c,max:h}=i.parameter;void 0!==c&&(a=String(e).length===c),void 0!==l&&(a=String(e).length>=l),void 0!==h&&(a=String(e).length<=h)}if("bounds"===i.type&&"number"==typeof e){const{min:l,minInclusive:c,max:h,maxInclusive:u}=i.parameter;let f=!0,d=!0;void 0!==l&&(f=c?e>=l:e>l),void 0!==h&&(d=u?e<=h:e<h),a=f&&d}return"prohibited"===this.cardinality&&(a=!a),"optional"===this.cardinality&&(a=!0),o.pass=a,o.pass}),this._components=t}addCheckResult(t,e){const i=e.findIndex(({parameter:s})=>s===t.parameter);-1!==i?e[i]=t:e.push(t)}getItemChecks(t,e,i,s){if(!("value"in i._localId)||"number"!=typeof i._localId.value)return null;let n=t.get(e);n||(n=new ot.jp,t.set(e,n));let o=n.get(i._localId.value);if(o&&s&&!o.pass)return null;if(!o){const c=[];o={guid:Array.isArray(i._guid)?void 0:i._guid.value,pass:!1,checks:c},Object.defineProperty(o,"pass",{get:()=>c.every(({pass:h})=>h)}),n.set(i._localId.value,o)}const a=[],l={facetType:this.facetType,cardinality:this.cardinality,checks:a,pass:!1};return Object.defineProperty(l,"pass",{get:()=>a.every(({pass:c})=>c)}),o.checks.push(l),l.checks}}const Se=(r,t)=>{let e="";if(!t)return e;if("simple"===t.type&&(e=`<simpleValue>${t.parameter}</simpleValue>`),"enumeration"===t.type&&(e=`<xs:restriction base="xs:string">\n ${t.parameter.map(n=>`<xs:enumeration value="${n}" />`).join("\n")}\n </xs:restriction>`),"pattern"===t.type&&(e=`<xs:restriction base="xs:string">\n <xs:pattern value="${t.parameter}" />\n </xs:restriction>`),"bounds"===t.type){const{min:s,minInclusive:n,max:o,maxInclusive:a}=t.parameter;let l="";void 0!==s&&(l=`<xs:min${n?"Inclusive":"Exclusive"} value="${s}">`);let c="";void 0!==o&&(c=`<xs:max${a?"Inclusive":"Exclusive"} value="${o}">`),e=`<xs:restriction base="xs:double">\n ${l}\n ${c}\n </xs:restriction>`}if("length"===t.type){const{length:s,min:n,max:o}=t.parameter;let a="";void 0!==s&&void 0===n&&void 0===o&&(a=`<xs:length value="${s}" />`);let l="";void 0!==n&&void 0===s&&(l=`<xs:minLength value="${n}" />`);let c="";void 0!==o&&void 0===s&&(c=`<xs:maxLength value="${o}" />`),e=`<xs:restriction base="xs:string">\n ${a}\n ${l}\n ${c}\n </xs:restriction>`}return`<${r[0].toLowerCase()+r.slice(1)}>\n ${e}\n </${r[0].toLowerCase()+r.slice(1)}>`};class Zf extends Ni{constructor(t,e){super(t),y(this,"facetType","Attribute"),y(this,"name"),y(this,"value"),this.name=e}serialize(t){const e=Se("Name",this.name),i=Se("Value",this.value);let s="";return"requirement"===t&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<attribute ${s}>\n ${e}\n ${i}\n</attribute>`}getEntities(){return(0,G.A)(function*(){})()}test(t,e){var i=this;return(0,G.A)(function*(s,n,o={skipIfFails:!0}){const a=i._components.get(ft);for(const[l,c]of Object.entries(s)){const h=a.list.get(l);if(!h)continue;const u=yield h.getItemsData([...c]);for(const f of u){const d=i.getItemChecks(n,l,f,o.skipIfFails);if(!d)continue;const m=Object.keys(f).filter(g=>{const v=i.evalRequirement(g,i.name,"Name");if(!v)return!1;const T=f[g];return!!Array.isArray(T)||(null===T||null===T.value?"optional"===i.cardinality||"prohibited"===i.cardinality:!(Array.isArray(T.value)&&0===T.value.length||"string"==typeof T.value&&""===T.value.trim())&&v)}),w=m.length>0;if(d.push({parameter:"Name",currentValue:w?m[0]:null,requiredValue:i.name,pass:"prohibited"===i.cardinality?!w:w}),i.value)if(m[0]){const g=f[m[0]];Array.isArray(g)||Array.isArray(g.value)?d.push({parameter:"Value",currentValue:null,requiredValue:i.value,pass:"prohibited"===i.cardinality}):i.evalRequirement(g.value,i.value,"Value",d)}else d.push({parameter:"Value",currentValue:null,requiredValue:i.value,pass:"prohibited"===i.cardinality})}}}).apply(this,arguments)}}class Wf extends Ni{constructor(t,e){super(t),y(this,"facetType","Classification"),y(this,"system"),y(this,"value"),y(this,"uri"),this.system=e}serialize(t){const e=Se("System",this.system),i=Se("Value",this.value);let s="";return"requirement"===t&&(s+=`cardinality="${this.cardinality}"`,s+=this.uri?`uri=${this.uri}`:"",s+=this.instructions?`instructions="${this.instructions}"`:""),`<classification ${s}>\n ${e}\n ${i}\n</classification>`}getEntities(t,e){return(0,G.A)(function*(){})()}test(t,e){return(0,G.A)(function*(){})()}}class Lr extends Ni{constructor(t,e){super(t),y(this,"facetType","Entity"),y(this,"name"),y(this,"predefinedType"),this.name=e}serialize(t){const e=Se("Name",this.name),i=Se("Name",this.predefinedType);let s="";return"requirement"===t&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<entity ${s}>\n ${e}\n ${i}\n</entity>`}getEntities(t,e){var i=this;return(0,G.A)(function*(){const s=i._components.get(ft),n=new Map;for(const[a,l]of s.list){if(!t.find(u=>u.test(a)))continue;const h=yield l.getCategories();for(const u of h){if(!(yield i.evalName(u)))continue;let d=n.get(a);d||(d=[],n.set(a,d)),d.push(u)}}const o={};if(yield Promise.all(Array.from(n.entries()).map(function(){var a=(0,G.A)(function*([l,c]){const h=s.list.get(l);if(!h)return;const u=c.map(_=>new RegExp(`^${_}$`)),f=yield h.getItemsOfCategories(u),d=Object.values(f).flat();o[l]=new Set(d)});return function(l){return a.apply(this,arguments)}}())),i.predefinedType)for(const[a,l]of Object.entries(o)){const c=s.list.get(a);if(!c)continue;const h=yield c.getItemsData([...l]);for(const u of h)"value"in u._localId&&(yield i.evalPredefinedType(a,u))&&Rt.append(e,a,u._localId.value)}else Rt.add(e,o)})()}test(t,e,i){var s=this;return(0,G.A)(function*(){const n=s._components.get(ft);for(const[o,a]of Object.entries(t)){const l=n.list.get(o);if(!l)continue;const c=yield l.getItemsData([...a]);for(const h of c){if(!("value"in h._category))continue;const u=s.getItemChecks(e,o,h,i.skipIfFails);u&&(yield s.evalName(h._category.value,u),yield s.evalPredefinedType(o,h,u))}}})()}evalName(t,e){var i=this;return(0,G.A)(function*(){return i.evalRequirement(t,i.name,"Name",e)})()}evalPredefinedType(t,e,i){var s=this;return(0,G.A)(function*(){if(!s.predefinedType||!("value"in e.PredefinedType))return null;const n="string"==typeof s.predefinedType.parameter&&"USERDEFINED"===s.predefinedType.parameter;let o=e.PredefinedType.value;if("USERDEFINED"===o&&!n){const c=Object.keys(e).find(h=>/^((?!Predefined).)*Type$/.test(h));if(c){const h=e[c];"value"in h&&(o=h.value)}else o="USERDEFINED"}if(!o){const c=s._components.get(ft).list.get(t);if(c&&"value"in e._localId){const[h]=yield c.getItemsData([e._localId.value],{relations:{IsTypedBy:{attributes:!0,relations:!1}}});if(Array.isArray(h.IsTypedBy)){const u=h.IsTypedBy[0];if(u&&"value"in u.PredefinedType&&(o=u.PredefinedType.value,"USERDEFINED"===o&&!n)){const d=Object.keys(u).find(_=>/^((?!Predefined).)*Type$/.test(_));if(d){const _=u[d];"value"in _&&(o=_.value)}else o="USERDEFINED"}}}}return s.evalRequirement(o,s.predefinedType,"PredefinedType",i)})()}}class Xf extends Ni{constructor(t,e,i){super(t),y(this,"facetType","Property"),y(this,"propertySet"),y(this,"baseName"),y(this,"value"),y(this,"dataType"),y(this,"uri"),y(this,"_unsupportedTypes",["IFCCOMPLEXPROPERTY","IFCPHYSICALCOMPLEXQUANTITY"]),this.propertySet=e,this.baseName=i}serialize(t){const e=Se("PropertySet",this.propertySet),i=Se("BaseName",this.baseName),s=Se("Value",this.value);let o="";return"requirement"===t&&(o+=`cardinality="${this.cardinality}"`,o+=this.uri?`uri=${this.uri}`:"",o+=this.instructions?`instructions="${this.instructions}"`:""),`<property ${this.dataType?`dataType=${this.dataType}`:""} ${o}>\n ${e}\n ${i}\n ${s}\n</property>`}getEntities(t,e){var i=this;return(0,G.A)(function*(){const s=i._components.get(ft);for(const[n,o]of s.list){if(!t.find(u=>u.test(n)))continue;const l=yield o.getItemsOfCategories([/PROPERTYSET/,/ELEMENTQUANTITY/]),c=Object.values(l).flat();if(0===c.length)continue;const h=yield o.getItemsData(c,{relations:{HasProperties:{attributes:!0,relations:!1},DefinesOcurrence:{attributes:!0,relations:!1}}});for(const u of h){if(!("value"in u._localId&&"value"in u._category&&"value"in u.Name&&Array.isArray(u.DefinesOcurrence)&&i.evalRequirement(u.Name.value,i.propertySet,"PropertySet")))continue;let d;if("IFCPROPERTYSET"===u._category.value&&(d="HasProperties"),"IFCELEMENTQUANTITY"===u._category.value&&(d="Quantities"),!d)continue;const _=u[d];if(Array.isArray(_))for(const m of _){const w=Object.keys(m),g=w.find(S=>/Name/.test(S));if(!g||!("value"in m[g]))continue;const v=m[g];if(!("value"in v)||!i.evalRequirement(v.value,i.baseName,"BaseName"))continue;if(i.value){const S=w.find(O=>/Value/.test(O));if(!S)continue;const M=m[S];if(!("value"in M)||!i.evalRequirement(M.value,i.value,"Value"))continue}const C=u.DefinesOcurrence.map(S=>"value"in S._localId&&"number"==typeof S._localId.value?S._localId.value:null).filter(S=>null!==S);Rt.append(e,n,...C)}}}})()}test(t,e){var i=this;return(0,G.A)(function*(s,n,o={skipIfFails:!0}){const a=i._components.get(ft);for(const[l,c]of Object.entries(s)){const h=a.list.get(l);if(!h)continue;const u=yield h.getItemsData([...c],{relations:{IsDefinedBy:{attributes:!0,relations:!0},IsTypedBy:{attributes:!0,relations:!1},HasPropertySets:{attributes:!0,relations:!0},DefinesOcurrence:{attributes:!1,relations:!1}}});for(const f of u){const d=i.getItemChecks(n,l,f,o.skipIfFails);if(!d)continue;const m=(yield i.getPsets(f)).filter(w=>!(!("value"in w.Name)||!i.evalRequirement(w.Name.value,i.propertySet,"PropertySet")||(d.push({currentValue:w.Name.value,parameter:"PropertySet",pass:!0,requiredValue:i.propertySet}),0)));if(0!==m.length)for(const w of m){const g=i.getPropertyListName(w);if(!g)continue;const v=w[g];if(!Array.isArray(v)){d.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:i.baseName});continue}const T=v.filter(C=>!(!("value"in C._category)||!("value"in C.Name)||i._unsupportedTypes.includes(C._category.value)||!i.evalRequirement(C.Name.value,i.baseName,"BaseName")||(d.push({currentValue:C.Name.value,parameter:"BaseName",pass:!0,requiredValue:i.baseName}),0)));if(0!==T.length)for(const C of T)i.evalValue(C,d),i.evalDataType(C,d),i.evalURI();else d.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:i.baseName})}else d.push({currentValue:null,parameter:"PropertySet",pass:!1,requiredValue:i.propertySet})}}}).apply(this,arguments)}getPropertyListName(t){let e;return"value"in t._category&&("IFCPROPERTYSET"===t._category.value&&(e="HasProperties"),"IFCELEMENTQUANTITY"===t._category.value&&(e="Quantities")),e}getValueKey(t){return Object.keys(t).find(e=>/Value/.test(e)||/Values/.test(e))}getTypePsets(t){if(!Array.isArray(t.IsTypedBy))return[];const[e]=t.IsTypedBy;return e&&Array.isArray(e.HasPropertySets)?e.HasPropertySets:[]}getPsets(t){var e=this;return(0,G.A)(function*(){const i=e.getTypePsets(t);if(!Array.isArray(t.IsDefinedBy))return i;const s=[];for(const n of t.IsDefinedBy){if(!("value"in n.Name))continue;const o=n.Name.value,a=e.getPropertyListName(n);if(!o||!a)continue;const l=i.find(c=>"value"in c.Name&&c.Name.value===o);if(l&&Array.isArray(l.HasProperties)&&Array.isArray(n.HasProperties))for(const c of l.HasProperties){if(!("value"in c.Name))continue;const h=c.Name.value;n.HasProperties.find(f=>"value"in f.Name&&f.Name.value===h)||n.HasProperties.push(c)}s.push(n)}return s})()}evalValue(t,e){const i=this.getValueKey(t),s=t[i];if(!("value"in s))return!1;if(this.value){if(!i)return e?.push({parameter:"Value",currentValue:null,pass:!1,requiredValue:this.value}),!1;const n=structuredClone(this.value);return"IFCLABEL"===s.type&&"simple"===n.type&&(n.parameter=String(n.parameter)),this.evalRequirement(s.value,n,"Value",e)}return!i||"string"!=typeof s.value||""!==s.value.trim()||(e?.push({parameter:"Value",currentValue:"",pass:!1,requiredValue:this.value}),!1)}evalDataType(t,e){if(!this.dataType)return!0;const i=this.getValueKey(t);return i&&"value"in t[i]?this.evalRequirement(t[i].type??null,{type:"simple",parameter:this.dataType},"DataType",e):(e?.push({parameter:"DataType",currentValue:null,pass:!1,requiredValue:this.dataType}),!1)}evalURI(){return!0}}class Kf extends Ni{constructor(){super(...arguments),y(this,"_ifcMaterialEntities",[/^IFCMATERIALLAYERSETUSAGE$/,/^IFCMATERIALCONSTITUENTSET$/,/^IFCMATERIAL$/,/^IFCMATERIALLIST$/]),y(this,"facetType","Material"),y(this,"value"),y(this,"uri")}serialize(t){if(!this.value||!this.uri)return"<material />";const e=Se("Value",this.value);let i="";return"requirement"===t&&(i+=`cardinality="${this.cardinality}"`,i+=this.uri?`uri=${this.uri}`:"",i+=this.instructions?`instructions="${this.instructions}"`:""),`<material ${i}>\n ${e}\n</material>`}getEntities(t,e){var i=this;return(0,G.A)(function*(){const s=i._components.get(ft);for(const[n,o]of s.list){if(!t.find(u=>u.test(n)))continue;const l=yield o.getItemsOfCategories(i._ifcMaterialEntities),c=Object.values(l).flat();if(0===c.length)continue;const h=yield o.getItemsData(c,{relations:{AssociatedTo:{attributes:!0,relations:!1},MaterialConstituents:{attributes:!0,relations:!0},ForLayerSet:{attributes:!0,relations:!0},MaterialLayers:{attributes:!0,relations:!0},Materials:{attributes:!0,relations:!1}}});for(const u of h){if(!("value"in u._localId&&"value"in u._category&&Array.isArray(u.AssociatedTo)&&i.hasValidMaterial(u)))continue;const d=u.AssociatedTo.map(_=>"value"in _._localId&&_._localId.value?_._localId.value:null).filter(_=>null!==_);Rt.append(e,n,...d)}}})()}test(t,e){var i=this;return(0,G.A)(function*(s,n,o={skipIfFails:!0}){const a=i._components.get(ft);for(const[l,c]of Object.entries(s)){const h=a.list.get(l);if(!h)continue;const u=yield h.getItemsData([[...c][0]],{relations:{AssociatedTo:{attributes:!1,relations:!1},HasAssociations:{attributes:!0,relations:!0},MaterialConstituents:{attributes:!0,relations:!0},ForLayerSet:{attributes:!0,relations:!0},MaterialLayers:{attributes:!0,relations:!0},Materials:{attributes:!0,relations:!1}}});for(const f of u){const d=i.getItemChecks(n,l,f,o.skipIfFails);if(d){if(!Array.isArray(f.HasAssociations)){d.push({parameter:null,currentValue:null,requiredValue:i.value,pass:!1});continue}for(const _ of f.HasAssociations)if(i._ifcMaterialEntities.some(w=>"value"in _._category&&w.test(_._category.value))&&i.hasValidMaterial(_,d))break}}}}).apply(this,arguments)}hasValidMaterial(t,e){let i=!1;if("value"in t._category&&"IFCMATERIAL"===t._category.value)this.evalValue(t,e)&&(i=!0);else for(const[s,n]of Object.entries(t))if(["ForLayerSet","MaterialLayers","Material","MaterialConstituents","Materials"].includes(s)&&Array.isArray(n))for(const o of n)if("value"in o._category&&"IFCMATERIAL"===o._category.value){if(this.evalValue(o,e)){i=!0;break}}else if(this.hasValidMaterial(o)){i=!0;break}return i}evalValue(t,e){if(!this.value)return e?.push({parameter:null,currentValue:t.Name&&"value"in t.Name?t.Name.value:null,pass:!0}),!0;if(!("value"in t._category)||"IFCMATERIAL"!==t._category.value)return null;let i=!1;return t.Name&&"value"in t.Name&&(i=this.evalRequirement(t.Name.value,this.value,"Value",e)),i||(t.Category&&"value"in t.Category&&(i=this.evalRequirement(t.Category.value,this.value,"Value",e)),i)}}class Qf extends Ni{constructor(t,e){super(t),y(this,"facetType","PartOf"),y(this,"_entityFacet"),y(this,"_entity"),y(this,"relation"),y(this,"cardinality","required"),this._entity=e,this._entityFacet=new Lr(t,e.name),this._entityFacet.predefinedType=e.predefinedType}set entity(t){this._entity=t;const{name:e,predefinedType:i}=t;this._entityFacet=new Lr(this._components,e),this._entityFacet.predefinedType=i}get entity(){return this._entity}serialize(){return""}getEntities(t,e){return(0,G.A)(function*(){})()}test(t){return(0,G.A)(function*(){})()}}class Jf{constructor(t,e,i){y(this,"name"),y(this,"ifcVersion",new Set),y(this,"identifier",ie.create()),y(this,"description"),y(this,"instructions"),y(this,"requirementsDescription"),y(this,"applicability",new ot.PG),y(this,"requirements",new ot.PG),y(this,"components"),this.components=t,this.name=e;for(const s of i)this.ifcVersion.add(s)}set(t){const e=t,i=this;for(const n in t)"identifier"!==n&&n in this&&(i[n]=e[n]);return this.components.get(tp).list.set(this.identifier,this),this}test(t){var e=this;return(0,G.A)(function*(i,s={skipIfFails:!0}){const n=new ot.jp;if(0===e.requirements.size)return n;const o={},a=[];for(const c of e.applicability)a.push(c.getEntities(i,o));yield Promise.all(a);const l=[];for(const c of e.requirements)l.push(c.test(o,n,s));return yield Promise.all(l),n}).apply(this,arguments)}serialize(){const t=`name="${this.name}"`,e=this.identifier?`identifier="${this.identifier}"`:"",i=this.description?`description="${this.description}"`:"",s=this.instructions?`instructions="${this.instructions}"`:"";return`<specification ifcVersion="${[...this.ifcVersion].join(" ")}" ${t} ${e} ${i} ${s}>\n <applicability minOccurs="1" maxOccurs="unbounded">\n ${[...this.applicability].map(o=>o.serialize("applicability")).join("\n")}\n </applicability>\n <requirements>\n ${[...this.requirements].map(o=>o.serialize("requirement")).join("\n")}\n </requirements>\n </specification>`}}const _e=r=>{if(!r)return;const t={};if("simpleValue"in r&&(t.type="simple",t.parameter=r.simpleValue),"restriction"in r){const e=r.restriction,i=Object.keys(e);if("pattern"in e&&(t.type="pattern",t.parameter=e.pattern.value),"enumeration"in e){t.type="enumeration";const s=e.enumeration.map(({value:n})=>e.base.includes("string")?String(n):e.base.includes("integer")||e.base.includes("double")?Number(n):n);t.parameter=s}if(i.some(s=>["minInclusive","minExclusive","maxInclusive","maxExclusive"].includes(s))){t.type="bounds";const s={},n=i.find(a=>a.includes("min")),o=i.find(a=>a.includes("max"));n&&(s.minInclusive="minInclusive"===n,s.min=e[n].value),o&&(s.maxInclusive="maxInclusive"===o,s.max=e[o].value),t.parameter=s}if(i.some(s=>["minLength","length","maxLength"].includes(s))){t.type="length";const s={};void 0!==e.length&&(s.length=e.length.value),void 0!==e.minLength&&(s.min=e.minLength.value),void 0!==e.maxLength&&(s.max=e.maxLength.value),t.parameter=s}}return void 0!==t.parameter?t:void 0},yl=(r,t)=>{const e=[];for(const i of t){const n=_e(i.name);if(!n)continue;const o=new Lr(r,n);i.cardinality&&(o.cardinality=i.cardinality),o.predefinedType=_e(i.predefinedType),o.instructions=i.instructions,e.push(o)}return e},wl=(r,t)=>{const e=[];for(const i of t){const n=_e(i.name);if(!n)continue;const o=new Zf(r,n);i.cardinality&&(o.cardinality=i.cardinality),o.value=_e(i.value),o.instructions=i.instructions,e.push(o)}return e},vl=(r,t)=>{const e=[];for(const i of t){const s=new Kf(r);i.cardinality&&(s.cardinality=i.cardinality);const n=_e(i.value);"enumeration"===n?.type&&Array.isArray(n.parameter)&&(n.parameter=n.parameter.map(String)),s.value=n,s.uri=i.uri,s.instructions=i.instructions,e.push(s)}return e},bl=(r,t)=>{const e=[];for(const i of t){const n=i.baseName,o=_e(i.propertySet),a=_e(n);if(!a||!o)continue;const l=new Xf(r,o,a);i.cardinality&&(l.cardinality=i.cardinality);const c=_e(i.value);l.value=c,l.dataType=i.dataType,l.uri=i.uri,l.instructions=i.instructions,e.push(l)}return e},xl=(r,t)=>{const e=[];for(const i of t){const n=_e(i.system);if(!n)continue;const o=new Wf(r,n);i.cardinality&&(o.cardinality=i.cardinality);const a=_e(i.value);"simple"===a?.type&&(a.parameter=String(a.parameter)),"enumeration"===a?.type&&Array.isArray(a.parameter)&&(a.parameter=a.parameter.map(String)),o.value=a,o.uri=i.uri,o.instructions=i.instructions,e.push(o)}return e},Cl=(r,t)=>{const e=[];for(const i of t){const s=_e(i.entity.name);if(!s)continue;const n=_e(i.entity.predefinedType),o=new Qf(r,{name:s,predefinedType:n});o.relation=i.relation,i.cardinality&&(o.cardinality=i.cardinality),o.instructions=i.instructions,e.push(o)}return e},Nr=class wo extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"IDSInfo"),y(this,"list",new ot.jp),t.add(wo.uuid,this)}getModelIdMap(t){const e={},i={};for(const[s,n]of t){const a=[...n].filter(([,h])=>h.pass).map(([h])=>h);Rt.append(e,s,...a);const c=[...n].filter(([,h])=>!h.pass).map(([h])=>h);Rt.append(i,s,...c)}return{pass:e,fail:i}}create(t,e,i){const s=new Jf(this.components,t,e);return i&&(s.identifier=i),this.list.set(s.identifier,s),s}load(t){const e=[],i=wo.xmlParser.parse(t).ids,{specifications:s,info:n}=i;if(this.IDSInfo={...n},s&&s.specification){const o=Array.isArray(s.specification)?s.specification:[s.specification];for(const a of o){const{name:l,ifcVersion:c,description:h,instructions:u,identifier:f}=a;if(!l||!c)continue;const d=[],_=[],{applicability:m,requirements:w}=a;if(m){const{maxOccurs:T,...C}=m,S=Array.isArray(C)?C:[C];for(const M of S)for(const A in M){const O=Array.isArray(M[A])?M[A]:[M[A]];if("entity"===A){const I=yl(this.components,O);d.push(...I)}if("attribute"===A){const I=wl(this.components,O);d.push(...I)}if("material"===A){const I=vl(this.components,O);d.push(...I)}if("classification"===A){const I=xl(this.components,O);d.push(...I)}if("property"===A){const I=bl(this.components,O);d.push(...I)}if("partOf"===A){const I=Cl(this.components,O);d.push(...I)}}}let g;if(w){const{maxOccurs:T,...C}=w;g=w.description;const S=Array.isArray(C)?C:[C];for(const M of S)for(const A in M){const O=Array.isArray(M[A])?M[A]:[M[A]];if("entity"===A){const I=yl(this.components,O);_.push(...I)}if("attribute"===A){const I=wl(this.components,O);_.push(...I)}if("material"===A){const I=vl(this.components,O);_.push(...I)}if("classification"===A){const I=xl(this.components,O);_.push(...I)}if("property"===A){const I=bl(this.components,O);_.push(...I)}if("partOf"===A){const I=Cl(this.components,O);_.push(...I)}}}const v=this.create(l,c.split(/\s+/),f);v.description=h,v.instructions=u,v.requirementsDescription=g,v.applicability.add(...d),v.requirements.add(..._),e.push(v)}}return e}export(t,e=this.list.values()){const i=e??this.list;return`<ids xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://standards.buildingsmart.org/IDS http://standards.buildingsmart.org/IDS/1.0/ids.xsd" xmlns:ids="http://standards.buildingsmart.org/IDS">\n \x3c!-- Made with That Open Engine ${Ar.release} (https://github.com/thatopen/engine_components) --\x3e\n <info>\n <title>${t.title}</title>\n ${t.copyright?`<copyright>${t.copyright}</copyright>`:""}\n ${t.version?`<version>${t.version}</version>`:""}\n ${t.description?`<description>${t.description}</description>`:""}\n ${t.author?`<author>${t.author}</author>`:""}\n ${t.date?`<date>${t.date.toISOString().split("T")[0]}</date>`:""}\n ${t.purpose?`<purpose>${t.purpose}</purpose>`:""}\n ${t.milestone?`<milestone>${t.milestone}</milestone>`:""}\n </info>\n <specifications>\n ${[...i].map(n=>n.serialize()).join("\n")}\n </specifications>\n</ids>`}};y(Nr,"uuid","9f0b9f78-9b2e-481a-b766-2fbfd01f342c"),y(Nr,"xmlParser",new Fn({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0}));let tp=Nr;y(class Xc extends At{constructor(t){super(t),y(this,"enabled",!0),t.add(Xc.uuid,this)}static distanceFromPointToLine(t,e,i,s=!1){const n=new p.cZY,o=new p.Pq0;return n.set(e,i),n.closestPointToPoint(t,s,o),o.distanceTo(t)}round(t){t.x=Math.trunc(1e3*t.x)/1e3,t.y=Math.trunc(1e3*t.y)/1e3,t.z=Math.trunc(1e3*t.z)/1e3}getVolumeFromFragments(t){var e=this;return(0,G.A)(function*(){return console.warn("getVolumeFromFragments is deprecated. Use getItemsVolume instead."),e.getItemsVolume(t)})()}getItemsVolume(t){var e=this;return(0,G.A)(function*(){let i=0;const s=e.components.get(ft);for(const[n,o]of Object.entries(t)){const a=s.list.get(n);a&&(i+=(yield a.getItemsVolume([...o])))}return i})()}static convertUnits(t,e,i,s=2){const n={m:1,cm:.01,mm:.001,km:1e3,m2:1,cm2:1e-4,mm2:1e-6,km2:1e6,m3:1,cm3:1e-6,mm3:1e-9,km3:1e9};if(!n[e]||!n[i])throw new Error("Invalid units provided for conversion.");if(!Number.isInteger(s)||s<0||s>5)throw new Error("Precision must be an integer between 0 and 5.");const l=10**s;return Math.round(t*(n[e]/n[i])*l)/l}},"uuid","267ca032-672f-4cb0-afa9-d24e904f39d6");const Tl=(r,t,e)=>{const i=new p.Pq0(-t.z,0,t.x),s=new p.Pq0(t.x+i.x,0,t.z+i.z).normalize().multiplyScalar(e/2);return[r.x+s.x,r.y,r.z+s.z,r.x-s.x,r.y,r.z-s.z]},Pl=(r,t,e)=>{const i=new p.Pq0(-t.z,0,t.x);return[r.x,r.y,r.z,r.x-t.x*e+i.x*e*.4,r.y,r.z-t.z*e+i.z*e*.4,r.x,r.y,r.z,r.x-t.x*e-i.x*e*.4,r.y,r.z-t.z*e-i.z*e*.4]},ep=()=>[],ip=(r,t,e)=>{const i=new p.Pq0(-t.z,0,t.x),s=r.clone().addScaledVector(t,-e),n=s.clone().addScaledVector(i,.4*e),o=s.clone().addScaledVector(i,.4*-e);return[r.x,r.y,r.z,n.x,n.y,n.z,o.x,o.y,o.z]};class sp extends ot.jp{constructor(){super()}getBySystem(t){const e=new Map;for(const[i,s]of this)s.system===t&&e.set(i,s.data);return e}}class np extends ot.jp{constructor(t){super(),y(this,"_container"),this._container=t,this.deleteGuard=e=>"0"!==e,this.set("0",{name:"0",visible:!0,material:new p.mrM({color:0})})}create(t,e){if(!this.has(t)){const i={name:t,visible:e?.visible??!0,material:e?.material??new p.mrM({color:0})};this.set(t,i)}return this.get(t)}setColor(t,e){const i=this.get(t);i&&(i.material.color.setHex(e),this.set(t,i))}setMaterial(t,e){const i=this.get(t);if(!i)return;const s=i.material;i.material=e,this._container.traverse(n=>{n.userData.layer===t&&(n.userData.isDimension||n.isLineSegments&&(n.material=e))}),s.dispose(),this.set(t,i)}setVisibility(t,e){const i=this.get(t);i&&(i.visible=e,this._container.traverse(s=>{s.userData.layer===t&&(s.visible=e)}),this.set(t,i))}assign(t,e){const i=this.get(e);i&&(t.userData.layer=e,i.visible||(t.visible=!1),t.isLineSegments&&(t.material=i.material))}resolveColor(t){const e=this.get(t);if(e)return e.material.color.getHex()}}const us=class qe extends p.YJl{constructor(t){super(),y(this,"_viewport"),y(this,"_border"),y(this,"_handles",[]),y(this,"_raycaster",new p.tBo),y(this,"_resizable",!1),y(this,"_movable",!1),y(this,"_dragHandle",null),y(this,"_dragConstraints",[]),y(this,"_hoveredHandle",null),y(this,"_moveDrag",null),y(this,"_hoveringBorder",!1),y(this,"_normalMat"),y(this,"_hoverMat"),y(this,"_borderMat"),this._viewport=t,this._borderMat=new p.mrM({color:qe._BORDER_COLOR,depthTest:!1});const e=new p.LoY;e.setAttribute("position",new p.THS(new Float32Array(24),3)),this._border=new p.DXC(e,this._borderMat),this._border.renderOrder=999,this._border.frustumCulled=!1,this._border.userData.isDimension=!0,this.add(this._border),this._normalMat=new p.V9B({color:qe._BORDER_COLOR}),this._hoverMat=new p.V9B({color:qe._BORDER_HOVER_COLOR});const i=new p.Gu$(.05,8,6);for(const s of qe._HANDLE_DEFS){const n=new p.eaF(i,this._normalMat);n.renderOrder=1e3,n.visible=!1,n.userData.constraints=s.constraints,n.userData.isDimension=!0,this.add(n),this._handles.push(n)}this.update()}get resizable(){return this._resizable}set resizable(t){this._resizable=t;for(const e of this._handles)e.visible=t;t||(this._hoveredHandle&&(this._hoveredHandle.material=this._normalMat,this._hoveredHandle=null),this._dragHandle=null,this._dragConstraints=[])}get movable(){return this._movable}set movable(t){this._movable=t,t||(this._moveDrag=null,this._setBorderHover(!1))}get isDragging(){return null!==this._dragHandle||null!==this._moveDrag}update(){const t=this._viewport,e=t.left,i=t.right,s=-t.top,n=-t.bottom,o=.005,a=this._border.geometry.attributes.position;a.setXYZ(0,e,o,s),a.setXYZ(1,i,o,s),a.setXYZ(2,i,o,s),a.setXYZ(3,i,o,n),a.setXYZ(4,i,o,n),a.setXYZ(5,e,o,n),a.setXYZ(6,e,o,n),a.setXYZ(7,e,o,s),a.needsUpdate=!0,this._border.geometry.computeBoundingSphere();const l=(e+i)/2,c=(s+n)/2,h=.01,u=[[e,h,s],[i,h,s],[i,h,n],[e,h,n],[l,h,s],[i,h,c],[l,h,n],[e,h,c]];for(let f=0;f<this._handles.length;f++)this._handles[f].position.set(...u[f])}onPointerMove(t){if(this._dragHandle){const i=this._projectToLocal(t);if(!i)return;for(const s of this._dragConstraints)switch(s){case"left":this._viewport.left=i.x;break;case"right":this._viewport.right=i.x;break;case"top":this._viewport.top=-i.z;break;case"bottom":this._viewport.bottom=-i.z}return this._viewport.right<this._viewport.left&&([this._viewport.left,this._viewport.right]=[this._viewport.right,this._viewport.left],this._dragConstraints=this._dragConstraints.map(s=>"right"===s?"left":"left"===s?"right":s)),this._viewport.top<this._viewport.bottom&&([this._viewport.top,this._viewport.bottom]=[this._viewport.bottom,this._viewport.top],this._dragConstraints=this._dragConstraints.map(s=>"top"===s?"bottom":"bottom"===s?"top":s)),void this.update()}if(this._moveDrag){const i=this._projectToLocal(t);if(!i)return;const s=i.x-this._moveDrag.origin.x,n=i.z-this._moveDrag.origin.z;return this._viewport.left=this._moveDrag.left0+s,this._viewport.right=this._moveDrag.right0+s,this._viewport.top=this._moveDrag.top0-n,this._viewport.bottom=this._moveDrag.bottom0-n,void this.update()}if(!this._resizable&&!this._movable)return;this._raycaster.set(t.origin,t.direction);let e=null;if(this._resizable){const i=this._handles.filter(n=>n.visible),s=this._raycaster.intersectObjects(i,!1);e=s.length>0?s[0].object:null}if(e!==this._hoveredHandle&&(this._hoveredHandle&&(this._hoveredHandle.material=this._normalMat),e&&(e.material=this._hoverMat),this._hoveredHandle=e),this._movable&&!this._hoveredHandle){this._raycaster.params.Line={threshold:qe._LINE_THRESHOLD};const i=this._raycaster.intersectObject(this._border,!1).length>0;this._setBorderHover(i)}else this._setBorderHover(!1)}onPointerDown(t){if(this._resizable||this._movable){if(this._raycaster.set(t.origin,t.direction),this._resizable){const e=this._handles.filter(s=>s.visible),i=this._raycaster.intersectObjects(e,!1);if(i.length>0)return this._dragHandle=i[0].object,void(this._dragConstraints=[...this._dragHandle.userData.constraints])}if(this._movable&&(this._raycaster.params.Line={threshold:qe._LINE_THRESHOLD},this._raycaster.intersectObject(this._border,!1).length>0)){const i=this._projectToLocal(t);if(!i)return;this._moveDrag={origin:i,left0:this._viewport.left,right0:this._viewport.right,top0:this._viewport.top,bottom0:this._viewport.bottom}}}}onPointerUp(){this._dragHandle=null,this._dragConstraints=[],this._moveDrag=null}dispose(){this._border.geometry.dispose(),this._borderMat.dispose(),this._normalMat.dispose(),this._hoverMat.dispose(),this._handles.length>0&&this._handles[0].geometry.dispose(),this.removeFromParent()}_projectToLocal(t){this.updateWorldMatrix(!0,!1);const e=new p.Pq0(0,1,0).transformDirection(this.matrixWorld),i=(new p.Pq0).setFromMatrixPosition(this.matrixWorld),s=(new p.Zcv).setFromNormalAndCoplanarPoint(e,i),n=new p.Pq0;return t.intersectPlane(s,n)?this.worldToLocal(n):null}_setBorderHover(t){t!==this._hoveringBorder&&(this._hoveringBorder=t,this._borderMat.color.setHex(t?qe._BORDER_HOVER_COLOR:qe._BORDER_COLOR))}};y(us,"_BORDER_COLOR",22015),y(us,"_BORDER_HOVER_COLOR",16746496),y(us,"_LINE_THRESHOLD",.06),y(us,"_HANDLE_DEFS",[{constraints:["left","top"]},{constraints:["right","top"]},{constraints:["right","bottom"]},{constraints:["left","bottom"]},{constraints:["top"]},{constraints:["right"]},{constraints:["bottom"]},{constraints:["left"]}]);let rp=us;class op{constructor(t){y(this,"uuid",p.cj9.generateUUID()),y(this,"name"),y(this,"camera"),y(this,"onDisposed",new Q),y(this,"_left"),y(this,"_right"),y(this,"_top"),y(this,"_bottom"),y(this,"_drawingScale"),y(this,"_container",null),y(this,"_helper",null),y(this,"_helperVisible",!1),this._left=t.left,this._right=t.right,this._top=t.top,this._bottom=t.bottom,this._drawingScale=t.scale??100,this.name=t.name??"Drawing Viewport",this.camera=new p.qUd(this._left,this._right,this._top,this._bottom,.1,30),this.camera.up.set(0,0,-1),this.camera.position.set(0,10,0),this.camera.lookAt(0,0,0),this.camera.layers.set(1)}get left(){return this._left}set left(t){var e;this._left=t,this.camera.left=t,this.camera.updateProjectionMatrix(),null==(e=this._helper)||e.update()}get right(){return this._right}set right(t){var e;this._right=t,this.camera.right=t,this.camera.updateProjectionMatrix(),null==(e=this._helper)||e.update()}get top(){return this._top}set top(t){var e;this._top=t,this.camera.top=t,this.camera.updateProjectionMatrix(),null==(e=this._helper)||e.update()}get bottom(){return this._bottom}set bottom(t){var e;this._bottom=t,this.camera.bottom=t,this.camera.updateProjectionMatrix(),null==(e=this._helper)||e.update()}get drawingScale(){return this._drawingScale}set drawingScale(t){this._drawingScale=t}get helper(){return this._helper||(this._helper=new rp(this)),this._helper}get helperVisible(){return this._helperVisible}set helperVisible(t){var e,i;this._helperVisible=t,t?null==(e=this._container)||e.add(this.helper):null==(i=this._helper)||i.removeFromParent()}get bbox(){const t=new p.Pq0(this._left,0,-this._top),e=new p.Pq0(this._right,0,-this._bottom);return new p.NRn(t,e)}get size(){const t=new p.Pq0;return this.bbox.getSize(t),new p.I9Y(1e3*t.x,1e3*t.z)}get localXAxis(){return new p.Pq0(1,0,0)}get localYAxis(){return new p.Pq0(0,0,-1)}get normal(){return new p.Pq0(0,1,0)}setContainer(t){this._container=t,this._helperVisible&&this._helper&&t.add(this._helper)}clipLine(t){const e=this.bbox,{start:i,end:s}=t,n=e.containsPoint(i),o=e.containsPoint(s);if(n&&o)return t;if(!n&&!o){const l=this.getPlaneIntersections(t);return l.length<2?null:new p.cZY(l[0],l[1])}const a=this.getPlaneIntersections(t);return 0===a.length?null:n?new p.cZY(i,a[0]):new p.cZY(a[0],s)}dispose(){var t;null==(t=this._helper)||t.dispose(),this._helper=null,this.onDisposed.trigger(),this.onDisposed.reset()}get bboxPlanes(){const t=this.bbox;return[new p.Zcv(new p.Pq0(1,0,0),-t.min.x),new p.Zcv(new p.Pq0(-1,0,0),t.max.x),new p.Zcv(new p.Pq0(0,0,1),-t.min.z),new p.Zcv(new p.Pq0(0,0,-1),t.max.z)]}getPlaneIntersections(t){const e=[];for(const i of this.bboxPlanes){const s=new p.Pq0;i.intersectLine(t,s)&&this.bbox.containsPoint(s)&&e.push(s)}return e}}class ap extends ot.jp{constructor(t){super(),y(this,"_container"),this._container=t,this.onBeforeDelete.add(({value:e})=>{this._container.remove(e.camera),e.dispose()})}create(t){const e=new op(t);return this._container.add(e.camera),e.setContainer(this._container),this.set(e.uuid,e),e}}const Sl=class wn extends p.YJl{constructor(t){super(),y(this,"_drawing"),y(this,"_topFrame"),y(this,"_pillars"),y(this,"_bottomFrame"),y(this,"_topPlane"),y(this,"_bottomPlane"),y(this,"_frameMat"),y(this,"_depthMat"),y(this,"_planeMat"),y(this,"width",10),y(this,"height",10),y(this,"farHandle",new p.B69),y(this,"widthHandle",new p.B69),y(this,"heightHandle",new p.B69),this._drawing=t,this._frameMat=new p.mrM({color:wn._FRAME_COLOR,depthTest:!1}),this._depthMat=new p.mrM({color:wn._DEPTH_COLOR,depthTest:!1,transparent:!0,opacity:.4}),this._planeMat=new p.V9B({color:wn._FRAME_COLOR,transparent:!0,opacity:.07,side:p.$EB,depthTest:!1});const e=()=>{const o=new p.LoY;return o.setAttribute("position",new p.THS(new Float32Array(12),3)),o.setIndex([0,1,2,0,2,3]),o};this._topPlane=new p.eaF(e(),this._planeMat),this._topPlane.renderOrder=998,this._topPlane.frustumCulled=!1,this._topPlane.userData.isDimension=!0,this._bottomPlane=new p.eaF(e(),this._planeMat),this._bottomPlane.renderOrder=998,this._bottomPlane.frustumCulled=!1,this._bottomPlane.userData.isDimension=!0;const i=new p.LoY;i.setAttribute("position",new p.THS(new Float32Array(24),3)),this._topFrame=new p.DXC(i,this._frameMat),this._topFrame.renderOrder=999,this._topFrame.frustumCulled=!1,this._topFrame.userData.isDimension=!0;const s=new p.LoY;s.setAttribute("position",new p.THS(new Float32Array(24),3)),this._pillars=new p.DXC(s,this._depthMat),this._pillars.renderOrder=999,this._pillars.frustumCulled=!1,this._pillars.userData.isDimension=!0;const n=new p.LoY;n.setAttribute("position",new p.THS(new Float32Array(24),3)),this._bottomFrame=new p.DXC(n,this._depthMat),this._bottomFrame.renderOrder=999,this._bottomFrame.frustumCulled=!1,this._bottomFrame.userData.isDimension=!0,this.add(this._topPlane,this._bottomPlane),this.add(this._topFrame,this._pillars,this._bottomFrame),this.add(this.farHandle,this.widthHandle,this.heightHandle),this.farHandle.rotation.x=Math.PI,this.update()}update(){const t=this.width/2,e=this.height/2,i=-this._drawing.far,s=.005,n=-t,o=t,a=-e,l=e,c=this._topFrame.geometry.attributes.position;c.setXYZ(0,n,s,a),c.setXYZ(1,o,s,a),c.setXYZ(2,o,s,a),c.setXYZ(3,o,s,l),c.setXYZ(4,o,s,l),c.setXYZ(5,n,s,l),c.setXYZ(6,n,s,l),c.setXYZ(7,n,s,a),c.needsUpdate=!0,this._topFrame.geometry.computeBoundingSphere();const h=this._pillars.geometry.attributes.position;h.setXYZ(0,n,s,a),h.setXYZ(1,n,i,a),h.setXYZ(2,o,s,a),h.setXYZ(3,o,i,a),h.setXYZ(4,o,s,l),h.setXYZ(5,o,i,l),h.setXYZ(6,n,s,l),h.setXYZ(7,n,i,l),h.needsUpdate=!0,this._pillars.geometry.computeBoundingSphere();const u=this._bottomFrame.geometry.attributes.position;u.setXYZ(0,n,i,a),u.setXYZ(1,o,i,a),u.setXYZ(2,o,i,a),u.setXYZ(3,o,i,l),u.setXYZ(4,o,i,l),u.setXYZ(5,n,i,l),u.setXYZ(6,n,i,l),u.setXYZ(7,n,i,a),u.needsUpdate=!0,this._bottomFrame.geometry.computeBoundingSphere();const f=(d,_)=>{const m=d.geometry.attributes.position;m.setXYZ(0,n,_,a),m.setXYZ(1,o,_,a),m.setXYZ(2,o,_,l),m.setXYZ(3,n,_,l),m.needsUpdate=!0,d.geometry.computeBoundingSphere()};f(this._topPlane,s),f(this._bottomPlane,i),this.farHandle.position.set(0,i,0),this.widthHandle.position.set(o,s,0),this.heightHandle.position.set(0,s,l)}attachFarGizmo(t){t.attach(this.farHandle),t.setSpace("local"),t.showX=!1,t.showZ=!1,t.addEventListener("objectChange",()=>{this.farHandle.position.x=0,this.farHandle.position.z=0;const e=Math.max(.1,-this.farHandle.position.y);this._drawing.far=e,this.farHandle.position.y=-e,this.update()})}attachWidthGizmo(t){t.attach(this.widthHandle),t.setSpace("local"),t.showY=!1,t.showZ=!1,t.addEventListener("objectChange",()=>{this.widthHandle.position.y=.005,this.widthHandle.position.z=0,this.width=Math.max(.1,2*this.widthHandle.position.x),this.widthHandle.position.x=this.width/2,this.update()})}attachHeightGizmo(t){t.attach(this.heightHandle),t.setSpace("local"),t.showX=!1,t.showY=!1,t.addEventListener("objectChange",()=>{this.heightHandle.position.x=0,this.heightHandle.position.y=.005,this.height=Math.max(.1,2*this.heightHandle.position.z),this.heightHandle.position.z=this.height/2,this.update()})}dispose(){this._topPlane.geometry.dispose(),this._bottomPlane.geometry.dispose(),this._topFrame.geometry.dispose(),this._pillars.geometry.dispose(),this._bottomFrame.geometry.dispose(),this._planeMat.dispose(),this._frameMat.dispose(),this._depthMat.dispose(),this.removeFromParent()}};y(Sl,"_FRAME_COLOR",22015),y(Sl,"_DEPTH_COLOR",22015);class Br{constructor(t){y(this,"uuid",p.cj9.generateUUID()),y(this,"_raycaster",new p.tBo),y(this,"_components"),y(this,"world",null),y(this,"three",new p.YJl),y(this,"annotations",new sp),y(this,"layers",new np(this.three)),y(this,"activeLayer","0"),y(this,"far",10),y(this,"viewports",new ap(this.three)),y(this,"onDisposed",new Q),this._components=t}raycast(t,e=null){this._raycaster.set(t.origin,t.direction),this._raycaster.layers.set(1),this._raycaster.params.Line&&(this._raycaster.params.Line.threshold=.1);const i=[];this.three.traverse(l=>{l instanceof p.DXC&&!l.userData.isDimension&&i.push(l)});const s=this._raycaster.intersectObjects(i,!1);if(0===s.length)return null;const n=s[0],o=this.three.worldToLocal(n.point.clone());let a=null;if(n.object instanceof p.DXC&&void 0!==n.index){const l=n.object.geometry.attributes.position,c=n.index,h=new p.Pq0(l.getX(c),l.getY(c),l.getZ(c)),u=new p.Pq0(l.getX(c+1),l.getY(c+1),l.getZ(c+1));h.applyMatrix4(n.object.matrixWorld),this.three.worldToLocal(h),u.applyMatrix4(n.object.matrixWorld),this.three.worldToLocal(u),a=new p.cZY(h,u)}return{point:o,object:n.object,viewport:e,line:a}}alignTo(t,e){(function lp(r,t){if(3!==r.length||3!==t.length)throw new Error("computeAlignmentMatrix requires exactly 3 point pairs.");const e=(d,_)=>{const m=(new p.Pq0).subVectors(d[1],d[0]),w=(new p.Pq0).subVectors(d[2],d[0]);if((new p.Pq0).crossVectors(m,w).length()<1e-6)throw new Error(`${_} points are collinear \u2014 three non-collinear points are required to define a plane.`)};e(r,"Drawing"),e(t,"World");const i=(d,_,m)=>{const w=(new p.Pq0).subVectors(_,d),g=(new p.Pq0).subVectors(m,d),v=w.clone().normalize(),T=(new p.Pq0).crossVectors(w,g).normalize(),C=(new p.Pq0).crossVectors(v,T).normalize();return(new p.kn4).makeBasis(v,T,C)},s=i(r[0],r[1],r[2]),o=i(t[0],t[1],t[2]).clone().multiply(s.clone().invert()),a=r[0].distanceTo(r[1]);if(a<1e-10)throw new Error("The first two drawing points are coincident \u2014 cannot compute scale.");const l=t[0].distanceTo(t[1])/a,c=r[0].clone().multiplyScalar(l).applyMatrix4(o),h=(new p.Pq0).subVectors(t[0],c),u=(new p.PTz).setFromRotationMatrix(o),f=new p.kn4;return f.compose(h,u,new p.Pq0(l,l,l)),f})(t,e).decompose(this.three.position,this.three.quaternion,this.three.scale)}static toDrawingSpace(t,e){t.updateWorldMatrix(!0,!1),e.three.updateWorldMatrix(!0,!1);const i=(new p.kn4).copy(e.three.matrixWorld).invert().multiply(t.matrixWorld),s=t.geometry.attributes.position,n=s.count,o=new Float32Array(3*n),a=new p.Pq0;for(let c=0;c<n;c++)a.fromBufferAttribute(s,c).applyMatrix4(i),o[3*c]=a.x,o[3*c+1]=0,o[3*c+2]=a.z;const l=new p.LoY;return l.setAttribute("position",new p.THS(o,3)),new p.DXC(l)}addProjectionLines(t,e="0"){return this.layers.has(e)||(console.warn(`[TechnicalDrawing] Layer "${e}" does not exist. Falling back to "0".`),e="0"),this.layers.assign(t,e),t.layers.set(1),t.material instanceof p.Fvt&&t.computeLineDistances(),t.geometry.computeBoundsTree({strategy:0,indirect:!0,type:xd}),this.three.add(t),t}addProjectionFromItems(t,e){var i=this;return(0,G.A)(function*(){if(!i.world)return void console.warn("[TechnicalDrawing] addProjectionFromItems: drawing has no world assigned.");for(const l of[e.layers.visible,e.layers.hidden])if(!i.layers.has(l))return void console.warn(`[TechnicalDrawing] Layer "${l}" does not exist \u2014 create it before calling addProjectionFromItems.`);const s=i._components.get(rf),n=s.projectionDirection.clone(),o=s.nearPlane,a=s.farPlane;try{i.three.updateWorldMatrix(!0,!1);const l=new p.Pq0(0,-1,0).transformDirection(i.three.matrixWorld).normalize();s.projectionDirection.copy(l);const c=(new p.kn4).makeRotationFromQuaternion((new p.PTz).setFromUnitVectors(l,new p.Pq0(0,-1,0))),h=(new p.Pq0).setFromMatrixPosition(i.three.matrixWorld).applyMatrix4(c).y;s.farPlane=h,s.nearPlane=h-i.far;const u=yield s.get(t,i.world,{onProgress:e.onProgress}),f=d=>Br.toDrawingSpace(new p.DXC(d),i);i.addProjectionLines(f(u.visible),e.layers.visible),i.addProjectionLines(f(u.hidden),e.layers.hidden)}finally{s.projectionDirection.copy(n),s.nearPlane=o,s.farPlane=a}})()}orientTo(t){const e=t.clone().normalize(),i=Math.SQRT1_2;e.x>.999?this.three.quaternion.set(.5,-.5,.5,.5):e.x<-.999?this.three.quaternion.set(.5,.5,-.5,.5):e.y>.999?this.three.quaternion.set(0,0,1,0):e.y<-.999?this.three.quaternion.set(0,0,0,1):e.z>.999?this.three.quaternion.set(0,i,-i,0):e.z<-.999?this.three.quaternion.set(i,0,0,i):console.warn("[TechnicalDrawing] orientTo: direction does not match any of the 6 standard axes.")}dispose(){this.viewports.clear(),this.layers.clear(),this.annotations.clear(),this._components.get(bi).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset()}}class Bi{constructor(t){y(this,"styles",new ot.jp),y(this,"activeStyle","default"),y(this,"onCommit",new Q),y(this,"onUpdate",new Q),y(this,"onDelete",new Q),y(this,"onDisposed",new Q),y(this,"_knownDrawings",new Set),y(this,"_previewMaterial",new p.mrM({color:16737894,depthTest:!1})),y(this,"_previewObject",null),y(this,"_previewDrawing",null),y(this,"_materialCache",new ot.jp),y(this,"_meshMaterialCache",new ot.jp),y(this,"_ownsChildGeometry",!0),this._components=t,this.styles.onItemUpdated.add(({key:e})=>{const i=this._materialCache.get(e);i&&i.color.setHex(this._resolveStyle(e).color);const s=this._meshMaterialCache.get(e);s&&s.color.setHex(this._resolveStyle(e).color);const n=this._components.get(Re),o=n?[...n.list.values()]:[...this._knownDrawings];for(const a of o){const l=[...a.annotations.getBySystem(this)].filter(([,c])=>c.style===e).map(([c])=>c);l.length>0&&this.update(a,l,{})}})}_onAfterPersist(t,e){}_onDispose(){}_updatePreview(){}get(t){const e=new ot.jp;for(const i of t)for(const[s,n]of i.annotations.getBySystem(this))e.set(s,{drawingUuid:i.uuid,item:n});return e}add(t,e){const i={uuid:p.cj9.generateUUID(),style:this.activeStyle,...e},s=this._persist(t,i);return this.onCommit.trigger([s]),i}update(t,e,i){for(const s of e){const n=t.annotations.get(s);if(!n||n.system!==this)continue;const o=n.data;Object.assign(o,i),this._redraw(o,n.three),this.onUpdate.trigger({item:o,group:n.three})}}pick(t,e=.05){const i=new p.tBo;i.ray.copy(t),i.params.Line={threshold:e},i.params.LineSegments={threshold:e};const s=p.N1A.prototype.raycast;let n=null,o=1/0;for(const a of this._knownDrawings)for(const[l,c]of a.annotations){if(c.system!==this)continue;const h=c.three;h.updateWorldMatrix(!0,!0),h.traverse(u=>{if(u===h)return;const f=[];if(u instanceof p.DXC&&u.userData.isDimension)s.call(u,i,f),f.length>0&&f[0].distance<o&&(o=f[0].distance,n=l);else if(u instanceof p.eaF){const d=(new p.NRn).setFromObject(u),_=new p.Pq0;if(i.ray.intersectBox(d,_)){const m=i.ray.origin.distanceTo(_);m<o&&(o=m,n=l)}}})}return n}delete(t,e){const i=[];for(const s of e){const n=t.annotations.get(s);!n||n.system!==this||(this._disposeGroup(n.three),t.annotations.delete(s),i.push(s))}i.length&&this.onDelete.trigger(i)}clear(t){const e=t??[...this._knownDrawings];for(const i of e){const s=[];for(const[n,o]of i.annotations)o.system===this&&s.push(n);for(const n of s){const o=i.annotations.get(n);this._disposeGroup(o.three),i.annotations.delete(n)}}}dispose(){this._clearPreview(),this._onDispose(),this.clear();for(const t of this._materialCache.values())t.dispose();this._materialCache.clear();for(const t of this._meshMaterialCache.values())t.dispose();this._meshMaterialCache.clear(),this._previewMaterial.dispose(),this.onCommit.reset(),this.onUpdate.reset(),this.onDelete.reset(),this.onDisposed.trigger(),this.onDisposed.reset()}_trackDrawing(t){this._knownDrawings.has(t)||(this._knownDrawings.add(t),t.onDisposed.add(()=>this._knownDrawings.delete(t)))}_resolveStyle(t){return this.styles.get(t)??this.styles.get("default")}_getMaterial(t){const e=this._materialCache.get(t);if(e)return e;const i=new p.mrM({color:this._resolveStyle(t).color});return this._materialCache.set(t,i),i}_getMeshMaterial(t){const e=this._meshMaterialCache.get(t);if(e)return e;const i=new p.V9B({color:this._resolveStyle(t).color,side:p.$EB});return this._meshMaterialCache.set(t,i),i}_disposeGroup(t){if(t.removeFromParent(),this._ownsChildGeometry)t.traverse(e=>{e.geometry instanceof p.LoY&&e.geometry.dispose()});else for(;t.children.length>0;)t.remove(t.children[0])}_clearPreview(){this._previewObject&&(this._previewObject.removeFromParent(),this._previewObject.geometry.dispose(),this._previewObject=null)}_persist(t,e){this._trackDrawing(t);const i=this._resolveStyle(e.style),s=this._buildGroup(e,i);return s.userData.isDimension=!0,s.userData.annotationUuid=e.uuid,s.userData.layer=t.activeLayer,t.three.add(s),t.annotations.set(e.uuid,{system:this,data:e,three:s}),this._onAfterPersist(e,s),{drawing:t,item:e,group:s}}_redraw(t,e){for(;e.children.length>0;){const n=e.children[0];this._ownsChildGeometry&&n.geometry instanceof p.LoY&&n.geometry.dispose(),e.remove(n)}const i=this._resolveStyle(t.style),s=this._buildGroup(t,i);for(;s.children.length>0;)e.add(s.children[0]);this._onAfterPersist(t,e)}}function El(r,t){const e=r[0],i=r[r.length-1],s=(new p.Pq0).subVectors(i,e);if(s.lengthSq()<1e-10)return 0;s.normalize();const n=new p.Pq0(-s.z,0,s.x);return t.clone().sub(e).dot(n)}function dp(r,t){const e=[];for(let i=0;i<r.length-1;i++)e.push({uuid:p.cj9.generateUUID(),pointA:r[i].clone(),pointB:r[i+1].clone(),offset:t,style:""});return e}function Al(r){const{pointA:t,pointB:e,offset:i}=r,s=(new p.Pq0).subVectors(e,t),n=new p.Pq0(-s.z,0,s.x).normalize(),o=t.clone().addScaledVector(n,i),a=e.clone().addScaledVector(n,i),l=(new p.Pq0).subVectors(a,o).normalize();return[{tip:o,dir:l},{tip:a,dir:l.clone().negate()}]}function Rr(r,t){const{pointA:e,pointB:i,offset:s}=r,n=(new p.Pq0).subVectors(i,e),o=new p.Pq0(-n.z,0,n.x).normalize(),a=s>=0?1:-1,l=Math.abs(s),c=e.clone().addScaledVector(o,t.extensionGap*a),h=e.clone().addScaledVector(o,(l+t.extensionOvershoot)*a),u=i.clone().addScaledVector(o,t.extensionGap*a),f=i.clone().addScaledVector(o,(l+t.extensionOvershoot)*a),d=e.clone().addScaledVector(o,s),_=i.clone().addScaledVector(o,s),m=(new p.Pq0).subVectors(_,d).normalize(),w=t.lineTick(d,m,t.tickSize),g=t.lineTick(_,m.clone().negate(),t.tickSize);return[c.x,c.y,c.z,h.x,h.y,h.z,u.x,u.y,u.z,f.x,f.y,f.z,d.x,d.y,d.z,_.x,_.y,_.z,...w,...g]}class mp extends Bi{constructor(t){super(t),y(this,"enabled",!0),y(this,"machineState",{kind:"awaitingFirstPoint"}),y(this,"onMachineStateChanged",new Q),this.styles.set("default",{lineTick:Tl,tickSize:.4,extensionGap:.05,extensionOvershoot:.2,color:0,textOffset:.4,fontSize:.45})}pickHandle(t,e,i=.1){const s=(new p.kn4).copy(t.three.matrixWorld).invert(),n=e.origin.clone().applyMatrix4(s),o=e.direction.clone().transformDirection(s).normalize(),a=new p.RlV(n,o),l=new p.Zcv(new p.Pq0(0,1,0),0),c=a.intersectPlane(l,new p.Pq0);if(!c)return null;let h=null,u=i;for(const[f,d]of t.annotations.getBySystem(this)){const _=(new p.Pq0).subVectors(d.pointB,d.pointA),m=new p.Pq0(-_.z,0,_.x).normalize(),w=(new p.Pq0).addVectors(d.pointA,d.pointB).multiplyScalar(.5).addScaledVector(m,d.offset);for(const[g,v]of[["pointA",d.pointA],["pointB",d.pointB],["offset",w]]){const T=Math.hypot(c.x-v.x,c.z-v.z);T<u&&(u=T,h={uuid:f,handle:g})}}return h}sendMachineEvent(t){const e=t.drawing??null;e&&(this._previewDrawing=e);const i=function fp(r,t){switch(r.kind){case"awaitingFirstPoint":if("CLICK"===t.type){if(!t.line)return r;const e=(new p.Pq0).subVectors(t.line.end,t.line.start).normalize();return{kind:"placingPoints",points:[t.point.clone()],cursor:null,lineDir:e,firstLine:t.line.clone()}}return"SELECT_LINE"===t.type?{kind:"positioningOffset",points:[t.line.start.clone(),t.line.end.clone()],cursor:null}:r;case"placingPoints":if("MOUSE_MOVE"===t.type){const e=new p.Pq0(-r.lineDir.z,0,r.lineDir.x),i=r.points[r.points.length-1],s=t.point.clone().sub(i).dot(e),n=i.clone().addScaledVector(e,s);return{...r,cursor:n}}if("CLICK"===t.type){if(!t.line||function up(r,t){return r.start.distanceTo(t.start)<1e-6&&r.end.distanceTo(t.end)<1e-6||r.start.distanceTo(t.end)<1e-6&&r.end.distanceTo(t.start)<1e-6}(t.line,r.firstLine))return r;if(!function hp(r,t){return Math.abs(r.dot(t))>.999}((new p.Pq0).subVectors(t.line.end,t.line.start).normalize(),r.lineDir))return r;const i=function cp(r,t,e){const i=r.clone().sub(t.start).dot(e);return t.start.clone().addScaledVector(e,i)}(r.points[0],t.line,r.lineDir),s=[...r.points,i];return{...r,points:s,cursor:r.cursor}}return"CONFIRM"===t.type&&r.points.length>=2?{kind:"positioningOffset",points:r.points,cursor:null}:"ESCAPE"===t.type?{kind:"awaitingFirstPoint"}:r;case"positioningOffset":if("MOUSE_MOVE"===t.type)return{...r,cursor:t.point.clone()};if("CLICK"===t.type){const e=El(r.points,t.point);return{kind:"committed",dimensions:dp(r.points,e)}}return"ESCAPE"===t.type?{kind:"awaitingFirstPoint"}:r;case"committed":return"ESCAPE"===t.type?{kind:"awaitingFirstPoint"}:r}}(this.machineState,t);if(i!==this.machineState){if(this.machineState=i,this._updatePreview(),"committed"===i.kind){if(!this._previewDrawing)return console.warn("LinearAnnotations: no drawing context \u2014 send a CLICK or SELECT_LINE with `drawing` first. Skipping."),void this._resetMachine();for(const n of i.dimensions)n.style=this.activeStyle;const s=i.dimensions.map(n=>this._persist(this._previewDrawing,n));this.onCommit.trigger(s)}this.onMachineStateChanged.trigger(this.machineState),"committed"===i.kind&&this._resetMachine()}}_buildGroup(t,e){const i=new p.YJl,s=Rr(t,e),n=new p.LoY;n.setAttribute("position",new p.THS(new Float32Array(s),3));const o=new p.DXC(n,this._getMaterial(t.style));if(o.layers.set(1),o.userData.isDimension=!0,i.add(o),e.meshTick)for(const{tip:a,dir:l}of Al(t)){const c=e.meshTick(a,l,e.tickSize),h=new p.LoY;h.setAttribute("position",new p.THS(new Float32Array(c),3));const u=new p.eaF(h,this._getMeshMaterial(t.style));u.layers.set(1),u.userData.isMeshTick=!0,i.add(u)}return i}_updatePreview(){const t=this.machineState;if("placingPoints"!==t.kind&&"positioningOffset"!==t.kind)return void this._clearPreview();if(!this._previewDrawing)return void this._clearPreview();const e=this._resolveStyle(this.activeStyle);this._previewMaterial.color.setHex(e.color);const i=function pp(r,t,e,i){if("placingPoints"===r){const o=[];for(let a=0;a<t.length-1;a++){const l=t[a],c=t[a+1];o.push(l.x,l.y,l.z,c.x,c.y,c.z)}if(e){const a=t[t.length-1];o.push(a.x,a.y,a.z,e.x,e.y,e.z)}return o}if(!e||t.length<2)return[];const s=El(t,e),n=[];for(let o=0;o<t.length-1;o++)n.push(...Rr({uuid:"",pointA:t[o],pointB:t[o+1],offset:s,style:""},i));return n}(t.kind,t.points,t.cursor,e);if(0!==i.length)if(this._previewObject&&this._previewObject.geometry.attributes.position.count===i.length/3){const o=this._previewObject.geometry.attributes.position;o.set(i),o.needsUpdate=!0}else{this._clearPreview();const o=new p.LoY;o.setAttribute("position",new p.THS(new Float32Array(i),3)),this._previewObject=new p.DXC(o,this._previewMaterial),this._previewObject.layers.set(1),this._previewObject.renderOrder=1,this._previewObject.userData.isDimension=!0,this._previewDrawing.three.add(this._previewObject)}else this._clearPreview()}_resetMachine(){this.machineState={kind:"awaitingFirstPoint"},this._previewDrawing=null,this._updatePreview(),this.onMachineStateChanged.trigger(this.machineState)}}const gp=Math.PI/180;function Ml(r,t,e,i){const s=function yp(r,t,e){const i=(new p.Pq0).subVectors(r,t).normalize(),s=(new p.Pq0).subVectors(e,t).normalize();return(new p.Pq0).addVectors(i,s).normalize()}(r,t,e);return(new p.Pq0).subVectors(i,t).setY(0).dot(s)}function Il(r,t,e,i){return Ml(r,t,e,i)<0}function Ol(r){const t=(new p.Pq0).subVectors(r.pointA,r.vertex).normalize(),e=(new p.Pq0).subVectors(r.pointB,r.vertex).normalize(),i=Math.atan2(t.z,t.x);let s=Math.atan2(e.z,e.x)-i;for(;s>Math.PI;)s-=2*Math.PI;for(;s<-Math.PI;)s+=2*Math.PI;r.flipped&&(s-=2*Math.sign(s)*Math.PI);const n=new p.Pq0(r.vertex.x+Math.cos(i)*r.arcRadius,0,r.vertex.z+Math.sin(i)*r.arcRadius),o=i+s,a=new p.Pq0(r.vertex.x+Math.cos(o)*r.arcRadius,0,r.vertex.z+Math.sin(o)*r.arcRadius),l=Math.sign(s);return[{tip:n,dir:new p.Pq0(-Math.sin(i)*l,0,Math.cos(i)*l)},{tip:a,dir:new p.Pq0(Math.sin(o)*l,0,-Math.cos(o)*l)}]}function vp(r){const t=(new p.Pq0).subVectors(r.pointA,r.vertex).normalize(),e=(new p.Pq0).subVectors(r.pointB,r.vertex).normalize(),i=Math.acos(p.cj9.clamp(t.dot(e),-1,1));return r.flipped?2*Math.PI-i:i}function bp(r){const t=(new p.Pq0).subVectors(r.pointA,r.vertex).normalize(),e=(new p.Pq0).subVectors(r.pointB,r.vertex).normalize(),i=Math.atan2(t.z,t.x);let s=Math.atan2(e.z,e.x)-i;for(;s>Math.PI;)s-=2*Math.PI;for(;s<-Math.PI;)s+=2*Math.PI;const n=i+s/2;return r.flipped?n+Math.PI:n}function zl(r,t,e,i,s,n=!1){const o=Math.atan2(t.z,t.x);let a=Math.atan2(e.z,e.x)-o;for(;a>Math.PI;)a-=2*Math.PI;for(;a<-Math.PI;)a+=2*Math.PI;n&&(a-=2*Math.sign(a)*Math.PI);const l=[];for(let v=0;v<8;v++){const T=o+a*(v/8),C=o+a*((v+1)/8);l.push(r.x+Math.cos(T)*i,0,r.z+Math.sin(T)*i,r.x+Math.cos(C)*i,0,r.z+Math.sin(C)*i)}const h=new p.Pq0(r.x+Math.cos(o)*i,0,r.z+Math.sin(o)*i),u=new p.Pq0(r.x+Math.cos(o+a)*i,0,r.z+Math.sin(o+a)*i),f=r.clone().addScaledVector(t,s.extensionGap),d=r.clone().addScaledVector(e,s.extensionGap);l.push(f.x,f.y,f.z,h.x,h.y,h.z,d.x,d.y,d.z,u.x,u.y,u.z);const _=Math.sign(a),m=new p.Pq0(-Math.sin(o)*_,0,Math.cos(o)*_),w=o+a,g=new p.Pq0(Math.sin(w)*_,0,-Math.cos(w)*_);return l.push(...s.lineTick(h,m,s.tickSize),...s.lineTick(u,g,s.tickSize)),l}function Dl(r,t){const e=(new p.Pq0).subVectors(r.pointA,r.vertex).normalize(),i=(new p.Pq0).subVectors(r.pointB,r.vertex).normalize();return zl(r.vertex,e,i,r.arcRadius,t,r.flipped??!1)}function kl(r,t,e,i,s,n=!1){if(!i)return[];const o=Math.max(.05,(new p.Pq0).subVectors(i,t).setY(0).length());return zl(t,(new p.Pq0).subVectors(r,t).normalize(),(new p.Pq0).subVectors(e,t).normalize(),o,s,n)}class xp extends Bi{constructor(t){super(t),y(this,"enabled",!0),y(this,"machineState",{kind:"awaitingFirstLine"}),y(this,"onMachineStateChanged",new Q),y(this,"_secondLinePreviewObject",null),this.styles.set("default",{lineTick:Tl,tickSize:.4,extensionGap:.05,color:0,textOffset:.25,fontSize:.45})}pickHandle(t,e,i){return null}sendMachineEvent(t){const e=t.drawing??null;if("awaitingSecondLine"===this.machineState.kind&&"MOUSE_MOVE"===t.type)return e&&(this._previewDrawing=e),void this._updateSecondLinePreview(t.point,t.line??null);const i=function wp(r,t){switch(r.kind){case"awaitingFirstLine":return"CLICK"===t.type&&t.line?{kind:"awaitingSecondLine",line1:t.line.clone(),pointA:t.point.clone()}:r;case"awaitingSecondLine":if("CLICK"===t.type&&t.line){const e=(new p.Pq0).subVectors(r.line1.end,r.line1.start).normalize(),i=(new p.Pq0).subVectors(t.line.end,t.line.start).normalize();if(Math.abs(e.dot(i))>Math.cos(gp))return r;const n=function _p(r,t,e,i){const s=t.x*i.z-t.z*i.x;if(Math.abs(s)<1e-10)return null;const n=(new p.Pq0).subVectors(e,r),o=(n.x*i.z-n.z*i.x)/s;return new p.Pq0(r.x+t.x*o,0,r.z+t.z*o)}(r.line1.start,e,t.line.start,i);return n?{kind:"positioningArc",pointA:r.pointA.clone(),vertex:n,pointB:t.point.clone(),cursor:null,flipped:!1}:r}return"ESCAPE"===t.type?{kind:"awaitingFirstLine"}:r;case"positioningArc":if("MOUSE_MOVE"===t.type){const e=Il(r.pointA,r.vertex,r.pointB,t.point);return{...r,cursor:t.point.clone(),flipped:e}}if("CLICK"===t.type){const e=Il(r.pointA,r.vertex,r.pointB,t.point),i=Math.max(.05,Math.abs(Ml(r.pointA,r.vertex,r.pointB,t.point)));return{kind:"committed",dimension:{uuid:p.cj9.generateUUID(),pointA:r.pointA.clone(),vertex:r.vertex.clone(),pointB:r.pointB.clone(),arcRadius:i,flipped:e,style:""}}}return"ESCAPE"===t.type?{kind:"awaitingFirstLine"}:r;case"committed":return"ESCAPE"===t.type?{kind:"awaitingFirstLine"}:r}}(this.machineState,t);if(i!==this.machineState){if("awaitingSecondLine"===this.machineState.kind&&this._clearSecondLinePreview(),this.machineState=i,e&&(this._previewDrawing=e),this._updatePreview(),"committed"===i.kind){if(!this._previewDrawing)return console.warn("AngleAnnotations: CLICK that commits must include `drawing`. Skipping."),void this._resetMachine();i.dimension.style=this.activeStyle;const s=this._persist(this._previewDrawing,i.dimension);this.onCommit.trigger([s])}this.onMachineStateChanged.trigger(this.machineState),"committed"===i.kind&&this._resetMachine()}}_buildGroup(t,e){const i=new p.YJl,s=Dl(t,e),n=new p.LoY;n.setAttribute("position",new p.THS(new Float32Array(s),3));const o=new p.DXC(n,this._getMaterial(t.style));if(o.layers.set(1),o.userData.isDimension=!0,i.add(o),e.meshTick)for(const{tip:a,dir:l}of Ol(t)){const c=e.meshTick(a,l,e.tickSize),h=new p.LoY;h.setAttribute("position",new p.THS(new Float32Array(c),3));const u=new p.eaF(h,this._getMeshMaterial(t.style));u.layers.set(1),u.userData.isMeshTick=!0,i.add(u)}return i}_updatePreview(){const t=this.machineState;if("positioningArc"!==t.kind)return void this._clearPreview();if(!this._previewDrawing)return void this._clearPreview();const e=this._resolveStyle(this.activeStyle),i=kl(t.pointA,t.vertex,t.pointB,t.cursor,e,t.flipped);if(0!==i.length)if(this._previewObject&&this._previewObject.geometry.attributes.position.count===i.length/3){const o=this._previewObject.geometry.attributes.position;o.set(i),o.needsUpdate=!0}else{this._clearPreview();const o=new p.LoY;o.setAttribute("position",new p.THS(new Float32Array(i),3)),this._previewObject=new p.DXC(o,this._previewMaterial),this._previewObject.layers.set(1),this._previewObject.renderOrder=1,this._previewObject.userData.isDimension=!0,this._previewDrawing.three.add(this._previewObject)}else this._clearPreview()}_onDispose(){this._clearSecondLinePreview()}_resetMachine(){this.machineState={kind:"awaitingFirstLine"},this._previewDrawing=null,this._updatePreview(),this.onMachineStateChanged.trigger(this.machineState)}_clearSecondLinePreview(){this._secondLinePreviewObject&&(this._secondLinePreviewObject.removeFromParent(),this._secondLinePreviewObject.geometry.dispose(),this._secondLinePreviewObject=null)}_updateSecondLinePreview(t,e){if("awaitingSecondLine"!==this.machineState.kind)return void this._clearSecondLinePreview();if(!this._previewDrawing)return void this._clearSecondLinePreview();const i=this.machineState,s=(new p.Pq0).subVectors(i.line1.end,i.line1.start).normalize();if(!e)return void this._clearSecondLinePreview();const n=(new p.Pq0).subVectors(e.end,e.start).normalize(),o=function Cp(r,t,e,i){const s=t.x*i.z-t.z*i.x;if(Math.abs(s)<1e-6)return null;const a=((e.x-r.x)*i.z-(e.z-r.z)*i.x)/s;return new p.Pq0(r.x+a*t.x,0,r.z+a*t.z)}(i.line1.start,s,e.start,n);if(!o)return void this._clearSecondLinePreview();const a=t.clone(),l=(new p.Pq0).subVectors(a,o).setY(0);if(l.length()<.01)return void this._clearSecondLinePreview();const c=(new p.Pq0).subVectors(i.pointA,o).normalize(),h=l.normalize(),u=Math.atan2(c.z,c.x);let f=Math.atan2(h.z,h.x)-u;for(;f>Math.PI;)f-=2*Math.PI;for(;f<-Math.PI;)f+=2*Math.PI;const d=u+f/2,_=Math.max(.1,.4*Math.min(i.pointA.distanceTo(o),a.distanceTo(o))),m=new p.Pq0(o.x+Math.cos(d)*_,0,o.z+Math.sin(d)*_),w=this._resolveStyle(this.activeStyle),g=kl(i.pointA,o,a,m,w);if(0!==g.length)if(this._secondLinePreviewObject&&this._secondLinePreviewObject.geometry.attributes.position.count===g.length/3){const C=this._secondLinePreviewObject.geometry.attributes.position;C.set(g),C.needsUpdate=!0}else{this._clearSecondLinePreview();const C=new p.LoY;C.setAttribute("position",new p.THS(new Float32Array(g),3)),this._secondLinePreviewObject=new p.DXC(C,this._previewMaterial),this._secondLinePreviewObject.layers.set(1),this._secondLinePreviewObject.renderOrder=1,this._secondLinePreviewObject.userData.isDimension=!0,this._previewDrawing.three.add(this._secondLinePreviewObject)}else this._clearSecondLinePreview()}}function Ll(r,t){const e=t.x-r.x,i=t.z-r.z,s=Math.sqrt(e*e+i*i);if(0===s)return r.clone();const n=Math.atan2(i,e),o=Math.round(n/(Math.PI/4))*(Math.PI/4);return new p.Pq0(r.x+Math.cos(o)*s,0,r.z+Math.sin(o)*s)}function Fr(r,t,e,i){return"curved"===i.leaderShape?function Ep(r,t,e,i){const n=new p.CV9(r,t,e).getPoints(24),o=[];for(let a=0;a<n.length-1;a++){const l=n[a],c=n[a+1];o.push(l.x,l.y,l.z,c.x,c.y,c.z)}if(i.lineTick){const a=(new p.Pq0).subVectors(r,t);a.lengthSq()>1e-10&&o.push(...i.lineTick(r,a.normalize(),i.tickSize))}return o}(r,t,e,i):function Sp(r,t,e,i){const s=[r.x,r.y,r.z,t.x,t.y,t.z,t.x,t.y,t.z,e.x,e.y,e.z];if(i.lineTick){const n=(new p.Pq0).subVectors(r,t);n.lengthSq()>1e-10&&s.push(...i.lineTick(r,n.normalize(),i.tickSize))}return s}(r,t,e,i)}function Nl(r,t){return Fr(r.arrowTip,r.elbow,r.extensionEnd,t)}function Bl(r,t,e,i,s){return i?Fr(t,"placingElbow"===r?i:e,i,s):[]}class Ap extends Bi{constructor(t){super(t),y(this,"enabled",!0),y(this,"machineState",{kind:"awaitingArrowTip"}),y(this,"onMachineStateChanged",new Q),y(this,"_previewMeshMaterial",new p.V9B({color:16737894,side:p.$EB,depthTest:!1})),y(this,"_previewMeshObject",null),this.styles.set("default",{tickSize:.4,color:0,textOffset:.1,fontSize:.45,lineTick:Pl})}pickHandle(t,e,i=.1){const s=(new p.kn4).copy(t.three.matrixWorld).invert(),n=e.origin.clone().applyMatrix4(s),o=e.direction.clone().transformDirection(s).normalize(),a=new p.RlV(n,o),l=new p.Zcv(new p.Pq0(0,1,0),0),c=a.intersectPlane(l,new p.Pq0);if(!c)return null;let h=null,u=i;for(const[f,d]of t.annotations.getBySystem(this))for(const[_,m]of[["elbow",d.elbow],["extensionEnd",d.extensionEnd]]){const w=Math.hypot(c.x-m.x,c.z-m.z);w<u&&(u=w,h={uuid:f,handle:_})}return h}sendMachineEvent(t){const e=t.drawing??null;e&&(this._previewDrawing=e);const i=function Tp(r,t){switch(r.kind){case"awaitingArrowTip":return"CLICK"===t.type?{kind:"placingElbow",arrowTip:t.point.clone(),cursor:null}:r;case"placingElbow":return"MOUSE_MOVE"===t.type?{...r,cursor:t.point.clone()}:"CLICK"===t.type?{kind:"placingExtension",arrowTip:r.arrowTip,elbow:t.point.clone(),cursor:null}:"ESCAPE"===t.type?{kind:"awaitingArrowTip"}:r;case"placingExtension":return"MOUSE_MOVE"===t.type?{...r,cursor:Ll(r.elbow,t.point)}:"CLICK"===t.type?{kind:"enteringText",arrowTip:r.arrowTip,elbow:r.elbow,extensionEnd:Ll(r.elbow,t.point)}:"ESCAPE"===t.type?{kind:"awaitingArrowTip"}:r;case"enteringText":return"SUBMIT_TEXT"===t.type&&t.text.trim().length>0?{kind:"committed",annotation:{uuid:p.cj9.generateUUID(),arrowTip:r.arrowTip.clone(),elbow:r.elbow.clone(),extensionEnd:r.extensionEnd.clone(),text:t.text.trim(),style:""}}:"ESCAPE"===t.type?{kind:"awaitingArrowTip"}:r;case"committed":return"ESCAPE"===t.type?{kind:"awaitingArrowTip"}:r}}(this.machineState,t);if(i!==this.machineState){if(this.machineState=i,this._updatePreview(),"committed"===i.kind){if(!this._previewDrawing)return console.warn("LeaderAnnotations: commit requires a drawing. Skipping."),void this._resetMachine();i.annotation.style=this.activeStyle;const s=this._persist(this._previewDrawing,i.annotation);this.onCommit.trigger([s])}this.onMachineStateChanged.trigger(this.machineState),"committed"===i.kind&&this._resetMachine()}}_buildGroup(t,e){const i=new p.YJl,s=Nl(t,e),n=new p.LoY;n.setAttribute("position",new p.THS(new Float32Array(s),3));const o=new p.DXC(n,this._getMaterial(t.style));if(o.layers.set(1),o.userData.isDimension=!0,i.add(o),e.meshTick){const a=(new p.Pq0).subVectors(t.arrowTip,t.elbow);if(a.lengthSq()>1e-10){a.normalize();const l=e.meshTick(t.arrowTip,a,e.tickSize),c=new p.LoY;c.setAttribute("position",new p.THS(new Float32Array(l),3));const h=new p.eaF(c,this._getMeshMaterial(t.style));h.layers.set(1),h.userData.isMeshArrow=!0,i.add(h)}}return i}_updatePreview(){const t=this.machineState;if("placingElbow"!==t.kind&&"placingExtension"!==t.kind)return void this._clearPreview();if(!this._previewDrawing)return void this._clearPreview();const e=this._resolveStyle(this.activeStyle),i="placingElbow"===t.kind?Bl("placingElbow",t.arrowTip,null,t.cursor,e):Bl("placingExtension",t.arrowTip,t.elbow,t.cursor,e);if(0!==i.length){if(this._previewObject&&this._previewObject.geometry.attributes.position.count===i.length/3){const o=this._previewObject.geometry.attributes.position;o.set(i),o.needsUpdate=!0}else{this._clearPreview();const o=new p.LoY;o.setAttribute("position",new p.THS(new Float32Array(i),3)),this._previewObject=new p.DXC(o,this._previewMaterial),this._previewObject.layers.set(1),this._previewObject.renderOrder=1,this._previewObject.frustumCulled=!1,this._previewObject.userData.isDimension=!0,this._previewDrawing.three.add(this._previewObject)}if(e.meshTick){const o="placingElbow"===t.kind?t.cursor:t.elbow,a=o?(new p.Pq0).subVectors(t.arrowTip,o):null;if(a&&a.lengthSq()>1e-10){a.normalize();const l=e.meshTick(t.arrowTip,a,e.tickSize);if(this._previewMeshObject){const c=this._previewMeshObject.geometry.attributes.position;c.set(l),c.needsUpdate=!0}else{const c=new p.LoY;c.setAttribute("position",new p.THS(new Float32Array(l),3)),this._previewMeshObject=new p.eaF(c,this._previewMeshMaterial),this._previewMeshObject.layers.set(1),this._previewMeshObject.renderOrder=1,this._previewMeshObject.frustumCulled=!1,this._previewDrawing.three.add(this._previewMeshObject)}}else this._clearPreviewMesh()}else this._clearPreviewMesh()}else this._clearPreview()}_clearPreview(){super._clearPreview(),this._clearPreviewMesh()}_onDispose(){this._clearPreviewMesh(),this._previewMeshMaterial.dispose()}_resetMachine(){this.machineState={kind:"awaitingArrowTip"},this._previewDrawing=null,this._updatePreview(),this.onMachineStateChanged.trigger(this.machineState)}_clearPreviewMesh(){this._previewMeshObject&&(this._previewMeshObject.removeFromParent(),this._previewMeshObject.geometry.dispose(),this._previewMeshObject=null)}}class Rl extends Bi{constructor(t){super(t),y(this,"enabled",!0),y(this,"_ownsChildGeometry",!1),y(this,"definitions",new ot.jp),this.styles.set("default",{color:0,textOffset:0,fontSize:0})}pickHandle(t,e,i){return null}pick(t,e=.05){const i=new p.tBo;i.ray.copy(t),i.params.Line={threshold:e},i.params.LineSegments={threshold:e};let s=null,n=1/0;for(const o of this._knownDrawings)for(const[a,l]of o.annotations){if(l.system!==this)continue;const c=l.three;c.updateWorldMatrix(!0,!0),c.traverse(h=>{if(h===c||!(h instanceof p.DXC))return;const u=[];h.raycast(i,u),u.length>0&&u[0].distance<n&&(n=u[0].distance,s=a)})}return s}define(t,e){this.definitions.set(t,e)}_buildGroup(t,e){const i=this.definitions.get(t.blockName);if(!i)throw new Error(`BlockAnnotations: block "${t.blockName}" is not defined.`);const s=new p.YJl;if(i.lines){const n=new p.DXC(i.lines,this._getMaterial(t.style));n.layers.set(1),n.userData.isDimension=!0,s.add(n)}if(i.mesh){const n=new p.eaF(i.mesh,this._getMeshMaterial(t.style));n.layers.set(1),n.userData.isBlockMesh=!0,s.add(n)}return s}_onAfterPersist(t,e){e.position.set(t.position.x,0,t.position.z),e.rotation.set(0,t.rotation,0),e.scale.setScalar(t.scale)}_onDispose(){var t,e;for(const i of this.definitions.values())null==(t=i.lines)||t.dispose(),null==(e=i.mesh)||e.dispose();this.definitions.clear()}}function Fl(r,t){const{position:e,direction:i}=r,{length:s}=t,n=new p.Pq0(e.x+i.x*s,0,e.z+i.z*s),o=new p.Pq0(i.x,0,i.z),a=t.lineTick(n,o,t.tickSize);return new Float32Array([e.x,0,e.z,n.x,0,n.z,...a])}function Vl(r,t){return new p.Pq0(r.position.x+r.direction.x*t,0,r.position.z+r.direction.z*t)}function Mp(r,t){switch(t){case"percentage":return`${(100*r).toFixed(2)} %`;case"ratio":return 0===r?"1:\u221e":`1:${(1/r).toFixed(2)}`;case"degrees":return`${(180*Math.atan(r)/Math.PI).toFixed(2)}\xb0`}}class Ip extends Bi{constructor(t){super(t),y(this,"enabled",!0),this.styles.set("default",{lineTick:ep,meshTick:ip,tickSize:.4,length:3,color:0,textOffset:.1,fontSize:.45,format:"percentage"})}pickHandle(t,e,i){return null}_buildGroup(t,e){const i=new p.YJl,s=Fl(t,e),n=new p.LoY;n.setAttribute("position",new p.THS(s,3));const o=new p.DXC(n,this._getMaterial(t.style));if(o.layers.set(1),o.userData.isDimension=!0,i.add(o),e.meshTick){const a=Vl(t,e.length),l=e.meshTick(a,t.direction,e.tickSize),c=new p.LoY;c.setAttribute("position",new p.THS(new Float32Array(l),3));const h=new p.eaF(c,this._getMeshMaterial(t.style));h.layers.set(1),h.userData.isDimension=!0,i.add(h)}return i}}function Ul(r,t){const e=t.x-r.x,i=t.z-r.z,s=Math.sqrt(e*e+i*i);if(0===s)return r.clone();const n=Math.atan2(i,e),o=Math.round(n/(Math.PI/4))*(Math.PI/4);return new p.Pq0(r.x+Math.cos(o)*s,0,r.z+Math.sin(o)*s)}function $l(r,t){const e=[];e.push(...t.enclosure.buildGeometry(r.center,r.halfW,r.halfH));const i=(new p.Pq0).subVectors(r.elbow,r.center),s=i.lengthSq()>1e-10?i.clone().normalize():new p.Pq0(1,0,0),n=t.enclosure.getAttachmentPoint(r.center,r.halfW,r.halfH,s);if(e.push(n.x,n.y,n.z,r.elbow.x,r.elbow.y,r.elbow.z,r.elbow.x,r.elbow.y,r.elbow.z,r.extensionEnd.x,r.extensionEnd.y,r.extensionEnd.z),t.lineTick){const o=(new p.Pq0).subVectors(r.extensionEnd,r.elbow);o.lengthSq()>1e-10&&e.push(...t.lineTick(r.extensionEnd,o.normalize(),t.tickSize))}return e}function Vr(r,t,e,i,s,n,o){const a="awaitingRadius"===r?n?Math.max(.05,Math.abs(n.x-t.x)):0:e,l="awaitingRadius"===r?n?Math.max(.05,Math.abs(n.z-t.z)):0:i;if(a<1e-10||l<1e-10)return[];const c=[];if(c.push(...o.enclosure.buildGeometry(t,a,l)),"awaitingRadius"===r)return c;const h="awaitingElbow"===r?n:s;if(!h)return c;const u=(new p.Pq0).subVectors(h,t),f=u.lengthSq()>1e-10?u.clone().normalize():new p.Pq0(1,0,0),d=o.enclosure.getAttachmentPoint(t,a,l,f);return"awaitingElbow"===r?(c.push(d.x,0,d.z,h.x,0,h.z),c):(n&&c.push(d.x,0,d.z,s.x,0,s.z,s.x,0,s.z,n.x,0,n.z),c)}const zp={buildGeometry(r,t,e){const i=.25*Math.min(t,e),s=new p.Pq0(r.x-t,0,r.z-e),n=new p.Pq0(r.x+t,0,r.z-e),o=new p.Pq0(r.x+t,0,r.z+e),a=new p.Pq0(r.x-t,0,r.z+e),l=[[s,n,new p.Pq0(0,0,-1)],[n,o,new p.Pq0(1,0,0)],[o,a,new p.Pq0(0,0,1)],[a,s,new p.Pq0(-1,0,0)]],c=[];for(const[h,u,f]of l){const d=h.distanceTo(u),_=Math.max(1,Math.round(d/(2*i))),m=d/_,w=m/2,g=(new p.Pq0).subVectors(u,h).normalize();for(let v=0;v<_;v++){const T=h.clone().addScaledVector(g,(v+.5)*m),C=h.clone().addScaledVector(g,v*m),S=(new p.Pq0).subVectors(C,T);let M=C.clone();for(let A=1;A<=8;A++){const O=A/8*Math.PI,I=T.x+S.x*Math.cos(O)+f.x*w*Math.sin(O),D=T.z+S.z*Math.cos(O)+f.z*w*Math.sin(O),B=new p.Pq0(I,0,D);c.push(M.x,0,M.z,B.x,0,B.z),M=B}}}return c},getAttachmentPoint(r,t,e,i){const s=Math.abs(i.x)>1e-10?t/Math.abs(i.x):1/0,n=Math.abs(i.z)>1e-10?e/Math.abs(i.z):1/0,o=Math.min(s,n);return new p.Pq0(r.x+i.x*o,0,r.z+i.z*o)}};class Dp extends Bi{constructor(t){super(t),y(this,"enabled",!0),y(this,"machineState",{kind:"awaitingCenter"}),y(this,"onMachineStateChanged",new Q),this.styles.set("default",{enclosure:zp,lineTick:Pl,tickSize:.4,color:22015,textOffset:.1,fontSize:.45})}pickHandle(t,e,i){return null}sendMachineEvent(t){const e=t.drawing??null;e&&(this._previewDrawing=e);const i=function Op(r,t){switch(r.kind){case"awaitingCenter":return"CLICK"===t.type?{kind:"awaitingRadius",center:t.point.clone(),cursor:null}:r;case"awaitingRadius":if("MOUSE_MOVE"===t.type)return{...r,cursor:t.point.clone()};if("CLICK"===t.type){const e=Math.max(.1,Math.abs(t.point.x-r.center.x)),i=Math.max(.1,Math.abs(t.point.z-r.center.z));return{kind:"awaitingElbow",center:r.center,halfW:e,halfH:i,cursor:null}}return"ESCAPE"===t.type?{kind:"awaitingCenter"}:r;case"awaitingElbow":return"MOUSE_MOVE"===t.type?{...r,cursor:t.point.clone()}:"CLICK"===t.type?{kind:"awaitingExtension",center:r.center,halfW:r.halfW,halfH:r.halfH,elbow:t.point.clone(),cursor:null}:"ESCAPE"===t.type?{kind:"awaitingCenter"}:r;case"awaitingExtension":return"MOUSE_MOVE"===t.type?{...r,cursor:Ul(r.elbow,t.point)}:"CLICK"===t.type?{kind:"enteringText",center:r.center,halfW:r.halfW,halfH:r.halfH,elbow:r.elbow,extensionEnd:Ul(r.elbow,t.point)}:"ESCAPE"===t.type?{kind:"awaitingCenter"}:r;case"enteringText":return"SUBMIT_TEXT"===t.type&&t.text.trim().length>0?{kind:"committed",annotation:{uuid:p.cj9.generateUUID(),center:r.center.clone(),halfW:r.halfW,halfH:r.halfH,elbow:r.elbow.clone(),extensionEnd:r.extensionEnd.clone(),text:t.text.trim(),style:""}}:"ESCAPE"===t.type?{kind:"awaitingCenter"}:r;case"committed":return"ESCAPE"===t.type?{kind:"awaitingCenter"}:r}}(this.machineState,t);if(i!==this.machineState){if(this.machineState=i,this._updatePreview(),"committed"===i.kind){if(!this._previewDrawing)return console.warn("CalloutAnnotations: commit requires a drawing. Pass `drawing` on the first CLICK."),void this._resetMachine();i.annotation.style=this.activeStyle;const s=this._persist(this._previewDrawing,i.annotation);this.onCommit.trigger([s])}this.onMachineStateChanged.trigger(this.machineState),"committed"===i.kind&&this._resetMachine()}}_buildGroup(t,e){const i=new p.YJl,s=$l(t,e),n=new p.LoY;n.setAttribute("position",new p.THS(new Float32Array(s),3));const o=new p.DXC(n,this._getMaterial(t.style));if(o.layers.set(1),o.userData.isDimension=!0,i.add(o),e.meshTick){const a=(new p.Pq0).subVectors(t.extensionEnd,t.elbow);if(a.lengthSq()>1e-10){a.normalize();const l=e.meshTick(t.extensionEnd,a,e.tickSize),c=new p.LoY;c.setAttribute("position",new p.THS(new Float32Array(l),3));const h=new p.eaF(c,this._getMeshMaterial(t.style));h.layers.set(1),h.userData.isMeshArrow=!0,i.add(h)}}return i}_updatePreview(){const t=this.machineState;if("awaitingRadius"!==t.kind&&"awaitingElbow"!==t.kind&&"awaitingExtension"!==t.kind)return void this._clearPreview();if(!this._previewDrawing)return;const e=this._resolveStyle(this.activeStyle),i=(()=>{switch(t.kind){case"awaitingRadius":return Vr("awaitingRadius",t.center,0,0,null,t.cursor,e);case"awaitingElbow":return Vr("awaitingElbow",t.center,t.halfW,t.halfH,null,t.cursor,e);case"awaitingExtension":return Vr("awaitingExtension",t.center,t.halfW,t.halfH,t.elbow,t.cursor,e)}})();if(0!==i.length)if(this._previewObject&&this._previewObject.geometry.attributes.position.count===i.length/3){const o=this._previewObject.geometry.attributes.position;o.set(i),o.needsUpdate=!0}else{this._clearPreview();const o=new p.LoY;o.setAttribute("position",new p.THS(new Float32Array(i),3)),this._previewObject=new p.DXC(o,this._previewMaterial),this._previewObject.layers.set(1),this._previewObject.renderOrder=1,this._previewObject.frustumCulled=!1,this._previewObject.userData.isDimension=!0,this._previewDrawing.three.add(this._previewObject)}else this._clearPreview()}_resetMachine(){this.machineState={kind:"awaitingCenter"},this._clearPreview(),this._previewDrawing=null,this.onMachineStateChanged.trigger(this.machineState)}}const Hl=class Kc extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"list",new ot.jp),y(this,"systems",new ot.jp),y(this,"onDisposed",new Q),t.add(Kc.uuid,this),this.list.onBeforeDelete.add(({value:e})=>e.dispose()),this.systems.onBeforeDelete.add(({value:e})=>e.dispose())}use(t){if(this.systems.has(t))return this.systems.get(t);const e=new t(this.components);return this.systems.set(t,e),e}create(t){const e=new Br(this.components);e.world=t,t.scene.three.add(e.three),t.onDisposed.add(()=>this.list.delete(e.uuid));const i=t.camera;return i.three.layers.enable(1),i instanceof ln&&(i.threePersp.layers.enable(1),i.threeOrtho.layers.enable(1)),this.list.set(e.uuid,e),e}dispose(){this.list.clear(),this.systems.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}};y(Hl,"uuid","5c7d3b9a-4e8f-4a2b-9c1d-0e3f2a5b7c8d");let Re=Hl;const kp=[[16711680,1],[16776960,2],[65280,3],[65535,4],[255,5],[16711935,6],[16777215,7],[0,7]];function Fe(r){const t=r>>16&255,e=r>>8&255,i=255&r;let s=7,n=1/0;for(const[o,a]of kp){const l=(t-(o>>16&255))**2+(e-(o>>8&255))**2+(i-(255&o))**2;l<n&&(n=l,s=a)}return s}const ql="\0HANDSEED\0";class Lp{constructor(){y(this,"_lines",[]),y(this,"_handleCounter",1)}p(t,e){return this._lines.push(String(t),String(e)),this}n(t,e,i=6){return this._lines.push(String(t),e.toFixed(i)),this}handle(){return(this._handleCounter++).toString(16).toUpperCase()}entityHeader(t,e,i){return this._lines.push("0",t,"5",this.handle(),"100","AcDbEntity","8",e,"62",String(i)),this}symbolTable(t,e){return this._lines.push("0","TABLE","2",t,"5",this.handle(),"100","AcDbSymbolTable","70",String(e)),this}symbolRecord(t,e){return this._lines.push("0",t,"5",this.handle(),"100","AcDbSymbolTableRecord","100",e),this}writeHandSeed(){return this._lines.push("9","$HANDSEED","5",ql),this}build(){return(this._lines.join("\n")+"\n").replace(ql,this._handleCounter.toString(16).toUpperCase())}}class Np{constructor(t){y(this,"precision",2),y(this,"config",{trueColor:!1}),y(this,"_viewport",null),y(this,"_paperSlot",null),y(this,"_annotationLayers",new Map),y(this,"_systemExporters",new Map),this._components=t}registerSystemExporter(t,e){this._systemExporters.set(t,e)}export(t,e){const i=!!e,s=new Lp,n=new Map;for(const h of t)for(const u of h.drawing.layers.values())n.has(u.name)||n.set(u.name,u);const o=[...n.values()],l=this._components.get(Re).systems.get(Rl),c=l?[...l.definitions.keys()]:[];this._writeHeader(s,i),this._writeTables(s,o,c),this._writeBlocks(s,l??null),s.p(0,"SECTION").p(2,"ENTITIES"),i&&e&&this._writePaperBorders(s,e);for(const h of t){h.drawing.three.traverse(u=>{u.userData.isDimension&&u.userData.annotationUuid&&this._annotationLayers.set(u.userData.annotationUuid,u.userData.layer??"0")});for(const u of h.viewports){if(this._viewport=u.viewport??null,i&&u.viewport){const f=u.viewport;this._paperSlot={x:u.x??0,y:e.heightMm-2*e.margin-(u.y??0),mmPerUnit:1e3/f.drawingScale,vpLeft:f.left,vpTop:f.top}}else this._paperSlot=null;this._writeViewportBorder(s),this._writeRawLines(s,h.drawing),this._writeLinearAnnotations(s,h.drawing),this._writeAngleAnnotations(s,h.drawing),this._writeLeaderAnnotations(s,h.drawing),this._writeSlopeAnnotations(s,h.drawing),this._writeCalloutAnnotations(s,h.drawing),this._writeBlockInsertions(s,h.drawing),this._writeCustomSystems(s,h.drawing)}this._annotationLayers.clear()}return s.p(0,"ENDSEC"),this._writeObjects(s),s.p(0,"EOF"),this._viewport=null,this._paperSlot=null,s.build()}_writeHeader(t,e){t.p(0,"SECTION").p(2,"HEADER"),t.p(9,"$ACADVER").p(1,this.config.trueColor?"AC1018":"AC1015"),t.p(9,"$DWGCODEPAGE").p(3,"ANSI_1252"),t.p(9,"$INSUNITS").p(70,e?4:6),t.writeHandSeed(),t.p(0,"ENDSEC")}_writeTables(t,e,i){t.p(0,"SECTION").p(2,"TABLES"),t.symbolTable("VPORT",0).p(0,"ENDTAB"),t.symbolTable("LTYPE",1),t.symbolRecord("LTYPE","AcDbLinetypeTableRecord").p(2,"CONTINUOUS").p(70,0).p(3,"Solid line").p(72,65).p(73,0).n(40,0),t.p(0,"ENDTAB"),t.symbolTable("LAYER",e.length);for(const n of e){const o=Fe(n.material.color.getHex());t.symbolRecord("LAYER","AcDbLayerTableRecord").p(2,n.name).p(70,0).p(62,o).p(6,"CONTINUOUS")}t.p(0,"ENDTAB"),t.symbolTable("STYLE",1),t.symbolRecord("STYLE","AcDbTextStyleTableRecord").p(2,"STANDARD").p(70,0).n(40,0).n(41,1).n(50,0).p(71,0).n(42,.2).p(3,"txt").p(4,""),t.p(0,"ENDTAB"),t.symbolTable("VIEW",0).p(0,"ENDTAB"),t.symbolTable("UCS",0).p(0,"ENDTAB"),t.symbolTable("APPID",1),t.symbolRecord("APPID","AcDbRegAppTableRecord").p(2,"ACAD").p(70,0),t.p(0,"ENDTAB"),t.symbolTable("DIMSTYLE",0).p(0,"ENDTAB");const s=["*Model_Space","*Paper_Space",...i];t.symbolTable("BLOCK_RECORD",s.length);for(const n of s)t.symbolRecord("BLOCK_RECORD","AcDbBlockTableRecord").p(2,n);t.p(0,"ENDTAB"),t.p(0,"ENDSEC")}_writeBlocks(t,e){if(t.p(0,"SECTION").p(2,"BLOCKS"),this._writeBlock(t,"*Model_Space",null),this._writeBlock(t,"*Paper_Space",null),e)for(const[i,s]of e.definitions)this._writeBlock(t,i,s.lines??null);t.p(0,"ENDSEC")}_writeBlock(t,e,i){if(t.p(0,"BLOCK").p(5,t.handle()).p(100,"AcDbEntity").p(8,"0").p(100,"AcDbBlockBegin").p(2,e).p(70,0).n(10,0).n(20,0).n(30,0).p(3,e).p(1,""),i){const s=this._viewport,n=this._paperSlot;this._viewport=null,this._paperSlot=null,this._writeGeoAsLines(t,i,"0"),this._viewport=s,this._paperSlot=n}t.p(0,"ENDBLK").p(5,t.handle()).p(100,"AcDbEntity").p(8,"0").p(100,"AcDbBlockEnd")}_writeViewportBorder(t){if(!this._viewport)return;const e=this._viewport,i=this._tx(e.left),s=this._tx(e.right),n=this._ty(-e.bottom),o=this._ty(-e.top);this._writeRawLine(t,i,n,s,n,"0",7),this._writeRawLine(t,s,n,s,o,"0",7),this._writeRawLine(t,s,o,i,o,"0",7),this._writeRawLine(t,i,o,i,n,"0",7)}_writePaperBorders(t,e){const{margin:i,widthMm:s,heightMm:n}=e,o=s-2*i,a=n-2*i;this._writeRawLine(t,0,0,o,0,"0",7),this._writeRawLine(t,o,0,o,a,"0",7),this._writeRawLine(t,o,a,0,a,"0",7),this._writeRawLine(t,0,a,0,0,"0",7),this._writeRawLine(t,-i,-i,o+i,-i,"0",7),this._writeRawLine(t,o+i,-i,o+i,a+i,"0",7),this._writeRawLine(t,o+i,a+i,-i,a+i,"0",7),this._writeRawLine(t,-i,a+i,-i,-i,"0",7)}_writeObjects(t){t.p(0,"SECTION").p(2,"OBJECTS"),t.p(0,"DICTIONARY").p(5,t.handle()).p(330,0).p(100,"AcDbDictionary").p(281,1),t.p(0,"ENDSEC")}_writeRawLines(t,e){e.three.traverse(i=>{var s;if(!(i instanceof p.DXC)||i.userData.isDimension||null!=(s=i.parent)&&s.userData.blockUuid||!i.visible)return;const n=i.userData.layer??"0",o=i.material.color.getHex();this._writeGeoAsLines(t,i.geometry,n,Fe(o),o)})}_writeLinearAnnotations(t,e){var i;const s=this._components.get(Re).systems.get(mp);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=Fe(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=Rr(n,o);if(!this._fullyInViewport(this._bboxFromPositions(c)))continue;if(this._writePairsAsLines(t,c,l,a,o.color),o.meshTick)for(const{tip:v,dir:T}of Al(n))this._writeMeshTriangles(t,o.meshTick(v,T,o.tickSize),l,a,o.color);const h=(new p.Pq0).subVectors(n.pointB,n.pointA),u=new p.Pq0(-h.z,0,h.x).normalize(),f=n.offset>=0?1:-1,d=n.pointA.clone().addScaledVector(u,n.offset),_=n.pointB.clone().addScaledVector(u,n.offset),m=d.clone().add(_).multiplyScalar(.5).addScaledVector(u,(o.textOffset+.5*o.fontSize)*f),w=o.unit??{factor:1,suffix:"m"},g=`${(n.pointA.distanceTo(n.pointB)*w.factor).toFixed(this.precision)} ${w.suffix}`;this._writeText(t,g,m.x,m.z,o.fontSize,l,a,this._textAngle(h.x,h.z),1,2,o.color)}}_writeAngleAnnotations(t,e){var i;const s=this._components.get(Re).systems.get(xp);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=Fe(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=Dl(n,o);if(!this._fullyInViewport(this._bboxFromPositions(c)))continue;if(this._writePairsAsLines(t,c,l,a,o.color),o.meshTick)for(const{tip:m,dir:w}of Ol(n))this._writeMeshTriangles(t,o.meshTick(m,w,o.tickSize),l,a,o.color);const h=bp(n),u=n.arcRadius+o.textOffset,f=n.vertex.x+Math.cos(h)*u,d=n.vertex.z+Math.sin(h)*u,_=p.cj9.radToDeg(vp(n));this._writeText(t,`${_.toFixed(this.precision)}\xb0`,f,d,o.fontSize,l,a,0,1,0,o.color)}}_writeLeaderAnnotations(t,e){var i;const s=this._components.get(Re).systems.get(Ap);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=Fe(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=Nl(n,o);if(!this._fullyInViewport(this._bboxFromPositions(c)))continue;if(this._writePairsAsLines(t,c,l,a,o.color),o.meshTick){const _=(new p.Pq0).subVectors(n.arrowTip,n.elbow);_.lengthSq()>1e-10&&this._writeMeshTriangles(t,o.meshTick(n.arrowTip,_.normalize(),o.tickSize),l,a,o.color)}const h=(new p.Pq0).subVectors(n.extensionEnd,n.elbow).setY(0).normalize(),u=h.x<-.1?2:h.x>.1?0:1,f=1===u?.5*o.fontSize:0,d=n.extensionEnd.clone().addScaledVector(h,o.textOffset+f);this._writeText(t,n.text,d.x,d.z,o.fontSize,l,a,0,u,2,o.color)}}_writeSlopeAnnotations(t,e){var i;const s=this._components.get(Re).systems.get(Ip);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=Fe(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=Fl(n,o);if(!this._fullyInViewport(this._bboxFromPositions(c)))continue;if(this._writePairsAsLines(t,c,l,a,o.color),o.meshTick){const f=Vl(n,o.length);this._writeMeshTriangles(t,o.meshTick(f,n.direction,o.tickSize),l,a,o.color)}const h=new p.Pq0(n.position.x+n.direction.x*o.length,0,n.position.z+n.direction.z*o.length),u=n.position.clone().add(h).multiplyScalar(.5).addScaledVector(new p.Pq0(-n.direction.z,0,n.direction.x),o.textOffset+o.fontSize);this._writeText(t,Mp(n.slope,o.format),u.x,u.z,o.fontSize,l,a,this._textAngle(n.direction.x,n.direction.z),1,0,o.color)}}_writeCalloutAnnotations(t,e){var i;const s=this._components.get(Re).systems.get(Dp);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=Fe(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=$l(n,o);if(!this._fullyInViewport(this._bboxFromPositions(c)))continue;if(this._writePairsAsLines(t,c,l,a,o.color),o.meshTick){const _=(new p.Pq0).subVectors(n.extensionEnd,n.elbow);_.lengthSq()>1e-10&&this._writeMeshTriangles(t,o.meshTick(n.extensionEnd,_.normalize(),o.tickSize),l,a,o.color)}const h=(new p.Pq0).subVectors(n.extensionEnd,n.elbow).setY(0).normalize(),u=h.x<-.1?2:h.x>.1?0:1,f=1===u?.5*o.fontSize:0,d=n.extensionEnd.clone().addScaledVector(h,o.textOffset+f);this._writeText(t,n.text,d.x,d.z,o.fontSize,l,a,0,u,2,o.color)}}_writeBlockInsertions(t,e){const i=this._components.get(Re).systems.get(Rl);if(i)for(const[,s]of e.annotations.getBySystem(i)){if(!this._inViewport(s.position.x,s.position.z))continue;const n=i.styles.get(s.style)??i.styles.get("default"),o=Fe(n.color),a=-p.cj9.radToDeg(s.rotation),l=s.scale*this._scale();t.entityHeader("INSERT","0",o),this._emitTrueColor(t,n.color),t.p(100,"AcDbBlockReference").p(2,s.blockName).n(10,this._tx(s.position.x)).n(20,this._ty(s.position.z)).n(30,0).n(41,l).n(42,l).n(43,l).n(50,a)}}_writeGeoAsLines(t,e,i,s=7,n){const o=e.attributes.position;if(o)for(let a=0;a+1<o.count;a+=2){const l=this._clipSegment(new p.Pq0(o.getX(a),0,o.getZ(a)),new p.Pq0(o.getX(a+1),0,o.getZ(a+1)));l&&this._writeLine(t,l.start.x,l.start.z,l.end.x,l.end.z,i,s,n)}}_writePairsAsLines(t,e,i,s=7,n){for(let o=0;o+5<e.length;o+=6){const a=this._clipSegment(new p.Pq0(e[o],0,e[o+2]),new p.Pq0(e[o+3],0,e[o+5]));a&&this._writeLine(t,a.start.x,a.start.z,a.end.x,a.end.z,i,s,n)}}_emitTrueColor(t,e){this.config.trueColor&&void 0!==e&&t.p(420,e)}_writeLine(t,e,i,s,n,o,a,l){t.entityHeader("LINE",o,a),this._emitTrueColor(t,l),t.p(100,"AcDbLine").n(10,this._tx(e)).n(20,this._ty(i)).n(30,0).n(11,this._tx(s)).n(21,this._ty(n)).n(31,0)}_writeRawLine(t,e,i,s,n,o,a){t.entityHeader("LINE",o,a).p(100,"AcDbLine").n(10,e).n(20,i).n(30,0).n(11,s).n(21,n).n(31,0)}_writeSolid(t,e,i,s,n,o,a,l,c,h){t.entityHeader("SOLID",l,c),this._emitTrueColor(t,h),t.p(100,"AcDbTrace").n(10,this._tx(e)).n(20,this._ty(i)).n(30,0).n(11,this._tx(s)).n(21,this._ty(n)).n(31,0).n(12,this._tx(o)).n(22,this._ty(a)).n(32,0).n(13,this._tx(o)).n(23,this._ty(a)).n(33,0)}_writeMeshTriangles(t,e,i,s,n){for(let o=0;o+8<e.length;o+=9)this._writeSolid(t,e[o],e[o+2],e[o+3],e[o+5],e[o+6],e[o+8],i,s,n)}_writeText(t,e,i,s,n,o,a,l=0,c=0,h=0,u){const f=this._tx(i),d=this._ty(s);t.entityHeader("TEXT",o,a),this._emitTrueColor(t,u),t.p(100,"AcDbText").n(10,f).n(20,d).n(30,0).n(40,n*this._scale()).n(50,l).p(1,e),(0!==c||0!==h)&&(0!==c&&t.p(72,c),0!==h&&t.p(73,h),t.n(11,f).n(21,d).n(31,0))}_tx(t){return this._paperSlot?this._paperSlot.x+(t-this._paperSlot.vpLeft)*this._paperSlot.mmPerUnit:this._viewport?t-this._viewport.left:t}_ty(t){return this._paperSlot?this._paperSlot.y-(t+this._paperSlot.vpTop)*this._paperSlot.mmPerUnit:this._viewport?-t-this._viewport.bottom:-t}_scale(){return this._paperSlot?this._paperSlot.mmPerUnit:1}_clipSegment(t,e){return this._viewport?this._viewport.clipLine(new p.cZY(t,e)):new p.cZY(t,e)}_inViewport(t,e){return!this._viewport||this._viewport.bbox.containsPoint(new p.Pq0(t,0,e))}_bboxFromPositions(t){const e=new p.NRn;for(let i=0;i+2<t.length;i+=3)e.expandByPoint(new p.Pq0(t[i],0,t[i+2]));return e}_fullyInViewport(t){return!this._viewport||this._viewport.bbox.containsBox(t)}_textAngle(t,e){let i=Math.atan2(-e,t);return(i>Math.PI/2||i<=-Math.PI/2)&&(i+=Math.PI),p.cj9.radToDeg(i)}_writeCustomSystems(t,e){if(0===this._systemExporters.size)return;const i=this._makeContext(t);for(const[s,n]of this._systemExporters){const o=this._components.get(Re).systems.get(s);o&&n(o,i)}}_makeContext(t){return{writeLine:(e,i,s,n,o="0",a=7)=>{this._writeLine(t,e,i,s,n,o,a)},writePairs:(e,i="0",s=7)=>{this._writePairsAsLines(t,e,i,s)},writeMeshTriangles:(e,i="0",s=7)=>{this._writeMeshTriangles(t,e,i,s)},writeText:(e,i,s,n,o={})=>{this._writeText(t,e,i,s,n,o.layer??"0",o.aciColor??7,o.rotDeg??0,o.hAlign??0)},hexToAci:Fe,textAngle:(e,i)=>this._textAngle(e,i)}}}y(class Qc extends At{constructor(t){super(t),y(this,"enabled",!0),y(this,"exporter",new Np(this.components)),t.add(Qc.uuid,this)}},"uuid","e9a2c3d4-5f67-4b89-a012-1c3d5e7f9b2a");let Gl=(()=>{class r extends At{static uuid="ab45d0a7-feea-4afc-927c-80832dae76dd";enabled=!0;_fragments=null;set fragments(e){this._fragments=e}geometries=new ot.jp;get(e,i){var s=this;return(0,G.A)(function*(){const{material:n,coordinate:o,applyTransformation:a}={coordinate:!0,applyTransformation:!0,...i},l=new ot.jp;for(const[c,h]of Object.entries(e)){const u=s._fragments.models.list.get(c);if(!u)continue;const f=s.getModelMeshes(c);for(const d of h){let _=l.get(c);_||(_=new ot.jp,l.set(c,_));let m=f.get(d);if(m&&m.length>0){const v=[];for(const[,{geometry:T}]of m.entries()){const C=yield s.createMesh(u,T,{material:n,applyTransformation:a,coordinate:o});v.push(C)}_.set(d,v);continue}m=[],f.set(d,m);const[w]=yield u.getItemsGeometry([d]);if(!w)continue;const g=[];for(const v of w){const T=s.createGeometry(v);if(!T)continue;const{geometry:C}=T;m.push(T);const S=yield s.createMesh(u,C,{material:n,applyTransformation:a,coordinate:o});g.push(S)}_.set(d,g)}}return l})()}getModelMeshes(e){let i=this.geometries.get(e);return i||(i=new ot.jp,this.geometries.set(e,i)),i}remove(e=[...this.geometries.keys()]){for(const i of e){const s=this.geometries.get(i);if(s){for(const[,n]of s)for(const{geometry:o}of n)o.dispose();this.geometries.delete(i)}}}onDisposed=new Q;dispose(e=!0){this.remove(),e&&this.geometries.dispose(),this.onDisposed.trigger(r.uuid)}getMeshesFromResult(e){const i=[];for(const s of e.values())for(const n of s.values())i.push(...n);return i}createGeometry(e){const{positions:i,indices:s,normals:n,transform:o}=e;if(!(i&&s&&n))return null;const a=new p.LoY;return a.setAttribute("position",new p.THS(i,3)),a.setAttribute("normal",new p.THS(n,3,!0)),a.setIndex(new p.THS(s,1)),a.applyMatrix4(o),{geometry:a,transform:o}}createMesh(e,i,s){var n=this;return(0,G.A)(function*(){const{material:o,applyTransformation:a,coordinate:l}={applyTransformation:!0,coordinate:!0,...s},c=n.components.get(ft),h=new p.eaF(i,o);if(h.applyMatrix4(e.object.matrixWorld),a||h.position.set(0,0,0),l&&c.baseCoordinationModel!==e.modelId){const u=yield e.getCoordinationMatrix();c.applyBaseCoordinateSystem(h,u)}return h})()}}return r})(),Ur=(()=>{class r extends At{static uuid="2695289f-e6c1-4980-919e-88b7591d7ea3";enabled=!0;originalColors=new Map;_ghostColor=new p.Q1f("white");_ghostedMaterials=[];set ghostColor(e){this._ghostColor=e}_ghostApplied=!1;get ghostApplied(){return this._ghostApplied}_world;set world(e){this._world=e,this._initEventListeners()}get ghostedMaterials(){return this._ghostedMaterials}_fragments;set fragments(e){this._fragments=e,this._initEventListeners()}onDisposed=new Q;constructor(e){super(e)}dispose(){this.onDisposed.trigger(r.uuid),this._ghostedMaterials=[]}setModelTransparent(e){const i=[...e.models.materials.list.values()];for(const s of i){if(s.userData.customId)continue;let n;n="color"in s?s.color.getHex():s.lodColor.getHex(),this.originalColors.set(s,{color:n,transparent:s.transparent,opacity:s.opacity}),s.transparent=!0,s.opacity=.05,s.needsUpdate=!0,"color"in s?s.color=this._ghostColor:s.lodColor=this._ghostColor,this._ghostedMaterials.push(s)}this._ghostApplied=!0}restoreModelMaterials(){for(const[e,i]of this.originalColors){const{color:s,transparent:n,opacity:o}=i;e.transparent=n,e.opacity=o,"color"in e?e.color.setHex(s):e.lodColor.setHex(s),e.needsUpdate=!0}this.originalColors.clear(),this._ghostedMaterials=[],this._ghostApplied=!1}toggleGhost(e){this.originalColors.size?this.restoreModelMaterials():this.setModelTransparent(e)}_initEventListeners(){void 0!==this._world&&void 0!==this._fragments&&(this._world.camera.controls.addEventListener("rest",()=>{this.enabled?this.setModelTransparent(this._fragments):this.restoreModelMaterials()}),this._fragments.models.list.onItemSet.add(({value:e})=>{console.log(`Model ${e.modelId} is ready`),setTimeout(()=>{this.enabled?(console.log("GHOST"),this.setModelTransparent(this._fragments)):this.restoreModelMaterials()},1500)}))}}return r})(),Yl=(()=>{class r extends At{static uuid="3abd8228-7bff-4ff6-ac30-53f97bdc8ae6";enabled=!0;_fragments;_isolated={};_hidden={};_colorOverrides={};_overrides={};onDisposed=new Q;constructor(e){super(e)}set fragments(e){this._fragments=e}_world;set world(e){this._world=e}get colorOverrides(){return this._colorOverrides}applyModelOverrides(e,i){var s=this;return(0,G.A)(function*(){s._overrides[e.modelId]=i,yield s._applyModelOverrides(e)})()}update(e){var i=this;return(0,G.A)(function*(){(void 0===e?i.fragments.models.list:[e]).forEach(n=>{i._appendOnModel(n)})})()}setNonColoredVisibility(e){var i=this;return(0,G.A)(function*(){if(void 0===i._fragments)return;const s=i._colorOverrides;console.log(s);for(const n of Object.keys(s)){const o=i._fragments.models.list.get(n);if(void 0===o)return;e?yield i._setVisibilityAll(o,!0):(yield i._setVisibilityAll(o,!1),o.setVisible([...s[n]],!0))}})()}dispose(){this.onDisposed.trigger(r.uuid)}_getLocalIdsByType(e,i){var s=this;return(0,G.A)(function*(){if(void 0===s._fragments)return null;const n=yield e.getItemsOfCategories(i);return new Set([...Object.values(n).flat()])})()}_applyModelOverrides(e){var i=this;return(0,G.A)(function*(){if(void 0!==i._fragments&&void 0!==i._overrides[e.modelId]){try{yield Promise.all([i._updateIsolatedMap(e),i._updateHiddenMap(e),i._updateColorOverrides(e)])}catch(n){console.log(n)}e&&i._appendOnModel(e)}})()}_appendOnModel(e){var i=this;return(0,G.A)(function*(){const s=i._overrides[e.modelId];if(void 0===s)return;const n=i._isolated[e.modelId],o=i._hidden[e.modelId];n?.size?(yield i._setVisibilityAll(e,!1),e?.setVisible([...n],!0)):o?.size&&e?.setVisible([...o],!1);for(const a of s.colorOverrides){const l={color:new p.Q1f(a.color),renderedFaces:ot.eB.TWO,opacity:a.opacity,transparent:!1,customId:`${e.modelId}_${a.color}`};yield e.highlight(a.ids,l)}})()}_updateIsolatedMap(e){var i=this;return(0,G.A)(function*(){const s=e.modelId,n=i._overrides[s];if(i._isolated[s]=new Set,n.isolatedTypes.length){const o=yield i._getLocalIdsByType(e,n.isolatedTypes);o&&o.forEach(a=>i._isolated[s].add(a))}n.isolated.length&&n.isolated.forEach(o=>i._isolated[s].add(o))})()}_updateHiddenMap(e){var i=this;return(0,G.A)(function*(){const s=e.modelId,n=i._overrides[s];if(i._hidden[s]=new Set,n.hiddenTypes.length){const o=yield i._getLocalIdsByType(e,n.hiddenTypes);o&&o.forEach(a=>i._hidden[s].add(a))}n.hidden.length&&n.hidden.forEach(o=>i._hidden[s].add(o))})()}_updateColorOverrides(e){var i=this;return(0,G.A)(function*(){const s=e.modelId;i._colorOverrides[e.modelId]=new Set,i._overrides[s].colorOverrides.forEach(o=>{o.ids.forEach(a=>i._colorOverrides[e.modelId].add(a))})})()}_setVisibilityAll=function(){var e=(0,G.A)(function*(i,s){const o=(yield i.getItemsWithGeometry()).map(l=>l.getLocalId()),a=(yield Promise.all(o)).filter(l=>null!==l);yield i.setVisible(a,s)});return function(i,s){return e.apply(this,arguments)}}()}return r})();const Zl=(r,t)=>{const e={...r};return Object.keys(t).forEach(i=>{e[i]=new Set([...e[i]||[],...t[i]])}),e},Wl=function(){var r=(0,G.A)(function*(t,e,i,s={}){const n=[];for(const[,l]of e.models.list){const c=yield l.raycast(i);if(c){const h={};h[l.modelId]=new Set,h[l.modelId].add(c.localId),n.push({...c,idMap:h})}}if(0===n.length)return Xl(e,s,!0),null;let o=n[0],a=o.distance;for(let l=1;l<n.length;l++)n[l].distance<a&&(a=n[l].distance,console.log(a),o=n[l]);return t.get(Ur).ghostApplied&&!((r,t)=>{if(null===t)return!1;let e=!1;return Object.keys(r).forEach(i=>{t[i].forEach(s=>{r[i].has(s)&&(e=!0)})}),e})(t.get(Yl).colorOverrides,o.idMap)?(Xl(e,s=Zl(s,o.idMap),!1),Wl(t,e,i,s)):o});return function(e,i,s){return r.apply(this,arguments)}}();function Xl(r,t,e){for(const i of Object.keys(t))r.models.list.get(i)?.setVisible([...t[i]],e)}class Vp{hoveredElement=new Q}let $r=(()=>{class r extends At{static uuid="26fbd870-b1b2-4b71-b747-4063d484de1b";HOVERER_OPACITY_KEY="_maxHoverOpacity";_hoverTimeout=null;_meshes=new ot.PG;_localId=null;_fadeAnimation=null;_world=null;_fragments=null;set world(e){if(e){this._world=e,this.setupEvents(!0);for(const i of this._meshes)e.scene.three.add(i)}else{this.setupEvents(!1),this._world=null;for(const i of this._meshes)i.removeFromParent()}}get world(){return this._world}events=new Vp;set fragments(e){this._fragments=e}_enabled=!1;set enabled(e){this.setupEvents(e),this._enabled=e}get enabled(){return this._enabled}_material=new p.V9B({color:16777215,transparent:!0,opacity:.5,depthTest:!1,userData:{[this.HOVERER_OPACITY_KEY]:.5}});set material(e){e.userData[this.HOVERER_OPACITY_KEY]=e.opacity;for(const i of this._meshes)i.material=e;this._material.dispose(),this._material=e}get material(){return this._material}onDisposed=new Q;duration=200;animation=!0;constructor(e){super(e),e.add(r.uuid,this),this._meshes.onBeforeDelete.add(i=>{i.removeFromParent(),i.geometry.dispose(),this._setCursor(!1)}),this._meshes.onItemAdded.add(i=>{this.world&&(this._setCursor(!0),this.world.scene.three.add(i))}),this._meshes.onCleared.add(()=>{this._localId=null,this._hoverTimeout&&(clearTimeout(this._hoverTimeout),this._hoverTimeout=null)})}setupEvents(e){if(!this.world||this.world.isDisposing)return;if(!this.world.renderer)throw new Error("The given world doesn't have a renderer!");const i=this.world.renderer.three.domElement;i.removeEventListener("mousemove",this.onMouseMove),i.removeEventListener("mouseleave",this.onMouseMove),e&&(i.addEventListener("mousemove",this.onMouseMove),i.addEventListener("mouseleave",this.onMouseLeave))}mouseStopTimeout=null;onMouseMove=e=>{null!==this.mouseStopTimeout&&clearTimeout(this.mouseStopTimeout),this.mouseStopTimeout=window.setTimeout(()=>this.hover(e),50)};onMouseLeave=()=>{this._meshes.clear()};animate=()=>{if(!(this._fadeAnimation&&this.animation&&this.material.transparent))return;const{startTime:e,duration:i,fadeIn:s}=this._fadeAnimation,n=Date.now()-e,o=Math.min(n/i,1),l=this.material.userData[this.HOVERER_OPACITY_KEY];this.material.opacity=(s?o:1-o)*(void 0!==l?l:1),o<1?requestAnimationFrame(this.animate):(s||this._meshes.clear(),this._fadeAnimation=null)};hover(e){var i=this;return(0,G.A)(function*(){if(!i.enabled||!i.world||!i._fragments)return;const s=new p.I9Y(e.clientX,e.clientY),n=yield Wl(i.components,i._fragments,{camera:i.world.camera.three,mouse:s,dom:i.world.renderer.three.domElement});if(!n)return i._meshes.clear(),void i.events.hoveredElement.trigger(null);if(i.components.get(Ur).ghostApplied&&!(yield n.fragments.getHighlightItemIds()).includes(n.localId))return console.log("Not a highlighted object!"),void i.events.hoveredElement.trigger(null);i.events.hoveredElement.trigger(n);const{fragments:o,localId:a}=n;i._localId!==a&&(i._meshes.clear(),i._localId=a,i._hoverTimeout=window.setTimeout((0,G.A)(function*(){const l={[o.modelId]:new Set([a])},c=i.components.get(Gl);c.fragments=i._fragments;const h=yield c.get(l);for(const[,u]of h.entries()){const f=[...u.values()].flat();for(const d of f)d.material=i.material,d.position.set(0,0,0),d.rotation.set(0,0,0),d.scale.set(1,1,1),d.applyMatrix4(o.object.matrixWorld),i._meshes.add(d)}i._fadeAnimation={startTime:Date.now(),duration:i.duration,fadeIn:!0},i.animate()}),100))})()}_setCursor(e){const i=this._world.renderer?.three.domElement;i&&(i.style.cursor=e?"pointer":"default")}clear(){this._meshes.clear()}dispose(){this._enabled=!1,this._meshes.clear(),this._fadeAnimation=null,this._hoverTimeout=null,this.onDisposed.trigger()}}return r})();var Up=mt(9595);const $p=function(){var r=(0,G.A)(function*(t,e){const i=Object.keys(e)[0];if(i&&t.models.list.get(i)){const s=t.models.list.get(i),[n]=yield s.getItemsData([...e[i]],{attributesDefault:!1,attributes:["Name","NominalValue"],relations:{IsDefinedBy:{attributes:!0,relations:!0},DefinesOcurrence:{attributes:!1,relations:!1}}});return n||null}return null});return function(e,i){return r.apply(this,arguments)}}();var jr=mt(7850);class jp{clickedElement=new Q;clickedCanvas=new Q;selection=new Q}let Kl=(()=>{class r extends At{static uuid="b7e0b697-172f-43db-b530-d775a2a34d55";HIGHLIGHT_ID="cue_selection";enabled=!0;multiSelect=!1;resetOnCanvasClick=!0;_fragments=null;set fragments(e){this._fragments=e}hoveredElement=null;selectedElements=null;set styles(e){const i=this.components.get(jr.TF);i.fillOpacity=e.fillOpacity,i.fillColor=e.fillColor,i.color=e.outlineColor}onDisposed=new Q;events=new jp;constructor(e){super(e),this._initEventListeners()}dispose(){this.hoveredElement=null,this.selectedElements=null,this.onDisposed.trigger(r.uuid)}_initEventListeners(){var e=this;this.components.get($r).events.hoveredElement.add(function(){var n=(0,G.A)(function*(o){if(!o)return void(e.hoveredElement=null);const a=o.localId,l=o.fragments.modelId;e.hoveredElement={[l]:new Set([a])}});return function(o){return n.apply(this,arguments)}}()),Up.B.getInstance().events.addListener("shortPressedLeft",(0,G.A)(function*(){if(!e.enabled)return;const n=e.components.get(jr.TF);n.clean();const o=e.hoveredElement;if(!o)return e.resetOnCanvasClick&&(e.selectedElements=null,e.events.selection.trigger(null),n.clean()),void e.events.clickedCanvas.trigger();const a=yield $p(e._fragments,o);a&&e.events.clickedElement.trigger(a);const l=Object.keys(o)[0],c=[...o[l]][0];let h=e.selectedElements?Object.assign({},e.selectedElements):null;h=e.multiSelect?h?e.resetOnCanvasClick&&h&&h[l]?.has(c)?((r,t)=>{const e={...r};return Object.keys(t).forEach(i=>{const s=t[i];e[i]&&(e[i]=new Set([...e[i]||[]].filter(n=>!s.has(n))),0===e[i].size&&delete e[i])}),0===Object.keys(e).length?null:e})(h,o):Zl(h,o):o:e.resetOnCanvasClick&&h&&h[l]?.has(c)?null:o,e.selectedElements=h,e.events.selection.trigger(h),h?n.addItems(h):n.clean()}))}}return r})(),Hp=(()=>{class r extends At{_world;_fragments;set world(e){this._world=e,e&&this.getRenderer().postproduction.excludedObjectsPass.addExcludedMaterial(this._points.material)}get world(){return this._world}set fragments(e){this._fragments=e}styles=new ot.PG;outlinePositions=!1;_mesh=null;get _points(){return this._mesh||(this._mesh=new p.ONl(new p.LoY,new p.BH$({size:10,sizeAttenuation:!1,depthTest:!1}))),this._mesh}get enabled(){return!(!this.world||this.world.isDisposing)&&this.getRenderer().postproduction.outlinesEnabled}set enabled(e){this.world&&!this.world.isDisposing&&(this.getRenderer().postproduction.outlinesEnabled=e,this.outlinePositions&&(this._points.material.color=this.color,this.world.scene.three.add(this._points)))}get color(){return this.getRenderer().postproduction.outlinePass.outlineColor}set color(e){this.getRenderer().postproduction.outlinePass.outlineColor.copy(e),this._points.material.color.copy(e)}get thickness(){return this.getRenderer().postproduction.outlinePass.thickness}set thickness(e){this.getRenderer().postproduction.outlinePass.thickness=e}get fillColor(){return this.getRenderer().postproduction.outlinePass.fillColor}set fillColor(e){this.getRenderer().postproduction.outlinePass.fillColor.copy(e)}get fillOpacity(){return this.getRenderer().postproduction.outlinePass.fillOpacity}set fillOpacity(e){this.getRenderer().postproduction.outlinePass.fillOpacity=e}onDisposed=new Q;static uuid="2fd3bcc5-b3b6-4ded-9f64-f47a02854a10";_meshes=[];_map={};_activeStyles=new Set;constructor(e){super(e),e.add(r.uuid,this)}update(){var e=this;return(0,G.A)(function*(i=e._map){if(i===e._map&&e.cleanMeshes(),e.outlinePositions&&e.updatePoints(),0===Object.keys(i).length)return;const n=e.getRenderer().postproduction.outlinePass,a=yield e.components.get(Gl).get(i);for(const l of Object.keys(i)){const c=e._fragments?.models.list.get(l);if(c)for(const[,h]of a.entries()){const u=[...h.values()].flat();for(const f of u)f.position.set(0,0,0),f.rotation.set(0,0,0),f.scale.set(1,1,1),f.applyMatrix4(c.object.matrixWorld),e._meshes.push(f),n.scene.add(f)}}}).apply(this,arguments)}addItems(e){var i=this;return(0,G.A)(function*(){Rt.add(i._map,e),yield i.update(e)})()}removeItems(e){var i=this;return(0,G.A)(function*(){Rt.remove(i._map,e),yield i.update()})()}clean(){this._map={},this._activeStyles.clear(),this.cleanMeshes(),this._mesh&&this.components.get(bi).destroy(this._mesh,!0,!0),this._mesh=null}dispose(){this.styles.clear(),this.clean(),this.onDisposed.trigger(r.uuid)}cleanMeshes(){for(const e of this._meshes)e.removeFromParent();this._meshes=[]}updatePoints(){var e=this;return(0,G.A)(function*(){let i=0;for(const[,o]of Object.entries(e._map))i+=o.size;e._points.geometry.setAttribute("position",new p.qtW(new Float32Array(3*i),3));const n=yield e.components.get(ft).getPositions(e._map);for(let o=0;o<n.length;o++){const{x:a,y:l,z:c}=n[o];e._points.geometry.attributes.position.array[3*o]=a,e._points.geometry.attributes.position.array[3*o+1]=l,e._points.geometry.attributes.position.array[3*o+2]=c}e._points.geometry.attributes.position.needsUpdate=!0})()}getRenderer(){if(!this.world)throw new Error("You must set a world to use the outliner!");const e=this.world.renderer;if(!e.postproduction)throw new Error("The world given to the outliner must use the postproduction renderer.");return e}}return r})();var Yp=mt(893);function Zp(r){return Hr.apply(this,arguments)}function Hr(){return(Hr=(0,G.A)(function*(r){console.warn("Set double sided is not implemented"),console.log(r)})).apply(this,arguments)}function qr(){return(qr=(0,G.A)(function*(r){try{const t=new URL(r,window.location.href);if(t.origin===window.location.origin)return r;const e=yield fetch(t.href);if(!e.ok)throw new Error(`HTTP ${e.status}`);const i=yield e.text(),s=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(s)}catch(t){return console.warn("[BIM] Could not fetch worker as blob, using direct URL:",t),r}})).apply(this,arguments)}const Xp=(r,t,e="./js/worker.mjs")=>{const i=new ot._i(e),s=r.get(Yl);return s.fragments=i,s.world=t,t.camera.controls.addEventListener("rest",()=>i.update(!0)),t.camera.controls.addEventListener("update",()=>i.update()),i.models.list.onItemSet.add(function(){var n=(0,G.A)(function*({value:o}){const a=o.object.userData.overrides;o.useCamera(t.camera.three),t.scene.three.add(o.object),ec(a)&&(o.object.visible=!1,yield Qp(1),yield s.applyModelOverrides(o,a),o.object.visible=!0),yield i.update(!0),o.object.visible=!0,ec(a)||(yield s.applyModelOverrides(o,a),yield i.update(!0)),yield i.update(!0)});return function(o){return n.apply(this,arguments)}}()),t.onCameraChanged.add(n=>{for(const[,o]of i.models.list)o.useCamera(n.three);i.update(!0)}),i},Kp=function(){var r=(0,G.A)(function*(t,e,i){void 0===i&&(i=tc(t));const s=e.map(a=>a.id),n=e.filter(a=>!i.includes(a.id)).filter(a=>!0===a.visible),o=i.filter(a=>!s.includes(a));return n.length&&(console.info(`Loading ${n.length} model(s)`),yield Ql(t,n)),o.length&&(console.info(`Disposing ${n.length} model(s)`),yield Jl(t,o)),[...t.models.list.values()]});return function(e,i,s){return r.apply(this,arguments)}}(),Ql=function(){var r=(0,G.A)(function*(t,e){const i=[];for(const s of e)try{console.info(`Loading ${s.name} (${s.id})...`);const o=yield(yield fetch(s.fileURL)).arrayBuffer();console.info("Got model buffer...");const a=yield t.load(o,{modelId:s.id,userData:{overrides:s.overrides}});console.info("Model loaded into fragments..."),s.makeAllMaterialsDoubleSided&&(yield Zp(a)),yield t.update(),i.push(a),s.visible=!0,console.info(`\u2705 ${s.name} (${s.id}) loaded`)}catch(n){console.error(`\u274c Error loading model ${s.name} (${s.id}): `,n)}return i});return function(e,i){return r.apply(this,arguments)}}(),Jl=function(){var r=(0,G.A)(function*(t,e){void 0===e&&(e=tc(t));const i=[];for(const s of e)i.push(t.disposeModel(s));yield Promise.all(i)});return function(e,i){return r.apply(this,arguments)}}(),tc=r=>[...r.models?.list.values()].map(i=>i.modelId),ec=r=>!(!r.isolated.length&&!r.isolatedTypes.length),Qp=function(){var r=(0,G.A)(function*(t){return new Promise(e=>setTimeout(()=>e(),t))});return function(e){return r.apply(this,arguments)}}(),Jp={"#e2f552":"accent","#2859e1":"primary","#1744c2":"secondary","#ffffff":"default","#8394b0":"fade"},tm={accent:new p.Q1f("#2859e1"),primary:new p.Q1f("#1744c2"),secondary:new p.Q1f("#2859e1"),default:new p.Q1f("#e2f552"),fade:new p.Q1f("#e2f552")},em={accent:new p.Q1f("#e2f552"),primary:new p.Q1f("#1744c2"),secondary:new p.Q1f("#1744c2"),default:new p.Q1f("#1744c2"),fade:new p.Q1f("#1744c2")},im={accent:new p.Q1f("#2859e1"),primary:new p.Q1f("#e2f552"),secondary:new p.Q1f("#e2f552"),default:new p.Q1f("#e2f552"),fade:new p.Q1f("#e2f552")},nm=r=>{const t=new p.Q1f(r),i=.299*t.r+.587*t.g+.114*t.b>.5?.75:1.25;return new p.Q1f(Math.min(t.r*i,1),Math.min(t.g*i,1),Math.min(t.b*i,1))};function rm(r){let t="";return t=r.LongName?.value?r.LongName.value:r.Name?.value?r.Name.value:r.type||"(no name)",`${t} [${r._category.value}]`}function ic(r,t,e){return Gr.apply(this,arguments)}function Gr(){return(Gr=(0,G.A)(function*(r,t,e){console.log(t);const i=yield r.getItemsData(t,{relations:{Decomposes:{attributes:!0,relations:!0}}});console.log(i),void 0===e.children&&(e.children=[]);for(const s of i){const n=[];for(const o of s.Decomposes||[]){const a=o._localId.value,l=yield r.getItemsData([a],{relations:{IsDecomposedBy:{attributes:!0,relations:!0}}});console.log(l);const c={id:a,label:rm(o)};yield ic(r,[a],c),n.push(c)}e.children.push(...n)}})).apply(this,arguments)}function Yr(){return(Yr=(0,G.A)(function*(r,t){const e=yield r.getItemsOfCategories([/IFCSITE/]),i={label:t,children:[]};yield ic(r,e.IFCSITE,i),console.log(i)})).apply(this,arguments)}let Zr=(()=>{class r{_workerUrl=(0,st.WQX)(Yp.g);_resolvedWorkerUrl=(0,st.vPA)(void 0);_container=(0,st.vPA)(void 0);modelsAreLoading=(0,st.vPA)(!1);settings=(0,st.vPA)(new $i.R_);_previousHighlights=null;raycastResult=(0,st.vPA)(null);hoveredElement=(0,Ot.EW)(()=>{const e=this.raycastResult()?.localId??null,i=this.raycastResult()?.fragments.modelId??null;return i&&e?{[i]:new Set([e])}:null},{equal:(e,i)=>((r,t)=>{if(!r&&!t)return!0;if(!r||!t)return!1;const e=Object.keys(r),i=Object.keys(t);if(e.length!==i.length||e[0]!==i[0])return!1;const s=r[e[0]],n=t[i[0]];if(s.size!==n.size)return!1;const o=Array.from(s.values()),a=Array.from(n.values());return o[0]===a[0]})(e,i)});clickedElement=(0,st.vPA)(null);selectedElements=(0,st.vPA)(null);init(e){this._container.set(e)}_colorDef=(0,Ot.EW)(()=>{const e=this._container();if(e)return(r=>{const e=window.getComputedStyle(r).getPropertyValue("--background-color"),i=Jp[e];return{hoverColor:tm[i]??new p.Q1f("#e2f552"),selectionColor:em[i]??new p.Q1f("#1744c2"),selectionOutlineColor:im[i]??new p.Q1f("#e2f552"),ghostColor:nm(e)}})(e)});_loadedModels=(0,st.vPA)([]);_components=(0,Ot.EW)(()=>{if(void 0!==this._container())return console.info("Building components..."),new Ar});_world=(0,Ot.EW)(()=>{const e=this._components(),i=this._container();if(void 0!==e&&void 0!==i)return console.info("Setting up scene..."),((r,t)=>{const i=r.get(an).create();i.scene=new al(r),i.scene.setup(),i.scene.three.background=null,i.renderer=new jr.Hs(r,t);const{postproduction:s}=i.renderer;return i.camera=new ln(r),r.init(),i.scene.setup(),s.enabled=!0,i.scene.three.background=null,i.camera.controls.restThreshold=.25,i})(e,i)});_fragments=(0,Ot.EW)(()=>{const e=this._world();if(void 0===e)return;const i=this._components();if(void 0===i)return;const s=this._resolvedWorkerUrl();return void 0!==s?(console.info("Setting up fragments..."),Xp(i,e,s)):void 0});viewerReady=(0,Ot.EW)(()=>!(void 0===this._components()||void 0===this._world()||void 0===this._fragments()));get loadedModels(){return this._loadedModels}constructor(){(function Wp(r){return qr.apply(this,arguments)})(this._workerUrl).then(e=>this._resolvedWorkerUrl.set(e)),(0,st.QZP)(()=>{this.viewerReady()&&(console.info("Initializing event listeners..."),this._initEventListeners(),console.info("BIM Fragments Viewer is ready"))}),(0,st.QZP)(()=>{const e=this.settings(),i=this._world(),s=this._components(),n=this._fragments(),o=this._colorDef();void 0===e||void 0===i||void 0===s||void 0===n||void 0===o||this.viewerReady()&&(((r,t,e,i,s)=>{e.dynamicAnchor=r.dynamicAnchor;const n=e.renderer?.postproduction;if(n&&(n.enabled=r.postProductionSettings.enabled,n.style=r.postProductionSettings.style),r.clickEnabled){const o=t.get($r);o.world=e,o.fragments=i,o.enabled=!0,o.material=new p.V9B({color:s.hoverColor,transparent:!0,opacity:.5,depthTest:!1});const a=t.get(Hp);a.world=e,a.fragments=i,a.enabled=!0;const l=t.get(Kl);l.enabled=!0,l.fragments=i,l.multiSelect=r.multiSelect,l.styles={fillColor:s.selectionColor,outlineColor:s.selectionOutlineColor,fillOpacity:.5}}if(r.applyGhosting){const o=t.get(Ur);o.enabled=!0,o.ghostColor=s.ghostColor,o.fragments=i,o.world=e}console.info("Settings updated")})(e,s,i,n,o),console.info("Settings updated"))})}dispose(){var e=this;return(0,G.A)(function*(){yield e.disposeModels()})()}loadFragmentFiles(e){var i=this;return(0,G.A)(function*(){console.log("LOAD FRAGMENTS");const s=i._fragments();if(void 0===s)throw new Error("Fragments not available");i.modelsAreLoading.set(!0);const n=yield Ql(s,e);i._loadedModels.update(()=>[...n]),console.log("YYY"),console.log(n),i.modelsAreLoading.set(!1)})()}disposeModels(e){var i=this;return(0,G.A)(function*(){const s=e?e.map(o=>o.id):void 0,n=i._fragments();if(void 0===n)throw new Error("Fragments not available");yield Jl(n,s),void 0!==e&&e.forEach(o=>o.visible=!1)})()}updateModels(e){var i=this;return(0,G.A)(function*(){const s=i._fragments();if(void 0===s)throw new Error("Fragments not available");const n=yield Kp(s,e);i._loadedModels.update(()=>[...n])})()}getSpatialStructure(e){var i=this;return(0,G.A)(function*(){const s=i._fragments()?.models.list.get(e.id);return void 0!==s&&function om(r,t){Yr.apply(this,arguments)}(s,e.name),s?.getSpatialStructure()})()}updateAspectRatio(){this._world()?.renderer?.resize(),this._world()?.camera.updateAspect()}_initEventListeners(){var e=this;const i=this._components().get(Kl);i.events.clickedElement.add(n=>{const o=this.hoveredElement();null!==o&&this.clickedElement.update(()=>({itemData:n,element:o}))}),i.events.clickedCanvas.add(()=>{this.clickedElement.update(()=>null)}),i.events.selection.add(n=>{this.selectedElements.update(()=>n)}),this._components().get($r).events.hoveredElement.add(function(){var n=(0,G.A)(function*(o){e.raycastResult.update(()=>o)});return function(o){return n.apply(this,arguments)}}()),this._fragments().models.list.onItemSet.add(()=>{})}static \u0275fac=function(i){return new(i||r)};static \u0275prov=st.jDH({token:r,factory:r.\u0275fac,providedIn:"root"})}return r})();var am=mt(7023),lm=mt(5970),Ri=mt(5381),Wr=mt(5187),un=mt(5971),Xr=mt(3319),b=mt(5547);function cm(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-flexcontainer",3)(1,"cue-button",5),b.bIt("click",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.zoomOut())}),b.nrm(2,"cue-button-icon",6),b.k0s(),b.j41(3,"cue-button",5),b.bIt("click",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.zoomIn())}),b.nrm(4,"cue-button-icon",7),b.k0s(),b.j41(5,"cue-button",5),b.bIt("click",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.zoomFit())}),b.nrm(6,"cue-button-icon",8),b.k0s()()}}function hm(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-button",5),b.bIt("click",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.toggleLayersVisible())}),b.nrm(1,"cue-button-icon",9),b.k0s()}if(2&r){const e=b.XpG();b.AVh("border-left",e.options().displayZoom&&e.displayDecompositionTree())}}let um=(()=>{class r{settings=(0,Tt.hFB)(new $i.R_);options=(0,Ot.EW)(()=>this.settings().toolbar);selectMenuPositions=(0,Ot.EW)(()=>"top"===this.options().position?"bottomleft":"topleft");displayDecompositionTree=(0,Ot.EW)(()=>void 0!==this.options().displayDecompositionTree);zoomIn(){}zoomOut(){}zoomFit(){}toggleLayersVisible(){}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-bim-fragments-toolbar"]],inputs:{settings:[1,"settings"]},decls:5,vars:3,consts:[["align","center",1,"container"],[1,"toolbar",3,"padded"],["align","center"],["align","center","gap","s"],["size","xs","variant","tertiary",3,"border-left"],["size","xs","variant","tertiary",3,"click"],["icon","zoom-out"],["icon","zoom-in"],["icon","zoom-fit"],["icon","tree"]],template:function(i,s){1&i&&(b.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),b.nVh(3,cm,7,0,"cue-flexcontainer",3),b.nVh(4,hm,2,2,"cue-button",4),b.k0s()()()),2&i&&(b.R7$(),b.Y8G("padded",!1),b.R7$(2),b.vxM(s.options().displayZoom?3:-1),b.R7$(),b.vxM(s.displayDecompositionTree()?4:-1))},dependencies:[Ri.FlexContainer,Wr.Card,un.Button,Xr.ButtonIcon],styles:[".container[_ngcontent-%COMP%]{height:100%;pointer-events:none}.toolbar[_ngcontent-%COMP%]{pointer-events:all;padding:5px 10px}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return r})();var dm=mt(9421),fm=mt(1024),dn=mt(2245);function pm(r,t){if(1&r&&b.nrm(0,"cue-key-val",3),2&r){const e=b.XpG();b.Y8G("val",e.name)}}function mm(r,t){if(1&r&&b.nrm(0,"cue-key-val",5),2&r){const e=t.$implicit;b.Y8G("key",e.label)("val",e.value)}}function gm(r,t){if(1&r&&(b.j41(0,"cue-typography",4),b.EFF(1),b.k0s(),b.j41(2,"cue-key-val-list"),b.Z7z(3,mm,1,2,"cue-key-val",5,b.Vm6),b.k0s()),2&r){const e=t.$implicit;b.R7$(),b.JRh(e.psetName),b.R7$(2),b.Dyx(e.props)}}function _m(r,t){if(1&r&&b.Z7z(0,gm,5,1,null,null,b.Vm6),2&r){const e=b.XpG();b.Dyx(e.psets)}}function ym(r,t){if(1&r&&(b.nVh(0,pm,1,1,"cue-key-val",3),b.nVh(1,_m,2,0)),2&r){const e=t;b.vxM(e.name?0:-1),b.R7$(),b.vxM(e.psets.length>0?1:-1)}}function wm(r,t){if(1&r&&(b.j41(0,"cue-card",1)(1,"cue-flexcontainer",2),b.nVh(2,ym,2,2),b.k0s()()),2&r){let e;const i=b.XpG();b.Y8G("padded",!1)("scrollable",!0),b.R7$(2),b.vxM((e=i.props())?2:-1,e)}}function vm(r,t){if(1&r&&b.nrm(0,"cue-key-val",3),2&r){const e=b.XpG();b.Y8G("val",e.name)}}function bm(r,t){if(1&r&&b.nrm(0,"cue-key-val",5),2&r){const e=t.$implicit;b.Y8G("key",e.label)("val",e.value)}}function xm(r,t){if(1&r&&(b.j41(0,"cue-typography",4),b.EFF(1),b.k0s(),b.j41(2,"cue-key-val-list"),b.Z7z(3,bm,1,2,"cue-key-val",5,b.Vm6),b.k0s()),2&r){const e=t.$implicit;b.R7$(),b.JRh(e.psetName),b.R7$(2),b.Dyx(e.props)}}function Cm(r,t){if(1&r&&b.Z7z(0,xm,5,1,null,null,b.Vm6),2&r){const e=b.XpG();b.Dyx(e.psets)}}function Tm(r,t){if(1&r&&(b.nVh(0,vm,1,1,"cue-key-val",3),b.nVh(1,Cm,2,0)),2&r){const e=t;b.vxM(e.name?0:-1),b.R7$(),b.vxM(e.psets.length>0?1:-1)}}function Pm(r,t){if(1&r&&(b.j41(0,"cue-flexcontainer",2),b.nVh(1,Tm,2,2),b.k0s()),2&r){let e;const i=b.XpG();b.R7$(),b.vxM((e=i.props())?1:-1,e)}}let Sm=(()=>{class r{element=Tt.hFB.required();wrapInCard=(0,Tt.hFB)(!0);props=(0,Ot.EW)(()=>{const e=this.element().itemData,i=this.formatItemPsets(e.IsDefinedBy||[]);return{name:e.Name?.value||"No name",psets:i}});formatItemPsets(e){const i=[];for(const[,s]of e.entries()){const{Name:n,HasProperties:o}=s;if(!("value"in n)||!Array.isArray(o))continue;const a=[];for(const[,l]of o.entries()){const{Name:c,NominalValue:h}=l;if(!("value"in c)||!("value"in h))continue;const u=c.value,f=h.value;u&&void 0!==f&&a.push({label:u,value:f.toString()})}i.push({psetName:n.value,props:a})}return i}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-bim-fragments-props-viewer"]],inputs:{element:[1,"element"],wrapInCard:[1,"wrapInCard"]},decls:3,vars:1,consts:[["direction","column","justify","start",1,"container"],[1,"card",3,"padded","scrollable"],["align","start","direction","column"],["key","Name",3,"val"],["size","s","weight","semibold"],[3,"key","val"]],template:function(i,s){1&i&&(b.j41(0,"cue-flexcontainer",0),b.nVh(1,wm,3,3,"cue-card",1)(2,Pm,2,1,"cue-flexcontainer",2),b.k0s()),2&i&&(b.R7$(),b.vxM(s.wrapInCard()?1:2))},dependencies:[Ri.FlexContainer,Wr.Card,dm.F,fm.p,dn.Typography],styles:[".container[_ngcontent-%COMP%]{height:100%;pointer-events:none}.card[_ngcontent-%COMP%]{pointer-events:all;max-height:100%;width:300px;flex:1 1}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return r})();var sc=mt(9769);let Em=(()=>{class r{selectedItem=(0,st.vPA)(void 0);static \u0275fac=function(i){return new(i||r)};static \u0275prov=st.jDH({token:r,factory:r.\u0275fac,providedIn:"root"})}return r})();var nc=mt(7089),Am=mt(5448),rc=mt(6117),Kr=mt(356),Qr=mt(6279);const oc=(r,t)=>t.path;function Mm(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-menu-item",7),b.bIt("click",function(s){const n=st.eBV(e).$implicit,o=b.XpG(2);return st.Njj(o.navigateTo(s,n.path))}),b.EFF(1),b.k0s()}if(2&r){const e=t.$implicit;b.R7$(),b.SpI(" ",e.name," ")}}function Im(r,t){if(1&r&&(b.j41(0,"cue-flexcontainer",2)(1,"cue-menu")(2,"cue-button",4,0)(4,"cue-button-label"),b.EFF(5,"..."),b.k0s()(),b.j41(6,"cue-menu-wrap",5),b.Z7z(7,Mm,2,1,"cue-menu-item",null,oc),b.k0s()(),b.j41(9,"cue-typography",6),b.EFF(10," \u203a "),b.k0s()()),2&r){const e=b.XpG();b.R7$(2),b.Y8G("size",e.buttonSize())("cueTooltip",e.hiddenPartsTooltip()),b.R7$(5),b.Dyx(e.hidddenParts()),b.R7$(2),b.Y8G("size",e.size())}}function Om(r,t){if(1&r&&(b.j41(0,"cue-typography",6),b.EFF(1," \u203a "),b.k0s()),2&r){const e=b.XpG(2);b.Y8G("size",e.size())}}function zm(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-flexcontainer",8),b.bIt("click",function(s){const n=st.eBV(e),o=n.$implicit,a=n.$index,l=n.$count,c=b.XpG();return st.Njj(a!==l-1&&!c.buttonMode()&&c.navigateTo(s,o.path))}),b.j41(1,"cue-typography",9),b.EFF(2),b.k0s(),b.nVh(3,Om,2,1,"cue-typography",6),b.k0s()}if(2&r){const e=t.$implicit,i=t.$index,s=t.$count,n=b.XpG();b.AVh("clickable",i!==s-1&&n.updatePathOnClick()&&!n.buttonMode()),b.R7$(),b.AVh("full-length",n.nameFullLength()),b.Y8G("size",n.size())("weight",i===s-1?"medium":"regular")("title",e.name),b.R7$(),b.SpI(" ",e.name," "),b.R7$(),b.vxM(i!==s-1?3:-1)}}let Dm=(()=>{class r{path=Tt.geq.required();size=(0,Tt.hFB)("xs");rootName=(0,Tt.hFB)(null);maxVisibleParts=(0,Tt.hFB)(3);nameFullLength=(0,Tt.hFB)(!1);updatePathOnClick=(0,Tt.hFB)(!0);buttonMode=(0,Tt.hFB)(!1);buttonSize=(0,Ot.EW)(()=>{switch(this.size()){case"xs":case"s":default:return"s";case"m":case"l":case"xl":return"m"}});get sizeAttribute(){return this.size()}get buttonModeClass(){return this.buttonMode()}onHostClick(e){this.buttonMode()&&(e.stopPropagation(),this.clickedPath.emit(this.path()))}pathChange=(0,Tt.CGW)();clickedPath=(0,Tt.CGW)();allBreadcrumbParts=(0,Ot.EW)(()=>{const e=this.path().split("/").filter(o=>""!==o),i=[],s=this.rootName();null!==s&&i.push({name:s,path:"/"});let n="";for(const o of e)n+=`/${o}`,i.push({name:o,path:n.endsWith("/")?n:`${n}/`});return i});shouldShowEllipsis=(0,Ot.EW)(()=>this.allBreadcrumbParts().length>this.maxVisibleParts());visibleBreadcrumbParts=(0,Ot.EW)(()=>{const e=this.allBreadcrumbParts(),i=this.maxVisibleParts();return e.length<=i?e:e.slice(-i)});hidddenParts=(0,Ot.EW)(()=>{const e=this.allBreadcrumbParts(),i=this.maxVisibleParts();return e.length<=i?[]:e.slice(0,-i)});hiddenPartsTooltip=(0,Ot.EW)(()=>{const e=this.hidddenParts();return 0===e.length?"":`${e.map(i=>i.name).join(" \u203a ")}`});navigateTo(e,i){console.log("Navigating to:",i),e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault(),this.clickedPath.emit(i),this.updatePathOnClick()&&(this.path.set(i),this.pathChange.emit(i))}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-breadcrumb"]],hostVars:3,hostBindings:function(i,s){1&i&&b.bIt("click",function(o){return s.onHostClick(o)}),2&i&&(b.BMQ("size",s.sizeAttribute),b.AVh("button-mode",s.buttonModeClass))},inputs:{path:[1,"path"],size:[1,"size"],rootName:[1,"rootName"],maxVisibleParts:[1,"maxVisibleParts"],nameFullLength:[1,"nameFullLength"],updatePathOnClick:[1,"updatePathOnClick"],buttonMode:[1,"buttonMode"]},outputs:{path:"pathChange",pathChange:"pathChange",clickedPath:"clickedPath"},decls:4,vars:1,consts:[["trigger",""],["direction","row","gap","s","align","center"],["direction","row","gap","s","align","center",1,"ellipsis-container"],["direction","row","gap","s",3,"clickable"],["trigger","","variant","ghost",3,"size","cueTooltip"],["menu",""],["weight","semibold",3,"size"],[3,"click"],["direction","row","gap","s",3,"click"],[1,"breadcrumb-text",3,"size","weight","title"]],template:function(i,s){1&i&&(b.j41(0,"cue-flexcontainer",1),b.nVh(1,Im,11,3,"cue-flexcontainer",2),b.Z7z(2,zm,4,9,"cue-flexcontainer",3,oc),b.k0s()),2&i&&(b.R7$(),b.vxM(s.shouldShowEllipsis()?1:-1),b.R7$(),b.Dyx(s.visibleBreadcrumbParts()))},dependencies:[sc.MD,dn.Typography,Ri.FlexContainer,un.Button,Am.ButtonLabel,nc.d,rc.W,Kr.M,Qr.D],styles:['.clickable[_ngcontent-%COMP%]{cursor:pointer}.clickable[_ngcontent-%COMP%]:hover{text-decoration:underline}.separator[_ngcontent-%COMP%]{color:#666;padding:0 4px}.full-length[_ngcontent-%COMP%]{max-width:none!important}.full-length[_ngcontent-%COMP%] > div[_ngcontent-%COMP%]{max-width:none!important;overflow:visible!important;text-overflow:unset!important;white-space:normal!important}.breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:100px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:block}.breadcrumb-text[_ngcontent-%COMP%]:not(.full-length) > div[_ngcontent-%COMP%]{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ellipsis-container[_ngcontent-%COMP%]{cursor:default;display:flex;align-items:center}.ellipsis-text[_ngcontent-%COMP%]{color:#666;font-style:italic;line-height:1;display:flex;align-items:center;text-align:center;vertical-align:middle;justify-content:center;height:100%;min-height:1em}.ellipsis-text[_ngcontent-%COMP%] span[_ngcontent-%COMP%]{display:inline-block!important}.ellipsis-text[_ngcontent-%COMP%] *{display:flex!important;align-items:center!important;justify-content:center!important;height:100%!important;line-height:1!important}.button-mode[_nghost-%COMP%]{cursor:pointer}[size="xs"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:70px}[size="s"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:80px}[size="m"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:100px}[size="l"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:120px}[size="xl"][_nghost-%COMP%] .breadcrumb-text[_ngcontent-%COMP%]:not(.full-length){max-width:150px}']})}return r})();var km=mt(29);const Lm=()=>[],Nm=()=>({}),Bm=(r,t)=>t.label;function Rm(r,t){if(1&r&&b.nrm(0,"cue-svg-icon",17),2&r){const e=b.XpG().$implicit;b.Y8G("name",e.icon)}}function Fm(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-menu-item",16),b.bIt("click",function(){const s=st.eBV(e).$implicit;return st.Njj(s.action())}),b.nVh(1,Rm,1,1,"cue-svg-icon",17),b.EFF(2),b.k0s()}if(2&r){const e=t.$implicit;b.Y8G("tooltip",e.tooltip??""),b.R7$(),b.vxM(e.icon?1:-1),b.R7$(),b.SpI(" ",e.label," ")}}function Vm(r,t){if(1&r&&(b.j41(0,"cue-menu",11),b.bIt("click",function(i){return i.stopPropagation()}),b.j41(1,"cue-button",12),b.nrm(2,"cue-button-icon",13),b.k0s(),b.j41(3,"cue-menu-wrap",14),b.Z7z(4,Fm,3,3,"cue-menu-item",15,Bm),b.k0s()()),2&r){const e=b.XpG().$implicit;b.R7$(),b.Y8G("cueTooltip",e.tooltip??""),b.R7$(),b.Y8G("icon",e.icon),b.R7$(2),b.Dyx(e.menuItems)}}function Um(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-button",18),b.bIt("click",function(s){return st.eBV(e),b.XpG().$implicit.action(),st.Njj(s.stopPropagation())}),b.nrm(1,"cue-button-icon",13),b.k0s()}if(2&r){const e=b.XpG().$implicit;b.Y8G("cueTooltip",e.tooltip??""),b.R7$(),b.Y8G("icon",e.icon)}}function $m(r,t){if(1&r&&b.nVh(0,Vm,6,2,"cue-menu")(1,Um,2,2,"cue-button",10),2&r){const e=t.$implicit;b.vxM(null!=e.menuItems&&e.menuItems.length?0:e.action?1:-1)}}function jm(r,t){if(1&r&&(b.j41(0,"cue-flexcontainer",3),b.Z7z(1,$m,2,1,null,null,b.Vm6),b.k0s()),2&r){const e=b.XpG().$implicit;b.R7$(),b.Dyx(e.buttons)}}function Hm(r,t){if(1&r&&(b.j41(0,"span",22),b.EFF(1),b.k0s()),2&r){const e=b.XpG(2).$implicit,i=b.XpG();b.AVh("checked",i.isSelected(e)),b.R7$(),b.SpI(" ",i.isSelected(e)?"\u2611":"\u2610"," ")}}function qm(r,t){if(1&r&&(b.j41(0,"cue-typography",21),b.EFF(1),b.k0s()),2&r){const e=b.XpG(2).$implicit;b.R7$(),b.JRh(e.subLabel)}}function Gm(r,t){if(1&r&&(b.j41(0,"div",4),b.nVh(1,Hm,2,3,"span",19),b.j41(2,"cue-typography",20),b.EFF(3),b.k0s(),b.nVh(4,qm,2,1,"cue-typography",21),b.k0s()),2&r){const e=b.XpG().$implicit,i=b.XpG();b.R7$(),b.vxM(i.multiSelect()&&!i.hasChildren(e)?1:-1),b.R7$(),b.Y8G("weight",i.isSelected(e)?"semibold":"regular")("size",i.size()),b.R7$(),b.JRh(e.label),b.R7$(),b.vxM(e.subLabel?4:-1)}}function Ym(r,t){if(1&r&&b.nrm(0,"cue-breadcrumb",6),2&r){const e=b.XpG().$implicit,i=b.XpG();b.Y8G("maxVisibleParts",5)("path",e.label)("size",i.size())("nameFullLength",!0)("updatePathOnClick",!1)}}function Zm(r,t){if(1&r&&b.nrm(0,"cue-svg-icon",23),2&r){const e=b.XpG().$implicit,i=b.XpG();b.AVh("expanded",i.isExpanded(e))}}function Wm(r,t){if(1&r&&(b.j41(0,"div",8),b.nrm(1,"cue-tree-menu",24),b.k0s()),2&r){const e=b.XpG().$implicit,i=b.XpG();b.R7$(),b.Y8G("items",e.children||b.lJ4(2,Lm))("size",i.size())}}function Xm(r,t){if(1&r&&(b.j41(0,"div",25),b.bIt("click",function(i){return i.stopPropagation()}),b.eu8(1,26),b.k0s()),2&r){const e=b.XpG().$implicit;b.R7$(),b.Y8G("ngTemplateOutlet",e.contentTemplate)("ngTemplateOutletContext",e.templateContext??b.lJ4(2,Nm))}}function Km(r,t){if(1&r){const e=b.RV6();b.j41(0,"li",1)(1,"cue-flexcontainer",2),b.bIt("click",function(){const s=st.eBV(e).$implicit,n=b.XpG();return st.Njj(n.handleItemClick(s))}),b.nVh(2,jm,3,0,"cue-flexcontainer",3),b.nVh(3,Gm,5,5,"div",4),b.nrm(4,"span",5),b.nVh(5,Ym,1,5,"cue-breadcrumb",6),b.nVh(6,Zm,1,2,"cue-svg-icon",7),b.k0s(),b.nVh(7,Wm,2,3,"div",8),b.nVh(8,Xm,2,3,"div",9),b.k0s()}if(2&r){const e=t.$implicit,i=b.XpG();b.R7$(),b.AVh("has-children",i.hasChildren(e)),b.R7$(),b.vxM(null!=e.buttons&&e.buttons.length?2:-1),b.R7$(),b.vxM(void 0===e.type||"text"===e.type?3:-1),b.R7$(2),b.vxM("breadcrumb"===e.type?5:-1),b.R7$(),b.vxM(i.hasChildren(e)?6:-1),b.R7$(),b.vxM(i.hasChildren(e)&&i.isExpanded(e)?7:-1),b.R7$(),b.vxM(e.contentTemplate?8:-1)}}let Qm=(()=>{class r{_service=(0,st.WQX)(Em);items=(0,Tt.geq)([]);size=(0,Tt.hFB)("m");collapseOnSelect=(0,Tt.hFB)(!1);initialExpandDepth=(0,Tt.hFB)(-1);multiSelect=(0,Tt.hFB)(!1);expandedItems=new Set;_multiSelectedIds=(0,st.vPA)(new Set);selectionChanged=(0,Tt.CGW)();multiSelectionChanged=(0,Tt.CGW)();onItemsChange=(0,st.QZP)(()=>{this.multiSelect()?(this._syncMultiSelectedFromItems(),this._doInitialExpand()):this.collapseOnSelect()||this._initialExpandSelected()});onSelectionChange=(0,st.QZP)(()=>{const e=this._service.selectedItem();void 0!==e&&this.selectionChanged.emit(e)});ngOnDestroy(){this.items.update(()=>[])}handleItemClick(e){if(this.hasChildren(e)){const i=e.id??e.label;if(this.expandedItems.has(i)?this.expandedItems.delete(i):this.expandedItems.add(i),!this.multiSelect()){const s=this._service.selectedItem();void 0!==s&&(s.selected=!1),e.selected=!0,this._service.selectedItem.set(e)}}else if(this.multiSelect()){const i=e.id??e.label;this._multiSelectedIds.update(s=>{const n=new Set(s);return n.has(i)?n.delete(i):n.add(i),n}),this.multiSelectionChanged.emit([...this._multiSelectedIds()])}else this._setSelected(e),this._update()}hasChildren(e){return!!e.children&&e.children.length>0}isExpanded(e){return this.expandedItems.has(e.id??e.label)}isSelected(e){return this.multiSelect()?this._multiSelectedIds().has(e.id??e.label):e.selected}_setSelected(e){const i=this._service.selectedItem();void 0!==i&&(i.selected=!1),e.selected=!0}_update(){this.items.update(()=>[...this.items()])}_syncMultiSelectedFromItems(){const e=new Set,i=s=>{for(const n of s)n.selected&&e.add(n.id??n.label),n.children?.length&&i(n.children)};i(this.items()??[]),this._multiSelectedIds.set(e)}_doInitialExpand(){this.expandedItems.clear();const e=this.initialExpandDepth(),i=(s,n=0)=>{for(const o of s)e>=0&&n<=e&&this.hasChildren(o)&&this.expandedItems.add(o.id??o.label),o.children?.length&&i(o.children,n+1)};i(this.items()??[])}_initialExpandSelected(){this.expandedItems.clear();const e=this.initialExpandDepth(),i=(s,n=[],o=0)=>{for(const a of s){if(e>=0&&o<=e&&this.hasChildren(a)&&this.expandedItems.add(a.id??a.label),a.selected){this._service.selectedItem.set(a);for(const l of n)this.expandedItems.add(l.id??l.label)}a.children&&a.children.length>0&&i(a.children,[...n,a],o+1)}};i(this.items()??[])}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-tree-menu"]],inputs:{items:[1,"items"],size:[1,"size"],collapseOnSelect:[1,"collapseOnSelect"],initialExpandDepth:[1,"initialExpandDepth"],multiSelect:[1,"multiSelect"]},outputs:{items:"itemsChange",selectionChanged:"selectionChanged",multiSelectionChanged:"multiSelectionChanged"},decls:3,vars:0,consts:[[1,"menu"],[1,"menu-item"],["justify","start","align","center","gap","s",1,"menu-item-header",3,"click"],["gap","s","align","center"],[2,"display","flex","flex-direction","row","align-items","baseline","gap","6px"],[2,"flex","1"],[3,"maxVisibleParts","path","size","nameFullLength","updatePathOnClick"],["name","arrow-dropdown",1,"menu-item-arrow",3,"expanded"],[1,"submenu"],[1,"menu-item-content"],["size","xs","variant","ghost","tooltipPlacement","right",3,"cueTooltip"],[3,"click"],["trigger","","size","xs","variant","ghost","tooltipPlacement","right",3,"cueTooltip"],[3,"icon"],["menu",""],[3,"tooltip"],[3,"click","tooltip"],["before","",3,"name"],["size","xs","variant","ghost","tooltipPlacement","right",3,"click","cueTooltip"],[1,"multi-check",3,"checked"],[3,"weight","size"],["size","xs",2,"opacity","0.6"],[1,"multi-check"],["name","arrow-dropdown",1,"menu-item-arrow"],[3,"items","size"],[1,"menu-item-content",3,"click"],[3,"ngTemplateOutlet","ngTemplateOutletContext"]],template:function(i,s){1&i&&(b.j41(0,"ul",0),b.Z7z(1,Km,9,8,"li",1,b.Vm6),b.k0s()),2&i&&(b.R7$(),b.Dyx(s.items()))},dependencies:[r,dn.Typography,Ri.FlexContainer,Dm,un.Button,Xr.ButtonIcon,km.A,nc.d,sc.T3,rc.W,Qr.D,Kr.M],styles:[".menu[_ngcontent-%COMP%]{list-style:none;padding:0;margin:0}.menu-item[_ngcontent-%COMP%]{cursor:pointer;-webkit-user-select:none;user-select:none}.menu-item-header[_ngcontent-%COMP%]{padding:8px 16px;transition:background-color .2s}.menu-item-header[_ngcontent-%COMP%]:hover{background-color:var(--cue-color-green);color:var(--cue-color-black)}.menu-item-header[_ngcontent-%COMP%]:hover *{color:var(--cue-color-black);fill:var(--cue-color-black)}.menu-item-header.has-children[_ngcontent-%COMP%]{font-weight:700}.menu-item-arrow[_ngcontent-%COMP%]{transition:transform .2s;flex-shrink:0}.menu-item-arrow.expanded[_ngcontent-%COMP%]{transform:rotate(180deg)}.submenu[_ngcontent-%COMP%]{padding-left:16px;border-left:1px solid}.multi-check[_ngcontent-%COMP%]{font-size:14px;line-height:1;color:var(--cue-defaultContrast);opacity:.5;flex-shrink:0}.multi-check.checked[_ngcontent-%COMP%]{opacity:1;color:var(--cue-accent, #4f7fff)}"]})}return r})(),Jm=(()=>{class r{_service=(0,st.WQX)(Zr);type=(0,Tt.hFB)("spatial");models=Tt.geq.required();treeItems=(0,st.vPA)([]);constructor(){var e=this;(0,st.QZP)((0,G.A)(function*(){if(!e._service.loadedModels().length)return;console.log(e._service.loadedModels());const i=yield Promise.all(e.models().map(n=>e.getSpatialStructure(n)));console.log("Model Trees:",i);const s=[];e.models().forEach(n=>{s.push({label:n.name,buttons:[{icon:n.visible?"view-inactive":"view-active",action:()=>e.toggleVisibility(n)}]})}),e.treeItems.update(()=>[...s])}))}toggleVisibility(e){var i=this;return(0,G.A)(function*(){e.visible?(yield i._service.disposeModels([e]),console.log(`Model ${e.name} (${e.id}) disposed`)):yield i._service.loadFragmentFiles([e]),i.models.update(()=>[...i.models()])})()}getSpatialStructure(e){var i=this;return(0,G.A)(function*(){const s=yield i._service.getSpatialStructure(e);if(s)return{label:s.category,children:s.children?.map(n=>({label:n.name,children:n.children?.map(o=>({label:o.name}))}))}})()}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-bim-fragments-tree-viewer"]],inputs:{type:[1,"type"],models:[1,"models"]},outputs:{models:"modelsChange"},decls:1,vars:1,consts:[["size","s",3,"items"]],template:function(i,s){1&i&&b.nrm(0,"cue-tree-menu",0),2&i&&b.Y8G("items",s.treeItems())},dependencies:[Qm],styles:[".container[_ngcontent-%COMP%]{height:100%;pointer-events:none}.card[_ngcontent-%COMP%]{pointer-events:all;max-height:100%;width:300px;flex:1 1}.border-left[_ngcontent-%COMP%]{border-left:1px solid;padding-left:12px}"],changeDetection:0})}return r})();var tg=mt(6034),eg=mt(4613);const ac=(r,t)=>t.id;function ig(r,t){1&r&&b.nrm(0,"cue-logo",4),2&r&&b.Y8G("active",!0)("continuous",!0)}function sg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-typography",6),b.EFF(1),b.k0s(),b.j41(2,"cue-button",7),b.bIt("click",function(){const s=st.eBV(e).$implicit,n=b.XpG(3);return st.Njj(n.toggleVisibility(s))}),b.nrm(3,"cue-button-icon",8),b.k0s()}if(2&r){const e=t.$implicit;b.R7$(),b.JRh(e.name),b.R7$(2),b.Y8G("icon",e.visible?"view-inactive":"view-active")}}function ng(r,t){if(1&r&&(b.j41(0,"cue-flexcontainer",5),b.Z7z(1,sg,4,2,null,null,ac),b.k0s()),2&r){const e=b.XpG(2);b.R7$(),b.Dyx(e.models())}}function rg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-typography",3),b.EFF(1),b.k0s(),b.j41(2,"cue-bim-fragments-tree-viewer",9),b.mxI("modelsChange",function(s){st.eBV(e);const n=b.XpG(2);return b.DH7(n.models,s)||(n.models=s),st.Njj(s)}),b.k0s()}if(2&r){const e=b.XpG(2);b.R7$(),b.JRh(e.treeLabel()),b.R7$(),b.R50("models",e.models)}}function og(r,t){if(1&r&&(b.j41(0,"cue-draggable-card",0)(1,"cue-flexcontainer",1)(2,"cue-flexcontainer",2)(3,"cue-typography",3),b.EFF(4,"Models"),b.k0s(),b.nVh(5,ig,1,2,"cue-logo",4)(6,ng,3,0,"cue-flexcontainer",5),b.k0s(),b.nVh(7,rg,3,2),b.k0s()()),2&r){const e=b.XpG();b.Y8G("padded",!1),b.R7$(5),b.vxM(e.modelsAreLoading()?5:6),b.R7$(2),b.vxM(e.displayDecompositionTree()?7:-1)}}function ag(r,t){1&r&&b.nrm(0,"cue-logo",4),2&r&&b.Y8G("active",!0)("continuous",!0)}function lg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-typography",6),b.EFF(1),b.k0s(),b.j41(2,"cue-button",7),b.bIt("click",function(){const s=st.eBV(e).$implicit,n=b.XpG(3);return st.Njj(n.toggleVisibility(s))}),b.nrm(3,"cue-button-icon",8),b.k0s()}if(2&r){const e=t.$implicit;b.R7$(),b.JRh(e.name),b.R7$(2),b.Y8G("icon",e.visible?"view-inactive":"view-active")}}function cg(r,t){if(1&r&&(b.j41(0,"cue-flexcontainer",5),b.Z7z(1,lg,4,2,null,null,ac),b.k0s()),2&r){const e=b.XpG(2);b.R7$(),b.Dyx(e.models())}}function hg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-typography",3),b.EFF(1),b.k0s(),b.j41(2,"cue-bim-fragments-tree-viewer",9),b.mxI("modelsChange",function(s){st.eBV(e);const n=b.XpG(2);return b.DH7(n.models,s)||(n.models=s),st.Njj(s)}),b.k0s()}if(2&r){const e=b.XpG(2);b.R7$(),b.JRh(e.treeLabel()),b.R7$(),b.R50("models",e.models)}}function ug(r,t){if(1&r&&(b.j41(0,"cue-flexcontainer",1)(1,"cue-flexcontainer",2)(2,"cue-typography",3),b.EFF(3,"Models"),b.k0s(),b.nVh(4,ag,1,2,"cue-logo",4)(5,cg,3,0,"cue-flexcontainer",5),b.k0s(),b.nVh(6,hg,3,2),b.k0s()),2&r){const e=b.XpG();b.R7$(4),b.vxM(e.modelsAreLoading()?4:5),b.R7$(2),b.vxM(e.displayDecompositionTree()?6:-1)}}let dg=(()=>{class r{_service=(0,st.WQX)(Zr);models=Tt.geq.required();draggable=(0,Tt.hFB)(!0);modelsAreLoading=this._service.modelsAreLoading;displayDecompositionTree=(0,Ot.EW)(()=>void 0!==this._service.settings().toolbar.displayDecompositionTree);treeLabel=(0,Ot.EW)(()=>"spatial"===this._service.settings().toolbar.displayDecompositionTree?"Spatial Decomposition":"System Decomposition");toggleVisibility(e){var i=this;return(0,G.A)(function*(){console.log("TOGGLE VISIBILITY",e),e.visible?(yield i._service.disposeModels([e]),console.log(`Model ${e.name} (${e.id}) disposed`)):yield i._service.loadFragmentFiles([e]),i.models.update(()=>[...i.models()])})()}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-bim-fragments-visibility-menu"]],inputs:{models:[1,"models"],draggable:[1,"draggable"]},outputs:{models:"modelsChange"},decls:2,vars:1,consts:[["margin","0",1,"draggable",3,"padded"],["direction","column","gap","l",2,"padding","0 10px 10px 10px"],["align","start","direction","column",2,"width","100%"],["size","s","weight","semibold"],["size","xs",3,"active","continuous"],["direction","row","justify","space-between","align","center",2,"width","100%"],["size","s"],["size","xs",3,"click"],[3,"icon"],[3,"modelsChange","models"]],template:function(i,s){1&i&&b.nVh(0,og,8,3,"cue-draggable-card",0)(1,ug,7,2,"cue-flexcontainer",1),2&i&&b.vxM(s.draggable()?0:1)},dependencies:[tg.y,dn.Typography,Ri.FlexContainer,un.Button,Xr.ButtonIcon,Jm,eg.Logo],styles:[".draggable[_ngcontent-%COMP%]{z-index:101}"],changeDetection:0})}return r})();var fg=mt(7851);const pg=["bimViewer"],lc=()=>({position:"bottomleft"}),mg=(r,t)=>t.label;function gg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-menu-item",4),b.bIt("click",function(){const s=st.eBV(e).$implicit;return st.Njj(s.action())}),b.EFF(1),b.k0s()}if(2&r){const e=t.$implicit;b.R7$(),b.JRh(e.label)}}function _g(r,t){if(1&r&&(b.j41(0,"cue-menu-wrap"),b.Z7z(1,gg,2,1,"cue-menu-item",null,mg),b.k0s()),2&r){const e=b.XpG();b.R7$(),b.Dyx(e.contextMenuItems())}}function yg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-bim-fragments-visibility-menu",13),b.mxI("modelsChange",function(s){st.eBV(e);const n=b.XpG(2);return b.DH7(n.models,s)||(n.models=s),st.Njj(s)}),b.k0s()}if(2&r){const e=b.XpG(2);b.R50("models",e.models),b.Y8G("draggable",!1)}}function wg(r,t){if(1&r&&b.nrm(0,"cue-bim-fragments-toolbar",15),2&r){const e=b.XpG(3),i=b.r8f(3);b.Aen(e.toolbarStyle()),b.Y8G("settings",i)}}function vg(r,t){1&r&&b.nVh(0,wg,1,3,"cue-bim-fragments-toolbar",14),2&r&&b.vxM(t.hidden?-1:0)}function bg(r,t){if(1&r&&(b.j41(0,"cue-card",16),b.nrm(1,"cue-bim-fragments-props-viewer",17),b.k0s()),2&r){const e=b.XpG(2);b.AVh("hidden",null===e.$clickedElement()),b.R7$(),b.Y8G("element",t)("wrapInCard",!1)}}function xg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-card",5),b.nVh(1,yg,1,2,"cue-bim-fragments-visibility-menu",6),b.k0s(),b.j41(2,"div",7)(3,"cue-card",8)(4,"div",9,1),b.bIt("resized",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.onResized())})("windowResized",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.onResized())}),b.k0s(),b.nVh(6,vg,1,1),b.k0s(),b.j41(7,"a",10),b.EFF(8,"Powered by "),b.j41(9,"span",11),b.EFF(10,"ThatOpen"),b.k0s()()(),b.nVh(11,bg,2,4,"cue-card",12)}if(2&r){let e,i;const s=b.XpG(),n=b.sdS(1),o=b.r8f(3);b.R7$(),b.vxM(o.showModelList&&s.models().length?1:-1),b.R7$(3),b.Y8G("cueLogoLoader",s.isLoading())("cueContextMenu",n)("contextMenuData",b.lJ4(7,lc))("cueContextEnabled",null!==s.$hoveredElement()),b.R7$(2),b.vxM((e=o.toolbar)?6:-1,e),b.R7$(5),b.vxM((i=s.$clickedElement())?11:-1,i)}}function Cg(r,t){if(1&r&&b.nrm(0,"cue-bim-fragments-toolbar",15),2&r){const e=b.XpG(3),i=b.r8f(3);b.Aen(e.toolbarStyle()),b.Y8G("settings",i)}}function Tg(r,t){1&r&&b.nVh(0,Cg,1,3,"cue-bim-fragments-toolbar",14),2&r&&b.vxM(t.hidden?-1:0)}function Pg(r,t){1&r&&(b.j41(0,"div",19),b.nrm(1,"cue-bim-fragments-props-viewer",21),b.k0s()),2&r&&(b.R7$(),b.Y8G("element",t))}function Sg(r,t){if(1&r){const e=b.RV6();b.j41(0,"cue-bim-fragments-visibility-menu",22),b.mxI("modelsChange",function(s){st.eBV(e);const n=b.XpG(2);return b.DH7(n.models,s)||(n.models=s),st.Njj(s)}),b.k0s()}if(2&r){const e=b.XpG(2);b.R50("models",e.models)}}function Eg(r,t){if(1&r){const e=b.RV6();b.j41(0,"div",18,1),b.bIt("resized",function(){st.eBV(e);const s=b.XpG();return st.Njj(s.onResized())}),b.nVh(2,Tg,1,1),b.nVh(3,Pg,2,1,"div",19),b.nVh(4,Sg,1,1,"cue-bim-fragments-visibility-menu",20),b.j41(5,"a",10),b.EFF(6,"Powered by "),b.j41(7,"span",11),b.EFF(8,"ThatOpen"),b.k0s()()()}if(2&r){let e,i;const s=b.XpG(),n=b.sdS(1),o=b.r8f(3);b.Y8G("cueLogoLoader",s.isLoading())("cueContextMenu",n)("contextMenuData",b.lJ4(7,lc))("cueContextEnabled",null!==s.$hoveredElement()),b.R7$(2),b.vxM((e=o.toolbar)?2:-1,e),b.R7$(),b.vxM((i=s.$clickedElement())?3:-1,i),b.R7$(),b.vxM(o.showModelList&&s.models().length?4:-1)}}let Ag=(()=>{class r{_service=(0,st.WQX)(Zr);data=(0,Tt.hFB)(void 0);settings=(0,Tt.hFB)(new $i.R_);clickedElement=(0,Tt.CGW)();hoveredElement=(0,Tt.CGW)();selectedElements=(0,Tt.CGW)();$hoveredElement=(0,st.vPA)(null);$clickedElement=(0,st.vPA)(null);_cachedClickedElement=(0,st.vPA)(null);_modelLoading=(0,st.vPA)(!0);isLoading=(0,Ot.EW)(()=>!this.viewerReady()||this._modelLoading());models=(0,Ot.uu)(()=>this.data()?.models??[]);detailedView=(0,Ot.EW)(()=>!0===this.settings().detailedViewEnabled);toolbarStyle=(0,Ot.EW)(()=>{const e=this.settings().toolbar;return{position:"absolute",left:e.margin,right:e.margin,["top"===e.position?"top":"bottom"]:e.margin,"z-index":"10",display:"flex","justify-content":"center"}});contextMenuItems=(0,Ot.EW)(()=>{const e=[];return this.settings().showPropertiesOnClick&&(console.log("ADDING PROPERTIES MENU ITEM"),e.push({label:"Show Properties",action:()=>{this.$clickedElement.set(this._cachedClickedElement())}})),this.settings().elementClickOptions&&e.push(...this.settings().elementClickOptions),e});viewerReady=this._service.viewerReady;onClickElement=(0,st.QZP)(()=>{const e=this._service.clickedElement();e&&this._cachedClickedElement.set(e),e||this.$clickedElement.set(null),this.clickedElement.emit(e)});onHoverElement=(0,st.QZP)(()=>{this.$hoveredElement.set(this._service.hoveredElement()),this.hoveredElement.emit(this._service.hoveredElement())});onSelectionChange=(0,st.QZP)(()=>{this.selectedElements.emit(this._service.selectedElements())});set bimViewer(e){e&&this._service.init(e.nativeElement)}loadFilesOnData=(0,st.QZP)(()=>{const e=this.models();console.log(e),this.viewerReady()&&e.length&&(console.info("Loading models:",e),this._modelLoading.set(!0),this._service.updateModels(e).then(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>this._modelLoading.set(!1))})}))});setSettings=(0,st.QZP)(()=>this._service.settings.update(()=>Object.assign({},this.settings())));ngOnDestroy(){this._service.dispose()}onResized(){this._service.updateAspectRatio()}static \u0275fac=function(i){return new(i||r)};static \u0275cmp=b.VBU({type:r,selectors:[["cue-bim-fragments-viewer"]],viewQuery:function(i,s){if(1&i&&b.GBs(pg,5),2&i){let n;b.mGM(n=b.lsd())&&(s.bimViewer=n.first)}},inputs:{data:[1,"data"],settings:[1,"settings"]},outputs:{clickedElement:"clickedElement",hoveredElement:"hoveredElement",selectedElements:"selectedElements"},decls:6,vars:2,consts:[["hoveringElement",""],["bimViewer",""],["direction","row",2,"flex","1 1","height","100%"],["cueResized","","trigger","leftclick",2,"height","100%","width","100%","position","relative",3,"cueLogoLoader","cueContextMenu","contextMenuData","cueContextEnabled"],[3,"click"],["variant","primary",2,"flex","0 0 250px","min-width","0","display","flex","flex-direction","column","gap","0.5rem","padding","0.5rem"],[3,"models","draggable"],[2,"flex","1 1 0","min-width","0","min-height","0","position","relative","display","flex"],[2,"flex","1 1 0","min-width","0","display","flex"],["cueResized","","trigger","leftclick",2,"height","100%","width","100%","min-width","0","min-height","0","flex","1 1 0",3,"resized","windowResized","cueLogoLoader","cueContextMenu","contextMenuData","cueContextEnabled"],["href","https://thatopen.com","target","_blank","rel","noopener noreferrer",1,"bim-viewer-credits"],[2,"font-weight","800"],["variant","accent",2,"flex","0 0 250px","min-width","0","display","flex","flex-direction","column","gap","0.5rem","padding","0.5rem",3,"hidden"],[3,"modelsChange","models","draggable"],[3,"settings","style"],[3,"settings"],["variant","accent",2,"flex","0 0 250px","min-width","0","display","flex","flex-direction","column","gap","0.5rem","padding","0.5rem"],[2,"flex","1 1","min-height","0",3,"element","wrapInCard"],["cueResized","","trigger","leftclick",2,"height","100%","width","100%","position","relative",3,"resized","cueLogoLoader","cueContextMenu","contextMenuData","cueContextEnabled"],[1,"viewer-popup","props-popup"],[3,"models"],[3,"element"],[3,"modelsChange","models"]],template:function(i,s){1&i&&(b.DNE(0,_g,3,0,"ng-template",null,0,b.C5r),b.j41(2,"cue-flexcontainer",2),b.SS7(3),b.nVh(4,xg,12,8)(5,Eg,9,8,"div",3),b.k0s()),2&i&&(b.R7$(3),b.bH3(s.settings()),b.R7$(),b.vxM(s.detailedView()?4:5))},dependencies:[lm.C,Kr.M,Qr.D,Ri.FlexContainer,Wr.Card,am.Q,um,Sm,dg,fg.k],styles:['@import"https://fonts.googleapis.com/css2?family=Sora:wght@400;700;800&display=swap";[_nghost-%COMP%]{display:contents}.viewer-popup[_ngcontent-%COMP%]{position:absolute;z-index:100}.props-popup[_ngcontent-%COMP%]{top:8px;right:8px;bottom:8px;width:300px}.hidden[_ngcontent-%COMP%]{display:none;color:red}.bim-viewer-credits[_ngcontent-%COMP%]{position:absolute;bottom:0;left:0;font-family:Sora,sans-serif;font-size:10px;line-height:1;color:#000000bf;background:#ffffffbf;padding:2px 5px;border-radius:3px;text-decoration:none;z-index:1000;pointer-events:auto}.bim-viewer-credits[_ngcontent-%COMP%]:hover{color:#000;background:#ffffffe6}'],changeDetection:0})}return r})()},6034(Jc,vn,mt){mt.d(vn,{y:()=>Oe});var st=mt(7705),Tt=mt(7598),Ot=mt(9769),$i=mt(5187),G=mt(2271),ot=mt(5547);const p=["*"];let gs=(()=>{class Nt{style=(0,st.hFB)("");gap=(0,st.hFB)("m");columns=(0,st.hFB)(1);getStyles=(0,G.EW)(()=>`\n grid-template-columns: repeat(${this.columns()}, minmax(0, 1fr));\n gap: var(--cue-grid-gap-${this.gap()});\n ${this.style()}\n `);static \u0275fac=function(oe){return new(oe||Nt)};static \u0275cmp=ot.VBU({type:Nt,selectors:[["cue-grid"]],hostVars:2,hostBindings:function(oe,Mt){2&oe&&ot.Aen(Mt.getStyles())},inputs:{style:[1,"style"],gap:[1,"gap"],columns:[1,"columns"]},ngContentSelectors:p,decls:1,vars:0,template:function(oe,Mt){1&oe&&(ot.NAR(),ot.SdG(0))},styles:["[_nghost-%COMP%]{display:grid}"]})}return Nt})();var bn=mt(2245),$=mt(5381),ji=mt(29);const zt=["*"];function j(Nt,ze){if(1&Nt&&(ot.j41(0,"cue-typography",2),ot.EFF(1),ot.k0s()),2&Nt){const ue=ot.XpG();ot.R7$(),ot.SpI(" ",ue.label()," ")}}let Oe=(()=>{class Nt{label=(0,st.hFB)("");variant=(0,st.hFB)("default");shadow=(0,st.hFB)(!1);padded=(0,st.hFB)(!0);showCloseBtn=(0,st.hFB)(!0);position=(0,st.hFB)("top-left");clickedClose=(0,st.CGW)();margin=(0,st.hFB)("0.5rem");close(ue){ue.stopPropagation(),ue.stopImmediatePropagation(),this.clickedClose.emit()}static \u0275fac=function(oe){return new(oe||Nt)};static \u0275cmp=ot.VBU({type:Nt,selectors:[["cue-draggable-card"]],inputs:{label:[1,"label"],variant:[1,"variant"],shadow:[1,"shadow"],padded:[1,"padded"],showCloseBtn:[1,"showCloseBtn"],position:[1,"position"],margin:[1,"margin"]},outputs:{clickedClose:"clickedClose"},ngContentSelectors:zt,decls:8,vars:14,consts:[["cdkDrag","",1,"panel",3,"variant","shadow","padded"],["justify","end"],["size","l"],[2,"width","100%"],["name","close",2,"cursor","pointer",3,"click"]],template:function(oe,Mt){1&oe&&(ot.NAR(),ot.j41(0,"cue-card",0)(1,"cue-typography")(2,"cue-grid")(3,"cue-flexcontainer",1),ot.nVh(4,j,2,1,"cue-typography",2),ot.nrm(5,"span",3),ot.j41(6,"cue-svg-icon",4),ot.bIt("click",function(It){return Mt.close(It)}),ot.k0s()(),ot.SdG(7),ot.k0s()()()),2&oe&&(ot.xc7("top","top-left"===Mt.position()||"top-right"===Mt.position()?Mt.margin():"null")("bottom","bottom-left"===Mt.position()||"bottom-right"===Mt.position()?Mt.margin():"null")("left","top-left"===Mt.position()||"bottom-left"===Mt.position()?Mt.margin():"null")("right","top-right"===Mt.position()||"bottom-right"===Mt.position()?Mt.margin():"null"),ot.Y8G("variant",Mt.variant())("shadow",Mt.shadow())("padded",Mt.padded()),ot.R7$(3),ot.xc7("padding",Mt.padded()?"0":"10px"),ot.R7$(),ot.vxM(Mt.label()&&"undefined"!==Mt.label()?4:-1))},dependencies:[Ot.MD,$i.Card,gs,bn.Typography,$.FlexContainer,ji.A,Tt.T1],styles:[".panel[_ngcontent-%COMP%]{position:absolute;width:fit-content;z-index:100}"]})}return Nt})()}}]);