@aibee/crc-bmap 0.0.26 → 0.0.28

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,3 +1,3 @@
1
- "use strict";(()=>{var Wt=Object.defineProperty;var xt=Object.getOwnPropertySymbols;var Yt=Object.prototype.hasOwnProperty,Zt=Object.prototype.propertyIsEnumerable;var O=Math.pow,ft=(o,s,t)=>s in o?Wt(o,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[s]=t,Z=(o,s)=>{for(var t in s||(s={}))Yt.call(s,t)&&ft(o,t,s[t]);if(xt)for(var t of xt(s))Zt.call(s,t)&&ft(o,t,s[t]);return o};var u=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(o,{get:(s,t)=>(typeof require!="undefined"?require:s)[t]}):o)(function(o){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var r=(o,s,t)=>(ft(o,typeof s!="symbol"?s+"":s,t),t);var V=(o,s,t)=>new Promise((e,i)=>{var n=h=>{try{c(t.next(h))}catch(p){i(p)}},a=h=>{try{c(t.throw(h))}catch(p){i(p)}},c=h=>h.done?e(h.value):Promise.resolve(h.value).then(n,a);c((t=t.apply(o,s)).next())});var Xt=u("three");var z=class{constructor(){r(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(s){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),s()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(s){this.tasks.requestAnimation.delete(s),window.cancelAnimationFrame(s)}setTimeout(s,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),s()},t);return this.tasks.timeout.add(e),e}clearTimeout(s){this.tasks.timeout.delete(s),window.clearTimeout(s)}setInterval(s,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),s()},t);return this.tasks.interval.add(e),e}clearInterval(s){this.tasks.interval.delete(s),window.clearInterval(s)}dispose(){this.tasks.requestAnimation.forEach(s=>{window.cancelAnimationFrame(s)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(s=>{window.clearTimeout(s)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(s=>{window.clearInterval(s)}),this.tasks.interval.clear()}};var g=u("three"),Et=u("three/examples/jsm/controls/MapControls");function bt(){let o=new g.Scene;return o.background=new g.Color(16777215),o}function Pt(){let o=new g.WebGLRenderer({antialias:!0});return o.setClearColor(16777215),o.setPixelRatio(window.devicePixelRatio),o.shadowMap.enabled=!0,o.shadowMap.autoUpdate=!0,o.shadowMap.type=g.PCFSoftShadowMap,o}function wt(o,s){let t=new g.OrthographicCamera(-o/2,o/2,s/2,-s/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function Lt(){let o=new g.Group,s=new g.HemisphereLight(16777215,15658734,1);s.intensity=1,s.position.set(0,0,10),s.up.set(0,0,1),o.add(s);let t=new g.AmbientLight(16777215);return o.add(t),o}function Ct(o,s){let t=new Et.MapControls(o,s);return t.enableDamping=!1,t.maxPolarAngle=0,t.minPolarAngle=0,t}function Gt(o,s=[]){let t=new g.Shape(o.map(e=>new g.Vector2(...e)));return s.length&&s.forEach(e=>{var i=new g.Path(e.map(n=>new g.Vector2(...n)));t.holes.push(i)}),t}function Mt(o=16777215,s=1){let t=new g.DirectionalLight(o,s);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 A(o,s){var t;if(s&&o.children&&o.children.length&&o.children.forEach(e=>{A(e,s)}),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 Dt(o){return/[\u4E00-\u9FA5]+/g.test(o)}var k=u("three");var q=new Map;function qt(){let o=document.createElement("canvas");o.width=1024,o.height=64;let s=o.getContext("2d",{willReadFrequently:!0});return s.font="54px sans-serif",s.textBaseline="hanging",s.lineWidth=12,s.fillStyle="rgba(0,0,0,1)",s.strokeStyle="white",{canvas:o,ctx:s}}var vt,R;function Qt(){if(!vt){let{canvas:o,ctx:s}=qt();vt=o,R=s}}function ce(o){if(q.has(o))return q.get(o);Qt(),R.clearRect(0,0,1024,64);let s=Dt(o)?4:8;R.strokeText(o,2,s),R.fillText(o,2,s);let t=Math.ceil(R.measureText(o).width);t=t%2===0?t:t+1,t+=2;let e=R.getImageData(0,0,t,64),i=new k.DataTexture(Uint8Array.from(e.data),t,64,k.RGBAFormat);return i.flipY=!0,i.minFilter=k.LinearFilter,i.magFilter=k.LinearFilter,q.set(o,i),i}function St(){q.clear()}function Ft(){R=null,vt=null}var I=u("@turf/turf");function E(o,s,t,e){let i=o.clone().project(s),n=t/2,a=e/2,c=Math.round(i.x*n+n),h=Math.round(-i.y*a+a);return{x:c,y:h}}function yt(o){let s=(0,I.featureCollection)(o.map(e=>(0,I.point)(e)));return(0,I.center)(s).geometry.coordinates}function Q(o,s,t){return o.x>=s.x&&o.x<=t.x&&o.y>=s.y&&o.y<=t.y}function N(o,s){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 s.dispatchEvent({type:`change-${e}`,value:i}),a}})}function J(o,s){return Promise.race([o,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),s)})])}function tt(o){return document.createElementNS("http://www.w3.org/2000/svg",o)}function Ot(o,s){let t=tt("svg");return t.setAttribute("width",o),t.setAttribute("height",s),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function _(o="2",s){let t=tt("circle");return t.setAttribute("r",o),t.setAttribute("fill",s),t}function et(o){let s=tt("line");return s.setAttribute("stroke",o),s}function $(o,s){let t=tt("rect");return t.setAttribute("stroke",o),t.setAttribute("fill",s),t}function B(o,s,t){o.setAttribute("cx",`${s}`),o.setAttribute("cy",`${t}`)}function G(o,s,t){s&&(o.setAttribute("x1",`${s.x}`),o.setAttribute("y1",`${s.y}`)),t&&(o.setAttribute("x2",`${t.x}`),o.setAttribute("y2",`${t.y}`))}function M(o,s,t,e,i){o.setAttribute("x",`${s}`),o.setAttribute("y",`${t}`),o.setAttribute("width",`${e}`),o.setAttribute("height",`${i}`)}var x=u("three"),U=u("@tweenjs/tween.js");var It=u("three");var f=u("three");var At=u("lodash");var Nt={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},S=class extends f.Object3D{constructor(t,e){super();this.context=t;r(this,"geometry");r(this,"material");r(this,"mesh");r(this,"line");r(this,"options");if(this.options=N((0,At.merge)({},Nt,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),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.material.color=new f.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 f.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 f.Vector3,e=new f.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new f.Vector3(0,0,0);let t=new f.Box3,e=new f.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=Gt(this.options.geometry.cds[0],this.options.geometry.cds.slice(1));return new f.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initMaterial(){return new f.MeshStandardMaterial({color:this.options.fillColor,roughness:1,transparent:!0,opacity:this.options.fillOpacity,depthWrite:!0})}initLineMaterial(){return new f.LineBasicMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity,transparent:!0,depthWrite:!0})}initMesh(){return new f.Mesh(this.geometry,this.material)}createBorder(){let t=this.initLineMaterial(),e=new f.EdgesGeometry(this.geometry),i=new f.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(){A(this),this.clear()}};var C=u("three");var it=class extends C.Object3D{constructor(){super();r(this,"directionalLight");r(this,"plane");r(this,"basicOpacity",.39);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=Mt(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 C.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 C.PlaneGeometry(t,e),n=new C.ShadowMaterial({transparent:!0,opacity:0,side:C.DoubleSide}),a=new C.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(){A(this,!0)}};var Tt=u("three"),Rt=u("lodash");var H=u("three");var nt=class extends H.EventDispatcher{constructor(t){super();this.context=t;r(this,"div");r(this,"element");r(this,"position",new H.Vector3);r(this,"onUpdate",()=>{let t=this.getPosition(),{clientWidth:e,clientHeight:i}=this.context.container,{x:n,y:a}=E(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 H.Box3().setFromObject(this.element).getCenter(new H.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 Jt={text:"",level:1,collision_enable:!0,opacity:1,id:""},W=class extends Tt.Object3D{constructor(t,e){super();this.context=t;r(this,"textDiv");r(this,"img");r(this,"overlay");r(this,"options");r(this,"_changePosition",()=>{this.overlay.div.style.transform=`translate3d(-50%, ${this.options.icon?"-100%":"-50%"}, 0)`});this.options=N((0,Rt.merge)({},Jt,e),this),this.overlay=new nt(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 D=u("three");var rt=u("three");var kt=u("three");var K=class extends kt.Object3D{constructor(t){super();this.context=t}dispose(){A(this),this.clear()}};var ot=class extends K{constructor(t){super(t);r(this,"graphicMap",new Map)}getCenter(){return new rt.Box3().setFromObject(this).getCenter(new rt.Vector3)}createGraphic(t){let e=new S(this.context,t);return this.add(e),this.graphicMap.set(t.id,e),e}getGraphicByRaycaster(t){let e={distance:1e4,graphic:null,position:null},i=this.children.reduce((n,a)=>{if(a instanceof S){let c=a.raycast(t);if(c){let{distance:h}=c;if(h<n.distance)return{distance:n.distance,position:n.position,graphic:a}}return n}else return n},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};var st=class extends K{constructor(t){super(t);r(this,"pois",[]);r(this,"onUpdate",()=>{this.collisionDetection()});this.registryEvent()}clear(){return super.clear(),this.pois=[],this}createPoi(t){let e=new W(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())}removePoiById(t){let e=this.pois.find(i=>i.options.id===t);e&&this.removePoi(e)}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 W&&n.isContain(t,e))}collisionDetection(){let t=[];this.pois.forEach((e,i)=>{e.setVisible(!0);let{left:n,right:a,top:c,bottom:h}=e.getBox();if(i===0){t.push({left:n,right:a,top:c,bottom:h});return}let p=t.some(l=>{let y=a<l.left||n>l.right,v=c>l.bottom||h<l.top;return y||v});e.setVisible(p)})}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 w=u("three"),Bt=u("@mars3d/heatmap.js"),T=u("@turf/turf");var at=class extends w.Object3D{constructor(t){super();this.context=t;r(this,"heatmap");r(this,"div");r(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,Bt.create)(Z({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 w.PlaneGeometry(t,e),n=new w.Texture(this.div.firstChild);n.needsUpdate=!0;let a=new w.MeshBasicMaterial({transparent:!0,side:w.DoubleSide,map:n});a.needsUpdate=!0,this.plane=new w.Mesh(i,a),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new w.Matrix3().makeScale(1,-1).multiply(new w.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(a=>{let c=new w.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,T.featureCollection)(t.data.map(p=>(0,T.point)([p.x,p.y]))),i=(0,T.bbox)(e),n=i[2]-i[0],a=i[3]-i[1],c={x:i[0],y:i[3]},h=(0,T.center)(e);return{width:n,height:a,leftTop:c,center:h.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var ct=class extends D.Object3D{constructor(t){super();this.context=t;r(this,"graphicLayer");r(this,"poiLayer");r(this,"grounds",new Set);r(this,"shadow",new it);r(this,"heatmap");r(this,"groundUpper",new D.Object3D);this.graphicLayer=new ot(this.context),this.poiLayer=new st(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 D.Box3().setFromObject(this.groundUpper).getCenter(new D.Vector3)}addShadow(){let t=new D.Box3().setFromObject(this.groundUpper),e=t.getCenter(new D.Vector3),i=t.getSize(new D.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 at(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new D.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 ht=u("three");var F=class extends ht.EventDispatcher{constructor(t){super();this.context=t;r(this,"points",[]);r(this,"svg");r(this,"enable",!0);this.svg=Ot(`${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:h}=i.domElement,p=n/c*2-1,l=1-a/h*2;return new ht.Vector3(p,l,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return E(t,e,i.clientWidth,i.clientHeight)}dispose(){this.context.container.removeChild(this.svg),this.svg=null}};var pt=class extends F{constructor(t){super(t);this.context=t;r(this,"circles");r(this,"line");r(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);B(this.circles[0],t.x,t.y),G(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);B(this.circles[1],t.x,t.y),G(this.line,void 0,t)}});r(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",G(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});r(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});r(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];B(a,i,n),this.points.length||G(this.line,{x:i,y:n},{x:i,y:n}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[_(e.radius,e.fill),_(e.radius,e.fill)],this.line=et(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(O(i-t,2)+O(n-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var lt=class extends F{constructor(t){super(t);r(this,"circles",[]);r(this,"lines",[]);r(this,"isClose",!1);r(this,"onUpdate",()=>{this.points.length&&this.points.forEach((t,e)=>{let i=this.getSvgCoordinate(t);this.circles[e]&&B(this.circles[e],i.x,i.y),e!==0&&G(this.lines[e-1],void 0,i),this.lines[e]&&G(this.lines[e],i)})});r(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",G(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});r(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});r(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:h}}=this.context.config.svg;if(!this.isClose){let p=_(c,a);B(p,i,n),this.addCircle(p)}if(this.lines.length&&G(this.lastLine,void 0,{x:i,y:n}),!this.isClose){let p=et(h);G(p,{x:i,y:n},{x:i,y:n}),this.addLine(p)}}});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(O(t-n,2)+O(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 Vt=u("three");var Ht=class extends F{constructor(t){super(t);this.context=t;r(this,"rect");r(this,"cornerRect",[]);r(this,"centerRect",[]);r(this,"graphic");r(this,"onUpdate",()=>{if(this.graphic){let t=new Vt.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:n}}=this.context,{min:a,max:c}=t,h=E(a,e,i,n),p=E(c,e,i,n);M(this.rect,h.x,p.y,Math.abs(p.x-h.x),Math.abs(p.y-h.y));let{x:l,y}=h,{x:v,y:d}=p,m=5,P=[{x:l-m,y:d-m},{x:v-m,y:d-m},{x:l-m,y:y-m},{x:v-m,y:y-m}];for(let L=0;L<P.length;L++)M(this.cornerRect[L],P[L].x,P[L].y,m*2,m*2);let b=4,j=(l+v)/2,Y=(y+d)/2,X=[{x:j-b,y:d-b},{x:l-b,y:Y-b},{x:v-b,y:Y-b},{x:j-b,y:y-b}];for(let L=0;L<X.length;L++)M(this.centerRect[L],X[L].x,X[L].y,b*2,b*2)}else{M(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)M(this.cornerRect[t],0,0,0,0),M(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=$(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=$(e.stroke,"#ffffff"),this.centerRect[i]=$(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=[]}};var zt=u("three");var dt=class extends F{constructor(t){super(t);r(this,"startPoint");r(this,"endPoint");r(this,"rect");r(this,"frustum",new zt.Frustum);r(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});r(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});r(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});r(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=Z({},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);M(this.rect,i.x,i.y,n,a)}else M(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=$(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),M(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=E(this.startPoint,e,i,n),c=E(this.endPoint,e,i,n),h={x:Math.min(a.x,c.x),y:Math.min(a.y,c.y)},p={x:Math.max(a.x,c.x),y:Math.max(a.y,c.y)},l=this.searchMapInFrustum(h,p);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 S&&this.searchChildInFrustum(a,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:n,container:{clientWidth:a,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let d=t.getPosition();if(d){let m=E(d,n,a,c);return Q(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:p,max:l}=h,y=E(p,n,a,c),v=E(l,n,a,c);return!(!Q(y,e,i)||!Q(v,e,i))}dispose(){this.unRegistryEvent()}};var mt=class extends It.EventDispatcher{constructor(t){super();this.context=t;r(this,"_list",new Set);r(this,"boxSelection");r(this,"prevPanStatus");r(this,"prevRotateStatus");r(this,"onPointerDown",t=>{let{graphics:e}=this.context.getGraphicsByDeviceXy(t.offsetX,t.offsetY),i=new Set(e.map(a=>a.options.id));this.context.getPoisByDeviceXy(t.clientX,t.clientY).forEach(a=>{var c;if(!i.has(a.options.id)){let h=((c=this.context.currentFloor)==null?void 0:c.graphicLayer.graphicMap.get(a.options.id))||null;h&&(e.push(h),i.add(a.options.id))}}),t.ctrlKey||this._list.clear(),e.forEach(a=>this._list.add(a)),this.selectEnd()});r(this,"onKeyDown",t=>{t.key==="Control"&&(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)});r(this,"onKeyUp",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)});r(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new dt(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 $t=u("three");var ut=class extends $t.EventDispatcher{constructor(t){super();this.context=t;r(this,"curGraphics",new Set);r(this,"timer",new z);r(this,"graphicTimerMap",new Map);r(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()});r(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 gt=class extends x.EventDispatcher{constructor(t,e){super();this.container=t;this.config=e;r(this,"scene",bt());r(this,"renderer",Pt());r(this,"camera");r(this,"control");r(this,"lights",Lt());r(this,"timer",new z);r(this,"tweenGroup",new U.Group);r(this,"currentFloor");r(this,"selection");r(this,"hoverHelper");r(this,"basicRatio");r(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)});r(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})});r(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})});r(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})});r(this,"onPointerleave",()=>{this.dispatchEvent({type:"pointer-level"})});r(this,"onSelectionSelect",({graphics:t})=>{this.dispatchEvent({type:"select-graphic",graphics:t})});r(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 mt(this),this.hoverHelper=new ut(this),this.registryEvent()}init(){let{clientWidth:t,clientHeight:e}=this.container;this.camera=wt(t,e),this.renderer.setSize(t,e),this.control=Ct(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 x.Vector3(0,0,0),e=new x.Vector3(100,0,0)){let{clientWidth:i,clientHeight:n}=this.container,a=E(t,this.camera,i,n),c=E(e,this.camera,i,n);return Math.ceil(Math.sqrt(O(c.x-a.x,2)+O(c.y-a.y,2)))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof x.AmbientLight&&(e.color=new x.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 x.Vector2;i.x=t/this.container.clientWidth*2-1,i.y=e/this.container.clientHeight*-2+1;let n=new x.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 J(new Promise(i=>{let n={polar:this.control.getPolarAngle()},a={polar:t},c=new U.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 x.Vector3().subVectors(this.control.target,this.camera.position)}setZoom(t,e,i=500){return J(new Promise(n=>{let a={zoom:this.camera.zoom,target:this.control.target.clone()},c=this.getCameraLookAt(),h=new U.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(h),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,h]=e,{clientWidth:p,clientHeight:l}=this.container,y=new x.Box3().setFromObject(t),{max:v,min:d}=y,m=E(v,this.camera,p,l),P=E(d,this.camera,p,l),j=new x.Box2().setFromPoints([new x.Vector2(m.x,m.y),new x.Vector2(P.x,P.y)]).getSize(new x.Vector2),Y=(p-a-h)/j.x,X=(l-n-c)/j.y,L=Math.min(Y,X),_t=new x.Vector3((v.x+d.x)/2,(v.y+d.y)/2,v.z);return this.setZoom(L*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 J(new Promise(i=>{let n=this.camera.position.clone(),a=this.getCameraLookAt(),c=new U.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()),A(this.scene)}};var Kt=u("lodash"),te={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 Ut(o){return(0,Kt.merge)({},te,o)}var jt=class extends Xt.EventDispatcher{constructor(t,e={}){super();this.container=t;r(this,"config");r(this,"context");r(this,"polarKeys",[]);r(this,"azimuthalKeys",[]);r(this,"svgLine");r(this,"svgPolygon");r(this,"basicZoom",1);r(this,"floorDataMap",new Map);r(this,"buildingGroundMap",new Map);r(this,"currentBuildGround",null);r(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)});r(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=Ut(e),this.context=new gt(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,resource_type_list:h}){let{apiDomain:l,apiPath:{floorGraphic:y},apiInfo:v}=this.config,d=`${l}${y}?brand=${t}&project=${e}&phase=${i}&building=${n}&floor=${a}&ts=${c}&resource_type_list=${h}`;return yield fetch(d,v).then(P=>P.json()).then(P=>P.data).then(P=>((P||[]).map(b=>b.info=JSON.parse(b.info)),P||[]))})}getBuildingKey({brand:t,project:e,phase:i,building:n}){return`${t}-${e}-${i}-${n}`}loadBuildingGround(a){return V(this,arguments,function*({brand:t,project:e,phase:i,building:n}){let c=this.getBuildingKey({brand:t,project:e,phase:i,building:n});if(this.buildingGroundMap.get(c))return this.buildingGroundMap.get(c)||null;let{apiDomain:h,apiPath:{floorRange:p},apiInfo:l}=this.config,y=`${h}${p}?brand=${t}&project=${e}&phase=${i}&building=${n}`,v=yield fetch(y,l).then(d=>d.json()).then(d=>d.data).then(d=>{let m=(d||[])[0];return m&&(m.info=JSON.parse(m.info)),m});return this.buildingGroundMap.set(c,v),v})}getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){return`${t}-${e}-${i}-${n}-${a}-${c}-${h}`}load(p){return V(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){let l=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h});if(this.floorDataMap.get(l))return;let[y,v]=yield Promise.all([this.loadGraphics({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}),this.loadBuildingGround({brand:t,project:e,phase:i,building:n})]);if(v){let d=yt(v.info.geometry.cds[0]);y.forEach(m=>{if(m.info.geometry.type==="polygon")m.info.geometry.cds.map(P=>{Array.isArray(P)&&P.forEach(b=>{b[0]-=d[0],b[1]-=d[1]})});else{let[P,b]=m.info.geometry.cds;m.info.geometry.cds=[P-d[0],b-d[1]]}m.info.transformToBuildingGround=!0})}return this.config.useFloorCache||this.floorDataMap.clear(),this.floorDataMap.set(l,y),y})}createFloor(t){let e=new ct(this.context);if(!t.length)return{curFloor:e,graphics:[]};let n=t.filter(p=>p.info.group==="ground").map(p=>new S(this.context,p.info));e.addGrounds(n);let a=t.filter(p=>p.info.group!=="ground"),c=new Map,h=a.map(p=>{let l=e.addGraphic(p.info);return l.userData.data=p,c.set(p.legacy_id,l),l});return e.addShadow(),e.userData.legacyToGraphicMap=c,{curFloor:e,graphics:h}}switchFloor(p){return V(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){let l=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}),y=this.floorDataMap.get(l);if(y){let v=this.getBuildingKey({brand:t,project:e,phase:i,building:n});this.currentBuildGround=this.buildingGroundMap.get(v)||null;let d=this.createFloor(y);d?(this.context.switchFloor(d.curFloor),this.context.control.minZoom=0,this.context.control.maxZoom=1/0,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] ["+a+"] \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 S))||[]}createGraphicPoi(t,e){if(this.context.currentFloor){e.id===void 0&&(e.id=t.options.id);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 E(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 pt(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 lt(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)}getGraphicByNodeId(t){return this.context.currentFloor&&this.context.currentFloor.graphicLayer.graphicMap.get(t)||null}deleteGraphic(t){this.context.currentFloor&&(this.context.currentFloor.graphicLayer.remove(t),t.dispose(),this.context.currentFloor.graphicLayer.graphicMap.delete(t.options.id))}createGraphicByOptions(t){var e;if(!t.transformToBuildingGround&&this.currentBuildGround){let i=yt(this.currentBuildGround.info.geometry.cds[0]);if(t.geometry.type==="polygon")t.geometry.cds.map(n=>{Array.isArray(n)&&n.forEach(a=>{a[0]-=i[0],a[1]-=i[1]})});else{let[n,a]=t.geometry.cds;t.geometry.cds=[n-i[0],a-i[1]]}}return(e=this.context.currentFloor)==null?void 0:e.graphicLayer.createGraphic(t)}removePoiById(t){var e;return(e=this.context.currentFloor)==null?void 0:e.poiLayer.removePoiById(t)}getPois(){var t;return((t=this.context.currentFloor)==null?void 0:t.poiLayer.pois)||[]}clearPoi(){this.context.currentFloor&&(this.getPois().forEach(t=>t.dispose()),this.context.currentFloor.poiLayer.clear())}dispose(){this.context.dispose(),St(),Ft(),this.unRegistryEvent()}};})();
1
+ "use strict";(()=>{var Wt=Object.defineProperty;var xt=Object.getOwnPropertySymbols;var Yt=Object.prototype.hasOwnProperty,Zt=Object.prototype.propertyIsEnumerable;var O=Math.pow,ft=(o,s,t)=>s in o?Wt(o,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[s]=t,Z=(o,s)=>{for(var t in s||(s={}))Yt.call(s,t)&&ft(o,t,s[t]);if(xt)for(var t of xt(s))Zt.call(s,t)&&ft(o,t,s[t]);return o};var u=(o=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(o,{get:(s,t)=>(typeof require!="undefined"?require:s)[t]}):o)(function(o){if(typeof require!="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var r=(o,s,t)=>(ft(o,typeof s!="symbol"?s+"":s,t),t);var V=(o,s,t)=>new Promise((e,i)=>{var n=h=>{try{c(t.next(h))}catch(p){i(p)}},a=h=>{try{c(t.throw(h))}catch(p){i(p)}},c=h=>h.done?e(h.value):Promise.resolve(h.value).then(n,a);c((t=t.apply(o,s)).next())});var Xt=u("three");var z=class{constructor(){r(this,"tasks",{requestAnimation:new Set,timeout:new Set,interval:new Set})}requestAnimationFrame(s){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),s()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(s){this.tasks.requestAnimation.delete(s),window.cancelAnimationFrame(s)}setTimeout(s,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),s()},t);return this.tasks.timeout.add(e),e}clearTimeout(s){this.tasks.timeout.delete(s),window.clearTimeout(s)}setInterval(s,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),s()},t);return this.tasks.interval.add(e),e}clearInterval(s){this.tasks.interval.delete(s),window.clearInterval(s)}dispose(){this.tasks.requestAnimation.forEach(s=>{window.cancelAnimationFrame(s)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(s=>{window.clearTimeout(s)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(s=>{window.clearInterval(s)}),this.tasks.interval.clear()}};var g=u("three"),Et=u("three/examples/jsm/controls/MapControls");function bt(){let o=new g.Scene;return o.background=new g.Color(16777215),o}function Pt(){let o=new g.WebGLRenderer({antialias:!0});return o.setClearColor(16777215),o.setPixelRatio(window.devicePixelRatio),o.shadowMap.enabled=!0,o.shadowMap.autoUpdate=!0,o.shadowMap.type=g.PCFSoftShadowMap,o}function wt(o,s){let t=new g.OrthographicCamera(-o/2,o/2,s/2,-s/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function Lt(){let o=new g.Group,s=new g.HemisphereLight(16777215,15658734,1);s.intensity=1,s.position.set(0,0,10),s.up.set(0,0,1),o.add(s);let t=new g.AmbientLight(16777215);return o.add(t),o}function Ct(o,s){let t=new Et.MapControls(o,s);return t.enableDamping=!1,t.maxPolarAngle=0,t.minPolarAngle=0,t}function Gt(o,s=[]){let t=new g.Shape(o.map(e=>new g.Vector2(...e)));return s.length&&s.forEach(e=>{var i=new g.Path(e.map(n=>new g.Vector2(...n)));t.holes.push(i)}),t}function Mt(o=16777215,s=1){let t=new g.DirectionalLight(o,s);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 A(o,s){var t;if(s&&o.children&&o.children.length&&o.children.forEach(e=>{A(e,s)}),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 Dt(o){return/[\u4E00-\u9FA5]+/g.test(o)}var k=u("three");var q=new Map;function qt(){let o=document.createElement("canvas");o.width=1024,o.height=64;let s=o.getContext("2d",{willReadFrequently:!0});return s.font="54px sans-serif",s.textBaseline="hanging",s.lineWidth=12,s.fillStyle="rgba(0,0,0,1)",s.strokeStyle="white",{canvas:o,ctx:s}}var vt,R;function Qt(){if(!vt){let{canvas:o,ctx:s}=qt();vt=o,R=s}}function ce(o){if(q.has(o))return q.get(o);Qt(),R.clearRect(0,0,1024,64);let s=Dt(o)?4:8;R.strokeText(o,2,s),R.fillText(o,2,s);let t=Math.ceil(R.measureText(o).width);t=t%2===0?t:t+1,t+=2;let e=R.getImageData(0,0,t,64),i=new k.DataTexture(Uint8Array.from(e.data),t,64,k.RGBAFormat);return i.flipY=!0,i.minFilter=k.LinearFilter,i.magFilter=k.LinearFilter,q.set(o,i),i}function St(){q.clear()}function Ft(){R=null,vt=null}var I=u("@turf/turf");function E(o,s,t,e){let i=o.clone().project(s),n=t/2,a=e/2,c=Math.round(i.x*n+n),h=Math.round(-i.y*a+a);return{x:c,y:h}}function yt(o){let s=(0,I.featureCollection)(o.map(e=>(0,I.point)(e)));return(0,I.center)(s).geometry.coordinates}function Q(o,s,t){return o.x>=s.x&&o.x<=t.x&&o.y>=s.y&&o.y<=t.y}function N(o,s){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 s.dispatchEvent({type:`change-${e}`,value:i}),a}})}function J(o,s){return Promise.race([o,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),s)})])}function tt(o){return document.createElementNS("http://www.w3.org/2000/svg",o)}function Ot(o,s){let t=tt("svg");return t.setAttribute("width",o),t.setAttribute("height",s),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function _(o="2",s){let t=tt("circle");return t.setAttribute("r",o),t.setAttribute("fill",s),t}function et(o){let s=tt("line");return s.setAttribute("stroke",o),s}function $(o,s){let t=tt("rect");return t.setAttribute("stroke",o),t.setAttribute("fill",s),t}function B(o,s,t){o.setAttribute("cx",`${s}`),o.setAttribute("cy",`${t}`)}function G(o,s,t){s&&(o.setAttribute("x1",`${s.x}`),o.setAttribute("y1",`${s.y}`)),t&&(o.setAttribute("x2",`${t.x}`),o.setAttribute("y2",`${t.y}`))}function M(o,s,t,e,i){o.setAttribute("x",`${s}`),o.setAttribute("y",`${t}`),o.setAttribute("width",`${e}`),o.setAttribute("height",`${i}`)}var x=u("three"),U=u("@tweenjs/tween.js");var It=u("three");var f=u("three");var At=u("lodash");var Nt={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},S=class extends f.Object3D{constructor(t,e){super();this.context=t;r(this,"geometry");r(this,"material");r(this,"mesh");r(this,"line");r(this,"options");if(this.options=N((0,At.merge)({},Nt,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),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.material.color=new f.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 f.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 f.Vector3,e=new f.Box3;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new f.Vector3(0,0,0);let t=new f.Box3,e=new f.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=Gt(this.options.geometry.cds[0],this.options.geometry.cds.slice(1));return new f.ExtrudeGeometry(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initMaterial(){return new f.MeshStandardMaterial({color:this.options.fillColor,roughness:1,transparent:!0,opacity:this.options.fillOpacity,depthWrite:!0})}initLineMaterial(){return new f.LineBasicMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity,transparent:!0,depthWrite:!0})}initMesh(){return new f.Mesh(this.geometry,this.material)}createBorder(){let t=this.initLineMaterial(),e=new f.EdgesGeometry(this.geometry),i=new f.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(){A(this),this.clear()}};var C=u("three");var it=class extends C.Object3D{constructor(){super();r(this,"directionalLight");r(this,"plane");r(this,"basicOpacity",.39);this.directionalLight=this.initLight(),this.initPlane()}initLight(){let t=Mt(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 C.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 C.PlaneGeometry(t,e),n=new C.ShadowMaterial({transparent:!0,opacity:0,side:C.DoubleSide}),a=new C.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(){A(this,!0)}};var Tt=u("three"),Rt=u("lodash");var H=u("three");var nt=class extends H.EventDispatcher{constructor(t){super();this.context=t;r(this,"div");r(this,"element");r(this,"position",new H.Vector3);r(this,"onUpdate",()=>{let t=this.getPosition(),{clientWidth:e,clientHeight:i}=this.context.container,{x:n,y:a}=E(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 H.Box3().setFromObject(this.element).getCenter(new H.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 Jt={text:"",level:1,collision_enable:!0,opacity:1,id:""},W=class extends Tt.Object3D{constructor(t,e){super();this.context=t;r(this,"textDiv");r(this,"img");r(this,"overlay");r(this,"options");r(this,"_changePosition",()=>{this.overlay.div.style.transform=`translate3d(-50%, ${this.options.icon?"-100%":"-50%"}, 0)`});this.options=N((0,Rt.merge)({},Jt,e),this),this.overlay=new nt(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",this.overlay.setOpacity(this.options.opacity),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 D=u("three");var rt=u("three");var kt=u("three");var K=class extends kt.Object3D{constructor(t){super();this.context=t}dispose(){A(this),this.clear()}};var ot=class extends K{constructor(t){super(t);r(this,"graphicMap",new Map)}getCenter(){return new rt.Box3().setFromObject(this).getCenter(new rt.Vector3)}createGraphic(t){let e=new S(this.context,t);return this.add(e),this.graphicMap.set(t.id,e),e}getGraphicByRaycaster(t){let e={distance:1e4,graphic:null,position:null},i=this.children.reduce((n,a)=>{if(a instanceof S){let c=a.raycast(t);if(c){let{distance:h}=c;if(h<n.distance)return{distance:n.distance,position:n.position,graphic:a}}return n}else return n},e);return i===e?{graphics:[],position:null}:{graphics:[i.graphic],position:i.position}}};var st=class extends K{constructor(t){super(t);r(this,"pois",[]);r(this,"onUpdate",()=>{this.collisionDetection()});this.registryEvent()}clear(){return super.clear(),this.pois=[],this}createPoi(t){let e=new W(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())}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===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 W&&n.isContain(t,e))}collisionDetection(){let t=[];this.pois.forEach((e,i)=>{e.setVisible(!0);let{left:n,right:a,top:c,bottom:h}=e.getBox();if(i===0){t.push({left:n,right:a,top:c,bottom:h});return}let p=t.some(l=>{let y=a<l.left||n>l.right,v=c>l.bottom||h<l.top;return y||v});e.setVisible(p)})}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 w=u("three"),Bt=u("@mars3d/heatmap.js"),T=u("@turf/turf");var at=class extends w.Object3D{constructor(t){super();this.context=t;r(this,"heatmap");r(this,"div");r(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,Bt.create)(Z({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 w.PlaneGeometry(t,e),n=new w.Texture(this.div.firstChild);n.needsUpdate=!0;let a=new w.MeshBasicMaterial({transparent:!0,side:w.DoubleSide,map:n});a.needsUpdate=!0,this.plane=new w.Mesh(i,a),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new w.Matrix3().makeScale(1,-1).multiply(new w.Matrix3().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(a=>{let c=new w.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,T.featureCollection)(t.data.map(p=>(0,T.point)([p.x,p.y]))),i=(0,T.bbox)(e),n=i[2]-i[0],a=i[3]-i[1],c={x:i[0],y:i[3]},h=(0,T.center)(e);return{width:n,height:a,leftTop:c,center:h.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};var ct=class extends D.Object3D{constructor(t){super();this.context=t;r(this,"graphicLayer");r(this,"poiLayer");r(this,"grounds",new Set);r(this,"shadow",new it);r(this,"heatmap");r(this,"groundUpper",new D.Object3D);this.graphicLayer=new ot(this.context),this.poiLayer=new st(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 D.Box3().setFromObject(this.groundUpper).getCenter(new D.Vector3)}addShadow(){let t=new D.Box3().setFromObject(this.groundUpper),e=t.getCenter(new D.Vector3),i=t.getSize(new D.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 at(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new D.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 ht=u("three");var F=class extends ht.EventDispatcher{constructor(t){super();this.context=t;r(this,"points",[]);r(this,"svg");r(this,"enable",!0);this.svg=Ot(`${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:h}=i.domElement,p=n/c*2-1,l=1-a/h*2;return new ht.Vector3(p,l,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return E(t,e,i.clientWidth,i.clientHeight)}dispose(){this.context.container.removeChild(this.svg),this.svg=null}};var pt=class extends F{constructor(t){super(t);this.context=t;r(this,"circles");r(this,"line");r(this,"onUpdate",()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);B(this.circles[0],t.x,t.y),G(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);B(this.circles[1],t.x,t.y),G(this.line,void 0,t)}});r(this,"onPointermove",t=>{this.points.length===1&&(this.line.style.display="block",G(this.line,void 0,{x:t.offsetX,y:t.offsetY}))});r(this,"onPointerleave",()=>{this.points[1]||(this.line.style.display="none")});r(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];B(a,i,n),this.points.length||G(this.line,{x:i,y:n},{x:i,y:n}),this.addPoint(e)}});let{config:{svg:{circle:e,line:i}}}=t;this.circles=[_(e.radius,e.fill),_(e.radius,e.fill)],this.line=et(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(O(i-t,2)+O(n-e,2))}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var lt=class extends F{constructor(t){super(t);r(this,"circles",[]);r(this,"lines",[]);r(this,"isClose",!1);r(this,"onUpdate",()=>{this.points.length&&this.points.forEach((t,e)=>{let i=this.getSvgCoordinate(t);this.circles[e]&&B(this.circles[e],i.x,i.y),e!==0&&G(this.lines[e-1],void 0,i),this.lines[e]&&G(this.lines[e],i)})});r(this,"onPointermove",t=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",G(this.lastLine,void 0,{x:t.offsetX,y:t.offsetY}))});r(this,"onPointerleave",()=>{this.isClose||(this.lastLine.style.display="none")});r(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:h}}=this.context.config.svg;if(!this.isClose){let p=_(c,a);B(p,i,n),this.addCircle(p)}if(this.lines.length&&G(this.lastLine,void 0,{x:i,y:n}),!this.isClose){let p=et(h);G(p,{x:i,y:n},{x:i,y:n}),this.addLine(p)}}});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(O(t-n,2)+O(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 Vt=u("three");var Ht=class extends F{constructor(t){super(t);this.context=t;r(this,"rect");r(this,"cornerRect",[]);r(this,"centerRect",[]);r(this,"graphic");r(this,"onUpdate",()=>{if(this.graphic){let t=new Vt.Box3().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:n}}=this.context,{min:a,max:c}=t,h=E(a,e,i,n),p=E(c,e,i,n);M(this.rect,h.x,p.y,Math.abs(p.x-h.x),Math.abs(p.y-h.y));let{x:l,y}=h,{x:v,y:d}=p,m=5,P=[{x:l-m,y:d-m},{x:v-m,y:d-m},{x:l-m,y:y-m},{x:v-m,y:y-m}];for(let L=0;L<P.length;L++)M(this.cornerRect[L],P[L].x,P[L].y,m*2,m*2);let b=4,j=(l+v)/2,Y=(y+d)/2,X=[{x:j-b,y:d-b},{x:l-b,y:Y-b},{x:v-b,y:Y-b},{x:j-b,y:y-b}];for(let L=0;L<X.length;L++)M(this.centerRect[L],X[L].x,X[L].y,b*2,b*2)}else{M(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)M(this.cornerRect[t],0,0,0,0),M(this.centerRect[t],0,0,0,0)}});let{config:{svg:{line:e}}}=t;this.rect=$(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=$(e.stroke,"#ffffff"),this.centerRect[i]=$(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=[]}};var zt=u("three");var dt=class extends F{constructor(t){super(t);r(this,"startPoint");r(this,"endPoint");r(this,"rect");r(this,"frustum",new zt.Frustum);r(this,"onPointerDown",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.startPoint=e),this.endPoint=void 0});r(this,"onPointerMove",t=>{if(!this.enable||!this.startPoint)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e)});r(this,"onPointerUp",t=>{if(!this.enable)return;let e=this.getIntersectByPointerEvent(t);e&&(this.endPoint=e),this.doSelect(),this.startPoint=void 0});r(this,"onUpdate",()=>{if(this.startPoint){let t=this.getSvgCoordinate(this.startPoint),e=Z({},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);M(this.rect,i.x,i.y,n,a)}else M(this.rect,0,0,0,0)});let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=$(i,e),this.svg.appendChild(this.rect),this.registryEvent()}setEnable(t){super.setEnable(t),M(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:n}}}=this,a=E(this.startPoint,e,i,n),c=E(this.endPoint,e,i,n),h={x:Math.min(a.x,c.x),y:Math.min(a.y,c.y)},p={x:Math.max(a.x,c.x),y:Math.max(a.y,c.y)},l=this.searchMapInFrustum(h,p);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 S&&this.searchChildInFrustum(a,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:n,container:{clientWidth:a,clientHeight:c}}}=this;if(!t)return!1;if(!t.mesh){let d=t.getPosition();if(d){let m=E(d,n,a,c);return Q(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:p,max:l}=h,y=E(p,n,a,c),v=E(l,n,a,c);return!(!Q(y,e,i)||!Q(v,e,i))}dispose(){this.unRegistryEvent()}};var mt=class extends It.EventDispatcher{constructor(t){super();this.context=t;r(this,"_list",new Set);r(this,"boxSelection");r(this,"prevPanStatus");r(this,"prevRotateStatus");r(this,"onPointerDown",t=>{let{graphics:e}=this.context.getGraphicsByDeviceXy(t.offsetX,t.offsetY),i=new Set(e.map(a=>a.options.id));this.context.getPoisByDeviceXy(t.clientX,t.clientY).forEach(a=>{var c;if(!i.has(a.options.id)){let h=((c=this.context.currentFloor)==null?void 0:c.graphicLayer.graphicMap.get(a.options.id))||null;h&&(e.push(h),i.add(a.options.id))}}),t.ctrlKey||this._list.clear(),e.forEach(a=>this._list.add(a)),this.selectEnd()});r(this,"onKeyDown",t=>{t.key==="Control"&&(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)});r(this,"onKeyUp",t=>{t.key==="Control"&&(this.boxSelection.setEnable(!1),this.context.control.enablePan=!!this.prevPanStatus,this.context.control.enableRotate=!!this.prevRotateStatus)});r(this,"onBoxSelected",({list:t})=>{this._list.clear(),t.forEach(e=>{this._list.add(e)}),this.selectEnd()});this.boxSelection=new dt(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 $t=u("three");var ut=class extends $t.EventDispatcher{constructor(t){super();this.context=t;r(this,"curGraphics",new Set);r(this,"timer",new z);r(this,"graphicTimerMap",new Map);r(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()});r(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 gt=class extends x.EventDispatcher{constructor(t,e){super();this.container=t;this.config=e;r(this,"scene",bt());r(this,"renderer",Pt());r(this,"camera");r(this,"control");r(this,"lights",Lt());r(this,"timer",new z);r(this,"tweenGroup",new U.Group);r(this,"currentFloor");r(this,"selection");r(this,"hoverHelper");r(this,"basicRatio");r(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)});r(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})});r(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})});r(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})});r(this,"onPointerleave",()=>{this.dispatchEvent({type:"pointer-level"})});r(this,"onSelectionSelect",({graphics:t})=>{this.dispatchEvent({type:"select-graphic",graphics:t})});r(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 mt(this),this.hoverHelper=new ut(this),this.registryEvent()}init(){let{clientWidth:t,clientHeight:e}=this.container;this.camera=wt(t,e),this.renderer.setSize(t,e),this.control=Ct(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 x.Vector3(0,0,0),e=new x.Vector3(100,0,0)){let{clientWidth:i,clientHeight:n}=this.container,a=E(t,this.camera,i,n),c=E(e,this.camera,i,n);return Math.ceil(Math.sqrt(O(c.x-a.x,2)+O(c.y-a.y,2)))}changeAmbientLightColor(t){this.lights.children.forEach(e=>{e instanceof x.AmbientLight&&(e.color=new x.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 x.Vector2;i.x=t/this.container.clientWidth*2-1,i.y=e/this.container.clientHeight*-2+1;let n=new x.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 J(new Promise(i=>{let n={polar:this.control.getPolarAngle()},a={polar:t},c=new U.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 x.Vector3().subVectors(this.control.target,this.camera.position)}setZoom(t,e,i=500){return J(new Promise(n=>{let a={zoom:this.camera.zoom,target:this.control.target.clone()},c=this.getCameraLookAt(),h=new U.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(h),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,h]=e,{clientWidth:p,clientHeight:l}=this.container,y=new x.Box3().setFromObject(t),{max:v,min:d}=y,m=E(v,this.camera,p,l),P=E(d,this.camera,p,l),j=new x.Box2().setFromPoints([new x.Vector2(m.x,m.y),new x.Vector2(P.x,P.y)]).getSize(new x.Vector2),Y=(p-a-h)/j.x,X=(l-n-c)/j.y,L=Math.min(Y,X),_t=new x.Vector3((v.x+d.x)/2,(v.y+d.y)/2,v.z);return this.setZoom(L*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 J(new Promise(i=>{let n=this.camera.position.clone(),a=this.getCameraLookAt(),c=new U.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()),A(this.scene)}};var Kt=u("lodash"),te={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 Ut(o){return(0,Kt.merge)({},te,o)}var jt=class extends Xt.EventDispatcher{constructor(t,e={}){super();this.container=t;r(this,"config");r(this,"context");r(this,"polarKeys",[]);r(this,"azimuthalKeys",[]);r(this,"svgLine");r(this,"svgPolygon");r(this,"basicZoom",1);r(this,"floorDataMap",new Map);r(this,"buildingGroundMap",new Map);r(this,"currentBuildGround",null);r(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)});r(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=Ut(e),this.context=new gt(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,resource_type_list:h}){let{apiDomain:l,apiPath:{floorGraphic:y},apiInfo:v}=this.config,d=`${l}${y}?brand=${t}&project=${e}&phase=${i}&building=${n}&floor=${a}&ts=${c}&resource_type_list=${h}`;return yield fetch(d,v).then(P=>P.json()).then(P=>P.data).then(P=>((P||[]).map(b=>b.info=JSON.parse(b.info)),P||[]))})}getBuildingKey({brand:t,project:e,phase:i,building:n}){return`${t}-${e}-${i}-${n}`}loadBuildingGround(a){return V(this,arguments,function*({brand:t,project:e,phase:i,building:n}){let c=this.getBuildingKey({brand:t,project:e,phase:i,building:n});if(this.buildingGroundMap.get(c))return this.buildingGroundMap.get(c)||null;let{apiDomain:h,apiPath:{floorRange:p},apiInfo:l}=this.config,y=`${h}${p}?brand=${t}&project=${e}&phase=${i}&building=${n}`,v=yield fetch(y,l).then(d=>d.json()).then(d=>d.data).then(d=>{let m=(d||[])[0];return m&&(m.info=JSON.parse(m.info)),m});return this.buildingGroundMap.set(c,v),v})}getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){return`${t}-${e}-${i}-${n}-${a}-${c}-${h}`}load(p){return V(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){let l=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h});if(this.floorDataMap.get(l))return;let[y,v]=yield Promise.all([this.loadGraphics({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}),this.loadBuildingGround({brand:t,project:e,phase:i,building:n})]);if(v){let d=yt(v.info.geometry.cds[0]);y.forEach(m=>{if(m.info.geometry.type==="polygon")m.info.geometry.cds.map(P=>{Array.isArray(P)&&P.forEach(b=>{b[0]-=d[0],b[1]-=d[1]})});else{let[P,b]=m.info.geometry.cds;m.info.geometry.cds=[P-d[0],b-d[1]]}m.info.transformToBuildingGround=!0})}return this.config.useFloorCache||this.floorDataMap.clear(),this.floorDataMap.set(l,y),y})}createFloor(t){let e=new ct(this.context);if(!t.length)return{curFloor:e,graphics:[]};let n=t.filter(p=>p.info.group==="ground").map(p=>new S(this.context,p.info));e.addGrounds(n);let a=t.filter(p=>p.info.group!=="ground"),c=new Map,h=a.map(p=>{let l=e.addGraphic(p.info);return l.userData.data=p,c.set(p.legacy_id,l),l});return e.addShadow(),e.userData.legacyToGraphicMap=c,{curFloor:e,graphics:h}}switchFloor(p){return V(this,arguments,function*({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}){let l=this.getFloorKey({brand:t,project:e,phase:i,building:n,floor:a,ts:c,resource_type_list:h}),y=this.floorDataMap.get(l);if(y){let v=this.getBuildingKey({brand:t,project:e,phase:i,building:n});this.currentBuildGround=this.buildingGroundMap.get(v)||null;let d=this.createFloor(y);d?(this.context.switchFloor(d.curFloor),this.context.control.minZoom=0,this.context.control.maxZoom=1/0,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] ["+a+"] \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 S))||[]}createGraphicPoi(t,e){if(this.context.currentFloor){e.id===void 0&&(e.id=t.options.id);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 E(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 pt(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 lt(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)}getGraphicByNodeId(t){return this.context.currentFloor&&this.context.currentFloor.graphicLayer.graphicMap.get(t)||null}deleteGraphic(t){this.context.currentFloor&&(this.context.currentFloor.graphicLayer.remove(t),t.dispose(),this.context.currentFloor.graphicLayer.graphicMap.delete(t.options.id))}createGraphicByOptions(t){var e;if(!t.transformToBuildingGround&&this.currentBuildGround){let i=yt(this.currentBuildGround.info.geometry.cds[0]);if(t.geometry.type==="polygon")t.geometry.cds.map(n=>{Array.isArray(n)&&n.forEach(a=>{a[0]-=i[0],a[1]-=i[1]})});else{let[n,a]=t.geometry.cds;t.geometry.cds=[n-i[0],a-i[1]]}}return(e=this.context.currentFloor)==null?void 0:e.graphicLayer.createGraphic(t)}removePoiById(t){var e;return(e=this.context.currentFloor)==null?void 0:e.poiLayer.removePoiById(t)}getPoiById(t){var e;return(e=this.context.currentFloor)==null?void 0:e.poiLayer.getPoiById(t)}getPois(){var t;return((t=this.context.currentFloor)==null?void 0:t.poiLayer.pois)||[]}clearPoi(){this.context.currentFloor&&(this.getPois().forEach(t=>t.dispose()),this.context.currentFloor.poiLayer.clear())}dispose(){this.context.dispose(),St(),Ft(),this.unRegistryEvent()}};})();
3
3
  //# sourceMappingURL=bmap.min.js.map