@qaecy/cue-ui 0.0.44 → 0.0.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/149.js +1 -0
- package/153.js +1 -1
- package/245.js +1 -0
- package/311.js +1 -1
- package/336.js +1 -1
- package/36.js +1 -1
- package/393.js +1 -1
- package/399.js +1 -1
- package/4.js +1 -1
- package/41.js +1 -1
- package/418.js +1 -1
- package/419.js +1 -1
- package/423.js +1 -1
- package/560.js +1 -1
- package/598.js +1 -1
- package/613.js +1 -1
- package/673.js +1 -1
- package/7.js +1 -1
- package/719.js +1 -1
- package/724.js +1 -1
- package/799.js +1 -0
- package/802.js +1 -1
- package/836.js +1 -1
- package/872.js +1 -1
- package/879.js +1 -1
- package/882.js +1 -1
- package/911.js +1 -1
- package/928.js +1 -1
- package/931.js +1 -0
- package/981.js +1 -1
- package/common.js +1 -1
- package/index.js +1 -1
- package/main.js +1 -1
- package/package.json +1 -1
- package/187.js +0 -1
- package/189.js +0 -1
- package/29.js +0 -1
- package/319.js +0 -1
- package/448.js +0 -1
- package/629.js +0 -1
- package/89.js +0 -1
- package/971.js +0 -1
package/419.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[419],{6419(vh,Co,mt){mt.d(Co,{BIMFragmentsViewer:()=>mh});var st=mt(5802),vt=mt(7705),St=mt(2271),rs=mt(8807),H=mt(467),ft=mt(8158),b=mt(4701),os=(mt(3973),mt(2085));const V=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 Ce(o){return o.isPerspectiveCamera}function pe(o){return o.isOrthographicCamera}const me=2*Math.PI,bn=Math.PI/2,Ge=Math.PI/180;function ie(o,e,t){return Math.max(e,Math.min(t,o))}function xt(o,e=1e-5){return Math.abs(o)<e}function yt(o,e,t=1e-5){return xt(o-e,t)}function Cn(o,e){return Math.round(o/e)*e}function Xe(o){return isFinite(o)?o:o<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Qe(o){return Math.abs(o)<Number.MAX_VALUE?o:o*(1/0)}function wi(o,e,t,i,s=1/0,n){const r=2/(i=Math.max(1e-4,i)),a=r*n,l=1/(1+a+.48*a*a+.235*a*a*a);let c=o-e;const u=e,h=s*i;c=ie(c,-h,h),e=o-c;const f=(t.value+r*c)*n;t.value=(t.value-r*f)*l;let d=e+(c+f)*l;return u-o>0==d>u&&(d=u,t.value=(d-u)/n),d}function Tn(o,e,t,i,s=1/0,n,r){const a=2/(i=Math.max(1e-4,i)),l=a*n,c=1/(1+l+.48*l*l+.235*l*l*l);let u=e.x,h=e.y,f=e.z,d=o.x-u,y=o.y-h,g=o.z-f;const _=u,p=h,x=f,E=s*i,A=d*d+y*y+g*g;if(A>E*E){const R=Math.sqrt(A);d=d/R*E,y=y/R*E,g=g/R*E}u=o.x-d,h=o.y-y,f=o.z-g;const M=(t.x+a*d)*n,S=(t.y+a*y)*n,z=(t.z+a*g)*n;return t.x=(t.x-a*M)*c,t.y=(t.y-a*S)*c,t.z=(t.z-a*z)*c,r.x=u+(d+M)*c,r.y=h+(y+S)*c,r.z=f+(g+z)*c,(_-o.x)*(r.x-_)+(p-o.y)*(r.y-p)+(x-o.z)*(r.z-x)>0&&(r.x=_,r.y=p,r.z=x,t.x=(r.x-_)/n,t.y=(r.y-p)/n,t.z=(r.z-x)/n),r}function as(o,e){e.set(0,0),o.forEach(t=>{e.x+=t.clientX,e.y+=t.clientY}),e.x/=o.length,e.y/=o.length}function ls(o,e){return!!pe(o)&&(console.warn(`${e} is not supported in OrthographicCamera`),!0)}class To{_listeners={};addEventListener(e,t){const i=this._listeners;void 0===i[e]&&(i[e]=[]),-1===i[e].indexOf(t)&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return void 0!==i[e]&&-1!==i[e].indexOf(t)}removeEventListener(e,t){const s=this._listeners[e];if(void 0!==s){const n=s.indexOf(t);-1!==n&&s.splice(n,1)}}removeAllEventListeners(e){e?Array.isArray(this._listeners[e])&&(this._listeners[e].length=0):this._listeners={}}dispatchEvent(e){const i=this._listeners[e.type];if(void 0!==i){e.target=this;const s=i.slice(0);for(let n=0,r=s.length;n<r;n++)s[n].call(this,e)}}}const bi=1/8,Ao=/Mac/.test(globalThis?.navigator?.platform);let lt,En,xi,cs,Ht,ut,gt,Oe,Ke,re,oe,Te,An,Pn,Wt,ke,ze,Sn,us,In,hs,ds,Ci;class Bt extends To{static install(e){lt=e.THREE,En=Object.freeze(new lt.Vector3(0,0,0)),xi=Object.freeze(new lt.Vector3(0,1,0)),cs=Object.freeze(new lt.Vector3(0,0,1)),Ht=new lt.Vector2,ut=new lt.Vector3,gt=new lt.Vector3,Oe=new lt.Vector3,Ke=new lt.Vector3,re=new lt.Vector3,oe=new lt.Vector3,Te=new lt.Vector3,An=new lt.Vector3,Pn=new lt.Vector3,Wt=new lt.Spherical,ke=new lt.Spherical,ze=new lt.Box3,Sn=new lt.Box3,us=new lt.Sphere,In=new lt.Quaternion,hs=new lt.Quaternion,ds=new lt.Matrix4,Ci=new lt.Raycaster}static get ACTION(){return V}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=V.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 lt.Vector3;_focalOffsetVelocity=new lt.Vector3;_zoomVelocity={value:0};set verticalDragToForward(e){console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.")}constructor(e,t){super(),typeof lt>"u"&&console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."),this._camera=e,this._yAxisUpSpace=(new lt.Quaternion).setFromUnitVectors(this._camera.up,xi),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=V.NONE,this._target=new lt.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new lt.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new lt.Spherical).setFromVector3(ut.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 lt.Vector3,new lt.Vector3,new lt.Vector3,new lt.Vector3],this._updateNearPlaneCorners(),this._boundary=new lt.Box3(new lt.Vector3(-1/0,-1/0,-1/0),new lt.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 lt.Vector2,this.mouseButtons={left:V.ROTATE,middle:V.DOLLY,right:V.TRUCK,wheel:Ce(this._camera)?V.DOLLY:pe(this._camera)?V.ZOOM:V.NONE},this.touches={one:V.TOUCH_ROTATE,two:Ce(this._camera)?V.TOUCH_DOLLY_TRUCK:pe(this._camera)?V.TOUCH_ZOOM_TRUCK:V.NONE,three:V.TOUCH_TRUCK};const i=new lt.Vector2,s=new lt.Vector2,n=new lt.Vector2,r=p=>{if(!this._enabled||!this._domElement)return;if(0!==this._interactiveArea.left||0!==this._interactiveArea.top||1!==this._interactiveArea.width||1!==this._interactiveArea.height){const T=this._domElement.getBoundingClientRect(),A=p.clientX/T.width,M=p.clientY/T.height;if(A<this._interactiveArea.left||A>this._interactiveArea.right||M<this._interactiveArea.top||M>this._interactiveArea.bottom)return}const x="mouse"!==p.pointerType?null:1&~p.buttons?4&~p.buttons?2&~p.buttons?null:2:4:1;if(null!==x){const T=this._findPointerByMouseButton(x);T&&this._disposePointer(T)}(1&~p.buttons||!this._lockedPointer)&&(this._activePointers.push({pointerId:p.pointerId,clientX:p.clientX,clientY:p.clientY,deltaX:0,deltaY:0,mouseButton:x}),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(p))},a=p=>{p.cancelable&&p.preventDefault();const E=this._lockedPointer||this._findPointerById(p.pointerId);if(E){if(E.clientX=p.clientX,E.clientY=p.clientY,E.deltaX=p.movementX,E.deltaY=p.movementY,this._state=0,"touch"===p.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&~p.buttons))&&(this._state=this._state|this.mouseButtons.left),this._isDragging&&!(4&~p.buttons)&&(this._state=this._state|this.mouseButtons.middle),this._isDragging&&!(2&~p.buttons)&&(this._state=this._state|this.mouseButtons.right);d()}},l=p=>{const x=this._findPointerById(p.pointerId);if(!x||x!==this._lockedPointer){if(x&&this._disposePointer(x),"touch"===p.pointerType)switch(this._activePointers.length){case 0:this._state=V.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=V.NONE;y()}};let c=-1;const u=p=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===V.NONE)return;if(0!==this._interactiveArea.left||0!==this._interactiveArea.top||1!==this._interactiveArea.width||1!==this._interactiveArea.height){const S=this._domElement.getBoundingClientRect(),z=p.clientX/S.width,O=p.clientY/S.height;if(z<this._interactiveArea.left||z>this._interactiveArea.right||O<this._interactiveArea.top||O>this._interactiveArea.bottom)return}if(p.preventDefault(),this.dollyToCursor||this.mouseButtons.wheel===V.ROTATE||this.mouseButtons.wheel===V.TRUCK){const S=performance.now();c-S<1e3&&this._getClientRect(this._elementRect),c=S}const x=Ao?-1:-3,E=1!==p.deltaMode||p.ctrlKey?p.deltaY/(10*x):p.deltaY/x,T=this.dollyToCursor?(p.clientX-this._elementRect.x)/this._elementRect.width*2-1:0,A=this.dollyToCursor?(p.clientY-this._elementRect.y)/this._elementRect.height*-2+1:0;switch(p.ctrlKey?V.ZOOM:this.mouseButtons.wheel){case V.ROTATE:this._rotateInternal(p.deltaX,p.deltaY),this._isUserControllingRotate=!0;break;case V.TRUCK:this._truckInternal(p.deltaX,p.deltaY,!1,!1),this._isUserControllingTruck=!0;break;case V.SCREEN_PAN:this._truckInternal(p.deltaX,p.deltaY,!1,!0),this._isUserControllingTruck=!0;break;case V.OFFSET:this._truckInternal(p.deltaX,p.deltaY,!0,!1),this._isUserControllingOffset=!0;break;case V.DOLLY:this._dollyInternal(-E,T,A),this._isUserControllingDolly=!0;break;case V.ZOOM:this._zoomInternal(-E,T,A),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},h=p=>{if(this._domElement&&this._enabled){if(this.mouseButtons.right===Bt.ACTION.NONE){const x=p instanceof PointerEvent?p.pointerId:0,E=this._findPointerById(x);return E&&this._disposePointer(E),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),void this._domElement.ownerDocument.removeEventListener("pointerup",l)}p.preventDefault()}},f=p=>{if(this._enabled){if(as(this._activePointers,Ht),this._getClientRect(this._elementRect),i.copy(Ht),s.copy(Ht),this._activePointers.length>=2){const E=Ht.x-this._activePointers[1].clientX,T=Ht.y-this._activePointers[1].clientY,A=Math.sqrt(E*E+T*T);n.set(0,A),s.set(.5*(this._activePointers[0].clientX+this._activePointers[1].clientX),.5*(this._activePointers[0].clientY+this._activePointers[1].clientY))}if(this._state=0,p)if("pointerType"in p&&"touch"===p.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&~p.buttons)&&(this._state=this._state|this.mouseButtons.left),!(4&~p.buttons)&&(this._state=this._state|this.mouseButtons.middle),!(2&~p.buttons)&&(this._state=this._state|this.mouseButtons.right);else this._lockedPointer&&(this._state=this._state|this.mouseButtons.left);((this._state&V.ROTATE)===V.ROTATE||(this._state&V.TOUCH_ROTATE)===V.TOUCH_ROTATE||(this._state&V.TOUCH_DOLLY_ROTATE)===V.TOUCH_DOLLY_ROTATE||(this._state&V.TOUCH_ZOOM_ROTATE)===V.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&V.TRUCK)===V.TRUCK||(this._state&V.SCREEN_PAN)===V.SCREEN_PAN||(this._state&V.TOUCH_TRUCK)===V.TOUCH_TRUCK||(this._state&V.TOUCH_SCREEN_PAN)===V.TOUCH_SCREEN_PAN||(this._state&V.TOUCH_DOLLY_TRUCK)===V.TOUCH_DOLLY_TRUCK||(this._state&V.TOUCH_DOLLY_SCREEN_PAN)===V.TOUCH_DOLLY_SCREEN_PAN||(this._state&V.TOUCH_ZOOM_TRUCK)===V.TOUCH_ZOOM_TRUCK||(this._state&V.TOUCH_ZOOM_SCREEN_PAN)===V.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&V.DOLLY)===V.DOLLY||(this._state&V.TOUCH_DOLLY)===V.TOUCH_DOLLY||(this._state&V.TOUCH_DOLLY_TRUCK)===V.TOUCH_DOLLY_TRUCK||(this._state&V.TOUCH_DOLLY_SCREEN_PAN)===V.TOUCH_DOLLY_SCREEN_PAN||(this._state&V.TOUCH_DOLLY_OFFSET)===V.TOUCH_DOLLY_OFFSET||(this._state&V.TOUCH_DOLLY_ROTATE)===V.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&V.ZOOM)===V.ZOOM||(this._state&V.TOUCH_ZOOM)===V.TOUCH_ZOOM||(this._state&V.TOUCH_ZOOM_TRUCK)===V.TOUCH_ZOOM_TRUCK||(this._state&V.TOUCH_ZOOM_SCREEN_PAN)===V.TOUCH_ZOOM_SCREEN_PAN||(this._state&V.TOUCH_ZOOM_OFFSET)===V.TOUCH_ZOOM_OFFSET||(this._state&V.TOUCH_ZOOM_ROTATE)===V.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&V.OFFSET)===V.OFFSET||(this._state&V.TOUCH_OFFSET)===V.TOUCH_OFFSET||(this._state&V.TOUCH_DOLLY_OFFSET)===V.TOUCH_DOLLY_OFFSET||(this._state&V.TOUCH_ZOOM_OFFSET)===V.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,as(this._activePointers,Ht);const x=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,E=x?-x.deltaX:s.x-Ht.x,T=x?-x.deltaY:s.y-Ht.y;if(s.copy(Ht),((this._state&V.ROTATE)===V.ROTATE||(this._state&V.TOUCH_ROTATE)===V.TOUCH_ROTATE||(this._state&V.TOUCH_DOLLY_ROTATE)===V.TOUCH_DOLLY_ROTATE||(this._state&V.TOUCH_ZOOM_ROTATE)===V.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(E,T),this._isUserControllingRotate=!0),(this._state&V.DOLLY)===V.DOLLY||(this._state&V.ZOOM)===V.ZOOM){const A=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,S=this.dollyDragInverted?-1:1;(this._state&V.DOLLY)===V.DOLLY?(this._dollyInternal(S*T*bi,A,M),this._isUserControllingDolly=!0):(this._zoomInternal(S*T*bi,A,M),this._isUserControllingZoom=!0)}if((this._state&V.TOUCH_DOLLY)===V.TOUCH_DOLLY||(this._state&V.TOUCH_ZOOM)===V.TOUCH_ZOOM||(this._state&V.TOUCH_DOLLY_TRUCK)===V.TOUCH_DOLLY_TRUCK||(this._state&V.TOUCH_ZOOM_TRUCK)===V.TOUCH_ZOOM_TRUCK||(this._state&V.TOUCH_DOLLY_SCREEN_PAN)===V.TOUCH_DOLLY_SCREEN_PAN||(this._state&V.TOUCH_ZOOM_SCREEN_PAN)===V.TOUCH_ZOOM_SCREEN_PAN||(this._state&V.TOUCH_DOLLY_OFFSET)===V.TOUCH_DOLLY_OFFSET||(this._state&V.TOUCH_ZOOM_OFFSET)===V.TOUCH_ZOOM_OFFSET||(this._state&V.TOUCH_DOLLY_ROTATE)===V.TOUCH_DOLLY_ROTATE||(this._state&V.TOUCH_ZOOM_ROTATE)===V.TOUCH_ZOOM_ROTATE){const A=Ht.x-this._activePointers[1].clientX,M=Ht.y-this._activePointers[1].clientY,S=Math.sqrt(A*A+M*M),z=n.y-S;n.set(0,S);const O=this.dollyToCursor?(s.x-this._elementRect.x)/this._elementRect.width*2-1:0,N=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&V.TOUCH_DOLLY)===V.TOUCH_DOLLY||(this._state&V.TOUCH_DOLLY_ROTATE)===V.TOUCH_DOLLY_ROTATE||(this._state&V.TOUCH_DOLLY_TRUCK)===V.TOUCH_DOLLY_TRUCK||(this._state&V.TOUCH_DOLLY_SCREEN_PAN)===V.TOUCH_DOLLY_SCREEN_PAN||(this._state&V.TOUCH_DOLLY_OFFSET)===V.TOUCH_DOLLY_OFFSET?(this._dollyInternal(z*bi,O,N),this._isUserControllingDolly=!0):(this._zoomInternal(z*bi,O,N),this._isUserControllingZoom=!0)}((this._state&V.TRUCK)===V.TRUCK||(this._state&V.TOUCH_TRUCK)===V.TOUCH_TRUCK||(this._state&V.TOUCH_DOLLY_TRUCK)===V.TOUCH_DOLLY_TRUCK||(this._state&V.TOUCH_ZOOM_TRUCK)===V.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(E,T,!1,!1),this._isUserControllingTruck=!0),((this._state&V.SCREEN_PAN)===V.SCREEN_PAN||(this._state&V.TOUCH_SCREEN_PAN)===V.TOUCH_SCREEN_PAN||(this._state&V.TOUCH_DOLLY_SCREEN_PAN)===V.TOUCH_DOLLY_SCREEN_PAN||(this._state&V.TOUCH_ZOOM_SCREEN_PAN)===V.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(E,T,!1,!0),this._isUserControllingTruck=!0),((this._state&V.OFFSET)===V.OFFSET||(this._state&V.TOUCH_OFFSET)===V.TOUCH_OFFSET||(this._state&V.TOUCH_DOLLY_OFFSET)===V.TOUCH_DOLLY_OFFSET||(this._state&V.TOUCH_ZOOM_OFFSET)===V.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(E,T,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},y=()=>{as(this._activePointers,Ht),s.copy(Ht),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",g),this._domElement.ownerDocument.addEventListener("pointerlockerror",_),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",g),this._domElement?.ownerDocument.removeEventListener("pointerlockerror",_),this.cancel()};const g=()=>{this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement||this.unlockPointer()},_=()=>{this.unlockPointer()};this._addAllEventListeners=p=>{this._domElement=p,this._domElement.style.touchAction="none",this._domElement.style.userSelect="none",this._domElement.style.webkitUserSelect="none",this._domElement.addEventListener("pointerdown",r),this._domElement.addEventListener("pointercancel",l),this._domElement.addEventListener("wheel",u,{passive:!1}),this._domElement.addEventListener("contextmenu",h)},this._removeAllEventListeners=()=>{this._domElement&&(this._domElement.style.touchAction="",this._domElement.style.userSelect="",this._domElement.style.webkitUserSelect="",this._domElement.removeEventListener("pointerdown",r),this._domElement.removeEventListener("pointercancel",l),this._domElement.removeEventListener("wheel",u,{passive:!1}),this._domElement.removeEventListener("contextmenu",h),this._domElement.ownerDocument.removeEventListener("pointermove",a,{passive:!1}),this._domElement.ownerDocument.removeEventListener("pointerup",l),this._domElement.ownerDocument.removeEventListener("pointerlockchange",g),this._domElement.ownerDocument.removeEventListener("pointerlockerror",_))},this.cancel=()=>{this._state!==V.NONE&&(this._state=V.NONE,this._activePointers.length=0,y())},t&&this.connect(t),this.update(0)}get camera(){return this._camera}set camera(e){this._camera=e,this.updateCameraUp(),this._camera.updateProjectionMatrix(),this._updateNearPlaneCorners(),this._needsUpdate=!0}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this._domElement&&(e?(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(e){this._spherical.radius===e&&this._sphericalEnd.radius===e||(this._spherical.radius=e,this._sphericalEnd.radius=e,this._needsUpdate=!0)}get azimuthAngle(){return this._spherical.theta}set azimuthAngle(e){this._spherical.theta===e&&this._sphericalEnd.theta===e||(this._spherical.theta=e,this._sphericalEnd.theta=e,this._needsUpdate=!0)}get polarAngle(){return this._spherical.phi}set polarAngle(e){this._spherical.phi===e&&this._sphericalEnd.phi===e||(this._spherical.phi=e,this._sphericalEnd.phi=e,this._needsUpdate=!0)}get boundaryEnclosesCamera(){return this._boundaryEnclosesCamera}set boundaryEnclosesCamera(e){this._boundaryEnclosesCamera=e,this._needsUpdate=!0}set interactiveArea(e){this._interactiveArea.width=ie(e.width,0,1),this._interactiveArea.height=ie(e.height,0,1),this._interactiveArea.x=ie(e.x,0,1-this._interactiveArea.width),this._interactiveArea.y=ie(e.y,0,1-this._interactiveArea.height)}addEventListener(e,t){super.addEventListener(e,t)}removeEventListener(e,t){super.removeEventListener(e,t)}rotate(e,t,i=!1){return this.rotateTo(this._sphericalEnd.theta+e,this._sphericalEnd.phi+t,i)}rotateAzimuthTo(e,t=!1){return this.rotateTo(e,this._sphericalEnd.phi,t)}rotatePolarTo(e,t=!1){return this.rotateTo(this._sphericalEnd.theta,e,t)}rotateTo(e,t,i=!1){this._isUserControllingRotate=!1;const s=ie(e,this.minAzimuthAngle,this.maxAzimuthAngle),n=ie(t,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 r=!i||yt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&yt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold);return this._createOnRestPromise(r)}dolly(e,t=!1){return this.dollyTo(this._sphericalEnd.radius-e,t)}dollyTo(e,t=!1){return this._isUserControllingDolly=!1,this._lastDollyDirection=0,this._changedDolly=0,this._dollyToNoClamp(ie(e,this.minDistance,this.maxDistance),t)}_dollyToNoClamp(e,t=!1){const i=this._sphericalEnd.radius;if(this.colliderMeshes.length>=1){const r=this._collisionTest(),a=yt(r,this._spherical.radius);if(!(i>e)&&a)return Promise.resolve();this._sphericalEnd.radius=Math.min(e,r)}else this._sphericalEnd.radius=e;this._needsUpdate=!0,t||(this._spherical.radius=this._sphericalEnd.radius);const n=!t||yt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(n)}dollyInFixed(e,t=!1){this._targetEnd.add(this._getCameraDirection(Ke).multiplyScalar(e)),t||this._target.copy(this._targetEnd);const i=!t||yt(this._target.x,this._targetEnd.x,this.restThreshold)&&yt(this._target.y,this._targetEnd.y,this.restThreshold)&&yt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(i)}zoom(e,t=!1){return this.zoomTo(this._zoomEnd+e,t)}zoomTo(e,t=!1){this._isUserControllingZoom=!1,this._zoomEnd=ie(e,this.minZoom,this.maxZoom),this._needsUpdate=!0,t||(this._zoom=this._zoomEnd);const i=!t||yt(this._zoom,this._zoomEnd,this.restThreshold);return this._changedZoom=0,this._createOnRestPromise(i)}pan(e,t,i=!1){return console.warn("`pan` has been renamed to `truck`"),this.truck(e,t,i)}truck(e,t,i=!1){this._camera.updateMatrix(),re.setFromMatrixColumn(this._camera.matrix,0),oe.setFromMatrixColumn(this._camera.matrix,1),re.multiplyScalar(e),oe.multiplyScalar(-t);const s=ut.copy(re).add(oe),n=gt.copy(this._targetEnd).add(s);return this.moveTo(n.x,n.y,n.z,i)}forward(e,t=!1){ut.setFromMatrixColumn(this._camera.matrix,0),ut.crossVectors(this._camera.up,ut),ut.multiplyScalar(e);const i=gt.copy(this._targetEnd).add(ut);return this.moveTo(i.x,i.y,i.z,t)}elevate(e,t=!1){return ut.copy(this._camera.up).multiplyScalar(e),this.moveTo(this._targetEnd.x+ut.x,this._targetEnd.y+ut.y,this._targetEnd.z+ut.z,t)}moveTo(e,t,i,s=!1){this._isUserControllingTruck=!1;const n=ut.set(e,t,i).sub(this._targetEnd);this._encloseToBoundary(this._targetEnd,n,this.boundaryFriction),this._needsUpdate=!0,s||this._target.copy(this._targetEnd);const r=!s||yt(this._target.x,this._targetEnd.x,this.restThreshold)&&yt(this._target.y,this._targetEnd.y,this.restThreshold)&&yt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(r)}lookInDirectionOf(e,t,i,s=!1){const a=ut.set(e,t,i).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);return this.setPosition(a.x,a.y,a.z,s)}fitToBox(e,t,{cover:i=!1,paddingLeft:s=0,paddingRight:n=0,paddingBottom:r=0,paddingTop:a=0}={}){const l=[],c=e.isBox3?ze.copy(e):ze.setFromObject(e);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const u=Cn(this._sphericalEnd.theta,bn),h=Cn(this._sphericalEnd.phi,bn);l.push(this.rotateTo(u,h,t));const f=ut.setFromSpherical(this._sphericalEnd).normalize(),d=In.setFromUnitVectors(f,cs),y=yt(Math.abs(f.y),1);y&&d.multiply(hs.setFromAxisAngle(xi,u)),d.multiply(this._yAxisUpSpaceInverse);const g=Sn.makeEmpty();gt.copy(c.min).applyQuaternion(d),g.expandByPoint(gt),gt.copy(c.min).setX(c.max.x).applyQuaternion(d),g.expandByPoint(gt),gt.copy(c.min).setY(c.max.y).applyQuaternion(d),g.expandByPoint(gt),gt.copy(c.max).setZ(c.min.z).applyQuaternion(d),g.expandByPoint(gt),gt.copy(c.min).setZ(c.max.z).applyQuaternion(d),g.expandByPoint(gt),gt.copy(c.max).setY(c.min.y).applyQuaternion(d),g.expandByPoint(gt),gt.copy(c.max).setX(c.min.x).applyQuaternion(d),g.expandByPoint(gt),gt.copy(c.max).applyQuaternion(d),g.expandByPoint(gt),g.min.x-=s,g.min.y-=r,g.max.x+=n,g.max.y+=a,d.setFromUnitVectors(cs,f),y&&d.premultiply(hs.invert()),d.premultiply(this._yAxisUpSpace);const _=g.getSize(ut),p=g.getCenter(gt).applyQuaternion(d);if(Ce(this._camera)){const x=this.getDistanceToFitBox(_.x,_.y,_.z,i);l.push(this.moveTo(p.x,p.y,p.z,t)),l.push(this.dollyTo(x,t)),l.push(this.setFocalOffset(0,0,0,t))}else if(pe(this._camera)){const x=this._camera,E=x.right-x.left,T=x.top-x.bottom,A=i?Math.max(E/_.x,T/_.y):Math.min(E/_.x,T/_.y);l.push(this.moveTo(p.x,p.y,p.z,t)),l.push(this.zoomTo(A,t)),l.push(this.setFocalOffset(0,0,0,t))}return Promise.all(l)}fitToSphere(e,t){const i=[],n="isObject3D"in e?Bt.createBoundingSphere(e,us):us.copy(e);if(i.push(this.moveTo(n.center.x,n.center.y,n.center.z,t)),Ce(this._camera)){const r=this.getDistanceToFitSphere(n.radius);i.push(this.dollyTo(r,t))}else if(pe(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,t))}return i.push(this.setFocalOffset(0,0,0,t)),Promise.all(i)}setLookAt(e,t,i,s,n,r,a=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=0,this._changedDolly=0;const l=gt.set(s,n,r),c=ut.set(e,t,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 u=!a||yt(this._target.x,this._targetEnd.x,this.restThreshold)&&yt(this._target.y,this._targetEnd.y,this.restThreshold)&&yt(this._target.z,this._targetEnd.z,this.restThreshold)&&yt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&yt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&yt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerp(e,t,i,s=!1){this._isUserControllingRotate=!1,this._isUserControllingDolly=!1,this._isUserControllingTruck=!1,this._lastDollyDirection=0,this._changedDolly=0;const n=ut.set(...e.target);if("spherical"in e)Wt.set(...e.spherical);else{const h=gt.set(...e.position);Wt.setFromVector3(h.sub(n).applyQuaternion(this._yAxisUpSpace))}const r=Oe.set(...t.target);if("spherical"in t)ke.set(...t.spherical);else{const h=gt.set(...t.position);ke.setFromVector3(h.sub(r).applyQuaternion(this._yAxisUpSpace))}this._targetEnd.copy(n.lerp(r,i)),this._sphericalEnd.set(Wt.radius+(ke.radius-Wt.radius)*i,Wt.phi+(ke.phi-Wt.phi)*i,Wt.theta+(ke.theta-Wt.theta)*i),this._needsUpdate=!0,s||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const u=!s||yt(this._target.x,this._targetEnd.x,this.restThreshold)&&yt(this._target.y,this._targetEnd.y,this.restThreshold)&&yt(this._target.z,this._targetEnd.z,this.restThreshold)&&yt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&yt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&yt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(u)}lerpLookAt(e,t,i,s,n,r,a,l,c,u,h,f,d,y=!1){return this.lerp({position:[e,t,i],target:[s,n,r]},{position:[a,l,c],target:[u,h,f]},d,y)}setPosition(e,t,i,s=!1){return this.setLookAt(e,t,i,this._targetEnd.x,this._targetEnd.y,this._targetEnd.z,s)}setTarget(e,t,i,s=!1){const n=this.getPosition(ut),r=this.setLookAt(n.x,n.y,n.z,e,t,i,s);return this._sphericalEnd.phi=ie(this._sphericalEnd.phi,this.minPolarAngle,this.maxPolarAngle),r}setFocalOffset(e,t,i,s=!1){this._isUserControllingOffset=!1,this._focalOffsetEnd.set(e,t,i),this._needsUpdate=!0,s||this._focalOffset.copy(this._focalOffsetEnd);const n=!s||yt(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&yt(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&yt(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}setOrbitPoint(e,t,i){this._camera.updateMatrixWorld(),re.setFromMatrixColumn(this._camera.matrixWorldInverse,0),oe.setFromMatrixColumn(this._camera.matrixWorldInverse,1),Te.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=ut.set(e,t,i),n=s.distanceTo(this._camera.position),r=s.sub(this._camera.position);re.multiplyScalar(r.x),oe.multiplyScalar(r.y),Te.multiplyScalar(r.z),ut.copy(re).add(oe).add(Te),ut.z=ut.z+n,this.dollyTo(n,!1),this.setFocalOffset(-ut.x,ut.y,-ut.z,!1),this.moveTo(e,t,i,!1)}setBoundary(e){if(!e)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(e),this._boundary.clampPoint(this._targetEnd,this._targetEnd),this._needsUpdate=!0}setViewport(e,t,i,s){null!==e?(this._viewport=this._viewport||new lt.Vector4,"number"==typeof e?this._viewport.set(e,t,i,s):this._viewport.copy(e)):this._viewport=null}getDistanceToFitBox(e,t,i,s=!1){if(ls(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const n=e/t,r=this._camera.getEffectiveFOV()*Ge,a=this._camera.aspect;return.5*((s?n>a:n<a)?t:e/a)/Math.tan(.5*r)+.5*i}getDistanceToFitSphere(e){if(ls(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const t=this._camera.getEffectiveFOV()*Ge,i=2*Math.atan(Math.tan(.5*t)*this._camera.aspect);return e/Math.sin(.5*(1<this._camera.aspect?t:i))}getTarget(e,t=!0){return(e&&e.isVector3?e:new lt.Vector3).copy(t?this._targetEnd:this._target)}getPosition(e,t=!0){return(e&&e.isVector3?e:new lt.Vector3).setFromSpherical(t?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t?this._targetEnd:this._target)}getSpherical(e,t=!0){return(e||new lt.Spherical).copy(t?this._sphericalEnd:this._spherical)}getFocalOffset(e,t=!0){return(e&&e.isVector3?e:new lt.Vector3).copy(t?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){return this._sphericalEnd.theta=(this._sphericalEnd.theta%me+me)%me,this._sphericalEnd.theta>Math.PI&&(this._sphericalEnd.theta-=me),this._spherical.theta+=me*Math.round((this._sphericalEnd.theta-this._spherical.theta)/me),this}stop(){this._focalOffset.copy(this._focalOffsetEnd),this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd),this._zoom=this._zoomEnd}reset(e=!1){if(!yt(this._camera.up.x,this._cameraUp0.x)||!yt(this._camera.up.y,this._cameraUp0.y)||!yt(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const i=this.getPosition(ut);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}const t=[this.setLookAt(this._position0.x,this._position0.y,this._position0.z,this._target0.x,this._target0.y,this._target0.z,e),this.setFocalOffset(this._focalOffset0.x,this._focalOffset0.y,this._focalOffset0.z,e),this.zoomTo(this._zoom0,e)];return Promise.all(t)}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,xi),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const e=ut.subVectors(this._target,this._camera.position).normalize(),t=gt.crossVectors(e,this._camera.up);this._camera.up.crossVectors(t,e).normalize(),this._camera.updateMatrixWorld();const i=this.getPosition(ut);this.updateCameraUp(),this.setPosition(i.x,i.y,i.z)}update(e){const t=this._sphericalEnd.theta-this._spherical.theta,i=this._sphericalEnd.phi-this._spherical.phi,s=this._sphericalEnd.radius-this._spherical.radius,n=An.subVectors(this._targetEnd,this._target),r=Pn.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(xt(t)?(this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta):(this._spherical.theta=wi(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime,1/0,e),this._needsUpdate=!0),xt(i)?(this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi):(this._spherical.phi=wi(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime,1/0,e),this._needsUpdate=!0),xt(s)?(this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius):(this._spherical.radius=wi(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,e),this._needsUpdate=!0),xt(n.x)&&xt(n.y)&&xt(n.z)?(this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd)):(Tn(this._target,this._targetEnd,this._targetVelocity,this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,e,this._target),this._needsUpdate=!0),xt(r.x)&&xt(r.y)&&xt(r.z)?(this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd)):(Tn(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,e,this._focalOffset),this._needsUpdate=!0),xt(a)?(this._zoomVelocity.value=0,this._zoom=this._zoomEnd):this._zoom=wi(this._zoom,this._zoomEnd,this._zoomVelocity,this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime,1/0,e),this.dollyToCursor)if(Ce(this._camera)&&0!==this._changedDolly){const h=this._spherical.radius-this._lastDistance,f=this._camera,d=this._getCameraDirection(Ke),y=ut.copy(d).cross(f.up).normalize();0===y.lengthSq()&&(y.x=1);const g=gt.crossVectors(y,d),_=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*Ge*.5),x=(this._sphericalEnd.radius-h-this._sphericalEnd.radius)/this._sphericalEnd.radius,E=Oe.copy(this._targetEnd).add(y.multiplyScalar(this._dollyControlCoord.x*_*f.aspect)).add(g.multiplyScalar(this._dollyControlCoord.y*_)),T=ut.copy(this._targetEnd).lerp(E,x);if(this.infinityDolly&&(1===this._lastDollyDirection&&this._spherical.radius<=this.minDistance||-1===this._lastDollyDirection&&this.maxDistance<=this._spherical.radius)){this._sphericalEnd.radius-=h,this._spherical.radius-=h;const z=gt.copy(d).multiplyScalar(-h);T.add(z)}this._boundary.clampPoint(T,T);const S=gt.subVectors(T,this._targetEnd);this._targetEnd.copy(T),this._target.add(S),this._changedDolly-=h,xt(this._changedDolly)&&(this._changedDolly=0)}else if(pe(this._camera)&&0!==this._changedZoom){const h=this._zoom-this._lastZoom,f=this._camera,d=ut.set(this._dollyControlCoord.x,this._dollyControlCoord.y,(f.near+f.far)/(f.near-f.far)).unproject(f),y=gt.set(0,0,-1).applyQuaternion(f.quaternion),g=Oe.copy(d).add(y.multiplyScalar(-d.dot(f.up))),p=-(this._zoom-h-this._zoom)/this._zoom,x=this._getCameraDirection(Ke),E=this._targetEnd.dot(x),T=ut.copy(this._targetEnd).lerp(g,p),A=T.dot(x),M=x.multiplyScalar(A-E);T.sub(M),this._boundary.clampPoint(T,T);const S=gt.subVectors(T,this._targetEnd);this._targetEnd.copy(T),this._target.add(S),this._changedZoom-=h,xt(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),(!xt(this._focalOffset.x)||!xt(this._focalOffset.y)||!xt(this._focalOffset.z))&&(this._camera.matrix.compose(this._camera.position,this._camera.quaternion,this._camera.scale),re.setFromMatrixColumn(this._camera.matrix,0),oe.setFromMatrixColumn(this._camera.matrix,1),Te.setFromMatrixColumn(this._camera.matrix,2),re.multiplyScalar(this._focalOffset.x),oe.multiplyScalar(-this._focalOffset.y),Te.multiplyScalar(this._focalOffset.z),ut.copy(re).add(oe).add(Te),this._camera.position.add(ut),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),ut.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse),1);const u=this._needsUpdate;return u&&!this._updatedLastTime?(this._hasRested=!1,this.dispatchEvent({type:"wake"}),this.dispatchEvent({type:"update"})):u?(this.dispatchEvent({type:"update"}),xt(t,this.restThreshold)&&xt(i,this.restThreshold)&&xt(s,this.restThreshold)&&xt(n.x,this.restThreshold)&&xt(n.y,this.restThreshold)&&xt(n.z,this.restThreshold)&&xt(r.x,this.restThreshold)&&xt(r.y,this.restThreshold)&&xt(r.z,this.restThreshold)&&xt(a,this.restThreshold)&&!this._hasRested&&(this._hasRested=!0,this.dispatchEvent({type:"rest"}))):!u&&this._updatedLastTime&&this.dispatchEvent({type:"sleep"}),this._lastDistance=this._spherical.radius,this._lastZoom=this._zoom,this._updatedLastTime=u,this._needsUpdate=!1,u}toJSON(){return JSON.stringify({enabled:this._enabled,minDistance:this.minDistance,maxDistance:Xe(this.maxDistance),minZoom:this.minZoom,maxZoom:Xe(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Xe(this.maxPolarAngle),minAzimuthAngle:Xe(this.minAzimuthAngle),maxAzimuthAngle:Xe(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:ut.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(e,t=!1){const i=JSON.parse(e);this.enabled=i.enabled,this.minDistance=i.minDistance,this.maxDistance=Qe(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=Qe(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=Qe(i.maxPolarAngle),this.minAzimuthAngle=Qe(i.minAzimuthAngle),this.maxAzimuthAngle=Qe(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],t),Wt.setFromVector3(ut.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(Wt.theta,Wt.phi,t),this.dollyTo(Wt.radius,t),this.zoomTo(i.zoom,t),this.setFocalOffset(i.focalOffset[0],i.focalOffset[1],i.focalOffset[2],t),this._needsUpdate=!0}connect(e){this._domElement?console.warn("camera-controls is already connected."):(e.setAttribute("data-camera-controls-version","3.1.2"),this._addAllEventListeners(e),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(e){return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse)}_getCameraDirection(e){return this._getTargetDirection(e).negate()}_findPointerById(e){return this._activePointers.find(t=>t.pointerId===e)}_findPointerByMouseButton(e){return this._activePointers.find(t=>t.mouseButton===e)}_disposePointer(e){this._activePointers.splice(this._activePointers.indexOf(e),1)}_encloseToBoundary(e,t,i){const s=t.lengthSq();if(0===s)return e;const n=gt.copy(t).add(e),a=this._boundary.clampPoint(n,Oe).sub(n),l=a.lengthSq();if(0===l)return e.add(t);if(l===s)return e;if(0===i)return e.add(t).add(a);{const c=1+i*l/t.dot(a);return e.add(gt.copy(t).multiplyScalar(c)).add(a.multiplyScalar(1-i))}}_updateNearPlaneCorners(){if(Ce(this._camera)){const e=this._camera,t=e.near,i=e.getEffectiveFOV()*Ge,s=Math.tan(.5*i)*t,n=s*e.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(pe(this._camera)){const e=this._camera,t=1/e.zoom,i=e.left*t,s=e.right*t,n=e.top*t,r=e.bottom*t;this._nearPlaneCorners[0].set(i,n,0),this._nearPlaneCorners[1].set(s,n,0),this._nearPlaneCorners[2].set(s,r,0),this._nearPlaneCorners[3].set(i,r,0)}}_truckInternal=(e,t,i,s)=>{let n,r;if(Ce(this._camera)){const a=ut.copy(this._camera.position).sub(this._target),l=this._camera.getEffectiveFOV()*Ge,c=a.length()*Math.tan(.5*l);n=this.truckSpeed*e*c/this._elementRect.height,r=this.truckSpeed*t*c/this._elementRect.height}else{if(!pe(this._camera))return;{const a=this._camera;n=this.truckSpeed*e*(a.right-a.left)/a.zoom/this._elementRect.width,r=this.truckSpeed*t*(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(-r,!0)):i?this.setFocalOffset(this._focalOffsetEnd.x+n,this._focalOffsetEnd.y+r,this._focalOffsetEnd.z,!0):this.truck(n,r,!0)};_rotateInternal=(e,t)=>{this.rotate(me*this.azimuthRotateSpeed*e/this._elementRect.height,me*this.polarRotateSpeed*t/this._elementRect.height,!0)};_dollyInternal=(e,t,i)=>{const s=Math.pow(.95,-e*this.dollySpeed),n=this._sphericalEnd.radius,r=this._sphericalEnd.radius*s,a=ie(r,this.minDistance,this.maxDistance),l=a-r;this.infinityDolly&&this.dollyToCursor?this._dollyToNoClamp(r,!0):this.infinityDolly&&!this.dollyToCursor?(this.dollyInFixed(l,!0),this._dollyToNoClamp(a,!0)):this._dollyToNoClamp(a,!0),this.dollyToCursor&&(this._changedDolly+=(this.infinityDolly?r:a)-n,this._dollyControlCoord.set(t,i)),this._lastDollyDirection=Math.sign(-e)};_zoomInternal=(e,t,i)=>{const s=Math.pow(.95,e*this.dollySpeed),n=this._zoom,r=this._zoom*s;this.zoomTo(r,!0),this.dollyToCursor&&(this._changedZoom+=r-n,this._dollyControlCoord.set(t,i))};_collisionTest(){let e=1/0;if(!(this.colliderMeshes.length>=1)||ls(this._camera,"_collisionTest"))return e;const i=this._getTargetDirection(Ke);ds.lookAt(En,i,this._camera.up);for(let s=0;s<4;s++){const n=gt.copy(this._nearPlaneCorners[s]);n.applyMatrix4(ds);const r=Oe.addVectors(this._target,n);Ci.set(r,i),Ci.far=this._spherical.radius+1;const a=Ci.intersectObjects(this.colliderMeshes);0!==a.length&&a[0].distance<e&&(e=a[0].distance)}return e}_getClientRect(e){if(!this._domElement)return;const t=this._domElement.getBoundingClientRect();return e.x=t.left,e.y=t.top,this._viewport?(e.x+=this._viewport.x,e.y+=t.height-this._viewport.w-this._viewport.y,e.width=this._viewport.z,e.height=this._viewport.w):(e.width=t.width,e.height=t.height),e}_createOnRestPromise(e){return e?Promise.resolve():(this._hasRested=!1,this.dispatchEvent({type:"transitionstart"}),new Promise(t=>{const i=()=>{this.removeEventListener("rest",i),t()};this.addEventListener("rest",i)}))}_addAllEventListeners(e){}_removeAllEventListeners(){}get dampingFactor(){return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."),0}set dampingFactor(e){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(e){console.warn(".draggingDampingFactor has been deprecated. use draggingSmoothTime (in seconds) instead.")}static createBoundingSphere(e,t=new lt.Sphere){const i=t,s=i.center;ze.makeEmpty(),e.traverseVisible(r=>{r.isMesh&&ze.expandByObject(r)}),ze.getCenter(s);let n=0;return e.traverseVisible(r=>{if(!r.isMesh)return;const a=r;if(!a.geometry)return;const l=a.geometry.clone();l.applyMatrix4(a.matrixWorld);const u=l.attributes.position;for(let h=0,f=u.count;h<f;h++)ut.fromBufferAttribute(u,h),n=Math.max(n,s.distanceToSquared(ut))}),i.radius=Math.sqrt(n),i}}var So=Object.defineProperty,w=(o,e,t)=>(((o,e,t)=>{e in o?So(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t})(o,"symbol"!=typeof e?e+"":e,t),t);class X{constructor(){w(this,"enabled",!0),w(this,"trigger",e=>{if(!this.enabled)return;const t=this.handlers.slice(0);for(const i of t)i(e)}),w(this,"handlers",[])}add(e){this.handlers.push(e)}remove(e){this.handlers=this.handlers.filter(t=>t!==e)}reset(){this.handlers.length=0}}class fs{constructor(e){w(this,"isDisposeable",()=>"dispose"in this&&"onDisposed"in this),w(this,"isResizeable",()=>"resize"in this&&"getSize"in this),w(this,"isUpdateable",()=>"onAfterUpdate"in this&&"onBeforeUpdate"in this&&"update"in this),w(this,"isHideable",()=>"visible"in this),w(this,"isConfigurable",()=>"setup"in this&&"config"in this&&"onSetup"in this),w(this,"isSerializable",()=>"import"in this&&"export"in this),this.components=e}}class Tt extends fs{}class ps extends fs{constructor(e){super(e),w(this,"worlds",new ft.jp),w(this,"onWorldChanged",new X),w(this,"_currentWorld",null),this.onWorldChanged.add(({world:t,action:i})=>{"removed"===i&&this.worlds.delete(t.uuid)})}set currentWorld(e){this._currentWorld=e}get currentWorld(){return this._currentWorld}}class Mo extends ps{constructor(){super(...arguments),w(this,"hasCameraControls",()=>"controls"in this)}}const Mn=class mn extends Tt{constructor(e){super(e),w(this,"_disposedComponents",new Set),w(this,"enabled",!0),e.add(mn.uuid,this)}get(){return this._disposedComponents}destroy(e,t=!0,i=!0){e.removeFromParent();const s=e;s.dispose&&s.dispose(),this.disposeGeometryAndMaterials(e,t),i&&s.children&&s.children.length&&this.disposeChildren(s),e.children.length=0}disposeGeometry(e){e.boundsTree&&e.disposeBoundsTree&&e.disposeBoundsTree(),e.dispose()}disposeGeometryAndMaterials(e,t){const i=e;i.geometry&&this.disposeGeometry(i.geometry),t&&i.material&&mn.disposeMaterial(i),i.material=[],i.geometry=null}disposeChildren(e){for(const t of e.children)this.destroy(t)}static disposeMaterial(e){if(e.material)if(Array.isArray(e.material))for(const t of e.material)t.dispose();else e.material.dispose()}};w(Mn,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let Je=Mn;class ko extends ps{constructor(e){super(e),w(this,"onDisposed",new X),w(this,"directionalLights",new Map),w(this,"ambientLights",new Map)}dispose(){const e=this.components.get(Je);for(const t of this.three.children)t.geometry&&e.destroy(t);this.deleteAllLights(),this.three.children=[],this.onDisposed.trigger(),this.onDisposed.reset()}deleteAllLights(){for(const[,e]of this.directionalLights)e.removeFromParent(),e.target.removeFromParent(),e.dispose();this.directionalLights.clear();for(const[,e]of this.ambientLights)e.removeFromParent(),e.dispose();this.ambientLights.clear()}}Set;const ms=class Rt{static create(){const e=4294967295*Math.random()|0,t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0;return`${Rt._lut[255&e]+Rt._lut[e>>8&255]+Rt._lut[e>>16&255]+Rt._lut[e>>24&255]}-${Rt._lut[255&t]}${Rt._lut[t>>8&255]}-${Rt._lut[t>>16&15|64]}${Rt._lut[t>>24&255]}-${Rt._lut[63&i|128]}${Rt._lut[i>>8&255]}-${Rt._lut[i>>16&255]}${Rt._lut[i>>24&255]}${Rt._lut[255&s]}${Rt._lut[s>>8&255]}${Rt._lut[s>>16&255]}${Rt._lut[s>>24&255]}`.toLowerCase()}static validate(e){if(!Rt._pattern.test(e))throw new Error(`${e} 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.`)}};w(ms,"_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}$/),w(ms,"_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 Yt=ms;const On=":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",No=new RegExp("^["+On+"]["+On+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function kn(o,e){const t=[];let i=e.exec(o);for(;i;){const s=[];s.startIndex=e.lastIndex-i[0].length;const n=i.length;for(let r=0;r<n;r++)s.push(i[r]);t.push(s),i=e.exec(o)}return t}const Ti=function(o){const e=No.exec(o);return!(null===e||typeof e>"u")},Ro={allowBooleanAttributes:!1,unpairedTags:[]};function zn(o){return" "===o||"\t"===o||"\n"===o||"\r"===o}function Fn(o,e){const t=e;for(;e<o.length;e++)if("?"==o[e]||" "==o[e]){const i=o.substr(t,e-t);if(e>5&&"xml"===i)return kt("InvalidXml","XML declaration allowed only at the start of the document.",Ut(o,e));if("?"==o[e]&&">"==o[e+1]){e++;break}continue}return e}function Nn(o,e){if(o.length>e+5&&"-"===o[e+1]&&"-"===o[e+2]){for(e+=3;e<o.length;e++)if("-"===o[e]&&"-"===o[e+1]&&">"===o[e+2]){e+=2;break}}else if(o.length>e+8&&"D"===o[e+1]&&"O"===o[e+2]&&"C"===o[e+3]&&"T"===o[e+4]&&"Y"===o[e+5]&&"P"===o[e+6]&&"E"===o[e+7]){let t=1;for(e+=8;e<o.length;e++)if("<"===o[e])t++;else if(">"===o[e]&&(t--,0===t))break}else if(o.length>e+9&&"["===o[e+1]&&"C"===o[e+2]&&"D"===o[e+3]&&"A"===o[e+4]&&"T"===o[e+5]&&"A"===o[e+6]&&"["===o[e+7])for(e+=8;e<o.length;e++)if("]"===o[e]&&"]"===o[e+1]&&">"===o[e+2]){e+=2;break}return e}function Uo(o,e){let t="",i="",s=!1;for(;e<o.length;e++){if('"'===o[e]||"'"===o[e])""===i?i=o[e]:i!==o[e]||(i="");else if(">"===o[e]&&""===i){s=!0;break}t+=o[e]}return""===i&&{value:t,index:e,tagClosed:s}}const $o=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function Dn(o,e){const t=kn(o,$o),i={};for(let s=0;s<t.length;s++){if(0===t[s][1].length)return kt("InvalidAttr","Attribute '"+t[s][2]+"' has no space in starting.",ti(t[s]));if(void 0!==t[s][3]&&void 0===t[s][4])return kt("InvalidAttr","Attribute '"+t[s][2]+"' is without value.",ti(t[s]));if(void 0===t[s][3]&&!e.allowBooleanAttributes)return kt("InvalidAttr","boolean attribute '"+t[s][2]+"' is not allowed.",ti(t[s]));const n=t[s][2];if(!Yo(n))return kt("InvalidAttr","Attribute '"+n+"' is an invalid name.",ti(t[s]));if(i.hasOwnProperty(n))return kt("InvalidAttr","Attribute '"+n+"' is repeated.",ti(t[s]));i[n]=1}return!0}function Ho(o,e){if(";"===o[++e])return-1;if("#"===o[e])return function jo(o,e){let t=/\d/;for("x"===o[e]&&(e++,t=/[\da-fA-F]/);e<o.length;e++){if(";"===o[e])return e;if(!o[e].match(t))break}return-1}(o,++e);let t=0;for(;e<o.length;e++,t++)if(!(o[e].match(/\w/)&&t<20)){if(";"===o[e])break;return-1}return e}function kt(o,e,t){return{err:{code:o,msg:e,line:t.line||t,col:t.col}}}function Yo(o){return Ti(o)}function Zo(o){return Ti(o)}function Ut(o,e){const t=o.substring(0,e).split(/\r?\n/);return{line:t.length,col:t[t.length-1].length+1}}function ti(o){return o.startIndex+o[1].length}const Wo={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(o,e){return e},attributeValueProcessor:function(o,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(o,e,t){return o},captureMetaData:!1};function Rn(o){return"boolean"==typeof o?{enabled:o,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:"object"==typeof o&&null!==o?{enabled:!1!==o.enabled,maxEntitySize:o.maxEntitySize??1e4,maxExpansionDepth:o.maxExpansionDepth??10,maxTotalExpansions:o.maxTotalExpansions??1e3,maxExpandedLength:o.maxExpandedLength??1e5,allowedTags:o.allowedTags??null,tagFilter:o.tagFilter??null}:Rn(!0)}const qo=function(o){const e=Object.assign({},Wo,o);return e.processEntities=Rn(e.processEntities),e};let Ei;Ei="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class Ee{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){"__proto__"===e&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){"__proto__"===e.tagname&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),void 0!==t&&(this.child[this.child.length-1][Ei]={startIndex:t})}static getMetaDataSymbol(){return Ei}}class Go{constructor(e){this.suppressValidationErr=!e,this.options=e}readDocType(e,t){const i={};if("O"!==e[t+3]||"C"!==e[t+4]||"T"!==e[t+5]||"Y"!==e[t+6]||"P"!==e[t+7]||"E"!==e[t+8])throw new Error("Invalid Tag instead of DOCTYPE");{t+=9;let s=1,n=!1,r=!1,a="";for(;t<e.length;t++)if("<"!==e[t]||r)if(">"===e[t]){if(r?"-"===e[t-1]&&"-"===e[t-2]&&(r=!1,s--):s--,0===s)break}else"["===e[t]?n=!0:a+=e[t];else{if(n&&Ae(e,"!ENTITY",t)){let l,c;if(t+=7,[l,c,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),-1===c.indexOf("&")){const u=l.replace(/[.\-+*:]/g,"\\.");i[l]={regx:RegExp(`&${u};`,"g"),val:c}}}else if(n&&Ae(e,"!ELEMENT",t)){t+=8;const{index:l}=this.readElementExp(e,t+1);t=l}else if(n&&Ae(e,"!ATTLIST",t))t+=8;else if(n&&Ae(e,"!NOTATION",t)){t+=9;const{index:l}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=l}else{if(!Ae(e,"!--",t))throw new Error("Invalid DOCTYPE");r=!0}s++,a=""}if(0!==s)throw new Error("Unclosed DOCTYPE")}return{entities:i,i:t}}readEntityExp(e,t){t=Zt(e,t);let i="";for(;t<e.length&&!/\s/.test(e[t])&&'"'!==e[t]&&"'"!==e[t];)i+=e[t],t++;if(ei(i),t=Zt(e,t),!this.suppressValidationErr){if("SYSTEM"===e.substring(t,t+6).toUpperCase())throw new Error("External entities are not supported");if("%"===e[t])throw new Error("Parameter entities are not supported")}let s="";if([t,s]=this.readIdentifierVal(e,t,"entity"),!1!==this.options.enabled&&this.options.maxEntitySize&&s.length>this.options.maxEntitySize)throw new Error(`Entity "${i}" size (${s.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[i,s,--t]}readNotationExp(e,t){t=Zt(e,t);let i="";for(;t<e.length&&!/\s/.test(e[t]);)i+=e[t],t++;!this.suppressValidationErr&&ei(i),t=Zt(e,t);const s=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&"SYSTEM"!==s&&"PUBLIC"!==s)throw new Error(`Expected SYSTEM or PUBLIC, found "${s}"`);t=Zt(e,t+=s.length);let n=null,r=null;if("PUBLIC"===s)[t,n]=this.readIdentifierVal(e,t,"publicIdentifier"),('"'===e[t=Zt(e,t)]||"'"===e[t])&&([t,r]=this.readIdentifierVal(e,t,"systemIdentifier"));else if("SYSTEM"===s&&([t,r]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!r))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:i,publicIdentifier:n,systemIdentifier:r,index:--t}}readIdentifierVal(e,t,i){let s="";const n=e[t];if('"'!==n&&"'"!==n)throw new Error(`Expected quoted string, found "${n}"`);for(t++;t<e.length&&e[t]!==n;)s+=e[t],t++;if(e[t]!==n)throw new Error(`Unterminated ${i} value`);return[++t,s]}readElementExp(e,t){t=Zt(e,t);let i="";for(;t<e.length&&!/\s/.test(e[t]);)i+=e[t],t++;if(!this.suppressValidationErr&&!Ti(i))throw new Error(`Invalid element name: "${i}"`);let s="";if("E"===e[t=Zt(e,t)]&&Ae(e,"MPTY",t))t+=4;else if("A"===e[t]&&Ae(e,"NY",t))t+=2;else if("("===e[t]){for(t++;t<e.length&&")"!==e[t];)s+=e[t],t++;if(")"!==e[t])throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:i,contentModel:s.trim(),index:t}}readAttlistExp(e,t){t=Zt(e,t);let i="";for(;t<e.length&&!/\s/.test(e[t]);)i+=e[t],t++;ei(i),t=Zt(e,t);let s="";for(;t<e.length&&!/\s/.test(e[t]);)s+=e[t],t++;if(!ei(s))throw new Error(`Invalid attribute name: "${s}"`);t=Zt(e,t);let n="";if("NOTATION"===e.substring(t,t+8).toUpperCase()){if(n="NOTATION","("!==e[t=Zt(e,t+=8)])throw new Error(`Expected '(', found "${e[t]}"`);t++;let a=[];for(;t<e.length&&")"!==e[t];){let l="";for(;t<e.length&&"|"!==e[t]&&")"!==e[t];)l+=e[t],t++;if(l=l.trim(),!ei(l))throw new Error(`Invalid notation name: "${l}"`);a.push(l),"|"===e[t]&&(t++,t=Zt(e,t))}if(")"!==e[t])throw new Error("Unterminated list of notations");t++,n+=" ("+a.join("|")+")"}else{for(;t<e.length&&!/\s/.test(e[t]);)n+=e[t],t++;if(!this.suppressValidationErr&&!["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"].includes(n.toUpperCase()))throw new Error(`Invalid attribute type: "${n}"`)}t=Zt(e,t);let r="";return"#REQUIRED"===e.substring(t,t+8).toUpperCase()?(r="#REQUIRED",t+=8):"#IMPLIED"===e.substring(t,t+7).toUpperCase()?(r="#IMPLIED",t+=7):[t,r]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:i,attributeName:s,attributeType:n,defaultValue:r,index:t}}}const Zt=(o,e)=>{for(;e<o.length&&/\s/.test(o[e]);)e++;return e};function Ae(o,e,t){for(let i=0;i<e.length;i++)if(e[i]!==o[t+i+1])return!1;return!0}function ei(o){if(Ti(o))return o;throw new Error(`Invalid entity name ${o}`)}const Xo=/^[-+]?0x[a-fA-F0-9]+$/,Qo=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Ko={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};const ta=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Bn(o){return"function"==typeof o?o:Array.isArray(o)?e=>{for(const t of o)if("string"==typeof t&&e===t||t instanceof RegExp&&t.test(e))return!0}:()=>!1}class na{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xa2"},pound:{regex:/&(pound|#163);/g,val:"\xa3"},yen:{regex:/&(yen|#165);/g,val:"\xa5"},euro:{regex:/&(euro|#8364);/g,val:"\u20ac"},copyright:{regex:/&(copy|#169);/g,val:"\xa9"},reg:{regex:/&(reg|#174);/g,val:"\xae"},inr:{regex:/&(inr|#8377);/g,val:"\u20b9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,i)=>Ln(i,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,i)=>Ln(i,16,"&#x")}},this.addExternalEntities=ra,this.parseXml=ua,this.parseTextData=oa,this.resolveNameSpace=aa,this.buildAttributesMap=ca,this.isItStopNode=pa,this.replaceEntitiesValue=da,this.readStopNodeData=ga,this.saveTextToParentTag=fa,this.addChild=ha,this.ignoreAttributesFn=Bn(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(let t=0;t<this.options.stopNodes.length;t++){const i=this.options.stopNodes[t];"string"==typeof i&&(i.startsWith("*.")?this.stopNodesWildcard.add(i.substring(2)):this.stopNodesExact.add(i))}}}}function ra(o){const e=Object.keys(o);for(let t=0;t<e.length;t++){const i=e[t],s=i.replace(/[.\-+*:]/g,"\\.");this.lastEntities[i]={regex:new RegExp("&"+s+";","g"),val:o[i]}}}function oa(o,e,t,i,s,n,r){if(void 0!==o&&(this.options.trimValues&&!i&&(o=o.trim()),o.length>0)){r||(o=this.replaceEntitiesValue(o,e,t));const a=this.options.tagValueProcessor(e,o,t,s,n);return null==a?o:typeof a!=typeof o||a!==o?a:this.options.trimValues||o.trim()===o?_s(o,this.options.parseTagValue,this.options.numberParseOptions):o}}function aa(o){if(this.options.removeNSPrefix){const e=o.split(":"),t="/"===o.charAt(0)?"/":"";if("xmlns"===e[0])return"";2===e.length&&(o=t+e[1])}return o}const la=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function ca(o,e,t){if(!0!==this.options.ignoreAttributes&&"string"==typeof o){const i=kn(o,la),s=i.length,n={};for(let r=0;r<s;r++){const a=this.resolveNameSpace(i[r][1]);if(this.ignoreAttributesFn(a,e))continue;let l=i[r][4],c=this.options.attributeNamePrefix+a;if(a.length)if(this.options.transformAttributeName&&(c=this.options.transformAttributeName(c)),"__proto__"===c&&(c="#__proto__"),void 0!==l){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,t,e);const u=this.options.attributeValueProcessor(a,l,e);n[c]=null==u?l:typeof u!=typeof l||u!==l?u:_s(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(n[c]=!0)}if(!Object.keys(n).length)return;if(this.options.attributesGroupName){const r={};return r[this.options.attributesGroupName]=n,r}return n}}const ua=function(o){o=o.replace(/\r\n?/g,"\n");const e=new Ee("!xml");let t=e,i="",s="";this.entityExpansionCount=0,this.currentExpandedLength=0;const n=new Go(this.options.processEntities);for(let r=0;r<o.length;r++)if("<"===o[r])if("/"===o[r+1]){const l=Pe(o,">",r,"Closing Tag is not closed.");let c=o.substring(r+2,l).trim();if(this.options.removeNSPrefix){const f=c.indexOf(":");-1!==f&&(c=c.substr(f+1))}this.options.transformTagName&&(c=this.options.transformTagName(c)),t&&(i=this.saveTextToParentTag(i,t,s));const u=s.substring(s.lastIndexOf(".")+1);if(c&&-1!==this.options.unpairedTags.indexOf(c))throw new Error(`Unpaired tag can not be used as closing tag: </${c}>`);let h=0;u&&-1!==this.options.unpairedTags.indexOf(u)?(h=s.lastIndexOf(".",s.lastIndexOf(".")-1),this.tagsNodeStack.pop()):h=s.lastIndexOf("."),s=s.substring(0,h),t=this.tagsNodeStack.pop(),i="",r=l}else if("?"===o[r+1]){let l=gs(o,r,!1,"?>");if(!l)throw new Error("Pi Tag is not closed.");if(i=this.saveTextToParentTag(i,t,s),!(this.options.ignoreDeclaration&&"?xml"===l.tagName||this.options.ignorePiTags)){const c=new Ee(l.tagName);c.add(this.options.textNodeName,""),l.tagName!==l.tagExp&&l.attrExpPresent&&(c[":@"]=this.buildAttributesMap(l.tagExp,s,l.tagName)),this.addChild(t,c,s,r)}r=l.closeIndex+1}else if("!--"===o.substr(r+1,3)){const l=Pe(o,"--\x3e",r+4,"Comment is not closed.");if(this.options.commentPropName){const c=o.substring(r+4,l-2);i=this.saveTextToParentTag(i,t,s),t.add(this.options.commentPropName,[{[this.options.textNodeName]:c}])}r=l}else if("!D"===o.substr(r+1,2)){const l=n.readDocType(o,r);this.docTypeEntities=l.entities,r=l.i}else if("!["===o.substr(r+1,2)){const l=Pe(o,"]]>",r,"CDATA is not closed.")-2,c=o.substring(r+9,l);i=this.saveTextToParentTag(i,t,s);let u=this.parseTextData(c,t.tagname,s,!0,!1,!0,!0);null==u&&(u=""),this.options.cdataPropName?t.add(this.options.cdataPropName,[{[this.options.textNodeName]:c}]):t.add(this.options.textNodeName,u),r=l+2}else{let l=gs(o,r,this.options.removeNSPrefix),c=l.tagName;const u=l.rawTagName;let h=l.tagExp,f=l.attrExpPresent,d=l.closeIndex;if(this.options.transformTagName){const _=this.options.transformTagName(c);h===c&&(h=_),c=_}t&&i&&"!xml"!==t.tagname&&(i=this.saveTextToParentTag(i,t,s,!1)),t&&-1!==this.options.unpairedTags.indexOf(t.tagname)&&(t=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf("."))),c!==e.tagname&&(s+=s?"."+c:c);const g=r;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,s,c)){let _="";if(h.length>0&&h.lastIndexOf("/")===h.length-1)"/"===c[c.length-1]?(c=c.substr(0,c.length-1),s=s.substr(0,s.length-1),h=c):h=h.substr(0,h.length-1),r=l.closeIndex;else if(-1!==this.options.unpairedTags.indexOf(c))r=l.closeIndex;else{const x=this.readStopNodeData(o,u,d+1);if(!x)throw new Error(`Unexpected end of ${u}`);r=x.i,_=x.tagContent}const p=new Ee(c);c!==h&&f&&(p[":@"]=this.buildAttributesMap(h,s,c)),_&&(_=this.parseTextData(_,c,s,!0,f,!0,!0)),s=s.substr(0,s.lastIndexOf(".")),p.add(this.options.textNodeName,_),this.addChild(t,p,s,g)}else{if(h.length>0&&h.lastIndexOf("/")===h.length-1){if("/"===c[c.length-1]?(c=c.substr(0,c.length-1),s=s.substr(0,s.length-1),h=c):h=h.substr(0,h.length-1),this.options.transformTagName){const p=this.options.transformTagName(c);h===c&&(h=p),c=p}const _=new Ee(c);c!==h&&f&&(_[":@"]=this.buildAttributesMap(h,s,c)),this.addChild(t,_,s,g),s=s.substr(0,s.lastIndexOf("."))}else{const _=new Ee(c);this.tagsNodeStack.push(t),c!==h&&f&&(_[":@"]=this.buildAttributesMap(h,s,c)),this.addChild(t,_,s,g),t=_}i="",r=d}}else i+=o[r];return e.child};function ha(o,e,t,i){this.options.captureMetaData||(i=void 0);const s=this.options.updateTag(e.tagname,t,e[":@"]);!1===s||("string"==typeof s&&(e.tagname=s),o.addChild(e,i))}const da=function(o,e,t){if(-1===o.indexOf("&"))return o;const i=this.options.processEntities;if(!i.enabled||i.allowedTags&&!i.allowedTags.includes(e)||i.tagFilter&&!i.tagFilter(e,t))return o;for(let s in this.docTypeEntities){const n=this.docTypeEntities[s],r=o.match(n.regx);if(r){if(this.entityExpansionCount+=r.length,i.maxTotalExpansions&&this.entityExpansionCount>i.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i.maxTotalExpansions}`);const a=o.length;if(o=o.replace(n.regx,n.val),i.maxExpandedLength&&(this.currentExpandedLength+=o.length-a,this.currentExpandedLength>i.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i.maxExpandedLength}`)}}if(-1===o.indexOf("&"))return o;for(let s in this.lastEntities){const n=this.lastEntities[s];o=o.replace(n.regex,n.val)}if(-1===o.indexOf("&"))return o;if(this.options.htmlEntities)for(let s in this.htmlEntities){const n=this.htmlEntities[s];o=o.replace(n.regex,n.val)}return o.replace(this.ampEntity.regex,this.ampEntity.val)};function fa(o,e,t,i){return o&&(void 0===i&&(i=0===e.child.length),void 0!==(o=this.parseTextData(o,e.tagname,t,!1,!!e[":@"]&&0!==Object.keys(e[":@"]).length,i))&&""!==o&&e.add(this.options.textNodeName,o),o=""),o}function pa(o,e,t,i){return!!(e&&e.has(i)||o&&o.has(t))}function Pe(o,e,t,i){const s=o.indexOf(e,t);if(-1===s)throw new Error(i);return s+e.length-1}function gs(o,e,t,i=">"){const s=function ma(o,e,t=">"){let i,s="";for(let n=e;n<o.length;n++){let r=o[n];if(i)r===i&&(i="");else if('"'===r||"'"===r)i=r;else if(r===t[0]){if(!t[1])return{data:s,index:n};if(o[n+1]===t[1])return{data:s,index:n}}else"\t"===r&&(r=" ");s+=r}}(o,e+1,i);if(!s)return;let n=s.data;const r=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 u=l;if(t){const h=l.indexOf(":");-1!==h&&(l=l.substr(h+1),c=l!==s.data.substr(h+1))}return{tagName:l,tagExp:n,closeIndex:r,attrExpPresent:c,rawTagName:u}}function ga(o,e,t){const i=t;let s=1;for(;t<o.length;t++)if("<"===o[t])if("/"===o[t+1]){const n=Pe(o,">",t,`${e} is not closed`);if(o.substring(t+2,n).trim()===e&&(s--,0===s))return{tagContent:o.substring(i,t),i:n};t=n}else if("?"===o[t+1])t=Pe(o,"?>",t+1,"StopNode is not closed.");else if("!--"===o.substr(t+1,3))t=Pe(o,"--\x3e",t+3,"StopNode is not closed.");else if("!["===o.substr(t+1,2))t=Pe(o,"]]>",t,"StopNode is not closed.")-2;else{const n=gs(o,t,">");n&&((n&&n.tagName)===e&&"/"!==n.tagExp[n.tagExp.length-1]&&s++,t=n.closeIndex)}}function _s(o,e,t){if(e&&"string"==typeof o){const i=o.trim();return"true"===i||"false"!==i&&function Jo(o,e={}){if(e=Object.assign({},Ko,e),!o||"string"!=typeof o)return o;let t=o.trim();if(void 0!==e.skipLike&&e.skipLike.test(t))return o;if("0"===o)return 0;if(e.hex&&Xo.test(t))return function sa(o,e){if(parseInt)return parseInt(o,e);if(Number.parseInt)return Number.parseInt(o,e);if(window&&window.parseInt)return window.parseInt(o,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}(t,16);if(t.includes("e")||t.includes("E"))return function ea(o,e,t){if(!t.eNotation)return o;const i=e.match(ta);if(i){let s=i[1]||"";const n=-1===i[3].indexOf("e")?"E":"e",r=i[2],a=s?o[r.length+1]===n:o[r.length]===n;return r.length>1&&a?o:1!==r.length||!i[3].startsWith(`.${n}`)&&i[3][0]!==n?t.leadingZeros&&!a?(e=(i[1]||"")+i[3],Number(e)):o:Number(e)}return o}(o,t,e);{const i=Qo.exec(t);if(i){const s=i[1]||"",n=i[2];let r=function ia(o){return o&&-1!==o.indexOf(".")&&("."===(o=o.replace(/0+$/,""))?o="0":"."===o[0]?o="0"+o:"."===o[o.length-1]&&(o=o.substring(0,o.length-1))),o}(i[3]);if(!e.leadingZeros&&(n.length>1||1===n.length&&!(s?"."===o[n.length+1]:"."===o[n.length])))return o;{const l=Number(t),c=String(l);if(0===l)return l;if(-1!==c.search(/[eE]/))return e.eNotation?l:o;if(-1!==t.indexOf("."))return"0"===c||c===r||c===`${s}${r}`?l:o;let u=n?r:t;return n?u===c||s+u===c?l:o:u===c||u===s+c?l:o}}return o}}(o,t)}return function Do(o){return typeof o<"u"}(o)?o:""}function Ln(o,e,t){const i=Number.parseInt(o,e);return i>=0&&i<=1114111?String.fromCodePoint(i):t+o+";"}const ys=Ee.getMetaDataSymbol();function _a(o,e){return Vn(o,e)}function Vn(o,e,t){let i;const s={};for(let n=0;n<o.length;n++){const r=o[n],a=ya(r);let l="";if(l=void 0===t?a:t+"."+a,a===e.textNodeName)void 0===i?i=r[a]:i+=""+r[a];else{if(void 0===a)continue;if(r[a]){let c=Vn(r[a],e,l);const u=wa(c,e);void 0!==r[ys]&&(c[ys]=r[ys]),r[":@"]?va(c,r[":@"],l,e):1!==Object.keys(c).length||void 0===c[e.textNodeName]||e.alwaysCreateTextNode?0===Object.keys(c).length&&(e.alwaysCreateTextNode?c[e.textNodeName]="":c=""):c=c[e.textNodeName],void 0!==s[a]&&s.hasOwnProperty(a)?(Array.isArray(s[a])||(s[a]=[s[a]]),s[a].push(c)):s[a]=e.isArray(a,l,u)?[c]:c}}}return"string"==typeof i?i.length>0&&(s[e.textNodeName]=i):void 0!==i&&(s[e.textNodeName]=i),s}function ya(o){const e=Object.keys(o);for(let t=0;t<e.length;t++){const i=e[t];if(":@"!==i)return i}}function va(o,e,t,i){if(e){const s=Object.keys(e),n=s.length;for(let r=0;r<n;r++){const a=s[r];o[a]=i.isArray(a,t+"."+a,!0,!0)?[e[a]]:e[a]}}}function wa(o,e){const{textNodeName:t}=e,i=Object.keys(o).length;return!(0!==i&&(1!==i||!o[t]&&"boolean"!=typeof o[t]&&0!==o[t]))}class vs{constructor(e){this.externalEntities={},this.options=qo(e)}parse(e,t){if("string"!=typeof e&&e.toString)e=e.toString();else if("string"!=typeof e)throw new Error("XML data is accepted in String or Bytes[] form.");if(t){!0===t&&(t={});const n=function Bo(o,e){e=Object.assign({},Ro,e);const t=[];let i=!1,s=!1;"\ufeff"===o[0]&&(o=o.substr(1));for(let n=0;n<o.length;n++)if("<"===o[n]&&"?"===o[n+1]){if(n+=2,n=Fn(o,n),n.err)return n}else{if("<"!==o[n]){if(zn(o[n]))continue;return kt("InvalidChar","char '"+o[n]+"' is not expected.",Ut(o,n))}{let r=n;if(n++,"!"===o[n]){n=Nn(o,n);continue}{let a=!1;"/"===o[n]&&(a=!0,n++);let l="";for(;n<o.length&&">"!==o[n]&&" "!==o[n]&&"\t"!==o[n]&&"\n"!==o[n]&&"\r"!==o[n];n++)l+=o[n];if(l=l.trim(),"/"===l[l.length-1]&&(l=l.substring(0,l.length-1),n--),!Zo(l)){let h;return h=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",kt("InvalidTag",h,Ut(o,n))}const c=Uo(o,n);if(!1===c)return kt("InvalidAttr","Attributes for '"+l+"' have open quote.",Ut(o,n));let u=c.value;if(n=c.index,"/"===u[u.length-1]){const h=n-u.length;u=u.substring(0,u.length-1);const f=Dn(u,e);if(!0!==f)return kt(f.err.code,f.err.msg,Ut(o,h+f.err.line));i=!0}else if(a){if(!c.tagClosed)return kt("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Ut(o,n));if(u.trim().length>0)return kt("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Ut(o,r));if(0===t.length)return kt("InvalidTag","Closing tag '"+l+"' has not been opened.",Ut(o,r));{const h=t.pop();if(l!==h.tagName){let f=Ut(o,h.tagStartPos);return kt("InvalidTag","Expected closing tag '"+h.tagName+"' (opened in line "+f.line+", col "+f.col+") instead of closing tag '"+l+"'.",Ut(o,r))}0==t.length&&(s=!0)}}else{const h=Dn(u,e);if(!0!==h)return kt(h.err.code,h.err.msg,Ut(o,n-u.length+h.err.line));if(!0===s)return kt("InvalidXml","Multiple possible root nodes found.",Ut(o,n));-1!==e.unpairedTags.indexOf(l)||t.push({tagName:l,tagStartPos:r}),i=!0}for(n++;n<o.length;n++)if("<"===o[n]){if("!"===o[n+1]){n++,n=Nn(o,n);continue}if("?"!==o[n+1])break;if(n=Fn(o,++n),n.err)return n}else if("&"===o[n]){const h=Ho(o,n);if(-1==h)return kt("InvalidChar","char '&' is not expected.",Ut(o,n));n=h}else if(!0===s&&!zn(o[n]))return kt("InvalidXml","Extra text at the end",Ut(o,n));"<"===o[n]&&n--}}}return i?1==t.length?kt("InvalidTag","Unclosed tag '"+t[0].tagName+"'.",Ut(o,t[0].tagStartPos)):!(t.length>0)||kt("InvalidXml","Invalid '"+JSON.stringify(t.map(n=>n.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):kt("InvalidXml","Start tag expected.",1)}(e,t);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const i=new na(this.options);i.addExternalEntities(this.externalEntities);const s=i.parseXml(e);return this.options.preserveOrder||void 0===s?s:_a(s,this.options)}addEntity(e,t){if(-1!==t.indexOf("&"))throw new Error("Entity value can't have '&'");if(-1!==e.indexOf("&")||-1!==e.indexOf(";"))throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if("&"===t)throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return Ee.getMetaDataSymbol()}}function xa(o,e){let t="";return e.format&&e.indentBy.length>0&&(t="\n"),Un(o,e,"",t)}function Un(o,e,t,i){let s="",n=!1;for(let r=0;r<o.length;r++){const a=o[r],l=Ca(a);if(void 0===l)continue;let c="";if(c=0===t.length?l:`${t}.${l}`,l===e.textNodeName){let y=a[l];Ta(c,e)||(y=e.tagValueProcessor(l,y),y=jn(y,e)),n&&(s+=i),s+=y,n=!1;continue}if(l===e.cdataPropName){n&&(s+=i),s+=`<![CDATA[${a[l][0][e.textNodeName]}]]>`,n=!1;continue}if(l===e.commentPropName){s+=i+`\x3c!--${a[l][0][e.textNodeName]}--\x3e`,n=!0;continue}if("?"===l[0]){const y=$n(a[":@"],e);let _=a[l][0][e.textNodeName];_=0!==_.length?" "+_:"",s+=("?xml"===l?"":i)+`<${l}${_}${y}?>`,n=!0;continue}let u=i;""!==u&&(u+=e.indentBy);const f=i+`<${l}${$n(a[":@"],e)}`,d=Un(a[l],e,c,u);-1!==e.unpairedTags.indexOf(l)?s+=e.suppressUnpairedNode?f+">":f+"/>":d&&0!==d.length||!e.suppressEmptyNode?d&&d.endsWith(">")?s+=f+`>${d}${i}</${l}>`:(s+=f+">",d&&""!==i&&(d.includes("/>")||d.includes("</"))?s+=i+e.indentBy+d+i:s+=d,s+=`</${l}>`):s+=f+"/>",n=!0}return s}function Ca(o){const e=Object.keys(o);for(let t=0;t<e.length;t++){const i=e[t];if(o.hasOwnProperty(i)&&":@"!==i)return i}}function $n(o,e){let t="";if(o&&!e.ignoreAttributes)for(let i in o){if(!o.hasOwnProperty(i))continue;let s=e.attributeValueProcessor(i,o[i]);s=jn(s,e),t+=!0===s&&e.suppressBooleanAttributes?` ${i.substr(e.attributeNamePrefix.length)}`:` ${i.substr(e.attributeNamePrefix.length)}="${s}"`}return t}function Ta(o,e){let t=(o=o.substr(0,o.length-e.textNodeName.length-1)).substr(o.lastIndexOf(".")+1);for(let i in e.stopNodes)if(e.stopNodes[i]===o||e.stopNodes[i]==="*."+t)return!0;return!1}function jn(o,e){if(o&&o.length>0&&e.processEntities)for(let t=0;t<e.entities.length;t++){const i=e.entities[t];o=o.replace(i.regex,i.val)}return o}const Ea={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(o,e){return e},attributeValueProcessor:function(o,e){return e},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1};function ge(o){this.options=Object.assign({},Ea,o),!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=Bn(this.options.ignoreAttributes),this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Sa),this.processTextOrObjNode=Aa,this.options.format?(this.indentate=Pa,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function Aa(o,e,t,i){const s=this.j2x(o,t+1,i.concat(e));return void 0!==o[this.options.textNodeName]&&1===Object.keys(o).length?this.buildTextValNode(o[this.options.textNodeName],e,s.attrStr,t):this.buildObjectNode(s.val,e,s.attrStr,t)}function Pa(o){return this.options.indentBy.repeat(o)}function Sa(o){return!(!o.startsWith(this.options.attributeNamePrefix)||o===this.options.textNodeName)&&o.substr(this.attrPrefixLen)}ge.prototype.build=function(o){return this.options.preserveOrder?xa(o,this.options):(Array.isArray(o)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(o={[this.options.arrayNodeName]:o}),this.j2x(o,0,[]).val)},ge.prototype.j2x=function(o,e,t){let i="",s="";const n=t.join(".");for(let r in o)if(Object.prototype.hasOwnProperty.call(o,r))if(typeof o[r]>"u")this.isAttribute(r)&&(s+="");else if(null===o[r])this.isAttribute(r)||r===this.options.cdataPropName?s+="":s+="?"===r[0]?this.indentate(e)+"<"+r+"?"+this.tagEndChar:this.indentate(e)+"<"+r+"/"+this.tagEndChar;else if(o[r]instanceof Date)s+=this.buildTextValNode(o[r],r,"",e);else if("object"!=typeof o[r]){const a=this.isAttribute(r);if(a&&!this.ignoreAttributesFn(a,n))i+=this.buildAttrPairStr(a,""+o[r]);else if(!a)if(r===this.options.textNodeName){let l=this.options.tagValueProcessor(r,""+o[r]);s+=this.replaceEntitiesValue(l)}else s+=this.buildTextValNode(o[r],r,"",e)}else if(Array.isArray(o[r])){const a=o[r].length;let l="",c="";for(let u=0;u<a;u++){const h=o[r][u];if(!(typeof h>"u"))if(null===h)s+="?"===r[0]?this.indentate(e)+"<"+r+"?"+this.tagEndChar:this.indentate(e)+"<"+r+"/"+this.tagEndChar;else if("object"==typeof h)if(this.options.oneListGroup){const f=this.j2x(h,e+1,t.concat(r));l+=f.val,this.options.attributesGroupName&&h.hasOwnProperty(this.options.attributesGroupName)&&(c+=f.attrStr)}else l+=this.processTextOrObjNode(h,r,e,t);else if(this.options.oneListGroup){let f=this.options.tagValueProcessor(r,h);f=this.replaceEntitiesValue(f),l+=f}else l+=this.buildTextValNode(h,r,"",e)}this.options.oneListGroup&&(l=this.buildObjectNode(l,r,c,e)),s+=l}else if(this.options.attributesGroupName&&r===this.options.attributesGroupName){const a=Object.keys(o[r]),l=a.length;for(let c=0;c<l;c++)i+=this.buildAttrPairStr(a[c],""+o[r][a[c]])}else s+=this.processTextOrObjNode(o[r],r,e,t);return{attrStr:i,val:s}},ge.prototype.buildAttrPairStr=function(o,e){return e=this.options.attributeValueProcessor(o,""+e),e=this.replaceEntitiesValue(e),this.options.suppressBooleanAttributes&&"true"===e?" "+o:" "+o+'="'+e+'"'},ge.prototype.buildObjectNode=function(o,e,t,i){if(""===o)return"?"===e[0]?this.indentate(i)+"<"+e+t+"?"+this.tagEndChar:this.indentate(i)+"<"+e+t+this.closeTag(e)+this.tagEndChar;{let s="</"+e+this.tagEndChar,n="";return"?"===e[0]&&(n="?",s=""),!t&&""!==t||-1!==o.indexOf("<")?!1!==this.options.commentPropName&&e===this.options.commentPropName&&0===n.length?this.indentate(i)+`\x3c!--${o}--\x3e`+this.newLine:this.indentate(i)+"<"+e+t+n+this.tagEndChar+o+this.indentate(i)+s:this.indentate(i)+"<"+e+t+n+">"+o+s}},ge.prototype.closeTag=function(o){let e="";return-1!==this.options.unpairedTags.indexOf(o)?this.options.suppressUnpairedNode||(e="/"):e=this.options.suppressEmptyNode?"/":`></${o}`,e},ge.prototype.buildTextValNode=function(o,e,t,i){if(!1!==this.options.cdataPropName&&e===this.options.cdataPropName)return this.indentate(i)+`<![CDATA[${o}]]>`+this.newLine;if(!1!==this.options.commentPropName&&e===this.options.commentPropName)return this.indentate(i)+`\x3c!--${o}--\x3e`+this.newLine;if("?"===e[0])return this.indentate(i)+"<"+e+t+"?"+this.tagEndChar;{let s=this.options.tagValueProcessor(e,o);return s=this.replaceEntitiesValue(s),""===s?this.indentate(i)+"<"+e+t+this.closeTag(e)+this.tagEndChar:this.indentate(i)+"<"+e+t+">"+s+"</"+e+this.tagEndChar}},ge.prototype.replaceEntitiesValue=function(o){if(o&&o.length>0&&this.options.processEntities)for(let e=0;e<this.options.entities.length;e++){const t=this.options.entities[e];o=o.replace(t.regex,t.val)}return o};class Ai{}w(Ai,"parser",new vs({allowBooleanAttributes:!0,attributeNamePrefix:"",ignoreAttributes:!1,ignoreDeclaration:!0,ignorePiTags:!0,numberParseOptions:{leadingZeros:!0,hex:!0},parseAttributeValue:!0,preserveOrder:!1,processEntities:!1,removeNSPrefix:!0,trimValues:!0})),w(Ai,"builder",new ge({attributeNamePrefix:"$",ignoreAttributes:!1,suppressBooleanAttributes:!1}));class Ft{static join(e){const t={};for(const i of e)for(const s in i)if(t[s])for(const n of i[s])t[s].add(n);else t[s]=new Set(i[s]);return t}static intersect(e){if(0===e.length)return{};let t=Ft.clone(e[0]);for(let i=1;i<e.length;i++){const s=e[i],n={};for(const r in t)if(s[r]){const a=new Set;for(const l of t[r])s[r].has(l)&&a.add(l);a.size>0&&(n[r]=a)}t=n}return t}static clone(e){const t={};for(const i in e)t[i]=new Set(e[i]);return t}static remove(e,t,i=!1){i&&(e=Ft.clone(e));for(const s in t)if(e[s]){for(const n of t[s])e[s].delete(n);0===e[s].size&&delete e[s]}}static add(e,t,i=!1){i&&(e=Ft.clone(e));for(const s in t)if(e[s])for(const n of t[s])e[s].add(n);else e[s]=new Set(t[s])}static append(e,t,...i){let s=e[t];s||(s=new Set,e[t]=s);for(const n of i)s.add(n)}static isEqual(e,t){const i=Object.keys(e),s=Object.keys(t);if(i.length!==s.length)return!1;for(const n of i){if(!t[n]||e[n].size!==t[n].size)return!1;for(const r of e[n])if(!t[n].has(r))return!1}return!0}static isEmpty(e){return 0===Object.values(e).reduce((i,s)=>i+s.size,0)}static toRaw(e){const t={};for(const i in e)t[i]=Array.from(e[i]);return t}static fromRaw(e){const t={};for(const i in e)t[i]=new Set(e[i]);return t}}Map;class ws{static isEntry(e){return new Set(["Boolean","Color","Text","Number","Select","Vector3","TextSet","None"]).has(e.type)}static copySchema(e,t={}){for(const i in e){const s=e[i];this.isEntry(s)?t[i]=this.copyEntry(s):(t[i]={},this.copySchema(s,t[i]))}return t}static copyEntry(e){if("Boolean"===e.type)return{type:e.type,value:e.value};if("Color"===e.type)return{type:e.type,value:e.value.clone()};if("Text"===e.type)return{type:e.type,value:e.value};if("Number"===e.type)return{type:e.type,value:e.value,min:e.min,max:e.max,interpolable:e.interpolable};if("Select"===e.type)return{type:e.type,value:e.value,multiple:e.multiple,options:new Set(e.options)};if("Vector3"===e.type)return{type:e.type,value:e.value.clone()};if("TextSet"===e.type)return{type:e.type,value:new Set(e.value)};if("None"===e.type)return{type:e.type,value:e.value};throw new Error("Invalid entry!")}}class ii{constructor(e,t,i,s){w(this,"_component"),w(this,"name"),w(this,"uuid"),this._component=e,this.name=i,this.uuid=s??Yt.create(),t.get(Pi).list.set(this.uuid,this)}get controls(){return ws.copySchema(this._config)}set(e){for(const t in e)t in this&&(this[t]=e[t].value)}export(e=this._config,t={}){for(const i in e){const s=e[i];if(ws.isEntry(s))if("Color"===s.type){const{r,g:a,b:l}=s.value;t[i]={...s,value:{r,g:a,b:l}}}else if("Vector3"===s.type){const{x:r,y:a,z:l}=s.value;t[i]={...s,value:{x:r,y:a,z:l}}}else if("TextSet"===s.type){const r=Array.from(s.value);t[i]={...s,value:r}}else if("Select"===s.type){const r=Array.from(s.options);t[i]={...s,options:r}}else t[i]={...s};else t[i]={},this.export(s,t[i])}return t}import(e,t={},i=!0){for(const s in e){const n=e[s];if(ws.isEntry(n))if("Color"===n.type){const{r:a,g:l,b:c}=n.value;t[s]={...n,value:new b.Q1f(a,l,c)}}else if("Vector3"===n.type){const{x:a,y:l,z:c}=n.value;t[s]={...n,value:new b.Pq0(a,l,c)}}else t[s]="TextSet"===n.type?{...n,value:new Set(n.value)}:"Select"===n.type?{...n,options:new Set(n.options)}:{...n};else t[s]={},this.import(n,t[s],!1)}i&&this.set(t)}}const Hn=class uo extends Tt{constructor(e){super(e),w(this,"list",new ft.jp),w(this,"enabled",!0),e.add(uo.uuid,this)}};w(Hn,"uuid","b8c764e0-6b24-4e77-9a32-35fa728ee5b4");let Pi=Hn;class Yn{constructor(e){w(this,"_event"),w(this,"_position",new b.I9Y),w(this,"onDisposed",new X),w(this,"updateMouseInfo",t=>{this._event=t}),this.dom=e,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(e){if(this._event){const t=this.dom.getBoundingClientRect();this._position.x=this.getPositionX(t,this._event,e),this._position.y=this.getPositionY(t,this._event,e)}}getPositionY(e,t,i){const s=this.getDataObject(t);return i?s.clientY:-(s.clientY-e.top)/(e.bottom-e.top)*2+1}getPositionX(e,t,i){const s=this.getDataObject(t);return i?s.clientX:(s.clientX-e.left)/(e.right-e.left)*2-1}getDataObject(e){return e instanceof MouseEvent?e:e.touches[0]}setupEvents(e){e?(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 Zn=class ho extends Tt{constructor(e){super(e),w(this,"onDisposed",new X),w(this,"onBeforeDispose",new X),w(this,"onFragmentsLoaded",new X),w(this,"baseCoordinationModel",""),w(this,"baseCoordinationMatrix",new b.kn4),w(this,"enabled",!0),w(this,"_core"),this.components.add(ho.uuid,this)}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(e,t){var i=this;this._core=new ft._i(e,t),this.core.onModelLoaded.add((0,H.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 b.kn4)})}raycast(e){var t=this;return(0,H.A)(function*(){const i=[];for(const r of t.core.models.list.values())if(e.snappingClasses&&e.snappingClasses.length>0){const a=yield r.raycastWithSnapping(e);if(a&&a.length>0)i.push(a[0]);else{const l=yield r.raycast(e);l&&i.push(l)}}else{const a=yield r.raycast(e);a&&i.push(a)}if(yield Promise.all(i),0===i.length)return;let s=i[0],n=s.distance;for(let r=1;r<i.length;r++)i[r].distance<n&&(n=i[r].distance,s=i[r]);return s})()}getPositions(e){var t=this;return(0,H.A)(function*(){const i=[],s=function(){var r=(0,H.A)(function*(a,l){const c=yield a.getPositions(l);for(const u of c)i.push(u)});return function(l,c){return r.apply(this,arguments)}}(),n=[];for(const r in e){const a=t.core.models.list.get(r);a&&n.push(s(a,Array.from(e[r])))}return yield Promise.all(n),i})()}getBBoxes(e){var t=this;return(0,H.A)(function*(){const i=[],s=function(){var r=(0,H.A)(function*(a,l){const c=yield a.getBoxes(l);if(c)for(const u of c)i.push(u)});return function(l,c){return r.apply(this,arguments)}}(),n=[];for(const r in e){const a=t.core.models.list.get(r);a&&n.push(s(a,Array.from(e[r])))}return yield Promise.all(n),i})()}highlight(e,t){var i=this;return(0,H.A)(function*(){yield i.forEachModel(t,"highlight",e)})()}getData(e,t){var i=this;return(0,H.A)(function*(){const s={};for(const[n,r]of Object.entries(e)){const a=i.list.get(n);if(!a)continue;if(0===r.size){s[n]=[];continue}const l=yield a.getItemsData([...r],t);s[n]=l}return s})()}resetHighlight(e){var t=this;return(0,H.A)(function*(){yield t.forEachModel(e,"resetHighlight")})()}forEachModel(e,t,...i){var s=this;return(0,H.A)(function*(){const n={};if(e)for(const a in e)n[a]=Array.from(e[a]);else for(const a of s.core.models.list.keys())n[a]=void 0;const r=[];for(const a in n){const l=s.core.models.list.get(a);if(l){const u=l[t](n[a],...i);r.push(u)}}yield Promise.all(r)})()}guidsToModelIdMap(e){var t=this;return(0,H.A)(function*(){const i={};for(const[s,n]of t.list){const r=(yield n.getLocalIdsByGuids([...e])).filter(a=>null!==a);i[s]=new Set(r)}return i})()}modelIdMapToGuids(e){var t=this;return(0,H.A)(function*(){const i=[];for(const[s,n]of Object.entries(e)){const r=t.list.get(s);if(!r)continue;const a=(yield r.getGuidsByLocalIds([...n])).filter(l=>null!==l);i.push(...a)}return i})()}applyBaseCoordinateSystem(e,t){const i=new b.kn4;return t&&i.copy(t.clone()).invert(),i.multiply(this.baseCoordinationMatrix),e.applyMatrix4(i),i}};w(Zn,"uuid","fef46874-46a3-461b-8c44-2922ab77c806");let ct=Zn;class Ia{constructor(){w(this,"wasm",{path:"",absolute:!1,logLevel:os.LogLevel.LOG_LEVEL_OFF}),w(this,"webIfc",{COORDINATE_TO_ORIGIN:!0}),w(this,"autoSetWasm",!0),w(this,"customLocateFileHandler",null)}}w(class gn extends Tt{constructor(e){super(e),w(this,"onDisposed",new X),w(this,"onIfcStartedLoading",new X),w(this,"onIfcImporterInitialized",new X),w(this,"onSetup",new X),w(this,"settings",new Ia),w(this,"webIfc",new os.IfcAPI),w(this,"enabled",!0),this.components.add(gn.uuid,this)}dispose(){this.webIfc=null,this.onDisposed.trigger(gn.uuid),this.onDisposed.reset()}setup(e){var t=this;return(0,H.A)(function*(){t.settings={...t.settings,...e},t.settings.autoSetWasm&&(yield t.autoSetWasm()),t.onSetup.trigger()})()}load(e,t,i,s){var n=this;return(0,H.A)(function*(){const r=n.components.get(ct);if(!r.initialized)throw new Error("You need to initialize fragments first.");n.settings.autoSetWasm&&(yield n.autoSetWasm()),r.core.settings.autoCoordinate=t;const a=new ft.$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:e});return yield r.core.load(l,{modelId:i,userData:s?.userData})})()}readIfcFile(e){var t=this;return(0,H.A)(function*(){const{path:i,absolute:s,logLevel:n}=t.settings.wasm;return t.webIfc.SetWasmPath(i,s),yield t.webIfc.Init(t.settings.customLocateFileHandler||void 0),n&&t.webIfc.SetLogLevel(n),t.webIfc.OpenModel(e,t.settings.webIfc)})()}cleanUp(){try{this.webIfc.Dispose()}catch{console.log("Web-ifc wasn't disposed.")}this.webIfc=null,this.webIfc=new os.IfcAPI}autoSetWasm(){var e=this;return(0,H.A)(function*(){const t=yield fetch(`https://unpkg.com/@thatopen/components@${js.release}/package.json`);if(!t.ok)return void console.warn("Couldn't get openbim-components package.json. Set wasm settings manually.");const i=yield t.json();"web-ifc"in i.peerDependencies?(e.settings.wasm.path=`https://unpkg.com/web-ifc@${i.peerDependencies["web-ifc"]}/`,e.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 Wn=class fo extends Tt{constructor(e){super(e),w(this,"enabled",!0),this.components.add(fo.uuid,this)}set(e,t){var i=this;return(0,H.A)(function*(){const s=i.components.get(ct),n=[];if(t)for(const[r,a]of Object.entries(t)){const l=s.list.get(r);l&&n.push(l.setVisible([...a],e))}else for(const r of s.list.values())n.push(r.setVisible(void 0,e));yield Promise.all(n),yield s.core.update(!0)})()}isolate(e){var t=this;return(0,H.A)(function*(){yield Promise.all([t.set(!1),t.set(!0,e)])})()}toggle(e){var t=this;return(0,H.A)(function*(){const i=[],s=t.components.get(ct);for(const[n,r]of Object.entries(e)){const a=s.list.get(n);a&&i.push(a.toggleVisible([...r]))}yield Promise.all(i),yield s.core.update(!0)})()}getVisibilityMap(e,t){var i=this;return(0,H.A)(function*(){const s=[],n=[],r=i.components.get(ct);if(t)for(const c of t){const u=r.list.get(c);u&&(s.push(u.modelId),n.push(u.getItemsByVisibility(e)))}else for(const c of r.list.values())s.push(c.modelId),n.push(c.getItemsByVisibility(e));const a=yield Promise.all(n),l={};for(const[c,u]of s.entries())l[u]=a[c];return l})()}};w(Wn,"uuid","dd9ccf2d-8a21-4821-b7f6-2949add16a29");let Ma=Wn;const qn=class _n extends Tt{constructor(e){super(e),w(this,"enabled",!0),w(this,"onDisposed",new X),w(this,"list",new ft.PG),this.components.add(_n.uuid,this)}dispose(e=!0){this.list.clear(),this.onDisposed.trigger(_n.uuid),e&&(this.onDisposed.reset(),this.list.eventsEnabled=!1,this.list.dispose())}get(){const e=new b.NRn;for(const t of this.list)e.union(t);return e}addFromModelIdMap(e){var t=this;return(0,H.A)(function*(){const i=t.components.get(ct),s=new b.NRn;for(const[n,r]of Object.entries(e)){const a=i.list.get(n);if(!a)continue;const l=yield a.getMergedBox([...r]);s.union(l)}t.list.add(s)})()}addFromModels(e){const t=this.components.get(ct);for(const[i,s]of t.list)e&&!e.some(n=>n.test(i))||this.list.add(s.box)}getCenter(e){var t=this;return(0,H.A)(function*(){t.list.clear(),yield t.addFromModelIdMap(e);const i=t.get();t.list.clear();const s=new b.Pq0;return i.getCenter(s),s})()}getCameraOrientation(e){var t=this;return(0,H.A)(function*(i,s=1){const n=t.components.get(ct);t.list.clear();for(const[h,f]of n.list)t.list.add(f.box);const r=t.get();t.list.clear();const a=new b.Pq0;r.getCenter(a);const l=new b.Pq0;r.getSize(l);const c=Math.max(l.x,l.y,l.z)*s,u=new b.Pq0;switch(i){case"front":default:u.set(a.x,a.y,a.z+c);break;case"back":u.set(a.x,a.y,a.z-c);break;case"left":u.set(a.x-c,a.y,a.z);break;case"right":u.set(a.x+c,a.y,a.z);break;case"top":u.set(a.x,a.y+c,a.z);break;case"bottom":u.set(a.x,a.y-c,a.z)}return{position:u,target:a}}).apply(this,arguments)}};w(qn,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let Gn=qn;class Oa{constructor(e,t){w(this,"name","Query"),w(this,"customData",{}),w(this,"_components"),w(this,"_queries",[]),w(this,"_aggregation","exclusive"),w(this,"result",null),w(this,"cache",!0),w(this,"serializeQueryParameters",i=>{var s;return{categories:null==(s=i.categories)?void 0:s.map(r=>r.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}}),w(this,"deserializeQueryParameters",i=>{var s;return{categories:null==(s=i.categories)?void 0:s.map(r=>new RegExp(r)),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=e,this.queries=t}set queries(e){this._queries=e,this.clearCache()}get queries(){return this._queries}set aggregation(e){e!==this._aggregation&&this.clearCache(),this._aggregation=e}get aggregation(){return this._aggregation}test(e){var t=this;return(0,H.A)(function*(){const{modelIds:i,force:s}={force:!1,...e};if(t.result&&!s)return t.result;const r=yield t._components.get(si).getItems(t.queries,{modelIds:i,aggregation:t.aggregation});return t.cache&&(t.result=r),r})()}clearCache(){this.result=null}serializeAttributeQuery(e){let t;return t=Array.isArray(e.value)?e.value.map(s=>s.source):e.value instanceof RegExp?e.value.source:e.value,{name:e.name.source,value:t,type:e.type instanceof RegExp?e.type.source:e.type,negate:e.negate,itemIds:e.itemIds}}toJSON(){return{guid:this._components.get(si).list.getKey(this)??Yt.create(),name:this.name,customData:this.customData,queries:this.queries.map(this.serializeQueryParameters),aggregation:this.aggregation,cache:this.cache}}deserializeAttributeQuery(e){let t;return t=Array.isArray(e.value)?e.value.map(s=>new RegExp(s)):"string"==typeof e.value?new RegExp(e.value):e.value,{name:new RegExp(e.name),value:t,type:e.type?new RegExp(e.type):void 0,negate:e.negate,itemIds:e.itemIds}}fromJSON(e){return this.name=e.name,this.customData=e.customData,this.aggregation=e.aggregation,this.cache=e.cache,this.queries=e.queries.map(this.deserializeQueryParameters),this}}const Xn=class po extends Tt{constructor(e){super(e),w(this,"enabled",!0),w(this,"list",new ft.jp),e.add(po.uuid,this)}getItems(e,t){var i=this;return(0,H.A)(function*(){let s;if(t){const{modelIds:c,items:u}=t;if(u){const h=Object.keys(u);h.length>0&&(s=h.map(f=>new RegExp(`^${f}$`)))}else c&&(s=c)}const n=t?.aggregation??"exclusive",r=i.components.get(ct),a=yield Promise.all(e.map(function(){var c=(0,H.A)(function*(u){const h={};return yield Promise.all(Array.from(r.list).map(function(){var f=(0,H.A)(function*([d,y]){var g;if(s&&!s.some(x=>x.test(d)))return;const _=null==(g=t?.items)?void 0:g[d],p=yield y.getItemsByQuery(u,{localIds:_?[..._]:void 0});h[d]=new Set(p)});return function(d){return f.apply(this,arguments)}}())),h});return function(u){return c.apply(this,arguments)}}()));return"inclusive"===n?Ft.join(a):Ft.intersect(a)})()}create(e,t){const i=new Oa(this.components,t);return this.list.set(e,i),i}addFromCategories(e){var t=this;return(0,H.A)(function*(){const i=new Set,s=t.components.get(ct);for(const[n,r]of s.list){if(e&&!e.some(c=>c.test(n)))continue;const a=(yield r.getItemsWithGeometryCategories()).filter(c=>null!==c),l=new Set(a);for(const c of l)t.list.has(c)||(t.create(c,[{categories:[new RegExp(`^${c}$`)]}]),i.add(c))}return[...i]})()}import(e){const{data:t}=e,i=[];if(!t)return i;for(const s of t){const n=this.create(s.guid,[]);n.fromJSON(s),i.push(n)}return i}export(){const e=[];for(const[t,i]of this.list.entries()){const n={...i.toJSON(),name:t};e.push(n)}return{data:e}}};w(Xn,"uuid","0da7ad77-f734-42ca-942f-a074adfd1e3a");let si=Xn;w(class mo extends Tt{constructor(e){var t;super(e),t=this,w(this,"enabled",!0),w(this,"onDisposed",new X),w(this,"list",new ft.jp),w(this,"defaultSaveFunction",s=>"value"in s.Name?s.Name.value:null),w(this,"onBeforeFragmentsDispose",function(){var s=(0,H.A)(function*(n){const{key:r,value:a}=n,l=yield a.getLocalIds(),c={[r]:new Set(l)};t.removeItems(c)});return function(n){return s.apply(this,arguments)}}()),e.add(mo.uuid,this),this.setupEvents(),e.get(ct).list.onBeforeDelete.add(this.onBeforeFragmentsDispose)}setupEvents(){this.list.onBeforeDelete.add(({value:e})=>e.dispose())}getClassificationGroups(e){let t=this.list.get(e);return t||(t=new ft.jp,this.list.set(e,t)),t}getModelItems(e,t,i){const{map:s}=this.getGroupData(e,t);let n=s[i];return n||(n=new Set,s[i]=n),n}getGroupData(e,t){const i=this.components.get(si),s=this.getClassificationGroups(e);let n=s.get(t);return n||(n={map:{},get:()=>new Promise(r=>{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(u=>{if(!n)return void r({});const h=Ft.join([u,n.map]);r(h)})}else r(n.map);else r({})})},s.set(t,n)),n}aggregateItems(e,t,i){var s=this;return(0,H.A)(function*(){const n=i?.data??void 0,r=i?.aggregationCallback??s.defaultSaveFunction,a=s.components.get(ct),c=yield s.components.get(si).getItems([t],{modelIds:i?.modelIds});for(const[u,h]of Object.entries(c)){const f=a.list.get(u);if(!f)continue;const d=(g,..._)=>{const p=s.getModelItems(e,g,u);for(const x of _)p.add(x)},y=yield f.getItemsData([...h],n);for(const g of y)r(g,d)}})()}addGroupItems(e,t,i){const{map:s}=this.getGroupData(e,t);Ft.add(s,i)}setGroupQuery(e,t,i){this.getGroupData(e,t).query=i}find(e){var t=this;return(0,H.A)(function*(){const i=[];for(const[n,r]of Object.entries(e)){const a=[],l=t.list.get(n);if(!l)continue;for(const u of r){const h=l.get(u);if(!h)continue;const f=yield h.get();a.push(f)}const c=Ft.join(a);i.push(c)}return Ft.intersect(i)})()}aggregateItemRelations(e,t,i,s){var n=this;return(0,H.A)(function*(){const r=s?.attribute??"Name",a={relations:{[i]:{attributes:!0,relations:!1}}};yield n.aggregateItems(e,t,{modelIds:s?.modelIds,data:a,aggregationCallback:(l,c)=>{if(!l?.[r])return;const u=l[r];if(!("value"in u))return;const h=l[i];if(Array.isArray(h))for(const f of h)"value"in f._localId&&c(u.value,f._localId.value)}})})()}byIfcBuildingStorey(e){var t=this;return(0,H.A)(function*(){yield t.aggregateItemRelations(e?.classificationName??"Storeys",{categories:[/BUILDINGSTOREY/]},"ContainsElements",{modelIds:e?.modelIds})})()}byCategory(e){var t=this;return(0,H.A)(function*(){const s=yield t.components.get(si).addFromCategories(e?.modelIds);for(const n of s)t.setGroupQuery(e?.classificationName??"Categories",n,{name:n})})()}dispose(){this.list.clear(),this.components.get(ct).list.onBeforeDelete.remove(this.onBeforeFragmentsDispose),this.onDisposed.trigger()}removeItems(e,t){if(t&&t.classificationName){const i=this.list.get(t.classificationName);if(!i||t.groupName&&!i.get(t.groupName))return;for(const[,s]of i)Ft.remove(s.map,e);return}for(const[,i]of this.list.entries())for(const[,s]of i)Ft.remove(s.map,e)}byModel(e){var t=this;return(0,H.A)(function*(){const i=t.components.get(ct),s=e?.classificationName??"Models";for(const[n,r]of i.list){if(e&&e.modelIds&&!e.modelIds.some(c=>c.test(n)))continue;const a=yield r.getItemsIdsWithGeometry(),l={[n]:new Set(a)};t.getGroupData(s,n),t.addGroupItems(s,n,l)}})()}},"uuid","e25a7f3c-46c4-4a14-9d3d-5115f24ebeb7");class ka{constructor(e,t){w(this,"enabled",!0),w(this,"components"),w(this,"onDisposed",new X),w(this,"mouse"),w(this,"world"),w(this,"debugMode",!1),w(this,"colorToModelId",new Map),w(this,"modelIdToColor",new Map),w(this,"renderTarget"),w(this,"renderTargetSize",new b.I9Y),w(this,"debugCanvas"),w(this,"debugContainer"),w(this,"colorMaterials",new Map),w(this,"originalMaterials",new Map),w(this,"originalLodColors",new Map),w(this,"colorsNeedUpdate",!0);const i=t.renderer;if(!i)throw new Error("A renderer is needed for the FastModelPicker to work!");this.world=t,this.mouse=new Yn(i.three.domElement),this.components=e,this.setupRenderTarget(),this.setupFragmentListeners()}setupFragmentListeners(){const e=this.components.get(ct);e.list.onItemSet.add(()=>{this.colorsNeedUpdate=!0}),e.list.onItemDeleted.add(()=>{this.colorsNeedUpdate=!0})}setupRenderTarget(){const t=this.world.renderer.three.getSize(new b.I9Y);this.renderTargetSize.copy(t),this.renderTarget=new b.nWS(t.x,t.y),this.renderTarget.texture.format=b.GWd,this.renderTarget.texture.type=b.OUM,this.debugMode&&this.setupDebugCanvas(),this.world.renderer.onResize.add(i=>{this.renderTargetSize.copy(i),this.renderTarget.setSize(i.x,i.y),this.debugCanvas&&(this.debugCanvas.width=i.x,this.debugCanvas.height=i.y)})}setupDebugCanvas(){if(this.debugCanvas)return;const e=this.world.renderer.three.getSize(new b.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=e.x,this.debugCanvas.height=e.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)}generateColorForModel(e){let t=0;for(let a=0;a<e.length;a++)t=(t<<5)-t+e.charCodeAt(a),t&=t;let i=Math.abs(t)%16777215;return 0===i&&(i=1),new b.Q1f((i>>16&255||1)/255,(i>>8&255||1)/255,(255&i||1)/255)}colorToId(e){return Math.round(255*e.r)<<16|Math.round(255*e.g)<<8|Math.round(255*e.b)}assignColors(){const e=this.components.get(ct);if(e.initialized){if(!this.colorsNeedUpdate){const t=new Set(e.list.keys()),i=new Set(this.modelIdToColor.keys());(t.size!==i.size||[...t].some(s=>!i.has(s)))&&(this.colorsNeedUpdate=!0)}if(this.colorsNeedUpdate){this.colorToModelId.clear(),this.modelIdToColor.clear();for(const t of this.colorMaterials.values())t.dispose();this.colorMaterials.clear();for(const[t]of e.list){const i=this.generateColorForModel(t),s=this.colorToId(i);this.colorToModelId.set(s,t),this.modelIdToColor.set(t,i);const n=new b.V9B({color:i,depthTest:!0,depthWrite:!0});this.colorMaterials.set(t,n)}this.colorsNeedUpdate=!1}}}applyColorMaterials(){const e=this.components.get(ct);if(e.initialized)for(const[t,i]of e.list){const s=this.colorMaterials.get(t);s&&i.object.traverse(n=>{if(n instanceof b.eaF){if("isLODGeometry"in n.geometry){const a=n.material[0].uniforms.lodColor;return this.originalLodColors.has(a)||this.originalLodColors.set(a,a.value),void(a.value=s.color)}this.originalMaterials.has(n)||this.originalMaterials.set(n,n.material),n.material=s}})}}restoreOriginalMaterials(){for(const[e,t]of this.originalMaterials)e.material=t;for(const[e,t]of this.originalLodColors)e.value=t;this.originalMaterials.clear()}renderColorCoded(){if(!this.renderTarget||!this.world.renderer)throw new Error("Render target not initialized!");const e=this.world.renderer.three,t=this.world.scene.three,i=this.world.camera.three,s=e.getRenderTarget(),n=e.autoClear,r=new b.Q1f,a=e.getClearAlpha();e.getClearColor(r),this.applyColorMaterials(),e.setRenderTarget(this.renderTarget),e.autoClear=!0,e.setClearColor(0,1),e.clear(!0,!0,!1),e.render(t,i),e.setRenderTarget(s),e.autoClear=n,e.setClearColor(r,a),this.restoreOriginalMaterials(),this.debugMode&&this.debugCanvas&&this.updateDebugCanvas()}updateDebugCanvas(){if(!this.debugCanvas||!this.renderTarget||!this.world.renderer)return;const e=this.world.renderer.three,t=this.renderTargetSize,i=new Uint8Array(t.x*t.y*4);e.readRenderTargetPixels(this.renderTarget,0,0,t.x,t.y,i);const s=this.debugCanvas.getContext("2d");if(!s)return;const n=s.createImageData(t.x,t.y),r=4*t.x;for(let a=0;a<t.y;a++){const u=a*r,h=(t.y-1-a)*r;n.data.set(i.subarray(u,u+r),h)}s.putImageData(n,0,0)}getModelAt(e){var t=this;return(0,H.A)(function*(){if(!t.renderTarget||!t.world.renderer)throw new Error("Render target not initialized!");const i=t.components.get(ct);if(!i.initialized||0===i.list.size)return null;t.assignColors(),t.renderColorCoded();const s=e||t.mouse.position,n=t.renderTargetSize,r=Math.floor(.5*(s.x+1)*n.x),a=Math.floor(.5*(s.y+1)*(n.y-1)),l=Math.max(0,Math.min(n.x-1,r)),c=Math.max(0,Math.min(n.y-1,a)),u=t.world.renderer.three,h=new Uint8Array(4);return u.readRenderTargetPixels(t.renderTarget,l,c,1,1,h),t.colorToModelId.get(h[0]<<16|h[1]<<8|h[2])||null})()}setDebugMode(e){this.debugMode=e,e?this.setupDebugCanvas():this.removeDebugCanvas()}removeDebugCanvas(){this.debugContainer&&(this.debugContainer.remove(),this.debugContainer=void 0,this.debugCanvas=void 0)}dispose(){this.mouse.dispose(),this.removeDebugCanvas();for(const e of this.colorMaterials.values())e.dispose();this.colorMaterials.clear(),this.renderTarget&&this.renderTarget.dispose(),this.colorToModelId.clear(),this.modelIdToColor.clear(),this.originalMaterials.clear(),this.originalLodColors.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}}const Qn=class go extends Tt{constructor(e){super(e),w(this,"enabled",!0),w(this,"list",new Map),w(this,"onDisposed",new X),e.add(go.uuid,this)}get(e){if(this.list.has(e.uuid))return this.list.get(e.uuid);const t=new ka(this.components,e);return this.list.set(e.uuid,t),e.onDisposed.add(()=>{this.delete(e)}),t}delete(e){const t=this.list.get(e.uuid);t&&t.dispose(),this.list.delete(e.uuid)}dispose(){for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger()}};w(Qn,"uuid","4a82430c-7ff2-49ea-9401-60807502dad6");let za=Qn;class Fa{constructor(e,t){w(this,"enabled",!0),w(this,"components"),w(this,"onDisposed",new X),w(this,"mouse"),w(this,"three",new b.tBo),w(this,"world"),w(this,"useFastModelPicking",!1);const i=t.renderer;if(!i)throw new Error("A renderer is needed for the raycaster to work!");this.world=t,this.mouse=new Yn(i.three.domElement),this.components=e}dispose(){this.mouse.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}castRayToObjects(e=Array.from(this.world.meshes),t=this.mouse.position){if(!this.world)throw new Error("A world is needed to cast rays!");return this.three.setFromCamera(t,this.world.camera.three),this.intersect(e)}castRay(e){var t=this;return(0,H.A)(function*(){const i=e?.snappingClasses,s=e?.items??Array.from(t.world.meshes),n=e?.position??t.mouse.position;if(!t.world)throw new Error("A world is needed to cast rays!");const r=t.world.camera.three,a=t.components.get(ct),l=t.world.renderer.three.domElement,c=t.mouse.rawPosition;let u=null;if(a.initialized){if(t.useFastModelPicking){const y=yield t.components.get(za).get(t.world).getModelAt(n);if(y){const g=a.list.get(y);if(g)if(i&&i.length>0){const _=yield g.raycastWithSnapping({camera:r,dom:l,mouse:c,snappingClasses:i});u=_&&_.length>0?_[0]:yield g.raycast({camera:r,dom:l,mouse:c})}else u=yield g.raycast({camera:r,dom:l,mouse:c})}}else u=yield a.raycast({camera:r,dom:l,mouse:c,snappingClasses:i});if(0===s.length)return u}t.three.setFromCamera(n,r);const h=t.intersect(s);return u?h&&h.distance<u.distance?h:u:h})()}castRayFromVector(e,t,i=Array.from(this.world.meshes)){return this.three.set(e,t),this.intersect(i)}intersect(e=Array.from(this.world.meshes)){const t=this.three.intersectObjects(e),i=this.filterClippingPlanes(t);return i.length>0?i[0]:null}filterClippingPlanes(e){if(!this.world.renderer)throw new Error("Renderer not found!");const t=this.world.renderer.three;if(!t.clippingPlanes)return e;const i=t.clippingPlanes;return e.length<=0||!i||i?.length<=0?e:e.filter(s=>i.every(n=>n.distanceToPoint(s.point)>0))}}const Kn=class _o extends Tt{constructor(e){super(e),w(this,"enabled",!0),w(this,"list",new Map),w(this,"onDisposed",new X),e.add(_o.uuid,this)}get(e){if(this.list.has(e.uuid))return this.list.get(e.uuid);const t=new Fa(this.components,e);return this.list.set(e.uuid,t),e.onDisposed.add(()=>{this.delete(e)}),t}delete(e){const t=this.list.get(e.uuid);t&&t.dispose(),this.list.delete(e.uuid)}dispose(){for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger()}};w(Kn,"uuid","d5d8bdf0-db25-4952-b951-b643af207ace");let Si=Kn;class Na extends fs{constructor(){var e;super(...arguments),e=this,w(this,"onCameraChanged",new X),w(this,"meshes",new Set),w(this,"onAfterUpdate",new X),w(this,"onBeforeUpdate",new X),w(this,"onDisposed",new X),w(this,"isDisposing",!1),w(this,"enabled",!0),w(this,"_dynamicAnchor",!1),w(this,"uuid",Yt.create()),w(this,"name"),w(this,"_scene"),w(this,"_camera"),w(this,"_renderer",null),w(this,"onPointerDown",function(){var t=(0,H.A)(function*(i){if(!e.camera.hasCameraControls())throw new Error("World: can't set dynamic anchor if the camera doesn't have controls.");const n=yield e.components.get(Si).get(e).castRay();n&&n.point&&0===i.button&&e.camera.controls.setOrbitPoint(n.point.x,n.point.y,n.point.z)});return function(i){return t.apply(this,arguments)}}()),w(this,"_defaultCamera")}set dynamicAnchor(e){var t;const i=null==(t=this.renderer)?void 0:t.three.domElement.parentElement;if(!i)throw new Error("World: the renderer must have a parentElement to set dynamic anchoring.");e?(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(e){this._defaultCamera=e}get scene(){if(!this._scene)throw new Error("No scene initialized!");return this._scene}set scene(e){this._scene=e,e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"})}get camera(){if(!this._camera)throw new Error("No camera initialized!");return this._camera}set camera(e){this._camera||(this.defaultCamera=e),this._camera=e,e.currentWorld=this,this.onCameraChanged.trigger(e)}get renderer(){return this._renderer}set renderer(e){this._renderer=e,e&&(e.worlds.set(this.uuid,this),e.currentWorld=this,e.onWorldChanged.trigger({world:this,action:"added"}))}useDefaultCamera(){this.camera=this.defaultCamera}update(e){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(e),this.camera.isUpdateable()&&this.camera.update(e),this.renderer&&this.renderer.update(e),this.onAfterUpdate.trigger()))}dispose(e=!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"}),e){const i=this.components.get(Je);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(bs).list.delete(this.uuid),this.onDisposed.trigger(),this.onDisposed.reset()}}class Da{constructor(e,t){w(this,"_list"),w(this,"_scene"),this._list=e,this._scene=t}get color(){return this._list.directionalLight.color.value}set color(e){this._list.directionalLight.color.value=e;for(const[,t]of this._scene.directionalLights)t.color.copy(e)}get intensity(){return this._list.directionalLight.intensity.value}set intensity(e){this._list.directionalLight.intensity.value=e;for(const[,t]of this._scene.directionalLights)t.intensity=e}get position(){return this._list.directionalLight.position.value.clone()}set position(e){this._list.directionalLight.position.value=e;for(const[,t]of this._scene.directionalLights)t.position.copy(e)}}class Ra{constructor(e,t){w(this,"_list"),w(this,"_scene"),this._list=e,this._scene=t}get color(){return this._list.ambientLight.color.value}set color(e){this._list.ambientLight.color.value=e;for(const[,t]of this._scene.ambientLights)t.color.copy(e)}get intensity(){return this._list.ambientLight.intensity.value}set intensity(e){this._list.ambientLight.intensity.value=e;for(const[,t]of this._scene.ambientLights)t.intensity=e}}class Ba extends ii{constructor(){super(...arguments),w(this,"_config",{backgroundColor:{value:new b.Q1f,type:"Color"},ambientLight:{color:{type:"Color",value:new b.Q1f},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2}},directionalLight:{color:{type:"Color",value:new b.Q1f},intensity:{type:"Number",interpolable:!0,min:0,max:10,value:2},position:{type:"Vector3",value:new b.Pq0}}}),w(this,"ambientLight",new Ra(this._config,this._component)),w(this,"directionalLight",new Da(this._config,this._component))}get backgroundColor(){return this._config.backgroundColor.value}set backgroundColor(e){this._config.backgroundColor.value=e,this._component.three.background=e}}class Jn extends ko{constructor(e){super(e),w(this,"onSetup",new X),w(this,"isSetup",!1),w(this,"three"),w(this,"config",new Ba(this,this.components,"Scene")),w(this,"_defaultConfig",{backgroundColor:new b.Q1f(2107698),directionalLight:{color:new b.Q1f("white"),intensity:1.5,position:new b.Pq0(5,10,3)},ambientLight:{color:new b.Q1f("white"),intensity:1}}),this.three=new b.Z58,this.three.background=new b.Q1f(2107698)}setup(e){const t={...this._defaultConfig,...e};this.config.backgroundColor=t.backgroundColor;const i=t.ambientLight;this.config.ambientLight.color=i.color,this.config.ambientLight.intensity=i.intensity;const s=t.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:r}=this.config.directionalLight,a=new b.ZyN(n,r);a.position.copy(s.position);const{color:l,intensity:c}=this.config.directionalLight,u=new b.$p8(l,c);this.three.add(a,u),this.directionalLights.set(a.uuid,a),this.ambientLights.set(u.uuid,u),this.isSetup=!0,this.onSetup.trigger()}dispose(){super.dispose(),this.components.get(Pi).list.delete(this.config.uuid)}}class ni extends Mo{constructor(e){super(e),w(this,"onBeforeUpdate",new X),w(this,"onAfterUpdate",new X),w(this,"onAspectUpdated",new X),w(this,"onDisposed",new X),w(this,"three"),w(this,"_resizeObserver",null),w(this,"_allControls",new Map),w(this,"updateAspect",()=>{var t;if(this.currentWorld&&this.currentWorld.renderer){if(this.three instanceof b.qUd)return void this.onAspectUpdated.trigger();if(null!=(t=this.currentWorld.renderer)&&t.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:t})=>{const i=this.newCameraControls();this.setupEvents(!0),this._allControls.set(t.uuid,i)}),this.worlds.onBeforeDelete.add(({value:t})=>{var i;const s=this._allControls.get(t.uuid);s&&(s.dispose(),this._allControls.delete(t.uuid)),null==(i=this._resizeObserver)||i.disconnect()})}get controls(){if(!this.currentWorld)throw new Error("This camera needs a world to work!");const e=this._allControls.get(this.currentWorld.uuid);if(!e)throw new Error("Controls not found!");return e}get enabled(){return null!==this.currentWorld&&this.controls.enabled}set enabled(e){null!==this.currentWorld&&(this.controls.enabled=e)}set currentWorld(e){super.currentWorld=e,e&&(this.worlds.get(e.uuid)||this.worlds.set(e.uuid,e))}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[e,t]of this._allControls)t.dispose();this.worlds.clear()}fitToItems(e){var t=this;return(0,H.A)(function*(){const i=yield t.getItemsBounding(e);yield t.controls.fitToSphere(i,!0)})()}setOrbitToItems(e){var t=this;return(0,H.A)(function*(){const i=yield t.getItemsBounding(e);t.controls.setOrbitPoint(i.center.x,i.center.y,i.center.z)})()}update(e){this.enabled&&(this.onBeforeUpdate.trigger(this),this.controls.update(e),this.onAfterUpdate.trigger(this))}getItemsBounding(e){var t=this;return(0,H.A)(function*(){const i=t.components.get(ct),s=t.components.get(Gn);s.list.clear();const n=new b.iyt;if(e)yield s.addFromModelIdMap(e);else for(const[,r]of i.list)s.list.add(r.box);return s.get().getBoundingSphere(n),s.list.clear(),n})()}setupCamera(){const e=window.innerWidth/window.innerHeight,t=new b.ubm(60,e,1,1e3);return t.position.set(50,50,50),t.lookAt(new b.Pq0(0,0,0)),t}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!");Bt.install({THREE:ni.getSubsetOfThree()});const{domElement:e}=this.currentWorld.renderer.three,t=new Bt(this.three,e);return t.smoothTime=.2,t.dollyToCursor=!0,t.infinityDolly=!0,t.minDistance=6,t}setupEvents(e){if(this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),e){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:t}=this.currentWorld.renderer.three;this._resizeObserver=new ResizeObserver(this.updateAspect),this._resizeObserver.observe(t)}}static getSubsetOfThree(){return{MOUSE:b.kBv,Vector2:b.I9Y,Vector3:b.Pq0,Vector4:b.IUQ,Quaternion:b.PTz,Matrix4:b.kn4,Spherical:b.YHV,Box3:b.NRn,Sphere:b.iyt,Raycaster:b.tBo,MathUtils:b.cj9}}}const tr=class yo extends Tt{constructor(e){super(e),w(this,"onAfterUpdate",new X),w(this,"onBeforeUpdate",new X),w(this,"onDisposed",new X),w(this,"list",new ft.jp),w(this,"enabled",!0),e.add(yo.uuid,this)}create(){const e=new Na(this.components),t=e.uuid;if(this.list.has(t))throw new Error("There is already a world with this name!");return this.list.set(t,e),e}delete(e){if(!this.list.has(e.uuid))throw new Error("The provided world is not found in the list!");this.list.delete(e.uuid),e.dispose()}dispose(){this.enabled=!1;for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger()}update(e){if(this.enabled)for(const[t,i]of this.list)i.update(e)}};w(tr,"uuid","fdb61dc4-2ec1-4966-b83d-54ea795fad4a");let bs=tr;class Va extends ii{constructor(){super(...arguments),w(this,"_config",{visible:{value:!0,type:"Boolean"},color:{value:new b.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(e){this._config.visible.value=e,this._component.visible=e}get color(){return this._config.color.value}set color(e){this._config.color.value=e,this._component.material.uniforms.uColor.value=e,this._component.material.uniformsNeedUpdate=!0}get primarySize(){return this._config.primarySize.value}set primarySize(e){this._config.primarySize.value=e,this._component.material.uniforms.uSize1.value=e,this._component.material.uniformsNeedUpdate=!0}get secondarySize(){return this._config.secondarySize.value}set secondarySize(e){this._config.secondarySize.value=e,this._component.material.uniforms.uSize2.value=e,this._component.material.uniformsNeedUpdate=!0}get distance(){return this._config.distance.value}set distance(e){this._config.distance.value=e,this._component.material.uniforms.uDistance.value=e,this._component.material.uniformsNeedUpdate=!0}}class Ua{constructor(e,t){w(this,"onDisposed",new X),w(this,"onSetup",new X),w(this,"isSetup",!1),w(this,"world"),w(this,"components"),w(this,"config"),w(this,"_defaultConfig",{visible:!0,color:new b.Q1f(12303291),primarySize:1,secondarySize:10,distance:500}),w(this,"three"),w(this,"_fade",3),w(this,"updateZoom",()=>{this.world.camera instanceof ni&&(this.material.uniforms.uZoom.value=this.world.camera.three.zoom)}),this.world=t;const{color:i,primarySize:s,secondarySize:n,distance:r}=this._defaultConfig;this.components=e,this.config=new Va(this,this.components,"Grid");const a=new b.bdM(2,2,1,1),l=new b.BKk({side:b.$EB,uniforms:{uSize1:{value:s},uSize2:{value:n},uColor:{value:i},uDistance:{value:r},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 b.eaF(a,l),this.three.frustumCulled=!1,t.scene.three.add(this.three),this.setupEvents(!0)}get visible(){return this.three.visible}set visible(e){this.three.visible=e,e?this.world.scene.three.add(this.three):this.three.removeFromParent()}get material(){return this.three.material}get fade(){return 3===this._fade}set fade(e){this._fade=e?3:0,this.material.uniforms.uFade.value=this._fade}setup(e){const t={...this._defaultConfig,...e};this.config.visible=!0,this.config.color=t.color,this.config.primarySize=t.primarySize,this.config.secondarySize=t.secondarySize,this.config.distance=t.distance,this.isSetup=!0,this.onSetup.trigger()}dispose(){this.setupEvents(!1),this.components.get(Pi).list.delete(this.config.uuid),this.components.get(Je).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset(),this.world=null,this.components=null}setupEvents(e){if(this.world.isDisposing||!(this.world.camera instanceof ni))return;const t=this.world.camera.controls;e?t.addEventListener("update",this.updateZoom):t.removeEventListener("update",this.updateZoom)}}w(class vo extends Tt{constructor(e){super(e),w(this,"list",new Map),w(this,"onDisposed",new X),w(this,"enabled",!0),e.add(vo.uuid,this)}create(e){if(this.list.has(e.uuid))throw new Error("This world already has a grid!");const t=new Ua(this.components,e);return this.list.set(e.uuid,t),e.onDisposed.add(()=>{this.delete(e)}),t}delete(e){const t=this.list.get(e.uuid);t&&t.dispose(),this.list.delete(e.uuid)}dispose(){for(const[e,t]of this.list)t.dispose();this.list.clear(),this.onDisposed.trigger(),this.onDisposed.reset()}},"uuid","d1e814d5-b81c-4452-87a2-f039375e0489");const Mi=65535,Ha=Math.pow(2,-24),Cs=Symbol("SKIP_GENERATION");function Fe(o){return function Ya(o){return o.index?o.index.count:o.attributes.position.count}(o)/3}function nr(o){const e=Fe(o),t=o.drawRange,s=(t.start+t.count)/3,n=Math.max(0,t.start/3),r=Math.min(e,s)-n;return[{offset:Math.floor(n),count:Math.floor(r)}]}function rr(o){if(!o.groups||!o.groups.length)return nr(o);const e=[],t=new Set,i=o.drawRange,s=i.start/3,n=(i.start+i.count)/3;for(const a of o.groups){const c=(a.start+a.count)/3;t.add(Math.max(s,a.start/3)),t.add(Math.min(n,c))}const r=Array.from(t.values()).sort((a,l)=>a-l);for(let a=0;a<r.length-1;a++){const l=r[a],c=r[a+1];e.push({offset:Math.floor(l),count:Math.floor(c-l)})}return e}function Mt(o,e,t){return t.min.x=e[o],t.min.y=e[o+1],t.min.z=e[o+2],t.max.x=e[o+3],t.max.y=e[o+4],t.max.z=e[o+5],t}function or(o){let e=-1,t=-1/0;for(let i=0;i<3;i++){const s=o[i+3]-o[i];s>t&&(t=s,e=i)}return e}function ar(o,e){e.set(o)}function lr(o,e,t){let i,s;for(let n=0;n<3;n++){const r=n+3;i=o[n],s=e[n],t[n]=i<s?i:s,i=o[r],s=e[r],t[r]=i>s?i:s}}function Oi(o,e,t){for(let i=0;i<3;i++){const s=e[o+2*i],n=e[o+2*i+1],r=s-n,a=s+n;r<t[i]&&(t[i]=r),a>t[i+3]&&(t[i+3]=a)}}function ri(o){const e=o[3]-o[0],t=o[4]-o[1],i=o[5]-o[2];return 2*(e*t+t*i+i*e)}function Ts(o,e,t,i,s=null){let n=1/0,r=1/0,a=1/0,l=-1/0,c=-1/0,u=-1/0,h=1/0,f=1/0,d=1/0,y=-1/0,g=-1/0,_=-1/0;const p=null!==s;for(let x=6*e,E=6*(e+t);x<E;x+=6){const T=o[x+0],A=o[x+1],M=T-A,S=T+A;M<n&&(n=M),S>l&&(l=S),p&&T<h&&(h=T),p&&T>y&&(y=T);const z=o[x+2],O=o[x+3],N=z-O,Z=z+O;N<r&&(r=N),Z>c&&(c=Z),p&&z<f&&(f=z),p&&z>g&&(g=z);const P=o[x+4],F=o[x+5],v=P-F,R=P+F;v<a&&(a=v),R>u&&(u=R),p&&P<d&&(d=P),p&&P>_&&(_=P)}i[0]=n,i[1]=r,i[2]=a,i[3]=l,i[4]=c,i[5]=u,p&&(s[0]=h,s[1]=f,s[2]=d,s[3]=y,s[4]=g,s[5]=_)}const Ka=(o,e)=>o.candidate-e.candidate,_e=new Array(32).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),ki=new Float32Array(6);class zi{constructor(){}}function el(o,e,t,i,s,n){let r=i,a=i+s-1;const l=n.pos,c=2*n.axis;for(;;){for(;r<=a&&t[6*r+c]<l;)r++;for(;r<=a&&t[6*a+c]>=l;)a--;if(!(r<a))return r;for(let u=0;u<3;u++){let h=e[3*r+u];e[3*r+u]=e[3*a+u],e[3*a+u]=h}for(let u=0;u<6;u++){let h=t[6*r+u];t[6*r+u]=t[6*a+u],t[6*a+u]=h}r++,a--}}function il(o,e,t,i,s,n){let r=i,a=i+s-1;const l=n.pos,c=2*n.axis;for(;;){for(;r<=a&&t[6*r+c]<l;)r++;for(;r<=a&&t[6*a+c]>=l;)a--;if(!(r<a))return r;{let u=o[r];o[r]=o[a],o[a]=u;for(let h=0;h<6;h++){let f=t[6*r+h];t[6*r+h]=t[6*a+h],t[6*a+h]=f}r++,a--}}}function rl(o,e){const t=o.geometry;e.indirect&&(o._indirectBuffer=function sl(o,e){const t=(o.index?o.index.count:o.attributes.position.count)/3,i=t>65536,s=i?4:2,n=e?new SharedArrayBuffer(t*s):new ArrayBuffer(t*s),r=i?new Uint32Array(n):new Uint16Array(n);for(let a=0,l=r.length;a<l;a++)r[a]=a;return r}(t,e.useSharedArrayBuffer),function qa(o){if(0===o.groups.length)return!1;const e=Fe(o),t=rr(o).sort((n,r)=>n.offset-r.offset),i=t[t.length-1];i.count=Math.min(e-i.offset,i.count);let s=0;return t.forEach(({count:n})=>s+=n),e!==s}(t)&&!e.verbose&&console.warn('MeshBVH: Provided geometry contains groups that do not fully span the vertex contents while using the "indirect" option. BVH may incorrectly report intersections on unrendered portions of the geometry.')),o._indirectBuffer||function Wa(o,e){if(!o.index){const t=o.attributes.position.count,s=function Za(o,e=ArrayBuffer){return o>65535?new Uint32Array(new e(4*o)):new Uint16Array(new e(2*o))}(t,e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer);o.setIndex(new b.THS(s,1));for(let n=0;n<t;n++)s[n]=n}}(t,e);const i=function nl(o,e){const t=o.geometry,i=t.index?t.index.array:null,s=e.maxDepth,n=e.verbose,r=e.maxLeafTris,a=e.strategy,l=e.onProgress,c=Fe(t),u=o._indirectBuffer;let h=!1;const f=new Float32Array(6),d=new Float32Array(6),y=function Qa(o,e){!function Ga(o){o[0]=o[1]=o[2]=1/0,o[3]=o[4]=o[5]=-1/0}(e);const t=o.attributes.position,i=o.index?o.index.array:null,s=Fe(o),n=new Float32Array(6*s),r=t.normalized,a=t.array,l=t.offset||0;let c=3;t.isInterleavedBufferAttribute&&(c=t.data.stride);const u=["getX","getY","getZ"];for(let h=0;h<s;h++){const f=3*h,d=6*h;let y=f+0,g=f+1,_=f+2;i&&(y=i[y],g=i[g],_=i[_]),r||(y=y*c+l,g=g*c+l,_=_*c+l);for(let p=0;p<3;p++){let x,E,T;r?(x=t[u[p]](y),E=t[u[p]](g),T=t[u[p]](_)):(x=a[y+p],E=a[g+p],T=a[_+p]);let A=x;E<A&&(A=E),T<A&&(A=T);let M=x;E>M&&(M=E),T>M&&(M=T);const S=(M-A)/2,z=2*p;n[d+z+0]=A+S,n[d+z+1]=S+(Math.abs(A)+S)*Ha,A<e[p]&&(e[p]=A),M>e[p+3]&&(e[p+3]=M)}}return n}(t,f),g=e.indirect?il:el,_=[],p=e.indirect?nr(t):rr(t);if(1===p.length){const T=p[0],A=new zi;A.boundingData=f,function Xa(o,e,t,i){let s=1/0,n=1/0,r=1/0,a=-1/0,l=-1/0,c=-1/0;for(let u=6*e,h=6*(e+t);u<h;u+=6){const f=o[u+0];f<s&&(s=f),f>a&&(a=f);const d=o[u+2];d<n&&(n=d),d>l&&(l=d);const y=o[u+4];y<r&&(r=y),y>c&&(c=y)}i[0]=s,i[1]=n,i[2]=r,i[3]=a,i[4]=l,i[5]=c}(y,T.offset,T.count,d),E(A,T.offset,T.count,d),_.push(A)}else for(let T of p){const A=new zi;A.boundingData=new Float32Array(6),Ts(y,T.offset,T.count,A.boundingData,d),E(A,T.offset,T.count,d),_.push(A)}return _;function x(T){l&&l(T/c)}function E(T,A,M,S=null,z=0){if(!h&&z>=s&&(h=!0,n&&(console.warn(`MeshBVH: Max depth of ${s} reached when generating BVH. Consider increasing maxDepth.`),console.warn(t))),M<=r||z>=s)return x(A+M),T.offset=A,T.count=M,T;const O=function Ja(o,e,t,i,s,n){let r=-1,a=0;if(0===n)r=or(e),-1!==r&&(a=(e[r]+e[r+3])/2);else if(1===n)r=or(o),-1!==r&&(a=function tl(o,e,t,i){let s=0;for(let n=e,r=e+t;n<r;n++)s+=o[6*n+2*i];return s/t}(t,i,s,r));else if(2===n){const l=ri(o);let c=1.25*s;const u=6*i,h=6*(i+s);for(let f=0;f<3;f++){const d=e[f],_=(e[f+3]-d)/32;if(s<8){const p=[..._e];p.length=s;let x=0;for(let T=u;T<h;T+=6,x++){const A=p[x];A.candidate=t[T+2*f],A.count=0;const{bounds:M,leftCacheBounds:S,rightCacheBounds:z}=A;for(let O=0;O<3;O++)z[O]=1/0,z[O+3]=-1/0,S[O]=1/0,S[O+3]=-1/0,M[O]=1/0,M[O+3]=-1/0;Oi(T,t,M)}p.sort(Ka);let E=s;for(let T=0;T<E;T++){const A=p[T];for(;T+1<E&&p[T+1].candidate===A.candidate;)p.splice(T+1,1),E--}for(let T=u;T<h;T+=6){const A=t[T+2*f];for(let M=0;M<E;M++){const S=p[M];A>=S.candidate?Oi(T,t,S.rightCacheBounds):(Oi(T,t,S.leftCacheBounds),S.count++)}}for(let T=0;T<E;T++){const A=p[T],M=A.count,S=s-A.count,O=A.rightCacheBounds;let N=0;0!==M&&(N=ri(A.leftCacheBounds)/l);let Z=0;0!==S&&(Z=ri(O)/l);const P=1+1.25*(N*M+Z*S);P<c&&(r=f,c=P,a=A.candidate)}}else{for(let E=0;E<32;E++){const T=_e[E];T.count=0,T.candidate=d+_+E*_;const A=T.bounds;for(let M=0;M<3;M++)A[M]=1/0,A[M+3]=-1/0}for(let E=u;E<h;E+=6){let M=~~((t[E+2*f]-d)/_);M>=32&&(M=31);const S=_e[M];S.count++,Oi(E,t,S.bounds)}const p=_e[31];ar(p.bounds,p.rightCacheBounds);for(let E=30;E>=0;E--){const T=_e[E];lr(T.bounds,_e[E+1].rightCacheBounds,T.rightCacheBounds)}let x=0;for(let E=0;E<31;E++){const T=_e[E],A=T.count,M=T.bounds,z=_e[E+1].rightCacheBounds;0!==A&&(0===x?ar(M,ki):lr(M,ki,ki)),x+=A;let O=0,N=0;0!==x&&(O=ri(ki)/l);const Z=s-x;0!==Z&&(N=ri(z)/l);const P=1+1.25*(O*x+N*Z);P<c&&(r=f,c=P,a=T.candidate)}}}}else console.warn(`MeshBVH: Invalid build strategy value ${n} used.`);return{axis:r,pos:a}}(T.boundingData,S,y,A,M,a);if(-1===O.axis)return x(A+M),T.offset=A,T.count=M,T;const N=g(u,i,y,A,M,O);if(N===A||N===A+M)x(A+M),T.offset=A,T.count=M;else{T.splitAxis=O.axis;const Z=new zi,P=A,F=N-A;T.left=Z,Z.boundingData=new Float32Array(6),Ts(y,P,F,Z.boundingData,d),E(Z,P,F,d,z+1);const v=new zi,R=N,Q=M-F;T.right=v,v.boundingData=new Float32Array(6),Ts(y,R,Q,v.boundingData,d),E(v,R,Q,d,z+1)}return T}}(o,e);let s,n,r;const a=[],l=e.useSharedArrayBuffer?SharedArrayBuffer:ArrayBuffer;for(let h=0;h<i.length;h++){const f=i[h],y=new l(32*c(f));s=new Float32Array(y),n=new Uint32Array(y),r=new Uint16Array(y),u(0,f),a.push(y)}return void(o._roots=a);function c(h){return h.count?1:1+c(h.left)+c(h.right)}function u(h,f){const d=h/4,y=h/2,g=!!f.count,_=f.boundingData;for(let p=0;p<6;p++)s[d+p]=_[p];if(g){const x=f.count;return n[d+6]=f.offset,r[y+14]=x,r[y+15]=Mi,h+32}{const x=f.right,E=f.splitAxis;let T;if(T=u(h+32,f.left),T/4>Math.pow(2,32))throw new Error("MeshBVH: Cannot store child pointer greater than 32 bits.");return n[d+6]=T/4,T=u(T,x),n[d+7]=E,T}}}class he{constructor(){this.min=1/0,this.max=-1/0}setFromPointsField(e,t){let i=1/0,s=-1/0;for(let n=0,r=e.length;n<r;n++){const l=e[n][t];i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}setFromPoints(e,t){let i=1/0,s=-1/0;for(let n=0,r=t.length;n<r;n++){const l=e.dot(t[n]);i=l<i?l:i,s=l>s?l:s}this.min=i,this.max=s}isSeparated(e){return this.min>e.max||e.min>this.max}}he.prototype.setFromBox=function(){const o=new b.Pq0;return function(t,i){const s=i.min,n=i.max;let r=1/0,a=-1/0;for(let l=0;l<=1;l++)for(let c=0;c<=1;c++)for(let u=0;u<=1;u++){o.x=s.x*l+n.x*(1-l),o.y=s.y*c+n.y*(1-c),o.z=s.z*u+n.z*(1-u);const h=t.dot(o);r=Math.min(h,r),a=Math.max(h,a)}this.min=r,this.max=a}}();const ol=function(){const o=new b.Pq0,e=new b.Pq0,t=new b.Pq0;return function(s,n,r){const l=o,u=e;t.subVectors(s.start,n.start),o.subVectors(s.end,s.start),e.subVectors(n.end,n.start);const h=t.dot(u),f=u.dot(l),d=u.dot(u),y=t.dot(l),_=l.dot(l)*d-f*f;let p,x;p=0!==_?(h*f-y*d)/_:0,x=(h+p*f)/d,r.x=p,r.y=x}}(),Es=function(){const o=new b.I9Y,e=new b.Pq0,t=new b.Pq0;return function(s,n,r,a){ol(s,n,o);let l=o.x,c=o.y;if(l>=0&&l<=1&&c>=0&&c<=1)return s.at(l,r),void n.at(c,a);if(l>=0&&l<=1)return n.at(c<0?0:1,a),void s.closestPointToPoint(a,!0,r);if(c>=0&&c<=1)return s.at(l<0?0:1,r),void n.closestPointToPoint(r,!0,a);{let u,h;u=l<0?s.start:s.end,h=c<0?n.start:n.end;const f=e,d=t;return s.closestPointToPoint(h,!0,e),n.closestPointToPoint(u,!0,t),f.distanceToSquared(h)<=d.distanceToSquared(u)?(r.copy(f),void a.copy(h)):(r.copy(u),void a.copy(d))}}}(),al=function(){const o=new b.Pq0,e=new b.Pq0,t=new b.Zcv,i=new b.cZY;return function(n,r){const{radius:a,center:l}=n,{a:c,b:u,c:h}=r;if(i.start=c,i.end=u,i.closestPointToPoint(l,!0,o).distanceTo(l)<=a||(i.start=c,i.end=h,i.closestPointToPoint(l,!0,o).distanceTo(l)<=a)||(i.start=u,i.end=h,i.closestPointToPoint(l,!0,o).distanceTo(l)<=a))return!0;const g=r.getPlane(t);if(Math.abs(g.distanceToPoint(l))<=a){const p=g.projectPoint(l,e);if(r.containsPoint(p))return!0}return!1}}();function As(o){return Math.abs(o)<1e-15}class se extends b.lMl{constructor(...e){super(...e),this.isExtendedTriangle=!0,this.satAxes=new Array(4).fill().map(()=>new b.Pq0),this.satBounds=new Array(4).fill().map(()=>new he),this.points=[this.a,this.b,this.c],this.sphere=new b.iyt,this.plane=new b.Zcv,this.needsUpdate=!0}intersectsSphere(e){return al(e,this)}update(){const e=this.a,t=this.b,i=this.c,s=this.points,n=this.satAxes,r=this.satBounds,a=n[0],l=r[0];this.getNormal(a),l.setFromPoints(a,s);const c=n[1],u=r[1];c.subVectors(e,t),u.setFromPoints(c,s);const h=n[2],f=r[2];h.subVectors(t,i),f.setFromPoints(h,s);const d=n[3],y=r[3];d.subVectors(i,e),y.setFromPoints(d,s),this.sphere.setFromPoints(this.points),this.plane.setFromNormalAndCoplanarPoint(a,e),this.needsUpdate=!1}}se.prototype.closestPointToSegment=function(){const o=new b.Pq0,e=new b.Pq0,t=new b.cZY;return function(s,n=null,r=null){const{start:a,end:l}=s,c=this.points;let u,h=1/0;for(let f=0;f<3;f++){const d=(f+1)%3;t.start.copy(c[f]),t.end.copy(c[d]),Es(t,s,o,e),u=o.distanceToSquared(e),u<h&&(h=u,n&&n.copy(o),r&&r.copy(e))}return this.closestPointToPoint(a,o),u=a.distanceToSquared(o),u<h&&(h=u,n&&n.copy(o),r&&r.copy(a)),this.closestPointToPoint(l,o),u=l.distanceToSquared(o),u<h&&(h=u,n&&n.copy(o),r&&r.copy(l)),Math.sqrt(h)}}(),se.prototype.intersectsTriangle=function(){const o=new se,e=new Array(3),t=new Array(3),i=new he,s=new he,n=new b.Pq0,r=new b.Pq0,a=new b.Pq0,l=new b.Pq0,c=new b.Pq0,u=new b.cZY,h=new b.cZY,f=new b.cZY,d=new b.Pq0;function y(g,_,p){const x=g.points;let E=0,T=-1;for(let A=0;A<3;A++){const{start:M,end:S}=u;M.copy(x[A]),S.copy(x[(A+1)%3]),u.delta(r);const z=As(_.distanceToPoint(M));if(As(_.normal.dot(r))&&z){p.copy(u),E=2;break}const O=_.intersectLine(u,d);if(!O&&z&&d.copy(M),(O||z)&&!As(d.distanceTo(S))){if(E<=1)(1===E?p.start:p.end).copy(d),z&&(T=E);else if(E>=2){(1===T?p.start:p.end).copy(d),E=2;break}if(E++,2===E&&-1===T)break}}return E}return function(_,p=null,x=!1){this.needsUpdate&&this.update(),_.isExtendedTriangle?_.needsUpdate&&_.update():(o.copy(_),o.update(),_=o);const E=this.plane,T=_.plane;if(Math.abs(E.normal.dot(T.normal))>1-1e-10){const A=this.satBounds,M=this.satAxes;t[0]=_.a,t[1]=_.b,t[2]=_.c;for(let O=0;O<4;O++){const N=A[O];if(i.setFromPoints(M[O],t),N.isSeparated(i))return!1}const S=_.satBounds,z=_.satAxes;e[0]=this.a,e[1]=this.b,e[2]=this.c;for(let O=0;O<4;O++){const N=S[O];if(i.setFromPoints(z[O],e),N.isSeparated(i))return!1}for(let O=0;O<4;O++){const N=M[O];for(let Z=0;Z<4;Z++)if(n.crossVectors(N,z[Z]),i.setFromPoints(n,e),s.setFromPoints(n,t),i.isSeparated(s))return!1}return p&&(x||console.warn("ExtendedTriangle.intersectsTriangle: Triangles are coplanar which does not support an output edge. Setting edge to 0, 0, 0."),p.start.set(0,0,0),p.end.set(0,0,0)),!0}{const A=y(this,T,h);if(1===A&&_.containsPoint(h.end))return p&&(p.start.copy(h.end),p.end.copy(h.end)),!0;if(2!==A)return!1;const M=y(_,E,f);if(1===M&&this.containsPoint(f.end))return p&&(p.start.copy(f.end),p.end.copy(f.end)),!0;if(2!==M)return!1;if(h.delta(a),f.delta(l),a.dot(l)<0){let F=f.start;f.start=f.end,f.end=F}const S=h.start.dot(a),z=h.end.dot(a),O=f.start.dot(a),N=f.end.dot(a);return(S===N||O===z||z<O!=S<N)&&(p&&(c.subVectors(h.start,f.start),c.dot(a)>0?p.start.copy(h.start):p.start.copy(f.start),c.subVectors(h.end,f.end),c.dot(a)<0?p.end.copy(h.end):p.end.copy(f.end)),!0)}}}(),se.prototype.distanceToPoint=function(){const o=new b.Pq0;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}(),se.prototype.distanceToTriangle=function(){const o=new b.Pq0,e=new b.Pq0,t=["a","b","c"],i=new b.cZY,s=new b.cZY;return function(r,a=null,l=null){const c=a||l?i:null;if(this.intersectsTriangle(r,c))return(a||l)&&(a&&c.getCenter(a),l&&c.getCenter(l)),0;let u=1/0;for(let h=0;h<3;h++){let f;const d=t[h],y=r[d];this.closestPointToPoint(y,o),f=y.distanceToSquared(o),f<u&&(u=f,a&&a.copy(o),l&&l.copy(y));const g=this[d];r.closestPointToPoint(g,o),f=g.distanceToSquared(o),f<u&&(u=f,a&&a.copy(g),l&&l.copy(o))}for(let h=0;h<3;h++){i.set(this[t[h]],this[t[(h+1)%3]]);for(let y=0;y<3;y++){s.set(r[t[y]],r[t[(y+1)%3]]),Es(i,s,o,e);const p=o.distanceToSquared(e);p<u&&(u=p,a&&a.copy(o),l&&l.copy(e))}}return Math.sqrt(u)}}();class $t{constructor(e,t,i){this.isOrientedBox=!0,this.min=new b.Pq0,this.max=new b.Pq0,this.matrix=new b.kn4,this.invMatrix=new b.kn4,this.points=new Array(8).fill().map(()=>new b.Pq0),this.satAxes=new Array(3).fill().map(()=>new b.Pq0),this.satBounds=new Array(3).fill().map(()=>new he),this.alignedSatBounds=new Array(3).fill().map(()=>new he),this.needsUpdate=!1,e&&this.min.copy(e),t&&this.max.copy(t),i&&this.matrix.copy(i)}set(e,t,i){this.min.copy(e),this.max.copy(t),this.matrix.copy(i),this.needsUpdate=!0}copy(e){this.min.copy(e.min),this.max.copy(e.max),this.matrix.copy(e.matrix),this.needsUpdate=!0}}$t.prototype.update=function(){return function(){const e=this.matrix,t=this.min,i=this.max,s=this.points;for(let c=0;c<=1;c++)for(let u=0;u<=1;u++)for(let h=0;h<=1;h++){const d=s[1*c|2*u|4*h];d.x=c?i.x:t.x,d.y=u?i.y:t.y,d.z=h?i.z:t.z,d.applyMatrix4(e)}const n=this.satBounds,r=this.satAxes,a=s[0];for(let c=0;c<3;c++){const u=r[c],h=n[c];u.subVectors(a,s[1<<c]),h.setFromPoints(u,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}}(),$t.prototype.intersectsBox=function(){const o=new he;return function(t){this.needsUpdate&&this.update();const i=t.min,s=t.max,n=this.satBounds,r=this.satAxes,a=this.alignedSatBounds;if(o.min=i.x,o.max=s.x,a[0].isSeparated(o)||(o.min=i.y,o.max=s.y,a[1].isSeparated(o))||(o.min=i.z,o.max=s.z,a[2].isSeparated(o)))return!1;for(let l=0;l<3;l++){const u=n[l];if(o.setFromBox(r[l],t),u.isSeparated(o))return!1}return!0}}(),$t.prototype.intersectsTriangle=function(){const o=new se,e=new Array(3),t=new he,i=new he,s=new b.Pq0;return function(r){this.needsUpdate&&this.update(),r.isExtendedTriangle?r.needsUpdate&&r.update():(o.copy(r),o.update(),r=o);const a=this.satBounds,l=this.satAxes;e[0]=r.a,e[1]=r.b,e[2]=r.c;for(let f=0;f<3;f++){const d=a[f];if(t.setFromPoints(l[f],e),d.isSeparated(t))return!1}const c=r.satBounds,u=r.satAxes,h=this.points;for(let f=0;f<3;f++){const d=c[f];if(t.setFromPoints(u[f],h),d.isSeparated(t))return!1}for(let f=0;f<3;f++){const d=l[f];for(let y=0;y<4;y++)if(s.crossVectors(d,u[y]),t.setFromPoints(s,e),i.setFromPoints(s,h),t.isSeparated(i))return!1}return!0}}(),$t.prototype.closestPointToPoint=function(){return function(e,t){return this.needsUpdate&&this.update(),t.copy(e).applyMatrix4(this.invMatrix).clamp(this.min,this.max).applyMatrix4(this.matrix),t}}(),$t.prototype.distanceToPoint=function(){const o=new b.Pq0;return function(t){return this.closestPointToPoint(t,o),t.distanceTo(o)}}(),$t.prototype.distanceToBox=function(){const o=["x","y","z"],e=new Array(12).fill().map(()=>new b.cZY),t=new Array(12).fill().map(()=>new b.cZY),i=new b.Pq0,s=new b.Pq0;return function(r,a=0,l=null,c=null){if(this.needsUpdate&&this.update(),this.intersectsBox(r))return(l||c)&&(r.getCenter(s),this.closestPointToPoint(s,i),r.closestPointToPoint(i,s),l&&l.copy(i),c&&c.copy(s)),0;const u=a*a,h=r.min,f=r.max,d=this.points;let y=1/0;for(let _=0;_<8;_++){const p=d[_];s.copy(p).clamp(h,f);const x=p.distanceToSquared(s);if(x<y&&(y=x,l&&l.copy(p),c&&c.copy(s),x<u))return Math.sqrt(x)}let g=0;for(let _=0;_<3;_++)for(let p=0;p<=1;p++)for(let x=0;x<=1;x++){const E=(_+1)%3,T=(_+2)%3;e[g].set(d[p<<E|x<<T],d[1<<_|p<<E|x<<T]);const N=o[_],Z=o[E],P=o[T],F=t[g],v=F.start,R=F.end;v[N]=h[N],v[Z]=p?h[Z]:f[Z],v[P]=x?h[P]:f[Z],R[N]=f[N],R[Z]=p?h[Z]:f[Z],R[P]=x?h[P]:f[Z],g++}for(let _=0;_<=1;_++)for(let p=0;p<=1;p++)for(let x=0;x<=1;x++){s.x=_?f.x:h.x,s.y=p?f.y:h.y,s.z=x?f.z:h.z,this.closestPointToPoint(s,i);const E=s.distanceToSquared(i);if(E<y&&(y=E,l&&l.copy(i),c&&c.copy(s),E<u))return Math.sqrt(E)}for(let _=0;_<12;_++){const p=e[_];for(let x=0;x<12;x++){Es(p,t[x],i,s);const T=i.distanceToSquared(s);if(T<y&&(y=T,l&&l.copy(i),c&&c.copy(s),T<u))return Math.sqrt(T)}}return Math.sqrt(y)}}();class Ps{constructor(e){this._getNewPrimitive=e,this._primitives=[]}getPrimitive(){const e=this._primitives;return 0===e.length?this._getNewPrimitive():e.pop()}releasePrimitive(e){this._primitives.push(e)}}class cl extends Ps{constructor(){super(()=>new se)}}const Xt=new cl;function qt(o,e){return 65535===e[o+15]}function Gt(o,e){return e[o+6]}function Qt(o,e){return e[o+14]}function Kt(o){return o+8}function Jt(o,e){return e[o+6]}function cr(o,e){return e[o+7]}const Et=new class ul{constructor(){this.float32Array=null,this.uint16Array=null,this.uint32Array=null;const e=[];let t=null;this.setBuffer=i=>{t&&e.push(t),t=i,this.float32Array=new Float32Array(i),this.uint16Array=new Uint16Array(i),this.uint32Array=new Uint32Array(i)},this.clearBuffer=()=>{t=null,this.float32Array=null,this.uint16Array=null,this.uint32Array=null,0!==e.length&&this.setBuffer(e.pop())}}};let ye,Ne;const De=[],Fi=new Ps(()=>new b.NRn);function hl(o,e,t,i,s,n){ye=Fi.getPrimitive(),Ne=Fi.getPrimitive(),De.push(ye,Ne),Et.setBuffer(o._roots[e]);const r=Ss(0,o.geometry,t,i,s,n);Et.clearBuffer(),Fi.releasePrimitive(ye),Fi.releasePrimitive(Ne),De.pop(),De.pop();const a=De.length;return a>0&&(Ne=De[a-1],ye=De[a-2]),r}function Ss(o,e,t,i,s=null,n=0,r=0){const{float32Array:a,uint16Array:l,uint32Array:c}=Et;let u=2*o;if(qt(u,l)){const f=Gt(o,c),d=Qt(u,l);return Mt(o,a,ye),i(f,d,!1,r,n+o,ye)}{let f=function(P){const{uint16Array:F,uint32Array:v}=Et;let R=2*P;for(;!qt(R,F);)R=2*(P=Kt(P));return Gt(P,v)},d=function(P){const{uint16Array:F,uint32Array:v}=Et;let R=2*P;for(;!qt(R,F);)R=2*(P=Jt(P,v));return Gt(P,v)+Qt(R,F)};const y=Kt(o),g=Jt(o,c);let x,E,T,A,_=y,p=g;if(s&&(T=ye,A=Ne,Mt(_,a,T),Mt(p,a,A),x=s(T),E=s(A),E<x)){_=g,p=y;const P=x;x=E,E=P,T=A}T||(T=ye,Mt(_,a,T));const S=t(T,qt(2*_,l),x,r+1,n+_);let z;if(2===S){const P=f(_);z=i(P,d(_)-P,!0,r+1,n+_,T)}else z=S&&Ss(_,e,t,i,s,n,r+1);if(z)return!0;A=Ne,Mt(p,a,A);const N=t(A,qt(2*p,l),E,r+1,n+p);let Z;if(2===N){const P=f(p);Z=i(P,d(p)-P,!0,r+1,n+p,A)}else Z=N&&Ss(p,e,t,i,s,n,r+1);return!!Z}}const oi=new b.Pq0,Is=new b.Pq0,Re=new b.Pq0,Be=new b.Pq0,Le=new b.Pq0,Ni=new b.I9Y,Di=new b.I9Y,Ri=new b.I9Y,ur=new b.Pq0,hr=new b.Pq0,dr=new b.Pq0,Bi=new b.Pq0;function Li(o,e,t,i,s){const n=3*i;let r=n+0,a=n+1,l=n+2;const c=o.index;o.index&&(r=c.getX(r),a=c.getX(a),l=c.getX(l));const{position:u,normal:h,uv:f,uv1:d}=o.attributes,y=function pl(o,e,t,i,s,n,r,a,l){Re.fromBufferAttribute(e,n),Be.fromBufferAttribute(e,r),Le.fromBufferAttribute(e,a);const c=function fl(o,e,t,i,s,n){let r;return r=n===b.hsX?o.intersectTriangle(i,t,e,!0,s):o.intersectTriangle(e,t,i,n!==b.$EB,s),null===r?null:{distance:o.origin.distanceTo(s),point:s.clone()}}(o,Re,Be,Le,Bi,l);if(c){i&&(Ni.fromBufferAttribute(i,n),Di.fromBufferAttribute(i,r),Ri.fromBufferAttribute(i,a),c.uv=b.lMl.getInterpolation(Bi,Re,Be,Le,Ni,Di,Ri,new b.I9Y)),s&&(Ni.fromBufferAttribute(s,n),Di.fromBufferAttribute(s,r),Ri.fromBufferAttribute(s,a),c.uv1=b.lMl.getInterpolation(Bi,Re,Be,Le,Ni,Di,Ri,new b.I9Y)),t&&(ur.fromBufferAttribute(t,n),hr.fromBufferAttribute(t,r),dr.fromBufferAttribute(t,a),c.normal=b.lMl.getInterpolation(Bi,Re,Be,Le,ur,hr,dr,new b.Pq0),c.normal.dot(o.direction)>0&&c.normal.multiplyScalar(-1));const u={a:n,b:r,c:a,normal:new b.Pq0,materialIndex:0};b.lMl.getNormal(Re,Be,Le,u.normal),c.face=u,c.faceIndex=n}return c}(t,u,h,f,d,r,a,l,e);return y?(y.faceIndex=i,s&&s.push(y),y):null}function Nt(o,e,t,i){const s=o.a,n=o.b,r=o.c;let a=e,l=e+1,c=e+2;t&&(a=t.getX(a),l=t.getX(l),c=t.getX(c)),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),r.x=i.getX(c),r.y=i.getY(c),r.z=i.getZ(c)}function _l(o,e,t,i,s,n,r){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let u=o,h=e+o;u<h;u++){let f;if(f=u,Nt(r,3*f,l,c),r.needsUpdate=!0,i(r,f,s,n))return!0}return!1}function yl(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let n,r,a,l,c=0;const u=o._roots;for(let f=0,d=u.length;f<d;f++)n=u[f],r=new Uint32Array(n),a=new Uint16Array(n),l=new Float32Array(n),h(0,c),c+=n.byteLength;function h(f,d,y=!1){const g=2*f;if(a[g+15]===Mi){const p=r[f+6];let E=1/0,T=1/0,A=1/0,M=-1/0,S=-1/0,z=-1/0;for(let O=3*p,N=3*(p+a[g+14]);O<N;O++){let Z=i[O];const P=s.getX(Z),F=s.getY(Z),v=s.getZ(Z);P<E&&(E=P),P>M&&(M=P),F<T&&(T=F),F>S&&(S=F),v<A&&(A=v),v>z&&(z=v)}return(l[f+0]!==E||l[f+1]!==T||l[f+2]!==A||l[f+3]!==M||l[f+4]!==S||l[f+5]!==z)&&(l[f+0]=E,l[f+1]=T,l[f+2]=A,l[f+3]=M,l[f+4]=S,l[f+5]=z,!0)}{const p=f+8,x=r[f+6],T=x+d;let A=y,M=!1,S=!1;e?A||(M=e.has(p+d),S=e.has(T),A=!M&&!S):(M=!0,S=!0);const O=A||S;let N=!1;(A||M)&&(N=h(p,d,A));let Z=!1;O&&(Z=h(x,d,A));const P=N||Z;if(P)for(let F=0;F<3;F++){const v=p+F,R=x+F,Q=l[v],j=l[v+3],rt=l[R],Y=l[R+3];l[f+F]=Q<rt?Q:rt,l[f+F+3]=j>Y?j:Y}return P}}}const fr=new b.NRn;function ve(o,e,t,i){return Mt(o,e,fr),t.intersectBox(fr,i)}function bl(o,e,t,i,s,n,r){const{geometry:a}=t,{index:l}=a,c=a.attributes.position;for(let u=o,h=e+o;u<h;u++){let f;if(f=t.resolveTriangleIndex(u),Nt(r,3*f,l,c),r.needsUpdate=!0,i(r,f,s,n))return!0}return!1}const pr=new b.Pq0;function xl(o,e,t,i,s){Et.setBuffer(o._roots[e]),Ms(0,o,t,i,s),Et.clearBuffer()}function Ms(o,e,t,i,s){const{float32Array:n,uint16Array:r,uint32Array:a}=Et,l=2*o;if(qt(l,r))!function ml(o,e,t,i,s,n){const{geometry:r}=o;for(let l=i,c=i+s;l<c;l++)Li(r,e,t,l,n)}(e,t,i,Gt(o,a),Qt(l,r),s);else{const u=Kt(o);ve(u,n,i,pr)&&Ms(u,e,t,i,s);const h=Jt(o,a);ve(h,n,i,pr)&&Ms(h,e,t,i,s)}}const mr=new b.Pq0,Cl=["x","y","z"];function Tl(o,e,t,i){Et.setBuffer(o._roots[e]);const s=Os(0,o,t,i);return Et.clearBuffer(),s}function Os(o,e,t,i){const{float32Array:s,uint16Array:n,uint32Array:r}=Et;let a=2*o;if(qt(a,n))return function gl(o,e,t,i,s){const{geometry:n}=o;let a=1/0,l=null;for(let c=i,u=i+s;c<u;c++){let h;h=Li(n,e,t,c),h&&h.distance<a&&(l=h,a=h.distance)}return l}(e,t,i,Gt(o,r),Qt(a,n));{const c=cr(o,r),u=Cl[c],f=i.direction[u]>=0;let d,y;f?(d=Kt(o),y=Jt(o,r)):(d=Jt(o,r),y=Kt(o));const _=ve(d,s,i,mr)?Os(d,e,t,i):null;if(_){const E=_.point[u];if(f?E<=s[y+c]:E>=s[y+c+3])return _}const x=ve(y,s,i,mr)?Os(y,e,t,i):null;return _&&x?_.distance<=x.distance?_:x:_||x||null}}const Vi=new b.NRn,Ve=new se,Ue=new se,ai=new b.kn4,gr=new $t,Ui=new $t;function El(o,e,t,i){Et.setBuffer(o._roots[e]);const s=ks(0,o,t,i);return Et.clearBuffer(),s}function ks(o,e,t,i,s=null){const{float32Array:n,uint16Array:r,uint32Array:a}=Et;let l=2*o;if(null===s&&(t.boundingBox||t.computeBoundingBox(),gr.set(t.boundingBox.min,t.boundingBox.max,i),s=gr),!qt(l,r)){const u=o+8,h=a[o+6];return Mt(u,n,Vi),!!(s.intersectsBox(Vi)&&ks(u,e,t,i,s)||(Mt(h,n,Vi),s.intersectsBox(Vi)&&ks(h,e,t,i,s)))}{const u=e.geometry,h=u.index,f=u.attributes.position,d=t.index,y=t.attributes.position,g=Gt(o,a),_=Qt(l,r);if(ai.copy(i).invert(),t.boundsTree)return Mt(o,n,Ui),Ui.matrix.copy(ai),Ui.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Ui.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(i),x.b.applyMatrix4(i),x.c.applyMatrix4(i),x.needsUpdate=!0;for(let E=3*g,T=3*(_+g);E<T;E+=3)if(Nt(Ue,E,h,f),Ue.needsUpdate=!0,x.intersectsTriangle(Ue))return!0;return!1}});for(let p=3*g,x=3*(_+g);p<x;p+=3){Nt(Ve,p,h,f),Ve.a.applyMatrix4(ai),Ve.b.applyMatrix4(ai),Ve.c.applyMatrix4(ai),Ve.needsUpdate=!0;for(let E=0,T=d.count;E<T;E+=3)if(Nt(Ue,E,d,y),Ue.needsUpdate=!0,Ve.intersectsTriangle(Ue))return!0}}}const $i=new b.kn4,zs=new $t,li=new $t,Al=new b.Pq0,Pl=new b.Pq0,Sl=new b.Pq0,Il=new b.Pq0;function Ml(o,e,t,i={},s={},n=0,r=1/0){e.boundingBox||e.computeBoundingBox(),zs.set(e.boundingBox.min,e.boundingBox.max,t),zs.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,c=a.index,u=e.attributes.position,h=e.index,f=Xt.getPrimitive(),d=Xt.getPrimitive();let y=Al,g=Pl,_=null,p=null;s&&(_=Sl,p=Il);let x=1/0,E=null,T=null;return $i.copy(t).invert(),li.matrix.copy($i),o.shapecast({boundsTraverseOrder:A=>zs.distanceToBox(A),intersectsBounds:(A,M,S)=>S<x&&S<r&&(M&&(li.min.copy(A.min),li.max.copy(A.max),li.needsUpdate=!0),!0),intersectsRange:(A,M)=>{if(e.boundsTree)return e.boundsTree.shapecast({boundsTraverseOrder:z=>li.distanceToBox(z),intersectsBounds:(z,O,N)=>N<x&&N<r,intersectsRange:(z,O)=>{for(let N=z,Z=z+O;N<Z;N++){Nt(d,3*N,h,u),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let P=A,F=A+M;P<F;P++){Nt(f,3*P,c,l),f.needsUpdate=!0;const v=f.distanceToTriangle(d,y,_);if(v<x&&(g.copy(y),p&&p.copy(_),x=v,E=P,T=N),v<n)return!0}}}});for(let z=0,O=Fe(e);z<O;z++){Nt(d,3*z,h,u),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let N=A,Z=A+M;N<Z;N++){Nt(f,3*N,c,l),f.needsUpdate=!0;const P=f.distanceToTriangle(d,y,_);if(P<x&&(g.copy(y),p&&p.copy(_),x=P,E=N,T=z),P<n)return!0}}}}),Xt.releasePrimitive(f),Xt.releasePrimitive(d),x===1/0?null:(i.point?i.point.copy(g):i.point=g.clone(),i.distance=x,i.faceIndex=E,s&&(s.point?s.point.copy(p):s.point=p.clone(),s.point.applyMatrix4($i),g.applyMatrix4($i),s.distance=g.sub(s.point).length(),s.faceIndex=T),i)}function Ol(o,e=null){e&&Array.isArray(e)&&(e=new Set(e));const t=o.geometry,i=t.index?t.index.array:null,s=t.attributes.position;let n,r,a,l,c=0;const u=o._roots;for(let f=0,d=u.length;f<d;f++)n=u[f],r=new Uint32Array(n),a=new Uint16Array(n),l=new Float32Array(n),h(0,c),c+=n.byteLength;function h(f,d,y=!1){const g=2*f;if(a[g+15]===Mi){const p=r[f+6];let E=1/0,T=1/0,A=1/0,M=-1/0,S=-1/0,z=-1/0;for(let O=p,N=p+a[g+14];O<N;O++){const Z=3*o.resolveTriangleIndex(O);for(let P=0;P<3;P++){let F=Z+P;F=i?i[F]:F;const v=s.getX(F),R=s.getY(F),Q=s.getZ(F);v<E&&(E=v),v>M&&(M=v),R<T&&(T=R),R>S&&(S=R),Q<A&&(A=Q),Q>z&&(z=Q)}}return(l[f+0]!==E||l[f+1]!==T||l[f+2]!==A||l[f+3]!==M||l[f+4]!==S||l[f+5]!==z)&&(l[f+0]=E,l[f+1]=T,l[f+2]=A,l[f+3]=M,l[f+4]=S,l[f+5]=z,!0)}{const p=f+8,x=r[f+6],T=x+d;let A=y,M=!1,S=!1;e?A||(M=e.has(p+d),S=e.has(T),A=!M&&!S):(M=!0,S=!0);const O=A||S;let N=!1;(A||M)&&(N=h(p,d,A));let Z=!1;O&&(Z=h(x,d,A));const P=N||Z;if(P)for(let F=0;F<3;F++){const v=p+F,R=x+F,Q=l[v],j=l[v+3],rt=l[R],Y=l[R+3];l[f+F]=Q<rt?Q:rt,l[f+F+3]=j>Y?j:Y}return P}}}const _r=new b.Pq0;function kl(o,e,t,i,s){Et.setBuffer(o._roots[e]),Fs(0,o,t,i,s),Et.clearBuffer()}function Fs(o,e,t,i,s){const{float32Array:n,uint16Array:r,uint32Array:a}=Et,l=2*o;if(qt(l,r))!function vl(o,e,t,i,s,n){const{geometry:r,_indirectBuffer:a}=o;for(let l=i,c=i+s;l<c;l++)Li(r,e,t,a?a[l]:l,n)}(e,t,i,Gt(o,a),Qt(l,r),s);else{const u=Kt(o);ve(u,n,i,_r)&&Fs(u,e,t,i,s);const h=Jt(o,a);ve(h,n,i,_r)&&Fs(h,e,t,i,s)}}const yr=new b.Pq0,zl=["x","y","z"];function Fl(o,e,t,i){Et.setBuffer(o._roots[e]);const s=Ns(0,o,t,i);return Et.clearBuffer(),s}function Ns(o,e,t,i){const{float32Array:s,uint16Array:n,uint32Array:r}=Et;let a=2*o;if(qt(a,n))return function wl(o,e,t,i,s){const{geometry:n,_indirectBuffer:r}=o;let a=1/0,l=null;for(let c=i,u=i+s;c<u;c++){let h;h=Li(n,e,t,r?r[c]:c),h&&h.distance<a&&(l=h,a=h.distance)}return l}(e,t,i,Gt(o,r),Qt(a,n));{const c=cr(o,r),u=zl[c],f=i.direction[u]>=0;let d,y;f?(d=Kt(o),y=Jt(o,r)):(d=Jt(o,r),y=Kt(o));const _=ve(d,s,i,yr)?Ns(d,e,t,i):null;if(_){const E=_.point[u];if(f?E<=s[y+c]:E>=s[y+c+3])return _}const x=ve(y,s,i,yr)?Ns(y,e,t,i):null;return _&&x?_.distance<=x.distance?_:x:_||x||null}}const ji=new b.NRn,$e=new se,je=new se,ci=new b.kn4,vr=new $t,Hi=new $t;function Nl(o,e,t,i){Et.setBuffer(o._roots[e]);const s=Ds(0,o,t,i);return Et.clearBuffer(),s}function Ds(o,e,t,i,s=null){const{float32Array:n,uint16Array:r,uint32Array:a}=Et;let l=2*o;if(null===s&&(t.boundingBox||t.computeBoundingBox(),vr.set(t.boundingBox.min,t.boundingBox.max,i),s=vr),!qt(l,r)){const u=o+8,h=a[o+6];return Mt(u,n,ji),!!(s.intersectsBox(ji)&&Ds(u,e,t,i,s)||(Mt(h,n,ji),s.intersectsBox(ji)&&Ds(h,e,t,i,s)))}{const u=e.geometry,h=u.index,f=u.attributes.position,d=t.index,y=t.attributes.position,g=Gt(o,a),_=Qt(l,r);if(ci.copy(i).invert(),t.boundsTree)return Mt(o,n,Hi),Hi.matrix.copy(ci),Hi.needsUpdate=!0,t.boundsTree.shapecast({intersectsBounds:x=>Hi.intersectsBox(x),intersectsTriangle:x=>{x.a.applyMatrix4(i),x.b.applyMatrix4(i),x.c.applyMatrix4(i),x.needsUpdate=!0;for(let E=g,T=_+g;E<T;E++)if(Nt(je,3*e.resolveTriangleIndex(E),h,f),je.needsUpdate=!0,x.intersectsTriangle(je))return!0;return!1}});for(let p=g,x=_+g;p<x;p++){const E=e.resolveTriangleIndex(p);Nt($e,3*E,h,f),$e.a.applyMatrix4(ci),$e.b.applyMatrix4(ci),$e.c.applyMatrix4(ci),$e.needsUpdate=!0;for(let T=0,A=d.count;T<A;T+=3)if(Nt(je,T,d,y),je.needsUpdate=!0,$e.intersectsTriangle(je))return!0}}}const Yi=new b.kn4,Rs=new $t,ui=new $t,Dl=new b.Pq0,Rl=new b.Pq0,Bl=new b.Pq0,Ll=new b.Pq0;function Vl(o,e,t,i={},s={},n=0,r=1/0){e.boundingBox||e.computeBoundingBox(),Rs.set(e.boundingBox.min,e.boundingBox.max,t),Rs.needsUpdate=!0;const a=o.geometry,l=a.attributes.position,c=a.index,u=e.attributes.position,h=e.index,f=Xt.getPrimitive(),d=Xt.getPrimitive();let y=Dl,g=Rl,_=null,p=null;s&&(_=Bl,p=Ll);let x=1/0,E=null,T=null;return Yi.copy(t).invert(),ui.matrix.copy(Yi),o.shapecast({boundsTraverseOrder:A=>Rs.distanceToBox(A),intersectsBounds:(A,M,S)=>S<x&&S<r&&(M&&(ui.min.copy(A.min),ui.max.copy(A.max),ui.needsUpdate=!0),!0),intersectsRange:(A,M)=>{if(e.boundsTree){const S=e.boundsTree;return S.shapecast({boundsTraverseOrder:z=>ui.distanceToBox(z),intersectsBounds:(z,O,N)=>N<x&&N<r,intersectsRange:(z,O)=>{for(let N=z,Z=z+O;N<Z;N++){const P=S.resolveTriangleIndex(N);Nt(d,3*P,h,u),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let F=A,v=A+M;F<v;F++){const R=o.resolveTriangleIndex(F);Nt(f,3*R,c,l),f.needsUpdate=!0;const Q=f.distanceToTriangle(d,y,_);if(Q<x&&(g.copy(y),p&&p.copy(_),x=Q,E=F,T=N),Q<n)return!0}}}})}for(let z=0,O=Fe(e);z<O;z++){Nt(d,3*z,h,u),d.a.applyMatrix4(t),d.b.applyMatrix4(t),d.c.applyMatrix4(t),d.needsUpdate=!0;for(let N=A,Z=A+M;N<Z;N++){const P=o.resolveTriangleIndex(N);Nt(f,3*P,c,l),f.needsUpdate=!0;const F=f.distanceToTriangle(d,y,_);if(F<x&&(g.copy(y),p&&p.copy(_),x=F,E=N,T=z),F<n)return!0}}}}),Xt.releasePrimitive(f),Xt.releasePrimitive(d),x===1/0?null:(i.point?i.point.copy(g):i.point=g.clone(),i.distance=x,i.faceIndex=E,s&&(s.point?s.point.copy(p):s.point=p.clone(),s.point.applyMatrix4(Yi),g.applyMatrix4(Yi),s.distance=g.sub(s.point).length(),s.faceIndex=T),i)}const hi=new Et.constructor,Zi=new Et.constructor,we=new Ps(()=>new b.NRn),He=new b.NRn,Ye=new b.NRn,Bs=new b.NRn,Ls=new b.NRn;let Vs=!1;function ne(o,e,t,i,s,n=0,r=0,a=0,l=0,c=null,u=!1){let h,f;u?(h=Zi,f=hi):(h=hi,f=Zi);const d=h.float32Array,y=h.uint32Array,g=h.uint16Array,_=f.float32Array,p=f.uint32Array,x=f.uint16Array,T=2*e,A=qt(2*o,g),M=qt(T,x);let S=!1;if(M&&A)S=u?s(Gt(e,p),Qt(2*e,x),Gt(o,y),Qt(2*o,g),l,r+e,a,n+o):s(Gt(o,y),Qt(2*o,g),Gt(e,p),Qt(2*e,x),a,n+o,l,r+e);else if(M){const z=we.getPrimitive();Mt(e,_,z),z.applyMatrix4(t);const O=Kt(o),N=Jt(o,y);Mt(O,d,He),Mt(N,d,Ye);const Z=z.intersectsBox(He),P=z.intersectsBox(Ye);S=Z&&ne(e,O,i,t,s,r,n,l,a+1,z,!u)||P&&ne(e,N,i,t,s,r,n,l,a+1,z,!u),we.releasePrimitive(z)}else{const z=Kt(e),O=Jt(e,p);Mt(z,_,Bs),Mt(O,_,Ls);const N=c.intersectsBox(Bs),Z=c.intersectsBox(Ls);if(N&&Z)S=ne(o,z,t,i,s,n,r,a,l+1,c,u)||ne(o,O,t,i,s,n,r,a,l+1,c,u);else if(N)if(A)S=ne(o,z,t,i,s,n,r,a,l+1,c,u);else{const P=we.getPrimitive();P.copy(Bs).applyMatrix4(t);const F=Kt(o),v=Jt(o,y);Mt(F,d,He),Mt(v,d,Ye);const R=P.intersectsBox(He),Q=P.intersectsBox(Ye);S=R&&ne(z,F,i,t,s,r,n,l,a+1,P,!u)||Q&&ne(z,v,i,t,s,r,n,l,a+1,P,!u),we.releasePrimitive(P)}else if(Z)if(A)S=ne(o,O,t,i,s,n,r,a,l+1,c,u);else{const P=we.getPrimitive();P.copy(Ls).applyMatrix4(t);const F=Kt(o),v=Jt(o,y);Mt(F,d,He),Mt(v,d,Ye);const R=P.intersectsBox(He),Q=P.intersectsBox(Ye);S=R&&ne(O,F,i,t,s,r,n,l,a+1,P,!u)||Q&&ne(O,v,i,t,s,r,n,l,a+1,P,!u),we.releasePrimitive(P)}}return S}const Wi=new $t,wr=new b.NRn;class Us{static serialize(e,t={}){t={cloneBuffers:!0,...t};const s=e._roots,n=e._indirectBuffer,r=e.geometry.getIndex();let a;return a=t.cloneBuffers?{roots:s.map(l=>l.slice()),index:r.array.slice(),indirectBuffer:n?n.slice():null}:{roots:s,index:r.array,indirectBuffer:n},a}static deserialize(e,t,i={}){i={setIndex:!0,indirect:!!e.indirectBuffer,...i};const{index:s,roots:n,indirectBuffer:r}=e,a=new Us(t,{...i,[Cs]:!0});if(a._roots=n,a._indirectBuffer=r||null,i.setIndex){const l=t.getIndex();if(null===l){const c=new b.THS(e.index,1,!1);t.setIndex(c)}else l.array!==s&&(l.array.set(s),l.needsUpdate=!0)}return a}get indirect(){return!!this._indirectBuffer}constructor(e,t={}){if(!e.isBufferGeometry)throw new Error("MeshBVH: Only BufferGeometries are supported.");if(e.index&&e.index.isInterleavedBufferAttribute)throw new Error("MeshBVH: InterleavedBufferAttribute is not supported for the index attribute.");if((t=Object.assign({strategy:0,maxDepth:40,maxLeafTris:10,verbose:!0,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,[Cs]:!1},t)).useSharedArrayBuffer&&!function Ul(){return typeof SharedArrayBuffer<"u"}())throw new Error("MeshBVH: SharedArrayBuffer is not available.");this.geometry=e,this._roots=null,this._indirectBuffer=null,t[Cs]||(rl(this,t),!e.boundingBox&&t.setBoundingBox&&(e.boundingBox=this.getBoundingBox(new b.NRn)));const{_indirectBuffer:i}=this;this.resolveTriangleIndex=t.indirect?s=>i[s]:s=>s}refit(e=null){return(this.indirect?Ol:yl)(this,e)}traverse(e,t=0){const i=this._roots[t],s=new Uint32Array(i),n=new Uint16Array(i);!function r(a,l=0){const c=2*a,u=n[c+15]===Mi;if(u){const h=s[a+6],f=n[c+14];e(l,u,new Float32Array(i,4*a,6),h,f)}else{const h=a+8,f=s[a+6],d=s[a+7];e(l,u,new Float32Array(i,4*a,6),d)||(r(h,l+1),r(f,l+1))}}(0)}raycast(e,t=b.hB5){const i=this._roots,s=this.geometry,n=[],r=t.isMaterial,a=Array.isArray(t),l=s.groups,c=r?t.side:t,u=this.indirect?kl:xl;for(let h=0,f=i.length;h<f;h++){const y=n.length;if(u(this,h,a?t[l[h].materialIndex].side:c,e,n),a){const g=l[h].materialIndex;for(let _=y,p=n.length;_<p;_++)n[_].face.materialIndex=g}}return n}raycastFirst(e,t=b.hB5){const i=this._roots,s=this.geometry,n=t.isMaterial,r=Array.isArray(t);let a=null;const l=s.groups,c=n?t.side:t,u=this.indirect?Fl:Tl;for(let h=0,f=i.length;h<f;h++){const y=u(this,h,r?t[l[h].materialIndex].side:c,e);null!=y&&(null==a||y.distance<a.distance)&&(a=y,r&&(y.face.materialIndex=l[h].materialIndex))}return a}intersectsGeometry(e,t){let i=!1;const n=this.indirect?Nl:El;for(let r=0,a=this._roots.length;r<a&&(i=n(this,r,e,t),!i);r++);return i}shapecast(e){const t=Xt.getPrimitive(),i=this.indirect?bl:_l;let{boundsTraverseOrder:s,intersectsBounds:n,intersectsRange:r,intersectsTriangle:a}=e;if(r&&a){const h=r;r=(f,d,y,g,_)=>!!h(f,d,y,g,_)||i(f,d,this,a,y,g,t)}else r||(r=a?(h,f,d,y)=>i(h,f,this,a,d,y,t):(h,f,d)=>d);let l=!1,c=0;const u=this._roots;for(let h=0,f=u.length;h<f;h++){const d=u[h];if(l=hl(this,h,n,r,s,c),l)break;c+=d.byteLength}return Xt.releasePrimitive(t),l}bvhcast(e,t,i){let{intersectsRanges:s,intersectsTriangles:n}=i;const r=Xt.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?y=>{const g=this.resolveTriangleIndex(y);Nt(r,3*g,a,l)}:y=>{Nt(r,3*y,a,l)},u=Xt.getPrimitive(),h=e.geometry.index,f=e.geometry.attributes.position,d=e.indirect?y=>{const g=e.resolveTriangleIndex(y);Nt(u,3*g,h,f)}:y=>{Nt(u,3*y,h,f)};if(n){const y=(g,_,p,x,E,T,A,M)=>{for(let S=p,z=p+x;S<z;S++){d(S),u.a.applyMatrix4(t),u.b.applyMatrix4(t),u.c.applyMatrix4(t),u.needsUpdate=!0;for(let O=g,N=g+_;O<N;O++)if(c(O),r.needsUpdate=!0,n(r,u,O,S,E,T,A,M))return!0}return!1};if(s){const g=s;s=function(_,p,x,E,T,A,M,S){return!!g(_,p,x,E,T,A,M,S)||y(_,p,x,E,T,A,M,S)}}else s=y}return function $l(o,e,t,i){if(Vs)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Vs=!0;const s=o._roots,n=e._roots;let r,a=0,l=0;const c=(new b.kn4).copy(t).invert();for(let u=0,h=s.length;u<h;u++){hi.setBuffer(s[u]),l=0;const f=we.getPrimitive();Mt(0,hi.float32Array,f),f.applyMatrix4(c);for(let d=0,y=n.length;d<y&&(Zi.setBuffer(n[u]),r=ne(0,0,t,c,i,a,l,0,0,f),Zi.clearBuffer(),l+=n[d].length,!r);d++);if(we.releasePrimitive(f),hi.clearBuffer(),a+=s[u].length,r)break}return Vs=!1,r}(this,e,t,s)}intersectsBox(e,t){return Wi.set(e.min,e.max,t),Wi.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Wi.intersectsBox(i),intersectsTriangle:i=>Wi.intersectsTriangle(i)})}intersectsSphere(e){return this.shapecast({intersectsBounds:t=>e.intersectsBox(t),intersectsTriangle:t=>t.intersectsSphere(e)})}closestPointToGeometry(e,t,i={},s={},n=0,r=1/0){return(this.indirect?Vl:Ml)(this,e,t,i,s,n,r)}closestPointToPoint(e,t={},i=0,s=1/0){return function dl(o,e,t={},i=0,s=1/0){const n=i*i,r=s*s;let a=1/0,l=null;if(o.shapecast({boundsTraverseOrder:u=>(oi.copy(e).clamp(u.min,u.max),oi.distanceToSquared(e)),intersectsBounds:(u,h,f)=>f<a&&f<r,intersectsTriangle:(u,h)=>{u.closestPointToPoint(e,oi);const f=e.distanceToSquared(oi);return f<a&&(Is.copy(oi),a=f,l=h),f<n}}),a===1/0)return null;const c=Math.sqrt(a);return t.point?t.point.copy(Is):t.point=Is.clone(),t.distance=c,t.faceIndex=l,t}(this,e,t,i,s)}getBoundingBox(e){return e.makeEmpty(),this._roots.forEach(i=>{Mt(0,new Float32Array(i),wr),e.union(wr)}),e}}function br(o,e,t){return null===o||(o.point.applyMatrix4(e.matrixWorld),o.distance=o.point.distanceTo(t.ray.origin),o.object=e,o.distance<t.near||o.distance>t.far)?null:o}const $s=new b.RlV,xr=new b.kn4,jl=b.eaF.prototype.raycast;function Hl(o,e){if(this.geometry.boundsTree){if(void 0===this.material)return;xr.copy(this.matrixWorld).invert(),$s.copy(o.ray).applyMatrix4(xr);const t=this.geometry.boundsTree;if(!0===o.firstHitOnly){const i=br(t.raycastFirst($s,this.material),this,o);i&&e.push(i)}else{const i=t.raycast($s,this.material);for(let s=0,n=i.length;s<n;s++){const r=br(i[s],this,o);r&&e.push(r)}}}else jl.call(this,o,e)}function Yl(o){return this.boundsTree=new Us(this,o),this.boundsTree}function Zl(){this.boundsTree=null}const Cr=class wo{constructor(){w(this,"onDisposed",new X),w(this,"list",new ft.jp),w(this,"enabled",!1),w(this,"_clock"),w(this,"onInit",new X),w(this,"update",()=>{if(!this.enabled)return;const e=this._clock.getDelta();for(const[t,i]of this.list)i.enabled&&i.isUpdateable()&&i.update(e);requestAnimationFrame(this.update)}),this._clock=new b.zD7,wo.setupBVH()}add(e,t){if(this.list.has(e))throw new Error("You're trying to add a component that already exists in the components instance. Use Components.get() instead.");Yt.validate(e),this.list.set(e,t)}get(e){var t;const i=e.uuid;if(!this.list.has(i)){const s=new e(this);return null!=(t=s.isDisposeable)&&t.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[e,t]of this.list.entries())t.enabled=!0;this._clock.start(),this.update(),this.onInit.trigger()}dispose(){let e;this.enabled=!1;for(const[t,i]of this.list)i.enabled=!1,t!==ct.uuid?i.isDisposeable()&&i.dispose():e=i;e?.dispose(),this._clock.stop(),this.onDisposed.trigger()}static setupBVH(){b.LoY.prototype.computeBoundsTree=Yl,b.LoY.prototype.disposeBoundsTree=Zl,b.eaF.prototype.raycast=Hl}};w(Cr,"release","2.4.3");let js=Cr;class Wl{constructor(e){w(this,"enabled",!1),w(this,"id","FirstPerson"),this.camera=e}set(e){if(this.enabled=e,e){if("Perspective"!==this.camera.projection.current)return void this.camera.set("Orbit");this.setupFirstPersonCamera()}}setupFirstPersonCamera(){const e=this.camera.controls,t=new b.Pq0;e.distance--,e.getPosition(t),e.minDistance=1,e.maxDistance=1,e.distance=1,e.moveTo(t.x,t.y,t.z),e.truckSpeed=50,e.mouseButtons.wheel=Bt.ACTION.DOLLY,e.touches.two=Bt.ACTION.TOUCH_ZOOM_TRUCK}}class ql{constructor(e){w(this,"enabled",!0),w(this,"id","Orbit"),this.camera=e,this.activateOrbitControls()}set(e){this.enabled=e,e&&this.activateOrbitControls()}activateOrbitControls(){const e=this.camera.controls;e.minDistance=1,e.maxDistance=300;const t=new b.Pq0;e.getPosition(t);const i=t.length();e.distance=i,e.truckSpeed=2;const{rotation:s}=this.camera.three,n=new b.Pq0(0,0,-1).applyEuler(s),r=t.addScaledVector(n,i);e.moveTo(r.x,r.y,r.z)}}class Gl{constructor(e){w(this,"enabled",!1),w(this,"id","Plan"),w(this,"mouseAction1"),w(this,"mouseAction2"),w(this,"mouseInitialized",!1),w(this,"defaultAzimuthSpeed"),w(this,"defaultPolarSpeed"),this.camera=e,this.defaultAzimuthSpeed=e.controls.azimuthRotateSpeed,this.defaultPolarSpeed=e.controls.polarRotateSpeed}set(e){this.enabled=e;const t=this.camera.controls;t.azimuthRotateSpeed=e?0:this.defaultAzimuthSpeed,t.polarRotateSpeed=e?0:this.defaultPolarSpeed,this.mouseInitialized||(this.mouseAction1=t.touches.one,this.mouseAction2=t.touches.two,this.mouseInitialized=!0),e?(t.mouseButtons.left=Bt.ACTION.TRUCK,t.touches.one=Bt.ACTION.TOUCH_TRUCK,t.touches.two=Bt.ACTION.TOUCH_ZOOM):(t.mouseButtons.left=Bt.ACTION.ROTATE,t.touches.one=this.mouseAction1,t.touches.two=this.mouseAction2)}}class Xl{constructor(e){w(this,"onChanged",new X),w(this,"current","Perspective"),w(this,"camera"),w(this,"matchOrthoDistanceEnabled",!1),w(this,"_component"),w(this,"_previousDistance",-1),this._component=e,this.camera=e.three}set(e){var t=this;return(0,H.A)(function*(){t.current!==e&&("Orthographic"===e?t.setOrthoCamera():yield t.setPerspectiveCamera(),t.onChanged.trigger(t.camera))})()}toggle(){var e=this;return(0,H.A)(function*(){const i="Perspective"===e.current?"Orthographic":"Perspective";yield e.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 e=this.getPerspectiveDims();if(!e)return;const{width:t,height:i}=e;this.setupOrthoCamera(i,t),this.camera=this._component.threeOrtho,this.current="Orthographic"}getPerspectiveDims(){const e=this._component.currentWorld;if(!e||!e.renderer)return null;const t=new b.Pq0;this._component.threePersp.getWorldDirection(t);const i=new b.Pq0;this._component.controls.getTarget(i);const n=i.clone().sub(this._component.threePersp.position).dot(t),r=e.renderer.getSize(),a=r.x/r.y,c=2*n*Math.atan(this._component.threePersp.fov*(Math.PI/180)/2);return{width:c*a,height:c}}setupOrthoCamera(e,t){this._component.controls.mouseButtons.wheel=Bt.ACTION.ZOOM,this._component.controls.mouseButtons.middle=Bt.ACTION.ZOOM;const i=this._component.threePersp,s=this._component.threeOrtho;s.zoom=1,s.left=t/-2,s.right=t/2,s.top=e/2,s.bottom=e/-2,s.updateProjectionMatrix(),s.position.copy(i.position),s.quaternion.copy(i.quaternion),this._component.controls.camera=s}getDistance(){const t=this._component.threeOrtho;return(t.top-t.bottom)/t.zoom/(2*Math.atan(this._component.threePersp.fov*(Math.PI/180)/2))}setPerspectiveCamera(){var e=this;return(0,H.A)(function*(){e._component.controls.mouseButtons.wheel=Bt.ACTION.DOLLY,e._component.controls.mouseButtons.middle=Bt.ACTION.DOLLY;const t=e._component.threePersp,i=e._component.threeOrtho;t.position.copy(i.position),t.quaternion.copy(i.quaternion),e._component.controls.mouseButtons.wheel=Bt.ACTION.DOLLY,e._component.controls.distance=e.matchOrthoDistanceEnabled?e.getDistance():e._previousDistance,yield e._component.controls.zoomTo(1),t.updateProjectionMatrix(),e._component.controls.camera=t,e.camera=t,e.current="Perspective"})()}}class Hs extends ni{constructor(e){super(e),w(this,"projection"),w(this,"threeOrtho"),w(this,"threePersp"),w(this,"_userInputButtons",{}),w(this,"_frustumSize",50),w(this,"_navigationModes",new Map),w(this,"_mode",null),w(this,"previousSize",null),this.threePersp=this.three,this.threeOrtho=this.newOrthoCamera(),this.projection=new Xl(this),this.onAspectUpdated.add(()=>{this.setOrthoPerspCameraAspect()}),this.projection.onChanged.add(t=>{this.three=t,this.updateAspect()}),this.worlds.onItemSet.add(()=>{this._navigationModes.clear(),this._navigationModes.set("Orbit",new ql(this)),this._navigationModes.set("FirstPerson",new Wl(this)),this._navigationModes.set("Plan",new Gl(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(e){if(null!==this.mode&&this.mode.id!==e){if(this.mode.set(!1),!this._navigationModes.has(e))throw new Error("The specified mode does not exist!");this._mode=this._navigationModes.get(e),this.mode.set(!0)}}fit(e){var t=this;return(0,H.A)(function*(i,s=1.5){if(!t.enabled)return;const n=Number.MAX_VALUE,r=Number.MIN_VALUE,a=new b.Pq0(n,n,n),l=new b.Pq0(r,r,r);for(const g of i){const _=(new b.NRn).setFromObject(g);_.min.x<a.x&&(a.x=_.min.x),_.min.y<a.y&&(a.y=_.min.y),_.min.z<a.z&&(a.z=_.min.z),_.max.x>l.x&&(l.x=_.max.x),_.max.y>l.y&&(l.y=_.max.y),_.max.z>l.z&&(l.z=_.max.z)}const c=new b.NRn(a,l),u=t.components.get(ct);if(u.initialized)for(const[,g]of u.list){const _=g.box;_.min.x<a.x&&(a.x=_.min.x),_.min.y<a.y&&(a.y=_.min.y),_.min.z<a.z&&(a.z=_.min.z),_.max.x>l.x&&(l.x=_.max.x),_.max.y>l.y&&(l.y=_.max.y),_.max.z>l.z&&(l.z=_.max.z)}const h=new b.Pq0;c.getSize(h);const f=new b.Pq0;c.getCenter(f);const d=Math.max(h.x,h.y,h.z)*s,y=new b.iyt(f,d);yield t.controls.fitToSphere(y,!0)}).apply(this,arguments)}setUserInput(e){e?this.enableUserInput():this.disableUserInput()}addCustomNavigationMode(e){this._navigationModes.set(e.id,e)}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 e=window.innerWidth/window.innerHeight;return new b.qUd(this._frustumSize*e/-2,this._frustumSize*e/2,this._frustumSize/2,this._frustumSize/-2,.1,1e3)}setOrthoPerspCameraAspect(){if(!this.currentWorld||!this.currentWorld.renderer||!this.previousSize)return;const e=this.currentWorld.renderer.getSize(),r=this.threeOrtho.top*(e.y/this.previousSize.y),a=this.threeOrtho.right*(e.x/this.previousSize.x);this.threeOrtho.left=-a,this.threeOrtho.right=a,this.threeOrtho.top=r,this.threeOrtho.bottom=-r,this.threeOrtho.updateProjectionMatrix(),this.previousSize.copy(e)}}var qi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ql(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}function Gi(o){throw new Error('Could not dynamically require "'+o+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Tr={exports:{}};Tr.exports=function t(i,s,n){function r(c,u){if(!s[c]){if(!i[c]){if(!u&&Gi)return Gi(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(y){return r(i[c][1][y]||y)},d,d.exports,t,i,s,n)}return s[c].exports}for(var a=Gi,l=0;l<n.length;l++)r(n[l]);return r}({1:[function(t,i,s){var n=t("./utils"),r=t("./support"),a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";s.encode=function(l){for(var c,u,h,d,y,g,_=[],p=0,x=l.length,E=x,T="string"!==n.getTypeOf(l);p<l.length;)E=x-p,h=T?(c=l[p++],u=p<x?l[p++]:0,p<x?l[p++]:0):(c=l.charCodeAt(p++),u=p<x?l.charCodeAt(p++):0,p<x?l.charCodeAt(p++):0),d=(3&c)<<4|u>>4,y=1<E?(15&u)<<2|h>>6:64,g=2<E?63&h:64,_.push(a.charAt(c>>2)+a.charAt(d)+a.charAt(y)+a.charAt(g));return _.join("")},s.decode=function(l){var c,u,h,f,d,y,g=0,_=0,p="data:";if(l.substr(0,5)===p)throw new Error("Invalid base64 input, it looks like a data url.");var x,E=3*(l=l.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(l.charAt(l.length-1)===a.charAt(64)&&E--,l.charAt(l.length-2)===a.charAt(64)&&E--,E%1!=0)throw new Error("Invalid base64 input, bad content length.");for(x=r.uint8array?new Uint8Array(0|E):new Array(0|E);g<l.length;)c=a.indexOf(l.charAt(g++))<<2|(f=a.indexOf(l.charAt(g++)))>>4,u=(15&f)<<4|(d=a.indexOf(l.charAt(g++)))>>2,h=(3&d)<<6|(y=a.indexOf(l.charAt(g++))),x[_++]=c,64!==d&&(x[_++]=u),64!==y&&(x[_++]=h);return x}},{"./support":30,"./utils":32}],2:[function(t,i,s){var n=t("./external"),r=t("./stream/DataWorker"),a=t("./stream/Crc32Probe"),l=t("./stream/DataLengthProbe");function c(u,h,f,d,y){this.compressedSize=u,this.uncompressedSize=h,this.crc32=f,this.compression=d,this.compressedContent=y}c.prototype={getContentWorker:function(){var u=new r(n.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new l("data_length")),h=this;return u.on("end",function(){if(this.streamInfo.data_length!==h.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),u},getCompressedWorker:function(){return new r(n.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},c.createWorkerFrom=function(u,h,f){return u.pipe(new a).pipe(new l("uncompressedSize")).pipe(h.compressWorker(f)).pipe(new l("compressedSize")).withStreamInfo("compression",h)},i.exports=c},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(t,i,s){var n=t("./stream/GenericWorker");s.STORE={magic:"\0\0",compressWorker:function(){return new n("STORE compression")},uncompressWorker:function(){return new n("STORE decompression")}},s.DEFLATE=t("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(t,i,s){var n=t("./utils"),r=function(){for(var a,l=[],c=0;c<256;c++){a=c;for(var u=0;u<8;u++)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,u,h){var d=r,y=0+h;c^=-1;for(var g=0;g<y;g++)c=c>>>8^d[255&(c^u[g])];return-1^c}(0|l,a,a.length):function(c,u,h){var d=r,y=0+h;c^=-1;for(var g=0;g<y;g++)c=c>>>8^d[255&(c^u.charCodeAt(g))];return-1^c}(0|l,a,a.length):0}},{"./utils":32}],5:[function(t,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(t,i,s){var n;n=typeof Promise<"u"?Promise:t("lie"),i.exports={Promise:n}},{lie:37}],7:[function(t,i,s){var n=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",r=t("pako"),a=t("./utils"),l=t("./stream/GenericWorker"),c=n?"uint8array":"array";function u(h,f){l.call(this,"FlateWorker/"+h),this._pako=null,this._pakoAction=h,this._pakoOptions=f,this.meta={}}s.magic="\b\0",a.inherits(u,l),u.prototype.processChunk=function(h){this.meta=h.meta,null===this._pako&&this._createPako(),this._pako.push(a.transformTo(c,h.data),!1)},u.prototype.flush=function(){l.prototype.flush.call(this),null===this._pako&&this._createPako(),this._pako.push([],!0)},u.prototype.cleanUp=function(){l.prototype.cleanUp.call(this),this._pako=null},u.prototype._createPako=function(){this._pako=new r[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var h=this;this._pako.onData=function(f){h.push({data:f,meta:h.meta})}},s.compressWorker=function(h){return new u("Deflate",h)},s.uncompressWorker=function(){return new u("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(t,i,s){function n(d,y){var g,_="";for(g=0;g<y;g++)_+=String.fromCharCode(255&d),d>>>=8;return _}function r(d,y,g,_,p,x){var E,T,A=d.file,M=d.compression,S=x!==c.utf8encode,z=a.transformTo("string",x(A.name)),O=a.transformTo("string",c.utf8encode(A.name)),N=A.comment,Z=a.transformTo("string",x(N)),P=a.transformTo("string",c.utf8encode(N)),F=O.length!==A.name.length,v=P.length!==N.length,R="",Q="",j="",rt=A.dir,Y=A.date,ot={crc32:0,compressedSize:0,uncompressedSize:0};y&&!g||(ot.crc32=d.crc32,ot.compressedSize=d.compressedSize,ot.uncompressedSize=d.uncompressedSize);var B=0;y&&(B|=8),S||!F&&!v||(B|=2048);var K,Ot,L=0,it=0;rt&&(L|=16),"UNIX"===p?(it=798,L|=(Ot=K=A.unixPermissions,K||(Ot=rt?16893:33204),(65535&Ot)<<16)):(it=20,L|=function(K){return 63&(K||0)}(A.dosPermissions)),E=Y.getUTCHours(),E<<=6,E|=Y.getUTCMinutes(),E<<=5,E|=Y.getUTCSeconds()/2,T=Y.getUTCFullYear()-1980,T<<=4,T|=Y.getUTCMonth()+1,T<<=5,T|=Y.getUTCDate(),F&&(Q=n(1,1)+n(u(z),4)+O,R+="up"+n(Q.length,2)+Q),v&&(j=n(1,1)+n(u(Z),4)+P,R+="uc"+n(j.length,2)+j);var et="";return et+="\n\0",et+=n(B,2),et+=M.magic,et+=n(E,2),et+=n(T,2),et+=n(ot.crc32,4),et+=n(ot.compressedSize,4),et+=n(ot.uncompressedSize,4),et+=n(z.length,2),et+=n(R.length,2),{fileRecord:h.LOCAL_FILE_HEADER+et+z+R,dirRecord:h.CENTRAL_FILE_HEADER+n(it,2)+et+n(Z.length,2)+"\0\0\0\0"+n(L,4)+n(_,4)+z+R+Z}}var a=t("../utils"),l=t("../stream/GenericWorker"),c=t("../utf8"),u=t("../crc32"),h=t("../signature");function f(d,y,g,_){l.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=y,this.zipPlatform=g,this.encodeFileName=_,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 y=d.meta.percent||0,g=this.entriesCount,_=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:g?(y+100*(g-_-1))/g:100}}))},f.prototype.openedSource=function(d){this.currentSourceOffset=this.bytesWritten,this.currentFile=d.file.name;var y=this.streamFiles&&!d.file.dir;if(y){var g=r(d,y,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},f.prototype.closedSource=function(d){this.accumulate=!1;var _,y=this.streamFiles&&!d.file.dir,g=r(d,y,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),y)this.push({data:(_=d,h.DATA_DESCRIPTOR+n(_.crc32,4)+n(_.compressedSize,4)+n(_.uncompressedSize,4)),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},f.prototype.flush=function(){for(var d=this.bytesWritten,y=0;y<this.dirRecords.length;y++)this.push({data:this.dirRecords[y],meta:{percent:100}});var p,x,E,M,_=(p=this.dirRecords.length,x=this.bytesWritten-d,E=d,M=a.transformTo("string",(0,this.encodeFileName)(this.zipComment)),h.CENTRAL_DIRECTORY_END+"\0\0\0\0"+n(p,2)+n(p,2)+n(x,4)+n(E,4)+n(M.length,2)+M);this.push({data:_,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 y=this;return d.on("data",function(g){y.processChunk(g)}),d.on("end",function(){y.closedSource(y.previous.streamInfo),y._sources.length?y.prepareNextSource():y.end()}),d.on("error",function(g){y.error(g)}),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 y=this._sources;if(!l.prototype.error.call(this,d))return!1;for(var g=0;g<y.length;g++)try{y[g].error(d)}catch{}return!0},f.prototype.lock=function(){l.prototype.lock.call(this);for(var d=this._sources,y=0;y<d.length;y++)d[y].lock()},i.exports=f},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(t,i,s){var n=t("../compressions"),r=t("./ZipFileWorker");s.generateWorker=function(a,l,c){var u=new r(l.streamFiles,c,l.platform,l.encodeFileName),h=0;try{a.forEach(function(f,d){h++;var y=function(x,E){var T=x||E,A=n[T];if(!A)throw new Error(T+" is not a valid compression method !");return A}(d.options.compression,l.compression),_=d.dir,p=d.date;d._compressWorker(y,d.options.compressionOptions||l.compressionOptions||{}).withStreamInfo("file",{name:f,dir:_,date:p,comment:d.comment||"",unixPermissions:d.unixPermissions,dosPermissions:d.dosPermissions}).pipe(u)}),u.entriesCount=h}catch(f){u.error(f)}return u}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(t,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 r=new n;for(var a in this)"function"!=typeof this[a]&&(r[a]=this[a]);return r}}(n.prototype=t("./object")).loadAsync=t("./load"),n.support=t("./support"),n.defaults=t("./defaults"),n.version="3.10.1",n.loadAsync=function(r,a){return(new n).loadAsync(r,a)},n.external=t("./external"),i.exports=n},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(t,i,s){var n=t("./utils"),r=t("./external"),a=t("./utf8"),l=t("./zipEntries"),c=t("./stream/Crc32Probe"),u=t("./nodejsUtils");function h(f){return new r.Promise(function(d,y){var g=f.decompressed.getContentWorker().pipe(new c);g.on("error",function(_){y(_)}).on("end",function(){g.streamInfo.crc32!==f.decompressed.crc32?y(new Error("Corrupted zip : CRC32 mismatch")):d()}).resume()})}i.exports=function(f,d){var y=this;return d=n.extend(d||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:a.utf8decode}),u.isNode&&u.isStream(f)?r.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(g){var _=new l(d);return _.load(g),_}).then(function(g){var _=[r.Promise.resolve(g)],p=g.files;if(d.checkCRC32)for(var x=0;x<p.length;x++)_.push(h(p[x]));return r.Promise.all(_)}).then(function(g){for(var _=g.shift(),p=_.files,x=0;x<p.length;x++){var E=p[x],T=E.fileNameStr,A=n.resolve(E.fileNameStr);y.file(A,E.decompressed,{binary:!0,optimizedBinaryString:!0,date:E.date,dir:E.dir,comment:E.fileCommentStr.length?E.fileCommentStr:null,unixPermissions:E.unixPermissions,dosPermissions:E.dosPermissions,createFolders:d.createFolders}),E.dir||(y.file(A).unsafeOriginalName=T)}return _.zipComment.length&&(y.comment=_.zipComment),y})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(t,i,s){var n=t("../utils"),r=t("../stream/GenericWorker");function a(l,c){r.call(this,"Nodejs stream input adapter for "+l),this._upstreamEnded=!1,this._bindStream(c)}n.inherits(a,r),a.prototype._bindStream=function(l){var c=this;(this._stream=l).pause(),l.on("data",function(u){c.push({data:u,meta:{percent:0}})}).on("error",function(u){c.isPaused?this.generatedError=u:c.error(u)}).on("end",function(){c.isPaused?c._upstreamEnded=!0:c.end()})},a.prototype.pause=function(){return!!r.prototype.pause.call(this)&&(this._stream.pause(),!0)},a.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},i.exports=a},{"../stream/GenericWorker":28,"../utils":32}],13:[function(t,i,s){var n=t("readable-stream").Readable;function r(a,l,c){n.call(this,l),this._helper=a;var u=this;a.on("data",function(h,f){u.push(h)||u._helper.pause(),c&&c(f)}).on("error",function(h){u.emit("error",h)}).on("end",function(){u.push(null)})}t("../utils").inherits(r,n),r.prototype._read=function(){this._helper.resume()},i.exports=r},{"../utils":32,"readable-stream":16}],14:[function(t,i,s){i.exports={isNode:typeof Buffer<"u",newBufferFrom:function(n,r){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(n,r);if("number"==typeof n)throw new Error('The "data" argument must not be a number');return new Buffer(n,r)},allocBuffer:function(n){if(Buffer.alloc)return Buffer.alloc(n);var r=new Buffer(n);return r.fill(0),r},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(t,i,s){function n(A,M,S){var z,O=a.getTypeOf(M),N=a.extend(S||{},u);N.date=N.date||new Date,null!==N.compression&&(N.compression=N.compression.toUpperCase()),"string"==typeof N.unixPermissions&&(N.unixPermissions=parseInt(N.unixPermissions,8)),N.unixPermissions&&16384&N.unixPermissions&&(N.dir=!0),N.dosPermissions&&16&N.dosPermissions&&(N.dir=!0),N.dir&&(A=p(A)),N.createFolders&&(z=_(A))&&x.call(this,z,!0),S&&void 0!==S.binary||(N.binary=!("string"===O&&!1===N.binary&&!1===N.base64)),(M instanceof h&&0===M.uncompressedSize||N.dir||!M||0===M.length)&&(N.base64=!1,N.binary=!0,M="",N.compression="STORE",O="string");var P;P=M instanceof h||M instanceof l?M:y.isNode&&y.isStream(M)?new g(A,M):a.prepareContent(A,M,N.binary,N.optimizedBinaryString,N.base64);var F=new f(A,P,N);this.files[A]=F}var r=t("./utf8"),a=t("./utils"),l=t("./stream/GenericWorker"),c=t("./stream/StreamHelper"),u=t("./defaults"),h=t("./compressedObject"),f=t("./zipObject"),d=t("./generate"),y=t("./nodejsUtils"),g=t("./nodejs/NodejsStreamInputAdapter"),_=function(A){"/"===A.slice(-1)&&(A=A.substring(0,A.length-1));var M=A.lastIndexOf("/");return 0<M?A.substring(0,M):""},p=function(A){return"/"!==A.slice(-1)&&(A+="/"),A},x=function(A,M){return M=void 0!==M?M:u.createFolders,A=p(A),this.files[A]||n.call(this,A,null,{dir:!0,createFolders:M}),this.files[A]};function E(A){return"[object RegExp]"===Object.prototype.toString.call(A)}var T={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(A){var M,S,z;for(M in this.files)z=this.files[M],(S=M.slice(this.root.length,M.length))&&M.slice(0,this.root.length)===this.root&&A(S,z)},filter:function(A){var M=[];return this.forEach(function(S,z){A(S,z)&&M.push(z)}),M},file:function(A,M,S){if(1!==arguments.length)return n.call(this,A=this.root+A,M,S),this;if(E(A)){var z=A;return this.filter(function(N,Z){return!Z.dir&&z.test(N)})}var O=this.files[this.root+A];return O&&!O.dir?O:null},folder:function(A){if(!A)return this;if(E(A))return this.filter(function(O,N){return N.dir&&A.test(O)});var S=x.call(this,this.root+A),z=this.clone();return z.root=S.name,z},remove:function(A){var M=this.files[A=this.root+A];if(M||("/"!==A.slice(-1)&&(A+="/"),M=this.files[A]),M&&!M.dir)delete this.files[A];else for(var S=this.filter(function(O,N){return N.name.slice(0,A.length)===A}),z=0;z<S.length;z++)delete this.files[S[z].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(A){var M,S={};try{if((S=a.extend(A||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:r.utf8encode})).type=S.type.toLowerCase(),S.compression=S.compression.toUpperCase(),"binarystring"===S.type&&(S.type="string"),!S.type)throw new Error("No output type specified.");a.checkSupport(S.type),"darwin"!==S.platform&&"freebsd"!==S.platform&&"linux"!==S.platform&&"sunos"!==S.platform||(S.platform="UNIX"),"win32"===S.platform&&(S.platform="DOS"),M=d.generateWorker(this,S,S.comment||this.comment||"")}catch(O){(M=new l("error")).error(O)}return new c(M,S.type||"string",S.mimeType)},generateAsync:function(A,M){return this.generateInternalStream(A).accumulate(M)},generateNodeStream:function(A,M){return(A=A||{}).type||(A.type="nodebuffer"),this.generateInternalStream(A).toNodejsStream(M)}};i.exports=T},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(t,i,s){i.exports=t("stream")},{stream:void 0}],17:[function(t,i,s){var n=t("./DataReader");function r(a){n.call(this,a);for(var l=0;l<this.data.length;l++)a[l]=255&a[l]}t("../utils").inherits(r,n),r.prototype.byteAt=function(a){return this.data[this.zero+a]},r.prototype.lastIndexOfSignature=function(a){for(var l=a.charCodeAt(0),c=a.charCodeAt(1),u=a.charCodeAt(2),h=a.charCodeAt(3),f=this.length-4;0<=f;--f)if(this.data[f]===l&&this.data[f+1]===c&&this.data[f+2]===u&&this.data[f+3]===h)return f-this.zero;return-1},r.prototype.readAndCheckSignature=function(a){var l=a.charCodeAt(0),c=a.charCodeAt(1),u=a.charCodeAt(2),h=a.charCodeAt(3),f=this.readData(4);return l===f[0]&&c===f[1]&&u===f[2]&&h===f[3]},r.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=r},{"../utils":32,"./DataReader":18}],18:[function(t,i,s){var n=t("../utils");function r(a){this.data=a,this.length=a.length,this.index=0,this.zero=0}r.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.length<this.zero+a||a<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var l,c=0;for(this.checkOffset(a),l=this.index+a-1;l>=this.index;l--)c=(c<<8)+this.byteAt(l);return this.index+=a,c},readString:function(a){return 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=r},{"../utils":32}],19:[function(t,i,s){var n=t("./Uint8ArrayReader");function r(a){n.call(this,a)}t("../utils").inherits(r,n),r.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=r},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(t,i,s){var n=t("./DataReader");function r(a){n.call(this,a)}t("../utils").inherits(r,n),r.prototype.byteAt=function(a){return this.data.charCodeAt(this.zero+a)},r.prototype.lastIndexOfSignature=function(a){return this.data.lastIndexOf(a)-this.zero},r.prototype.readAndCheckSignature=function(a){return a===this.readData(4)},r.prototype.readData=function(a){this.checkOffset(a);var l=this.data.slice(this.zero+this.index,this.zero+this.index+a);return this.index+=a,l},i.exports=r},{"../utils":32,"./DataReader":18}],21:[function(t,i,s){var n=t("./ArrayReader");function r(a){n.call(this,a)}t("../utils").inherits(r,n),r.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=r},{"../utils":32,"./ArrayReader":17}],22:[function(t,i,s){var n=t("../utils"),r=t("../support"),a=t("./ArrayReader"),l=t("./StringReader"),c=t("./NodeBufferReader"),u=t("./Uint8ArrayReader");i.exports=function(h){var f=n.getTypeOf(h);return n.checkSupport(f),"string"!==f||r.uint8array?"nodebuffer"===f?new c(h):r.uint8array?new u(n.transformTo("uint8array",h)):new a(n.transformTo("array",h)):new l(h)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(t,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(t,i,s){var n=t("./GenericWorker"),r=t("../utils");function a(l){n.call(this,"ConvertWorker to "+l),this.destType=l}r.inherits(a,n),a.prototype.processChunk=function(l){this.push({data:r.transformTo(this.destType,l.data),meta:l.meta})},i.exports=a},{"../utils":32,"./GenericWorker":28}],25:[function(t,i,s){var n=t("./GenericWorker"),r=t("../crc32");function a(){n.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}t("../utils").inherits(a,n),a.prototype.processChunk=function(l){this.streamInfo.crc32=r(l.data,this.streamInfo.crc32||0),this.push(l)},i.exports=a},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(t,i,s){var n=t("../utils"),r=t("./GenericWorker");function a(l){r.call(this,"DataLengthProbe for "+l),this.propName=l,this.withStreamInfo(l,0)}n.inherits(a,r),a.prototype.processChunk=function(l){l&&(this.streamInfo[this.propName]=(this.streamInfo[this.propName]||0)+l.data.length),r.prototype.processChunk.call(this,l)},i.exports=a},{"../utils":32,"./GenericWorker":28}],27:[function(t,i,s){var n=t("../utils"),r=t("./GenericWorker");function a(l){r.call(this,"DataWorker");var c=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,l.then(function(u){c.dataIsReady=!0,c.data=u,c.max=u&&u.length||0,c.type=n.getTypeOf(u),c.isPaused||c._tickAndRepeat()},function(u){c.error(u)})}n.inherits(a,r),a.prototype.cleanUp=function(){r.prototype.cleanUp.call(this),this.data=null},a.prototype.resume=function(){return!!r.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,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(t,i,s){function n(r){this.name=r||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}n.prototype={push:function(r){this.emit("data",r)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(r){this.emit("error",r)}return!0},error:function(r){return!this.isFinished&&(this.isPaused?this.generatedError=r:(this.isFinished=!0,this.emit("error",r),this.previous&&this.previous.error(r),this.cleanUp()),!0)},on:function(r,a){return this._listeners[r].push(a),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(r,a){if(this._listeners[r])for(var l=0;l<this._listeners[r].length;l++)this._listeners[r][l].call(this,a)},pipe:function(r){return r.registerPrevious(this)},registerPrevious:function(r){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=r.streamInfo,this.mergeStreamInfo(),this.previous=r;var a=this;return r.on("data",function(l){a.processChunk(l)}),r.on("end",function(){a.end()}),r.on("error",function(l){a.error(l)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var r=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),r=!0),this.previous&&this.previous.resume(),!r},flush:function(){},processChunk:function(r){this.push(r)},withStreamInfo:function(r,a){return this.extraStreamInfo[r]=a,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var r in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,r)&&(this.streamInfo[r]=this.extraStreamInfo[r])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var r="Worker "+this.name;return this.previous?this.previous+" -> "+r:r}},i.exports=n},{}],29:[function(t,i,s){var n=t("../utils"),r=t("./ConvertWorker"),a=t("./GenericWorker"),l=t("../base64"),c=t("../support"),u=t("../external"),h=null;if(c.nodestream)try{h=t("../nodejs/NodejsStreamOutputAdapter")}catch{}function d(y,g,_){var p=g;switch(g){case"blob":case"arraybuffer":p="uint8array";break;case"base64":p="string"}try{this._internalType=p,this._outputType=g,this._mimeType=_,n.checkSupport(p),this._worker=y.pipe(new r(p)),y.lock()}catch(x){this._worker=new a("error"),this._worker.error(x)}}d.prototype={accumulate:function(y){return function f(y,g){return new u.Promise(function(_,p){var x=[],E=y._internalType,T=y._outputType,A=y._mimeType;y.on("data",function(M,S){x.push(M),g&&g(S)}).on("error",function(M){x=[],p(M)}).on("end",function(){try{var M=function(S,z,O){switch(S){case"blob":return n.newBlob(n.transformTo("arraybuffer",z),O);case"base64":return l.encode(z);default:return n.transformTo(S,z)}}(T,function(S,z){var O,N=0,Z=null,P=0;for(O=0;O<z.length;O++)P+=z[O].length;switch(S){case"string":return z.join("");case"array":return Array.prototype.concat.apply([],z);case"uint8array":for(Z=new Uint8Array(P),O=0;O<z.length;O++)Z.set(z[O],N),N+=z[O].length;return Z;case"nodebuffer":return Buffer.concat(z);default:throw new Error("concat : unsupported type '"+S+"'")}}(E,x),A);_(M)}catch(S){p(S)}x=[]}).resume()})}(this,y)},on:function(y,g){var _=this;return this._worker.on(y,"data"===y?function(p){g.call(_,p.data,p.meta)}:function(){n.delay(g,arguments,_)}),this},resume:function(){return n.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(y){if(n.checkSupport("nodestream"),"nodebuffer"!==this._outputType)throw new Error(this._outputType+" is not supported by this method");return new h(this,{objectMode:"nodebuffer"!==this._outputType},y)}},i.exports=d},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(t,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 r=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);r.append(n),s.blob=0===r.getBlob("application/zip").size}catch{s.blob=!1}}}try{s.nodestream=!!t("readable-stream").Readable}catch{s.nodestream=!1}},{"readable-stream":16}],31:[function(t,i,s){for(var n=t("./utils"),r=t("./support"),a=t("./nodejsUtils"),l=t("./stream/GenericWorker"),c=new Array(256),u=0;u<256;u++)c[u]=252<=u?6:248<=u?5:240<=u?4:224<=u?3:192<=u?2:1;function h(){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 r.nodebuffer?a.newBufferFrom(d,"utf-8"):function(y){var g,_,p,x,E,T=y.length,A=0;for(x=0;x<T;x++)55296==(64512&(_=y.charCodeAt(x)))&&x+1<T&&56320==(64512&(p=y.charCodeAt(x+1)))&&(_=65536+(_-55296<<10)+(p-56320),x++),A+=_<128?1:_<2048?2:_<65536?3:4;for(g=r.uint8array?new Uint8Array(A):new Array(A),x=E=0;E<A;x++)55296==(64512&(_=y.charCodeAt(x)))&&x+1<T&&56320==(64512&(p=y.charCodeAt(x+1)))&&(_=65536+(_-55296<<10)+(p-56320),x++),_<128?g[E++]=_:(_<2048?g[E++]=192|_>>>6:(_<65536?g[E++]=224|_>>>12:(g[E++]=240|_>>>18,g[E++]=128|_>>>12&63),g[E++]=128|_>>>6&63),g[E++]=128|63&_);return g}(d)},s.utf8decode=function(d){return r.nodebuffer?n.transformTo("nodebuffer",d).toString("utf-8"):function(y){var g,_,p,x,E=y.length,T=new Array(2*E);for(g=_=0;g<E;)if((p=y[g++])<128)T[_++]=p;else if(4<(x=c[p]))T[_++]=65533,g+=x-1;else{for(p&=2===x?31:3===x?15:7;1<x&&g<E;)p=p<<6|63&y[g++],x--;1<x?T[_++]=65533:p<65536?T[_++]=p:(T[_++]=55296|(p-=65536)>>10&1023,T[_++]=56320|1023&p)}return T.length!==_&&(T.subarray?T=T.subarray(0,_):T.length=_),n.applyFromCharCode(T)}(d=n.transformTo(r.uint8array?"uint8array":"array",d))},n.inherits(h,l),h.prototype.processChunk=function(d){var y=n.transformTo(r.uint8array?"uint8array":"array",d.data);if(this.leftOver&&this.leftOver.length){if(r.uint8array){var g=y;(y=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),y.set(g,this.leftOver.length)}else y=this.leftOver.concat(y);this.leftOver=null}var _=function(x,E){var T;for((E=E||x.length)>x.length&&(E=x.length),T=E-1;0<=T&&128==(192&x[T]);)T--;return T<0||0===T?E:T+c[x[T]]>E?T:E}(y),p=y;_!==y.length&&(r.uint8array?(p=y.subarray(0,_),this.leftOver=y.subarray(_,y.length)):(p=y.slice(0,_),this.leftOver=y.slice(_,y.length))),this.push({data:s.utf8decode(p),meta:d.meta})},h.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:s.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},s.Utf8DecodeWorker=h,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(t,i,s){var n=t("./support"),r=t("./base64"),a=t("./nodejsUtils"),l=t("./external");function c(g){return g}function u(g,_){for(var p=0;p<g.length;++p)_[p]=255&g.charCodeAt(p);return _}t("setimmediate"),s.newBlob=function(g,_){s.checkSupport("blob");try{return new Blob([g],{type:_})}catch{try{var p=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return p.append(g),p.getBlob(_)}catch{throw new Error("Bug : can't construct the Blob.")}}};var h={stringifyByChunk:function(g,_,p){var x=[],E=0,T=g.length;if(T<=p)return String.fromCharCode.apply(null,g);for(;E<T;)x.push(String.fromCharCode.apply(null,"array"===_||"nodebuffer"===_?g.slice(E,Math.min(E+p,T)):g.subarray(E,Math.min(E+p,T)))),E+=p;return x.join("")},stringifyByChar:function(g){for(var _="",p=0;p<g.length;p++)_+=String.fromCharCode(g[p]);return _},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(g){var _=65536,p=s.getTypeOf(g),x=!0;if("uint8array"===p?x=h.applyCanBeUsed.uint8array:"nodebuffer"===p&&(x=h.applyCanBeUsed.nodebuffer),x)for(;1<_;)try{return h.stringifyByChunk(g,p,_)}catch{_=Math.floor(_/2)}return h.stringifyByChar(g)}function d(g,_){for(var p=0;p<g.length;p++)_[p]=g[p];return _}s.applyFromCharCode=f;var y={};y.string={string:c,array:function(g){return u(g,new Array(g.length))},arraybuffer:function(g){return y.string.uint8array(g).buffer},uint8array:function(g){return u(g,new Uint8Array(g.length))},nodebuffer:function(g){return u(g,a.allocBuffer(g.length))}},y.array={string:f,array:c,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return a.newBufferFrom(g)}},y.arraybuffer={string:function(g){return f(new Uint8Array(g))},array:function(g){return d(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:c,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return a.newBufferFrom(new Uint8Array(g))}},y.uint8array={string:f,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:c,nodebuffer:function(g){return a.newBufferFrom(g)}},y.nodebuffer={string:f,array:function(g){return d(g,new Array(g.length))},arraybuffer:function(g){return y.nodebuffer.uint8array(g).buffer},uint8array:function(g){return d(g,new Uint8Array(g.length))},nodebuffer:c},s.transformTo=function(g,_){if(_=_||"",!g)return _;s.checkSupport(g);var p=s.getTypeOf(_);return y[p][g](_)},s.resolve=function(g){for(var _=g.split("/"),p=[],x=0;x<_.length;x++){var E=_[x];"."===E||""===E&&0!==x&&x!==_.length-1||(".."===E?p.pop():p.push(E))}return p.join("/")},s.getTypeOf=function(g){return"string"==typeof g?"string":"[object Array]"===Object.prototype.toString.call(g)?"array":n.nodebuffer&&a.isBuffer(g)?"nodebuffer":n.uint8array&&g instanceof Uint8Array?"uint8array":n.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},s.checkSupport=function(g){if(!n[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},s.MAX_VALUE_16BITS=65535,s.MAX_VALUE_32BITS=-1,s.pretty=function(g){var _,p,x="";for(p=0;p<(g||"").length;p++)x+="\\x"+((_=g.charCodeAt(p))<16?"0":"")+_.toString(16).toUpperCase();return x},s.delay=function(g,_,p){setImmediate(function(){g.apply(p||null,_||[])})},s.inherits=function(g,_){function p(){}p.prototype=_.prototype,g.prototype=new p},s.extend=function(){var g,_,p={};for(g=0;g<arguments.length;g++)for(_ in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],_)&&void 0===p[_]&&(p[_]=arguments[g][_]);return p},s.prepareContent=function(g,_,p,x,E){return l.Promise.resolve(_).then(function(T){return n.blob&&(T instanceof Blob||-1!==["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(T)))&&typeof FileReader<"u"?new l.Promise(function(A,M){var S=new FileReader;S.onload=function(z){A(z.target.result)},S.onerror=function(z){M(z.target.error)},S.readAsArrayBuffer(T)}):T}).then(function(T){var M,A=s.getTypeOf(T);return A?("arraybuffer"===A?T=s.transformTo("uint8array",T):"string"===A&&(E?T=r.decode(T):p&&!0!==x&&(T=u(M=T,n.uint8array?new Uint8Array(M.length):new Array(M.length)))),T):l.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(t,i,s){var n=t("./reader/readerFor"),r=t("./utils"),a=t("./signature"),l=t("./zipEntry"),c=t("./support");function u(h){this.files=[],this.loadOptions=h}u.prototype={checkSignature:function(h){if(!this.reader.readAndCheckSignature(h)){this.reader.index-=4;var f=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+r.pretty(f)+", expected "+r.pretty(h)+")")}},isSignature:function(h,f){var d=this.reader.index;this.reader.setIndex(h);var y=this.reader.readString(4)===f;return this.reader.setIndex(d),y},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 h=this.reader.readData(this.zipCommentLength),d=r.transformTo(c.uint8array?"uint8array":"array",h);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 h,f,d,y=this.zip64EndOfCentralSize-44;0<y;)h=this.reader.readInt(2),f=this.reader.readInt(4),d=this.reader.readData(f),this.zip64ExtensibleData[h]={id:h,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 h,f;for(h=0;h<this.files.length;h++)this.reader.setIndex((f=this.files[h]).localHeaderOffset),this.checkSignature(a.LOCAL_FILE_HEADER),f.readLocalPart(this.reader),f.handleUTF8(),f.processAttributes()},readCentralDir:function(){var h;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(a.CENTRAL_FILE_HEADER);)(h=new l({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(h);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 h=this.reader.lastIndexOfSignature(a.CENTRAL_DIRECTORY_END);if(h<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(h);var f=h;if(this.checkSignature(a.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===r.MAX_VALUE_16BITS||this.diskWithCentralDirStart===r.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===r.MAX_VALUE_16BITS||this.centralDirRecords===r.MAX_VALUE_16BITS||this.centralDirSize===r.MAX_VALUE_32BITS||this.centralDirOffset===r.MAX_VALUE_32BITS){if(this.zip64=!0,(h=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(h),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 y=f-d;if(0<y)this.isSignature(f,a.CENTRAL_FILE_HEADER)||(this.reader.zero=y);else if(y<0)throw new Error("Corrupted zip: missing "+Math.abs(y)+" bytes.")},prepareReader:function(h){this.reader=n(h)},load:function(h){this.prepareReader(h),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},i.exports=u},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(t,i,s){var n=t("./reader/readerFor"),r=t("./utils"),a=t("./compressedObject"),l=t("./crc32"),c=t("./utf8"),u=t("./compressions"),h=t("./support");function f(d,y){this.options=d,this.loadOptions=y}f.prototype={isEncrypted:function(){return!(1&~this.bitFlag)},useUTF8:function(){return!(2048&~this.bitFlag)},readLocalPart:function(d){var y,g;if(d.skip(22),this.fileNameLength=d.readInt(2),g=d.readInt(2),this.fileName=d.readData(this.fileNameLength),d.skip(g),-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===(y=function(_){for(var p in u)if(Object.prototype.hasOwnProperty.call(u,p)&&u[p].magic===_)return u[p];return null}(this.compressionMethod)))throw new Error("Corrupted zip : compression "+r.pretty(this.compressionMethod)+" unknown (inner file : "+r.transformTo("string",this.fileName)+")");this.decompressed=new a(this.compressedSize,this.uncompressedSize,this.crc32,y,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 y=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(y),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===r.MAX_VALUE_32BITS&&(this.uncompressedSize=d.readInt(8)),this.compressedSize===r.MAX_VALUE_32BITS&&(this.compressedSize=d.readInt(8)),this.localHeaderOffset===r.MAX_VALUE_32BITS&&(this.localHeaderOffset=d.readInt(8)),this.diskNumberStart===r.MAX_VALUE_32BITS&&(this.diskNumberStart=d.readInt(4))}},readExtraFields:function(d){var y,g,_,p=d.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});d.index+4<p;)y=d.readInt(2),g=d.readInt(2),_=d.readData(g),this.extraFields[y]={id:y,length:g,value:_};d.setIndex(p)},handleUTF8:function(){var d=h.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=c.utf8decode(this.fileName),this.fileCommentStr=c.utf8decode(this.fileComment);else{var y=this.findExtraFieldUnicodePath();if(null!==y)this.fileNameStr=y;else{var g=r.transformTo(d,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var _=this.findExtraFieldUnicodeComment();if(null!==_)this.fileCommentStr=_;else{var p=r.transformTo(d,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(p)}}},findExtraFieldUnicodePath:function(){var d=this.extraFields[28789];if(d){var y=n(d.value);return 1!==y.readInt(1)||l(this.fileName)!==y.readInt(4)?null:c.utf8decode(y.readData(d.length-5))}return null},findExtraFieldUnicodeComment:function(){var d=this.extraFields[25461];if(d){var y=n(d.value);return 1!==y.readInt(1)||l(this.fileComment)!==y.readInt(4)?null:c.utf8decode(y.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(t,i,s){function n(y,g,_){this.name=y,this.dir=_.dir,this.date=_.date,this.comment=_.comment,this.unixPermissions=_.unixPermissions,this.dosPermissions=_.dosPermissions,this._data=g,this._dataBinary=_.binary,this.options={compression:_.compression,compressionOptions:_.compressionOptions}}var r=t("./stream/StreamHelper"),a=t("./stream/DataWorker"),l=t("./utf8"),c=t("./compressedObject"),u=t("./stream/GenericWorker");n.prototype={internalStream:function(y){var g=null,_="string";try{if(!y)throw new Error("No output type specified.");var p="string"===(_=y.toLowerCase())||"text"===_;"binarystring"!==_&&"text"!==_||(_="string"),g=this._decompressWorker();var x=!this._dataBinary;x&&!p&&(g=g.pipe(new l.Utf8EncodeWorker)),!x&&p&&(g=g.pipe(new l.Utf8DecodeWorker))}catch(E){(g=new u("error")).error(E)}return new r(g,_,"")},async:function(y,g){return this.internalStream(y).accumulate(g)},nodeStream:function(y,g){return this.internalStream(y||"nodebuffer").toNodejsStream(g)},_compressWorker:function(y,g){if(this._data instanceof c&&this._data.compression.magic===y.magic)return this._data.getCompressedWorker();var _=this._decompressWorker();return this._dataBinary||(_=_.pipe(new l.Utf8EncodeWorker)),c.createWorkerFrom(_,y,g)},_decompressWorker:function(){return this._data instanceof c?this._data.getContentWorker():this._data instanceof u?this._data:new a(this._data)}};for(var h=["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<h.length;d++)n.prototype[h[d]]=f;i.exports=n},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(t,i,s){(function(n){var r,a,l=n.MutationObserver||n.WebKitMutationObserver;if(l){var c=0,u=new l(y),h=n.document.createTextNode("");u.observe(h,{characterData:!0}),r=function(){h.data=c=++c%2}}else if(n.setImmediate||void 0===n.MessageChannel)r="document"in n&&"onreadystatechange"in n.document.createElement("script")?function(){var g=n.document.createElement("script");g.onreadystatechange=function(){y(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},n.document.documentElement.appendChild(g)}:function(){setTimeout(y,0)};else{var f=new n.MessageChannel;f.port1.onmessage=y,r=function(){f.port2.postMessage(0)}}var d=[];function y(){var g,_;a=!0;for(var p=d.length;p;){for(_=d,d=[],g=-1;++g<p;)_[g]();p=d.length}a=!1}i.exports=function(g){1!==d.push(g)||a||r()}}).call(this,typeof qi<"u"?qi:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(t,i,s){var n=t("immediate");function r(){}var a={},l=["REJECTED"],c=["FULFILLED"],u=["PENDING"];function h(p){if("function"!=typeof p)throw new TypeError("resolver must be a function");this.state=u,this.queue=[],this.outcome=void 0,p!==r&&g(this,p)}function f(p,x,E){this.promise=p,"function"==typeof x&&(this.onFulfilled=x,this.callFulfilled=this.otherCallFulfilled),"function"==typeof E&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}function d(p,x,E){n(function(){var T;try{T=x(E)}catch(A){return a.reject(p,A)}T===p?a.reject(p,new TypeError("Cannot resolve promise with itself")):a.resolve(p,T)})}function y(p){var x=p&&p.then;if(p&&("object"==typeof p||"function"==typeof p)&&"function"==typeof x)return function(){x.apply(p,arguments)}}function g(p,x){var E=!1;function T(S){E||(E=!0,a.reject(p,S))}function A(S){E||(E=!0,a.resolve(p,S))}var M=_(function(){x(A,T)});"error"===M.status&&T(M.value)}function _(p,x){var E={};try{E.value=p(x),E.status="success"}catch(T){E.status="error",E.value=T}return E}(i.exports=h).prototype.finally=function(p){if("function"!=typeof p)return this;var x=this.constructor;return this.then(function(E){return x.resolve(p()).then(function(){return E})},function(E){return x.resolve(p()).then(function(){throw E})})},h.prototype.catch=function(p){return this.then(null,p)},h.prototype.then=function(p,x){if("function"!=typeof p&&this.state===c||"function"!=typeof x&&this.state===l)return this;var E=new this.constructor(r);return this.state!==u?d(E,this.state===c?p:x,this.outcome):this.queue.push(new f(E,p,x)),E},f.prototype.callFulfilled=function(p){a.resolve(this.promise,p)},f.prototype.otherCallFulfilled=function(p){d(this.promise,this.onFulfilled,p)},f.prototype.callRejected=function(p){a.reject(this.promise,p)},f.prototype.otherCallRejected=function(p){d(this.promise,this.onRejected,p)},a.resolve=function(p,x){var E=_(y,x);if("error"===E.status)return a.reject(p,E.value);var T=E.value;if(T)g(p,T);else{p.state=c,p.outcome=x;for(var A=-1,M=p.queue.length;++A<M;)p.queue[A].callFulfilled(x)}return p},a.reject=function(p,x){p.state=l,p.outcome=x;for(var E=-1,T=p.queue.length;++E<T;)p.queue[E].callRejected(x);return p},h.resolve=function(p){return p instanceof this?p:a.resolve(new this(r),p)},h.reject=function(p){var x=new this(r);return a.reject(x,p)},h.all=function(p){var x=this;if("[object Array]"!==Object.prototype.toString.call(p))return this.reject(new TypeError("must be an array"));var E=p.length,T=!1;if(!E)return this.resolve([]);for(var A=new Array(E),M=0,S=-1,z=new this(r);++S<E;)O(p[S],S);return z;function O(N,Z){x.resolve(N).then(function(P){A[Z]=P,++M!==E||T||(T=!0,a.resolve(z,A))},function(P){T||(T=!0,a.reject(z,P))})}},h.race=function(p){if("[object Array]"!==Object.prototype.toString.call(p))return this.reject(new TypeError("must be an array"));var E=p.length,T=!1;if(!E)return this.resolve([]);for(var A=-1,M=new this(r);++A<E;)this.resolve(p[A]).then(function(z){T||(T=!0,a.resolve(M,z))},function(z){T||(T=!0,a.reject(M,z))});return M}},{immediate:36}],38:[function(t,i,s){var n={};(0,t("./lib/utils/common").assign)(n,t("./lib/deflate"),t("./lib/inflate"),t("./lib/zlib/constants")),i.exports=n},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(t,i,s){var n=t("./zlib/deflate"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/messages"),c=t("./zlib/zstream"),u=Object.prototype.toString;function g(p){if(!(this instanceof g))return new g(p);this.options=r.assign({level:-1,method:8,chunkSize:16384,windowBits:15,memLevel:8,strategy:0,to:""},p||{});var x=this.options;x.raw&&0<x.windowBits?x.windowBits=-x.windowBits:x.gzip&&0<x.windowBits&&x.windowBits<16&&(x.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new c,this.strm.avail_out=0;var E=n.deflateInit2(this.strm,x.level,x.method,x.windowBits,x.memLevel,x.strategy);if(0!==E)throw new Error(l[E]);if(x.header&&n.deflateSetHeader(this.strm,x.header),x.dictionary){var T;if(T="string"==typeof x.dictionary?a.string2buf(x.dictionary):"[object ArrayBuffer]"===u.call(x.dictionary)?new Uint8Array(x.dictionary):x.dictionary,0!==(E=n.deflateSetDictionary(this.strm,T)))throw new Error(l[E]);this._dict_set=!0}}function _(p,x){var E=new g(x);if(E.push(p,!0),E.err)throw E.msg||l[E.err];return E.result}g.prototype.push=function(p,x){var E,T,A=this.strm,M=this.options.chunkSize;if(this.ended)return!1;T=x===~~x?x:!0===x?4:0,A.input="string"==typeof p?a.string2buf(p):"[object ArrayBuffer]"===u.call(p)?new Uint8Array(p):p,A.next_in=0,A.avail_in=A.input.length;do{if(0===A.avail_out&&(A.output=new r.Buf8(M),A.next_out=0,A.avail_out=M),1!==(E=n.deflate(A,T))&&0!==E)return this.onEnd(E),!(this.ended=!0);0!==A.avail_out&&(0!==A.avail_in||4!==T&&2!==T)||this.onData("string"===this.options.to?a.buf2binstring(r.shrinkBuf(A.output,A.next_out)):r.shrinkBuf(A.output,A.next_out))}while((0<A.avail_in||0===A.avail_out)&&1!==E);return 4===T?(E=n.deflateEnd(this.strm),this.onEnd(E),this.ended=!0,0===E):2!==T||(this.onEnd(0),!(A.avail_out=0))},g.prototype.onData=function(p){this.chunks.push(p)},g.prototype.onEnd=function(p){0===p&&(this.result="string"===this.options.to?this.chunks.join(""):r.flattenChunks(this.chunks)),this.chunks=[],this.err=p,this.msg=this.strm.msg},s.Deflate=g,s.deflate=_,s.deflateRaw=function(p,x){return(x=x||{}).raw=!0,_(p,x)},s.gzip=function(p,x){return(x=x||{}).gzip=!0,_(p,x)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(t,i,s){var n=t("./zlib/inflate"),r=t("./utils/common"),a=t("./utils/strings"),l=t("./zlib/constants"),c=t("./zlib/messages"),u=t("./zlib/zstream"),h=t("./zlib/gzheader"),f=Object.prototype.toString;function d(g){if(!(this instanceof d))return new d(g);this.options=r.assign({chunkSize:16384,windowBits:0,to:""},g||{});var _=this.options;_.raw&&0<=_.windowBits&&_.windowBits<16&&(_.windowBits=-_.windowBits,0===_.windowBits&&(_.windowBits=-15)),!(0<=_.windowBits&&_.windowBits<16)||g&&g.windowBits||(_.windowBits+=32),15<_.windowBits&&_.windowBits<48&&!(15&_.windowBits)&&(_.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new u,this.strm.avail_out=0;var p=n.inflateInit2(this.strm,_.windowBits);if(p!==l.Z_OK)throw new Error(c[p]);this.header=new h,n.inflateGetHeader(this.strm,this.header)}function y(g,_){var p=new d(_);if(p.push(g,!0),p.err)throw p.msg||c[p.err];return p.result}d.prototype.push=function(g,_){var p,x,E,T,A,M,S=this.strm,z=this.options.chunkSize,O=this.options.dictionary,N=!1;if(this.ended)return!1;x=_===~~_?_:!0===_?l.Z_FINISH:l.Z_NO_FLUSH,S.input="string"==typeof g?a.binstring2buf(g):"[object ArrayBuffer]"===f.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 r.Buf8(z),S.next_out=0,S.avail_out=z),(p=n.inflate(S,l.Z_NO_FLUSH))===l.Z_NEED_DICT&&O&&(M="string"==typeof O?a.string2buf(O):"[object ArrayBuffer]"===f.call(O)?new Uint8Array(O):O,p=n.inflateSetDictionary(this.strm,M)),p===l.Z_BUF_ERROR&&!0===N&&(p=l.Z_OK,N=!1),p!==l.Z_STREAM_END&&p!==l.Z_OK)return this.onEnd(p),!(this.ended=!0);S.next_out&&(0!==S.avail_out&&p!==l.Z_STREAM_END&&(0!==S.avail_in||x!==l.Z_FINISH&&x!==l.Z_SYNC_FLUSH)||("string"===this.options.to?(E=a.utf8border(S.output,S.next_out),T=S.next_out-E,A=a.buf2string(S.output,E),S.next_out=T,S.avail_out=z-T,T&&r.arraySet(S.output,S.output,E,T,0),this.onData(A)):this.onData(r.shrinkBuf(S.output,S.next_out)))),0===S.avail_in&&0===S.avail_out&&(N=!0)}while((0<S.avail_in||0===S.avail_out)&&p!==l.Z_STREAM_END);return p===l.Z_STREAM_END&&(x=l.Z_FINISH),x===l.Z_FINISH?(p=n.inflateEnd(this.strm),this.onEnd(p),this.ended=!0,p===l.Z_OK):x!==l.Z_SYNC_FLUSH||(this.onEnd(l.Z_OK),!(S.avail_out=0))},d.prototype.onData=function(g){this.chunks.push(g)},d.prototype.onEnd=function(g){g===l.Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):r.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},s.Inflate=d,s.inflate=y,s.inflateRaw=function(g,_){return(_=_||{}).raw=!0,y(g,_)},s.ungzip=y},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(t,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 u=c.shift();if(u){if("object"!=typeof u)throw new TypeError(u+"must be non-object");for(var h in u)u.hasOwnProperty(h)&&(l[h]=u[h])}}return l},s.shrinkBuf=function(l,c){return l.length===c?l:l.subarray?l.subarray(0,c):(l.length=c,l)};var r={arraySet:function(l,c,u,h,f){if(c.subarray&&l.subarray)l.set(c.subarray(u,u+h),f);else for(var d=0;d<h;d++)l[f+d]=c[u+d]},flattenChunks:function(l){var c,u,h,f,d,y;for(c=h=0,u=l.length;c<u;c++)h+=l[c].length;for(y=new Uint8Array(h),c=f=0,u=l.length;c<u;c++)y.set(d=l[c],f),f+=d.length;return y}},a={arraySet:function(l,c,u,h,f){for(var d=0;d<h;d++)l[f+d]=c[u+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,r)):(s.Buf8=Array,s.Buf16=Array,s.Buf32=Array,s.assign(s,a))},s.setTyped(n)},{}],42:[function(t,i,s){var n=t("./common"),r=!0,a=!0;try{String.fromCharCode.apply(null,[0])}catch{r=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{a=!1}for(var l=new 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 u(h,f){if(f<65537&&(h.subarray&&a||!h.subarray&&r))return String.fromCharCode.apply(null,n.shrinkBuf(h,f));for(var d="",y=0;y<f;y++)d+=String.fromCharCode(h[y]);return d}l[254]=l[254]=1,s.string2buf=function(h){var f,d,y,g,_,p=h.length,x=0;for(g=0;g<p;g++)55296==(64512&(d=h.charCodeAt(g)))&&g+1<p&&56320==(64512&(y=h.charCodeAt(g+1)))&&(d=65536+(d-55296<<10)+(y-56320),g++),x+=d<128?1:d<2048?2:d<65536?3:4;for(f=new n.Buf8(x),g=_=0;_<x;g++)55296==(64512&(d=h.charCodeAt(g)))&&g+1<p&&56320==(64512&(y=h.charCodeAt(g+1)))&&(d=65536+(d-55296<<10)+(y-56320),g++),d<128?f[_++]=d:(d<2048?f[_++]=192|d>>>6:(d<65536?f[_++]=224|d>>>12:(f[_++]=240|d>>>18,f[_++]=128|d>>>12&63),f[_++]=128|d>>>6&63),f[_++]=128|63&d);return f},s.buf2binstring=function(h){return u(h,h.length)},s.binstring2buf=function(h){for(var f=new n.Buf8(h.length),d=0,y=f.length;d<y;d++)f[d]=h.charCodeAt(d);return f},s.buf2string=function(h,f){var d,y,g,_,p=f||h.length,x=new Array(2*p);for(d=y=0;d<p;)if((g=h[d++])<128)x[y++]=g;else if(4<(_=l[g]))x[y++]=65533,d+=_-1;else{for(g&=2===_?31:3===_?15:7;1<_&&d<p;)g=g<<6|63&h[d++],_--;1<_?x[y++]=65533:g<65536?x[y++]=g:(x[y++]=55296|(g-=65536)>>10&1023,x[y++]=56320|1023&g)}return u(x,y)},s.utf8border=function(h,f){var d;for((f=f||h.length)>h.length&&(f=h.length),d=f-1;0<=d&&128==(192&h[d]);)d--;return d<0||0===d?f:d+l[h[d]]>f?d:f}},{"./common":41}],43:[function(t,i,s){i.exports=function(n,r,a,l){for(var c=65535&n,u=n>>>16&65535,h=0;0!==a;){for(a-=h=2e3<a?2e3:a;u=u+(c=c+r[l++]|0)|0,--h;);c%=65521,u%=65521}return c|u<<16}},{}],44:[function(t,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(t,i,s){var n=function(){for(var r,a=[],l=0;l<256;l++){r=l;for(var c=0;c<8;c++)r=1&r?3988292384^r>>>1:r>>>1;a[l]=r}return a}();i.exports=function(r,a,l,c){var u=n,h=c+l;r^=-1;for(var f=c;f<h;f++)r=r>>>8^u[255&(r^a[f])];return-1^r}},{}],46:[function(t,i,s){var n,r=t("../utils/common"),a=t("./trees"),l=t("./adler32"),c=t("./crc32"),u=t("./messages"),y=-2,N=258,Z=262,F=113;function rt(C,W){return C.msg=u[W],W}function Y(C){return(C<<1)-(4<C?9:0)}function ot(C){for(var W=C.length;0<=--W;)C[W]=0}function B(C){var W=C.state,$=W.pending;$>C.avail_out&&($=C.avail_out),0!==$&&(r.arraySet(C.output,W.pending_buf,W.pending_out,$,C.next_out),C.next_out+=$,W.pending_out+=$,C.total_out+=$,C.avail_out-=$,W.pending-=$,0===W.pending&&(W.pending_out=0))}function L(C,W){a._tr_flush_block(C,0<=C.block_start?C.block_start:-1,C.strstart-C.block_start,W),C.block_start=C.strstart,B(C.strm)}function it(C,W){C.pending_buf[C.pending++]=W}function et(C,W){C.pending_buf[C.pending++]=W>>>8&255,C.pending_buf[C.pending++]=255&W}function K(C,W){var $,k,I=C.max_chain_length,D=C.strstart,q=C.prev_length,G=C.nice_match,U=C.strstart>C.w_size-Z?C.strstart-(C.w_size-Z):0,J=C.window,nt=C.w_mask,tt=C.prev,at=C.strstart+N,Ct=J[D+q-1],pt=J[D+q];C.prev_length>=C.good_match&&(I>>=2),G>C.lookahead&&(G=C.lookahead);do{if(J[($=W)+q]===pt&&J[$+q-1]===Ct&&J[$]===J[D]&&J[++$]===J[D+1]){D+=2,$++;do{}while(J[++D]===J[++$]&&J[++D]===J[++$]&&J[++D]===J[++$]&&J[++D]===J[++$]&&J[++D]===J[++$]&&J[++D]===J[++$]&&J[++D]===J[++$]&&J[++D]===J[++$]&&D<at);if(k=N-(at-D),D=at-N,q<k){if(C.match_start=W,G<=(q=k))break;Ct=J[D+q-1],pt=J[D+q]}}}while((W=tt[W&nt])>U&&0!=--I);return q<=C.lookahead?q:C.lookahead}function _t(C){var W,$,k,I,D,q,G,U,J,nt,tt=C.w_size;do{if(I=C.window_size-C.lookahead-C.strstart,C.strstart>=tt+(tt-Z)){for(r.arraySet(C.window,C.window,tt,tt,0),C.match_start-=tt,C.strstart-=tt,C.block_start-=tt,W=$=C.hash_size;k=C.head[--W],C.head[W]=tt<=k?k-tt:0,--$;);for(W=$=tt;k=C.prev[--W],C.prev[W]=tt<=k?k-tt:0,--$;);I+=tt}if(0===C.strm.avail_in)break;if(G=C.window,U=C.strstart+C.lookahead,nt=void 0,(J=I)<(nt=(q=C.strm).avail_in)&&(nt=J),$=0===nt?0:(q.avail_in-=nt,r.arraySet(G,q.input,q.next_in,nt,U),1===q.state.wrap?q.adler=l(q.adler,G,nt,U):2===q.state.wrap&&(q.adler=c(q.adler,G,nt,U)),q.next_in+=nt,q.total_in+=nt,nt),C.lookahead+=$,C.lookahead+C.insert>=3)for(C.ins_h=C.window[D=C.strstart-C.insert],C.ins_h=(C.ins_h<<C.hash_shift^C.window[D+1])&C.hash_mask;C.insert&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[D+3-1])&C.hash_mask,C.prev[D&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=D,D++,C.insert--,!(C.lookahead+C.insert<3)););}while(C.lookahead<Z&&0!==C.strm.avail_in)}function Ot(C,W){for(var $,k;;){if(C.lookahead<Z){if(_t(C),C.lookahead<Z&&0===W)return 1;if(0===C.lookahead)break}if($=0,C.lookahead>=3&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+3-1])&C.hash_mask,$=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),0!==$&&C.strstart-$<=C.w_size-Z&&(C.match_length=K(C,$)),C.match_length>=3)if(k=a._tr_tally(C,C.strstart-C.match_start,C.match_length-3),C.lookahead-=C.match_length,C.match_length<=C.max_lazy_match&&C.lookahead>=3){for(C.match_length--;C.strstart++,C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+3-1])&C.hash_mask,$=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart,0!=--C.match_length;);C.strstart++}else C.strstart+=C.match_length,C.match_length=0,C.ins_h=C.window[C.strstart],C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+1])&C.hash_mask;else k=a._tr_tally(C,0,C.window[C.strstart]),C.lookahead--,C.strstart++;if(k&&(L(C,!1),0===C.strm.avail_out))return 1}return C.insert=C.strstart<2?C.strstart:2,4===W?(L(C,!0),0===C.strm.avail_out?3:4):C.last_lit&&(L(C,!1),0===C.strm.avail_out)?1:2}function ht(C,W){for(var $,k,I;;){if(C.lookahead<Z){if(_t(C),C.lookahead<Z&&0===W)return 1;if(0===C.lookahead)break}if($=0,C.lookahead>=3&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+3-1])&C.hash_mask,$=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),C.prev_length=C.match_length,C.prev_match=C.match_start,C.match_length=2,0!==$&&C.prev_length<C.max_lazy_match&&C.strstart-$<=C.w_size-Z&&(C.match_length=K(C,$),C.match_length<=5&&(1===C.strategy||3===C.match_length&&4096<C.strstart-C.match_start)&&(C.match_length=2)),C.prev_length>=3&&C.match_length<=C.prev_length){for(I=C.strstart+C.lookahead-3,k=a._tr_tally(C,C.strstart-1-C.prev_match,C.prev_length-3),C.lookahead-=C.prev_length-1,C.prev_length-=2;++C.strstart<=I&&(C.ins_h=(C.ins_h<<C.hash_shift^C.window[C.strstart+3-1])&C.hash_mask,$=C.prev[C.strstart&C.w_mask]=C.head[C.ins_h],C.head[C.ins_h]=C.strstart),0!=--C.prev_length;);if(C.match_available=0,C.match_length=2,C.strstart++,k&&(L(C,!1),0===C.strm.avail_out))return 1}else if(C.match_available){if((k=a._tr_tally(C,0,C.window[C.strstart-1]))&&L(C,!1),C.strstart++,C.lookahead--,0===C.strm.avail_out)return 1}else C.match_available=1,C.strstart++,C.lookahead--}return C.match_available&&(k=a._tr_tally(C,0,C.window[C.strstart-1]),C.match_available=0),C.insert=C.strstart<2?C.strstart:2,4===W?(L(C,!0),0===C.strm.avail_out?3:4):C.last_lit&&(L(C,!1),0===C.strm.avail_out)?1:2}function dt(C,W,$,k,I){this.good_length=C,this.max_lazy=W,this.nice_length=$,this.max_chain=k,this.func=I}function Pt(){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 r.Buf16(1146),this.dyn_dtree=new r.Buf16(122),this.bl_tree=new r.Buf16(78),ot(this.dyn_ltree),ot(this.dyn_dtree),ot(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new r.Buf16(16),this.heap=new r.Buf16(573),ot(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new r.Buf16(573),ot(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 bt(C){var W;return C&&C.state?(C.total_in=C.total_out=0,C.data_type=2,(W=C.state).pending=0,W.pending_out=0,W.wrap<0&&(W.wrap=-W.wrap),W.status=W.wrap?42:F,C.adler=2===W.wrap?0:1,W.last_flush=0,a._tr_init(W),0):rt(C,y)}function jt(C){var $,W=bt(C);return 0===W&&(($=C.state).window_size=2*$.w_size,ot($.head),$.max_lazy_match=n[$.level].max_lazy,$.good_match=n[$.level].good_length,$.nice_match=n[$.level].nice_length,$.max_chain_length=n[$.level].max_chain,$.strstart=0,$.block_start=0,$.lookahead=0,$.insert=0,$.match_length=$.prev_length=2,$.match_available=0,$.ins_h=0),W}function Vt(C,W,$,k,I,D){if(!C)return y;var q=1;if(-1===W&&(W=6),k<0?(q=0,k=-k):15<k&&(q=2,k-=16),I<1||9<I||8!==$||k<8||15<k||W<0||9<W||D<0||4<D)return rt(C,y);8===k&&(k=9);var G=new Pt;return(C.state=G).strm=C,G.wrap=q,G.gzhead=null,G.w_bits=k,G.w_size=1<<G.w_bits,G.w_mask=G.w_size-1,G.hash_bits=I+7,G.hash_size=1<<G.hash_bits,G.hash_mask=G.hash_size-1,G.hash_shift=~~((G.hash_bits+3-1)/3),G.window=new r.Buf8(2*G.w_size),G.head=new r.Buf16(G.hash_size),G.prev=new r.Buf16(G.w_size),G.lit_bufsize=1<<I+6,G.pending_buf_size=4*G.lit_bufsize,G.pending_buf=new r.Buf8(G.pending_buf_size),G.d_buf=1*G.lit_bufsize,G.l_buf=3*G.lit_bufsize,G.level=W,G.strategy=D,G.method=$,jt(C)}n=[new dt(0,0,0,0,function(C,W){var $=65535;for($>C.pending_buf_size-5&&($=C.pending_buf_size-5);;){if(C.lookahead<=1){if(_t(C),0===C.lookahead&&0===W)return 1;if(0===C.lookahead)break}C.strstart+=C.lookahead,C.lookahead=0;var k=C.block_start+$;if((0===C.strstart||C.strstart>=k)&&(C.lookahead=C.strstart-k,C.strstart=k,L(C,!1),0===C.strm.avail_out)||C.strstart-C.block_start>=C.w_size-Z&&(L(C,!1),0===C.strm.avail_out))return 1}return C.insert=0,4===W?(L(C,!0),0===C.strm.avail_out?3:4):(C.strstart>C.block_start&&L(C,!1),1)}),new dt(4,4,8,4,Ot),new dt(4,5,16,8,Ot),new dt(4,6,32,32,Ot),new dt(4,4,16,16,ht),new dt(8,16,32,32,ht),new dt(8,16,128,128,ht),new dt(8,32,128,256,ht),new dt(32,128,258,1024,ht),new dt(32,258,258,4096,ht)],s.deflateInit=function(C,W){return Vt(C,W,8,15,8,0)},s.deflateInit2=Vt,s.deflateReset=jt,s.deflateResetKeep=bt,s.deflateSetHeader=function(C,W){return C&&C.state?2!==C.state.wrap?y:(C.state.gzhead=W,0):y},s.deflate=function(C,W){var $,k,I,D;if(!C||!C.state||5<W||W<0)return C?rt(C,y):y;if(k=C.state,!C.output||!C.input&&0!==C.avail_in||666===k.status&&4!==W)return rt(C,0===C.avail_out?-5:y);if(k.strm=C,$=k.last_flush,k.last_flush=W,42===k.status)if(2===k.wrap)C.adler=0,it(k,31),it(k,139),it(k,8),k.gzhead?(it(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)),it(k,255&k.gzhead.time),it(k,k.gzhead.time>>8&255),it(k,k.gzhead.time>>16&255),it(k,k.gzhead.time>>24&255),it(k,9===k.level?2:2<=k.strategy||k.level<2?4:0),it(k,255&k.gzhead.os),k.gzhead.extra&&k.gzhead.extra.length&&(it(k,255&k.gzhead.extra.length),it(k,k.gzhead.extra.length>>8&255)),k.gzhead.hcrc&&(C.adler=c(C.adler,k.pending_buf,k.pending,0)),k.gzindex=0,k.status=69):(it(k,0),it(k,0),it(k,0),it(k,0),it(k,0),it(k,9===k.level?2:2<=k.strategy||k.level<2?4:0),it(k,3),k.status=F);else{var q=8+(k.w_bits-8<<4)<<8;q|=(2<=k.strategy||k.level<2?0:k.level<6?1:6===k.level?2:3)<<6,0!==k.strstart&&(q|=32),q+=31-q%31,k.status=F,et(k,q),0!==k.strstart&&(et(k,C.adler>>>16),et(k,65535&C.adler)),C.adler=1}if(69===k.status)if(k.gzhead.extra){for(I=k.pending;k.gzindex<(65535&k.gzhead.extra.length)&&(k.pending!==k.pending_buf_size||(k.gzhead.hcrc&&k.pending>I&&(C.adler=c(C.adler,k.pending_buf,k.pending-I,I)),B(C),I=k.pending,k.pending!==k.pending_buf_size));)it(k,255&k.gzhead.extra[k.gzindex]),k.gzindex++;k.gzhead.hcrc&&k.pending>I&&(C.adler=c(C.adler,k.pending_buf,k.pending-I,I)),k.gzindex===k.gzhead.extra.length&&(k.gzindex=0,k.status=73)}else k.status=73;if(73===k.status)if(k.gzhead.name){I=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>I&&(C.adler=c(C.adler,k.pending_buf,k.pending-I,I)),B(C),I=k.pending,k.pending===k.pending_buf_size)){D=1;break}D=k.gzindex<k.gzhead.name.length?255&k.gzhead.name.charCodeAt(k.gzindex++):0,it(k,D)}while(0!==D);k.gzhead.hcrc&&k.pending>I&&(C.adler=c(C.adler,k.pending_buf,k.pending-I,I)),0===D&&(k.gzindex=0,k.status=91)}else k.status=91;if(91===k.status)if(k.gzhead.comment){I=k.pending;do{if(k.pending===k.pending_buf_size&&(k.gzhead.hcrc&&k.pending>I&&(C.adler=c(C.adler,k.pending_buf,k.pending-I,I)),B(C),I=k.pending,k.pending===k.pending_buf_size)){D=1;break}D=k.gzindex<k.gzhead.comment.length?255&k.gzhead.comment.charCodeAt(k.gzindex++):0,it(k,D)}while(0!==D);k.gzhead.hcrc&&k.pending>I&&(C.adler=c(C.adler,k.pending_buf,k.pending-I,I)),0===D&&(k.status=103)}else k.status=103;if(103===k.status&&(k.gzhead.hcrc?(k.pending+2>k.pending_buf_size&&B(C),k.pending+2<=k.pending_buf_size&&(it(k,255&C.adler),it(k,C.adler>>8&255),C.adler=0,k.status=F)):k.status=F),0!==k.pending){if(B(C),0===C.avail_out)return k.last_flush=-1,0}else if(0===C.avail_in&&Y(W)<=Y($)&&4!==W)return rt(C,-5);if(666===k.status&&0!==C.avail_in)return rt(C,-5);if(0!==C.avail_in||0!==k.lookahead||0!==W&&666!==k.status){var G=2===k.strategy?function(U,J){for(var nt;;){if(0===U.lookahead&&(_t(U),0===U.lookahead)){if(0===J)return 1;break}if(U.match_length=0,nt=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++,nt&&(L(U,!1),0===U.strm.avail_out))return 1}return U.insert=0,4===J?(L(U,!0),0===U.strm.avail_out?3:4):U.last_lit&&(L(U,!1),0===U.strm.avail_out)?1:2}(k,W):3===k.strategy?function(U,J){for(var nt,tt,at,Ct,pt=U.window;;){if(U.lookahead<=N){if(_t(U),U.lookahead<=N&&0===J)return 1;if(0===U.lookahead)break}if(U.match_length=0,U.lookahead>=3&&0<U.strstart&&(tt=pt[at=U.strstart-1])===pt[++at]&&tt===pt[++at]&&tt===pt[++at]){Ct=U.strstart+N;do{}while(tt===pt[++at]&&tt===pt[++at]&&tt===pt[++at]&&tt===pt[++at]&&tt===pt[++at]&&tt===pt[++at]&&tt===pt[++at]&&tt===pt[++at]&&at<Ct);U.match_length=N-(Ct-at),U.match_length>U.lookahead&&(U.match_length=U.lookahead)}if(U.match_length>=3?(nt=a._tr_tally(U,1,U.match_length-3),U.lookahead-=U.match_length,U.strstart+=U.match_length,U.match_length=0):(nt=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++),nt&&(L(U,!1),0===U.strm.avail_out))return 1}return U.insert=0,4===J?(L(U,!0),0===U.strm.avail_out?3:4):U.last_lit&&(L(U,!1),0===U.strm.avail_out)?1:2}(k,W):n[k.level].func(k,W);if(3!==G&&4!==G||(k.status=666),1===G||3===G)return 0===C.avail_out&&(k.last_flush=-1),0;if(2===G&&(1===W?a._tr_align(k):5!==W&&(a._tr_stored_block(k,0,0,!1),3===W&&(ot(k.head),0===k.lookahead&&(k.strstart=0,k.block_start=0,k.insert=0))),B(C),0===C.avail_out))return k.last_flush=-1,0}return 4!==W?0:k.wrap<=0?1:(2===k.wrap?(it(k,255&C.adler),it(k,C.adler>>8&255),it(k,C.adler>>16&255),it(k,C.adler>>24&255),it(k,255&C.total_in),it(k,C.total_in>>8&255),it(k,C.total_in>>16&255),it(k,C.total_in>>24&255)):(et(k,C.adler>>>16),et(k,65535&C.adler)),B(C),0<k.wrap&&(k.wrap=-k.wrap),0!==k.pending?0:1)},s.deflateEnd=function(C){var W;return C&&C.state?42!==(W=C.state.status)&&69!==W&&73!==W&&91!==W&&103!==W&&W!==F&&666!==W?rt(C,y):(C.state=null,W===F?rt(C,-3):0):y},s.deflateSetDictionary=function(C,W){var $,k,I,D,q,G,U,J,nt=W.length;if(!C||!C.state||2===(D=($=C.state).wrap)||1===D&&42!==$.status||$.lookahead)return y;for(1===D&&(C.adler=l(C.adler,W,nt,0)),$.wrap=0,nt>=$.w_size&&(0===D&&(ot($.head),$.strstart=0,$.block_start=0,$.insert=0),J=new r.Buf8($.w_size),r.arraySet(J,W,nt-$.w_size,$.w_size,0),W=J,nt=$.w_size),q=C.avail_in,G=C.next_in,U=C.input,C.avail_in=nt,C.next_in=0,C.input=W,_t($);$.lookahead>=3;){for(k=$.strstart,I=$.lookahead-2;$.ins_h=($.ins_h<<$.hash_shift^$.window[k+3-1])&$.hash_mask,$.prev[k&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=k,k++,--I;);$.strstart=k,$.lookahead=2,_t($)}return $.strstart+=$.lookahead,$.block_start=$.strstart,$.insert=$.lookahead,$.lookahead=0,$.match_length=$.prev_length=2,$.match_available=0,C.next_in=G,C.input=U,C.avail_in=q,$.wrap=D,0},s.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(t,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(t,i,s){i.exports=function(n,r){var a,l,c,u,h,f,d,y,g,_,p,x,E,T,A,M,S,z,O,N,Z,P,F,v,R;v=n.input,c=(l=n.next_in)+(n.avail_in-5),R=n.output,h=(u=n.next_out)-(r-n.avail_out),f=u+(n.avail_out-257),d=(a=n.state).dmax,y=a.wsize,g=a.whave,_=a.wnext,p=a.window,x=a.hold,E=a.bits,T=a.lencode,A=a.distcode,M=(1<<a.lenbits)-1,S=(1<<a.distbits)-1;t:do{E<15&&(x+=v[l++]<<E,x+=v[l++]<<(E+=8),E+=8),z=T[x&M];e:for(;;){if(x>>>=O=z>>>24,E-=O,0==(O=z>>>16&255))R[u++]=65535&z;else{if(!(16&O)){if(!(64&O)){z=T[(65535&z)+(x&(1<<O)-1)];continue e}if(32&O){a.mode=12;break t}n.msg="invalid literal/length code",a.mode=30;break t}N=65535&z,(O&=15)&&(E<O&&(x+=v[l++]<<E,E+=8),N+=x&(1<<O)-1,x>>>=O,E-=O),E<15&&(x+=v[l++]<<E,x+=v[l++]<<(E+=8),E+=8),z=A[x&S];i:for(;;){if(x>>>=O=z>>>24,E-=O,!(16&(O=z>>>16&255))){if(!(64&O)){z=A[(65535&z)+(x&(1<<O)-1)];continue i}n.msg="invalid distance code",a.mode=30;break t}if(Z=65535&z,E<(O&=15)&&(x+=v[l++]<<E,(E+=8)<O&&(x+=v[l++]<<E,E+=8)),d<(Z+=x&(1<<O)-1)){n.msg="invalid distance too far back",a.mode=30;break t}if(x>>>=O,E-=O,(O=u-h)<Z){if(g<(O=Z-O)&&a.sane){n.msg="invalid distance too far back",a.mode=30;break t}if(F=p,(P=0)===_){if(P+=y-O,O<N){for(N-=O;R[u++]=p[P++],--O;);P=u-Z,F=R}}else if(_<O){if(P+=y+_-O,(O-=_)<N){for(N-=O;R[u++]=p[P++],--O;);if(P=0,_<N){for(N-=O=_;R[u++]=p[P++],--O;);P=u-Z,F=R}}}else if(P+=_-O,O<N){for(N-=O;R[u++]=p[P++],--O;);P=u-Z,F=R}for(;2<N;)R[u++]=F[P++],R[u++]=F[P++],R[u++]=F[P++],N-=3;N&&(R[u++]=F[P++],1<N&&(R[u++]=F[P++]))}else{for(P=u-Z;R[u++]=R[P++],R[u++]=R[P++],R[u++]=R[P++],2<(N-=3););N&&(R[u++]=R[P++],1<N&&(R[u++]=R[P++]))}break}}break}}while(l<c&&u<f);l-=N=E>>3,x&=(1<<(E-=N<<3))-1,n.next_in=l,n.next_out=u,n.avail_in=l<c?c-l+5:5-(l-c),n.avail_out=u<f?f-u+257:257-(u-f),a.hold=x,a.bits=E}},{}],49:[function(t,i,s){var n=t("../utils/common"),r=t("./adler32"),a=t("./crc32"),l=t("./inffast"),c=t("./inftrees"),d=-2;function p(P){return(P>>>24&255)+(P>>>8&65280)+((65280&P)<<8)+((255&P)<<24)}function x(){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 E(P){var F;return P&&P.state?(P.total_in=P.total_out=(F=P.state).total=0,P.msg="",F.wrap&&(P.adler=1&F.wrap),F.mode=1,F.last=0,F.havedict=0,F.dmax=32768,F.head=null,F.hold=0,F.bits=0,F.lencode=F.lendyn=new n.Buf32(852),F.distcode=F.distdyn=new n.Buf32(592),F.sane=1,F.back=-1,0):d}function T(P){var F;return P&&P.state?((F=P.state).wsize=0,F.whave=0,F.wnext=0,E(P)):d}function A(P,F){var v,R;return P&&P.state?(R=P.state,F<0?(v=0,F=-F):(v=1+(F>>4),F<48&&(F&=15)),F&&(F<8||15<F)?d:(null!==R.window&&R.wbits!==F&&(R.window=null),R.wrap=v,R.wbits=F,T(P))):d}function M(P,F){var v,R;return P?(R=new x,(P.state=R).window=null,0!==(v=A(P,F))&&(P.state=null),v):d}var S,z,O=!0;function N(P){if(O){var F;for(S=new n.Buf32(512),z=new n.Buf32(32),F=0;F<144;)P.lens[F++]=8;for(;F<256;)P.lens[F++]=9;for(;F<280;)P.lens[F++]=7;for(;F<288;)P.lens[F++]=8;for(c(1,P.lens,0,288,S,0,P.work,{bits:9}),F=0;F<32;)P.lens[F++]=5;c(2,P.lens,0,32,z,0,P.work,{bits:5}),O=!1}P.lencode=S,P.lenbits=9,P.distcode=z,P.distbits=5}function Z(P,F,v,R){var Q,j=P.state;return null===j.window&&(j.wsize=1<<j.wbits,j.wnext=0,j.whave=0,j.window=new n.Buf8(j.wsize)),R>=j.wsize?(n.arraySet(j.window,F,v-j.wsize,j.wsize,0),j.wnext=0,j.whave=j.wsize):(R<(Q=j.wsize-j.wnext)&&(Q=R),n.arraySet(j.window,F,v-R,Q,j.wnext),(R-=Q)?(n.arraySet(j.window,F,v-R,R,0),j.wnext=R,j.whave=j.wsize):(j.wnext+=Q,j.wnext===j.wsize&&(j.wnext=0),j.whave<j.wsize&&(j.whave+=Q))),0}s.inflateReset=T,s.inflateReset2=A,s.inflateResetKeep=E,s.inflateInit=function(P){return M(P,15)},s.inflateInit2=M,s.inflate=function(P,F){var v,R,Q,j,rt,Y,ot,B,L,it,et,K,_t,Ot,ht,dt,Pt,bt,jt,Vt,C,W,$,k,I=0,D=new n.Buf8(4),q=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!P||!P.state||!P.output||!P.input&&0!==P.avail_in)return d;12===(v=P.state).mode&&(v.mode=13),rt=P.next_out,Q=P.output,j=P.next_in,R=P.input,B=v.hold,L=v.bits,it=Y=P.avail_in,et=ot=P.avail_out,W=0;t:for(;;)switch(v.mode){case 1:if(0===v.wrap){v.mode=13;break}for(;L<16;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(2&v.wrap&&35615===B){D[v.check=0]=255&B,D[1]=B>>>8&255,v.check=a(v.check,D,2,0),L=B=0,v.mode=2;break}if(v.flags=0,v.head&&(v.head.done=!1),!(1&v.wrap)||(((255&B)<<8)+(B>>8))%31){P.msg="incorrect header check",v.mode=30;break}if(8!=(15&B)){P.msg="unknown compression method",v.mode=30;break}if(L-=4,C=8+(15&(B>>>=4)),0===v.wbits)v.wbits=C;else if(C>v.wbits){P.msg="invalid window size",v.mode=30;break}v.dmax=1<<C,P.adler=v.check=1,v.mode=512&B?10:12,L=B=0;break;case 2:for(;L<16;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(v.flags=B,8!=(255&v.flags)){P.msg="unknown compression method",v.mode=30;break}if(57344&v.flags){P.msg="unknown header flags set",v.mode=30;break}v.head&&(v.head.text=B>>8&1),512&v.flags&&(D[0]=255&B,D[1]=B>>>8&255,v.check=a(v.check,D,2,0)),L=B=0,v.mode=3;case 3:for(;L<32;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}v.head&&(v.head.time=B),512&v.flags&&(D[0]=255&B,D[1]=B>>>8&255,D[2]=B>>>16&255,D[3]=B>>>24&255,v.check=a(v.check,D,4,0)),L=B=0,v.mode=4;case 4:for(;L<16;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}v.head&&(v.head.xflags=255&B,v.head.os=B>>8),512&v.flags&&(D[0]=255&B,D[1]=B>>>8&255,v.check=a(v.check,D,2,0)),L=B=0,v.mode=5;case 5:if(1024&v.flags){for(;L<16;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}v.length=B,v.head&&(v.head.extra_len=B),512&v.flags&&(D[0]=255&B,D[1]=B>>>8&255,v.check=a(v.check,D,2,0)),L=B=0}else v.head&&(v.head.extra=null);v.mode=6;case 6:if(1024&v.flags&&(Y<(K=v.length)&&(K=Y),K&&(v.head&&(C=v.head.extra_len-v.length,v.head.extra||(v.head.extra=new Array(v.head.extra_len)),n.arraySet(v.head.extra,R,j,K,C)),512&v.flags&&(v.check=a(v.check,R,K,j)),Y-=K,j+=K,v.length-=K),v.length))break t;v.length=0,v.mode=7;case 7:if(2048&v.flags){if(0===Y)break t;for(K=0;C=R[j+K++],v.head&&C&&v.length<65536&&(v.head.name+=String.fromCharCode(C)),C&&K<Y;);if(512&v.flags&&(v.check=a(v.check,R,K,j)),Y-=K,j+=K,C)break t}else v.head&&(v.head.name=null);v.length=0,v.mode=8;case 8:if(4096&v.flags){if(0===Y)break t;for(K=0;C=R[j+K++],v.head&&C&&v.length<65536&&(v.head.comment+=String.fromCharCode(C)),C&&K<Y;);if(512&v.flags&&(v.check=a(v.check,R,K,j)),Y-=K,j+=K,C)break t}else v.head&&(v.head.comment=null);v.mode=9;case 9:if(512&v.flags){for(;L<16;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(B!==(65535&v.check)){P.msg="header crc mismatch",v.mode=30;break}L=B=0}v.head&&(v.head.hcrc=v.flags>>9&1,v.head.done=!0),P.adler=v.check=0,v.mode=12;break;case 10:for(;L<32;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}P.adler=v.check=p(B),L=B=0,v.mode=11;case 11:if(0===v.havedict)return P.next_out=rt,P.avail_out=ot,P.next_in=j,P.avail_in=Y,v.hold=B,v.bits=L,2;P.adler=v.check=1,v.mode=12;case 12:if(5===F||6===F)break t;case 13:if(v.last){B>>>=7&L,L-=7&L,v.mode=27;break}for(;L<3;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}switch(v.last=1&B,L-=1,3&(B>>>=1)){case 0:v.mode=14;break;case 1:if(N(v),v.mode=20,6!==F)break;B>>>=2,L-=2;break t;case 2:v.mode=17;break;case 3:P.msg="invalid block type",v.mode=30}B>>>=2,L-=2;break;case 14:for(B>>>=7&L,L-=7&L;L<32;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if((65535&B)!=(B>>>16^65535)){P.msg="invalid stored block lengths",v.mode=30;break}if(v.length=65535&B,L=B=0,v.mode=15,6===F)break t;case 15:v.mode=16;case 16:if(K=v.length){if(Y<K&&(K=Y),ot<K&&(K=ot),0===K)break t;n.arraySet(Q,R,j,K,rt),Y-=K,j+=K,ot-=K,rt+=K,v.length-=K;break}v.mode=12;break;case 17:for(;L<14;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(v.nlen=257+(31&B),L-=5,v.ndist=1+(31&(B>>>=5)),L-=5,v.ncode=4+(15&(B>>>=5)),B>>>=4,L-=4,286<v.nlen||30<v.ndist){P.msg="too many length or distance symbols",v.mode=30;break}v.have=0,v.mode=18;case 18:for(;v.have<v.ncode;){for(;L<3;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}v.lens[q[v.have++]]=7&B,B>>>=3,L-=3}for(;v.have<19;)v.lens[q[v.have++]]=0;if(v.lencode=v.lendyn,v.lenbits=7,W=c(0,v.lens,0,19,v.lencode,0,v.work,$={bits:v.lenbits}),v.lenbits=$.bits,W){P.msg="invalid code lengths set",v.mode=30;break}v.have=0,v.mode=19;case 19:for(;v.have<v.nlen+v.ndist;){for(;dt=(I=v.lencode[B&(1<<v.lenbits)-1])>>>16&255,Pt=65535&I,!((ht=I>>>24)<=L);){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(Pt<16)B>>>=ht,L-=ht,v.lens[v.have++]=Pt;else{if(16===Pt){for(k=ht+2;L<k;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(B>>>=ht,L-=ht,0===v.have){P.msg="invalid bit length repeat",v.mode=30;break}C=v.lens[v.have-1],K=3+(3&B),B>>>=2,L-=2}else if(17===Pt){for(k=ht+3;L<k;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}L-=ht,C=0,K=3+(7&(B>>>=ht)),B>>>=3,L-=3}else{for(k=ht+7;L<k;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}L-=ht,C=0,K=11+(127&(B>>>=ht)),B>>>=7,L-=7}if(v.have+K>v.nlen+v.ndist){P.msg="invalid bit length repeat",v.mode=30;break}for(;K--;)v.lens[v.have++]=C}}if(30===v.mode)break;if(0===v.lens[256]){P.msg="invalid code -- missing end-of-block",v.mode=30;break}if(v.lenbits=9,W=c(1,v.lens,0,v.nlen,v.lencode,0,v.work,$={bits:v.lenbits}),v.lenbits=$.bits,W){P.msg="invalid literal/lengths set",v.mode=30;break}if(v.distbits=6,v.distcode=v.distdyn,W=c(2,v.lens,v.nlen,v.ndist,v.distcode,0,v.work,$={bits:v.distbits}),v.distbits=$.bits,W){P.msg="invalid distances set",v.mode=30;break}if(v.mode=20,6===F)break t;case 20:v.mode=21;case 21:if(6<=Y&&258<=ot){P.next_out=rt,P.avail_out=ot,P.next_in=j,P.avail_in=Y,v.hold=B,v.bits=L,l(P,et),rt=P.next_out,Q=P.output,ot=P.avail_out,j=P.next_in,R=P.input,Y=P.avail_in,B=v.hold,L=v.bits,12===v.mode&&(v.back=-1);break}for(v.back=0;dt=(I=v.lencode[B&(1<<v.lenbits)-1])>>>16&255,Pt=65535&I,!((ht=I>>>24)<=L);){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(dt&&!(240&dt)){for(bt=ht,jt=dt,Vt=Pt;dt=(I=v.lencode[Vt+((B&(1<<bt+jt)-1)>>bt)])>>>16&255,Pt=65535&I,!(bt+(ht=I>>>24)<=L);){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}B>>>=bt,L-=bt,v.back+=bt}if(B>>>=ht,L-=ht,v.back+=ht,v.length=Pt,0===dt){v.mode=26;break}if(32&dt){v.back=-1,v.mode=12;break}if(64&dt){P.msg="invalid literal/length code",v.mode=30;break}v.extra=15&dt,v.mode=22;case 22:if(v.extra){for(k=v.extra;L<k;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}v.length+=B&(1<<v.extra)-1,B>>>=v.extra,L-=v.extra,v.back+=v.extra}v.was=v.length,v.mode=23;case 23:for(;dt=(I=v.distcode[B&(1<<v.distbits)-1])>>>16&255,Pt=65535&I,!((ht=I>>>24)<=L);){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(!(240&dt)){for(bt=ht,jt=dt,Vt=Pt;dt=(I=v.distcode[Vt+((B&(1<<bt+jt)-1)>>bt)])>>>16&255,Pt=65535&I,!(bt+(ht=I>>>24)<=L);){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}B>>>=bt,L-=bt,v.back+=bt}if(B>>>=ht,L-=ht,v.back+=ht,64&dt){P.msg="invalid distance code",v.mode=30;break}v.offset=Pt,v.extra=15&dt,v.mode=24;case 24:if(v.extra){for(k=v.extra;L<k;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}v.offset+=B&(1<<v.extra)-1,B>>>=v.extra,L-=v.extra,v.back+=v.extra}if(v.offset>v.dmax){P.msg="invalid distance too far back",v.mode=30;break}v.mode=25;case 25:if(0===ot)break t;if(v.offset>(K=et-ot)){if((K=v.offset-K)>v.whave&&v.sane){P.msg="invalid distance too far back",v.mode=30;break}_t=K>v.wnext?v.wsize-(K-=v.wnext):v.wnext-K,K>v.length&&(K=v.length),Ot=v.window}else Ot=Q,_t=rt-v.offset,K=v.length;for(ot<K&&(K=ot),ot-=K,v.length-=K;Q[rt++]=Ot[_t++],--K;);0===v.length&&(v.mode=21);break;case 26:if(0===ot)break t;Q[rt++]=v.length,ot--,v.mode=21;break;case 27:if(v.wrap){for(;L<32;){if(0===Y)break t;Y--,B|=R[j++]<<L,L+=8}if(P.total_out+=et-=ot,v.total+=et,et&&(P.adler=v.check=v.flags?a(v.check,Q,et,rt-et):r(v.check,Q,et,rt-et)),et=ot,(v.flags?B:p(B))!==v.check){P.msg="incorrect data check",v.mode=30;break}L=B=0}v.mode=28;case 28:if(v.wrap&&v.flags){for(;L<32;){if(0===Y)break t;Y--,B+=R[j++]<<L,L+=8}if(B!==(4294967295&v.total)){P.msg="incorrect length check",v.mode=30;break}L=B=0}v.mode=29;case 29:W=1;break t;case 30:W=-3;break t;case 31:return-4;default:return d}return P.next_out=rt,P.avail_out=ot,P.next_in=j,P.avail_in=Y,v.hold=B,v.bits=L,(v.wsize||et!==P.avail_out&&v.mode<30&&(v.mode<27||4!==F))&&Z(P,P.output,P.next_out,et-P.avail_out)?(v.mode=31,-4):(et-=P.avail_out,P.total_in+=it-=P.avail_in,P.total_out+=et,v.total+=et,v.wrap&&et&&(P.adler=v.check=v.flags?a(v.check,Q,et,P.next_out-et):r(v.check,Q,et,P.next_out-et)),P.data_type=v.bits+(v.last?64:0)+(12===v.mode?128:0)+(20===v.mode||15===v.mode?256:0),(0==it&&0===et||4===F)&&0===W&&(W=-5),W)},s.inflateEnd=function(P){if(!P||!P.state)return d;var F=P.state;return F.window&&(F.window=null),P.state=null,0},s.inflateGetHeader=function(P,F){var v;return P&&P.state&&2&(v=P.state).wrap?((v.head=F).done=!1,0):d},s.inflateSetDictionary=function(P,F){var v,R=F.length;return P&&P.state?0!==(v=P.state).wrap&&11!==v.mode?d:11===v.mode&&r(1,F,R,0)!==v.check?-3:Z(P,F,R,R)?(v.mode=31,-4):(v.havedict=1,0):d},s.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(t,i,s){var n=t("../utils/common"),r=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],a=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],l=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],c=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];i.exports=function(u,h,f,d,y,g,_,p){var x,E,T,A,M,S,z,O,N,Z=p.bits,P=0,F=0,v=0,R=0,Q=0,j=0,rt=0,Y=0,ot=0,B=0,L=null,it=0,et=new n.Buf16(16),K=new n.Buf16(16),_t=null,Ot=0;for(P=0;P<=15;P++)et[P]=0;for(F=0;F<d;F++)et[h[f+F]]++;for(Q=Z,R=15;1<=R&&0===et[R];R--);if(R<Q&&(Q=R),0===R)return y[g++]=20971520,y[g++]=20971520,p.bits=1,0;for(v=1;v<R&&0===et[v];v++);for(Q<v&&(Q=v),P=Y=1;P<=15;P++)if(Y<<=1,(Y-=et[P])<0)return-1;if(0<Y&&(0===u||1!==R))return-1;for(K[1]=0,P=1;P<15;P++)K[P+1]=K[P]+et[P];for(F=0;F<d;F++)0!==h[f+F]&&(_[K[h[f+F]]++]=F);if(S=0===u?(L=_t=_,19):1===u?(L=r,it-=257,_t=a,Ot-=257,256):(L=l,_t=c,-1),P=v,M=g,rt=F=B=0,T=-1,A=(ot=1<<(j=Q))-1,1===u&&852<ot||2===u&&592<ot)return 1;for(;;){for(z=P-rt,N=_[F]<S?(O=0,_[F]):_[F]>S?(O=_t[Ot+_[F]],L[it+_[F]]):(O=96,0),x=1<<P-rt,v=E=1<<j;y[M+(B>>rt)+(E-=x)]=z<<24|O<<16|N,0!==E;);for(x=1<<P-1;B&x;)x>>=1;if(0!==x?(B&=x-1,B+=x):B=0,F++,0==--et[P]){if(P===R)break;P=h[f+_[F]]}if(Q<P&&(B&A)!==T){for(0===rt&&(rt=Q),M+=v,Y=1<<(j=P-rt);j+rt<R&&!((Y-=et[j+rt])<=0);)j++,Y<<=1;if(ot+=1<<j,1===u&&852<ot||2===u&&592<ot)return 1;y[T=B&A]=Q<<24|j<<16|M-g}}return 0!==B&&(y[M+B]=P-rt<<24|64<<16),p.bits=Q,0}},{"../utils/common":41}],51:[function(t,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(t,i,s){var n=t("../utils/common");function l(I){for(var D=I.length;0<=--D;)I[D]=0}var h=256,f=286,d=30,_=15,S=[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],z=[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],O=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],N=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],Z=new Array(576);l(Z);var P=new Array(60);l(P);var F=new Array(512);l(F);var v=new Array(256);l(v);var R=new Array(29);l(R);var Q,j,rt,Y=new Array(d);function ot(I,D,q,G,U){this.static_tree=I,this.extra_bits=D,this.extra_base=q,this.elems=G,this.max_length=U,this.has_stree=I&&I.length}function B(I,D){this.dyn_tree=I,this.max_code=0,this.stat_desc=D}function L(I){return I<256?F[I]:F[256+(I>>>7)]}function it(I,D){I.pending_buf[I.pending++]=255&D,I.pending_buf[I.pending++]=D>>>8&255}function et(I,D,q){I.bi_valid>16-q?(I.bi_buf|=D<<I.bi_valid&65535,it(I,I.bi_buf),I.bi_buf=D>>16-I.bi_valid,I.bi_valid+=q-16):(I.bi_buf|=D<<I.bi_valid&65535,I.bi_valid+=q)}function K(I,D,q){et(I,q[2*D],q[2*D+1])}function _t(I,D){for(var q=0;q|=1&I,I>>>=1,q<<=1,0<--D;);return q>>>1}function Ot(I,D,q){var G,U,J=new Array(16),nt=0;for(G=1;G<=_;G++)J[G]=nt=nt+q[G-1]<<1;for(U=0;U<=D;U++){var tt=I[2*U+1];0!==tt&&(I[2*U]=_t(J[tt]++,tt))}}function ht(I){var D;for(D=0;D<f;D++)I.dyn_ltree[2*D]=0;for(D=0;D<d;D++)I.dyn_dtree[2*D]=0;for(D=0;D<19;D++)I.bl_tree[2*D]=0;I.dyn_ltree[512]=1,I.opt_len=I.static_len=0,I.last_lit=I.matches=0}function dt(I){8<I.bi_valid?it(I,I.bi_buf):0<I.bi_valid&&(I.pending_buf[I.pending++]=I.bi_buf),I.bi_buf=0,I.bi_valid=0}function Pt(I,D,q,G){var U=2*D,J=2*q;return I[U]<I[J]||I[U]===I[J]&&G[D]<=G[q]}function bt(I,D,q){for(var G=I.heap[q],U=q<<1;U<=I.heap_len&&(U<I.heap_len&&Pt(D,I.heap[U+1],I.heap[U],I.depth)&&U++,!Pt(D,G,I.heap[U],I.depth));)I.heap[q]=I.heap[U],q=U,U<<=1;I.heap[q]=G}function jt(I,D,q){var G,U,J,nt,tt=0;if(0!==I.last_lit)for(;G=I.pending_buf[I.d_buf+2*tt]<<8|I.pending_buf[I.d_buf+2*tt+1],U=I.pending_buf[I.l_buf+tt],tt++,0===G?K(I,U,D):(K(I,(J=v[U])+h+1,D),0!==(nt=S[J])&&et(I,U-=R[J],nt),K(I,J=L(--G),q),0!==(nt=z[J])&&et(I,G-=Y[J],nt)),tt<I.last_lit;);K(I,256,D)}function Vt(I,D){var q,G,U,J=D.dyn_tree,nt=D.stat_desc.static_tree,tt=D.stat_desc.has_stree,at=D.stat_desc.elems,Ct=-1;for(I.heap_len=0,I.heap_max=573,q=0;q<at;q++)0!==J[2*q]?(I.heap[++I.heap_len]=Ct=q,I.depth[q]=0):J[2*q+1]=0;for(;I.heap_len<2;)J[2*(U=I.heap[++I.heap_len]=Ct<2?++Ct:0)]=1,I.depth[U]=0,I.opt_len--,tt&&(I.static_len-=nt[2*U+1]);for(D.max_code=Ct,q=I.heap_len>>1;1<=q;q--)bt(I,J,q);for(U=at;q=I.heap[1],I.heap[1]=I.heap[I.heap_len--],bt(I,J,1),G=I.heap[1],I.heap[--I.heap_max]=q,I.heap[--I.heap_max]=G,J[2*U]=J[2*q]+J[2*G],I.depth[U]=(I.depth[q]>=I.depth[G]?I.depth[q]:I.depth[G])+1,J[2*q+1]=J[2*G+1]=U,I.heap[1]=U++,bt(I,J,1),2<=I.heap_len;);I.heap[--I.heap_max]=I.heap[1],function(pt,ee){var gi,ce,_i,zt,is,pn,fe=ee.dyn_tree,lo=ee.max_code,gh=ee.stat_desc.static_tree,_h=ee.stat_desc.has_stree,yh=ee.stat_desc.extra_bits,co=ee.stat_desc.extra_base,yi=ee.stat_desc.max_length,ss=0;for(zt=0;zt<=_;zt++)pt.bl_count[zt]=0;for(fe[2*pt.heap[pt.heap_max]+1]=0,gi=pt.heap_max+1;gi<573;gi++)yi<(zt=fe[2*fe[2*(ce=pt.heap[gi])+1]+1]+1)&&(zt=yi,ss++),fe[2*ce+1]=zt,lo<ce||(pt.bl_count[zt]++,is=0,co<=ce&&(is=yh[ce-co]),pt.opt_len+=(pn=fe[2*ce])*(zt+is),_h&&(pt.static_len+=pn*(gh[2*ce+1]+is)));if(0!==ss){do{for(zt=yi-1;0===pt.bl_count[zt];)zt--;pt.bl_count[zt]--,pt.bl_count[zt+1]+=2,pt.bl_count[yi]--,ss-=2}while(0<ss);for(zt=yi;0!==zt;zt--)for(ce=pt.bl_count[zt];0!==ce;)lo<(_i=pt.heap[--gi])||(fe[2*_i+1]!==zt&&(pt.opt_len+=(zt-fe[2*_i+1])*fe[2*_i],fe[2*_i+1]=zt),ce--)}}(I,D),Ot(J,Ct,I.bl_count)}function C(I,D,q){var G,U,J=-1,nt=D[1],tt=0,at=7,Ct=4;for(0===nt&&(at=138,Ct=3),D[2*(q+1)+1]=65535,G=0;G<=q;G++)U=nt,nt=D[2*(G+1)+1],++tt<at&&U===nt||(tt<Ct?I.bl_tree[2*U]+=tt:0!==U?(U!==J&&I.bl_tree[2*U]++,I.bl_tree[32]++):tt<=10?I.bl_tree[34]++:I.bl_tree[36]++,J=U,Ct=(tt=0)===nt?(at=138,3):U===nt?(at=6,3):(at=7,4))}function W(I,D,q){var G,U,J=-1,nt=D[1],tt=0,at=7,Ct=4;for(0===nt&&(at=138,Ct=3),G=0;G<=q;G++)if(U=nt,nt=D[2*(G+1)+1],!(++tt<at&&U===nt)){if(tt<Ct)for(;K(I,U,I.bl_tree),0!=--tt;);else 0!==U?(U!==J&&(K(I,U,I.bl_tree),tt--),K(I,16,I.bl_tree),et(I,tt-3,2)):tt<=10?(K(I,17,I.bl_tree),et(I,tt-3,3)):(K(I,18,I.bl_tree),et(I,tt-11,7));J=U,Ct=(tt=0)===nt?(at=138,3):U===nt?(at=6,3):(at=7,4)}}l(Y);var $=!1;function k(I,D,q,G){var U,J,nt;et(I,0+(G?1:0),3),J=D,nt=q,dt(U=I),it(U,nt),it(U,~nt),n.arraySet(U.pending_buf,U.window,J,nt,U.pending),U.pending+=nt}s._tr_init=function(I){$||(function(){var D,q,G,U,J,nt=new Array(16);for(U=G=0;U<28;U++)for(R[U]=G,D=0;D<1<<S[U];D++)v[G++]=U;for(v[G-1]=U,U=J=0;U<16;U++)for(Y[U]=J,D=0;D<1<<z[U];D++)F[J++]=U;for(J>>=7;U<d;U++)for(Y[U]=J<<7,D=0;D<1<<z[U]-7;D++)F[256+J++]=U;for(q=0;q<=_;q++)nt[q]=0;for(D=0;D<=143;)Z[2*D+1]=8,D++,nt[8]++;for(;D<=255;)Z[2*D+1]=9,D++,nt[9]++;for(;D<=279;)Z[2*D+1]=7,D++,nt[7]++;for(;D<=287;)Z[2*D+1]=8,D++,nt[8]++;for(Ot(Z,287,nt),D=0;D<d;D++)P[2*D+1]=5,P[2*D]=_t(D,5);Q=new ot(Z,S,257,f,_),j=new ot(P,z,0,d,_),rt=new ot(new Array(0),O,0,19,7)}(),$=!0),I.l_desc=new B(I.dyn_ltree,Q),I.d_desc=new B(I.dyn_dtree,j),I.bl_desc=new B(I.bl_tree,rt),I.bi_buf=0,I.bi_valid=0,ht(I)},s._tr_stored_block=k,s._tr_flush_block=function(I,D,q,G){var U,J,nt=0;0<I.level?(2===I.strm.data_type&&(I.strm.data_type=function(tt){var at,Ct=4093624447;for(at=0;at<=31;at++,Ct>>>=1)if(1&Ct&&0!==tt.dyn_ltree[2*at])return 0;if(0!==tt.dyn_ltree[18]||0!==tt.dyn_ltree[20]||0!==tt.dyn_ltree[26])return 1;for(at=32;at<h;at++)if(0!==tt.dyn_ltree[2*at])return 1;return 0}(I)),Vt(I,I.l_desc),Vt(I,I.d_desc),nt=function(tt){var at;for(C(tt,tt.dyn_ltree,tt.l_desc.max_code),C(tt,tt.dyn_dtree,tt.d_desc.max_code),Vt(tt,tt.bl_desc),at=18;3<=at&&0===tt.bl_tree[2*N[at]+1];at--);return tt.opt_len+=3*(at+1)+5+5+4,at}(I),(J=I.static_len+3+7>>>3)<=(U=I.opt_len+3+7>>>3)&&(U=J)):U=J=q+5,q+4<=U&&-1!==D?k(I,D,q,G):4===I.strategy||J===U?(et(I,2+(G?1:0),3),jt(I,Z,P)):(et(I,4+(G?1:0),3),function(tt,at,Ct,pt){var ee;for(et(tt,at-257,5),et(tt,Ct-1,5),et(tt,pt-4,4),ee=0;ee<pt;ee++)et(tt,tt.bl_tree[2*N[ee]+1],3);W(tt,tt.dyn_ltree,at-1),W(tt,tt.dyn_dtree,Ct-1)}(I,I.l_desc.max_code+1,I.d_desc.max_code+1,nt+1),jt(I,I.dyn_ltree,I.dyn_dtree)),ht(I),G&&dt(I)},s._tr_tally=function(I,D,q){return I.pending_buf[I.d_buf+2*I.last_lit]=D>>>8&255,I.pending_buf[I.d_buf+2*I.last_lit+1]=255&D,I.pending_buf[I.l_buf+I.last_lit]=255&q,I.last_lit++,0===D?I.dyn_ltree[2*q]++:(I.matches++,D--,I.dyn_ltree[2*(v[q]+h+1)]++,I.dyn_dtree[2*L(D)]++),I.last_lit===I.lit_bufsize-1},s._tr_align=function(I){var D;et(I,2,3),K(I,256,Z),16===(D=I).bi_valid?(it(D,D.bi_buf),D.bi_buf=0,D.bi_valid=0):8<=D.bi_valid&&(D.pending_buf[D.pending++]=255&D.bi_buf,D.bi_buf>>=8,D.bi_valid-=8)}},{"../utils/common":41}],53:[function(t,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(t,i,s){(function(n){!function(r){if(!r.setImmediate){var l,c,u,h,f=1,d={},y=!1,g=r.document,_=Object.getPrototypeOf&&Object.getPrototypeOf(r);_=_&&_.setTimeout?_:r,l="[object process]"==={}.toString.call(r.process)?function(T){process.nextTick(function(){x(T)})}:function(){if(r.postMessage&&!r.importScripts){var T=!0,A=r.onmessage;return r.onmessage=function(){T=!1},r.postMessage("","*"),r.onmessage=A,T}}()?(h="setImmediate$"+Math.random()+"$",r.addEventListener?r.addEventListener("message",E,!1):r.attachEvent("onmessage",E),function(T){r.postMessage(h+T,"*")}):r.MessageChannel?((u=new MessageChannel).port1.onmessage=function(T){x(T.data)},function(T){u.port2.postMessage(T)}):g&&"onreadystatechange"in g.createElement("script")?(c=g.documentElement,function(T){var A=g.createElement("script");A.onreadystatechange=function(){x(T),A.onreadystatechange=null,c.removeChild(A),A=null},c.appendChild(A)}):function(T){setTimeout(x,0,T)},_.setImmediate=function(T){"function"!=typeof T&&(T=new Function(""+T));for(var A=new Array(arguments.length-1),M=0;M<A.length;M++)A[M]=arguments[M+1];return d[f]={callback:T,args:A},l(f),f++},_.clearImmediate=p}function p(T){delete d[T]}function x(T){if(y)setTimeout(x,0,T);else{var A=d[T];if(A){y=!0;try{!function(M){var S=M.callback,z=M.args;switch(z.length){case 0:S();break;case 1:S(z[0]);break;case 2:S(z[0],z[1]);break;case 3:S(z[0],z[1],z[2]);break;default:S.apply(void 0,z)}}(A)}finally{p(T),y=!1}}}}function E(T){T.source===r&&"string"==typeof T.data&&0===T.data.indexOf(h)&&x(+T.data.slice(h.length))}}(typeof self>"u"?void 0===n?this:n:self)}).call(this,typeof qi<"u"?qi:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10);const Er=Ql(Tr.exports);class Ys{constructor(e,t){w(this,"date",new Date),w(this,"author"),w(this,"guid",Yt.create()),w(this,"viewpoint"),w(this,"modifiedAuthor"),w(this,"modifiedDate"),w(this,"topic"),w(this,"_components"),w(this,"_comment",""),this._components=e,this._comment=t;const i=this._components.get(Dt);this.author=i.config.author}set comment(e){var t;const i=this._components.get(Dt);this._comment=e,this.modifiedDate=new Date,this.modifiedAuthor=i.config.author,null==(t=this.topic)||t.comments.set(this.guid,this)}get comment(){return this._comment}toJSON(){var e,t;const i={guid:this.guid,date:this.date.toISOString(),author:this.author,comment:this.comment,topic_guid:null==(e=this.topic)?void 0:e.guid,viewpoint_guid:this.viewpoint,modified_date:null==(t=this.modifiedDate)?void 0:t.toISOString(),modified_author:this.modifiedAuthor};for(const[s,n]of Object.entries(i))void 0===n&&delete i[s];return i}}const Ar=class xe{constructor(e){w(this,"guid",Yt.create()),w(this,"title",xe.default.title),w(this,"creationDate",new Date),w(this,"creationAuthor",""),w(this,"viewpoints",new ft.PG),w(this,"relatedTopics",new ft.PG),w(this,"comments",new ft.jp),w(this,"documentReferences",new ft.PG),w(this,"customData",{}),w(this,"description"),w(this,"serverAssignedId"),w(this,"dueDate"),w(this,"modifiedAuthor"),w(this,"modifiedDate"),w(this,"index"),w(this,"_type",xe.default.type),w(this,"_status",xe.default.status),w(this,"_priority",xe.default.priority),w(this,"_stage",xe.default.stage),w(this,"_assignedTo",xe.default.assignedTo),w(this,"_labels",xe.default.labels??new Set),w(this,"_components"),this._components=e;const t=e.get(Dt);this.creationAuthor=t.config.author,this.relatedTopics.guard=i=>i!==this.guid}set type(e){const t=this._components.get(Dt),{strict:i,types:s}=t.config;(!i||s.has(e))&&(this._type=e)}get type(){return this._type}set status(e){const t=this._components.get(Dt),{strict:i,statuses:s}=t.config;(!i||s.has(e))&&(this._status=e)}get status(){return this._status}set priority(e){const t=this._components.get(Dt);if(e){const{strict:i,priorities:s}=t.config;if(i&&!s.has(e))return;this._priority=e}else this._priority=e}get priority(){return this._priority}set stage(e){const t=this._components.get(Dt);if(e){const{strict:i,stages:s}=t.config;if(i&&!s.has(e))return;this._stage=e}else this._stage=e}get stage(){return this._stage}set assignedTo(e){const t=this._components.get(Dt);if(e){const{strict:i,users:s}=t.config;if(i&&!s.has(e))return;this._assignedTo=e}else this._assignedTo=e}get assignedTo(){return this._assignedTo}set labels(e){const t=this._components.get(Dt),{strict:i,labels:s}=t.config;if(i){const n=new Set;for(const r of e)(!i||s.has(r))&&n.add(r);this._labels=n}else this._labels=e}get labels(){return this._labels}get _managerVersion(){return this._components.get(Dt).config.version}set(e){const t=e,i=this;for(const n in e)"guid"!==n&&n in this&&(i[n]=t[n]);return this._components.get(Dt).list.set(this.guid,this),this}createComment(e,t){const i=new Ys(this._components,e);return i.viewpoint=t,i.topic=this,this.comments.set(i.guid,i),i}createLabelTags(){const e=[...this.labels];if(this._components.get(Dt).config.exportCustomDataAsLabels)for(const i in this.customData){const s=this.customData[i];"string"==typeof s&&e.push(s)}return e}createCommentTags(){return[...this.comments.values()].map(e=>{var t;return{$Guid:e.guid,Date:e.date.toISOString(),Author:e.author,Comment:e.comment,ModifiedAuthor:e.modifiedAuthor,ModifiedDate:null==(t=e.modifiedDate)?void 0:t.toISOString(),Viewpoint:e.viewpoint?{$Guid:e.viewpoint}:void 0}})}createViewpointTags(){const e=this._components.get(de);return[...this.viewpoints].map(i=>e.list.get(i)).filter(i=>i).map(i=>{const s={$Guid:i.guid,Viewpoint:`${i.title??i.guid}.bcfv`};if(e.snapshots.get(i.snapshot)){const r=e.getSnapshotExtension(i.snapshot);s.Snapshot=`${i.snapshot}.${r}`}return s})}createRelatedTopicTags(){return[...this.relatedTopics].map(e=>({$Guid:e}))}createDocumentReferencesTag(e=this._managerVersion){const t=[];if("3"!==e&&"2.1"!==e)return t;const i=this._components.get(Dt);for(const s of this.documentReferences){const n=i.documents.get(s);if(!n)continue;let r={$Guid:Yt.create(),Description:n.description};"2.1"===e&&(r={...r,$isExternal:"external"===n.type||void 0,ReferencedDocument:"external"===n.type?n.url:`../${n.fileName}`}),"3"===e&&(r={...r,DocumentGuid:"internal"===n.type?s:void 0,Url:"external"===n.type?n.url:void 0}),Object.keys(r).length>0&&t.push(r)}return t}toJSON(){var e,t;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==(e=this.modifiedDate)?void 0:e.toISOString(),modified_author:this.modifiedAuthor,assigned_to:this.assignedTo,stage:this.stage,description:this.description,due_date:null==(t=this.dueDate)?void 0:t.toISOString(),comments:[...this.comments].map(([r,a])=>a.toJSON()),relatedTopics:[...this.relatedTopics].map(r=>({related_topic_guid:r}))},s=this._components.get(de);for(const r of this.viewpoints){const a=s.list.get(r);a&&(i.viewpoints||(i.viewpoints=[]),i.viewpoints.push(a.toJSON()))}const n=this._components.get(Dt);for(const r of this.documentReferences){const a=n.documents.get(r);a&&(i.document_references||(i.document_references=[]),i.document_references.push("external"===a.type?{guid:Yt.create(),description:a.description,url:a.url}:{guid:Yt.create(),description:a.description,document_guid:r}))}for(const[r,a]of Object.entries(i))(void 0===a||Array.isArray(a)&&0===a.length)&&delete i[r];return i}serialize(){var e,t;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==(e=this.modifiedDate)?void 0:e.toISOString(),ModifiedAuthor:this.modifiedAuthor,DueDate:null==(t=this.dueDate)?void 0:t.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 ${Ai.builder.build(n)}`}};w(Ar,"default",{title:"BCF Topic",type:"Issue",status:"Active"});let Pr=Ar;class tc extends ii{constructor(){super(...arguments),w(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(e){this._config.version.value=e}get author(){return this._config.author.value}set author(e){this._config.author.value=e}get types(){return this._config.types.value}set types(e){this._config.types.value=e}get statuses(){return this._config.statuses.value}set statuses(e){this._config.statuses.value=e}get priorities(){return this._config.priorities.value}set priorities(e){this._config.priorities.value=e}get labels(){return this._config.labels.value}set labels(e){this._config.labels.value=e}get stages(){return this._config.stages.value}set stages(e){this._config.stages.value=e}get users(){return this._config.users.value}set users(e){this._config.users.value=e}get includeSelectionTag(){return this._config.includeSelectionTag.value}set includeSelectionTag(e){this._config.includeSelectionTag.value=e}get updateExtensionsOnImport(){return this._config.updateExtensionsOnImport.value}set updateExtensionsOnImport(e){this._config.updateExtensionsOnImport.value=e}get strict(){return this._config.strict.value}set strict(e){this._config.strict.value=e}get includeAllExtensionsOnExport(){return this._config.includeAllExtensionsOnExport.value}set includeAllExtensionsOnExport(e){this._config.includeAllExtensionsOnExport.value=e}get fallbackVersionOnImport(){return this._config.fallbackVersionOnImport.value}set fallbackVersionOnImport(e){this._config.fallbackVersionOnImport.value=e}get ignoreIncompleteTopicsOnImport(){return this._config.ignoreIncompleteTopicsOnImport.value}set ignoreIncompleteTopicsOnImport(e){this._config.ignoreIncompleteTopicsOnImport.value=e}get exportCustomDataAsLabels(){return this._config.exportCustomDataAsLabels.value}set exportCustomDataAsLabels(e){this._config.exportCustomDataAsLabels.value=e}}const Zs=class vi extends Tt{constructor(){super(...arguments),w(this,"enabled",!1),w(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}),w(this,"config",new tc(this,this.components,"BCF Topics",vi.uuid)),w(this,"list",new ft.jp),w(this,"documents",new ft.jp),w(this,"onSetup",new X),w(this,"isSetup",!1),w(this,"onBCFImported",new X),w(this,"onDisposed",new X)}setup(e){if(this.isSetup)return;const t={...this._defaultConfig,...e};this.config.version=t.version,this.config.author=t.author,this.config.types=t.types,this.config.statuses=t.statuses,this.config.priorities=t.priorities,this.config.labels=t.labels,this.config.stages=t.stages,this.config.users=t.users,this.config.includeSelectionTag=t.includeSelectionTag,this.config.updateExtensionsOnImport=t.updateExtensionsOnImport,this.config.strict=t.strict,this.config.includeAllExtensionsOnExport=t.includeAllExtensionsOnExport,this.config.fallbackVersionOnImport=t.fallbackVersionOnImport||"",this.config.ignoreIncompleteTopicsOnImport=t.ignoreIncompleteTopicsOnImport,this.isSetup=!0,this.enabled=!0,this.onSetup.trigger()}create(e){const t=new Pr(this.components);return e?(t.guid=e.guid??t.guid,t.set(e)):this.list.set(t.guid,t),t}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}get usedTypes(){const e=[...this.list].map(([t,i])=>i.type);return new Set(e)}get usedStatuses(){const e=[...this.list].map(([t,i])=>i.status);return new Set(e)}get usedPriorities(){const e=[...this.list].map(([t,i])=>i.priority).filter(t=>t);return new Set(e)}get usedStages(){const e=[...this.list].map(([t,i])=>i.stage).filter(t=>t);return new Set(e)}get usedUsers(){const e=[];for(const[t,i]of this.list){e.push(i.creationAuthor),i.assignedTo&&e.push(i.assignedTo),i.modifiedAuthor&&e.push(i.modifiedAuthor);for(const[s,n]of i.comments)e.push(n.author),n.modifiedAuthor&&e.push(n.modifiedAuthor)}return new Set(e)}get usedLabels(){const e=[];for(const[t,i]of this.list)e.push(...i.labels);return new Set(e)}updateExtensions(){for(const[e,t]of this.list){for(const i of t.labels)this.config.labels.add(i);this.config.types.add(t.type),t.priority&&this.config.priorities.add(t.priority),t.stage&&this.config.stages.add(t.stage),this.config.statuses.add(t.status),this.config.users.add(t.creationAuthor),t.assignedTo&&this.config.users.add(t.assignedTo),t.modifiedAuthor&&this.config.users.add(t.modifiedAuthor);for(const[i,s]of t.comments)this.config.users.add(s.author),s.modifiedAuthor&&this.config.users.add(s.modifiedAuthor)}}updateViewpointReferences(){const e=this.components.get(de);for(const[t,i]of this.list)for(const s of i.viewpoints)e.list.has(s)||i.viewpoints.delete(s)}export(){var e=this;return(0,H.A)(function*(t=e.list.values()){const i=new Er;i.file("bcf.version",`<?xml version="1.0" encoding="UTF-8"?>\n <Version VersionId="${e.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[r,a]of e.documents.entries())"external"!==a.type&&i.file("2.1"===e.config.version?a.fileName:`documents/${r}`,a.data);if("3"===e.config.version){const r=[];for(const[a,l]of e.documents.entries()){const{type:c,description:u}=l;"external"!==c&&r.push(`<Document Guid="${a}">\n <Filename>${l.fileName}</Filename>\n ${u?`<Description>${u}</Description>`:""}\n </Document>`)}r.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 ${r.join("\n")}\n </Documents>\n </DocumentInfo>`)}i.file("bcf.extensions",e.serializeExtensions());const s=e.components.get(de);for(const r of t){const a=i.folder(r.guid);a.file("markup.bcf",r.serialize());for(const l of r.viewpoints){const c=s.list.get(l);if(!c)continue;a.file(`${c.title??c.guid}.bcfv`,yield c.serialize());const h=s.snapshots.get(c.snapshot);if(!h)continue;const f=h?c.snapshot:c.guid,d=s.getSnapshotExtension(c.snapshot);a.file(`${f}.${d}`,h,{binary:!0})}}return yield i.generateAsync({type:"blob"})}).apply(this,arguments)}serializeExtensions(){const e=[...this.config.types].map(a=>`<TopicType>${a}</TopicType>`).join("\n"),t=[...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"),r=[...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!==e.length?`<TopicTypes>\n${e}\n</TopicTypes>`:""}\n ${0!==t.length?`<TopicStatuses>\n${t}\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!==r.length?`<Users>\n${r}\n</Users>`:""}\n </Extensions>\n `}processMarkupComment(e){const{Guid:t,Date:i,Author:s,Comment:n,Viewpoint:r}=e;if(!(t&&i&&s&&(Ys||r)))return null;const a=new Ys(this.components,n??"");return a.guid=t,a.date=new Date(i),a.author=s,a.viewpoint=r?.Guid,a.modifiedAuthor=e.ModifiedAuthor,a.modifiedDate=e.ModifiedDate?new Date(e.ModifiedDate):void 0,a}getMarkupComments(e,t){var i;let s;if("2.1"===t&&(s=e.Comment),"3"===t&&(s=null==(i=e.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(e,t){var i;let s;return"2.1"===t&&(s=e.Topic.Labels),"3"===t&&(s=null==(i=e.Topic.Labels)?void 0:i.Label),s?Array.isArray(s)?s:[s]:[]}getMarkupViewpoints(e,t){var i;let s;return"2.1"===t&&(s=e.Viewpoints),"3"===t&&(s=null==(i=e.Topic.Viewpoints)?void 0:i.ViewPoint),s?(s=Array.isArray(s)?s:[s],s):[]}getMarkupRelatedTopics(e,t){var i;let s;return"2.1"===t&&(s=e.Topic.RelatedTopic),"3"===t&&(s=null==(i=e.Topic.RelatedTopics)?void 0:i.RelatedTopic),s?(Array.isArray(s)?s:[s]).map(r=>r.Guid):[]}getMarkupDocumentReferences(e,t){var i;let s;return"2.1"===t&&(s=e.Topic.DocumentReference),"3"===t&&(s=null==(i=e.Topic.DocumentReferences)?void 0:i.DocumentReference),s?Array.isArray(s)?s:[s]:[]}load(e){var t=this;return(0,H.A)(function*(){var i,s,n;const{fallbackVersionOnImport:r,ignoreIncompleteTopicsOnImport:a,updateExtensionsOnImport:l}=t.config,c=new Er;yield c.loadAsync(e);const u=Object.values(c.files);let h=r;const f=u.find(T=>T.name.endsWith(".version"));if(f){const T=yield f.async("string"),A=vi.xmlParser.parse(T).Version.VersionId;h=String(A)}if(!h||"2.1"!==h&&"3"!==h)throw new Error(`BCFTopics: ${h} is not supported.`);const d=u.find(T=>T.name.endsWith(".extensions"));if(l&&d){const T=yield d.async("string");((o,e)=>{if(""===e.trim())return;const t=Dt.xmlParser.parse(e).Extensions;if(!t)return;const{Priorities:i,TopicStatuses:s,TopicTypes:n,Users:r}=t;if(i&&i.Priority){const a=Array.isArray(i.Priority)?i.Priority:[i.Priority];for(const l of a)o.config.priorities.add(l)}if(s&&s.TopicStatus){const a=Array.isArray(s.TopicStatus)?s.TopicStatus:[s.TopicStatus];for(const l of a)o.config.statuses.add(l)}if(n&&n.TopicType){const a=Array.isArray(n.TopicType)?n.TopicType:[n.TopicType];for(const l of a)o.config.types.add(l)}if(r&&r.User){const a=Array.isArray(r.User)?r.User:[r.User];for(const l of a)o.config.users.add(l)}})(t,T)}const y=[],g=t.components.get(de),_=u.filter(T=>T.name.endsWith(".bcfv"));for(const T of _){const A=yield T.async("string"),M=vi.xmlParser.parse(A).VisualizationInfo;if(!M){console.warn("Missing VisualizationInfo in Viewpoint");continue}const S={},{Guid:z,ClippingPlanes:O,Components:N,OrthogonalCamera:Z,PerspectiveCamera:P}=M;if(z&&(S.guid=z),N){const v={selection:[],coloring:[],visibility:{default_visibility:!1,exceptions:[],view_setup_hints:{spaces_visible:!1,space_boundaries_visible:!1,openings_visible:!1}}};S.components=v;const{Selection:R,Visibility:Q}=N;if(R&&R.Component){const Y=Array.isArray(R.Component)?R.Component:[R.Component];v.selection=Y.map(ot=>ot.IfcGuid?{ifc_guid:ot.IfcGuid}:null).filter(ot=>null!==ot)}if(Q&&"DefaultVisibility"in Q&&(v.visibility.default_visibility=Q.DefaultVisibility),Q&&Q.Exceptions&&"Component"in Q.Exceptions){const{Component:Y}=Q.Exceptions,ot=Array.isArray(Y)?Y:[Y];v.visibility.exceptions=ot.map(B=>B.IfcGuid?{ifc_guid:B.IfcGuid}:null).filter(B=>null!==B)}let j;"2.1"===h&&(j=N.ViewSetupHints),"3"===h&&(j=null==(i=N.Visibility)?void 0:i.ViewSetupHints),j&&("OpeningsVisible"in j&&(v.visibility.view_setup_hints.openings_visible=j.OpeningsVisible),"SpacesVisible"in j&&(v.visibility.view_setup_hints.spaces_visible=j.SpacesVisible),"SpaceBoundariesVisible"in j&&(v.visibility.view_setup_hints.space_boundaries_visible=j.SpaceBoundariesVisible));const{Coloring:rt}=N;if(rt&&rt.Color){const Y=Array.isArray(rt.Color)?rt.Color:[rt.Color];for(const ot of Y){const{Color:B,Component:L}=ot;if(6!==B.length&&8!==B.length)continue;const it=6===B.length?B:B.slice(2),K=(Array.isArray(L)?L:[L]).map(_t=>_t.IfcGuid?{ifc_guid:_t.IfcGuid}:null).filter(_t=>null!==_t);v.coloring.push({color:it,components:K})}}}if(Z||P){const v=M.PerspectiveCamera??M.OrthogonalCamera,{CameraViewPoint:R,CameraDirection:Q}=v,j=new b.Pq0(Number(R.X),Number(R.Z),Number(-R.Y)),rt=new b.Pq0(Number(Q.X),Number(Q.Z),Number(-Q.Y)),Y={camera_view_point:{x:j.x,y:j.y,z:j.z},camera_direction:{x:rt.x,y:rt.y,z:rt.z},aspect_ratio:"AspectRatio"in v?v.AspectRatio:1,camera_up_vector:{x:0,y:0,z:0}};"ViewToWorldScale"in v&&(S.orthogonal_camera={...Y,view_to_world_scale:v.ViewToWorldScale}),"FieldOfView"in v&&(S.perspective_camera={...Y,field_of_view:v.FieldOfView})}if(O){const R=(Array.isArray(O.ClippingPlane)?O.ClippingPlane:[O.ClippingPlane]).map(({Location:Q,Direction:j})=>({location:{x:Q.x,y:Q.y,z:Q.z},direction:{x:j.x,y:j.y,z:j.z}}));S.clipping_planes=R}const F=new Dr(t.components,S);y.push(F)}const p={},x=[],E=u.filter(T=>T.name.endsWith(".bcf"));for(const T of E){const A=yield T.async("string"),M=vi.xmlParser.parse(A).Markup,S=M.Topic,{Guid:z,TopicType:O,TopicStatus:N,Title:Z,CreationDate:P,CreationAuthor:F}=S;if(a&&!(z&&O&&N&&Z&&P&&F))continue;const v=new Pr(t.components);v.guid=z??v.guid;const R=t.getMarkupRelatedTopics(M,h);p[v.guid]=new Set(R),v.type=O??v.type,v.status=N??v.status,v.title=Z??v.title,v.creationDate=P?new Date(P):v.creationDate,v.creationAuthor=F??v.creationAuthor,v.serverAssignedId=S.ServerAssignedId,v.priority=S.Priority,v.index=S.Index,v.modifiedDate=S.ModifiedDate?new Date(S.ModifiedDate):void 0,v.modifiedAuthor=S.ModifiedAuthor,v.dueDate=S.DueDate?new Date(S.DueDate):void 0,v.assignedTo=S.AssignedTo,v.description=S.Description,v.stage=S.Stage;const Q=t.getMarkupLabels(M,h);for(const it of Q)v.labels.add(it);const j=t.getMarkupComments(M,h);for(const it of j)v.comments.set(it.guid,it);const rt=t.getMarkupViewpoints(M,h);for(const it of rt){if(!it||!it.Guid)continue;const et=g.list.get(it.Guid);if(!et)continue;v.viewpoints.add(et.guid);const K=`${v.guid}/${it.Snapshot}`,_t=u.find(({name:Ot})=>Ot===K);if(_t){const Ot=yield _t.async("arraybuffer"),ht=new Uint8Array(Ot);g.snapshots.set(et.guid,ht),et.snapshot=et.guid??null}}const Y=t.getMarkupDocumentReferences(M,h),ot=u.find(it=>"documents.xml"===it.name);let B=[];const L=yield ot?.async("string");if(L){const it=null==(n=null==(s=Ai.parser.parse(L).DocumentInfo)?void 0:s.Documents)?void 0:n.Document;B=Array.isArray(it)?it:[it]}for(const it of Y){const{Description:et,DocumentGuid:K,Url:_t,isExternal:Ot,ReferencedDocument:ht}=it;if(K&&B.length>0){const dt=B.find(({Guid:C})=>C===K),Pt=u.find(C=>C.name.endsWith(K)),bt=yield Pt?.async("uint8array");if(!dt||!bt)continue;const{Description:jt,Filename:Vt}=dt;t.documents.set(K,{type:"internal",fileName:Vt,description:jt,data:bt}),v.documentReferences.add(K)}if(_t){const dt=t.documents.add({type:"external",url:_t,description:et});v.documentReferences.add(dt)}if(ht){let dt=null;if(Ot)dt=t.documents.add({type:"external",url:ht,description:et});else{const Pt=ht.split("/"),bt=Pt[Pt.length-1],jt=u.find(C=>C.name.endsWith(bt)),Vt=yield jt?.async("uint8array");if(!Vt)continue;dt=t.documents.add({type:"internal",fileName:bt,data:Vt,description:et})}v.documentReferences.add(dt)}}t.list.set(v.guid,v),x.push(v)}for(const T in p){const A=t.list.get(T);if(!A)continue;const M=p[T];for(const S of M)A.relatedTopics.add(S)}return t.onBCFImported.trigger(x),{viewpoints:y,topics:x}})()}};w(Zs,"uuid","de977976-e4f6-4e4f-a01a-204727839802"),w(Zs,"xmlParser",new vs({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 Dt=Zs;const Se=new b.tBo,Lt=new b.Pq0,be=new b.Pq0,At=new b.PTz,Sr={X:new b.Pq0(1,0,0),Y:new b.Pq0(0,1,0),Z:new b.Pq0(0,0,1)},Ws={type:"change"},Ir={type:"mouseDown",mode:null},Mr={type:"mouseUp",mode:null},Or={type:"objectChange"};class ec extends b.H2z{constructor(e,t=null){super(void 0,t);const i=new ac(this);this._root=i;const s=new lc;this._gizmo=s,i.add(s);const n=new cc;this._plane=n,i.add(n);const r=this;function a(E,T){let A=T;Object.defineProperty(r,E,{get:function(){return void 0!==A?A:T},set:function(M){A!==M&&(A=M,n[E]=M,s[E]=M,r.dispatchEvent({type:E+"-changed",value:M}),r.dispatchEvent(Ws))}}),r[E]=T,n[E]=T,s[E]=T}a("camera",e),a("object",void 0),a("enabled",!0),a("axis",null),a("mode","translate"),a("translationSnap",null),a("rotationSnap",null),a("scaleSnap",null),a("space","world"),a("size",1),a("dragging",!1),a("showX",!0),a("showY",!0),a("showZ",!0),a("minX",-1/0),a("maxX",1/0),a("minY",-1/0),a("maxY",1/0),a("minZ",-1/0),a("maxZ",1/0);const l=new b.Pq0,c=new b.Pq0,u=new b.PTz,h=new b.PTz,f=new b.Pq0,d=new b.PTz,y=new b.Pq0,g=new b.Pq0,_=new b.Pq0,x=new b.Pq0;a("worldPosition",l),a("worldPositionStart",c),a("worldQuaternion",u),a("worldQuaternionStart",h),a("cameraPosition",f),a("cameraQuaternion",d),a("pointStart",y),a("pointEnd",g),a("rotationAxis",_),a("rotationAngle",0),a("eye",x),this._offset=new b.Pq0,this._startNorm=new b.Pq0,this._endNorm=new b.Pq0,this._cameraScale=new b.Pq0,this._parentPosition=new b.Pq0,this._parentQuaternion=new b.PTz,this._parentQuaternionInv=new b.PTz,this._parentScale=new b.Pq0,this._worldScaleStart=new b.Pq0,this._worldQuaternionInv=new b.PTz,this._worldScale=new b.Pq0,this._positionStart=new b.Pq0,this._quaternionStart=new b.PTz,this._scaleStart=new b.Pq0,this._getPointer=ic.bind(this),this._onPointerDown=nc.bind(this),this._onPointerHover=sc.bind(this),this._onPointerMove=rc.bind(this),this._onPointerUp=oc.bind(this),null!==t&&this.connect(t)}connect(e){super.connect(e),this.domElement.addEventListener("pointerdown",this._onPointerDown),this.domElement.addEventListener("pointermove",this._onPointerHover),this.domElement.addEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="none"}disconnect(){this.domElement.removeEventListener("pointerdown",this._onPointerDown),this.domElement.removeEventListener("pointermove",this._onPointerHover),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.domElement.removeEventListener("pointerup",this._onPointerUp),this.domElement.style.touchAction="auto"}getHelper(){return this._root}pointerHover(e){if(void 0===this.object||!0===this.dragging)return;null!==e&&Se.setFromCamera(e,this.camera);const t=qs(this._gizmo.picker[this.mode],Se);this.axis=t?t.object.name:null}pointerDown(e){if(void 0!==this.object&&!0!==this.dragging&&(null==e||0===e.button)&&null!==this.axis){null!==e&&Se.setFromCamera(e,this.camera);const t=qs(this._plane,Se,!0);t&&(this.object.updateMatrixWorld(),this.object.parent.updateMatrixWorld(),this._positionStart.copy(this.object.position),this._quaternionStart.copy(this.object.quaternion),this._scaleStart.copy(this.object.scale),this.object.matrixWorld.decompose(this.worldPositionStart,this.worldQuaternionStart,this._worldScaleStart),this.pointStart.copy(t.point).sub(this.worldPositionStart)),this.dragging=!0,Ir.mode=this.mode,this.dispatchEvent(Ir)}}pointerMove(e){const t=this.axis,i=this.mode,s=this.object;let n=this.space;if("scale"===i?n="local":("E"===t||"XYZE"===t||"XYZ"===t)&&(n="world"),void 0===s||null===t||!1===this.dragging||null!==e&&-1!==e.button)return;null!==e&&Se.setFromCamera(e,this.camera);const r=qs(this._plane,Se,!0);if(r){if(this.pointEnd.copy(r.point).sub(this.worldPositionStart),"translate"===i)this._offset.copy(this.pointEnd).sub(this.pointStart),"local"===n&&"XYZ"!==t&&this._offset.applyQuaternion(this._worldQuaternionInv),-1===t.indexOf("X")&&(this._offset.x=0),-1===t.indexOf("Y")&&(this._offset.y=0),-1===t.indexOf("Z")&&(this._offset.z=0),"local"===n&&"XYZ"!==t?this._offset.applyQuaternion(this._quaternionStart).divide(this._parentScale):this._offset.applyQuaternion(this._parentQuaternionInv).divide(this._parentScale),s.position.copy(this._offset).add(this._positionStart),this.translationSnap&&("local"===n&&(s.position.applyQuaternion(At.copy(this._quaternionStart).invert()),-1!==t.search("X")&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.position.applyQuaternion(this._quaternionStart)),"world"===n&&(s.parent&&s.position.add(Lt.setFromMatrixPosition(s.parent.matrixWorld)),-1!==t.search("X")&&(s.position.x=Math.round(s.position.x/this.translationSnap)*this.translationSnap),-1!==t.search("Y")&&(s.position.y=Math.round(s.position.y/this.translationSnap)*this.translationSnap),-1!==t.search("Z")&&(s.position.z=Math.round(s.position.z/this.translationSnap)*this.translationSnap),s.parent&&s.position.sub(Lt.setFromMatrixPosition(s.parent.matrixWorld)))),s.position.x=Math.max(this.minX,Math.min(this.maxX,s.position.x)),s.position.y=Math.max(this.minY,Math.min(this.maxY,s.position.y)),s.position.z=Math.max(this.minZ,Math.min(this.maxZ,s.position.z));else if("scale"===i){if(-1!==t.search("XYZ")){let a=this.pointEnd.length()/this.pointStart.length();this.pointEnd.dot(this.pointStart)<0&&(a*=-1),be.set(a,a,a)}else Lt.copy(this.pointStart),be.copy(this.pointEnd),Lt.applyQuaternion(this._worldQuaternionInv),be.applyQuaternion(this._worldQuaternionInv),be.divide(Lt),-1===t.search("X")&&(be.x=1),-1===t.search("Y")&&(be.y=1),-1===t.search("Z")&&(be.z=1);s.scale.copy(this._scaleStart).multiply(be),this.scaleSnap&&(-1!==t.search("X")&&(s.scale.x=Math.round(s.scale.x/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Y")&&(s.scale.y=Math.round(s.scale.y/this.scaleSnap)*this.scaleSnap||this.scaleSnap),-1!==t.search("Z")&&(s.scale.z=Math.round(s.scale.z/this.scaleSnap)*this.scaleSnap||this.scaleSnap))}else if("rotate"===i){this._offset.copy(this.pointEnd).sub(this.pointStart);const a=20/this.worldPosition.distanceTo(Lt.setFromMatrixPosition(this.camera.matrixWorld));let l=!1;"XYZE"===t?(this.rotationAxis.copy(this._offset).cross(this.eye).normalize(),this.rotationAngle=this._offset.dot(Lt.copy(this.rotationAxis).cross(this.eye))*a):("X"===t||"Y"===t||"Z"===t)&&(this.rotationAxis.copy(Sr[t]),Lt.copy(Sr[t]),"local"===n&&Lt.applyQuaternion(this.worldQuaternion),Lt.cross(this.eye),0===Lt.length()?l=!0:this.rotationAngle=this._offset.dot(Lt.normalize())*a),("E"===t||l)&&(this.rotationAxis.copy(this.eye),this.rotationAngle=this.pointEnd.angleTo(this.pointStart),this._startNorm.copy(this.pointStart).normalize(),this._endNorm.copy(this.pointEnd).normalize(),this.rotationAngle*=this._endNorm.cross(this._startNorm).dot(this.eye)<0?1:-1),this.rotationSnap&&(this.rotationAngle=Math.round(this.rotationAngle/this.rotationSnap)*this.rotationSnap),"local"===n&&"E"!==t&&"XYZE"!==t?(s.quaternion.copy(this._quaternionStart),s.quaternion.multiply(At.setFromAxisAngle(this.rotationAxis,this.rotationAngle)).normalize()):(this.rotationAxis.applyQuaternion(this._parentQuaternionInv),s.quaternion.copy(At.setFromAxisAngle(this.rotationAxis,this.rotationAngle)),s.quaternion.multiply(this._quaternionStart).normalize())}this.dispatchEvent(Ws),this.dispatchEvent(Or)}}pointerUp(e){null!==e&&0!==e.button||(this.dragging&&null!==this.axis&&(Mr.mode=this.mode,this.dispatchEvent(Mr)),this.dragging=!1,this.axis=null)}dispose(){this.disconnect(),this._root.dispose()}attach(e){return this.object=e,this._root.visible=!0,this}detach(){return this.object=void 0,this.axis=null,this._root.visible=!1,this}reset(){this.enabled&&this.dragging&&(this.object.position.copy(this._positionStart),this.object.quaternion.copy(this._quaternionStart),this.object.scale.copy(this._scaleStart),this.dispatchEvent(Ws),this.dispatchEvent(Or),this.pointStart.copy(this.pointEnd))}getRaycaster(){return Se}getMode(){return this.mode}setMode(e){this.mode=e}setTranslationSnap(e){this.translationSnap=e}setRotationSnap(e){this.rotationSnap=e}setScaleSnap(e){this.scaleSnap=e}setSize(e){this.size=e}setSpace(e){this.space=e}}function ic(o){if(this.domElement.ownerDocument.pointerLockElement)return{x:0,y:0,button:o.button};{const e=this.domElement.getBoundingClientRect();return{x:(o.clientX-e.left)/e.width*2-1,y:-(o.clientY-e.top)/e.height*2+1,button:o.button}}}function sc(o){if(this.enabled)switch(o.pointerType){case"mouse":case"pen":this.pointerHover(this._getPointer(o))}}function nc(o){this.enabled&&(document.pointerLockElement||this.domElement.setPointerCapture(o.pointerId),this.domElement.addEventListener("pointermove",this._onPointerMove),this.pointerHover(this._getPointer(o)),this.pointerDown(this._getPointer(o)))}function rc(o){this.enabled&&this.pointerMove(this._getPointer(o))}function oc(o){this.enabled&&(this.domElement.releasePointerCapture(o.pointerId),this.domElement.removeEventListener("pointermove",this._onPointerMove),this.pointerUp(this._getPointer(o)))}function qs(o,e,t){const i=e.intersectObject(o,!0);for(let s=0;s<i.length;s++)if(i[s].object.visible||t)return i[s];return!1}const Xi=new b.O9p,wt=new b.Pq0(0,1,0),kr=new b.Pq0(0,0,0),zr=new b.kn4,Qi=new b.PTz,Ki=new b.PTz,ae=new b.Pq0,Fr=new b.kn4,di=new b.Pq0(1,0,0),Ie=new b.Pq0(0,1,0),fi=new b.Pq0(0,0,1),Ji=new b.Pq0,pi=new b.Pq0,mi=new b.Pq0;class ac extends b.B69{constructor(e){super(),this.isTransformControlsRoot=!0,this.controls=e,this.visible=!1}updateMatrixWorld(e){const t=this.controls;void 0!==t.object&&(t.object.updateMatrixWorld(),null===t.object.parent?console.error("TransformControls: The attached 3D object must be a part of the scene graph."):t.object.parent.matrixWorld.decompose(t._parentPosition,t._parentQuaternion,t._parentScale),t.object.matrixWorld.decompose(t.worldPosition,t.worldQuaternion,t._worldScale),t._parentQuaternionInv.copy(t._parentQuaternion).invert(),t._worldQuaternionInv.copy(t.worldQuaternion).invert()),t.camera.updateMatrixWorld(),t.camera.matrixWorld.decompose(t.cameraPosition,t.cameraQuaternion,t._cameraScale),t.camera.isOrthographicCamera?t.camera.getWorldDirection(t.eye).negate():t.eye.copy(t.cameraPosition).sub(t.worldPosition).normalize(),super.updateMatrixWorld(e)}dispose(){this.traverse(function(e){e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()})}}class lc extends b.B69{constructor(){super(),this.isTransformControlsGizmo=!0,this.type="TransformControlsGizmo";const e=new b.V9B({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),t=new b.mrM({depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1,transparent:!0}),i=e.clone();i.opacity=.15;const s=t.clone();s.opacity=.5;const n=e.clone();n.color.setHex(16711680);const r=e.clone();r.color.setHex(65280);const a=e.clone();a.color.setHex(255);const l=e.clone();l.color.setHex(16711680),l.opacity=.5;const c=e.clone();c.color.setHex(65280),c.opacity=.5;const u=e.clone();u.color.setHex(255),u.opacity=.5;const h=e.clone();h.opacity=.25;const f=e.clone();f.color.setHex(16776960),f.opacity=.25,e.clone().color.setHex(16776960);const y=e.clone();y.color.setHex(7895160);const g=new b.Ho_(0,.04,.1,12);g.translate(0,.05,0);const _=new b.iNn(.08,.08,.08);_.translate(0,.04,0);const p=new b.LoY;p.setAttribute("position",new b.qtW([0,0,0,1,0,0],3));const x=new b.Ho_(.0075,.0075,.5,3);function E(R,Q){const j=new b.O3Y(R,.0075,3,64,Q*Math.PI*2);return j.rotateY(Math.PI/2),j.rotateX(Math.PI/2),j}x.translate(0,.25,0);const A={X:[[new b.eaF(g,n),[.5,0,0],[0,0,-Math.PI/2]],[new b.eaF(g,n),[-.5,0,0],[0,0,Math.PI/2]],[new b.eaF(x,n),[0,0,0],[0,0,-Math.PI/2]]],Y:[[new b.eaF(g,r),[0,.5,0]],[new b.eaF(g,r),[0,-.5,0],[Math.PI,0,0]],[new b.eaF(x,r)]],Z:[[new b.eaF(g,a),[0,0,.5],[Math.PI/2,0,0]],[new b.eaF(g,a),[0,0,-.5],[-Math.PI/2,0,0]],[new b.eaF(x,a),null,[Math.PI/2,0,0]]],XYZ:[[new b.eaF(new b.Ufg(.1,0),h.clone()),[0,0,0]]],XY:[[new b.eaF(new b.iNn(.15,.15,.01),u.clone()),[.15,.15,0]]],YZ:[[new b.eaF(new b.iNn(.15,.15,.01),l.clone()),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new b.eaF(new b.iNn(.15,.15,.01),c.clone()),[.15,0,.15],[-Math.PI/2,0,0]]]},M={X:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,.3,0]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XYZ:[[new b.eaF(new b.Ufg(.2,0),i)]],XY:[[new b.eaF(new b.iNn(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new b.eaF(new b.iNn(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new b.eaF(new b.iNn(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]]},S={START:[[new b.eaF(new b.Ufg(.01,2),s),null,null,null,"helper"]],END:[[new b.eaF(new b.Ufg(.01,2),s),null,null,null,"helper"]],DELTA:[[new b.N1A(function T(){const R=new b.LoY;return R.setAttribute("position",new b.qtW([0,0,0,1,1,1],3)),R}(),s),null,null,null,"helper"]],X:[[new b.N1A(p,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new b.N1A(p,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new b.N1A(p,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]},z={XYZE:[[new b.eaF(E(.5,1),y),null,[0,Math.PI/2,0]]],X:[[new b.eaF(E(.5,.5),n)]],Y:[[new b.eaF(E(.5,.5),r),null,[0,0,-Math.PI/2]]],Z:[[new b.eaF(E(.5,.5),a),null,[0,Math.PI/2,0]]],E:[[new b.eaF(E(.75,1),f),null,[0,Math.PI/2,0]]]},O={AXIS:[[new b.N1A(p,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]]},N={XYZE:[[new b.eaF(new b.Gu$(.25,10,8),i)]],X:[[new b.eaF(new b.O3Y(.5,.1,4,24),i),[0,0,0],[0,-Math.PI/2,-Math.PI/2]]],Y:[[new b.eaF(new b.O3Y(.5,.1,4,24),i),[0,0,0],[Math.PI/2,0,0]]],Z:[[new b.eaF(new b.O3Y(.5,.1,4,24),i),[0,0,0],[0,0,-Math.PI/2]]],E:[[new b.eaF(new b.O3Y(.75,.1,2,24),i)]]},Z={X:[[new b.eaF(_,n),[.5,0,0],[0,0,-Math.PI/2]],[new b.eaF(x,n),[0,0,0],[0,0,-Math.PI/2]],[new b.eaF(_,n),[-.5,0,0],[0,0,Math.PI/2]]],Y:[[new b.eaF(_,r),[0,.5,0]],[new b.eaF(x,r)],[new b.eaF(_,r),[0,-.5,0],[0,0,Math.PI]]],Z:[[new b.eaF(_,a),[0,0,.5],[Math.PI/2,0,0]],[new b.eaF(x,a),[0,0,0],[Math.PI/2,0,0]],[new b.eaF(_,a),[0,0,-.5],[-Math.PI/2,0,0]]],XY:[[new b.eaF(new b.iNn(.15,.15,.01),u),[.15,.15,0]]],YZ:[[new b.eaF(new b.iNn(.15,.15,.01),l),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new b.eaF(new b.iNn(.15,.15,.01),c),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new b.eaF(new b.iNn(.1,.1,.1),h.clone())]]},P={X:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[.3,0,0],[0,0,-Math.PI/2]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[-.3,0,0],[0,0,Math.PI/2]]],Y:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,.3,0]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,-.3,0],[0,0,Math.PI]]],Z:[[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,0,.3],[Math.PI/2,0,0]],[new b.eaF(new b.Ho_(.2,0,.6,4),i),[0,0,-.3],[-Math.PI/2,0,0]]],XY:[[new b.eaF(new b.iNn(.2,.2,.01),i),[.15,.15,0]]],YZ:[[new b.eaF(new b.iNn(.2,.2,.01),i),[0,.15,.15],[0,Math.PI/2,0]]],XZ:[[new b.eaF(new b.iNn(.2,.2,.01),i),[.15,0,.15],[-Math.PI/2,0,0]]],XYZ:[[new b.eaF(new b.iNn(.2,.2,.2),i),[0,0,0]]]},F={X:[[new b.N1A(p,s.clone()),[-1e3,0,0],null,[1e6,1,1],"helper"]],Y:[[new b.N1A(p,s.clone()),[0,-1e3,0],[0,0,Math.PI/2],[1e6,1,1],"helper"]],Z:[[new b.N1A(p,s.clone()),[0,0,-1e3],[0,-Math.PI/2,0],[1e6,1,1],"helper"]]};function v(R){const Q=new b.B69;for(const j in R)for(let rt=R[j].length;rt--;){const Y=R[j][rt][0].clone(),ot=R[j][rt][1],B=R[j][rt][2],L=R[j][rt][3],it=R[j][rt][4];Y.name=j,Y.tag=it,ot&&Y.position.set(ot[0],ot[1],ot[2]),B&&Y.rotation.set(B[0],B[1],B[2]),L&&Y.scale.set(L[0],L[1],L[2]),Y.updateMatrix();const et=Y.geometry.clone();et.applyMatrix4(Y.matrix),Y.geometry=et,Y.renderOrder=1/0,Y.position.set(0,0,0),Y.rotation.set(0,0,0),Y.scale.set(1,1,1),Q.add(Y)}return Q}this.gizmo={},this.picker={},this.helper={},this.add(this.gizmo.translate=v(A)),this.add(this.gizmo.rotate=v(z)),this.add(this.gizmo.scale=v(Z)),this.add(this.picker.translate=v(M)),this.add(this.picker.rotate=v(N)),this.add(this.picker.scale=v(P)),this.add(this.helper.translate=v(S)),this.add(this.helper.rotate=v(O)),this.add(this.helper.scale=v(F)),this.picker.translate.visible=!1,this.picker.rotate.visible=!1,this.picker.scale.visible=!1}updateMatrixWorld(e){const i="local"===("scale"===this.mode?"local":this.space)?this.worldQuaternion:Ki;this.gizmo.translate.visible="translate"===this.mode,this.gizmo.rotate.visible="rotate"===this.mode,this.gizmo.scale.visible="scale"===this.mode,this.helper.translate.visible="translate"===this.mode,this.helper.rotate.visible="rotate"===this.mode,this.helper.scale.visible="scale"===this.mode;let s=[];s=s.concat(this.picker[this.mode].children),s=s.concat(this.gizmo[this.mode].children),s=s.concat(this.helper[this.mode].children);for(let n=0;n<s.length;n++){const r=s[n];let a;r.visible=!0,r.rotation.set(0,0,0),r.position.copy(this.worldPosition),a=this.camera.isOrthographicCamera?(this.camera.top-this.camera.bottom)/this.camera.zoom:this.worldPosition.distanceTo(this.cameraPosition)*Math.min(1.9*Math.tan(Math.PI*this.camera.fov/360)/this.camera.zoom,7),r.scale.set(1,1,1).multiplyScalar(a*this.size/4),"helper"!==r.tag?(r.quaternion.copy(i),"translate"===this.mode||"scale"===this.mode?("X"===r.name&&Math.abs(wt.copy(di).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"Y"===r.name&&Math.abs(wt.copy(Ie).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"Z"===r.name&&Math.abs(wt.copy(fi).applyQuaternion(i).dot(this.eye))>.99&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"XY"===r.name&&Math.abs(wt.copy(fi).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"YZ"===r.name&&Math.abs(wt.copy(di).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1),"XZ"===r.name&&Math.abs(wt.copy(Ie).applyQuaternion(i).dot(this.eye))<.2&&(r.scale.set(1e-10,1e-10,1e-10),r.visible=!1)):"rotate"===this.mode&&(Qi.copy(i),wt.copy(this.eye).applyQuaternion(At.copy(i).invert()),-1!==r.name.search("E")&&r.quaternion.setFromRotationMatrix(zr.lookAt(this.eye,kr,Ie)),"X"===r.name&&(At.setFromAxisAngle(di,Math.atan2(-wt.y,wt.z)),At.multiplyQuaternions(Qi,At),r.quaternion.copy(At)),"Y"===r.name&&(At.setFromAxisAngle(Ie,Math.atan2(wt.x,wt.z)),At.multiplyQuaternions(Qi,At),r.quaternion.copy(At)),"Z"===r.name&&(At.setFromAxisAngle(fi,Math.atan2(wt.y,wt.x)),At.multiplyQuaternions(Qi,At),r.quaternion.copy(At))),r.visible=r.visible&&(-1===r.name.indexOf("X")||this.showX),r.visible=r.visible&&(-1===r.name.indexOf("Y")||this.showY),r.visible=r.visible&&(-1===r.name.indexOf("Z")||this.showZ),r.visible=r.visible&&(-1===r.name.indexOf("E")||this.showX&&this.showY&&this.showZ),r.material._color=r.material._color||r.material.color.clone(),r.material._opacity=r.material._opacity||r.material.opacity,r.material.color.copy(r.material._color),r.material.opacity=r.material._opacity,this.enabled&&this.axis&&(r.name===this.axis||this.axis.split("").some(function(l){return r.name===l}))&&(r.material.color.setHex(16776960),r.material.opacity=1)):(r.visible=!1,"AXIS"===r.name?(r.visible=!!this.axis,"X"===this.axis&&(At.setFromEuler(Xi.set(0,0,0)),r.quaternion.copy(i).multiply(At),Math.abs(wt.copy(di).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),"Y"===this.axis&&(At.setFromEuler(Xi.set(0,0,Math.PI/2)),r.quaternion.copy(i).multiply(At),Math.abs(wt.copy(Ie).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),"Z"===this.axis&&(At.setFromEuler(Xi.set(0,Math.PI/2,0)),r.quaternion.copy(i).multiply(At),Math.abs(wt.copy(fi).applyQuaternion(i).dot(this.eye))>.9&&(r.visible=!1)),"XYZE"===this.axis&&(At.setFromEuler(Xi.set(0,Math.PI/2,0)),wt.copy(this.rotationAxis),r.quaternion.setFromRotationMatrix(zr.lookAt(kr,wt,Ie)),r.quaternion.multiply(At),r.visible=this.dragging),"E"===this.axis&&(r.visible=!1)):"START"===r.name?(r.position.copy(this.worldPositionStart),r.visible=this.dragging):"END"===r.name?(r.position.copy(this.worldPosition),r.visible=this.dragging):"DELTA"===r.name?(r.position.copy(this.worldPositionStart),r.quaternion.copy(this.worldQuaternionStart),Lt.set(1e-10,1e-10,1e-10).add(this.worldPositionStart).sub(this.worldPosition).multiplyScalar(-1),Lt.applyQuaternion(this.worldQuaternionStart.clone().invert()),r.scale.copy(Lt),r.visible=this.dragging):(r.quaternion.copy(i),r.position.copy(this.dragging?this.worldPositionStart:this.worldPosition),this.axis&&(r.visible=-1!==this.axis.search(r.name))))}super.updateMatrixWorld(e)}}class cc extends b.eaF{constructor(){super(new b.bdM(1e5,1e5,2,2),new b.V9B({visible:!1,wireframe:!0,side:b.$EB,transparent:!0,opacity:.1,toneMapped:!1})),this.isTransformControlsPlane=!0,this.type="TransformControlsPlane"}updateMatrixWorld(e){let t=this.space;switch(this.position.copy(this.worldPosition),"scale"===this.mode&&(t="local"),Ji.copy(di).applyQuaternion("local"===t?this.worldQuaternion:Ki),pi.copy(Ie).applyQuaternion("local"===t?this.worldQuaternion:Ki),mi.copy(fi).applyQuaternion("local"===t?this.worldQuaternion:Ki),wt.copy(pi),this.mode){case"translate":case"scale":switch(this.axis){case"X":wt.copy(this.eye).cross(Ji),ae.copy(Ji).cross(wt);break;case"Y":wt.copy(this.eye).cross(pi),ae.copy(pi).cross(wt);break;case"Z":wt.copy(this.eye).cross(mi),ae.copy(mi).cross(wt);break;case"XY":ae.copy(mi);break;case"YZ":ae.copy(Ji);break;case"XZ":wt.copy(mi),ae.copy(pi);break;case"XYZ":case"E":ae.set(0,0,0)}break;default:ae.set(0,0,0)}0===ae.length()?this.quaternion.copy(this.cameraQuaternion):(Fr.lookAt(Lt.set(0,0,0),ae,wt),this.quaternion.setFromRotationMatrix(Fr)),super.updateMatrixWorld(e)}}class Gs{constructor(e,t,i,s,n,r=5,a=!0){var l;if(w(this,"onDraggingStarted",new X),w(this,"onDraggingEnded",new X),w(this,"onDisposed",new X),w(this,"normal"),w(this,"origin"),w(this,"three",new b.Zcv),w(this,"components"),w(this,"world"),w(this,"type","default"),w(this,"_title","Clipping Plane"),w(this,"_helper"),w(this,"_visible",!0),w(this,"_enabled",!0),w(this,"_controlsActive",!1),w(this,"_arrowBoundBox",new b.eaF),w(this,"_planeMesh"),w(this,"_controls"),w(this,"_hiddenMaterial",new b.V9B({visible:!1})),w(this,"_sizeMultiplier",5),w(this,"_autoScale",!0),w(this,"_visibilityBeforeDisabled",!0),w(this,"notifyManager",()=>{const c=this.components.get(Ze),u=c.list.getKey(this);u&&c.list.set(u,this)}),w(this,"update",()=>{this._enabled&&(this.three.setFromNormalAndCoplanarPoint(this.normal,this._helper.position),this.updateScale())}),w(this,"updateScale",()=>{var c;if(!this.autoScale)return;const u=null==(c=this.world.camera)?void 0:c.three;if(!(u&&u instanceof b.ubm))return;const h=new b.Pq0;u.getWorldPosition(h);const d=h.distanceTo(this._helper.position)/7*this._sizeMultiplier;this._planeMesh.scale.set(d,d,d)}),w(this,"changeDrag",c=>{this._visible=!c.value,this.preventCameraMovement(),this.notifyDraggingChanged(c)}),this.components=e,this.world=t,!t.renderer)throw new Error("The given world must have a renderer!");this.normal=s,this.origin=i,this._sizeMultiplier=r,t.renderer.setPlane(!0,this.three),this._planeMesh=Gs.newPlaneMesh(r,n),this._helper=this.newHelper(),this._controls=this.newTransformControls(),this.three.setFromNormalAndCoplanarPoint(s,i),a&&this.toggleControls(!0),this.updateScale(),null!=(l=t.camera)&&l.controls&&t.camera.controls.addEventListener("update",this.updateScale)}set title(e){this._title=e,this.notifyManager()}get title(){return this._title}get autoScale(){return this._autoScale}set autoScale(e){this._autoScale=e,e&&this.updateScale()}get enabled(){return this._enabled}set enabled(e){if(!this.world.isDisposing){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");this._enabled=e,e?this.visible=this._visibilityBeforeDisabled:(this._visibilityBeforeDisabled=this.visible,this.visible=!1),this.world.renderer.setPlane(e,this.three),this.notifyManager()}}get visible(){return this._visible}set visible(e){this._visible=e,this._controls.getHelper().visible=e,this._helper.visible=e,this.toggleControls(e),this.notifyManager()}get meshes(){return[this._planeMesh,this._arrowBoundBox]}get planeMaterial(){return this._planeMesh.material}set planeMaterial(e){this._planeMesh.material=e}get size(){return this._sizeMultiplier}set size(e){this._sizeMultiplier=e,this.autoScale?this.updateScale():this._planeMesh.scale.set(e,e,e)}get helper(){return this._helper}get controls(){return this._controls}setFromNormalAndCoplanarPoint(e,t){this.reset(),this.normal.equals(e)||(this.normal.copy(e),this._helper.lookAt(e)),this.origin.copy(t),this._helper.position.copy(t),this._helper.updateMatrix(),this.update()}dispose(){var e;this._enabled=!1,null!=(e=this.world.camera)&&e.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 e=new b.Pq0(1,0,0),t=new b.Pq0;this.normal.equals(e)||(this.normal.copy(e),this._helper.lookAt(e)),this.origin.copy(t),this._helper.position.copy(t),this._helper.updateMatrix()}toggleControls(e){if(e){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=e}newTransformControls(){if(!this.world.renderer)throw new Error("No renderer found for clipping plane!");const i=new ec(this.world.camera.three,this.world.renderer.three.domElement);return this.initializeControls(i),this.world.scene.three.add(i.getHelper()),i}initializeControls(e){e.attach(this._helper),e.showX=!1,e.showY=!1,e.setSpace("local"),this.createArrowBoundingBox(),e.getHelper().children[0].children[0].add(this._arrowBoundBox)}createArrowBoundingBox(){this._arrowBoundBox.geometry=new b.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(e){e.value?this.onDraggingStarted.trigger():this.onDraggingEnded.trigger()}preventCameraMovement(){this.world.camera.enabled=this._visible}newHelper(){const e=new b.B69;return e.lookAt(this.normal),e.position.copy(this.origin),this._planeMesh.position.z+=.01,e.add(this._planeMesh),this.world.scene.three.add(e),e}static newPlaneMesh(e,t){const i=new b.bdM(1),s=new b.eaF(i,t);return s.scale.set(e,e,e),s}}class uc extends ii{constructor(){super(...arguments),w(this,"_config",{enabled:{value:!0,type:"Boolean"},visible:{value:!0,type:"Boolean"},color:{value:new b.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(e){this._config.enabled.value=e,this._component.enabled=e}get visible(){return this._config.visible.value}set visible(e){this._config.visible.value=e,this._component.visible=e}get color(){return this._config.color.value}set color(e){this._config.color.value=e,this._component.material.color.copy(e)}get opacity(){return this._config.opacity.value}set opacity(e){this._config.opacity.value=e,this._component.material.opacity=e}get size(){return this._config.size.value}set size(e){this._config.size.value=e,this._component.size=e}}const Nr=class ns extends Tt{constructor(e){super(e),w(this,"onSetup",new X),w(this,"onBeforeDrag",new X),w(this,"onAfterDrag",new X),w(this,"onBeforeCreate",new X),w(this,"onBeforeCancel",new X),w(this,"onAfterCancel",new X),w(this,"onBeforeDelete",new X),w(this,"onAfterCreate",new X),w(this,"onAfterDelete",new X),w(this,"onDisposed",new X),w(this,"isSetup",!1),w(this,"orthogonalY",!1),w(this,"toleranceOrthogonalY",.7),w(this,"autoScalePlanes",!0),w(this,"Type",Gs),w(this,"list",new ft.jp),w(this,"config",new uc(this,this.components,"Clipper",ns.uuid)),w(this,"_defaultConfig",{color:new b.Q1f(12255487),opacity:.2,size:2}),w(this,"_material",new b.V9B({color:12255487,side:b.$EB,transparent:!0,opacity:.2})),w(this,"_size",5),w(this,"_enabled",!1),w(this,"_visible",!0),w(this,"onStateChanged",new X),this.components.add(ns.uuid,this),this.setEvents()}get enabled(){return this._enabled}set enabled(e){this._enabled=e,this.onStateChanged.trigger(["enabled"])}get visible(){return this._visible}set visible(e){this._visible=e;for(const[t,i]of this.list)i.visible=e;this.onStateChanged.trigger(["visibility"])}get material(){return this._material}set material(e){this._material=e;for(const[t,i]of this.list)i.planeMaterial=e;this.onStateChanged.trigger(["material"])}get size(){return this._size}set size(e){this._size=e;for(const[t,i]of this.list)i.size=e;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)})}dispose(){this._enabled=!1,this.components.get(Pi).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(ns.uuid),this.onDisposed.reset()}create(e){var t=this;return(0,H.A)(function*(){const n=yield t.components.get(Si).get(e).castRay();return n?t.createPlaneFromIntersection(e,n):null})()}createFromNormalAndCoplanarPoint(e,t,i){const s=this.newPlane(e,i,t);return this.updateMaterialsAndPlanes(),s}delete(e,t){var i=this;return(0,H.A)(function*(){if(!t){const s=yield i.pickPlane(e);if(!s)return;t=i.list.getKey(s)}t&&i.list.delete(t)})()}deleteAll(e){for(const[t,i]of this.list)(!e||e.has(i.type))&&this.list.delete(t)}setup(e){const t={...this._defaultConfig,...e};this.config.color=t.color,this.config.opacity=t.opacity,this.config.size=t.size,this.isSetup=!0,this.onSetup.trigger()}pickPlane(e){const i=this.components.get(Si).get(e),s=this.getAllPlaneMeshes(),n=i.castRayToObjects(s);if(n){const r=n.object;return[...this.list.values()].find(a=>a.meshes.includes(r))}}getAllPlaneMeshes(){const e=[];for(const[t,i]of this.list)e.push(...i.meshes);return e}createPlaneFromIntersection(e,t){var i;if(!e.renderer)throw new Error("The given world must have a renderer!");const s=t.point.distanceTo(new b.Pq0(0,0,0)),n=t.normal||(null==(i=t.face)?void 0:i.normal);if(!s||!n)return null;const r=this.getWorldNormal(t,n),a=this.newPlane(e,t.point,r.negate()),l=this.list.get(a);return l.visible=this._visible,l.size=this._size,e.renderer.setPlane(!0,l.three),this.updateMaterialsAndPlanes(),l}getWorldNormal(e,t){const i=e.object;let s=e.object.matrixWorld.clone();if(i instanceof b.ZLX&&void 0!==e.instanceId){const l=new b.kn4;i.getMatrixAt(e.instanceId,l),s=l.multiply(s)}const r=(new b.dwI).getNormalMatrix(s),a=t.clone().applyMatrix3(r).normalize();return this.normalizePlaneDirectionY(a),a}normalizePlaneDirectionY(e){this.orthogonalY&&(e.y>this.toleranceOrthogonalY&&(e.x=0,e.y=1,e.z=0),e.y<-this.toleranceOrthogonalY&&(e.x=0,e.y=-1,e.z=0))}newPlane(e,t,i){const s=new this.Type(this.components,e,t,i,this._material);s.autoScale=this.autoScalePlanes,s.onDraggingStarted.add(()=>this.onBeforeDrag.trigger(s)),s.onDraggingEnded.add(()=>this.onAfterDrag.trigger(s));const n=Yt.create();return this.list.set(n,s),this.onAfterCreate.trigger(s),n}updateMaterialsAndPlanes(){const e=this.components.get(bs);for(const[t,i]of e.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 r of n.material)r.clippingPlanes=s;else n.material.clippingPlanes=s}}};w(Nr,"uuid","66290bc5-18c4-4cd1-9379-2e17a0617611");let Ze=Nr;class Dr{constructor(e,t){w(this,"title"),w(this,"guid",Yt.create()),w(this,"clippingPlanes",new ft.PG),w(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}}),w(this,"customData",{}),w(this,"exceptionComponents",new ft.PG),w(this,"selectionComponents",new ft.PG),w(this,"componentColors",new ft.jp),w(this,"spacesVisible",!1),w(this,"spaceBoundariesVisible",!1),w(this,"openingsVisible",!1),w(this,"defaultVisibility",!0),w(this,"snapshot",this.guid),w(this,"_components"),w(this,"_world",null),w(this,"notifyUpdate",()=>{this._components.get(de).list.set(this.guid,this)}),this._components=e,t&&(this.guid=t.guid??this.guid,this.set(t)),this.setEvents()}getSelectionMap(){var e=this;return(0,H.A)(function*(){return yield e._components.get(ct).guidsToModelIdMap([...e.selectionComponents])})()}getExceptionMap(){var e=this;return(0,H.A)(function*(){return yield e._components.get(ct).guidsToModelIdMap([...e.exceptionComponents])})()}get projection(){return"field_of_view"in this.camera?"Perspective":"Orthographic"}get position(){const e=this._components.get(ct),{camera_view_point:t}=this.camera,{x:i,y:s,z:n}=t,r=new b.Pq0(i,s,n);return e.applyBaseCoordinateSystem(r,new b.kn4),r}set position(e){const t=e.clone(),i=this._components.get(ct);e.clone().applyMatrix4(i.baseCoordinationMatrix.clone().invert()),this.camera.camera_view_point={x:t.x,y:t.y,z:t.z}}get direction(){const{camera_direction:e}=this.camera,{x:t,y:i,z:s}=e;return new b.Pq0(t,i,s)}set world(e){this._world=e}get world(){return this._world}get _managerVersion(){return this._components.get(Dt).config.version}get topics(){return[...this._components.get(Dt).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(e){this.title=e.title;const{components:t,perspective_camera:i,orthogonal_camera:s,clipping_planes:n}=e;if(t){const{selection:r,visibility:a,coloring:l}=t;if(r){this.selectionComponents.clear();for(const{ifc_guid:c}of r)c&&this.selectionComponents.add(c)}if(a){const{default_visibility:c,exceptions:u,view_setup_hints:h}=a;if(void 0!==c&&(this.defaultVisibility=c),u){this.exceptionComponents.clear();for(const{ifc_guid:f}of u)f&&this.exceptionComponents.add(f)}if(h){const{spaces_visible:f,space_boundaries_visible:d,openings_visible:y}=h;void 0!==f&&(this.spacesVisible=f),void 0!==d&&(this.spaceBoundariesVisible=d),void 0!==y&&(this.openingsVisible=y)}}if(l){this.componentColors.clear();for(const c of l){const{color:u,components:h}=c,f=h.map(d=>d.ifc_guid).filter(d=>null!==d);this.componentColors.set(u,f)}}}if((i||s)&&(this.camera=i??s),n&&this.world){const r=this._components.get(Ze);for(const a of n){const{location:l,direction:c}=a,u=new b.Pq0(l.x,l.z,-l.y),h=new b.Pq0(c.x,c.z,-c.y),f=r.createFromNormalAndCoplanarPoint(this.world,h,u);this.clippingPlanes.add(f),r.list.get(f).enabled=!1,r.list.get(f).visible=!1}}this.notifyUpdate()}go(e){var t=this;return(0,H.A)(function*(){if(!t.world)return;const{camera:i}=t.world;if(!(i instanceof Hs))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:r,clippingsVisibility:a}={transition:!0,applyClippings:!0,applyVisibility:!0,clippingsVisibility:!0,...e};i.projection.set(t.projection);const l=new b.Pq0(t.camera.camera_view_point.x,t.camera.camera_view_point.y,t.camera.camera_view_point.z),c=new b.Pq0(t.camera.camera_direction.x,t.camera.camera_direction.y,t.camera.camera_direction.z);if(l.equals(new b.Pq0)&&c.equals(new b.Pq0))return;const u=t.position,h=t.direction,d={x:u.x+80*h.x,y:u.y+80*h.y,z:u.z+80*h.z},y=[];n&&t.setClippingState(!0),r&&y.push(t.applyVisibility()),t.setClippingVisibility(a),y.push(i.controls.setLookAt(u.x,u.y,u.z,d.x,d.y,d.z,s)),yield Promise.all(y)})()}updateCamera(){var e=this;return(0,H.A)(function*(t=!0){return new Promise(i=>{if(!e.world)return void i(!1);const{camera:s,renderer:n}=e.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 r=new b.Pq0;s.controls.getPosition(r);const a=s.three,l=new b.Pq0(0,0,-1).applyEuler(a.rotation),{width:c,height:u}=n.getSize();let h=c/u;Number.isNaN(h)&&(h=1);const f=e._components.get(ct);r.applyMatrix4(f.baseCoordinationMatrix.clone().invert());const d={aspect_ratio:h,camera_view_point:{x:r.x,y:r.y,z:r.z},camera_direction:{x:l.x,y:l.y,z:l.z},camera_up_vector:{x:0,y:1,z:0}};if(a instanceof b.ubm?e.camera={...d,field_of_view:a.fov}:a instanceof b.qUd&&(e.camera={...d,view_to_world_scale:a.top-a.bottom}),t){const y=e._components.get(de),g=n.three.domElement;n.three.render(e.world.scene.three,s.three),g.toBlob(function(){var _=(0,H.A)(function*(p){if(p){const x=yield p.arrayBuffer(),E=new Uint8Array(x);y.snapshots.set(e.guid,E)}e.notifyUpdate(),i(!0)});return function(p){return _.apply(this,arguments)}}())}else e.notifyUpdate(),i(!0)})}).apply(this,arguments)}takeSnapshot(){var e=this;return new Promise(t=>{if(!this.world)return void t(!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(de),r=s.three.domElement;s.three.render(this.world.scene.three,i.three),r.toBlob(function(){var a=(0,H.A)(function*(l){if(l){const c=yield l.arrayBuffer(),u=new Uint8Array(c);n.snapshots.set(e.guid,u)}e.notifyUpdate(),t(!0)});return function(l){return a.apply(this,arguments)}}())})}updateClippingPlanes(){this.clippingPlanes.clear();const e=this._components.get(Ze);for(const[t,i]of e.list)i.enabled&&this.clippingPlanes.add(t)}applyVisibility(){var e=this;return(0,H.A)(function*(){const t=e._components.get(Ma);t.set(e.defaultVisibility);const i=yield e.getExceptionMap();t.set(!e.defaultVisibility,i);const s=yield e.getSelectionMap();t.set(!0,s)})()}setColorizationState(e){var t=this;return(0,H.A)(function*(){const i=t._components.get(ct),s=[];if(e)for(const[n,r]of t.componentColors){const a=`#${n}`,l=yield i.guidsToModelIdMap(r);for(const[c,u]of Object.entries(l)){const h=i.list.get(c);h&&s.push(h.highlight([...u],{customId:a,color:new b.Q1f(a),renderedFaces:ft.eB.ONE,opacity:1,transparent:!1}))}}else for(const[n,r]of t.componentColors){const a=yield i.guidsToModelIdMap(r);for(const[l,c]of Object.entries(a)){const u=i.list.get(l);u&&s.push(u.resetHighlight([...c]))}}s.push(i.core.update(!0)),yield Promise.all(s)})()}setClippingState(e){const t=this._components.get(Ze);for(const[i,s]of t.list)s.enabled=e&&this.clippingPlanes.has(i)}setClippingVisibility(e){const t=this._components.get(Ze);for(const i of this.clippingPlanes){const s=t.list.get(i);s&&(s.visible=e)}}createComponentTags(e){var t=this;return(0,H.A)(function*(){var i;const s=t._components.get(ct);let r="";if(t._components.get(Dt).config.includeSelectionTag){const a="selection"===e?yield t.getSelectionMap():yield t.getExceptionMap();for(const l in a){const c=s.list.get(l);if(!c)continue;const u=a[l];for(const h of u){const f=c.getItem(h),d=yield f.getGuid();if(!d)continue;const y=null==(i=yield f.getAttributes())?void 0:i.getValue("Tag");let g=null;y&&(g=`AuthoringToolId="${y}"`),r+=`\n<Component IfcGuid="${d}" ${g??""} />`}}}else r=[...t.selectionComponents].map(a=>`<Component IfcGuid="${a}" />`).join("\n");return r})()}createColorTags(){let e="";for(const[t,i]of this.componentColors.entries())e+=`<Color Color="${t}">\n${i.map(n=>`\n<Component IfcGuid="${n}" />`).join("\n")}\n</Color>`;return 0!==e.length?`<Coloring>\n${e}\n</Coloring>`:"<Coloring />"}toJSON(){const e=this._components.get(Ze),t={guid:this.guid,components:{selection:[...this.selectionComponents].map(n=>({ifc_guid:n,authoring_tool_id:null})),coloring:[...this.componentColors].map(([n,r])=>({color:n,components:r.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 r=e.list.get(n);if(!r)return null;const a=r._controls.worldPosition??r.origin,{normal:l}=r;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?t.perspective_camera=this.camera:t.orthogonal_camera=this.camera;const i=this._components.get(de),s=i.snapshots.get(this.snapshot);if(s){const n=s.toString(),r=btoa(n),a=i.getSnapshotExtension(this.snapshot);t.snapshot={snapshot_type:a,snapshot_data:r}}return t}serialize(){var e=this;return(0,H.A)(function*(t=e._managerVersion){const i=e._components.get(ct),s=e.position;s.applyMatrix4(i.baseCoordinationMatrix.clone().invert());const n=e.direction;n.normalize();const r=(new b.kn4).makeRotationX(Math.PI/2),a=n.clone().applyMatrix4(r);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>`,u=`<CameraUpVector>\n <X>${a.x}</X>\n <Y>${-a.z}</Y>\n <Z>${a.y}</Z>\n </CameraUpVector>`,h=`<AspectRatio>${e.camera.aspect_ratio}</AspectRatio>`;let f="";"view_to_world_scale"in e.camera?f=`<OrthogonalCamera>\n ${l}\n ${c}\n ${u}\n ${h}\n <ViewToWorldScale>${e.camera.view_to_world_scale}</ViewToWorldScale>\n </OrthogonalCamera>`:"field_of_view"in e.camera&&(f=`<PerspectiveCamera>\n ${l}\n ${c}\n ${u}\n ${h}\n <FieldOfView>${e.camera.field_of_view}</FieldOfView>\n </PerspectiveCamera>`);const d=`<ViewSetupHints SpacesVisible="${e.spacesVisible??!1}" SpaceBoundariesVisible="${e.spaceBoundariesVisible??!1}" OpeningsVisible="${e.openingsVisible??!1}" />`,y=(yield e.createComponentTags("selection")).trim(),g=(yield e.createComponentTags("exception")).trim(),_=e.createColorTags();return`<?xml version="1.0" encoding="UTF-8"?>\n <VisualizationInfo Guid="${e.guid}">\n <Components>\n ${"2.1"===t?d:""}\n ${0!==y.length?`<Selection>${y}</Selection>`:""}\n <Visibility DefaultVisibility="${e.defaultVisibility}">\n ${"3"===t?d:""}\n ${0!==g.length?`<Exceptions>${g}</Exceptions>`:""}\n </Visibility>\n ${_}\n </Components>\n ${f}\n </VisualizationInfo>`}).apply(this,arguments)}}class hc extends ii{constructor(){super(...arguments),w(this,"_config",{overwriteColors:{value:!1,type:"Boolean"}})}get overwriteColors(){return this._config.overwriteColors.value}set overwriteColors(e){this._config.overwriteColors.value=e}}const Rr=class yn extends Tt{constructor(e){super(e),w(this,"enabled",!0),w(this,"world",null),w(this,"list",new ft.jp),w(this,"snapshots",new ft.jp),w(this,"isSetup",!1),w(this,"onSetup",new X),w(this,"config",new hc(this,this.components,"Viewpoints",yn.uuid)),w(this,"onDisposed",new X),e.add(yn.uuid,this)}create(e){const t=new Dr(this.components,e);return t.world=this.world,e||this.list.set(t.guid,t),t}getSnapshotExtension(e){let t="jpeg";const i=this.snapshots.get(e);if(!i)return t;const s=i.subarray(0,4);let n="";for(let r=0;r<s.length;r++)n+=s[r].toString(16);return n.startsWith("89504e47")&&(t="png"),n.startsWith("ffd8ffe")&&(t="jpeg"),t}setup(){}dispose(){this.list.dispose(),this.onDisposed.trigger(),this.onDisposed.reset()}};w(Rr,"uuid","ee867824-a796-408d-8aa0-4e5962a83c66");let de=Rr;class Br{constructor(e,t){w(this,"_components"),w(this,"_cameraOffset",10),w(this,"_planeHelper"),w(this,"_farPlaneHelper"),w(this,"_cameraHelper"),w(this,"onStateChanged",new X),w(this,"onUpdated",new X),w(this,"onDisposed",new X),w(this,"camera"),w(this,"plane",new b.Zcv),w(this,"farPlane",new b.Zcv),w(this,"id",Yt.create()),w(this,"_open",!1),w(this,"_range",dc.defaultRange),w(this,"_world",null),w(this,"_helpersVisible",!1),w(this,"_planesEnabled",!1),this._components=e,this.camera=new Hs(this._components);const{threeOrtho:i}=this.camera;if(t?.id&&(this.id=t.id),t?.normal&&t?.point){const{normal:s,point:n}=t;this.plane.setFromNormalAndCoplanarPoint(s,n)}this._cameraHelper=new b.WTh(i),this._planeHelper=new b.ZM4(this.plane,50),this._farPlaneHelper=new b.ZM4(this.farPlane,50),this.farPlaneHelperColor=new b.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(e){this._open=e,this.onStateChanged.trigger(["open"])}get open(){return this._open}set planeHelperColor(e){!Array.isArray(this._planeHelper.material)&&"color"in this._planeHelper.material&&this._planeHelper.material.color instanceof b.Q1f&&(this._planeHelper.material.color=e)}set farPlaneHelperColor(e){!Array.isArray(this._farPlaneHelper.material)&&"color"in this._farPlaneHelper.material&&this._farPlaneHelper.material.color instanceof b.Q1f&&(this._farPlaneHelper.material.color=e)}set range(e){this._range=e,this.update()}get range(){return this._range}set distance(e){this.plane.constant=e,this.update()}get distance(){return this.plane.constant}set world(e){this._world=e,this.camera.currentWorld=e,e&&(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(e){if(!e)return this._helpersVisible=e,this._planeHelper.removeFromParent(),this._farPlaneHelper.removeFromParent(),void this._cameraHelper.removeFromParent();this.world&&(this._helpersVisible=e,this.world.scene.three.add(this._planeHelper,this._farPlaneHelper))}get helpersVisible(){return this._helpersVisible}set planesEnabled(e){const{world:t}=this;if(!t)return;const{renderer:i}=t;i&&(i.setPlane(e,this.plane),i.setPlane(e,this.farPlane),this._planesEnabled=e)}get planesEnabled(){return this._planesEnabled}dispose(){this.helpersVisible=!1;const e=this._components.get(Je);e.destroy(this._planeHelper),e.destroy(this._farPlaneHelper),e.destroy(this._cameraHelper),this.camera.dispose(),this.onDisposed.trigger()}update(){if(this.world){const e=this._cameraPosition,t=this._planePosition;this.camera.controls.setLookAt(e.x,e.y,e.z,t.x,t.y,t.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 Xs=class bo extends Tt{constructor(e){super(e),w(this,"list",new ft.jp),w(this,"enabled",!0),w(this,"world",null),w(this,"_fragmentsUpdateEvent",()=>{this.components.get(ct).core.update(!0)}),e.add(bo.uuid,this),this.setupEvents()}get hasOpenViews(){return[...this.list.values()].some(e=>e.open)}setupEvents(){this.list.onBeforeDelete.add(({key:e,value:t})=>{t.open&&this.close(e),t.dispose()})}create(e,t,i){const s=new Br(this.components,{id:i?.id,normal:e,point:t});return s.world=i?.world??this.world,this.list.set(s.id,s),s}createFromPlane(e,t){const i=new Br(this.components,{id:t?.id});return i.plane.copy(e),i.update(),i.world=t?.world??this.world,this.list.set(i.id,i),i}createFromIfcStoreys(e){var t=this;return(0,H.A)(function*(){const i=[],s=t.components.get(ct),n=void 0===e?.offset?.25:e.offset;for(const[r,a]of s.list){if(e&&e.modelIds&&!e.modelIds.some(f=>f.test(r)))continue;const l=Object.values(yield a.getItemsOfCategories([/BUILDINGSTOREY/])).flat();if(0===l.length)continue;const c=yield a.getItemsData(l),[,u]=yield a.getCoordinates(),h=new b.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(e?.storeyNames&&!e.storeyNames.some(p=>p.test(d)))continue;const g=new b.Zcv(h,f.Elevation.value+u+n),_=t.createFromPlane(g,{id:d,world:e?.world});i.push(_)}}return i})()}createElevations(e){const t=[],i=this.components.get(ct),s=void 0!==e?.combine&&e.combine,n=e?.namingCallback??(a=>({front:s?"Front":`${a}: Front`,back:s?"Back":`${a}: Back`,left:s?"Left":`${a}: Left`,right:s?"Right":`${a}: Right`}));let r=[];for(const[a,l]of i.list)e&&e.modelIds&&!e.modelIds.some(c=>c.test(a))||r.push({id:a,box:l.box});if(0===r.length)return t;if(s){const a=this.components.get(Gn);a.list.clear(),a.list.add(...r.map(c=>c.box)),r=[{id:"combined",box:a.get()}]}for(const{id:a,box:l}of r){const{min:c,max:u}=l,h=Math.abs(u.x-c.x),f=Math.abs(u.z-c.z),d=new b.Pq0;l.getCenter(d);const y=new b.Zcv(new b.Pq0(0,0,-1),u.z),g=new b.Zcv(new b.Pq0(0,0,1),-c.z),_=new b.Zcv(new b.Pq0(-1,0,0),u.x),p=new b.Zcv(new b.Pq0(1,0,0),-c.x),{front:x,back:E,left:T,right:A}=n(a),M=this.createFromPlane(y,{id:x,world:e?.world});M.range=f;const S=this.createFromPlane(g,{id:E,world:e?.world});S.range=f;const z=this.createFromPlane(_,{id:T,world:e?.world});z.range=h;const O=this.createFromPlane(p,{id:A,world:e?.world});O.range=h,t.push(M,S,z,O)}return t}open(e){const t=this.list.get(e);if(!t)throw new Error(`Views: the view with id ${e} doesn't exist.`);if(t.open)return;const{world:i}=t;if(!i)throw new Error(`Views: no world found for view with id ${e}.`);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);s.setPlane(!0,t.plane),s.setPlane(!0,t.farPlane),t.camera.controls.addEventListener("rest",this._fragmentsUpdateEvent),i.camera=t.camera,t.open=!0}close(e){let t;if(t=e?this.list.get(e):[...this.list.values()].find(n=>n.open),e&&!t)throw new Error(`Views: the view with id ${e} doesn't exist.`);if(!t||!t.open)return;const{world:i}=t;if(!i)throw new Error(`Views: no world found for view with id ${e}.`);const{renderer:s}=i;if(!s)throw new Error(`Views: no renderer found for world with id ${i.uuid}.`);s.setPlane(!1,t.plane),s.setPlane(!1,t.farPlane),t.camera.controls.removeEventListener("rest",this._fragmentsUpdateEvent),i.useDefaultCamera(),t.open=!1}};w(Xs,"uuid","fb22f1f5-6598-4664-a11d-de8963ae420f"),w(Xs,"defaultRange",15);let dc=Xs;class We{constructor(e){w(this,"cardinality","required"),w(this,"instructions"),w(this,"evalRequirement",(t,i,s,n)=>{const r={parameter:s,currentValue:t,requiredValue:i,pass:!1};n&&this.addCheckResult(r,n);let a=!1;if("simple"===i.type&&(a=t===i.parameter),"enumeration"===i.type&&(a=i.parameter.includes(t)),"pattern"===i.type&&(a=new RegExp(i.parameter).test(String(t))),"length"===i.type){const{min:l,length:c,max:u}=i.parameter;void 0!==c&&(a=String(t).length===c),void 0!==l&&(a=String(t).length>=l),void 0!==u&&(a=String(t).length<=u)}if("bounds"===i.type&&"number"==typeof t){const{min:l,minInclusive:c,max:u,maxInclusive:h}=i.parameter;let f=!0,d=!0;void 0!==l&&(f=c?t>=l:t>l),void 0!==u&&(d=h?t<=u:t<u),a=f&&d}return"prohibited"===this.cardinality&&(a=!a),"optional"===this.cardinality&&(a=!0),r.pass=a,r.pass}),this._components=e}addCheckResult(e,t){const i=t.findIndex(({parameter:s})=>s===e.parameter);-1!==i?t[i]=e:t.push(e)}getItemChecks(e,t,i,s){if(!("value"in i._localId)||"number"!=typeof i._localId.value)return null;let n=e.get(t);n||(n=new ft.jp,e.set(t,n));let r=n.get(i._localId.value);if(r&&s&&!r.pass)return null;if(!r){const c=[];r={guid:Array.isArray(i._guid)?void 0:i._guid.value,pass:!1,checks:c},Object.defineProperty(r,"pass",{get:()=>c.every(({pass:u})=>u)}),n.set(i._localId.value,r)}const a=[],l={facetType:this.facetType,cardinality:this.cardinality,checks:a,pass:!1};return Object.defineProperty(l,"pass",{get:()=>a.every(({pass:c})=>c)}),r.checks.push(l),l.checks}}const le=(o,e)=>{let t="";if(!e)return t;if("simple"===e.type&&(t=`<simpleValue>${e.parameter}</simpleValue>`),"enumeration"===e.type&&(t=`<xs:restriction base="xs:string">\n ${e.parameter.map(n=>`<xs:enumeration value="${n}" />`).join("\n")}\n </xs:restriction>`),"pattern"===e.type&&(t=`<xs:restriction base="xs:string">\n <xs:pattern value="${e.parameter}" />\n </xs:restriction>`),"bounds"===e.type){const{min:s,minInclusive:n,max:r,maxInclusive:a}=e.parameter;let l="";void 0!==s&&(l=`<xs:min${n?"Inclusive":"Exclusive"} value="${s}">`);let c="";void 0!==r&&(c=`<xs:max${a?"Inclusive":"Exclusive"} value="${r}">`),t=`<xs:restriction base="xs:double">\n ${l}\n ${c}\n </xs:restriction>`}if("length"===e.type){const{length:s,min:n,max:r}=e.parameter;let a="";void 0!==s&&void 0===n&&void 0===r&&(a=`<xs:length value="${s}" />`);let l="";void 0!==n&&void 0===s&&(l=`<xs:minLength value="${n}" />`);let c="";void 0!==r&&void 0===s&&(c=`<xs:maxLength value="${r}" />`),t=`<xs:restriction base="xs:string">\n ${a}\n ${l}\n ${c}\n </xs:restriction>`}return`<${o[0].toLowerCase()+o.slice(1)}>\n ${t}\n </${o[0].toLowerCase()+o.slice(1)}>`};class _c extends We{constructor(e,t){super(e),w(this,"facetType","Attribute"),w(this,"name"),w(this,"value"),this.name=t}serialize(e){const t=le("Name",this.name),i=le("Value",this.value);let s="";return"requirement"===e&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<attribute ${s}>\n ${t}\n ${i}\n</attribute>`}getEntities(){return(0,H.A)(function*(){})()}test(e,t){var i=this;return(0,H.A)(function*(s,n,r={skipIfFails:!0}){const a=i._components.get(ct);for(const[l,c]of Object.entries(s)){const u=a.list.get(l);if(!u)continue;const h=yield u.getItemsData([...c]);for(const f of h){const d=i.getItemChecks(n,l,f,r.skipIfFails);if(!d)continue;const g=Object.keys(f).filter(p=>{const x=i.evalRequirement(p,i.name,"Name");if(!x)return!1;const E=f[p];return!!Array.isArray(E)||(null===E||null===E.value?"optional"===i.cardinality||"prohibited"===i.cardinality:!(Array.isArray(E.value)&&0===E.value.length||"string"==typeof E.value&&""===E.value.trim())&&x)}),_=g.length>0;if(d.push({parameter:"Name",currentValue:_?g[0]:null,requiredValue:i.name,pass:"prohibited"===i.cardinality?!_:_}),i.value)if(g[0]){const p=f[g[0]];Array.isArray(p)||Array.isArray(p.value)?d.push({parameter:"Value",currentValue:null,requiredValue:i.value,pass:"prohibited"===i.cardinality}):i.evalRequirement(p.value,i.value,"Value",d)}else d.push({parameter:"Value",currentValue:null,requiredValue:i.value,pass:"prohibited"===i.cardinality})}}}).apply(this,arguments)}}class yc extends We{constructor(e,t){super(e),w(this,"facetType","Classification"),w(this,"system"),w(this,"value"),w(this,"uri"),this.system=t}serialize(e){const t=le("System",this.system),i=le("Value",this.value);let s="";return"requirement"===e&&(s+=`cardinality="${this.cardinality}"`,s+=this.uri?`uri=${this.uri}`:"",s+=this.instructions?`instructions="${this.instructions}"`:""),`<classification ${s}>\n ${t}\n ${i}\n</classification>`}getEntities(e,t){return(0,H.A)(function*(){})()}test(e,t){return(0,H.A)(function*(){})()}}class Js extends We{constructor(e,t){super(e),w(this,"facetType","Entity"),w(this,"name"),w(this,"predefinedType"),this.name=t}serialize(e){const t=le("Name",this.name),i=le("Name",this.predefinedType);let s="";return"requirement"===e&&(s+=`cardinality="${this.cardinality}"`,s+=this.instructions?`instructions="${this.instructions}"`:""),`<entity ${s}>\n ${t}\n ${i}\n</entity>`}getEntities(e,t){var i=this;return(0,H.A)(function*(){const s=i._components.get(ct),n=new Map;for(const[a,l]of s.list){if(!e.find(h=>h.test(a)))continue;const u=yield l.getCategories();for(const h of u){if(!(yield i.evalName(h)))continue;let d=n.get(a);d||(d=[],n.set(a,d)),d.push(h)}}const r={};if(yield Promise.all(Array.from(n.entries()).map(function(){var a=(0,H.A)(function*([l,c]){const u=s.list.get(l);if(!u)return;const h=c.map(y=>new RegExp(`^${y}$`)),f=yield u.getItemsOfCategories(h),d=Object.values(f).flat();r[l]=new Set(d)});return function(l){return a.apply(this,arguments)}}())),i.predefinedType)for(const[a,l]of Object.entries(r)){const c=s.list.get(a);if(!c)continue;const u=yield c.getItemsData([...l]);for(const h of u)"value"in h._localId&&(yield i.evalPredefinedType(a,h))&&Ft.append(t,a,h._localId.value)}else Ft.add(t,r)})()}test(e,t,i){var s=this;return(0,H.A)(function*(){const n=s._components.get(ct);for(const[r,a]of Object.entries(e)){const l=n.list.get(r);if(!l)continue;const c=yield l.getItemsData([...a]);for(const u of c){if(!("value"in u._category))continue;const h=s.getItemChecks(t,r,u,i.skipIfFails);h&&(yield s.evalName(u._category.value,h),yield s.evalPredefinedType(r,u,h))}}})()}evalName(e,t){var i=this;return(0,H.A)(function*(){return i.evalRequirement(e,i.name,"Name",t)})()}evalPredefinedType(e,t,i){var s=this;return(0,H.A)(function*(){if(!s.predefinedType||!("value"in t.PredefinedType))return null;const n="string"==typeof s.predefinedType.parameter&&"USERDEFINED"===s.predefinedType.parameter;let r=t.PredefinedType.value;if("USERDEFINED"===r&&!n){const c=Object.keys(t).find(u=>/^((?!Predefined).)*Type$/.test(u));if(c){const u=t[c];"value"in u&&(r=u.value)}else r="USERDEFINED"}if(!r){const c=s._components.get(ct).list.get(e);if(c&&"value"in t._localId){const[u]=yield c.getItemsData([t._localId.value],{relations:{IsTypedBy:{attributes:!0,relations:!1}}});if(Array.isArray(u.IsTypedBy)){const h=u.IsTypedBy[0];if(h&&"value"in h.PredefinedType&&(r=h.PredefinedType.value,"USERDEFINED"===r&&!n)){const d=Object.keys(h).find(y=>/^((?!Predefined).)*Type$/.test(y));if(d){const y=h[d];"value"in y&&(r=y.value)}else r="USERDEFINED"}}}}return s.evalRequirement(r,s.predefinedType,"PredefinedType",i)})()}}class vc extends We{constructor(e,t,i){super(e),w(this,"facetType","Property"),w(this,"propertySet"),w(this,"baseName"),w(this,"value"),w(this,"dataType"),w(this,"uri"),w(this,"_unsupportedTypes",["IFCCOMPLEXPROPERTY","IFCPHYSICALCOMPLEXQUANTITY"]),this.propertySet=t,this.baseName=i}serialize(e){const t=le("PropertySet",this.propertySet),i=le("BaseName",this.baseName),s=le("Value",this.value);let r="";return"requirement"===e&&(r+=`cardinality="${this.cardinality}"`,r+=this.uri?`uri=${this.uri}`:"",r+=this.instructions?`instructions="${this.instructions}"`:""),`<property ${this.dataType?`dataType=${this.dataType}`:""} ${r}>\n ${t}\n ${i}\n ${s}\n</property>`}getEntities(e,t){var i=this;return(0,H.A)(function*(){const s=i._components.get(ct);for(const[n,r]of s.list){if(!e.find(h=>h.test(n)))continue;const l=yield r.getItemsOfCategories([/PROPERTYSET/,/ELEMENTQUANTITY/]),c=Object.values(l).flat();if(0===c.length)continue;const u=yield r.getItemsData(c,{relations:{HasProperties:{attributes:!0,relations:!1},DefinesOcurrence:{attributes:!0,relations:!1}}});for(const h of u){if(!("value"in h._localId&&"value"in h._category&&"value"in h.Name&&Array.isArray(h.DefinesOcurrence)&&i.evalRequirement(h.Name.value,i.propertySet,"PropertySet")))continue;let d;if("IFCPROPERTYSET"===h._category.value&&(d="HasProperties"),"IFCELEMENTQUANTITY"===h._category.value&&(d="Quantities"),!d)continue;const y=h[d];if(Array.isArray(y))for(const g of y){const _=Object.keys(g),p=_.find(A=>/Name/.test(A));if(!p||!("value"in g[p]))continue;const x=g[p];if(!("value"in x)||!i.evalRequirement(x.value,i.baseName,"BaseName"))continue;if(i.value){const A=_.find(z=>/Value/.test(z));if(!A)continue;const M=g[A];if(!("value"in M)||!i.evalRequirement(M.value,i.value,"Value"))continue}const T=h.DefinesOcurrence.map(A=>"value"in A._localId&&"number"==typeof A._localId.value?A._localId.value:null).filter(A=>null!==A);Ft.append(t,n,...T)}}}})()}test(e,t){var i=this;return(0,H.A)(function*(s,n,r={skipIfFails:!0}){const a=i._components.get(ct);for(const[l,c]of Object.entries(s)){const u=a.list.get(l);if(!u)continue;const h=yield u.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 h){const d=i.getItemChecks(n,l,f,r.skipIfFails);if(!d)continue;const g=(yield i.getPsets(f)).filter(_=>!(!("value"in _.Name)||!i.evalRequirement(_.Name.value,i.propertySet,"PropertySet")||(d.push({currentValue:_.Name.value,parameter:"PropertySet",pass:!0,requiredValue:i.propertySet}),0)));if(0!==g.length)for(const _ of g){const p=i.getPropertyListName(_);if(!p)continue;const x=_[p];if(!Array.isArray(x)){d.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:i.baseName});continue}const E=x.filter(T=>!(!("value"in T._category)||!("value"in T.Name)||i._unsupportedTypes.includes(T._category.value)||!i.evalRequirement(T.Name.value,i.baseName,"BaseName")||(d.push({currentValue:T.Name.value,parameter:"BaseName",pass:!0,requiredValue:i.baseName}),0)));if(0!==E.length)for(const T of E)i.evalValue(T,d),i.evalDataType(T,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(e){let t;return"value"in e._category&&("IFCPROPERTYSET"===e._category.value&&(t="HasProperties"),"IFCELEMENTQUANTITY"===e._category.value&&(t="Quantities")),t}getValueKey(e){return Object.keys(e).find(t=>/Value/.test(t)||/Values/.test(t))}getTypePsets(e){if(!Array.isArray(e.IsTypedBy))return[];const[t]=e.IsTypedBy;return t&&Array.isArray(t.HasPropertySets)?t.HasPropertySets:[]}getPsets(e){var t=this;return(0,H.A)(function*(){const i=t.getTypePsets(e);if(!Array.isArray(e.IsDefinedBy))return i;const s=[];for(const n of e.IsDefinedBy){if(!("value"in n.Name))continue;const r=n.Name.value,a=t.getPropertyListName(n);if(!r||!a)continue;const l=i.find(c=>"value"in c.Name&&c.Name.value===r);if(l&&Array.isArray(l.HasProperties)&&Array.isArray(n.HasProperties))for(const c of l.HasProperties){if(!("value"in c.Name))continue;const u=c.Name.value;n.HasProperties.find(f=>"value"in f.Name&&f.Name.value===u)||n.HasProperties.push(c)}s.push(n)}return s})()}evalValue(e,t){const i=this.getValueKey(e),s=e[i];if(!("value"in s))return!1;if(this.value){if(!i)return t?.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",t)}return!i||"string"!=typeof s.value||""!==s.value.trim()||(t?.push({parameter:"Value",currentValue:"",pass:!1,requiredValue:this.value}),!1)}evalDataType(e,t){if(!this.dataType)return!0;const i=this.getValueKey(e);return i&&"value"in e[i]?this.evalRequirement(e[i].type??null,{type:"simple",parameter:this.dataType},"DataType",t):(t?.push({parameter:"DataType",currentValue:null,pass:!1,requiredValue:this.dataType}),!1)}evalURI(){return!0}}class wc extends We{constructor(){super(...arguments),w(this,"_ifcMaterialEntities",[/^IFCMATERIALLAYERSETUSAGE$/,/^IFCMATERIALCONSTITUENTSET$/,/^IFCMATERIAL$/,/^IFCMATERIALLIST$/]),w(this,"facetType","Material"),w(this,"value"),w(this,"uri")}serialize(e){if(!this.value||!this.uri)return"<material />";const t=le("Value",this.value);let i="";return"requirement"===e&&(i+=`cardinality="${this.cardinality}"`,i+=this.uri?`uri=${this.uri}`:"",i+=this.instructions?`instructions="${this.instructions}"`:""),`<material ${i}>\n ${t}\n</material>`}getEntities(e,t){var i=this;return(0,H.A)(function*(){const s=i._components.get(ct);for(const[n,r]of s.list){if(!e.find(h=>h.test(n)))continue;const l=yield r.getItemsOfCategories(i._ifcMaterialEntities),c=Object.values(l).flat();if(0===c.length)continue;const u=yield r.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 h of u){if(!("value"in h._localId&&"value"in h._category&&Array.isArray(h.AssociatedTo)&&i.hasValidMaterial(h)))continue;const d=h.AssociatedTo.map(y=>"value"in y._localId&&y._localId.value?y._localId.value:null).filter(y=>null!==y);Ft.append(t,n,...d)}}})()}test(e,t){var i=this;return(0,H.A)(function*(s,n,r={skipIfFails:!0}){const a=i._components.get(ct);for(const[l,c]of Object.entries(s)){const u=a.list.get(l);if(!u)continue;const h=yield u.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 h){const d=i.getItemChecks(n,l,f,r.skipIfFails);if(d){if(!Array.isArray(f.HasAssociations)){d.push({parameter:null,currentValue:null,requiredValue:i.value,pass:!1});continue}for(const y of f.HasAssociations)if(i._ifcMaterialEntities.some(_=>"value"in y._category&&_.test(y._category.value))&&i.hasValidMaterial(y,d))break}}}}).apply(this,arguments)}hasValidMaterial(e,t){let i=!1;if("value"in e._category&&"IFCMATERIAL"===e._category.value)this.evalValue(e,t)&&(i=!0);else for(const[s,n]of Object.entries(e))if(["ForLayerSet","MaterialLayers","Material","MaterialConstituents","Materials"].includes(s)&&Array.isArray(n))for(const r of n)if("value"in r._category&&"IFCMATERIAL"===r._category.value){if(this.evalValue(r,t)){i=!0;break}}else if(this.hasValidMaterial(r)){i=!0;break}return i}evalValue(e,t){if(!this.value)return t?.push({parameter:null,currentValue:e.Name&&"value"in e.Name?e.Name.value:null,pass:!0}),!0;if(!("value"in e._category)||"IFCMATERIAL"!==e._category.value)return null;let i=!1;return e.Name&&"value"in e.Name&&(i=this.evalRequirement(e.Name.value,this.value,"Value",t)),i||(e.Category&&"value"in e.Category&&(i=this.evalRequirement(e.Category.value,this.value,"Value",t)),i)}}class bc extends We{constructor(e,t){super(e),w(this,"facetType","PartOf"),w(this,"_entityFacet"),w(this,"_entity"),w(this,"relation"),w(this,"cardinality","required"),this._entity=t,this._entityFacet=new Js(e,t.name),this._entityFacet.predefinedType=t.predefinedType}set entity(e){this._entity=e;const{name:t,predefinedType:i}=e;this._entityFacet=new Js(this._components,t),this._entityFacet.predefinedType=i}get entity(){return this._entity}serialize(){return""}getEntities(e,t){return(0,H.A)(function*(){})()}test(e){return(0,H.A)(function*(){})()}}class xc{constructor(e,t,i){w(this,"name"),w(this,"ifcVersion",new Set),w(this,"identifier",Yt.create()),w(this,"description"),w(this,"instructions"),w(this,"requirementsDescription"),w(this,"applicability",new ft.PG),w(this,"requirements",new ft.PG),w(this,"components"),this.components=e,this.name=t;for(const s of i)this.ifcVersion.add(s)}set(e){const t=e,i=this;for(const n in e)"identifier"!==n&&n in this&&(i[n]=t[n]);return this.components.get(Cc).list.set(this.identifier,this),this}test(e){var t=this;return(0,H.A)(function*(i,s={skipIfFails:!0}){const n=new ft.jp;if(0===t.requirements.size)return n;const r={},a=[];for(const c of t.applicability)a.push(c.getEntities(i,r));yield Promise.all(a);const l=[];for(const c of t.requirements)l.push(c.test(r,n,s));return yield Promise.all(l),n}).apply(this,arguments)}serialize(){const e=`name="${this.name}"`,t=this.identifier?`identifier="${this.identifier}"`:"",i=this.description?`description="${this.description}"`:"",s=this.instructions?`instructions="${this.instructions}"`:"";return`<specification ifcVersion="${[...this.ifcVersion].join(" ")}" ${e} ${t} ${i} ${s}>\n <applicability minOccurs="1" maxOccurs="unbounded">\n ${[...this.applicability].map(r=>r.serialize("applicability")).join("\n")}\n </applicability>\n <requirements>\n ${[...this.requirements].map(r=>r.serialize("requirement")).join("\n")}\n </requirements>\n </specification>`}}const te=o=>{if(!o)return;const e={};if("simpleValue"in o&&(e.type="simple",e.parameter=o.simpleValue),"restriction"in o){const t=o.restriction,i=Object.keys(t);if("pattern"in t&&(e.type="pattern",e.parameter=t.pattern.value),"enumeration"in t){e.type="enumeration";const s=t.enumeration.map(({value:n})=>t.base.includes("string")?String(n):t.base.includes("integer")||t.base.includes("double")?Number(n):n);e.parameter=s}if(i.some(s=>["minInclusive","minExclusive","maxInclusive","maxExclusive"].includes(s))){e.type="bounds";const s={},n=i.find(a=>a.includes("min")),r=i.find(a=>a.includes("max"));n&&(s.minInclusive="minInclusive"===n,s.min=t[n].value),r&&(s.maxInclusive="maxInclusive"===r,s.max=t[r].value),e.parameter=s}if(i.some(s=>["minLength","length","maxLength"].includes(s))){e.type="length";const s={};void 0!==t.length&&(s.length=t.length.value),void 0!==t.minLength&&(s.min=t.minLength.value),void 0!==t.maxLength&&(s.max=t.maxLength.value),e.parameter=s}}return void 0!==e.parameter?e:void 0},Lr=(o,e)=>{const t=[];for(const i of e){const n=te(i.name);if(!n)continue;const r=new Js(o,n);i.cardinality&&(r.cardinality=i.cardinality),r.predefinedType=te(i.predefinedType),r.instructions=i.instructions,t.push(r)}return t},Vr=(o,e)=>{const t=[];for(const i of e){const n=te(i.name);if(!n)continue;const r=new _c(o,n);i.cardinality&&(r.cardinality=i.cardinality),r.value=te(i.value),r.instructions=i.instructions,t.push(r)}return t},Ur=(o,e)=>{const t=[];for(const i of e){const s=new wc(o);i.cardinality&&(s.cardinality=i.cardinality);const n=te(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,t.push(s)}return t},$r=(o,e)=>{const t=[];for(const i of e){const n=i.baseName,r=te(i.propertySet),a=te(n);if(!a||!r)continue;const l=new vc(o,r,a);i.cardinality&&(l.cardinality=i.cardinality);const c=te(i.value);l.value=c,l.dataType=i.dataType,l.uri=i.uri,l.instructions=i.instructions,t.push(l)}return t},jr=(o,e)=>{const t=[];for(const i of e){const n=te(i.system);if(!n)continue;const r=new yc(o,n);i.cardinality&&(r.cardinality=i.cardinality);const a=te(i.value);"simple"===a?.type&&(a.parameter=String(a.parameter)),"enumeration"===a?.type&&Array.isArray(a.parameter)&&(a.parameter=a.parameter.map(String)),r.value=a,r.uri=i.uri,r.instructions=i.instructions,t.push(r)}return t},Hr=(o,e)=>{const t=[];for(const i of e){const s=te(i.entity.name);if(!s)continue;const n=te(i.entity.predefinedType),r=new bc(o,{name:s,predefinedType:n});r.relation=i.relation,i.cardinality&&(r.cardinality=i.cardinality),r.instructions=i.instructions,t.push(r)}return t},tn=class vn extends Tt{constructor(e){super(e),w(this,"enabled",!0),w(this,"IDSInfo"),w(this,"list",new ft.jp),e.add(vn.uuid,this)}getModelIdMap(e){const t={},i={};for(const[s,n]of e){const a=[...n].filter(([,u])=>u.pass).map(([u])=>u);Ft.append(t,s,...a);const c=[...n].filter(([,u])=>!u.pass).map(([u])=>u);Ft.append(i,s,...c)}return{pass:t,fail:i}}create(e,t,i){const s=new xc(this.components,e,t);return i&&(s.identifier=i),this.list.set(s.identifier,s),s}load(e){const t=[],i=vn.xmlParser.parse(e).ids,{specifications:s,info:n}=i;if(this.IDSInfo={...n},s&&s.specification){const r=Array.isArray(s.specification)?s.specification:[s.specification];for(const a of r){const{name:l,ifcVersion:c,description:u,instructions:h,identifier:f}=a;if(!l||!c)continue;const d=[],y=[],{applicability:g,requirements:_}=a;if(g){const{maxOccurs:E,...T}=g,A=Array.isArray(T)?T:[T];for(const M of A)for(const S in M){const z=Array.isArray(M[S])?M[S]:[M[S]];if("entity"===S){const O=Lr(this.components,z);d.push(...O)}if("attribute"===S){const O=Vr(this.components,z);d.push(...O)}if("material"===S){const O=Ur(this.components,z);d.push(...O)}if("classification"===S){const O=jr(this.components,z);d.push(...O)}if("property"===S){const O=$r(this.components,z);d.push(...O)}if("partOf"===S){const O=Hr(this.components,z);d.push(...O)}}}let p;if(_){const{maxOccurs:E,...T}=_;p=_.description;const A=Array.isArray(T)?T:[T];for(const M of A)for(const S in M){const z=Array.isArray(M[S])?M[S]:[M[S]];if("entity"===S){const O=Lr(this.components,z);y.push(...O)}if("attribute"===S){const O=Vr(this.components,z);y.push(...O)}if("material"===S){const O=Ur(this.components,z);y.push(...O)}if("classification"===S){const O=jr(this.components,z);y.push(...O)}if("property"===S){const O=$r(this.components,z);y.push(...O)}if("partOf"===S){const O=Hr(this.components,z);y.push(...O)}}}const x=this.create(l,c.split(/\s+/),f);x.description=u,x.instructions=h,x.requirementsDescription=p,x.applicability.add(...d),x.requirements.add(...y),t.push(x)}}return t}export(e,t=this.list.values()){const i=t??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 ${js.release} (https://github.com/thatopen/engine_components) --\x3e\n <info>\n <title>${e.title}</title>\n ${e.copyright?`<copyright>${e.copyright}</copyright>`:""}\n ${e.version?`<version>${e.version}</version>`:""}\n ${e.description?`<description>${e.description}</description>`:""}\n ${e.author?`<author>${e.author}</author>`:""}\n ${e.date?`<date>${e.date.toISOString().split("T")[0]}</date>`:""}\n ${e.purpose?`<purpose>${e.purpose}</purpose>`:""}\n ${e.milestone?`<milestone>${e.milestone}</milestone>`:""}\n </info>\n <specifications>\n ${[...i].map(n=>n.serialize()).join("\n")}\n </specifications>\n</ids>`}};w(tn,"uuid","9f0b9f78-9b2e-481a-b766-2fbfd01f342c"),w(tn,"xmlParser",new vs({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 Cc=tn;w(class xo extends Tt{constructor(e){super(e),w(this,"enabled",!0),e.add(xo.uuid,this)}static distanceFromPointToLine(e,t,i,s=!1){const n=new b.cZY,r=new b.Pq0;return n.set(t,i),n.closestPointToPoint(e,s,r),r.distanceTo(e)}round(e){e.x=Math.trunc(1e3*e.x)/1e3,e.y=Math.trunc(1e3*e.y)/1e3,e.z=Math.trunc(1e3*e.z)/1e3}getVolumeFromFragments(e){var t=this;return(0,H.A)(function*(){return console.warn("getVolumeFromFragments is deprecated. Use getItemsVolume instead."),t.getItemsVolume(e)})()}getItemsVolume(e){var t=this;return(0,H.A)(function*(){let i=0;const s=t.components.get(ct);for(const[n,r]of Object.entries(e)){const a=s.list.get(n);a&&(i+=(yield a.getItemsVolume([...r])))}return i})()}static convertUnits(e,t,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[t]||!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(e*(n[t]/n[i])*l)/l}},"uuid","267ca032-672f-4cb0-afa9-d24e904f39d6");let Yr=(()=>{class o extends Tt{static uuid="ab45d0a7-feea-4afc-927c-80832dae76dd";enabled=!0;_fragments=null;set fragments(t){this._fragments=t}geometries=new ft.jp;get(t,i){var s=this;return(0,H.A)(function*(){const{material:n,coordinate:r,applyTransformation:a}={coordinate:!0,applyTransformation:!0,...i},l=new ft.jp;for(const[c,u]of Object.entries(t)){const h=s._fragments.models.list.get(c);if(!h)continue;const f=s.getModelMeshes(c);for(const d of u){let y=l.get(c);y||(y=new ft.jp,l.set(c,y));let g=f.get(d);if(g&&g.length>0){const x=[];for(const[,{geometry:E}]of g.entries()){const T=yield s.createMesh(h,E,{material:n,applyTransformation:a,coordinate:r});x.push(T)}y.set(d,x);continue}g=[],f.set(d,g);const[_]=yield h.getItemsGeometry([d]);if(!_)continue;const p=[];for(const x of _){const E=s.createGeometry(x);if(!E)continue;const{geometry:T}=E;g.push(E);const A=yield s.createMesh(h,T,{material:n,applyTransformation:a,coordinate:r});p.push(A)}y.set(d,p)}}return l})()}getModelMeshes(t){let i=this.geometries.get(t);return i||(i=new ft.jp,this.geometries.set(t,i)),i}remove(t=[...this.geometries.keys()]){for(const i of t){const s=this.geometries.get(i);if(s){for(const[,n]of s)for(const{geometry:r}of n)r.dispose();this.geometries.delete(i)}}}onDisposed=new X;dispose(t=!0){this.remove(),t&&this.geometries.dispose(),this.onDisposed.trigger(o.uuid)}getMeshesFromResult(t){const i=[];for(const s of t.values())for(const n of s.values())i.push(...n);return i}createGeometry(t){const{positions:i,indices:s,normals:n,transform:r}=t;if(!(i&&s&&n))return null;const a=new b.LoY;return a.setAttribute("position",new b.THS(i,3)),a.setAttribute("normal",new b.THS(n,3,!0)),a.setIndex(new b.THS(s,1)),a.applyMatrix4(r),{geometry:a,transform:r}}createMesh(t,i,s){var n=this;return(0,H.A)(function*(){const{material:r,applyTransformation:a,coordinate:l}={applyTransformation:!0,coordinate:!0,...s},c=n.components.get(ct),u=new b.eaF(i,r);if(u.applyMatrix4(t.object.matrixWorld),a||u.position.set(0,0,0),l&&c.baseCoordinationModel!==t.modelId){const h=yield t.getCoordinationMatrix();c.applyBaseCoordinateSystem(u,h)}return u})()}}return o})(),en=(()=>{class o extends Tt{static uuid="2695289f-e6c1-4980-919e-88b7591d7ea3";enabled=!0;originalColors=new Map;_ghostColor=new b.Q1f("white");_ghostedMaterials=[];set ghostColor(t){this._ghostColor=t}_ghostApplied=!1;get ghostApplied(){return this._ghostApplied}_world;set world(t){this._world=t,this._initEventListeners()}get ghostedMaterials(){return this._ghostedMaterials}_fragments;set fragments(t){this._fragments=t,this._initEventListeners()}onDisposed=new X;constructor(t){super(t)}dispose(){this.onDisposed.trigger(o.uuid),this._ghostedMaterials=[]}setModelTransparent(t){const i=[...t.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[t,i]of this.originalColors){const{color:s,transparent:n,opacity:r}=i;t.transparent=n,t.opacity=r,"color"in t?t.color.setHex(s):t.lodColor.setHex(s),t.needsUpdate=!0}this.originalColors.clear(),this._ghostedMaterials=[],this._ghostApplied=!1}toggleGhost(t){this.originalColors.size?this.restoreModelMaterials():this.setModelTransparent(t)}_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:t})=>{console.log(`Model ${t.modelId} is ready`),setTimeout(()=>{this.enabled?(console.log("GHOST"),this.setModelTransparent(this._fragments)):this.restoreModelMaterials()},1500)}))}}return o})(),Zr=(()=>{class o extends Tt{static uuid="3abd8228-7bff-4ff6-ac30-53f97bdc8ae6";enabled=!0;_fragments;_isolated={};_hidden={};_colorOverrides={};_overrides={};onDisposed=new X;constructor(t){super(t)}set fragments(t){this._fragments=t}_world;set world(t){this._world=t}get colorOverrides(){return this._colorOverrides}applyModelOverrides(t,i){var s=this;return(0,H.A)(function*(){s._overrides[t.modelId]=i,yield s._applyModelOverrides(t)})()}update(t){var i=this;return(0,H.A)(function*(){(void 0===t?i.fragments.models.list:[t]).forEach(n=>{i._appendOnModel(n)})})()}setNonColoredVisibility(t){var i=this;return(0,H.A)(function*(){if(void 0===i._fragments)return;const s=i._colorOverrides;console.log(s);for(const n of Object.keys(s)){const r=i._fragments.models.list.get(n);if(void 0===r)return;t?yield i._setVisibilityAll(r,!0):(yield i._setVisibilityAll(r,!1),r.setVisible([...s[n]],!0))}})()}dispose(){this.onDisposed.trigger(o.uuid)}_getLocalIdsByType(t,i){var s=this;return(0,H.A)(function*(){if(void 0===s._fragments)return null;const n=yield t.getItemsOfCategories(i);return new Set([...Object.values(n).flat()])})()}_applyModelOverrides(t){var i=this;return(0,H.A)(function*(){if(void 0!==i._fragments&&void 0!==i._overrides[t.modelId]){try{yield Promise.all([i._updateIsolatedMap(t),i._updateHiddenMap(t),i._updateColorOverrides(t)])}catch(n){console.log(n)}t&&i._appendOnModel(t)}})()}_appendOnModel(t){var i=this;return(0,H.A)(function*(){const s=i._overrides[t.modelId];if(void 0===s)return;const n=i._isolated[t.modelId],r=i._hidden[t.modelId];n?.size?(yield i._setVisibilityAll(t,!1),t?.setVisible([...n],!0)):r?.size&&t?.setVisible([...r],!1);for(const a of s.colorOverrides){const l={color:new b.Q1f(a.color),renderedFaces:ft.eB.TWO,opacity:a.opacity,transparent:!1,customId:`${t.modelId}_${a.color}`};yield t.highlight(a.ids,l)}})()}_updateIsolatedMap(t){var i=this;return(0,H.A)(function*(){const s=t.modelId,n=i._overrides[s];if(i._isolated[s]=new Set,n.isolatedTypes.length){const r=yield i._getLocalIdsByType(t,n.isolatedTypes);r&&r.forEach(a=>i._isolated[s].add(a))}n.isolated.length&&n.isolated.forEach(r=>i._isolated[s].add(r))})()}_updateHiddenMap(t){var i=this;return(0,H.A)(function*(){const s=t.modelId,n=i._overrides[s];if(i._hidden[s]=new Set,n.hiddenTypes.length){const r=yield i._getLocalIdsByType(t,n.hiddenTypes);r&&r.forEach(a=>i._hidden[s].add(a))}n.hidden.length&&n.hidden.forEach(r=>i._hidden[s].add(r))})()}_updateColorOverrides(t){var i=this;return(0,H.A)(function*(){const s=t.modelId;i._colorOverrides[t.modelId]=new Set,i._overrides[s].colorOverrides.forEach(r=>{r.ids.forEach(a=>i._colorOverrides[t.modelId].add(a))})})()}_setVisibilityAll=function(){var t=(0,H.A)(function*(i,s){const r=(yield i.getItemsWithGeometry()).map(l=>l.getLocalId()),a=(yield Promise.all(r)).filter(l=>null!==l);yield i.setVisible(a,s)});return function(i,s){return t.apply(this,arguments)}}()}return o})();const Wr=(o,e)=>{const t={...o};return Object.keys(e).forEach(i=>{t[i]=new Set([...t[i]||[],...e[i]])}),t},qr=function(){var o=(0,H.A)(function*(e,t,i,s={}){const n=[];for(const[,l]of t.models.list){const c=yield l.raycast(i);if(c){const u={};u[l.modelId]=new Set,u[l.modelId].add(c.localId),n.push({...c,idMap:u})}}if(0===n.length)return Gr(t,s,!0),null;let r=n[0],a=r.distance;for(let l=1;l<n.length;l++)n[l].distance<a&&(a=n[l].distance,console.log(a),r=n[l]);return e.get(en).ghostApplied&&!((o,e)=>{if(null===e)return!1;let t=!1;return Object.keys(o).forEach(i=>{e[i].forEach(s=>{o[i].has(s)&&(t=!0)})}),t})(e.get(Zr).colorOverrides,r.idMap)?(Gr(t,s=Wr(s,r.idMap),!1),qr(e,t,i,s)):r});return function(t,i,s){return o.apply(this,arguments)}}();function Gr(o,e,t){for(const i of Object.keys(e))o.models.list.get(i)?.setVisible([...e[i]],t)}class Pc{hoveredElement=new X}let sn=(()=>{class o extends Tt{static uuid="26fbd870-b1b2-4b71-b747-4063d484de1b";HOVERER_OPACITY_KEY="_maxHoverOpacity";_hoverTimeout=null;_meshes=new ft.PG;_localId=null;_fadeAnimation=null;_world=null;_fragments=null;set world(t){if(t){this._world=t,this.setupEvents(!0);for(const i of this._meshes)t.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 Pc;set fragments(t){this._fragments=t}_enabled=!1;set enabled(t){this.setupEvents(t),this._enabled=t}get enabled(){return this._enabled}_material=new b.V9B({color:16777215,transparent:!0,opacity:.5,depthTest:!1,userData:{[this.HOVERER_OPACITY_KEY]:.5}});set material(t){t.userData[this.HOVERER_OPACITY_KEY]=t.opacity;for(const i of this._meshes)i.material=t;this._material.dispose(),this._material=t}get material(){return this._material}onDisposed=new X;duration=200;animation=!0;constructor(t){super(t),t.add(o.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(t){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),t&&(i.addEventListener("mousemove",this.onMouseMove),i.addEventListener("mouseleave",this.onMouseLeave))}mouseStopTimeout=null;onMouseMove=t=>{null!==this.mouseStopTimeout&&clearTimeout(this.mouseStopTimeout),this.mouseStopTimeout=window.setTimeout(()=>this.hover(t),50)};onMouseLeave=()=>{this._meshes.clear()};animate=()=>{if(!(this._fadeAnimation&&this.animation&&this.material.transparent))return;const{startTime:t,duration:i,fadeIn:s}=this._fadeAnimation,n=Date.now()-t,r=Math.min(n/i,1),l=this.material.userData[this.HOVERER_OPACITY_KEY];this.material.opacity=(s?r:1-r)*(void 0!==l?l:1),r<1?requestAnimationFrame(this.animate):(s||this._meshes.clear(),this._fadeAnimation=null)};hover(t){var i=this;return(0,H.A)(function*(){if(!i.enabled||!i.world||!i._fragments)return;const s=new b.I9Y(t.clientX,t.clientY),n=yield qr(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(en).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:r,localId:a}=n;i._localId!==a&&(i._meshes.clear(),i._localId=a,i._hoverTimeout=window.setTimeout((0,H.A)(function*(){const l={[r.modelId]:new Set([a])},c=i.components.get(Yr);c.fragments=i._fragments;const u=yield c.get(l);for(const[,h]of u.entries()){const f=[...h.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(r.object.matrixWorld),i._meshes.add(d)}i._fadeAnimation={startTime:Date.now(),duration:i.duration,fadeIn:!0},i.animate()}),100))})()}_setCursor(t){const i=this._world.renderer?.three.domElement;i&&(i.style.cursor=t?"pointer":"default")}clear(){this._meshes.clear()}dispose(){this._enabled=!1,this._meshes.clear(),this._fadeAnimation=null,this._hoverTimeout=null,this.onDisposed.trigger()}}return o})();var Sc=mt(9595);const Ic=function(){var o=(0,H.A)(function*(e,t){const i=Object.keys(t)[0];if(i&&e.models.list.get(i)){const s=e.models.list.get(i),[n]=yield s.getItemsData([...t[i]],{attributesDefault:!1,attributes:["Name","NominalValue"],relations:{IsDefinedBy:{attributes:!0,relations:!0},DefinesOcurrence:{attributes:!1,relations:!1}}});return n||null}return null});return function(t,i){return o.apply(this,arguments)}}();var nn=mt(1452);class Mc{clickedElement=new X;clickedCanvas=new X;selection=new X}let Xr=(()=>{class o extends Tt{static uuid="b7e0b697-172f-43db-b530-d775a2a34d55";HIGHLIGHT_ID="cue_selection";enabled=!0;multiSelect=!1;resetOnCanvasClick=!0;_fragments=null;set fragments(t){this._fragments=t}hoveredElement=null;selectedElements=null;set styles(t){const i=this.components.get(nn.TF);i.fillOpacity=t.fillOpacity,i.fillColor=t.fillColor,i.color=t.outlineColor}onDisposed=new X;events=new Mc;constructor(t){super(t),this._initEventListeners()}dispose(){this.hoveredElement=null,this.selectedElements=null,this.onDisposed.trigger(o.uuid)}_initEventListeners(){var t=this;this.components.get(sn).events.hoveredElement.add(function(){var n=(0,H.A)(function*(r){if(!r)return void(t.hoveredElement=null);const a=r.localId,l=r.fragments.modelId;t.hoveredElement={[l]:new Set([a])}});return function(r){return n.apply(this,arguments)}}()),Sc.B.getInstance().events.addListener("shortPressedLeft",(0,H.A)(function*(){if(!t.enabled)return;const n=t.components.get(nn.TF);n.clean();const r=t.hoveredElement;if(!r)return t.resetOnCanvasClick&&(t.selectedElements=null,t.events.selection.trigger(null),n.clean()),void t.events.clickedCanvas.trigger();const a=yield Ic(t._fragments,r);a&&t.events.clickedElement.trigger(a);const l=Object.keys(r)[0],c=[...r[l]][0];let u=t.selectedElements?Object.assign({},t.selectedElements):null;u=t.multiSelect?u?t.resetOnCanvasClick&&u&&u[l]?.has(c)?((o,e)=>{const t={...o};return Object.keys(e).forEach(i=>{const s=e[i];t[i]&&(t[i]=new Set([...t[i]||[]].filter(n=>!s.has(n))),0===t[i].size&&delete t[i])}),0===Object.keys(t).length?null:t})(u,r):Wr(u,r):r:t.resetOnCanvasClick&&u&&u[l]?.has(c)?null:r,t.selectedElements=u,t.events.selection.trigger(u),u?n.addItems(u):n.clean()}))}}return o})(),Oc=(()=>{class o extends Tt{_world;_fragments;set world(t){this._world=t,t&&this.getRenderer().postproduction.excludedObjectsPass.addExcludedMaterial(this._points.material)}get world(){return this._world}set fragments(t){this._fragments=t}styles=new ft.PG;outlinePositions=!1;_mesh=null;get _points(){return this._mesh||(this._mesh=new b.ONl(new b.LoY,new b.BH$({size:10,sizeAttenuation:!1,depthTest:!1}))),this._mesh}get enabled(){return!(!this.world||this.world.isDisposing)&&this.getRenderer().postproduction.outlinesEnabled}set enabled(t){this.world&&!this.world.isDisposing&&(this.getRenderer().postproduction.outlinesEnabled=t,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(t){this.getRenderer().postproduction.outlinePass.outlineColor.copy(t),this._points.material.color.copy(t)}get thickness(){return this.getRenderer().postproduction.outlinePass.thickness}set thickness(t){this.getRenderer().postproduction.outlinePass.thickness=t}get fillColor(){return this.getRenderer().postproduction.outlinePass.fillColor}set fillColor(t){this.getRenderer().postproduction.outlinePass.fillColor.copy(t)}get fillOpacity(){return this.getRenderer().postproduction.outlinePass.fillOpacity}set fillOpacity(t){this.getRenderer().postproduction.outlinePass.fillOpacity=t}onDisposed=new X;static uuid="2fd3bcc5-b3b6-4ded-9f64-f47a02854a10";_meshes=[];_map={};_activeStyles=new Set;constructor(t){super(t),t.add(o.uuid,this)}update(){var t=this;return(0,H.A)(function*(i=t._map){if(i===t._map&&t.cleanMeshes(),t.outlinePositions&&t.updatePoints(),0===Object.keys(i).length)return;const n=t.getRenderer().postproduction.outlinePass,a=yield t.components.get(Yr).get(i);for(const l of Object.keys(i)){const c=t._fragments?.models.list.get(l);if(c)for(const[,u]of a.entries()){const h=[...u.values()].flat();for(const f of h)f.position.set(0,0,0),f.rotation.set(0,0,0),f.scale.set(1,1,1),f.applyMatrix4(c.object.matrixWorld),t._meshes.push(f),n.scene.add(f)}}}).apply(this,arguments)}addItems(t){var i=this;return(0,H.A)(function*(){Ft.add(i._map,t),yield i.update(t)})()}removeItems(t){var i=this;return(0,H.A)(function*(){Ft.remove(i._map,t),yield i.update()})()}clean(){this._map={},this._activeStyles.clear(),this.cleanMeshes(),this._mesh&&this.components.get(Je).destroy(this._mesh,!0,!0),this._mesh=null}dispose(){this.styles.clear(),this.clean(),this.onDisposed.trigger(o.uuid)}cleanMeshes(){for(const t of this._meshes)t.removeFromParent();this._meshes=[]}updatePoints(){var t=this;return(0,H.A)(function*(){let i=0;for(const[,r]of Object.entries(t._map))i+=r.size;t._points.geometry.setAttribute("position",new b.qtW(new Float32Array(3*i),3));const n=yield t.components.get(ct).getPositions(t._map);for(let r=0;r<n.length;r++){const{x:a,y:l,z:c}=n[r];t._points.geometry.attributes.position.array[3*r]=a,t._points.geometry.attributes.position.array[3*r+1]=l,t._points.geometry.attributes.position.array[3*r+2]=c}t._points.geometry.attributes.position.needsUpdate=!0})()}getRenderer(){if(!this.world)throw new Error("You must set a world to use the outliner!");const t=this.world.renderer;if(!t.postproduction)throw new Error("The world given to the outliner must use the postproduction renderer.");return t}}return o})();var Fc=mt(893);function Nc(o){return rn.apply(this,arguments)}function rn(){return(rn=(0,H.A)(function*(o){console.warn("Set double sided is not implemented"),console.log(o)})).apply(this,arguments)}function on(){return(on=(0,H.A)(function*(o){try{const e=new URL(o,window.location.href);if(e.origin===window.location.origin)return o;const t=yield fetch(e.href);if(!t.ok)throw new Error(`HTTP ${t.status}`);const i=yield t.text(),s=new Blob([i],{type:"application/javascript"});return URL.createObjectURL(s)}catch(e){return console.warn("[BIM] Could not fetch worker as blob, using direct URL:",e),o}})).apply(this,arguments)}const Rc=(o,e,t="./js/worker.mjs")=>{const i=new ft._i(t),s=o.get(Zr);return s.fragments=i,s.world=e,e.camera.controls.addEventListener("rest",()=>i.update(!0)),e.camera.controls.addEventListener("update",()=>i.update()),i.models.list.onItemSet.add(function(){var n=(0,H.A)(function*({value:r}){const a=r.object.userData.overrides;r.useCamera(e.camera.three),e.scene.three.add(r.object),to(a)&&(r.object.visible=!1,yield Lc(1),yield s.applyModelOverrides(r,a),r.object.visible=!0),yield i.update(!0),r.object.visible=!0,to(a)||(yield s.applyModelOverrides(r,a),yield i.update(!0)),yield i.update(!0)});return function(r){return n.apply(this,arguments)}}()),e.onCameraChanged.add(n=>{for(const[,r]of i.models.list)r.useCamera(n.three);i.update(!0)}),i},Bc=function(){var o=(0,H.A)(function*(e,t,i){void 0===i&&(i=Jr(e));const s=t.map(a=>a.id),n=t.filter(a=>!i.includes(a.id)).filter(a=>!0===a.visible),r=i.filter(a=>!s.includes(a));return n.length&&(console.info(`Loading ${n.length} model(s)`),yield Qr(e,n)),r.length&&(console.info(`Disposing ${n.length} model(s)`),yield Kr(e,r)),[...e.models.list.values()]});return function(t,i,s){return o.apply(this,arguments)}}(),Qr=function(){var o=(0,H.A)(function*(e,t){const i=[];for(const s of t)try{console.info(`Loading ${s.name} (${s.id})...`);const r=yield(yield fetch(s.fileURL)).arrayBuffer();console.info("Got model buffer...");const a=yield e.load(r,{modelId:s.id,userData:{overrides:s.overrides}});console.info("Model loaded into fragments..."),s.makeAllMaterialsDoubleSided&&(yield Nc(a)),yield e.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(t,i){return o.apply(this,arguments)}}(),Kr=function(){var o=(0,H.A)(function*(e,t){void 0===t&&(t=Jr(e));const i=[];for(const s of t)i.push(e.disposeModel(s));yield Promise.all(i)});return function(t,i){return o.apply(this,arguments)}}(),Jr=o=>[...o.models?.list.values()].map(i=>i.modelId),to=o=>!(!o.isolated.length&&!o.isolatedTypes.length),Lc=function(){var o=(0,H.A)(function*(e){return new Promise(t=>setTimeout(()=>t(),e))});return function(t){return o.apply(this,arguments)}}(),Vc={"#e2f552":"accent","#2859e1":"primary","#1744c2":"secondary","#ffffff":"default","#8394b0":"fade"},Uc={accent:new b.Q1f("#2859e1"),primary:new b.Q1f("#1744c2"),secondary:new b.Q1f("#2859e1"),default:new b.Q1f("#e2f552"),fade:new b.Q1f("#e2f552")},$c={accent:new b.Q1f("#e2f552"),primary:new b.Q1f("#1744c2"),secondary:new b.Q1f("#1744c2"),default:new b.Q1f("#1744c2"),fade:new b.Q1f("#1744c2")},jc={accent:new b.Q1f("#2859e1"),primary:new b.Q1f("#e2f552"),secondary:new b.Q1f("#e2f552"),default:new b.Q1f("#e2f552"),fade:new b.Q1f("#e2f552")},Yc=o=>{const e=new b.Q1f(o),i=.299*e.r+.587*e.g+.114*e.b>.5?.75:1.25;return new b.Q1f(Math.min(e.r*i,1),Math.min(e.g*i,1),Math.min(e.b*i,1))};function Zc(o){let e="";return e=o.LongName?.value?o.LongName.value:o.Name?.value?o.Name.value:o.type||"(no name)",`${e} [${o._category.value}]`}function eo(o,e,t){return an.apply(this,arguments)}function an(){return(an=(0,H.A)(function*(o,e,t){console.log(e);const i=yield o.getItemsData(e,{relations:{Decomposes:{attributes:!0,relations:!0}}});console.log(i),void 0===t.children&&(t.children=[]);for(const s of i){const n=[];for(const r of s.Decomposes||[]){const a=r._localId.value,l=yield o.getItemsData([a],{relations:{IsDecomposedBy:{attributes:!0,relations:!0}}});console.log(l);const c={id:a,label:Zc(r)};yield eo(o,[a],c),n.push(c)}t.children.push(...n)}})).apply(this,arguments)}function ln(){return(ln=(0,H.A)(function*(o,e){const t=yield o.getItemsOfCategories([/IFCSITE/]),i={label:e,children:[]};yield eo(o,t.IFCSITE,i),console.log(i)})).apply(this,arguments)}let cn=(()=>{class o{_workerUrl=(0,st.WQX)(Fc.g);_resolvedWorkerUrl=(0,st.vPA)(void 0);_container=(0,st.vPA)(void 0);modelsAreLoading=(0,st.vPA)(!1);settings=(0,st.vPA)(new rs.R_);_previousHighlights=null;raycastResult=(0,st.vPA)(null);hoveredElement=(0,St.EW)(()=>{const t=this.raycastResult()?.localId??null,i=this.raycastResult()?.fragments.modelId??null;return i&&t?{[i]:new Set([t])}:null},{equal:(t,i)=>((o,e)=>{if(!o&&!e)return!0;if(!o||!e)return!1;const t=Object.keys(o),i=Object.keys(e);if(t.length!==i.length||t[0]!==i[0])return!1;const s=o[t[0]],n=e[i[0]];if(s.size!==n.size)return!1;const r=Array.from(s.values()),a=Array.from(n.values());return r[0]===a[0]})(t,i)});clickedElement=(0,st.vPA)(null);selectedElements=(0,st.vPA)(null);init(t){this._container.set(t)}_colorDef=(0,St.EW)(()=>{const t=this._container();if(t)return(o=>{const t=window.getComputedStyle(o).getPropertyValue("--background-color"),i=Vc[t];return{hoverColor:Uc[i]??new b.Q1f("#e2f552"),selectionColor:$c[i]??new b.Q1f("#1744c2"),selectionOutlineColor:jc[i]??new b.Q1f("#e2f552"),ghostColor:Yc(t)}})(t)});_loadedModels=(0,st.vPA)([]);_components=(0,St.EW)(()=>{if(void 0!==this._container())return console.info("Building components..."),new js});_world=(0,St.EW)(()=>{const t=this._components(),i=this._container();if(void 0!==t&&void 0!==i)return console.info("Setting up scene..."),((o,e)=>{const i=o.get(bs).create();i.scene=new Jn(o),i.scene.setup(),i.scene.three.background=null,i.renderer=new nn.Hs(o,e);const{postproduction:s}=i.renderer;return i.camera=new Hs(o),o.init(),i.scene.setup(),s.enabled=!0,i.scene.three.background=null,i.camera.controls.restThreshold=.25,i})(t,i)});_fragments=(0,St.EW)(()=>{const t=this._world();if(void 0===t)return;const i=this._components();if(void 0===i)return;const s=this._resolvedWorkerUrl();return void 0!==s?(console.info("Setting up fragments..."),Rc(i,t,s)):void 0});viewerReady=(0,St.EW)(()=>!(void 0===this._components()||void 0===this._world()||void 0===this._fragments()));get loadedModels(){return this._loadedModels}constructor(){(function Dc(o){return on.apply(this,arguments)})(this._workerUrl).then(t=>this._resolvedWorkerUrl.set(t)),(0,st.QZP)(()=>{this.viewerReady()&&(console.info("Initializing event listeners..."),this._initEventListeners(),console.info("BIM Fragments Viewer is ready"))}),(0,st.QZP)(()=>{const t=this.settings(),i=this._world(),s=this._components(),n=this._fragments(),r=this._colorDef();void 0===t||void 0===i||void 0===s||void 0===n||void 0===r||this.viewerReady()&&(((o,e,t,i,s)=>{t.dynamicAnchor=o.dynamicAnchor;const n=t.renderer?.postproduction;if(n&&(n.enabled=o.postProductionSettings.enabled,n.style=o.postProductionSettings.style),o.clickEnabled){const r=e.get(sn);r.world=t,r.fragments=i,r.enabled=!0,r.material=new b.V9B({color:s.hoverColor,transparent:!0,opacity:.5,depthTest:!1});const a=e.get(Oc);a.world=t,a.fragments=i,a.enabled=!0;const l=e.get(Xr);l.enabled=!0,l.fragments=i,l.multiSelect=o.multiSelect,l.styles={fillColor:s.selectionColor,outlineColor:s.selectionOutlineColor,fillOpacity:.5}}if(o.applyGhosting){const r=e.get(en);r.enabled=!0,r.ghostColor=s.ghostColor,r.fragments=i,r.world=t}console.info("Settings updated")})(t,s,i,n,r),console.info("Settings updated"))})}dispose(){var t=this;return(0,H.A)(function*(){yield t.disposeModels()})()}loadFragmentFiles(t){var i=this;return(0,H.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 Qr(s,t);i._loadedModels.update(()=>[...n]),console.log("YYY"),console.log(n),i.modelsAreLoading.set(!1)})()}disposeModels(t){var i=this;return(0,H.A)(function*(){const s=t?t.map(r=>r.id):void 0,n=i._fragments();if(void 0===n)throw new Error("Fragments not available");yield Kr(n,s),void 0!==t&&t.forEach(r=>r.visible=!1)})()}updateModels(t){var i=this;return(0,H.A)(function*(){const s=i._fragments();if(void 0===s)throw new Error("Fragments not available");const n=yield Bc(s,t);i._loadedModels.update(()=>[...n])})()}getSpatialStructure(t){var i=this;return(0,H.A)(function*(){const s=i._fragments()?.models.list.get(t.id);return void 0!==s&&function Wc(o,e){ln.apply(this,arguments)}(s,t.name),s?.getSpatialStructure()})()}updateAspectRatio(){this._world()?.renderer?.resize(),this._world()?.camera.updateAspect()}_initEventListeners(){var t=this;const i=this._components().get(Xr);i.events.clickedElement.add(n=>{const r=this.hoveredElement();null!==r&&this.clickedElement.update(()=>({itemData:n,element:r}))}),i.events.clickedCanvas.add(()=>{this.clickedElement.update(()=>null)}),i.events.selection.add(n=>{this.selectedElements.update(()=>n)}),this._components().get(sn).events.hoveredElement.add(function(){var n=(0,H.A)(function*(r){t.raycastResult.update(()=>r)});return function(r){return n.apply(this,arguments)}}()),this._fragments().models.list.onItemSet.add(()=>{})}static \u0275fac=function(i){return new(i||o)};static \u0275prov=st.jDH({token:o,factory:o.\u0275fac,providedIn:"root"})}return o})();var qc=mt(7023),Gc=mt(5970),qe=mt(5381),un=mt(5187),ts=mt(5971),hn=mt(3319),m=mt(5547);function Xc(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-flexcontainer",3)(1,"cue-button",5),m.bIt("click",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.zoomOut())}),m.nrm(2,"cue-button-icon",6),m.k0s(),m.j41(3,"cue-button",5),m.bIt("click",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.zoomIn())}),m.nrm(4,"cue-button-icon",7),m.k0s(),m.j41(5,"cue-button",5),m.bIt("click",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.zoomFit())}),m.nrm(6,"cue-button-icon",8),m.k0s()()}}function Qc(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-button",5),m.bIt("click",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.toggleLayersVisible())}),m.nrm(1,"cue-button-icon",9),m.k0s()}if(2&o){const t=m.XpG();m.AVh("border-left",t.options().displayZoom&&t.displayDecompositionTree())}}let Kc=(()=>{class o{settings=(0,vt.hFB)(new rs.R_);options=(0,St.EW)(()=>this.settings().toolbar);selectMenuPositions=(0,St.EW)(()=>"top"===this.options().position?"bottomleft":"topleft");displayDecompositionTree=(0,St.EW)(()=>void 0!==this.options().displayDecompositionTree);zoomIn(){}zoomOut(){}zoomFit(){}toggleLayersVisible(){}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,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&&(m.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),m.nVh(3,Xc,7,0,"cue-flexcontainer",3),m.nVh(4,Qc,2,2,"cue-button",4),m.k0s()()()),2&i&&(m.R7$(),m.Y8G("padded",!1),m.R7$(2),m.vxM(s.options().displayZoom?3:-1),m.R7$(),m.vxM(s.displayDecompositionTree()?4:-1))},dependencies:[qe.n,un.Card,ts.Button,hn.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 o})();var Jc=mt(9421),tu=mt(1024),es=mt(2245);function eu(o,e){if(1&o&&m.nrm(0,"cue-key-val",3),2&o){const t=m.XpG();m.Y8G("val",t.name)}}function iu(o,e){if(1&o&&m.nrm(0,"cue-key-val",5),2&o){const t=e.$implicit;m.Y8G("key",t.label)("val",t.value)}}function su(o,e){if(1&o&&(m.j41(0,"cue-typography",4),m.EFF(1),m.k0s(),m.j41(2,"cue-key-val-list"),m.Z7z(3,iu,1,2,"cue-key-val",5,m.Vm6),m.k0s()),2&o){const t=e.$implicit;m.R7$(),m.JRh(t.psetName),m.R7$(2),m.Dyx(t.props)}}function nu(o,e){if(1&o&&m.Z7z(0,su,5,1,null,null,m.Vm6),2&o){const t=m.XpG();m.Dyx(t.psets)}}function ru(o,e){if(1&o&&(m.nVh(0,eu,1,1,"cue-key-val",3),m.nVh(1,nu,2,0)),2&o){const t=e;m.vxM(t.name?0:-1),m.R7$(),m.vxM(t.psets.length>0?1:-1)}}function ou(o,e){if(1&o&&(m.j41(0,"cue-card",1)(1,"cue-flexcontainer",2),m.nVh(2,ru,2,2),m.k0s()()),2&o){let t;const i=m.XpG();m.Y8G("padded",!1)("scrollable",!0),m.R7$(2),m.vxM((t=i.props())?2:-1,t)}}function au(o,e){if(1&o&&m.nrm(0,"cue-key-val",3),2&o){const t=m.XpG();m.Y8G("val",t.name)}}function lu(o,e){if(1&o&&m.nrm(0,"cue-key-val",5),2&o){const t=e.$implicit;m.Y8G("key",t.label)("val",t.value)}}function cu(o,e){if(1&o&&(m.j41(0,"cue-typography",4),m.EFF(1),m.k0s(),m.j41(2,"cue-key-val-list"),m.Z7z(3,lu,1,2,"cue-key-val",5,m.Vm6),m.k0s()),2&o){const t=e.$implicit;m.R7$(),m.JRh(t.psetName),m.R7$(2),m.Dyx(t.props)}}function uu(o,e){if(1&o&&m.Z7z(0,cu,5,1,null,null,m.Vm6),2&o){const t=m.XpG();m.Dyx(t.psets)}}function hu(o,e){if(1&o&&(m.nVh(0,au,1,1,"cue-key-val",3),m.nVh(1,uu,2,0)),2&o){const t=e;m.vxM(t.name?0:-1),m.R7$(),m.vxM(t.psets.length>0?1:-1)}}function du(o,e){if(1&o&&(m.j41(0,"cue-flexcontainer",2),m.nVh(1,hu,2,2),m.k0s()),2&o){let t;const i=m.XpG();m.R7$(),m.vxM((t=i.props())?1:-1,t)}}let fu=(()=>{class o{element=vt.hFB.required();wrapInCard=(0,vt.hFB)(!0);props=(0,St.EW)(()=>{const t=this.element().itemData,i=this.formatItemPsets(t.IsDefinedBy||[]);return{name:t.Name?.value||"No name",psets:i}});formatItemPsets(t){const i=[];for(const[,s]of t.entries()){const{Name:n,HasProperties:r}=s;if(!("value"in n)||!Array.isArray(r))continue;const a=[];for(const[,l]of r.entries()){const{Name:c,NominalValue:u}=l;if(!("value"in c)||!("value"in u))continue;const h=c.value,f=u.value;h&&void 0!==f&&a.push({label:h,value:f.toString()})}i.push({psetName:n.value,props:a})}return i}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,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&&(m.j41(0,"cue-flexcontainer",0),m.nVh(1,ou,3,3,"cue-card",1)(2,du,2,1,"cue-flexcontainer",2),m.k0s()),2&i&&(m.R7$(),m.vxM(s.wrapInCard()?1:2))},dependencies:[qe.n,un.Card,Jc.F,tu.p,es.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 o})();var io=mt(9769);let pu=(()=>{class o{selectedItem=(0,st.vPA)(void 0);static \u0275fac=function(i){return new(i||o)};static \u0275prov=st.jDH({token:o,factory:o.\u0275fac,providedIn:"root"})}return o})();var so=mt(7089),mu=mt(5448),no=mt(6117),dn=mt(356),fn=mt(6279);const ro=(o,e)=>e.path;function gu(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-menu-item",7),m.bIt("click",function(s){const n=st.eBV(t).$implicit,r=m.XpG(2);return st.Njj(r.navigateTo(s,n.path))}),m.EFF(1),m.k0s()}if(2&o){const t=e.$implicit;m.R7$(),m.SpI(" ",t.name," ")}}function _u(o,e){if(1&o&&(m.j41(0,"cue-flexcontainer",2)(1,"cue-menu")(2,"cue-button",4,0)(4,"cue-button-label"),m.EFF(5,"..."),m.k0s()(),m.j41(6,"cue-menu-wrap",5),m.Z7z(7,gu,2,1,"cue-menu-item",null,ro),m.k0s()(),m.j41(9,"cue-typography",6),m.EFF(10," \u203a "),m.k0s()()),2&o){const t=m.XpG();m.R7$(2),m.Y8G("size",t.buttonSize())("cueTooltip",t.hiddenPartsTooltip()),m.R7$(5),m.Dyx(t.hidddenParts()),m.R7$(2),m.Y8G("size",t.size())}}function yu(o,e){if(1&o&&(m.j41(0,"cue-typography",6),m.EFF(1," \u203a "),m.k0s()),2&o){const t=m.XpG(2);m.Y8G("size",t.size())}}function vu(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-flexcontainer",8),m.bIt("click",function(s){const n=st.eBV(t),r=n.$implicit,a=n.$index,l=n.$count,c=m.XpG();return st.Njj(a!==l-1&&!c.buttonMode()&&c.navigateTo(s,r.path))}),m.j41(1,"cue-typography",9),m.EFF(2),m.k0s(),m.nVh(3,yu,2,1,"cue-typography",6),m.k0s()}if(2&o){const t=e.$implicit,i=e.$index,s=e.$count,n=m.XpG();m.AVh("clickable",i!==s-1&&n.updatePathOnClick()&&!n.buttonMode()),m.R7$(),m.AVh("full-length",n.nameFullLength()),m.Y8G("size",n.size())("weight",i===s-1?"medium":"regular")("title",t.name),m.R7$(),m.SpI(" ",t.name," "),m.R7$(),m.vxM(i!==s-1?3:-1)}}let wu=(()=>{class o{path=vt.geq.required();size=(0,vt.hFB)("xs");rootName=(0,vt.hFB)(null);maxVisibleParts=(0,vt.hFB)(3);nameFullLength=(0,vt.hFB)(!1);updatePathOnClick=(0,vt.hFB)(!0);buttonMode=(0,vt.hFB)(!1);buttonSize=(0,St.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(t){this.buttonMode()&&(t.stopPropagation(),this.clickedPath.emit(this.path()))}pathChange=(0,vt.CGW)();clickedPath=(0,vt.CGW)();allBreadcrumbParts=(0,St.EW)(()=>{const t=this.path().split("/").filter(r=>""!==r),i=[],s=this.rootName();null!==s&&i.push({name:s,path:"/"});let n="";for(const r of t)n+=`/${r}`,i.push({name:r,path:n.endsWith("/")?n:`${n}/`});return i});shouldShowEllipsis=(0,St.EW)(()=>this.allBreadcrumbParts().length>this.maxVisibleParts());visibleBreadcrumbParts=(0,St.EW)(()=>{const t=this.allBreadcrumbParts(),i=this.maxVisibleParts();return t.length<=i?t:t.slice(-i)});hidddenParts=(0,St.EW)(()=>{const t=this.allBreadcrumbParts(),i=this.maxVisibleParts();return t.length<=i?[]:t.slice(0,-i)});hiddenPartsTooltip=(0,St.EW)(()=>{const t=this.hidddenParts();return 0===t.length?"":`${t.map(i=>i.name).join(" \u203a ")}`});navigateTo(t,i){console.log("Navigating to:",i),t.stopImmediatePropagation(),t.stopPropagation(),t.preventDefault(),this.clickedPath.emit(i),this.updatePathOnClick()&&(this.path.set(i),this.pathChange.emit(i))}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,selectors:[["cue-breadcrumb"]],hostVars:3,hostBindings:function(i,s){1&i&&m.bIt("click",function(r){return s.onHostClick(r)}),2&i&&(m.BMQ("size",s.sizeAttribute),m.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&&(m.j41(0,"cue-flexcontainer",1),m.nVh(1,_u,11,3,"cue-flexcontainer",2),m.Z7z(2,vu,4,9,"cue-flexcontainer",3,ro),m.k0s()),2&i&&(m.R7$(),m.vxM(s.shouldShowEllipsis()?1:-1),m.R7$(),m.Dyx(s.visibleBreadcrumbParts()))},dependencies:[io.MD,es.Typography,qe.n,ts.Button,mu.ButtonLabel,so.d,no.W,dn.M,fn.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 o})();var bu=mt(29);const xu=()=>[],Cu=()=>({}),Tu=(o,e)=>e.label;function Eu(o,e){if(1&o&&m.nrm(0,"cue-svg-icon",17),2&o){const t=m.XpG().$implicit;m.Y8G("name",t.icon)}}function Au(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-menu-item",16),m.bIt("click",function(){const s=st.eBV(t).$implicit;return st.Njj(s.action())}),m.nVh(1,Eu,1,1,"cue-svg-icon",17),m.EFF(2),m.k0s()}if(2&o){const t=e.$implicit;m.Y8G("tooltip",t.tooltip??""),m.R7$(),m.vxM(t.icon?1:-1),m.R7$(),m.SpI(" ",t.label," ")}}function Pu(o,e){if(1&o&&(m.j41(0,"cue-menu",11),m.bIt("click",function(i){return i.stopPropagation()}),m.j41(1,"cue-button",12),m.nrm(2,"cue-button-icon",13),m.k0s(),m.j41(3,"cue-menu-wrap",14),m.Z7z(4,Au,3,3,"cue-menu-item",15,Tu),m.k0s()()),2&o){const t=m.XpG().$implicit;m.R7$(),m.Y8G("cueTooltip",t.tooltip??""),m.R7$(),m.Y8G("icon",t.icon),m.R7$(2),m.Dyx(t.menuItems)}}function Su(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-button",18),m.bIt("click",function(s){return st.eBV(t),m.XpG().$implicit.action(),st.Njj(s.stopPropagation())}),m.nrm(1,"cue-button-icon",13),m.k0s()}if(2&o){const t=m.XpG().$implicit;m.Y8G("cueTooltip",t.tooltip??""),m.R7$(),m.Y8G("icon",t.icon)}}function Iu(o,e){if(1&o&&m.nVh(0,Pu,6,2,"cue-menu")(1,Su,2,2,"cue-button",10),2&o){const t=e.$implicit;m.vxM(null!=t.menuItems&&t.menuItems.length?0:t.action?1:-1)}}function Mu(o,e){if(1&o&&(m.j41(0,"cue-flexcontainer",3),m.Z7z(1,Iu,2,1,null,null,m.Vm6),m.k0s()),2&o){const t=m.XpG().$implicit;m.R7$(),m.Dyx(t.buttons)}}function Ou(o,e){if(1&o&&(m.j41(0,"span",22),m.EFF(1),m.k0s()),2&o){const t=m.XpG(2).$implicit,i=m.XpG();m.AVh("checked",i.isSelected(t)),m.R7$(),m.SpI(" ",i.isSelected(t)?"\u2611":"\u2610"," ")}}function ku(o,e){if(1&o&&(m.j41(0,"cue-typography",21),m.EFF(1),m.k0s()),2&o){const t=m.XpG(2).$implicit;m.R7$(),m.JRh(t.subLabel)}}function zu(o,e){if(1&o&&(m.j41(0,"div",4),m.nVh(1,Ou,2,3,"span",19),m.j41(2,"cue-typography",20),m.EFF(3),m.k0s(),m.nVh(4,ku,2,1,"cue-typography",21),m.k0s()),2&o){const t=m.XpG().$implicit,i=m.XpG();m.R7$(),m.vxM(i.multiSelect()&&!i.hasChildren(t)?1:-1),m.R7$(),m.Y8G("weight",i.isSelected(t)?"semibold":"regular")("size",i.size()),m.R7$(),m.JRh(t.label),m.R7$(),m.vxM(t.subLabel?4:-1)}}function Fu(o,e){if(1&o&&m.nrm(0,"cue-breadcrumb",6),2&o){const t=m.XpG().$implicit,i=m.XpG();m.Y8G("maxVisibleParts",5)("path",t.label)("size",i.size())("nameFullLength",!0)("updatePathOnClick",!1)}}function Nu(o,e){if(1&o&&m.nrm(0,"cue-svg-icon",23),2&o){const t=m.XpG().$implicit,i=m.XpG();m.AVh("expanded",i.isExpanded(t))}}function Du(o,e){if(1&o&&(m.j41(0,"div",8),m.nrm(1,"cue-tree-menu",24),m.k0s()),2&o){const t=m.XpG().$implicit,i=m.XpG();m.R7$(),m.Y8G("items",t.children||m.lJ4(2,xu))("size",i.size())}}function Ru(o,e){if(1&o&&(m.j41(0,"div",25),m.bIt("click",function(i){return i.stopPropagation()}),m.eu8(1,26),m.k0s()),2&o){const t=m.XpG().$implicit;m.R7$(),m.Y8G("ngTemplateOutlet",t.contentTemplate)("ngTemplateOutletContext",t.templateContext??m.lJ4(2,Cu))}}function Bu(o,e){if(1&o){const t=m.RV6();m.j41(0,"li",1)(1,"cue-flexcontainer",2),m.bIt("click",function(){const s=st.eBV(t).$implicit,n=m.XpG();return st.Njj(n.handleItemClick(s))}),m.nVh(2,Mu,3,0,"cue-flexcontainer",3),m.nVh(3,zu,5,5,"div",4),m.nrm(4,"span",5),m.nVh(5,Fu,1,5,"cue-breadcrumb",6),m.nVh(6,Nu,1,2,"cue-svg-icon",7),m.k0s(),m.nVh(7,Du,2,3,"div",8),m.nVh(8,Ru,2,3,"div",9),m.k0s()}if(2&o){const t=e.$implicit,i=m.XpG();m.R7$(),m.AVh("has-children",i.hasChildren(t)),m.R7$(),m.vxM(null!=t.buttons&&t.buttons.length?2:-1),m.R7$(),m.vxM(void 0===t.type||"text"===t.type?3:-1),m.R7$(2),m.vxM("breadcrumb"===t.type?5:-1),m.R7$(),m.vxM(i.hasChildren(t)?6:-1),m.R7$(),m.vxM(i.hasChildren(t)&&i.isExpanded(t)?7:-1),m.R7$(),m.vxM(t.contentTemplate?8:-1)}}let Lu=(()=>{class o{_service=(0,st.WQX)(pu);items=(0,vt.geq)([]);size=(0,vt.hFB)("m");collapseOnSelect=(0,vt.hFB)(!1);initialExpandDepth=(0,vt.hFB)(-1);multiSelect=(0,vt.hFB)(!1);expandedItems=new Set;_multiSelectedIds=(0,st.vPA)(new Set);selectionChanged=(0,vt.CGW)();multiSelectionChanged=(0,vt.CGW)();onItemsChange=(0,st.QZP)(()=>{this.multiSelect()?(this._syncMultiSelectedFromItems(),this._doInitialExpand()):this.collapseOnSelect()||this._initialExpandSelected()});onSelectionChange=(0,st.QZP)(()=>{const t=this._service.selectedItem();void 0!==t&&this.selectionChanged.emit(t)});ngOnDestroy(){this.items.update(()=>[])}handleItemClick(t){if(this.hasChildren(t)){const i=t.id??t.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),t.selected=!0,this._service.selectedItem.set(t)}}else if(this.multiSelect()){const i=t.id??t.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(t),this._update()}hasChildren(t){return!!t.children&&t.children.length>0}isExpanded(t){return this.expandedItems.has(t.id??t.label)}isSelected(t){return this.multiSelect()?this._multiSelectedIds().has(t.id??t.label):t.selected}_setSelected(t){const i=this._service.selectedItem();void 0!==i&&(i.selected=!1),t.selected=!0}_update(){this.items.update(()=>[...this.items()])}_syncMultiSelectedFromItems(){const t=new Set,i=s=>{for(const n of s)n.selected&&t.add(n.id??n.label),n.children?.length&&i(n.children)};i(this.items()??[]),this._multiSelectedIds.set(t)}_doInitialExpand(){this.expandedItems.clear();const t=this.initialExpandDepth(),i=(s,n=0)=>{for(const r of s)t>=0&&n<=t&&this.hasChildren(r)&&this.expandedItems.add(r.id??r.label),r.children?.length&&i(r.children,n+1)};i(this.items()??[])}_initialExpandSelected(){this.expandedItems.clear();const t=this.initialExpandDepth(),i=(s,n=[],r=0)=>{for(const a of s){if(t>=0&&r<=t&&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],r+1)}};i(this.items()??[])}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,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&&(m.j41(0,"ul",0),m.Z7z(1,Bu,9,8,"li",1,m.Vm6),m.k0s()),2&i&&(m.R7$(),m.Dyx(s.items()))},dependencies:[o,es.Typography,qe.n,wu,ts.Button,hn.ButtonIcon,bu.A,so.d,io.T3,no.W,fn.D,dn.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 o})(),Vu=(()=>{class o{_service=(0,st.WQX)(cn);type=(0,vt.hFB)("spatial");models=vt.geq.required();treeItems=(0,st.vPA)([]);constructor(){var t=this;(0,st.QZP)((0,H.A)(function*(){if(!t._service.loadedModels().length)return;console.log(t._service.loadedModels());const i=yield Promise.all(t.models().map(n=>t.getSpatialStructure(n)));console.log("Model Trees:",i);const s=[];t.models().forEach(n=>{s.push({label:n.name,buttons:[{icon:n.visible?"view-inactive":"view-active",action:()=>t.toggleVisibility(n)}]})}),t.treeItems.update(()=>[...s])}))}toggleVisibility(t){var i=this;return(0,H.A)(function*(){t.visible?(yield i._service.disposeModels([t]),console.log(`Model ${t.name} (${t.id}) disposed`)):yield i._service.loadFragmentFiles([t]),i.models.update(()=>[...i.models()])})()}getSpatialStructure(t){var i=this;return(0,H.A)(function*(){const s=yield i._service.getSpatialStructure(t);if(s)return{label:s.category,children:s.children?.map(n=>({label:n.name,children:n.children?.map(r=>({label:r.name}))}))}})()}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,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&&m.nrm(0,"cue-tree-menu",0),2&i&&m.Y8G("items",s.treeItems())},dependencies:[Lu],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 o})();var Uu=mt(6034),$u=mt(4613);const oo=(o,e)=>e.id;function ju(o,e){1&o&&m.nrm(0,"cue-logo",4),2&o&&m.Y8G("active",!0)("continuous",!0)}function Hu(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-typography",6),m.EFF(1),m.k0s(),m.j41(2,"cue-button",7),m.bIt("click",function(){const s=st.eBV(t).$implicit,n=m.XpG(3);return st.Njj(n.toggleVisibility(s))}),m.nrm(3,"cue-button-icon",8),m.k0s()}if(2&o){const t=e.$implicit;m.R7$(),m.JRh(t.name),m.R7$(2),m.Y8G("icon",t.visible?"view-inactive":"view-active")}}function Yu(o,e){if(1&o&&(m.j41(0,"cue-flexcontainer",5),m.Z7z(1,Hu,4,2,null,null,oo),m.k0s()),2&o){const t=m.XpG(2);m.R7$(),m.Dyx(t.models())}}function Zu(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-typography",3),m.EFF(1),m.k0s(),m.j41(2,"cue-bim-fragments-tree-viewer",9),m.mxI("modelsChange",function(s){st.eBV(t);const n=m.XpG(2);return m.DH7(n.models,s)||(n.models=s),st.Njj(s)}),m.k0s()}if(2&o){const t=m.XpG(2);m.R7$(),m.JRh(t.treeLabel()),m.R7$(),m.R50("models",t.models)}}function Wu(o,e){if(1&o&&(m.j41(0,"cue-draggable-card",0)(1,"cue-flexcontainer",1)(2,"cue-flexcontainer",2)(3,"cue-typography",3),m.EFF(4,"Models"),m.k0s(),m.nVh(5,ju,1,2,"cue-logo",4)(6,Yu,3,0,"cue-flexcontainer",5),m.k0s(),m.nVh(7,Zu,3,2),m.k0s()()),2&o){const t=m.XpG();m.Y8G("padded",!1),m.R7$(5),m.vxM(t.modelsAreLoading()?5:6),m.R7$(2),m.vxM(t.displayDecompositionTree()?7:-1)}}function qu(o,e){1&o&&m.nrm(0,"cue-logo",4),2&o&&m.Y8G("active",!0)("continuous",!0)}function Gu(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-typography",6),m.EFF(1),m.k0s(),m.j41(2,"cue-button",7),m.bIt("click",function(){const s=st.eBV(t).$implicit,n=m.XpG(3);return st.Njj(n.toggleVisibility(s))}),m.nrm(3,"cue-button-icon",8),m.k0s()}if(2&o){const t=e.$implicit;m.R7$(),m.JRh(t.name),m.R7$(2),m.Y8G("icon",t.visible?"view-inactive":"view-active")}}function Xu(o,e){if(1&o&&(m.j41(0,"cue-flexcontainer",5),m.Z7z(1,Gu,4,2,null,null,oo),m.k0s()),2&o){const t=m.XpG(2);m.R7$(),m.Dyx(t.models())}}function Qu(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-typography",3),m.EFF(1),m.k0s(),m.j41(2,"cue-bim-fragments-tree-viewer",9),m.mxI("modelsChange",function(s){st.eBV(t);const n=m.XpG(2);return m.DH7(n.models,s)||(n.models=s),st.Njj(s)}),m.k0s()}if(2&o){const t=m.XpG(2);m.R7$(),m.JRh(t.treeLabel()),m.R7$(),m.R50("models",t.models)}}function Ku(o,e){if(1&o&&(m.j41(0,"cue-flexcontainer",1)(1,"cue-flexcontainer",2)(2,"cue-typography",3),m.EFF(3,"Models"),m.k0s(),m.nVh(4,qu,1,2,"cue-logo",4)(5,Xu,3,0,"cue-flexcontainer",5),m.k0s(),m.nVh(6,Qu,3,2),m.k0s()),2&o){const t=m.XpG();m.R7$(4),m.vxM(t.modelsAreLoading()?4:5),m.R7$(2),m.vxM(t.displayDecompositionTree()?6:-1)}}let Ju=(()=>{class o{_service=(0,st.WQX)(cn);models=vt.geq.required();draggable=(0,vt.hFB)(!0);modelsAreLoading=this._service.modelsAreLoading;displayDecompositionTree=(0,St.EW)(()=>void 0!==this._service.settings().toolbar.displayDecompositionTree);treeLabel=(0,St.EW)(()=>"spatial"===this._service.settings().toolbar.displayDecompositionTree?"Spatial Decomposition":"System Decomposition");toggleVisibility(t){var i=this;return(0,H.A)(function*(){console.log("TOGGLE VISIBILITY",t),t.visible?(yield i._service.disposeModels([t]),console.log(`Model ${t.name} (${t.id}) disposed`)):yield i._service.loadFragmentFiles([t]),i.models.update(()=>[...i.models()])})()}static \u0275fac=function(i){return new(i||o)};static \u0275cmp=m.VBU({type:o,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&&m.nVh(0,Wu,8,3,"cue-draggable-card",0)(1,Ku,7,2,"cue-flexcontainer",1),2&i&&m.vxM(s.draggable()?0:1)},dependencies:[Uu.y,es.Typography,qe.n,ts.Button,hn.ButtonIcon,Vu,$u.Logo],styles:[".draggable[_ngcontent-%COMP%]{z-index:101}"],changeDetection:0})}return o})();var th=mt(7851);const eh=["bimViewer"],ao=()=>({position:"bottomleft"}),ih=(o,e)=>e.label;function sh(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-menu-item",4),m.bIt("click",function(){const s=st.eBV(t).$implicit;return st.Njj(s.action())}),m.EFF(1),m.k0s()}if(2&o){const t=e.$implicit;m.R7$(),m.JRh(t.label)}}function nh(o,e){if(1&o&&(m.j41(0,"cue-menu-wrap"),m.Z7z(1,sh,2,1,"cue-menu-item",null,ih),m.k0s()),2&o){const t=m.XpG();m.R7$(),m.Dyx(t.contextMenuItems())}}function rh(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-bim-fragments-visibility-menu",13),m.mxI("modelsChange",function(s){st.eBV(t);const n=m.XpG(2);return m.DH7(n.models,s)||(n.models=s),st.Njj(s)}),m.k0s()}if(2&o){const t=m.XpG(2);m.R50("models",t.models),m.Y8G("draggable",!1)}}function oh(o,e){if(1&o&&m.nrm(0,"cue-bim-fragments-toolbar",15),2&o){const t=m.XpG(3),i=m.r8f(3);m.Aen(t.toolbarStyle()),m.Y8G("settings",i)}}function ah(o,e){1&o&&m.nVh(0,oh,1,3,"cue-bim-fragments-toolbar",14),2&o&&m.vxM(e.hidden?-1:0)}function lh(o,e){if(1&o&&(m.j41(0,"cue-card",16),m.nrm(1,"cue-bim-fragments-props-viewer",17),m.k0s()),2&o){const t=m.XpG(2);m.AVh("hidden",null===t.$clickedElement()),m.R7$(),m.Y8G("element",e)("wrapInCard",!1)}}function ch(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-card",5),m.nVh(1,rh,1,2,"cue-bim-fragments-visibility-menu",6),m.k0s(),m.j41(2,"div",7)(3,"cue-card",8)(4,"div",9,1),m.bIt("resized",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.onResized())})("windowResized",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.onResized())}),m.k0s(),m.nVh(6,ah,1,1),m.k0s(),m.j41(7,"a",10),m.EFF(8,"Powered by "),m.j41(9,"span",11),m.EFF(10,"ThatOpen"),m.k0s()()(),m.nVh(11,lh,2,4,"cue-card",12)}if(2&o){let t,i;const s=m.XpG(),n=m.sdS(1),r=m.r8f(3);m.R7$(),m.vxM(r.showModelList&&s.models().length?1:-1),m.R7$(3),m.Y8G("cueLogoLoader",s.isLoading())("cueContextMenu",n)("contextMenuData",m.lJ4(7,ao))("cueContextEnabled",null!==s.$hoveredElement()),m.R7$(2),m.vxM((t=r.toolbar)?6:-1,t),m.R7$(5),m.vxM((i=s.$clickedElement())?11:-1,i)}}function uh(o,e){if(1&o&&m.nrm(0,"cue-bim-fragments-toolbar",15),2&o){const t=m.XpG(3),i=m.r8f(3);m.Aen(t.toolbarStyle()),m.Y8G("settings",i)}}function hh(o,e){1&o&&m.nVh(0,uh,1,3,"cue-bim-fragments-toolbar",14),2&o&&m.vxM(e.hidden?-1:0)}function dh(o,e){1&o&&(m.j41(0,"div",19),m.nrm(1,"cue-bim-fragments-props-viewer",21),m.k0s()),2&o&&(m.R7$(),m.Y8G("element",e))}function fh(o,e){if(1&o){const t=m.RV6();m.j41(0,"cue-bim-fragments-visibility-menu",22),m.mxI("modelsChange",function(s){st.eBV(t);const n=m.XpG(2);return m.DH7(n.models,s)||(n.models=s),st.Njj(s)}),m.k0s()}if(2&o){const t=m.XpG(2);m.R50("models",t.models)}}function ph(o,e){if(1&o){const t=m.RV6();m.j41(0,"div",18,1),m.bIt("resized",function(){st.eBV(t);const s=m.XpG();return st.Njj(s.onResized())}),m.nVh(2,hh,1,1),m.nVh(3,dh,2,1,"div",19),m.nVh(4,fh,1,1,"cue-bim-fragments-visibility-menu",20),m.j41(5,"a",10),m.EFF(6,"Powered by "),m.j41(7,"span",11),m.EFF(8,"ThatOpen"),m.k0s()()()}if(2&o){let t,i;const s=m.XpG(),n=m.sdS(1),r=m.r8f(3);m.Y8G("cueLogoLoader",s.isLoading())("cueContextMenu",n)("contextMenuData",m.lJ4(7,ao))("cueContextEnabled",null!==s.$hoveredElement()),m.R7$(2),m.vxM((t=r.toolbar)?2:-1,t),m.R7$(),m.vxM((i=s.$clickedElement())?3:-1,i),m.R7$(),m.vxM(r.showModelList&&s.models().length?4:-1)}}let mh=(()=>{class o{_service=(0,st.WQX)(cn);data=(0,vt.hFB)(void 0);settings=(0,vt.hFB)(new rs.R_);clickedElement=(0,vt.CGW)();hoveredElement=(0,vt.CGW)();selectedElements=(0,vt.CGW)();$hoveredElement=(0,st.vPA)(null);$clickedElement=(0,st.vPA)(null);_cachedClickedElement=(0,st.vPA)(null);_modelLoading=(0,st.vPA)(!0);isLoading=(0,St.EW)(()=>!this.viewerReady()||this._modelLoading());models=(0,St.uu)(()=>this.data()?.models??[]);detailedView=(0,St.EW)(()=>!0===this.settings().detailedViewEnabled);toolbarStyle=(0,St.EW)(()=>{const t=this.settings().toolbar;return{position:"absolute",left:t.margin,right:t.margin,["top"===t.position?"top":"bottom"]:t.margin,"z-index":"10",display:"flex","justify-content":"center"}});contextMenuItems=(0,St.EW)(()=>{const t=[];return this.settings().showPropertiesOnClick&&(console.log("ADDING PROPERTIES MENU ITEM"),t.push({label:"Show Properties",action:()=>{this.$clickedElement.set(this._cachedClickedElement())}})),this.settings().elementClickOptions&&t.push(...this.settings().elementClickOptions),t});viewerReady=this._service.viewerReady;onClickElement=(0,st.QZP)(()=>{const t=this._service.clickedElement();t&&this._cachedClickedElement.set(t),t||this.$clickedElement.set(null),this.clickedElement.emit(t)});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(t){t&&this._service.init(t.nativeElement)}loadFilesOnData=(0,st.QZP)(()=>{const t=this.models();console.log(t),this.viewerReady()&&t.length&&(console.info("Loading models:",t),this._modelLoading.set(!0),this._service.updateModels(t).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||o)};static \u0275cmp=m.VBU({type:o,selectors:[["cue-bim-fragments-viewer"]],viewQuery:function(i,s){if(1&i&&m.GBs(eh,5),2&i){let n;m.mGM(n=m.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&&(m.DNE(0,nh,3,0,"ng-template",null,0,m.C5r),m.j41(2,"cue-flexcontainer",2),m.SS7(3),m.nVh(4,ch,12,8)(5,ph,9,8,"div",3),m.k0s()),2&i&&(m.R7$(3),m.bH3(s.settings()),m.R7$(),m.vxM(s.detailedView()?4:5))},dependencies:[Gc.C,dn.M,fn.D,qe.n,un.Card,qc.Q,Kc,fu,Ju,th.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 o})()}}]);
|
|
1
|
+
"use strict";(self.webpackChunkcue_ui=self.webpackChunkcue_ui||[]).push([[419],{6419(r_,Kc,wt){wt.d(Kc,{BIMFragmentsViewer:()=>Eg});var ot=wt(5802),At=wt(7705),Ot=wt(2271),mn=wt(8807),G=wt(467),ft=wt(6095),p=wt(4701),Qc=(wt(3973),wt(7126)),j=wt(639),gn=wt(2085);const H=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 ii(r){return r.isPerspectiveCamera}function Ve(r){return r.isOrthographicCamera}const Ue=2*Math.PI,go=Math.PI/2,Fi=Math.PI/180;function me(r,t,e){return Math.max(t,Math.min(e,r))}function Mt(r,t=1e-5){return Math.abs(r)<t}function Tt(r,t,e=1e-5){return Mt(r-t,e)}function yo(r,t){return Math.round(r/t)*t}function Vi(r){return isFinite(r)?r:r<0?-Number.MAX_VALUE:Number.MAX_VALUE}function Ui(r){return Math.abs(r)<Number.MAX_VALUE?r:r*(1/0)}function ds(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=me(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 wo(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,b=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)+(b-r.z)*(o.z-b)>0&&(o.x=w,o.y=g,o.z=b,e.x=(o.x-w)/n,e.y=(o.y-g)/n,e.z=(o.z-b)/n),o}function _n(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 yn(r,t){return!!Ve(r)&&(console.warn(`${t} is not supported in OrthographicCamera`),!0)}class Jc{_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 fs=1/8,eh=/Mac/.test(globalThis?.navigator?.platform);let mt,bo,ps,wn,Jt,_t,Ct,mi,$i,we,be,si,vo,xo,ne,gi,_i,Co,bn,To,vn,xn,ms;class Gt extends Jc{static install(t){mt=t.THREE,bo=Object.freeze(new mt.Vector3(0,0,0)),ps=Object.freeze(new mt.Vector3(0,1,0)),wn=Object.freeze(new mt.Vector3(0,0,1)),Jt=new mt.Vector2,_t=new mt.Vector3,Ct=new mt.Vector3,mi=new mt.Vector3,$i=new mt.Vector3,we=new mt.Vector3,be=new mt.Vector3,si=new mt.Vector3,vo=new mt.Vector3,xo=new mt.Vector3,ne=new mt.Spherical,gi=new mt.Spherical,_i=new mt.Box3,Co=new mt.Box3,bn=new mt.Sphere,To=new mt.Quaternion,vn=new mt.Quaternion,xn=new mt.Matrix4,ms=new mt.Raycaster}static get ACTION(){return H}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=H.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 mt.Vector3;_focalOffsetVelocity=new mt.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 mt>"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 mt.Quaternion).setFromUnitVectors(this._camera.up,ps),this._yAxisUpSpaceInverse=this._yAxisUpSpace.clone().invert(),this._state=H.NONE,this._target=new mt.Vector3,this._targetEnd=this._target.clone(),this._focalOffset=new mt.Vector3,this._focalOffsetEnd=this._focalOffset.clone(),this._spherical=(new mt.Spherical).setFromVector3(_t.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 mt.Vector3,new mt.Vector3,new mt.Vector3,new mt.Vector3],this._updateNearPlaneCorners(),this._boundary=new mt.Box3(new mt.Vector3(-1/0,-1/0,-1/0),new mt.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 mt.Vector2,this.mouseButtons={left:H.ROTATE,middle:H.DOLLY,right:H.TRUCK,wheel:ii(this._camera)?H.DOLLY:Ve(this._camera)?H.ZOOM:H.NONE},this.touches={one:H.TOUCH_ROTATE,two:ii(this._camera)?H.TOUCH_DOLLY_TRUCK:Ve(this._camera)?H.TOUCH_ZOOM_TRUCK:H.NONE,three:H.TOUCH_TRUCK};const i=new mt.Vector2,s=new mt.Vector2,n=new mt.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 b="mouse"!==g.pointerType?null:1&~g.buttons?4&~g.buttons?2&~g.buttons?null:2:4:1;if(null!==b){const C=this._findPointerByMouseButton(b);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:b}),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 b=this._findPointerById(g.pointerId);if(!b||b!==this._lockedPointer){if(b&&this._disposePointer(b),"touch"===g.pointerType)switch(this._activePointers.length){case 0:this._state=H.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=H.NONE;_()}};let c=-1;const h=g=>{if(!this._domElement||!this._enabled||this.mouseButtons.wheel===H.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===H.ROTATE||this.mouseButtons.wheel===H.TRUCK){const A=performance.now();c-A<1e3&&this._getClientRect(this._elementRect),c=A}const b=eh?-1:-3,T=1!==g.deltaMode||g.ctrlKey?g.deltaY/(10*b):g.deltaY/b,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?H.ZOOM:this.mouseButtons.wheel){case H.ROTATE:this._rotateInternal(g.deltaX,g.deltaY),this._isUserControllingRotate=!0;break;case H.TRUCK:this._truckInternal(g.deltaX,g.deltaY,!1,!1),this._isUserControllingTruck=!0;break;case H.SCREEN_PAN:this._truckInternal(g.deltaX,g.deltaY,!1,!0),this._isUserControllingTruck=!0;break;case H.OFFSET:this._truckInternal(g.deltaX,g.deltaY,!0,!1),this._isUserControllingOffset=!0;break;case H.DOLLY:this._dollyInternal(-T,C,S),this._isUserControllingDolly=!0;break;case H.ZOOM:this._zoomInternal(-T,C,S),this._isUserControllingZoom=!0}this.dispatchEvent({type:"control"})},u=g=>{if(this._domElement&&this._enabled){if(this.mouseButtons.right===Gt.ACTION.NONE){const b=g instanceof PointerEvent?g.pointerId:0,T=this._findPointerById(b);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(_n(this._activePointers,Jt),this._getClientRect(this._elementRect),i.copy(Jt),s.copy(Jt),this._activePointers.length>=2){const T=Jt.x-this._activePointers[1].clientX,C=Jt.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&H.ROTATE)===H.ROTATE||(this._state&H.TOUCH_ROTATE)===H.TOUCH_ROTATE||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE||(this._state&H.TOUCH_ZOOM_ROTATE)===H.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&H.TRUCK)===H.TRUCK||(this._state&H.SCREEN_PAN)===H.SCREEN_PAN||(this._state&H.TOUCH_TRUCK)===H.TOUCH_TRUCK||(this._state&H.TOUCH_SCREEN_PAN)===H.TOUCH_SCREEN_PAN||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_DOLLY_SCREEN_PAN)===H.TOUCH_DOLLY_SCREEN_PAN||(this._state&H.TOUCH_ZOOM_TRUCK)===H.TOUCH_ZOOM_TRUCK||(this._state&H.TOUCH_ZOOM_SCREEN_PAN)===H.TOUCH_DOLLY_SCREEN_PAN)&&(this._targetEnd.copy(this._target),this._targetVelocity.set(0,0,0)),((this._state&H.DOLLY)===H.DOLLY||(this._state&H.TOUCH_DOLLY)===H.TOUCH_DOLLY||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_DOLLY_SCREEN_PAN)===H.TOUCH_DOLLY_SCREEN_PAN||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE)&&(this._sphericalEnd.radius=this._spherical.radius,this._radiusVelocity.value=0),((this._state&H.ZOOM)===H.ZOOM||(this._state&H.TOUCH_ZOOM)===H.TOUCH_ZOOM||(this._state&H.TOUCH_ZOOM_TRUCK)===H.TOUCH_ZOOM_TRUCK||(this._state&H.TOUCH_ZOOM_SCREEN_PAN)===H.TOUCH_ZOOM_SCREEN_PAN||(this._state&H.TOUCH_ZOOM_OFFSET)===H.TOUCH_ZOOM_OFFSET||(this._state&H.TOUCH_ZOOM_ROTATE)===H.TOUCH_ZOOM_ROTATE)&&(this._zoomEnd=this._zoom,this._zoomVelocity.value=0),((this._state&H.OFFSET)===H.OFFSET||(this._state&H.TOUCH_OFFSET)===H.TOUCH_OFFSET||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET||(this._state&H.TOUCH_ZOOM_OFFSET)===H.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,_n(this._activePointers,Jt);const b=this._domElement&&this._domElement.ownerDocument.pointerLockElement===this._domElement?this._lockedPointer||this._activePointers[0]:null,T=b?-b.deltaX:s.x-Jt.x,C=b?-b.deltaY:s.y-Jt.y;if(s.copy(Jt),((this._state&H.ROTATE)===H.ROTATE||(this._state&H.TOUCH_ROTATE)===H.TOUCH_ROTATE||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE||(this._state&H.TOUCH_ZOOM_ROTATE)===H.TOUCH_ZOOM_ROTATE)&&(this._rotateInternal(T,C),this._isUserControllingRotate=!0),(this._state&H.DOLLY)===H.DOLLY||(this._state&H.ZOOM)===H.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&H.DOLLY)===H.DOLLY?(this._dollyInternal(A*C*fs,S,M),this._isUserControllingDolly=!0):(this._zoomInternal(A*C*fs,S,M),this._isUserControllingZoom=!0)}if((this._state&H.TOUCH_DOLLY)===H.TOUCH_DOLLY||(this._state&H.TOUCH_ZOOM)===H.TOUCH_ZOOM||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_ZOOM_TRUCK)===H.TOUCH_ZOOM_TRUCK||(this._state&H.TOUCH_DOLLY_SCREEN_PAN)===H.TOUCH_DOLLY_SCREEN_PAN||(this._state&H.TOUCH_ZOOM_SCREEN_PAN)===H.TOUCH_ZOOM_SCREEN_PAN||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET||(this._state&H.TOUCH_ZOOM_OFFSET)===H.TOUCH_ZOOM_OFFSET||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE||(this._state&H.TOUCH_ZOOM_ROTATE)===H.TOUCH_ZOOM_ROTATE){const S=Jt.x-this._activePointers[1].clientX,M=Jt.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,k=this.dollyToCursor?(s.y-this._elementRect.y)/this._elementRect.height*-2+1:0;(this._state&H.TOUCH_DOLLY)===H.TOUCH_DOLLY||(this._state&H.TOUCH_DOLLY_ROTATE)===H.TOUCH_DOLLY_ROTATE||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_DOLLY_SCREEN_PAN)===H.TOUCH_DOLLY_SCREEN_PAN||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET?(this._dollyInternal(O*fs,I,k),this._isUserControllingDolly=!0):(this._zoomInternal(O*fs,I,k),this._isUserControllingZoom=!0)}((this._state&H.TRUCK)===H.TRUCK||(this._state&H.TOUCH_TRUCK)===H.TOUCH_TRUCK||(this._state&H.TOUCH_DOLLY_TRUCK)===H.TOUCH_DOLLY_TRUCK||(this._state&H.TOUCH_ZOOM_TRUCK)===H.TOUCH_ZOOM_TRUCK)&&(this._truckInternal(T,C,!1,!1),this._isUserControllingTruck=!0),((this._state&H.SCREEN_PAN)===H.SCREEN_PAN||(this._state&H.TOUCH_SCREEN_PAN)===H.TOUCH_SCREEN_PAN||(this._state&H.TOUCH_DOLLY_SCREEN_PAN)===H.TOUCH_DOLLY_SCREEN_PAN||(this._state&H.TOUCH_ZOOM_SCREEN_PAN)===H.TOUCH_ZOOM_SCREEN_PAN)&&(this._truckInternal(T,C,!1,!0),this._isUserControllingTruck=!0),((this._state&H.OFFSET)===H.OFFSET||(this._state&H.TOUCH_OFFSET)===H.TOUCH_OFFSET||(this._state&H.TOUCH_DOLLY_OFFSET)===H.TOUCH_DOLLY_OFFSET||(this._state&H.TOUCH_ZOOM_OFFSET)===H.TOUCH_ZOOM_OFFSET)&&(this._truckInternal(T,C,!0,!1),this._isUserControllingOffset=!0),this.dispatchEvent({type:"control"})},_=()=>{_n(this._activePointers,Jt),s.copy(Jt),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!==H.NONE&&(this._state=H.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=me(t.width,0,1),this._interactiveArea.height=me(t.height,0,1),this._interactiveArea.x=me(t.x,0,1-this._interactiveArea.width),this._interactiveArea.y=me(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=me(t,this.minAzimuthAngle,this.maxAzimuthAngle),n=me(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||Tt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Tt(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(me(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=Tt(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||Tt(this._spherical.radius,this._sphericalEnd.radius,this.restThreshold);return this._createOnRestPromise(n)}dollyInFixed(t,e=!1){this._targetEnd.add(this._getCameraDirection($i).multiplyScalar(t)),e||this._target.copy(this._targetEnd);const i=!e||Tt(this._target.x,this._targetEnd.x,this.restThreshold)&&Tt(this._target.y,this._targetEnd.y,this.restThreshold)&&Tt(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=me(t,this.minZoom,this.maxZoom),this._needsUpdate=!0,e||(this._zoom=this._zoomEnd);const i=!e||Tt(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(),we.setFromMatrixColumn(this._camera.matrix,0),be.setFromMatrixColumn(this._camera.matrix,1),we.multiplyScalar(t),be.multiplyScalar(-e);const s=_t.copy(we).add(be),n=Ct.copy(this._targetEnd).add(s);return this.moveTo(n.x,n.y,n.z,i)}forward(t,e=!1){_t.setFromMatrixColumn(this._camera.matrix,0),_t.crossVectors(this._camera.up,_t),_t.multiplyScalar(t);const i=Ct.copy(this._targetEnd).add(_t);return this.moveTo(i.x,i.y,i.z,e)}elevate(t,e=!1){return _t.copy(this._camera.up).multiplyScalar(t),this.moveTo(this._targetEnd.x+_t.x,this._targetEnd.y+_t.y,this._targetEnd.z+_t.z,e)}moveTo(t,e,i,s=!1){this._isUserControllingTruck=!1;const n=_t.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||Tt(this._target.x,this._targetEnd.x,this.restThreshold)&&Tt(this._target.y,this._targetEnd.y,this.restThreshold)&&Tt(this._target.z,this._targetEnd.z,this.restThreshold);return this._createOnRestPromise(o)}lookInDirectionOf(t,e,i,s=!1){const a=_t.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?_i.copy(t):_i.setFromObject(t);c.isEmpty()&&(console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"),Promise.resolve());const h=yo(this._sphericalEnd.theta,go),u=yo(this._sphericalEnd.phi,go);l.push(this.rotateTo(h,u,e));const f=_t.setFromSpherical(this._sphericalEnd).normalize(),d=To.setFromUnitVectors(f,wn),_=Tt(Math.abs(f.y),1);_&&d.multiply(vn.setFromAxisAngle(ps,h)),d.multiply(this._yAxisUpSpaceInverse);const m=Co.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(wn,f),_&&d.premultiply(vn.invert()),d.premultiply(this._yAxisUpSpace);const w=m.getSize(_t),g=m.getCenter(Ct).applyQuaternion(d);if(ii(this._camera)){const b=this.getDistanceToFitBox(w.x,w.y,w.z,i);l.push(this.moveTo(g.x,g.y,g.z,e)),l.push(this.dollyTo(b,e)),l.push(this.setFocalOffset(0,0,0,e))}else if(Ve(this._camera)){const b=this._camera,T=b.right-b.left,C=b.top-b.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?Gt.createBoundingSphere(t,bn):bn.copy(t);if(i.push(this.moveTo(n.center.x,n.center.y,n.center.z,e)),ii(this._camera)){const o=this.getDistanceToFitSphere(n.radius);i.push(this.dollyTo(o,e))}else if(Ve(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=_t.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||Tt(this._target.x,this._targetEnd.x,this.restThreshold)&&Tt(this._target.y,this._targetEnd.y,this.restThreshold)&&Tt(this._target.z,this._targetEnd.z,this.restThreshold)&&Tt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Tt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Tt(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=_t.set(...t.target);if("spherical"in t)ne.set(...t.spherical);else{const u=Ct.set(...t.position);ne.setFromVector3(u.sub(n).applyQuaternion(this._yAxisUpSpace))}const o=mi.set(...e.target);if("spherical"in e)gi.set(...e.spherical);else{const u=Ct.set(...e.position);gi.setFromVector3(u.sub(o).applyQuaternion(this._yAxisUpSpace))}this._targetEnd.copy(n.lerp(o,i)),this._sphericalEnd.set(ne.radius+(gi.radius-ne.radius)*i,ne.phi+(gi.phi-ne.phi)*i,ne.theta+(gi.theta-ne.theta)*i),this._needsUpdate=!0,s||(this._target.copy(this._targetEnd),this._spherical.copy(this._sphericalEnd));const h=!s||Tt(this._target.x,this._targetEnd.x,this.restThreshold)&&Tt(this._target.y,this._targetEnd.y,this.restThreshold)&&Tt(this._target.z,this._targetEnd.z,this.restThreshold)&&Tt(this._spherical.theta,this._sphericalEnd.theta,this.restThreshold)&&Tt(this._spherical.phi,this._sphericalEnd.phi,this.restThreshold)&&Tt(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(_t),o=this.setLookAt(n.x,n.y,n.z,t,e,i,s);return this._sphericalEnd.phi=me(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||Tt(this._focalOffset.x,this._focalOffsetEnd.x,this.restThreshold)&&Tt(this._focalOffset.y,this._focalOffsetEnd.y,this.restThreshold)&&Tt(this._focalOffset.z,this._focalOffsetEnd.z,this.restThreshold);return this._createOnRestPromise(n)}setOrbitPoint(t,e,i){this._camera.updateMatrixWorld(),we.setFromMatrixColumn(this._camera.matrixWorldInverse,0),be.setFromMatrixColumn(this._camera.matrixWorldInverse,1),si.setFromMatrixColumn(this._camera.matrixWorldInverse,2);const s=_t.set(t,e,i),n=s.distanceTo(this._camera.position),o=s.sub(this._camera.position);we.multiplyScalar(o.x),be.multiplyScalar(o.y),si.multiplyScalar(o.z),_t.copy(we).add(be).add(si),_t.z=_t.z+n,this.dollyTo(n,!1),this.setFocalOffset(-_t.x,_t.y,-_t.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 mt.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(yn(this._camera,"getDistanceToFitBox"))return this._spherical.radius;const n=t/e,o=this._camera.getEffectiveFOV()*Fi,a=this._camera.aspect;return.5*((s?n>a:n<a)?e:t/a)/Math.tan(.5*o)+.5*i}getDistanceToFitSphere(t){if(yn(this._camera,"getDistanceToFitSphere"))return this._spherical.radius;const e=this._camera.getEffectiveFOV()*Fi,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 mt.Vector3).copy(e?this._targetEnd:this._target)}getPosition(t,e=!0){return(t&&t.isVector3?t:new mt.Vector3).setFromSpherical(e?this._sphericalEnd:this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(e?this._targetEnd:this._target)}getSpherical(t,e=!0){return(t||new mt.Spherical).copy(e?this._sphericalEnd:this._spherical)}getFocalOffset(t,e=!0){return(t&&t.isVector3?t:new mt.Vector3).copy(e?this._focalOffsetEnd:this._focalOffset)}normalizeRotations(){return this._sphericalEnd.theta=(this._sphericalEnd.theta%Ue+Ue)%Ue,this._sphericalEnd.theta>Math.PI&&(this._sphericalEnd.theta-=Ue),this._spherical.theta+=Ue*Math.round((this._sphericalEnd.theta-this._spherical.theta)/Ue),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(!Tt(this._camera.up.x,this._cameraUp0.x)||!Tt(this._camera.up.y,this._cameraUp0.y)||!Tt(this._camera.up.z,this._cameraUp0.z)){this._camera.up.copy(this._cameraUp0);const i=this.getPosition(_t);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,ps),this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert()}applyCameraUp(){const t=_t.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(_t);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=vo.subVectors(this._targetEnd,this._target),o=xo.subVectors(this._focalOffsetEnd,this._focalOffset),a=this._zoomEnd-this._zoom;if(Mt(e)?(this._thetaVelocity.value=0,this._spherical.theta=this._sphericalEnd.theta):(this._spherical.theta=ds(this._spherical.theta,this._sphericalEnd.theta,this._thetaVelocity,this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime,1/0,t),this._needsUpdate=!0),Mt(i)?(this._phiVelocity.value=0,this._spherical.phi=this._sphericalEnd.phi):(this._spherical.phi=ds(this._spherical.phi,this._sphericalEnd.phi,this._phiVelocity,this._isUserControllingRotate?this.draggingSmoothTime:this.smoothTime,1/0,t),this._needsUpdate=!0),Mt(s)?(this._radiusVelocity.value=0,this._spherical.radius=this._sphericalEnd.radius):(this._spherical.radius=ds(this._spherical.radius,this._sphericalEnd.radius,this._radiusVelocity,this._isUserControllingDolly?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,t),this._needsUpdate=!0),Mt(n.x)&&Mt(n.y)&&Mt(n.z)?(this._targetVelocity.set(0,0,0),this._target.copy(this._targetEnd)):(wo(this._target,this._targetEnd,this._targetVelocity,this._isUserControllingTruck?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,t,this._target),this._needsUpdate=!0),Mt(o.x)&&Mt(o.y)&&Mt(o.z)?(this._focalOffsetVelocity.set(0,0,0),this._focalOffset.copy(this._focalOffsetEnd)):(wo(this._focalOffset,this._focalOffsetEnd,this._focalOffsetVelocity,this._isUserControllingOffset?this.draggingSmoothTime:this.smoothTime,this.maxSpeed,t,this._focalOffset),this._needsUpdate=!0),Mt(a)?(this._zoomVelocity.value=0,this._zoom=this._zoomEnd):this._zoom=ds(this._zoom,this._zoomEnd,this._zoomVelocity,this._isUserControllingZoom?this.draggingSmoothTime:this.smoothTime,1/0,t),this.dollyToCursor)if(ii(this._camera)&&0!==this._changedDolly){const u=this._spherical.radius-this._lastDistance,f=this._camera,d=this._getCameraDirection($i),_=_t.copy(d).cross(f.up).normalize();0===_.lengthSq()&&(_.x=1);const m=Ct.crossVectors(_,d),w=this._sphericalEnd.radius*Math.tan(f.getEffectiveFOV()*Fi*.5),b=(this._sphericalEnd.radius-u-this._sphericalEnd.radius)/this._sphericalEnd.radius,T=mi.copy(this._targetEnd).add(_.multiplyScalar(this._dollyControlCoord.x*w*f.aspect)).add(m.multiplyScalar(this._dollyControlCoord.y*w)),C=_t.copy(this._targetEnd).lerp(T,b);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,Mt(this._changedDolly)&&(this._changedDolly=0)}else if(Ve(this._camera)&&0!==this._changedZoom){const u=this._zoom-this._lastZoom,f=this._camera,d=_t.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=mi.copy(d).add(_.multiplyScalar(-d.dot(f.up))),g=-(this._zoom-u-this._zoom)/this._zoom,b=this._getCameraDirection($i),T=this._targetEnd.dot(b),C=_t.copy(this._targetEnd).lerp(m,g),S=C.dot(b),M=b.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,Mt(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),(!Mt(this._focalOffset.x)||!Mt(this._focalOffset.y)||!Mt(this._focalOffset.z))&&(this._camera.matrix.compose(this._camera.position,this._camera.quaternion,this._camera.scale),we.setFromMatrixColumn(this._camera.matrix,0),be.setFromMatrixColumn(this._camera.matrix,1),si.setFromMatrixColumn(this._camera.matrix,2),we.multiplyScalar(this._focalOffset.x),be.multiplyScalar(-this._focalOffset.y),si.multiplyScalar(this._focalOffset.z),_t.copy(we).add(be).add(si),this._camera.position.add(_t),this._camera.updateMatrixWorld()),this._boundaryEnclosesCamera&&this._encloseToBoundary(this._camera.position.copy(this._target),_t.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"}),Mt(e,this.restThreshold)&&Mt(i,this.restThreshold)&&Mt(s,this.restThreshold)&&Mt(n.x,this.restThreshold)&&Mt(n.y,this.restThreshold)&&Mt(n.z,this.restThreshold)&&Mt(o.x,this.restThreshold)&&Mt(o.y,this.restThreshold)&&Mt(o.z,this.restThreshold)&&Mt(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:Vi(this.maxDistance),minZoom:this.minZoom,maxZoom:Vi(this.maxZoom),minPolarAngle:this.minPolarAngle,maxPolarAngle:Vi(this.maxPolarAngle),minAzimuthAngle:Vi(this.minAzimuthAngle),maxAzimuthAngle:Vi(this.maxAzimuthAngle),smoothTime:this.smoothTime,draggingSmoothTime:this.draggingSmoothTime,dollySpeed:this.dollySpeed,truckSpeed:this.truckSpeed,dollyToCursor:this.dollyToCursor,target:this._targetEnd.toArray(),position:_t.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=Ui(i.maxDistance),this.minZoom=i.minZoom,this.maxZoom=Ui(i.maxZoom),this.minPolarAngle=i.minPolarAngle,this.maxPolarAngle=Ui(i.maxPolarAngle),this.minAzimuthAngle=Ui(i.minAzimuthAngle),this.maxAzimuthAngle=Ui(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),ne.setFromVector3(_t.fromArray(i.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)),this.rotateTo(ne.theta,ne.phi,e),this.dollyTo(ne.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,mi).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(ii(this._camera)){const t=this._camera,e=t.near,i=t.getEffectiveFOV()*Fi,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(Ve(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(ii(this._camera)){const a=_t.copy(this._camera.position).sub(this._target),l=this._camera.getEffectiveFOV()*Fi,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(!Ve(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(Ue*this.azimuthRotateSpeed*t/this._elementRect.height,Ue*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=me(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)||yn(this._camera,"_collisionTest"))return t;const i=this._getTargetDirection($i);xn.lookAt(bo,i,this._camera.up);for(let s=0;s<4;s++){const n=Ct.copy(this._nearPlaneCorners[s]);n.applyMatrix4(xn);const o=mi.addVectors(this._target,n);ms.set(o,i),ms.far=this._spherical.radius+1;const a=ms.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 mt.Sphere){const i=e,s=i.center;_i.makeEmpty(),t.traverseVisible(o=>{o.isMesh&&_i.expandByObject(o)}),_i.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++)_t.fromBufferAttribute(h,u),n=Math.max(n,s.distanceToSquared(_t))}),i.radius=Math.sqrt(n),i}}var ih=wt(8785),nh=Object.defineProperty,y=(r,t,e)=>(((r,t,e)=>{t in r?nh(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 Cn{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 Et extends Cn{}class Tn extends Cn{constructor(t){super(t),y(this,"worlds",new ft.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 oh extends Tn{constructor(){super(...arguments),y(this,"hasCameraControls",()=>"controls"in this)}}const So=class lo extends Et{constructor(t){super(t),y(this,"_disposedComponents",new Set),y(this,"enabled",!0),t.add(lo.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&&lo.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(So,"uuid","76e9cd8e-ad8f-4753-9ef6-cbc60f7247fe");let yi=So;class lh extends Tn{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(yi);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 Pn=class Ht{static create(){const t=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0,s=4294967295*Math.random()|0;return`${Ht._lut[255&t]+Ht._lut[t>>8&255]+Ht._lut[t>>16&255]+Ht._lut[t>>24&255]}-${Ht._lut[255&e]}${Ht._lut[e>>8&255]}-${Ht._lut[e>>16&15|64]}${Ht._lut[e>>24&255]}-${Ht._lut[63&i|128]}${Ht._lut[i>>8&255]}-${Ht._lut[i>>16&255]}${Ht._lut[i>>24&255]}${Ht._lut[255&s]}${Ht._lut[s>>8&255]}${Ht._lut[s>>16&255]}${Ht._lut[s>>24&255]}`.toLowerCase()}static validate(t){if(!Ht._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(Pn,"_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(Pn,"_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 te=Pn;const Eo=":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",uh=new RegExp("^["+Eo+"]["+Eo+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function Ao(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 gs=function(r){const t=uh.exec(r);return!(null===t||typeof t>"u")},Sn=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],Mo=["__proto__","constructor","prototype"],fh={allowBooleanAttributes:!1,unpairedTags:[]};function Io(r){return" "===r||"\t"===r||"\n"===r||"\r"===r}function Oo(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 Lt("InvalidXml","XML declaration allowed only at the start of the document.",Wt(r,t));if("?"==r[t]&&">"==r[t+1]){t++;break}continue}return t}function zo(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 _h(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 yh=new RegExp("(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['\"])(([\\s\\S])*?)\\5)?","g");function ko(r,t){const e=Ao(r,yh),i={};for(let s=0;s<e.length;s++){if(0===e[s][1].length)return Lt("InvalidAttr","Attribute '"+e[s][2]+"' has no space in starting.",ji(e[s]));if(void 0!==e[s][3]&&void 0===e[s][4])return Lt("InvalidAttr","Attribute '"+e[s][2]+"' is without value.",ji(e[s]));if(void 0===e[s][3]&&!t.allowBooleanAttributes)return Lt("InvalidAttr","boolean attribute '"+e[s][2]+"' is not allowed.",ji(e[s]));const n=e[s][2];if(!vh(n))return Lt("InvalidAttr","Attribute '"+n+"' is an invalid name.",ji(e[s]));if(Object.prototype.hasOwnProperty.call(i,n))return Lt("InvalidAttr","Attribute '"+n+"' is repeated.",ji(e[s]));i[n]=1}return!0}function bh(r,t){if(";"===r[++t])return-1;if("#"===r[t])return function wh(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 Lt(r,t,e){return{err:{code:r,msg:t,line:e.line||e,col:e.col}}}function vh(r){return gs(r)}function xh(r){return gs(r)}function Wt(r,t){const e=r.substring(0,t).split(/\r?\n/);return{line:e.length,col:e[e.length-1].length+1}}function ji(r){return r.startIndex+r[1].length}const Ch={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"},Do={amp:"&",apos:"'",gt:">",lt:"<",quot:'"'},Th={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"},Ph=new Set("!?\\\\/[]$%{}^&*()<>|+");function Lo(r){if("#"===r[0])throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${r}"`);for(const t of r)if(Ph.has(t))throw new Error(`[EntityReplacer] Invalid character '${t}' in entity name: "${r}"`);return r}function En(...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 ni="external",_s="base",ee=Object.freeze({allow:0,leave:1,remove:2,throw:3}),Eh=new Set([9,10,13]);class Mh{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 Sh(r){return r&&r!==ni?"all"===r?new Set(["all"]):r===_s?new Set([_s]):Array.isArray(r)?new Set(r):new Set([ni]):new Set([ni])}(this._limit.applyLimitsTo??ni),this._numericAllowed=t.numericAllowed??!0,this._baseMap=En(Do,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 Ah(r){return r?{xmlVersion:1.1===r.xmlVersion?1.1:1,onLevel:ee[r.onNCR]??ee.allow,nullLevel:Math.max(ee[r.nullNCR]??ee.remove,ee.remove)}:{xmlVersion:1,onLevel:ee.allow,nullLevel:ee.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))Lo(e);this._externalMap=En(t)}addExternalEntity(t,e){Lo(t),"string"==typeof e&&-1===e.indexOf("&")&&(this._externalMap[t]=e)}addInputEntities(t){this._totalExpansions=0,this._expandedLength=0,this._inputMap=En(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===_&&(_=ni);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,_=_s}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:ni}:t in this._externalMap?{value:this._externalMap[t],tier:ni}:t in this._baseMap?{value:this._baseMap[t],tier:_s}:void 0}_classifyNCR(t){return 0===t?this._ncrNullLevel:t>=55296&&t<=57343||1===this._ncrXmlVersion&&t>=1&&t<=31&&!Eh.has(t)?ee.remove:-1}_applyNCRAction(t,e,i){switch(t){case ee.allow:return String.fromCodePoint(i);case ee.remove:return"";case ee.leave:return;case ee.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<ee.remove)return;const n=-1===s?this._ncrOnLevel:Math.max(this._ncrOnLevel,s);return this._applyNCRAction(n,t,i)}}const No=r=>Sn.includes(r)?"__"+r:r,Ih={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:No};function Oh(r,t){if("string"!=typeof r)return;const e=r.toLowerCase();if(Sn.some(i=>e===i.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${r}" is a reserved JavaScript keyword that could cause prototype pollution`);if(Mo.some(i=>e===i.toLowerCase()))throw new Error(`[SECURITY] Invalid ${t}: "${r}" is a reserved JavaScript keyword that could cause prototype pollution`)}function Bo(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"}:Bo(!0)}const zh=function(r){const t=Object.assign({},Ih,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&&Oh(i,s);return null===t.onDangerousProperty&&(t.onDangerousProperty=No),t.processEntities=Bo(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 ys;ys="function"!=typeof Symbol?"@@xmlMetadata":Symbol("XML Node Metadata");class $e{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][ys]={startIndex:e})}static getMetaDataSymbol(){return ys}}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&&ri(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&&ri(t,"!ELEMENT",e)){e+=8;const{index:c}=this.readElementExp(t,e+1);e=c}else if(o&&ri(t,"!ATTLIST",e))e+=8;else if(o&&ri(t,"!NOTATION",e)){e+=9;const{index:c}=this.readNotationExp(t,e+1,this.suppressValidationErr);e=c}else{if(!ri(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=ie(t,e);for(;e<t.length&&!/\s/.test(t[e])&&'"'!==t[e]&&"'"!==t[e];)e++;let s=t.substring(i,e);if(Hi(s),e=ie(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=ie(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let s=t.substring(i,e);!this.suppressValidationErr&&Hi(s),e=ie(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=ie(t,e+=n.length);let o=null,a=null;if("PUBLIC"===n)[e,o]=this.readIdentifierVal(t,e,"publicIdentifier"),('"'===t[e=ie(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=ie(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let s=t.substring(i,e);if(!this.suppressValidationErr&&!gs(s))throw new Error(`Invalid element name: "${s}"`);let n="";if("E"===t[e=ie(t,e)]&&ri(t,"MPTY",e))e+=4;else if("A"===t[e]&&ri(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=ie(t,e);for(;e<t.length&&!/\s/.test(t[e]);)e++;let s=t.substring(i,e);for(Hi(s),i=e=ie(t,e);e<t.length&&!/\s/.test(t[e]);)e++;let n=t.substring(i,e);if(!Hi(n))throw new Error(`Invalid attribute name: "${n}"`);e=ie(t,e);let o="";if("NOTATION"===t.substring(e,e+8).toUpperCase()){if(o="NOTATION","("!==t[e=ie(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(),!Hi(h))throw new Error(`Invalid notation name: "${h}"`);l.push(h),"|"===t[e]&&(e++,e=ie(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=ie(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 ie=(r,t)=>{for(;t<r.length&&/\s/.test(r[t]);)t++;return t};function ri(r,t,e){for(let i=0;i<t.length;i++)if(t[i]!==r[e+i+1])return!1;return!0}function Hi(r){if(gs(r))return r;throw new Error(`Invalid entity name ${r}`)}const Dh=/^[-+]?0x[a-fA-F0-9]+$/,Lh=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Nh={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0,infinity:"original"};const Rh=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;class wi{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 Hh{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 qh{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 Mn{constructor(t={}){this.separator=t.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new qh(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 Gh(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 Yh(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 Zh{constructor(t,e){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=Jh,this.parseTextData=Wh,this.resolveNameSpace=Xh,this.buildAttributesMap=Qh,this.isItStopNode=su,this.replaceEntitiesValue=eu,this.readStopNodeData=ou,this.saveTextToParentTag=iu,this.addChild=tu,this.ignoreAttributesFn=function jh(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={...Do};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:("object"==typeof this.options.htmlEntities?i=this.options.htmlEntities:!0===this.options.htmlEntities&&(i={...Th,...Ch}),this.entityDecoder=new Mh({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 Mn,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new Hh;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 wi(o)):o instanceof wi&&this.stopNodeExpressionsSet.add(o)}this.stopNodeExpressionsSet.seal()}}}function Wh(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?On(r,a.parseTagValue,a.numberParseOptions):r}}function Xh(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 Kh=new RegExp("([^\\s=]+)\\s*(=\\s*(['\"])([\\s\\S]*?)\\3)?","gm");function Qh(r,t,e,i=!1){const s=this.options;if(!0===i||!0!==s.ignoreAttributes&&"string"==typeof r){const n=Ao(r,Kh),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=Ro(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:On(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 Jh=function(r){r=r.replace(/\r\n?/g,"\n");const t=new $e("!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=bi(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=zn(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=In(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 $e(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=bi(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=bi(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=In(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}=zn(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,b=null;T=Yh(f),u!==t.tagname&&this.matcher.push(u,{},T),u!==d&&_&&(b=this.buildAttributesMap(d,this.matcher,u),b&&Gh(b,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 $e(u);b&&(M[":@"]=b),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}=zn(s.transformTagName,u,d,s));const S=new $e(u);b&&(S[":@"]=b),this.addChild(e,S,this.readonlyMatcher,C),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(s.unpairedTagsSet.has(u)){const S=new $e(u);b&&(S[":@"]=b),this.addChild(e,S,this.readonlyMatcher,C),this.matcher.pop(),this.isCurrentNodeStopNode=!1,a=h.closeIndex;continue}{const S=new $e(u);if(this.tagsNodeStack.length>s.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(e),b&&(S[":@"]=b),this.addChild(e,S,this.readonlyMatcher,C),e=S}}i="",a=m}}}else i+=r[a];return t.child};function tu(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 eu(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 iu(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 su(){return 0!==this.stopNodeExpressionsSet.size&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function bi(r,t,e,i){const s=r.indexOf(t,e);if(-1===s)throw new Error(i);return s+t.length-1}function ru(r,t,e,i){const s=r.indexOf(t,e);if(-1===s)throw new Error(i);return s}function In(r,t,e,i=">"){const s=function nu(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 ou(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=ru(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=bi(r,"?>",e+1,"StopNode is not closed.");else if(33===o&&45===r.charCodeAt(e+2)&&45===r.charCodeAt(e+3))e=bi(r,"--\x3e",e+3,"StopNode is not closed.");else if(33===o&&91===r.charCodeAt(e+2))e=bi(r,"]]>",e,"StopNode is not closed.")-2;else{const a=In(r,e,">");a&&((a&&a.tagName)===t&&"/"!==a.tagExp[a.tagExp.length-1]&&s++,e=a.closeIndex)}}}function On(r,t,e){if(t&&"string"==typeof r){const i=r.trim();return"true"===i||"false"!==i&&function Bh(r,t={}){if(t=Object.assign({},Nh,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&&Dh.test(e))return function Uh(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 Fh(r,t,e){if(!e.eNotation)return r;const i=t.match(Rh);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=Lh.exec(e);if(i){const s=i[1]||"",n=i[2];let o=function Vh(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 $h(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 dh(r){return typeof r<"u"}(r)?r:""}function zn(r,t,e,i){if(r){const s=r(t);e===t&&(e=s),t=s}return{tagName:t=Ro(t,i),tagExp:e}}function Ro(r,t){if(Mo.includes(r))throw new Error(`[SECURITY] Invalid name: "${r}" is a reserved JavaScript keyword that could cause prototype pollution`);return Sn.includes(r)?t.onDangerousProperty(r):r}const kn=$e.getMetaDataSymbol();function au(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 lu(r,t,e,i){return Fo(r,t,e,i)}function Fo(r,t,e,i){let s;const n={};for(let o=0;o<r.length;o++){const a=r[o],l=cu(a);if(void 0!==l&&l!==t.textNodeName){const c=au(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=Fo(a[l],t,e,i);const h=uu(c,t);if(a[":@"]?hu(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[kn]&&"object"==typeof c&&null!==c&&(c[kn]=a[kn]),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 cu(r){const t=Object.keys(r);for(let e=0;e<t.length;e++){const i=t[e];if(":@"!==i)return i}}function hu(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 uu(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 Dn{constructor(t){this.externalEntities={},this.options=zh(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 ph(r,t){t=Object.assign({},fh,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=Oo(r,n),n.err)return n}else{if("<"!==r[n]){if(Io(r[n]))continue;return Lt("InvalidChar","char '"+r[n]+"' is not expected.",Wt(r,n))}{let o=n;if(n++,"!"===r[n]){n=zo(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--),!xh(l)){let u;return u=0===l.trim().length?"Invalid space after '<'.":"Tag '"+l+"' is an invalid name.",Lt("InvalidTag",u,Wt(r,n))}const c=_h(r,n);if(!1===c)return Lt("InvalidAttr","Attributes for '"+l+"' have open quote.",Wt(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=ko(h,t);if(!0!==f)return Lt(f.err.code,f.err.msg,Wt(r,u+f.err.line));i=!0}else if(a){if(!c.tagClosed)return Lt("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",Wt(r,n));if(h.trim().length>0)return Lt("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",Wt(r,o));if(0===e.length)return Lt("InvalidTag","Closing tag '"+l+"' has not been opened.",Wt(r,o));{const u=e.pop();if(l!==u.tagName){let f=Wt(r,u.tagStartPos);return Lt("InvalidTag","Expected closing tag '"+u.tagName+"' (opened in line "+f.line+", col "+f.col+") instead of closing tag '"+l+"'.",Wt(r,o))}0==e.length&&(s=!0)}}else{const u=ko(h,t);if(!0!==u)return Lt(u.err.code,u.err.msg,Wt(r,n-h.length+u.err.line));if(!0===s)return Lt("InvalidXml","Multiple possible root nodes found.",Wt(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=zo(r,n);continue}if("?"!==r[n+1])break;if(n=Oo(r,++n),n.err)return n}else if("&"===r[n]){const u=bh(r,n);if(-1==u)return Lt("InvalidChar","char '&' is not expected.",Wt(r,n));n=u}else if(!0===s&&!Io(r[n]))return Lt("InvalidXml","Extra text at the end",Wt(r,n));"<"===r[n]&&n--}}}return i?1==e.length?Lt("InvalidTag","Unclosed tag '"+e[0].tagName+"'.",Wt(r,e[0].tagStartPos)):!(e.length>0)||Lt("InvalidXml","Invalid '"+JSON.stringify(e.map(n=>n.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):Lt("InvalidXml","Start tag expected.",1)}(t,e);if(!0!==n)throw Error(`${n.err.msg}:${n.err.line}:${n.err.col}`)}const i=new Zh(this.options,this.externalEntities),s=i.parseXml(t);return this.options.preserveOrder||void 0===s?s:lu(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 '
'");if("&"===e)throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=e}static getMetaDataSymbol(){return $e.getMetaDataSymbol()}}function fu(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 wi(o)):o instanceof wi&&i.push(o)}return Vo(r,t,e,new Mn,i)}function Vo(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=Ln(a,t),a}return""}for(let a=0;a<r.length;a++){const l=r[a],c=$o(l);if(void 0===c)continue;const h=pu(l[":@"],t);i.push(c,h);const u=gu(i,s);if(c===t.textNodeName){let w=l[c];u||(w=t.tagValueProcessor(c,w),w=Ln(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=jo(l[":@"],t,u);let b=l[c][0][t.textNodeName];b=0!==b.length?" "+b:"",n+=("?xml"===c?"":e)+`<${c}${b}${w}?>`,o=!0,i.pop();continue}let f=e;""!==f&&(f+=t.indentBy);const _=e+`<${c}${jo(l[":@"],t,u)}`;let m;m=u?Uo(l[c],t):Vo(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 pu(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 Uo(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=$o(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=mu(s[":@"],t),a=Uo(s[n],t);e+=a&&0!==a.length?`<${n}${o}>${a}</${n}>`:`<${n}${o}/>`}}}return e}function mu(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 $o(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 jo(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=Ln(n,t)),i+=!0===n&&t.suppressBooleanAttributes?` ${s.substr(t.attributeNamePrefix.length)}`:` ${s.substr(t.attributeNamePrefix.length)}="${n}"`}return i}function gu(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 Ln(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 yu={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:"&"},{regex:new RegExp(">","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0};function le(r){if(this.options=Object.assign({},yu,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 wi(e)):e instanceof wi&&this.stopNodeExpressions.push(e)}!0===this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.ignoreAttributesFn=function _u(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=vu),this.processTextOrObjNode=wu,this.options.format?(this.indentate=bu,this.tagEndChar=">\n",this.newLine="\n"):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function wu(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 vu(r){return!(!r.startsWith(this.options.attributeNamePrefix)||r===this.options.textNodeName)&&r.substr(this.attrPrefixLen)}le.prototype.build=function(r){if(this.options.preserveOrder)return fu(r,this.options);{Array.isArray(r)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(r={[this.options.arrayNodeName]:r});const t=new Mn;return this.j2x(r,0,t).val}},le.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}},le.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+'"'},le.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},le.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},le.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},le.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}},le.prototype.closeTag=function(r){let t="";return-1!==this.options.unpairedTags.indexOf(r)?this.options.suppressUnpairedNode||(t="/"):t=this.options.suppressEmptyNode?"/":`></${r}`,t},le.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},le.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}},le.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 ws{}y(ws,"parser",new Dn({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(ws,"builder",new le({attributeNamePrefix:"$",ignoreAttributes:!1,suppressBooleanAttributes:!1}));class Nt{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=Nt.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=Nt.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=Nt.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 Nn{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 qi{constructor(t,e,i,s){y(this,"_component"),y(this,"name"),y(this,"uuid"),this._component=t,this.name=i,this.uuid=s??te.create(),e.get(bs).list.set(this.uuid,this)}get controls(){return Nn.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(Nn.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(Nn.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 Ho=class Lc extends Et{constructor(t){super(t),y(this,"list",new ft.jp),y(this,"enabled",!0),t.add(Lc.uuid,this)}};y(Ho,"uuid","b8c764e0-6b24-4e77-9a32-35fa728ee5b4");let bs=Ho;class qo{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 vs=Math.pow(2,-24),Fn=Symbol("SKIP_GENERATION"),Xo={strategy:0,maxDepth:40,maxLeafSize:10,useSharedArrayBuffer:!1,setBoundingBox:!0,onProgress:null,indirect:!1,verbose:!0,range:null,[Fn]:!1};function Dt(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 Ko(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 Qo(r,t){t.set(r)}function Jo(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 xs(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 Gi(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 Ft(r,t){return 65535===t[r+15]}function Zt(r,t){return t[r+6]}function Xt(r,t){return t[r+14]}function Ut(r){return r+8}function $t(r,t){return r+8*t[r+6]}function Vn(r,t){return t[r+7]}function Un(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 b=6*(t-g),T=6*(t+e-g);b<T;b+=6){const C=r[b+0],S=r[b+1],M=C-S,A=C+S;M<n&&(n=M),A>l&&(l=A),C<u&&(u=C),C>_&&(_=C);const O=r[b+2],I=r[b+3],k=O-I,B=O+I;k<o&&(o=k),B>c&&(c=B),O<f&&(f=O),O>m&&(m=O);const E=r[b+4],L=r[b+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 Pu=(r,t)=>r.candidate-t.candidate,je=new Array(32).fill().map(()=>({count:0,bounds:new Float32Array(6),rightCacheBounds:new Float32Array(6),leftCacheBounds:new Float32Array(6),candidate:0})),Cs=new Float32Array(6);class $n{constructor(){this.boundingData=new Float32Array(6)}}let ta,Ts,jn,ea;const Mu=Math.pow(2,32);function Hn(r){return"count"in r?1:1+Hn(r.left)+Hn(r.right)}function Iu(r,t,e){return ta=new Float32Array(e),Ts=new Uint32Array(e),jn=new Uint16Array(e),ea=new Uint8Array(e),qn(r,t)}function qn(r,t){const e=r/4,i=r/2,s="count"in t,n=t.boundingData;for(let o=0;o<6;o++)ta[e+o]=n[o];if(s)return t.buffer?(ea.set(new Uint8Array(t.buffer),r),r+t.buffer.byteLength):(Ts[e+6]=t.offset,jn[i+14]=t.count,jn[i+15]=65535,r+32);{const{left:o,right:a,splitAxis:l}=t;let h=qn(r+32,o);const d=h/32-r/32;if(d>Mu)throw new Error("MeshBVH: Cannot store relative child node offset greater than 32 bits.");return Ts[e+6]=d,Ts[e+7]=l,qn(h,a)}}function zu(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 Ou(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 $n;return Un(t,e,i,m.boundingData,d),function g(b,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),b.offset=T,b.count=C,b;const A=function Su(r,t,e,i,s,n){let o=-1,a=0;if(0===n)o=Ko(t),-1!==o&&(a=(t[o]+t[o+3])/2);else if(1===n)o=Ko(r),-1!==o&&(a=function Eu(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=Gi(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 b=[...je];b.length=s;let T=0;for(let S=u;S<f;S+=6,T++){const M=b[T];M.candidate=e[S+2*d],M.count=0;const{bounds:A,leftCacheBounds:O,rightCacheBounds:I}=M;for(let k=0;k<3;k++)I[k]=1/0,I[k+3]=-1/0,O[k]=1/0,O[k+3]=-1/0,A[k]=1/0,A[k+3]=-1/0;xs(S,e,A)}b.sort(Pu);let C=s;for(let S=0;S<C;S++){const M=b[S];for(;S+1<C&&b[S+1].candidate===M.candidate;)b.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=b[A];M>=O.candidate?xs(S,e,O.rightCacheBounds):(xs(S,e,O.leftCacheBounds),O.count++)}}for(let S=0;S<C;S++){const M=b[S],A=M.count,O=s-M.count,k=M.rightCacheBounds;let B=0;0!==A&&(B=Gi(M.leftCacheBounds)/l);let E=0;0!==O&&(E=Gi(k)/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=je[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=je[A];O.count++,xs(C,e,O.bounds)}const b=je[31];Qo(b.bounds,b.rightCacheBounds);for(let C=30;C>=0;C--){const S=je[C];Jo(S.bounds,je[C+1].rightCacheBounds,S.rightCacheBounds)}let T=0;for(let C=0;C<31;C++){const S=je[C],M=S.count,A=S.bounds,I=je[C+1].rightCacheBounds;0!==M&&(0===T?Qo(A,Cs):Jo(A,Cs,Cs)),T+=M;let k=0,B=0;0!==T&&(k=Gi(Cs)/l);const E=s-T;0!==E&&(B=Gi(I)/l);const L=1+1.25*(k*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}}(b.boundingData,S,t,T,C,c);if(-1===A.axis)return w(T+C),b.offset=T,b.count=C,b;const O=function Au(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),b.offset=T,b.count=C;else{b.splitAxis=A.axis;const I=new $n,k=T,B=O-T;b.left=I,Un(t,k,B,I.boundingData,d),g(I,k,B,d,M+1);const E=new $n,L=O,x=C-B;b.right=E,Un(t,L,x,E.boundingData,d),g(E,L,x,d,M+1)}return b}(m,e,i,d),m;function w(b){h&&h((b-n.offset)/n.count)}}(r,a,l.offset,l.count,t,o),h=Hn(c),u=new e(32*h);return Iu(0,c,u),u})}class Ps{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 It=new ku;let He,vi;const xi=[],Ss=new Ps(()=>new p.NRn);function Du(r,t,e,i,s,n){He=Ss.getPrimitive(),vi=Ss.getPrimitive(),xi.push(He,vi),It.setBuffer(r._roots[t]);const o=Gn(0,r.geometry,e,i,s,n);It.clearBuffer(),Ss.releasePrimitive(He),Ss.releasePrimitive(vi),xi.pop(),xi.pop();const a=xi.length;return a>0&&(vi=xi[a-1],He=xi[a-2]),o}function Gn(r,t,e,i,s=null,n=0,o=0){const{float32Array:a,uint16Array:l,uint32Array:c}=It;let h=2*r;if(Ft(h,l)){const f=Zt(r,c),d=Xt(h,l);return Dt(r,a,He),i(f,d,!1,o,n+r/8,He)}{let f=function(E){const{uint16Array:L,uint32Array:x}=It;let N=2*E;for(;!Ft(N,L);)N=2*(E=Ut(E));return Zt(E,x)},d=function(E){const{uint16Array:L,uint32Array:x}=It;let N=2*E;for(;!Ft(N,L);)N=2*(E=$t(E,x));return Zt(E,x)+Xt(N,L)};const _=Ut(r),m=$t(r,c);let b,T,C,S,w=_,g=m;if(s&&(C=He,S=vi,Dt(w,a,C),Dt(g,a,S),b=s(C),T=s(S),T<b)){w=m,g=_;const E=b;b=T,T=E,C=S}C||(C=He,Dt(w,a,C));const A=e(C,Ft(2*w,l),b,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&&Gn(w,t,e,i,s,n,o+1);if(O)return!0;S=vi,Dt(g,a,S);const k=e(S,Ft(2*g,l),T,o+1,n+g/8);let B;if(2===k){const E=f(g);B=i(E,d(g)-E,!0,o+1,n+g/8,S)}else B=k&&Gn(g,t,e,i,s,n,o+1);return!!B}}const Yi=new It.constructor,Es=new It.constructor,qe=new Ps(()=>new p.NRn),Ci=new p.NRn,Ti=new p.NRn,Yn=new p.NRn,Zn=new p.NRn;let Wn=!1;function ge(r,t,e,i,s,n=0,o=0,a=0,l=0,c=null,h=!1){let u,f;h?(u=Es,f=Yi):(u=Yi,f=Es);const d=u.float32Array,_=u.uint32Array,m=u.uint16Array,w=f.float32Array,g=f.uint32Array,b=f.uint16Array,C=2*t,S=Ft(2*r,m),M=Ft(C,b);let A=!1;if(M&&S)A=h?s(Zt(t,g),Xt(2*t,b),Zt(r,_),Xt(2*r,m),l,o+t/8,a,n+r/8):s(Zt(r,_),Xt(2*r,m),Zt(t,g),Xt(2*t,b),a,n+r/8,l,o+t/8);else if(M){const O=qe.getPrimitive();Dt(t,w,O),O.applyMatrix4(e);const I=Ut(r),k=$t(r,_);Dt(I,d,Ci),Dt(k,d,Ti);const B=O.intersectsBox(Ci),E=O.intersectsBox(Ti);A=B&&ge(t,I,i,e,s,o,n,l,a+1,O,!h)||E&&ge(t,k,i,e,s,o,n,l,a+1,O,!h),qe.releasePrimitive(O)}else{const O=Ut(t),I=$t(t,g);Dt(O,w,Yn),Dt(I,w,Zn);const k=c.intersectsBox(Yn),B=c.intersectsBox(Zn);if(k&&B)A=ge(r,O,e,i,s,n,o,a,l+1,c,h)||ge(r,I,e,i,s,n,o,a,l+1,c,h);else if(k)if(S)A=ge(r,O,e,i,s,n,o,a,l+1,c,h);else{const E=qe.getPrimitive();E.copy(Yn).applyMatrix4(e);const L=Ut(r),x=$t(r,_);Dt(L,d,Ci),Dt(x,d,Ti);const N=E.intersectsBox(Ci),Y=E.intersectsBox(Ti);A=N&&ge(O,L,i,e,s,o,n,l,a+1,E,!h)||Y&&ge(O,x,i,e,s,o,n,l,a+1,E,!h),qe.releasePrimitive(E)}else if(B)if(S)A=ge(r,I,e,i,s,n,o,a,l+1,c,h);else{const E=qe.getPrimitive();E.copy(Zn).applyMatrix4(e);const L=Ut(r),x=$t(r,_);Dt(L,d,Ci),Dt(x,d,Ti);const N=E.intersectsBox(Ci),Y=E.intersectsBox(Ti);A=N&&ge(I,L,i,e,s,o,n,l,a+1,E,!h)||Y&&ge(I,x,i,e,s,o,n,l,a+1,E,!h),qe.releasePrimitive(E)}}return A}const ia=new p.NRn,Pi=new Float32Array(6);class sa{constructor(){this._roots=null,this.primitiveBuffer=null,this.primitiveBufferStride=null}init(t){zu(this,t={...Xo,...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,Pi,0);const[d,_,m,w,g,b]=Pi;d<n&&(n=d),w>l&&(l=w),_<o&&(o=_),g>c&&(c=g),m<a&&(a=m),b>h&&(h=b)}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,Pi,0);const[a,l,c,h,u,f]=Pi,d=(a+h)/2,_=(l+u)/2,m=(c+f)/2,w=(h-a)/2,g=(u-l)/2,b=(f-c)/2,T=6*(n-s);i[T+0]=d,i[T+1]=w+(Math.abs(d)+w)*vs,i[T+2]=_,i[T+3]=g+(Math.abs(_)+g)*vs,i[T+4]=m,i[T+5]=b+(Math.abs(m)+b)*vs}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;Ft(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=Ft(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=Ut(a),f=$t(a,s),d=Vn(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(Ft(u,o)){const d=Zt(h,n),_=Xt(u,o);this.writePrimitiveRangeBounds(d,_,Pi,0),a.set(Pi,h)}else{const d=Ut(h),_=$t(h,n);for(let m=0;m<3;m++){const w=a[d+m],g=a[d+m+3],b=a[_+m],T=a[_+m+3];a[h+m]=w<b?w:b,a[h+m+3]=g>T?g:T}}}}}getBoundingBox(t){return t.makeEmpty(),this._roots.forEach(i=>{Dt(0,new Float32Array(i),ia),t.union(ia)}),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=Du(this,u,i,s,e,c),l)break;c+=d.byteLength/32}return l}bvhcast(t,e,i){let{intersectsRanges:s}=i;return function Lu(r,t,e,i){if(Wn)throw new Error("MeshBVH: Recursive calls to bvhcast not supported.");Wn=!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++){Yi.setBuffer(s[h]),l=0;const f=qe.getPrimitive();Dt(0,Yi.float32Array,f),f.applyMatrix4(c);for(let d=0,_=n.length;d<_&&(Es.setBuffer(n[d]),o=ge(0,0,e,c,i,a,l,0,0,f),Es.clearBuffer(),l+=n[d].byteLength/32,!o);d++);if(qe.releasePrimitive(f),Yi.clearBuffer(),a+=s[h].byteLength/32,o)break}return Wn=!1,o}(this,t,e,s)}}function Xn(r){return r.index?r.index.count:r.attributes.position.count}function As(r){return Xn(r)/3}function na(r,t,e){const i=function Fu(r,t,e){const i=Xn(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 Vu(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=Xn(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 ra extends sa{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 Nu(){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={...Xo,...e})[Fn]||this.init(e)}init(t){const{geometry:e,primitiveStride:i}=this;if(t.indirect){const n=function Uu(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}(na(e,t.range,i),t.useSharedArrayBuffer);this._indirectBuffer=n}else!function Ru(r,t){if(!r.index){const e=r.attributes.position.count,s=function Bu(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}]:na(this.geometry,t,this.primitiveStride)}raycastObject3D(){throw new Error("BVH: raycastObject3D() not implemented")}}class Ae{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}}Ae.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 $u=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,b;g=0!==w?(u*f-_*d)/w:0,b=(u+g*f)/d,o.x=g,o.y=b}}(),Kn=function(){const r=new p.I9Y,t=new p.Pq0,e=new p.Pq0;return function(s,n,o,a){$u(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))}}}(),ju=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}}(),Hu=["x","y","z"],Me=1e-15;function ce(r){return Math.abs(r)<Me}class re 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 Ae),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 ju(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<Me?w<Me||g<Me?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(t),this.degenerateSegment.end.copy(i)):w<Me?g<Me?this.isDegenerateIntoPoint=!0:(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(e),this.degenerateSegment.end.copy(t)):g<Me&&(this.isDegenerateIntoSegment=!0,this.degenerateSegment.start.copy(i),this.degenerateSegment.end.copy(e)),this.plane.setFromNormalAndCoplanarPoint(a,t),this.needsUpdate=!1}}re.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]),Kn(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)}}(),re.prototype.intersectsTriangle=function(){const r=new re,t=new Ae,e=new Ae,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 k=C.satBounds,B=C.satAxes;for(let E=1;E<4;E++){const L=k[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,k,B,E,L){let x=I/(I-k);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,k,B,E,L){if(A>0)d(T.c,T.a,T.b,M,C,S,B,I,k,E,L);else if(O>0)d(T.b,T.a,T.c,S,C,M,k,I,B,E,L);else if(k*B>0||0!=I)d(T.a,T.b,T.c,C,S,M,I,k,B,E,L);else if(0!=k)d(T.b,T.a,T.c,S,C,M,k,I,B,E,L);else{if(0==B)return!0;d(T.c,T.a,T.b,M,C,S,B,I,k,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 ce(O)?ce(I)?f(T,C,S,M):(S&&(S.start.copy(A.start),S.end.copy(A.start)),T.containsPoint(A.start)):ce(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!(!ce(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 b(T,C,S,M){if(T.isDegenerateIntoSegment){if(C.isDegenerateIntoSegment){const A=T.degenerateSegment,O=C.degenerateSegment,I=s,k=n;A.delta(I),O.delta(k);const B=i.subVectors(O.start,A.start),E=I.x*k.y-I.y*k.x;if(ce(E))return!1;const L=(B.x*k.y-B.y*k.x)/E,x=-(I.x*B.y-I.y*B.x)/E;return!(L<0||L>1||x<0||x>1||!ce(A.start.z+I.z*L-(O.start.z+k.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 k=I.distanceToPoint(this.a),B=I.distanceToPoint(this.b),E=I.distanceToPoint(this.c);ce(k)&&(k=0),ce(B)&&(B=0),ce(E)&&(E=0);const L=k*B,x=k*E;if(L>0&&x>0)return!1;let N=O.distanceToPoint(C.a),Y=O.distanceToPoint(C.b),q=O.distanceToPoint(C.c);ce(N)&&(N=0),ce(Y)&&(Y=0),ce(q)&&(q=0);const lt=N*Y,Z=N*q;if(lt>0&&Z>0)return!1;s.copy(O.normal),n.copy(I.normal);const rt=s.cross(n);let F=0,V=Math.abs(rt.x);const st=Math.abs(rt.y);st>V&&(V=st,F=1),Math.abs(rt.z)>V&&(F=2);const J=Hu[F],nt=C.a[J],ct=C.b[J],pt=C.c[J];if(_(this,this.a[J],this.b[J],this.c[J],L,x,k,B,E,h,a))return f(this,C,S,M);if(_(C,nt,ct,pt,lt,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))}}(),re.prototype.distanceToPoint=function(){const r=new p.Pq0;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),re.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]]),Kn(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 Kt{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 Ae),this.alignedSatBounds=new Array(3).fill().map(()=>new Ae),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}}Kt.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}}(),Kt.prototype.intersectsBox=function(){const r=new Ae;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}}(),Kt.prototype.intersectsTriangle=function(){const r=new re,t=new Array(3),e=new Ae,i=new Ae,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}}(),Kt.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}}(),Kt.prototype.distanceToPoint=function(){const r=new p.Pq0;return function(e){return this.closestPointToPoint(e,r),e.distanceTo(r)}}(),Kt.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 b=g.distanceToSquared(s);if(b<_&&(_=b,l&&l.copy(g),c&&c.copy(s),b<h))return Math.sqrt(b)}let m=0;for(let w=0;w<3;w++)for(let g=0;g<=1;g++)for(let b=0;b<=1;b++){const T=(w+1)%3,C=(w+2)%3;t[m].set(d[g<<T|b<<C],d[1<<w|g<<T|b<<C]);const k=r[w],B=r[T],E=r[C],L=e[m],x=L.start,N=L.end;x[k]=u[k],x[B]=g?u[B]:f[B],x[E]=b?u[E]:f[B],N[k]=f[k],N[B]=g?u[B]:f[B],N[E]=b?u[E]:f[B],m++}for(let w=0;w<=1;w++)for(let g=0;g<=1;g++)for(let b=0;b<=1;b++){s.x=w?f.x:u.x,s.y=g?f.y:u.y,s.z=b?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 b=0;b<12;b++){Kn(g,e[b],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 qu extends Ps{constructor(){super(()=>new re)}}const he=new qu,Zi=new p.Pq0,Qn=new p.Pq0,Ms=parseInt(p.sPf)>=169,Yu=parseInt(p.sPf)<=161,oi=new p.Pq0,ai=new p.Pq0,li=new p.Pq0,Is=new p.I9Y,Os=new p.I9Y,zs=new p.I9Y,aa=new p.Pq0,la=new p.Pq0,ca=new p.Pq0,Wi=new p.Pq0;function ha(r,t,e,i,s,n,o,a,l,c,h){oi.fromBufferAttribute(t,n),ai.fromBufferAttribute(t,o),li.fromBufferAttribute(t,a);const u=function Zu(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,oi,ai,li,Wi,l,c,h);if(u){if(i){Is.fromBufferAttribute(i,n),Os.fromBufferAttribute(i,o),zs.fromBufferAttribute(i,a),u.uv=new p.I9Y;const d=p.lMl.getInterpolation(Wi,oi,ai,li,Is,Os,zs,u.uv);Ms||(u.uv=d)}if(s){Is.fromBufferAttribute(s,n),Os.fromBufferAttribute(s,o),zs.fromBufferAttribute(s,a),u.uv1=new p.I9Y;const d=p.lMl.getInterpolation(Wi,oi,ai,li,Is,Os,zs,u.uv1);Ms||(u.uv1=d),Yu&&(u.uv2=u.uv1)}if(e){aa.fromBufferAttribute(e,n),la.fromBufferAttribute(e,o),ca.fromBufferAttribute(e,a),u.normal=new p.Pq0;const d=p.lMl.getInterpolation(Wi,oi,ai,li,aa,la,ca,u.normal);u.normal.dot(r.direction)>0&&u.normal.multiplyScalar(-1),Ms||(u.normal=d)}const f={a:n,b:o,c:a,normal:new p.Pq0,materialIndex:0};if(p.lMl.getNormal(oi,ai,li,f.normal),u.face=f,u.faceIndex=n,Ms){const d=new p.Pq0;p.lMl.getBarycoord(Wi,oi,ai,li,d),u.barycoord=d}}return u}function ua(r){return r&&r.isMaterial?r.side:r}function ks(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 b=0,T=f.length;b<T;b++){const{start:C,count:S,materialIndex:M}=f[b];if(g>=C&&g<C+S){const O=ha(e,d,_,m,w,l,c,h,ua(t[M]),n,o);if(O){if(O.faceIndex=i,O.face.materialIndex=M,!s)return O;s.push(O)}}}}else{const b=ha(e,d,_,m,w,l,c,h,ua(t),n,o);if(b){if(b.faceIndex=i,b.face.materialIndex=0,!s)return b;s.push(b)}}return null}function Bt(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 Ku(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,Bt(o,3*f,l,c),o.needsUpdate=!0,i(o,f,s,n))return!0}return!1}function Qu(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(Ft(m,a)){const w=Zt(f,o);let b=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+Xt(m,a));O<I;O++){let k=i[O];const B=s.getX(k),E=s.getY(k),L=s.getZ(k);B<b&&(b=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]!==b||l[f+1]!==T||l[f+2]!==C||l[f+3]!==S||l[f+4]!==M||l[f+5]!==A)&&(l[f+0]=b,l[f+1]=T,l[f+2]=C,l[f+3]=S,l[f+4]=M,l[f+5]=A,!0)}{const w=Ut(f),g=$t(f,o);let b=_,T=!1,C=!1;if(t){if(!b){const B=g/8+d/32;T=t.has(w/8+d/32),C=t.has(B),b=!T&&!C}}else T=!0,C=!0;const M=b||C;let A=!1;(b||T)&&(A=u(w,d,b));let O=!1;M&&(O=u(g,d,b));const I=A||O;if(I)for(let k=0;k<3;k++){const B=w+k,E=g+k,L=l[B],x=l[B+3],N=l[E],Y=l[E+3];l[f+k]=L<N?L:N,l[f+k+3]=x>Y?x:Y}return I}}}function Ge(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],b=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=(b-_)*u):(n=(b-_)*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 ed(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),Bt(o,3*f,l,c),o.needsUpdate=!0,i(o,f,s,n))return!0}return!1}function id(r,t,e,i,s,n,o){It.setBuffer(r._roots[t]),Jn(0,r,e,i,s,n,o),It.clearBuffer()}function Jn(r,t,e,i,s,n,o){const{float32Array:a,uint16Array:l,uint32Array:c}=It,h=2*r;if(Ft(h,l))!function Wu(r,t,e,i,s,n,o,a){const{geometry:l}=r;for(let h=i,u=i+s;h<u;h++)ks(l,t,e,h,n,o,a)}(t,e,i,Zt(r,c),Xt(h,l),s,n,o);else{const f=Ut(r);Ge(f,a,i,n,o)&&Jn(f,t,e,i,s,n,o);const d=$t(r,c);Ge(d,a,i,n,o)&&Jn(d,t,e,i,s,n,o)}}const sd=["x","y","z"];function nd(r,t,e,i,s,n){It.setBuffer(r._roots[t]);const o=tr(0,r,e,i,s,n);return It.clearBuffer(),o}function tr(r,t,e,i,s,n){const{float32Array:o,uint16Array:a,uint32Array:l}=It;let c=2*r;if(Ft(c,a))return function Xu(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=ks(a,t,e,u,null,n,o),d&&d.distance<c&&(h=d,c=d.distance)}return h}(t,e,i,Zt(r,l),Xt(c,a),s,n);{const u=Vn(r,l),f=sd[u],_=i.direction[f]>=0;let m,w;_?(m=Ut(r),w=$t(r,l)):(m=$t(r,l),w=Ut(r));const b=Ge(m,o,i,s,n)?tr(m,t,e,i,s,n):null;if(b){const S=b.point[f];if(_?S<=o[w+u]:S>=o[w+u+3])return b}const C=Ge(w,o,i,s,n)?tr(w,t,e,i,s,n):null;return b&&C?b.distance<=C.distance?b:C:b||C||null}}const Ds=new p.NRn,Si=new re,Ei=new re,Xi=new p.kn4,da=new Kt,Ls=new Kt;function rd(r,t,e,i){It.setBuffer(r._roots[t]);const s=er(0,r,e,i);return It.clearBuffer(),s}function er(r,t,e,i,s=null){const{float32Array:n,uint16Array:o,uint32Array:a}=It;let l=2*r;if(null===s&&(e.boundingBox||e.computeBoundingBox(),da.set(e.boundingBox.min,e.boundingBox.max,i),s=da),!Ft(l,o)){const h=Ut(r),u=$t(r,a);return Dt(h,n,Ds),!!(s.intersectsBox(Ds)&&er(h,t,e,i,s)||(Dt(u,n,Ds),s.intersectsBox(Ds)&&er(u,t,e,i,s)))}{const h=t.geometry,u=h.index,f=h.attributes.position,d=e.index,_=e.attributes.position,m=Zt(r,a),w=Xt(l,o);if(Xi.copy(i).invert(),e.boundsTree)return Dt(r,n,Ls),Ls.matrix.copy(Xi),Ls.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:b=>Ls.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(i),b.b.applyMatrix4(i),b.c.applyMatrix4(i),b.needsUpdate=!0;for(let T=3*m,C=3*(w+m);T<C;T+=3)if(Bt(Ei,T,u,f),Ei.needsUpdate=!0,b.intersectsTriangle(Ei))return!0;return!1}});{const g=As(e);for(let b=3*m,T=3*(w+m);b<T;b+=3){Bt(Si,b,u,f),Si.a.applyMatrix4(Xi),Si.b.applyMatrix4(Xi),Si.c.applyMatrix4(Xi),Si.needsUpdate=!0;for(let C=0,S=3*g;C<S;C+=3)if(Bt(Ei,C,d,_),Ei.needsUpdate=!0,Si.intersectsTriangle(Ei))return!0}}}}const Ns=new p.kn4,ir=new Kt,Ki=new Kt,od=new p.Pq0,ad=new p.Pq0,ld=new p.Pq0,cd=new p.Pq0;function hd(r,t,e,i={},s={},n=0,o=1/0){t.boundingBox||t.computeBoundingBox(),ir.set(t.boundingBox.min,t.boundingBox.max,e),ir.needsUpdate=!0;const a=r.geometry,l=a.attributes.position,c=a.index,h=t.attributes.position,u=t.index,f=he.getPrimitive(),d=he.getPrimitive();let _=od,m=ad,w=null,g=null;s&&(w=ld,g=cd);let b=1/0,T=null,C=null;return Ns.copy(e).invert(),Ki.matrix.copy(Ns),r.shapecast({boundsTraverseOrder:S=>ir.distanceToBox(S),intersectsBounds:(S,M,A)=>A<b&&A<o&&(M&&(Ki.min.copy(S.min),Ki.max.copy(S.max),Ki.needsUpdate=!0),!0),intersectsRange:(S,M)=>{if(t.boundsTree)return t.boundsTree.shapecast({boundsTraverseOrder:O=>Ki.distanceToBox(O),intersectsBounds:(O,I,k)=>k<b&&k<o,intersectsRange:(O,I)=>{for(let k=O,B=O+I;k<B;k++){Bt(d,3*k,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++){Bt(f,3*E,c,l),f.needsUpdate=!0;const x=f.distanceToTriangle(d,_,w);if(x<b&&(m.copy(_),g&&g.copy(w),b=x,T=E,C=k),x<n)return!0}}}});for(let O=0,I=As(t);O<I;O++){Bt(d,3*O,u,h),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let k=S,B=S+M;k<B;k++){Bt(f,3*k,c,l),f.needsUpdate=!0;const E=f.distanceToTriangle(d,_,w);if(E<b&&(m.copy(_),g&&g.copy(w),b=E,T=k,C=O),E<n)return!0}}}}),he.releasePrimitive(f),he.releasePrimitive(d),b===1/0?null:(i.point?i.point.copy(m):i.point=m.clone(),i.distance=b,i.faceIndex=T,s&&(s.point?s.point.copy(g):s.point=g.clone(),s.point.applyMatrix4(Ns),m.applyMatrix4(Ns),s.distance=m.sub(s.point).length(),s.faceIndex=C),i)}function ud(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(Ft(m,a)){const w=Zt(f,o);let b=1/0,T=1/0,C=1/0,S=-1/0,M=-1/0,A=-1/0;for(let O=w,I=w+Xt(m,a);O<I;O++){const k=3*r.resolveTriangleIndex(O);for(let B=0;B<3;B++){let E=k+B;E=i?i[E]:E;const L=s.getX(E),x=s.getY(E),N=s.getZ(E);L<b&&(b=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]!==b||l[f+1]!==T||l[f+2]!==C||l[f+3]!==S||l[f+4]!==M||l[f+5]!==A)&&(l[f+0]=b,l[f+1]=T,l[f+2]=C,l[f+3]=S,l[f+4]=M,l[f+5]=A,!0)}{const w=Ut(f),g=$t(f,o);let b=_,T=!1,C=!1;if(t){if(!b){const B=g/8+d/32;T=t.has(w/8+d/32),C=t.has(B),b=!T&&!C}}else T=!0,C=!0;const M=b||C;let A=!1;(b||T)&&(A=u(w,d,b));let O=!1;M&&(O=u(g,d,b));const I=A||O;if(I)for(let k=0;k<3;k++){const B=w+k,E=g+k,L=l[B],x=l[B+3],N=l[E],Y=l[E+3];l[f+k]=L<N?L:N,l[f+k+3]=x>Y?x:Y}return I}}}function dd(r,t,e,i,s,n,o){It.setBuffer(r._roots[t]),sr(0,r,e,i,s,n,o),It.clearBuffer()}function sr(r,t,e,i,s,n,o){const{float32Array:a,uint16Array:l,uint32Array:c}=It,h=2*r;if(Ft(h,l))!function Ju(r,t,e,i,s,n,o,a){const{geometry:l,_indirectBuffer:c}=r;for(let h=i,u=i+s;h<u;h++)ks(l,t,e,c?c[h]:h,n,o,a)}(t,e,i,Zt(r,c),Xt(h,l),s,n,o);else{const f=Ut(r);Ge(f,a,i,n,o)&&sr(f,t,e,i,s,n,o);const d=$t(r,c);Ge(d,a,i,n,o)&&sr(d,t,e,i,s,n,o)}}const fd=["x","y","z"];function pd(r,t,e,i,s,n){It.setBuffer(r._roots[t]);const o=nr(0,r,e,i,s,n);return It.clearBuffer(),o}function nr(r,t,e,i,s,n){const{float32Array:o,uint16Array:a,uint32Array:l}=It;let c=2*r;if(Ft(c,a))return function td(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=ks(a,t,e,l?l[u]:u,null,n,o),d&&d.distance<c&&(h=d,c=d.distance)}return h}(t,e,i,Zt(r,l),Xt(c,a),s,n);{const u=Vn(r,l),f=fd[u],_=i.direction[f]>=0;let m,w;_?(m=Ut(r),w=$t(r,l)):(m=$t(r,l),w=Ut(r));const b=Ge(m,o,i,s,n)?nr(m,t,e,i,s,n):null;if(b){const S=b.point[f];if(_?S<=o[w+u]:S>=o[w+u+3])return b}const C=Ge(w,o,i,s,n)?nr(w,t,e,i,s,n):null;return b&&C?b.distance<=C.distance?b:C:b||C||null}}const Bs=new p.NRn,Ai=new re,Mi=new re,Qi=new p.kn4,fa=new Kt,Rs=new Kt;function md(r,t,e,i){It.setBuffer(r._roots[t]);const s=rr(0,r,e,i);return It.clearBuffer(),s}function rr(r,t,e,i,s=null){const{float32Array:n,uint16Array:o,uint32Array:a}=It;let l=2*r;if(null===s&&(e.boundingBox||e.computeBoundingBox(),fa.set(e.boundingBox.min,e.boundingBox.max,i),s=fa),!Ft(l,o)){const h=Ut(r),u=$t(r,a);return Dt(h,n,Bs),!!(s.intersectsBox(Bs)&&rr(h,t,e,i,s)||(Dt(u,n,Bs),s.intersectsBox(Bs)&&rr(u,t,e,i,s)))}{const h=t.geometry,u=h.index,f=h.attributes.position,d=e.index,_=e.attributes.position,m=Zt(r,a),w=Xt(l,o);if(Qi.copy(i).invert(),e.boundsTree)return Dt(r,n,Rs),Rs.matrix.copy(Qi),Rs.needsUpdate=!0,e.boundsTree.shapecast({intersectsBounds:b=>Rs.intersectsBox(b),intersectsTriangle:b=>{b.a.applyMatrix4(i),b.b.applyMatrix4(i),b.c.applyMatrix4(i),b.needsUpdate=!0;for(let T=m,C=w+m;T<C;T++)if(Bt(Mi,3*t.resolveTriangleIndex(T),u,f),Mi.needsUpdate=!0,b.intersectsTriangle(Mi))return!0;return!1}});{const g=As(e);for(let b=m,T=w+m;b<T;b++){const C=t.resolveTriangleIndex(b);Bt(Ai,3*C,u,f),Ai.a.applyMatrix4(Qi),Ai.b.applyMatrix4(Qi),Ai.c.applyMatrix4(Qi),Ai.needsUpdate=!0;for(let S=0,M=3*g;S<M;S+=3)if(Bt(Mi,S,d,_),Mi.needsUpdate=!0,Ai.intersectsTriangle(Mi))return!0}}}}const Fs=new p.kn4,or=new Kt,Ji=new Kt,gd=new p.Pq0,_d=new p.Pq0,yd=new p.Pq0,wd=new p.Pq0;function bd(r,t,e,i={},s={},n=0,o=1/0){t.boundingBox||t.computeBoundingBox(),or.set(t.boundingBox.min,t.boundingBox.max,e),or.needsUpdate=!0;const a=r.geometry,l=a.attributes.position,c=a.index,h=t.attributes.position,u=t.index,f=he.getPrimitive(),d=he.getPrimitive();let _=gd,m=_d,w=null,g=null;s&&(w=yd,g=wd);let b=1/0,T=null,C=null;return Fs.copy(e).invert(),Ji.matrix.copy(Fs),r.shapecast({boundsTraverseOrder:S=>or.distanceToBox(S),intersectsBounds:(S,M,A)=>A<b&&A<o&&(M&&(Ji.min.copy(S.min),Ji.max.copy(S.max),Ji.needsUpdate=!0),!0),intersectsRange:(S,M)=>{if(t.boundsTree){const A=t.boundsTree;return A.shapecast({boundsTraverseOrder:O=>Ji.distanceToBox(O),intersectsBounds:(O,I,k)=>k<b&&k<o,intersectsRange:(O,I)=>{for(let k=O,B=O+I;k<B;k++){const E=A.resolveTriangleIndex(k);Bt(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);Bt(f,3*N,c,l),f.needsUpdate=!0;const Y=f.distanceToTriangle(d,_,w);if(Y<b&&(m.copy(_),g&&g.copy(w),b=Y,T=L,C=k),Y<n)return!0}}}})}for(let O=0,I=As(t);O<I;O++){Bt(d,3*O,u,h),d.a.applyMatrix4(e),d.b.applyMatrix4(e),d.c.applyMatrix4(e),d.needsUpdate=!0;for(let k=S,B=S+M;k<B;k++){const E=r.resolveTriangleIndex(k);Bt(f,3*E,c,l),f.needsUpdate=!0;const L=f.distanceToTriangle(d,_,w);if(L<b&&(m.copy(_),g&&g.copy(w),b=L,T=k,C=O),L<n)return!0}}}}),he.releasePrimitive(f),he.releasePrimitive(d),b===1/0?null:(i.point?i.point.copy(m):i.point=m.clone(),i.distance=b,i.faceIndex=T,s&&(s.point?s.point.copy(g):s.point=g.clone(),s.point.applyMatrix4(Fs),m.applyMatrix4(Fs),s.distance=m.sub(s.point).length(),s.faceIndex=C),i)}function pa(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 Vs=new Kt,Us=new p.RlV,ma=new p.Pq0,ga=new p.kn4,_a=new p.Pq0,ar=["getX","getY","getZ"];class Ye extends ra{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*_;Ft(2*w,d)||(f[w+6]=f[w+6]/8-_)}}}(n));const a=new Ye(e,{...i,[Fn]:!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[ar[d]](h),m=o[ar[d]](u),w=o[ar[d]](f);let g=_;m<g&&(g=m),w<g&&(g=w);let b=_;m>b&&(b=m),w>b&&(b=w),e[i+d]=g,e[i+d+3]=b}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[_]:_),b=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 k=A;O<k&&(k=O),I<k&&(k=I);let B=A;O>B&&(B=O),I>B&&(B=I);const E=(B-k)/2,L=2*M;i[b+L+0]=k+E,i[b+L+1]=E+(Math.abs(k)+E)*vs}}return i}raycastObject3D(t,e,i=[]){const{material:s}=t;if(void 0===s)return;ga.copy(t.matrixWorld).invert(),Us.copy(e.ray).applyMatrix4(ga),_a.setFromMatrixScale(t.matrixWorld),ma.copy(Us.direction).multiply(_a);const n=ma.length(),o=e.near/n,a=e.far/n;if(!0===e.firstHitOnly){let l=this.raycastFirst(Us,s,o,a);l=pa(l,t,e),l&&i.push(l)}else{const l=this.raycast(Us,s,o,a);for(let c=0,h=l.length;c<h;c++){const u=pa(l[c],t,e);u&&i.push(u)}}return i}refit(t=null){return(this.indirect?ud:Qu)(this,t)}raycast(t,e=p.hB5,i=0,s=1/0){const o=[],a=this.indirect?dd:id;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?pd:nd;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?md:rd;for(let o=0,a=this._roots.length;o<a&&(i=n(this,o,t,e),!i);o++);return i}shapecast(t){const e=he.getPrimitive(),i=super.shapecast({...t,intersectsPrimitive:t.intersectsTriangle,scratchPrimitive:e,iterate:this.indirect?ed:Ku});return he.releasePrimitive(e),i}bvhcast(t,e,i){let{intersectsRanges:s,intersectsTriangles:n}=i;const o=he.getPrimitive(),a=this.geometry.index,l=this.geometry.attributes.position,c=this.indirect?_=>{const m=this.resolveTriangleIndex(_);Bt(o,3*m,a,l)}:_=>{Bt(o,3*_,a,l)},h=he.getPrimitive(),u=t.geometry.index,f=t.geometry.attributes.position,d=t.indirect?_=>{const m=t.resolveTriangleIndex(_);Bt(h,3*m,u,f)}:_=>{Bt(h,3*_,u,f)};if(n){if(!(t instanceof Ye))throw new Error('MeshBVH: "intersectsTriangles" callback can only be used with another MeshBVH.');const _=(m,w,g,b,T,C,S,M)=>{for(let A=g,O=g+b;A<O;A++){d(A),h.a.applyMatrix4(e),h.b.applyMatrix4(e),h.c.applyMatrix4(e),h.needsUpdate=!0;for(let I=m,k=m+w;I<k;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,b,T,C,S,M,A){return!!m(w,g,b,T,C,S,M,A)||_(w,g,b,T,C,S,M,A)}}else s=_}return super.bvhcast(t,e,{intersectsRanges:s})}intersectsBox(t,e){return Vs.set(t.min,t.max,e),Vs.needsUpdate=!0,this.shapecast({intersectsBounds:i=>Vs.intersectsBox(i),intersectsTriangle:i=>Vs.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:hd)(this,t,e,i,s,n,o)}closestPointToPoint(t,e={},i=0,s=1/0){return function Gu(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=>(Zi.copy(t).clamp(h.min,h.max),Zi.distanceToSquared(t)),intersectsBounds:(h,u,f)=>f<a&&f<o,intersectsTriangle:(h,u)=>{h.closestPointToPoint(t,Zi);const f=t.distanceToSquared(Zi);return f<a&&(Qn.copy(Zi),a=f,l=u),f<n}}),a===1/0)return null;const c=Math.sqrt(a);return e.point?e.point.copy(Qn):e.point=Qn.clone(),e.distance=c,e.faceIndex=l,e}(this,t,e,i,s)}}const ya=new p.kn4,$s=new p.RlV,wa=new Ps(()=>new p.cZY),lr=new p.Pq0,ba=new p.Pq0,va=new p.NRn,xa=["getX","getY","getZ"];class vd extends ra{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[xa[d]](u),m=a[xa[d]](f),g=_>m?_:m;e[i+d]=_<m?_:m,e[i+d+3]=g}return e}shapecast(t){const e=wa.getPrimitive(),i=super.shapecast({...t,intersectsPrimitive:t.intersectsLine,scratchPrimitive:e,iterate:xd});return wa.releasePrimitive(e),i}raycastObject3D(t,e,i=[]){const{matrixWorld:s}=t,{firstHitOnly:n}=e;ya.copy(s).invert(),$s.copy(e.ray).applyMatrix4(ya);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($s.origin),intersectsBounds:u=>(va.copy(u).expandByScalar(Math.abs(a)),$s.intersectsBox(va)?1:0),intersectsLine:(u,f)=>{if($s.distanceSqToSegment(u.start,u.end,lr,ba)>l)return;lr.applyMatrix4(t.matrixWorld);const _=e.ray.origin.distanceTo(lr);_<e.near||_>e.far||n&&_>=h||(h=_,f=this.resolvePrimitiveIndex(f),c={distance:_,point:ba.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 xd(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 Ii={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},qt=new p.eaF,js=[];function Ca(r,t){if(this.isBatchedMesh)Cd.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=Ii.Mesh;else if(this instanceof p.DXC)i=Ii.LineSegments;else if(this instanceof p.FCc)i=Ii.LineLoop;else if(this instanceof p.N1A)i=Ii.Line;else{if(!(this instanceof p.ONl))throw new Error("BVH: Fallback raycast function not found.");i=Ii.Points}i.call(this,r,t)}}}function Cd(r,t){if(this.boundsTrees){const e=this.boundsTrees,i=this._drawInfo||this._instanceInfo,s=this._drawRanges||this._geometryInfo,n=this.matrixWorld;qt.material=this.material,qt.geometry=this.geometry;const o=qt.geometry.boundsTree,a=qt.geometry.drawRange;null===qt.geometry.boundingSphere&&(qt.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(qt.geometry.boundsTree=e[h],this.getMatrixAt(l,qt.matrixWorld).premultiply(n),!qt.geometry.boundsTree){this.getBoundingBoxAt(h,qt.geometry.boundingBox),this.getBoundingSphereAt(h,qt.geometry.boundingSphere);const u=s[h];qt.geometry.setDrawRange(u.start,u.count)}qt.raycast(r,js);for(let u=0,f=js.length;u<f;u++){const d=js[u];d.object=this,d.batchId=l,t.push(d)}js.length=0}qt.geometry.boundsTree=o,qt.geometry.drawRange=a,qt.material=null,qt.geometry=null}else Ii.BatchedMesh.call(this,r,t)}function Td(r={}){const{type:t=Ye}=r;return this.boundsTree=new t(this,r),this.boundsTree}function Pd(){this.boundsTree=null}const Ta=class Nc extends Et{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(Nc.uuid,this)}static getWorker(){return ft._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 ft._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(Ta,"uuid","fef46874-46a3-461b-8c44-2922ab77c806");let dt=Ta;function Ed(r,t){return r[t]|r[t+1]<<8|r[t+2]<<16}class Md{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 Ad(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(k=>{a.expandByObject(k)}),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 k=0;k<t.length;k++){const B=t[k];m.set(B,B.material),w.set(B,B.parent);const E=new Id;E.objectId=k,g.push(E),B.material=E,_.add(B)}const b=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 k=0;k<f;k++)for(let B=0;B<d;B++){const E=a.min.x+O*k,x=a.min.z+I*B;o.position.set((E+(E+O))/2,a.max.y,(x+(x+I))/2);const lt=O/2,Z=I/2;o.left=-lt,o.right=lt,o.top=Z,o.bottom=-Z,o.updateProjectionMatrix(),i.render(_,o);const rt=yield i.readRenderTargetPixelsAsync(l,0,0,l.width,l.height,M);for(let F=0,V=rt.length;F<V;F+=4){if(0===rt[F+3])continue;const st=Ed(rt,F);A.add(t[st])}}for(const k of t){k.material=m.get(k);const B=w.get(k);B?B.add(k):_.remove(k)}i.setClearColor(b,T),i.setRenderTarget(C),i.autoClear=S;for(const k of g)k.dispose();return l.dispose(),Array.from(A)})()}}class Id extends p.BKk{get objectId(){return this._objectId}set objectId(t){this._objectId=t,function Sd(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 Od=new p.Pq0(0,1,0),Pa=new p.Pq0;function Sa(r){return r.delta(Pa).normalize(),Math.abs(Pa.dot(Od))>=1-1e-16}function hr(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 Ze=new p.cZY;function Ea(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;Ze.start.lerpVectors(a,l,s[n][0]),Ze.end.lerpVectors(a,l,s[n][1]),i.push(new Float32Array([Ze.start.x,Ze.start.y,Ze.start.z,Ze.end.x,Ze.end.y,Ze.end.z]))}return i}const zd=new p.Pq0(0,1,0),Ma=new p.Pq0,Ia=new p.Pq0,Hs=new p.Pq0,qs=new p.lMl;function*Oa(r,t=[],e={}){const{projectionDirection:i=zd,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:b,b:T,c:C}=qs;if(b.fromBufferAttribute(h,f[0]),T.fromBufferAttribute(h,f[1]),C.fromBufferAttribute(h,f[2]),qs.getNormal(Hs),_[0]=`${Math.round(b.x*a)},${Math.round(b.y*a)},${Math.round(b.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=qs[d[S]],k=qs[d[M]],B=`${A}_${O}`,E=`${O}_${A}`;if(E in m&&m[E]){const L=m[E].normal,x=Hs.dot(L)<=l;let N=!1;if(null!==i){let Y=i.dot(Hs);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(k),t.push(Y)}m[E]=null}else B in m||(m[B]={index0:f[S],index1:f[M],normal:Hs.clone()})}}for(const g in m)if(m[g]){const{index0:b,index1:T}=m[g];Ma.fromBufferAttribute(h,b),Ia.fromBufferAttribute(h,T);const C=new p.cZY;C.start.copy(Ma),C.end.copy(Ia),t.push(C)}return t}const Gs=new p.cZY;function za(r,t,e,i=[]){return r.bvhcast(t,e,{intersectsTriangles:(s,n)=>{if(function Dd(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,Gs,!0)&&!hr(s,Gs)&&!hr(n,Gs)&&i.push(Gs.clone())}}),i}function kd(r,t){return r.distanceTo(t)<1e-10}function ur(r){ka(r);let t=[];return r.traverse(e=>{e.geometry&&e.visible&&t.push(e)}),t}const ka=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):ka(e)},Ys=new p.kn4,Da=new p.kn4;class Ld{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=ur(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&&(Da.copy(u.matrixWorld).invert(),l.copy(s).transformDirection(Da).normalize());const f=yield*Oa(u.geometry,[],{projectionDirection:l,thresholdAngle:n,iterationTime:o});La(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*Oa(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=ur(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 Ye(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);Ys.copy(h.matrixWorld).invert().multiply(u.matrixWorld);const _=za(f,d,Ys,[]);La(_,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 Ye(t,{maxLeafSize:1}):(n=t,t=n.geometry),Ys.identity(),za(n,n,Ys,e)}}}function La(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 Nd extends sa{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 Bd=new p.Pq0(0,1,0),ci=new p.Zcv,dr=new p.Pq0,Ba=new p.Pq0;function Rd(r,t,e){r.needsUpdate&&r.update(),ci.copy(r.plane),ci.normal.dot(Bd)<0&&(ci.normal.multiplyScalar(-1),ci.constant*=-1);const i=ci.distanceToPoint(t.start),s=ci.distanceToPoint(t.end),n=Math.abs(i)<1e-16,o=i<0,a=s<0;if(t.delta(Ba).normalize(),Math.abs(ci.normal.dot(Ba))<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,dr),o)return e.start.copy(t.start),e.end.copy(dr),!0;if(a)return e.end.copy(t.end),e.start.copy(dr),!0}return!1}const fr=new p.Zcv,Zs=new p.Pq0,pr=new p.Pq0,We=new re,ve=new p.cZY,Ie=new p.cZY,Oi=new p.Pq0,Fa=new p.Pq0,Va=new p.Pq0;function Vd(r,t,e=new p.cZY){if(We.copy(t),We.a.y=0,We.b.y=0,We.c.y=0,We.update(),ve.copy(r),ve.start.y=0,ve.end.y=0,We.getArea()<=1e-16)return null;const i=ve.distance();ve.delta(Oi).divideScalar(i),Fa.copy(Oi).cross(We.plane.normal).normalize(),fr.setFromNormalAndCoplanarPoint(Fa,ve.start);let s=0;const{points:n}=We;for(let o=0;o<3;o++){const a=n[o],l=n[(o+1)%3],c=fr.distanceToPoint(a),h=fr.distanceToPoint(l),u=Math.abs(c)<1e-16,f=Math.abs(h)<1e-16;let d=!1;if(!u&&!f&&c*h<0&&(Zs.lerpVectors(a,l,c/(c-h)),d=!0),(d&&!f||u)&&(u&&!d&&Zs.copy(a),0===s?Ie.start.copy(Zs):Ie.end.copy(Zs),s++,2===s))break}if(2===s){if(Ie.delta(Va).normalize(),Oi.dot(Va)<0){const f=Ie.start;Ie.start=Ie.end,Ie.end=f}const o=0,a=pr.subVectors(ve.end,ve.start).dot(Oi),l=pr.subVectors(Ie.start,ve.start).dot(Oi),c=pr.subVectors(Ie.end,ve.start).dot(Oi);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 Ua=new p.Pq0,$a=new p.Pq0,ja=new p.Pq0;function $d(r,t,e){const i=function jd(r,t){r.delta(Ua),$a.subVectors(t.start,r.start),ja.subVectors(t.end,r.start);const e=Ua.length();let i=$a.length()/e,s=ja.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&&(Ha(i,e),!0)}function Ha(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 Hd=new p.Pq0(0,1,0),Ws=new p.cZY,qa=new p.cZY,ue=new re;function Gd(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,b=3*m+1,T=3*m+2;n.index&&(g=n.index.getX(g),b=n.index.getX(b),T=n.index.getX(T));const{a:C,b:S,c:M}=ue;if(C.fromBufferAttribute(n.attributes.position,g).applyMatrix4(o),S.fromBufferAttribute(n.attributes.position,b).applyMatrix4(o),M.fromBufferAttribute(n.attributes.position,T).applyMatrix4(o),ue.needsUpdate=!0,ue.update(),l!==p.$EB&&ue.plane.normal.dot(Hd)!==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=ue.plane.normal;let k=I.x,B=I.y,E=I.z,L=ue.plane.constant;B<0&&(k=-k,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),lt=Math.max(Y.start.y,Y.end.y);if(A<=q){s&&s.yBoundsCulled++;continue}const Z=Y.end.x-Y.start.x,rt=Y.end.z-Y.start.z,F=Z*Z+rt*rt;if(F>1e-20){const it=1/Math.sqrt(F),J=Z*it,gt=rt*it,Pt=-gt,ut=J,nt=C.x-Y.start.x,ct=C.z-Y.start.z,pt=S.x-Y.start.x,xt=S.z-Y.start.z,St=M.x-Y.start.x,P=M.z-Y.start.z,W=nt*J+ct*gt,$=pt*J+xt*gt,D=St*J+P*gt,z=1/it,R=Math.min(W,$,D);if(Math.max(W,$,D)<0||R>z){s&&s.xzBoundsCulled++;continue}const K=nt*Pt+ct*ut,U=pt*Pt+xt*ut,tt=St*Pt+P*ut,at=Math.min(K,U,tt),et=Math.max(K,U,tt);if(at>0||et<0){s&&s.xzBoundsCulled++;continue}}if(k*Y.start.x+B*Y.start.y+E*Y.start.z+L>=0&&k*Y.end.x+B*Y.end.y+E*Y.end.z+L>=0)s&&s.planeTrimCulled++;else if(hr(ue,Y))s&&s.triangleEdgeCulled++;else{if(lt<O)Ws.copy(Y);else if(!Rd(ue,Y,Ws)){s&&s.planeTrimCulled++;continue}Ws.distance()<1e-10?s&&s.distThresholdCulled++:Vd(Ws,ue,qa)?(s&&s.used++,$d(Y,qa,i[x])):s&&s.noOverlapCulled++}}}}})}ue.update=()=>{ue.plane.setFromCoplanarPoints(...ue.points)};let zi=!1;const Xs={},ts={};let hi=null,mr=0,gr=0;const vt={get enabled(){return zi},set enabled(r){zi=r},reset(){for(const r in Xs)delete Xs[r];for(const r in ts)delete ts[r];hi=null,mr=0,gr=0},setStat(r,t){ts[r]=t},startTotal(){zi&&(gr=performance.now())},startStep(r){zi&&(null!==hi&&this.endStep(),hi=r,mr=performance.now())},endStep(){if(!zi||null===hi)return;const r=performance.now()-mr;Xs[hi]=r,hi=null},printSummary(){if(!zi)return;null!==hi&&this.endStep();const r=performance.now()-gr;console.log("\n=== Projection Summary ==="),console.log(`Total time: ${r.toFixed(1)}ms\n`);for(const[t,e]of Object.entries(Xs)){const i=(e/r*100).toFixed(1);console.log(` ${t}: ${e.toFixed(1)}ms (${i}%)`)}if(Object.keys(ts).length>0){console.log("\n--- Stats ---");for(const[t,e]of Object.entries(ts))console.log(` ${t}: ${e}`)}console.log("")}},_e=1e-5,Ks=1e-16,Qs=1e-16;function Zd(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 es=null;function wr(){return(wr=(0,G.A)(function*(){return null===es&&(es=new Qc.uV1,yield es.init()),es})).apply(this,arguments)}function br(){return br=(0,G.A)(function*(r,t,e,i,s=null){const n=yield function Qd(){return wr.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,j.$_z)(function Yd(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");vt.enabled&&console.log("Number of meshes:",t.length),vt.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,b=g.index?g.index.count/3:g.attributes.position.count/3;if(m>_&&(m-_>=1e3||w+b>1e5))break;w+=b,m++}a.push({start:_,end:m}),_=m}}vt.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;vt.enabled&&console.log(`Processing batch ${_+1}/${a.length} (meshes ${m}-${w-1})`);let b=0,T=0;const C=[];for(let nt=m;nt<w;nt++){const ct=t[nt].geometry;C.push(T/3),b+=ct.attributes.position.array.length,T+=ct.index.array.length}const S=new Float32Array(b),M=new Uint32Array(T);let A=0,O=0,I=0;for(let nt=m;nt<w;nt++){const ct=t[nt].geometry,pt=ct.attributes.position.array,xt=ct.index.array;S.set(pt,A),A+=pt.length;for(let St=0;St<xt.length;St++)M[O+St]=xt[St]+I;O+=xt.length,I+=ct.attributes.position.count}const k=new Float32Array(16*g);for(let nt=m;nt<w;nt++)k.set(t[nt].matrixWorld.elements,16*(nt-m));const B=[];for(let nt=0;nt<r.groupCount;nt++){const ct=r.meshIndex[nt];if(ct>=m&&ct<w){const pt=ct-m;B.push({edgeOffset:r.edgeOffsets[nt],edgeCount:r.edgeCounts[nt],triOffset:C[pt]+r.meshOffsets[nt],triCount:r.meshCounts[nt],meshIdx:pt})}}if(0===B.length){vt.enabled&&console.log(` Batch ${_+1}: no groups, skipping`);continue}const E=new Uint32Array(5*B.length);for(let nt=0;nt<B.length;nt++){const ct=B[nt],pt=5*nt;E[pt+0]=ct.edgeOffset,E[pt+1]=ct.edgeCount,E[pt+2]=ct.triOffset,E[pt+3]=ct.triCount,E[pt+4]=ct.meshIdx}let L=0;for(let nt=0;nt<B.length;nt++)L+=B[nt].edgeCount*B[nt].triCount;s&&(s.candidates+=L);let x=Math.min(Math.ceil(.1*L),2e6),N=Math.max(x,1e4);vt.enabled&&console.log(` Batch ${_+1}: ${B.length} groups, ${b/3} vertices, ${T/3} triangles, ${L} pairs, buffer for ${N} overlaps`);const Y=performance.now(),q=(0,j.$_z)(S,"float"),lt=(0,j.$_z)(M,"uint"),Z=(0,j.$_z)(k,"float"),rt=(0,j.$_z)(E,"uint");let F=(0,j.$_z)(new Uint32Array([0]),"uint").toAtomic(),V=(0,j.$_z)(new Float32Array(3*N),"float");u+=performance.now()-Y;const st=performance.now(),it=(0,j.Fn)(()=>{const ct=j.cGD.mul(5),pt=rt.element(ct),xt=rt.element(ct.add(1)),St=rt.element(ct.add(2)),P=rt.element(ct.add(3)),$=rt.element(ct.add(4)).mul(16),D=(0,j.pBV)(Z.element($),Z.element($.add(1)),Z.element($.add(2)),Z.element($.add(3)),Z.element($.add(4)),Z.element($.add(5)),Z.element($.add(6)),Z.element($.add(7)),Z.element($.add(8)),Z.element($.add(9)),Z.element($.add(10)),Z.element($.add(11)),Z.element($.add(12)),Z.element($.add(13)),Z.element($.add(14)),Z.element($.add(15)));(0,j.FZF)({start:(0,j.Whr)(0),end:P.toInt(),type:"int",condition:"<",name:"triIdx"},({triIdx:z})=>{const X=St.add(z.toUint()).mul(3),K=lt.element(X),U=lt.element(X.add(1)),tt=lt.element(X.add(2)),at=(0,j.eR5)(q.element(K.mul(3)),q.element(K.mul(3).add(1)),q.element(K.mul(3).add(2))),et=(0,j.eR5)(q.element(U.mul(3)),q.element(U.mul(3).add(1)),q.element(U.mul(3).add(2))),ht=(0,j.eR5)(q.element(tt.mul(3)),q.element(tt.mul(3).add(1)),q.element(tt.mul(3).add(2))),bt=D.mul((0,j.lnd)(at,(0,j.fVC)(1))).xyz,yt=D.mul((0,j.lnd)(et,(0,j.fVC)(1))).xyz,Vt=D.mul((0,j.lnd)(ht,(0,j.fVC)(1))).xyz,ui=yt.sub(bt),fe=Vt.sub(bt),Ce=(0,j.$An)(ui,fe),kt=Ce.dot(Ce);(0,j.If)(kt.lessThan((0,j.fVC)(4*Ks*Ks)),()=>{(0,j.wPH)()}),(0,j.If)(Ce.y.lessThan(0),()=>{(0,j.wPH)()});const Ni=(0,j.T9B)(bt.y,(0,j.T9B)(yt.y,Vt.y));(0,j.FZF)({start:(0,j.Whr)(0),end:xt.toInt(),type:"int",condition:"<",name:"edgeIdx"},({edgeIdx:ls})=>{const pe=pt.add(ls.toUint()),De=pe.mul(6),oe=(0,j.eR5)(o.element(De),o.element(De.add(1)),o.element(De.add(2))),ae=(0,j.eR5)(o.element(De.add(3)),o.element(De.add(4)),o.element(De.add(5))),Zr=(0,j.jkA)(oe.y,ae.y);(0,j.If)(Ni.lessThanEqual(Zr),()=>{(0,j.wPH)()});const di=(0,j.S86)(Ce),Ke=di.dot(bt).negate(),fi=di.y.lessThan(0),ac=(0,j.Ltv)(fi,di.negate(),di),lc=(0,j.Ltv)(fi,Ke.negate(),Ke),ln=ac.dot(oe).add(lc),cc=ac.dot(ae).add(lc),cs=ln.lessThan(0),cn=cc.lessThan(0),Ag=(0,j.tnl)(ln).lessThan((0,j.fVC)(_e)),Mg=cs.not().and(cn.not()),hc=cc.sub(ln),Qe=(0,j.tnl)(hc).lessThan((0,j.fVC)(_e)),Ig=Qe.and(Ag.or(cs.not()));(0,j.If)(Ig,()=>{(0,j.wPH)()}),(0,j.If)(Mg.and(Qe.not()),()=>{(0,j.wPH)()});const Og=ln.negate().div(hc),Bi=(0,j.jhA)(oe,ae,Og),Wr=(0,j.eR5)((0,j.Ltv)(Qe.or(cs),oe.x,Bi.x),(0,j.Ltv)(Qe.or(cs),oe.y,Bi.y),(0,j.Ltv)(Qe.or(cs),oe.z,Bi.z)),Xr=(0,j.eR5)((0,j.Ltv)(Qe.or(cn),ae.x,Bi.x),(0,j.Ltv)(Qe.or(cn),ae.y,Bi.y),(0,j.Ltv)(Qe.or(cn),ae.z,Bi.z)),uc=Xr.sub(Wr),zg=uc.dot(uc);(0,j.If)(zg.lessThan((0,j.fVC)(_e)),()=>{(0,j.wPH)()});const dc=oe.sub(bt),fc=oe.sub(yt),pc=oe.sub(Vt),mc=ae.sub(bt),gc=ae.sub(yt),_c=ae.sub(Vt),kg=dc.dot(dc).lessThanEqual((0,j.fVC)(_e)),Dg=fc.dot(fc).lessThanEqual((0,j.fVC)(_e)),Lg=pc.dot(pc).lessThanEqual((0,j.fVC)(_e)),Ng=mc.dot(mc).lessThanEqual((0,j.fVC)(_e)),Bg=gc.dot(gc).lessThanEqual((0,j.fVC)(_e)),Rg=_c.dot(_c).lessThanEqual((0,j.fVC)(_e)),Fg=kg.or(Dg).or(Lg),Vg=Ng.or(Bg).or(Rg),Ug=Fg.and(Vg);(0,j.If)(Ug,()=>{(0,j.wPH)()});const ye=(0,j.eR5)(bt.x,(0,j.fVC)(0),bt.z),Te=(0,j.eR5)(yt.x,(0,j.fVC)(0),yt.z),Pe=(0,j.eR5)(Vt.x,(0,j.fVC)(0),Vt.z),Je=(0,j.eR5)(Wr.x,(0,j.fVC)(0),Wr.z),$g=(0,j.eR5)(Xr.x,(0,j.fVC)(0),Xr.z),Kr=(0,j.eR5)(oe.x,(0,j.fVC)(0),oe.z),Qr=(0,j.eR5)(ae.x,(0,j.fVC)(0),ae.z).sub(Kr),yc=Qr.dot(Qr);(0,j.If)(yc.lessThan((0,j.fVC)(_e)),()=>{(0,j.wPH)()});const Jr=yc.sqrt(),jg=Te.sub(ye),Hg=Pe.sub(ye),to=(0,j.$An)(jg,Hg),qg=to.dot(to);(0,j.If)(qg.lessThanEqual((0,j.fVC)(4*Ks*Ks)),()=>{(0,j.wPH)()});const eo=$g.sub(Je),wc=eo.dot(eo);(0,j.If)(wc.lessThan((0,j.fVC)(_e)),()=>{(0,j.wPH)()});const bc=wc.sqrt(),Ri=eo.div(bc),vc=Qr.div(Jr),Gg=(0,j.S86)(to),io=(0,j.$An)(Ri,Gg),Le=(0,j.fVC)(0).toVar(),Ne=(0,j.fVC)(0).toVar(),Be=(0,j.fVC)(0).toVar(),Re=(0,j.fVC)(0).toVar(),Qt=(0,j.Hdr)(0).toVar(),hs=io.dot(ye.sub(Je)),hn=io.dot(Te.sub(Je)),un=(0,j.tnl)(hs).lessThan((0,j.fVC)(Qs)),xc=(0,j.tnl)(hn).lessThan((0,j.fVC)(Qs)),Cc=un.not().and(xc.not()).and(hs.mul(hn).lessThan(0));(0,j.If)(Cc,()=>{const se=hs.div(hs.sub(hn)),Se=(0,j.jhA)(ye.x,Te.x,se),ti=(0,j.jhA)(ye.z,Te.z,se);(0,j.If)(Qt.equal(0),()=>{Le.assign(Se),Ne.assign(ti)}).Else(()=>{Be.assign(Se),Re.assign(ti)}),Qt.addAssign(1)}).ElseIf(un,()=>{(0,j.If)(Qt.equal(0),()=>{Le.assign(ye.x),Ne.assign(ye.z)}).Else(()=>{Be.assign(ye.x),Re.assign(ye.z)}),Qt.addAssign(1)});const so=hn,dn=io.dot(Pe.sub(Je)),no=xc,Tc=(0,j.tnl)(dn).lessThan((0,j.fVC)(Qs)),Pc=no.not().and(Tc.not()).and(so.mul(dn).lessThan(0));(0,j.If)(Qt.lessThan(2),()=>{(0,j.If)(Pc,()=>{const se=so.div(so.sub(dn)),Se=(0,j.jhA)(Te.x,Pe.x,se),ti=(0,j.jhA)(Te.z,Pe.z,se);(0,j.If)(Qt.equal(0),()=>{Le.assign(Se),Ne.assign(ti)}).Else(()=>{Be.assign(Se),Re.assign(ti)}),Qt.addAssign(1)}).ElseIf(no.and(Cc.not()).and(un.not()),()=>{(0,j.If)(Qt.equal(0),()=>{Le.assign(Te.x),Ne.assign(Te.z)}).Else(()=>{Be.assign(Te.x),Re.assign(Te.z)}),Qt.addAssign(1)})});const ro=dn,Sc=hs,Ec=Tc,Yg=un,Zg=Ec.not().and(Yg.not()).and(ro.mul(Sc).lessThan(0));(0,j.If)(Qt.lessThan(2),()=>{(0,j.If)(Zg,()=>{const se=ro.div(ro.sub(Sc)),Se=(0,j.jhA)(Pe.x,ye.x,se),ti=(0,j.jhA)(Pe.z,ye.z,se);(0,j.If)(Qt.equal(0),()=>{Le.assign(Se),Ne.assign(ti)}).Else(()=>{Be.assign(Se),Re.assign(ti)}),Qt.addAssign(1)}).ElseIf(Ec.and(Pc.not()).and(no.not()),()=>{(0,j.If)(Qt.equal(0),()=>{Le.assign(Pe.x),Ne.assign(Pe.z)}).Else(()=>{Be.assign(Pe.x),Re.assign(Pe.z)}),Qt.addAssign(1)})}),(0,j.If)(Qt.notEqual(2),()=>{(0,j.wPH)()});const Wg=(0,j.eR5)(Le,(0,j.fVC)(0),Ne),Xg=(0,j.eR5)(Be,(0,j.fVC)(0),Re).sub(Wg).dot(Ri),oo=(0,j.eR5)(Le,(0,j.fVC)(0),Ne).toVar(),ao=(0,j.eR5)(Be,(0,j.fVC)(0),Re).toVar();(0,j.If)(Xg.lessThan(0),()=>{const se=Le,Se=Ne;oo.x.assign(Be),oo.z.assign(Re),ao.x.assign(se),ao.z.assign(Se)});const Ac=(0,j.fVC)(0),Mc=bc,Ic=oo.sub(Je).dot(Ri),Oc=ao.sub(Je).dot(Ri),Kg=Mc.lessThanEqual(Ic).or(Oc.lessThanEqual(Ac));(0,j.If)(Kg,()=>{(0,j.wPH)()});const Qg=(0,j.T9B)(Ac,Ic),Jg=(0,j.jkA)(Mc,Oc),t_=Je.add(Ri.mul(Qg)),e_=Je.add(Ri.mul(Jg)),i_=t_.sub(Kr).dot(vc).div(Jr),s_=e_.sub(Kr).dot(vc).div(Jr),zc=(0,j.T9B)((0,j.fVC)(0),(0,j.jkA)((0,j.fVC)(1),i_)),kc=(0,j.T9B)((0,j.fVC)(0),(0,j.jkA)((0,j.fVC)(1),s_)),n_=(0,j.tnl)(kc.sub(zc));(0,j.If)(n_.lessThanEqual((0,j.fVC)(Qs)),()=>{(0,j.wPH)()});const Dc=(0,j.Rnb)(F.element(0),1);(0,j.If)(Dc.lessThan((0,j.Hdr)(N)),()=>{const se=Dc.mul(3);V.element(se).assign(pe.toFloat()),V.element(se.add(1)).assign(zc),V.element(se.add(2)).assign(kc)})})})})().compute(B.length);f+=performance.now()-st;const J=performance.now();yield n.computeAsync(it),l+=performance.now()-J;const gt=performance.now(),Pt=yield n.getArrayBufferAsync(F.value),ut=new Uint32Array(Pt)[0];if(s&&(s.used+=Math.min(ut,N)),vt.enabled&&console.log(` Batch ${_+1}: ${ut} overlaps found (capacity: ${N})`),ut>N&&vt.enabled&&console.warn(` WARNING: Overlap buffer overflow! ${ut} > ${N}. Some occlusion data lost.`),ut>0){const nt=yield n.getArrayBufferAsync(V.value),ct=new Float32Array(nt);c+=performance.now()-gt;const pt=performance.now(),xt=Math.min(ut,N);for(let St=0;St<xt;St++){const P=3*St,W=Math.round(ct[P]);Ha([ct[P+1],ct[P+2]],i[W])}h+=performance.now()-pt,vt.enabled&&console.log(` Processed ${xt} overlaps into hiddenOverlapMap`)}else c+=performance.now()-gt}n.dispose(),es=null,vt.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`))}),br.apply(this,arguments)}const tf=new p.Pq0(0,1,0);function Ga(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 ef{constructor(t,e=!0){this.meshes=ur(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 Ga(this.visibleEdges,this.groupKeyToIndex?this.visibleGroupIndices:null)}getHiddenLineGeometry(){return Ga(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();vt.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 Ye(T);s.set(T,C)}}let c=0;for(let g=0;g<i.length;g++){const b=i[g].geometry;c+=b.index?b.index.count/3:b.attributes.position.count/3}const h={};for(let g=0;g<t.length;g++)h[g]=[];vt.startStep("Building line BVH");const u=new Nd(t,{maxLeafSize:2,strategy:2});vt.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 b=i[g];d?Zd(u,s.get(b.geometry),b,_,g):Gd(u,s.get(b.geometry),b,h,f)}if(d){let g=!1;for(function Jd(r,t,e,i){return br.apply(this,arguments)}(_,i,u,h,f).then(()=>{g=!0});!g;)yield}const m=f.totalEdges*f.totalTriangles;if(vt.setStat("Total edges",f.totalEdges.toLocaleString()),vt.setStat("Total triangles",f.totalTriangles.toLocaleString()),vt.setStat("Brute-force pairs (edges \xd7 triangles)",m.toLocaleString()),vt.setStat("BVH candidate pairs",f.candidates.toLocaleString()),m>0&&vt.setStat("BVH reduction",(f.candidates/m*100).toFixed(3)+"% of brute-force"),f.candidates>0){const g=f.candidates,b=T=>(T/g*100).toFixed(2)+"%";d||(vt.setStat("Rejected: back-face culling",f.backFaceCulled.toLocaleString()+" ("+b(f.backFaceCulled)+")"),vt.setStat("Rejected: Y-bounds (tri below edge)",f.yBoundsCulled.toLocaleString()+" ("+b(f.yBoundsCulled)+")"),vt.setStat("Rejected: XZ-bounds (no 2D overlap)",f.xzBoundsCulled.toLocaleString()+" ("+b(f.xzBoundsCulled)+")"),vt.setStat("Rejected: edge lies on triangle",f.triangleEdgeCulled.toLocaleString()+" ("+b(f.triangleEdgeCulled)+")"),vt.setStat("Rejected: line above tri plane",f.planeTrimCulled.toLocaleString()+" ("+b(f.planeTrimCulled)+")"),vt.setStat("Rejected: trimmed edge too small",f.distThresholdCulled.toLocaleString()+" ("+b(f.distThresholdCulled)+")"),vt.setStat("Rejected: no projected overlap",f.noOverlapCulled.toLocaleString()+" ("+b(f.noOverlapCulled)+")")),vt.setStat("Producing overlaps",f.used.toLocaleString()+" ("+b(f.used)+")")}vt.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 b=t[g],T=h[g],C=n.length,S=o.length;if(Ea(b,T,!1,n),Ea(b,T,!0,o),w){const M=b.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 sf{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(vt.reset(),vt.startTotal(),t.isBufferGeometry&&(t=new p.eaF(t)),a){vt.startStep("Visibility culling");let d=!1;for(a.cull(t).then(_=>{(t=new p.Z58).children=_,d=!0});!d;)yield}const c=new Ld;c.iterationTime=i,c.thresholdAngle=s,c.projectionDirection.copy(tf),vt.startStep("Generating candidate edges"),o("Generating candidate edges");let h=[],u=l?[]:null;if(yield*c.getEdgesGenerator(t,h,u),n&&(vt.startStep("Generating intersection edges"),o("Generating intersection edges"),yield*c.getIntersectionEdgesGenerator(t,h,u)),vt.startStep("Pre-filtering edges"),o("Pre-filtering edges"),u){const d=[],_=[];for(let m=0;m<h.length;m++)Sa(h[m])||(d.push(h[m]),_.push(u[m]));h=d,u=_}else h=h.filter(d=>!Sa(d));yield;const f=new ef(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}),vt.printSummary(),f}}new p.cZY,new p.cZY,new p.Pq0;const Ya=class co extends Et{constructor(t){super(t),y(this,"enabled",!0),y(this,"onDisposed",new Q),y(this,"generator",new sf),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(co.uuid,this),this.generator.includeIntersectionEdges=!1}get(t,e,i){var s=this;return(0,G.A)(function*(){const n=s.components.get(dt),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 k=yield A.getItemsGeometry(I);for(const B in k){const E=k[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 Ye(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 Md(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(),b=w.getHiddenLineGeometry();g.applyMatrix4(f),b.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:b,groups:C}})()}dispose(){this.onDisposed.trigger(co.uuid),this.onDisposed.reset()}};y(Ya,"uuid","f2e76c3a-8b1d-4d5e-9a3f-7c6b2d4e8f1a");let nf=Ya;class rf{constructor(){y(this,"wasm",{path:"",absolute:!1,logLevel:gn.LogLevel.LOG_LEVEL_OFF}),y(this,"webIfc",{COORDINATE_TO_ORIGIN:!0}),y(this,"autoSetWasm",!0),y(this,"customLocateFileHandler",null)}}y(class ho extends Et{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 rf),y(this,"webIfc",new gn.IfcAPI),y(this,"enabled",!0),this.components.add(ho.uuid,this)}dispose(){this.webIfc=null,this.onDisposed.trigger(ho.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(dt);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 ft.$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 gn.IfcAPI}autoSetWasm(){var t=this;return(0,G.A)(function*(){const e=yield fetch(`https://unpkg.com/@thatopen/components@${Cr.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 Za=class Bc extends Et{constructor(t){super(t),y(this,"enabled",!0),this.components.add(Bc.uuid,this)}set(t,e){var i=this;return(0,G.A)(function*(){const s=i.components.get(dt),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(dt);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(dt);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(Za,"uuid","dd9ccf2d-8a21-4821-b7f6-2949add16a29");let of=Za;const Wa=class uo extends Et{constructor(t){super(t),y(this,"enabled",!0),y(this,"onDisposed",new Q),y(this,"list",new ft.PG),this.components.add(uo.uuid,this)}dispose(t=!0){this.list.clear(),this.onDisposed.trigger(uo.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(dt),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(dt);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(dt);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(Wa,"uuid","d1444724-dba6-4cdd-a0c7-68ee1450d166");let Xa=Wa;class af{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(is).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(is).list.getKey(this)??te.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 Ka=class Rc extends Et{constructor(t){super(t),y(this,"enabled",!0),y(this,"list",new ft.jp),t.add(Rc.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(dt),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(b=>b.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?Nt.join(a):Nt.intersect(a)})()}create(t,e){const i=new af(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(dt);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(Ka,"uuid","0da7ad77-f734-42ca-942f-a074adfd1e3a");let is=Ka;y(class Fc extends Et{constructor(t){var e;super(t),e=this,y(this,"enabled",!0),y(this,"onDisposed",new Q),y(this,"list",new ft.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(Fc.uuid,this),this.setupEvents(),t.get(dt).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 ft.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(is),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=Nt.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(dt),c=yield s.components.get(is).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 b of w)g.add(b)},_=yield f.getItemsData([...u],n);for(const m of _)o(m,d)}})()}addGroupItems(t,e,i){const{map:s}=this.getGroupData(t,e);Nt.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=Nt.join(a);i.push(c)}return Nt.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(is).addFromCategories(t?.modelIds);for(const n of s)e.setGroupQuery(t?.classificationName??"Categories",n,{name:n})})()}dispose(){this.list.clear(),this.components.get(dt).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)Nt.remove(s.map,t);return}for(const[,i]of this.list.entries())for(const[,s]of i)Nt.remove(s.map,t)}byModel(t){var e=this;return(0,G.A)(function*(){const i=e.components.get(dt),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 Qa=class Vc{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 qo(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(dt).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(dt);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 cf(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 hf(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(dt);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(dt);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(dt),e=new Map;let i=1;for(const[s,n]of t.list){if(i>Vc.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(dt),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,b=e.height,T=Math.floor(.5*(s.x+1)*g),C=Math.floor(.5*(s.y+1)*(b-1)),M=Math.max(0,Math.min(g-4,T-2)),A=Math.max(0,Math.min(b-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 k=new Set(I.values()),B=new Map;o.traverse(x=>{x!==o&&x.isMesh&&((x=>{let N=x;for(;N;){if(k.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(dt),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 b=g.geometry;if(!b)return;if(!b.attributes||!b.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(Qa,"MAX_MODELS",254);let lf=Qa;const Ja=class Uc extends Et{constructor(t){super(t),y(this,"enabled",!0),y(this,"list",new Map),y(this,"onDisposed",new Q),t.add(Uc.uuid,this)}get(t){if(this.list.has(t.uuid))return this.list.get(t.uuid);const e=new lf(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(Ja,"uuid","4a82430c-7ff2-49ea-9401-60807502dad6");let uf=Ja;class ss{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=ss.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=ss.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=ss.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(dt).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=pf(a,o.globalTransforms[f.item],o.localTransforms[f.localTransform]);i.collectPolygonsFromShell(_,g,l)}if(0===l.length)return null;const c=function _f(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],_=wf(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 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=s[3*o],l=s[3*o+1],c=s[3*o+2],h=xr(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 mf(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:gf(s.points.length/3)}}:null}}const ff=new p.kn4,ns=new p.Pq0,rs=new p.Pq0,Js=new p.Pq0;function tl(r,t){if(!r)return t.identity();const e=r.position[0],i=r.position[1],s=r.position[2];return ns.set(r.xDirection[0],r.xDirection[1],r.xDirection[2]),rs.set(r.yDirection[0],r.yDirection[1],r.yDirection[2]),Js.crossVectors(ns,rs),t.set(ns.x,rs.x,Js.x,e,ns.y,rs.y,Js.y,i,ns.z,rs.z,Js.z,s,0,0,0,1),t}const el=new p.kn4,il=new p.kn4;function pf(r,t,e){return tl(t,el),tl(e,il),ff.copy(r).multiply(el).multiply(il).clone()}function gf(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 xr(r,t,e){return`${Math.round(1e3*r)},${Math.round(1e3*t)},${Math.round(1e3*e)}`}function wf(r,t,e,i,s,n){const o=xr(r,t,e),a=xr(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-_,b=r.z-m;return w*w+g*g+b*b}const sl=class $c extends Et{constructor(t){super(t),y(this,"enabled",!0),y(this,"onDisposed",new Q),y(this,"_resolver"),t.add($c.uuid,this),this._resolver=new ss(t)}get(){return this._resolver}dispose(){this._resolver.dispose(),this.onDisposed.trigger()}};y(sl,"uuid","be9b8e6c-7f5b-4a36-8e7e-3a1f5e2a6c9d");let vf=sl;class xf{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 qo(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(dt);let l=null;if(a.initialized){const f=yield e.components.get(uf).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(vf).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 nl=class jc extends Et{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 xf(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(nl,"uuid","d5d8bdf0-db25-4952-b951-b643af207ace");let tn=nl;class Cf extends Cn{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",te.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(tn).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(yi);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(en).list.delete(this.uuid),this.onDisposed.trigger(),this.onDisposed.reset()}}class Tf{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 Pf{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 Sf extends qi{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 Pf(this._config,this._component)),y(this,"directionalLight",new Tf(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 rl extends lh{constructor(t){super(t),y(this,"onSetup",new Q),y(this,"isSetup",!1),y(this,"three"),y(this,"config",new Sf(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(bs).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 os extends oh{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(dt),s=e.components.get(Xa);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!");Gt.install({THREE:os.getSubsetOfThree()});const{domElement:t}=this.currentWorld.renderer.three,e=new Gt(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 ol=class Hc extends Et{constructor(t){super(t),y(this,"onAfterUpdate",new Q),y(this,"onBeforeUpdate",new Q),y(this,"onDisposed",new Q),y(this,"list",new ft.jp),y(this,"enabled",!0),t.add(Hc.uuid,this)}create(){const t=new Cf(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(ol,"uuid","fdb61dc4-2ec1-4966-b83d-54ea795fad4a");let en=ol;class If extends qi{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 Of{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 os&&(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 If(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(bs).list.delete(this.config.uuid),this.components.get(yi).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 os))return;const e=this.world.camera.controls;t?e.addEventListener("update",this.updateZoom):e.removeEventListener("update",this.updateZoom)}}y(class qc extends Et{constructor(t){super(t),y(this,"list",new Map),y(this,"onDisposed",new Q),y(this,"enabled",!0),t.add(qc.uuid,this)}create(t){if(this.list.has(t.uuid))throw new Error("This world already has a grid!");const e=new Of(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 al=class Gc{constructor(){y(this,"onDisposed",new Q),y(this,"list",new ft.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,Gc.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.");te.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!==dt.uuid?i.isDisposeable()&&i.dispose():t=i;t?.dispose(),this._timer.dispose(),this.onDisposed.trigger()}static setupBVH(){p.LoY.prototype.computeBoundsTree=Td,p.LoY.prototype.disposeBoundsTree=Pd,p.eaF.prototype.raycast=Ca,p.DXC.prototype.raycast=Ca}};y(al,"release","2.4.3");let Cr=al;class zf{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=Gt.ACTION.DOLLY,t.touches.two=Gt.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 Df{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=Gt.ACTION.TRUCK,e.touches.one=Gt.ACTION.TOUCH_TRUCK,e.touches.two=Gt.ACTION.TOUCH_ZOOM):(e.mouseButtons.left=Gt.ACTION.ROTATE,e.touches.one=this.mouseAction1,e.touches.two=this.mouseAction2)}}class Lf{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=Gt.ACTION.ZOOM,this._component.controls.mouseButtons.middle=Gt.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=Gt.ACTION.DOLLY,t._component.controls.mouseButtons.middle=Gt.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=Gt.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 sn extends os{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 Lf(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 zf(this)),this._navigationModes.set("Plan",new Df(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(dt);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 nn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Nf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}function rn(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 ll={exports:{}};ll.exports=function e(i,s,n){function o(c,h){if(!s[c]){if(!i[c]){if(!h&&rn)return rn(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=rn,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,b=l.length,T=b,C="string"!==n.getTypeOf(l);g<l.length;)T=b-g,u=C?(c=l[g++],h=g<b?l[g++]:0,g<b?l[g++]:0):(c=l.charCodeAt(g++),h=g<b?l.charCodeAt(g++):0,g<b?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 b,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(b=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++))),b[w++]=c,64!==d&&(b[w++]=h),64!==_&&(b[w++]=u);return b}},{"./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,b){var T,C,S=d.file,M=d.compression,A=b!==c.utf8encode,O=a.transformTo("string",b(S.name)),I=a.transformTo("string",c.utf8encode(S.name)),k=S.comment,B=a.transformTo("string",b(k)),E=a.transformTo("string",c.utf8encode(k)),L=I.length!==S.name.length,x=E.length!==k.length,N="",Y="",q="",lt=S.dir,Z=S.date,rt={crc32:0,compressedSize:0,uncompressedSize:0};_&&!m||(rt.crc32=d.crc32,rt.compressedSize=d.compressedSize,rt.uncompressedSize=d.uncompressedSize);var F=0;_&&(F|=8),A||!L&&!x||(F|=2048);var J,Pt,V=0,st=0;lt&&(V|=16),"UNIX"===g?(st=798,V|=(Pt=J=S.unixPermissions,J||(Pt=lt?16893:33204),(65535&Pt)<<16)):(st=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(rt.crc32,4),it+=n(rt.compressedSize,4),it+=n(rt.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(st,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,b,T,M,w=(g=this.dirRecords.length,b=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(b,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(b,T){var C=b||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 b=0;b<g.length;b++)w.push(u(g[b]));return o.Promise.all(w)}).then(function(m){for(var w=m.shift(),g=w.files,b=0;b<g.length;b++){var T=g[b],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),k=a.extend(A||{},h);k.date=k.date||new Date,null!==k.compression&&(k.compression=k.compression.toUpperCase()),"string"==typeof k.unixPermissions&&(k.unixPermissions=parseInt(k.unixPermissions,8)),k.unixPermissions&&16384&k.unixPermissions&&(k.dir=!0),k.dosPermissions&&16&k.dosPermissions&&(k.dir=!0),k.dir&&(S=g(S)),k.createFolders&&(O=w(S))&&b.call(this,O,!0),A&&void 0!==A.binary||(k.binary=!("string"===I&&!1===k.binary&&!1===k.base64)),(M instanceof u&&0===M.uncompressedSize||k.dir||!M||0===M.length)&&(k.base64=!1,k.binary=!0,M="",k.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,k.binary,k.optimizedBinaryString,k.base64);var L=new f(S,E,k);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},b=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(k,B){return!B.dir&&O.test(k)})}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,k){return k.dir&&S.test(I)});var A=b.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,k){return k.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(b){this._worker=new a("error"),this._worker.error(b)}}d.prototype={accumulate:function(_){return function f(_,m){return new h.Promise(function(w,g){var b=[],T=_._internalType,C=_._outputType,S=_._mimeType;_.on("data",function(M,A){b.push(M),m&&m(A)}).on("error",function(M){b=[],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,k=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],k),k+=O[I].length;return B;case"nodebuffer":return Buffer.concat(O);default:throw new Error("concat : unsupported type '"+A+"'")}}(T,b),S);w(M)}catch(A){g(A)}b=[]}).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,b,T,C=_.length,S=0;for(b=0;b<C;b++)55296==(64512&(w=_.charCodeAt(b)))&&b+1<C&&56320==(64512&(g=_.charCodeAt(b+1)))&&(w=65536+(w-55296<<10)+(g-56320),b++),S+=w<128?1:w<2048?2:w<65536?3:4;for(m=o.uint8array?new Uint8Array(S):new Array(S),b=T=0;T<S;b++)55296==(64512&(w=_.charCodeAt(b)))&&b+1<C&&56320==(64512&(g=_.charCodeAt(b+1)))&&(w=65536+(w-55296<<10)+(g-56320),b++),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,b,T=_.length,C=new Array(2*T);for(m=w=0;m<T;)if((g=_[m++])<128)C[w++]=g;else if(4<(b=c[g]))C[w++]=65533,m+=b-1;else{for(g&=2===b?31:3===b?15:7;1<b&&m<T;)g=g<<6|63&_[m++],b--;1<b?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(b,T){var C;for((T=T||b.length)>b.length&&(T=b.length),C=T-1;0<=C&&128==(192&b[C]);)C--;return C<0||0===C?T:C+c[b[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 b=[],T=0,C=m.length;if(C<=g)return String.fromCharCode.apply(null,m);for(;T<C;)b.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 b.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),b=!0;if("uint8array"===g?b=u.applyCanBeUsed.uint8array:"nodebuffer"===g&&(b=u.applyCanBeUsed.nodebuffer),b)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=[],b=0;b<w.length;b++){var T=w[b];"."===T||""===T&&0!==b&&b!==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,b="";for(g=0;g<(m||"").length;g++)b+="\\x"+((w=m.charCodeAt(g))<16?"0":"")+w.toString(16).toUpperCase();return b},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,b,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!==b&&(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 b=!this._dataBinary;b&&!g&&(m=m.pipe(new l.Utf8EncodeWorker)),!b&&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 nn<"u"?nn: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,b,T){this.promise=g,"function"==typeof b&&(this.onFulfilled=b,this.callFulfilled=this.otherCallFulfilled),"function"==typeof T&&(this.onRejected=T,this.callRejected=this.otherCallRejected)}function d(g,b,T){n(function(){var C;try{C=b(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 b=g&&g.then;if(g&&("object"==typeof g||"function"==typeof g)&&"function"==typeof b)return function(){b.apply(g,arguments)}}function m(g,b){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(){b(S,C)});"error"===M.status&&C(M.value)}function w(g,b){var T={};try{T.value=g(b),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 b=this.constructor;return this.then(function(T){return b.resolve(g()).then(function(){return T})},function(T){return b.resolve(g()).then(function(){throw T})})},u.prototype.catch=function(g){return this.then(null,g)},u.prototype.then=function(g,b){if("function"!=typeof g&&this.state===c||"function"!=typeof b&&this.state===l)return this;var T=new this.constructor(o);return this.state!==h?d(T,this.state===c?g:b,this.outcome):this.queue.push(new f(T,g,b)),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,b){var T=w(_,b);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=b;for(var S=-1,M=g.queue.length;++S<M;)g.queue[S].callFulfilled(b)}return g},a.reject=function(g,b){g.state=l,g.outcome=b;for(var T=-1,C=g.queue.length;++T<C;)g.queue[T].callRejected(b);return g},u.resolve=function(g){return g instanceof this?g:a.resolve(new this(o),g)},u.reject=function(g){var b=new this(o);return a.reject(b,g)},u.all=function(g){var b=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(k,B){b.resolve(k).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 b=this.options;b.raw&&0<b.windowBits?b.windowBits=-b.windowBits:b.gzip&&0<b.windowBits&&b.windowBits<16&&(b.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,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(0!==T)throw new Error(l[T]);if(b.header&&n.deflateSetHeader(this.strm,b.header),b.dictionary){var C;if(C="string"==typeof b.dictionary?a.string2buf(b.dictionary):"[object ArrayBuffer]"===h.call(b.dictionary)?new Uint8Array(b.dictionary):b.dictionary,0!==(T=n.deflateSetDictionary(this.strm,C)))throw new Error(l[T]);this._dict_set=!0}}function w(g,b){var T=new m(b);if(T.push(g,!0),T.err)throw T.msg||l[T.err];return T.result}m.prototype.push=function(g,b){var T,C,S=this.strm,M=this.options.chunkSize;if(this.ended)return!1;C=b===~~b?b:!0===b?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,b){return(b=b||{}).raw=!0,w(g,b)},s.gzip=function(g,b){return(b=b||{}).gzip=!0,w(g,b)}},{"./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,b,T,C,S,M,A=this.strm,O=this.options.chunkSize,I=this.options.dictionary,k=!1;if(this.ended)return!1;b=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===k&&(g=l.Z_OK,k=!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||b!==l.Z_FINISH&&b!==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&&(k=!0)}while((0<A.avail_in||0===A.avail_out)&&g!==l.Z_STREAM_END);return g===l.Z_STREAM_END&&(b=l.Z_FINISH),b===l.Z_FINISH?(g=n.inflateEnd(this.strm),this.onEnd(g),this.ended=!0,g===l.Z_OK):b!==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,b=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++),b+=d<128?1:d<2048?2:d<65536?3:4;for(f=new n.Buf8(b),m=w=0;w<b;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,b=new Array(2*g);for(d=_=0;d<g;)if((m=u[d++])<128)b[_++]=m;else if(4<(w=l[m]))b[_++]=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?b[_++]=65533:m<65536?b[_++]=m:(b[_++]=55296|(m-=65536)>>10&1023,b[_++]=56320|1023&m)}return h(b,_)},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,k=258,B=262,L=113;function lt(P,W){return P.msg=h[W],W}function Z(P){return(P<<1)-(4<P?9:0)}function rt(P){for(var W=P.length;0<=--W;)P[W]=0}function F(P){var W=P.state,$=W.pending;$>P.avail_out&&($=P.avail_out),0!==$&&(o.arraySet(P.output,W.pending_buf,W.pending_out,$,P.next_out),P.next_out+=$,W.pending_out+=$,P.total_out+=$,P.avail_out-=$,W.pending-=$,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 st(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 $,D,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,at=P.w_mask,et=P.prev,ht=P.strstart+k,bt=tt[R+X-1],yt=tt[R+X];P.prev_length>=P.good_match&&(z>>=2),K>P.lookahead&&(K=P.lookahead);do{if(tt[($=W)+X]===yt&&tt[$+X-1]===bt&&tt[$]===tt[R]&&tt[++$]===tt[R+1]){R+=2,$++;do{}while(tt[++R]===tt[++$]&&tt[++R]===tt[++$]&&tt[++R]===tt[++$]&&tt[++R]===tt[++$]&&tt[++R]===tt[++$]&&tt[++R]===tt[++$]&&tt[++R]===tt[++$]&&tt[++R]===tt[++$]&&R<ht);if(D=k-(ht-R),R=ht-k,X<D){if(P.match_start=W,K<=(X=D))break;bt=tt[R+X-1],yt=tt[R+X]}}}while((W=et[W&at])>U&&0!=--z);return X<=P.lookahead?X:P.lookahead}function gt(P){var W,$,D,z,R,X,K,U,tt,at,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=$=P.hash_size;D=P.head[--W],P.head[W]=et<=D?D-et:0,--$;);for(W=$=et;D=P.prev[--W],P.prev[W]=et<=D?D-et:0,--$;);z+=et}if(0===P.strm.avail_in)break;if(K=P.window,U=P.strstart+P.lookahead,at=void 0,(tt=z)<(at=(X=P.strm).avail_in)&&(at=tt),$=0===at?0:(X.avail_in-=at,o.arraySet(K,X.input,X.next_in,at,U),1===X.state.wrap?X.adler=l(X.adler,K,at,U):2===X.state.wrap&&(X.adler=c(X.adler,K,at,U)),X.next_in+=at,X.total_in+=at,at),P.lookahead+=$,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 Pt(P,W){for(var $,D;;){if(P.lookahead<B){if(gt(P),P.lookahead<B&&0===W)return 1;if(0===P.lookahead)break}if($=0,P.lookahead>=3&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+3-1])&P.hash_mask,$=P.prev[P.strstart&P.w_mask]=P.head[P.ins_h],P.head[P.ins_h]=P.strstart),0!==$&&P.strstart-$<=P.w_size-B&&(P.match_length=J(P,$)),P.match_length>=3)if(D=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,$=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 D=a._tr_tally(P,0,P.window[P.strstart]),P.lookahead--,P.strstart++;if(D&&(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 ut(P,W){for(var $,D,z;;){if(P.lookahead<B){if(gt(P),P.lookahead<B&&0===W)return 1;if(0===P.lookahead)break}if($=0,P.lookahead>=3&&(P.ins_h=(P.ins_h<<P.hash_shift^P.window[P.strstart+3-1])&P.hash_mask,$=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!==$&&P.prev_length<P.max_lazy_match&&P.strstart-$<=P.w_size-B&&(P.match_length=J(P,$),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,D=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,$=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++,D&&(V(P,!1),0===P.strm.avail_out))return 1}else if(P.match_available){if((D=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&&(D=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 nt(P,W,$,D,z){this.good_length=P,this.max_lazy=W,this.nice_length=$,this.max_chain=D,this.func=z}function ct(){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),rt(this.dyn_ltree),rt(this.dyn_dtree),rt(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),rt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new o.Buf16(573),rt(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):lt(P,_)}function xt(P){var $,W=pt(P);return 0===W&&(($=P.state).window_size=2*$.w_size,rt($.head),$.max_lazy_match=n[$.level].max_lazy,$.good_match=n[$.level].good_length,$.nice_match=n[$.level].nice_length,$.max_chain_length=n[$.level].max_chain,$.strstart=0,$.block_start=0,$.lookahead=0,$.insert=0,$.match_length=$.prev_length=2,$.match_available=0,$.ins_h=0),W}function St(P,W,$,D,z,R){if(!P)return _;var X=1;if(-1===W&&(W=6),D<0?(X=0,D=-D):15<D&&(X=2,D-=16),z<1||9<z||8!==$||D<8||15<D||W<0||9<W||R<0||4<R)return lt(P,_);8===D&&(D=9);var K=new ct;return(P.state=K).strm=P,K.wrap=X,K.gzhead=null,K.w_bits=D,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=$,xt(P)}n=[new nt(0,0,0,0,function(P,W){var $=65535;for($>P.pending_buf_size-5&&($=P.pending_buf_size-5);;){if(P.lookahead<=1){if(gt(P),0===P.lookahead&&0===W)return 1;if(0===P.lookahead)break}P.strstart+=P.lookahead,P.lookahead=0;var D=P.block_start+$;if((0===P.strstart||P.strstart>=D)&&(P.lookahead=P.strstart-D,P.strstart=D,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 nt(4,4,8,4,Pt),new nt(4,5,16,8,Pt),new nt(4,6,32,32,Pt),new nt(4,4,16,16,ut),new nt(8,16,32,32,ut),new nt(8,16,128,128,ut),new nt(8,32,128,256,ut),new nt(32,128,258,1024,ut),new nt(32,258,258,4096,ut)],s.deflateInit=function(P,W){return St(P,W,8,15,8,0)},s.deflateInit2=St,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 $,D,z,R;if(!P||!P.state||5<W||W<0)return P?lt(P,_):_;if(D=P.state,!P.output||!P.input&&0!==P.avail_in||666===D.status&&4!==W)return lt(P,0===P.avail_out?-5:_);if(D.strm=P,$=D.last_flush,D.last_flush=W,42===D.status)if(2===D.wrap)P.adler=0,st(D,31),st(D,139),st(D,8),D.gzhead?(st(D,(D.gzhead.text?1:0)+(D.gzhead.hcrc?2:0)+(D.gzhead.extra?4:0)+(D.gzhead.name?8:0)+(D.gzhead.comment?16:0)),st(D,255&D.gzhead.time),st(D,D.gzhead.time>>8&255),st(D,D.gzhead.time>>16&255),st(D,D.gzhead.time>>24&255),st(D,9===D.level?2:2<=D.strategy||D.level<2?4:0),st(D,255&D.gzhead.os),D.gzhead.extra&&D.gzhead.extra.length&&(st(D,255&D.gzhead.extra.length),st(D,D.gzhead.extra.length>>8&255)),D.gzhead.hcrc&&(P.adler=c(P.adler,D.pending_buf,D.pending,0)),D.gzindex=0,D.status=69):(st(D,0),st(D,0),st(D,0),st(D,0),st(D,0),st(D,9===D.level?2:2<=D.strategy||D.level<2?4:0),st(D,3),D.status=L);else{var X=8+(D.w_bits-8<<4)<<8;X|=(2<=D.strategy||D.level<2?0:D.level<6?1:6===D.level?2:3)<<6,0!==D.strstart&&(X|=32),X+=31-X%31,D.status=L,it(D,X),0!==D.strstart&&(it(D,P.adler>>>16),it(D,65535&P.adler)),P.adler=1}if(69===D.status)if(D.gzhead.extra){for(z=D.pending;D.gzindex<(65535&D.gzhead.extra.length)&&(D.pending!==D.pending_buf_size||(D.gzhead.hcrc&&D.pending>z&&(P.adler=c(P.adler,D.pending_buf,D.pending-z,z)),F(P),z=D.pending,D.pending!==D.pending_buf_size));)st(D,255&D.gzhead.extra[D.gzindex]),D.gzindex++;D.gzhead.hcrc&&D.pending>z&&(P.adler=c(P.adler,D.pending_buf,D.pending-z,z)),D.gzindex===D.gzhead.extra.length&&(D.gzindex=0,D.status=73)}else D.status=73;if(73===D.status)if(D.gzhead.name){z=D.pending;do{if(D.pending===D.pending_buf_size&&(D.gzhead.hcrc&&D.pending>z&&(P.adler=c(P.adler,D.pending_buf,D.pending-z,z)),F(P),z=D.pending,D.pending===D.pending_buf_size)){R=1;break}R=D.gzindex<D.gzhead.name.length?255&D.gzhead.name.charCodeAt(D.gzindex++):0,st(D,R)}while(0!==R);D.gzhead.hcrc&&D.pending>z&&(P.adler=c(P.adler,D.pending_buf,D.pending-z,z)),0===R&&(D.gzindex=0,D.status=91)}else D.status=91;if(91===D.status)if(D.gzhead.comment){z=D.pending;do{if(D.pending===D.pending_buf_size&&(D.gzhead.hcrc&&D.pending>z&&(P.adler=c(P.adler,D.pending_buf,D.pending-z,z)),F(P),z=D.pending,D.pending===D.pending_buf_size)){R=1;break}R=D.gzindex<D.gzhead.comment.length?255&D.gzhead.comment.charCodeAt(D.gzindex++):0,st(D,R)}while(0!==R);D.gzhead.hcrc&&D.pending>z&&(P.adler=c(P.adler,D.pending_buf,D.pending-z,z)),0===R&&(D.status=103)}else D.status=103;if(103===D.status&&(D.gzhead.hcrc?(D.pending+2>D.pending_buf_size&&F(P),D.pending+2<=D.pending_buf_size&&(st(D,255&P.adler),st(D,P.adler>>8&255),P.adler=0,D.status=L)):D.status=L),0!==D.pending){if(F(P),0===P.avail_out)return D.last_flush=-1,0}else if(0===P.avail_in&&Z(W)<=Z($)&&4!==W)return lt(P,-5);if(666===D.status&&0!==P.avail_in)return lt(P,-5);if(0!==P.avail_in||0!==D.lookahead||0!==W&&666!==D.status){var K=2===D.strategy?function(U,tt){for(var at;;){if(0===U.lookahead&&(gt(U),0===U.lookahead)){if(0===tt)return 1;break}if(U.match_length=0,at=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++,at&&(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}(D,W):3===D.strategy?function(U,tt){for(var at,et,ht,bt,yt=U.window;;){if(U.lookahead<=k){if(gt(U),U.lookahead<=k&&0===tt)return 1;if(0===U.lookahead)break}if(U.match_length=0,U.lookahead>=3&&0<U.strstart&&(et=yt[ht=U.strstart-1])===yt[++ht]&&et===yt[++ht]&&et===yt[++ht]){bt=U.strstart+k;do{}while(et===yt[++ht]&&et===yt[++ht]&&et===yt[++ht]&&et===yt[++ht]&&et===yt[++ht]&&et===yt[++ht]&&et===yt[++ht]&&et===yt[++ht]&&ht<bt);U.match_length=k-(bt-ht),U.match_length>U.lookahead&&(U.match_length=U.lookahead)}if(U.match_length>=3?(at=a._tr_tally(U,1,U.match_length-3),U.lookahead-=U.match_length,U.strstart+=U.match_length,U.match_length=0):(at=a._tr_tally(U,0,U.window[U.strstart]),U.lookahead--,U.strstart++),at&&(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}(D,W):n[D.level].func(D,W);if(3!==K&&4!==K||(D.status=666),1===K||3===K)return 0===P.avail_out&&(D.last_flush=-1),0;if(2===K&&(1===W?a._tr_align(D):5!==W&&(a._tr_stored_block(D,0,0,!1),3===W&&(rt(D.head),0===D.lookahead&&(D.strstart=0,D.block_start=0,D.insert=0))),F(P),0===P.avail_out))return D.last_flush=-1,0}return 4!==W?0:D.wrap<=0?1:(2===D.wrap?(st(D,255&P.adler),st(D,P.adler>>8&255),st(D,P.adler>>16&255),st(D,P.adler>>24&255),st(D,255&P.total_in),st(D,P.total_in>>8&255),st(D,P.total_in>>16&255),st(D,P.total_in>>24&255)):(it(D,P.adler>>>16),it(D,65535&P.adler)),F(P),0<D.wrap&&(D.wrap=-D.wrap),0!==D.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?lt(P,_):(P.state=null,W===L?lt(P,-3):0):_},s.deflateSetDictionary=function(P,W){var $,D,z,R,X,K,U,tt,at=W.length;if(!P||!P.state||2===(R=($=P.state).wrap)||1===R&&42!==$.status||$.lookahead)return _;for(1===R&&(P.adler=l(P.adler,W,at,0)),$.wrap=0,at>=$.w_size&&(0===R&&(rt($.head),$.strstart=0,$.block_start=0,$.insert=0),tt=new o.Buf8($.w_size),o.arraySet(tt,W,at-$.w_size,$.w_size,0),W=tt,at=$.w_size),X=P.avail_in,K=P.next_in,U=P.input,P.avail_in=at,P.next_in=0,P.input=W,gt($);$.lookahead>=3;){for(D=$.strstart,z=$.lookahead-2;$.ins_h=($.ins_h<<$.hash_shift^$.window[D+3-1])&$.hash_mask,$.prev[D&$.w_mask]=$.head[$.ins_h],$.head[$.ins_h]=D,D++,--z;);$.strstart=D,$.lookahead=2,gt($)}return $.strstart+=$.lookahead,$.block_start=$.strstart,$.insert=$.lookahead,$.lookahead=0,$.match_length=$.prev_length=2,$.match_available=0,P.next_in=K,P.input=U,P.avail_in=X,$.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,b,T,C,S,M,A,O,I,k,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,b=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&&(b+=x[l++]<<T,b+=x[l++]<<(T+=8),T+=8),O=C[b&M];e:for(;;){if(b>>>=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)+(b&(1<<I)-1)];continue e}if(32&I){a.mode=12;break t}n.msg="invalid literal/length code",a.mode=30;break t}k=65535&O,(I&=15)&&(T<I&&(b+=x[l++]<<T,T+=8),k+=b&(1<<I)-1,b>>>=I,T-=I),T<15&&(b+=x[l++]<<T,b+=x[l++]<<(T+=8),T+=8),O=S[b&A];i:for(;;){if(b>>>=I=O>>>24,T-=I,!(16&(I=O>>>16&255))){if(!(64&I)){O=S[(65535&O)+(b&(1<<I)-1)];continue i}n.msg="invalid distance code",a.mode=30;break t}if(B=65535&O,T<(I&=15)&&(b+=x[l++]<<T,(T+=8)<I&&(b+=x[l++]<<T,T+=8)),d<(B+=b&(1<<I)-1)){n.msg="invalid distance too far back",a.mode=30;break t}if(b>>>=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<k){for(k-=I;N[h++]=g[E++],--I;);E=h-B,L=N}}else if(w<I){if(E+=_+w-I,(I-=w)<k){for(k-=I;N[h++]=g[E++],--I;);if(E=0,w<k){for(k-=I=w;N[h++]=g[E++],--I;);E=h-B,L=N}}}else if(E+=w-I,I<k){for(k-=I;N[h++]=g[E++],--I;);E=h-B,L=N}for(;2<k;)N[h++]=L[E++],N[h++]=L[E++],N[h++]=L[E++],k-=3;k&&(N[h++]=L[E++],1<k&&(N[h++]=L[E++]))}else{for(E=h-B;N[h++]=N[E++],N[h++]=N[E++],N[h++]=N[E++],2<(k-=3););k&&(N[h++]=N[E++],1<k&&(N[h++]=N[E++]))}break}}break}}while(l<c&&h<f);l-=k=T>>3,b&=(1<<(T-=k<<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=b,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 b(){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 b,(E.state=N).window=null,0!==(x=S(E,L))&&(E.state=null),x):d}var A,O,I=!0;function k(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,lt,Z,rt,F,V,st,it,J,gt,Pt,ut,nt,ct,pt,xt,St,P,W,$,D,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),lt=E.next_out,Y=E.output,q=E.next_in,N=E.input,F=x.hold,V=x.bits,st=Z=E.avail_in,it=rt=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=lt,E.avail_out=rt,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(k(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),rt<J&&(J=rt),0===J)break t;n.arraySet(Y,N,q,J,lt),Z-=J,q+=J,rt-=J,lt+=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,$={bits:x.lenbits}),x.lenbits=$.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(;nt=(z=x.lencode[F&(1<<x.lenbits)-1])>>>16&255,ct=65535&z,!((ut=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(ct<16)F>>>=ut,V-=ut,x.lens[x.have++]=ct;else{if(16===ct){for(D=ut+2;V<D;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(F>>>=ut,V-=ut,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===ct){for(D=ut+3;V<D;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}V-=ut,P=0,J=3+(7&(F>>>=ut)),F>>>=3,V-=3}else{for(D=ut+7;V<D;){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}V-=ut,P=0,J=11+(127&(F>>>=ut)),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,$={bits:x.lenbits}),x.lenbits=$.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,$={bits:x.distbits}),x.distbits=$.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<=rt){E.next_out=lt,E.avail_out=rt,E.next_in=q,E.avail_in=Z,x.hold=F,x.bits=V,l(E,it),lt=E.next_out,Y=E.output,rt=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;nt=(z=x.lencode[F&(1<<x.lenbits)-1])>>>16&255,ct=65535&z,!((ut=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(nt&&!(240&nt)){for(pt=ut,xt=nt,St=ct;nt=(z=x.lencode[St+((F&(1<<pt+xt)-1)>>pt)])>>>16&255,ct=65535&z,!(pt+(ut=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}F>>>=pt,V-=pt,x.back+=pt}if(F>>>=ut,V-=ut,x.back+=ut,x.length=ct,0===nt){x.mode=26;break}if(32&nt){x.back=-1,x.mode=12;break}if(64&nt){E.msg="invalid literal/length code",x.mode=30;break}x.extra=15&nt,x.mode=22;case 22:if(x.extra){for(D=x.extra;V<D;){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(;nt=(z=x.distcode[F&(1<<x.distbits)-1])>>>16&255,ct=65535&z,!((ut=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}if(!(240&nt)){for(pt=ut,xt=nt,St=ct;nt=(z=x.distcode[St+((F&(1<<pt+xt)-1)>>pt)])>>>16&255,ct=65535&z,!(pt+(ut=z>>>24)<=V);){if(0===Z)break t;Z--,F+=N[q++]<<V,V+=8}F>>>=pt,V-=pt,x.back+=pt}if(F>>>=ut,V-=ut,x.back+=ut,64&nt){E.msg="invalid distance code",x.mode=30;break}x.offset=ct,x.extra=15&nt,x.mode=24;case 24:if(x.extra){for(D=x.extra;V<D;){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===rt)break t;if(x.offset>(J=it-rt)){if((J=x.offset-J)>x.whave&&x.sane){E.msg="invalid distance too far back",x.mode=30;break}gt=J>x.wnext?x.wsize-(J-=x.wnext):x.wnext-J,J>x.length&&(J=x.length),Pt=x.window}else Pt=Y,gt=lt-x.offset,J=x.length;for(rt<J&&(J=rt),rt-=J,x.length-=J;Y[lt++]=Pt[gt++],--J;);0===x.length&&(x.mode=21);break;case 26:if(0===rt)break t;Y[lt++]=x.length,rt--,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-=rt,x.total+=it,it&&(E.adler=x.check=x.flags?a(x.check,Y,it,lt-it):o(x.check,Y,it,lt-it)),it=rt,(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=lt,E.avail_out=rt,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+=st-=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==st&&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 b,T,C,S,M,A,O,I,k,B=g.bits,E=0,L=0,x=0,N=0,Y=0,q=0,lt=0,Z=0,rt=0,F=0,V=null,st=0,it=new n.Buf16(16),J=new n.Buf16(16),gt=null,Pt=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=gt=w,19):1===h?(V=o,st-=257,gt=a,Pt-=257,256):(V=l,gt=c,-1),E=x,M=m,lt=L=F=0,C=-1,S=(rt=1<<(q=Y))-1,1===h&&852<rt||2===h&&592<rt)return 1;for(;;){for(O=E-lt,k=w[L]<A?(I=0,w[L]):w[L]>A?(I=gt[Pt+w[L]],V[st+w[L]]):(I=96,0),b=1<<E-lt,x=T=1<<q;_[M+(F>>lt)+(T-=b)]=O<<24|I<<16|k,0!==T;);for(b=1<<E-1;F&b;)b>>=1;if(0!==b?(F&=b-1,F+=b):F=0,L++,0==--it[E]){if(E===N)break;E=u[f+w[L]]}if(Y<E&&(F&S)!==C){for(0===lt&&(lt=Y),M+=x,Z=1<<(q=E-lt);q+lt<N&&!((Z-=it[q+lt])<=0);)q++,Z<<=1;if(rt+=1<<q,1===h&&852<rt||2===h&&592<rt)return 1;_[C=F&S]=Y<<24|q<<16|M-m}}return 0!==F&&(_[M+F]=E-lt<<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],k=[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,lt,Z=new Array(d);function rt(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 st(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,st(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 gt(z,R){for(var X=0;X|=1&z,z>>>=1,X<<=1,0<--R;);return X>>>1}function Pt(z,R,X){var K,U,tt=new Array(16),at=0;for(K=1;K<=w;K++)tt[K]=at=at+X[K-1]<<1;for(U=0;U<=R;U++){var et=z[2*U+1];0!==et&&(z[2*U]=gt(tt[et]++,et))}}function ut(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 nt(z){8<z.bi_valid?st(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 ct(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&&ct(R,z.heap[U+1],z.heap[U],z.depth)&&U++,!ct(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,at,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!==(at=A[tt])&&it(z,U-=N[tt],at),J(z,tt=V(--K),X),0!==(at=O[tt])&&it(z,K-=Z[tt],at)),et<z.last_lit;);J(z,256,R)}function St(z,R){var X,K,U,tt=R.dyn_tree,at=R.stat_desc.static_tree,et=R.stat_desc.has_stree,ht=R.stat_desc.elems,bt=-1;for(z.heap_len=0,z.heap_max=573,X=0;X<ht;X++)0!==tt[2*X]?(z.heap[++z.heap_len]=bt=X,z.depth[X]=0):tt[2*X+1]=0;for(;z.heap_len<2;)tt[2*(U=z.heap[++z.heap_len]=bt<2?++bt:0)]=1,z.depth[U]=0,z.opt_len--,et&&(z.static_len-=at[2*U+1]);for(R.max_code=bt,X=z.heap_len>>1;1<=X;X--)pt(z,tt,X);for(U=ht;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(yt,Vt){var ui,fe,Ce,kt,Ni,ls,pe=Vt.dyn_tree,De=Vt.max_code,oe=Vt.stat_desc.static_tree,ae=Vt.stat_desc.has_stree,Zr=Vt.stat_desc.extra_bits,di=Vt.stat_desc.extra_base,Ke=Vt.stat_desc.max_length,fi=0;for(kt=0;kt<=w;kt++)yt.bl_count[kt]=0;for(pe[2*yt.heap[yt.heap_max]+1]=0,ui=yt.heap_max+1;ui<573;ui++)Ke<(kt=pe[2*pe[2*(fe=yt.heap[ui])+1]+1]+1)&&(kt=Ke,fi++),pe[2*fe+1]=kt,De<fe||(yt.bl_count[kt]++,Ni=0,di<=fe&&(Ni=Zr[fe-di]),yt.opt_len+=(ls=pe[2*fe])*(kt+Ni),ae&&(yt.static_len+=ls*(oe[2*fe+1]+Ni)));if(0!==fi){do{for(kt=Ke-1;0===yt.bl_count[kt];)kt--;yt.bl_count[kt]--,yt.bl_count[kt+1]+=2,yt.bl_count[Ke]--,fi-=2}while(0<fi);for(kt=Ke;0!==kt;kt--)for(fe=yt.bl_count[kt];0!==fe;)De<(Ce=yt.heap[--ui])||(pe[2*Ce+1]!==kt&&(yt.opt_len+=(kt-pe[2*Ce+1])*pe[2*Ce],pe[2*Ce+1]=kt),fe--)}}(z,R),Pt(tt,bt,z.bl_count)}function P(z,R,X){var K,U,tt=-1,at=R[1],et=0,ht=7,bt=4;for(0===at&&(ht=138,bt=3),R[2*(X+1)+1]=65535,K=0;K<=X;K++)U=at,at=R[2*(K+1)+1],++et<ht&&U===at||(et<bt?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,bt=(et=0)===at?(ht=138,3):U===at?(ht=6,3):(ht=7,4))}function W(z,R,X){var K,U,tt=-1,at=R[1],et=0,ht=7,bt=4;for(0===at&&(ht=138,bt=3),K=0;K<=X;K++)if(U=at,at=R[2*(K+1)+1],!(++et<ht&&U===at)){if(et<bt)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,bt=(et=0)===at?(ht=138,3):U===at?(ht=6,3):(ht=7,4)}}l(Z);var $=!1;function D(z,R,X,K){var U,tt,at;it(z,0+(K?1:0),3),tt=R,at=X,nt(U=z),st(U,at),st(U,~at),n.arraySet(U.pending_buf,U.window,tt,at,U.pending),U.pending+=at}s._tr_init=function(z){$||(function(){var R,X,K,U,tt,at=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++)at[X]=0;for(R=0;R<=143;)B[2*R+1]=8,R++,at[8]++;for(;R<=255;)B[2*R+1]=9,R++,at[9]++;for(;R<=279;)B[2*R+1]=7,R++,at[7]++;for(;R<=287;)B[2*R+1]=8,R++,at[8]++;for(Pt(B,287,at),R=0;R<d;R++)E[2*R+1]=5,E[2*R]=gt(R,5);Y=new rt(B,A,257,f,w),q=new rt(E,O,0,d,w),lt=new rt(new Array(0),I,0,19,7)}(),$=!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,lt),z.bi_buf=0,z.bi_valid=0,ut(z)},s._tr_stored_block=D,s._tr_flush_block=function(z,R,X,K){var U,tt,at=0;0<z.level?(2===z.strm.data_type&&(z.strm.data_type=function(et){var ht,bt=4093624447;for(ht=0;ht<=31;ht++,bt>>>=1)if(1&bt&&0!==et.dyn_ltree[2*ht])return 0;if(0!==et.dyn_ltree[18]||0!==et.dyn_ltree[20]||0!==et.dyn_ltree[26])return 1;for(ht=32;ht<u;ht++)if(0!==et.dyn_ltree[2*ht])return 1;return 0}(z)),St(z,z.l_desc),St(z,z.d_desc),at=function(et){var ht;for(P(et,et.dyn_ltree,et.l_desc.max_code),P(et,et.dyn_dtree,et.d_desc.max_code),St(et,et.bl_desc),ht=18;3<=ht&&0===et.bl_tree[2*k[ht]+1];ht--);return et.opt_len+=3*(ht+1)+5+5+4,ht}(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?D(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,ht,bt,yt){var Vt;for(it(et,ht-257,5),it(et,bt-1,5),it(et,yt-4,4),Vt=0;Vt<yt;Vt++)it(et,et.bl_tree[2*k[Vt]+1],3);W(et,et.dyn_ltree,ht-1),W(et,et.dyn_dtree,bt-1)}(z,z.l_desc.max_code+1,z.d_desc.max_code+1,at+1),xt(z,z.dyn_ltree,z.dyn_dtree)),ut(z),K&&nt(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?(st(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(){b(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){b(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(){b(C),S.onreadystatechange=null,c.removeChild(S),S=null},c.appendChild(S)}):function(C){setTimeout(b,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 b(C){if(_)setTimeout(b,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)&&b(+C.data.slice(u.length))}}(typeof self>"u"?void 0===n?this:n:self)}).call(this,typeof nn<"u"?nn:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10);const cl=Nf(ll.exports);class Tr{constructor(t,e){y(this,"date",new Date),y(this,"author"),y(this,"guid",te.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(jt);this.author=i.config.author}set comment(t){var e;const i=this._components.get(jt);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 hl=class ei{constructor(t){y(this,"guid",te.create()),y(this,"title",ei.default.title),y(this,"creationDate",new Date),y(this,"creationAuthor",""),y(this,"viewpoints",new ft.PG),y(this,"relatedTopics",new ft.PG),y(this,"comments",new ft.jp),y(this,"documentReferences",new ft.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",ei.default.type),y(this,"_status",ei.default.status),y(this,"_priority",ei.default.priority),y(this,"_stage",ei.default.stage),y(this,"_assignedTo",ei.default.assignedTo),y(this,"_labels",ei.default.labels??new Set),y(this,"_components"),this._components=t;const e=t.get(jt);this.creationAuthor=e.config.author,this.relatedTopics.guard=i=>i!==this.guid}set type(t){const e=this._components.get(jt),{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(jt),{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(jt);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(jt);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(jt);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(jt),{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(jt).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(jt).list.set(this.guid,this),this}createComment(t,e){const i=new Tr(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(jt).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(Oe);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(jt);for(const s of this.documentReferences){const n=i.documents.get(s);if(!n)continue;let o={$Guid:te.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(Oe);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(jt);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:te.create(),description:a.description,url:a.url}:{guid:te.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 ${ws.builder.build(n)}`}};y(hl,"default",{title:"BCF Topic",type:"Issue",status:"Active"});let ul=hl;class Ff extends qi{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 Pr=class us extends Et{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 Ff(this,this.components,"BCF Topics",us.uuid)),y(this,"list",new ft.jp),y(this,"documents",new ft.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 ul(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(Oe);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 cl;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(Oe);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&&Tr))return null;const a=new Tr(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 cl;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=us.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=jt.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(Oe),w=h.filter(C=>C.name.endsWith(".bcfv"));for(const C of w){const S=yield C.async("string"),M=us.xmlParser.parse(S).VisualizationInfo;if(!M){console.warn("Missing VisualizationInfo in Viewpoint");continue}const A={},{Guid:O,ClippingPlanes:I,Components:k,OrthogonalCamera:B,PerspectiveCamera:E}=M;if(O&&(A.guid=O),k){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}=k;if(N&&N.Component){const Z=Array.isArray(N.Component)?N.Component:[N.Component];x.selection=Z.map(rt=>rt.IfcGuid?{ifc_guid:rt.IfcGuid}:null).filter(rt=>null!==rt)}if(Y&&"DefaultVisibility"in Y&&(x.visibility.default_visibility=Y.DefaultVisibility),Y&&Y.Exceptions&&"Component"in Y.Exceptions){const{Component:Z}=Y.Exceptions,rt=Array.isArray(Z)?Z:[Z];x.visibility.exceptions=rt.map(F=>F.IfcGuid?{ifc_guid:F.IfcGuid}:null).filter(F=>null!==F)}let q;"2.1"===u&&(q=k.ViewSetupHints),"3"===u&&(q=null==(i=k.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:lt}=k;if(lt&<.Color){const Z=Array.isArray(lt.Color)?lt.Color:[lt.Color];for(const rt of Z){const{Color:F,Component:V}=rt;if(6!==F.length&&8!==F.length)continue;const st=6===F.length?F:F.slice(2),J=(Array.isArray(V)?V:[V]).map(gt=>gt.IfcGuid?{ifc_guid:gt.IfcGuid}:null).filter(gt=>null!==gt);x.coloring.push({color:st,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)),lt=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:lt.x,y:lt.y,z:lt.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 fl(e.components,A);_.push(L)}const g={},b=[],T=h.filter(C=>C.name.endsWith(".bcf"));for(const C of T){const S=yield C.async("string"),M=us.xmlParser.parse(S).Markup,A=M.Topic,{Guid:O,TopicType:I,TopicStatus:k,Title:B,CreationDate:E,CreationAuthor:L}=A;if(a&&!(O&&I&&k&&B&&E&&L))continue;const x=new ul(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=k??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 st of Y)x.labels.add(st);const q=e.getMarkupComments(M,u);for(const st of q)x.comments.set(st.guid,st);const lt=e.getMarkupViewpoints(M,u);for(const st of lt){if(!st||!st.Guid)continue;const it=m.list.get(st.Guid);if(!it)continue;x.viewpoints.add(it.guid);const J=`${x.guid}/${st.Snapshot}`,gt=h.find(({name:Pt})=>Pt===J);if(gt){const Pt=yield gt.async("arraybuffer"),ut=new Uint8Array(Pt);m.snapshots.set(it.guid,ut),it.snapshot=it.guid??null}}const Z=e.getMarkupDocumentReferences(M,u),rt=h.find(st=>"documents.xml"===st.name);let F=[];const V=yield rt?.async("string");if(V){const st=null==(n=null==(s=ws.parser.parse(V).DocumentInfo)?void 0:s.Documents)?void 0:n.Document;F=Array.isArray(st)?st:[st]}for(const st of Z){const{Description:it,DocumentGuid:J,Url:gt,isExternal:Pt,ReferencedDocument:ut}=st;if(J&&F.length>0){const nt=F.find(({Guid:P})=>P===J),ct=h.find(P=>P.name.endsWith(J)),pt=yield ct?.async("uint8array");if(!nt||!pt)continue;const{Description:xt,Filename:St}=nt;e.documents.set(J,{type:"internal",fileName:St,description:xt,data:pt}),x.documentReferences.add(J)}if(gt){const nt=e.documents.add({type:"external",url:gt,description:it});x.documentReferences.add(nt)}if(ut){let nt=null;if(Pt)nt=e.documents.add({type:"external",url:ut,description:it});else{const ct=ut.split("/"),pt=ct[ct.length-1],xt=h.find(P=>P.name.endsWith(pt)),St=yield xt?.async("uint8array");if(!St)continue;nt=e.documents.add({type:"internal",fileName:pt,data:St,description:it})}x.documentReferences.add(nt)}}e.list.set(x.guid,x),b.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(b),{viewpoints:_,topics:b}})()}};y(Pr,"uuid","de977976-e4f6-4e4f-a01a-204727839802"),y(Pr,"xmlParser",new Dn({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 jt=Pr;class Sr{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(Xe),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(Xe);e.renderer.setPlane(!0,this.three,c.localClippingPlanes),this._planeMesh=Sr.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(Xe);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 ih.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 Vf extends qi{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 dl=class fn extends Et{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",Sr),y(this,"list",new ft.jp),y(this,"config",new Vf(this,this.components,"Clipper",fn.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(fn.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(dt);if(t.initialized)this.subscribeToFragmentMaterials();else{const e=()=>{t.onFragmentsLoaded.remove(e),this.subscribeToFragmentMaterials()};t.onFragmentsLoaded.add(e)}}subscribeToFragmentMaterials(){const t=this.components.get(dt);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(en);for(const[,i]of e.list)if(i.renderer)return void(t.clippingPlanes=i.renderer.clippingPlanes)}dispose(){this._enabled=!1,this.components.get(bs).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(fn.uuid),this.onDisposed.reset()}create(t){var e=this;return(0,G.A)(function*(){const n=yield e.components.get(tn).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(tn).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=te.create();return this.list.set(n,s),this.onAfterCreate.trigger(s),n}updateMaterialsAndPlanes(){const t=this.components.get(en);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(dl,"uuid","66290bc5-18c4-4cd1-9379-2e17a0617611");let Xe=dl;class fl{constructor(t,e){y(this,"title"),y(this,"guid",te.create()),y(this,"clippingPlanes",new ft.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 ft.PG),y(this,"selectionComponents",new ft.PG),y(this,"componentColors",new ft.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(Oe).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(dt).guidsToModelIdMap([...t.selectionComponents])})()}getExceptionMap(){var t=this;return(0,G.A)(function*(){return yield t._components.get(dt).guidsToModelIdMap([...t.exceptionComponents])})()}get projection(){return"field_of_view"in this.camera?"Perspective":"Orthographic"}get position(){const t=this._components.get(dt),{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(dt);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(jt).config.version}get topics(){return[...this._components.get(jt).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(Xe);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 sn))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(dt);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(Oe),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 b=yield g.arrayBuffer(),T=new Uint8Array(b);_.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(Oe),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(Xe);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(of);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(dt),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:ft.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(Xe);for(const[i,s]of e.list)s.enabled=t&&this.clippingPlanes.has(i)}setClippingVisibility(t){const e=this._components.get(Xe);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(dt);let o="";if(e._components.get(jt).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(Xe),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(Oe),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(dt),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 Uf extends qi{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 pl=class fo extends Et{constructor(t){super(t),y(this,"enabled",!0),y(this,"world",null),y(this,"list",new ft.jp),y(this,"snapshots",new ft.jp),y(this,"isSetup",!1),y(this,"onSetup",new Q),y(this,"config",new Uf(this,this.components,"Viewpoints",fo.uuid)),y(this,"onDisposed",new Q),t.add(fo.uuid,this)}create(t){const e=new fl(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(pl,"uuid","ee867824-a796-408d-8aa0-4e5962a83c66");let Oe=pl;class ml{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",te.create()),y(this,"_open",!1),y(this,"_range",$f.defaultRange),y(this,"_world",null),y(this,"_helpersVisible",!1),y(this,"_planesEnabled",!1),this._components=t,this.camera=new sn(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(yi);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 Er=class Yc extends Et{constructor(t){super(t),y(this,"list",new ft.jp),y(this,"enabled",!0),y(this,"world",null),y(this,"_fragmentsUpdateEvent",()=>{this.components.get(dt).core.update(!0)}),y(this,"restoreCameraOnClose",!0),y(this,"_restoreState",null),t.add(Yc.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 ml(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 ml(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(dt),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(dt),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(Xa);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:b,back:T,left:C,right:S}=n(a),M=this.createFromPlane(_,{id:b,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(Er,"uuid","fb22f1f5-6598-4664-a11d-de8963ae420f"),y(Er,"defaultRange",15);let $f=Er;class ki{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 ft.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 xe=(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 Yf extends ki{constructor(t,e){super(t),y(this,"facetType","Attribute"),y(this,"name"),y(this,"value"),this.name=e}serialize(t){const e=xe("Name",this.name),i=xe("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(dt);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 b=i.evalRequirement(g,i.name,"Name");if(!b)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())&&b)}),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 Zf extends ki{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=xe("System",this.system),i=xe("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 Ir extends ki{constructor(t,e){super(t),y(this,"facetType","Entity"),y(this,"name"),y(this,"predefinedType"),this.name=e}serialize(t){const e=xe("Name",this.name),i=xe("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(dt),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))&&Nt.append(e,a,u._localId.value)}else Nt.add(e,o)})()}test(t,e,i){var s=this;return(0,G.A)(function*(){const n=s._components.get(dt);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(dt).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 Wf extends ki{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=xe("PropertySet",this.propertySet),i=xe("BaseName",this.baseName),s=xe("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(dt);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 b=m[g];if(!("value"in b)||!i.evalRequirement(b.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);Nt.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(dt);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 b=w[g];if(!Array.isArray(b)){d.push({currentValue:null,parameter:"BaseName",pass:!1,requiredValue:i.baseName});continue}const T=b.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 Xf extends ki{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=xe("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(dt);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!==_);Nt.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(dt);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 Kf extends ki{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 Ir(t,e.name),this._entityFacet.predefinedType=e.predefinedType}set entity(t){this._entity=t;const{name:e,predefinedType:i}=t;this._entityFacet=new Ir(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 Qf{constructor(t,e,i){y(this,"name"),y(this,"ifcVersion",new Set),y(this,"identifier",te.create()),y(this,"description"),y(this,"instructions"),y(this,"requirementsDescription"),y(this,"applicability",new ft.PG),y(this,"requirements",new ft.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(Jf).list.set(this.identifier,this),this}test(t){var e=this;return(0,G.A)(function*(i,s={skipIfFails:!0}){const n=new ft.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 de=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},gl=(r,t)=>{const e=[];for(const i of t){const n=de(i.name);if(!n)continue;const o=new Ir(r,n);i.cardinality&&(o.cardinality=i.cardinality),o.predefinedType=de(i.predefinedType),o.instructions=i.instructions,e.push(o)}return e},_l=(r,t)=>{const e=[];for(const i of t){const n=de(i.name);if(!n)continue;const o=new Yf(r,n);i.cardinality&&(o.cardinality=i.cardinality),o.value=de(i.value),o.instructions=i.instructions,e.push(o)}return e},yl=(r,t)=>{const e=[];for(const i of t){const s=new Xf(r);i.cardinality&&(s.cardinality=i.cardinality);const n=de(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},wl=(r,t)=>{const e=[];for(const i of t){const n=i.baseName,o=de(i.propertySet),a=de(n);if(!a||!o)continue;const l=new Wf(r,o,a);i.cardinality&&(l.cardinality=i.cardinality);const c=de(i.value);l.value=c,l.dataType=i.dataType,l.uri=i.uri,l.instructions=i.instructions,e.push(l)}return e},bl=(r,t)=>{const e=[];for(const i of t){const n=de(i.system);if(!n)continue;const o=new Zf(r,n);i.cardinality&&(o.cardinality=i.cardinality);const a=de(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},vl=(r,t)=>{const e=[];for(const i of t){const s=de(i.entity.name);if(!s)continue;const n=de(i.entity.predefinedType),o=new Kf(r,{name:s,predefinedType:n});o.relation=i.relation,i.cardinality&&(o.cardinality=i.cardinality),o.instructions=i.instructions,e.push(o)}return e},Or=class po extends Et{constructor(t){super(t),y(this,"enabled",!0),y(this,"IDSInfo"),y(this,"list",new ft.jp),t.add(po.uuid,this)}getModelIdMap(t){const e={},i={};for(const[s,n]of t){const a=[...n].filter(([,h])=>h.pass).map(([h])=>h);Nt.append(e,s,...a);const c=[...n].filter(([,h])=>!h.pass).map(([h])=>h);Nt.append(i,s,...c)}return{pass:e,fail:i}}create(t,e,i){const s=new Qf(this.components,t,e);return i&&(s.identifier=i),this.list.set(s.identifier,s),s}load(t){const e=[],i=po.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=gl(this.components,O);d.push(...I)}if("attribute"===A){const I=_l(this.components,O);d.push(...I)}if("material"===A){const I=yl(this.components,O);d.push(...I)}if("classification"===A){const I=bl(this.components,O);d.push(...I)}if("property"===A){const I=wl(this.components,O);d.push(...I)}if("partOf"===A){const I=vl(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=gl(this.components,O);_.push(...I)}if("attribute"===A){const I=_l(this.components,O);_.push(...I)}if("material"===A){const I=yl(this.components,O);_.push(...I)}if("classification"===A){const I=bl(this.components,O);_.push(...I)}if("property"===A){const I=wl(this.components,O);_.push(...I)}if("partOf"===A){const I=vl(this.components,O);_.push(...I)}}}const b=this.create(l,c.split(/\s+/),f);b.description=h,b.instructions=u,b.requirementsDescription=g,b.applicability.add(...d),b.requirements.add(..._),e.push(b)}}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 ${Cr.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(Or,"uuid","9f0b9f78-9b2e-481a-b766-2fbfd01f342c"),y(Or,"xmlParser",new Dn({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 Jf=Or;y(class Zc extends Et{constructor(t){super(t),y(this,"enabled",!0),t.add(Zc.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(dt);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 xl=(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]},Cl=(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]},tp=()=>[],ep=(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 ip extends ft.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 sp extends ft.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 as=class Fe 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:Fe._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:Fe._BORDER_COLOR}),this._hoverMat=new p.V9B({color:Fe._BORDER_HOVER_COLOR});const i=new p.Gu$(.05,8,6);for(const s of Fe._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:Fe._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:Fe._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?Fe._BORDER_HOVER_COLOR:Fe._BORDER_COLOR))}};y(as,"_BORDER_COLOR",22015),y(as,"_BORDER_HOVER_COLOR",16746496),y(as,"_LINE_THRESHOLD",.06),y(as,"_HANDLE_DEFS",[{constraints:["left","top"]},{constraints:["right","top"]},{constraints:["right","bottom"]},{constraints:["left","bottom"]},{constraints:["top"]},{constraints:["right"]},{constraints:["bottom"]},{constraints:["left"]}]);let np=as;class rp{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 np(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 op extends ft.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 rp(t);return this._container.add(e.camera),e.setContainer(this._container),this.set(e.uuid,e),e}}const Tl=class pn 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:pn._FRAME_COLOR,depthTest:!1}),this._depthMat=new p.mrM({color:pn._DEPTH_COLOR,depthTest:!1,transparent:!0,opacity:.4}),this._planeMat=new p.V9B({color:pn._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(Tl,"_FRAME_COLOR",22015),y(Tl,"_DEPTH_COLOR",22015);class zr{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 ip),y(this,"layers",new sp(this.three)),y(this,"activeLayer","0"),y(this,"far",10),y(this,"viewports",new op(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 ap(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),b=w.clone().normalize(),T=(new p.Pq0).crossVectors(w,g).normalize(),C=(new p.Pq0).crossVectors(b,T).normalize();return(new p.kn4).makeBasis(b,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:vd}),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(nf),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=>zr.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(yi).destroy(this.three),this.onDisposed.trigger(),this.onDisposed.reset()}}class Di{constructor(t){y(this,"styles",new ft.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 ft.jp),y(this,"_meshMaterialCache",new ft.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(ze),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 ft.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 Pl(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 up(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 Sl(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 kr(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 pp extends Di{constructor(t){super(t),y(this,"enabled",!0),y(this,"machineState",{kind:"awaitingFirstPoint"}),y(this,"onMachineStateChanged",new Q),this.styles.set("default",{lineTick:xl,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,b]of[["pointA",d.pointA],["pointB",d.pointB],["offset",w]]){const T=Math.hypot(c.x-b.x,c.z-b.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 dp(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 hp(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 cp(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 lp(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=Pl(r.points,t.point);return{kind:"committed",dimensions:up(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=kr(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 Sl(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 fp(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=Pl(t,e),n=[];for(let o=0;o<t.length-1;o++)n.push(...kr({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 mp=Math.PI/180;function El(r,t,e,i){const s=function _p(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 Al(r,t,e,i){return El(r,t,e,i)<0}function Ml(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 wp(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 Il(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 b=0;b<8;b++){const T=o+a*(b/8),C=o+a*((b+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 Ol(r,t){const e=(new p.Pq0).subVectors(r.pointA,r.vertex).normalize(),i=(new p.Pq0).subVectors(r.pointB,r.vertex).normalize();return Il(r.vertex,e,i,r.arcRadius,t,r.flipped??!1)}function zl(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 Il(t,(new p.Pq0).subVectors(r,t).normalize(),(new p.Pq0).subVectors(e,t).normalize(),o,s,n)}class vp extends Di{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:xl,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 yp(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(mp))return r;const n=function gp(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=Al(r.pointA,r.vertex,r.pointB,t.point);return{...r,cursor:t.point.clone(),flipped:e}}if("CLICK"===t.type){const e=Al(r.pointA,r.vertex,r.pointB,t.point),i=Math.max(.05,Math.abs(El(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=Ol(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 Ml(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=zl(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 xp(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=zl(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 kl(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 Dr(r,t,e,i){return"curved"===i.leaderShape?function Sp(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 Pp(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 Dl(r,t){return Dr(r.arrowTip,r.elbow,r.extensionEnd,t)}function Ll(r,t,e,i,s){return i?Dr(t,"placingElbow"===r?i:e,i,s):[]}class Ep extends Di{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:Cl})}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 Cp(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:kl(r.elbow,t.point)}:"CLICK"===t.type?{kind:"enteringText",arrowTip:r.arrowTip,elbow:r.elbow,extensionEnd:kl(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=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){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?Ll("placingElbow",t.arrowTip,null,t.cursor,e):Ll("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 Nl extends Di{constructor(t){super(t),y(this,"enabled",!0),y(this,"_ownsChildGeometry",!1),y(this,"definitions",new ft.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 Bl(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 Rl(r,t){return new p.Pq0(r.position.x+r.direction.x*t,0,r.position.z+r.direction.z*t)}function Ap(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 Mp extends Di{constructor(t){super(t),y(this,"enabled",!0),this.styles.set("default",{lineTick:tp,meshTick:ep,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=Bl(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=Rl(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 Fl(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 Vl(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 Lr(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 Op={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 b=0;b<_;b++){const T=h.clone().addScaledVector(g,(b+.5)*m),C=h.clone().addScaledVector(g,b*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),k=T.z+S.z*Math.cos(O)+f.z*w*Math.sin(O),B=new p.Pq0(I,0,k);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 zp extends Di{constructor(t){super(t),y(this,"enabled",!0),y(this,"machineState",{kind:"awaitingCenter"}),y(this,"onMachineStateChanged",new Q),this.styles.set("default",{enclosure:Op,lineTick:Cl,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 Ip(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:Fl(r.elbow,t.point)}:"CLICK"===t.type?{kind:"enteringText",center:r.center,halfW:r.halfW,halfH:r.halfH,elbow:r.elbow,extensionEnd:Fl(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=Vl(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 Lr("awaitingRadius",t.center,0,0,null,t.cursor,e);case"awaitingElbow":return Lr("awaitingElbow",t.center,t.halfW,t.halfH,null,t.cursor,e);case"awaitingExtension":return Lr("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 $l=class Wc extends Et{constructor(t){super(t),y(this,"enabled",!0),y(this,"list",new ft.jp),y(this,"systems",new ft.jp),y(this,"onDisposed",new Q),t.add(Wc.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 zr(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 sn&&(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($l,"uuid","5c7d3b9a-4e8f-4a2b-9c1d-0e3f2a5b7c8d");let ze=$l;const kp=[[16711680,1],[16776960,2],[65280,3],[65535,4],[255,5],[16711935,6],[16777215,7],[0,7]];function ke(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 jl="\0HANDSEED\0";class Dp{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",jl),this}build(){return(this._lines.join("\n")+"\n").replace(jl,this._handleCounter.toString(16).toUpperCase())}}class Lp{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 Dp,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(ze).systems.get(Nl),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=ke(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,ke(o),o)})}_writeLinearAnnotations(t,e){var i;const s=this._components.get(ze).systems.get(pp);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=ke(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=kr(n,o);if(!this._fullyInViewport(this._bboxFromPositions(c)))continue;if(this._writePairsAsLines(t,c,l,a,o.color),o.meshTick)for(const{tip:b,dir:T}of Sl(n))this._writeMeshTriangles(t,o.meshTick(b,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(ze).systems.get(vp);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=ke(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=Ol(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 Ml(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(wp(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(ze).systems.get(Ep);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=ke(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){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(ze).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=ke(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=Bl(n,o);if(!this._fullyInViewport(this._bboxFromPositions(c)))continue;if(this._writePairsAsLines(t,c,l,a,o.color),o.meshTick){const f=Rl(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,Ap(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(ze).systems.get(zp);if(s)for(const[,n]of e.annotations.getBySystem(s)){const o=s.styles.get(n.style)??s.styles.get("default"),a=ke(o.color),l=this._annotationLayers.get(n.uuid)??"0";if(!1===(null==(i=e.layers.get(l))?void 0:i.visible))continue;const c=Vl(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(ze).systems.get(Nl);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=ke(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(ze).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:ke,textAngle:(e,i)=>this._textAngle(e,i)}}}y(class Xc extends Et{constructor(t){super(t),y(this,"enabled",!0),y(this,"exporter",new Lp(this.components)),t.add(Xc.uuid,this)}},"uuid","e9a2c3d4-5f67-4b89-a012-1c3d5e7f9b2a");let Hl=(()=>{class r extends Et{static uuid="ab45d0a7-feea-4afc-927c-80832dae76dd";enabled=!0;_fragments=null;set fragments(e){this._fragments=e}geometries=new ft.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 ft.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 ft.jp,l.set(c,_));let m=f.get(d);if(m&&m.length>0){const b=[];for(const[,{geometry:T}]of m.entries()){const C=yield s.createMesh(u,T,{material:n,applyTransformation:a,coordinate:o});b.push(C)}_.set(d,b);continue}m=[],f.set(d,m);const[w]=yield u.getItemsGeometry([d]);if(!w)continue;const g=[];for(const b of w){const T=s.createGeometry(b);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 ft.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(dt),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})(),Nr=(()=>{class r extends Et{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})(),ql=(()=>{class r extends Et{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:ft.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 Gl=(r,t)=>{const e={...r};return Object.keys(t).forEach(i=>{e[i]=new Set([...e[i]||[],...t[i]])}),e},Yl=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 Zl(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(Nr).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(ql).colorOverrides,o.idMap)?(Zl(e,s=Gl(s,o.idMap),!1),Yl(t,e,i,s)):o});return function(e,i,s){return r.apply(this,arguments)}}();function Zl(r,t,e){for(const i of Object.keys(t))r.models.list.get(i)?.setVisible([...t[i]],e)}class Fp{hoveredElement=new Q}let Br=(()=>{class r extends Et{static uuid="26fbd870-b1b2-4b71-b747-4063d484de1b";HOVERER_OPACITY_KEY="_maxHoverOpacity";_hoverTimeout=null;_meshes=new ft.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 Fp;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 Yl(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(Nr).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(Hl);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 Vp=wt(9595);const Up=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 Rr=wt(7850);class $p{clickedElement=new Q;clickedCanvas=new Q;selection=new Q}let Wl=(()=>{class r extends Et{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(Rr.TF);i.fillOpacity=e.fillOpacity,i.fillColor=e.fillColor,i.color=e.outlineColor}onDisposed=new Q;events=new $p;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(Br).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)}}()),Vp.B.getInstance().events.addListener("shortPressedLeft",(0,G.A)(function*(){if(!e.enabled)return;const n=e.components.get(Rr.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 Up(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):Gl(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})(),jp=(()=>{class r extends Et{_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 ft.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(Hl).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*(){Nt.add(i._map,e),yield i.update(e)})()}removeItems(e){var i=this;return(0,G.A)(function*(){Nt.remove(i._map,e),yield i.update()})()}clean(){this._map={},this._activeStyles.clear(),this.cleanMeshes(),this._mesh&&this.components.get(yi).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(dt).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 Gp=wt(893);function Yp(r){return Fr.apply(this,arguments)}function Fr(){return(Fr=(0,G.A)(function*(r){console.warn("Set double sided is not implemented"),console.log(r)})).apply(this,arguments)}function Vr(){return(Vr=(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 Wp=(r,t,e="./js/worker.mjs")=>{const i=new ft._i(e),s=r.get(ql);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),Jl(a)&&(o.object.visible=!1,yield Kp(1),yield s.applyModelOverrides(o,a),o.object.visible=!0),yield i.update(!0),o.object.visible=!0,Jl(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},Xp=function(){var r=(0,G.A)(function*(t,e,i){void 0===i&&(i=Ql(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 Xl(t,n)),o.length&&(console.info(`Disposing ${n.length} model(s)`),yield Kl(t,o)),[...t.models.list.values()]});return function(e,i,s){return r.apply(this,arguments)}}(),Xl=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 Yp(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)}}(),Kl=function(){var r=(0,G.A)(function*(t,e){void 0===e&&(e=Ql(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)}}(),Ql=r=>[...r.models?.list.values()].map(i=>i.modelId),Jl=r=>!(!r.isolated.length&&!r.isolatedTypes.length),Kp=function(){var r=(0,G.A)(function*(t){return new Promise(e=>setTimeout(()=>e(),t))});return function(e){return r.apply(this,arguments)}}(),Qp={"#e2f552":"accent","#2859e1":"primary","#1744c2":"secondary","#ffffff":"default","#8394b0":"fade"},Jp={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")},tm={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")},em={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")},sm=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 nm(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 tc(r,t,e){return Ur.apply(this,arguments)}function Ur(){return(Ur=(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:nm(o)};yield tc(r,[a],c),n.push(c)}e.children.push(...n)}})).apply(this,arguments)}function $r(){return($r=(0,G.A)(function*(r,t){const e=yield r.getItemsOfCategories([/IFCSITE/]),i={label:t,children:[]};yield tc(r,e.IFCSITE,i),console.log(i)})).apply(this,arguments)}let jr=(()=>{class r{_workerUrl=(0,ot.WQX)(Gp.g);_resolvedWorkerUrl=(0,ot.vPA)(void 0);_container=(0,ot.vPA)(void 0);modelsAreLoading=(0,ot.vPA)(!1);settings=(0,ot.vPA)(new mn.R_);_previousHighlights=null;raycastResult=(0,ot.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,ot.vPA)(null);selectedElements=(0,ot.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=Qp[e];return{hoverColor:Jp[i]??new p.Q1f("#e2f552"),selectionColor:tm[i]??new p.Q1f("#1744c2"),selectionOutlineColor:em[i]??new p.Q1f("#e2f552"),ghostColor:sm(e)}})(e)});_loadedModels=(0,ot.vPA)([]);_components=(0,Ot.EW)(()=>{if(void 0!==this._container())return console.info("Building components..."),new Cr});_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(en).create();i.scene=new rl(r),i.scene.setup(),i.scene.three.background=null,i.renderer=new Rr.Hs(r,t);const{postproduction:s}=i.renderer;return i.camera=new sn(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..."),Wp(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 Zp(r){return Vr.apply(this,arguments)})(this._workerUrl).then(e=>this._resolvedWorkerUrl.set(e)),(0,ot.QZP)(()=>{this.viewerReady()&&(console.info("Initializing event listeners..."),this._initEventListeners(),console.info("BIM Fragments Viewer is ready"))}),(0,ot.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(Br);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(jp);a.world=e,a.fragments=i,a.enabled=!0;const l=t.get(Wl);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(Nr);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 Xl(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 Kl(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 Xp(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 rm(r,t){$r.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(Wl);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(Br).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=ot.jDH({token:r,factory:r.\u0275fac,providedIn:"root"})}return r})();var om=wt(7023),am=wt(5970),Li=wt(5381),Hr=wt(5187),on=wt(5971),qr=wt(3319),v=wt(5547);function lm(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-flexcontainer",3)(1,"cue-button",5),v.bIt("click",function(){ot.eBV(e);const s=v.XpG();return ot.Njj(s.zoomOut())}),v.nrm(2,"cue-button-icon",6),v.k0s(),v.j41(3,"cue-button",5),v.bIt("click",function(){ot.eBV(e);const s=v.XpG();return ot.Njj(s.zoomIn())}),v.nrm(4,"cue-button-icon",7),v.k0s(),v.j41(5,"cue-button",5),v.bIt("click",function(){ot.eBV(e);const s=v.XpG();return ot.Njj(s.zoomFit())}),v.nrm(6,"cue-button-icon",8),v.k0s()()}}function cm(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-button",5),v.bIt("click",function(){ot.eBV(e);const s=v.XpG();return ot.Njj(s.toggleLayersVisible())}),v.nrm(1,"cue-button-icon",9),v.k0s()}if(2&r){const e=v.XpG();v.AVh("border-left",e.options().displayZoom&&e.displayDecompositionTree())}}let hm=(()=>{class r{settings=(0,At.hFB)(new mn.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=v.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&&(v.j41(0,"cue-flexcontainer",0)(1,"cue-card",1)(2,"cue-flexcontainer",2),v.nVh(3,lm,7,0,"cue-flexcontainer",3),v.nVh(4,cm,2,2,"cue-button",4),v.k0s()()()),2&i&&(v.R7$(),v.Y8G("padded",!1),v.R7$(2),v.vxM(s.options().displayZoom?3:-1),v.R7$(),v.vxM(s.displayDecompositionTree()?4:-1))},dependencies:[Li.n,Hr.Z,on.$,qr.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 um=wt(9421),dm=wt(1024),an=wt(2245);function fm(r,t){if(1&r&&v.nrm(0,"cue-key-val",3),2&r){const e=v.XpG();v.Y8G("val",e.name)}}function pm(r,t){if(1&r&&v.nrm(0,"cue-key-val",5),2&r){const e=t.$implicit;v.Y8G("key",e.label)("val",e.value)}}function mm(r,t){if(1&r&&(v.j41(0,"cue-typography",4),v.EFF(1),v.k0s(),v.j41(2,"cue-key-val-list"),v.Z7z(3,pm,1,2,"cue-key-val",5,v.Vm6),v.k0s()),2&r){const e=t.$implicit;v.R7$(),v.JRh(e.psetName),v.R7$(2),v.Dyx(e.props)}}function gm(r,t){if(1&r&&v.Z7z(0,mm,5,1,null,null,v.Vm6),2&r){const e=v.XpG();v.Dyx(e.psets)}}function _m(r,t){if(1&r&&(v.nVh(0,fm,1,1,"cue-key-val",3),v.nVh(1,gm,2,0)),2&r){const e=t;v.vxM(e.name?0:-1),v.R7$(),v.vxM(e.psets.length>0?1:-1)}}function ym(r,t){if(1&r&&(v.j41(0,"cue-card",1)(1,"cue-flexcontainer",2),v.nVh(2,_m,2,2),v.k0s()()),2&r){let e;const i=v.XpG();v.Y8G("padded",!1)("scrollable",!0),v.R7$(2),v.vxM((e=i.props())?2:-1,e)}}function wm(r,t){if(1&r&&v.nrm(0,"cue-key-val",3),2&r){const e=v.XpG();v.Y8G("val",e.name)}}function bm(r,t){if(1&r&&v.nrm(0,"cue-key-val",5),2&r){const e=t.$implicit;v.Y8G("key",e.label)("val",e.value)}}function vm(r,t){if(1&r&&(v.j41(0,"cue-typography",4),v.EFF(1),v.k0s(),v.j41(2,"cue-key-val-list"),v.Z7z(3,bm,1,2,"cue-key-val",5,v.Vm6),v.k0s()),2&r){const e=t.$implicit;v.R7$(),v.JRh(e.psetName),v.R7$(2),v.Dyx(e.props)}}function xm(r,t){if(1&r&&v.Z7z(0,vm,5,1,null,null,v.Vm6),2&r){const e=v.XpG();v.Dyx(e.psets)}}function Cm(r,t){if(1&r&&(v.nVh(0,wm,1,1,"cue-key-val",3),v.nVh(1,xm,2,0)),2&r){const e=t;v.vxM(e.name?0:-1),v.R7$(),v.vxM(e.psets.length>0?1:-1)}}function Tm(r,t){if(1&r&&(v.j41(0,"cue-flexcontainer",2),v.nVh(1,Cm,2,2),v.k0s()),2&r){let e;const i=v.XpG();v.R7$(),v.vxM((e=i.props())?1:-1,e)}}let Pm=(()=>{class r{element=At.hFB.required();wrapInCard=(0,At.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=v.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&&(v.j41(0,"cue-flexcontainer",0),v.nVh(1,ym,3,3,"cue-card",1)(2,Tm,2,1,"cue-flexcontainer",2),v.k0s()),2&i&&(v.R7$(),v.vxM(s.wrapInCard()?1:2))},dependencies:[Li.n,Hr.Z,um.F,dm.p,an.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 ec=wt(9769);let Sm=(()=>{class r{selectedItem=(0,ot.vPA)(void 0);static \u0275fac=function(i){return new(i||r)};static \u0275prov=ot.jDH({token:r,factory:r.\u0275fac,providedIn:"root"})}return r})();var ic=wt(7089),Em=wt(5448),sc=wt(6117),Gr=wt(356),Yr=wt(6279);const nc=(r,t)=>t.path;function Am(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-menu-item",7),v.bIt("click",function(s){const n=ot.eBV(e).$implicit,o=v.XpG(2);return ot.Njj(o.navigateTo(s,n.path))}),v.EFF(1),v.k0s()}if(2&r){const e=t.$implicit;v.R7$(),v.SpI(" ",e.name," ")}}function Mm(r,t){if(1&r&&(v.j41(0,"cue-flexcontainer",2)(1,"cue-menu")(2,"cue-button",4,0)(4,"cue-button-label"),v.EFF(5,"..."),v.k0s()(),v.j41(6,"cue-menu-wrap",5),v.Z7z(7,Am,2,1,"cue-menu-item",null,nc),v.k0s()(),v.j41(9,"cue-typography",6),v.EFF(10," \u203a "),v.k0s()()),2&r){const e=v.XpG();v.R7$(2),v.Y8G("size",e.buttonSize())("cueTooltip",e.hiddenPartsTooltip()),v.R7$(5),v.Dyx(e.hidddenParts()),v.R7$(2),v.Y8G("size",e.size())}}function Im(r,t){if(1&r&&(v.j41(0,"cue-typography",6),v.EFF(1," \u203a "),v.k0s()),2&r){const e=v.XpG(2);v.Y8G("size",e.size())}}function Om(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-flexcontainer",8),v.bIt("click",function(s){const n=ot.eBV(e),o=n.$implicit,a=n.$index,l=n.$count,c=v.XpG();return ot.Njj(a!==l-1&&!c.buttonMode()&&c.navigateTo(s,o.path))}),v.j41(1,"cue-typography",9),v.EFF(2),v.k0s(),v.nVh(3,Im,2,1,"cue-typography",6),v.k0s()}if(2&r){const e=t.$implicit,i=t.$index,s=t.$count,n=v.XpG();v.AVh("clickable",i!==s-1&&n.updatePathOnClick()&&!n.buttonMode()),v.R7$(),v.AVh("full-length",n.nameFullLength()),v.Y8G("size",n.size())("weight",i===s-1?"medium":"regular")("title",e.name),v.R7$(),v.SpI(" ",e.name," "),v.R7$(),v.vxM(i!==s-1?3:-1)}}let zm=(()=>{class r{path=At.geq.required();size=(0,At.hFB)("xs");rootName=(0,At.hFB)(null);maxVisibleParts=(0,At.hFB)(3);nameFullLength=(0,At.hFB)(!1);updatePathOnClick=(0,At.hFB)(!0);buttonMode=(0,At.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,At.CGW)();clickedPath=(0,At.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=v.VBU({type:r,selectors:[["cue-breadcrumb"]],hostVars:3,hostBindings:function(i,s){1&i&&v.bIt("click",function(o){return s.onHostClick(o)}),2&i&&(v.BMQ("size",s.sizeAttribute),v.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&&(v.j41(0,"cue-flexcontainer",1),v.nVh(1,Mm,11,3,"cue-flexcontainer",2),v.Z7z(2,Om,4,9,"cue-flexcontainer",3,nc),v.k0s()),2&i&&(v.R7$(),v.vxM(s.shouldShowEllipsis()?1:-1),v.R7$(),v.Dyx(s.visibleBreadcrumbParts()))},dependencies:[ec.MD,an.Typography,Li.n,on.$,Em.L,ic.d,sc.W,Gr.M,Yr.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=wt(29);const Dm=()=>[],Lm=()=>({}),Nm=(r,t)=>t.label;function Bm(r,t){if(1&r&&v.nrm(0,"cue-svg-icon",17),2&r){const e=v.XpG().$implicit;v.Y8G("name",e.icon)}}function Rm(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-menu-item",16),v.bIt("click",function(){const s=ot.eBV(e).$implicit;return ot.Njj(s.action())}),v.nVh(1,Bm,1,1,"cue-svg-icon",17),v.EFF(2),v.k0s()}if(2&r){const e=t.$implicit;v.Y8G("tooltip",e.tooltip??""),v.R7$(),v.vxM(e.icon?1:-1),v.R7$(),v.SpI(" ",e.label," ")}}function Fm(r,t){if(1&r&&(v.j41(0,"cue-menu",11),v.bIt("click",function(i){return i.stopPropagation()}),v.j41(1,"cue-button",12),v.nrm(2,"cue-button-icon",13),v.k0s(),v.j41(3,"cue-menu-wrap",14),v.Z7z(4,Rm,3,3,"cue-menu-item",15,Nm),v.k0s()()),2&r){const e=v.XpG().$implicit;v.R7$(),v.Y8G("cueTooltip",e.tooltip??""),v.R7$(),v.Y8G("icon",e.icon),v.R7$(2),v.Dyx(e.menuItems)}}function Vm(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-button",18),v.bIt("click",function(s){return ot.eBV(e),v.XpG().$implicit.action(),ot.Njj(s.stopPropagation())}),v.nrm(1,"cue-button-icon",13),v.k0s()}if(2&r){const e=v.XpG().$implicit;v.Y8G("cueTooltip",e.tooltip??""),v.R7$(),v.Y8G("icon",e.icon)}}function Um(r,t){if(1&r&&v.nVh(0,Fm,6,2,"cue-menu")(1,Vm,2,2,"cue-button",10),2&r){const e=t.$implicit;v.vxM(null!=e.menuItems&&e.menuItems.length?0:e.action?1:-1)}}function $m(r,t){if(1&r&&(v.j41(0,"cue-flexcontainer",3),v.Z7z(1,Um,2,1,null,null,v.Vm6),v.k0s()),2&r){const e=v.XpG().$implicit;v.R7$(),v.Dyx(e.buttons)}}function jm(r,t){if(1&r&&(v.j41(0,"span",22),v.EFF(1),v.k0s()),2&r){const e=v.XpG(2).$implicit,i=v.XpG();v.AVh("checked",i.isSelected(e)),v.R7$(),v.SpI(" ",i.isSelected(e)?"\u2611":"\u2610"," ")}}function Hm(r,t){if(1&r&&(v.j41(0,"cue-typography",21),v.EFF(1),v.k0s()),2&r){const e=v.XpG(2).$implicit;v.R7$(),v.JRh(e.subLabel)}}function qm(r,t){if(1&r&&(v.j41(0,"div",4),v.nVh(1,jm,2,3,"span",19),v.j41(2,"cue-typography",20),v.EFF(3),v.k0s(),v.nVh(4,Hm,2,1,"cue-typography",21),v.k0s()),2&r){const e=v.XpG().$implicit,i=v.XpG();v.R7$(),v.vxM(i.multiSelect()&&!i.hasChildren(e)?1:-1),v.R7$(),v.Y8G("weight",i.isSelected(e)?"semibold":"regular")("size",i.size()),v.R7$(),v.JRh(e.label),v.R7$(),v.vxM(e.subLabel?4:-1)}}function Gm(r,t){if(1&r&&v.nrm(0,"cue-breadcrumb",6),2&r){const e=v.XpG().$implicit,i=v.XpG();v.Y8G("maxVisibleParts",5)("path",e.label)("size",i.size())("nameFullLength",!0)("updatePathOnClick",!1)}}function Ym(r,t){if(1&r&&v.nrm(0,"cue-svg-icon",23),2&r){const e=v.XpG().$implicit,i=v.XpG();v.AVh("expanded",i.isExpanded(e))}}function Zm(r,t){if(1&r&&(v.j41(0,"div",8),v.nrm(1,"cue-tree-menu",24),v.k0s()),2&r){const e=v.XpG().$implicit,i=v.XpG();v.R7$(),v.Y8G("items",e.children||v.lJ4(2,Dm))("size",i.size())}}function Wm(r,t){if(1&r&&(v.j41(0,"div",25),v.bIt("click",function(i){return i.stopPropagation()}),v.eu8(1,26),v.k0s()),2&r){const e=v.XpG().$implicit;v.R7$(),v.Y8G("ngTemplateOutlet",e.contentTemplate)("ngTemplateOutletContext",e.templateContext??v.lJ4(2,Lm))}}function Xm(r,t){if(1&r){const e=v.RV6();v.j41(0,"li",1)(1,"cue-flexcontainer",2),v.bIt("click",function(){const s=ot.eBV(e).$implicit,n=v.XpG();return ot.Njj(n.handleItemClick(s))}),v.nVh(2,$m,3,0,"cue-flexcontainer",3),v.nVh(3,qm,5,5,"div",4),v.nrm(4,"span",5),v.nVh(5,Gm,1,5,"cue-breadcrumb",6),v.nVh(6,Ym,1,2,"cue-svg-icon",7),v.k0s(),v.nVh(7,Zm,2,3,"div",8),v.nVh(8,Wm,2,3,"div",9),v.k0s()}if(2&r){const e=t.$implicit,i=v.XpG();v.R7$(),v.AVh("has-children",i.hasChildren(e)),v.R7$(),v.vxM(null!=e.buttons&&e.buttons.length?2:-1),v.R7$(),v.vxM(void 0===e.type||"text"===e.type?3:-1),v.R7$(2),v.vxM("breadcrumb"===e.type?5:-1),v.R7$(),v.vxM(i.hasChildren(e)?6:-1),v.R7$(),v.vxM(i.hasChildren(e)&&i.isExpanded(e)?7:-1),v.R7$(),v.vxM(e.contentTemplate?8:-1)}}let Km=(()=>{class r{_service=(0,ot.WQX)(Sm);items=(0,At.geq)([]);size=(0,At.hFB)("m");collapseOnSelect=(0,At.hFB)(!1);initialExpandDepth=(0,At.hFB)(-1);multiSelect=(0,At.hFB)(!1);expandedItems=new Set;_multiSelectedIds=(0,ot.vPA)(new Set);selectionChanged=(0,At.CGW)();multiSelectionChanged=(0,At.CGW)();onItemsChange=(0,ot.QZP)(()=>{this.multiSelect()?(this._syncMultiSelectedFromItems(),this._doInitialExpand()):this.collapseOnSelect()||this._initialExpandSelected()});onSelectionChange=(0,ot.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=v.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&&(v.j41(0,"ul",0),v.Z7z(1,Xm,9,8,"li",1,v.Vm6),v.k0s()),2&i&&(v.R7$(),v.Dyx(s.items()))},dependencies:[r,an.Typography,Li.n,zm,on.$,qr.a,km.A,ic.d,ec.T3,sc.W,Yr.D,Gr.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})(),Qm=(()=>{class r{_service=(0,ot.WQX)(jr);type=(0,At.hFB)("spatial");models=At.geq.required();treeItems=(0,ot.vPA)([]);constructor(){var e=this;(0,ot.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=v.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&&v.nrm(0,"cue-tree-menu",0),2&i&&v.Y8G("items",s.treeItems())},dependencies:[Km],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 Jm=wt(6034),tg=wt(4613);const rc=(r,t)=>t.id;function eg(r,t){1&r&&v.nrm(0,"cue-logo",4),2&r&&v.Y8G("active",!0)("continuous",!0)}function ig(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-typography",6),v.EFF(1),v.k0s(),v.j41(2,"cue-button",7),v.bIt("click",function(){const s=ot.eBV(e).$implicit,n=v.XpG(3);return ot.Njj(n.toggleVisibility(s))}),v.nrm(3,"cue-button-icon",8),v.k0s()}if(2&r){const e=t.$implicit;v.R7$(),v.JRh(e.name),v.R7$(2),v.Y8G("icon",e.visible?"view-inactive":"view-active")}}function sg(r,t){if(1&r&&(v.j41(0,"cue-flexcontainer",5),v.Z7z(1,ig,4,2,null,null,rc),v.k0s()),2&r){const e=v.XpG(2);v.R7$(),v.Dyx(e.models())}}function ng(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-typography",3),v.EFF(1),v.k0s(),v.j41(2,"cue-bim-fragments-tree-viewer",9),v.mxI("modelsChange",function(s){ot.eBV(e);const n=v.XpG(2);return v.DH7(n.models,s)||(n.models=s),ot.Njj(s)}),v.k0s()}if(2&r){const e=v.XpG(2);v.R7$(),v.JRh(e.treeLabel()),v.R7$(),v.R50("models",e.models)}}function rg(r,t){if(1&r&&(v.j41(0,"cue-draggable-card",0)(1,"cue-flexcontainer",1)(2,"cue-flexcontainer",2)(3,"cue-typography",3),v.EFF(4,"Models"),v.k0s(),v.nVh(5,eg,1,2,"cue-logo",4)(6,sg,3,0,"cue-flexcontainer",5),v.k0s(),v.nVh(7,ng,3,2),v.k0s()()),2&r){const e=v.XpG();v.Y8G("padded",!1),v.R7$(5),v.vxM(e.modelsAreLoading()?5:6),v.R7$(2),v.vxM(e.displayDecompositionTree()?7:-1)}}function og(r,t){1&r&&v.nrm(0,"cue-logo",4),2&r&&v.Y8G("active",!0)("continuous",!0)}function ag(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-typography",6),v.EFF(1),v.k0s(),v.j41(2,"cue-button",7),v.bIt("click",function(){const s=ot.eBV(e).$implicit,n=v.XpG(3);return ot.Njj(n.toggleVisibility(s))}),v.nrm(3,"cue-button-icon",8),v.k0s()}if(2&r){const e=t.$implicit;v.R7$(),v.JRh(e.name),v.R7$(2),v.Y8G("icon",e.visible?"view-inactive":"view-active")}}function lg(r,t){if(1&r&&(v.j41(0,"cue-flexcontainer",5),v.Z7z(1,ag,4,2,null,null,rc),v.k0s()),2&r){const e=v.XpG(2);v.R7$(),v.Dyx(e.models())}}function cg(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-typography",3),v.EFF(1),v.k0s(),v.j41(2,"cue-bim-fragments-tree-viewer",9),v.mxI("modelsChange",function(s){ot.eBV(e);const n=v.XpG(2);return v.DH7(n.models,s)||(n.models=s),ot.Njj(s)}),v.k0s()}if(2&r){const e=v.XpG(2);v.R7$(),v.JRh(e.treeLabel()),v.R7$(),v.R50("models",e.models)}}function hg(r,t){if(1&r&&(v.j41(0,"cue-flexcontainer",1)(1,"cue-flexcontainer",2)(2,"cue-typography",3),v.EFF(3,"Models"),v.k0s(),v.nVh(4,og,1,2,"cue-logo",4)(5,lg,3,0,"cue-flexcontainer",5),v.k0s(),v.nVh(6,cg,3,2),v.k0s()),2&r){const e=v.XpG();v.R7$(4),v.vxM(e.modelsAreLoading()?4:5),v.R7$(2),v.vxM(e.displayDecompositionTree()?6:-1)}}let ug=(()=>{class r{_service=(0,ot.WQX)(jr);models=At.geq.required();draggable=(0,At.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=v.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&&v.nVh(0,rg,8,3,"cue-draggable-card",0)(1,hg,7,2,"cue-flexcontainer",1),2&i&&v.vxM(s.draggable()?0:1)},dependencies:[Jm.y,an.Typography,Li.n,on.$,qr.a,Qm,tg.Logo],styles:[".draggable[_ngcontent-%COMP%]{z-index:101}"],changeDetection:0})}return r})();var dg=wt(7851);const fg=["bimViewer"],oc=()=>({position:"bottomleft"}),pg=(r,t)=>t.label;function mg(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-menu-item",4),v.bIt("click",function(){const s=ot.eBV(e).$implicit;return ot.Njj(s.action())}),v.EFF(1),v.k0s()}if(2&r){const e=t.$implicit;v.R7$(),v.JRh(e.label)}}function gg(r,t){if(1&r&&(v.j41(0,"cue-menu-wrap"),v.Z7z(1,mg,2,1,"cue-menu-item",null,pg),v.k0s()),2&r){const e=v.XpG();v.R7$(),v.Dyx(e.contextMenuItems())}}function _g(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-bim-fragments-visibility-menu",13),v.mxI("modelsChange",function(s){ot.eBV(e);const n=v.XpG(2);return v.DH7(n.models,s)||(n.models=s),ot.Njj(s)}),v.k0s()}if(2&r){const e=v.XpG(2);v.R50("models",e.models),v.Y8G("draggable",!1)}}function yg(r,t){if(1&r&&v.nrm(0,"cue-bim-fragments-toolbar",15),2&r){const e=v.XpG(3),i=v.r8f(3);v.Aen(e.toolbarStyle()),v.Y8G("settings",i)}}function wg(r,t){1&r&&v.nVh(0,yg,1,3,"cue-bim-fragments-toolbar",14),2&r&&v.vxM(t.hidden?-1:0)}function bg(r,t){if(1&r&&(v.j41(0,"cue-card",16),v.nrm(1,"cue-bim-fragments-props-viewer",17),v.k0s()),2&r){const e=v.XpG(2);v.AVh("hidden",null===e.$clickedElement()),v.R7$(),v.Y8G("element",t)("wrapInCard",!1)}}function vg(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-card",5),v.nVh(1,_g,1,2,"cue-bim-fragments-visibility-menu",6),v.k0s(),v.j41(2,"div",7)(3,"cue-card",8)(4,"div",9,1),v.bIt("resized",function(){ot.eBV(e);const s=v.XpG();return ot.Njj(s.onResized())})("windowResized",function(){ot.eBV(e);const s=v.XpG();return ot.Njj(s.onResized())}),v.k0s(),v.nVh(6,wg,1,1),v.k0s(),v.j41(7,"a",10),v.EFF(8,"Powered by "),v.j41(9,"span",11),v.EFF(10,"ThatOpen"),v.k0s()()(),v.nVh(11,bg,2,4,"cue-card",12)}if(2&r){let e,i;const s=v.XpG(),n=v.sdS(1),o=v.r8f(3);v.R7$(),v.vxM(o.showModelList&&s.models().length?1:-1),v.R7$(3),v.Y8G("cueLogoLoader",s.isLoading())("cueContextMenu",n)("contextMenuData",v.lJ4(7,oc))("cueContextEnabled",null!==s.$hoveredElement()),v.R7$(2),v.vxM((e=o.toolbar)?6:-1,e),v.R7$(5),v.vxM((i=s.$clickedElement())?11:-1,i)}}function xg(r,t){if(1&r&&v.nrm(0,"cue-bim-fragments-toolbar",15),2&r){const e=v.XpG(3),i=v.r8f(3);v.Aen(e.toolbarStyle()),v.Y8G("settings",i)}}function Cg(r,t){1&r&&v.nVh(0,xg,1,3,"cue-bim-fragments-toolbar",14),2&r&&v.vxM(t.hidden?-1:0)}function Tg(r,t){1&r&&(v.j41(0,"div",19),v.nrm(1,"cue-bim-fragments-props-viewer",21),v.k0s()),2&r&&(v.R7$(),v.Y8G("element",t))}function Pg(r,t){if(1&r){const e=v.RV6();v.j41(0,"cue-bim-fragments-visibility-menu",22),v.mxI("modelsChange",function(s){ot.eBV(e);const n=v.XpG(2);return v.DH7(n.models,s)||(n.models=s),ot.Njj(s)}),v.k0s()}if(2&r){const e=v.XpG(2);v.R50("models",e.models)}}function Sg(r,t){if(1&r){const e=v.RV6();v.j41(0,"div",18,1),v.bIt("resized",function(){ot.eBV(e);const s=v.XpG();return ot.Njj(s.onResized())}),v.nVh(2,Cg,1,1),v.nVh(3,Tg,2,1,"div",19),v.nVh(4,Pg,1,1,"cue-bim-fragments-visibility-menu",20),v.j41(5,"a",10),v.EFF(6,"Powered by "),v.j41(7,"span",11),v.EFF(8,"ThatOpen"),v.k0s()()()}if(2&r){let e,i;const s=v.XpG(),n=v.sdS(1),o=v.r8f(3);v.Y8G("cueLogoLoader",s.isLoading())("cueContextMenu",n)("contextMenuData",v.lJ4(7,oc))("cueContextEnabled",null!==s.$hoveredElement()),v.R7$(2),v.vxM((e=o.toolbar)?2:-1,e),v.R7$(),v.vxM((i=s.$clickedElement())?3:-1,i),v.R7$(),v.vxM(o.showModelList&&s.models().length?4:-1)}}let Eg=(()=>{class r{_service=(0,ot.WQX)(jr);data=(0,At.hFB)(void 0);settings=(0,At.hFB)(new mn.R_);clickedElement=(0,At.CGW)();hoveredElement=(0,At.CGW)();selectedElements=(0,At.CGW)();$hoveredElement=(0,ot.vPA)(null);$clickedElement=(0,ot.vPA)(null);_cachedClickedElement=(0,ot.vPA)(null);_modelLoading=(0,ot.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,ot.QZP)(()=>{const e=this._service.clickedElement();e&&this._cachedClickedElement.set(e),e||this.$clickedElement.set(null),this.clickedElement.emit(e)});onHoverElement=(0,ot.QZP)(()=>{this.$hoveredElement.set(this._service.hoveredElement()),this.hoveredElement.emit(this._service.hoveredElement())});onSelectionChange=(0,ot.QZP)(()=>{this.selectedElements.emit(this._service.selectedElements())});set bimViewer(e){e&&this._service.init(e.nativeElement)}loadFilesOnData=(0,ot.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,ot.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=v.VBU({type:r,selectors:[["cue-bim-fragments-viewer"]],viewQuery:function(i,s){if(1&i&&v.GBs(fg,5),2&i){let n;v.mGM(n=v.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&&(v.DNE(0,gg,3,0,"ng-template",null,0,v.C5r),v.j41(2,"cue-flexcontainer",2),v.SS7(3),v.nVh(4,vg,12,8)(5,Sg,9,8,"div",3),v.k0s()),2&i&&(v.R7$(3),v.bH3(s.settings()),v.R7$(),v.vxM(s.detailedView()?4:5))},dependencies:[am.C,Gr.M,Yr.D,Li.n,Hr.Z,om.Q,hm,Pm,ug,dg.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})()}}]);
|