@aibee/crc-bmap 0.0.88 → 0.0.89

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.
@@ -1,4 +1,4 @@
1
- var oe=Object.defineProperty,ne=Object.defineProperties;var re=Object.getOwnPropertyDescriptors;var Dt=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var E=Math.pow,yt=(a,r,t)=>r in a?oe(a,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[r]=t,b=(a,r)=>{for(var t in r||(r={}))se.call(r,t)&&yt(a,t,r[t]);if(Dt)for(var t of Dt(r))ae.call(r,t)&&yt(a,t,r[t]);return a},I=(a,r)=>ne(a,re(r));var n=(a,r,t)=>(yt(a,typeof r!="symbol"?r+"":r,t),t);var P=(a,r,t)=>new Promise((e,i)=>{var o=h=>{try{c(t.next(h))}catch(l){i(l)}},s=h=>{try{c(t.throw(h))}catch(l){i(l)}},c=h=>h.done?e(h.value):Promise.resolve(h.value).then(o,s);c((t=t.apply(a,r)).next())});import{EventDispatcher as zi}from"three";var z=class{constructor(){n(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(r){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),r()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(r){this.tasks.requestAnimation.delete(r),window.cancelAnimationFrame(r)}setTimeout(r,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),r()},t);return this.tasks.timeout.add(e),e}clearTimeout(r){this.tasks.timeout.delete(r),window.clearTimeout(r)}setInterval(r,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),r()},t);return this.tasks.interval.add(e),e}clearInterval(r){this.tasks.interval.delete(r),window.clearInterval(r)}dispose(){this.tasks.requestAnimation.forEach(r=>{window.cancelAnimationFrame(r)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(r=>{window.clearTimeout(r)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(r=>{window.clearInterval(r)}),this.tasks.interval.clear()}};import{Scene as ce,WebGLRenderer as he,OrthographicCamera as le,Shape as pe,PCFSoftShadowMap as me,Group as de,Color as ue,DirectionalLight as ge,AmbientLight as fe,Path as ve,Vector2 as Ot}from"three";import{MapControls as ye}from"three/examples/jsm/controls/MapControls";function zt(){let a=new ce;return a.background=new ue(16777215),a}function kt(){let a=new he({antialias:!0});return a.autoClear=!0,a.setClearAlpha(1),a.setClearColor(16777215),a.setPixelRatio(window.devicePixelRatio),a.shadowMap.enabled=!0,a.shadowMap.autoUpdate=!0,a.shadowMap.type=me,a}function At(a,r){let t=new le(-a/2,a/2,r/2,-r/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function Tt(){let a=new de,r=new fe(16777215,2.6);return a.add(r),a}function Bt(a,r){let t=new ye(a,r);return t.enableDamping=!1,t.zoomSpeed=2,t}function Ft(a,r=[]){let t=new pe(a.map(e=>new Ot(...e)));return r.length&&r.forEach(e=>{var i=new ve(e.map(o=>new Ot(...o)));t.holes.push(i)}),t}function Rt(a=16777215,r=1){let t=new ge(a,r);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(256,256),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function O(a,r){var t;if(r&&a.children&&a.children.length&&a.children.forEach(e=>{O(e,r)}),a.isMesh){let e=a;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}a.isLight&&((t=a.dispose)==null||t.call(a))}function Ht(a){return/[\u4E00-\u9FA5]+/g.test(a)}import{DataTexture as xe,RGBAFormat as be,LinearFilter as Vt}from"three";var U=new Map;function Ee(){let a=document.createElement("canvas");a.width=1024,a.height=64;let r=a.getContext("2d",{willReadFrequently:!0});return r.font="54px sans-serif",r.textBaseline="hanging",r.lineWidth=12,r.fillStyle="rgba(0,0,0,1)",r.strokeStyle="white",{canvas:a,ctx:r}}var xt,A;function we(){if(!xt){let{canvas:a,ctx:r}=Ee();xt=a,A=r}}function Zi(a){if(U.has(a))return U.get(a);we(),A.clearRect(0,0,1024,64);let r=Ht(a)?4:8;A.strokeText(a,2,r),A.fillText(a,2,r);let t=Math.ceil(A.measureText(a).width);t=t%2===0?t:t+1,t+=2;let e=A.getImageData(0,0,t,64),i=new xe(Uint8Array.from(e.data),t,64,be);return i.flipY=!0,i.minFilter=Vt,i.magFilter=Vt,U.set(a,i),i}function _t(){U.clear()}function $t(){A=null,xt=null}import{Vector3 as bt}from"three";import{point as Pe,featureCollection as Me,center as Ce}from"@turf/turf";function y(a,r,t,e){let i=a.clone().project(r),o=t/2,s=e/2,c=Math.round(i.x*o+o),h=Math.round(-i.y*s+s);return{x:c,y:h}}function Et(a){let r=Me(a.map(e=>Pe(e)));return Ce(r).geometry.coordinates}function K(a,r,t){return a.x>=r.x&&a.x<=t.x&&a.y>=r.y&&a.y<=t.y}function Ni(a){let r=0,t=new bt;for(let e=1;e<a.length;e++){let i=new bt(a[e-1][0],a[e-1][1],0),o=new bt(a[e][0],a[e][1],0),s=o.distanceTo(i);s>r&&(r=s,t=o.clone().sub(i).normalize())}return t}function j(a,r){return new Proxy(a,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,o)=>{let s=Reflect.get(t,e,o),c=Reflect.set(t,e,i,o);return s!==i&&r.dispatchEvent({type:`change-${e}`,value:i}),c}})}function V(a,r){return Promise.race([a,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),r)})])}function Z(a){return document.createElementNS("http://www.w3.org/2000/svg",a)}function It(a,r){let t=Z("svg");return t.setAttribute("width",a),t.setAttribute("height",r),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function _(a="2",r){let t=Z("circle");return t.setAttribute("r",a),t.setAttribute("fill",r),t}function X(a){let r=Z("line");return r.setAttribute("stroke",a),r}function F(a,r){let t=Z("rect");return t.setAttribute("stroke",a),t.setAttribute("fill",r),t}function T(a,r,t){a.setAttribute("cx",`${r}`),a.setAttribute("cy",`${t}`)}function M(a,r,t){r&&(a.setAttribute("x1",`${r.x}`),a.setAttribute("y1",`${r.y}`)),t&&(a.setAttribute("x2",`${t.x}`),a.setAttribute("y2",`${t.y}`))}function C(a,r,t,e,i){a.setAttribute("x",`${r}`),a.setAttribute("y",`${t}`),a.setAttribute("width",`${e}`),a.setAttribute("height",`${i}`)}function Ut(){return Promise.resolve()}function io(){return new Promise(a=>{requestAnimationFrame(a)})}function no(a){return parseInt(a.replace("#","0x"),16)}function ro(a,r){let t=parseInt(a.substring(1,3),16),e=parseInt(a.substring(3,5),16),i=parseInt(a.substring(5,7),16),o=Math.round(t*r),s=Math.round(e*r),c=Math.round(i*r);return`#${(1<<24|o<<16|s<<8|c).toString(16).slice(1)}`}function W(a,r=.85){let t,e,i;if(a.startsWith("#"))t=parseInt(a.substring(1,3),16),e=parseInt(a.substring(3,5),16),i=parseInt(a.substring(5,7),16);else{let s=a.slice(4,-1).split(",");t=parseInt(s[0].trim()),e=parseInt(s[1].trim()),i=parseInt(s[2].trim())}return t=Math.floor(t*r),e=Math.floor(e*r),i=Math.floor(i*r),"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)}import{GLTFLoader as Le}from"three/examples/jsm/loaders/GLTFLoader";function Ge(){return new Le}var Y=null,q=new Map;function Kt(a){if(q.has(a)){let t=q.get(a).then(e=>(e.scene=e.scene.clone(),e))}Y||(Y=Ge());let r=new Promise((t,e)=>{Y.load(a,i=>{t(i)},void 0,e)});return q.set(a,r),r.then(t=>(t.scene=t.scene.clone(),t))}function jt(){Y=null,q.clear()}var N=navigator.userAgent.toUpperCase().indexOf("MAC")>=0;function wt(a){return N?a==="Meta":a==="Control"}import{EventDispatcher as wi,Box2 as Pi,Vector3 as k,Vector2 as H,Raycaster as Mi,Box3 as Ci,Color as Li,AmbientLight as Gi}from"three";import{Group as Si,Tween as ft}from"@tweenjs/tween.js";import{EventDispatcher as ui}from"three";import{Object3D as Se,ExtrudeGeometry as De,Mesh as Oe,Box3 as Pt,Vector3 as B,BufferGeometry as ze,LineSegments as ke}from"three";var Ae={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,strokeWidth:1,doors:[],locked:!1,visible:!0,geometry:{type:"polygon",cds:[],coords:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{},gradualColor:[],renderType:"single"},L=class extends Se{constructor(t,e){super();this.context=t;n(this,"geometry");n(this,"material");n(this,"mesh");n(this,"line");n(this,"lineMaterial");n(this,"lineGeometry");n(this,"options");if(this.options=j(b(b({},Ae),e),this),this.options.geometry.type==="point"){let[i,o]=this.options.geometry.coords;return this.position.set(i,o,this.options.height+this.options.airHeight),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i}),this.addEventListener("change-stroke",({value:i})=>{var o;if(i){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),(o=this.lineGeometry)==null||o.dispose())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()})}getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new B,e=new Pt;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new B(0,0,0);let t=new Pt,e=new B;return t.setFromObject(this),t.getSize(e),e}getPosition(){let t=this.getCenter();return t.setZ(t.z+this.options.height),t}init(){this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initGeometry(){let t=Ft(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new De(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initSingleMaterial(){let t=this.context.materialFactory.createMeshBasicMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});if(this.options.height<=.1)return this.material=t,t;let e=this.context.materialFactory.createMeshBasicMaterial({color:W(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,e],[t,e]}initGradualMaterial(){let{max:t,min:e}=new Pt().setFromObject(this),i=t.clone().sub(e),o=Math.max(i.x,i.y,i.z)/2,s=this.context.materialFactory.createShaderMaterial({gradualColor:this.options.gradualColor,center:this.getPosition(),maxValue:o,opacity:this.options.fillOpacity,direction:new B(-1,.2,0),max:t,min:e});if(this.options.height<=.1)return this.material=s,s;let c=this.context.materialFactory.createShaderMaterial({gradualColor:[W(this.options.gradualColor[0],.95),W(this.options.gradualColor[1],.95)],center:this.getCenter(),maxValue:o,opacity:this.options.fillOpacity,direction:new B(-1,.2,1),max:t,min:e});return this.material=[s,c],[s,c]}initMaterial(){return this.options.renderType==="gradual"?this.initGradualMaterial():this.initSingleMaterial()}initLineMaterial(){let t=this.context.materialFactory.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new Oe(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],e=this.options.height+this.options.deltaHeight,{coords:i}=this.options.geometry;for(let o=0;o<i.length;o++){let s=i[o];for(let c=0;c<s.length;c++){let h=s[c],l=c+1===s.length?s[0]:s[c+1];t.push(new B(h[0],h[1],e)),t.push(new B(l[0],l[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new ze().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new ke(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.line=t,this.add(t),t}raycast(t){if(!this.visible||this.options.geometry.type==="point")return!1;let e=t.intersectObject(this.mesh);if(e[0]){let{point:i,distance:o}=e[0];return{position:i,distance:o}}return!1}dispose(){var t;this.geometry.dispose(),(t=this.line)==null||t.geometry.dispose(),this.clear()}};import{Object3D as Te,PlaneGeometry as Be,Mesh as Fe,ShadowMaterial as Re,Color as He,DoubleSide as Ve}from"three";var Q=class extends Te{constructor(){super();n(this,"directionalLight");n(this,"plane");n(this,"basicOpacity",.07);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=Rt(16777215,.5);return t.position.set(0,0,100),this.add(t),t}changeLightCamera(t){let e=t.x,i=t.y;this.directionalLight.shadow.camera.left=-e,this.directionalLight.shadow.camera.right=e,this.directionalLight.shadow.camera.top=i,this.directionalLight.shadow.camera.bottom=-i,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(e,i)}changeLightColor(t){this.directionalLight.color=new He(t)}setPosition(t){this.position.copy(t),this.directionalLight.position.set(-t.x/2,-t.y/2,100)}initPlane(t=1e3,e=1e3){let i=new Be(t,e),o=new Re({transparent:!0,opacity:0,side:Ve}),s=new Fe(i,o);return s.receiveShadow=!0,s.position.z=-10,this.add(s),this.plane=s,s}setTarget(t){this.directionalLight.target=t}transformOpacity(t){return t*this.basicOpacity}setOpacity(t){this.plane.material.opacity=this.transformOpacity(t)}dispose(){O(this,!0)}};import{EventDispatcher as Ue,Vector3 as Ke}from"three";import{Box3 as _e,EventDispatcher as $e,Vector3 as Zt}from"three";var Ie={autoUpdate:!0,appendToBody:!1},J=class extends $e{constructor(t,e={}){super();this.context=t;n(this,"div");n(this,"element");n(this,"position",new Zt);n(this,"clientPos",{x:0,y:0});n(this,"visible",!0);n(this,"options");n(this,"onUpdate",()=>{this.updatePosition()});this.options=b(b({},Ie),e),this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):this.context.container.appendChild(this.div)}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}bindElement(t){this.element=t,this.onUpdate()}unBindElement(){this.element=void 0}setVisible(t,e="block"){t!==this.visible&&(this.div.style.display=t?e:"none",this.visible=t)}setOpacity(t){this.div.style.opacity=`${t}`}getPosition(){return this.element?typeof this.element.getPosition=="function"?this.element.getPosition():new _e().setFromObject(this.element).getCenter(new Zt):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:o}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=o}updatePosition(t=!1){let e=this.getPosition(),{width:i,height:o,x:s,y:c}=this.context.clientSize,{x:h,y:l}=y(e,this.context.camera,i,o);this.clientPos.x===h&&this.clientPos.y===l&&!t||(this.clientPos={x:h,y:l},this.options.appendToBody&&(this.div.style.left=`${s}px`,this.div.style.top=`${c+o}px`),this.options.autoUpdate?this.div.style.transform=`translate3d(${h}px, ${-o+l}px, 0)`:this.dispatchEvent({type:"update-position",x:h,y:l,width:i,height:o}))}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){var t;this.unRegistryEvent(),this.unBindElement(),(t=this.div)==null||t.remove(),this.div=null}};var je={texts:[{text:""}],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},icon_opacity:1,icon_border:{color:"#586EE0",width:0},background:"",collision_hide_icon:!0,built_in:!1,box_only_icon:!1},$=class extends Ue{constructor(t,e){var i,o,s;super();this.context=t;n(this,"div");n(this,"textDiv");n(this,"img");n(this,"overlay");n(this,"options");n(this,"visible",!0);n(this,"size",{width:0,height:0});n(this,"position",new Ke);n(this,"userData",{});n(this,"showTextStatus",!0);n(this,"_changePosition",()=>{this.overlay.updatePosition(!0)});this.options=j(b(b({},je),e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((o=e.position)==null?void 0:o.y)||0,((s=e.position)==null?void 0:s.z)||0),this.overlay=new J(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:c,y:h,height:l})=>{this.overlay.div.style.transform=`translate3d(calc(${c}px - 50%), calc(${-l+h}px - ${this.options.icon?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:c})=>{c?this.img?this.img.setAttribute("src",c):(this.div.appendChild(this.initIcon()),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:c})=>{this.div.removeChild(this.textDiv),this.div.firstChild?this.div.insertBefore(this.initText(),this.div.firstChild):this.div.appendChild(this.initText()),this.resetSize()}),this.addEventListener("change-opacity",({value:c})=>{this.overlay.setOpacity(c)}),this.addEventListener("change-icon_size",({value:c})=>{this.img&&(this.img.style.width=`${(c==null?void 0:c[0])||32}px`,this.img.style.height=`${(c==null?void 0:c[1])||32}px`,this.resetSize())}),this.addEventListener("change-icon_opacity",({value:c})=>{this.img&&(this.img.style.opacity=`${c}`)}),this.addEventListener("change-icon_border",({value:c})=>{this.img&&(this.img.style.border=`${c.width}px solid ${c.color}`)}),this.addEventListener("change-background",({value:c})=>{this.div.style.background=c})}get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return P(this,null,function*(){if(yield Ut(),this.options.box_only_icon){if(!this.img)return;let{width:t,height:e}=this.img.getBoundingClientRect();this.size={width:t+2,height:e+2}}else{let{width:t,height:e}=this.div.getBoundingClientRect();this.size={width:t+2,height:e+2}}})}renderHelperBox(){}get clientPos(){return this.overlay.clientPos}initDiv(){let t=document.createElement("div");return t.appendChild(this.initText()),this.options.icon&&t.appendChild(this.initIcon()),t.style.fontSize="12px",t.style.textShadow="#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.padding="4px",this.overlay.setOpacity(this.options.opacity),this.overlay.div.style.pointerEvents="none",this.overlay.div.style.userSelect="none",this.overlay.div.appendChild(t),this.div=t,this.resetSize(),t}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.textAlign="center",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.texts.forEach(e=>{let i=document.createElement("div");if(i.style.whiteSpace="nowrap",e.styles)for(let[o,s]of Object.entries(e.styles))i.style[o]=s;i.textContent=e.text,t.appendChild(i)}),t}initIcon(){var e,i;let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${((e=this.options.icon_size)==null?void 0:e[0])||32}px`,t.style.height=`${((i=this.options.icon_size)==null?void 0:i[1])||32}px`,t.style.opacity=`${this.options.icon_opacity}px`,t.style.borderRadius="50%",this.options.icon_border.width&&(t.style.border=`${this.options.icon_border.width}px solid ${this.options.icon_border.color}`),t.onload=()=>{this.resetSize()},this.img=t,t}registryEvent(){}unRegistryEvent(){}setVisible(t){t!==this.visible&&(this.visible=t,this.changeOverlayVisible(t))}changeOverlayVisible(t){if(!(t===this.overlay.visible&&this.options.collision_hide_icon))if(this.options.collision_hide_icon)this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden";else{if(this.showTextStatus===t)return;this.textDiv.style.visibility=t?"visible":"hidden",this.showTextStatus=t}}parentSetVisible(t){this.visible&&this.changeOverlayVisible(t)}getBox(t=this.context.config.poi.boxScale){let{width:e,height:i}=this.size,o=e*t,s=i*t,{x:c,y:h}=this.overlay.clientPos;return{left:c-o/2,right:c+o/2,top:this.options.icon?h-s:h-s/2,bottom:this.options.icon?h:h+s/2}}getOriginBox(){return this.getBox(1)}isContain(t,e){if(!this.overlay.visible||!this.visible)return!1;let i=this.getOriginBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.div=null,this.textDiv=null,this.img=void 0,this.overlay.dispose()}};import{Box3 as nt,Object3D as Mt,Vector3 as rt}from"three";import{Box3 as Xe,Vector3 as We}from"three";import{Object3D as Ze}from"three";var R=class extends Ze{constructor(t){super();this.context=t}dispose(){O(this),this.clear()}};var tt=class extends R{constructor(t){super(t);n(this,"graphicMap",new Map)}getCenter(){return new Xe().setFromObject(this).getCenter(new We)}createGraphic(t){let e=new L(this.context,t);return this.add(e),this.graphicMap.set(t.id,e),e}removeGraphic(t){this.remove(t),this.graphicMap.delete(t.options.id),t.dispose()}removeGraphicById(t){this.graphicMap.has(t)&&this.removeGraphic(this.graphicMap.get(t))}getGraphicByNodeId(t){return this.graphicMap.get(t)||null}getGraphicByRaycaster(t){let e={distance:1e4,graphic:null,position:null},i=this.children.reduce((o,s)=>{if(s instanceof L){let c=s.raycast(t);if(c){let{distance:h}=c;if(h<o.distance)return{distance:o.distance,position:o.position,graphic:s}}return o}else return o},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};import{debounce as Ye}from"lodash";var et=class extends R{constructor(t){super(t);n(this,"pois",[]);n(this,"debounceCollisionDetection");n(this,"timer",new z);n(this,"onUpdate",()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})});this.registryEvent(),this.debounceCollisionDetection=Ye(this.collisionDetection,10)}clear(t=!1){return this.pois.forEach(e=>{e.options.built_in&&!t||e.dispose()}),this.pois=t?[]:this.pois.filter(e=>e.options.built_in),this}createPoi(t){let e=new $(this.context,t);return this.pushPoi(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),e}changePoiLevelOrCollisionEnable(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),this.pushPoi(t))}removePoi(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),t.dispose())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}getPoiById(t){return this.pois.find(i=>i.options.id===t)||null}pushPoi(t){if(!t.options.collision_enable){this.pois.unshift(t);return}if(t.options.level===0){this.pois.push(t);return}for(let e=0;e<this.pois.length;e++){let i=this.pois[e];if(i.options.collision_enable&&i.options.level<=t.options.level){this.pois.splice(e,0,t);return}}this.pois.push(t)}getPoiByDeviceXy(t,e){return this.pois.filter(o=>o instanceof $&&o.isContain(t,e))}collisionDetection(){let t=[];this.pois.filter(i=>i.visible&&i.withinDisplayRange).forEach((i,o)=>{let{left:s,right:c,top:h,bottom:l}=i.getBox();if(o===0||!i.options.collision_enable){t.push({left:s,right:c,top:h,bottom:l}),i.parentSetVisible(!0);return}let p=t.some(d=>d.left<c&&d.right>s&&d.top<l&&d.bottom>h);i.parentSetVisible(!p),p||t.push({left:s,right:c,top:h,bottom:l})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(t=>t.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};import{MeshBasicMaterial as qe,Object3D as Ne,PlaneGeometry as Qe,Texture as Je,DoubleSide as ti,Mesh as ei,Matrix3 as Xt,Vector2 as ii}from"three";import{create as oi}from"@mars3d/heatmap.js";import{featureCollection as ni,point as ri,bbox as si,center as ai}from"@turf/turf";var it=class extends Ne{constructor(t){super();this.context=t;n(this,"heatmap");n(this,"div");n(this,"plane");this.div=document.createElement("div")}clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:e,height:i,leftTop:o,center:s}=this.getBox(t);this.heatmap=oi(b({width:e,height:i,container:this.div},this.context.config.heatMap)),this.heatmap.setData(this.transformData(t,o)),this.initPlane(e,i),this.position.set(s[0],s[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new Qe(t,e),o=new Je(this.div.firstChild);o.needsUpdate=!0;let s=new qe({transparent:!0,side:ti,map:o});s.needsUpdate=!0,this.plane=new ei(i,s),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new Xt().makeScale(1,-1).multiply(new Xt().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(s=>{let c=new ii(s.x,s.y).applyMatrix3(i);return{x:c.x,y:c.y,value:s.value}}),max:t.max,min:t.min}}getBox(t){let e=ni(t.data.map(l=>ri([l.x,l.y]))),i=si(e),o=i[2]-i[0],s=i[3]-i[1],c={x:i[0],y:i[3]},h=ai(e);return{width:o,height:s,leftTop:c,center:h.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};import{Box3 as ci,Object3D as hi,Vector3 as Wt}from"three";var ot=class extends hi{constructor(t,e){super();this.context=t;this.options=e;n(this,"poi",null);n(this,"model",null);this.position.copy(e.position||new Wt(0,0,0)),this.loadModel()}loadModel(){return P(this,null,function*(){let t=yield Kt(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t,this.initPoi()})}initPoi(){var e;if(!this.options.icon)return;let t=(e=this.context.currentFloor)==null?void 0:e.addPoi({icon:this.options.icon,icon_size:this.options.icon_size,built_in:!0,level:0});this.poi=t||null,this.model&&t&&(t.position=new ci().setFromObject(this).getCenter(new Wt))}dispose(){var t;O(this),this.model=null,this.poi&&((t=this.context.currentFloor)==null||t.poiLayer.removePoi(this.poi),this.poi=null)}};var st=class extends Mt{constructor(t){super();this.context=t;n(this,"graphicLayer");n(this,"poiLayer");n(this,"grounds",new Set);n(this,"shadow",new Q);n(this,"heatmap");n(this,"groundUpper",new Mt);n(this,"models",new Mt);n(this,"modelMap",new Map);n(this,"groundMaxHeight",0);this.graphicLayer=new tt(this.context),this.poiLayer=new et(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper),this.add(this.models)}getPosition(){return new nt().setFromObject(this.groundUpper).getCenter(new rt)}createGround(t){let e=new L(this.context,t);this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.mesh.castShadow=!0,this.grounds.add(e),this.groundUpper.add(e))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(e=>e.options.height+e.options.airHeight+e.options.deltaHeight)):0,this.graphicLayer.position.z=this.groundMaxHeight,this.models.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new nt().setFromObject(this.groundUpper).getCenter(new rt)}addModel(t){let e=new ot(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new nt().setFromObject(this.groundUpper),e=t.getCenter(new rt),i=t.getSize(new rt);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new it(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new nt().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(e.max.z),this.heatmap}removeHeatMap(){this.heatmap&&(this.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=void 0)}setShadowOpacity(t){this.shadow.setOpacity(t)}setShadowVisible(t){this.shadow.visible=t}dispose(){var t;this.shadow.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.grounds.forEach(e=>e.dispose()),(t=this.heatmap)==null||t.dispose(),this.groundUpper.clear(),this.models.children.forEach(e=>e.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}};import{EventDispatcher as li,Vector3 as pi}from"three";var S=class extends li{constructor(t){super();this.context=t;n(this,"points",[]);n(this,"svg");n(this,"enable",!0);n(this,"_onResize",({width:t,height:e})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${e}`))});this.svg=It(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}_registryEvent(){this.context.addEventListener("resize",this._onResize)}_unRegistryEvent(){this.context.removeEventListener("resize",this._onResize)}setEnable(t){this.enable=t,t?this.svg.style.display="block":this.svg.style.display="none"}getIntersectByPointerEvent(t){let{camera:e,renderer:i}=this.context,{offsetX:o,offsetY:s}=t,{clientWidth:c,clientHeight:h}=i.domElement,l=o/c*2-1,p=1-s/h*2;return new pi(l,p,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return y(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}};var at=class extends S{constructor(t){super(t);this.context=t;n(this,"circles");n(this,"line");n(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);T(this.circles[0],t.x,t.y),M(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);T(this.circles[1],t.x,t.y),M(this.line,void 0,t)}});n(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",M(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});n(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});n(this,"onPointerdown",t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t,s=this.circles[this.points.length];T(s,i,o),this.points.length||M(this.line,{x:i,y:o},{x:i,y:o}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[_(e.radius,e.fill),_(e.radius,e.fill)],this.line=X(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}addPoint(t){if(this.points.push(t),this.points.length>=2){let e=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:e})}}calculatedDistance(){let[{x:t,y:e},{x:i,y:o}]=this.points;return Math.sqrt(E(i-t,2)+E(o-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var ct=class extends S{constructor(t){super(t);n(this,"circles",[]);n(this,"lines",[]);n(this,"isClose",!1);n(this,"onUpdate",()=>{this.points.length&&this.points.forEach((t,e)=>{let i=this.getSvgCoordinate(t);this.circles[e]&&T(this.circles[e],i.x,i.y),e!==0&&M(this.lines[e-1],void 0,i),this.lines[e]&&M(this.lines[e],i)})});n(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",M(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});n(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});n(this,"onPointerdown",t=>{if(this.isClose)return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t;this.checkAdsorb(i,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(e);let{circle:{fill:s,radius:c},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let l=_(c,s);T(l,i,o),this.addCircle(l)}if(this.lines.length&&M(this.lastLine,void 0,{x:i,y:o}),!this.isClose){let l=X(h);M(l,{x:i,y:o},{x:i,y:o}),this.addLine(l)}}});this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(t){this.circles.push(t),this.svg.appendChild(t)}addLine(t){this.lines.push(t),this.svg.appendChild(t)}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}checkAdsorb(t,e){if(this.points.length<3)return!1;let i=this.circles[0],o=+i.getAttribute("cx"),s=+i.getAttribute("cy");return Math.sqrt(E(t-o,2)+E(e-s,2))<=5}addPoint(t){if(this.points.push(t),this.isClose){let e=this.calculatedArea();this.dispatchEvent({type:"area",area:e})}}calculatedArea(){let t=this.points.map(o=>[o.x,o.y]),e=0,i=t.length;for(let o=0;o<i;o++){let s=(o+1)%i;e+=t[o][0]*t[s][1]-t[s][0]*t[o][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};import{Box3 as mi}from"three";var Yt=class extends S{constructor(t){super(t);this.context=t;n(this,"rect");n(this,"cornerRect",[]);n(this,"centerRect",[]);n(this,"graphic");n(this,"onUpdate",()=>{if(this.graphic){let t=new mi().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:o}}=this.context,{min:s,max:c}=t,h=y(s,e,i,o),l=y(c,e,i,o);C(this.rect,h.x,l.y,Math.abs(l.x-h.x),Math.abs(l.y-h.y));let{x:p,y:d}=h,{x:f,y:g}=l,m=5,x=[{x:p-m,y:g-m},{x:f-m,y:g-m},{x:p-m,y:d-m},{x:f-m,y:d-m}];for(let w=0;w<x.length;w++)C(this.cornerRect[w],x[w].x,x[w].y,m*2,m*2);let v=4,u=(p+f)/2,D=(d+g)/2,G=[{x:u-v,y:g-v},{x:p-v,y:D-v},{x:f-v,y:D-v},{x:u-v,y:d-v}];for(let w=0;w<G.length;w++)C(this.centerRect[w],G[w].x,G[w].y,v*2,v*2)}else{C(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)C(this.cornerRect[t],0,0,0,0),C(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=F(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=F(e.stroke,"#ffffff"),this.centerRect[i]=F(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}};import{Frustum as di}from"three";var ht=class extends S{constructor(t){super(t);n(this,"startPoint");n(this,"endPoint");n(this,"rect");n(this,"frustum",new di);n(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});n(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});n(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});n(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=b({},t);this.endPoint&&(e=this.getSvgCoordinate(this.endPoint));let i={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y)},o=Math.abs(e.x-t.x),s=Math.abs(e.y-t.y);C(this.rect,i.x,i.y,o,s)}else C(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=F(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),C(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:o}}}=this,s=y(this.startPoint,e,i,o),c=y(this.endPoint,e,i,o),h={x:Math.min(s.x,c.x),y:Math.min(s.y,c.y)},l={x:Math.max(s.x,c.x),y:Math.max(s.y,c.y)},p=this.searchMapInFrustum(h,l);this.dispatchEvent({type:"selected",list:p})}}searchMapInFrustum(t,e){var o;let{context:i}=this;return((o=i.currentFloor)==null?void 0:o.graphicLayer.children.filter(s=>s instanceof L&&this.searchChildInFrustum(s,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:o,container:{clientWidth:s,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let g=t.getPosition();if(g){let m=y(g,o,s,c);return K(m,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let h=t.mesh.geometry.boundingBox;if(!h)return!1;let{min:l,max:p}=h,d=y(l,o,s,c),f=y(p,o,s,c);return!(!K(d,e,i)||!K(f,e,i))}dispose(){this.unRegistryEvent()}};var lt=class extends ui{constructor(t){super();this.context=t;n(this,"_list",new Set);n(this,"boxSelection");n(this,"prevPanStatus");n(this,"prevRotateStatus");n(this,"downPoint",null);n(this,"isMultipleSelect",!1);n(this,"onPointerDown",t=>{this.downPoint={x:t.offsetX,y:t.offsetY}});n(this,"onPointerUp",t=>{if(!this.downPoint)return;let{offsetX:e,offsetY:i}=t,{x:o,y:s}=this.downPoint;if(Math.sqrt(E(o-e,2)+E(s-i,2))>3)return;let{graphics:c}=this.context.getGraphicsByDeviceXy(e,i),h=new Set(c.map(p=>p.options.id));this.context.getPoisByDeviceXy(e,i).forEach(p=>{var d;if(!h.has(p.options.id)){let f=((d=this.context.currentFloor)==null?void 0:d.graphicLayer.graphicMap.get(p.options.id))||null;f&&f.options.geometry.type==="point"&&(c.push(f),h.add(p.options.id))}}),(N?t.metaKey:t.ctrlKey)||this._list.clear(),c.forEach(p=>this._list.add(p)),this.selectEnd(),this.downPoint=null});n(this,"onPointerOut",t=>{this.disableBoxSelection()});n(this,"onKeyDown",t=>{wt(t.key)&&this.enableBoxSelection()});n(this,"onKeyUp",t=>{wt(t.key)&&this.disableBoxSelection()});n(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new ht(t),this.boxSelection.setEnable(!1),this.registryEvent()}get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.context.control.enablePan,this.prevRotateStatus=this.context.control.enableRotate,this.context.control.enablePan=!1,this.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.container.addEventListener("pointerout",this.onPointerOut),this.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.container.removeEventListener("pointerout",this.onPointerOut),this.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent()}};import{EventDispatcher as gi}from"three";var pt=class extends gi{constructor(t){super();this.context=t;n(this,"curGraphics",new Set);n(this,"timer",new z);n(this,"graphicTimerMap",new Map);n(this,"onPointerMove",({graphics:t,pois:e,e:i})=>{let o=e.map(l=>{var p;return(p=this.context.currentFloor)==null?void 0:p.graphicLayer.graphicMap.get(l.options.id)}).filter(l=>l&&l.options.geometry.type==="point");if(!t.length&&!o.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:s}=this.context.config.hover,c=new Set;if(o.length){let l,p=1e4;o.forEach(d=>{let f=e.find(v=>v.options.id===d.options.id),{x:g,y:m}=f.clientPos,x=Math.sqrt(E(g-i.offsetX,2)+E(m-i.offsetY,2));x<p&&(p=x,l=d)}),c.add(l)}c.size||t.forEach(l=>c.add(l)),c.forEach(l=>{if(this.graphicTimerMap.get(l)||this.curGraphics.has(l))return;let p=this.timer.setTimeout(()=>{this.curGraphics.add(l),this.graphicTimerMap.delete(l),this.timer.clearTimeout(p),this.handleHoverGraphicsChange()},s);this.graphicTimerMap.set(l,p)}),this.graphicTimerMap.forEach((l,p)=>{c.has(p)||(this.timer.clearTimeout(l),this.graphicTimerMap.delete(p))});let h=this.curGraphics.size;this.curGraphics.forEach(l=>{c.has(l)||this.curGraphics.delete(l)}),h!==this.curGraphics.size&&this.handleHoverGraphicsChange()});n(this,"onPointerLevel",()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()});this.registryEvent()}handleHoverGraphicsChange(t=this.curGraphics){this.dispatchEvent({type:"hover-change",graphics:Array.from(t)})}registryEvent(){this.context.addEventListener("pointer-over",this.onPointerMove),this.context.addEventListener("pointer-move",this.onPointerMove),this.context.addEventListener("pointer-level",this.onPointerLevel)}unRegistryEvent(){this.context.removeEventListener("pointer-over",this.onPointerMove),this.context.removeEventListener("pointer-move",this.onPointerMove),this.context.removeEventListener("pointer-level",this.onPointerLevel)}dispose(){this.unRegistryEvent(),this.timer.dispose()}};import{Color as mt,LineBasicMaterial as fi,MeshStandardMaterial as vi,MeshBasicMaterial as yi,ShaderMaterial as xi,DoubleSide as bi}from"three";function qt(a){return`${a.x}-${a.y}-${a.z}`}var dt=class{constructor(r){this.context=r;n(this,"lineMaterialMap",new Map);n(this,"meshStandardMaterialMap",new Map);n(this,"meshBasicMaterialMap",new Map);n(this,"shaderMaterialMap",new Map)}generateLineMaterialKey({color:r,opacity:t}){return`${r}-${t}`}createLineMaterial({color:r,opacity:t}){let e=this.generateLineMaterialKey({color:r,opacity:t});if(this.lineMaterialMap.has(e))return this.lineMaterialMap.get(e);let i=new fi({color:new mt(r).convertLinearToSRGB(),transparent:!0,opacity:t});return this.lineMaterialMap.set(e,i),i}createMeshStandardMaterial({color:r,opacity:t}){let e=`${r}-${t}`;if(this.meshStandardMaterialMap.has(e))return this.meshStandardMaterialMap.get(e);let i=new vi({color:new mt(r).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:t,depthWrite:!0});return this.meshStandardMaterialMap.set(e,i),i}createMeshBasicMaterial({color:r,opacity:t}){let e=`${r}-${t}`;if(this.meshBasicMaterialMap.has(e))return this.meshBasicMaterialMap.get(e);let i=new yi({color:r,transparent:!0,opacity:t,depthWrite:!0});return this.meshBasicMaterialMap.set(e,i),i}createShaderMaterial({gradualColor:r,center:t,maxValue:e,opacity:i,direction:o,max:s,min:c}){let h=`${r.toString()}-${qt(t)}-${e}-${i}-${qt(o)}`;if(this.shaderMaterialMap.has(h))return this.shaderMaterialMap.get(h);let l=`
1
+ var oe=Object.defineProperty,ne=Object.defineProperties;var re=Object.getOwnPropertyDescriptors;var Dt=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var E=Math.pow,yt=(a,r,t)=>r in a?oe(a,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[r]=t,b=(a,r)=>{for(var t in r||(r={}))se.call(r,t)&&yt(a,t,r[t]);if(Dt)for(var t of Dt(r))ae.call(r,t)&&yt(a,t,r[t]);return a},I=(a,r)=>ne(a,re(r));var n=(a,r,t)=>(yt(a,typeof r!="symbol"?r+"":r,t),t);var P=(a,r,t)=>new Promise((e,i)=>{var o=h=>{try{c(t.next(h))}catch(l){i(l)}},s=h=>{try{c(t.throw(h))}catch(l){i(l)}},c=h=>h.done?e(h.value):Promise.resolve(h.value).then(o,s);c((t=t.apply(a,r)).next())});import{EventDispatcher as zi}from"three";var z=class{constructor(){n(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(r){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),r()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(r){this.tasks.requestAnimation.delete(r),window.cancelAnimationFrame(r)}setTimeout(r,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),r()},t);return this.tasks.timeout.add(e),e}clearTimeout(r){this.tasks.timeout.delete(r),window.clearTimeout(r)}setInterval(r,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),r()},t);return this.tasks.interval.add(e),e}clearInterval(r){this.tasks.interval.delete(r),window.clearInterval(r)}dispose(){this.tasks.requestAnimation.forEach(r=>{window.cancelAnimationFrame(r)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(r=>{window.clearTimeout(r)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(r=>{window.clearInterval(r)}),this.tasks.interval.clear()}};import{Scene as ce,WebGLRenderer as he,OrthographicCamera as le,Shape as pe,PCFSoftShadowMap as me,Group as de,Color as ue,DirectionalLight as ge,AmbientLight as fe,Path as ve,Vector2 as Ot}from"three";import{MapControls as ye}from"three/examples/jsm/controls/MapControls";function zt(){let a=new ce;return a.background=new ue(16777215),a}function kt(){let a=new he({antialias:!0});return a.autoClear=!0,a.setClearAlpha(1),a.setClearColor(16777215),a.setPixelRatio(window.devicePixelRatio),a.shadowMap.enabled=!0,a.shadowMap.autoUpdate=!0,a.shadowMap.type=me,a}function At(a,r){let t=new le(-a/2,a/2,r/2,-r/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function Tt(){let a=new de,r=new fe(16777215,2.6);return a.add(r),a}function Bt(a,r){let t=new ye(a,r);return t.enableDamping=!1,t.zoomSpeed=2,t}function Ft(a,r=[]){let t=new pe(a.map(e=>new Ot(...e)));return r.length&&r.forEach(e=>{var i=new ve(e.map(o=>new Ot(...o)));t.holes.push(i)}),t}function Rt(a=16777215,r=1){let t=new ge(a,r);return t.castShadow=!0,t.shadow.radius=8,t.shadow.bias=-.001,t.shadow.mapSize.set(256,256),t.shadow.camera.left=-200,t.shadow.camera.right=200,t.shadow.camera.top=200,t.shadow.camera.bottom=-200,t}function O(a,r){var t;if(r&&a.children&&a.children.length&&a.children.forEach(e=>{O(e,r)}),a.isMesh){let e=a;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}a.isLight&&((t=a.dispose)==null||t.call(a))}function Ht(a){return/[\u4E00-\u9FA5]+/g.test(a)}import{DataTexture as xe,RGBAFormat as be,LinearFilter as Vt}from"three";var U=new Map;function Ee(){let a=document.createElement("canvas");a.width=1024,a.height=64;let r=a.getContext("2d",{willReadFrequently:!0});return r.font="54px sans-serif",r.textBaseline="hanging",r.lineWidth=12,r.fillStyle="rgba(0,0,0,1)",r.strokeStyle="white",{canvas:a,ctx:r}}var xt,A;function we(){if(!xt){let{canvas:a,ctx:r}=Ee();xt=a,A=r}}function Zi(a){if(U.has(a))return U.get(a);we(),A.clearRect(0,0,1024,64);let r=Ht(a)?4:8;A.strokeText(a,2,r),A.fillText(a,2,r);let t=Math.ceil(A.measureText(a).width);t=t%2===0?t:t+1,t+=2;let e=A.getImageData(0,0,t,64),i=new xe(Uint8Array.from(e.data),t,64,be);return i.flipY=!0,i.minFilter=Vt,i.magFilter=Vt,U.set(a,i),i}function _t(){U.clear()}function $t(){A=null,xt=null}import{Vector3 as bt}from"three";import{point as Pe,featureCollection as Me,center as Ce}from"@turf/turf";function y(a,r,t,e){let i=a.clone().project(r),o=t/2,s=e/2,c=Math.round(i.x*o+o),h=Math.round(-i.y*s+s);return{x:c,y:h}}function Et(a){let r=Me(a.map(e=>Pe(e)));return Ce(r).geometry.coordinates}function K(a,r,t){return a.x>=r.x&&a.x<=t.x&&a.y>=r.y&&a.y<=t.y}function Ni(a){let r=0,t=new bt;for(let e=1;e<a.length;e++){let i=new bt(a[e-1][0],a[e-1][1],0),o=new bt(a[e][0],a[e][1],0),s=o.distanceTo(i);s>r&&(r=s,t=o.clone().sub(i).normalize())}return t}function j(a,r){return new Proxy(a,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,o)=>{let s=Reflect.get(t,e,o),c=Reflect.set(t,e,i,o);return s!==i&&r.dispatchEvent({type:`change-${e}`,value:i}),c}})}function V(a,r){return Promise.race([a,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),r)})])}function Z(a){return document.createElementNS("http://www.w3.org/2000/svg",a)}function It(a,r){let t=Z("svg");return t.setAttribute("width",a),t.setAttribute("height",r),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function _(a="2",r){let t=Z("circle");return t.setAttribute("r",a),t.setAttribute("fill",r),t}function X(a){let r=Z("line");return r.setAttribute("stroke",a),r}function F(a,r){let t=Z("rect");return t.setAttribute("stroke",a),t.setAttribute("fill",r),t}function T(a,r,t){a.setAttribute("cx",`${r}`),a.setAttribute("cy",`${t}`)}function M(a,r,t){r&&(a.setAttribute("x1",`${r.x}`),a.setAttribute("y1",`${r.y}`)),t&&(a.setAttribute("x2",`${t.x}`),a.setAttribute("y2",`${t.y}`))}function C(a,r,t,e,i){a.setAttribute("x",`${r}`),a.setAttribute("y",`${t}`),a.setAttribute("width",`${e}`),a.setAttribute("height",`${i}`)}function Ut(){return Promise.resolve()}function io(){return new Promise(a=>{requestAnimationFrame(a)})}function no(a){return parseInt(a.replace("#","0x"),16)}function ro(a,r){let t=parseInt(a.substring(1,3),16),e=parseInt(a.substring(3,5),16),i=parseInt(a.substring(5,7),16),o=Math.round(t*r),s=Math.round(e*r),c=Math.round(i*r);return`#${(1<<24|o<<16|s<<8|c).toString(16).slice(1)}`}function W(a,r=.85){let t,e,i;if(a.startsWith("#"))t=parseInt(a.substring(1,3),16),e=parseInt(a.substring(3,5),16),i=parseInt(a.substring(5,7),16);else{let s=a.slice(4,-1).split(",");t=parseInt(s[0].trim()),e=parseInt(s[1].trim()),i=parseInt(s[2].trim())}return t=Math.min(Math.floor(t*r),255),e=Math.min(Math.floor(e*r),255),i=Math.min(Math.floor(i*r),255),"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)}import{GLTFLoader as Le}from"three/examples/jsm/loaders/GLTFLoader";function Ge(){return new Le}var Y=null,q=new Map;function Kt(a){if(q.has(a)){let t=q.get(a).then(e=>(e.scene=e.scene.clone(),e))}Y||(Y=Ge());let r=new Promise((t,e)=>{Y.load(a,i=>{t(i)},void 0,e)});return q.set(a,r),r.then(t=>(t.scene=t.scene.clone(),t))}function jt(){Y=null,q.clear()}var N=navigator.userAgent.toUpperCase().indexOf("MAC")>=0;function wt(a){return N?a==="Meta":a==="Control"}import{EventDispatcher as wi,Box2 as Pi,Vector3 as k,Vector2 as H,Raycaster as Mi,Box3 as Ci,Color as Li,AmbientLight as Gi}from"three";import{Group as Si,Tween as ft}from"@tweenjs/tween.js";import{EventDispatcher as ui}from"three";import{Object3D as Se,ExtrudeGeometry as De,Mesh as Oe,Box3 as Pt,Vector3 as B,BufferGeometry as ze,LineSegments as ke}from"three";var Ae={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,strokeWidth:1,doors:[],locked:!1,visible:!0,geometry:{type:"polygon",cds:[],coords:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{},gradualColor:[],renderType:"single",colorFactor:.9},L=class extends Se{constructor(t,e){super();this.context=t;n(this,"geometry");n(this,"material");n(this,"mesh");n(this,"line");n(this,"lineMaterial");n(this,"lineGeometry");n(this,"options");if(this.options=j(b(b({},Ae),e),this),this.options.geometry.type==="point"){let[i,o]=this.options.geometry.coords;return this.position.set(i,o,this.options.height+this.options.airHeight),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i}),this.addEventListener("change-stroke",({value:i})=>{var o;if(i){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),(o=this.lineGeometry)==null||o.dispose())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-gradualColor",()=>{this.initMaterial(),this.initMesh()})}getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new B,e=new Pt;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new B(0,0,0);let t=new Pt,e=new B;return t.setFromObject(this),t.getSize(e),e}getPosition(){let t=this.getCenter();return t.setZ(t.z+this.options.height),t}init(){this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initGeometry(){let t=Ft(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new De(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initSingleMaterial(){let t=this.context.materialFactory.createMeshBasicMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});if(this.options.height<=.1)return this.material=t,t;let e=this.context.materialFactory.createMeshBasicMaterial({color:W(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,e],[t,e]}initGradualMaterial(){let{max:t,min:e}=new Pt().setFromObject(this),i=t.clone().sub(e),o=Math.max(i.x,i.y,i.z)/2,s=this.context.materialFactory.createShaderMaterial({gradualColor:this.options.gradualColor,center:this.getPosition(),maxValue:o,opacity:this.options.fillOpacity,direction:new B(-1,.2,0),max:t,min:e});if(this.options.height<=.1)return this.material=s,s;let c=this.context.materialFactory.createShaderMaterial({gradualColor:[W(this.options.gradualColor[0],this.options.colorFactor),W(this.options.gradualColor[1],this.options.colorFactor)],center:this.getCenter(),maxValue:o,opacity:this.options.fillOpacity,direction:new B(-1,.2,1),max:t,min:e});return this.material=[s,c],[s,c]}initMaterial(){return this.options.renderType==="gradual"?this.initGradualMaterial():this.initSingleMaterial()}initLineMaterial(){let t=this.context.materialFactory.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new Oe(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],e=this.options.height+this.options.deltaHeight,{coords:i}=this.options.geometry;for(let o=0;o<i.length;o++){let s=i[o];for(let c=0;c<s.length;c++){let h=s[c],l=c+1===s.length?s[0]:s[c+1];t.push(new B(h[0],h[1],e)),t.push(new B(l[0],l[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new ze().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new ke(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.line=t,this.add(t),t}raycast(t){if(!this.visible||this.options.geometry.type==="point")return!1;let e=t.intersectObject(this.mesh);if(e[0]){let{point:i,distance:o}=e[0];return{position:i,distance:o}}return!1}dispose(){var t;this.geometry.dispose(),(t=this.line)==null||t.geometry.dispose(),this.clear()}};import{Object3D as Te,PlaneGeometry as Be,Mesh as Fe,ShadowMaterial as Re,Color as He,DoubleSide as Ve}from"three";var Q=class extends Te{constructor(){super();n(this,"directionalLight");n(this,"plane");n(this,"basicOpacity",.07);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=Rt(16777215,.5);return t.position.set(0,0,100),this.add(t),t}changeLightCamera(t){let e=t.x,i=t.y;this.directionalLight.shadow.camera.left=-e,this.directionalLight.shadow.camera.right=e,this.directionalLight.shadow.camera.top=i,this.directionalLight.shadow.camera.bottom=-i,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(e,i)}changeLightColor(t){this.directionalLight.color=new He(t)}setPosition(t){this.position.copy(t),this.directionalLight.position.set(-t.x/2,-t.y/2,100)}initPlane(t=1e3,e=1e3){let i=new Be(t,e),o=new Re({transparent:!0,opacity:0,side:Ve}),s=new Fe(i,o);return s.receiveShadow=!0,s.position.z=-10,this.add(s),this.plane=s,s}setTarget(t){this.directionalLight.target=t}transformOpacity(t){return t*this.basicOpacity}setOpacity(t){this.plane.material.opacity=this.transformOpacity(t)}dispose(){O(this,!0)}};import{EventDispatcher as Ue,Vector3 as Ke}from"three";import{Box3 as _e,EventDispatcher as $e,Vector3 as Zt}from"three";var Ie={autoUpdate:!0,appendToBody:!1},J=class extends $e{constructor(t,e={}){super();this.context=t;n(this,"div");n(this,"element");n(this,"position",new Zt);n(this,"clientPos",{x:0,y:0});n(this,"visible",!0);n(this,"options");n(this,"onUpdate",()=>{this.updatePosition()});this.options=b(b({},Ie),e),this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):this.context.container.appendChild(this.div)}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}bindElement(t){this.element=t,this.onUpdate()}unBindElement(){this.element=void 0}setVisible(t,e="block"){t!==this.visible&&(this.div.style.display=t?e:"none",this.visible=t)}setOpacity(t){this.div.style.opacity=`${t}`}getPosition(){return this.element?typeof this.element.getPosition=="function"?this.element.getPosition():new _e().setFromObject(this.element).getCenter(new Zt):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:o}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=o}updatePosition(t=!1){let e=this.getPosition(),{width:i,height:o,x:s,y:c}=this.context.clientSize,{x:h,y:l}=y(e,this.context.camera,i,o);this.clientPos.x===h&&this.clientPos.y===l&&!t||(this.clientPos={x:h,y:l},this.options.appendToBody&&(this.div.style.left=`${s}px`,this.div.style.top=`${c+o}px`),this.options.autoUpdate?this.div.style.transform=`translate3d(${h}px, ${-o+l}px, 0)`:this.dispatchEvent({type:"update-position",x:h,y:l,width:i,height:o}))}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){var t;this.unRegistryEvent(),this.unBindElement(),(t=this.div)==null||t.remove(),this.div=null}};var je={texts:[{text:""}],level:1,collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},icon_opacity:1,icon_border:{color:"#586EE0",width:0},background:"",collision_hide_icon:!0,built_in:!1,box_only_icon:!1},$=class extends Ue{constructor(t,e){var i,o,s;super();this.context=t;n(this,"div");n(this,"textDiv");n(this,"img");n(this,"overlay");n(this,"options");n(this,"visible",!0);n(this,"size",{width:0,height:0});n(this,"position",new Ke);n(this,"userData",{});n(this,"showTextStatus",!0);n(this,"_changePosition",()=>{this.overlay.updatePosition(!0)});this.options=j(b(b({},je),e),this),this.position.set(((i=e.position)==null?void 0:i.x)||0,((o=e.position)==null?void 0:o.y)||0,((s=e.position)==null?void 0:s.z)||0),this.overlay=new J(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:c,y:h,height:l})=>{this.overlay.div.style.transform=`translate3d(calc(${c}px - 50%), calc(${-l+h}px - ${this.options.icon?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:c})=>{c?this.img?this.img.setAttribute("src",c):(this.div.appendChild(this.initIcon()),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:c})=>{this.div.removeChild(this.textDiv),this.div.firstChild?this.div.insertBefore(this.initText(),this.div.firstChild):this.div.appendChild(this.initText()),this.resetSize()}),this.addEventListener("change-opacity",({value:c})=>{this.overlay.setOpacity(c)}),this.addEventListener("change-icon_size",({value:c})=>{this.img&&(this.img.style.width=`${(c==null?void 0:c[0])||32}px`,this.img.style.height=`${(c==null?void 0:c[1])||32}px`,this.resetSize())}),this.addEventListener("change-icon_opacity",({value:c})=>{this.img&&(this.img.style.opacity=`${c}`)}),this.addEventListener("change-icon_border",({value:c})=>{this.img&&(this.img.style.border=`${c.width}px solid ${c.color}`)}),this.addEventListener("change-background",({value:c})=>{this.div.style.background=c})}get withinDisplayRange(){return this.overlay.withinDisplayRange}resetSize(){return P(this,null,function*(){if(yield Ut(),this.options.box_only_icon){if(!this.img)return;let{width:t,height:e}=this.img.getBoundingClientRect();this.size={width:t+2,height:e+2}}else{let{width:t,height:e}=this.div.getBoundingClientRect();this.size={width:t+2,height:e+2}}})}renderHelperBox(){}get clientPos(){return this.overlay.clientPos}initDiv(){let t=document.createElement("div");return t.appendChild(this.initText()),this.options.icon&&t.appendChild(this.initIcon()),t.style.fontSize="12px",t.style.textShadow="#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.padding="4px",this.overlay.setOpacity(this.options.opacity),this.overlay.div.style.pointerEvents="none",this.overlay.div.style.userSelect="none",this.overlay.div.appendChild(t),this.div=t,this.resetSize(),t}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.textAlign="center",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.texts.forEach(e=>{let i=document.createElement("div");if(i.style.whiteSpace="nowrap",e.styles)for(let[o,s]of Object.entries(e.styles))i.style[o]=s;i.textContent=e.text,t.appendChild(i)}),t}initIcon(){var e,i;let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${((e=this.options.icon_size)==null?void 0:e[0])||32}px`,t.style.height=`${((i=this.options.icon_size)==null?void 0:i[1])||32}px`,t.style.opacity=`${this.options.icon_opacity}px`,t.style.borderRadius="50%",this.options.icon_border.width&&(t.style.border=`${this.options.icon_border.width}px solid ${this.options.icon_border.color}`),t.onload=()=>{this.resetSize()},this.img=t,t}registryEvent(){}unRegistryEvent(){}setVisible(t){t!==this.visible&&(this.visible=t,this.changeOverlayVisible(t))}changeOverlayVisible(t){if(!(t===this.overlay.visible&&this.options.collision_hide_icon))if(this.options.collision_hide_icon)this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden";else{if(this.showTextStatus===t)return;this.textDiv.style.visibility=t?"visible":"hidden",this.showTextStatus=t}}parentSetVisible(t){this.visible&&this.changeOverlayVisible(t)}getBox(t=this.context.config.poi.boxScale){let{width:e,height:i}=this.size,o=e*t,s=i*t,{x:c,y:h}=this.overlay.clientPos;return{left:c-o/2,right:c+o/2,top:this.options.icon?h-s:h-s/2,bottom:this.options.icon?h:h+s/2}}getOriginBox(){return this.getBox(1)}isContain(t,e){if(!this.overlay.visible||!this.visible)return!1;let i=this.getOriginBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.div=null,this.textDiv=null,this.img=void 0,this.overlay.dispose()}};import{Box3 as nt,Object3D as Mt,Vector3 as rt}from"three";import{Box3 as Xe,Vector3 as We}from"three";import{Object3D as Ze}from"three";var R=class extends Ze{constructor(t){super();this.context=t}dispose(){O(this),this.clear()}};var tt=class extends R{constructor(t){super(t);n(this,"graphicMap",new Map)}getCenter(){return new Xe().setFromObject(this).getCenter(new We)}createGraphic(t){let e=new L(this.context,t);return this.add(e),this.graphicMap.set(t.id,e),e}removeGraphic(t){this.remove(t),this.graphicMap.delete(t.options.id),t.dispose()}removeGraphicById(t){this.graphicMap.has(t)&&this.removeGraphic(this.graphicMap.get(t))}getGraphicByNodeId(t){return this.graphicMap.get(t)||null}getGraphicByRaycaster(t){let e={distance:1e4,graphic:null,position:null},i=this.children.reduce((o,s)=>{if(s instanceof L){let c=s.raycast(t);if(c){let{distance:h}=c;if(h<o.distance)return{distance:o.distance,position:o.position,graphic:s}}return o}else return o},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};import{debounce as Ye}from"lodash";var et=class extends R{constructor(t){super(t);n(this,"pois",[]);n(this,"debounceCollisionDetection");n(this,"timer",new z);n(this,"onUpdate",()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})});this.registryEvent(),this.debounceCollisionDetection=Ye(this.collisionDetection,10)}clear(t=!1){return this.pois.forEach(e=>{e.options.built_in&&!t||e.dispose()}),this.pois=t?[]:this.pois.filter(e=>e.options.built_in),this}createPoi(t){let e=new $(this.context,t);return this.pushPoi(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),e}changePoiLevelOrCollisionEnable(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),this.pushPoi(t))}removePoi(t){let e=this.pois.findIndex(i=>i===t);e!==-1&&(this.pois.splice(e,1),t.dispose())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}getPoiById(t){return this.pois.find(i=>i.options.id===t)||null}pushPoi(t){if(!t.options.collision_enable){this.pois.unshift(t);return}if(t.options.level===0){this.pois.push(t);return}for(let e=0;e<this.pois.length;e++){let i=this.pois[e];if(i.options.collision_enable&&i.options.level<=t.options.level){this.pois.splice(e,0,t);return}}this.pois.push(t)}getPoiByDeviceXy(t,e){return this.pois.filter(o=>o instanceof $&&o.isContain(t,e))}collisionDetection(){let t=[];this.pois.filter(i=>i.visible&&i.withinDisplayRange).forEach((i,o)=>{let{left:s,right:c,top:h,bottom:l}=i.getBox();if(o===0||!i.options.collision_enable){t.push({left:s,right:c,top:h,bottom:l}),i.parentSetVisible(!0);return}let p=t.some(d=>d.left<c&&d.right>s&&d.top<l&&d.bottom>h);i.parentSetVisible(!p),p||t.push({left:s,right:c,top:h,bottom:l})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(t=>t.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};import{MeshBasicMaterial as qe,Object3D as Ne,PlaneGeometry as Qe,Texture as Je,DoubleSide as ti,Mesh as ei,Matrix3 as Xt,Vector2 as ii}from"three";import{create as oi}from"@mars3d/heatmap.js";import{featureCollection as ni,point as ri,bbox as si,center as ai}from"@turf/turf";var it=class extends Ne{constructor(t){super();this.context=t;n(this,"heatmap");n(this,"div");n(this,"plane");this.div=document.createElement("div")}clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:e,height:i,leftTop:o,center:s}=this.getBox(t);this.heatmap=oi(b({width:e,height:i,container:this.div},this.context.config.heatMap)),this.heatmap.setData(this.transformData(t,o)),this.initPlane(e,i),this.position.set(s[0],s[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new Qe(t,e),o=new Je(this.div.firstChild);o.needsUpdate=!0;let s=new qe({transparent:!0,side:ti,map:o});s.needsUpdate=!0,this.plane=new ei(i,s),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new Xt().makeScale(1,-1).multiply(new Xt().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(s=>{let c=new ii(s.x,s.y).applyMatrix3(i);return{x:c.x,y:c.y,value:s.value}}),max:t.max,min:t.min}}getBox(t){let e=ni(t.data.map(l=>ri([l.x,l.y]))),i=si(e),o=i[2]-i[0],s=i[3]-i[1],c={x:i[0],y:i[3]},h=ai(e);return{width:o,height:s,leftTop:c,center:h.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};import{Box3 as ci,Object3D as hi,Vector3 as Wt}from"three";var ot=class extends hi{constructor(t,e){super();this.context=t;this.options=e;n(this,"poi",null);n(this,"model",null);this.position.copy(e.position||new Wt(0,0,0)),this.loadModel()}loadModel(){return P(this,null,function*(){let t=yield Kt(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t,this.initPoi()})}initPoi(){var e;if(!this.options.icon)return;let t=(e=this.context.currentFloor)==null?void 0:e.addPoi({icon:this.options.icon,icon_size:this.options.icon_size,built_in:!0,level:0});this.poi=t||null,this.model&&t&&(t.position=new ci().setFromObject(this).getCenter(new Wt))}dispose(){var t;O(this),this.model=null,this.poi&&((t=this.context.currentFloor)==null||t.poiLayer.removePoi(this.poi),this.poi=null)}};var st=class extends Mt{constructor(t){super();this.context=t;n(this,"graphicLayer");n(this,"poiLayer");n(this,"grounds",new Set);n(this,"shadow",new Q);n(this,"heatmap");n(this,"groundUpper",new Mt);n(this,"models",new Mt);n(this,"modelMap",new Map);n(this,"groundMaxHeight",0);this.graphicLayer=new tt(this.context),this.poiLayer=new et(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper),this.add(this.models)}getPosition(){return new nt().setFromObject(this.groundUpper).getCenter(new rt)}createGround(t){let e=new L(this.context,t);this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.mesh.castShadow=!0,this.grounds.add(e),this.groundUpper.add(e))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(e=>e.options.height+e.options.airHeight+e.options.deltaHeight)):0,this.graphicLayer.position.z=this.groundMaxHeight,this.models.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new nt().setFromObject(this.groundUpper).getCenter(new rt)}addModel(t){let e=new ot(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new nt().setFromObject(this.groundUpper),e=t.getCenter(new rt),i=t.getSize(new rt);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new it(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new nt().setFromObject(this.graphicLayer);return this.heatmap.position.setZ(e.max.z),this.heatmap}removeHeatMap(){this.heatmap&&(this.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=void 0)}setShadowOpacity(t){this.shadow.setOpacity(t)}setShadowVisible(t){this.shadow.visible=t}dispose(){var t;this.shadow.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.grounds.forEach(e=>e.dispose()),(t=this.heatmap)==null||t.dispose(),this.groundUpper.clear(),this.models.children.forEach(e=>e.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}};import{EventDispatcher as li,Vector3 as pi}from"three";var S=class extends li{constructor(t){super();this.context=t;n(this,"points",[]);n(this,"svg");n(this,"enable",!0);n(this,"_onResize",({width:t,height:e})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${e}`))});this.svg=It(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}_registryEvent(){this.context.addEventListener("resize",this._onResize)}_unRegistryEvent(){this.context.removeEventListener("resize",this._onResize)}setEnable(t){this.enable=t,t?this.svg.style.display="block":this.svg.style.display="none"}getIntersectByPointerEvent(t){let{camera:e,renderer:i}=this.context,{offsetX:o,offsetY:s}=t,{clientWidth:c,clientHeight:h}=i.domElement,l=o/c*2-1,p=1-s/h*2;return new pi(l,p,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return y(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}};var at=class extends S{constructor(t){super(t);this.context=t;n(this,"circles");n(this,"line");n(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);T(this.circles[0],t.x,t.y),M(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);T(this.circles[1],t.x,t.y),M(this.line,void 0,t)}});n(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",M(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});n(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});n(this,"onPointerdown",t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t,s=this.circles[this.points.length];T(s,i,o),this.points.length||M(this.line,{x:i,y:o},{x:i,y:o}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[_(e.radius,e.fill),_(e.radius,e.fill)],this.line=X(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}addPoint(t){if(this.points.push(t),this.points.length>=2){let e=this.calculatedDistance();this.dispatchEvent({type:"distance",distance:e})}}calculatedDistance(){let[{x:t,y:e},{x:i,y:o}]=this.points;return Math.sqrt(E(i-t,2)+E(o-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var ct=class extends S{constructor(t){super(t);n(this,"circles",[]);n(this,"lines",[]);n(this,"isClose",!1);n(this,"onUpdate",()=>{this.points.length&&this.points.forEach((t,e)=>{let i=this.getSvgCoordinate(t);this.circles[e]&&T(this.circles[e],i.x,i.y),e!==0&&M(this.lines[e-1],void 0,i),this.lines[e]&&M(this.lines[e],i)})});n(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",M(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});n(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});n(this,"onPointerdown",t=>{if(this.isClose)return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:o}=t;this.checkAdsorb(i,o)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(e);let{circle:{fill:s,radius:c},line:{stroke:h}}=this.context.config.svg;if(!this.isClose){let l=_(c,s);T(l,i,o),this.addCircle(l)}if(this.lines.length&&M(this.lastLine,void 0,{x:i,y:o}),!this.isClose){let l=X(h);M(l,{x:i,y:o},{x:i,y:o}),this.addLine(l)}}});this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(t){this.circles.push(t),this.svg.appendChild(t)}addLine(t){this.lines.push(t),this.svg.appendChild(t)}registryEvent(){this.context.container.addEventListener("pointerenter",this.onPointermove),this.context.container.addEventListener("pointermove",this.onPointermove),this.context.container.addEventListener("pointerleave",this.onPointerleave),this.context.container.addEventListener("pointerdown",this.onPointerdown),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerenter",this.onPointermove),this.context.container.removeEventListener("pointermove",this.onPointermove),this.context.container.removeEventListener("pointerleave",this.onPointerleave),this.context.container.removeEventListener("pointerdown",this.onPointerdown),this.context.removeEventListener("update",this.onUpdate)}checkAdsorb(t,e){if(this.points.length<3)return!1;let i=this.circles[0],o=+i.getAttribute("cx"),s=+i.getAttribute("cy");return Math.sqrt(E(t-o,2)+E(e-s,2))<=5}addPoint(t){if(this.points.push(t),this.isClose){let e=this.calculatedArea();this.dispatchEvent({type:"area",area:e})}}calculatedArea(){let t=this.points.map(o=>[o.x,o.y]),e=0,i=t.length;for(let o=0;o<i;o++){let s=(o+1)%i;e+=t[o][0]*t[s][1]-t[s][0]*t[o][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};import{Box3 as mi}from"three";var Yt=class extends S{constructor(t){super(t);this.context=t;n(this,"rect");n(this,"cornerRect",[]);n(this,"centerRect",[]);n(this,"graphic");n(this,"onUpdate",()=>{if(this.graphic){let t=new mi().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:o}}=this.context,{min:s,max:c}=t,h=y(s,e,i,o),l=y(c,e,i,o);C(this.rect,h.x,l.y,Math.abs(l.x-h.x),Math.abs(l.y-h.y));let{x:p,y:d}=h,{x:f,y:g}=l,m=5,x=[{x:p-m,y:g-m},{x:f-m,y:g-m},{x:p-m,y:d-m},{x:f-m,y:d-m}];for(let w=0;w<x.length;w++)C(this.cornerRect[w],x[w].x,x[w].y,m*2,m*2);let v=4,u=(p+f)/2,D=(d+g)/2,G=[{x:u-v,y:g-v},{x:p-v,y:D-v},{x:f-v,y:D-v},{x:u-v,y:d-v}];for(let w=0;w<G.length;w++)C(this.centerRect[w],G[w].x,G[w].y,v*2,v*2)}else{C(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)C(this.cornerRect[t],0,0,0,0),C(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=F(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=F(e.stroke,"#ffffff"),this.centerRect[i]=F(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}};import{Frustum as di}from"three";var ht=class extends S{constructor(t){super(t);n(this,"startPoint");n(this,"endPoint");n(this,"rect");n(this,"frustum",new di);n(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});n(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});n(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});n(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=b({},t);this.endPoint&&(e=this.getSvgCoordinate(this.endPoint));let i={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y)},o=Math.abs(e.x-t.x),s=Math.abs(e.y-t.y);C(this.rect,i.x,i.y,o,s)}else C(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=F(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),C(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:o}}}=this,s=y(this.startPoint,e,i,o),c=y(this.endPoint,e,i,o),h={x:Math.min(s.x,c.x),y:Math.min(s.y,c.y)},l={x:Math.max(s.x,c.x),y:Math.max(s.y,c.y)},p=this.searchMapInFrustum(h,l);this.dispatchEvent({type:"selected",list:p})}}searchMapInFrustum(t,e){var o;let{context:i}=this;return((o=i.currentFloor)==null?void 0:o.graphicLayer.children.filter(s=>s instanceof L&&this.searchChildInFrustum(s,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:o,container:{clientWidth:s,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let g=t.getPosition();if(g){let m=y(g,o,s,c);return K(m,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let h=t.mesh.geometry.boundingBox;if(!h)return!1;let{min:l,max:p}=h,d=y(l,o,s,c),f=y(p,o,s,c);return!(!K(d,e,i)||!K(f,e,i))}dispose(){this.unRegistryEvent()}};var lt=class extends ui{constructor(t){super();this.context=t;n(this,"_list",new Set);n(this,"boxSelection");n(this,"prevPanStatus");n(this,"prevRotateStatus");n(this,"downPoint",null);n(this,"isMultipleSelect",!1);n(this,"onPointerDown",t=>{this.downPoint={x:t.offsetX,y:t.offsetY}});n(this,"onPointerUp",t=>{if(!this.downPoint)return;let{offsetX:e,offsetY:i}=t,{x:o,y:s}=this.downPoint;if(Math.sqrt(E(o-e,2)+E(s-i,2))>3)return;let{graphics:c}=this.context.getGraphicsByDeviceXy(e,i),h=new Set(c.map(p=>p.options.id));this.context.getPoisByDeviceXy(e,i).forEach(p=>{var d;if(!h.has(p.options.id)){let f=((d=this.context.currentFloor)==null?void 0:d.graphicLayer.graphicMap.get(p.options.id))||null;f&&f.options.geometry.type==="point"&&(c.push(f),h.add(p.options.id))}}),(N?t.metaKey:t.ctrlKey)||this._list.clear(),c.forEach(p=>this._list.add(p)),this.selectEnd(),this.downPoint=null});n(this,"onPointerOut",t=>{this.disableBoxSelection()});n(this,"onKeyDown",t=>{wt(t.key)&&this.enableBoxSelection()});n(this,"onKeyUp",t=>{wt(t.key)&&this.disableBoxSelection()});n(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new ht(t),this.boxSelection.setEnable(!1),this.registryEvent()}get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.context.control.enablePan,this.prevRotateStatus=this.context.control.enableRotate,this.context.control.enablePan=!1,this.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.container.addEventListener("pointerout",this.onPointerOut),this.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.container.removeEventListener("pointerout",this.onPointerOut),this.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent()}};import{EventDispatcher as gi}from"three";var pt=class extends gi{constructor(t){super();this.context=t;n(this,"curGraphics",new Set);n(this,"timer",new z);n(this,"graphicTimerMap",new Map);n(this,"onPointerMove",({graphics:t,pois:e,e:i})=>{let o=e.map(l=>{var p;return(p=this.context.currentFloor)==null?void 0:p.graphicLayer.graphicMap.get(l.options.id)}).filter(l=>l&&l.options.geometry.type==="point");if(!t.length&&!o.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:s}=this.context.config.hover,c=new Set;if(o.length){let l,p=1e4;o.forEach(d=>{let f=e.find(v=>v.options.id===d.options.id),{x:g,y:m}=f.clientPos,x=Math.sqrt(E(g-i.offsetX,2)+E(m-i.offsetY,2));x<p&&(p=x,l=d)}),c.add(l)}c.size||t.forEach(l=>c.add(l)),c.forEach(l=>{if(this.graphicTimerMap.get(l)||this.curGraphics.has(l))return;let p=this.timer.setTimeout(()=>{this.curGraphics.add(l),this.graphicTimerMap.delete(l),this.timer.clearTimeout(p),this.handleHoverGraphicsChange()},s);this.graphicTimerMap.set(l,p)}),this.graphicTimerMap.forEach((l,p)=>{c.has(p)||(this.timer.clearTimeout(l),this.graphicTimerMap.delete(p))});let h=this.curGraphics.size;this.curGraphics.forEach(l=>{c.has(l)||this.curGraphics.delete(l)}),h!==this.curGraphics.size&&this.handleHoverGraphicsChange()});n(this,"onPointerLevel",()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()});this.registryEvent()}handleHoverGraphicsChange(t=this.curGraphics){this.dispatchEvent({type:"hover-change",graphics:Array.from(t)})}registryEvent(){this.context.addEventListener("pointer-over",this.onPointerMove),this.context.addEventListener("pointer-move",this.onPointerMove),this.context.addEventListener("pointer-level",this.onPointerLevel)}unRegistryEvent(){this.context.removeEventListener("pointer-over",this.onPointerMove),this.context.removeEventListener("pointer-move",this.onPointerMove),this.context.removeEventListener("pointer-level",this.onPointerLevel)}dispose(){this.unRegistryEvent(),this.timer.dispose()}};import{Color as mt,LineBasicMaterial as fi,MeshStandardMaterial as vi,MeshBasicMaterial as yi,ShaderMaterial as xi,DoubleSide as bi}from"three";function qt(a){return`${a.x}-${a.y}-${a.z}`}var dt=class{constructor(r){this.context=r;n(this,"lineMaterialMap",new Map);n(this,"meshStandardMaterialMap",new Map);n(this,"meshBasicMaterialMap",new Map);n(this,"shaderMaterialMap",new Map)}generateLineMaterialKey({color:r,opacity:t}){return`${r}-${t}`}createLineMaterial({color:r,opacity:t}){let e=this.generateLineMaterialKey({color:r,opacity:t});if(this.lineMaterialMap.has(e))return this.lineMaterialMap.get(e);let i=new fi({color:new mt(r).convertLinearToSRGB(),transparent:!0,opacity:t});return this.lineMaterialMap.set(e,i),i}createMeshStandardMaterial({color:r,opacity:t}){let e=`${r}-${t}`;if(this.meshStandardMaterialMap.has(e))return this.meshStandardMaterialMap.get(e);let i=new vi({color:new mt(r).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:t,depthWrite:!0});return this.meshStandardMaterialMap.set(e,i),i}createMeshBasicMaterial({color:r,opacity:t}){let e=`${r}-${t}`;if(this.meshBasicMaterialMap.has(e))return this.meshBasicMaterialMap.get(e);let i=new yi({color:r,transparent:!0,opacity:t,depthWrite:!0});return this.meshBasicMaterialMap.set(e,i),i}createShaderMaterial({gradualColor:r,center:t,maxValue:e,opacity:i,direction:o,max:s,min:c}){let h=`${r.toString()}-${qt(t)}-${e}-${i}-${qt(o)}`;if(this.shaderMaterialMap.has(h))return this.shaderMaterialMap.get(h);let l=`
2
2
  uniform vec3 uColor;
3
3
  uniform vec3 uGradualColor;
4
4
  uniform vec3 center;