@aibee/crc-bmap 0.0.13 → 0.0.15

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/lib/bmap.min.js CHANGED
@@ -1,2 +1,3 @@
1
- "use strict";(()=>{var Kt=Object.defineProperty;var dt=Object.getOwnPropertySymbols;var Xt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var L=Math.pow,ct=(o,r,t)=>r in o?Kt(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,j=(o,r)=>{for(var t in r||(r={}))Xt.call(r,t)&&ct(o,t,r[t]);if(dt)for(var t of dt(r))_t.call(r,t)&&ct(o,t,r[t]);return o};var d=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(o,{get:(r,t)=>(typeof require!="undefined"?require:r)[t]}):o)(function(o){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var s=(o,r,t)=>(ct(o,typeof r!="symbol"?r+"":r,t),t);var V=(o,r,t)=>new Promise((e,i)=>{var n=p=>{try{c(t.next(p))}catch(h){i(h)}},a=p=>{try{c(t.throw(p))}catch(h){i(h)}},c=p=>p.done?e(p.value):Promise.resolve(p.value).then(n,a);c((t=t.apply(o,r)).next())});var Vt=d("three");var F=class{constructor(){s(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()}};var m=d("three"),ut=d("three/examples/jsm/controls/MapControls");function gt(){let o=new m.Scene;return o.background=new m.Color(16777215),o}function vt(){let o=new m.WebGLRenderer({antialias:!0});return o.setClearColor(16777215),o.setPixelRatio(window.devicePixelRatio),o.shadowMap.enabled=!0,o.shadowMap.autoUpdate=!0,o.shadowMap.type=m.PCFSoftShadowMap,o}function ft(o,r){let t=new m.OrthographicCamera(-o/2,o/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 xt(){let o=new m.Group,r=new m.HemisphereLight(16777215,15658734,1);r.intensity=1,r.position.set(0,0,10),r.up.set(0,0,1),o.add(r);let t=new m.AmbientLight(16777215);return o.add(t),o}function yt(o,r){let t=new ut.MapControls(o,r);return t.enableDamping=!1,t.maxPolarAngle=0,t.minPolarAngle=0,t.maxAzimuthAngle=0,t.minAzimuthAngle=0,t.minZoom=1,t.maxZoom=100,t}function bt(o,r=[]){let t=new m.Shape(o.map(e=>new m.Vector2(...e)));return r.length&&r.forEach(e=>{var i=new m.Path(e.map(n=>new m.Vector2(...n)));t.holes.push(i)}),t}function Et(o=16777215,r=1){let t=new m.DirectionalLight(o,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 M(o,r){var t;if(r&&o.children&&o.children.length&&o.children.forEach(e=>{M(e,r)}),o.isMesh){let e=o;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}o.isLight&&((t=o.dispose)==null||t.call(o))}function wt(o){return/[\u4E00-\u9FA5]+/g.test(o)}var O=d("three");var $=new Map;function Wt(){let o=document.createElement("canvas");o.width=1024,o.height=64;let r=o.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:o,ctx:r}}var ht,A;function Yt(){if(!ht){let{canvas:o,ctx:r}=Wt();ht=o,A=r}}function se(o){if($.has(o))return $.get(o);Yt(),A.clearRect(0,0,1024,64);let r=wt(o)?4:8;A.strokeText(o,2,r),A.fillText(o,2,r);let t=Math.ceil(A.measureText(o).width);t=t%2===0?t:t+1,t+=2;let e=A.getImageData(0,0,t,64),i=new O.DataTexture(Uint8Array.from(e.data),t,64,O.RGBAFormat);return i.flipY=!0,i.minFilter=O.LinearFilter,i.magFilter=O.LinearFilter,$.set(o,i),i}function Pt(){$.clear()}function Ct(){A=null,ht=null}var H=d("@turf/turf");function x(o,r,t,e){let i=o.clone().project(r),n=t/2,a=e/2,c=Math.round(i.x*n+n),p=Math.round(-i.y*a+a);return{x:c,y:p}}function Lt(o){let r=(0,H.featureCollection)(o.map(e=>(0,H.point)(e)));return(0,H.center)(r).geometry.coordinates}function pt(o,r,t){return o.x>=r.x&&o.x<=t.x&&o.y>=r.y&&o.y<=t.y}function K(o,r){return new Proxy(o,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,n)=>{let a=Reflect.set(t,e,i,n);return r.dispatchEvent({type:`change-${e}`,value:i}),a}})}function X(o,r){return Promise.race([o,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),r)})])}function _(o){return document.createElementNS("http://www.w3.org/2000/svg",o)}function Mt(o,r){let t=_("svg");return t.setAttribute("width",o),t.setAttribute("height",r),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function I(o="2",r){let t=_("circle");return t.setAttribute("r",o),t.setAttribute("fill",r),t}function W(o){let r=_("line");return r.setAttribute("stroke",o),r}function Gt(o,r){let t=_("rect");return t.setAttribute("stroke",o),t.setAttribute("fill",r),t}function T(o,r,t){o.setAttribute("cx",`${r}`),o.setAttribute("cy",`${t}`)}function P(o,r,t){r&&(o.setAttribute("x1",`${r.x}`),o.setAttribute("y1",`${r.y}`)),t&&(o.setAttribute("x2",`${t.x}`),o.setAttribute("y2",`${t.y}`))}function lt(o,r,t,e,i){o.setAttribute("x",`${r}`),o.setAttribute("y",`${t}`),o.setAttribute("width",`${e}`),o.setAttribute("height",`${i}`)}var g=d("three"),B=d("@tweenjs/tween.js");var Ft=d("three");var u=d("three");var Dt=d("lodash");var qt={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,doors:[],locked:!1,visible:!0,geometry:{type:"polygon",cds:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0},C=class extends u.Object3D{constructor(t,e){super();this.context=t;s(this,"geometry");s(this,"material");s(this,"mesh");s(this,"line");s(this,"options");this.options=K((0,Dt.merge)({},qt,e),this),this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.material.color=new u.Color(i)}),this.addEventListener("change-fillOpacity",({value:i})=>{this.material.opacity=i}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.line.material.color=new u.Color(i)}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.line.material.opacity=i}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i})}getCenter(){let t=new u.Vector3,e=new u.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){let t=new u.Box3,e=new u.Vector3;return t.setFromObject(this),t.getSize(e),e}getPosition(){return this.getCenter()}init(){this.geometry=this.initGeometry(),this.material=this.initMaterial(),this.mesh=this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.height/2,this.mesh.castShadow=!0,this.add(this.mesh),this.line=this.createBorder(),this.add(this.line)}initGeometry(){let t=bt(this.options.geometry.cds[0],this.options.geometry.cds.slice(1));return new u.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initMaterial(){return new u.MeshStandardMaterial({color:this.options.fillColor,roughness:1,transparent:!0,opacity:this.options.fillOpacity,depthWrite:!0})}initLineMaterial(){return new u.LineBasicMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity,transparent:!0,depthWrite:!0})}initMesh(){return new u.Mesh(this.geometry,this.material)}createBorder(){let t=this.initLineMaterial(),e=new u.EdgesGeometry(this.geometry),i=new u.LineSegments(e,t);return i.position.z=this.options.airHeight+this.options.height/2,i}raycast(t){if(!this.visible)return!1;let e=t.intersectObject(this.mesh);return e[0]?e[0].point:!1}dispose(){M(this),this.clear()}};var w=d("three");var Y=class extends w.Object3D{constructor(){super();s(this,"directionalLight");s(this,"plane");s(this,"basicOpacity",.39);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=Et(16777215,1);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 w.Color(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 w.PlaneGeometry(t,e),n=new w.ShadowMaterial({transparent:!0,opacity:0,side:w.DoubleSide}),a=new w.Mesh(i,n);return a.receiveShadow=!0,a.position.z=-5,this.add(a),this.plane=a,a}setTarget(t){this.directionalLight.target=t}transformOpacity(t){return t*this.basicOpacity}setOpacity(t){this.plane.material.opacity=this.transformOpacity(t)}dispose(){M(this,!0)}};var St=d("three"),At=d("lodash");var k=d("three");var q=class extends k.EventDispatcher{constructor(t){super();this.context=t;s(this,"div");s(this,"element");s(this,"position",new k.Vector3);s(this,"onUpdate",()=>{let t=this.getPosition(),{clientWidth:e,clientHeight:i}=this.context.container,{x:n,y:a}=x(t,this.context.camera,e,i);this.div.style.left=`${n}px`,this.div.style.top=`${a}px`});this.registryEvent(),this.div=this.initDiv(),this.context.container.appendChild(this.div)}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}bindElement(t){this.element=t}unBindElement(){this.element=void 0}setVisible(t,e="block"){this.div.style.display=t?e:"none"}getPosition(){return this.element?typeof this.element.getPosition=="function"?this.element.getPosition():new k.Box3().setFromObject(this.element).getCenter(new k.Vector3):this.position}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.unRegistryEvent(),this.unBindElement(),this.context.container.removeChild(this.div),this.div=null}};var Zt={text:"",level:1,collision_enable:!0},U=class extends St.Object3D{constructor(t,e){super();this.context=t;s(this,"span");s(this,"img");s(this,"overlay");s(this,"options");s(this,"_changePosition",()=>{this.overlay.div.style.transform=`translate3d(-50%, ${this.options.icon?"-100%":"-50%"}, 0)`});this.options=K((0,At.merge)({},Zt,e),this),this.overlay=new q(this.context),this.overlay.bindElement(this),this._changePosition(),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:i})=>{i?this.img?this.img.setAttribute("src",i):this.overlay.div.appendChild(this.initIcon()):(this.img&&this.overlay.div.removeChild(this.img),this.img=void 0)}),this.addEventListener("change-text",({value:i})=>{this.span.textContent=i})}initDiv(){let t=this.overlay.div;return t.appendChild(this.initText()),this.options.icon&&t.appendChild(this.initIcon()),t.style.fontSize="12px",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.pointerEvents="none",t}getPosition(){return this.position}initText(){let t=document.createElement("span");return t.style.whiteSpace="nowrap",t.textContent=this.options.text,this.span=t,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`,this.img=t,t}registryEvent(){this.context.addEventListener("update",this._changePosition)}unRegistryEvent(){this.context.removeEventListener("update",this._changePosition)}setVisible(t){this.overlay.setVisible(t,"flex")}getBox(){return this.overlay.div.getBoundingClientRect()}isContain(t,e){let i=this.getBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.overlay.dispose(),this.span=null,this.img=void 0}};var G=d("three");var Q=d("three");var Ot=d("three");var R=class extends Ot.Object3D{constructor(t){super();this.context=t}dispose(){M(this),this.clear()}};var Z=class extends R{constructor(r){super(r)}getCenter(){return new Q.Box3().setFromObject(this).getCenter(new Q.Vector3)}createGraphic(r){let t=new C(this.context,r);return this.add(t),t}getGraphicByRaycaster(r){let t=null;return{graphics:this.children.filter(i=>{if(i instanceof C){let n=i.raycast(r);return n&&(t?n.z>t.z&&(t=n):t=n),!!n}}),position:t}}};var N=class extends R{constructor(t){super(t);s(this,"pois",[]);s(this,"onUpdate",()=>{this.collisionDetection()});this.registryEvent()}createPoi(t){let e=new U(this.context,t);return this.add(e),this.pushPoi(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),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),this.remove(t),t.dispose())}pushPoi(t){if(!t.options.collision_enable){this.pois.unshift(t);return}if(t.options.level===1){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.children.filter(n=>n instanceof U&&n.isContain(t,e))}collisionDetection(){let t=[];this.pois.forEach((e,i)=>{e.setVisible(!0);let{left:n,right:a,top:c,bottom:p}=e.getBox();if(i===0){t.push({left:n,right:a,top:c,bottom:p});return}let h=t.some(l=>{let y=a<l.left||n>l.right,v=c>l.bottom||p<l.top;return y||v});e.setVisible(h)})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){super.dispose(),this.unRegistryEvent(),this.pois.forEach(t=>t.dispose()),this.pois.length=0}};var f=d("three"),Tt=d("@mars3d/heatmap.js"),D=d("@turf/turf");var J=class extends f.Object3D{constructor(t){super();this.context=t;s(this,"heatmap");s(this,"div");s(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:n,center:a}=this.getBox(t);this.heatmap=(0,Tt.create)(j({width:e,height:i,container:this.div},this.context.config.heatMap)),this.heatmap.setData(this.transformData(t,n)),this.initPlane(e,i),this.position.set(a[0],a[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new f.PlaneGeometry(t,e),n=new f.Texture(this.div.firstChild);n.needsUpdate=!0;let a=new f.MeshBasicMaterial({transparent:!0,side:f.DoubleSide,map:n});a.needsUpdate=!0,this.plane=new f.Mesh(i,a),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new f.Matrix3().makeScale(1,-1).multiply(new f.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(a=>{let c=new f.Vector2(a.x,a.y).applyMatrix3(i);return{x:c.x,y:c.y,value:a.value}}),max:t.max,min:t.min}}getBox(t){let e=(0,D.featureCollection)(t.data.map(h=>(0,D.point)([h.x,h.y]))),i=(0,D.bbox)(e),n=i[2]-i[0],a=i[3]-i[1],c={x:i[0],y:i[3]},p=(0,D.center)(e);return{width:n,height:a,leftTop:c,center:p.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var tt=class extends G.Object3D{constructor(t){super();this.context=t;s(this,"graphicLayer");s(this,"poiLayer");s(this,"grounds",new Set);s(this,"shadow",new Y);s(this,"heatmap");s(this,"groundUpper",new G.Object3D);this.graphicLayer=new Z(this.context),this.poiLayer=new N(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper)}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(this.grounds.add(e),this.groundUpper.add(e))})}addShadow(){let t=new G.Box3().setFromObject(this.groundUpper),e=t.getCenter(new G.Vector3),i=t.getSize(new G.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i),this.add(this.shadow)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new J(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new G.Box3().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.clear()}};var et=d("three");var S=class extends et.EventDispatcher{constructor(t){super();this.context=t;s(this,"points",[]);s(this,"svg");s(this,"enable",!0);this.svg=Mt(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg)}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:n,offsetY:a}=t,{clientWidth:c,clientHeight:p}=i.domElement,h=n/c*2-1,l=1-a/p*2;return new et.Vector3(h,l,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return x(t,e,i.clientWidth,i.clientHeight)}dispose(){this.context.container.removeChild(this.svg),this.svg=null}};var it=class extends S{constructor(t){super(t);this.context=t;s(this,"circles");s(this,"line");s(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);T(this.circles[0],t.x,t.y),P(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);T(this.circles[1],t.x,t.y),P(this.line,void 0,t)}});s(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",P(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});s(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});s(this,"onPointerdown",t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:n}=t,a=this.circles[this.points.length];T(a,i,n),this.points.length||P(this.line,{x:i,y:n},{x:i,y:n}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[I(e.radius,e.fill),I(e.radius,e.fill)],this.line=W(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:n}]=this.points;return Math.sqrt(L(i-t,2)+L(n-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var nt=class extends S{constructor(t){super(t);s(this,"circles",[]);s(this,"lines",[]);s(this,"isClose",!1);s(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&&P(this.lines[e-1],void 0,i),this.lines[e]&&P(this.lines[e],i)})});s(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",P(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});s(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});s(this,"onPointerdown",t=>{if(this.isClose)return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:n}=t;this.checkAdsorb(i,n)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(e);let{circle:{fill:a,radius:c},line:{stroke:p}}=this.context.config.svg;if(!this.isClose){let h=I(c,a);T(h,i,n),this.addCircle(h)}if(this.lines.length&&P(this.lastLine,void 0,{x:i,y:n}),!this.isClose){let h=W(p);P(h,{x:i,y:n},{x:i,y:n}),this.addLine(h)}}});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],n=+i.getAttribute("cx"),a=+i.getAttribute("cy");return Math.sqrt(L(t-n,2)+L(e-a,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(n=>[n.x,n.y]),e=0,i=t.length;for(let n=0;n<i;n++){let a=(n+1)%i;e+=t[n][0]*t[a][1]-t[a][0]*t[n][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var kt=d("three");var ot=class extends S{constructor(t){super(t);s(this,"startPoint");s(this,"endPoint");s(this,"rect");s(this,"frustum",new kt.Frustum);s(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});s(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});s(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});s(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=j({},t);this.endPoint&&(e=this.getSvgCoordinate(this.endPoint));let i={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y)},n=Math.abs(e.x-t.x),a=Math.abs(e.y-t.y);lt(this.rect,i.x,i.y,n,a)}});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=Gt(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),lt(this.rect,0,0,0,0)}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:n}}}=this,a=x(this.startPoint,e,i,n),c=x(this.endPoint,e,i,n),p={x:Math.min(a.x,c.x),y:Math.min(a.y,c.y)},h={x:Math.max(a.x,c.x),y:Math.max(a.y,c.y)},l=this.searchMapInFrustum(p,h);this.dispatchEvent({type:"selected",list:l})}}searchMapInFrustum(t,e){var n;let{context:i}=this;return((n=i.currentFloor)==null?void 0:n.graphicLayer.children.filter(a=>a instanceof C&&this.searchChildInFrustum(a,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:n,container:{clientWidth:a,clientHeight:c}}}=this;if(!t)return!1;t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let p=t.mesh.geometry.boundingBox;if(!p)return!1;let{min:h,max:l}=p,y=x(h,n,a,c),v=x(l,n,a,c);return!(!pt(y,e,i)||!pt(v,e,i))}dispose(){this.unRegistryEvent()}};var rt=class extends Ft.EventDispatcher{constructor(t){super();this.context=t;s(this,"_list",new Set);s(this,"boxSelection");s(this,"prevPanStatus");s(this,"onPointerDown",t=>{let{graphics:e}=this.context.getGraphicsByDeviceXy(t.offsetX,t.offsetY);t.ctrlKey||this._list.clear(),e.forEach(i=>this._list.add(i)),this.selectEnd()});s(this,"onKeyDown",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!0),this.prevPanStatus=this.context.control.enablePan,this.context.control.enablePan=!1)});s(this,"onKeyUp",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus)});s(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new ot(t),this.boxSelection.setEnable(!1),this.registryEvent()}get list(){return this._list}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list]})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}dispose(){this.unRegistryEvent()}};var Ht=d("three");var st=class extends Ht.EventDispatcher{constructor(t){super();this.context=t;s(this,"curGraphics",new Set);s(this,"timer",new F);s(this,"graphicTimerMap",new Map);s(this,"onPointerMove",({graphics:t})=>{if(!t.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:e}=this.context.config.hover;t.forEach(n=>{if(this.graphicTimerMap.get(n)||this.curGraphics.has(n))return;let a=this.timer.setTimeout(()=>{this.curGraphics.add(n),this.handleHoverGraphicsChange()},e);this.graphicTimerMap.set(n,a)}),this.graphicTimerMap.forEach((n,a)=>{t.includes(a)||(this.timer.clearTimeout(n),this.graphicTimerMap.delete(a))});let i=this.curGraphics.size;this.curGraphics.forEach(n=>{t.includes(n)||this.curGraphics.delete(n)}),i!==this.curGraphics.size&&this.handleHoverGraphicsChange()});s(this,"onPointerLevel",()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()});this.registryEvent()}handleHoverGraphicsChange(t=this.curGraphics){this.dispatchEvent({type:"hover-change",graphics:Array.from(this.curGraphics)})}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()}};var at=class extends g.EventDispatcher{constructor(t,e){super();this.container=t;this.config=e;s(this,"scene",gt());s(this,"renderer",vt());s(this,"camera");s(this,"control");s(this,"lights",xt());s(this,"timer",new F);s(this,"tweenGroup",new B.Group);s(this,"currentFloor");s(this,"selection");s(this,"hoverHelper");s(this,"basicRatio");s(this,"onWindowResize",()=>{let{container:t,camera:e,renderer:i}=this,{clientWidth:n,clientHeight:a}=t;e.left=-n/2,e.right=n/2,e.top=a/2,e.bottom=-a/2,e.updateProjectionMatrix(),i.setSize(window.innerWidth,window.innerHeight)});s(this,"onClick",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY);e.length&&this.dispatchEvent({type:"graphic-click",graphics:e,position:i});let n=this.getPoisByDeviceXy(t.clientX,t.clientY);n.length&&this.dispatchEvent({type:"poi-click",pois:n})});s(this,"onPointerover",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),n=this.getPoisByDeviceXy(t.clientX,t.clientY);this.dispatchEvent({type:"pointer-over",graphics:e,pois:n,position:i})});s(this,"onPointermove",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),n=this.getPoisByDeviceXy(t.clientX,t.clientY);this.dispatchEvent({type:"pointer-move",graphics:e,pois:n,position:i})});s(this,"onPointerleave",()=>{this.dispatchEvent({type:"pointer-level"})});s(this,"onSelectionSelect",({graphics:t})=>{this.dispatchEvent({type:"select-graphic",graphics:t})});s(this,"onHoverChange",({graphics:t})=>{this.dispatchEvent({type:"hover",graphics:t})});this.container.style.position="relative",this.container.style.overflow="hidden",this.init(),this.selection=new rt(this),this.hoverHelper=new st(this),this.registryEvent()}init(){let{clientWidth:t,clientHeight:e}=this.container;this.camera=ft(t,e),this.renderer.setSize(t,e),this.control=yt(this.camera,this.renderer.domElement),this.container.appendChild(this.renderer.domElement),this.scene.add(this.lights),this.basicRatio=this.getRatio(),this.control.addEventListener("change",()=>{var n;let i=this.control.getPolarAngle();(n=this.currentFloor)==null||n.setShadowOpacity(i/this.config.control.maxPolar),this.dispatchEvent({type:"change-ratio",px:(this.basicRatio||0)*this.camera.zoom})})}getRatio(t=new g.Vector3(0,0,0),e=new g.Vector3(100,0,0)){let{clientWidth:i,clientHeight:n}=this.container,a=x(t,this.camera,i,n),c=x(e,this.camera,i,n);return Math.ceil(Math.sqrt(L(c.x-a.x,2)+L(c.y-a.y,2)))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof g.AmbientLight&&(e.color=new g.Color(t))})}switchFloor(t){var i;this.currentFloor&&(this.scene.remove(this.currentFloor),this.currentFloor.dispose()),this.currentFloor=t,this.scene.add(t);let e=(i=t.graphicLayer)==null?void 0:i.getCenter();e&&(this.lights.position.x=e.x,this.lights.position.y=e.y)}getGraphicsByDeviceXy(t,e){var c;let i=new g.Vector2;i.x=t/this.container.clientWidth*2-1,i.y=e/this.container.clientHeight*-2+1;let n=new g.Raycaster;return n.setFromCamera(i,this.camera),((c=this.currentFloor)==null?void 0:c.graphicLayer.getGraphicByRaycaster(n))||{graphics:[],position:null}}getPoisByDeviceXy(t,e){var n;return((n=this.currentFloor)==null?void 0:n.poiLayer.getPoiByDeviceXy(t,e))||[]}registryEvent(){window.addEventListener("resize",this.onWindowResize),this.container.addEventListener("click",this.onClick),this.container.addEventListener("pointerover",this.onPointerover),this.container.addEventListener("pointermove",this.onPointermove),this.container.addEventListener("pointerleave",this.onPointerleave),this.selection.addEventListener("select",this.onSelectionSelect),this.hoverHelper.addEventListener("hover-change",this.onHoverChange)}unRegistryEvent(){window.removeEventListener("resize",this.onWindowResize),this.container.removeEventListener("click",this.onClick),this.container.removeEventListener("pointerover",this.onPointerover),this.container.removeEventListener("pointermove",this.onPointermove),this.container.removeEventListener("pointerleave",this.onPointerleave),this.selection.removeEventListener("select",this.onSelectionSelect),this.hoverHelper.removeEventListener("hover-change",this.onHoverChange)}setPolarAngle(t,e=500){return X(new Promise(i=>{let n={polar:this.control.getPolarAngle()},a={polar:t},c=new B.Tween(n,this.tweenGroup).to(a,e).onUpdate(()=>{this.control.maxPolarAngle=n.polar,this.control.minPolarAngle=n.polar,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}getCameraLookAt(){return new g.Vector3().subVectors(this.control.target,this.camera.position)}setZoom(t,e,i=500){return X(new Promise(n=>{let a={zoom:this.camera.zoom,target:this.control.target.clone()},c=this.getCameraLookAt(),p=new B.Tween(a,this.tweenGroup).to({zoom:t,target:e},i).onUpdate(()=>{this.camera.position.copy(a.target.clone().sub(c)),this.control.target.copy(a.target),this.camera.zoom=a.zoom,this.control.update()}).onComplete(()=>{this.tweenGroup.remove(p),this.control.enabled=!0,n(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),i+500)}fitCameraToObject(t,e=[20,20,20,20],i=500){let[n,a,c,p]=e,{clientWidth:h,clientHeight:l}=this.container,y=new g.Box3().setFromObject(t),{max:v,min:b}=y,E=x(v,this.camera,h,l),z=x(b,this.camera,h,l),mt=new g.Box2().setFromPoints([new g.Vector2(E.x,E.y),new g.Vector2(z.x,z.y)]).getSize(new g.Vector2),It=(h-a-p)/mt.x,Ut=(l-n-c)/mt.y,jt=Math.min(It,Ut),$t=new g.Vector3((v.x+b.x)/2,(v.y+b.y)/2,v.z);return this.setZoom(jt*this.camera.zoom,$t,i)}fitCameraToGround(t=[20,20,20,20],e=500){return this.currentFloor?this.fitCameraToObject(this.currentFloor.groundUpper,t,e):Promise.resolve(!1)}setCameraPosition(t,e){return X(new Promise(i=>{let n=this.camera.position.clone(),a=this.getCameraLookAt(),c=new B.Tween(n,this.tweenGroup).to(t,e).onUpdate(()=>{this.camera.position.copy(n),this.control.target.copy(t.clone().add(a))}).onComplete(()=>{this.tweenGroup.remove(c),this.control.update(),this.control.enabled=!0,i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}render(){this.renderer.render(this.scene,this.camera),this.dispatchEvent({type:"update"}),this.timer.requestAnimationFrame(()=>{this.render()}),this.tweenGroup.update()}dispose(){this.selection.dispose(),this.hoverHelper.dispose(),this.tweenGroup.getAll().forEach(t=>t.stop()),this.tweenGroup.removeAll(),this.unRegistryEvent(),this.container.removeChild(this.renderer.domElement),this.timer.dispose(),this.renderer.dispose(),this.lights.children.forEach(t=>t.dispose()),M(this.scene)}};var Rt=d("lodash"),Qt={apiDomain:"",apiInfo:{},apiPath:{floorGraphic:"/api/inception-map/floor/get",floorRange:"/api/inception-map/range/get"},heatMap:{radius:50,gradient:{0:"#8F9FCD",.5:"#6284FF",1:"#F95D5D"}},useFloorCache:!0,control:{maxPolar:1.2},svg:{circle:{radius:"2",fill:"#1CADFF"},line:{stroke:"#1CADFF"}},selectBox:{stroke:"#1CADFF",fill:"rgba(28, 173, 255, 0.3)"},hover:{time:500}};function Bt(o){return(0,Rt.merge)({},Qt,o)}var zt=class extends Vt.EventDispatcher{constructor(t,e={}){super();this.container=t;s(this,"config");s(this,"context");s(this,"polarKeys",[]);s(this,"azimuthalKeys",[]);s(this,"svgLine");s(this,"svgPolygon");s(this,"basicZoom",1);s(this,"floorDataMap",new Map);s(this,"onKeydown",t=>{this.polarKeys.includes(t.code)&&(this.context.control.maxPolarAngle=this.config.control.maxPolar,this.context.control.minPolarAngle=0),this.azimuthalKeys.includes(t.code)&&(this.context.control.maxAzimuthAngle=1/0,this.context.control.minAzimuthAngle=1/0)});s(this,"onKeyUp",t=>{if(this.polarKeys.includes(t.code)){let e=this.context.control.getPolarAngle();this.context.control.maxPolarAngle=e,this.context.control.minPolarAngle=e}if(this.azimuthalKeys.includes(t.code)){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e,this.context.control.minAzimuthAngle=e}});this.config=Bt(e),this.context=new at(t,this.config),this.registryEvent(),this.context.render()}loadGraphics(p){return V(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c}){let{apiDomain:h,apiPath:{floorGraphic:l},apiInfo:y}=this.config,v=`${h}${l}?brand=${t}&project=${e}&phase=${i}&building=${n}&floor=${a}&ts=${c}&resource_type_list=`;return yield fetch(v,y).then(E=>E.json()).then(E=>E.data).then(E=>((E||[]).map(z=>z.info=JSON.parse(z.info)),E||[]))})}loadBuildingGround(a){return V(this,arguments,function*({brand:t,project:e,phase:i,building:n}){let{apiDomain:c,apiPath:{floorRange:p},apiInfo:h}=this.config,l=`${c}${p}?brand=${t}&project=${e}&phase=${i}&building=${n}`;return yield fetch(l,h).then(v=>v.json()).then(v=>v.data).then(v=>{let b=(v||[])[0];return b&&(b.info=JSON.parse(b.info)),b})})}load(p){return V(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c}){if(this.floorDataMap.get(a))return;let[h,l]=yield Promise.all([this.loadGraphics({brand:t,project:e,phase:i,building:n,floor:a,ts:c}),this.loadBuildingGround({brand:t,project:e,phase:i,building:n})]);if(l){let y=Lt(l.info.geometry.cds[0]);h.forEach(v=>{v.info.geometry.cds.map(b=>{Array.isArray(b)&&b.forEach(E=>{E[0]-=y[0],E[1]-=y[1]})})})}return this.config.useFloorCache||this.floorDataMap.clear(),this.floorDataMap.set(a,h),h})}createFloor(t){let e=new tt(this.context);if(!t.length)return{curFloor:e,graphics:[]};let n=t.filter(h=>h.info.group==="ground").map(h=>new C(this.context,h.info));e.addGrounds(n);let a=t.filter(h=>h.info.group!=="ground"),c=new Map,p=a.map(h=>{let l=e.addGraphic(h.info);return l.userData.data=h,c.set(h.legacy_id,l),l});return e.addShadow(),e.userData.legacyToGraphicMap=c,{curFloor:e,graphics:p}}switchFloor(t){let e=this.floorDataMap.get(t);if(e){let i=this.createFloor(e);i?(this.context.switchFloor(i.curFloor),this.context.fitCameraToGround(void 0,0),this.basicZoom=this.context.camera.zoom):console.warn("[switchFloor error] ["+t+"] \u697C\u5C42\u6CA1\u6709\u6570\u636E")}else console.warn("[switchFloor error] \u6CA1\u6709\u8FD9\u4E2A\u697C\u5C42\uFF0C\u8BF7\u5148\u8C03\u7528load\u65B9\u6CD5\u52A0\u8F7D\u697C\u5C42")}addHeatmap(t){var e;return(e=this.context.currentFloor)==null?void 0:e.addHeatmap(t)}getLegacyToGraphicMap(){var t;return((t=this.context.currentFloor)==null?void 0:t.userData.legacyToGraphicMap)||new Map}getFloorAllGraphics(){var t;return((t=this.context.currentFloor)==null?void 0:t.graphicLayer.children.filter(e=>e instanceof C))||[]}createGraphicPoi(t,e){if(this.context.currentFloor){let i=this.context.currentFloor.addPoi(e);i.position.copy(t.getCenter()),i.position.z=i.position.z+t.options.height/2}return null}removeHeatMap(){var t;(t=this.context.currentFloor)==null||t.removeHeatMap()}translateElementToCenter(t,e=500){let i=t.position.clone().setFromMatrixPosition(t.matrixWorld);return this.context.setCameraPosition(i,e)}getElementDeviceCoordinate(t){let e=t.position.clone(),{clientWidth:i,clientHeight:n}=this.container;return x(e,this.context.camera,i,n)}changeMapType(t,e=500){t==="2d"?this.context.setPolarAngle(0):this.context.setPolarAngle(1.2)}reduceMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i-t,this.context.control.target,e)}enlargeMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i+t,this.context.control.target,e)}registryEvent(){window.addEventListener("keydown",this.onKeydown),window.addEventListener("keyup",this.onKeyUp)}unRegistryEvent(){window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("keyup",this.onKeyUp)}configurePolarShortcutKeys(t){this.polarKeys=t}configureAzimuthalShortcutKeys(t){this.azimuthalKeys=t}rotateMap(t=.1){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e+t,this.context.control.minAzimuthAngle=e+t,this.context.control.update()}measureDistance(){return V(this,null,function*(){return this.cancelDistance(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgLine=new it(this.context);let i=this.svgLine.dispose.bind(this.svgLine);this.svgLine.dispose=function(){i(),e("cancel")},this.svgLine.addEventListener("distance",({distance:n})=>{t(n)})})})}cancelDistance(){this.svgLine&&(this.svgLine.dispose(),this.svgLine=void 0,this.context.control.enableRotate=!0)}measureArea(){return this.cancelArea(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgPolygon=new nt(this.context);let i=this.svgPolygon.dispose.bind(this.svgPolygon);this.svgPolygon.dispose=function(){i(),e("cancel")},this.svgPolygon.addEventListener("area",({area:n})=>{t(n)})})}cancelArea(){this.svgPolygon&&(this.svgPolygon.dispose(),this.svgPolygon=void 0,this.context.control.enableRotate=!0)}dispose(){this.context.dispose(),Pt(),Ct(),this.unRegistryEvent()}};})();
1
+ "use strict";(()=>{var Kt=Object.defineProperty;var dt=Object.getOwnPropertySymbols;var Xt=Object.prototype.hasOwnProperty,_t=Object.prototype.propertyIsEnumerable;var G=Math.pow,ct=(o,r,t)=>r in o?Kt(o,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[r]=t,j=(o,r)=>{for(var t in r||(r={}))Xt.call(r,t)&&ct(o,t,r[t]);if(dt)for(var t of dt(r))_t.call(r,t)&&ct(o,t,r[t]);return o};var d=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(o,{get:(r,t)=>(typeof require!="undefined"?require:r)[t]}):o)(function(o){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var s=(o,r,t)=>(ct(o,typeof r!="symbol"?r+"":r,t),t);var k=(o,r,t)=>new Promise((e,i)=>{var n=p=>{try{c(t.next(p))}catch(h){i(h)}},a=p=>{try{c(t.throw(p))}catch(h){i(h)}},c=p=>p.done?e(p.value):Promise.resolve(p.value).then(n,a);c((t=t.apply(o,r)).next())});var Vt=d("three");var H=class{constructor(){s(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()}};var m=d("three"),ut=d("three/examples/jsm/controls/MapControls");function gt(){let o=new m.Scene;return o.background=new m.Color(16777215),o}function vt(){let o=new m.WebGLRenderer({antialias:!0});return o.setClearColor(16777215),o.setPixelRatio(window.devicePixelRatio),o.shadowMap.enabled=!0,o.shadowMap.autoUpdate=!0,o.shadowMap.type=m.PCFSoftShadowMap,o}function ft(o,r){let t=new m.OrthographicCamera(-o/2,o/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 xt(){let o=new m.Group,r=new m.HemisphereLight(16777215,15658734,1);r.intensity=1,r.position.set(0,0,10),r.up.set(0,0,1),o.add(r);let t=new m.AmbientLight(16777215);return o.add(t),o}function yt(o,r){let t=new ut.MapControls(o,r);return t.enableDamping=!1,t.maxPolarAngle=0,t.minPolarAngle=0,t.maxAzimuthAngle=0,t.minAzimuthAngle=0,t}function bt(o,r=[]){let t=new m.Shape(o.map(e=>new m.Vector2(...e)));return r.length&&r.forEach(e=>{var i=new m.Path(e.map(n=>new m.Vector2(...n)));t.holes.push(i)}),t}function Et(o=16777215,r=1){let t=new m.DirectionalLight(o,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 M(o,r){var t;if(r&&o.children&&o.children.length&&o.children.forEach(e=>{M(e,r)}),o.isMesh){let e=o;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}o.isLight&&((t=o.dispose)==null||t.call(o))}function Pt(o){return/[\u4E00-\u9FA5]+/g.test(o)}var O=d("three");var $=new Map;function Wt(){let o=document.createElement("canvas");o.width=1024,o.height=64;let r=o.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:o,ctx:r}}var ht,A;function Yt(){if(!ht){let{canvas:o,ctx:r}=Wt();ht=o,A=r}}function se(o){if($.has(o))return $.get(o);Yt(),A.clearRect(0,0,1024,64);let r=Pt(o)?4:8;A.strokeText(o,2,r),A.fillText(o,2,r);let t=Math.ceil(A.measureText(o).width);t=t%2===0?t:t+1,t+=2;let e=A.getImageData(0,0,t,64),i=new O.DataTexture(Uint8Array.from(e.data),t,64,O.RGBAFormat);return i.flipY=!0,i.minFilter=O.LinearFilter,i.magFilter=O.LinearFilter,$.set(o,i),i}function wt(){$.clear()}function Ct(){A=null,ht=null}var R=d("@turf/turf");function x(o,r,t,e){let i=o.clone().project(r),n=t/2,a=e/2,c=Math.round(i.x*n+n),p=Math.round(-i.y*a+a);return{x:c,y:p}}function Lt(o){let r=(0,R.featureCollection)(o.map(e=>(0,R.point)(e)));return(0,R.center)(r).geometry.coordinates}function pt(o,r,t){return o.x>=r.x&&o.x<=t.x&&o.y>=r.y&&o.y<=t.y}function K(o,r){return new Proxy(o,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,n)=>{let a=Reflect.set(t,e,i,n);return r.dispatchEvent({type:`change-${e}`,value:i}),a}})}function X(o,r){return Promise.race([o,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),r)})])}function _(o){return document.createElementNS("http://www.w3.org/2000/svg",o)}function Gt(o,r){let t=_("svg");return t.setAttribute("width",o),t.setAttribute("height",r),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function I(o="2",r){let t=_("circle");return t.setAttribute("r",o),t.setAttribute("fill",r),t}function W(o){let r=_("line");return r.setAttribute("stroke",o),r}function Mt(o,r){let t=_("rect");return t.setAttribute("stroke",o),t.setAttribute("fill",r),t}function T(o,r,t){o.setAttribute("cx",`${r}`),o.setAttribute("cy",`${t}`)}function w(o,r,t){r&&(o.setAttribute("x1",`${r.x}`),o.setAttribute("y1",`${r.y}`)),t&&(o.setAttribute("x2",`${t.x}`),o.setAttribute("y2",`${t.y}`))}function lt(o,r,t,e,i){o.setAttribute("x",`${r}`),o.setAttribute("y",`${t}`),o.setAttribute("width",`${e}`),o.setAttribute("height",`${i}`)}var g=d("three"),z=d("@tweenjs/tween.js");var kt=d("three");var u=d("three");var Dt=d("lodash");var qt={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,doors:[],locked:!1,visible:!0,geometry:{type:"polygon",cds:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0},L=class extends u.Object3D{constructor(t,e){super();this.context=t;s(this,"geometry");s(this,"material");s(this,"mesh");s(this,"line");s(this,"options");if(this.options=K((0,Dt.merge)({},qt,e),this),this.options.geometry.type==="point"){let[i,n]=this.options.geometry.cds;return this.position.set(i,n,this.options.height+this.options.airHeight),console.log(this.options),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.material.color=new u.Color(i)}),this.addEventListener("change-fillOpacity",({value:i})=>{this.material.opacity=i}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.line.material.color=new u.Color(i)}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.line.material.opacity=i}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i})}getCenter(){if(this.options.geometry.type==="point")return this.position;let t=new u.Vector3,e=new u.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new u.Vector3(0,0,0);let t=new u.Box3,e=new u.Vector3;return t.setFromObject(this),t.getSize(e),e}getPosition(){return this.getCenter()}init(){this.geometry=this.initGeometry(),this.material=this.initMaterial(),this.mesh=this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.height/2,this.mesh.castShadow=!0,this.add(this.mesh),this.line=this.createBorder(),this.add(this.line)}initGeometry(){let t=bt(this.options.geometry.cds[0],this.options.geometry.cds.slice(1));return new u.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initMaterial(){return new u.MeshStandardMaterial({color:this.options.fillColor,roughness:1,transparent:!0,opacity:this.options.fillOpacity,depthWrite:!0})}initLineMaterial(){return new u.LineBasicMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity,transparent:!0,depthWrite:!0})}initMesh(){return new u.Mesh(this.geometry,this.material)}createBorder(){let t=this.initLineMaterial(),e=new u.EdgesGeometry(this.geometry),i=new u.LineSegments(e,t);return i.position.z=this.options.airHeight+this.options.height/2,i}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:n}=e[0];return{position:i,distance:n}}return!1}dispose(){M(this),this.clear()}};var P=d("three");var Y=class extends P.Object3D{constructor(){super();s(this,"directionalLight");s(this,"plane");s(this,"basicOpacity",.39);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=Et(16777215,1);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 P.Color(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 P.PlaneGeometry(t,e),n=new P.ShadowMaterial({transparent:!0,opacity:0,side:P.DoubleSide}),a=new P.Mesh(i,n);return a.receiveShadow=!0,a.position.z=-5,this.add(a),this.plane=a,a}setTarget(t){this.directionalLight.target=t}transformOpacity(t){return t*this.basicOpacity}setOpacity(t){this.plane.material.opacity=this.transformOpacity(t)}dispose(){M(this,!0)}};var St=d("three"),At=d("lodash");var F=d("three");var q=class extends F.EventDispatcher{constructor(t){super();this.context=t;s(this,"div");s(this,"element");s(this,"position",new F.Vector3);s(this,"onUpdate",()=>{let t=this.getPosition(),{clientWidth:e,clientHeight:i}=this.context.container,{x:n,y:a}=x(t,this.context.camera,e,i);this.div.style.left=`${n}px`,this.div.style.top=`${a}px`});this.registryEvent(),this.div=this.initDiv(),this.context.container.appendChild(this.div)}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}bindElement(t){this.element=t}unBindElement(){this.element=void 0}setVisible(t,e="block"){this.div.style.display=t?e:"none"}setOpacity(t){this.div.style.opacity=`${t}`}getPosition(){return this.element?typeof this.element.getPosition=="function"?this.element.getPosition():new F.Box3().setFromObject(this.element).getCenter(new F.Vector3):this.position}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.unRegistryEvent(),this.unBindElement(),this.context.container.removeChild(this.div),this.div=null}};var Zt={text:"",level:1,collision_enable:!0,opacity:1},U=class extends St.Object3D{constructor(t,e){super();this.context=t;s(this,"textDiv");s(this,"img");s(this,"overlay");s(this,"options");s(this,"_changePosition",()=>{this.overlay.div.style.transform=`translate3d(-50%, ${this.options.icon?"-100%":"-50%"}, 0)`});this.options=K((0,At.merge)({},Zt,e),this),this.overlay=new q(this.context),this.overlay.bindElement(this),this._changePosition(),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:i})=>{i?this.img?this.img.setAttribute("src",i):this.overlay.div.appendChild(this.initIcon()):(this.img&&this.overlay.div.removeChild(this.img),this.img=void 0)}),this.addEventListener("change-text",({value:i})=>{this.overlay.div.removeChild(this.textDiv),this.overlay.div.appendChild(this.initText())}),this.addEventListener("change-opacity",({value:i})=>{this.overlay.setOpacity(i)})}initDiv(){let t=this.overlay.div;return t.appendChild(this.initText()),this.options.icon&&t.appendChild(this.initIcon()),t.style.fontSize="12px",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.pointerEvents="none",t}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.background="rgba(255, 255, 255, .7)",t.style.padding="2px",t.style.borderRadius="4px",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.text.split(`\r
2
+ `).forEach(e=>{let i=document.createElement("div");i.style.whiteSpace="nowrap",i.textContent=e,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`,this.img=t,t}registryEvent(){this.context.addEventListener("update",this._changePosition)}unRegistryEvent(){this.context.removeEventListener("update",this._changePosition)}setVisible(t){this.overlay.setVisible(t,"flex")}getBox(){return this.overlay.div.getBoundingClientRect()}isContain(t,e){let i=this.getBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.textDiv=null,this.img=void 0,this.overlay.dispose()}};var C=d("three");var Q=d("three");var Ot=d("three");var B=class extends Ot.Object3D{constructor(t){super();this.context=t}dispose(){M(this),this.clear()}};var Z=class extends B{constructor(r){super(r)}getCenter(){return new Q.Box3().setFromObject(this).getCenter(new Q.Vector3)}createGraphic(r){let t=new L(this.context,r);return this.add(t),t}getGraphicByRaycaster(r){let t={distance:1e4,graphic:null,position:null},e=this.children.reduce((i,n)=>{if(n instanceof L){let a=n.raycast(r);if(a){let{distance:c}=a;if(c<i.distance)return{distance:i.distance,position:i.position,graphic:n}}return i}else return i},t);return e===t?{graphics:[],position:null}:{graphics:[e.graphic],position:e.position}}};var N=class extends B{constructor(t){super(t);s(this,"pois",[]);s(this,"onUpdate",()=>{this.collisionDetection()});this.registryEvent()}createPoi(t){let e=new U(this.context,t);return this.add(e),this.pushPoi(e),e.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(e)),e.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(e)),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),this.remove(t),t.dispose())}pushPoi(t){if(!t.options.collision_enable){this.pois.unshift(t);return}if(t.options.level===1){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.children.filter(n=>n instanceof U&&n.isContain(t,e))}collisionDetection(){let t=[];this.pois.forEach((e,i)=>{e.setVisible(!0);let{left:n,right:a,top:c,bottom:p}=e.getBox();if(i===0){t.push({left:n,right:a,top:c,bottom:p});return}let h=t.some(l=>{let y=a<l.left||n>l.right,v=c>l.bottom||p<l.top;return y||v});e.setVisible(h)})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){super.dispose(),this.unRegistryEvent(),this.pois.forEach(t=>t.dispose()),this.pois.length=0}};var f=d("three"),Tt=d("@mars3d/heatmap.js"),D=d("@turf/turf");var J=class extends f.Object3D{constructor(t){super();this.context=t;s(this,"heatmap");s(this,"div");s(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:n,center:a}=this.getBox(t);this.heatmap=(0,Tt.create)(j({width:e,height:i,container:this.div},this.context.config.heatMap)),this.heatmap.setData(this.transformData(t,n)),this.initPlane(e,i),this.position.set(a[0],a[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new f.PlaneGeometry(t,e),n=new f.Texture(this.div.firstChild);n.needsUpdate=!0;let a=new f.MeshBasicMaterial({transparent:!0,side:f.DoubleSide,map:n});a.needsUpdate=!0,this.plane=new f.Mesh(i,a),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new f.Matrix3().makeScale(1,-1).multiply(new f.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(a=>{let c=new f.Vector2(a.x,a.y).applyMatrix3(i);return{x:c.x,y:c.y,value:a.value}}),max:t.max,min:t.min}}getBox(t){let e=(0,D.featureCollection)(t.data.map(h=>(0,D.point)([h.x,h.y]))),i=(0,D.bbox)(e),n=i[2]-i[0],a=i[3]-i[1],c={x:i[0],y:i[3]},p=(0,D.center)(e);return{width:n,height:a,leftTop:c,center:p.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var tt=class extends C.Object3D{constructor(t){super();this.context=t;s(this,"graphicLayer");s(this,"poiLayer");s(this,"grounds",new Set);s(this,"shadow",new Y);s(this,"heatmap");s(this,"groundUpper",new C.Object3D);this.graphicLayer=new Z(this.context),this.poiLayer=new N(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.add(this.groundUpper)}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(this.grounds.add(e),this.groundUpper.add(e))})}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new C.Box3().setFromObject(this.groundUpper).getCenter(new C.Vector3)}addShadow(){let t=new C.Box3().setFromObject(this.groundUpper),e=t.getCenter(new C.Vector3),i=t.getSize(new C.Vector3);this.shadow.setPosition(e),this.shadow.changeLightCamera(i),this.add(this.shadow)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new J(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new C.Box3().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.clear()}};var et=d("three");var S=class extends et.EventDispatcher{constructor(t){super();this.context=t;s(this,"points",[]);s(this,"svg");s(this,"enable",!0);this.svg=Gt(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg)}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:n,offsetY:a}=t,{clientWidth:c,clientHeight:p}=i.domElement,h=n/c*2-1,l=1-a/p*2;return new et.Vector3(h,l,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return x(t,e,i.clientWidth,i.clientHeight)}dispose(){this.context.container.removeChild(this.svg),this.svg=null}};var it=class extends S{constructor(t){super(t);this.context=t;s(this,"circles");s(this,"line");s(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);T(this.circles[0],t.x,t.y),w(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);T(this.circles[1],t.x,t.y),w(this.line,void 0,t)}});s(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",w(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});s(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});s(this,"onPointerdown",t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:n}=t,a=this.circles[this.points.length];T(a,i,n),this.points.length||w(this.line,{x:i,y:n},{x:i,y:n}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[I(e.radius,e.fill),I(e.radius,e.fill)],this.line=W(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:n}]=this.points;return Math.sqrt(G(i-t,2)+G(n-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var nt=class extends S{constructor(t){super(t);s(this,"circles",[]);s(this,"lines",[]);s(this,"isClose",!1);s(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&&w(this.lines[e-1],void 0,i),this.lines[e]&&w(this.lines[e],i)})});s(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",w(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});s(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});s(this,"onPointerdown",t=>{if(this.isClose)return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:n}=t;this.checkAdsorb(i,n)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(e);let{circle:{fill:a,radius:c},line:{stroke:p}}=this.context.config.svg;if(!this.isClose){let h=I(c,a);T(h,i,n),this.addCircle(h)}if(this.lines.length&&w(this.lastLine,void 0,{x:i,y:n}),!this.isClose){let h=W(p);w(h,{x:i,y:n},{x:i,y:n}),this.addLine(h)}}});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],n=+i.getAttribute("cx"),a=+i.getAttribute("cy");return Math.sqrt(G(t-n,2)+G(e-a,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(n=>[n.x,n.y]),e=0,i=t.length;for(let n=0;n<i;n++){let a=(n+1)%i;e+=t[n][0]*t[a][1]-t[a][0]*t[n][1]}return Math.abs(e/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};var Ft=d("three");var ot=class extends S{constructor(t){super(t);s(this,"startPoint");s(this,"endPoint");s(this,"rect");s(this,"frustum",new Ft.Frustum);s(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});s(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});s(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});s(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=j({},t);this.endPoint&&(e=this.getSvgCoordinate(this.endPoint));let i={x:Math.min(t.x,e.x),y:Math.min(t.y,e.y)},n=Math.abs(e.x-t.x),a=Math.abs(e.y-t.y);lt(this.rect,i.x,i.y,n,a)}});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=Mt(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),lt(this.rect,0,0,0,0)}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:n}}}=this,a=x(this.startPoint,e,i,n),c=x(this.endPoint,e,i,n),p={x:Math.min(a.x,c.x),y:Math.min(a.y,c.y)},h={x:Math.max(a.x,c.x),y:Math.max(a.y,c.y)},l=this.searchMapInFrustum(p,h);this.dispatchEvent({type:"selected",list:l})}}searchMapInFrustum(t,e){var n;let{context:i}=this;return((n=i.currentFloor)==null?void 0:n.graphicLayer.children.filter(a=>a instanceof L&&this.searchChildInFrustum(a,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:n,container:{clientWidth:a,clientHeight:c}}}=this;if(!t)return!1;t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let p=t.mesh.geometry.boundingBox;if(!p)return!1;let{min:h,max:l}=p,y=x(h,n,a,c),v=x(l,n,a,c);return!(!pt(y,e,i)||!pt(v,e,i))}dispose(){this.unRegistryEvent()}};var rt=class extends kt.EventDispatcher{constructor(t){super();this.context=t;s(this,"_list",new Set);s(this,"boxSelection");s(this,"prevPanStatus");s(this,"onPointerDown",t=>{let{graphics:e}=this.context.getGraphicsByDeviceXy(t.offsetX,t.offsetY);t.ctrlKey||this._list.clear(),e.forEach(i=>this._list.add(i)),this.selectEnd()});s(this,"onKeyDown",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!0),this.prevPanStatus=this.context.control.enablePan,this.context.control.enablePan=!1)});s(this,"onKeyUp",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus)});s(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new ot(t),this.boxSelection.setEnable(!1),this.registryEvent()}get list(){return this._list}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list]})}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}dispose(){this.unRegistryEvent()}};var Ht=d("three");var st=class extends Ht.EventDispatcher{constructor(t){super();this.context=t;s(this,"curGraphics",new Set);s(this,"timer",new H);s(this,"graphicTimerMap",new Map);s(this,"onPointerMove",({graphics:t})=>{if(!t.length&&this.curGraphics.size){this.curGraphics.clear(),this.handleHoverGraphicsChange();return}let{time:e}=this.context.config.hover;t.forEach(n=>{if(this.graphicTimerMap.get(n)||this.curGraphics.has(n))return;let a=this.timer.setTimeout(()=>{this.curGraphics.add(n),this.handleHoverGraphicsChange()},e);this.graphicTimerMap.set(n,a)}),this.graphicTimerMap.forEach((n,a)=>{t.includes(a)||(this.timer.clearTimeout(n),this.graphicTimerMap.delete(a))});let i=this.curGraphics.size;this.curGraphics.forEach(n=>{t.includes(n)||this.curGraphics.delete(n)}),i!==this.curGraphics.size&&this.handleHoverGraphicsChange()});s(this,"onPointerLevel",()=>{this.curGraphics.clear(),this.handleHoverGraphicsChange()});this.registryEvent()}handleHoverGraphicsChange(t=this.curGraphics){this.dispatchEvent({type:"hover-change",graphics:Array.from(this.curGraphics)})}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()}};var at=class extends g.EventDispatcher{constructor(t,e){super();this.container=t;this.config=e;s(this,"scene",gt());s(this,"renderer",vt());s(this,"camera");s(this,"control");s(this,"lights",xt());s(this,"timer",new H);s(this,"tweenGroup",new z.Group);s(this,"currentFloor");s(this,"selection");s(this,"hoverHelper");s(this,"basicRatio");s(this,"onWindowResize",()=>{let{container:t,camera:e,renderer:i}=this,{clientWidth:n,clientHeight:a}=t;e.left=-n/2,e.right=n/2,e.top=a/2,e.bottom=-a/2,e.updateProjectionMatrix(),i.setSize(n,a)});s(this,"onClick",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY);e.length&&this.dispatchEvent({type:"graphic-click",graphics:e,position:i});let n=this.getPoisByDeviceXy(t.clientX,t.clientY);n.length&&this.dispatchEvent({type:"poi-click",pois:n})});s(this,"onPointerover",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),n=this.getPoisByDeviceXy(t.clientX,t.clientY);this.dispatchEvent({type:"pointer-over",graphics:e,pois:n,position:i})});s(this,"onPointermove",t=>{let{graphics:e,position:i}=this.getGraphicsByDeviceXy(t.offsetX,t.offsetY),n=this.getPoisByDeviceXy(t.clientX,t.clientY);this.dispatchEvent({type:"pointer-move",graphics:e,pois:n,position:i})});s(this,"onPointerleave",()=>{this.dispatchEvent({type:"pointer-level"})});s(this,"onSelectionSelect",({graphics:t})=>{this.dispatchEvent({type:"select-graphic",graphics:t})});s(this,"onHoverChange",({graphics:t})=>{this.dispatchEvent({type:"hover",graphics:t})});this.container.style.position="relative",this.container.style.overflow="hidden",this.init(),this.selection=new rt(this),this.hoverHelper=new st(this),this.registryEvent()}init(){let{clientWidth:t,clientHeight:e}=this.container;this.camera=ft(t,e),this.renderer.setSize(t,e),this.control=yt(this.camera,this.renderer.domElement),this.container.appendChild(this.renderer.domElement),this.scene.add(this.lights),this.basicRatio=this.getRatio(),this.control.addEventListener("change",()=>{var n;let i=this.control.getPolarAngle();(n=this.currentFloor)==null||n.setShadowOpacity(i/this.config.control.maxPolar),this.dispatchEvent({type:"change-ratio",px:(this.basicRatio||0)*this.camera.zoom})})}getRatio(t=new g.Vector3(0,0,0),e=new g.Vector3(100,0,0)){let{clientWidth:i,clientHeight:n}=this.container,a=x(t,this.camera,i,n),c=x(e,this.camera,i,n);return Math.ceil(Math.sqrt(G(c.x-a.x,2)+G(c.y-a.y,2)))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof g.AmbientLight&&(e.color=new g.Color(t))})}switchFloor(t){this.currentFloor&&(this.scene.remove(this.currentFloor),this.currentFloor.dispose()),this.currentFloor=t,this.scene.add(t);let e=t.getCenter();e&&(this.lights.position.x=e.x,this.lights.position.y=e.y)}getGraphicsByDeviceXy(t,e){var c;let i=new g.Vector2;i.x=t/this.container.clientWidth*2-1,i.y=e/this.container.clientHeight*-2+1;let n=new g.Raycaster;return n.setFromCamera(i,this.camera),((c=this.currentFloor)==null?void 0:c.graphicLayer.getGraphicByRaycaster(n))||{graphics:[],position:null}}getPoisByDeviceXy(t,e){var n;return((n=this.currentFloor)==null?void 0:n.poiLayer.getPoiByDeviceXy(t,e))||[]}registryEvent(){window.addEventListener("resize",this.onWindowResize),this.container.addEventListener("click",this.onClick),this.container.addEventListener("pointerover",this.onPointerover),this.container.addEventListener("pointermove",this.onPointermove),this.container.addEventListener("pointerleave",this.onPointerleave),this.selection.addEventListener("select",this.onSelectionSelect),this.hoverHelper.addEventListener("hover-change",this.onHoverChange)}unRegistryEvent(){window.removeEventListener("resize",this.onWindowResize),this.container.removeEventListener("click",this.onClick),this.container.removeEventListener("pointerover",this.onPointerover),this.container.removeEventListener("pointermove",this.onPointermove),this.container.removeEventListener("pointerleave",this.onPointerleave),this.selection.removeEventListener("select",this.onSelectionSelect),this.hoverHelper.removeEventListener("hover-change",this.onHoverChange)}setPolarAngle(t,e=500){return X(new Promise(i=>{let n={polar:this.control.getPolarAngle()},a={polar:t},c=new z.Tween(n,this.tweenGroup).to(a,e).onUpdate(()=>{this.control.maxPolarAngle=n.polar,this.control.minPolarAngle=n.polar,this.control.update()}).onComplete(()=>{this.control.enabled=!0,this.tweenGroup.remove(c),i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}getCameraLookAt(){return new g.Vector3().subVectors(this.control.target,this.camera.position)}setZoom(t,e,i=500){return X(new Promise(n=>{let a={zoom:this.camera.zoom,target:this.control.target.clone()},c=this.getCameraLookAt(),p=new z.Tween(a,this.tweenGroup).to({zoom:t,target:e},i).onUpdate(()=>{this.camera.position.copy(a.target.clone().sub(c)),this.control.target.copy(a.target),this.camera.zoom=a.zoom,this.control.update()}).onComplete(()=>{this.tweenGroup.remove(p),this.control.enabled=!0,n(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),i+500)}fitCameraToObject(t,e=[20,20,20,20],i=500){let[n,a,c,p]=e,{clientWidth:h,clientHeight:l}=this.container,y=new g.Box3().setFromObject(t),{max:v,min:b}=y,E=x(v,this.camera,h,l),V=x(b,this.camera,h,l),mt=new g.Box2().setFromPoints([new g.Vector2(E.x,E.y),new g.Vector2(V.x,V.y)]).getSize(new g.Vector2),It=(h-a-p)/mt.x,Ut=(l-n-c)/mt.y,jt=Math.min(It,Ut),$t=new g.Vector3((v.x+b.x)/2,(v.y+b.y)/2,v.z);return this.setZoom(jt*this.camera.zoom,$t,i)}fitCameraToGround(t=[20,20,20,20],e=500){return this.currentFloor&&this.currentFloor.hasElement?this.fitCameraToObject(this.currentFloor.groundUpper,t,e):Promise.resolve(!1)}setCameraPosition(t,e){return X(new Promise(i=>{let n=this.camera.position.clone(),a=this.getCameraLookAt(),c=new z.Tween(n,this.tweenGroup).to(t,e).onUpdate(()=>{this.camera.position.copy(n),this.control.target.copy(t.clone().add(a))}).onComplete(()=>{this.tweenGroup.remove(c),this.control.update(),this.control.enabled=!0,i(!0)}).onStart(()=>{this.control.enabled=!1}).start()}),e+500)}render(){this.renderer.render(this.scene,this.camera),this.dispatchEvent({type:"update"}),this.timer.requestAnimationFrame(()=>{this.render()}),this.tweenGroup.update()}dispose(){this.selection.dispose(),this.hoverHelper.dispose(),this.tweenGroup.getAll().forEach(t=>t.stop()),this.tweenGroup.removeAll(),this.unRegistryEvent(),this.container.removeChild(this.renderer.domElement),this.timer.dispose(),this.renderer.dispose(),this.lights.children.forEach(t=>t.dispose()),M(this.scene)}};var Rt=d("lodash"),Qt={apiDomain:"",apiInfo:{},apiPath:{floorGraphic:"/api/inception-map/floor/get",floorRange:"/api/inception-map/range/get"},heatMap:{radius:50,gradient:{0:"#8F9FCD",.5:"#6284FF",1:"#F95D5D"}},useFloorCache:!0,control:{maxPolar:1.2},svg:{circle:{radius:"2",fill:"#1CADFF"},line:{stroke:"#1CADFF"}},selectBox:{stroke:"#1CADFF",fill:"rgba(28, 173, 255, 0.3)"},hover:{time:500}};function Bt(o){return(0,Rt.merge)({},Qt,o)}var zt=class extends Vt.EventDispatcher{constructor(t,e={}){super();this.container=t;s(this,"config");s(this,"context");s(this,"polarKeys",[]);s(this,"azimuthalKeys",[]);s(this,"svgLine");s(this,"svgPolygon");s(this,"basicZoom",1);s(this,"floorDataMap",new Map);s(this,"onKeydown",t=>{this.polarKeys.includes(t.code)&&(this.context.control.maxPolarAngle=this.config.control.maxPolar,this.context.control.minPolarAngle=0),this.azimuthalKeys.includes(t.code)&&(this.context.control.maxAzimuthAngle=1/0,this.context.control.minAzimuthAngle=1/0)});s(this,"onKeyUp",t=>{if(this.polarKeys.includes(t.code)){let e=this.context.control.getPolarAngle();this.context.control.maxPolarAngle=e,this.context.control.minPolarAngle=e}if(this.azimuthalKeys.includes(t.code)){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e,this.context.control.minAzimuthAngle=e}});this.config=Bt(e),this.context=new at(t,this.config),this.registryEvent(),this.context.render()}loadGraphics(p){return k(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c}){let{apiDomain:h,apiPath:{floorGraphic:l},apiInfo:y}=this.config,v=`${h}${l}?brand=${t}&project=${e}&phase=${i}&building=${n}&floor=${a}&ts=${c}&resource_type_list=`;return yield fetch(v,y).then(E=>E.json()).then(E=>E.data).then(E=>((E||[]).map(V=>V.info=JSON.parse(V.info)),E||[]))})}loadBuildingGround(a){return k(this,arguments,function*({brand:t,project:e,phase:i,building:n}){let{apiDomain:c,apiPath:{floorRange:p},apiInfo:h}=this.config,l=`${c}${p}?brand=${t}&project=${e}&phase=${i}&building=${n}`;return yield fetch(l,h).then(v=>v.json()).then(v=>v.data).then(v=>{let b=(v||[])[0];return b&&(b.info=JSON.parse(b.info)),b})})}load(p){return k(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c}){if(this.floorDataMap.get(a))return;let[h,l]=yield Promise.all([this.loadGraphics({brand:t,project:e,phase:i,building:n,floor:a,ts:c}),this.loadBuildingGround({brand:t,project:e,phase:i,building:n})]);if(l){let y=Lt(l.info.geometry.cds[0]);h.forEach(v=>{if(v.info.geometry.type==="polygon")v.info.geometry.cds.map(b=>{Array.isArray(b)&&b.forEach(E=>{E[0]-=y[0],E[1]-=y[1]})});else{let[b,E]=v.info.geometry.cds;v.info.geometry.cds=[b-y[0],E-y[1]]}})}return this.config.useFloorCache||this.floorDataMap.clear(),this.floorDataMap.set(a,h),h})}createFloor(t){let e=new tt(this.context);if(!t.length)return{curFloor:e,graphics:[]};let n=t.filter(h=>h.info.group==="ground").map(h=>new L(this.context,h.info));e.addGrounds(n);let a=t.filter(h=>h.info.group!=="ground"),c=new Map,p=a.map(h=>{let l=e.addGraphic(h.info);return l.userData.data=h,c.set(h.legacy_id,l),l});return e.addShadow(),e.userData.legacyToGraphicMap=c,{curFloor:e,graphics:p}}switchFloor(t){return k(this,null,function*(){let e=this.floorDataMap.get(t);if(e){let i=this.createFloor(e);i?(this.context.switchFloor(i.curFloor),yield this.context.fitCameraToGround(void 0,0),this.basicZoom=this.context.camera.zoom,this.context.control.minZoom=this.basicZoom,this.context.control.maxZoom=this.basicZoom*25):console.warn("[switchFloor error] ["+t+"] \u697C\u5C42\u6CA1\u6709\u6570\u636E")}else console.warn("[switchFloor error] \u6CA1\u6709\u8FD9\u4E2A\u697C\u5C42\uFF0C\u8BF7\u5148\u8C03\u7528load\u65B9\u6CD5\u52A0\u8F7D\u697C\u5C42")})}addHeatmap(t){var e;return(e=this.context.currentFloor)==null?void 0:e.addHeatmap(t)}getLegacyToGraphicMap(){var t;return((t=this.context.currentFloor)==null?void 0:t.userData.legacyToGraphicMap)||new Map}getFloorAllGraphics(){var t;return((t=this.context.currentFloor)==null?void 0:t.graphicLayer.children.filter(e=>e instanceof L))||[]}createGraphicPoi(t,e){if(this.context.currentFloor){let i=this.context.currentFloor.addPoi(e),n=t.getCenter();return n.z+=t.options.height/2,i.position.copy(n),i.position.z=i.position.z+t.options.height/2,i}return null}removeHeatMap(){var t;(t=this.context.currentFloor)==null||t.removeHeatMap()}translateElementToCenter(t,e=500){let i=t.position.clone().setFromMatrixPosition(t.matrixWorld);return this.context.setCameraPosition(i,e)}getElementDeviceCoordinate(t){let e=t.position.clone(),{clientWidth:i,clientHeight:n}=this.container;return x(e,this.context.camera,i,n)}changeMapType(t,e=500){t==="2d"?this.context.setPolarAngle(0):this.context.setPolarAngle(1.2)}reduceMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i-t,this.context.control.target,e)}enlargeMap(t=.5,e=500){let i=this.context.camera.zoom;return this.context.setZoom(i+t,this.context.control.target,e)}registryEvent(){window.addEventListener("keydown",this.onKeydown),window.addEventListener("keyup",this.onKeyUp)}unRegistryEvent(){window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("keyup",this.onKeyUp)}configurePolarShortcutKeys(t){this.polarKeys=t}configureAzimuthalShortcutKeys(t){this.azimuthalKeys=t}rotateMap(t=.1){let e=this.context.control.getAzimuthalAngle();this.context.control.maxAzimuthAngle=e+t,this.context.control.minAzimuthAngle=e+t,this.context.control.update()}measureDistance(){return k(this,null,function*(){return this.cancelDistance(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgLine=new it(this.context);let i=this.svgLine.dispose.bind(this.svgLine);this.svgLine.dispose=function(){i(),e("cancel")},this.svgLine.addEventListener("distance",({distance:n})=>{t(n)})})})}cancelDistance(){this.svgLine&&(this.svgLine.dispose(),this.svgLine=void 0,this.context.control.enableRotate=!0)}measureArea(){return this.cancelArea(),new Promise((t,e)=>{this.changeMapType("2d",0),this.context.control.enableRotate=!1,this.svgPolygon=new nt(this.context);let i=this.svgPolygon.dispose.bind(this.svgPolygon);this.svgPolygon.dispose=function(){i(),e("cancel")},this.svgPolygon.addEventListener("area",({area:n})=>{t(n)})})}cancelArea(){this.svgPolygon&&(this.svgPolygon.dispose(),this.svgPolygon=void 0,this.context.control.enableRotate=!0)}dispose(){this.context.dispose(),wt(),Ct(),this.unRegistryEvent()}};})();
2
3
  //# sourceMappingURL=bmap.min.js.map