@aibee/crc-bmap 0.0.137 → 0.0.139
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.cjs.min.js +1 -1
- package/lib/bmap.cjs.min.js.map +2 -2
- package/lib/bmap.esm.js +1 -1
- package/lib/bmap.esm.js.map +1 -1
- package/lib/bmap.esm.min.js +1 -1
- package/lib/bmap.esm.min.js.map +2 -2
- package/lib/bmap.min.js +1 -1
- package/lib/bmap.min.js.map +2 -2
- package/package.json +1 -1
package/lib/bmap.esm.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var pi=Object.create;var Pe=Object.defineProperty;var fi=Object.getOwnPropertyDescriptor;var di=Object.getOwnPropertyNames;var gi=Object.getPrototypeOf,mi=Object.prototype.hasOwnProperty;var nt=(o,n)=>()=>(n||o((n={exports:{}}).exports,n),n.exports);var yi=(o,n,t,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of di(n))!mi.call(o,i)&&i!==t&&Pe(o,i,{get:()=>n[i],enumerable:!(e=fi(n,i))||e.enumerable});return o};var ce=(o,n,t)=>(t=o!=null?pi(gi(o)):{},yi(n||!o||!o.__esModule?Pe(t,"default",{value:o,enumerable:!0}):t,o));var Ze=nt((qs,$e)=>{$e.exports=function(n,t){return n[0]=t[0],n[1]=t[1],n}});var Qe=nt((js,Je)=>{var Ke=Ze();Je.exports=function(o,n){Array.isArray(n)||(n=[]),o.length>0&&n.push(Ke([0,0],o[0]));for(var t=0;t<o.length-1;t++){var e=o[t],i=o[t+1],r=e[0],s=e[1],l=i[0],u=i[1],a=[.75*r+.25*l,.75*s+.25*u],c=[.25*r+.75*l,.25*s+.75*u];n.push(a),n.push(c)}return o.length>1&&n.push(Ke([0,0],o[o.length-1])),n}});var an=nt((Js,sn)=>{var ge=class{constructor(){this.keys=new Set,this.queue=[]}sort(){this.queue.sort((n,t)=>n.priority-t.priority)}set(n,t){let e=Number(t);if(isNaN(e))throw new TypeError('"priority" must be a number');return this.keys.has(n)?this.queue.map(i=>(i.key===n&&Object.assign(i,{priority:e}),i)):(this.keys.add(n),this.queue.push({key:n,priority:e})),this.sort(),this.queue.length}next(){let n=this.queue.shift();return this.keys.delete(n.key),n}isEmpty(){return this.queue.length===0}has(n){return this.keys.has(n)}get(n){return this.queue.find(t=>t.key===n)}};sn.exports=ge});var cn=nt((Qs,un)=>{function ln(o,n){let t=new Map;for(let[e,i]of o)e!==n&&i instanceof Map?t.set(e,ln(i,n)):e!==n&&t.set(e,i);return t}un.exports=ln});var fn=nt((ta,pn)=>{function Xi(o){let n=Number(o);return!(isNaN(n)||n<=0)}function hn(o){let n=new Map;return Object.keys(o).forEach(e=>{let i=o[e];if(i!==null&&typeof i=="object"&&!Array.isArray(i))return n.set(e,hn(i));if(!Xi(i))throw new Error(`Could not add node at key "${e}", make sure it's a valid node`,i);return n.set(e,Number(i))}),n}pn.exports=hn});var mn=nt((ea,gn)=>{function dn(o){if(!(o instanceof Map))throw new Error(`Invalid graph: Expected Map instead found ${typeof o}`);o.forEach((n,t)=>{if(typeof n=="object"&&n instanceof Map){dn(n);return}if(typeof n!="number"||n<=0)throw new Error(`Values must be numbers greater than 0. Found value ${n} at ${t}`)})}gn.exports=dn});var ye=nt((na,vn)=>{var qi=an(),ji=cn(),yn=fn(),_n=mn(),me=class{constructor(n){n instanceof Map?(_n(n),this.graph=n):n?this.graph=yn(n):this.graph=new Map}addNode(n,t){let e;return t instanceof Map?(_n(t),e=t):e=yn(t),this.graph.set(n,e),this}addVertex(n,t){return this.addNode(n,t)}removeNode(n){return this.graph=ji(this.graph,n),this}path(n,t,e={}){if(!this.graph.size)return e.cost?{path:null,cost:0}:null;let i=new Set,r=new qi,s=new Map,l=[],u=0,a=[];if(e.avoid&&(a=[].concat(e.avoid)),a.includes(n))throw new Error(`Starting node (${n}) cannot be avoided`);if(a.includes(t))throw new Error(`Ending node (${t}) cannot be avoided`);for(r.set(n,0);!r.isEmpty();){let c=r.next();if(c.key===t){u=c.priority;let f=c.key;for(;s.has(f);)l.push(f),f=s.get(f);break}i.add(c.key),(this.graph.get(c.key)||new Map).forEach((f,m)=>{if(i.has(m)||a.includes(m))return null;if(!r.has(m))return s.set(m,c.key),r.set(m,c.priority+f);let h=r.get(m).priority,d=c.priority+f;return d<h?(s.set(m,c.key),r.set(m,d)):null})}return l.length?(e.trim?l.shift():l=l.concat([n]),e.reverse||(l=l.reverse()),e.cost?{path:l,cost:u}:l):e.cost?{path:null,cost:0}:null}shortestPath(...n){return this.path(...n)}};vn.exports=me});import{EventDispatcher as Bo,Vector3 as Go}from"three";var R=class{tasks={requestAnimation:new Set,timeout:new Set,interval:new Set};requestAnimationFrame(n){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),n()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(n){this.tasks.requestAnimation.delete(n),window.cancelAnimationFrame(n)}setTimeout(n,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),n()},t);return this.tasks.timeout.add(e),e}clearTimeout(n){this.tasks.timeout.delete(n),window.clearTimeout(n)}setInterval(n,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),n()},t);return this.tasks.interval.add(e),e}clearInterval(n){this.tasks.interval.delete(n),window.clearInterval(n)}dispose(){this.tasks.requestAnimation.forEach(n=>{window.cancelAnimationFrame(n)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(n=>{window.clearTimeout(n)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(n=>{window.clearInterval(n)}),this.tasks.interval.clear()}};import{Scene as _i,WebGLRenderer as vi,OrthographicCamera as xi,Shape as Ei,PCFSoftShadowMap as bi,Group as Mi,Color as Si,DirectionalLight as wi,AmbientLight as Ti,Path as Ci,Vector2 as Le}from"three";import{MapControls as Pi}from"three/examples/jsm/controls/MapControls";function Ae(){let o=new _i;return o.background=new Si(16777215),o}function Re(){let o=new vi({antialias:!0});return o.autoClear=!0,o.setClearAlpha(1),o.setClearColor(16777215),o.setPixelRatio(window.devicePixelRatio),o.shadowMap.enabled=!0,o.shadowMap.autoUpdate=!0,o.shadowMap.type=bi,o}function Ie(o,n){let t=new xi(-o/2,o/2,n/2,-n/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function Ne(){let o=new Mi,n=new Ti(16777215,2.6);return o.add(n),o}function De(o,n){let t=new Pi(o,n);return t.enableDamping=!1,t.zoomSpeed=1.5,t}function z(o,n=[]){let t=new Ei(o.map(e=>new Le(...e)));return n.length&&n.forEach(e=>{var i=new Ci(e.map(r=>new Le(...r)));t.holes.push(i)}),t}function Oe(o=16777215,n=1){let t=new wi(o,n);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 D(o,n){if(n&&o.children&&o.children.length&&o.children.forEach(t=>{D(t,n)}),o.isMesh){let t=o;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(e=>{e.dispose()}):t.material.dispose())}o.isLight&&o.dispose?.()}function Fe(o){return/[\u4E00-\u9FA5]+/g.test(o)}import{DataTexture as Li,RGBAFormat as Ue,LinearFilter as bt,TextureLoader as Ai}from"three";var lt=new Map,gt=new Map,Ri=new Ai;function Ii(){let o=document.createElement("canvas");o.width=1024,o.height=64;let n=o.getContext("2d",{willReadFrequently:!0});return n.font="54px sans-serif",n.textBaseline="hanging",n.lineWidth=12,n.fillStyle="rgba(0,0,0,1)",n.strokeStyle="white",{canvas:o,ctx:n}}var he,it;function Ni(){if(!he){let{canvas:o,ctx:n}=Ii();he=o,it=n}}function Be(o){if(gt.has(o))return gt.get(o);Ni(),it.clearRect(0,0,1024,64);let n=Fe(o)?4:8;it.strokeText(o,2,n),it.fillText(o,2,n);let t=Math.ceil(it.measureText(o).width);t=t%2===0?t:t+1,t+=2;let e=it.getImageData(0,0,t,64),i=new Li(Uint8Array.from(e.data),t,64,Ue);return i.flipY=!0,i.minFilter=bt,i.magFilter=bt,gt.set(o,i),i}function Ge(){gt.forEach((o,n)=>{o.dispose()}),lt.forEach(o=>{o instanceof Promise?o.then(n=>n.dispose()):o.dispose()}),gt.clear(),lt.clear()}function ze(){it=null,he=null}async function ke(o){if(lt.has(o))return lt.get(o);let n=Ri.loadAsync(o);return n.then(t=>{t.format=Ue,t.magFilter=bt,t.minFilter=bt,t.colorSpace="srgb",lt.set(o,t)}),lt.set(o,n),n}import{Vector3 as pe,Vector2 as Y,Matrix3 as Mt}from"three";import{point as Di,featureCollection as Oi,center as Fi}from"@turf/turf";function v(o,n,t,e){let i=o.clone().project(n),r=t/2,s=e/2,l=Math.round(i.x*r+r),u=Math.round(-i.y*s+s);return{x:l,y:u}}function St(o){let n=Oi(o.map(e=>Di(e)));return Fi(n).geometry.coordinates}function wt(o,n,t){return o.x>=n.x&&o.x<=t.x&&o.y>=n.y&&o.y<=t.y}function Ss(o){let n=0,t=new pe;for(let e=1;e<o.length;e++){let i=new pe(o[e-1][0],o[e-1][1],0),r=new pe(o[e][0],o[e][1],0),s=r.distanceTo(i);s>n&&(n=s,t=r.clone().sub(i).normalize())}return t}function S(o,n){return Math.sqrt((n[0]-o[0])**2+(n[1]-o[1])**2)}function J(o){let n=0;for(let t=0;t<o.length-1;t++)n+=S(o[t],o[t+1]);return n}function Tt(o,n,t){let e=new Y(n[0]-o[0],n[1]-o[1]),i=new Y(n[0]-t[0],n[1]-t[1]),s=e.angleTo(i)*180/Math.PI,l=new Y(n[0]-o[0],n[1]-o[1]);return new Y(t[0]-o[0],t[1]-o[1]).cross(l)>0?s:-s}function Ve(o,n){let t=Math.min(S(o[0][0],o[0][1]),S(o[0][2],o[0][1]))-1;n||(n=St(o[0]));let e=Ui(n,t),i=new Y(o[0][0][0],o[0][0][1]),r=new Y(o[0][1][0],o[0][1][1]),s=new Y(o[0][2][0],o[0][2][1]),u=(i.distanceTo(r)>r.distanceTo(s)?r.clone().sub(i):s.clone().sub(r)).angleTo(new Y(0,1)),a=new Mt;return a.multiply(new Mt().translate(n[0],n[1])).multiply(new Mt().rotate(u)).multiply(new Mt().translate(-n[0],-n[1])),[e.map(c=>{let p=new Y(c[0],c[1]).applyMatrix3(a);return[p.x,p.y]})]}function Ui(o,n){let t=n/2;return[[o[0]-t,o[1]+t],[o[0]+t,o[1]+t],[o[0]+t,o[1]-t],[o[0]-t,o[1]-t],[o[0]-t,o[1]+t]]}function He(o,n){let t=0,e=1/0,[i,r]=n;for(let s=0;s<o.length-1;s++){let[l,u]=o[s],[a,c]=o[s+1],p=Math.min(l,a)<=i&&i<=Math.max(l,a),f=Math.min(u,c)<=r&&r<=Math.max(u,c);if(p&&f){let m=Math.abs((a-l)*(r-u)-(c-u)*(i-l));m<e&&(e=m,t=s)}}return t}function We(o,n){let t=o[0],e=o[1],i=!1;for(let r=0,s=n.length-1;r<n.length;s=r++){let l=n[r][0],u=n[r][1],a=n[s][0],c=n[s][1];u>e!=c>e&&t<(a-l)*(e-u)/(c-u)+l&&(i=!i)}return i}function ut(o,n){return new Proxy(o,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,r)=>{let s=Reflect.get(t,e,r),l=Reflect.set(t,e,i,r);return s!==i&&n.dispatchEvent({type:`change-${e}`,value:i}),l}})}function rt(o,n){return Promise.race([o,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),n)})])}function Ct(o){return document.createElementNS("http://www.w3.org/2000/svg",o)}function Xe(o,n){let t=Ct("svg");return t.setAttribute("width",o),t.setAttribute("height",n),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function mt(o="2",n){let t=Ct("circle");return t.setAttribute("r",o),t.setAttribute("fill",n),t}function Pt(o){let n=Ct("line");return n.setAttribute("stroke",o),n}function ct(o,n){let t=Ct("rect");return t.setAttribute("stroke",o),t.setAttribute("fill",n),t}function ot(o,n,t){o.setAttribute("cx",`${n}`),o.setAttribute("cy",`${t}`)}function O(o,n,t){n&&(o.setAttribute("x1",`${n.x}`),o.setAttribute("y1",`${n.y}`)),t&&(o.setAttribute("x2",`${t.x}`),o.setAttribute("y2",`${t.y}`))}function F(o,n,t,e,i){o.setAttribute("x",`${n}`),o.setAttribute("y",`${t}`),o.setAttribute("width",`${e}`),o.setAttribute("height",`${i}`)}function qe(){return Promise.resolve()}function Ls(){return new Promise(o=>{requestAnimationFrame(o)})}function Rs(o){return parseInt(o.replace("#","0x"),16)}function Is(o,n){let t=parseInt(o.substring(1,3),16),e=parseInt(o.substring(3,5),16),i=parseInt(o.substring(5,7),16),r=Math.round(t*n),s=Math.round(e*n),l=Math.round(i*n);return`#${(1<<24|r<<16|s<<8|l).toString(16).slice(1)}`}function $(o,n=.85){let t,e,i;if(o.startsWith("#"))t=parseInt(o.substring(1,3),16),e=parseInt(o.substring(3,5),16),i=parseInt(o.substring(5,7),16);else{let s=o.slice(4,-1).split(",");t=parseInt(s[0].trim()),e=parseInt(s[1].trim()),i=parseInt(s[2].trim())}return t=Math.min(Math.floor(t*n),255),e=Math.min(Math.floor(e*n),255),i=Math.min(Math.floor(i*n),255),"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)}import{GLTFLoader as Bi}from"three/examples/jsm/loaders/GLTFLoader";function Gi(){return new Bi}var Lt=null,At=new Map;function Rt(o){if(At.has(o)){let t=At.get(o).then(e=>(e.scene=e.scene.clone(),e))}Lt||(Lt=Gi());let n=new Promise((t,e)=>{Lt.load(o,i=>{t(i)},void 0,e)});return At.set(o,n),n.then(t=>(t.scene=t.scene.clone(),t))}function je(){Lt=null,At.clear()}var It=navigator.userAgent.toUpperCase().indexOf("MAC")>=0;function fe(o){return It?o==="Meta":o==="Control"}var de="__once__",Ye=class{events=new Map;on(n,t){if(typeof t!="function")return;let e=this.events.get(n);return e?e.add(t):this.events.set(n,new Set([t]))}once(n,t){if(typeof t!="function")return;let e=`${de}${n}`,i=this.events.get(e);return i?i.add(t):this.events.set(e,new Set([t]))}off(n,t){let e=this.events.get(n),i=this.events.get(`${de}${n}`);!e&&!i||(t===void 0&&(e?.clear(),i?.clear()),e?.has(t)&&e.delete(t),i?.has(t)&&i.delete(t))}offAll(){this.events.clear()}emit(n,...t){let e=this.events.get(n),i=this.events.get(`${de}${n}`);!e&&!i||(e?.forEach(r=>{typeof r=="function"&&r(...t)}),i?.forEach(r=>{typeof r=="function"&&r(...t)}),i?.clear())}};var yt=(t=>(t.SWITCH_FLOOR_BEFORE="switch_floor_before",t.SWITCH_FLOOR_AFTER="switch_floor_after",t))(yt||{});function U(o){return Object.keys(o).sort().map(n=>`${n}=${o[n]}`).join("&")}function Hs(o,n){return new Promise((t,e)=>{let i=new XMLHttpRequest;i.open("GET",o,!0),Object.keys(n.headers||{}).forEach(r=>{i.setRequestHeader(r,n.headers[r])}),n.responseType&&(i.responseType=n.responseType),i.onload=()=>{if(i.status>=200&&i.status<300)if(n.responseType==="arraybuffer")t(i.response);else try{let r=JSON.parse(i.responseText);t(r)}catch(r){e(r)}else e(i.statusText)},i.onerror=()=>{e(i.statusText)},i.send()})}var ht=class o{keySet=new Set;static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}genUniqueKey(){let n=o.createKey();for(;this.keySet.has(n);)n=o.createKey();return n}removeKey(n){this.keySet.delete(n)}dispose(){this.keySet.clear()}};var tn=ce(Qe(),1);import{Vector2 as _t}from"three";function zi(o,n){let t=o.clone().normalize(),e=n.clone().normalize();return Math.acos(t.dot(e))}function ki(o){let n=0;return o.reduce(([t,e],[i,r])=>(n+=Math.sqrt((i-t)**2+(r-e)**2),[i,r])),n/o.length}function en(o,n=.25){if(ki(o)<n)return o;let t=(0,tn.default)(o);return en(t,n)}function nn(o,n=!1,t=!0,e=5,i=150,r=3){let s=[],l=!n;if(s.push(o[0]),o.length<2)return s;for(let a=0;a<o.length-2;a+=1){let c=o[a],p=o[a+1],f=o[a+2],m=new _t(c[0]-p[0],c[1]-p[1]),h=new _t(f[0]-p[0],f[1]-p[1]),d=zi(m,h)/Math.PI*180,g=m.length()+h.length();(!l||d<i&&g>.01||g>e)&&(s.push(o[a+1]),l=!0)}if(s.push(o[o.length-1]),!t)return s;let u=[];u.push(s[0]);for(let a=0;a<s.length-2;a+=1){let c=new _t(s[a][0],s[a][1]),p=new _t(s[a+1][0],s[a+1][1]),f=new _t(s[a+2][0],s[a+2][1]),m=c.distanceTo(p)/2,h=f.distanceTo(p)/2,d=p.clone(),g=p.clone();d.add(c.clone().sub(p).normalize().multiplyScalar(m>r?r/2:m)),g.add(f.clone().sub(p).normalize().multiplyScalar(h>r?r/2:h));let y=[[d.x,d.y],[p.x,p.y],[g.x,g.y]];u.push(...en(y,r/25))}return u.push(s[s.length-1]),Vi(u)}function Vi(o){if(o.length<=1)return o;let n=[],t;return o.forEach(([e,i])=>{t?e===t[0]&&i===t[1]||(t=[e,i],n.push([e,i])):(t=[e,i],n.push([e,i]))}),n}function rn(o,n,t){let e=Math.sqrt((t[0]-n[0])**2+(t[1]-n[1])**2);if(e===0)return{distance:Math.sqrt((o[0]-n[0])**2+(o[1]-n[1])**2),closestPoint:n.slice(0)};let i=Math.max(0,Math.min(1,((o[0]-n[0])*(t[0]-n[0])+(o[1]-n[1])*(t[1]-n[1]))/e**2)),r=[n[0]+i*(t[0]-n[0]),n[1]+i*(t[1]-n[1])];return{distance:Math.sqrt((o[0]-r[0])**2+(o[1]-r[1])**2),closestPoint:r}}function on(o,n,t){let[e,i]=o,[r,s]=n,l=Math.sqrt(Math.pow(r-e,2)+Math.pow(s-i,2));if(l===0||l<t)return[...n];let u=t/l,a=e+(r-e)*u,c=i+(s-i)*u;return[a,c]}var Hi=(a=>(a.START="start",a.END="end",a.FRONT="front",a.RIGHT="right",a.LEFT="left",a.RIGHT_FRONT="right_front",a.LEFT_FRONT="left_front",a.RIGHT_BACK="right_back",a.LEFT_BACK="left_back",a))(Hi||{});function Wi(o,n,t){let e=Tt(o,n,t);return 180-Math.abs(e)<15?"front":e>135?"right_front":e<-135?"left_front":e<=135&&e>=60?"right":e>=-135&&e<=-60?"left":e<60&&e>0?"right_back":e>-60&&e<0?"left_back":"front"}function Zs(o){let n=[{direction:"start",distance:S(o[0],o[1]),points:[o[0],o[1]]}];for(let t=2;t<o.length;t++){let e=Wi(o[t-2],o[t-1],o[t]);if(e==="front"){let i=n[n.length-1],r=S(o[t-1],o[t]);i.distance+=r,t!==2&&i.points.push(o[t-1])}else n.push({direction:e,distance:S(o[t-1],o[t]),points:[o[t-1],o[t]]})}return n.push({direction:"end",distance:0,points:[o[o.length-1]]}),n}var k=ce(ye(),1);var I="___",xn=class{constructor(n=3){this.lift_priority=n}roadInfo=[];pointMap=new Map;nodeMap=new Map;facilityMap=new Map;straightLadderMap=new Map;escalatorMap=new Map;staircaseMap=new Map;lineMap=new Map;baseRoute=new k.default;escalatorRoute=new k.default;straightLadderRoute=new k.default;initRoute(n){this.clear(),this.roadInfo=n,n.length&&(n.forEach(t=>{t.points.forEach(e=>{let i=`${t.floor}${I}${e.id}`;if(this.pointMap.set(i,e),this.nodeMap.set(`${e.floor}${I}${e.nodeId}`,i),e.type==="straightLadder"){let r=this.straightLadderMap.get(e.name)||[];r.push({...e}),this.straightLadderMap.set(e.name,r)}if(e.type==="staircase"){let r=this.staircaseMap.get(e.name)||[];r.push({...e}),this.staircaseMap.set(e.name,r)}if(e.type==="escalator"){let r=this.escalatorMap.get(e.name)||{};e.escalatorDirection==="exit"?r.end={floor:e.floor,id:e.id}:r.start={floor:e.floor,id:e.id},this.escalatorMap.set(e.name,r)}if(e.type==="facility"){let r=this.facilityMap.get(e.targetId)||[];r.push({...e}),this.facilityMap.set(e.targetId,r)}}),t.lines.filter(e=>e.direction!=="no").forEach(e=>{let i=`${t.floor}${I}${e.from}`,r=`${t.floor}${I}${e.to}`,s=this.pointMap.get(i)?.cds,l=this.pointMap.get(r)?.cds;if(s?.length&&l?.length){let u=S(s,l);this.addLineItem(i,r,u),e.direction==="double"&&this.addLineItem(r,i,u)}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute())}addLineItem(n,t,e,i=this.lineMap){let r=i.get(n)||new Map;r.set(t,e),i.set(n,r)}addFacilityToLineMap(n,t,e,i){[...this.straightLadderMap,...this.staircaseMap].forEach(([r,s])=>{if(!(s.length<2))for(let l=0;l<s.length;l++){let u=`${s[l].floor}${I}${s[l].id}`;for(let a=0;a<s.length;a++)if(l!==a){let c=`${s[a].floor}${I}${s[a].id}`,p=this.pointMap.get(u)?.cds,f=this.pointMap.get(c)?.cds;if(p?.length&&f?.length)if(s[l].type==="straightLadder"){let m=t;this.addLineItem(u,c,m,i)}else{let m=e;this.addLineItem(u,c,m,i)}}}}),this.escalatorMap.forEach((r,s)=>{if(r.start&&r.end){let l=`${r.start.floor}${I}${r.start.id}`,u=`${r.end.floor}${I}${r.end.id}`,a=this.pointMap.get(l)?.cds,c=this.pointMap.get(u)?.cds;if(a?.length&&c?.length){let p=n;this.addLineItem(l,u,p,i)}}})}initBaseRoute(){let n=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,n),this.baseRoute=new k.default(n)}initEscalatorRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(1*t,this.lift_priority*t,3e4*t,n),this.escalatorRoute=new k.default(n)}initStraightLadderRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(3*t,1*t,3e4*t,n),this.straightLadderRoute=new k.default(n)}checkStart(n){return!(!n.floor||!n.nodeId&&(!n.coord||n.coord.length<2))}checkEnd(n){return n.facility?!0:this.checkStart(n)}transformStart(n){if(n.nodeId){let t=this.nodeMap.get(`${n.floor}${I}${n.nodeId}`);if(t){let[e,i]=t.split(I);return{floor:e,id:i}}}if(n.coord?.length){let t=this.roadInfo.find(i=>i.floor===n.floor);if(!t)return null;let e=t.points.reduce((i,r)=>{let s=S(n.coord,r.cds);return s<i.min&&(i.min=s,i.point=r),i},{min:1/0,point:t.points[0]});return{floor:e.point.floor,id:e.point.id}}return null}transformEnd(n){if(n.floor){let t=this.transformStart(n);if(t)return t}return n.facility&&this.facilityMap.get(n.facility)?.length?{floor:n.floor,facility:n.facility}:null}getPath(n,t,e=""){if(!this.checkStart(n))return"start-error";if(!this.checkEnd(t))return"end-error";let i=this.transformStart(n);if(!i)return"no-start";let r=this.transformEnd(t);if(!r)return"no-end";let s=this.getBasePath.bind(this);switch(e){case"escalator":s=this.getEscalatorPath.bind(this);break;case"straightLadder":s=this.getStraightLadderPath.bind(this);break;default:s=this.getBasePath.bind(this);break}if(console.log(i,r),r.id)return s(i,r);if(r.facility){let l=this.facilityMap.get(r.facility).filter(a=>r.floor?a.floor===r.floor:!0);if(!l.length)return null;let u=l.map(a=>s(i,{floor:a.floor,id:a.id})).filter(a=>!!a);return u.reduce((a,c)=>{let p=c.reduce((f,m)=>f+J(m.points),0);return p<a.distance&&(a.distance=p,a.path=c),a},{distance:1/0,path:u[0]}).path}}getRoutePath(n,t,e){let i=`${n.floor}${I}${n.id}`,r=`${t.floor}${I}${t.id}`,s=e.path(i,r);if(console.log(i,r,s),!s)return null;let l=[];return s.map(u=>{let a=this.pointMap.get(u);if(a){let{floor:c}=a;if(l[l.length-1]?.floor===c){let p=l[l.length-1];p.points.push(a.cds),p.endType=a.type,p.destId=a.nodeId}else l.push({floor:c,points:[a.cds],endType:a.type,destId:a.nodeId})}}),l}getBasePath(n,t){return this.getRoutePath(n,t,this.baseRoute)}getEscalatorPath(n,t){return this.getRoutePath(n,t,this.escalatorRoute)}getStraightLadderPath(n,t){return this.getRoutePath(n,t,this.straightLadderRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new k.default,this.escalatorRoute=new k.default,this.straightLadderRoute=new k.default}};var N=ce(ye(),1);var C="___",En=class{constructor(n=3){this.lift_priority=n}roadInfo=[];pointMap=new Map;nodeMap=new Map;facilityMap=new Map;straightLadderMap=new Map;escalatorMap=new Map;staircaseMap=new Map;parkingMap=new Map;lineMap=new Map;baseRoute=new N.default;escalatorRoute=new N.default;straightLadderRoute=new N.default;forwardLineMap=new Map;forwardRoute=new N.default;initRoute(n){this.clear(),this.roadInfo=n,n.length&&(n.forEach(t=>{t.points.forEach(e=>{let i=`${t.floor}${C}${e.id}`;if(this.pointMap.set(i,e),this.nodeMap.set(`${e.floor}${C}${e.nodeId}`,i),e.type==="straightLadder"){let r=this.straightLadderMap.get(e.name)||[];r.push({...e}),this.straightLadderMap.set(e.name,r)}if(e.type==="staircase"){let r=this.staircaseMap.get(e.name)||[];r.push({...e}),this.staircaseMap.set(e.name,r)}if(e.type==="escalator"){let r=this.escalatorMap.get(e.name)||{};e.escalatorDirection==="exit"?r.end={floor:e.floor,id:e.id}:r.start={floor:e.floor,id:e.id},this.escalatorMap.set(e.name,r)}if(e.type==="facility"){let r=this.facilityMap.get(e.targetId)||[];r.push({...e}),this.facilityMap.set(e.targetId,r)}e.type==="parkingSpace"&&this.parkingMap.set(`${e.floor}${C}${e.name}`,e)}),t.lines.filter(e=>e.direction!=="no").forEach(e=>{let i=`${t.floor}${C}${e.from}`,r=`${t.floor}${C}${e.to}`,s=this.pointMap.get(i)?.cds,l=this.pointMap.get(r)?.cds;if(s?.length&&l?.length){let u=S(s,l);switch(this.addLineItem(i,r,u),this.addLineItem(r,i,u),e.direction){case"double":this.addLineItem(i,r,u,this.forwardLineMap),this.addLineItem(r,i,u,this.forwardLineMap);break;case"single":this.addLineItem(i,r,u,this.forwardLineMap);break;case"back":this.addLineItem(r,i,u,this.forwardLineMap);break}}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}addLineItem(n,t,e,i=this.lineMap){let r=i.get(n)||new Map;r.set(t,e),i.set(n,r)}addFacilityToLineMap(n,t,e,i){[...this.straightLadderMap,...this.staircaseMap].forEach(([r,s])=>{if(!(s.length<2))for(let l=0;l<s.length;l++){let u=`${s[l].floor}${C}${s[l].id}`;for(let a=0;a<s.length;a++)if(l!==a){let c=`${s[a].floor}${C}${s[a].id}`,p=this.pointMap.get(u)?.cds,f=this.pointMap.get(c)?.cds;if(p?.length&&f?.length)if(s[l].type==="straightLadder"){let m=t;this.addLineItem(u,c,m,i)}else{let m=e;this.addLineItem(u,c,m,i)}}}}),this.escalatorMap.forEach((r,s)=>{if(r.start&&r.end){let l=`${r.start.floor}${C}${r.start.id}`,u=`${r.end.floor}${C}${r.end.id}`,a=this.pointMap.get(l)?.cds,c=this.pointMap.get(u)?.cds;if(a?.length&&c?.length){let p=n;this.addLineItem(l,u,p,i)}}})}initBaseRoute(){let n=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,n),this.baseRoute=new N.default(n)}initEscalatorRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(1*t,this.lift_priority*t,3e4*t,n),this.escalatorRoute=new N.default(n)}initStraightLadderRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(3*t,1*t,3e4*t,n),this.straightLadderRoute=new N.default(n)}initForwardRoute(){this.forwardRoute=new N.default(this.forwardLineMap)}checkStart(n){return!(!n.floor||!n.nodeId&&(!n.coord||n.coord.length<2))}checkEnd(n){return n.facility||n.parkingSpace&&n.floor?!0:this.checkStart(n)}transformStart(n){if(n.nodeId){let t=this.nodeMap.get(`${n.floor}${C}${n.nodeId}`);if(t){let[e,i]=t.split(C);return{floor:e,id:i}}}if(n.coord?.length){let t=this.roadInfo.find(i=>i.floor===n.floor);if(!t)return null;let e=t.points.reduce((i,r)=>{let s=S(n.coord,r.cds);return s<i.min&&(i.min=s,i.point=r),i},{min:1/0,point:t.points[0]});return{floor:e.point.floor,id:e.point.id}}return null}transformEnd(n){if(n.floor){if(n.parkingSpace){let e=this.parkingMap.get(`${n.floor}${C}${n.parkingSpace}`);if(e)return{floor:e.floor,id:e.id}}let t=this.transformStart(n);if(t)return t}return n.facility&&this.facilityMap.get(n.facility)?.length?{floor:n.floor,facility:n.facility}:null}getPath(n,t,e=""){if(!this.checkStart(n))return"start-error";if(!this.checkEnd(t))return"end-error";let i=this.transformStart(n);if(!i)return"no-start";let r=this.transformEnd(t);if(!r)return"no-end";let s=this.getBasePath.bind(this);switch(e){case"escalator":s=this.getEscalatorPath.bind(this);break;case"straightLadder":s=this.getStraightLadderPath.bind(this);break;case"forward":s=this.getForwardPath.bind(this);break;default:s=this.getBasePath.bind(this);break}if(r.id)return s(i,r);if(r.facility){let l=this.facilityMap.get(r.facility).filter(a=>r.floor?a.floor===r.floor:!0);if(!l.length)return null;let u=l.map(a=>s(i,{floor:a.floor,id:a.id})).filter(a=>!!a);return u.reduce((a,c)=>{let p=c.reduce((f,m)=>f+J(m.points),0);return p<a.distance&&(a.distance=p,a.path=c),a},{distance:1/0,path:u[0]}).path}}getRoutePath(n,t,e){let i=`${n.floor}${C}${n.id}`,r=`${t.floor}${C}${t.id}`,s=e.path(i,r);if(!s)return null;let l=[];return s.map(u=>{let a=this.pointMap.get(u);if(a){let{floor:c}=a;if(l[l.length-1]?.floor===c){let p=l[l.length-1];p.points.push(a.cds),p.endType=a.type,p.destId=a.nodeId,p.distance=J(p.points)}else l.push({floor:c,points:[a.cds],endType:a.type,destId:a.nodeId,distance:0})}}),l}getBasePath(n,t){return this.getRoutePath(n,t,this.baseRoute)}getEscalatorPath(n,t){return this.getRoutePath(n,t,this.escalatorRoute)}getStraightLadderPath(n,t){return this.getRoutePath(n,t,this.straightLadderRoute)}getForwardPath(n,t){return this.getRoutePath(n,t,this.forwardRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new N.default,this.escalatorRoute=new N.default,this.straightLadderRoute=new N.default}};function bn(o){return o.replace(/[A-Z]/g,n=>"_"+n.toLowerCase()).replace(/^_/,"")}var Mn=new ht;function pt(o,n,t){return new Promise((e,i)=>{let r=Mn.genUniqueKey(),s=({data:l})=>{l.type===`${n}_result`&&l.key===r&&(Mn.removeKey(r),self.removeEventListener("message",s),l.error?i(l.error):e(l.data))};o.addEventListener("message",s),o.postMessage({type:n,key:r,data:t})})}function ca(o){let n={};for(let e in o)e.startsWith("on")&&(n[bn(e.slice(2))]=o[e]);let t=async({data:e})=>{if(n[e.type])try{let i=await n[e.type](e.data);self.postMessage({type:`${e.type}_result`,key:e.key,data:i})}catch(i){self.postMessage({type:`${e.type}_result`,key:e.key,error:i})}else self.postMessage({type:`${e.type}_result`,key:e.key,error:"no_event"})};return self.addEventListener("message",t),()=>{self.removeEventListener("message",t)}}import{EventDispatcher as Lo,Box2 as Ao,Vector3 as Q,Vector2 as dt,Raycaster as Ro,Box3 as Io,Color as No,AmbientLight as Do}from"three";import{Group as Oo,Tween as ie}from"@tweenjs/tween.js";import{EventDispatcher as _o}from"three";import{Object3D as Yi,ExtrudeGeometry as $i,Mesh as Zi,Box3 as Nt,Vector3 as B,BufferGeometry as Ki,LineSegments as Ji,Ray as Sn,Vector2 as Z}from"three";var _e={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,strokeWidth:1,doors:[],locked:!1,visible:!0,geometry:{type:"polygon",cds:[],coords:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{},gradualColor:[],renderType:"single",colorFactor:.9},w=class extends Yi{constructor(t,e){super();this.context=t;if(this.options=ut({..._e,...e},this),this.options.geometry.type==="point"){let[i,r]=this.options.geometry.coords;return this.position.set(i,r,this.options.height+this.options.airHeight),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i}),this.addEventListener("change-stroke",({value:i})=>{if(i){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),this.lineGeometry?.dispose())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-gradualColor",()=>{this.initMaterial(),this.initMesh()})}geometry;material;mesh;line;lineMaterial;lineGeometry;options;getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new B,e=new Nt;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new B(0,0,0);let t=new Nt,e=new B;return t.setFromObject(this),t.getSize(e),e}getPosition(){let t=this.getCenter();return t.setZ(t.z+this.options.height/2),t}init(){this.initDoor(),this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&this.options.strokeOpacity!==0&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initDoor(){if(this.options.doors&&this.options.geometry.type==="polygon"){let t=this.options.geometry.coords[0];this.options.doors.forEach(e=>{let i=e.type==="single"?.5:1,r=.5,s=He(t,e.coord),l=new Z(...e.coord),u=new Z(...t[s]).sub(new Z(...e.coord)).normalize(),a=new Z().addVectors(l,u.clone().multiplyScalar(i)),c=new Z().addVectors(l,u.clone().multiplyScalar(-i)),p=new Z(-u.y,u.x),f=new Z().addVectors(a,p.clone().multiplyScalar(r));We([f.x,f.y],t)||(p.multiplyScalar(-1),f=new Z().addVectors(a,p.clone().multiplyScalar(r)));let m=new Z().addVectors(c,p.clone().multiplyScalar(r)),h=[[a.x,a.y],[f.x,f.y],[m.x,m.y],[c.x,c.y]];this.options.geometry.coords=[[...t.slice(0,s+1),...h,...t.slice(s+1)]],t=this.options.geometry.coords[0]})}}initGeometry(){let t=z(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new $i(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initSingleMaterial(){let t=this.context.materialFactory.createMeshBasicMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});if(this.options.height<=.1)return this.material=t,t;let e=this.context.materialFactory.createMeshBasicMaterial({color:$(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,e],[t,e]}getMaxAndMin(t,e){let i=new Nt().setFromObject(this),r=t.clone().add(e.clone().multiplyScalar(1e3)),s=new Sn(r,e.clone().multiplyScalar(-1)),l=new B;s.intersectBox(i,l);let u=t.clone().add(e.clone().multiplyScalar(-1e3)),a=new Sn(u,e.clone()),c=new B;return a.intersectBox(i,c),{max:c,min:l}}initGradualMaterial(){let{max:t,min:e}=new Nt().setFromObject(this),i=t.clone().sub(e),r=Math.max(i.x,i.y,i.z)/2,s=this.getPosition(),l=new B(-1,.2,0).normalize(),{max:u,min:a}=this.getMaxAndMin(s,l),c=this.context.materialFactory.createShaderMaterial({gradualColor:this.options.gradualColor,center:this.getPosition(),maxValue:r,opacity:this.options.fillOpacity,direction:new B(-1,.2,0),max:u,min:a});if(this.options.height<=.1)return this.material=c,c;let p=this.getCenter(),f=new B(-1,.2,1).normalize(),{max:m,min:h}=this.getMaxAndMin(p,f),d=this.context.materialFactory.createShaderMaterial({gradualColor:[$(this.options.gradualColor[0],this.options.colorFactor),$(this.options.gradualColor[1],this.options.colorFactor)],center:this.getCenter(),maxValue:r,opacity:this.options.fillOpacity,direction:new B(-1,.2,1),max:m,min:h});return this.material=[c,d],[c,d]}initMaterial(){return this.options.renderType==="gradual"?this.initGradualMaterial():this.initSingleMaterial()}initLineMaterial(){let t=this.context.materialFactory.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new Zi(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],e=this.options.height+this.options.deltaHeight,{coords:i}=this.options.geometry;for(let r=0;r<i.length;r++){let s=i[r];for(let l=0;l<s.length;l++){let u=s[l],a=l+1===s.length?s[0]:s[l+1];t.push(new B(u[0],u[1],e)),t.push(new B(a[0],a[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new Ki().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new Ji(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.line=t,this.add(t),t}raycast(t){if(!this.visible||this.options.geometry.type==="point")return!1;this.mesh.updateMatrixWorld(!0);let e=t.intersectObject(this.mesh);if(e[0]){let{point:i,distance:r}=e[0];return{position:i,distance:r}}return!1}dispose(){this.geometry?.dispose(),this.line?.geometry.dispose(),this.clear()}};import{Object3D as Qi,PlaneGeometry as tr,Mesh as er,ShadowMaterial as nr,Color as ir,DoubleSide as rr}from"three";var Dt=class extends Qi{directionalLight;plane;basicOpacity=.07;constructor(){super(),this.directionalLight=this.initLight(),this.initPlane()}initLight(){let n=Oe(16777215,.5);return n.position.set(0,0,100),this.add(n),n}changeLightCamera(n){let t=n.x,e=n.y;this.directionalLight.shadow.camera.left=-t,this.directionalLight.shadow.camera.right=t,this.directionalLight.shadow.camera.top=e,this.directionalLight.shadow.camera.bottom=-e,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(t,e)}changeLightColor(n){this.directionalLight.color=new ir(n)}setPosition(n){this.position.copy(n),this.directionalLight.position.set(-n.x/2,-n.y/2,100)}initPlane(n=1e3,t=1e3){let e=new tr(n,t),i=new nr({transparent:!0,opacity:0,side:rr}),r=new er(e,i);return r.receiveShadow=!0,r.position.z=-10,this.add(r),this.plane=r,r}setTarget(n){this.directionalLight.target=n}transformOpacity(n){return n*this.basicOpacity}setOpacity(n){this.plane.material.opacity=this.transformOpacity(n)}dispose(){D(this,!0)}};import{EventDispatcher as lr,Vector3 as ur}from"three";import{Box3 as wn,EventDispatcher as or,Vector3 as M}from"three";import{debounce as sr}from"lodash";var ar={autoUpdate:!0,appendToBody:!1,autoChangePlacement:!1},Ot=class extends or{constructor(t,e={}){super();this.context=t;this.options={...ar,...e},this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):this.context.container.appendChild(this.div)}div;element;position=new M;clientPos={x:0,y:0};visible=!0;options;placement="top";observer=null;initObserver(){let t=new MutationObserver(sr(()=>{this.div&&this.usePlacement()},100));t.observe(this.div,{childList:!0,subtree:!0,attributes:!0}),this.observer=t}getPlacementPosition(){if(this.element instanceof w&&this.element.options.geometry.type==="polygon"){let{max:r,min:s}=new wn().setFromObject(this.element),l=(r.x+s.x)/2,u=(r.y+s.y)/2;return{left:new M(s.x,u,r.z),leftTop:new M(s.x,r.y,r.z),top:new M(l,r.y,r.z),rightTop:new M(r.x,r.y,r.z),right:new M(r.x,u,r.z),rightBottom:new M(r.x,s.y,r.z),bottom:new M(l,s.y,r.z),leftBottom:new M(s.x,s.y,r.z),center:new M(l,u,r.z)}}let{x:t,y:e,z:i}=this.element?.getPosition?.()||this.position;return{left:new M(t,e,i),leftTop:new M(t,e,i),top:new M(t,e,i),rightTop:new M(t,e,i),right:new M(t,e,i),rightBottom:new M(t,e,i),bottom:new M(t,e,i),leftBottom:new M(t,e,i),center:new M(t,e,i)}}getPlacementScreenPosition(){let{width:t,height:e}=this.context.clientSize,i=this.getPlacementPosition();return Object.keys(i).reduce((r,s)=>{let{x:l,y:u}=v(i[s],this.context.camera,t,e);return r[s]={x:l,y:u},r},{})}checkOverflow(t,e){let{width:i,height:r}=this.context.clientSize;return e.x>0&&t.x<i&&e.y<r&&t.y>0}getPlacement(){let{clientWidth:t,clientHeight:e}=this.div,i=this.getPlacementScreenPosition(),r=t/2,s=e/2,l=[{type:"center",getBox(u,a){return{max:{x:r+u,y:a-e},min:{x:u-r,y:a}}}},{type:"left",getBox(u,a){return{max:{x:u,y:a-s},min:{x:u-t,y:a+s}}}},{type:"leftTop",getBox(u,a){return{max:{x:u,y:a-e},min:{x:u-t,y:a}}}},{type:"top",getBox(u,a){return{max:{x:u+r,y:a-e},min:{x:u-r,y:a}}}},{type:"rightTop",getBox(u,a){return{max:{x:u+t,y:a-e},min:{x:u,y:a}}}},{type:"right",getBox(u,a){return{max:{x:u+t,y:a-s},min:{x:u,y:a+s}}}},{type:"rightBottom",getBox(u,a){return{max:{x:u+t,y:a},min:{x:u,y:a+e}}}},{type:"bottom",getBox(u,a){return{max:{x:u+r,y:a},min:{x:u-r,y:a+e}}}},{type:"leftBottom",getBox(u,a){return{max:{x:u,y:a},min:{x:u-t,y:a+s}}}}];for(let u=0;u<l.length;u++){let a=l[u],c=i[a.type],{max:p,min:f}=a.getBox(c.x,c.y);if(this.checkOverflow(p,f))return{type:a.type,position:c}}return{type:"center",position:i.center}}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}usePlacement(){let t=this.getPlacement();this.div.className=`overlay_${t.type}`,this._updatePosition(t.position.x,t.position.y)}bindElement(t){this.element=t,this.options.autoChangePlacement&&this.initObserver(),this.onUpdate()}unBindElement(){this.element=void 0}setVisible(t,e="block"){t!==this.visible&&(this.div.style.display=t?e:"none",this.visible=t)}setOpacity(t){this.div.style.opacity=`${t}`}getPosition(){return this.element?typeof this.element.getPosition=="function"?this.element.getPosition():new wn().setFromObject(this.element).getCenter(new M):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:r}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=r}_updatePosition(t,e){this.clientPos={x:t,y:e};let{width:i,height:r,x:s,y:l}=this.context.clientSize;this.options.appendToBody&&(this.div.style.left=`${s}px`,this.div.style.top=`${l+r}px`),this.options.autoUpdate?this.div.style.transform=`translate3d(${t}px, ${-r+e}px, 0)`:this.dispatchEvent({type:"update-position",x:t,y:e,width:i,height:r})}updatePosition(t=!1){let e=this.getPosition(),{width:i,height:r}=this.context.clientSize,{x:s,y:l}=v(e,this.context.camera,i,r);this.clientPos.x===s&&this.clientPos.y===l&&!t||this._updatePosition(s,l)}onUpdate=()=>{this.options.autoChangePlacement?this.usePlacement():this.updatePosition()};registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.unRegistryEvent(),this.unBindElement(),this.observer?.disconnect(),this.div?.remove(),this.div=null}};var cr={texts:[{text:""}],level:1,icon_position:"bottom",collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},icon_opacity:1,icon_border:{color:"#586EE0",width:0},background:"",collision_hide_icon:!0,built_in:!1,box_only_icon:!1},st=class extends lr{constructor(t,e){super();this.context=t;this.options=ut({...cr,...e},this),this.position.set(e.position?.x||0,e.position?.y||0,e.position?.z||0),this.overlay=new Ot(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:i,y:r,height:s})=>{this.overlay.div.style.transform=`translate3d(calc(${i}px - 50%), calc(${-s+r}px - ${this.options.icon&&this.options.icon_position!=="center"?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:i})=>{i?this.img?this.img.setAttribute("src",i):(this.addIcon(),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:i})=>{let r=this.textDiv;if(r){let s=this.initText();this.div.replaceChild(s,r)}else this.addText();this.resetSize()}),this.addEventListener("change-opacity",({value:i})=>{this.overlay.setOpacity(i)}),this.addEventListener("change-icon_size",({value:i})=>{this.img&&(this.img.style.width=`${i?.[0]||32}px`,this.img.style.height=`${i?.[1]||32}px`,this.resetSize())}),this.addEventListener("change-icon_opacity",({value:i})=>{this.img&&(this.img.style.opacity=`${i}`)}),this.addEventListener("change-icon_border",({value:i})=>{this.img&&(this.img.style.border=`${i.width}px solid ${i.color}`)}),this.addEventListener("change-background",({value:i})=>{this.div.style.background=i})}div;textDiv;img;overlay;options;visible=!0;size={width:0,height:0};position=new ur;userData={};showTextStatus=!0;disposed=!1;get withinDisplayRange(){return this.overlay.withinDisplayRange}async resetSize(){if(await qe(),!this.disposed)if(this.options.box_only_icon){if(!this.img)return;let{width:t,height:e}=this.img.getBoundingClientRect();this.size={width:t+2,height:e+2}}else{let{width:t,height:e}=this.div.getBoundingClientRect();this.size={width:t+2,height:e+2}}}renderHelperBox(){}get clientPos(){return this.overlay.clientPos}initDiv(){let t=document.createElement("div");return this.div=t,this.addText(),this.options.icon&&this.addIcon(),t.style.fontSize="12px",t.style.textShadow="#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.padding="4px",this.overlay.setOpacity(this.options.opacity),this.overlay.div.style.pointerEvents="none",this.overlay.div.style.userSelect="none",this.overlay.div.appendChild(t),this.resetSize(),t}addIcon(){if(!this.img){let t=this.initIcon();this.options.icon_position==="top"?this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t):this.div.appendChild(t)}}addText(){let t=this.initText();this.options.icon_position==="top"?this.div.appendChild(t):this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t)}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.textAlign="center",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.texts.forEach(e=>{let i=document.createElement("div");if(i.style.whiteSpace="nowrap",e.styles)for(let[r,s]of Object.entries(e.styles))i.style[r]=s;i.textContent=e.text,t.appendChild(i)}),t}initIcon(){let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${this.options.icon_size?.[0]||32}px`,t.style.height=`${this.options.icon_size?.[1]||32}px`,t.style.opacity=`${this.options.icon_opacity}px`,t.style.borderRadius="50%",this.options.icon_border.width&&(t.style.border=`${this.options.icon_border.width}px solid ${this.options.icon_border.color}`),t.onload=()=>{this.resetSize()},this.img=t,t}_changePosition=()=>{this.overlay.updatePosition(!0)};registryEvent(){}unRegistryEvent(){}setVisible(t){t!==this.visible&&(this.visible=t,this.changeOverlayVisible(t))}changeOverlayVisible(t){if(!(t===this.overlay.visible&&this.options.collision_hide_icon))if(this.options.collision_hide_icon)this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden";else{if(this.showTextStatus===t)return;this.textDiv.style.visibility=t?"visible":"hidden",this.showTextStatus=t}}parentSetVisible(t){this.visible&&this.changeOverlayVisible(t)}getBox(t=this.context.config.poi.boxScale){let{width:e,height:i}=this.size,r=e*t,s=i*t,{x:l,y:u}=this.overlay.clientPos;return{left:l-r/2,right:l+r/2,top:this.options.icon?u-s:u-s/2,bottom:this.options.icon?u:u+s/2}}getOriginBox(){return this.getBox(1)}isContain(t,e){if(!this.overlay.visible||!this.visible)return!1;let i=this.getOriginBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.div=null,this.textDiv=null,this.img=void 0,this.overlay.dispose(),this.disposed=!0}};import{Box3 as zt,Object3D as ve,Vector3 as kt}from"three";import{MeshBasicMaterial as hr,Object3D as pr,PlaneGeometry as fr,Texture as dr,DoubleSide as gr,Mesh as mr,Matrix3 as Tn,Vector2 as yr}from"three";import{create as _r}from"@mars3d/heatmap.js";import{featureCollection as vr,point as xr,bbox as Er,center as br}from"@turf/turf";var Ft=class extends pr{constructor(t){super();this.context=t;this.div=document.createElement("div")}heatmap;div;plane;clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:e,height:i,leftTop:r,center:s}=this.getBox(t);this.heatmap=_r({width:e,height:i,container:this.div,...this.context.config.heatMap}),this.heatmap.setData(this.transformData(t,r)),this.initPlane(e,i),this.position.set(s[0],s[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new fr(t,e),r=new dr(this.div.firstChild);r.needsUpdate=!0;let s=new hr({transparent:!0,side:gr,map:r});s.needsUpdate=!0,this.plane=new mr(i,s),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new Tn().makeScale(1,-1).multiply(new Tn().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(s=>{let l=new yr(s.x,s.y).applyMatrix3(i);return{x:l.x,y:l.y,value:s.value}}),max:t.max,min:t.min}}getBox(t){let e=vr(t.data.map(a=>xr([a.x,a.y]))),i=Er(e),r=i[2]-i[0],s=i[3]-i[1],l={x:i[0],y:i[3]},u=br(e);return{width:r,height:s,leftTop:l,center:u.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};import{Object3D as Mr,Vector3 as Sr}from"three";var Ut=class extends Mr{constructor(t,e){super();this.context=t;this.options=e;this.position.copy(e.position||new Sr(0,0,0)),this.loadModel()}model=null;async loadModel(){let t=await Rt(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t}dispose(){D(this),this.model=null}};import{Box3 as Tr,Vector3 as Cr}from"three";import{Object3D as wr}from"three";var T=class extends wr{constructor(t){super();this.context=t}dispose(){D(this),this.children.forEach(t=>t.dispose?.()),this.clear()}};var Bt=class extends T{graphicMap=new Map;constructor(n){super(n)}getCenter(){return new Tr().setFromObject(this).getCenter(new Cr)}createGraphic(n){let t=new w(this.context,n);return this.add(t),this.graphicMap.set(n.id,t),t}removeGraphic(n){this.remove(n),this.graphicMap.delete(n.options.id),n.dispose()}removeGraphicById(n){this.graphicMap.has(n)&&this.removeGraphic(this.graphicMap.get(n))}getGraphicByNodeId(n){return this.graphicMap.get(n)||null}getGraphicByRaycaster(n){let t={distance:1e4,graphic:null,position:null},e=this.children.reduce((i,r)=>{if(r instanceof w){let s=r.raycast(n);if(s){let{distance:l}=s;if(l<i.distance)return{distance:s.distance,position:s.position,graphic:r}}return i}else return i},t);return e===t?{graphics:[],position:null}:{graphics:[e.graphic],position:e.position}}};import{debounce as Pr}from"lodash";var ft=class extends T{pois=[];debounceCollisionDetection;timer=new R;constructor(n){super(n),this.registryEvent(),this.debounceCollisionDetection=Pr(this.collisionDetection,10)}clear(n=!1){return this.pois.forEach(t=>{t.options.built_in&&!n||t.dispose()}),this.pois=n?[]:this.pois.filter(t=>t.options.built_in),this}createPoi(n){let t=new st(this.context,n);return this.pushPoi(t),t.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(t)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),t}changePoiLevelOrCollisionEnable(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.pois.splice(t,1),this.pushPoi(n))}removePoi(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.pois.splice(t,1),n.dispose())}removePoiById(n){let t=this.pois.find(e=>e.options.id===n);t&&this.removePoi(t)}getPoiById(n){return this.pois.find(e=>e.options.id===n)||null}pushPoi(n){if(!n.options.collision_enable){this.pois.unshift(n);return}if(n.options.level===0){this.pois.push(n);return}for(let t=0;t<this.pois.length;t++){let e=this.pois[t];if(e.options.collision_enable&&e.options.level<=n.options.level){this.pois.splice(t,0,n);return}}this.pois.push(n)}getPoiByDeviceXy(n,t){return this.pois.filter(i=>i instanceof st&&i.isContain(n,t))}onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})};collisionDetection(){let n=[];this.pois.filter(e=>e.visible&&e.withinDisplayRange).forEach((e,i)=>{let{left:r,right:s,top:l,bottom:u}=e.getBox();if(i===0||!e.options.collision_enable){n.push({left:r,right:s,top:l,bottom:u}),e.parentSetVisible(!0);return}let a=n.some(c=>c.left<s&&c.right>r&&c.top<u&&c.bottom>l);e.parentSetVisible(!a),a||n.push({left:r,right:s,top:l,bottom:u})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(n=>n.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};import{debounce as Lr}from"lodash";import{Vector2 as Ar,Vector3 as Rr}from"three";var Gt=class extends T{pois=[];debounceCollisionDetection;timer=new R;constructor(n){super(n),this.registryEvent(),this.debounceCollisionDetection=Lr(this.collisionDetection,10)}clear(){return this.pois.forEach(n=>{n.dispose()}),this.pois=[],this}createPoi(n){let t=new P(this.context,n);return this.pushPoi(t),t.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(t)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),t}changePoiLevelOrCollisionEnable(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.pois.splice(t,1),this.pushPoi(n))}removePoi(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.remove(n),this.pois.splice(t,1),n.dispose())}removePoiById(n){let t=this.pois.find(e=>e.options.id===n);t&&this.removePoi(t)}getPoiById(n){return this.pois.find(e=>e.options.id===n)||null}pushPoi(n){if(this.add(n),!n.options.collision_enable){this.pois.unshift(n);return}if(n.options.level===0){this.pois.push(n);return}for(let t=0;t<this.pois.length;t++){let e=this.pois[t];if(e.options.collision_enable&&e.options.level<=n.options.level){this.pois.splice(t,0,n);return}}this.pois.push(n)}getPoiByDeviceXy(n,t){let e=new Ar(n,t);return this.pois.filter(r=>r instanceof P&&r.canSelect&&r.box.containsPoint(e))}changeParkingSpaceVisibleByZoom=()=>{let n=this.parent?.parent;if(n&&n instanceof V){let{clientSize:{width:t,height:e}}=this.context,{max:i,min:r}=n.box,l=Math.min(t/(i.x-r.x),e/(i.y-r.y))*(i.x-r.x)/60;this.pois.filter(u=>u.userData.type==="parkingSpace").map(u=>{let a=this.context.camera.zoom>=l;u.visible=a,a||u.parentSetVisible(a)})}};onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})};collisionDetection(){let n=[],{camera:t}=this.context;t.updateMatrixWorld();let e=s=>s<=1&&s>=-1,i=t.projectionMatrix.clone();i.multiply(t.matrixWorldInverse),this.pois.filter(s=>{if(s.visible){let l=new Rr().setFromMatrixPosition(s.matrixWorld);return l.applyMatrix4(i),s.screenPosition=l,e(l.x)&&e(l.y)&&e(l.z)}return!1}).forEach((s,l)=>{let u=s.getBox(s.screenPosition);if(l===0||!s.options.collision_enable){n.push(u),s.parentSetVisible(!0);return}let a=n.some(c=>c.intersectsBox(u));s.parentSetVisible(!a),a||n.push(u)})}registryEvent(){this.context.addEventListener("update",this.onUpdate),this.context.addEventListener("control-zoom-change",this.changeParkingSpaceVisibleByZoom)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate),this.context.removeEventListener("control-zoom-change",this.changeParkingSpaceVisibleByZoom)}dispose(){this.timer.dispose(),this.pois.forEach(n=>n.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var V=class extends ve{constructor(t){super();this.context=t;this.groundLayer=new T(this.context),this.graphicLayer=new Bt(this.context),this.poiLayer=new ft(this.context),this.poiLayer2=new Gt(this.context),this.wallLayer=new T(this.context),this.textureLayer=new T(this.context),this.glbModelLayer=new T(this.context),this.laneLayer=new T(this.context),this.mergeGraphicLayer=new T(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),this.groundUpper.add(this.wallLayer),this.groundUpper.add(this.textureLayer),this.groundUpper.add(this.glbModelLayer),this.groundUpper.add(this.laneLayer),this.groundUpper.add(this.mergeGraphicLayer),this.add(this.groundUpper),this.add(this.groundLayer),this.add(this.models)}graphicLayer;poiLayer;poiLayer2;wallLayer;textureLayer;glbModelLayer;laneLayer;mergeGraphicLayer;grounds=new Set;groundLayer;shadow=new Dt;heatmap;groundUpper=new ve;models=new ve;modelMap=new Map;groundMaxHeight=0;name="";key="";box=new zt;getPosition(){return this.box.getCenter(new kt)}createGround(t){let e=new w(this.context,t);this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.mesh.castShadow=!0,this.grounds.add(e),this.groundLayer.add(e))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(e=>e.options.height+e.options.airHeight+e.options.deltaHeight)):0,this.groundUpper.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new zt().setFromObject(this).getCenter(new kt)}addModel(t){let e=new Ut(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new zt().setFromObject(this.groundUpper),e=t.getCenter(new kt),i=t.getSize(new kt);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new Ft(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new zt().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}updateBox(){this.box.setFromObject(this)}dispose(){this.shadow.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.dispose(),this.wallLayer.dispose(),this.textureLayer.dispose(),this.glbModelLayer.dispose(),this.laneLayer.dispose(),this.mergeGraphicLayer.dispose(),this.grounds.forEach(t=>t.dispose()),this.heatmap?.dispose(),this.groundUpper.clear(),this.models.children.forEach(t=>t.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}};import{EventDispatcher as Ir,Vector3 as Nr}from"three";var H=class extends Ir{constructor(t){super();this.context=t;this.svg=Xe(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}points=[];svg;enable=!0;_onResize=({width:t,height:e})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${e}`))};_registryEvent(){this.context.addEventListener("resize",this._onResize)}_unRegistryEvent(){this.context.removeEventListener("resize",this._onResize)}setEnable(t){this.enable=t,t?this.svg.style.display="block":this.svg.style.display="none"}getIntersectByPointerEvent(t){let{camera:e,renderer:i}=this.context,{offsetX:r,offsetY:s}=t,{clientWidth:l,clientHeight:u}=i.domElement,a=r/l*2-1,c=1-s/u*2;return new Nr(a,c,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return v(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}};var Vt=class extends H{constructor(t){super(t);this.context=t;let{config:{svg:{circle:e,line:i}}}=t;this.circles=[mt(e.radius,e.fill),mt(e.radius,e.fill)],this.line=Pt(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}circles;line;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)}onUpdate=()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);ot(this.circles[0],t.x,t.y),O(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);ot(this.circles[1],t.x,t.y),O(this.line,void 0,t)}};onPointermove=t=>{this.points.length===1&&(this.line.style.display="block",O(this.line,void 0,{x:t.offsetX,y:t.offsetY}))};onPointerleave=()=>{this.points[1]||(this.line.style.display="none")};onPointerdown=t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:r}=t,s=this.circles[this.points.length];ot(s,i,r),this.points.length||O(this.line,{x:i,y:r},{x:i,y:r}),this.addPoint(e)}};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:r}]=this.points;return Math.sqrt((i-t)**2+(r-e)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var Ht=class extends H{circles=[];lines=[];isClose=!1;constructor(n){super(n),this.registryEvent()}setEnable(n){super.setEnable(n),n?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(n){this.circles.push(n),this.svg.appendChild(n)}addLine(n){this.lines.push(n),this.svg.appendChild(n)}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)}onUpdate=()=>{this.points.length&&this.points.forEach((n,t)=>{let e=this.getSvgCoordinate(n);this.circles[t]&&ot(this.circles[t],e.x,e.y),t!==0&&O(this.lines[t-1],void 0,e),this.lines[t]&&O(this.lines[t],e)})};onPointermove=n=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",O(this.lastLine,void 0,{x:n.offsetX,y:n.offsetY}))};onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")};onPointerdown=n=>{if(this.isClose)return;let t=this.getIntersectByPointerEvent(n);if(t){let{offsetX:e,offsetY:i}=n;this.checkAdsorb(e,i)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(t);let{circle:{fill:r,radius:s},line:{stroke:l}}=this.context.config.svg;if(!this.isClose){let u=mt(s,r);ot(u,e,i),this.addCircle(u)}if(this.lines.length&&O(this.lastLine,void 0,{x:e,y:i}),!this.isClose){let u=Pt(l);O(u,{x:e,y:i},{x:e,y:i}),this.addLine(u)}}};checkAdsorb(n,t){if(this.points.length<3)return!1;let e=this.circles[0],i=+e.getAttribute("cx"),r=+e.getAttribute("cy");return Math.sqrt((n-i)**2+(t-r)**2)<=5}addPoint(n){if(this.points.push(n),this.isClose){let t=this.calculatedArea();this.dispatchEvent({type:"area",area:t})}}calculatedArea(){let n=this.points.map(i=>[i.x,i.y]),t=0,e=n.length;for(let i=0;i<e;i++){let r=(i+1)%e;t+=n[i][0]*n[r][1]-n[r][0]*n[i][1]}return Math.abs(t/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};import{Box3 as Dr}from"three";var Cn=class extends H{constructor(t){super(t);this.context=t;let{config:{svg:{line:e}}}=t;this.rect=ct(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=ct(e.stroke,"#ffffff"),this.centerRect[i]=ct(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}rect;cornerRect=[];centerRect=[];graphic;setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}onUpdate=()=>{if(this.graphic){let t=new Dr().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:r}}=this.context,{min:s,max:l}=t,u=v(s,e,i,r),a=v(l,e,i,r);F(this.rect,u.x,a.y,Math.abs(a.x-u.x),Math.abs(a.y-u.y));let{x:c,y:p}=u,{x:f,y:m}=a,h=5,d=[{x:c-h,y:m-h},{x:f-h,y:m-h},{x:c-h,y:p-h},{x:f-h,y:p-h}];for(let _=0;_<d.length;_++)F(this.cornerRect[_],d[_].x,d[_].y,h*2,h*2);let g=4,y=(c+f)/2,b=(p+m)/2,E=[{x:y-g,y:m-g},{x:c-g,y:b-g},{x:f-g,y:b-g},{x:y-g,y:p-g}];for(let _=0;_<E.length;_++)F(this.centerRect[_],E[_].x,E[_].y,g*2,g*2)}else{F(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)F(this.cornerRect[t],0,0,0,0),F(this.centerRect[t],0,0,0,0)}};selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}};import{BufferGeometry as Or,Color as xe,ExtrudeGeometry as Fr,LineSegments as Ur,Mesh as Br,Object3D as Gr,ShaderMaterial as zr,Vector3 as Pn}from"three";import{mergeGeometries as Ln}from"three/examples/jsm/utils/BufferGeometryUtils";var Wt=class extends Gr{constructor(t,e){super();this.context=t;this.options=e;e.length&&this.init()}geometry;material;lineMaterial;lineGeometry;Mesh;LineMesh;initGeometry(){let t=this.options.map(e=>{let i=z(e.geometry.coords[0],e.geometry.coords.slice(1));return new Fr(i,{steps:1,bevelEnabled:!1,depth:e.height,curveSegments:4})});this.geometry=Ln(t),t.forEach(e=>e.dispose())}initMaterial(){let t=`
|
|
1
|
+
var pi=Object.create;var Pe=Object.defineProperty;var fi=Object.getOwnPropertyDescriptor;var di=Object.getOwnPropertyNames;var gi=Object.getPrototypeOf,mi=Object.prototype.hasOwnProperty;var nt=(o,n)=>()=>(n||o((n={exports:{}}).exports,n),n.exports);var yi=(o,n,t,e)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of di(n))!mi.call(o,i)&&i!==t&&Pe(o,i,{get:()=>n[i],enumerable:!(e=fi(n,i))||e.enumerable});return o};var ce=(o,n,t)=>(t=o!=null?pi(gi(o)):{},yi(n||!o||!o.__esModule?Pe(t,"default",{value:o,enumerable:!0}):t,o));var Ze=nt((qs,$e)=>{$e.exports=function(n,t){return n[0]=t[0],n[1]=t[1],n}});var Qe=nt((js,Je)=>{var Ke=Ze();Je.exports=function(o,n){Array.isArray(n)||(n=[]),o.length>0&&n.push(Ke([0,0],o[0]));for(var t=0;t<o.length-1;t++){var e=o[t],i=o[t+1],r=e[0],s=e[1],l=i[0],u=i[1],a=[.75*r+.25*l,.75*s+.25*u],c=[.25*r+.75*l,.25*s+.75*u];n.push(a),n.push(c)}return o.length>1&&n.push(Ke([0,0],o[o.length-1])),n}});var an=nt((Js,sn)=>{var ge=class{constructor(){this.keys=new Set,this.queue=[]}sort(){this.queue.sort((n,t)=>n.priority-t.priority)}set(n,t){let e=Number(t);if(isNaN(e))throw new TypeError('"priority" must be a number');return this.keys.has(n)?this.queue.map(i=>(i.key===n&&Object.assign(i,{priority:e}),i)):(this.keys.add(n),this.queue.push({key:n,priority:e})),this.sort(),this.queue.length}next(){let n=this.queue.shift();return this.keys.delete(n.key),n}isEmpty(){return this.queue.length===0}has(n){return this.keys.has(n)}get(n){return this.queue.find(t=>t.key===n)}};sn.exports=ge});var cn=nt((Qs,un)=>{function ln(o,n){let t=new Map;for(let[e,i]of o)e!==n&&i instanceof Map?t.set(e,ln(i,n)):e!==n&&t.set(e,i);return t}un.exports=ln});var fn=nt((ta,pn)=>{function Xi(o){let n=Number(o);return!(isNaN(n)||n<=0)}function hn(o){let n=new Map;return Object.keys(o).forEach(e=>{let i=o[e];if(i!==null&&typeof i=="object"&&!Array.isArray(i))return n.set(e,hn(i));if(!Xi(i))throw new Error(`Could not add node at key "${e}", make sure it's a valid node`,i);return n.set(e,Number(i))}),n}pn.exports=hn});var mn=nt((ea,gn)=>{function dn(o){if(!(o instanceof Map))throw new Error(`Invalid graph: Expected Map instead found ${typeof o}`);o.forEach((n,t)=>{if(typeof n=="object"&&n instanceof Map){dn(n);return}if(typeof n!="number"||n<=0)throw new Error(`Values must be numbers greater than 0. Found value ${n} at ${t}`)})}gn.exports=dn});var ye=nt((na,vn)=>{var qi=an(),ji=cn(),yn=fn(),_n=mn(),me=class{constructor(n){n instanceof Map?(_n(n),this.graph=n):n?this.graph=yn(n):this.graph=new Map}addNode(n,t){let e;return t instanceof Map?(_n(t),e=t):e=yn(t),this.graph.set(n,e),this}addVertex(n,t){return this.addNode(n,t)}removeNode(n){return this.graph=ji(this.graph,n),this}path(n,t,e={}){if(!this.graph.size)return e.cost?{path:null,cost:0}:null;let i=new Set,r=new qi,s=new Map,l=[],u=0,a=[];if(e.avoid&&(a=[].concat(e.avoid)),a.includes(n))throw new Error(`Starting node (${n}) cannot be avoided`);if(a.includes(t))throw new Error(`Ending node (${t}) cannot be avoided`);for(r.set(n,0);!r.isEmpty();){let c=r.next();if(c.key===t){u=c.priority;let f=c.key;for(;s.has(f);)l.push(f),f=s.get(f);break}i.add(c.key),(this.graph.get(c.key)||new Map).forEach((f,m)=>{if(i.has(m)||a.includes(m))return null;if(!r.has(m))return s.set(m,c.key),r.set(m,c.priority+f);let h=r.get(m).priority,d=c.priority+f;return d<h?(s.set(m,c.key),r.set(m,d)):null})}return l.length?(e.trim?l.shift():l=l.concat([n]),e.reverse||(l=l.reverse()),e.cost?{path:l,cost:u}:l):e.cost?{path:null,cost:0}:null}shortestPath(...n){return this.path(...n)}};vn.exports=me});import{EventDispatcher as Bo,Vector3 as Go}from"three";var R=class{tasks={requestAnimation:new Set,timeout:new Set,interval:new Set};requestAnimationFrame(n){let t=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(t),n()});return this.tasks.requestAnimation.add(t),t}cancelAnimationFrame(n){this.tasks.requestAnimation.delete(n),window.cancelAnimationFrame(n)}setTimeout(n,t){let e=window.setTimeout(()=>{this.tasks.timeout.delete(e),n()},t);return this.tasks.timeout.add(e),e}clearTimeout(n){this.tasks.timeout.delete(n),window.clearTimeout(n)}setInterval(n,t){let e=window.setInterval(()=>{this.tasks.interval.delete(e),n()},t);return this.tasks.interval.add(e),e}clearInterval(n){this.tasks.interval.delete(n),window.clearInterval(n)}dispose(){this.tasks.requestAnimation.forEach(n=>{window.cancelAnimationFrame(n)}),this.tasks.requestAnimation.clear(),this.tasks.timeout.forEach(n=>{window.clearTimeout(n)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(n=>{window.clearInterval(n)}),this.tasks.interval.clear()}};import{Scene as _i,WebGLRenderer as vi,OrthographicCamera as xi,Shape as Ei,PCFSoftShadowMap as bi,Group as Mi,Color as Si,DirectionalLight as wi,AmbientLight as Ti,Path as Ci,Vector2 as Le}from"three";import{MapControls as Pi}from"three/examples/jsm/controls/MapControls";function Ae(){let o=new _i;return o.background=new Si(16777215),o}function Re(){let o=new vi({antialias:!0});return o.autoClear=!0,o.setClearAlpha(1),o.setClearColor(16777215),o.setPixelRatio(window.devicePixelRatio),o.shadowMap.enabled=!0,o.shadowMap.autoUpdate=!0,o.shadowMap.type=bi,o}function Ie(o,n){let t=new xi(-o/2,o/2,n/2,-n/2,-1e3,5e3);return t.up.set(0,0,1),t.position.set(0,0,100),t.lookAt(0,0,0),t}function Ne(){let o=new Mi,n=new Ti(16777215,2.6);return o.add(n),o}function De(o,n){let t=new Pi(o,n);return t.enableDamping=!1,t.zoomSpeed=.5,t}function z(o,n=[]){let t=new Ei(o.map(e=>new Le(...e)));return n.length&&n.forEach(e=>{var i=new Ci(e.map(r=>new Le(...r)));t.holes.push(i)}),t}function Oe(o=16777215,n=1){let t=new wi(o,n);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 D(o,n){if(n&&o.children&&o.children.length&&o.children.forEach(t=>{D(t,n)}),o.isMesh){let t=o;t.geometry&&t.geometry.dispose(),t.material&&(Array.isArray(t.material)?t.material.forEach(e=>{e.dispose()}):t.material.dispose())}o.isLight&&o.dispose?.()}function Fe(o){return/[\u4E00-\u9FA5]+/g.test(o)}import{DataTexture as Li,RGBAFormat as Ue,LinearFilter as bt,TextureLoader as Ai}from"three";var lt=new Map,gt=new Map,Ri=new Ai;function Ii(){let o=document.createElement("canvas");o.width=1024,o.height=64;let n=o.getContext("2d",{willReadFrequently:!0});return n.font="54px sans-serif",n.textBaseline="hanging",n.lineWidth=12,n.fillStyle="rgba(0,0,0,1)",n.strokeStyle="white",{canvas:o,ctx:n}}var he,it;function Ni(){if(!he){let{canvas:o,ctx:n}=Ii();he=o,it=n}}function Be(o){if(gt.has(o))return gt.get(o);Ni(),it.clearRect(0,0,1024,64);let n=Fe(o)?4:8;it.strokeText(o,2,n),it.fillText(o,2,n);let t=Math.ceil(it.measureText(o).width);t=t%2===0?t:t+1,t+=2;let e=it.getImageData(0,0,t,64),i=new Li(Uint8Array.from(e.data),t,64,Ue);return i.flipY=!0,i.minFilter=bt,i.magFilter=bt,gt.set(o,i),i}function Ge(){gt.forEach((o,n)=>{o.dispose()}),lt.forEach(o=>{o instanceof Promise?o.then(n=>n.dispose()):o.dispose()}),gt.clear(),lt.clear()}function ze(){it=null,he=null}async function ke(o){if(lt.has(o))return lt.get(o);let n=Ri.loadAsync(o);return n.then(t=>{t.format=Ue,t.magFilter=bt,t.minFilter=bt,t.colorSpace="srgb",lt.set(o,t)}),lt.set(o,n),n}import{Vector3 as pe,Vector2 as Y,Matrix3 as Mt}from"three";import{point as Di,featureCollection as Oi,center as Fi}from"@turf/turf";function v(o,n,t,e){let i=o.clone().project(n),r=t/2,s=e/2,l=Math.round(i.x*r+r),u=Math.round(-i.y*s+s);return{x:l,y:u}}function St(o){let n=Oi(o.map(e=>Di(e)));return Fi(n).geometry.coordinates}function wt(o,n,t){return o.x>=n.x&&o.x<=t.x&&o.y>=n.y&&o.y<=t.y}function Ss(o){let n=0,t=new pe;for(let e=1;e<o.length;e++){let i=new pe(o[e-1][0],o[e-1][1],0),r=new pe(o[e][0],o[e][1],0),s=r.distanceTo(i);s>n&&(n=s,t=r.clone().sub(i).normalize())}return t}function S(o,n){return Math.sqrt((n[0]-o[0])**2+(n[1]-o[1])**2)}function J(o){let n=0;for(let t=0;t<o.length-1;t++)n+=S(o[t],o[t+1]);return n}function Tt(o,n,t){let e=new Y(n[0]-o[0],n[1]-o[1]),i=new Y(n[0]-t[0],n[1]-t[1]),s=e.angleTo(i)*180/Math.PI,l=new Y(n[0]-o[0],n[1]-o[1]);return new Y(t[0]-o[0],t[1]-o[1]).cross(l)>0?s:-s}function Ve(o,n){let t=Math.min(S(o[0][0],o[0][1]),S(o[0][2],o[0][1]))-1;n||(n=St(o[0]));let e=Ui(n,t),i=new Y(o[0][0][0],o[0][0][1]),r=new Y(o[0][1][0],o[0][1][1]),s=new Y(o[0][2][0],o[0][2][1]),u=(i.distanceTo(r)>r.distanceTo(s)?r.clone().sub(i):s.clone().sub(r)).angleTo(new Y(0,1)),a=new Mt;return a.multiply(new Mt().translate(n[0],n[1])).multiply(new Mt().rotate(u)).multiply(new Mt().translate(-n[0],-n[1])),[e.map(c=>{let p=new Y(c[0],c[1]).applyMatrix3(a);return[p.x,p.y]})]}function Ui(o,n){let t=n/2;return[[o[0]-t,o[1]+t],[o[0]+t,o[1]+t],[o[0]+t,o[1]-t],[o[0]-t,o[1]-t],[o[0]-t,o[1]+t]]}function He(o,n){let t=0,e=1/0,[i,r]=n;for(let s=0;s<o.length-1;s++){let[l,u]=o[s],[a,c]=o[s+1],p=Math.min(l,a)<=i&&i<=Math.max(l,a),f=Math.min(u,c)<=r&&r<=Math.max(u,c);if(p&&f){let m=Math.abs((a-l)*(r-u)-(c-u)*(i-l));m<e&&(e=m,t=s)}}return t}function We(o,n){let t=o[0],e=o[1],i=!1;for(let r=0,s=n.length-1;r<n.length;s=r++){let l=n[r][0],u=n[r][1],a=n[s][0],c=n[s][1];u>e!=c>e&&t<(a-l)*(e-u)/(c-u)+l&&(i=!i)}return i}function ut(o,n){return new Proxy(o,{get:(t,e,i)=>Reflect.get(t,e,i),set:(t,e,i,r)=>{let s=Reflect.get(t,e,r),l=Reflect.set(t,e,i,r);return s!==i&&n.dispatchEvent({type:`change-${e}`,value:i}),l}})}function rt(o,n){return Promise.race([o,new Promise((t,e)=>{setTimeout(()=>e(new Error("Promise timeout")),n)})])}function Ct(o){return document.createElementNS("http://www.w3.org/2000/svg",o)}function Xe(o,n){let t=Ct("svg");return t.setAttribute("width",o),t.setAttribute("height",n),t.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",t}function mt(o="2",n){let t=Ct("circle");return t.setAttribute("r",o),t.setAttribute("fill",n),t}function Pt(o){let n=Ct("line");return n.setAttribute("stroke",o),n}function ct(o,n){let t=Ct("rect");return t.setAttribute("stroke",o),t.setAttribute("fill",n),t}function ot(o,n,t){o.setAttribute("cx",`${n}`),o.setAttribute("cy",`${t}`)}function O(o,n,t){n&&(o.setAttribute("x1",`${n.x}`),o.setAttribute("y1",`${n.y}`)),t&&(o.setAttribute("x2",`${t.x}`),o.setAttribute("y2",`${t.y}`))}function F(o,n,t,e,i){o.setAttribute("x",`${n}`),o.setAttribute("y",`${t}`),o.setAttribute("width",`${e}`),o.setAttribute("height",`${i}`)}function qe(){return Promise.resolve()}function Ls(){return new Promise(o=>{requestAnimationFrame(o)})}function Rs(o){return parseInt(o.replace("#","0x"),16)}function Is(o,n){let t=parseInt(o.substring(1,3),16),e=parseInt(o.substring(3,5),16),i=parseInt(o.substring(5,7),16),r=Math.round(t*n),s=Math.round(e*n),l=Math.round(i*n);return`#${(1<<24|r<<16|s<<8|l).toString(16).slice(1)}`}function $(o,n=.85){let t,e,i;if(o.startsWith("#"))t=parseInt(o.substring(1,3),16),e=parseInt(o.substring(3,5),16),i=parseInt(o.substring(5,7),16);else{let s=o.slice(4,-1).split(",");t=parseInt(s[0].trim()),e=parseInt(s[1].trim()),i=parseInt(s[2].trim())}return t=Math.min(Math.floor(t*n),255),e=Math.min(Math.floor(e*n),255),i=Math.min(Math.floor(i*n),255),"#"+((1<<24)+(t<<16)+(e<<8)+i).toString(16).slice(1)}import{GLTFLoader as Bi}from"three/examples/jsm/loaders/GLTFLoader";function Gi(){return new Bi}var Lt=null,At=new Map;function Rt(o){if(At.has(o)){let t=At.get(o).then(e=>(e.scene=e.scene.clone(),e))}Lt||(Lt=Gi());let n=new Promise((t,e)=>{Lt.load(o,i=>{t(i)},void 0,e)});return At.set(o,n),n.then(t=>(t.scene=t.scene.clone(),t))}function je(){Lt=null,At.clear()}var It=navigator.userAgent.toUpperCase().indexOf("MAC")>=0;function fe(o){return It?o==="Meta":o==="Control"}var de="__once__",Ye=class{events=new Map;on(n,t){if(typeof t!="function")return;let e=this.events.get(n);return e?e.add(t):this.events.set(n,new Set([t]))}once(n,t){if(typeof t!="function")return;let e=`${de}${n}`,i=this.events.get(e);return i?i.add(t):this.events.set(e,new Set([t]))}off(n,t){let e=this.events.get(n),i=this.events.get(`${de}${n}`);!e&&!i||(t===void 0&&(e?.clear(),i?.clear()),e?.has(t)&&e.delete(t),i?.has(t)&&i.delete(t))}offAll(){this.events.clear()}emit(n,...t){let e=this.events.get(n),i=this.events.get(`${de}${n}`);!e&&!i||(e?.forEach(r=>{typeof r=="function"&&r(...t)}),i?.forEach(r=>{typeof r=="function"&&r(...t)}),i?.clear())}};var yt=(t=>(t.SWITCH_FLOOR_BEFORE="switch_floor_before",t.SWITCH_FLOOR_AFTER="switch_floor_after",t))(yt||{});function U(o){return Object.keys(o).sort().map(n=>`${n}=${o[n]}`).join("&")}function Hs(o,n){return new Promise((t,e)=>{let i=new XMLHttpRequest;i.open("GET",o,!0),Object.keys(n.headers||{}).forEach(r=>{i.setRequestHeader(r,n.headers[r])}),n.responseType&&(i.responseType=n.responseType),i.onload=()=>{if(i.status>=200&&i.status<300)if(n.responseType==="arraybuffer")t(i.response);else try{let r=JSON.parse(i.responseText);t(r)}catch(r){e(r)}else e(i.statusText)},i.onerror=()=>{e(i.statusText)},i.send()})}var ht=class o{keySet=new Set;static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}genUniqueKey(){let n=o.createKey();for(;this.keySet.has(n);)n=o.createKey();return n}removeKey(n){this.keySet.delete(n)}dispose(){this.keySet.clear()}};var tn=ce(Qe(),1);import{Vector2 as _t}from"three";function zi(o,n){let t=o.clone().normalize(),e=n.clone().normalize();return Math.acos(t.dot(e))}function ki(o){let n=0;return o.reduce(([t,e],[i,r])=>(n+=Math.sqrt((i-t)**2+(r-e)**2),[i,r])),n/o.length}function en(o,n=.25){if(ki(o)<n)return o;let t=(0,tn.default)(o);return en(t,n)}function nn(o,n=!1,t=!0,e=5,i=150,r=3){let s=[],l=!n;if(s.push(o[0]),o.length<2)return s;for(let a=0;a<o.length-2;a+=1){let c=o[a],p=o[a+1],f=o[a+2],m=new _t(c[0]-p[0],c[1]-p[1]),h=new _t(f[0]-p[0],f[1]-p[1]),d=zi(m,h)/Math.PI*180,g=m.length()+h.length();(!l||d<i&&g>.01||g>e)&&(s.push(o[a+1]),l=!0)}if(s.push(o[o.length-1]),!t)return s;let u=[];u.push(s[0]);for(let a=0;a<s.length-2;a+=1){let c=new _t(s[a][0],s[a][1]),p=new _t(s[a+1][0],s[a+1][1]),f=new _t(s[a+2][0],s[a+2][1]),m=c.distanceTo(p)/2,h=f.distanceTo(p)/2,d=p.clone(),g=p.clone();d.add(c.clone().sub(p).normalize().multiplyScalar(m>r?r/2:m)),g.add(f.clone().sub(p).normalize().multiplyScalar(h>r?r/2:h));let y=[[d.x,d.y],[p.x,p.y],[g.x,g.y]];u.push(...en(y,r/25))}return u.push(s[s.length-1]),Vi(u)}function Vi(o){if(o.length<=1)return o;let n=[],t;return o.forEach(([e,i])=>{t?e===t[0]&&i===t[1]||(t=[e,i],n.push([e,i])):(t=[e,i],n.push([e,i]))}),n}function rn(o,n,t){let e=Math.sqrt((t[0]-n[0])**2+(t[1]-n[1])**2);if(e===0)return{distance:Math.sqrt((o[0]-n[0])**2+(o[1]-n[1])**2),closestPoint:n.slice(0)};let i=Math.max(0,Math.min(1,((o[0]-n[0])*(t[0]-n[0])+(o[1]-n[1])*(t[1]-n[1]))/e**2)),r=[n[0]+i*(t[0]-n[0]),n[1]+i*(t[1]-n[1])];return{distance:Math.sqrt((o[0]-r[0])**2+(o[1]-r[1])**2),closestPoint:r}}function on(o,n,t){let[e,i]=o,[r,s]=n,l=Math.sqrt(Math.pow(r-e,2)+Math.pow(s-i,2));if(l===0||l<t)return[...n];let u=t/l,a=e+(r-e)*u,c=i+(s-i)*u;return[a,c]}var Hi=(a=>(a.START="start",a.END="end",a.FRONT="front",a.RIGHT="right",a.LEFT="left",a.RIGHT_FRONT="right_front",a.LEFT_FRONT="left_front",a.RIGHT_BACK="right_back",a.LEFT_BACK="left_back",a))(Hi||{});function Wi(o,n,t){let e=Tt(o,n,t);return 180-Math.abs(e)<15?"front":e>135?"right_front":e<-135?"left_front":e<=135&&e>=60?"right":e>=-135&&e<=-60?"left":e<60&&e>0?"right_back":e>-60&&e<0?"left_back":"front"}function Zs(o){let n=[{direction:"start",distance:S(o[0],o[1]),points:[o[0],o[1]]}];for(let t=2;t<o.length;t++){let e=Wi(o[t-2],o[t-1],o[t]);if(e==="front"){let i=n[n.length-1],r=S(o[t-1],o[t]);i.distance+=r,t!==2&&i.points.push(o[t-1])}else n.push({direction:e,distance:S(o[t-1],o[t]),points:[o[t-1],o[t]]})}return n.push({direction:"end",distance:0,points:[o[o.length-1]]}),n}var k=ce(ye(),1);var I="___",xn=class{constructor(n=3){this.lift_priority=n}roadInfo=[];pointMap=new Map;nodeMap=new Map;facilityMap=new Map;straightLadderMap=new Map;escalatorMap=new Map;staircaseMap=new Map;lineMap=new Map;baseRoute=new k.default;escalatorRoute=new k.default;straightLadderRoute=new k.default;initRoute(n){this.clear(),this.roadInfo=n,n.length&&(n.forEach(t=>{t.points.forEach(e=>{let i=`${t.floor}${I}${e.id}`;if(this.pointMap.set(i,e),this.nodeMap.set(`${e.floor}${I}${e.nodeId}`,i),e.type==="straightLadder"){let r=this.straightLadderMap.get(e.name)||[];r.push({...e}),this.straightLadderMap.set(e.name,r)}if(e.type==="staircase"){let r=this.staircaseMap.get(e.name)||[];r.push({...e}),this.staircaseMap.set(e.name,r)}if(e.type==="escalator"){let r=this.escalatorMap.get(e.name)||{};e.escalatorDirection==="exit"?r.end={floor:e.floor,id:e.id}:r.start={floor:e.floor,id:e.id},this.escalatorMap.set(e.name,r)}if(e.type==="facility"){let r=this.facilityMap.get(e.targetId)||[];r.push({...e}),this.facilityMap.set(e.targetId,r)}}),t.lines.filter(e=>e.direction!=="no").forEach(e=>{let i=`${t.floor}${I}${e.from}`,r=`${t.floor}${I}${e.to}`,s=this.pointMap.get(i)?.cds,l=this.pointMap.get(r)?.cds;if(s?.length&&l?.length){let u=S(s,l);this.addLineItem(i,r,u),e.direction==="double"&&this.addLineItem(r,i,u)}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute())}addLineItem(n,t,e,i=this.lineMap){let r=i.get(n)||new Map;r.set(t,e),i.set(n,r)}addFacilityToLineMap(n,t,e,i){[...this.straightLadderMap,...this.staircaseMap].forEach(([r,s])=>{if(!(s.length<2))for(let l=0;l<s.length;l++){let u=`${s[l].floor}${I}${s[l].id}`;for(let a=0;a<s.length;a++)if(l!==a){let c=`${s[a].floor}${I}${s[a].id}`,p=this.pointMap.get(u)?.cds,f=this.pointMap.get(c)?.cds;if(p?.length&&f?.length)if(s[l].type==="straightLadder"){let m=t;this.addLineItem(u,c,m,i)}else{let m=e;this.addLineItem(u,c,m,i)}}}}),this.escalatorMap.forEach((r,s)=>{if(r.start&&r.end){let l=`${r.start.floor}${I}${r.start.id}`,u=`${r.end.floor}${I}${r.end.id}`,a=this.pointMap.get(l)?.cds,c=this.pointMap.get(u)?.cds;if(a?.length&&c?.length){let p=n;this.addLineItem(l,u,p,i)}}})}initBaseRoute(){let n=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,n),this.baseRoute=new k.default(n)}initEscalatorRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(1*t,this.lift_priority*t,3e4*t,n),this.escalatorRoute=new k.default(n)}initStraightLadderRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(3*t,1*t,3e4*t,n),this.straightLadderRoute=new k.default(n)}checkStart(n){return!(!n.floor||!n.nodeId&&(!n.coord||n.coord.length<2))}checkEnd(n){return n.facility?!0:this.checkStart(n)}transformStart(n){if(n.nodeId){let t=this.nodeMap.get(`${n.floor}${I}${n.nodeId}`);if(t){let[e,i]=t.split(I);return{floor:e,id:i}}}if(n.coord?.length){let t=this.roadInfo.find(i=>i.floor===n.floor);if(!t)return null;let e=t.points.reduce((i,r)=>{let s=S(n.coord,r.cds);return s<i.min&&(i.min=s,i.point=r),i},{min:1/0,point:t.points[0]});return{floor:e.point.floor,id:e.point.id}}return null}transformEnd(n){if(n.floor){let t=this.transformStart(n);if(t)return t}return n.facility&&this.facilityMap.get(n.facility)?.length?{floor:n.floor,facility:n.facility}:null}getPath(n,t,e=""){if(!this.checkStart(n))return"start-error";if(!this.checkEnd(t))return"end-error";let i=this.transformStart(n);if(!i)return"no-start";let r=this.transformEnd(t);if(!r)return"no-end";let s=this.getBasePath.bind(this);switch(e){case"escalator":s=this.getEscalatorPath.bind(this);break;case"straightLadder":s=this.getStraightLadderPath.bind(this);break;default:s=this.getBasePath.bind(this);break}if(console.log(i,r),r.id)return s(i,r);if(r.facility){let l=this.facilityMap.get(r.facility).filter(a=>r.floor?a.floor===r.floor:!0);if(!l.length)return null;let u=l.map(a=>s(i,{floor:a.floor,id:a.id})).filter(a=>!!a);return u.reduce((a,c)=>{let p=c.reduce((f,m)=>f+J(m.points),0);return p<a.distance&&(a.distance=p,a.path=c),a},{distance:1/0,path:u[0]}).path}}getRoutePath(n,t,e){let i=`${n.floor}${I}${n.id}`,r=`${t.floor}${I}${t.id}`,s=e.path(i,r);if(console.log(i,r,s),!s)return null;let l=[];return s.map(u=>{let a=this.pointMap.get(u);if(a){let{floor:c}=a;if(l[l.length-1]?.floor===c){let p=l[l.length-1];p.points.push(a.cds),p.endType=a.type,p.destId=a.nodeId}else l.push({floor:c,points:[a.cds],endType:a.type,destId:a.nodeId})}}),l}getBasePath(n,t){return this.getRoutePath(n,t,this.baseRoute)}getEscalatorPath(n,t){return this.getRoutePath(n,t,this.escalatorRoute)}getStraightLadderPath(n,t){return this.getRoutePath(n,t,this.straightLadderRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new k.default,this.escalatorRoute=new k.default,this.straightLadderRoute=new k.default}};var N=ce(ye(),1);var C="___",En=class{constructor(n=3){this.lift_priority=n}roadInfo=[];pointMap=new Map;nodeMap=new Map;facilityMap=new Map;straightLadderMap=new Map;escalatorMap=new Map;staircaseMap=new Map;parkingMap=new Map;lineMap=new Map;baseRoute=new N.default;escalatorRoute=new N.default;straightLadderRoute=new N.default;forwardLineMap=new Map;forwardRoute=new N.default;initRoute(n){this.clear(),this.roadInfo=n,n.length&&(n.forEach(t=>{t.points.forEach(e=>{let i=`${t.floor}${C}${e.id}`;if(this.pointMap.set(i,e),this.nodeMap.set(`${e.floor}${C}${e.nodeId}`,i),e.type==="straightLadder"){let r=this.straightLadderMap.get(e.name)||[];r.push({...e}),this.straightLadderMap.set(e.name,r)}if(e.type==="staircase"){let r=this.staircaseMap.get(e.name)||[];r.push({...e}),this.staircaseMap.set(e.name,r)}if(e.type==="escalator"){let r=this.escalatorMap.get(e.name)||{};e.escalatorDirection==="exit"?r.end={floor:e.floor,id:e.id}:r.start={floor:e.floor,id:e.id},this.escalatorMap.set(e.name,r)}if(e.type==="facility"){let r=this.facilityMap.get(e.targetId)||[];r.push({...e}),this.facilityMap.set(e.targetId,r)}e.type==="parkingSpace"&&this.parkingMap.set(`${e.floor}${C}${e.name}`,e)}),t.lines.filter(e=>e.direction!=="no").forEach(e=>{let i=`${t.floor}${C}${e.from}`,r=`${t.floor}${C}${e.to}`,s=this.pointMap.get(i)?.cds,l=this.pointMap.get(r)?.cds;if(s?.length&&l?.length){let u=S(s,l);switch(this.addLineItem(i,r,u),this.addLineItem(r,i,u),e.direction){case"double":this.addLineItem(i,r,u,this.forwardLineMap),this.addLineItem(r,i,u,this.forwardLineMap);break;case"single":this.addLineItem(i,r,u,this.forwardLineMap);break;case"back":this.addLineItem(r,i,u,this.forwardLineMap);break}}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}addLineItem(n,t,e,i=this.lineMap){let r=i.get(n)||new Map;r.set(t,e),i.set(n,r)}addFacilityToLineMap(n,t,e,i){[...this.straightLadderMap,...this.staircaseMap].forEach(([r,s])=>{if(!(s.length<2))for(let l=0;l<s.length;l++){let u=`${s[l].floor}${C}${s[l].id}`;for(let a=0;a<s.length;a++)if(l!==a){let c=`${s[a].floor}${C}${s[a].id}`,p=this.pointMap.get(u)?.cds,f=this.pointMap.get(c)?.cds;if(p?.length&&f?.length)if(s[l].type==="straightLadder"){let m=t;this.addLineItem(u,c,m,i)}else{let m=e;this.addLineItem(u,c,m,i)}}}}),this.escalatorMap.forEach((r,s)=>{if(r.start&&r.end){let l=`${r.start.floor}${C}${r.start.id}`,u=`${r.end.floor}${C}${r.end.id}`,a=this.pointMap.get(l)?.cds,c=this.pointMap.get(u)?.cds;if(a?.length&&c?.length){let p=n;this.addLineItem(l,u,p,i)}}})}initBaseRoute(){let n=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,n),this.baseRoute=new N.default(n)}initEscalatorRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(1*t,this.lift_priority*t,3e4*t,n),this.escalatorRoute=new N.default(n)}initStraightLadderRoute(){let n=new Map([...this.lineMap]),t=1e4;this.addFacilityToLineMap(3*t,1*t,3e4*t,n),this.straightLadderRoute=new N.default(n)}initForwardRoute(){this.forwardRoute=new N.default(this.forwardLineMap)}checkStart(n){return!(!n.floor||!n.nodeId&&(!n.coord||n.coord.length<2))}checkEnd(n){return n.facility||n.parkingSpace&&n.floor?!0:this.checkStart(n)}transformStart(n){if(n.nodeId){let t=this.nodeMap.get(`${n.floor}${C}${n.nodeId}`);if(t){let[e,i]=t.split(C);return{floor:e,id:i}}}if(n.coord?.length){let t=this.roadInfo.find(i=>i.floor===n.floor);if(!t)return null;let e=t.points.reduce((i,r)=>{let s=S(n.coord,r.cds);return s<i.min&&(i.min=s,i.point=r),i},{min:1/0,point:t.points[0]});return{floor:e.point.floor,id:e.point.id}}return null}transformEnd(n){if(n.floor){if(n.parkingSpace){let e=this.parkingMap.get(`${n.floor}${C}${n.parkingSpace}`);if(e)return{floor:e.floor,id:e.id}}let t=this.transformStart(n);if(t)return t}return n.facility&&this.facilityMap.get(n.facility)?.length?{floor:n.floor,facility:n.facility}:null}getPath(n,t,e=""){if(!this.checkStart(n))return"start-error";if(!this.checkEnd(t))return"end-error";let i=this.transformStart(n);if(!i)return"no-start";let r=this.transformEnd(t);if(!r)return"no-end";let s=this.getBasePath.bind(this);switch(e){case"escalator":s=this.getEscalatorPath.bind(this);break;case"straightLadder":s=this.getStraightLadderPath.bind(this);break;case"forward":s=this.getForwardPath.bind(this);break;default:s=this.getBasePath.bind(this);break}if(r.id)return s(i,r);if(r.facility){let l=this.facilityMap.get(r.facility).filter(a=>r.floor?a.floor===r.floor:!0);if(!l.length)return null;let u=l.map(a=>s(i,{floor:a.floor,id:a.id})).filter(a=>!!a);return u.reduce((a,c)=>{let p=c.reduce((f,m)=>f+J(m.points),0);return p<a.distance&&(a.distance=p,a.path=c),a},{distance:1/0,path:u[0]}).path}}getRoutePath(n,t,e){let i=`${n.floor}${C}${n.id}`,r=`${t.floor}${C}${t.id}`,s=e.path(i,r);if(!s)return null;let l=[];return s.map(u=>{let a=this.pointMap.get(u);if(a){let{floor:c}=a;if(l[l.length-1]?.floor===c){let p=l[l.length-1];p.points.push(a.cds),p.endType=a.type,p.destId=a.nodeId,p.distance=J(p.points)}else l.push({floor:c,points:[a.cds],endType:a.type,destId:a.nodeId,distance:0})}}),l}getBasePath(n,t){return this.getRoutePath(n,t,this.baseRoute)}getEscalatorPath(n,t){return this.getRoutePath(n,t,this.escalatorRoute)}getStraightLadderPath(n,t){return this.getRoutePath(n,t,this.straightLadderRoute)}getForwardPath(n,t){return this.getRoutePath(n,t,this.forwardRoute)}clear(){this.roadInfo=[],this.pointMap.clear(),this.nodeMap.clear(),this.facilityMap.clear(),this.straightLadderMap.clear(),this.escalatorMap.clear(),this.staircaseMap.clear(),this.lineMap.clear(),this.baseRoute=new N.default,this.escalatorRoute=new N.default,this.straightLadderRoute=new N.default}};function bn(o){return o.replace(/[A-Z]/g,n=>"_"+n.toLowerCase()).replace(/^_/,"")}var Mn=new ht;function pt(o,n,t){return new Promise((e,i)=>{let r=Mn.genUniqueKey(),s=({data:l})=>{l.type===`${n}_result`&&l.key===r&&(Mn.removeKey(r),self.removeEventListener("message",s),l.error?i(l.error):e(l.data))};o.addEventListener("message",s),o.postMessage({type:n,key:r,data:t})})}function ca(o){let n={};for(let e in o)e.startsWith("on")&&(n[bn(e.slice(2))]=o[e]);let t=async({data:e})=>{if(n[e.type])try{let i=await n[e.type](e.data);self.postMessage({type:`${e.type}_result`,key:e.key,data:i})}catch(i){self.postMessage({type:`${e.type}_result`,key:e.key,error:i})}else self.postMessage({type:`${e.type}_result`,key:e.key,error:"no_event"})};return self.addEventListener("message",t),()=>{self.removeEventListener("message",t)}}import{EventDispatcher as Lo,Box2 as Ao,Vector3 as Q,Vector2 as dt,Raycaster as Ro,Box3 as Io,Color as No,AmbientLight as Do}from"three";import{Group as Oo,Tween as ie}from"@tweenjs/tween.js";import{EventDispatcher as _o}from"three";import{Object3D as Yi,ExtrudeGeometry as $i,Mesh as Zi,Box3 as Nt,Vector3 as B,BufferGeometry as Ki,LineSegments as Ji,Ray as Sn,Vector2 as Z}from"three";var _e={id:"",height:.1,airHeight:0,area:0,group:"",fillColor:"#EFF4FB",strokeColor:"#ffffff",fillOpacity:1,strokeOpacity:1,strokeWidth:1,doors:[],locked:!1,visible:!0,geometry:{type:"polygon",cds:[],coords:[],curveCpt:[],curveIndex:[]},layerType:"",zIndex:0,stroke:!0,deltaHeight:0,userData:{},gradualColor:[],renderType:"single",colorFactor:.9},w=class extends Yi{constructor(t,e){super();this.context=t;if(this.options=ut({..._e,...e},this),this.options.geometry.type==="point"){let[i,r]=this.options.geometry.coords;return this.position.set(i,r,this.options.height+this.options.airHeight),this}this.init(),this.visible=this.options.visible,this.addEventListener("change-fillColor",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-fillOpacity",({value:i})=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-height",({value:i})=>{this.dispose(),this.init()}),this.addEventListener("change-strokeColor",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-strokeOpacity",({value:i})=>{this.options.stroke&&(this.initLineMaterial(),this.createBorder())}),this.addEventListener("change-airHeight",({value:i})=>{this.position.z=i}),this.addEventListener("change-visible",({value:i})=>{this.visible=i}),this.addEventListener("change-stroke",({value:i})=>{if(i){if(this.line)return;this.initLineGeometry(),this.initLineMaterial(),this.createBorder()}else this.line&&(this.remove(this.line),this.lineGeometry?.dispose())}),this.addEventListener("change-renderType",()=>{this.initMaterial(),this.initMesh()}),this.addEventListener("change-gradualColor",()=>{this.initMaterial(),this.initMesh()})}geometry;material;mesh;line;lineMaterial;lineGeometry;options;getCenter(){if(this.options.geometry.type==="point")return this.position.clone();let t=new B,e=new Nt;return e.setFromObject(this),e.getCenter(t),t}getSize(){if(this.options.geometry.type==="point")return new B(0,0,0);let t=new Nt,e=new B;return t.setFromObject(this),t.getSize(e),e}getPosition(){let t=this.getCenter();return t.setZ(t.z+this.options.height/2),t}init(){this.initDoor(),this.geometry=this.initGeometry(),this.initMaterial(),this.initMesh(),this.mesh.position.z=this.options.airHeight+this.options.deltaHeight,this.options.stroke&&this.options.strokeOpacity!==0&&(this.initLineMaterial(),this.initLineGeometry(),this.createBorder())}initDoor(){if(this.options.doors&&this.options.geometry.type==="polygon"){let t=this.options.geometry.coords[0];this.options.doors.forEach(e=>{let i=e.type==="single"?.5:1,r=.5,s=He(t,e.coord),l=new Z(...e.coord),u=new Z(...t[s]).sub(new Z(...e.coord)).normalize(),a=new Z().addVectors(l,u.clone().multiplyScalar(i)),c=new Z().addVectors(l,u.clone().multiplyScalar(-i)),p=new Z(-u.y,u.x),f=new Z().addVectors(a,p.clone().multiplyScalar(r));We([f.x,f.y],t)||(p.multiplyScalar(-1),f=new Z().addVectors(a,p.clone().multiplyScalar(r)));let m=new Z().addVectors(c,p.clone().multiplyScalar(r)),h=[[a.x,a.y],[f.x,f.y],[m.x,m.y],[c.x,c.y]];this.options.geometry.coords=[[...t.slice(0,s+1),...h,...t.slice(s+1)]],t=this.options.geometry.coords[0]})}}initGeometry(){let t=z(this.options.geometry.coords[0],this.options.geometry.coords.slice(1));return new $i(t,{steps:1,bevelEnabled:!1,depth:this.options.height,curveSegments:4})}initSingleMaterial(){let t=this.context.materialFactory.createMeshBasicMaterial({color:this.options.fillColor,opacity:this.options.fillOpacity});if(this.options.height<=.1)return this.material=t,t;let e=this.context.materialFactory.createMeshBasicMaterial({color:$(this.options.fillColor),opacity:this.options.fillOpacity});return this.material=[t,e],[t,e]}getMaxAndMin(t,e){let i=new Nt().setFromObject(this),r=t.clone().add(e.clone().multiplyScalar(1e3)),s=new Sn(r,e.clone().multiplyScalar(-1)),l=new B;s.intersectBox(i,l);let u=t.clone().add(e.clone().multiplyScalar(-1e3)),a=new Sn(u,e.clone()),c=new B;return a.intersectBox(i,c),{max:c,min:l}}initGradualMaterial(){let{max:t,min:e}=new Nt().setFromObject(this),i=t.clone().sub(e),r=Math.max(i.x,i.y,i.z)/2,s=this.getPosition(),l=new B(-1,.2,0).normalize(),{max:u,min:a}=this.getMaxAndMin(s,l),c=this.context.materialFactory.createShaderMaterial({gradualColor:this.options.gradualColor,center:this.getPosition(),maxValue:r,opacity:this.options.fillOpacity,direction:new B(-1,.2,0),max:u,min:a});if(this.options.height<=.1)return this.material=c,c;let p=this.getCenter(),f=new B(-1,.2,1).normalize(),{max:m,min:h}=this.getMaxAndMin(p,f),d=this.context.materialFactory.createShaderMaterial({gradualColor:[$(this.options.gradualColor[0],this.options.colorFactor),$(this.options.gradualColor[1],this.options.colorFactor)],center:this.getCenter(),maxValue:r,opacity:this.options.fillOpacity,direction:new B(-1,.2,1),max:m,min:h});return this.material=[c,d],[c,d]}initMaterial(){return this.options.renderType==="gradual"?this.initGradualMaterial():this.initSingleMaterial()}initLineMaterial(){let t=this.context.materialFactory.createLineMaterial({color:this.options.strokeColor,opacity:this.options.strokeOpacity});return this.lineMaterial=t,t}initMesh(){this.mesh&&this.remove(this.mesh),this.mesh=new Zi(this.geometry,this.material),this.add(this.mesh)}getBorderPoints(){let t=[],e=this.options.height+this.options.deltaHeight,{coords:i}=this.options.geometry;for(let r=0;r<i.length;r++){let s=i[r];for(let l=0;l<s.length;l++){let u=s[l],a=l+1===s.length?s[0]:s[l+1];t.push(new B(u[0],u[1],e)),t.push(new B(a[0],a[1],e))}}return t}initLineGeometry(){this.lineGeometry&&this.lineGeometry.dispose();let t=this.getBorderPoints(),e=new Ki().setFromPoints(t);this.lineGeometry=e}createBorder(){this.line&&this.remove(this.line);let t=new Ji(this.lineGeometry,this.lineMaterial);return t.position.z=this.options.airHeight+.01,this.line=t,this.add(t),t}raycast(t){if(!this.visible||this.options.geometry.type==="point")return!1;this.mesh.updateMatrixWorld(!0);let e=t.intersectObject(this.mesh);if(e[0]){let{point:i,distance:r}=e[0];return{position:i,distance:r}}return!1}dispose(){this.geometry?.dispose(),this.line?.geometry.dispose(),this.clear()}};import{Object3D as Qi,PlaneGeometry as tr,Mesh as er,ShadowMaterial as nr,Color as ir,DoubleSide as rr}from"three";var Dt=class extends Qi{directionalLight;plane;basicOpacity=.07;constructor(){super(),this.directionalLight=this.initLight(),this.initPlane()}initLight(){let n=Oe(16777215,.5);return n.position.set(0,0,100),this.add(n),n}changeLightCamera(n){let t=n.x,e=n.y;this.directionalLight.shadow.camera.left=-t,this.directionalLight.shadow.camera.right=t,this.directionalLight.shadow.camera.top=e,this.directionalLight.shadow.camera.bottom=-e,this.directionalLight.shadow.camera.near=.5,this.directionalLight.shadow.camera.far=Math.max(t,e)}changeLightColor(n){this.directionalLight.color=new ir(n)}setPosition(n){this.position.copy(n),this.directionalLight.position.set(-n.x/2,-n.y/2,100)}initPlane(n=1e3,t=1e3){let e=new tr(n,t),i=new nr({transparent:!0,opacity:0,side:rr}),r=new er(e,i);return r.receiveShadow=!0,r.position.z=-10,this.add(r),this.plane=r,r}setTarget(n){this.directionalLight.target=n}transformOpacity(n){return n*this.basicOpacity}setOpacity(n){this.plane.material.opacity=this.transformOpacity(n)}dispose(){D(this,!0)}};import{EventDispatcher as lr,Vector3 as ur}from"three";import{Box3 as wn,EventDispatcher as or,Vector3 as M}from"three";import{debounce as sr}from"lodash";var ar={autoUpdate:!0,appendToBody:!1,autoChangePlacement:!1},Ot=class extends or{constructor(t,e={}){super();this.context=t;this.options={...ar,...e},this.registryEvent(),this.div=this.initDiv(),this.options.appendToBody?document.body.appendChild(this.div):this.context.container.appendChild(this.div)}div;element;position=new M;clientPos={x:0,y:0};visible=!0;options;placement="top";observer=null;initObserver(){let t=new MutationObserver(sr(()=>{this.div&&this.usePlacement()},100));t.observe(this.div,{childList:!0,subtree:!0,attributes:!0}),this.observer=t}getPlacementPosition(){if(this.element instanceof w&&this.element.options.geometry.type==="polygon"){let{max:r,min:s}=new wn().setFromObject(this.element),l=(r.x+s.x)/2,u=(r.y+s.y)/2;return{left:new M(s.x,u,r.z),leftTop:new M(s.x,r.y,r.z),top:new M(l,r.y,r.z),rightTop:new M(r.x,r.y,r.z),right:new M(r.x,u,r.z),rightBottom:new M(r.x,s.y,r.z),bottom:new M(l,s.y,r.z),leftBottom:new M(s.x,s.y,r.z),center:new M(l,u,r.z)}}let{x:t,y:e,z:i}=this.element?.getPosition?.()||this.position;return{left:new M(t,e,i),leftTop:new M(t,e,i),top:new M(t,e,i),rightTop:new M(t,e,i),right:new M(t,e,i),rightBottom:new M(t,e,i),bottom:new M(t,e,i),leftBottom:new M(t,e,i),center:new M(t,e,i)}}getPlacementScreenPosition(){let{width:t,height:e}=this.context.clientSize,i=this.getPlacementPosition();return Object.keys(i).reduce((r,s)=>{let{x:l,y:u}=v(i[s],this.context.camera,t,e);return r[s]={x:l,y:u},r},{})}checkOverflow(t,e){let{width:i,height:r}=this.context.clientSize;return e.x>0&&t.x<i&&e.y<r&&t.y>0}getPlacement(){let{clientWidth:t,clientHeight:e}=this.div,i=this.getPlacementScreenPosition(),r=t/2,s=e/2,l=[{type:"center",getBox(u,a){return{max:{x:r+u,y:a-e},min:{x:u-r,y:a}}}},{type:"left",getBox(u,a){return{max:{x:u,y:a-s},min:{x:u-t,y:a+s}}}},{type:"leftTop",getBox(u,a){return{max:{x:u,y:a-e},min:{x:u-t,y:a}}}},{type:"top",getBox(u,a){return{max:{x:u+r,y:a-e},min:{x:u-r,y:a}}}},{type:"rightTop",getBox(u,a){return{max:{x:u+t,y:a-e},min:{x:u,y:a}}}},{type:"right",getBox(u,a){return{max:{x:u+t,y:a-s},min:{x:u,y:a+s}}}},{type:"rightBottom",getBox(u,a){return{max:{x:u+t,y:a},min:{x:u,y:a+e}}}},{type:"bottom",getBox(u,a){return{max:{x:u+r,y:a},min:{x:u-r,y:a+e}}}},{type:"leftBottom",getBox(u,a){return{max:{x:u,y:a},min:{x:u-t,y:a+s}}}}];for(let u=0;u<l.length;u++){let a=l[u],c=i[a.type],{max:p,min:f}=a.getBox(c.x,c.y);if(this.checkOverflow(p,f))return{type:a.type,position:c}}return{type:"center",position:i.center}}initDiv(){let t=document.createElement("div");return t.style.position="absolute",t}usePlacement(){let t=this.getPlacement();this.div.className=`overlay_${t.type}`,this._updatePosition(t.position.x,t.position.y)}bindElement(t){this.element=t,this.options.autoChangePlacement&&this.initObserver(),this.onUpdate()}unBindElement(){this.element=void 0}setVisible(t,e="block"){t!==this.visible&&(this.div.style.display=t?e:"none",this.visible=t)}setOpacity(t){this.div.style.opacity=`${t}`}getPosition(){return this.element?typeof this.element.getPosition=="function"?this.element.getPosition():new wn().setFromObject(this.element).getCenter(new M):this.position}get withinDisplayRange(){let{x:t,y:e}=this.clientPos,{width:i,height:r}=this.context.clientSize;return t>=0&&t<=i&&e>=0&&e<=r}_updatePosition(t,e){this.clientPos={x:t,y:e};let{width:i,height:r,x:s,y:l}=this.context.clientSize;this.options.appendToBody&&(this.div.style.left=`${s}px`,this.div.style.top=`${l+r}px`),this.options.autoUpdate?this.div.style.transform=`translate3d(${t}px, ${-r+e}px, 0)`:this.dispatchEvent({type:"update-position",x:t,y:e,width:i,height:r})}updatePosition(t=!1){let e=this.getPosition(),{width:i,height:r}=this.context.clientSize,{x:s,y:l}=v(e,this.context.camera,i,r);this.clientPos.x===s&&this.clientPos.y===l&&!t||this._updatePosition(s,l)}onUpdate=()=>{this.options.autoChangePlacement?this.usePlacement():this.updatePosition()};registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.unRegistryEvent(),this.unBindElement(),this.observer?.disconnect(),this.div?.remove(),this.div=null}};var cr={texts:[{text:""}],level:1,icon_position:"bottom",collision_enable:!0,opacity:1,id:"",position:{x:0,y:0,z:0},icon_opacity:1,icon_border:{color:"#586EE0",width:0},background:"",collision_hide_icon:!0,built_in:!1,box_only_icon:!1},st=class extends lr{constructor(t,e){super();this.context=t;this.options=ut({...cr,...e},this),this.position.set(e.position?.x||0,e.position?.y||0,e.position?.z||0),this.overlay=new Ot(this.context,{autoUpdate:!1}),this.overlay.addEventListener("update-position",({x:i,y:r,height:s})=>{this.overlay.div.style.transform=`translate3d(calc(${i}px - 50%), calc(${-s+r}px - ${this.options.icon&&this.options.icon_position!=="center"?"100%":"50%"}), 0)`}),this.overlay.bindElement(this),this.registryEvent(),this.initDiv(),this.addEventListener("change-icon",({value:i})=>{i?this.img?this.img.setAttribute("src",i):(this.addIcon(),this._changePosition()):(this.img&&this.div.removeChild(this.img),this.img=void 0,this._changePosition(),this.resetSize())}),this.addEventListener("change-texts",({value:i})=>{let r=this.textDiv;if(r){let s=this.initText();this.div.replaceChild(s,r)}else this.addText();this.resetSize()}),this.addEventListener("change-opacity",({value:i})=>{this.overlay.setOpacity(i)}),this.addEventListener("change-icon_size",({value:i})=>{this.img&&(this.img.style.width=`${i?.[0]||32}px`,this.img.style.height=`${i?.[1]||32}px`,this.resetSize())}),this.addEventListener("change-icon_opacity",({value:i})=>{this.img&&(this.img.style.opacity=`${i}`)}),this.addEventListener("change-icon_border",({value:i})=>{this.img&&(this.img.style.border=`${i.width}px solid ${i.color}`)}),this.addEventListener("change-background",({value:i})=>{this.div.style.background=i})}div;textDiv;img;overlay;options;visible=!0;size={width:0,height:0};position=new ur;userData={};showTextStatus=!0;disposed=!1;get withinDisplayRange(){return this.overlay.withinDisplayRange}async resetSize(){if(await qe(),!this.disposed)if(this.options.box_only_icon){if(!this.img)return;let{width:t,height:e}=this.img.getBoundingClientRect();this.size={width:t+2,height:e+2}}else{let{width:t,height:e}=this.div.getBoundingClientRect();this.size={width:t+2,height:e+2}}}renderHelperBox(){}get clientPos(){return this.overlay.clientPos}initDiv(){let t=document.createElement("div");return this.div=t,this.addText(),this.options.icon&&this.addIcon(),t.style.fontSize="12px",t.style.textShadow="#fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0",t.style.display="flex",t.style.flexDirection="column",t.style.justifyContent="center",t.style.alignItems="center",t.style.padding="4px",this.overlay.setOpacity(this.options.opacity),this.overlay.div.style.pointerEvents="none",this.overlay.div.style.userSelect="none",this.overlay.div.appendChild(t),this.resetSize(),t}addIcon(){if(!this.img){let t=this.initIcon();this.options.icon_position==="top"?this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t):this.div.appendChild(t)}}addText(){let t=this.initText();this.options.icon_position==="top"?this.div.appendChild(t):this.div.firstChild?this.div.insertBefore(t,this.div.firstChild):this.div.appendChild(t)}getPosition(){return this.position}initText(){let t=document.createElement("div");return t.appendChild(this.createTextFragment()),t.style.textAlign="center",this.textDiv=t,t}createTextFragment(){let t=document.createDocumentFragment();return this.options.texts.forEach(e=>{let i=document.createElement("div");if(i.style.whiteSpace="nowrap",e.styles)for(let[r,s]of Object.entries(e.styles))i.style[r]=s;i.textContent=e.text,t.appendChild(i)}),t}initIcon(){let t=document.createElement("img");return t.setAttribute("src",this.options.icon),t.style.width=`${this.options.icon_size?.[0]||32}px`,t.style.height=`${this.options.icon_size?.[1]||32}px`,t.style.opacity=`${this.options.icon_opacity}px`,t.style.borderRadius="50%",this.options.icon_border.width&&(t.style.border=`${this.options.icon_border.width}px solid ${this.options.icon_border.color}`),t.onload=()=>{this.resetSize()},this.img=t,t}_changePosition=()=>{this.overlay.updatePosition(!0)};registryEvent(){}unRegistryEvent(){}setVisible(t){t!==this.visible&&(this.visible=t,this.changeOverlayVisible(t))}changeOverlayVisible(t){if(!(t===this.overlay.visible&&this.options.collision_hide_icon))if(this.options.collision_hide_icon)this.overlay.visible=t,this.overlay.div.style.visibility=t?"visible":"hidden";else{if(this.showTextStatus===t)return;this.textDiv.style.visibility=t?"visible":"hidden",this.showTextStatus=t}}parentSetVisible(t){this.visible&&this.changeOverlayVisible(t)}getBox(t=this.context.config.poi.boxScale){let{width:e,height:i}=this.size,r=e*t,s=i*t,{x:l,y:u}=this.overlay.clientPos;return{left:l-r/2,right:l+r/2,top:this.options.icon?u-s:u-s/2,bottom:this.options.icon?u:u+s/2}}getOriginBox(){return this.getBox(1)}isContain(t,e){if(!this.overlay.visible||!this.visible)return!1;let i=this.getOriginBox();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}dispose(){this.unRegistryEvent(),this.div=null,this.textDiv=null,this.img=void 0,this.overlay.dispose(),this.disposed=!0}};import{Box3 as zt,Object3D as ve,Vector3 as kt}from"three";import{MeshBasicMaterial as hr,Object3D as pr,PlaneGeometry as fr,Texture as dr,DoubleSide as gr,Mesh as mr,Matrix3 as Tn,Vector2 as yr}from"three";import{create as _r}from"@mars3d/heatmap.js";import{featureCollection as vr,point as xr,bbox as Er,center as br}from"@turf/turf";var Ft=class extends pr{constructor(t){super();this.context=t;this.div=document.createElement("div")}heatmap;div;plane;clearHeatmap(){this.div.firstChild&&this.div.removeChild(this.div.firstChild),this.heatmap=void 0}loadData(t){this.clearHeatmap();let{width:e,height:i,leftTop:r,center:s}=this.getBox(t);this.heatmap=_r({width:e,height:i,container:this.div,...this.context.config.heatMap}),this.heatmap.setData(this.transformData(t,r)),this.initPlane(e,i),this.position.set(s[0],s[1],this.position.z)}initPlane(t,e){this.plane&&this.remove(this.plane);let i=new fr(t,e),r=new dr(this.div.firstChild);r.needsUpdate=!0;let s=new hr({transparent:!0,side:gr,map:r});s.needsUpdate=!0,this.plane=new mr(i,s),this.add(this.plane)}getTransMatrix({x:t,y:e}){return new Tn().makeScale(1,-1).multiply(new Tn().makeTranslation(0-t,0-e))}transformData(t,e){let i=this.getTransMatrix(e);return{data:t.data.map(s=>{let l=new yr(s.x,s.y).applyMatrix3(i);return{x:l.x,y:l.y,value:s.value}}),max:t.max,min:t.min}}getBox(t){let e=vr(t.data.map(a=>xr([a.x,a.y]))),i=Er(e),r=i[2]-i[0],s=i[3]-i[1],l={x:i[0],y:i[3]},u=br(e);return{width:r,height:s,leftTop:l,center:u.geometry.coordinates}}dispose(){this.div=null,this.heatmap=void 0}};import{Object3D as Mr,Vector3 as Sr}from"three";var Ut=class extends Mr{constructor(t,e){super();this.context=t;this.options=e;this.position.copy(e.position||new Sr(0,0,0)),this.loadModel()}model=null;async loadModel(){let t=await Rt(this.options.modelUrl);t.scene.rotation.set(Math.PI/2,Math.PI/2,0),this.add(t.scene),this.model=t}dispose(){D(this),this.model=null}};import{Box3 as Tr,Vector3 as Cr}from"three";import{Object3D as wr}from"three";var T=class extends wr{constructor(t){super();this.context=t}dispose(){D(this),this.children.forEach(t=>t.dispose?.()),this.clear()}};var Bt=class extends T{graphicMap=new Map;constructor(n){super(n)}getCenter(){return new Tr().setFromObject(this).getCenter(new Cr)}createGraphic(n){let t=new w(this.context,n);return this.add(t),this.graphicMap.set(n.id,t),t}removeGraphic(n){this.remove(n),this.graphicMap.delete(n.options.id),n.dispose()}removeGraphicById(n){this.graphicMap.has(n)&&this.removeGraphic(this.graphicMap.get(n))}getGraphicByNodeId(n){return this.graphicMap.get(n)||null}getGraphicByRaycaster(n){let t={distance:1e4,graphic:null,position:null},e=this.children.reduce((i,r)=>{if(r instanceof w){let s=r.raycast(n);if(s){let{distance:l}=s;if(l<i.distance)return{distance:s.distance,position:s.position,graphic:r}}return i}else return i},t);return e===t?{graphics:[],position:null}:{graphics:[e.graphic],position:e.position}}};import{debounce as Pr}from"lodash";var ft=class extends T{pois=[];debounceCollisionDetection;timer=new R;constructor(n){super(n),this.registryEvent(),this.debounceCollisionDetection=Pr(this.collisionDetection,10)}clear(n=!1){return this.pois.forEach(t=>{t.options.built_in&&!n||t.dispose()}),this.pois=n?[]:this.pois.filter(t=>t.options.built_in),this}createPoi(n){let t=new st(this.context,n);return this.pushPoi(t),t.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(t)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),t}changePoiLevelOrCollisionEnable(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.pois.splice(t,1),this.pushPoi(n))}removePoi(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.pois.splice(t,1),n.dispose())}removePoiById(n){let t=this.pois.find(e=>e.options.id===n);t&&this.removePoi(t)}getPoiById(n){return this.pois.find(e=>e.options.id===n)||null}pushPoi(n){if(!n.options.collision_enable){this.pois.unshift(n);return}if(n.options.level===0){this.pois.push(n);return}for(let t=0;t<this.pois.length;t++){let e=this.pois[t];if(e.options.collision_enable&&e.options.level<=n.options.level){this.pois.splice(t,0,n);return}}this.pois.push(n)}getPoiByDeviceXy(n,t){return this.pois.filter(i=>i instanceof st&&i.isContain(n,t))}onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})};collisionDetection(){let n=[];this.pois.filter(e=>e.visible&&e.withinDisplayRange).forEach((e,i)=>{let{left:r,right:s,top:l,bottom:u}=e.getBox();if(i===0||!e.options.collision_enable){n.push({left:r,right:s,top:l,bottom:u}),e.parentSetVisible(!0);return}let a=n.some(c=>c.left<s&&c.right>r&&c.top<u&&c.bottom>l);e.parentSetVisible(!a),a||n.push({left:r,right:s,top:l,bottom:u})})}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}dispose(){this.timer.dispose(),this.pois.forEach(n=>n.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};import{debounce as Lr}from"lodash";import{Vector2 as Ar,Vector3 as Rr}from"three";var Gt=class extends T{pois=[];debounceCollisionDetection;timer=new R;constructor(n){super(n),this.registryEvent(),this.debounceCollisionDetection=Lr(this.collisionDetection,10)}clear(){return this.pois.forEach(n=>{n.dispose()}),this.pois=[],this}createPoi(n){let t=new P(this.context,n);return this.pushPoi(t),t.addEventListener("change-level",()=>this.changePoiLevelOrCollisionEnable(t)),t.addEventListener("change-collision_enable",()=>this.changePoiLevelOrCollisionEnable(t)),Promise.resolve().then(()=>{this.debounceCollisionDetection()}),t}changePoiLevelOrCollisionEnable(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.pois.splice(t,1),this.pushPoi(n))}removePoi(n){let t=this.pois.findIndex(e=>e===n);t!==-1&&(this.remove(n),this.pois.splice(t,1),n.dispose())}removePoiById(n){let t=this.pois.find(e=>e.options.id===n);t&&this.removePoi(t)}getPoiById(n){return this.pois.find(e=>e.options.id===n)||null}pushPoi(n){if(this.add(n),!n.options.collision_enable){this.pois.unshift(n);return}if(n.options.level===0){this.pois.push(n);return}for(let t=0;t<this.pois.length;t++){let e=this.pois[t];if(e.options.collision_enable&&e.options.level<=n.options.level){this.pois.splice(t,0,n);return}}this.pois.push(n)}getPoiByDeviceXy(n,t){let e=new Ar(n,t);return this.pois.filter(r=>r instanceof P&&r.canSelect&&r.box.containsPoint(e))}changeParkingSpaceVisibleByZoom=()=>{let n=this.parent?.parent;if(n&&n instanceof V){let{clientSize:{width:t,height:e}}=this.context,{max:i,min:r}=n.box,l=Math.min(t/(i.x-r.x),e/(i.y-r.y))*(i.x-r.x)/60;this.pois.filter(u=>u.userData.type==="parkingSpace").map(u=>{let a=this.context.camera.zoom>=l;u.visible=a,a||u.parentSetVisible(a)})}};onUpdate=()=>{this.timer.requestAnimationFrame(()=>{this.collisionDetection()})};collisionDetection(){let n=[],{camera:t}=this.context;t.updateMatrixWorld();let e=s=>s<=1&&s>=-1,i=t.projectionMatrix.clone();i.multiply(t.matrixWorldInverse),this.pois.filter(s=>{if(s.visible){let l=new Rr().setFromMatrixPosition(s.matrixWorld);return l.applyMatrix4(i),s.screenPosition=l,e(l.x)&&e(l.y)&&e(l.z)}return!1}).forEach((s,l)=>{let u=s.getBox(s.screenPosition);if(l===0||!s.options.collision_enable){n.push(u),s.parentSetVisible(!0);return}let a=n.some(c=>c.intersectsBox(u));s.parentSetVisible(!a),a||n.push(u)})}registryEvent(){this.context.addEventListener("update",this.onUpdate),this.context.addEventListener("control-zoom-change",this.changeParkingSpaceVisibleByZoom)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate),this.context.removeEventListener("control-zoom-change",this.changeParkingSpaceVisibleByZoom)}dispose(){this.timer.dispose(),this.pois.forEach(n=>n.dispose()),this.pois.length=0,this.debounceCollisionDetection=()=>{},super.dispose(),this.unRegistryEvent()}};var V=class extends ve{constructor(t){super();this.context=t;this.groundLayer=new T(this.context),this.graphicLayer=new Bt(this.context),this.poiLayer=new ft(this.context),this.poiLayer2=new Gt(this.context),this.wallLayer=new T(this.context),this.textureLayer=new T(this.context),this.glbModelLayer=new T(this.context),this.laneLayer=new T(this.context),this.mergeGraphicLayer=new T(this.context),this.groundUpper.add(this.graphicLayer),this.groundUpper.add(this.poiLayer),this.groundUpper.add(this.poiLayer2),this.groundUpper.add(this.wallLayer),this.groundUpper.add(this.textureLayer),this.groundUpper.add(this.glbModelLayer),this.groundUpper.add(this.laneLayer),this.groundUpper.add(this.mergeGraphicLayer),this.add(this.groundUpper),this.add(this.groundLayer),this.add(this.models)}graphicLayer;poiLayer;poiLayer2;wallLayer;textureLayer;glbModelLayer;laneLayer;mergeGraphicLayer;grounds=new Set;groundLayer;shadow=new Dt;heatmap;groundUpper=new ve;models=new ve;modelMap=new Map;groundMaxHeight=0;name="";key="";box=new zt;getPosition(){return this.box.getCenter(new kt)}createGround(t){let e=new w(this.context,t);this.addGrounds([e])}addGrounds(t){t.forEach(e=>{this.grounds.has(e)||(e.mesh.castShadow=!0,this.grounds.add(e),this.groundLayer.add(e))}),this.changeGroundMaxHeight()}changeGroundMaxHeight(){let t=Array.from(this.grounds);this.groundMaxHeight=this.grounds.size>0?Math.max(...t.map(e=>e.options.height+e.options.airHeight+e.options.deltaHeight)):0,this.groundUpper.position.z=this.groundMaxHeight}get hasElement(){return!!(this.grounds.size||this.graphicLayer.children.length)}getCenter(){return new zt().setFromObject(this).getCenter(new kt)}addModel(t){let e=new Ut(this.context,t);return this.models.add(e),this.modelMap.set(t.id,e),e}addShadow(){let t=new zt().setFromObject(this.groundUpper),e=t.getCenter(new kt),i=t.getSize(new kt);this.shadow.setPosition(e),this.shadow.changeLightCamera(i)}addGraphic(t){return this.graphicLayer.createGraphic(t)}addPoi(t){return this.poiLayer.createPoi(t)}addHeatmap(t){this.heatmap||(this.heatmap=new Ft(this.context),this.add(this.heatmap)),this.heatmap.loadData(t);let e=new zt().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}updateBox(){this.box.setFromObject(this)}dispose(){this.shadow.dispose(),this.groundLayer.dispose(),this.graphicLayer.dispose(),this.poiLayer.dispose(),this.poiLayer2.dispose(),this.wallLayer.dispose(),this.textureLayer.dispose(),this.glbModelLayer.dispose(),this.laneLayer.dispose(),this.mergeGraphicLayer.dispose(),this.grounds.forEach(t=>t.dispose()),this.heatmap?.dispose(),this.groundUpper.clear(),this.models.children.forEach(t=>t.dispose()),this.models.clear(),this.modelMap.clear(),this.clear()}};import{EventDispatcher as Ir,Vector3 as Nr}from"three";var H=class extends Ir{constructor(t){super();this.context=t;this.svg=Xe(`${t.container.clientWidth}`,`${t.container.clientHeight}`),t.container.appendChild(this.svg),this._registryEvent()}points=[];svg;enable=!0;_onResize=({width:t,height:e})=>{this.svg&&(this.svg.setAttribute("width",`${t}`),this.svg.setAttribute("height",`${e}`))};_registryEvent(){this.context.addEventListener("resize",this._onResize)}_unRegistryEvent(){this.context.removeEventListener("resize",this._onResize)}setEnable(t){this.enable=t,t?this.svg.style.display="block":this.svg.style.display="none"}getIntersectByPointerEvent(t){let{camera:e,renderer:i}=this.context,{offsetX:r,offsetY:s}=t,{clientWidth:l,clientHeight:u}=i.domElement,a=r/l*2-1,c=1-s/u*2;return new Nr(a,c,0).unproject(e)}getSvgCoordinate(t){let{camera:e,container:i}=this.context;return v(t,e,i.clientWidth,i.clientHeight)}dispose(){this._unRegistryEvent(),this.context.container.removeChild(this.svg),this.svg=null}};var Vt=class extends H{constructor(t){super(t);this.context=t;let{config:{svg:{circle:e,line:i}}}=t;this.circles=[mt(e.radius,e.fill),mt(e.radius,e.fill)],this.line=Pt(i.stroke),this.svg.appendChild(this.circles[0]),this.svg.appendChild(this.circles[1]),this.svg.appendChild(this.line),this.registryEvent()}circles;line;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)}onUpdate=()=>{if(this.points[0]){let t=this.getSvgCoordinate(this.points[0]);ot(this.circles[0],t.x,t.y),O(this.line,t)}if(this.points[1]){let t=this.getSvgCoordinate(this.points[1]);ot(this.circles[1],t.x,t.y),O(this.line,void 0,t)}};onPointermove=t=>{this.points.length===1&&(this.line.style.display="block",O(this.line,void 0,{x:t.offsetX,y:t.offsetY}))};onPointerleave=()=>{this.points[1]||(this.line.style.display="none")};onPointerdown=t=>{if(this.points[1])return;let e=this.getIntersectByPointerEvent(t);if(e){let{offsetX:i,offsetY:r}=t,s=this.circles[this.points.length];ot(s,i,r),this.points.length||O(this.line,{x:i,y:r},{x:i,y:r}),this.addPoint(e)}};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:r}]=this.points;return Math.sqrt((i-t)**2+(r-e)**2)}dispose(){super.dispose(),this.unRegistryEvent(),this.line=null,this.circles=[]}};var Ht=class extends H{circles=[];lines=[];isClose=!1;constructor(n){super(n),this.registryEvent()}setEnable(n){super.setEnable(n),n?this.registryEvent():this.unRegistryEvent()}get lastLine(){return this.lines.slice(-1)[0]}addCircle(n){this.circles.push(n),this.svg.appendChild(n)}addLine(n){this.lines.push(n),this.svg.appendChild(n)}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)}onUpdate=()=>{this.points.length&&this.points.forEach((n,t)=>{let e=this.getSvgCoordinate(n);this.circles[t]&&ot(this.circles[t],e.x,e.y),t!==0&&O(this.lines[t-1],void 0,e),this.lines[t]&&O(this.lines[t],e)})};onPointermove=n=>{!this.lastLine||this.isClose||(this.lastLine.style.display="block",O(this.lastLine,void 0,{x:n.offsetX,y:n.offsetY}))};onPointerleave=()=>{this.isClose||(this.lastLine.style.display="none")};onPointerdown=n=>{if(this.isClose)return;let t=this.getIntersectByPointerEvent(n);if(t){let{offsetX:e,offsetY:i}=n;this.checkAdsorb(e,i)?(this.isClose=!0,this.addPoint(this.points[0])):this.addPoint(t);let{circle:{fill:r,radius:s},line:{stroke:l}}=this.context.config.svg;if(!this.isClose){let u=mt(s,r);ot(u,e,i),this.addCircle(u)}if(this.lines.length&&O(this.lastLine,void 0,{x:e,y:i}),!this.isClose){let u=Pt(l);O(u,{x:e,y:i},{x:e,y:i}),this.addLine(u)}}};checkAdsorb(n,t){if(this.points.length<3)return!1;let e=this.circles[0],i=+e.getAttribute("cx"),r=+e.getAttribute("cy");return Math.sqrt((n-i)**2+(t-r)**2)<=5}addPoint(n){if(this.points.push(n),this.isClose){let t=this.calculatedArea();this.dispatchEvent({type:"area",area:t})}}calculatedArea(){let n=this.points.map(i=>[i.x,i.y]),t=0,e=n.length;for(let i=0;i<e;i++){let r=(i+1)%e;t+=n[i][0]*n[r][1]-n[r][0]*n[i][1]}return Math.abs(t/2)}dispose(){super.dispose(),this.unRegistryEvent(),this.lines=[],this.circles=[]}};import{Box3 as Dr}from"three";var Cn=class extends H{constructor(t){super(t);this.context=t;let{config:{svg:{line:e}}}=t;this.rect=ct(e.stroke,"transparent"),this.svg.appendChild(this.rect);for(let i=0;i<4;i++)this.cornerRect[i]=ct(e.stroke,"#ffffff"),this.centerRect[i]=ct(e.stroke,"#ffffff"),this.svg.appendChild(this.cornerRect[i]),this.svg.appendChild(this.centerRect[i]);this.registryEvent()}rect;cornerRect=[];centerRect=[];graphic;setEnable(t){super.setEnable(t),t?this.registryEvent():this.unRegistryEvent()}registryEvent(){this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.removeEventListener("update",this.onUpdate)}onUpdate=()=>{if(this.graphic){let t=new Dr().setFromObject(this.graphic),{camera:e,container:{clientWidth:i,clientHeight:r}}=this.context,{min:s,max:l}=t,u=v(s,e,i,r),a=v(l,e,i,r);F(this.rect,u.x,a.y,Math.abs(a.x-u.x),Math.abs(a.y-u.y));let{x:c,y:p}=u,{x:f,y:m}=a,h=5,d=[{x:c-h,y:m-h},{x:f-h,y:m-h},{x:c-h,y:p-h},{x:f-h,y:p-h}];for(let _=0;_<d.length;_++)F(this.cornerRect[_],d[_].x,d[_].y,h*2,h*2);let g=4,y=(c+f)/2,b=(p+m)/2,E=[{x:y-g,y:m-g},{x:c-g,y:b-g},{x:f-g,y:b-g},{x:y-g,y:p-g}];for(let _=0;_<E.length;_++)F(this.centerRect[_],E[_].x,E[_].y,g*2,g*2)}else{F(this.rect,0,0,0,0);for(let t=0;t<this.cornerRect.length;t++)F(this.cornerRect[t],0,0,0,0),F(this.centerRect[t],0,0,0,0)}};selectGraphic(t){this.graphic=t}dispose(){super.dispose(),this.unRegistryEvent(),this.rect=null,this.cornerRect=[],this.centerRect=[]}};import{BufferGeometry as Or,Color as xe,ExtrudeGeometry as Fr,LineSegments as Ur,Mesh as Br,Object3D as Gr,ShaderMaterial as zr,Vector3 as Pn}from"three";import{mergeGeometries as Ln}from"three/examples/jsm/utils/BufferGeometryUtils";var Wt=class extends Gr{constructor(t,e){super();this.context=t;this.options=e;e.length&&this.init()}geometry;material;lineMaterial;lineGeometry;Mesh;LineMesh;initGeometry(){let t=this.options.map(e=>{let i=z(e.geometry.coords[0],e.geometry.coords.slice(1));return new Fr(i,{steps:1,bevelEnabled:!1,depth:e.height,curveSegments:4})});this.geometry=Ln(t),t.forEach(e=>e.dispose())}initMaterial(){let t=`
|
|
2
2
|
varying vec3 vPosition; // \u7528\u4E8E\u4F20\u9012\u9876\u70B9\u7684\u4F4D\u7F6E\u7ED9\u7247\u6BB5\u7740\u8272\u5668
|
|
3
3
|
uniform float maxZ; // \u58F0\u660E\u4E00\u4E2Auniform\u53D8\u91CF
|
|
4
4
|
uniform vec3 uColor;
|