@aibee/crc-bmap 0.14.7 → 0.14.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- var ra=Object.create;var Gs=Object.defineProperty;var aa=Object.getOwnPropertyDescriptor;var ha=Object.getOwnPropertyNames,Go=Object.getOwnPropertySymbols,ca=Object.getPrototypeOf,Fo=Object.prototype.hasOwnProperty,la=Object.prototype.propertyIsEnumerable;var Rs=(a,t,e)=>t in a?Gs(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Ue=(a,t)=>{for(var e in t||(t={}))Fo.call(t,e)&&Rs(a,e,t[e]);if(Go)for(var e of Go(t))la.call(t,e)&&Rs(a,e,t[e]);return a};var ie=(a,t)=>()=>(t||a((t={exports:{}}).exports,t),t.exports);var pa=(a,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ha(t))!Fo.call(a,s)&&s!==e&&Gs(a,s,{get:()=>t[s],enumerable:!(i=aa(t,s))||i.enumerable});return a};var Fs=(a,t,e)=>(e=a!=null?ra(ca(a)):{},pa(t||!a||!a.__esModule?Gs(e,"default",{value:a,enumerable:!0}):e,a));var K=(a,t,e)=>Rs(a,typeof t!="symbol"?t+"":t,e);var f=(a,t,e)=>new Promise((i,s)=>{var o=h=>{try{r(e.next(h))}catch(c){s(c)}},n=h=>{try{r(e.throw(h))}catch(c){s(c)}},r=h=>h.done?i(h.value):Promise.resolve(h.value).then(o,n);r((e=e.apply(a,t)).next())});var Yo=ie((tm,Xo)=>{Xo.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t}});var Jo=ie((em,$o)=>{var qo=Yo();$o.exports=function(a,t){Array.isArray(t)||(t=[]),a.length>0&&t.push(qo([0,0],a[0]));for(var e=0;e<a.length-1;e++){var i=a[e],s=a[e+1],o=i[0],n=i[1],r=s[0],h=s[1],c=[.75*o+.25*r,.75*n+.25*h],l=[.25*o+.75*r,.25*n+.75*h];t.push(c),t.push(l)}return a.length>1&&t.push(qo([0,0],a[a.length-1])),t}});var nn=ie((cm,on)=>{var Ns=class{constructor(){this.keys=new Set,this.queue=[]}sort(){this.queue.sort((t,e)=>t.priority-e.priority)}set(t,e){let i=Number(e);if(isNaN(i))throw new TypeError('"priority" must be a number');return this.keys.has(t)?this.queue.map(s=>(s.key===t&&Object.assign(s,{priority:i}),s)):(this.keys.add(t),this.queue.push({key:t,priority:i})),this.sort(),this.queue.length}next(){let t=this.queue.shift();return this.keys.delete(t.key),t}isEmpty(){return this.queue.length===0}has(t){return this.keys.has(t)}get(t){return this.queue.find(e=>e.key===t)}};on.exports=Ns});var hn=ie((lm,an)=>{function rn(a,t){let e=new Map;for(let[i,s]of a)i!==t&&s instanceof Map?e.set(i,rn(s,t)):i!==t&&e.set(i,s);return e}an.exports=rn});var pn=ie((pm,ln)=>{function ba(a){let t=Number(a);return!(isNaN(t)||t<=0)}function cn(a){let t=new Map;return Object.keys(a).forEach(i=>{let s=a[i];if(s!==null&&typeof s=="object"&&!Array.isArray(s))return t.set(i,cn(s));if(!ba(s))throw new Error(`Could not add node at key "${i}", make sure it's a valid node`,s);return t.set(i,Number(s))}),t}ln.exports=cn});var mn=ie((dm,un)=>{function dn(a){if(!(a instanceof Map))throw new Error(`Invalid graph: Expected Map instead found ${typeof a}`);a.forEach((t,e)=>{if(typeof t=="object"&&t instanceof Map){dn(t);return}if(typeof t!="number"||t<=0)throw new Error(`Values must be numbers greater than 0. Found value ${t} at ${e}`)})}un.exports=dn});var js=ie((um,yn)=>{var Sa=nn(),Ea=hn(),fn=pn(),gn=mn(),Zs=class{constructor(t){t instanceof Map?(gn(t),this.graph=t):t?this.graph=fn(t):this.graph=new Map}addNode(t,e){let i;return e instanceof Map?(gn(e),i=e):i=fn(e),this.graph.set(t,i),this}addVertex(t,e){return this.addNode(t,e)}removeNode(t){return this.graph=Ea(this.graph,t),this}path(t,e,i={}){if(!this.graph.size)return i.cost?{path:null,cost:0}:null;let s=new Set,o=new Sa,n=new Map,r=[],h=0,c=[];if(i.avoid&&(c=[].concat(i.avoid)),c.includes(t))throw new Error(`Starting node (${t}) cannot be avoided`);if(c.includes(e))throw new Error(`Ending node (${e}) cannot be avoided`);for(o.set(t,0);!o.isEmpty();){let l=o.next();if(l.key===e){h=l.priority;let d=l.key;for(;n.has(d);)r.push(d),d=n.get(d);break}s.add(l.key),(this.graph.get(l.key)||new Map).forEach((d,u)=>{if(s.has(u)||c.includes(u))return null;if(!o.has(u))return n.set(u,l.key),o.set(u,l.priority+d);let m=o.get(u).priority,v=l.priority+d;return v<m?(n.set(u,l.key),o.set(u,v)):null})}return r.length?(i.trim?r.shift():r=r.concat([t]),i.reverse||(r=r.reverse()),i.cost?{path:r,cost:h}:r):i.cost?{path:null,cost:0}:null}shortestPath(...t){return this.path(...t)}};yn.exports=Zs});function w(){return w=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},w.apply(this,arguments)}import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.json.stringify.js";import{Box3 as Bp,EventDispatcher as Wp,Sprite as vo,Vector3 as ms}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";var z=class{requestAnimationFrame(t){let e=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(e),t()});return this.tasks.requestAnimation.add(e),e}cancelAnimationFrame(t){this.tasks.requestAnimation.delete(t),window.cancelAnimationFrame(t)}setTimeout(t,e){let i=window.setTimeout(()=>{this.tasks.timeout.delete(i),t()},e);return this.tasks.timeout.add(i),i}clearTimeout(t){this.tasks.timeout.delete(t),window.clearTimeout(t)}setInterval(t,e){let i=window.setInterval(()=>{t()},e);return this.tasks.interval.add(i),i}clearInterval(t){this.tasks.interval.delete(t),window.clearInterval(t)}requestIdleCallback(t,e){let i=window.requestIdleCallback(s=>{this.tasks.requestIdleCallback.delete(i),t(s)},e);return this.tasks.requestIdleCallback.add(i),i}cancelIdleCallback(t){this.tasks.requestIdleCallback.delete(t),window.cancelIdleCallback(t)}dispose(){this.tasks.requestAnimation.forEach(t=>{window.cancelAnimationFrame(t)}),this.tasks.requestAnimation.clear(),this.tasks.requestIdleCallback.forEach(t=>{window.cancelIdleCallback(t)}),this.tasks.requestIdleCallback.clear(),this.tasks.timeout.forEach(t=>{window.clearTimeout(t)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(t=>{window.clearInterval(t)}),this.tasks.interval.clear()}constructor(){this.tasks={requestAnimation:new Set,requestIdleCallback:new Set,timeout:new Set,interval:new Set}}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Shape as da,Group as ua,DirectionalLight as ma,AmbientLight as fa,Path as ga,Vector2 as zo}from"three";function Bo(){let a=new ua,t=new fa(16777215,.3);return a.add(t),a}function hi(a,t){t===void 0&&(t=[]);let e=new da(a.map(i=>new zo(...i)));return t.length&&t.forEach(i=>{var s=new ga(i.map(o=>new zo(...o)));e.holes.push(s)}),e}function Wo(a,t){a===void 0&&(a=16777215),t===void 0&&(t=1);let e=new ma(a,t);return e.castShadow=!0,e.shadow.radius=8,e.shadow.bias=-.001,e.shadow.mapSize.set(256,256),e.shadow.camera.left=-200,e.shadow.camera.right=200,e.shadow.camera.top=200,e.shadow.camera.bottom=-200,e}function D(a,t){if(t&&a.children&&a.children.length&&a.children.forEach(e=>{D(e,t)}),a.isMesh){let e=a;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}a.isLight&&(a.dispose==null||a.dispose.call(a))}import"core-js/modules/es.regexp.exec.js";function Uo(a){return/[\u4E00-\u9FA5]+/g.test(a)}import"core-js/modules/web.dom-collections.iterator.js";import{Vector3 as li,Vector2 as zt,Matrix3 as ci}from"three";import{point as ya,featureCollection as va,center as xa}from"@turf/turf";function C(a,t,e,i){let s=a.clone().project(t),o=e/2,n=i/2,r=Math.round(s.x*o+o),h=Math.round(-s.y*n+n);return{x:r,y:h}}function vu(a,t,e,i,s){if(!s)return null;e=Math.min(1,e),i=Math.min(1,i);let o=a/e*2-1,n=1-t/i*2;return new li(o,n,0).unproject(s)}function pi(a){let t=va(a.map(i=>ya(i)));return xa(t).geometry.coordinates}function Yt(a,t,e){return a.x>=t.x&&a.x<=e.x&&a.y>=t.y&&a.y<=e.y}function xu(a){let t=0,e=new li;for(let i=1;i<a.length;i++){let s=new li(a[i-1][0],a[i-1][1],0),o=new li(a[i][0],a[i][1],0),n=o.distanceTo(s);n>t&&(t=n,e=o.clone().sub(s).normalize())}return e}function k(a,t){return Math.sqrt((t[0]-a[0])**2+(t[1]-a[1])**2)}function ht(a){let t=0;for(let e=0;e<a.length-1;e++)t+=k(a[e],a[e+1]);return t}function me(a,t,e){let i=new zt(t[0]-a[0],t[1]-a[1]),s=new zt(t[0]-e[0],t[1]-e[1]),n=i.angleTo(s)*180/Math.PI,r=new zt(t[0]-a[0],t[1]-a[1]);return new zt(e[0]-a[0],e[1]-a[1]).cross(r)>0?n:-n}function wu(a,t){let e=Math.min(k(a[0][0],a[0][1]),k(a[0][2],a[0][1]))-1;t||(t=pi(a[0]));let i=wa(t,e),s=new zt(a[0][0][0],a[0][0][1]),o=new zt(a[0][1][0],a[0][1][1]),n=new zt(a[0][2][0],a[0][2][1]),h=(s.distanceTo(o)>o.distanceTo(n)?o.clone().sub(s):n.clone().sub(o)).angleTo(new zt(0,1)),c=new ci;return c.multiply(new ci().translate(t[0],t[1])).multiply(new ci().rotate(h)).multiply(new ci().translate(-t[0],-t[1])),[i.map(l=>{let p=new zt(l[0],l[1]).applyMatrix3(c);return[p.x,p.y]})]}function wa(a,t){let e=t/2;return[[a[0]-e,a[1]+e],[a[0]+e,a[1]+e],[a[0]+e,a[1]-e],[a[0]-e,a[1]-e],[a[0]-e,a[1]+e]]}function Bt(a,t){let e=0,i=1/0,[s,o]=t;for(let n=0;n<a.length-1;n++){let[r,h]=a[n],[c,l]=a[n+1],p=Math.min(r,c)<=s&&s<=Math.max(r,c),d=Math.min(h,l)<=o&&o<=Math.max(h,l);if(p&&d){let u=Math.abs((c-r)*(o-h)-(l-h)*(s-r));u<i&&(i=u,e=n)}}return e}function Ho(a,t){let e=a[0],i=a[1],s=!1;for(let o=0,n=t.length-1;o<t.length;n=o++){let r=t[o][0],h=t[o][1],c=t[n][0],l=t[n][1];h>i!=l>i&&e<(c-r)*(i-h)/(l-h)+r&&(s=!s)}return s}import"core-js/modules/es.reflect.to-string-tag.js";function fe(a,t){return new Proxy(a,{get:(e,i,s)=>Reflect.get(e,i,s),set:(e,i,s,o)=>{let n=Reflect.get(e,i,o),r=Reflect.set(e,i,s,o);return n!==s&&t.dispatchEvent({type:"change-"+i,value:s}),r}})}import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.error.cause.js";function ft(a,t){return Promise.race([a,new Promise((e,i)=>{setTimeout(()=>i(new Error("Promise timeout")),t)})])}function di(a){return document.createElementNS("http://www.w3.org/2000/svg",a)}function No(a,t){let e=di("svg");return e.setAttribute("width",a),e.setAttribute("height",t),e.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",e}function He(a,t){a===void 0&&(a="2");let e=di("circle");return e.setAttribute("r",a),e.setAttribute("fill",t),e}function ui(a){let t=di("line");return t.setAttribute("stroke",a),t}function qt(a,t){let e=di("rect");return e.setAttribute("stroke",a),e.setAttribute("fill",t),e}function se(a,t,e){a.setAttribute("cx",""+t),a.setAttribute("cy",""+e)}function Mt(a,t,e){t&&(a.setAttribute("x1",""+t.x),a.setAttribute("y1",""+t.y)),e&&(a.setAttribute("x2",""+e.x),a.setAttribute("y2",""+e.y))}function ot(a,t,e,i,s){a.setAttribute("x",""+t),a.setAttribute("y",""+e),a.setAttribute("width",""+i),a.setAttribute("height",""+s)}function Zo(){return Promise.resolve()}function zs(){return new Promise(a=>{requestAnimationFrame(a)})}function jo(a){return a===void 0&&(a=1),new Promise(t=>{function e(){a<=0?t(!0):(a--,window.requestAnimationFrame(e))}window.requestAnimationFrame(e)})}import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.trim.js";function Au(a){return parseInt(a.replace("#","0x"),16)}function Ou(a,t){let e=parseInt(a.substring(1,3),16),i=parseInt(a.substring(3,5),16),s=parseInt(a.substring(5,7),16),o=Math.round(e*t),n=Math.round(i*t),r=Math.round(s*t);return"#"+(1<<24|o<<16|n<<8|r).toString(16).slice(1)}function Wt(a,t){t===void 0&&(t=.85);let e,i,s;if(a.startsWith("#"))e=parseInt(a.substring(1,3),16),i=parseInt(a.substring(3,5),16),s=parseInt(a.substring(5,7),16);else{let n=a.slice(4,-1).split(",");e=parseInt(n[0].trim()),i=parseInt(n[1].trim()),s=parseInt(n[2].trim())}return e=Math.min(Math.floor(e*t),255),i=Math.min(Math.floor(i*t),255),s=Math.min(Math.floor(s*t),255),"#"+((1<<24)+(e<<16)+(i<<8)+s).toString(16).slice(1)}function Bs(a,t){a=a.replace(/^#/,"");let e=parseInt(a.substring(0,2),16),i=parseInt(a.substring(2,4),16),s=parseInt(a.substring(4,6),16);return t!==void 0?"rgba("+e+", "+i+", "+s+", "+t+")":"rgb("+e+", "+i+", "+s+")"}import"core-js/modules/es.regexp.exec.js";var ge=navigator.userAgent.toUpperCase().indexOf("MAC")>=0,Vo=(navigator.userAgent||"").toLocaleLowerCase(),Ut=/ios|iphone/i.test(Vo),Gu=/android|adr|linux/gi.test(Vo);function ye(a){return ge?a==="Meta":a==="Control"}import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";var Ws="__once__",Ko=class{on(t,e){if(typeof e!="function")return;let i=this.events.get(t);return i?i.add(e):this.events.set(t,new Set([e]))}once(t,e){if(typeof e!="function")return;let i=""+Ws+t,s=this.events.get(i);return s?s.add(e):this.events.set(i,new Set([e]))}off(t,e){let i=this.events.get(t),s=this.events.get(""+Ws+t);!i&&!s||(e===void 0&&(i==null||i.clear(),s==null||s.clear()),i!=null&&i.has(e)&&i.delete(e),s!=null&&s.has(e)&&s.delete(e))}offAll(){this.events.clear()}emit(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];let o=this.events.get(t),n=this.events.get(""+Ws+t);!o&&!n||(o==null||o.forEach(r=>{typeof r=="function"&&r(...i)}),n==null||n.forEach(r=>{typeof r=="function"&&r(...i)}),n==null||n.clear())}constructor(){this.events=new Map}};var it=function(a){return a.SWITCH_FLOOR_BEFORE="switch_floor_before",a.SWITCH_FLOOR_GROUND="switch_floor_ground",a.SWITCH_FLOOR_AFTER="switch_floor_after",a}({});import"core-js/modules/es.array.sort.js";function oe(a){return Object.keys(a).sort().map(t=>t+"="+a[t]).join("&")}function Ju(a,t){return new Promise((e,i)=>{let s=new XMLHttpRequest;s.open("GET",a,!0),Object.keys(t.headers||{}).forEach(o=>{s.setRequestHeader(o,t.headers[o])}),t.responseType&&(s.responseType=t.responseType),s.onload=()=>{if(s.status>=200&&s.status<300)if(t.responseType==="arraybuffer")e(s.response);else try{let o=JSON.parse(s.responseText);e(o)}catch(o){i(o)}else i(s.statusText)},s.onerror=()=>{i(s.statusText)},s.send()})}var Qo=Fs(Jo(),1);import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Vector2 as Ne}from"three";function Ma(a,t){let e=a.clone().normalize(),i=t.clone().normalize();return Math.acos(e.dot(i))}function _a(a){let t=0;return a.reduce((e,i)=>{let[s,o]=e,[n,r]=i;return t+=Math.sqrt((n-s)**2+(r-o)**2),[n,r]}),t/a.length}function tn(a,t){if(t===void 0&&(t=.25),_a(a)<t)return a;let e=(0,Qo.default)(a);return tn(e,t)}function mi(a,t,e,i,s,o){t===void 0&&(t=!1),e===void 0&&(e=!0),i===void 0&&(i=5),s===void 0&&(s=150),o===void 0&&(o=3);let n=[],r=!t;if(n.push(a[0]),a.length<2)return n;for(let c=0;c<a.length-2;c+=1){let l=a[c],p=a[c+1],d=a[c+2],u=new Ne(l[0]-p[0],l[1]-p[1]),m=new Ne(d[0]-p[0],d[1]-p[1]),v=Ma(u,m)/Math.PI*180,g=u.length()+m.length();(!r||v<s&&g>.01||g>i)&&(n.push(a[c+1]),r=!0)}if(n.push(a[a.length-1]),!e)return n;let h=[];h.push(n[0]);for(let c=0;c<n.length-2;c+=1){let l=new Ne(n[c][0],n[c][1]),p=new Ne(n[c+1][0],n[c+1][1]),d=new Ne(n[c+2][0],n[c+2][1]),u=l.distanceTo(p)/2,m=d.distanceTo(p)/2,v=p.clone(),g=p.clone();v.add(l.clone().sub(p).normalize().multiplyScalar(u>o?o/2:u)),g.add(d.clone().sub(p).normalize().multiplyScalar(m>o?o/2:m));let x=[[v.x,v.y],[p.x,p.y],[g.x,g.y]];h.push(...tn(x,o/25))}return h.push(n[n.length-1]),Pa(h)}function Pa(a){if(a.length<=1)return a;let t=[],e;return a.forEach(i=>{let[s,o]=i;e?s===e[0]&&o===e[1]||(e=[s,o],t.push([s,o])):(e=[s,o],t.push([s,o]))}),t}function en(a,t,e){let i=Math.sqrt((e[0]-t[0])**2+(e[1]-t[1])**2);if(i===0)return{distance:Math.sqrt((a[0]-t[0])**2+(a[1]-t[1])**2),closestPoint:t.slice(0)};let s=Math.max(0,Math.min(1,((a[0]-t[0])*(e[0]-t[0])+(a[1]-t[1])*(e[1]-t[1]))/i**2)),o=[t[0]+s*(e[0]-t[0]),t[1]+s*(e[1]-t[1])];return{distance:Math.sqrt((a[0]-o[0])**2+(a[1]-o[1])**2),closestPoint:o}}function rm(a,t,e){let[i,s]=a,[o,n]=t,r=Math.sqrt(Math.pow(o-i,2)+Math.pow(n-s,2));if(r===0||r<e)return[...t];let h=e/r,c=i+(o-i)*h,l=s+(n-s)*h;return[c,l]}var Ht=function(a){return 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}({});function Us(a,t,e){let i=me(a,t,e);return Hs(i)}function Hs(a){return 180-Math.abs(a)<15?"front":a>135?"right_front":a<-135?"left_front":a<=135&&a>=60?"right":a>=-135&&a<=-60?"left":a<60&&a>0?"right_back":a>-60&&a<0?"left_back":"front"}function am(a){if(!a.length)return[];if(a.length===1)return[{direction:"start",distance:0,points:a}];let t=[{direction:"start",distance:k(a[0],a[1]),points:[a[0],a[1]]}];for(let e=2;e<a.length;e++){let i=Us(a[e-2],a[e-1],a[e]);if(i==="front"){let s=t[t.length-1],o=k(a[e-1],a[e]);s.distance+=o,e!==2&&s.points.push(a[e-1])}else t.push({direction:i,distance:k(a[e-1],a[e]),points:[a[e-1],a[e]]})}return t.push({direction:"end",distance:0,points:[a[a.length-1]]}),t}function sn(a,t){if(a.length<2)return-1;let e=0;for(let i=1;i<a.length;i++){let s=a[i-1],o=a[i],n=[t[0]-s[0],t[1]-s[1]],r=[o[0]-s[0],o[1]-s[1]],h=Math.min(o[0],s[0])<=t[0]&&t[0]<=Math.max(o[0],s[0]),c=Math.min(o[1],s[1])<=t[1]&&t[1]<=Math.max(o[1],s[1]);if(h&&c){let l=n[0]*r[1]-n[1]*r[0];if(Math.abs(l)<1e-6){let p=Math.sqrt((t[0]-s[0])**2+(t[1]-s[1])**2);return e+p}}e+=Math.sqrt((o[0]-s[0])**2+(o[1]-s[1])**2)}return-1}function ve(a,t){if(a.length<2){var e;return(e=a[0])!=null?e:null}let i=0;for(let s=1;s<a.length;s++){let o=a[s-1],n=a[s],r=Math.sqrt((n[0]-o[0])**2+(n[1]-o[1])**2);if(i+=r,i>=t){let h=(t-(i-r))/r,c=o[0]+(n[0]-o[0])*h,l=o[1]+(n[1]-o[1])*h;return[c,l]}}return null}var Tt=Fs(js(),1);import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.regexp.exec.js";var gt="___",vn=class{initRoute(t){this.clear(),this.roadInfo=t,t.length&&(t.forEach(e=>{e.points.forEach(i=>{let s=""+e.floor+gt+i.id;if(this.pointMap.set(s,i),this.nodeMap.set(""+i.floor+gt+i.nodeId,s),i.type==="straightLadder"){let o=this.straightLadderMap.get(i.name)||[];o.push(w({},i)),this.straightLadderMap.set(i.name,o)}if(i.type==="staircase"){let o=this.staircaseMap.get(i.name)||[];o.push(w({},i)),this.staircaseMap.set(i.name,o)}if(i.type==="escalator"){let o=this.escalatorMap.get(i.name)||{};i.escalatorDirection==="exit"?o.end={floor:i.floor,id:i.id}:o.start={floor:i.floor,id:i.id},this.escalatorMap.set(i.name,o)}if(i.type==="facility"){let o=this.facilityMap.get(i.targetId)||[];o.push(w({},i)),this.facilityMap.set(i.targetId,o)}}),e.lines.filter(i=>i.direction!=="no").forEach(i=>{var s,o;let n=""+e.floor+gt+i.from,r=""+e.floor+gt+i.to,h=(s=this.pointMap.get(n))==null?void 0:s.cds,c=(o=this.pointMap.get(r))==null?void 0:o.cds;if(h!=null&&h.length&&(c!=null&&c.length)){let l=k(h,c);this.addLineItem(n,r,l),i.direction==="double"&&this.addLineItem(r,n,l)}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute())}addLineItem(t,e,i,s){s===void 0&&(s=this.lineMap);let o=s.get(t)||new Map;o.set(e,i),s.set(t,o)}addFacilityToLineMap(t,e,i,s){[...this.straightLadderMap,...this.staircaseMap].forEach(o=>{let[n,r]=o;if(!(r.length<2))for(let l=0;l<r.length;l++){let p=""+r[l].floor+gt+r[l].id;for(let d=0;d<r.length;d++)if(l!==d){var h,c;let u=""+r[d].floor+gt+r[d].id,m=(h=this.pointMap.get(p))==null?void 0:h.cds,v=(c=this.pointMap.get(u))==null?void 0:c.cds;if(m!=null&&m.length&&(v!=null&&v.length))if(r[l].type==="straightLadder"){let g=e;this.addLineItem(p,u,g,s)}else{let g=i;this.addLineItem(p,u,g,s)}}}}),this.escalatorMap.forEach((o,n)=>{if(o.start&&o.end){var r,h;let c=""+o.start.floor+gt+o.start.id,l=""+o.end.floor+gt+o.end.id,p=(r=this.pointMap.get(c))==null?void 0:r.cds,d=(h=this.pointMap.get(l))==null?void 0:h.cds;if(p!=null&&p.length&&(d!=null&&d.length)){let u=t;this.addLineItem(c,l,u,s)}}})}initBaseRoute(){let t=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,t),this.baseRoute=new Tt.default(t)}initEscalatorRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(1*e,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new Tt.default(t)}initStraightLadderRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(3*e,1*e,3e4*e,t),this.straightLadderRoute=new Tt.default(t)}checkStart(t){return!(!t.floor||!t.nodeId&&(!t.coord||t.coord.length<2))}checkEnd(t){return t.facility?!0:this.checkStart(t)}transformStart(t){var e;if(t.nodeId){let i=this.nodeMap.get(""+t.floor+gt+t.nodeId);if(i){let[s,o]=i.split(gt);return{floor:s,id:o}}}if((e=t.coord)!=null&&e.length){let i=this.roadInfo.find(o=>o.floor===t.floor);if(!i)return null;let s=i.points.reduce((o,n)=>{let r=k(t.coord,n.cds);return r<o.min&&(o.min=r,o.point=n),o},{min:1/0,point:i.points[0]});return{floor:s.point.floor,id:s.point.id}}return null}transformEnd(t){if(t.floor){let e=this.transformStart(t);if(e)return e}if(t.facility){let e=this.facilityMap.get(t.facility);if(e!=null&&e.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,i){if(i===void 0&&(i=""),!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let s=this.transformStart(t);if(!s)return"no-start";let o=this.transformEnd(e);if(!o)return"no-end";let n=this.getBasePath.bind(this);switch(i){case"escalator":n=this.getEscalatorPath.bind(this);break;case"straightLadder":n=this.getStraightLadderPath.bind(this);break;default:n=this.getBasePath.bind(this);break}if(o.id)return n(s,o);if(o.facility){let r=this.facilityMap.get(o.facility).filter(c=>o.floor?c.floor===o.floor:!0);if(!r.length)return null;let h=r.map(c=>n(s,{floor:c.floor,id:c.id})).filter(c=>!!c);return h.reduce((c,l)=>{let p=l.reduce((d,u)=>d+ht(u.points),0);return p<c.distance&&(c.distance=p,c.path=l),c},{distance:1/0,path:h[0]}).path}}getRoutePath(t,e,i){let s=""+t.floor+gt+t.id,o=""+e.floor+gt+e.id,n=i.path(s,o);if(!n)return null;let r=[];return n.map(h=>{let c=this.pointMap.get(h);if(c){var l;let{floor:p}=c;if(((l=r[r.length-1])==null?void 0:l.floor)===p){let d=r[r.length-1];d.points.push(c.cds),d.endType=c.type,d.destId=c.nodeId,d.distance=ht(d.points)}else r.push({floor:p,points:[c.cds],endType:c.type,destId:c.nodeId,distance:0})}}),r}getBasePath(t,e){return this.getRoutePath(t,e,this.baseRoute)}getEscalatorPath(t,e){return this.getRoutePath(t,e,this.escalatorRoute)}getStraightLadderPath(t,e){return this.getRoutePath(t,e,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 Tt.default,this.escalatorRoute=new Tt.default,this.straightLadderRoute=new Tt.default}constructor(t=3){this.lift_priority=t,this.roadInfo=[],this.pointMap=new Map,this.nodeMap=new Map,this.facilityMap=new Map,this.straightLadderMap=new Map,this.escalatorMap=new Map,this.staircaseMap=new Map,this.lineMap=new Map,this.baseRoute=new Tt.default,this.escalatorRoute=new Tt.default,this.straightLadderRoute=new Tt.default}};var tt=Fs(js(),1);import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{cloneDeep as $t,isNil as fi}from"lodash";import{Vector2 as Vs}from"three";var T="___",xn=class{setLiftPriority(t){this.lift_priority=t}isFacilityByType(t){return["facility","escalator","straightLadder","staircase","ramp","connectionPoint"].includes(t)}initFacilities(t){this.facilities=t.map(e=>{let i=[];try{i=JSON.parse(e.entry_end_floor)}catch(o){i=[]}let s=[];try{s=JSON.parse(e.entry_start_floor)}catch(o){s=[]}return w({},e,{entry_start_floor:s,entry_end_floor:i})})}getParkingSpaceInfo(t,e){let i=""+t+T+e;var s;return(s=this.parkingMap.get(i))!=null?s:null}getNodeInfo(t,e){let i=""+t+T+e,s=this.nodeMap.get(i);if(!(s!=null&&s.length))return null;let o=this.pointMap.get(s[0]);return o!=null?o:null}initRoute(t,e){this.clear(),this.roadInfo=t,this.initFacilities(e);let i=new Date,s=i.getHours()*60+i.getMinutes();t.length&&(t.forEach(o=>{let n=(o.points||[]).filter(r=>!fi(r.passWeight)&&r.passWeight!==1&&!fi(r.coverageArea)&&r.coverageArea!==0);(o.points||[]).filter(r=>r.openStatus!==!1).filter(r=>{if(!r.startTime||!r.endTime)return!0;let[h,c]=r.startTime.split(":").map(m=>+m),[l,p]=r.endTime.split(":").map(m=>+m),d=h*60+c,u=l*60+p;return s>=d&&s<=u}).forEach(r=>{r.floor=o.floor;let h=""+o.floor+T+r.id,c=""+o.floor+T+r.nodeId,l=this.nodeMap.get(c)||[];if(l.push(""+o.floor+T+(r.relatedId||r.id)),this.nodeMap.set(""+o.floor+T+r.nodeId,l),this.pointMap.set(h,r),this.isFacilityByType(r.type)){let p=this.facilities.find(d=>d.id===+r.targetId);if(p){switch(p.entry_infra_type){case"straightLadder":if(p.entry_end_floor.find(g=>g.floor===o.floor)&&p.entry_start_floor.find(g=>g.floor===o.floor)){let g=this.straightLadderMap.get(r.targetId)||[];g.push(w({},r)),this.straightLadderMap.set(r.targetId,g)}break;case"staircase":if(p.entry_end_floor.find(g=>g.floor===o.floor)&&p.entry_start_floor.find(g=>g.floor===o.floor)){let g=this.staircaseMap.get(r.targetId)||[];g.push(w({},r)),this.staircaseMap.set(r.targetId,g)}break;case"escalator":let u=this.escalatorMap.get(r.targetId)||[];if(p.entry_start_floor.find(g=>g.floor===o.floor)){let g=u.find(x=>{var M;return((M=x.end)==null?void 0:M.floor)!==o.floor&&!x.start});g?g.start=r:u.push({start:r})}if(p.entry_end_floor.find(g=>g.floor===o.floor)){let g=u.find(x=>{var M;return((M=x.start)==null?void 0:M.floor)!==o.floor&&!x.end});g?g.end=r:u.push({end:r})}this.escalatorMap.set(r.targetId,u);break;case"ramp":let m=this.rampMap.get(r.targetId)||[];if(p.entry_start_floor.find(g=>g.floor===o.floor)){let g=m.find(x=>{var M;return((M=x.end)==null?void 0:M.floor)!==o.floor&&!x.start});g?g.start=r:m.push({start:r})}if(p.entry_end_floor.find(g=>g.floor===o.floor)){let g=m.find(x=>{var M;return((M=x.start)==null?void 0:M.floor)!==o.floor&&!x.end});g?g.end=r:m.push({end:r})}this.rampMap.set(r.targetId,m);break;case"connectionPoint":let v=this.connectionPointMap.get(r.targetId)||[];if(p.entry_start_floor.find(g=>g.floor===o.floor)){let g=v.find(x=>{var M;return((M=x.end)==null?void 0:M.floor)!==o.floor&&!x.start});g?g.start=r:v.push({start:r})}if(p.entry_end_floor.find(g=>g.floor===o.floor)){let g=v.find(x=>{var M;return((M=x.start)==null?void 0:M.floor)!==o.floor&&!x.end});g?g.end=r:v.push({end:r})}this.connectionPointMap.set(r.targetId,v);break}let d=this.facilityMap.get(r.targetId)||[];d.push(w({},r)),this.facilityMap.set(r.targetId,d)}}r.type==="parkingSpace"&&r.name.split(/[,,]/).forEach(d=>{this.parkingMap.set(""+o.floor+T+d,r)})}),(o.lines||[]).filter(r=>r.to!==r.from).forEach(r=>{let h=""+o.floor+T+r.from,c=""+o.floor+T+r.to,l=this.pointMap.get(h),p=this.pointMap.get(c);if(!l||!p)return;let d=l.cds,u=p.cds,m=k(d,u);if(n.forEach(v=>{(v.id===r.from||v.id===r.to)&&(m=m/v.passWeight);let g=k(d,v.cds)<=v.coverageArea,x=k(u,v.cds)<=v.coverageArea;(g||x)&&(m=m/v.passWeight)}),!l.permission&&!p.permission){switch(this.addLineItem(h,c,m),this.addLineItem(c,h,m),r.direction){case"double":this.addLineItem(h,c,m,this.forwardLineMap),this.addLineItem(c,h,m,this.forwardLineMap);break;case"single":this.addLineItem(h,c,m,this.forwardLineMap);break;case"back":this.addLineItem(c,h,m,this.forwardLineMap);break}(l.type==="parkingSpace"||p.type==="parkingSpace")&&r.direction==="noDir"&&(this.addLineItem(h,c,m,this.forwardLineMap),this.addLineItem(c,h,m,this.forwardLineMap))}else l.permission&&(this.setPermissionLine(h,c,l.permission,m,""),this.setPermissionLine(c,h,l.permission,m,"")),p.permission&&p.permission!==l.permission&&(this.setPermissionLine(h,c,p.permission,m,""),this.setPermissionLine(c,h,p.permission,m,""))})}),this.addPermissionFacility(),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}getPermissionMap(t){return this["permission_"+t]||(this["permission_"+t]=new Set),this["permission_"+t]}setPermissionLine(t,e,i,s,o){this.getPermissionMap(i).add({fromKey:t,toKey:e,distance:s,type:o})}addPermissionFacility(){this.straightLadderMap.forEach((t,e)=>{if(t.length<2){this.straightLadderMap.delete(e);return}for(let i=0;i<t.length;i++){let s=""+t[i].floor+T+t[i].id,o=this.pointMap.get(s);if(o){for(let n=0;n<t.length;n++)if(i!==n){let r=""+t[n].floor+T+t[n].id,h=this.pointMap.get(r);if(!h)continue;o.permission&&this.setPermissionLine(s,r,o.permission,1,"straightLadder"),h.permission&&h.permission!==o.permission&&this.setPermissionLine(s,r,h.permission,1,"straightLadder")}}}}),this.staircaseMap.forEach((t,e)=>{if(t.length<2){this.staircaseMap.delete(e);return}for(let i=0;i<t.length;i++){let s=""+t[i].floor+T+t[i].id,o=this.pointMap.get(s);if(o){for(let n=0;n<t.length;n++)if(i!==n){let r=""+t[n].floor+T+t[n].id,h=this.pointMap.get(r);if(!h)continue;o.permission&&this.setPermissionLine(s,r,o.permission,1,"staircase"),h.permission&&h.permission!==o.permission&&this.setPermissionLine(s,r,h.permission,1,"staircase")}}}}),this.escalatorMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&(n.permission&&this.setPermissionLine(s,o,n.permission,1,"escalator"),r.permission&&r.permission!==n.permission&&this.setPermissionLine(s,o,r.permission,1,"escalator"))}})}),this.rampMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&(n.permission&&this.setPermissionLine(s,o,n.permission,10,"ramp"),r.permission&&r.permission!==n.permission&&this.setPermissionLine(s,o,r.permission,10,"ramp"))}})}),this.connectionPointMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&(n.permission&&this.setPermissionLine(s,o,n.permission,1,"connectionPoint"),r.permission&&r.permission!==n.permission&&this.setPermissionLine(s,o,r.permission,1,"connectionPoint"))}})})}addPermissionLineToMap(t,e,i,s){this.getPermissionMap(t).forEach(n=>{e.includes(n.type)&&(n.type===""?this.addLineItem(n.fromKey,n.toKey,n.distance,i):this.addLineItem(n.fromKey,n.toKey,s.get(n.type),i))})}addLineItem(t,e,i,s){s===void 0&&(s=this.lineMap);let o=s.get(t)||new Map;o.set(e,i),s.set(t,o)}addFacilityToLineMap(t,e,i,s){[...this.straightLadderMap,...this.staircaseMap].forEach(o=>{let[n,r]=o;if(!(r.length<2))for(let h=0;h<r.length;h++){let c=""+r[h].floor+T+r[h].id,l=this.pointMap.get(c);if(!(!l||l.permission)){for(let p=0;p<r.length;p++)if(h!==p){let d=""+r[p].floor+T+r[p].id,u=this.pointMap.get(d);if(!u||u.permission)continue;if(r[h].type==="straightLadder"){let m=e;this.addLineItem(c,d,m,s)}else{let m=i;this.addLineItem(c,d,m,s)}}}}}),this.escalatorMap.forEach((o,n)=>{o.forEach(r=>{if(r.start&&r.end){let h=""+r.start.floor+T+r.start.id,c=""+r.end.floor+T+r.end.id,l=this.pointMap.get(h),p=this.pointMap.get(c);if(l&&p&&!l.permission&&!p.permission){let d=t;this.addLineItem(h,c,d,s)}}})}),this.connectionPointMap.forEach((o,n)=>{o.forEach(r=>{if(r.start&&r.end){let h=""+r.start.floor+T+r.start.id,c=""+r.end.floor+T+r.end.id,l=this.pointMap.get(h),p=this.pointMap.get(c);l&&p&&!l.permission&&!p.permission&&this.addLineItem(h,c,100,s)}})})}initBaseRoute(){let t=new Map($t([...this.lineMap]));this.addFacilityToLineMap(100,100*this.lift_priority,3e4,t),this.baseRoute=new tt.default(t)}initEscalatorRoute(){let t=new Map($t([...this.lineMap])),e=1e4;this.addFacilityToLineMap(100,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new tt.default(t)}initStraightLadderRoute(){let t=new Map($t([...this.lineMap])),e=1e4;this.addFacilityToLineMap(3*e,300,3e4*e,t),this.straightLadderRoute=new tt.default(t)}initForwardRoute(){this.rampMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&!n.permission&&!r.permission&&this.addLineItem(s,o,10,this.forwardLineMap)}})}),this.connectionPointMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&!n.permission&&!r.permission&&this.addLineItem(s,o,100,this.forwardLineMap)}})}),this.forwardRoute=new tt.default(this.forwardLineMap)}checkStart(t){return!(!t.floor||!t.nodeId&&(!t.coord||t.coord.length<2))}checkEnd(t){return t.facility||t.parkingSpace&&t.floor?!0:this.checkStart(t)}transformStart(t,e,i){i===void 0&&(i={});var s;if(t.nodeId){let o=this.nodeMap.get(""+t.floor+T+t.nodeId);if(o!=null&&o.length)return o.map(n=>{let[r,h]=n.split(T);return{floor:r,id:h}})}if((s=t.coord)!=null&&s.length){let o=this.roadInfo.find(c=>c.floor===t.floor);if(!o)return null;let n=o.points.filter(c=>c.isStarted),r=o.points.filter(c=>{let l=""+c.floor+T+c.id;if(e==="forward"){if(!this.forwardLineMap.has(l)||i.adsorptionIntersection&&n.length&&!c.isStarted)return!1}else if(!this.lineMap.has(l))return!1;return!0});if(!r.length)return null;let h=r.reduce((c,l)=>{if(l.relatedId)return c;let p=k(t.coord,l.cds);return p<c.min&&(c.min=p,c.point=l),c},{min:1/0,point:r[0]});return[{floor:o.floor,id:h.point.id}]}return null}transformEnd(t,e){if(t.floor){if(t.parkingSpace){let s=this.parkingMap.get(""+t.floor+T+t.parkingSpace);if(s)return[{floor:t.floor,id:s.id}]}let i=this.transformStart(t,e);if(i)return i}if(t.facility){let s=this.facilities.filter(o=>+o.type_id==+t.facility).map(o=>o.id).map(o=>this.facilityMap.get(""+o)).flat(2);if(s!=null&&s.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,i,s,o,n){if(i===void 0&&(i=""),n===void 0&&(n={}),!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let r=this.transformStart(t,i,n);if(!r)return"no-start";let h=this.transformEnd(e,i);if(!h)return"no-end";let c=[];if(Array.isArray(h))for(let d=0;d<r.length;d++){let u=r[d];for(let m=0;m<h.length;m++){let v=h[m];if(u.floor===v.floor&&u.id===v.id)return"near"}}else{c=this.facilities.filter(u=>+u.type_id==+e.facility).map(u=>u.id).map(u=>this.facilityMap.get(""+u)).flat(2).filter(u=>u).filter(u=>h.floor?u.floor===h.floor:!0);for(let u=0;u<r.length;u++){let m=r[u];for(let v=0;v<c.length;v++){let g=c[v];if(m.floor===g.floor&&m.id===g.id)return"near"}}}let l;switch(i){case"escalator":l=this.getEscalatorPath.bind(this);break;case"straightLadder":l=this.getStraightLadderPath.bind(this);break;case"forward":l=this.getForwardPath.bind(this);break;default:l=this.getBasePath.bind(this);break}let p=null;return r.forEach(d=>{if(Array.isArray(h))h.forEach(u=>{let m=l(d,u,s,o);m&&m&&(!p||m[0].consume<p[0].consume)&&(p=m)});else{if(!c.length)return null;let u=c.map(m=>l(d,{floor:m.floor,id:m.id},s,o)).filter(m=>!!m);p=u.reduce((m,v)=>{let g=v[0].consume;return g<m.distance&&(m.distance=g,m.path=v),m},{distance:1/0,path:u[0]}).path}}),p}getRoutePath(t,e,i){let s=""+t.floor+T+t.id,o=this.pointMap.get(s),n=""+e.floor+T+e.id,r=this.pointMap.get(n);if(!o||!r)return null;let h=""+o.floor+T+(o.relatedId||o.id),c=""+r.floor+T+(r.relatedId||r.id),l=i.path(h,c);if(!l)return null;let p=[],d=l.reduce((u,m,v,g)=>{if(v===0)return 0;let x=g[v-1],M=i.graph.get(x).get(m);return u+M},0);return l.map(u=>{let m=this.pointMap.get(u);if(m){var v;let{floor:g}=m,x=m.type;if(this.isFacilityByType(m.type)){let M=this.facilities.find(P=>P.id===+m.targetId);M&&(x=M.entry_infra_type)}if(((v=p[p.length-1])==null?void 0:v.floor)===g){let M=p[p.length-1];M.points.push(m.cds),M.pointInfos.push(m),M.endType=x,M.destId=m.nodeId,M.distance=ht(M.points)}else p.push({floor:g,points:[m.cds],pointInfos:[m],endType:x,destId:m.nodeId,distance:0,consume:d})}}),p}getBasePath(t,e,i){if(!i)return this.getRoutePath(t,e,this.baseRoute);let s=$t(this.baseRoute.graph),o=r=>{this.addPermissionLineToMap(r,["","escalator","staircase","straightLadder","connectionPoint"],s,new Map([["escalator",100],["connectionPoint",100],["straightLadder",100*this.lift_priority],["staircase",3e4]]))};Array.isArray(i)?i.forEach(r=>{o(r)}):o(i);let n=new tt.default(s);return this.getRoutePath(t,e,n)}getEscalatorPath(t,e,i){if(!i)return this.getRoutePath(t,e,this.escalatorRoute);let s=$t(this.escalatorRoute.graph),o=1e4,n=h=>{this.addPermissionLineToMap(h,["","escalator","staircase","straightLadder","connectionPoint"],s,new Map([["escalator",100],["connectionPoint",100],["straightLadder",this.lift_priority*o],["staircase",3e4*o]]))};Array.isArray(i)?i.forEach(h=>{n(h)}):n(i);let r=new tt.default(s);return this.getRoutePath(t,e,r)}getStraightLadderPath(t,e,i){if(!i)return this.getRoutePath(t,e,this.straightLadderRoute);let s=$t(this.straightLadderRoute.graph),o=1e4,n=h=>{this.addPermissionLineToMap(h,["","escalator","staircase","straightLadder","connectionPoint"],s,new Map([["escalator",3*o],["connectionPoint",100],["straightLadder",300],["staircase",3e4*o]]))};Array.isArray(i)?i.forEach(h=>{n(h)}):n(i);let r=new tt.default(s);return this.getRoutePath(t,e,r)}getForwardPath(t,e,i,s){let o=new Map,n=u=>{let m=this.forwardRoute.graph.get(h);u.forEach(v=>{let g=m.get(v);fi(g)||(o.set(v,g),m.delete(v))})},r=()=>{let u=this.forwardRoute.graph.get(h);o.forEach((m,v)=>{u.set(v,m)})},h=""+t.floor+T+t.id;if(!fi(s)){let u=this.forwardLineMap.get(h),m=this.pointMap.get(h);if(m&&(u!=null&&u.size)&&u.size>1){let v=new Vs(m.cds[0],m.cds[1]),g=new Map;u.forEach((M,P)=>{let E=this.pointMap.get(P);if(E){let b=new Vs(E.cds[0],E.cds[1]),S=360-(new Vs().subVectors(b,v).angle()/Math.PI*180-90+360)%360;g.set(P,S)}});let x=Array.from(g).filter(M=>{let[P,E]=M;return Math.abs(E-s)<=60}).map(M=>{let[P]=M;return P});if(x.length)x.forEach(M=>g.delete(M)),n([...g.keys()]);else{let M=Array.from(g).reduce((P,E)=>{let b=Math.abs(E[1]-s);return b<P.diff?{diff:b,key:E[0]}:P},{diff:1/0,key:""});g.delete(M.key),n([...g.keys()])}}}if(!i){let u=this.getRoutePath(t,e,this.forwardRoute);return r(),u||this.getRoutePath(t,e,this.forwardRoute)}let c=$t(this.forwardRoute.graph),l=u=>{this.addPermissionLineToMap(u,["","ramp"],c,new Map([["ramp",10]]))};Array.isArray(i)?i.forEach(u=>{l(u)}):l(i);let p=new tt.default(c),d=this.getRoutePath(t,e,p);if(r(),d)return d;{let u=$t(this.forwardRoute.graph);Array.isArray(i)?i.forEach(g=>{l(g)}):l(i);let m=new tt.default(u);return this.getRoutePath(t,e,m)}}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 tt.default,this.escalatorRoute=new tt.default,this.straightLadderRoute=new tt.default}constructor(t=3){this.lift_priority=t,this.roadInfo=[],this.facilities=[],this.pointMap=new Map,this.nodeMap=new Map,this.facilityMap=new Map,this.straightLadderMap=new Map,this.escalatorMap=new Map,this.rampMap=new Map,this.staircaseMap=new Map,this.connectionPointMap=new Map,this.parkingMap=new Map,this.lineMap=new Map,this.baseRoute=new tt.default,this.escalatorRoute=new tt.default,this.straightLadderRoute=new tt.default,this.forwardLineMap=new Map,this.forwardRoute=new tt.default}};import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";var Jt=class{static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}static genUniqueKey(){let t=this.createKey();for(;this.keySet.has(t);)t=this.createKey();return t}static removeKey(t){this.keySet.delete(t)}static dispose(){this.keySet.clear()}};Jt.keySet=new Set;import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.array.push.js";function wn(a){return a.replace(/[A-Z]/g,t=>"_"+t.toLowerCase()).replace(/^_/,"")}function Mn(a){let t=[],e=/(\([^()]*\))|([^()]*)/g,i=0,s;for(;(s=e.exec(a))!==null;)s.index>i&&t.push(a.substring(i,s.index)),t.push(s[0]),i=s.index+s[0].length;return i<a.length&&t.push(a.substring(i)),t}function F(a,t,e){return new Promise((i,s)=>{let o=Jt.genUniqueKey(),n=r=>{let{data:h}=r;h.type===""+t+"_result"&&h.key===o&&(Jt.removeKey(o),self.removeEventListener("message",n),h.error?s(h.error):i(h.data))};a.addEventListener("message",n),a.postMessage({type:t,key:o,data:e})})}function Jm(a){let t={};for(let i in a)i.startsWith("on")&&(t[wn(i.slice(2))]=a[i],t[i]=a[i]);let e=i=>f(this,null,function*(){let{data:s}=i;if(t[s.type])try{let o=yield t[s.type](s.data);if(o!=null&&o.$transfer&&Array.isArray(o.$transfer)){let n=o.$transfer;delete o.$transfer,self.postMessage({type:""+s.type+"_result",key:s.key,data:o},n)}else self.postMessage({type:""+s.type+"_result",key:s.key,data:o})}catch(o){self.postMessage({type:""+s.type+"_result",key:s.key,error:o})}else self.postMessage({type:""+s.type+"_result",key:s.key,error:"no_event"})});return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}}import{BoxGeometry as La,BufferGeometry as Ca,Line as Ta,LineBasicMaterial as ka,Mesh as Da,MeshBasicMaterial as Aa}from"three";function sf(a,t){t===void 0&&(t=16711680);let e=new ka({color:t}),i=new Ca().setFromPoints(a);return new Ta(i,e)}function of(a,t){t===void 0&&(t=16711680);let e=new Aa({color:t,depthTest:!1,transparent:!0}),i=new La(1,1,1),s=new Da(i,e);return s.position.copy(a),s.renderOrder=100100,s}import"core-js/modules/es.json.stringify.js";import"core-js/modules/web.dom-collections.iterator.js";function gi(a,t,e){e===void 0&&(e=0),a.forEach(i=>{if(i.geometry.coords=JSON.parse(JSON.stringify(i.geometry.cds)),i.geometry.type==="polygon"){var s;i.geometry.coords.map(o=>{Array.isArray(o)&&o.forEach(n=>{n[0]-=t[0],n[1]-=t[1]})}),i.geometry.otherCds&&(i.geometry.otherCoords=i.geometry.otherCds.map(o=>o.map(n=>xe(n,t)))),(s=i.doors)!=null&&s.length&&i.doors.map(o=>{o.coord=xe(o.coordinate,t)}),i.center&&(i.centerCoords=xe(i.center,t))}else i.geometry.coords=xe(i.geometry.cds,t),i.center&&(i.centerCoords=xe(i.center,t));if(i.center_x&&i.center_y){let[o,n]=xe([i.center_x,i.center_y],t);i.center_coord_x=o,i.center_coord_y=n}});for(let i=0;i<a.length;i++){let s=a[i];s.deltaHeight=1e-5*(e+i+1)}}function xe(a,t){return[a[0]-t[0],a[1]-t[1]]}import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";import{Group as Oa}from"@tweenjs/tween.js";var Qt=class{update(){this.group.update()}pause(){this.pauseTween=!0,this.getAll().forEach(t=>{this.tweenStore.add(t),t.pause()})}continue(){this.pauseTween&&(this.tweenStore.forEach(t=>{t.resume()}),this.tweenStore.clear(),this.pauseTween=!1)}remove(t){this.group.remove(t)}getAll(){return this.group.getAll()}clear(){this.getAll().forEach(t=>t.stop()),this.group.removeAll()}dispose(){this.clear()}constructor(){this.pauseTween=!1,this.tweenStore=new Set,this.group=new Oa}};import{EventDispatcher as Ia}from"three";var yi=class extends Ia{registryEvent(){this.ctn.addEventListener("pointerdown",this._pointerDown),this.ctn.addEventListener("pointerup",this._pointerUp)}unRegistryEvent(){this.ctn.removeEventListener("pointerdown",this._pointerDown),this.ctn.removeEventListener("pointerup",this._pointerUp)}dispose(){this.unRegistryEvent()}constructor(t){super(),this.ctn=t,this._pointerDown=e=>{this.point={x:e.offsetX,y:e.offsetY}},this._pointerUp=e=>{if(!this.point)return;let{offsetX:i,offsetY:s}=e,{x:o,y:n}=this.point;Math.hypot(o-i+(n-s))>3||this.dispatchEvent({type:"click",e})},this.registryEvent()}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import{isNil as Ra}from"lodash";import{EventDispatcher as Ga}from"three";var we=class extends Ga{_isEffectiveTask(t){return t&&typeof t.run=="function"}_getIndexByTid(t){return this._task.findIndex(e=>e.tid===t)}_createTask(t){return this._isEffectiveTask(t)?w({},t,{tid:++this._id,meta:t.meta||{}}):!1}get task(){return[...this._task]}getTasks(){return[...this._task]}add(t){if(this._isEffectiveTask(t)){let e=this._createTask(t);return this._task.push(e),this.started&&!this.activeTask&&this.start(),e.tid}return!1}replace(t,e){if(!this._isEffectiveTask(e))return console.warn("[TaskQueue] replace\u65B9\u6CD5\u4F20\u5165\u7684task\u53C2\u6570\u683C\u5F0F\u4E0D\u6B63\u786E"),!1;let i=this._getIndexByTid(t);if(i===-1)return console.warn("[TaskQueue] \u6CA1\u6709\u627E\u5230id="+t+"\u7684\u4EFB\u52A1"),!1;let s=this._createTask(e);return this._task.splice(i,1,s),s.tid}replaceByMetaType(t){var e;let i=(e=t.meta)==null?void 0:e.type;if(Ra(i))return this.add(t);{let s=this._task.find(o=>o.meta.type===i);return s?this.replace(s.tid,t):this.add(t)}}remove(t){let e=this._getIndexByTid(t);return e===-1?(console.warn("[TaskQueue] remove\u65B9\u6CD5\u4F20\u5165\u7684id\uFF1A"+t+"\u627E\u4E0D\u5230\u5BF9\u5E94\u7684task"),!1):(this._task.splice(e,1),!0)}clear(){this._task.length=0}start(){this.started=!0,!this.activeTask&&this._task.length&&this.exec()}stop(){this.started=!1}exec(){return f(this,null,function*(){if(!this.started||!this._task.length)return!1;let t=this._task.shift();this.activeTask=t,this.dispatchEvent({type:"active-task-start",task:t});let e;try{e=yield t.run()}catch(i){console.warn("[task run err]",i,t)}return this.activeTask=null,this.dispatchEvent({type:"active-task-end",task:t,res:e}),this.exec()})}constructor(t=!0){super(),this._task=[],this.started=!1,this.activeTask=null,this._id=0,t&&this.start()}};import"core-js/modules/es.array.push.js";import{EventDispatcher as Fa}from"three";var vi=class extends Fa{getWorker(){return new Promise(t=>{let e=this.pool.find(s=>s.state==="leisure");if(e){e.state="used",t(e.worker);return}if(this.pool.length<this.max&&this.workerConstructor){let s=this.workerConstructor();this.pool.push({worker:s,state:"used"}),t(s);return}let i=()=>{let s=this.pool.find(o=>o.state==="leisure");s&&(this.removeEventListener("release",i),s.state="used",t(s.worker))};this.addEventListener("release",i)})}releaseWorker(t){let e=this.pool.find(i=>i.worker===t);e&&(e.state="leisure",this.dispatchEvent({type:"release",worker:t}))}dispose(){this._listeners={},this.pool.forEach(t=>{t.worker.terminate()}),this.pool=[]}constructor(t=10,e){super(),this.max=10,this.pool=[],this.max=t,this.workerConstructor=e}};import{EventDispatcher as za}from"three";var X=class extends za{dispose(){this._listeners={}}};var xi=class{filter(t){let e=this.estimate,i=this.errorEstimate+this.processNoise,s=i/(i+this.measurementNoise);return this.estimate=e+s*(t-e),this.errorEstimate=(1-s)*i,this.estimate}constructor(t={}){this.estimate=0,this.errorEstimate=1,this.processNoise=.1,this.measurementNoise=1,this.measurementNoise=t.measurementNoise||1,this.processNoise=t.processNoise||.1,this.errorEstimate=t.errorEstimate||1}};import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{BufferAttribute as Me,BufferGeometry as Ba,Color as Ks,ExtrudeGeometry as Wa,Matrix4 as Ua,Quaternion as Ha,Vector3 as Ze}from"three";import{mergeGeometries as Na}from"three/examples/jsm/utils/BufferGeometryUtils.js";import{polygon as Za,center as ja}from"@turf/turf";function og(a,t,e){t===void 0&&(t=!0),e===void 0&&(e=!1);let i=a.filter(r=>r.geometry.type==="polygon");if(!i.length)return null;let s=i.map(r=>{var h;let c=r.geometry.coords,l=hi(c[0],c.slice(1)),p=new Wa(l,{steps:1,bevelEnabled:!1,depth:r.height,curveSegments:4});(h=r).deltaHeight||(h.deltaHeight=0),p.translate(0,0,r.airHeight+r.deltaHeight);let d=p.attributes.position.count,u=new Float32Array(d).fill(r.height+r.airHeight+r.deltaHeight);if(p.setAttribute("maxZ",new Me(u,1)),p.setAttribute("opacity",new Me(new Float32Array(d).fill(r.fillOpacity),1)),e){let g=new Float32Array(d).fill(r.airHeight+r.deltaHeight);p.setAttribute("minZ",new Me(g,1))}let m=new Ks(r.fillColor).convertLinearToSRGB(),v=new Float32Array(d*3);for(let g=0;g<d;g++)v[g*3]=m.r,v[g*3+1]=m.g,v[g*3+2]=m.b;return p.setAttribute("color",new Me(v,3)),p}),o=Na(s);s.forEach(r=>r.dispose());let n={geometry:o};return o.dispose(),t&&(n.lineGeometry=Va(i)||void 0),n}function ng(a){let t=a.filter(h=>h.geometry.type==="polygon");if(!t.length)return null;let e=[],i=[],s=[],o=[],n=[],r=[];return t.map((h,c)=>{var l;(l=h).deltaHeight||(l.deltaHeight=0);let p=h.geometry.coords,d=k(p[0][0],p[0][1]),u=k(p[0][1],p[0][2]),m=p[0][1][0]-p[0][0][0],v=p[0][1][1]-p[0][0][1],g=Math.atan2(v,m),x=ja(Za(p)),M=x.geometry.coordinates[0],P=x.geometry.coordinates[1],E=new Ua().compose(new Ze(M,P,h.deltaHeight+h.airHeight+h.height/2),new Ha().setFromAxisAngle(new Ze(0,0,1),g),new Ze(d,u,h.height));e.push(...E.toArray()),i.push(...new Ks(h.fillColor).convertLinearToSRGB().toArray());var b;s[c]=(b=h.fillOpacity)!=null?b:1;var A;o[c]=((A=h.deltaHeight)!=null?A:0)+h.airHeight+h.height,n[c]=h.id,r[c]=h.airHeight+h.deltaHeight}),{size:t.length,ids:n,matrixes:e,colors:i,opacities:s,maxZs:o,minZs:r}}function Va(a){let{points:t,colors:e,opacities:i}=Xs(a);if(!t.length)return null;let s=new Ba().setFromPoints(t);return s.setAttribute("color",new Me(new Float32Array(e),3)),s.setAttribute("opacity",new Me(new Float32Array(i),1)),s}function Xs(a){let t=[],e=[],i=[];return a.filter(s=>s.strokeOpacity>0).map(s=>{let o=s.height+(s.deltaHeight||0)+s.airHeight,{coords:n}=s.geometry,{strokeColor:r,strokeOpacity:h}=s,c=new Ks(r).convertLinearToSRGB();for(let l=0;l<n.length;l++){let p=n[l];for(let d=0;d<p.length;d++){let u=p[d],m=d+1===p.length?p[0]:p[d+1];t.push(new Ze(u[0],u[1],o)),t.push(new Ze(m[0],m[1],o)),e.push(c.r,c.g,c.b),e.push(c.r,c.g,c.b),i.push(h),i.push(h)}}}),{points:t,colors:e,opacities:i}}function rg(a){if(a.length>1)return!1;let t=a[0];if(t.length!==5)return!1;let[e]=t,i=t[t.length-1];if(e[0]!==i[0]||e[1]!==i[1])return!1;let s=[Math.round(k(t[0],t[1])),Math.round(k(t[1],t[2])),Math.round(k(t[2],t[3])),Math.round(k(t[3],t[4]))];if(!(s[2]===s[0]&&s[3]===s[1]))return!1;let o=me(t[0],t[1],t[2]);return Math.abs(Math.abs(o)-90)<1}import{EventDispatcher as up,Box2 as mp,Vector3 as jt,Vector2 as Ae,Raycaster as fp,Box3 as gp,Color as yp,AmbientLight as vp}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.push.js";import{EventDispatcher as Xl}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Object3D as hh,ExtrudeGeometry as ch,Mesh as lh,Box3 as Si,Vector3 as yt,BufferGeometry as ph,LineSegments as dh,Ray as Gn,Vector2 as Nt,DoubleSide as uh,RepeatWrapping as Fn}from"three";import"core-js/modules/web.dom-collections.iterator.js";import{LineMaterial as Ka}from"three/examples/jsm/lines/LineMaterial.js";import{Color as je,LineBasicMaterial as Xa,MeshStandardMaterial as Ya,MeshBasicMaterial as qa,ShaderMaterial as _e,DoubleSide as $a,LineDashedMaterial as Ja}from"three";function _n(a){return a.x+"-"+a.y+"-"+a.z}var L=class{static generateLineMaterialKey(t){let{color:e,opacity:i}=t;return e+"-"+i}static createLineMaterial(t){let{color:e,opacity:i,vertexColors:s}=t,o=this.generateLineMaterialKey({color:e,opacity:i,vertexColors:s});if(this.lineMaterialMap.has(o))return this.lineMaterialMap.get(o);let n=new Xa({color:new je(e).convertLinearToSRGB(),transparent:!0,opacity:i,vertexColors:s!=null?s:!1});return this.lineMaterialMap.set(o,n),n}static createMeshStandardMaterial(t){let{color:e,opacity:i}=t,s=e+"-"+i;if(this.meshStandardMaterialMap.has(s))return this.meshStandardMaterialMap.get(s);let o=new Ya({color:new je(e).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:i,depthWrite:!0});return this.meshStandardMaterialMap.set(s,o),o}static createMeshBasicMaterial(t){let{color:e,opacity:i,vertexColors:s}=t,o=e+"-"+i+"-"+s;if(this.meshBasicMaterialMap.has(o))return this.meshBasicMaterialMap.get(o);let n=new qa({color:e,transparent:!0,opacity:i,depthWrite:!0,vertexColors:s!=null?s:!1});return this.meshBasicMaterialMap.set(o,n),n}static createShaderMaterial(t){let{gradualColor:e,center:i,maxValue:s,opacity:o,direction:n,max:r,min:h}=t,c=e.toString()+"-"+_n(i)+"-"+s+"-"+o+"-"+_n(n);if(this.shaderMaterialMap.has(c))return this.shaderMaterialMap.get(c);let l=`
1
+ var ra=Object.create;var Gs=Object.defineProperty;var aa=Object.getOwnPropertyDescriptor;var ha=Object.getOwnPropertyNames,Go=Object.getOwnPropertySymbols,ca=Object.getPrototypeOf,Fo=Object.prototype.hasOwnProperty,la=Object.prototype.propertyIsEnumerable;var Rs=(a,t,e)=>t in a?Gs(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,Ue=(a,t)=>{for(var e in t||(t={}))Fo.call(t,e)&&Rs(a,e,t[e]);if(Go)for(var e of Go(t))la.call(t,e)&&Rs(a,e,t[e]);return a};var ie=(a,t)=>()=>(t||a((t={exports:{}}).exports,t),t.exports);var pa=(a,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ha(t))!Fo.call(a,s)&&s!==e&&Gs(a,s,{get:()=>t[s],enumerable:!(i=aa(t,s))||i.enumerable});return a};var Fs=(a,t,e)=>(e=a!=null?ra(ca(a)):{},pa(t||!a||!a.__esModule?Gs(e,"default",{value:a,enumerable:!0}):e,a));var K=(a,t,e)=>Rs(a,typeof t!="symbol"?t+"":t,e);var f=(a,t,e)=>new Promise((i,s)=>{var o=h=>{try{r(e.next(h))}catch(c){s(c)}},n=h=>{try{r(e.throw(h))}catch(c){s(c)}},r=h=>h.done?i(h.value):Promise.resolve(h.value).then(o,n);r((e=e.apply(a,t)).next())});var Yo=ie((tm,Xo)=>{Xo.exports=function(t,e){return t[0]=e[0],t[1]=e[1],t}});var Jo=ie((em,$o)=>{var qo=Yo();$o.exports=function(a,t){Array.isArray(t)||(t=[]),a.length>0&&t.push(qo([0,0],a[0]));for(var e=0;e<a.length-1;e++){var i=a[e],s=a[e+1],o=i[0],n=i[1],r=s[0],h=s[1],c=[.75*o+.25*r,.75*n+.25*h],l=[.25*o+.75*r,.25*n+.75*h];t.push(c),t.push(l)}return a.length>1&&t.push(qo([0,0],a[a.length-1])),t}});var nn=ie((cm,on)=>{var Ns=class{constructor(){this.keys=new Set,this.queue=[]}sort(){this.queue.sort((t,e)=>t.priority-e.priority)}set(t,e){let i=Number(e);if(isNaN(i))throw new TypeError('"priority" must be a number');return this.keys.has(t)?this.queue.map(s=>(s.key===t&&Object.assign(s,{priority:i}),s)):(this.keys.add(t),this.queue.push({key:t,priority:i})),this.sort(),this.queue.length}next(){let t=this.queue.shift();return this.keys.delete(t.key),t}isEmpty(){return this.queue.length===0}has(t){return this.keys.has(t)}get(t){return this.queue.find(e=>e.key===t)}};on.exports=Ns});var hn=ie((lm,an)=>{function rn(a,t){let e=new Map;for(let[i,s]of a)i!==t&&s instanceof Map?e.set(i,rn(s,t)):i!==t&&e.set(i,s);return e}an.exports=rn});var pn=ie((pm,ln)=>{function ba(a){let t=Number(a);return!(isNaN(t)||t<=0)}function cn(a){let t=new Map;return Object.keys(a).forEach(i=>{let s=a[i];if(s!==null&&typeof s=="object"&&!Array.isArray(s))return t.set(i,cn(s));if(!ba(s))throw new Error(`Could not add node at key "${i}", make sure it's a valid node`,s);return t.set(i,Number(s))}),t}ln.exports=cn});var mn=ie((dm,un)=>{function dn(a){if(!(a instanceof Map))throw new Error(`Invalid graph: Expected Map instead found ${typeof a}`);a.forEach((t,e)=>{if(typeof t=="object"&&t instanceof Map){dn(t);return}if(typeof t!="number"||t<=0)throw new Error(`Values must be numbers greater than 0. Found value ${t} at ${e}`)})}un.exports=dn});var js=ie((um,yn)=>{var Sa=nn(),Ea=hn(),fn=pn(),gn=mn(),Zs=class{constructor(t){t instanceof Map?(gn(t),this.graph=t):t?this.graph=fn(t):this.graph=new Map}addNode(t,e){let i;return e instanceof Map?(gn(e),i=e):i=fn(e),this.graph.set(t,i),this}addVertex(t,e){return this.addNode(t,e)}removeNode(t){return this.graph=Ea(this.graph,t),this}path(t,e,i={}){if(!this.graph.size)return i.cost?{path:null,cost:0}:null;let s=new Set,o=new Sa,n=new Map,r=[],h=0,c=[];if(i.avoid&&(c=[].concat(i.avoid)),c.includes(t))throw new Error(`Starting node (${t}) cannot be avoided`);if(c.includes(e))throw new Error(`Ending node (${e}) cannot be avoided`);for(o.set(t,0);!o.isEmpty();){let l=o.next();if(l.key===e){h=l.priority;let d=l.key;for(;n.has(d);)r.push(d),d=n.get(d);break}s.add(l.key),(this.graph.get(l.key)||new Map).forEach((d,u)=>{if(s.has(u)||c.includes(u))return null;if(!o.has(u))return n.set(u,l.key),o.set(u,l.priority+d);let m=o.get(u).priority,v=l.priority+d;return v<m?(n.set(u,l.key),o.set(u,v)):null})}return r.length?(i.trim?r.shift():r=r.concat([t]),i.reverse||(r=r.reverse()),i.cost?{path:r,cost:h}:r):i.cost?{path:null,cost:0}:null}shortestPath(...t){return this.path(...t)}};yn.exports=Zs});function w(){return w=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},w.apply(this,arguments)}import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.json.stringify.js";import{Box3 as Bp,EventDispatcher as Wp,Sprite as vo,Vector3 as ms}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";var z=class{requestAnimationFrame(t){let e=window.requestAnimationFrame(()=>{this.tasks.requestAnimation.delete(e),t()});return this.tasks.requestAnimation.add(e),e}cancelAnimationFrame(t){this.tasks.requestAnimation.delete(t),window.cancelAnimationFrame(t)}setTimeout(t,e){let i=window.setTimeout(()=>{this.tasks.timeout.delete(i),t()},e);return this.tasks.timeout.add(i),i}clearTimeout(t){this.tasks.timeout.delete(t),window.clearTimeout(t)}setInterval(t,e){let i=window.setInterval(()=>{t()},e);return this.tasks.interval.add(i),i}clearInterval(t){this.tasks.interval.delete(t),window.clearInterval(t)}requestIdleCallback(t,e){let i=window.requestIdleCallback(s=>{this.tasks.requestIdleCallback.delete(i),t(s)},e);return this.tasks.requestIdleCallback.add(i),i}cancelIdleCallback(t){this.tasks.requestIdleCallback.delete(t),window.cancelIdleCallback(t)}dispose(){this.tasks.requestAnimation.forEach(t=>{window.cancelAnimationFrame(t)}),this.tasks.requestAnimation.clear(),this.tasks.requestIdleCallback.forEach(t=>{window.cancelIdleCallback(t)}),this.tasks.requestIdleCallback.clear(),this.tasks.timeout.forEach(t=>{window.clearTimeout(t)}),this.tasks.timeout.clear(),this.tasks.interval.forEach(t=>{window.clearInterval(t)}),this.tasks.interval.clear()}constructor(){this.tasks={requestAnimation:new Set,requestIdleCallback:new Set,timeout:new Set,interval:new Set}}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Shape as da,Group as ua,DirectionalLight as ma,AmbientLight as fa,Path as ga,Vector2 as zo}from"three";function Bo(){let a=new ua,t=new fa(16777215,.3);return a.add(t),a}function hi(a,t){t===void 0&&(t=[]);let e=new da(a.map(i=>new zo(...i)));return t.length&&t.forEach(i=>{var s=new ga(i.map(o=>new zo(...o)));e.holes.push(s)}),e}function Wo(a,t){a===void 0&&(a=16777215),t===void 0&&(t=1);let e=new ma(a,t);return e.castShadow=!0,e.shadow.radius=8,e.shadow.bias=-.001,e.shadow.mapSize.set(256,256),e.shadow.camera.left=-200,e.shadow.camera.right=200,e.shadow.camera.top=200,e.shadow.camera.bottom=-200,e}function D(a,t){if(t&&a.children&&a.children.length&&a.children.forEach(e=>{D(e,t)}),a.isMesh){let e=a;e.geometry&&e.geometry.dispose(),e.material&&(Array.isArray(e.material)?e.material.forEach(i=>{i.dispose()}):e.material.dispose())}a.isLight&&(a.dispose==null||a.dispose.call(a))}import"core-js/modules/es.regexp.exec.js";function Uo(a){return/[\u4E00-\u9FA5]+/g.test(a)}import"core-js/modules/web.dom-collections.iterator.js";import{Vector3 as li,Vector2 as zt,Matrix3 as ci}from"three";import{point as ya,featureCollection as va,center as xa}from"@turf/turf";function C(a,t,e,i){let s=a.clone().project(t),o=e/2,n=i/2,r=Math.round(s.x*o+o),h=Math.round(-s.y*n+n);return{x:r,y:h}}function vu(a,t,e,i,s){if(!s)return null;e=Math.min(1,e),i=Math.min(1,i);let o=a/e*2-1,n=1-t/i*2;return new li(o,n,0).unproject(s)}function pi(a){let t=va(a.map(i=>ya(i)));return xa(t).geometry.coordinates}function Yt(a,t,e){return a.x>=t.x&&a.x<=e.x&&a.y>=t.y&&a.y<=e.y}function xu(a){let t=0,e=new li;for(let i=1;i<a.length;i++){let s=new li(a[i-1][0],a[i-1][1],0),o=new li(a[i][0],a[i][1],0),n=o.distanceTo(s);n>t&&(t=n,e=o.clone().sub(s).normalize())}return e}function k(a,t){return Math.sqrt((t[0]-a[0])**2+(t[1]-a[1])**2)}function ht(a){let t=0;for(let e=0;e<a.length-1;e++)t+=k(a[e],a[e+1]);return t}function me(a,t,e){let i=new zt(t[0]-a[0],t[1]-a[1]),s=new zt(t[0]-e[0],t[1]-e[1]),n=i.angleTo(s)*180/Math.PI,r=new zt(t[0]-a[0],t[1]-a[1]);return new zt(e[0]-a[0],e[1]-a[1]).cross(r)>0?n:-n}function wu(a,t){let e=Math.min(k(a[0][0],a[0][1]),k(a[0][2],a[0][1]))-1;t||(t=pi(a[0]));let i=wa(t,e),s=new zt(a[0][0][0],a[0][0][1]),o=new zt(a[0][1][0],a[0][1][1]),n=new zt(a[0][2][0],a[0][2][1]),h=(s.distanceTo(o)>o.distanceTo(n)?o.clone().sub(s):n.clone().sub(o)).angleTo(new zt(0,1)),c=new ci;return c.multiply(new ci().translate(t[0],t[1])).multiply(new ci().rotate(h)).multiply(new ci().translate(-t[0],-t[1])),[i.map(l=>{let p=new zt(l[0],l[1]).applyMatrix3(c);return[p.x,p.y]})]}function wa(a,t){let e=t/2;return[[a[0]-e,a[1]+e],[a[0]+e,a[1]+e],[a[0]+e,a[1]-e],[a[0]-e,a[1]-e],[a[0]-e,a[1]+e]]}function Bt(a,t){let e=0,i=1/0,[s,o]=t;for(let n=0;n<a.length-1;n++){let[r,h]=a[n],[c,l]=a[n+1],p=Math.min(r,c)<=s&&s<=Math.max(r,c),d=Math.min(h,l)<=o&&o<=Math.max(h,l);if(p&&d){let u=Math.abs((c-r)*(o-h)-(l-h)*(s-r));u<i&&(i=u,e=n)}}return e}function Ho(a,t){let e=a[0],i=a[1],s=!1;for(let o=0,n=t.length-1;o<t.length;n=o++){let r=t[o][0],h=t[o][1],c=t[n][0],l=t[n][1];h>i!=l>i&&e<(c-r)*(i-h)/(l-h)+r&&(s=!s)}return s}import"core-js/modules/es.reflect.to-string-tag.js";function fe(a,t){return new Proxy(a,{get:(e,i,s)=>Reflect.get(e,i,s),set:(e,i,s,o)=>{let n=Reflect.get(e,i,o),r=Reflect.set(e,i,s,o);return n!==s&&t.dispatchEvent({type:"change-"+i,value:s}),r}})}import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.error.cause.js";function ft(a,t){return Promise.race([a,new Promise((e,i)=>{setTimeout(()=>i(new Error("Promise timeout")),t)})])}function di(a){return document.createElementNS("http://www.w3.org/2000/svg",a)}function No(a,t){let e=di("svg");return e.setAttribute("width",a),e.setAttribute("height",t),e.style.cssText="position: absolute; left: 0; top: 0; pointer-events: none;",e}function He(a,t){a===void 0&&(a="2");let e=di("circle");return e.setAttribute("r",a),e.setAttribute("fill",t),e}function ui(a){let t=di("line");return t.setAttribute("stroke",a),t}function qt(a,t){let e=di("rect");return e.setAttribute("stroke",a),e.setAttribute("fill",t),e}function se(a,t,e){a.setAttribute("cx",""+t),a.setAttribute("cy",""+e)}function Mt(a,t,e){t&&(a.setAttribute("x1",""+t.x),a.setAttribute("y1",""+t.y)),e&&(a.setAttribute("x2",""+e.x),a.setAttribute("y2",""+e.y))}function ot(a,t,e,i,s){a.setAttribute("x",""+t),a.setAttribute("y",""+e),a.setAttribute("width",""+i),a.setAttribute("height",""+s)}function Zo(){return Promise.resolve()}function zs(){return new Promise(a=>{requestAnimationFrame(a)})}function jo(a){return a===void 0&&(a=1),new Promise(t=>{function e(){a<=0?t(!0):(a--,window.requestAnimationFrame(e))}window.requestAnimationFrame(e)})}import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.string.trim.js";function Au(a){return parseInt(a.replace("#","0x"),16)}function Ou(a,t){let e=parseInt(a.substring(1,3),16),i=parseInt(a.substring(3,5),16),s=parseInt(a.substring(5,7),16),o=Math.round(e*t),n=Math.round(i*t),r=Math.round(s*t);return"#"+(1<<24|o<<16|n<<8|r).toString(16).slice(1)}function Wt(a,t){t===void 0&&(t=.85);let e,i,s;if(a.startsWith("#"))e=parseInt(a.substring(1,3),16),i=parseInt(a.substring(3,5),16),s=parseInt(a.substring(5,7),16);else{let n=a.slice(4,-1).split(",");e=parseInt(n[0].trim()),i=parseInt(n[1].trim()),s=parseInt(n[2].trim())}return e=Math.min(Math.floor(e*t),255),i=Math.min(Math.floor(i*t),255),s=Math.min(Math.floor(s*t),255),"#"+((1<<24)+(e<<16)+(i<<8)+s).toString(16).slice(1)}function Bs(a,t){a=a.replace(/^#/,"");let e=parseInt(a.substring(0,2),16),i=parseInt(a.substring(2,4),16),s=parseInt(a.substring(4,6),16);return t!==void 0?"rgba("+e+", "+i+", "+s+", "+t+")":"rgb("+e+", "+i+", "+s+")"}import"core-js/modules/es.regexp.exec.js";var ge=navigator.userAgent.toUpperCase().indexOf("MAC")>=0,Vo=(navigator.userAgent||"").toLocaleLowerCase(),Ut=/ios|iphone/i.test(Vo),Gu=/android|adr|linux/gi.test(Vo);function ye(a){return ge?a==="Meta":a==="Control"}import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";var Ws="__once__",Ko=class{on(t,e){if(typeof e!="function")return;let i=this.events.get(t);return i?i.add(e):this.events.set(t,new Set([e]))}once(t,e){if(typeof e!="function")return;let i=""+Ws+t,s=this.events.get(i);return s?s.add(e):this.events.set(i,new Set([e]))}off(t,e){let i=this.events.get(t),s=this.events.get(""+Ws+t);!i&&!s||(e===void 0&&(i==null||i.clear(),s==null||s.clear()),i!=null&&i.has(e)&&i.delete(e),s!=null&&s.has(e)&&s.delete(e))}offAll(){this.events.clear()}emit(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;s<e;s++)i[s-1]=arguments[s];let o=this.events.get(t),n=this.events.get(""+Ws+t);!o&&!n||(o==null||o.forEach(r=>{typeof r=="function"&&r(...i)}),n==null||n.forEach(r=>{typeof r=="function"&&r(...i)}),n==null||n.clear())}constructor(){this.events=new Map}};var it=function(a){return a.SWITCH_FLOOR_BEFORE="switch_floor_before",a.SWITCH_FLOOR_GROUND="switch_floor_ground",a.SWITCH_FLOOR_AFTER="switch_floor_after",a}({});import"core-js/modules/es.array.sort.js";function oe(a){return Object.keys(a).sort().map(t=>t+"="+a[t]).join("&")}function Ju(a,t){return new Promise((e,i)=>{let s=new XMLHttpRequest;s.open("GET",a,!0),Object.keys(t.headers||{}).forEach(o=>{s.setRequestHeader(o,t.headers[o])}),t.responseType&&(s.responseType=t.responseType),s.onload=()=>{if(s.status>=200&&s.status<300)if(t.responseType==="arraybuffer")e(s.response);else try{let o=JSON.parse(s.responseText);e(o)}catch(o){i(o)}else i(s.statusText)},s.onerror=()=>{i(s.statusText)},s.send()})}var Qo=Fs(Jo(),1);import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Vector2 as Ne}from"three";function Ma(a,t){let e=a.clone().normalize(),i=t.clone().normalize();return Math.acos(e.dot(i))}function _a(a){let t=0;return a.reduce((e,i)=>{let[s,o]=e,[n,r]=i;return t+=Math.sqrt((n-s)**2+(r-o)**2),[n,r]}),t/a.length}function tn(a,t){if(t===void 0&&(t=.25),_a(a)<t)return a;let e=(0,Qo.default)(a);return tn(e,t)}function mi(a,t,e,i,s,o){t===void 0&&(t=!1),e===void 0&&(e=!0),i===void 0&&(i=5),s===void 0&&(s=150),o===void 0&&(o=3);let n=[],r=!t;if(n.push(a[0]),a.length<2)return n;for(let c=0;c<a.length-2;c+=1){let l=a[c],p=a[c+1],d=a[c+2],u=new Ne(l[0]-p[0],l[1]-p[1]),m=new Ne(d[0]-p[0],d[1]-p[1]),v=Ma(u,m)/Math.PI*180,g=u.length()+m.length();(!r||v<s&&g>.01||g>i)&&(n.push(a[c+1]),r=!0)}if(n.push(a[a.length-1]),!e)return n;let h=[];h.push(n[0]);for(let c=0;c<n.length-2;c+=1){let l=new Ne(n[c][0],n[c][1]),p=new Ne(n[c+1][0],n[c+1][1]),d=new Ne(n[c+2][0],n[c+2][1]),u=l.distanceTo(p)/2,m=d.distanceTo(p)/2,v=p.clone(),g=p.clone();v.add(l.clone().sub(p).normalize().multiplyScalar(u>o?o/2:u)),g.add(d.clone().sub(p).normalize().multiplyScalar(m>o?o/2:m));let x=[[v.x,v.y],[p.x,p.y],[g.x,g.y]];h.push(...tn(x,o/25))}return h.push(n[n.length-1]),Pa(h)}function Pa(a){if(a.length<=1)return a;let t=[],e;return a.forEach(i=>{let[s,o]=i;e?s===e[0]&&o===e[1]||(e=[s,o],t.push([s,o])):(e=[s,o],t.push([s,o]))}),t}function en(a,t,e){let i=Math.sqrt((e[0]-t[0])**2+(e[1]-t[1])**2);if(i===0)return{distance:Math.sqrt((a[0]-t[0])**2+(a[1]-t[1])**2),closestPoint:t.slice(0)};let s=Math.max(0,Math.min(1,((a[0]-t[0])*(e[0]-t[0])+(a[1]-t[1])*(e[1]-t[1]))/i**2)),o=[t[0]+s*(e[0]-t[0]),t[1]+s*(e[1]-t[1])];return{distance:Math.sqrt((a[0]-o[0])**2+(a[1]-o[1])**2),closestPoint:o}}function rm(a,t,e){let[i,s]=a,[o,n]=t,r=Math.sqrt(Math.pow(o-i,2)+Math.pow(n-s,2));if(r===0||r<e)return[...t];let h=e/r,c=i+(o-i)*h,l=s+(n-s)*h;return[c,l]}var Ht=function(a){return 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}({});function Us(a,t,e){let i=me(a,t,e);return Hs(i)}function Hs(a){return 180-Math.abs(a)<15?"front":a>135?"right_front":a<-135?"left_front":a<=135&&a>=60?"right":a>=-135&&a<=-60?"left":a<60&&a>0?"right_back":a>-60&&a<0?"left_back":"front"}function am(a){if(!a.length)return[];if(a.length===1)return[{direction:"start",distance:0,points:a}];let t=[{direction:"start",distance:k(a[0],a[1]),points:[a[0],a[1]]}];for(let e=2;e<a.length;e++){let i=Us(a[e-2],a[e-1],a[e]);if(i==="front"){let s=t[t.length-1],o=k(a[e-1],a[e]);s.distance+=o,e!==2&&s.points.push(a[e-1])}else t.push({direction:i,distance:k(a[e-1],a[e]),points:[a[e-1],a[e]]})}return t.push({direction:"end",distance:0,points:[a[a.length-1]]}),t}function sn(a,t){if(a.length<2)return-1;let e=0;for(let i=1;i<a.length;i++){let s=a[i-1],o=a[i],n=[t[0]-s[0],t[1]-s[1]],r=[o[0]-s[0],o[1]-s[1]],h=Math.min(o[0],s[0])<=t[0]&&t[0]<=Math.max(o[0],s[0]),c=Math.min(o[1],s[1])<=t[1]&&t[1]<=Math.max(o[1],s[1]);if(h&&c){let l=n[0]*r[1]-n[1]*r[0];if(Math.abs(l)<1e-6){let p=Math.sqrt((t[0]-s[0])**2+(t[1]-s[1])**2);return e+p}}e+=Math.sqrt((o[0]-s[0])**2+(o[1]-s[1])**2)}return-1}function ve(a,t){if(a.length<2){var e;return(e=a[0])!=null?e:null}let i=0;for(let s=1;s<a.length;s++){let o=a[s-1],n=a[s],r=Math.sqrt((n[0]-o[0])**2+(n[1]-o[1])**2);if(i+=r,i>=t){let h=(t-(i-r))/r,c=o[0]+(n[0]-o[0])*h,l=o[1]+(n[1]-o[1])*h;return[c,l]}}return null}var Tt=Fs(js(),1);import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.regexp.exec.js";var gt="___",vn=class{initRoute(t){this.clear(),this.roadInfo=t,t.length&&(t.forEach(e=>{e.points.forEach(i=>{let s=""+e.floor+gt+i.id;if(this.pointMap.set(s,i),this.nodeMap.set(""+i.floor+gt+i.nodeId,s),i.type==="straightLadder"){let o=this.straightLadderMap.get(i.name)||[];o.push(w({},i)),this.straightLadderMap.set(i.name,o)}if(i.type==="staircase"){let o=this.staircaseMap.get(i.name)||[];o.push(w({},i)),this.staircaseMap.set(i.name,o)}if(i.type==="escalator"){let o=this.escalatorMap.get(i.name)||{};i.escalatorDirection==="exit"?o.end={floor:i.floor,id:i.id}:o.start={floor:i.floor,id:i.id},this.escalatorMap.set(i.name,o)}if(i.type==="facility"){let o=this.facilityMap.get(i.targetId)||[];o.push(w({},i)),this.facilityMap.set(i.targetId,o)}}),e.lines.filter(i=>i.direction!=="no").forEach(i=>{var s,o;let n=""+e.floor+gt+i.from,r=""+e.floor+gt+i.to,h=(s=this.pointMap.get(n))==null?void 0:s.cds,c=(o=this.pointMap.get(r))==null?void 0:o.cds;if(h!=null&&h.length&&(c!=null&&c.length)){let l=k(h,c);this.addLineItem(n,r,l),i.direction==="double"&&this.addLineItem(r,n,l)}})}),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute())}addLineItem(t,e,i,s){s===void 0&&(s=this.lineMap);let o=s.get(t)||new Map;o.set(e,i),s.set(t,o)}addFacilityToLineMap(t,e,i,s){[...this.straightLadderMap,...this.staircaseMap].forEach(o=>{let[n,r]=o;if(!(r.length<2))for(let l=0;l<r.length;l++){let p=""+r[l].floor+gt+r[l].id;for(let d=0;d<r.length;d++)if(l!==d){var h,c;let u=""+r[d].floor+gt+r[d].id,m=(h=this.pointMap.get(p))==null?void 0:h.cds,v=(c=this.pointMap.get(u))==null?void 0:c.cds;if(m!=null&&m.length&&(v!=null&&v.length))if(r[l].type==="straightLadder"){let g=e;this.addLineItem(p,u,g,s)}else{let g=i;this.addLineItem(p,u,g,s)}}}}),this.escalatorMap.forEach((o,n)=>{if(o.start&&o.end){var r,h;let c=""+o.start.floor+gt+o.start.id,l=""+o.end.floor+gt+o.end.id,p=(r=this.pointMap.get(c))==null?void 0:r.cds,d=(h=this.pointMap.get(l))==null?void 0:h.cds;if(p!=null&&p.length&&(d!=null&&d.length)){let u=t;this.addLineItem(c,l,u,s)}}})}initBaseRoute(){let t=new Map([...this.lineMap]);this.addFacilityToLineMap(1,this.lift_priority,3e4,t),this.baseRoute=new Tt.default(t)}initEscalatorRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(1*e,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new Tt.default(t)}initStraightLadderRoute(){let t=new Map([...this.lineMap]),e=1e4;this.addFacilityToLineMap(3*e,1*e,3e4*e,t),this.straightLadderRoute=new Tt.default(t)}checkStart(t){return!(!t.floor||!t.nodeId&&(!t.coord||t.coord.length<2))}checkEnd(t){return t.facility?!0:this.checkStart(t)}transformStart(t){var e;if(t.nodeId){let i=this.nodeMap.get(""+t.floor+gt+t.nodeId);if(i){let[s,o]=i.split(gt);return{floor:s,id:o}}}if((e=t.coord)!=null&&e.length){let i=this.roadInfo.find(o=>o.floor===t.floor);if(!i)return null;let s=i.points.reduce((o,n)=>{let r=k(t.coord,n.cds);return r<o.min&&(o.min=r,o.point=n),o},{min:1/0,point:i.points[0]});return{floor:s.point.floor,id:s.point.id}}return null}transformEnd(t){if(t.floor){let e=this.transformStart(t);if(e)return e}if(t.facility){let e=this.facilityMap.get(t.facility);if(e!=null&&e.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,i){if(i===void 0&&(i=""),!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let s=this.transformStart(t);if(!s)return"no-start";let o=this.transformEnd(e);if(!o)return"no-end";let n=this.getBasePath.bind(this);switch(i){case"escalator":n=this.getEscalatorPath.bind(this);break;case"straightLadder":n=this.getStraightLadderPath.bind(this);break;default:n=this.getBasePath.bind(this);break}if(o.id)return n(s,o);if(o.facility){let r=this.facilityMap.get(o.facility).filter(c=>o.floor?c.floor===o.floor:!0);if(!r.length)return null;let h=r.map(c=>n(s,{floor:c.floor,id:c.id})).filter(c=>!!c);return h.reduce((c,l)=>{let p=l.reduce((d,u)=>d+ht(u.points),0);return p<c.distance&&(c.distance=p,c.path=l),c},{distance:1/0,path:h[0]}).path}}getRoutePath(t,e,i){let s=""+t.floor+gt+t.id,o=""+e.floor+gt+e.id,n=i.path(s,o);if(!n)return null;let r=[];return n.map(h=>{let c=this.pointMap.get(h);if(c){var l;let{floor:p}=c;if(((l=r[r.length-1])==null?void 0:l.floor)===p){let d=r[r.length-1];d.points.push(c.cds),d.endType=c.type,d.destId=c.nodeId,d.distance=ht(d.points)}else r.push({floor:p,points:[c.cds],endType:c.type,destId:c.nodeId,distance:0})}}),r}getBasePath(t,e){return this.getRoutePath(t,e,this.baseRoute)}getEscalatorPath(t,e){return this.getRoutePath(t,e,this.escalatorRoute)}getStraightLadderPath(t,e){return this.getRoutePath(t,e,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 Tt.default,this.escalatorRoute=new Tt.default,this.straightLadderRoute=new Tt.default}constructor(t=3){this.lift_priority=t,this.roadInfo=[],this.pointMap=new Map,this.nodeMap=new Map,this.facilityMap=new Map,this.straightLadderMap=new Map,this.escalatorMap=new Map,this.staircaseMap=new Map,this.lineMap=new Map,this.baseRoute=new Tt.default,this.escalatorRoute=new Tt.default,this.straightLadderRoute=new Tt.default}};var tt=Fs(js(),1);import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{cloneDeep as $t,isNil as fi}from"lodash";import{Vector2 as Vs}from"three";var T="___",xn=class{setLiftPriority(t){this.lift_priority=t}isFacilityByType(t){return["facility","escalator","straightLadder","staircase","ramp","connectionPoint"].includes(t)}initFacilities(t){this.facilities=t.map(e=>{let i=[];try{i=JSON.parse(e.entry_end_floor)}catch(o){i=[]}let s=[];try{s=JSON.parse(e.entry_start_floor)}catch(o){s=[]}return w({},e,{entry_start_floor:s,entry_end_floor:i})})}getParkingSpaceInfo(t,e){let i=""+t+T+e;var s;return(s=this.parkingMap.get(i))!=null?s:null}getNodeInfo(t,e){let i=""+t+T+e,s=this.nodeMap.get(i);if(!(s!=null&&s.length))return null;let o=this.pointMap.get(s[0]);return o!=null?o:null}initRoute(t,e){this.clear(),this.roadInfo=t,this.initFacilities(e);let i=new Date,s=i.getHours()*60+i.getMinutes();t.length&&(t.forEach(o=>{let n=(o.points||[]).filter(r=>!fi(r.passWeight)&&r.passWeight!==1&&!fi(r.coverageArea)&&r.coverageArea!==0);(o.points||[]).filter(r=>r.openStatus!==!1).filter(r=>{if(!r.startTime||!r.endTime)return!0;let[h,c]=r.startTime.split(":").map(m=>+m),[l,p]=r.endTime.split(":").map(m=>+m),d=h*60+c,u=l*60+p;return s>=d&&s<=u}).forEach(r=>{r.floor=o.floor;let h=""+o.floor+T+r.id,c=""+o.floor+T+r.nodeId,l=this.nodeMap.get(c)||[];if(l.push(""+o.floor+T+(r.relatedId||r.id)),this.nodeMap.set(""+o.floor+T+r.nodeId,l),this.pointMap.set(h,r),this.isFacilityByType(r.type)){let p=this.facilities.find(d=>d.id===+r.targetId);if(p){switch(p.entry_infra_type){case"straightLadder":if(p.entry_end_floor.find(g=>g.floor===o.floor)&&p.entry_start_floor.find(g=>g.floor===o.floor)){let g=this.straightLadderMap.get(r.targetId)||[];g.push(w({},r)),this.straightLadderMap.set(r.targetId,g)}break;case"staircase":if(p.entry_end_floor.find(g=>g.floor===o.floor)&&p.entry_start_floor.find(g=>g.floor===o.floor)){let g=this.staircaseMap.get(r.targetId)||[];g.push(w({},r)),this.staircaseMap.set(r.targetId,g)}break;case"escalator":let u=this.escalatorMap.get(r.targetId)||[];if(p.entry_start_floor.find(g=>g.floor===o.floor)){let g=u.find(x=>{var M;return((M=x.end)==null?void 0:M.floor)!==o.floor&&!x.start});g?g.start=r:u.push({start:r})}if(p.entry_end_floor.find(g=>g.floor===o.floor)){let g=u.find(x=>{var M;return((M=x.start)==null?void 0:M.floor)!==o.floor&&!x.end});g?g.end=r:u.push({end:r})}this.escalatorMap.set(r.targetId,u);break;case"ramp":let m=this.rampMap.get(r.targetId)||[];if(p.entry_start_floor.find(g=>g.floor===o.floor)){let g=m.find(x=>{var M;return((M=x.end)==null?void 0:M.floor)!==o.floor&&!x.start});g?g.start=r:m.push({start:r})}if(p.entry_end_floor.find(g=>g.floor===o.floor)){let g=m.find(x=>{var M;return((M=x.start)==null?void 0:M.floor)!==o.floor&&!x.end});g?g.end=r:m.push({end:r})}this.rampMap.set(r.targetId,m);break;case"connectionPoint":let v=this.connectionPointMap.get(r.targetId)||[];if(p.entry_start_floor.find(g=>g.floor===o.floor)){let g=v.find(x=>{var M;return((M=x.end)==null?void 0:M.floor)!==o.floor&&!x.start});g?g.start=r:v.push({start:r})}if(p.entry_end_floor.find(g=>g.floor===o.floor)){let g=v.find(x=>{var M;return((M=x.start)==null?void 0:M.floor)!==o.floor&&!x.end});g?g.end=r:v.push({end:r})}this.connectionPointMap.set(r.targetId,v);break}let d=this.facilityMap.get(r.targetId)||[];d.push(w({},r)),this.facilityMap.set(r.targetId,d)}}r.type==="parkingSpace"&&r.name.split(/[,,]/).forEach(d=>{this.parkingMap.set(""+o.floor+T+d,r)})}),(o.lines||[]).filter(r=>r.to!==r.from).forEach(r=>{let h=""+o.floor+T+r.from,c=""+o.floor+T+r.to,l=this.pointMap.get(h),p=this.pointMap.get(c);if(!l||!p)return;let d=l.cds,u=p.cds,m=k(d,u);if(n.forEach(v=>{(v.id===r.from||v.id===r.to)&&(m=m/v.passWeight);let g=k(d,v.cds)<=v.coverageArea,x=k(u,v.cds)<=v.coverageArea;(g||x)&&(m=m/v.passWeight)}),!l.permission&&!p.permission){switch(r.direction){case"single-people":this.addLineItem(h,c,m);break;case"back-people":this.addLineItem(c,h,m);break;default:this.addLineItem(h,c,m),this.addLineItem(c,h,m)}switch(r.direction){case"double":this.addLineItem(h,c,m,this.forwardLineMap),this.addLineItem(c,h,m,this.forwardLineMap);break;case"single":this.addLineItem(h,c,m,this.forwardLineMap);break;case"back":this.addLineItem(c,h,m,this.forwardLineMap);break}(l.type==="parkingSpace"||p.type==="parkingSpace")&&r.direction==="noDir"&&(this.addLineItem(h,c,m,this.forwardLineMap),this.addLineItem(c,h,m,this.forwardLineMap))}else l.permission&&this.setPermissionLine(h,c,l.permission,m,"",r.direction),p.permission&&p.permission!==l.permission&&this.setPermissionLine(h,c,p.permission,m,"",r.direction)})}),this.addPermissionFacility(),this.initBaseRoute(),this.initEscalatorRoute(),this.initStraightLadderRoute(),this.initForwardRoute())}getPermissionMap(t){return this["permission_"+t]||(this["permission_"+t]=new Set),this["permission_"+t]}setPermissionLine(t,e,i,s,o,n){this.getPermissionMap(i).add({fromKey:t,toKey:e,distance:s,type:o,direction:n})}addPermissionFacility(){this.straightLadderMap.forEach((t,e)=>{if(t.length<2){this.straightLadderMap.delete(e);return}for(let i=0;i<t.length;i++){let s=""+t[i].floor+T+t[i].id,o=this.pointMap.get(s);if(o){for(let n=0;n<t.length;n++)if(i!==n){let r=""+t[n].floor+T+t[n].id,h=this.pointMap.get(r);if(!h)continue;o.permission&&this.setPermissionLine(s,r,o.permission,1,"straightLadder"),h.permission&&h.permission!==o.permission&&this.setPermissionLine(s,r,h.permission,1,"straightLadder")}}}}),this.staircaseMap.forEach((t,e)=>{if(t.length<2){this.staircaseMap.delete(e);return}for(let i=0;i<t.length;i++){let s=""+t[i].floor+T+t[i].id,o=this.pointMap.get(s);if(o){for(let n=0;n<t.length;n++)if(i!==n){let r=""+t[n].floor+T+t[n].id,h=this.pointMap.get(r);if(!h)continue;o.permission&&this.setPermissionLine(s,r,o.permission,1,"staircase"),h.permission&&h.permission!==o.permission&&this.setPermissionLine(s,r,h.permission,1,"staircase")}}}}),this.escalatorMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&(n.permission&&this.setPermissionLine(s,o,n.permission,1,"escalator"),r.permission&&r.permission!==n.permission&&this.setPermissionLine(s,o,r.permission,1,"escalator"))}})}),this.rampMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&(n.permission&&this.setPermissionLine(s,o,n.permission,10,"ramp"),r.permission&&r.permission!==n.permission&&this.setPermissionLine(s,o,r.permission,10,"ramp"))}})}),this.connectionPointMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&(n.permission&&this.setPermissionLine(s,o,n.permission,1,"connectionPoint"),r.permission&&r.permission!==n.permission&&this.setPermissionLine(s,o,r.permission,1,"connectionPoint"))}})})}addPermissionLineToMap(t,e,i,s){this.getPermissionMap(t).forEach(n=>{if(e.includes(n.type))if(n.type==="")switch(n.direction){case"single":this.addLineItem(n.fromKey,n.toKey,n.distance,i);break;case"back":this.addLineItem(n.toKey,n.fromKey,n.distance,i);break;case"single-people":this.addLineItem(n.fromKey,n.toKey,n.distance,i);break;case"back-people":this.addLineItem(n.toKey,n.fromKey,n.distance,i);break;default:this.addLineItem(n.fromKey,n.toKey,n.distance,i),this.addLineItem(n.toKey,n.fromKey,n.distance,i);break}else this.addLineItem(n.fromKey,n.toKey,s.get(n.type),i)})}addLineItem(t,e,i,s){s===void 0&&(s=this.lineMap);let o=s.get(t)||new Map;o.set(e,i),s.set(t,o)}addFacilityToLineMap(t,e,i,s){[...this.straightLadderMap,...this.staircaseMap].forEach(o=>{let[n,r]=o;if(!(r.length<2))for(let h=0;h<r.length;h++){let c=""+r[h].floor+T+r[h].id,l=this.pointMap.get(c);if(!(!l||l.permission)){for(let p=0;p<r.length;p++)if(h!==p){let d=""+r[p].floor+T+r[p].id,u=this.pointMap.get(d);if(!u||u.permission)continue;if(r[h].type==="straightLadder"){let m=e;this.addLineItem(c,d,m,s)}else{let m=i;this.addLineItem(c,d,m,s)}}}}}),this.escalatorMap.forEach((o,n)=>{o.forEach(r=>{if(r.start&&r.end){let h=""+r.start.floor+T+r.start.id,c=""+r.end.floor+T+r.end.id,l=this.pointMap.get(h),p=this.pointMap.get(c);if(l&&p&&!l.permission&&!p.permission){let d=t;this.addLineItem(h,c,d,s)}}})}),this.connectionPointMap.forEach((o,n)=>{o.forEach(r=>{if(r.start&&r.end){let h=""+r.start.floor+T+r.start.id,c=""+r.end.floor+T+r.end.id,l=this.pointMap.get(h),p=this.pointMap.get(c);l&&p&&!l.permission&&!p.permission&&this.addLineItem(h,c,100,s)}})})}initBaseRoute(){let t=new Map($t([...this.lineMap]));this.addFacilityToLineMap(100,100*this.lift_priority,3e4,t),this.baseRoute=new tt.default(t)}initEscalatorRoute(){let t=new Map($t([...this.lineMap])),e=1e4;this.addFacilityToLineMap(100,this.lift_priority*e,3e4*e,t),this.escalatorRoute=new tt.default(t)}initStraightLadderRoute(){let t=new Map($t([...this.lineMap])),e=1e4;this.addFacilityToLineMap(3*e,300,3e4*e,t),this.straightLadderRoute=new tt.default(t)}initForwardRoute(){this.rampMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&!n.permission&&!r.permission&&this.addLineItem(s,o,10,this.forwardLineMap)}})}),this.connectionPointMap.forEach((t,e)=>{t.forEach(i=>{if(i.start&&i.end){let s=""+i.start.floor+T+i.start.id,o=""+i.end.floor+T+i.end.id,n=this.pointMap.get(s),r=this.pointMap.get(o);n&&r&&!n.permission&&!r.permission&&this.addLineItem(s,o,100,this.forwardLineMap)}})}),this.forwardRoute=new tt.default(this.forwardLineMap)}checkStart(t){return!(!t.floor||!t.nodeId&&(!t.coord||t.coord.length<2))}checkEnd(t){return t.facility||t.parkingSpace&&t.floor?!0:this.checkStart(t)}transformStart(t,e,i){i===void 0&&(i={});var s;if(t.nodeId){let o=this.nodeMap.get(""+t.floor+T+t.nodeId);if(o!=null&&o.length)return o.map(n=>{let[r,h]=n.split(T);return{floor:r,id:h}})}if((s=t.coord)!=null&&s.length){let o=this.roadInfo.find(c=>c.floor===t.floor);if(!o)return null;let n=o.points.filter(c=>c.isStarted),r=o.points.filter(c=>{let l=""+c.floor+T+c.id;if(e==="forward"){if(!this.forwardLineMap.has(l)||i.adsorptionIntersection&&n.length&&!c.isStarted)return!1}else if(!this.lineMap.has(l))return!1;return!0});if(!r.length)return null;let h=r.reduce((c,l)=>{if(l.relatedId)return c;let p=k(t.coord,l.cds);return p<c.min&&(c.min=p,c.point=l),c},{min:1/0,point:r[0]});return[{floor:o.floor,id:h.point.id}]}return null}transformEnd(t,e){if(t.floor){if(t.parkingSpace){let s=this.parkingMap.get(""+t.floor+T+t.parkingSpace);if(s)return[{floor:t.floor,id:s.id}]}let i=this.transformStart(t,e);if(i)return i}if(t.facility){let s=this.facilities.filter(o=>+o.type_id==+t.facility).map(o=>o.id).map(o=>this.facilityMap.get(""+o)).flat(2);if(s!=null&&s.length)return{floor:t.floor,facility:t.facility}}return null}getPath(t,e,i,s,o,n){if(i===void 0&&(i=""),n===void 0&&(n={}),!this.checkStart(t))return"start-error";if(!this.checkEnd(e))return"end-error";let r=this.transformStart(t,i,n);if(!r)return"no-start";let h=this.transformEnd(e,i);if(!h)return"no-end";let c=[];if(Array.isArray(h))for(let d=0;d<r.length;d++){let u=r[d];for(let m=0;m<h.length;m++){let v=h[m];if(u.floor===v.floor&&u.id===v.id)return"near"}}else{c=this.facilities.filter(u=>+u.type_id==+e.facility).map(u=>u.id).map(u=>this.facilityMap.get(""+u)).flat(2).filter(u=>u).filter(u=>h.floor?u.floor===h.floor:!0);for(let u=0;u<r.length;u++){let m=r[u];for(let v=0;v<c.length;v++){let g=c[v];if(m.floor===g.floor&&m.id===g.id)return"near"}}}let l;switch(i){case"escalator":l=this.getEscalatorPath.bind(this);break;case"straightLadder":l=this.getStraightLadderPath.bind(this);break;case"forward":l=this.getForwardPath.bind(this);break;default:l=this.getBasePath.bind(this);break}let p=null;return r.forEach(d=>{if(Array.isArray(h))h.forEach(u=>{let m=l(d,u,s,o);m&&m&&(!p||m[0].consume<p[0].consume)&&(p=m)});else{if(!c.length)return null;let u=c.map(m=>l(d,{floor:m.floor,id:m.id},s,o)).filter(m=>!!m);p=u.reduce((m,v)=>{let g=v[0].consume;return g<m.distance&&(m.distance=g,m.path=v),m},{distance:1/0,path:u[0]}).path}}),p}getRoutePath(t,e,i){let s=""+t.floor+T+t.id,o=this.pointMap.get(s),n=""+e.floor+T+e.id,r=this.pointMap.get(n);if(!o||!r)return null;let h=""+o.floor+T+(o.relatedId||o.id),c=""+r.floor+T+(r.relatedId||r.id),l=i.path(h,c);if(!l)return null;let p=[],d=l.reduce((u,m,v,g)=>{if(v===0)return 0;let x=g[v-1],M=i.graph.get(x).get(m);return u+M},0);return l.map(u=>{let m=this.pointMap.get(u);if(m){var v;let{floor:g}=m,x=m.type;if(this.isFacilityByType(m.type)){let M=this.facilities.find(P=>P.id===+m.targetId);M&&(x=M.entry_infra_type)}if(((v=p[p.length-1])==null?void 0:v.floor)===g){let M=p[p.length-1];M.points.push(m.cds),M.pointInfos.push(m),M.endType=x,M.destId=m.nodeId,M.distance=ht(M.points)}else p.push({floor:g,points:[m.cds],pointInfos:[m],endType:x,destId:m.nodeId,distance:0,consume:d})}}),p}getBasePath(t,e,i){if(!i)return this.getRoutePath(t,e,this.baseRoute);let s=$t(this.baseRoute.graph),o=r=>{this.addPermissionLineToMap(r,["","escalator","staircase","straightLadder","connectionPoint"],s,new Map([["escalator",100],["connectionPoint",100],["straightLadder",100*this.lift_priority],["staircase",3e4]]))};Array.isArray(i)?i.forEach(r=>{o(r)}):o(i);let n=new tt.default(s);return this.getRoutePath(t,e,n)}getEscalatorPath(t,e,i){if(!i)return this.getRoutePath(t,e,this.escalatorRoute);let s=$t(this.escalatorRoute.graph),o=1e4,n=h=>{this.addPermissionLineToMap(h,["","escalator","staircase","straightLadder","connectionPoint"],s,new Map([["escalator",100],["connectionPoint",100],["straightLadder",this.lift_priority*o],["staircase",3e4*o]]))};Array.isArray(i)?i.forEach(h=>{n(h)}):n(i);let r=new tt.default(s);return this.getRoutePath(t,e,r)}getStraightLadderPath(t,e,i){if(!i)return this.getRoutePath(t,e,this.straightLadderRoute);let s=$t(this.straightLadderRoute.graph),o=1e4,n=h=>{this.addPermissionLineToMap(h,["","escalator","staircase","straightLadder","connectionPoint"],s,new Map([["escalator",3*o],["connectionPoint",100],["straightLadder",300],["staircase",3e4*o]]))};Array.isArray(i)?i.forEach(h=>{n(h)}):n(i);let r=new tt.default(s);return this.getRoutePath(t,e,r)}getForwardPath(t,e,i,s){let o=new Map,n=u=>{let m=this.forwardRoute.graph.get(h);u.forEach(v=>{let g=m.get(v);fi(g)||(o.set(v,g),m.delete(v))})},r=()=>{let u=this.forwardRoute.graph.get(h);o.forEach((m,v)=>{u.set(v,m)})},h=""+t.floor+T+t.id;if(!fi(s)){let u=this.forwardLineMap.get(h),m=this.pointMap.get(h);if(m&&(u!=null&&u.size)&&u.size>1){let v=new Vs(m.cds[0],m.cds[1]),g=new Map;u.forEach((M,P)=>{let E=this.pointMap.get(P);if(E){let b=new Vs(E.cds[0],E.cds[1]),S=360-(new Vs().subVectors(b,v).angle()/Math.PI*180-90+360)%360;g.set(P,S)}});let x=Array.from(g).filter(M=>{let[P,E]=M;return Math.abs(E-s)<=60}).map(M=>{let[P]=M;return P});if(x.length)x.forEach(M=>g.delete(M)),n([...g.keys()]);else{let M=Array.from(g).reduce((P,E)=>{let b=Math.abs(E[1]-s);return b<P.diff?{diff:b,key:E[0]}:P},{diff:1/0,key:""});g.delete(M.key),n([...g.keys()])}}}if(!i){let u=this.getRoutePath(t,e,this.forwardRoute);return r(),u||this.getRoutePath(t,e,this.forwardRoute)}let c=$t(this.forwardRoute.graph),l=u=>{this.addPermissionLineToMap(u,["","ramp"],c,new Map([["ramp",10]]))};Array.isArray(i)?i.forEach(u=>{l(u)}):l(i);let p=new tt.default(c),d=this.getRoutePath(t,e,p);if(r(),d)return d;{let u=$t(this.forwardRoute.graph);Array.isArray(i)?i.forEach(g=>{l(g)}):l(i);let m=new tt.default(u);return this.getRoutePath(t,e,m)}}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 tt.default,this.escalatorRoute=new tt.default,this.straightLadderRoute=new tt.default}constructor(t=3){this.lift_priority=t,this.roadInfo=[],this.facilities=[],this.pointMap=new Map,this.nodeMap=new Map,this.facilityMap=new Map,this.straightLadderMap=new Map,this.escalatorMap=new Map,this.rampMap=new Map,this.staircaseMap=new Map,this.connectionPointMap=new Map,this.parkingMap=new Map,this.lineMap=new Map,this.baseRoute=new tt.default,this.escalatorRoute=new tt.default,this.straightLadderRoute=new tt.default,this.forwardLineMap=new Map,this.forwardRoute=new tt.default}};import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";var Jt=class{static createKey(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}static genUniqueKey(){let t=this.createKey();for(;this.keySet.has(t);)t=this.createKey();return t}static removeKey(t){this.keySet.delete(t)}static dispose(){this.keySet.clear()}};Jt.keySet=new Set;import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/es.array.push.js";function wn(a){return a.replace(/[A-Z]/g,t=>"_"+t.toLowerCase()).replace(/^_/,"")}function Mn(a){let t=[],e=/(\([^()]*\))|([^()]*)/g,i=0,s;for(;(s=e.exec(a))!==null;)s.index>i&&t.push(a.substring(i,s.index)),t.push(s[0]),i=s.index+s[0].length;return i<a.length&&t.push(a.substring(i)),t}function F(a,t,e){return new Promise((i,s)=>{let o=Jt.genUniqueKey(),n=r=>{let{data:h}=r;h.type===""+t+"_result"&&h.key===o&&(Jt.removeKey(o),self.removeEventListener("message",n),h.error?s(h.error):i(h.data))};a.addEventListener("message",n),a.postMessage({type:t,key:o,data:e})})}function Jm(a){let t={};for(let i in a)i.startsWith("on")&&(t[wn(i.slice(2))]=a[i],t[i]=a[i]);let e=i=>f(this,null,function*(){let{data:s}=i;if(t[s.type])try{let o=yield t[s.type](s.data);if(o!=null&&o.$transfer&&Array.isArray(o.$transfer)){let n=o.$transfer;delete o.$transfer,self.postMessage({type:""+s.type+"_result",key:s.key,data:o},n)}else self.postMessage({type:""+s.type+"_result",key:s.key,data:o})}catch(o){self.postMessage({type:""+s.type+"_result",key:s.key,error:o})}else self.postMessage({type:""+s.type+"_result",key:s.key,error:"no_event"})});return self.addEventListener("message",e),()=>{self.removeEventListener("message",e)}}import{BoxGeometry as La,BufferGeometry as Ca,Line as Ta,LineBasicMaterial as ka,Mesh as Da,MeshBasicMaterial as Aa}from"three";function sf(a,t){t===void 0&&(t=16711680);let e=new ka({color:t}),i=new Ca().setFromPoints(a);return new Ta(i,e)}function of(a,t){t===void 0&&(t=16711680);let e=new Aa({color:t,depthTest:!1,transparent:!0}),i=new La(1,1,1),s=new Da(i,e);return s.position.copy(a),s.renderOrder=100100,s}import"core-js/modules/es.json.stringify.js";import"core-js/modules/web.dom-collections.iterator.js";function gi(a,t,e){e===void 0&&(e=0),a.forEach(i=>{if(i.geometry.coords=JSON.parse(JSON.stringify(i.geometry.cds)),i.geometry.type==="polygon"){var s;i.geometry.coords.map(o=>{Array.isArray(o)&&o.forEach(n=>{n[0]-=t[0],n[1]-=t[1]})}),i.geometry.otherCds&&(i.geometry.otherCoords=i.geometry.otherCds.map(o=>o.map(n=>xe(n,t)))),(s=i.doors)!=null&&s.length&&i.doors.map(o=>{o.coord=xe(o.coordinate,t)}),i.center&&(i.centerCoords=xe(i.center,t))}else i.geometry.coords=xe(i.geometry.cds,t),i.center&&(i.centerCoords=xe(i.center,t));if(i.center_x&&i.center_y){let[o,n]=xe([i.center_x,i.center_y],t);i.center_coord_x=o,i.center_coord_y=n}});for(let i=0;i<a.length;i++){let s=a[i];s.deltaHeight=1e-5*(e+i+1)}}function xe(a,t){return[a[0]-t[0],a[1]-t[1]]}import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/web.dom-collections.iterator.js";import{Group as Oa}from"@tweenjs/tween.js";var Qt=class{update(){this.group.update()}pause(){this.pauseTween=!0,this.getAll().forEach(t=>{this.tweenStore.add(t),t.pause()})}continue(){this.pauseTween&&(this.tweenStore.forEach(t=>{t.resume()}),this.tweenStore.clear(),this.pauseTween=!1)}remove(t){this.group.remove(t)}getAll(){return this.group.getAll()}clear(){this.getAll().forEach(t=>t.stop()),this.group.removeAll()}dispose(){this.clear()}constructor(){this.pauseTween=!1,this.tweenStore=new Set,this.group=new Oa}};import{EventDispatcher as Ia}from"three";var yi=class extends Ia{registryEvent(){this.ctn.addEventListener("pointerdown",this._pointerDown),this.ctn.addEventListener("pointerup",this._pointerUp)}unRegistryEvent(){this.ctn.removeEventListener("pointerdown",this._pointerDown),this.ctn.removeEventListener("pointerup",this._pointerUp)}dispose(){this.unRegistryEvent()}constructor(t){super(),this.ctn=t,this._pointerDown=e=>{this.point={x:e.offsetX,y:e.offsetY}},this._pointerUp=e=>{if(!this.point)return;let{offsetX:i,offsetY:s}=e,{x:o,y:n}=this.point;Math.hypot(o-i+(n-s))>3||this.dispatchEvent({type:"click",e})},this.registryEvent()}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.string.replace.js";import"core-js/modules/es.regexp.exec.js";import{isNil as Ra}from"lodash";import{EventDispatcher as Ga}from"three";var we=class extends Ga{_isEffectiveTask(t){return t&&typeof t.run=="function"}_getIndexByTid(t){return this._task.findIndex(e=>e.tid===t)}_createTask(t){return this._isEffectiveTask(t)?w({},t,{tid:++this._id,meta:t.meta||{}}):!1}get task(){return[...this._task]}getTasks(){return[...this._task]}add(t){if(this._isEffectiveTask(t)){let e=this._createTask(t);return this._task.push(e),this.started&&!this.activeTask&&this.start(),e.tid}return!1}replace(t,e){if(!this._isEffectiveTask(e))return console.warn("[TaskQueue] replace\u65B9\u6CD5\u4F20\u5165\u7684task\u53C2\u6570\u683C\u5F0F\u4E0D\u6B63\u786E"),!1;let i=this._getIndexByTid(t);if(i===-1)return console.warn("[TaskQueue] \u6CA1\u6709\u627E\u5230id="+t+"\u7684\u4EFB\u52A1"),!1;let s=this._createTask(e);return this._task.splice(i,1,s),s.tid}replaceByMetaType(t){var e;let i=(e=t.meta)==null?void 0:e.type;if(Ra(i))return this.add(t);{let s=this._task.find(o=>o.meta.type===i);return s?this.replace(s.tid,t):this.add(t)}}remove(t){let e=this._getIndexByTid(t);return e===-1?(console.warn("[TaskQueue] remove\u65B9\u6CD5\u4F20\u5165\u7684id\uFF1A"+t+"\u627E\u4E0D\u5230\u5BF9\u5E94\u7684task"),!1):(this._task.splice(e,1),!0)}clear(){this._task.length=0}start(){this.started=!0,!this.activeTask&&this._task.length&&this.exec()}stop(){this.started=!1}exec(){return f(this,null,function*(){if(!this.started||!this._task.length)return!1;let t=this._task.shift();this.activeTask=t,this.dispatchEvent({type:"active-task-start",task:t});let e;try{e=yield t.run()}catch(i){console.warn("[task run err]",i,t)}return this.activeTask=null,this.dispatchEvent({type:"active-task-end",task:t,res:e}),this.exec()})}constructor(t=!0){super(),this._task=[],this.started=!1,this.activeTask=null,this._id=0,t&&this.start()}};import"core-js/modules/es.array.push.js";import{EventDispatcher as Fa}from"three";var vi=class extends Fa{getWorker(){return new Promise(t=>{let e=this.pool.find(s=>s.state==="leisure");if(e){e.state="used",t(e.worker);return}if(this.pool.length<this.max&&this.workerConstructor){let s=this.workerConstructor();this.pool.push({worker:s,state:"used"}),t(s);return}let i=()=>{let s=this.pool.find(o=>o.state==="leisure");s&&(this.removeEventListener("release",i),s.state="used",t(s.worker))};this.addEventListener("release",i)})}releaseWorker(t){let e=this.pool.find(i=>i.worker===t);e&&(e.state="leisure",this.dispatchEvent({type:"release",worker:t}))}dispose(){this._listeners={},this.pool.forEach(t=>{t.worker.terminate()}),this.pool=[]}constructor(t=10,e){super(),this.max=10,this.pool=[],this.max=t,this.workerConstructor=e}};import{EventDispatcher as za}from"three";var X=class extends za{dispose(){this._listeners={}}};var xi=class{filter(t){let e=this.estimate,i=this.errorEstimate+this.processNoise,s=i/(i+this.measurementNoise);return this.estimate=e+s*(t-e),this.errorEstimate=(1-s)*i,this.estimate}constructor(t={}){this.estimate=0,this.errorEstimate=1,this.processNoise=.1,this.measurementNoise=1,this.measurementNoise=t.measurementNoise||1,this.processNoise=t.processNoise||.1,this.errorEstimate=t.errorEstimate||1}};import"core-js/modules/es.typed-array.float32-array.js";import"core-js/modules/es.typed-array.at.js";import"core-js/modules/es.typed-array.fill.js";import"core-js/modules/es.typed-array.find-last.js";import"core-js/modules/es.typed-array.find-last-index.js";import"core-js/modules/es.typed-array.set.js";import"core-js/modules/es.typed-array.sort.js";import"core-js/modules/es.typed-array.to-reversed.js";import"core-js/modules/es.typed-array.to-sorted.js";import"core-js/modules/es.typed-array.with.js";import"core-js/modules/es.array-buffer.constructor.js";import"core-js/modules/es.array-buffer.slice.js";import"core-js/modules/es.array-buffer.detached.js";import"core-js/modules/es.array-buffer.transfer.js";import"core-js/modules/es.array-buffer.transfer-to-fixed-length.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import{BufferAttribute as Me,BufferGeometry as Ba,Color as Ks,ExtrudeGeometry as Wa,Matrix4 as Ua,Quaternion as Ha,Vector3 as Ze}from"three";import{mergeGeometries as Na}from"three/examples/jsm/utils/BufferGeometryUtils.js";import{polygon as Za,center as ja}from"@turf/turf";function og(a,t,e){t===void 0&&(t=!0),e===void 0&&(e=!1);let i=a.filter(r=>r.geometry.type==="polygon");if(!i.length)return null;let s=i.map(r=>{var h;let c=r.geometry.coords,l=hi(c[0],c.slice(1)),p=new Wa(l,{steps:1,bevelEnabled:!1,depth:r.height,curveSegments:4});(h=r).deltaHeight||(h.deltaHeight=0),p.translate(0,0,r.airHeight+r.deltaHeight);let d=p.attributes.position.count,u=new Float32Array(d).fill(r.height+r.airHeight+r.deltaHeight);if(p.setAttribute("maxZ",new Me(u,1)),p.setAttribute("opacity",new Me(new Float32Array(d).fill(r.fillOpacity),1)),e){let g=new Float32Array(d).fill(r.airHeight+r.deltaHeight);p.setAttribute("minZ",new Me(g,1))}let m=new Ks(r.fillColor).convertLinearToSRGB(),v=new Float32Array(d*3);for(let g=0;g<d;g++)v[g*3]=m.r,v[g*3+1]=m.g,v[g*3+2]=m.b;return p.setAttribute("color",new Me(v,3)),p}),o=Na(s);s.forEach(r=>r.dispose());let n={geometry:o};return o.dispose(),t&&(n.lineGeometry=Va(i)||void 0),n}function ng(a){let t=a.filter(h=>h.geometry.type==="polygon");if(!t.length)return null;let e=[],i=[],s=[],o=[],n=[],r=[];return t.map((h,c)=>{var l;(l=h).deltaHeight||(l.deltaHeight=0);let p=h.geometry.coords,d=k(p[0][0],p[0][1]),u=k(p[0][1],p[0][2]),m=p[0][1][0]-p[0][0][0],v=p[0][1][1]-p[0][0][1],g=Math.atan2(v,m),x=ja(Za(p)),M=x.geometry.coordinates[0],P=x.geometry.coordinates[1],E=new Ua().compose(new Ze(M,P,h.deltaHeight+h.airHeight+h.height/2),new Ha().setFromAxisAngle(new Ze(0,0,1),g),new Ze(d,u,h.height));e.push(...E.toArray()),i.push(...new Ks(h.fillColor).convertLinearToSRGB().toArray());var b;s[c]=(b=h.fillOpacity)!=null?b:1;var A;o[c]=((A=h.deltaHeight)!=null?A:0)+h.airHeight+h.height,n[c]=h.id,r[c]=h.airHeight+h.deltaHeight}),{size:t.length,ids:n,matrixes:e,colors:i,opacities:s,maxZs:o,minZs:r}}function Va(a){let{points:t,colors:e,opacities:i}=Xs(a);if(!t.length)return null;let s=new Ba().setFromPoints(t);return s.setAttribute("color",new Me(new Float32Array(e),3)),s.setAttribute("opacity",new Me(new Float32Array(i),1)),s}function Xs(a){let t=[],e=[],i=[];return a.filter(s=>s.strokeOpacity>0).map(s=>{let o=s.height+(s.deltaHeight||0)+s.airHeight,{coords:n}=s.geometry,{strokeColor:r,strokeOpacity:h}=s,c=new Ks(r).convertLinearToSRGB();for(let l=0;l<n.length;l++){let p=n[l];for(let d=0;d<p.length;d++){let u=p[d],m=d+1===p.length?p[0]:p[d+1];t.push(new Ze(u[0],u[1],o)),t.push(new Ze(m[0],m[1],o)),e.push(c.r,c.g,c.b),e.push(c.r,c.g,c.b),i.push(h),i.push(h)}}}),{points:t,colors:e,opacities:i}}function rg(a){if(a.length>1)return!1;let t=a[0];if(t.length!==5)return!1;let[e]=t,i=t[t.length-1];if(e[0]!==i[0]||e[1]!==i[1])return!1;let s=[Math.round(k(t[0],t[1])),Math.round(k(t[1],t[2])),Math.round(k(t[2],t[3])),Math.round(k(t[3],t[4]))];if(!(s[2]===s[0]&&s[3]===s[1]))return!1;let o=me(t[0],t[1],t[2]);return Math.abs(Math.abs(o)-90)<1}import{EventDispatcher as up,Box2 as mp,Vector3 as jt,Vector2 as Ae,Raycaster as fp,Box3 as gp,Color as yp,AmbientLight as vp}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.push.js";import{EventDispatcher as Xl}from"three";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import{Object3D as hh,ExtrudeGeometry as ch,Mesh as lh,Box3 as Si,Vector3 as yt,BufferGeometry as ph,LineSegments as dh,Ray as Gn,Vector2 as Nt,DoubleSide as uh,RepeatWrapping as Fn}from"three";import"core-js/modules/web.dom-collections.iterator.js";import{LineMaterial as Ka}from"three/examples/jsm/lines/LineMaterial.js";import{Color as je,LineBasicMaterial as Xa,MeshStandardMaterial as Ya,MeshBasicMaterial as qa,ShaderMaterial as _e,DoubleSide as $a,LineDashedMaterial as Ja}from"three";function _n(a){return a.x+"-"+a.y+"-"+a.z}var L=class{static generateLineMaterialKey(t){let{color:e,opacity:i}=t;return e+"-"+i}static createLineMaterial(t){let{color:e,opacity:i,vertexColors:s}=t,o=this.generateLineMaterialKey({color:e,opacity:i,vertexColors:s});if(this.lineMaterialMap.has(o))return this.lineMaterialMap.get(o);let n=new Xa({color:new je(e).convertLinearToSRGB(),transparent:!0,opacity:i,vertexColors:s!=null?s:!1});return this.lineMaterialMap.set(o,n),n}static createMeshStandardMaterial(t){let{color:e,opacity:i}=t,s=e+"-"+i;if(this.meshStandardMaterialMap.has(s))return this.meshStandardMaterialMap.get(s);let o=new Ya({color:new je(e).convertLinearToSRGB(),roughness:1,transparent:!0,opacity:i,depthWrite:!0});return this.meshStandardMaterialMap.set(s,o),o}static createMeshBasicMaterial(t){let{color:e,opacity:i,vertexColors:s}=t,o=e+"-"+i+"-"+s;if(this.meshBasicMaterialMap.has(o))return this.meshBasicMaterialMap.get(o);let n=new qa({color:e,transparent:!0,opacity:i,depthWrite:!0,vertexColors:s!=null?s:!1});return this.meshBasicMaterialMap.set(o,n),n}static createShaderMaterial(t){let{gradualColor:e,center:i,maxValue:s,opacity:o,direction:n,max:r,min:h}=t,c=e.toString()+"-"+_n(i)+"-"+s+"-"+o+"-"+_n(n);if(this.shaderMaterialMap.has(c))return this.shaderMaterialMap.get(c);let l=`
2
2
  uniform vec3 uColor;
3
3
  uniform vec3 uGradualColor;
4
4
  uniform vec3 center;
@@ -505,7 +505,7 @@ var ra=Object.create;var Gs=Object.defineProperty;var aa=Object.getOwnPropertyDe
505
505
  top: 0;
506
506
  left: 0;
507
507
  z-index: 9999;
508
- `,document.body.appendChild(a.canvas)}setAngle(t){if(console.log("angle",t),a.textureMap.has(t))this._initIcon(a.textureMap.get(t));else{this.draw(t);let e=this.getTexture(this.getImageData());a.textureMap.set(t,e),this._initIcon(e),this._initScale({zoom:this.bmap.context.camera.zoom})}}_initIcon(t){if(this.spriteIcon)this.spriteIcon.material.map=t,t.needsUpdate=!0;else{let e=new ld(new pd({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI}));e.renderOrder=1e5+this.options.level,t.needsUpdate=!0,this.add(e),e.center.set(.5,.5),this.spriteIcon=e}}initSize(){this.spriteIcon&&this.spriteIcon.center.set(.5,.5)}draw(t){let{ctx:e}=a,{config:{size:i}}=this,s=i[0]/2,o=i[1]/2,n=4,r=1,h=n+r;if(e.clearRect(0,0,i[0],i[1]),e.setLineDash([10,10]),e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),e.arc(s,o,o-h,-Math.PI/2,Math.PI*2-Math.PI/2,t<Math.PI),e.stroke(),e.strokeStyle="#0A7AFF",t<Math.PI){let c=-Math.PI/2,l=c-t;e.beginPath(),e.arc(s,o,o-h,c,l,!0)}else{let c=-Math.PI/2,l=c+Math.PI*2-t;e.beginPath(),e.arc(s,o,o-h,c,l,!1)}e.stroke(),e.clearRect(s-h*2,0,h*4,h*4),e.beginPath(),e.arc(s,h,n,0,Math.PI*2),e.fillStyle="#0A7AFF",e.fill(),e.setLineDash([10,0]),e.strokeStyle="#fff",e.lineWidth=r,e.stroke(),e.clearRect(0,o-5,10,10),e.clearRect(s-5,i[1]-10,10,10),e.clearRect(i[0]-10,o-5,10,10),t>Math.PI/2&&t<Math.PI?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(0,o-1,10,2),e.fillStyle="#fff",e.fillRect(s-1,i[1]-10,2,10),t>Math.PI&&t<Math.PI/2*3?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(i[0]-10,o-1,10,2)}getImageData(){let{ctx:t}=a,{config:{size:e}}=this;return t.getImageData(0,0,e[0],e[1])}getTexture(t){let{config:{size:e}}=this,i=new cd(Uint8Array.from(t.data),e[0],e[1],Er);return i.format=Er,i.magFilter=Sr,i.minFilter=Sr,i.colorSpace="srgb",i.flipY=!0,i}dispose(){var t;super.dispose(),(t=this.spriteIcon)==null||t.material.dispose()}static dispose(){this.textureMap.forEach(t=>{t.dispose()}),this.textureMap.clear(),this.ctx=null,this.canvas=null}constructor(t,e){super(t.context,{icon_size:e.size,collision_enable:!1,level:2}),this.bmap=t,this.config=e,a.canvas.width=e.size[0],a.canvas.height=e.size[1]}};Vt.canvas=document.createElement("canvas");Vt.ctx=Vt.canvas.getContext("2d",{willReadFrequently:!0});Vt.textureMap=new Map;var md={path:{},cheapMaximumDistance:20,needStartPoi:!1,startPoi:{},positionNavigation:{},offsetY:150,directionEmitThreshold:5,disablePathAnimation:!1,disablePathRotate:!1,disablePathShorten:!1,speed:1,roadData:[],runAnimationMaxTime:1,navigationCameraBasic:45,canBack:!1},Lr=class extends B{get curFloorPathLength(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.distance)!=null?e:0}get curFloorPathPoints(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.points)!=null?e:[]}registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate),this.bmap.addEventListener(it.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.addEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.addEventListener("control-change",this.onControlChangeForStartPoi)}setRoadData(t){this.options.roadData=t,this.positionNavigation.setRoadData(t)}showStartRotateHelperPoi(){var t;if(this.needStartRotateHelperPoi=!0,!this.startPoi||this.startRotateHelperPoi)return;let e=this.startPoi.options.icon_size;this.startRotateHelperPoi=new Vt(this.bmap,{size:[e[0]+20,e[1]+20]}),this.startRotateHelperPoi.setAngle(0),this.startRotateHelperPoi.position.setZ(.51),(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.startRotateHelperPoi)}hideStartRotateHelperPoi(){if(this.needStartRotateHelperPoi=!1,this.startRotateHelperPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}setStartPoiPosition(t,e){this.startPoi&&(this.startPoi.position.setX(t).setY(e),this.startRotateHelperPoi&&this.startRotateHelperPoi.position.setX(t).setY(e),this.detachLine&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position))}resetStatus(){this.pauseAnimation(),this.positionNavigation.resetStatus(this.paths),this.movedDistance=0,this.startPoi&&this.translatePath&&this.setStartPoiPosition(this.translatePath[0][0],this.translatePath[0][1])}toPositionByTask(t){var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="toPosition"))==null?void 0:e.tid,o={run:()=>this.toPositionBySpeed(t,this.options.speed),meta:{type:"toPosition"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)}pauseAnimation(){this.taskQueue.clear(),this.positionNavigation.pause(),this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue(),this.positionNavigation.continue()}clearTween(){this.tweenUtil.clear(),this.taskQueue.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate),this.bmap.removeEventListener(it.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.removeEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.removeEventListener("control-change",this.onControlChangeForStartPoi)}clearPath(){if(this.resetStatus(),this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.clearTween()),this.startPoi){var t;if((t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.detachStartPoi){var i;(i=this.bmap.context.currentFloor)==null||i.removePoi2(this.detachStartPoi),this.detachStartPoi=null}this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.translatePath=null}setCurFloorPath(t){t===null?(this.curFloorPath=null,this.currentPathPosition=null,this.toPointPosition=null):(this.curFloorPath=t,this.currentPathPosition=t.points[0],this.toPointPosition=t.points[0]),this.movedDistance=0,this.clearTween()}setCurPathIndex(t){var e,i;this.curPathIndex=t,((e=this.paths[t])==null?void 0:e.floor)===((i=this.bmap.context.currentFloor)==null?void 0:i.name)?(this.setCurFloorPath(this.paths[t]),this.renderPath(this.translatePoints(this.curFloorPathPoints))):this.clearPath()}addPath(t,e){e===void 0&&(e=0);var i;this.paths=t,this.curPathIndex=e,this.clearTween(),this.clearPath();let s=(i=this.bmap.context.currentFloor)==null?void 0:i.name,o=t[e];if(s&&(o==null?void 0:o.floor)===s)if(this.setCurFloorPath(o),this.bmap.currentBuildGround)this.renderPath(this.translatePoints(o.points));else{let n=()=>{this.bmap.removeEventListener("center-change",n),this.renderPath(this.translatePoints(o.points))};this.bmap.addEventListener("center-change",n)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,i]=this.bmap.buildingCenter;return t.map(s=>[s[0]-e,s[1]-i])}renderPath(t){this.translatePath=t;let e=this.catmullRomCurve3(t);if(this.cPath=e,this.animationPathOptions={cPathIndex:0},this.pathStart=e[0],this.path?this.path.updatePoints(e):(this.path=new fs(this,this.options.path),this.path.create(e),this.path.position.z=this.bmap.context.currentFloor.groundMaxHeight+.5,this.bmap.context.scene.add(this.path)),this.path.movePath(0),this.startPoi){var i;if((i=this.bmap.context.currentFloor)==null||i.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var s;(s=this.bmap.context.currentFloor)==null||s.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.removeDetachStart(),this.showDetachStartState&&this.options.detachStartPoi){var o;this.detachStartPoi=new j(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(o=this.bmap.context.currentFloor)==null||o.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new $e(this.bmap.context,new bt(e[0][0],e[0][1],.51),new bt(e[0][0],e[0][1],.51)),this.bmap.context.scene.add(this.detachLine)}if(this.options.needStartPoi){var n;this.startPoi=new j(this.bmap.context,w({},this.options.startPoi,{id:"navigation_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(n=this.bmap.context.currentFloor)==null||n.poiLayer2.pushPoi(this.startPoi),this.needStartRotateHelperPoi&&this.showStartRotateHelperPoi(),console.log(this.startRotateHelperPoi)}this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return mi(t,!1,!0,.1,170,2.5)}getPathDirection(){if(!this.curFloorPath||!this.currentPathPosition||this.curFloorPathPoints.length<2)return null;let t=Bt(this.curFloorPathPoints,this.currentPathPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1],s=new bt(i[0]-e[0],i[1]-e[1],0).normalize(),o=new bt(0,1,0).normalize(),n=s.angleTo(o),r=new bt().crossVectors(o,s);return(Object.is(r.y,0)?-1:1)*n}getPathDirection2(){if(!this.curFloorPath||!this.toPointPosition||this.curFloorPathPoints.length<2)return null;let t=Bt(this.curFloorPathPoints,this.toPointPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1];return(new ud(i[0]-e[0],i[1]-e[1]).normalize().angle()*180/Math.PI-90+360)%360}changeCameraToPathUp(t){return f(this,null,function*(){t===void 0&&(t=100);let e=this.getPathDirection();if(e===null)return;let i=this.bmap.context.control.getAzimuthalAngle();Math.abs(i-e)>Math.PI&&(i>0?e=Math.PI*2+e:e=e-Math.PI*2);let s=Math.abs(e-this.bmap.context.control.getAzimuthalAngle());if(s<.01)return;let{control:o}=this.bmap.context,n=t/Math.PI*6*s;return ft(new Promise(r=>{let h={azimuthal:o.getAzimuthalAngle()},c={azimuthal:e},l=o.getPolarAngle(),{maxPolarAngle:p,minPolarAngle:d}=o;o.maxPolarAngle=l,o.minPolarAngle=l;let u=new Mo(h,this.tweenUtil.group).to(c,n).easing(dd.Quadratic.InOut).onUpdate(()=>f(this,null,function*(){this.startPoi&&o.target.copy(this.startPoi.position),o.setAzimuthalAngle(h.azimuthal,!0),o.setTargetByOffset(this.options.offsetY)})).onComplete(()=>{o.enabled=!0,this.tweenUtil.remove(u),o.maxPolarAngle=p,o.minPolarAngle=d,r(!0)}).onStart(()=>{o.enabled=!1}).start()}),n+500).finally(()=>{this.bmap.context.control.enabled=!0})})}initNavigationCamera(t){return f(this,null,function*(){t===void 0&&(t=1e3);var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="initNavigationCamera"))==null?void 0:e.tid,o={run:()=>ft(f(this,null,function*(){yield this.initCameraZoom(t/2),this.options.disablePathRotate||(yield this.changeCameraToPathUp(t/4)),yield this.translateCameraToStartPoi(t/(this.options.disablePathRotate?2:4))}),t+500).finally(()=>{this.bmap.context.control.enabled=!0}),meta:{type:"initNavigationCamera"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)})}translateCameraToStartPoi(t){return f(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},camera:s,control:o}=this.bmap.context,n=Math.round(e/2),r=Math.round(i/2),h=o.target.clone(),c=C(this.startPoi.position,s,e,i),l=c.x-n,p=r-c.y+this.options.offsetY;if(!(Math.abs(l)<=1&&Math.abs(p)<=1)){if(Math.abs(l)>=1){let d=new bt;d.setFromMatrixColumn(s.matrix,0),d.normalize(),d.multiplyScalar(l/s.zoom),h.add(new bt(d.x,d.y,0))}if(Math.abs(p)>=1){let d=new bt;d.setFromMatrixColumn(s.matrix,1),d.normalize(),d.multiplyScalar(p/s.zoom),h.add(new bt(d.x,d.y,0))}return ft(new Promise(d=>{let u=o.target.clone();console.log(u,h,t);let m=new Mo(u,this.tweenUtil.group).to(h,t).onUpdate(()=>{this.bmap.context.control.setCameraPositionByTarget(u,0)}).onComplete(()=>{this.bmap.context.control.setCameraPositionByTarget(h,0),this.tweenUtil.remove(m),this.bmap.context.control.enabled=!0,d(!0)}).onStart(()=>{this.bmap.context.control.enabled=!1}).start()}),t+500).then(()=>{this.bmap.context.control.enabled=!0})}})}initCameraZoom(t){return f(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},currentFloor:s}=this.bmap.context,{max:o,min:n}=s.box,h=Math.min(e/(o.x-n.x),i/(o.y-n.y))*(o.x-n.x)/this.options.navigationCameraBasic;return this.bmap.context.setZoom(h,this.startPoi.position,t).finally(()=>{this.bmap.context.control.enabled=!0})})}toPosition(t,e){if(this.paths[this.curPathIndex]&&this.paths[this.curPathIndex].floor===t&&this.detachStartPoi){let i=this.translatePoints([e]);this.detachStartPoi.position.setX(i[0][0]),this.detachStartPoi.position.setY(i[0][1]),this.detachLine&&this.startPoi&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position)}this.options.canBack&&(this.positionNavigation.pointIndex=0,this.positionNavigation.position=this.paths[this.curPathIndex].points[0]),this.positionNavigation.toPosition(t,e)}startSimulation(){this.positionNavigation.startSimulation()}setSimulationSpeed(t){this.positionNavigation.changeSimulationSpeed(t)}toPositionBySpeed(t,e){return f(this,null,function*(){let{currentPathPosition:i,curFloorPath:s,curFloorPathPoints:o}=this;if(!s||!i)return null;let n=this.movedDistance,r=sn(o,t);if(n===-1||r===-1||!this.options.canBack&&r<=n)return null;let h=r-n;if(!h)return;let c=Math.min(Math.abs(h)/e,this.options.runAnimationMaxTime);return this.pathTween&&this.clearTween(),ft(new Promise(l=>{let p=this.pathTween=new Mo({distance:0},this.tweenUtil.group).to({distance:h},c*1e3).onUpdate(d=>f(this,null,function*(){this.moveDistance(d.distance+n,p)})).onComplete(()=>{this.tweenUtil.remove(p),l(!0)}).start()}),c*1e3+500).finally(()=>{this.bmap.context.control.enabled=!0})})}moveDistance(t,e){return f(this,null,function*(){if(this.movedDistance=t,!this.options.disablePathShorten){var i;(i=this.path)==null||i.movePath(this.movedDistance/this.curFloorPathLength)}let s=ve(this.curFloorPathPoints,this.movedDistance);if(s===null)return;this.currentPathPosition=s;let o=this.translatePoints([s])[0];this.startPoi&&(this.setStartPoiPosition(o[0],o[1]),this.options.disablePathAnimation||this.bmap.context.control.setTargetByOffset(this.options.offsetY,this.startPoi.position.clone())),!this.options.disablePathAnimation&&!this.options.disablePathRotate&&(e==null||e.pause(),yield this.changeCameraToPathUp(500/this.options.speed),e==null||e.resume())})}removeDetachStart(){if(this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.detachStartPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.detachStartPoi),this.detachStartPoi=null}}hideDetachStart(){this.showDetachStartState=!1,this.removeDetachStart()}showDetachStart(){if(!this.detachStartPoi&&(this.showDetachStartState=!0,this.path&&this.startPoi&&this.options.detachStartPoi)){var t;let e=this.startPoi.position;this.detachStartPoi=new j(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:e,collision_enable:!1}))||null,(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new $e(this.bmap.context,new bt(e.x,e.y,.51),new bt(e.x,e.y,.51)),this.bmap.context.scene.add(this.detachLine)}}setStartPoiRotate(t){this.startPoiRotate=t;let i=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360,s=(360-t-i)%360;this.detachStartPoi&&(this.detachStartPoi.options.icon_rotate=s),this.startPoi&&(this.startPoi.options.icon_rotate=s,this.startRotateHelperPoi&&this.startRotateHelperPoi.setAngle(s))}dispose(){var t;if(this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.hideDetachStart(),this.startPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startPoi),this.startPoi=null}this.tweenUtil.dispose(),this.unRegistryEvent(),(t=this.startRotateHelperPoi)==null||t.dispose(),Vt.dispose(),this.positionNavigation.dispose(),this.startRotateHelperPoi=null,super.dispose()}constructor(t,e={},i){super(t),this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curPathIndex=0,this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.toPointPosition=null,this.pathTween=null,this.startPoi=null,this.detachStartPoi=null,this.detachLine=null,this.startPoiRotate=null,this.startRotateHelperPoi=null,this.needStartRotateHelperPoi=!1,this.showDetachStartState=!0,this.movedDistance=0,this.pathStart=[0,0],this.tweenUtil=new Qt,this.taskQueue=new we,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onNavigationInfo=s=>{let{info:o}=s;if(this.dispatchEvent({type:"navigation-info",info:o}),!o.offset){if(o.routeIndex!==this.curPathIndex)return;this.toPointPosition=o.pos,this.toPositionByTask(o.pos)}},this.onUpdate=()=>{this.tweenUtil.update()},this.onSwitchFloor=s=>{let{data:{curFloor:o}}=s;if(this.clearTween(),this.paths[this.curPathIndex]){let n=this.paths[this.curPathIndex];this.setCurFloorPath(n!=null?n:null),n?this.renderPath(this.translatePoints(n.points)):this.clearPath()}else this.clearPath()},this.onControlChangeForStartPoi=()=>{this.startPoi&&this.startPoiRotate!==null&&this.setStartPoiRotate(this.startPoiRotate)},!i&&typeof e=="object"&&(i=e),this.options=Object.assign({},md,i),this.positionNavigation=new gs(this,w({simulationSpeed:this.options.speed},this.options.positionNavigation),this.options.roadData),this.registryEvent()}};import"core-js/modules/web.dom-collections.iterator.js";import{Group as fd,Color as Cr}from"three";var Tr=class extends B{show(t,e){let i=0;t.forEach(n=>{n.onAddToScene("mulFloors"),n.position.z=i,i+=n.userData.height,n.poiLayer2.pois.forEach(r=>{r.options.depth_test=!0})});let{scene:s,currentFloor:o}=this.bmap.context;s.background=new Cr((e==null?void 0:e.backgroundColor)||"#f1f7f6"),o&&(s.remove(o),o.dispose()),this.group.add(...t),s.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}showStep(t,e){return this.show(t,e)}hide(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.dispose()}),this.floors=[],this.group.clear(),this.showStatus=!1}showByNotDispose(t,e,i){i===void 0&&(i=()=>!0);let s=0;t.forEach(r=>{[...r.poiLayer2.pois].forEach(h=>{if(!i(h)){h.visible=!1;return}h.options.depth_test=!0}),r.position.z=s,s+=r.userData.height,r.onAddToScene("mulFloors")});let{scene:o,currentFloor:n}=this.bmap.context;o.background=new Cr((e==null?void 0:e.backgroundColor)||"#f1f7f6"),n&&o.remove(n),this.group.add(...t),o.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}hideByNotDispose(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.poiLayer2.pois.forEach(i=>{i.visible=!0,i.options.depth_test=!1})}),this.floors.forEach(e=>{e.position.z=0,e.onRemoveFromScene()}),this.group.clear(),this.showStatus=!1}fitCamera(){let{context:t,config:e}=this.bmap;t.cameraBound.setEnable(!1),t.control.minZoom=0,t.control.maxZoom=1/0,t.camera.zoom=1,t.setAzimuthalAngle(e.control.defaultAzimuthal,0),t.setPolarAngle(e.control.defaultPolar,0),t.fitCameraToObject(this.group,e.defaultPadding,0,!1);let i=t.camera.zoom;t.control.minZoom=i,t.control.maxZoom=i*e.control.maxZoomScale,this.bmap.basicZoom=t.camera.zoom,t.control.addEventListener("change",this.bmap.onControlChange),this.bmap.onControlChange(),t.cameraBound.setEnable(!0)}dispose(){this.floors.forEach(t=>t.dispose()),this.floors=[],super.dispose()}constructor(t){super(t),this.floors=[],this.group=new fd,this.showStatus=!1,this.group.name="mul-floor-group"}};import{EventDispatcher as gd}from"three";function _o(){return new Worker(new URL("./worker/path.worker-C7N3AIZ3.js",import.meta.url))}var ys=class extends gd{setLiftPriority(t){return F(this.worker,"onSetLiftPriority",t)}loaded(){return new Promise(t=>{if(this.initRoadStatus)t(!0);else{let e=i=>{let{status:s}=i;s&&(this.removeEventListener("init-road-status",e),t(!0))};this.addEventListener("init-road-status",e)}})}setRoadData(t,e){return f(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield F(this.worker,"set_road_info",{roadData:t,facilities:e}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i,s,o,n){return f(this,null,function*(){return i===void 0&&(i=""),new Promise((r,h)=>{let c=()=>{F(this.worker,"get_path",{start:t,end:e,type:i,permission:s,travelDirection:o,options:n}).then(l=>{l?typeof l=="string"?h(l):r(l):h("no-path")})};if(this.initRoadStatus)c();else{let l=p=>{let{status:d}=p;d&&(this.removeEventListener("init-road-status",l),c())};this.addEventListener("init-road-status",l)}})})}getDirectionPath(t){return F(this.worker,"get_direction_path",t)}dispose(){return f(this,null,function*(){F(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=_o(),this.initRoadStatus=!1}};import{EventDispatcher as yd}from"three";function Po(){return new Worker(new URL("./worker/cr-path.worker-RCWZ3ILJ.js",import.meta.url))}var kr=class extends yd{setRoadData(t){return f(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield F(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i){return f(this,null,function*(){return i===void 0&&(i=""),new Promise((s,o)=>{let n=()=>{F(this.worker,"get_path",{start:t,end:e,type:i}).then(r=>{r?typeof r=="string"?o(r):s(r):o("no-path")})};if(this.initRoadStatus)n();else{let r=h=>{let{status:c}=h;c&&(this.removeEventListener("init-road-status",r),n())};this.addEventListener("init-road-status",r)}})})}getDirectionPath(t){return F(this.worker,"get_direction_path",t)}dispose(){return f(this,null,function*(){F(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=Po(),this.initRoadStatus=!1}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.push.js";import{Frustum as vd}from"three";var vs=class extends vt{setEnable(t){super.setEnable(t),ot(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:s}}}=this,o=C(this.startPoint,e,i,s),n=C(this.endPoint,e,i,s),r={x:Math.min(o.x,n.x),y:Math.min(o.y,n.y)},h={x:Math.max(o.x,n.x),y:Math.max(o.y,n.y)},c=this.searchMapInFrustum(r,h);this.dispatchEvent({type:"selected",list:c})}}searchMapInFrustum(t,e){var i;let{context:s}=this;return((i=s.currentFloor)==null?void 0:i.graphicLayer.children.filter(o=>o instanceof J&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:s,container:{clientWidth:o,clientHeight:n}}}=this;if(!t)return!1;if(!t.mesh){let d=t.getPosition();if(d){let u=C(d,s,o,n);return Yt(u,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let r=t.mesh.geometry.boundingBox;if(!r)return!1;let{min:h,max:c}=r,l=C(h,s,o,n),p=C(c,s,o,n);return!(!Yt(l,e,i)||!Yt(p,e,i))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new vd,this.onPointerDown=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=s=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o)},this.onPointerUp=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let s=this.getSvgCoordinate(this.startPoint),o=w({},s);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let n={x:Math.min(s.x,o.x),y:Math.min(s.y,o.y)},r=Math.abs(o.x-s.x),h=Math.abs(o.y-s.y);ot(this.rect,n.x,n.y,r,h)}else ot(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=qt(i,e),this.svg.appendChild(this.rect),this.registryEvent()}};var xd={boxSelection:!1,elements:["graphic","poi"]},Dr=class extends B{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.options.boxSelection||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.bmap.context.control.enablePan=!!this.prevPanStatus,this.bmap.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],pois:[...this._poiList],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp),this.bmap.context.container.addEventListener("pointerout",this.onPointerOut),this.bmap.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp),this.bmap.context.container.removeEventListener("pointerout",this.onPointerOut),this.bmap.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent(),super.dispose()}constructor(t,e={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=i=>{this.downPoint={x:i.offsetX,y:i.offsetY}},this.onPointerUp=i=>{if(!this.downPoint)return;let{offsetX:s,offsetY:o}=i,{x:n,y:r}=this.downPoint;if(Math.sqrt((n-s)**2+(r-o)**2)>3)return;let h=new Set,c=[],l=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(s,o);p.map(d=>h.add(d.options.id)),c.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(s,o);l.push(...p),p.forEach(d=>{if(!h.has(d.options.id)){var u;let m=((u=this.bmap.context.currentFloor)==null?void 0:u.graphicLayer.graphicMap.get(d.options.id))||null;m&&(h.add(d.options.id),c.push(m))}})}(!this.options.boxSelection||!(ge?i.metaKey:i.ctrlKey))&&(this._list.clear(),this._poiList.clear()),c.forEach(p=>this._list.add(p)),l.forEach(p=>this._poiList.add(p)),this.selectEnd(),this.downPoint=null},this.onPointerOut=i=>{this.disableBoxSelection()},this.onKeyDown=i=>{ye(i.key)&&this.enableBoxSelection()},this.onKeyUp=i=>{ye(i.key)&&this.disableBoxSelection()},this.onBoxSelected=i=>{let{list:s}=i;this._list.clear(),this._poiList.clear(),s.forEach(o=>{if(this.options.elements.includes("graphic")&&this._list.add(o),this.options.elements.includes("poi")){let n=this.bmap.getPoiById(o.options.id);n&&this._poiList.add(n)}}),this.selectEnd()},this.options=w({},xd,e),this.boxSelection=new vs(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};import"core-js/modules/es.array.push.js";import{cloneDeep as wd,isNil as ee,throttle as Ar}from"lodash";var O=function(a){return a.COMPASS="compass",a.DEVICE_MOTION="deviceMotion",a.ACCELERATION="acceleration",a.GPS="gps",a}({});var Md={time:1e3,elements:[O.COMPASS,O.DEVICE_MOTION,O.ACCELERATION,O.GPS]},xs=class extends X{start(){this.options.elements.some(t=>[O.DEVICE_MOTION,O.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(O.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(O.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:wd(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){Ut?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}listenAcceleration(){window.addEventListener("devicemotion",this.handleAcceleration,!1)}listenGps(){this.gpsTimer=navigator.geolocation.watchPosition(t=>{console.log("watch gps",t.coords),this.addDataItem({type:O.GPS,timestamp:Date.now(),res:[t.coords.longitude,t.coords.latitude,t.coords.accuracy]})},t=>{console.log("\u83B7\u53D6gps\u5931\u8D25",t)},{enableHighAccuracy:!0})}checkSensor(){return f(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return f(this,null,function*(){var t;if(!Ut)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var e;return(yield(e=window.DeviceOrientationEvent)==null?void 0:e.requestPermission())==="granted"}catch(i){return!1}return!1})}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),Ut?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),ee(this.gpsTimer)||navigator.geolocation.clearWatch(this.gpsTimer),this.dispatchTimer&&this.timer.clearInterval(this.dispatchTimer),this.data=[],this.dispatchEvent({type:"stop"})}constructor(t={}){super(),this.gpsTimer=null,this.data=[],this.timer=new z,this.dispatchTimer=null,this.addAcceleration=Ar(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=Ar(e=>{let i=Date.now(),{alpha:s,beta:o,gamma:n}=e;if(ee(s)||ee(o)||ee(n))return;let r;Ut?r=e.webkitCompassHeading:r=360-s,this.options.elements.includes(O.DEVICE_MOTION)&&this.addDataItem({type:O.DEVICE_MOTION,timestamp:i,res:[s,o,n]}),this.options.elements.includes(O.COMPASS)&&this.addDataItem({type:O.COMPASS,timestamp:i,res:r})},200),this.handleAcceleration=e=>{let i=e.accelerationIncludingGravity;ee(i)||ee(i.x)||ee(i.y)||ee(i.z)||this.addAcceleration({type:O.ACCELERATION,timestamp:Date.now(),res:[i.x,i.y,i.z]})},this.options=w({},Md,t)}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";function ws(a,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(a,2)/(2*Math.pow(t,2)))}function ii(a){return(a+360)%360}function Or(a,t){let i=6378137*a*Math.PI/180,s=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:i,y:s}}function Re(a,t,e,i){return Math.sqrt(Math.pow(Math.abs(a-e),2)+Math.pow(Math.abs(t-i),2))}var Ms=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=ii(this.last_yaw_compass+t);for(let e=0;e<this.NumParticle;e++){let i=Math.random()*this.yaw_noise_sigma;this.particleX[2][e]=this.particleX[2][e]+t+i,this.particleX[2][e]=ii(this.particleX[2][e])}}}motionModelStepLength(t,e){if(t===0)return;for(let s=0;s<this.NumParticle;s++){let o=Math.random()*this.step_noise_sigma;this.particleX[0][s]+=(.65+o)*Math.sin(-this.particleX[2][s]/180*Math.PI),this.particleX[1][s]+=(.65+o)*Math.cos(this.particleX[2][s]/180*Math.PI),e(this.particleX[0][s],this.particleX[1][s])||(this.particleWeight[0][s]*=this.unaccess_weight)}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}motionModelCompassYaw(t,e){if(e-this.last_compass_time>this.compass_update_interval){let i=360-t;i+=this.delta_yaw,i=ii(i),Math.abs(i-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let o=0;o<this.NumParticle;o++){let n=Math.abs(this.particleX[2][o]-i);n>180&&(n=360-n),this.particleWeight[0][o]*=ws(n,this.sigmaCompass)}let s=this.particleWeight[0].reduce((o,n)=>o+n,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/s),this.setLastCompassTime(e)}}resampling(){if(1/this.particleWeight[0].reduce((e,i)=>e+i*i,0)<this.reSampNumParticle){let e=this.particleWeight[0].reduce((r,h,c)=>r.concat(r[c]+h),[0]),s=this.particleWeight[0].map(()=>1/this.NumParticle).map((r,h)=>r+Math.random()/this.NumParticle),o=[],n=0;for(let r=0;r<this.NumParticle;r++){for(;s[r]>e[n];)n++;o.push(n)}this.particleX=this.particleX.map((r,h)=>o.map(c=>r[c])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let s=0;s<this.NumParticle;s++){let o=Re(this.particleX[0][s],this.particleX[1][s],t.x,t.y);this.particleWeight[0][s]=Math.max(1e-7,this.particleWeight[0][s]*ws(o,e))}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}updateCar(t,e){let i=t.x-this.xEst[0][0],s=t.y-this.xEst[1][0];for(let n=0;n<this.NumParticle;n++){let r=Re(this.particleX[0][n],this.particleX[1][n],t.x,t.y);this.particleWeight[0][n]=Math.max(1e-7,this.particleWeight[0][n]*ws(r,e)),this.particleX[0][n]+=i,this.particleX[1][n]+=s}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o)}getPosInitFlag(){return this.particle_PosInitFlag}getYawInitFlag(){return this.particle_yawInitFlag}setPosInitFlag(t){this.particle_PosInitFlag=t}setYawInitFlag(t){this.particle_yawInitFlag=t}getResultX(){let t=[0,0,0];for(let e=0;e<3;e++)for(let i=0;i<this.NumParticle;i++)t[e]+=this.particleX[e][i]*this.particleWeight[0][i];return this.xEst=t.map(e=>[e]),this.xEst[0][0]}getResultY(){return this.xEst[1][0]}getResultYaw(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0]));return this.particleX[2][t]}getEstConfidence(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0])),e=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),i=[this.particleX[0][t],this.particleX[1][t]],s=[this.particleX[0][e],this.particleX[1][e]],o=Re(i[0],i[1],s[0],s[1]),n=o*.67;return console.log(o,n),n}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,e,i){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let s=0;for(;s<this.NumParticle;){let n=(2*Math.random()-1)*this.initial_xy_uncertainty,r=(2*Math.random()-1)*this.initial_xy_uncertainty;i(t+n,e+r)||(this.particleWeight[0][s]*=this.unaccess_weight),this.particleX[0][s]=t+n,this.particleX[1][s]=e+r,s++}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=e,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log("Init compass: "+t);let e=360-t;e+=this.delta_yaw,e=ii(e),console.log("Init Yaw: "+e);for(let i=0;i<this.NumParticle;i++){let s=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][i]=e+s}this.particle_yawInitFlag=!0,this.xEst[2][0]=e,this.last_yaw_compass=e,this.compass_consecutive_offset_count=0}constructor(t){this.last_yaw_compass=0,this.compass_consecutive_offset_count=0,this.NumParticle=t.NumParticle,this.reSampNumParticle=t.reSampNumParticle,this.initial_xy_uncertainty=t.initial_xy_uncertainty,this.initial_yaw_uncertainty=t.initial_yaw_uncertainty,this.step_noise_sigma=t.step_noise_sigma,this.yaw_noise_sigma=t.yaw_noise_sigma,this.compass_update_interval=t.compass_update_interval,this.sigmaCompass=t.sigmaCompass,this.delta_yaw=t.delta_yaw,this.sigmaBeacon=t.sigmaBeacon,this.unaccess_weight=t.unaccess_weight,this.particle_PosInitFlag=!1,this.particle_yawInitFlag=!1,this.xEst=[[0],[0],[0]],this.particleX=Array.from({length:3},()=>Array(this.NumParticle).fill(0)),this.particleWeight=Array.from({length:1},()=>Array(this.NumParticle).fill(1/this.NumParticle)),this.last_compass_time=0}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";var _s=class{init(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10+.5,this.max_valley=10-.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.65,this.last_rot=[0,0,0],this.delta_rot=[0,0,0],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[],this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0}reset(){this.init()}setInitPose(t){t===void 0&&(t=[0,0]),this.last_px=t[0],this.last_py=t[1],console.info("pdr init pos: "+this.last_px+", "+this.last_py)}setInitYaw(t){t===void 0&&(t=0),this.last_yaw=t}getPos(t,e,i){let s=0;return i.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,i)),e.length===3&&(s=this.getStepLength(t,e)),s!==0&&(this.last_px+=this.delta_px,this.last_py+=this.delta_py),[this.last_px,this.last_py]}getDeltaPose(){return[this.delta_px,this.delta_py]}getMotionState(){return this.currentMotionState}getStepLength(t,e){if(e.length<3)return console.warn("acc data less than 3"),0;let i=!1,s=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2));if(this.accH_fifo.push(s),this.accH_time_fifo.push(t),this.imuFreUpdate(),!this.isMoving(e,this.last_rot))return 0;if(this.accH_fifo.length<this.accH_fifo_len+1)i=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let n=this.PVStepDetec(),r=this.FFTStepDetec(),h=this.recheckState(),c=this.accH_time_fifo[Math.floor(this.accH_time_fifo.length*3/4)];Math.abs(this.abnor_start_time)<.001&&this.abnor_fft_detected?this.abnor_start_time=c:this.abnor_fft_detected||(this.abnor_start_time=0),n&&r&&h?(this.step_count+=1,this.last_step_time=c,i=!0):Math.abs(this.abnor_start_time)>.001&&this.abnor_peak_time-this.abnor_start_time>this.abnor_time_threshold&&this.step_count>1&&this.abnor_peak_time-this.last_step_time>1?(this.step_count+=1,this.last_step_time=c,i=!0):(c-this.last_step_time>2&&(this.state_count=0),i=!1)}if(i){let n=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(n),this.delta_py=this.const_step_length*Math.sin(n),this.const_step_length}else return 0}imuFreUpdate(){if(this.accH_time_fifo.length>2&&(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]<0||this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]>10||this.accH_time_fifo[this.accH_time_fifo.length-1]===this.accH_time_fifo[0])&&(console.warn("pdr reset last one time "+this.accH_time_fifo[this.accH_time_fifo.length-1]+" last two time "+this.accH_time_fifo[this.accH_time_fifo.length-2]),this.reset()),this.accH_fifo.length>9||this.fre<15){let t=(this.accH_fifo.length-1)/(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[0]);Math.abs(this.fre-t)>8&&(this.fre=Math.round((t-3)/10)*10,(this.fre<=10||this.fre>=100)&&(console.warn("Frequency Error "+this.fre),this.fre=100),console.debug("Frequency change to "+this.fre),this.accH_fifo_len=Math.floor(1*this.fre)+1)}}recheckState(){return!0}PVStepDetec(){let t=!1,e=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),i=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),s=e[Math.floor(e.length/2)],o=i[Math.floor(i.length/2)],n=Math.max(...e),r=Math.min(...e),h=!1,c=!1;return Math.abs(s-r)<.01&&s<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?c=!0:c=o-this.last_valley_time>this.min_step_time,c&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(s-n)<.01&&s>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?h=!0:h=o-this.last_peak_time>this.min_step_time,h&&(this.last_peak_time=o,this.peak_num+=1)),s===n&&s>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=s),this.peak_num===this.valley_num&&(h||c)&&(t=!0),t}FFTStepDetec(){return!0}isMoving(t,e){if(t.length<3||e.length<3)return!1;this.acc_buffer.push([...t]),this.acc_buffer.length>this.static_window_size&&this.acc_buffer.shift();let i=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2));this.acc_variance_buffer.push(i),this.acc_variance_buffer.length>this.static_window_size&&this.acc_variance_buffer.shift();let s=Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2]);if(this.rot_variance_buffer.push(s),this.rot_variance_buffer.length>this.static_window_size&&this.rot_variance_buffer.shift(),this.acc_variance_buffer.length<10)return this.is_moving;let o=this.acc_variance_buffer.slice(-10),n=this.rot_variance_buffer.slice(-10),r=this.calculateMean(o),h=this.calculateStdDeviation(o),c=this.calculateMean(n),l=this.calculateStdDeviation(n),p;return r>this.walkingThreshold&&h>.5?(this.walkingCount++,this.stationaryCount=0,this.phoneUseCount=0,p="WALKING"):r<this.phoneUseThreshold&&c>this.rotationThreshold?(this.phoneUseCount++,this.walkingCount=0,this.stationaryCount=0,p="USING_PHONE"):c<.5?(this.stationaryCount++,this.walkingCount=0,this.phoneUseCount=0,p="STATIONARY"):p="UNKNOWN",p!==this.currentMotionState?(this.stateCounter++,this.stateCounter>=this.stateChangeThreshold&&(this.previousMotionState=this.currentMotionState,this.currentMotionState=p,this.stateCounter=0,console.debug("Motion state changed: "+this.previousMotionState+" -> "+this.currentMotionState),console.debug("Stats: avgAcc="+r.toFixed(2)+", accStdDev="+h.toFixed(2)+", avgRot="+c.toFixed(2)+", rotStdDev="+l.toFixed(2)))):this.stateCounter=0,this.is_moving=this.currentMotionState==="WALKING",this.is_moving}calculateMean(t){return t.length===0?0:t.reduce((e,i)=>e+i,0)/t.length}calculateStdDeviation(t){if(t.length<2)return 0;let e=this.calculateMean(t),s=t.map(o=>{let n=o-e;return n*n}).reduce((o,n)=>o+n,0)/t.length;return Math.sqrt(s)}getMotionStatistics(){let t=this.acc_variance_buffer.slice(-10),e=this.rot_variance_buffer.slice(-10),i=this.calculateMean(t),s=this.calculateMean(e),o=this.calculateStdDeviation(t),n=this.calculateStdDeviation(e);return console.debug("\u8FD0\u52A8\u68C0\u6D4B: avgAcc="+i.toFixed(2)+", accStdDev="+o.toFixed(2)+", avgRot="+s.toFixed(2)+", rotStdDev="+n.toFixed(2)),console.debug("\u72B6\u6001\u5224\u65AD\u6761\u4EF6: \u884C\u8D70(avgAcc>"+this.walkingThreshold+", accStdDev>0.5), \u9759\u6B62(avgRot<0.5), \u624B\u673A(avgAcc<"+this.phoneUseThreshold+", avgRot>"+this.rotationThreshold+")"),console.debug("\u5F53\u524D\u72B6\u6001: "+this.currentMotionState+", \u8BA1\u6570: \u884C\u8D70="+this.walkingCount+", \u9759\u6B62="+this.stationaryCount+", \u624B\u673A="+this.phoneUseCount),{currentState:this.currentMotionState,avgAcceleration:i,avgRotation:s,accStdDeviation:o,rotStdDeviation:n,walkingCount:this.walkingCount,stationaryCount:this.stationaryCount,phoneUseCount:this.phoneUseCount,dataPoints:this.acc_variance_buffer.length,isMoving:this.is_moving}}getDeltaYawFromRot(t,e){if(e.length<3)return console.warn("rot data less than 3"),0;let i=[0,0,0];this.last_rot.length===3&&(i=e.map((r,h)=>r-this.last_rot[h]));for(let r=0;r<e.length;r++)i[r]<-180?i[r]+=360:i[r]>180&&(i[r]-=360);let s=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((r,h)=>s*r+(1-s)*i[h]):this.delta_rot=i,this.last_rot=e,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let o=this.delta_rot.reduce((r,h)=>r+Math.abs(h),0);this.delta_rot_sum_fifo.push(o),this.delta_rot_sum_time_fifo.push(t),Math.abs(this.delta_rot_sum_time_fifo[this.delta_rot_sum_time_fifo.length-1]-this.delta_rot_sum_time_fifo[0])>1&&(this.delta_rot_sum_fifo.shift(),this.delta_rot_sum_time_fifo.shift()),this.delta_yaw_accum+=this.delta_yaw;let n=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(n=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,n):null}limitYaw(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}constructor(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10.5,this.max_valley=9.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_time_threshold=4,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.85,this.last_rot=[],this.delta_rot=[],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.walkingThreshold=1,this.stationaryThreshold=.6,this.phoneUseThreshold=.7,this.rotationThreshold=.8,this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0,this.stateChangeThreshold=3,this.static_window_size=20,this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[]}};var _d={using_gps:!0,gps_max_horizontalAccuracy:20,initial_gps_delay_time:3e3},Ps=class{pfFusionPDRiBeacon(t){let{type:e,timestamp:i,res:s}=t,o=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(e===O.ACCELERATION){let n=s,r=this.pdr.getStepLength(i/1e3,n);r!==0&&(this.particleFilter.motionModelStepLength(r,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===O.GPS)if(this.last_beacon_time===null||i-this.last_beacon_time>5e3){let n=this.getGpsPosition(s);o=n!==null,n&&(this.particleFilter.update(n,this.gps_horizontalAccuracy),this.resetParticleFilterDist(n,"gps",s[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}else return[!1,0,0];if(e===O.DEVICE_MOTION){let n=this.pdr.getDeltaYawFromRot(i/1e3,s);n!==null&&this.particleFilter.motionModelRotYaw(n)}e===O.COMPASS&&this.particleFilter.motionModelCompassYaw(s,i),this.last_pos_time&&i-this.last_pos_time>500&&(this.position_count+=1,o=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&e===O.GPS)if(this.startTime&&Date.now()-this.startTime>this.options.initial_gps_delay_time){let n=this.getGpsPosition(s);o=n!==null,console.log("gps_pos",n,s),n?(this.particleFilter.initParticlesByPos(n.x,n.y,()=>!0),this.last_pos_time=i,console.log("init Pos by gps success time "+i),this.cacheSensorData.length=0):console.log("init Pos by gps fail time "+i)}else this.startTime||(this.startTime=i);else if(!this.particleFilter.getYawInitFlag()&&e===O.COMPASS){let n=s;this.particleFilter.initParticlesByCompass(n),this.particleFilter.setLastCompassTime(i),console.log("init yaw by compass success time "+i)}return o&&(this.last_pos_time=i),[o,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,e){if(this.last_beacon_time=e,this.particleFilter.getPosInitFlag())this.particleFilter.update(t,this.sigmaBeacon);else{this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0);let i=this.cacheSensorData.filter(s=>s.timestamp>e);console.log("\u521D\u59CBsensorData",i),i.map(s=>this.pfFusionPDRiBeacon(s))}return this.resetParticleFilterDist(t),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0,[this.particleFilter.getResultX(),this.particleFilter.getResultY()]}getGpsPosition(t){return t[2]>this.gps_max_horizontalAccuracy?null:Or(t[0],t[1])}resetParticleFilterDist(t,e,i){let s=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),n=Re(s,o,t.x,t.y);(e==="gps"?i&&n>i||n>this.GpsMaxEstimateErr:n>this.MaxEstimateErr)?(this.outTrustRegionNum+=1,this.outTrustRegionNum>=this.TrustNum&&(console.info("\u8D85\u51FA\u53EF\u4FE1\u533A\u57DF\uFF0C\u91CD\u7F6E\u7C92\u5B50\u8FC7\u6EE4\u5668\u5230: "+t.x+", "+t.y),this.particleFilter.setPosInitFlag(!1),this.particleFilter.setYawInitFlag(!1),this.outTrustRegionNum=0,this.startTime=Date.now())):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=Date.now(),this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=1,this.cacheSensorData=[],this.startTime=null;let e=w({},_d,t);this.options=e,this.using_gps=e.using_gps,this.gps_max_horizontalAccuracy=e.gps_max_horizontalAccuracy,this.particleFilter=new Ms({NumParticle:200,reSampNumParticle:.65,initial_xy_uncertainty:12,initial_yaw_uncertainty:100,step_noise_sigma:.5,yaw_noise_sigma:2,compass_update_interval:3e3,sigmaCompass:80,delta_yaw:2,sigmaBeacon:5,unaccess_weight:.7}),this.pdr=new _s}};import{booleanPointInPolygon as Pd,point as bd}from"@turf/turf";var bs=class extends X{checkSensor(){return this.sensor.checkSensor()}setSensor(t){this.sensor=t}start(){this.sensor.start(),this.pdr.startTime=Date.now(),this.sensor.addEventListener("add-data-item",t=>{let{item:e}=t;this.getPositionBySensorItem(e,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,e){e===void 0&&(e=!0);let[i,s,o]=this.pdr.pfFusionPDRiBeacon(t);return i&&e&&Pd(bd([s,o]),this.bmap.context.range)&&this.dispatchEvent({type:"position",x:s,y:o,_type:t.type===O.GPS?"gps":"pdr"}),[i,s,o]}setBeaconPosition(t,e){let[i,s]=this.pdr.setBeaconPosition(t,e);this.dispatchEvent({type:"position",x:i,y:s,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t,e={}){super(),this.bmap=t,this._pause=!1,this.sensor=new xs(e.sensor),this.pdr=new Ps(e.pdr||{})}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{Object3D as Ed,TextureLoader as Ld,Color as Cd,Vector2 as bo,Vector3 as Td,NormalBlending as kd,RepeatWrapping as Dd,Box3 as Ad}from"three";import{ShaderLib as Ss,ShaderMaterial as Sd,UniformsLib as Es,UniformsUtils as Rr,Vector2 as Ir}from"three";Es["custom-line"]={linewidth:{value:1},resolution:{value:new Ir(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},repeat:{value:new Ir(1,1)},allDistance:{value:1}};Ss["custom-line"]={uniforms:Rr.merge([Es.common,Es.fog,Es["custom-line"]]),vertexShader:`
508
+ `,document.body.appendChild(a.canvas)}setAngle(t){if(console.log("angle",t),a.textureMap.has(t))this._initIcon(a.textureMap.get(t));else{this.draw(t);let e=this.getTexture(this.getImageData());a.textureMap.set(t,e),this._initIcon(e),this._initScale({zoom:this.bmap.context.camera.zoom})}}_initIcon(t){if(this.spriteIcon)this.spriteIcon.material.map=t,t.needsUpdate=!0;else{let e=new ld(new pd({map:t,transparent:!0,alphaTest:.2,depthTest:this.options.depth_test,rotation:this.options.icon_rotate/180*Math.PI}));e.renderOrder=1e5+this.options.level,t.needsUpdate=!0,this.add(e),e.center.set(.5,.5),this.spriteIcon=e}}initSize(){this.spriteIcon&&this.spriteIcon.center.set(.5,.5)}draw(t){let{ctx:e}=a,{config:{size:i}}=this,s=i[0]/2,o=i[1]/2,n=4,r=1,h=n+r;if(e.clearRect(0,0,i[0],i[1]),e.setLineDash([10,10]),e.strokeStyle="#fff",e.lineWidth=2,e.beginPath(),e.arc(s,o,o-h,-Math.PI/2,Math.PI*2-Math.PI/2,t<Math.PI),e.stroke(),e.strokeStyle="#0A7AFF",t<Math.PI){let c=-Math.PI/2,l=c-t;e.beginPath(),e.arc(s,o,o-h,c,l,!0)}else{let c=-Math.PI/2,l=c+Math.PI*2-t;e.beginPath(),e.arc(s,o,o-h,c,l,!1)}e.stroke(),e.clearRect(s-h*2,0,h*4,h*4),e.beginPath(),e.arc(s,h,n,0,Math.PI*2),e.fillStyle="#0A7AFF",e.fill(),e.setLineDash([10,0]),e.strokeStyle="#fff",e.lineWidth=r,e.stroke(),e.clearRect(0,o-5,10,10),e.clearRect(s-5,i[1]-10,10,10),e.clearRect(i[0]-10,o-5,10,10),t>Math.PI/2&&t<Math.PI?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(0,o-1,10,2),e.fillStyle="#fff",e.fillRect(s-1,i[1]-10,2,10),t>Math.PI&&t<Math.PI/2*3?e.fillStyle="#0A7AFF":e.fillStyle="#fff",e.fillRect(i[0]-10,o-1,10,2)}getImageData(){let{ctx:t}=a,{config:{size:e}}=this;return t.getImageData(0,0,e[0],e[1])}getTexture(t){let{config:{size:e}}=this,i=new cd(Uint8Array.from(t.data),e[0],e[1],Er);return i.format=Er,i.magFilter=Sr,i.minFilter=Sr,i.colorSpace="srgb",i.flipY=!0,i}dispose(){var t;super.dispose(),(t=this.spriteIcon)==null||t.material.dispose()}static dispose(){this.textureMap.forEach(t=>{t.dispose()}),this.textureMap.clear(),this.ctx=null,this.canvas=null}constructor(t,e){super(t.context,{icon_size:e.size,collision_enable:!1,level:2}),this.bmap=t,this.config=e,a.canvas.width=e.size[0],a.canvas.height=e.size[1]}};Vt.canvas=document.createElement("canvas");Vt.ctx=Vt.canvas.getContext("2d",{willReadFrequently:!0});Vt.textureMap=new Map;var md={path:{},cheapMaximumDistance:20,needStartPoi:!1,startPoi:{},positionNavigation:{},offsetY:150,directionEmitThreshold:5,disablePathAnimation:!1,disablePathRotate:!1,disablePathShorten:!1,speed:1,roadData:[],runAnimationMaxTime:1,navigationCameraBasic:45,canBack:!1},Lr=class extends B{get curFloorPathLength(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.distance)!=null?e:0}get curFloorPathPoints(){var t,e;return(e=(t=this.curFloorPath)==null?void 0:t.points)!=null?e:[]}registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate),this.bmap.addEventListener(it.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.addEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.addEventListener("control-change",this.onControlChangeForStartPoi)}setRoadData(t){this.options.roadData=t,this.positionNavigation.setRoadData(t)}showStartRotateHelperPoi(){var t;if(this.needStartRotateHelperPoi=!0,!this.startPoi||this.startRotateHelperPoi)return;let e=this.startPoi.options.icon_size;this.startRotateHelperPoi=new Vt(this.bmap,{size:[e[0]+20,e[1]+20]}),this.startRotateHelperPoi.setAngle(0),this.startRotateHelperPoi.position.setZ(.51),(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.startRotateHelperPoi)}hideStartRotateHelperPoi(){if(this.needStartRotateHelperPoi=!1,this.startRotateHelperPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}setStartPoiPosition(t,e){this.startPoi&&(this.startPoi.position.setX(t).setY(e),this.startRotateHelperPoi&&this.startRotateHelperPoi.position.setX(t).setY(e),this.detachLine&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position))}resetStatus(){this.pauseAnimation(),this.positionNavigation.resetStatus(this.paths),this.movedDistance=0,this.startPoi&&this.translatePath&&this.setStartPoiPosition(this.translatePath[0][0],this.translatePath[0][1])}toPositionByTask(t){var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="toPosition"))==null?void 0:e.tid,o={run:()=>this.toPositionBySpeed(t,this.options.speed),meta:{type:"toPosition"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)}pauseAnimation(){this.taskQueue.clear(),this.positionNavigation.pause(),this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue(),this.positionNavigation.continue()}clearTween(){this.tweenUtil.clear(),this.taskQueue.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate),this.bmap.removeEventListener(it.SWITCH_FLOOR_GROUND,this.onSwitchFloor),this.positionNavigation.removeEventListener("navigation-info",this.onNavigationInfo),this.bmap.context.removeEventListener("control-change",this.onControlChangeForStartPoi)}clearPath(){if(this.resetStatus(),this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.clearTween()),this.startPoi){var t;if((t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.detachStartPoi){var i;(i=this.bmap.context.currentFloor)==null||i.removePoi2(this.detachStartPoi),this.detachStartPoi=null}this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.translatePath=null}setCurFloorPath(t){t===null?(this.curFloorPath=null,this.currentPathPosition=null,this.toPointPosition=null):(this.curFloorPath=t,this.currentPathPosition=t.points[0],this.toPointPosition=t.points[0]),this.movedDistance=0,this.clearTween()}setCurPathIndex(t){var e,i;this.curPathIndex=t,((e=this.paths[t])==null?void 0:e.floor)===((i=this.bmap.context.currentFloor)==null?void 0:i.name)?(this.setCurFloorPath(this.paths[t]),this.renderPath(this.translatePoints(this.curFloorPathPoints))):this.clearPath()}addPath(t,e){e===void 0&&(e=0);var i;this.paths=t,this.curPathIndex=e,this.clearTween(),this.clearPath();let s=(i=this.bmap.context.currentFloor)==null?void 0:i.name,o=t[e];if(s&&(o==null?void 0:o.floor)===s)if(this.setCurFloorPath(o),this.bmap.currentBuildGround)this.renderPath(this.translatePoints(o.points));else{let n=()=>{this.bmap.removeEventListener("center-change",n),this.renderPath(this.translatePoints(o.points))};this.bmap.addEventListener("center-change",n)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,i]=this.bmap.buildingCenter;return t.map(s=>[s[0]-e,s[1]-i])}renderPath(t){this.translatePath=t;let e=this.catmullRomCurve3(t);if(this.cPath=e,this.animationPathOptions={cPathIndex:0},this.pathStart=e[0],this.path?this.path.updatePoints(e):(this.path=new fs(this,this.options.path),this.path.create(e),this.path.position.z=this.bmap.context.currentFloor.groundMaxHeight+.5,this.bmap.context.scene.add(this.path)),this.path.movePath(0),this.startPoi){var i;if((i=this.bmap.context.currentFloor)==null||i.poiLayer2.removePoi(this.startPoi),this.startPoi=null,this.startRotateHelperPoi){var s;(s=this.bmap.context.currentFloor)==null||s.poiLayer2.removePoi(this.startRotateHelperPoi),this.startRotateHelperPoi=null}}if(this.removeDetachStart(),this.showDetachStartState&&this.options.detachStartPoi){var o;this.detachStartPoi=new j(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(o=this.bmap.context.currentFloor)==null||o.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new $e(this.bmap.context,new bt(e[0][0],e[0][1],.51),new bt(e[0][0],e[0][1],.51)),this.bmap.context.scene.add(this.detachLine)}if(this.options.needStartPoi){var n;this.startPoi=new j(this.bmap.context,w({},this.options.startPoi,{id:"navigation_start_poi",position:{x:e[0][0],y:e[0][1],z:.51},collision_enable:!1}))||null,(n=this.bmap.context.currentFloor)==null||n.poiLayer2.pushPoi(this.startPoi),this.needStartRotateHelperPoi&&this.showStartRotateHelperPoi(),console.log(this.startRotateHelperPoi)}this.dispatchEvent({type:"render-path",path:this.path})}catmullRomCurve3(t){return mi(t,!1,!0,.1,170,2.5)}getPathDirection(){if(!this.curFloorPath||!this.currentPathPosition||this.curFloorPathPoints.length<2)return null;let t=Bt(this.curFloorPathPoints,this.currentPathPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1],s=new bt(i[0]-e[0],i[1]-e[1],0).normalize(),o=new bt(0,1,0).normalize(),n=s.angleTo(o),r=new bt().crossVectors(o,s);return(Object.is(r.y,0)?-1:1)*n}getPathDirection2(){if(!this.curFloorPath||!this.toPointPosition||this.curFloorPathPoints.length<2)return null;let t=Bt(this.curFloorPathPoints,this.toPointPosition),e=this.curFloorPathPoints[t],i=this.curFloorPathPoints[t+1];return(new ud(i[0]-e[0],i[1]-e[1]).normalize().angle()*180/Math.PI-90+360)%360}changeCameraToPathUp(t){return f(this,null,function*(){t===void 0&&(t=100);let e=this.getPathDirection();if(e===null)return;let i=this.bmap.context.control.getAzimuthalAngle();Math.abs(i-e)>Math.PI&&(i>0?e=Math.PI*2+e:e=e-Math.PI*2);let s=Math.abs(e-this.bmap.context.control.getAzimuthalAngle());if(s<.01)return;let{control:o}=this.bmap.context,n=t/Math.PI*6*s;return ft(new Promise(r=>{let h={azimuthal:o.getAzimuthalAngle()},c={azimuthal:e},l=o.getPolarAngle(),{maxPolarAngle:p,minPolarAngle:d}=o;o.maxPolarAngle=l,o.minPolarAngle=l;let u=new Mo(h,this.tweenUtil.group).to(c,n).easing(dd.Quadratic.InOut).onUpdate(()=>f(this,null,function*(){this.startPoi&&o.target.copy(this.startPoi.position),o.setAzimuthalAngle(h.azimuthal,!0),o.setTargetByOffset(this.options.offsetY)})).onComplete(()=>{o.enabled=!0,this.tweenUtil.remove(u),o.maxPolarAngle=p,o.minPolarAngle=d,r(!0)}).onStart(()=>{o.enabled=!1}).start()}),n+500).finally(()=>{this.bmap.context.control.enabled=!0})})}initNavigationCamera(t){return f(this,null,function*(){t===void 0&&(t=1e3);var e;let s=(e=this.taskQueue.getTasks().find(n=>n.meta.type==="initNavigationCamera"))==null?void 0:e.tid,o={run:()=>ft(f(this,null,function*(){yield this.initCameraZoom(t/2),this.options.disablePathRotate||(yield this.changeCameraToPathUp(t/4)),yield this.translateCameraToStartPoi(t/(this.options.disablePathRotate?2:4))}),t+500).finally(()=>{this.bmap.context.control.enabled=!0}),meta:{type:"initNavigationCamera"}};s?this.taskQueue.replace(s,o):this.taskQueue.add(o)})}translateCameraToStartPoi(t){return f(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},camera:s,control:o}=this.bmap.context,n=Math.round(e/2),r=Math.round(i/2),h=o.target.clone(),c=C(this.startPoi.position,s,e,i),l=c.x-n,p=r-c.y+this.options.offsetY;if(!(Math.abs(l)<=1&&Math.abs(p)<=1)){if(Math.abs(l)>=1){let d=new bt;d.setFromMatrixColumn(s.matrix,0),d.normalize(),d.multiplyScalar(l/s.zoom),h.add(new bt(d.x,d.y,0))}if(Math.abs(p)>=1){let d=new bt;d.setFromMatrixColumn(s.matrix,1),d.normalize(),d.multiplyScalar(p/s.zoom),h.add(new bt(d.x,d.y,0))}return ft(new Promise(d=>{let u=o.target.clone();console.log(u,h,t);let m=new Mo(u,this.tweenUtil.group).to(h,t).onUpdate(()=>{this.bmap.context.control.setCameraPositionByTarget(u,0)}).onComplete(()=>{this.bmap.context.control.setCameraPositionByTarget(h,0),this.tweenUtil.remove(m),this.bmap.context.control.enabled=!0,d(!0)}).onStart(()=>{this.bmap.context.control.enabled=!1}).start()}),t+500).then(()=>{this.bmap.context.control.enabled=!0})}})}initCameraZoom(t){return f(this,null,function*(){if(t===void 0&&(t=100),!this.startPoi)return;let{clientSize:{width:e,height:i},currentFloor:s}=this.bmap.context,{max:o,min:n}=s.box,h=Math.min(e/(o.x-n.x),i/(o.y-n.y))*(o.x-n.x)/this.options.navigationCameraBasic;return this.bmap.context.setZoom(h,this.startPoi.position,t).finally(()=>{this.bmap.context.control.enabled=!0})})}toPosition(t,e){if(this.paths[this.curPathIndex]&&this.paths[this.curPathIndex].floor===t&&this.detachStartPoi){let i=this.translatePoints([e]);this.detachStartPoi.position.setX(i[0][0]),this.detachStartPoi.position.setY(i[0][1]),this.detachLine&&this.startPoi&&this.detachLine.setPosition(this.startPoi.position,this.detachStartPoi.position)}this.options.canBack&&(this.positionNavigation.pointIndex=0,this.positionNavigation.position=this.paths[this.curPathIndex].points[0]),this.positionNavigation.toPosition(t,e)}startSimulation(){this.positionNavigation.startSimulation()}setSimulationSpeed(t){this.positionNavigation.changeSimulationSpeed(t)}toPositionBySpeed(t,e){return f(this,null,function*(){let{currentPathPosition:i,curFloorPath:s,curFloorPathPoints:o}=this;if(!s||!i)return null;let n=this.movedDistance,r=sn(o,t);if(n===-1||r===-1||!this.options.canBack&&r<=n)return null;let h=r-n;if(!h)return;let c=Math.min(Math.abs(h)/e,this.options.runAnimationMaxTime);return this.pathTween&&this.clearTween(),ft(new Promise(l=>{let p=this.pathTween=new Mo({distance:0},this.tweenUtil.group).to({distance:h},c*1e3).onUpdate(d=>f(this,null,function*(){this.moveDistance(d.distance+n,p)})).onComplete(()=>{this.tweenUtil.remove(p),l(!0)}).start()}),c*1e3+500).finally(()=>{this.bmap.context.control.enabled=!0})})}moveDistance(t,e){return f(this,null,function*(){if(this.movedDistance=t,!this.options.disablePathShorten){var i;(i=this.path)==null||i.movePath(this.movedDistance/this.curFloorPathLength)}let s=ve(this.curFloorPathPoints,this.movedDistance);if(s===null)return;this.currentPathPosition=s;let o=this.translatePoints([s])[0];this.startPoi&&(this.setStartPoiPosition(o[0],o[1]),this.options.disablePathAnimation||this.bmap.context.control.setTargetByOffset(this.options.offsetY,this.startPoi.position.clone())),!this.options.disablePathAnimation&&!this.options.disablePathRotate&&(e==null||e.pause(),yield this.changeCameraToPathUp(500/this.options.speed),e==null||e.resume())})}removeDetachStart(){if(this.detachLine&&(this.bmap.context.scene.remove(this.detachLine),this.detachLine.dispose(),this.detachLine=null),this.detachStartPoi){var t;(t=this.bmap.context.currentFloor)==null||t.poiLayer2.removePoi(this.detachStartPoi),this.detachStartPoi=null}}hideDetachStart(){this.showDetachStartState=!1,this.removeDetachStart()}showDetachStart(){if(!this.detachStartPoi&&(this.showDetachStartState=!0,this.path&&this.startPoi&&this.options.detachStartPoi)){var t;let e=this.startPoi.position;this.detachStartPoi=new j(this.bmap.context,w({},this.options.detachStartPoi,{id:"navigation_detach_start_poi",position:e,collision_enable:!1}))||null,(t=this.bmap.context.currentFloor)==null||t.poiLayer2.pushPoi(this.detachStartPoi),this.detachLine=new $e(this.bmap.context,new bt(e.x,e.y,.51),new bt(e.x,e.y,.51)),this.bmap.context.scene.add(this.detachLine)}}setStartPoiRotate(t){this.startPoiRotate=t;let i=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360,s=(360-t-i)%360;this.detachStartPoi&&(this.detachStartPoi.options.icon_rotate=s),this.startPoi&&(this.startPoi.options.icon_rotate=s,this.startRotateHelperPoi&&this.startRotateHelperPoi.setAngle(s))}dispose(){var t;if(this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.hideDetachStart(),this.startPoi){var e;(e=this.bmap.context.currentFloor)==null||e.poiLayer2.removePoi(this.startPoi),this.startPoi=null}this.tweenUtil.dispose(),this.unRegistryEvent(),(t=this.startRotateHelperPoi)==null||t.dispose(),Vt.dispose(),this.positionNavigation.dispose(),this.startRotateHelperPoi=null,super.dispose()}constructor(t,e={},i){super(t),this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curPathIndex=0,this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.toPointPosition=null,this.pathTween=null,this.startPoi=null,this.detachStartPoi=null,this.detachLine=null,this.startPoiRotate=null,this.startRotateHelperPoi=null,this.needStartRotateHelperPoi=!1,this.showDetachStartState=!0,this.movedDistance=0,this.pathStart=[0,0],this.tweenUtil=new Qt,this.taskQueue=new we,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onNavigationInfo=s=>{let{info:o}=s;if(this.dispatchEvent({type:"navigation-info",info:o}),!o.offset){if(o.routeIndex!==this.curPathIndex)return;this.toPointPosition=o.pos,this.toPositionByTask(o.pos)}},this.onUpdate=()=>{this.tweenUtil.update()},this.onSwitchFloor=s=>{let{data:{curFloor:o}}=s;if(this.clearTween(),this.paths[this.curPathIndex]){let n=this.paths[this.curPathIndex];this.setCurFloorPath(n!=null?n:null),n?this.renderPath(this.translatePoints(n.points)):this.clearPath()}else this.clearPath()},this.onControlChangeForStartPoi=()=>{this.startPoi&&this.startPoiRotate!==null&&this.setStartPoiRotate(this.startPoiRotate)},!i&&typeof e=="object"&&(i=e),this.options=Object.assign({},md,i),this.positionNavigation=new gs(this,w({simulationSpeed:this.options.speed},this.options.positionNavigation),this.options.roadData),this.registryEvent()}};import"core-js/modules/web.dom-collections.iterator.js";import{Group as fd,Color as Cr}from"three";var Tr=class extends B{show(t,e){let i=0;t.forEach(n=>{n.onAddToScene("mulFloors"),n.position.z=i,i+=n.userData.height,n.poiLayer2.pois.forEach(r=>{r.options.depth_test=!0})});let{scene:s,currentFloor:o}=this.bmap.context;s.background=new Cr((e==null?void 0:e.backgroundColor)||"#f1f7f6"),o&&(s.remove(o),o.dispose()),this.group.add(...t),s.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}showStep(t,e){return this.show(t,e)}hide(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.dispose()}),this.floors=[],this.group.clear(),this.showStatus=!1}showByNotDispose(t,e,i){i===void 0&&(i=()=>!0);let s=0;t.forEach(r=>{[...r.poiLayer2.pois].forEach(h=>{if(!i(h)){h.visible=!1;return}h.options.depth_test=!0}),r.position.z=s,s+=r.userData.height,r.onAddToScene("mulFloors")});let{scene:o,currentFloor:n}=this.bmap.context;o.background=new Cr((e==null?void 0:e.backgroundColor)||"#f1f7f6"),n&&o.remove(n),this.group.add(...t),o.add(this.group),this.floors=t,this.fitCamera(),this.bmap.context.cameraBound.updateBox(),this.showStatus=!0,this.bmap.context.forceUpdate()}hideByNotDispose(){let{scene:t}=this.bmap.context;t.remove(this.group),this.floors.forEach(e=>{e.poiLayer2.pois.forEach(i=>{i.visible=!0,i.options.depth_test=!1})}),this.floors.forEach(e=>{e.position.z=0,e.onRemoveFromScene()}),this.group.clear(),this.showStatus=!1}fitCamera(){let{context:t,config:e}=this.bmap;t.cameraBound.setEnable(!1),t.control.minZoom=0,t.control.maxZoom=1/0,t.camera.zoom=1,t.setAzimuthalAngle(e.control.defaultAzimuthal,0),t.setPolarAngle(e.control.defaultPolar,0),t.fitCameraToObject(this.group,e.defaultPadding,0,!1);let i=t.camera.zoom;t.control.minZoom=i,t.control.maxZoom=i*e.control.maxZoomScale,this.bmap.basicZoom=t.camera.zoom,t.control.addEventListener("change",this.bmap.onControlChange),this.bmap.onControlChange(),t.cameraBound.setEnable(!0)}dispose(){this.floors.forEach(t=>t.dispose()),this.floors=[],super.dispose()}constructor(t){super(t),this.floors=[],this.group=new fd,this.showStatus=!1,this.group.name="mul-floor-group"}};import{EventDispatcher as gd}from"three";function _o(){return new Worker(new URL("./worker/path.worker-K74NBLDI.js",import.meta.url))}var ys=class extends gd{setLiftPriority(t){return F(this.worker,"onSetLiftPriority",t)}loaded(){return new Promise(t=>{if(this.initRoadStatus)t(!0);else{let e=i=>{let{status:s}=i;s&&(this.removeEventListener("init-road-status",e),t(!0))};this.addEventListener("init-road-status",e)}})}setRoadData(t,e){return f(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield F(this.worker,"set_road_info",{roadData:t,facilities:e}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i,s,o,n){return f(this,null,function*(){return i===void 0&&(i=""),new Promise((r,h)=>{let c=()=>{F(this.worker,"get_path",{start:t,end:e,type:i,permission:s,travelDirection:o,options:n}).then(l=>{l?typeof l=="string"?h(l):r(l):h("no-path")})};if(this.initRoadStatus)c();else{let l=p=>{let{status:d}=p;d&&(this.removeEventListener("init-road-status",l),c())};this.addEventListener("init-road-status",l)}})})}getDirectionPath(t){return F(this.worker,"get_direction_path",t)}dispose(){return f(this,null,function*(){F(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=_o(),this.initRoadStatus=!1}};import{EventDispatcher as yd}from"three";function Po(){return new Worker(new URL("./worker/cr-path.worker-RCWZ3ILJ.js",import.meta.url))}var kr=class extends yd{setRoadData(t){return f(this,null,function*(){this.initRoadStatus=!1,this.dispatchEvent({type:"init-road-status",status:!1}),yield F(this.worker,"set_road_info",{roadData:t}),this.initRoadStatus=!0,this.dispatchEvent({type:"init-road-status",status:!0})})}getPath(t,e,i){return f(this,null,function*(){return i===void 0&&(i=""),new Promise((s,o)=>{let n=()=>{F(this.worker,"get_path",{start:t,end:e,type:i}).then(r=>{r?typeof r=="string"?o(r):s(r):o("no-path")})};if(this.initRoadStatus)n();else{let r=h=>{let{status:c}=h;c&&(this.removeEventListener("init-road-status",r),n())};this.addEventListener("init-road-status",r)}})})}getDirectionPath(t){return F(this.worker,"get_direction_path",t)}dispose(){return f(this,null,function*(){F(this.worker,"clear",""),this.worker.terminate()})}constructor(){super(),this.worker=Po(),this.initRoadStatus=!1}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.set.difference.v2.js";import"core-js/modules/es.set.intersection.v2.js";import"core-js/modules/es.set.is-disjoint-from.v2.js";import"core-js/modules/es.set.is-subset-of.v2.js";import"core-js/modules/es.set.is-superset-of.v2.js";import"core-js/modules/es.set.symmetric-difference.v2.js";import"core-js/modules/es.set.union.v2.js";import"core-js/modules/es.array.push.js";import{Frustum as vd}from"three";var vs=class extends vt{setEnable(t){super.setEnable(t),ot(this.rect,0,0,0,0),t?this.registryEvent():(this.startPoint=void 0,this.unRegistryEvent())}registryEvent(){this.context.container.addEventListener("pointerdown",this.onPointerDown),this.context.container.addEventListener("pointermove",this.onPointerMove),this.context.container.addEventListener("pointerup",this.onPointerUp),this.context.addEventListener("update",this.onUpdate)}unRegistryEvent(){this.context.container.removeEventListener("pointerdown",this.onPointerDown),this.context.container.removeEventListener("pointermove",this.onPointerMove),this.context.container.removeEventListener("pointerup",this.onPointerUp),this.context.removeEventListener("update",this.onUpdate)}doSelect(){if(this.startPoint&&this.endPoint){if(this.startPoint.distanceTo(this.endPoint)<.1)return;let{context:{camera:e,container:{clientWidth:i,clientHeight:s}}}=this,o=C(this.startPoint,e,i,s),n=C(this.endPoint,e,i,s),r={x:Math.min(o.x,n.x),y:Math.min(o.y,n.y)},h={x:Math.max(o.x,n.x),y:Math.max(o.y,n.y)},c=this.searchMapInFrustum(r,h);this.dispatchEvent({type:"selected",list:c})}}searchMapInFrustum(t,e){var i;let{context:s}=this;return((i=s.currentFloor)==null?void 0:i.graphicLayer.children.filter(o=>o instanceof J&&this.searchChildInFrustum(o,t,e)))||[]}searchChildInFrustum(t,e,i){let{context:{camera:s,container:{clientWidth:o,clientHeight:n}}}=this;if(!t)return!1;if(!t.mesh){let d=t.getPosition();if(d){let u=C(d,s,o,n);return Yt(u,e,i)}return!1}t.mesh.geometry.boundingBox||t.mesh.geometry.computeBoundingBox();let r=t.mesh.geometry.boundingBox;if(!r)return!1;let{min:h,max:c}=r,l=C(h,s,o,n),p=C(c,s,o,n);return!(!Yt(l,e,i)||!Yt(p,e,i))}dispose(){super.dispose(),this.rect=null,this.unRegistryEvent()}constructor(t){super(t),this.frustum=new vd,this.onPointerDown=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.startPoint=o),this.endPoint=void 0},this.onPointerMove=s=>{if(!this.enable||!this.startPoint)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o)},this.onPointerUp=s=>{if(!this.enable)return;let o=this.getIntersectByPointerEvent(s);o&&(this.endPoint=o),this.doSelect(),this.startPoint=void 0},this.onUpdate=()=>{if(this.startPoint){let s=this.getSvgCoordinate(this.startPoint),o=w({},s);this.endPoint&&(o=this.getSvgCoordinate(this.endPoint));let n={x:Math.min(s.x,o.x),y:Math.min(s.y,o.y)},r=Math.abs(o.x-s.x),h=Math.abs(o.y-s.y);ot(this.rect,n.x,n.y,r,h)}else ot(this.rect,0,0,0,0)};let{config:{selectBox:{fill:e,stroke:i}}}=t;this.rect=qt(i,e),this.svg.appendChild(this.rect),this.registryEvent()}};var xd={boxSelection:!1,elements:["graphic","poi"]},Dr=class extends B{get list(){return this._list}enableBoxSelection(){this.isMultipleSelect||!this.options.boxSelection||(this.isMultipleSelect=!0,this.boxSelection.setEnable(!0),this.prevPanStatus=this.bmap.context.control.enablePan,this.prevRotateStatus=this.bmap.context.control.enableRotate,this.bmap.context.control.enablePan=!1,this.bmap.context.control.enableRotate=!1)}disableBoxSelection(){this.isMultipleSelect&&(this.isMultipleSelect=!1,this.boxSelection.setEnable(!1),this.bmap.context.control.enablePan=!!this.prevPanStatus,this.bmap.context.control.enableRotate=!!this.prevRotateStatus)}selectEnd(){this.dispatchEvent({type:"select",graphics:[...this._list],pois:[...this._poiList],isMultipleSelect:this.isMultipleSelect})}registryEvent(){this.bmap.context.container.addEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.addEventListener("pointerup",this.onPointerUp),this.bmap.context.container.addEventListener("pointerout",this.onPointerOut),this.bmap.context.container.addEventListener("pointercancel",this.onPointerOut),window.addEventListener("keydown",this.onKeyDown),window.addEventListener("keyup",this.onKeyUp),this.boxSelection.addEventListener("selected",this.onBoxSelected)}unRegistryEvent(){this.bmap.context.container.removeEventListener("pointerdown",this.onPointerDown),this.bmap.context.container.removeEventListener("pointerup",this.onPointerUp),this.bmap.context.container.removeEventListener("pointerout",this.onPointerOut),this.bmap.context.container.removeEventListener("pointercancel",this.onPointerOut),window.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("keyup",this.onKeyUp),this.boxSelection.removeEventListener("selected",this.onBoxSelected)}clear(){this._list.clear()}remove(t){this._list.delete(t)}dispose(){this.unRegistryEvent(),super.dispose()}constructor(t,e={}){super(t),this._list=new Set,this._poiList=new Set,this.downPoint=null,this.isMultipleSelect=!1,this.onPointerDown=i=>{this.downPoint={x:i.offsetX,y:i.offsetY}},this.onPointerUp=i=>{if(!this.downPoint)return;let{offsetX:s,offsetY:o}=i,{x:n,y:r}=this.downPoint;if(Math.sqrt((n-s)**2+(r-o)**2)>3)return;let h=new Set,c=[],l=[];if(this.options.elements.includes("graphic")){let{graphics:p}=this.bmap.context.getGraphicsByDeviceXy(s,o);p.map(d=>h.add(d.options.id)),c.push(...p)}if(this.options.elements.includes("poi")){let p=this.bmap.context.getPoisByDeviceXy(s,o);l.push(...p),p.forEach(d=>{if(!h.has(d.options.id)){var u;let m=((u=this.bmap.context.currentFloor)==null?void 0:u.graphicLayer.graphicMap.get(d.options.id))||null;m&&(h.add(d.options.id),c.push(m))}})}(!this.options.boxSelection||!(ge?i.metaKey:i.ctrlKey))&&(this._list.clear(),this._poiList.clear()),c.forEach(p=>this._list.add(p)),l.forEach(p=>this._poiList.add(p)),this.selectEnd(),this.downPoint=null},this.onPointerOut=i=>{this.disableBoxSelection()},this.onKeyDown=i=>{ye(i.key)&&this.enableBoxSelection()},this.onKeyUp=i=>{ye(i.key)&&this.disableBoxSelection()},this.onBoxSelected=i=>{let{list:s}=i;this._list.clear(),this._poiList.clear(),s.forEach(o=>{if(this.options.elements.includes("graphic")&&this._list.add(o),this.options.elements.includes("poi")){let n=this.bmap.getPoiById(o.options.id);n&&this._poiList.add(n)}}),this.selectEnd()},this.options=w({},xd,e),this.boxSelection=new vs(this.bmap.context),this.boxSelection.setEnable(!1),this.registryEvent()}};import"core-js/modules/es.array.push.js";import{cloneDeep as wd,isNil as ee,throttle as Ar}from"lodash";var O=function(a){return a.COMPASS="compass",a.DEVICE_MOTION="deviceMotion",a.ACCELERATION="acceleration",a.GPS="gps",a}({});var Md={time:1e3,elements:[O.COMPASS,O.DEVICE_MOTION,O.ACCELERATION,O.GPS]},xs=class extends X{start(){this.options.elements.some(t=>[O.DEVICE_MOTION,O.COMPASS].includes(t))&&this.listenDeviceOrientation(),this.options.elements.includes(O.ACCELERATION)&&this.listenAcceleration(),this.options.elements.includes(O.GPS)&&this.listenGps(),this.dispatchEvent({type:"start"}),this.dispatchTimer=this.timer.setInterval(()=>{this.dispatchEvent({type:"sensor-data",data:wd(this.data)}),this.data=[]},this.options.time)}addDataItem(t){this.data.push(t),this.dispatchEvent({type:"add-data-item",item:t})}listenDeviceOrientation(){Ut?window.addEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.addEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0})}listenAcceleration(){window.addEventListener("devicemotion",this.handleAcceleration,!1)}listenGps(){this.gpsTimer=navigator.geolocation.watchPosition(t=>{console.log("watch gps",t.coords),this.addDataItem({type:O.GPS,timestamp:Date.now(),res:[t.coords.longitude,t.coords.latitude,t.coords.accuracy]})},t=>{console.log("\u83B7\u53D6gps\u5931\u8D25",t)},{enableHighAccuracy:!0})}checkSensor(){return f(this,null,function*(){return{deviceOrientation:yield this.checkDeviceOrientation()}})}checkDeviceOrientation(){return f(this,null,function*(){var t;if(!Ut)return!0;if(typeof window.DeviceOrientationEvent!="undefined"&&typeof((t=window.DeviceOrientationEvent)==null?void 0:t.requestPermission)=="function")try{var e;return(yield(e=window.DeviceOrientationEvent)==null?void 0:e.requestPermission())==="granted"}catch(i){return!1}return!1})}stop(){window.removeEventListener("devicemotion",this.handleAcceleration,!1),Ut?window.removeEventListener("deviceorientation",this.deviceOrientationAbsHandler,!1):window.removeEventListener("deviceorientationabsolute",this.deviceOrientationAbsHandler,{absolute:!0}),ee(this.gpsTimer)||navigator.geolocation.clearWatch(this.gpsTimer),this.dispatchTimer&&this.timer.clearInterval(this.dispatchTimer),this.data=[],this.dispatchEvent({type:"stop"})}constructor(t={}){super(),this.gpsTimer=null,this.data=[],this.timer=new z,this.dispatchTimer=null,this.addAcceleration=Ar(e=>{this.addDataItem(e)},20),this.deviceOrientationAbsHandler=Ar(e=>{let i=Date.now(),{alpha:s,beta:o,gamma:n}=e;if(ee(s)||ee(o)||ee(n))return;let r;Ut?r=e.webkitCompassHeading:r=360-s,this.options.elements.includes(O.DEVICE_MOTION)&&this.addDataItem({type:O.DEVICE_MOTION,timestamp:i,res:[s,o,n]}),this.options.elements.includes(O.COMPASS)&&this.addDataItem({type:O.COMPASS,timestamp:i,res:r})},200),this.handleAcceleration=e=>{let i=e.accelerationIncludingGravity;ee(i)||ee(i.x)||ee(i.y)||ee(i.z)||this.addAcceleration({type:O.ACCELERATION,timestamp:Date.now(),res:[i.x,i.y,i.z]})},this.options=w({},Md,t)}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";function ws(a,t){return 1/Math.sqrt(2*Math.PI*Math.pow(t,2))*Math.exp(-Math.pow(a,2)/(2*Math.pow(t,2)))}function ii(a){return(a+360)%360}function Or(a,t){let i=6378137*a*Math.PI/180,s=6378137*Math.log(Math.tan(Math.PI/4+t*Math.PI/180/2));return{x:i,y:s}}function Re(a,t,e,i){return Math.sqrt(Math.pow(Math.abs(a-e),2)+Math.pow(Math.abs(t-i),2))}var Ms=class{motionModelRotYaw(t){if(!(Math.abs(t)<.001)){this.last_yaw_compass=ii(this.last_yaw_compass+t);for(let e=0;e<this.NumParticle;e++){let i=Math.random()*this.yaw_noise_sigma;this.particleX[2][e]=this.particleX[2][e]+t+i,this.particleX[2][e]=ii(this.particleX[2][e])}}}motionModelStepLength(t,e){if(t===0)return;for(let s=0;s<this.NumParticle;s++){let o=Math.random()*this.step_noise_sigma;this.particleX[0][s]+=(.65+o)*Math.sin(-this.particleX[2][s]/180*Math.PI),this.particleX[1][s]+=(.65+o)*Math.cos(this.particleX[2][s]/180*Math.PI),e(this.particleX[0][s],this.particleX[1][s])||(this.particleWeight[0][s]*=this.unaccess_weight)}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}motionModelCompassYaw(t,e){if(e-this.last_compass_time>this.compass_update_interval){let i=360-t;i+=this.delta_yaw,i=ii(i),Math.abs(i-this.last_yaw_compass)>60?this.compass_consecutive_offset_count++:this.compass_consecutive_offset_count=0;for(let o=0;o<this.NumParticle;o++){let n=Math.abs(this.particleX[2][o]-i);n>180&&(n=360-n),this.particleWeight[0][o]*=ws(n,this.sigmaCompass)}let s=this.particleWeight[0].reduce((o,n)=>o+n,0);this.particleWeight[0]=this.particleWeight[0].map(o=>o/s),this.setLastCompassTime(e)}}resampling(){if(1/this.particleWeight[0].reduce((e,i)=>e+i*i,0)<this.reSampNumParticle){let e=this.particleWeight[0].reduce((r,h,c)=>r.concat(r[c]+h),[0]),s=this.particleWeight[0].map(()=>1/this.NumParticle).map((r,h)=>r+Math.random()/this.NumParticle),o=[],n=0;for(let r=0;r<this.NumParticle;r++){for(;s[r]>e[n];)n++;o.push(n)}this.particleX=this.particleX.map((r,h)=>o.map(c=>r[c])),this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle)}}update(t,e){for(let s=0;s<this.NumParticle;s++){let o=Re(this.particleX[0][s],this.particleX[1][s],t.x,t.y);this.particleWeight[0][s]=Math.max(1e-7,this.particleWeight[0][s]*ws(o,e))}let i=this.particleWeight[0].reduce((s,o)=>s+o,0);this.particleWeight[0]=this.particleWeight[0].map(s=>s/i)}updateCar(t,e){let i=t.x-this.xEst[0][0],s=t.y-this.xEst[1][0];for(let n=0;n<this.NumParticle;n++){let r=Re(this.particleX[0][n],this.particleX[1][n],t.x,t.y);this.particleWeight[0][n]=Math.max(1e-7,this.particleWeight[0][n]*ws(r,e)),this.particleX[0][n]+=i,this.particleX[1][n]+=s}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o)}getPosInitFlag(){return this.particle_PosInitFlag}getYawInitFlag(){return this.particle_yawInitFlag}setPosInitFlag(t){this.particle_PosInitFlag=t}setYawInitFlag(t){this.particle_yawInitFlag=t}getResultX(){let t=[0,0,0];for(let e=0;e<3;e++)for(let i=0;i<this.NumParticle;i++)t[e]+=this.particleX[e][i]*this.particleWeight[0][i];return this.xEst=t.map(e=>[e]),this.xEst[0][0]}getResultY(){return this.xEst[1][0]}getResultYaw(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0]));return this.particleX[2][t]}getEstConfidence(){let t=this.particleWeight[0].indexOf(Math.max(...this.particleWeight[0])),e=this.particleWeight[0].indexOf(Math.min(...this.particleWeight[0])),i=[this.particleX[0][t],this.particleX[1][t]],s=[this.particleX[0][e],this.particleX[1][e]],o=Re(i[0],i[1],s[0],s[1]),n=o*.67;return console.log(o,n),n}getParticleNum(){return this.NumParticle}getParticleX(){return this.particleX}setLastCompassTime(t){this.last_compass_time=t}getLastCompassTime(){return this.last_compass_time}initParticlesByPos(t,e,i){if(!this.particle_PosInitFlag){this.particleWeight[0]=Array(this.NumParticle).fill(1/this.NumParticle);let s=0;for(;s<this.NumParticle;){let n=(2*Math.random()-1)*this.initial_xy_uncertainty,r=(2*Math.random()-1)*this.initial_xy_uncertainty;i(t+n,e+r)||(this.particleWeight[0][s]*=this.unaccess_weight),this.particleX[0][s]=t+n,this.particleX[1][s]=e+r,s++}let o=this.particleWeight[0].reduce((n,r)=>n+r,0);this.particleWeight[0]=this.particleWeight[0].map(n=>n/o),this.particle_PosInitFlag=!0,this.xEst[0][0]=t,this.xEst[1][0]=e,this.xEst[2][0]=0}}initParticlesByCompass(t){console.log("Init compass: "+t);let e=360-t;e+=this.delta_yaw,e=ii(e),console.log("Init Yaw: "+e);for(let i=0;i<this.NumParticle;i++){let s=(2*Math.random()-1)*this.initial_yaw_uncertainty;this.particleX[2][i]=e+s}this.particle_yawInitFlag=!0,this.xEst[2][0]=e,this.last_yaw_compass=e,this.compass_consecutive_offset_count=0}constructor(t){this.last_yaw_compass=0,this.compass_consecutive_offset_count=0,this.NumParticle=t.NumParticle,this.reSampNumParticle=t.reSampNumParticle,this.initial_xy_uncertainty=t.initial_xy_uncertainty,this.initial_yaw_uncertainty=t.initial_yaw_uncertainty,this.step_noise_sigma=t.step_noise_sigma,this.yaw_noise_sigma=t.yaw_noise_sigma,this.compass_update_interval=t.compass_update_interval,this.sigmaCompass=t.sigmaCompass,this.delta_yaw=t.delta_yaw,this.sigmaBeacon=t.sigmaBeacon,this.unaccess_weight=t.unaccess_weight,this.particle_PosInitFlag=!1,this.particle_yawInitFlag=!1,this.xEst=[[0],[0],[0]],this.particleX=Array.from({length:3},()=>Array(this.NumParticle).fill(0)),this.particleWeight=Array.from({length:1},()=>Array(this.NumParticle).fill(1/this.NumParticle)),this.last_compass_time=0}};import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";var _s=class{init(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10+.5,this.max_valley=10-.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.65,this.last_rot=[0,0,0],this.delta_rot=[0,0,0],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[],this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0}reset(){this.init()}setInitPose(t){t===void 0&&(t=[0,0]),this.last_px=t[0],this.last_py=t[1],console.info("pdr init pos: "+this.last_px+", "+this.last_py)}setInitYaw(t){t===void 0&&(t=0),this.last_yaw=t}getPos(t,e,i){let s=0;return i.length===3&&(this.delta_yaw=this.getDeltaYawFromRot(t,i)),e.length===3&&(s=this.getStepLength(t,e)),s!==0&&(this.last_px+=this.delta_px,this.last_py+=this.delta_py),[this.last_px,this.last_py]}getDeltaPose(){return[this.delta_px,this.delta_py]}getMotionState(){return this.currentMotionState}getStepLength(t,e){if(e.length<3)return console.warn("acc data less than 3"),0;let i=!1,s=Math.sqrt(Math.pow(e[0],2)+Math.pow(e[1],2)+Math.pow(e[2],2));if(this.accH_fifo.push(s),this.accH_time_fifo.push(t),this.imuFreUpdate(),!this.isMoving(e,this.last_rot))return 0;if(this.accH_fifo.length<this.accH_fifo_len+1)i=!1;else{for(;this.accH_fifo.length>=this.accH_fifo_len+1;)this.accH_fifo.shift(),this.accH_time_fifo.shift();let n=this.PVStepDetec(),r=this.FFTStepDetec(),h=this.recheckState(),c=this.accH_time_fifo[Math.floor(this.accH_time_fifo.length*3/4)];Math.abs(this.abnor_start_time)<.001&&this.abnor_fft_detected?this.abnor_start_time=c:this.abnor_fft_detected||(this.abnor_start_time=0),n&&r&&h?(this.step_count+=1,this.last_step_time=c,i=!0):Math.abs(this.abnor_start_time)>.001&&this.abnor_peak_time-this.abnor_start_time>this.abnor_time_threshold&&this.step_count>1&&this.abnor_peak_time-this.last_step_time>1?(this.step_count+=1,this.last_step_time=c,i=!0):(c-this.last_step_time>2&&(this.state_count=0),i=!1)}if(i){let n=this.last_yaw/180*Math.PI;return this.delta_px=this.const_step_length*Math.cos(n),this.delta_py=this.const_step_length*Math.sin(n),this.const_step_length}else return 0}imuFreUpdate(){if(this.accH_time_fifo.length>2&&(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]<0||this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[this.accH_time_fifo.length-2]>10||this.accH_time_fifo[this.accH_time_fifo.length-1]===this.accH_time_fifo[0])&&(console.warn("pdr reset last one time "+this.accH_time_fifo[this.accH_time_fifo.length-1]+" last two time "+this.accH_time_fifo[this.accH_time_fifo.length-2]),this.reset()),this.accH_fifo.length>9||this.fre<15){let t=(this.accH_fifo.length-1)/(this.accH_time_fifo[this.accH_time_fifo.length-1]-this.accH_time_fifo[0]);Math.abs(this.fre-t)>8&&(this.fre=Math.round((t-3)/10)*10,(this.fre<=10||this.fre>=100)&&(console.warn("Frequency Error "+this.fre),this.fre=100),console.debug("Frequency change to "+this.fre),this.accH_fifo_len=Math.floor(1*this.fre)+1)}}recheckState(){return!0}PVStepDetec(){let t=!1,e=this.accH_fifo.slice(Math.floor(this.accH_fifo_len/2)),i=this.accH_time_fifo.slice(Math.floor(this.accH_fifo_len/2)),s=e[Math.floor(e.length/2)],o=i[Math.floor(i.length/2)],n=Math.max(...e),r=Math.min(...e),h=!1,c=!1;return Math.abs(s-r)<.01&&s<this.max_valley&&this.valley_num<=this.peak_num&&(this.last_valley_time===0?c=!0:c=o-this.last_valley_time>this.min_step_time,c&&(this.last_valley_time=o,this.valley_num+=1)),Math.abs(s-n)<.01&&s>this.min_peak&&this.peak_num<=this.valley_num&&(this.last_peak_time===0?h=!0:h=o-this.last_peak_time>this.min_step_time,h&&(this.last_peak_time=o,this.peak_num+=1)),s===n&&s>this.min_peak&&(this.abnor_peak_time=o,this.abnor_peak_accH=s),this.peak_num===this.valley_num&&(h||c)&&(t=!0),t}FFTStepDetec(){return!0}isMoving(t,e){if(t.length<3||e.length<3)return!1;this.acc_buffer.push([...t]),this.acc_buffer.length>this.static_window_size&&this.acc_buffer.shift();let i=Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2));this.acc_variance_buffer.push(i),this.acc_variance_buffer.length>this.static_window_size&&this.acc_variance_buffer.shift();let s=Math.abs(e[0])+Math.abs(e[1])+Math.abs(e[2]);if(this.rot_variance_buffer.push(s),this.rot_variance_buffer.length>this.static_window_size&&this.rot_variance_buffer.shift(),this.acc_variance_buffer.length<10)return this.is_moving;let o=this.acc_variance_buffer.slice(-10),n=this.rot_variance_buffer.slice(-10),r=this.calculateMean(o),h=this.calculateStdDeviation(o),c=this.calculateMean(n),l=this.calculateStdDeviation(n),p;return r>this.walkingThreshold&&h>.5?(this.walkingCount++,this.stationaryCount=0,this.phoneUseCount=0,p="WALKING"):r<this.phoneUseThreshold&&c>this.rotationThreshold?(this.phoneUseCount++,this.walkingCount=0,this.stationaryCount=0,p="USING_PHONE"):c<.5?(this.stationaryCount++,this.walkingCount=0,this.phoneUseCount=0,p="STATIONARY"):p="UNKNOWN",p!==this.currentMotionState?(this.stateCounter++,this.stateCounter>=this.stateChangeThreshold&&(this.previousMotionState=this.currentMotionState,this.currentMotionState=p,this.stateCounter=0,console.debug("Motion state changed: "+this.previousMotionState+" -> "+this.currentMotionState),console.debug("Stats: avgAcc="+r.toFixed(2)+", accStdDev="+h.toFixed(2)+", avgRot="+c.toFixed(2)+", rotStdDev="+l.toFixed(2)))):this.stateCounter=0,this.is_moving=this.currentMotionState==="WALKING",this.is_moving}calculateMean(t){return t.length===0?0:t.reduce((e,i)=>e+i,0)/t.length}calculateStdDeviation(t){if(t.length<2)return 0;let e=this.calculateMean(t),s=t.map(o=>{let n=o-e;return n*n}).reduce((o,n)=>o+n,0)/t.length;return Math.sqrt(s)}getMotionStatistics(){let t=this.acc_variance_buffer.slice(-10),e=this.rot_variance_buffer.slice(-10),i=this.calculateMean(t),s=this.calculateMean(e),o=this.calculateStdDeviation(t),n=this.calculateStdDeviation(e);return console.debug("\u8FD0\u52A8\u68C0\u6D4B: avgAcc="+i.toFixed(2)+", accStdDev="+o.toFixed(2)+", avgRot="+s.toFixed(2)+", rotStdDev="+n.toFixed(2)),console.debug("\u72B6\u6001\u5224\u65AD\u6761\u4EF6: \u884C\u8D70(avgAcc>"+this.walkingThreshold+", accStdDev>0.5), \u9759\u6B62(avgRot<0.5), \u624B\u673A(avgAcc<"+this.phoneUseThreshold+", avgRot>"+this.rotationThreshold+")"),console.debug("\u5F53\u524D\u72B6\u6001: "+this.currentMotionState+", \u8BA1\u6570: \u884C\u8D70="+this.walkingCount+", \u9759\u6B62="+this.stationaryCount+", \u624B\u673A="+this.phoneUseCount),{currentState:this.currentMotionState,avgAcceleration:i,avgRotation:s,accStdDeviation:o,rotStdDeviation:n,walkingCount:this.walkingCount,stationaryCount:this.stationaryCount,phoneUseCount:this.phoneUseCount,dataPoints:this.acc_variance_buffer.length,isMoving:this.is_moving}}getDeltaYawFromRot(t,e){if(e.length<3)return console.warn("rot data less than 3"),0;let i=[0,0,0];this.last_rot.length===3&&(i=e.map((r,h)=>r-this.last_rot[h]));for(let r=0;r<e.length;r++)i[r]<-180?i[r]+=360:i[r]>180&&(i[r]-=360);let s=.2;this.delta_rot.length===3?this.delta_rot=this.delta_rot.map((r,h)=>s*r+(1-s)*i[h]):this.delta_rot=i,this.last_rot=e,this.delta_yaw=this.delta_rot[0],this.last_yaw+=this.delta_yaw,this.last_yaw=this.limitYaw(this.last_yaw);let o=this.delta_rot.reduce((r,h)=>r+Math.abs(h),0);this.delta_rot_sum_fifo.push(o),this.delta_rot_sum_time_fifo.push(t),Math.abs(this.delta_rot_sum_time_fifo[this.delta_rot_sum_time_fifo.length-1]-this.delta_rot_sum_time_fifo[0])>1&&(this.delta_rot_sum_fifo.shift(),this.delta_rot_sum_time_fifo.shift()),this.delta_yaw_accum+=this.delta_yaw;let n=0;return Math.abs(this.delta_yaw_accum_timestamp-t)>this.delta_yaw_time_threshold?(n=this.delta_yaw_accum,this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=t,n):null}limitYaw(t){for(;t<-180;)t+=360;for(;t>180;)t-=360;return t}constructor(){this.fre=100,this.accH_fifo=[],this.accH_time_fifo=[],this.accH_fifo_len=Math.floor(1*this.fre)+1,this.step_count=0,this.state_count=0,this.last_valley_time=0,this.last_peak_time=0,this.last_step_time=0,this.min_step_time=.3,this.max_step_time=1,this.min_peak=10.5,this.max_valley=9.5,this.peak_num=0,this.valley_num=0,this.fft_min_amp=.3,this.fft_min_fre=0,this.fft_max_fre=4,this.last_fft_amp=0,this.abnor_start_time=0,this.abnor_fft_detected=!1,this.abnor_time_threshold=4,this.abnor_peak_time=0,this.abnor_peak_accH=0,this.const_step_length=.85,this.last_rot=[],this.delta_rot=[],this.last_yaw=0,this.delta_yaw=null,this.delta_rot_sum_fifo=[],this.delta_rot_sum_time_fifo=[],this.delta_yaw_accum=0,this.delta_yaw_accum_timestamp=0,this.delta_yaw_time_threshold=.5,this.last_px=0,this.last_py=0,this.delta_px=0,this.delta_py=0,this.is_moving=!1,this.currentMotionState="UNKNOWN",this.previousMotionState="UNKNOWN",this.walkingThreshold=1,this.stationaryThreshold=.6,this.phoneUseThreshold=.7,this.rotationThreshold=.8,this.walkingCount=0,this.stationaryCount=0,this.phoneUseCount=0,this.stateCounter=0,this.stateChangeThreshold=3,this.static_window_size=20,this.acc_variance_buffer=[],this.rot_variance_buffer=[],this.acc_buffer=[]}};var _d={using_gps:!0,gps_max_horizontalAccuracy:20,initial_gps_delay_time:3e3},Ps=class{pfFusionPDRiBeacon(t){let{type:e,timestamp:i,res:s}=t,o=!1;if(this.cacheSensorData.push(t),this.particleFilter.getPosInitFlag()&&this.particleFilter.getYawInitFlag()){if(e===O.ACCELERATION){let n=s,r=this.pdr.getStepLength(i/1e3,n);r!==0&&(this.particleFilter.motionModelStepLength(r,()=>!0),this.particleFilter.resampling(),this.position_count+=1,o=!0)}if(this.using_gps&&e===O.GPS)if(this.last_beacon_time===null||i-this.last_beacon_time>5e3){let n=this.getGpsPosition(s);o=n!==null,n&&(this.particleFilter.update(n,this.gps_horizontalAccuracy),this.resetParticleFilterDist(n,"gps",s[2]),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0)}else return[!1,0,0];if(e===O.DEVICE_MOTION){let n=this.pdr.getDeltaYawFromRot(i/1e3,s);n!==null&&this.particleFilter.motionModelRotYaw(n)}e===O.COMPASS&&this.particleFilter.motionModelCompassYaw(s,i),this.last_pos_time&&i-this.last_pos_time>500&&(this.position_count+=1,o=!0)}else if(!this.particleFilter.getPosInitFlag()&&this.using_gps&&e===O.GPS)if(this.startTime&&Date.now()-this.startTime>this.options.initial_gps_delay_time){let n=this.getGpsPosition(s);o=n!==null,console.log("gps_pos",n,s),n?(this.particleFilter.initParticlesByPos(n.x,n.y,()=>!0),this.last_pos_time=i,console.log("init Pos by gps success time "+i),this.cacheSensorData.length=0):console.log("init Pos by gps fail time "+i)}else this.startTime||(this.startTime=i);else if(!this.particleFilter.getYawInitFlag()&&e===O.COMPASS){let n=s;this.particleFilter.initParticlesByCompass(n),this.particleFilter.setLastCompassTime(i),console.log("init yaw by compass success time "+i)}return o&&(this.last_pos_time=i),[o,this.particleFilter.getResultX(),this.particleFilter.getResultY()]}setBeaconPosition(t,e){if(this.last_beacon_time=e,this.particleFilter.getPosInitFlag())this.particleFilter.update(t,this.sigmaBeacon);else{this.particleFilter.initParticlesByPos(t.x,t.y,()=>!0);let i=this.cacheSensorData.filter(s=>s.timestamp>e);console.log("\u521D\u59CBsensorData",i),i.map(s=>this.pfFusionPDRiBeacon(s))}return this.resetParticleFilterDist(t),this.particleFilter.resampling(),this.position_count+=1,this.cacheSensorData.length=0,[this.particleFilter.getResultX(),this.particleFilter.getResultY()]}getGpsPosition(t){return t[2]>this.gps_max_horizontalAccuracy?null:Or(t[0],t[1])}resetParticleFilterDist(t,e,i){let s=this.particleFilter.getResultX(),o=this.particleFilter.getResultY(),n=Re(s,o,t.x,t.y);(e==="gps"?i&&n>i||n>this.GpsMaxEstimateErr:n>this.MaxEstimateErr)?(this.outTrustRegionNum+=1,this.outTrustRegionNum>=this.TrustNum&&(console.info("\u8D85\u51FA\u53EF\u4FE1\u533A\u57DF\uFF0C\u91CD\u7F6E\u7C92\u5B50\u8FC7\u6EE4\u5668\u5230: "+t.x+", "+t.y),this.particleFilter.setPosInitFlag(!1),this.particleFilter.setYawInitFlag(!1),this.outTrustRegionNum=0,this.startTime=Date.now())):this.outTrustRegionNum=0}constructor(t){this.sigmaBeacon=5,this.gps_horizontalAccuracy=10,this.using_gps=!0,this.last_beacon_time=Date.now(),this.position_count=0,this.gps_max_horizontalAccuracy=20,this.MaxEstimateErr=5,this.GpsMaxEstimateErr=30,this.outTrustRegionNum=0,this.TrustNum=1,this.cacheSensorData=[],this.startTime=null;let e=w({},_d,t);this.options=e,this.using_gps=e.using_gps,this.gps_max_horizontalAccuracy=e.gps_max_horizontalAccuracy,this.particleFilter=new Ms({NumParticle:200,reSampNumParticle:.65,initial_xy_uncertainty:12,initial_yaw_uncertainty:100,step_noise_sigma:.5,yaw_noise_sigma:2,compass_update_interval:3e3,sigmaCompass:80,delta_yaw:2,sigmaBeacon:5,unaccess_weight:.7}),this.pdr=new _s}};import{booleanPointInPolygon as Pd,point as bd}from"@turf/turf";var bs=class extends X{checkSensor(){return this.sensor.checkSensor()}setSensor(t){this.sensor=t}start(){this.sensor.start(),this.pdr.startTime=Date.now(),this.sensor.addEventListener("add-data-item",t=>{let{item:e}=t;this.getPositionBySensorItem(e,!this._pause)})}pause(){this._pause=!0}continue(){this._pause=!1}getPositionBySensorItem(t,e){e===void 0&&(e=!0);let[i,s,o]=this.pdr.pfFusionPDRiBeacon(t);return i&&e&&Pd(bd([s,o]),this.bmap.context.range)&&this.dispatchEvent({type:"position",x:s,y:o,_type:t.type===O.GPS?"gps":"pdr"}),[i,s,o]}setBeaconPosition(t,e){let[i,s]=this.pdr.setBeaconPosition(t,e);this.dispatchEvent({type:"position",x:i,y:s,_type:"beacon"})}dispose(){this.sensor.stop()}constructor(t,e={}){super(),this.bmap=t,this._pause=!1,this.sensor=new xs(e.sensor),this.pdr=new Ps(e.pdr||{})}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{Object3D as Ed,TextureLoader as Ld,Color as Cd,Vector2 as bo,Vector3 as Td,NormalBlending as kd,RepeatWrapping as Dd,Box3 as Ad}from"three";import{ShaderLib as Ss,ShaderMaterial as Sd,UniformsLib as Es,UniformsUtils as Rr,Vector2 as Ir}from"three";Es["custom-line"]={linewidth:{value:1},resolution:{value:new Ir(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1},repeat:{value:new Ir(1,1)},allDistance:{value:1}};Ss["custom-line"]={uniforms:Rr.merge([Es.common,Es.fog,Es["custom-line"]]),vertexShader:`
509
509
  #include <common>
510
510
  #include <color_pars_vertex>
511
511
  #include <fog_pars_vertex>
@@ -698,4 +698,4 @@ var ra=Object.create;var Gs=Object.defineProperty;var aa=Object.getOwnPropertyDe
698
698
  float uvx = prevUv + (vUv.y + 1.0) / 2.0 * vCustomUv;
699
699
  gl_FragColor = diffuseColor * texture2D(map, vec2(uvx, (vUv.x + 1.0) / 2.0) * repeat);
700
700
  }
701
- `};var Ls=class extends Sd{constructor(t){super({type:"ArrowLineMaterial",uniforms:Object.assign({},Rr.clone(Ss["custom-line"].uniforms),{map:{value:null}}),vertexShader:Ss["custom-line"].vertexShader,fragmentShader:Ss["custom-line"].fragmentShader,clipping:!0}),this.dashed=!1,Object.defineProperties(this,{map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(e){this.uniforms.map.value=e}},color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(e){this.uniforms.repeat.value.copy(e)}},allDistance:{enumerable:!0,get:function(){return this.uniforms.allDistance.value},set:function(e){this.uniforms.allDistance.value=e}}}),this.setValues(t),this.isLineMaterial=!0}};import{LineGeometry as Od}from"three/examples/jsm/lines/LineGeometry.js";import{Line2 as Id}from"three/examples/jsm/lines/Line2.js";var Gr={texture_url:Pi,lineWidth:8,color:16777215},Cs=class extends Ed{registryEvent(){this.navigation.bmap.context.addEventListener("control-change",this.onControlChange),this.navigation.bmap.context.addEventListener("update",this.onUpdate),this.navigation.bmap.context.addEventListener("resize",this.onResize)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("control-change",this.onControlChange),this.navigation.bmap.context.removeEventListener("update",this.onUpdate),this.navigation.bmap.context.removeEventListener("resize",this.onResize)}getRepeat(){let{points:t,navigation:{bmap:{context:{camera:e,clientSize:{width:i,height:s}}}}}=this,o=t.map(r=>{let[h,c,l]=r;return C(new Td(h,c,l),e,i,s)}).map(r=>{let{x:h,y:c}=r;return[h,c]});return ht(o)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new bo(t,1)}loadTexture(t){return new Promise((e,i)=>{new Ld().load(t,e,void 0,i)})}transformPoints(t){let e=[];for(let i=0;i<t.length;i++)e.push(...t[i]);return e}updatePoints(t){if(this.points=t,this.mesh){var e,i;this.remove(this.mesh),(e=this.material)==null||e.dispose(),(i=this.geometry)==null||i.dispose()}this.geometry=new Od,this.geometry.setPositions(t.flat(2));let s=ht(t.map(r=>{let[h,c]=r;return[h,c]})),o=this.material=new Ls({color:new Cd(this.config.color),transparent:!0,resolution:new bo(this.navigation.bmap.context.clientSize.width,this.navigation.bmap.context.clientSize.height),depthTest:!0,depthWrite:!0,linewidth:this.config.lineWidth,map:this.texture,blending:kd,repeat:new bo(this.getRepeat(),1),allDistance:s}),n=this.mesh=new Id(this.geometry,o);return n.computeLineDistances(),n.renderOrder=9,this.add(n),n}movePath(t){this.material&&(this.material.thresholdRatio=t)}create(t){return f(this,null,function*(){if(!this.texture){let e=this.texture=yield this.loadTexture(this.config.texture_url);e.wrapS=e.wrapT=Dd}return this.updatePoints(t)})}getBoundingBox(){return this.mesh?(this.mesh.geometry.computeBoundingBox(),new Ad().copy(this.mesh.geometry.boundingBox).applyMatrix4(this.mesh.matrixWorld)):null}dispose(){var t,e,i;this.unRegistryEvent(),this.clear(),(t=this.geometry)==null||t.dispose(),(e=this.material)==null||e.dispose(),(i=this.texture)==null||i.dispose(),this.navigation=null}constructor(t,e){super(),this.navigation=t,this.mesh=null,this.geometry=null,this.material=null,this.texture=null,this.config=Gr,this.points=[],this.basicRepeat=1,this.prevCameraZoom=0,this.onControlChange=()=>{let i=this.navigation.bmap.context.camera.zoom;i!==this.prevCameraZoom&&(this.prevCameraZoom=i,this.changeRepeat())},this.onUpdate=()=>{this.texture},this.onResize=()=>{if(this.material){let{width:i,height:s}=this.navigation.bmap.context.clientSize;this.material.resolution.set(i,s)}},this.config=Object.assign({},Gr,e),this.registryEvent(),this.prevCameraZoom=this.navigation.bmap.context.camera.zoom}};import{Tween as Wd}from"@tweenjs/tween.js";import{AnimationMixer as Rd,Box3 as Gd,Object3D as Fr,Vector3 as Fd,Mesh as zd,Euler as Bd}from"three";var Ts=class extends Fr{meshSetMaterial(t){t instanceof zd&&(t.material.emissiveIntensity=.5,t.material.shininess=0,t.material.emissive=t.material.color,t.material.emissiveMap=t.material.map,t.material.transparent=!0,t.material.depthTest=!1,t.renderOrder=1e6),t.children.forEach(i=>{this.meshSetMaterial(i)})}getBaseScale(t){let{clientSize:{height:e},camera:i}=this.bmap.context,o=(i.top-i.bottom)/i.zoom/e;return this.options.size*o/this.modelMaxLength}registryEvent(){this.bmap.context.addEventListener("update",this._update),this.bmap.context.addEventListener("control-zoom-change",this._onChangeZoom)}unRegistryEvent(){this.bmap.context.removeEventListener("update",this._update),this.bmap.context.removeEventListener("control-zoom-change",this._onChangeZoom)}lookAtCamera(){if(this.model&&this.bmap&&this.bmap.context){let t=this.bmap.context.camera,e=new Bd;e.setFromQuaternion(t.quaternion,"ZYX"),this.group.rotation.copy(e)}}setClips(t){this.clearClips(),t.length&&(this.mixer=new Rd(this.model.scene),t.forEach(e=>this.mixer.clipAction(e).play()))}startClips(){var t;this.setClips(((t=this.model)==null?void 0:t.animations)||[])}clearClips(){this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),this.mixer=null)}dispose(){this.unRegistryEvent(),this.clearClips(),this.clear(),this.model&&D(this.model.scene),this.bmap=null}constructor(t,e,i={}){super(),this.bmap=t,this.group=new Fr,this.mixer=null,this.previewTime=0,this.modelMaxLength=0,this.options={size:40},this._update=()=>{let s=Date.now();if(!this.previewTime)this.previewTime=s;else{var o;let n=s-this.previewTime;this.previewTime=s,(o=this.mixer)==null||o.update(n/1e3)}this.lookAtCamera()},this._onChangeZoom=s=>{let{zoom:o}=s;var n;if(!this.model)return;let r=this.getBaseScale(this.model.scene);(n=this.model)==null||n.scene.scale.set(r,r,r)},this.options=w({},this.options,i),this.add(this.group),st.loadModel(e,!1).then(s=>{this.model=s;let n=new Gd().setFromObject(s.scene).getSize(new Fd),r=Math.max(n.x,n.y,n.z);this.modelMaxLength=r;let h=this.getBaseScale(s.scene);s.scene.scale.set(h,h,h),this.meshSetMaterial(s.scene),this.group.add(s.scene),this.setClips(s.animations),this.group.rotation.set(Math.PI/2,Math.PI,0),this.dispatchEvent({type:"loaded"})}),this.registryEvent()}};import{Vector3 as So}from"three";var zr=class extends B{registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate)}pauseAnimation(){this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue()}clearTween(){this.tweenUtil.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate)}clearPath(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.movedDistance=0,this.clearTween()),this.startModel&&(this.startModel.visible=!1),this.translatePath=null}addPath(t){this.paths=t;let e=t.map(i=>w({},i,{points:this.translatePoints(i.points)}));if(this.clearTween(),this.movedDistance=0,this.bmap.currentBuildGround)this.renderPath(e);else{let i=()=>{this.bmap.removeEventListener("center-change",i),this.renderPath(e)};this.bmap.addEventListener("center-change",i)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,i]=this.bmap.buildingCenter;return t.map(s=>[s[0]-e,s[1]-i])}renderPath(t){return f(this,null,function*(){if(!t.length)return this.clearPath();let e=[];t.forEach((i,s,o)=>{let n=this.mulFloor.floors.find(r=>r.name===i.floor);e.push(...i.points.map(r=>{let[h,c]=r;return[h,c,n.position.z+n.groundMaxHeight]}))}),this.cPath=e,this.animationPathOptions={cPathIndex:0},this.path?this.path.updatePoints(e):(this.path=new Cs(this),yield this.path.create(e),this.path.position.z=.5,this.bmap.context.scene.add(this.path)),this.startModel&&(this.startModel.position.set(e[0][0],e[0][1],e[0][2]),this.startModel.visible=!0),this.dispatchEvent({type:"render-path",path:this.path})})}catmullRomCurve3(t){return mi(t,!1,!0,.1,170,2.5)}getPathDirection(t,e){if(t.length<2)return null;let i=Bt(t,e),s=t[i],o=t[i+1],n=new So(o[0]-s[0],o[1]-s[1],0).normalize(),r=new So(0,1,0).normalize(),h=n.angleTo(r),c=new So().crossVectors(r,n);return(Object.is(c.y,0)?-1:1)*h}startSimulation(t){return f(this,null,function*(){t===void 0&&(t=1);let{paths:e,movedDistance:i}=this;if(!e.length)return;let s=e.reduce((n,r)=>n+r.distance,0);if(!s||i>=s)return;this.simulationTween&&this.tweenUtil.remove(this.simulationTween);let o=s/t;return this.startModel.startClips(),new Promise(n=>{let r=this.simulationTween=new Wd({distance:this.movedDistance},this.tweenUtil.group).to({distance:s},o*1e3).onUpdate(h=>{var c;this.movedDistance=h.distance;let l=h.distance,p=0;for(let g=0;g<e.length;g++)if(e[g].distance>=l){p=g;break}else l-=e[g].distance;let d=ve(e[p].points,l);if(d===null)return;this.currentPathPosition=d;let u=this.translatePoints([d])[0],m=this.mulFloor.floors.find(g=>g.name===e[p].floor),v=m?m.position.z+m.groundMaxHeight:(c=this.startModel)==null?void 0:c.position.z;this.startModel&&this.startModel.position.set(u[0],u[1],v)}).onComplete(()=>{if(this.tweenUtil.remove(r),this.startModel.clearClips(),this.startModel){var h,c,l,p;let d=(l=e.slice(-1)[0])==null||(c=l.points)==null||(h=c.slice(-1))==null?void 0:h[0];if(!d)return;let u=this.mulFloor.floors.find(g=>{var x;return g.name===((x=e.slice(-1)[0])==null?void 0:x.floor)});if(!u)return;let m=u?u.position.z+u.groundMaxHeight:(p=this.startModel)==null?void 0:p.position.z,v=this.translatePoints([d])[0];this.startModel.position.set(v[0],v[1],m)}n(!0)}).start()})})}setStartPoiRotate(t){if(this.startPoi){let i=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360;this.startPoi.options.icon_rotate=(360-t-i)%360}}dispose(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.startModel&&(this.bmap.context.scene.remove(this.startModel),this.startModel.dispose()),this.tweenUtil.dispose(),this.unRegistryEvent(),super.dispose()}constructor(t,e,i={}){super(t),this.mulFloor=e,this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.pathTween=null,this.startPoi=null,this.movedDistance=0,this.tweenUtil=new Qt,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onUpdate=()=>{this.tweenUtil.update()},this.startModel=new Ts(t,Dn,i.startModel),this.startModel.visible=!1,this.bmap.context.scene.add(this.startModel),this.registryEvent()}};import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{Raycaster as Ud,Vector2 as Hd}from"three";var Br=class extends B{registryEvent(){this.clickHelper.addEventListener("click",this._click)}unRegistryEvent(){this.clickHelper.removeEventListener("click",this._click)}dispose(){this.unRegistryEvent(),this.clickHelper.dispose(),this.mulFloors=null,super.dispose()}constructor(t,e){super(t),this.mulFloors=e,this._click=i=>{let{e:s}=i;if(!this.mulFloors.showStatus)return;let o=new Hd,{offsetX:n,offsetY:r}=s,h=this.mulFloors.floors.map(d=>d.poiLayer2.getPoiByDeviceXy(n,r)).flat(2),{clientSize:c}=this.bmap.context;o.x=n/c.width*2-1,o.y=r/c.height*-2+1;let l=new Ud;l.setFromCamera(o,this.bmap.context.camera),l.ray.origin.sub(l.ray.direction.clone().multiplyScalar(1e4));let p=this.mulFloors.floors.map(d=>d.graphicLayer.getGraphicByRaycaster(l).graphics).flat();this.dispatchEvent({type:"select",pois:h,graphics:p})},this.clickHelper=new yi(this.bmap.context.container),this.registryEvent()}};import"core-js/modules/es.array.find-last-index.js";import"core-js/modules/es.array.find-last.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.sort.js";import{Vector2 as si}from"three";function Nd(a){let t=a.length,e=0,i=0,s=0,o=0;a.forEach(h=>{e+=h[0],i+=h[1],s+=h[0]*h[1],o+=h[0]*h[0]});let n=(t*s-e*i)/(t*o-e*e),r=(i-n*e)/t;return{m:n,b:r}}function Zd(a,t,e){let i=e[0][0],s=e.slice(-1)[0][0],o=a*i+t,n=a*s+t;return{start:[i,o],end:[s,n]}}function ks(a){if(a.length<2)return null;let t=a.filter((h,c)=>{let l=[...a];return l.splice(c,1),l.every(p=>p[0]!==h[0]&&p[1]!==h[1])});if(t.length<2)return null;let{m:e,b:i}=Nd(t),{start:s,end:o}=Zd(e,i,t),r=360-(new si().subVectors(new si(o[0],o[1]),new si(s[0],s[1])).angle()/Math.PI*180-90+360)%360;return Number.isNaN(r)?null:r}function lC(a){let t=[];for(let e=1;e<a.length;e++){let i=a[e-1],s=a[e],o=s.position[0]-i.position[0],n=s.position[1]-i.position[1],r=Math.sqrt(o**2+n**2),h=s.time-i.time;if(h>0){let c=r/h;console.log("speedDelta",i.type,s.type,Eo(c),r,h),t.push(c)}else t.push(0)}return t}function pC(a,t){let e=a[0],i=a.slice(-1)[0],s=k(i.position,e.position),o=i.time-e.time;return o<100||s<3?null:s/o}function Eo(a){return a*60*60}function oi(a,t,e,i){let s=(e+90)%360*(Math.PI/180),o=t*i,n=new si(a[0],a[1]),r=Math.cos(s),h=Math.sin(s),c=new si(r,h);return n.add(c.normalize().multiplyScalar(o)),[n.x,n.y]}function dC(a){let t=[...a].sort((c,l)=>c-l),e=Wr(t,25),i=Wr(t,75),s=i-e,o=e-1.5*s,n=i+1.5*s,r=t.filter(c=>c>=o&&c<=n);return a.filter(c=>r.includes(c))}function Wr(a,t){let e=t/100*(a.length-1),i=Math.floor(e),s=Math.ceil(e);if(i===s)return a[i];let o=e-i;return a[i]*(1-o)+a[s]*o}import{isNil as Ds}from"lodash";var As=class extends X{setPathAngle(t){this.pathAngle=t,this.dispatchEvent({type:"change-compass",value:this.pathAngle}),Ds(this.angle)&&(this.angle=t)}changeSpeed(){let t=this.history.filter(h=>["vision"].includes(h.type));if(t.length<2){this.speedFilter.filter(0),this.speed=0;return}let e=t[0],i=t.slice(-1)[0],s=k(i.position,e.position),o=i.time-e.time,n=o>0?s/o:0,r=this.speedFilter.filter(n);this.speed=r}changeAngle(t){t===void 0&&(t=this.visionHistory),t.length<2&&(this.angle=null);let e=ks(t.map(i=>i.position));e!==null&&this.setAngle(e)}setAngle(t,e){e===void 0&&(e=!0),this.angle=t,e&&this.dispatchEvent({type:"change-position-compass",value:t})}setPosition(t,e,i){let s={position:t,time:e,clientTime:Date.now()-i,type:"vision"};if(this._setVisionHistoryForAngle(s),Ds(this.angle)||!this.speed){this.addHistory(s);return}let o=this.history.findLastIndex(r=>r.type==="vision"),n=this.history[o];if(n){if(n.time>e)return;let r=ks([this.history.slice(-1)[0].position,t]);if(r&&Math.abs(r-this.angle)<60){this.addHistory(s);return}let h=oi(t,this.speed,360-this.pathAngle,i);k(h,this.history.slice(-1)[0].position)>5?this.visionExcessesCount++:this.visionExcessesCount=0,this.visionExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21\u89C6\u89C9\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528\u89C6\u89C9\u6821\u51C6"),this.addHistory(s),this.visionExcessesCount=0)}}resetPdrPosition(){let t=this.history.findLast(e=>e.type==="vision");if(t&&this.speed){let e=oi(t.position,this.speed,360-this.pathAngle,Date.now()-t.clientTime);e&&this.history.push({position:e,time:Date.now(),clientTime:Date.now(),type:"pdr"})}}getLastVisionPdrPos(){let t=this.history.findLastIndex(i=>i.type==="vision");if(t!==-1){var e;return(e=this.history[t+1])!=null?e:this.history[t]}return null}_setVisionHistoryForAngle(t){if(!this.visionHistory.length){this.visionHistory.push(t);return}let e=ks([this.visionHistory.slice(-1)[0].position,t.position]);if(e!==null&&(this.angle&&Math.abs(this.angle-e)>60?this.angleExcessesCount++:(this.angleExcessesCount=0,this.visionHistory.push(t))),this.angleExcessesCount>3)console.warn("\u8FDE\u7EED\u4E09\u6B21\u89D2\u5EA6\u6BD4\u8F83\u6B6A\uFF0C\u91CD\u65B0\u77EB\u6B63"),this.visionHistory=[t],this.angleExcessesCount=0;else{let i=k(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position);for(;i>5&&this.visionHistory.length>15;)this.visionHistory.shift(),i=k(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position)}this.changeAngle()}addHistory(t){this.history.push(t);let e=this.history.filter(r=>r.type==="vision"),i=e.length?Date.now()-e.slice(-1)[0].clientTime:0,s=k(this.history[0].position,this.history.slice(-1)[0].position),o=i>5e3?10:3,n=i>5e3?0:5;for(i>5e3&&console.warn("\u89C6\u89C9\u7ED3\u679C\u8D85\u51FA5s\u4E0D\u53EF\u7528\uFF0C\u5168\u90E8\u6E05\u7A7A");e.length>n&&s>o;)this.history.shift(),e=this.history.filter(r=>r.type==="vision"),s=k(this.history[0].position,this.history.slice(-1)[0].position);n===0?this.changeSpeed():t.type==="vision"&&this.changeSpeed(),this.changePosition(t.type)}setBeaconPosition(t,e,i){let s=Date.now()-i,o={position:t,time:e,clientTime:s,type:"beacon"},n=this.history.findLastIndex(l=>l.type!=="pdr"),r=this.history[n];if(!r){this.addHistory(o);return}if(Ds(this.pathAngle)||!this.speed){this.addHistory(o);return}if(r&&r.time>e)return;let h=oi(t,this.speed,360-this.pathAngle,i);k(h,this.history.slice(-1)[0].position)>5?this.beaconExcessesCount++:this.beaconExcessesCount=0,this.beaconExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21beacon\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528beacon\u6821\u51C6"),this.addHistory(o),this.beaconExcessesCount=0)}startPositionTimer(){this.positionTimer&&this.timer.clearInterval(this.positionTimer),this.positionTimer=this.timer.setInterval(()=>{this.changePosition()},20)}stopPositionTimer(){this.positionTimer&&(this.timer.clearInterval(this.positionTimer),this.positionTimer=null)}changePosition(t){t===void 0&&(t="pdr");let e=this.getPosition(t);e.success&&(this.history.push({position:e.pos,time:Date.now(),clientTime:Date.now(),type:"pdr"}),this.speed?this.dispatchEvent({type:"change-pos",value:w({},e)}):this.dispatchEvent({type:"change-pos",value:e}))}getPosition(t){if(this.history.length===0)return{success:!1,pos:[0,0],compass:null,speed:0};let e=this.history.slice(-1)[0];if(this.history.length<2)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};if(Ds(this.pathAngle)||!this.speed)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};let i=e.clientTime,s=Date.now()-i;return{success:!0,pos:this.pathAngle?oi(e.position,this.speed,360-this.pathAngle,s):e.position,compass:this.pathAngle,speed:Eo(this.speed)}}dispose(){this.timer.dispose()}constructor(){super(),this.history=[],this.visionHistory=[],this.speed=0,this.angle=null,this.timer=new z,this.positionTimer=null,this.speedFilter=new xi,this.visionExcessesCount=0,this.beaconExcessesCount=0,this.angleExcessesCount=0,this.pathAngle=0,this.startPositionTimer()}};import"core-js/modules/es.json.stringify.js";function Lo(){return new Worker(new URL("./worker/recommend.worker-SNFR5ZXU.js",import.meta.url))}var jd={placeId:0,catLotStatusApi:"https://vrapi.aibee.cn/parking/cat-lot-status"},Ur=class{setRoadData(t,e){return F(this.worker,"set_road_info",{roadData:t,facilities:e})}recommend(t){return f(this,null,function*(){let e=yield fetch(this.options.catLotStatusApi,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({place_id:+this.options.placeId})}).then(i=>i.json()).then(i=>i.data.filter(s=>s.status===0)).then(i=>{var s;return i.filter((s=this.options.filterCarLotStatus)!=null?s:()=>!0)});return F(this.worker,"recommend",w({},t,{carLotStatus:e}))})}dispose(){this.worker.terminate()}constructor(t={}){this.worker=Lo(),this.options=w({},jd,t)}};import"core-js/modules/es.json.stringify.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.sort.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/web.url-search-params.js";import"core-js/modules/web.url-search-params.delete.js";import"core-js/modules/web.url-search-params.has.js";import"core-js/modules/web.url-search-params.size.js";import"core-js/modules/es.json.stringify.js";var Vd={url:"",reconnect:!0,heartBeat:2e3,heartMsg:JSON.stringify({command:"PING"}),reconnectTime:3e3,reconnectMaxCount:1e6,noMessageTime:6e3},ni=class extends X{initWebsocket(){this.ws=new WebSocket(this.options.url),this.ws.onopen=()=>{this.alive=!0,this.startHeart(),this.startOnMessageTimer(),this.stopReconnect(),this.dispatchEvent({type:"open"})},this.ws.onerror=()=>{this.alive=!1,this.ws=null,this.stopHeart(),this.stopOnMessageTimer(),this.startReconnect(),this.registryEvent()},this.ws.onclose=()=>{this.alive=!1,this.ws=null,this.stopHeart(),this.stopOnMessageTimer(),this.startReconnect()},this.ws.onmessage=t=>{this.startOnMessageTimer(),this.dispatchEvent({type:"message",message:t})}}startHeart(){this.stopHeart(),this.heartTimer=this.timer.setInterval(()=>{this.send(this.options.heartMsg)&&this.dispatchEvent({type:"send-heart"})},this.options.heartBeat)}stopHeart(){this.heartTimer&&(this.timer.clearInterval(this.heartTimer),this.heartTimer=null)}startReconnect(t){t===void 0&&(t=this.options.reconnectTime),this.stopReconnect(),this.options.reconnect&&(this.options.reconnectMaxCount--,this.options.reconnectMaxCount>=0&&(this.reconnectTimer=this.timer.setTimeout(()=>{this.initWebsocket()},t)))}stopReconnect(){this.reconnectTimer&&(this.timer.clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}startOnMessageTimer(){this.stopOnMessageTimer(),this.noMessageTimer=this.timer.setTimeout(()=>{var t;(t=this.ws)==null||t.close(),this.dispatchEvent({type:"no-message-timeout"})},this.options.noMessageTime)}stopOnMessageTimer(){this.noMessageTimer&&(this.timer.clearTimeout(this.noMessageTimer),this.noMessageTimer=null)}send(t){var e;let i=typeof t=="string"?t:JSON.stringify(t);return this.alive&&((e=this.ws)==null?void 0:e.readyState)===1?(this.ws.send(i),this.dispatchEvent({type:"send-success",msg:i}),!0):(this.dispatchEvent({type:"send-fail",msg:i}),!1)}registryEvent(){window.addEventListener("online",this.onOnline)}unRegistryEvent(){window.removeEventListener("online",this.onOnline)}close(){var t;this.unRegistryEvent(),this.options.reconnect=!1,this.alive=!1,this.stopHeart(),this.stopReconnect(),this.stopOnMessageTimer(),(t=this.ws)==null||t.close(),this.ws=null,this.dispatchEvent({type:"close"})}dispose(){this.close(),this.timer.dispose(),super.dispose()}constructor(t){super(),this.ws=null,this.alive=!1,this.timer=new z,this.heartTimer=null,this.reconnectTimer=null,this.noMessageTimer=null,this.onOnline=()=>{this.startReconnect()},this.options=w({},Vd,t||{}),this.options.url&&this.initWebsocket()}};import{isNil as Hr}from"lodash";var Co=a=>{let t=a.toString(2),e=""+Array(16-t.length+1).join("0")+t,i=parseInt(e.slice(0,4),2)*10,s=parseInt(e.slice(4,16),2);return[i,s]};var Nr=class extends X{initPositionWebSocket(){let t=w({},this.options.ext_position_params,{place_id:this.options.place_id,token:this.options.access_token}),e=Object.keys(t).filter(i=>!Hr(t[i])).map(i=>i+"="+t[i]).join("&");this.positionWebSocket=new ni({url:this.options.wss_position_url+"?"+e}),this.positionWebSocket.addEventListener("message",i=>{let{message:s}=i,o=(()=>{try{return JSON.parse(s.data)}catch(I){return s.data}})();if(this.dispatchEvent({type:"ws-message",data:o}),o.command==="POSITION_RESULT"&&o.data.success)if(["POSITION","FLOOR","PARK_POSITION","AOA"].includes(o.data.success_type)&&this.useGpsFloorTimer&&(this.positionFloor=o.data.floor,this.timer.clearTimeout(this.useGpsFloorTimer),this.useGpsFloorTimer=null),o.data.success_type==="AOA"){let{x:I,y:R,time:N,floor:W,ts:Et}=o.data,Lt=this.positionFloor!==W;if(this.positionFloor=W,this.dispatchEvent({type:"ws-position",floor:W,x:I,y:R,time:N,_type:"aoa"}),this.options.upload_position){var n;(n=this.positionWebSocket)==null||n.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:I,y:R,floor:W,type:"aoa"}),serverData:JSON.stringify(o)})}if(!this.options.use_pdr){this.dispatchEvent({type:"position",floor:W,x:I,y:R,time:new Date(Et).getTime()-o.lag-o.duration});return}if(this.options.type!==1){var r;if(Lt){var h,c,l;(l=this.pdrPosition)==null||(c=l.pdr)==null||(h=c.particleFilter)==null||h.setPosInitFlag(!1)}(r=this.pdrPosition)==null||r.setBeaconPosition({x:I,y:R},new Date(Et).getTime()-o.lag-o.duration)}else if(Lt){var p;if(this.resetPdr(),(p=this.carInertialPosition)==null||p.stopPositionTimer(),this.path){let Xt=this.path.findIndex(Fe=>Fe.floor===W),It=this.path[Xt];if(It){var d;this.resetPdr(),(d=this.carInertialPosition)==null||d.setBeaconPosition(It.points[0],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}else{var u;(u=this.carInertialPosition)==null||u.setBeaconPosition([I,R],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var m;(m=this.carInertialPosition)==null||m.setBeaconPosition([I,R],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var v;(v=this.carInertialPosition)==null||v.setBeaconPosition([I,R],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}}else if(o.data.success_type==="POSITION"){let{x:I,y:R,time:N,floor:W,ts:Et}=o.data,Lt=this.positionFloor!==W;if(this.positionFloor=W,this.dispatchEvent({type:"ws-position",floor:W,x:I,y:R,time:N,_type:"beacon"}),console.log("positionFloor",W,Lt),this.options.upload_position){var g;(g=this.positionWebSocket)==null||g.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:I,y:R,floor:W,type:"originBeacon"}),serverData:JSON.stringify(o)})}if(!this.options.use_pdr){this.dispatchEvent({type:"position",floor:W,x:I,y:R,time:new Date(Et).getTime()-o.lag-o.duration});return}if(this.options.type!==1){var x;if(Lt){var M,P,E;(E=this.pdrPosition)==null||(P=E.pdr)==null||(M=P.particleFilter)==null||M.setPosInitFlag(!1)}(x=this.pdrPosition)==null||x.setBeaconPosition({x:I,y:R},new Date(Et).getTime()-o.lag-o.duration)}else if(Lt){var b;if(this.resetPdr(),(b=this.carInertialPosition)==null||b.stopPositionTimer(),this.path){let Xt=this.path.findIndex(Fe=>Fe.floor===W),It=this.path[Xt];if(It){var A;this.resetPdr(),(A=this.carInertialPosition)==null||A.setBeaconPosition(It.points[0],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}else{var S;(S=this.carInertialPosition)==null||S.setBeaconPosition([I,R],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var V;(V=this.carInertialPosition)==null||V.setBeaconPosition([I,R],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var rt;(rt=this.carInertialPosition)==null||rt.setBeaconPosition([I,R],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}}else if(o.data.success_type==="PARK_POSITION"&&o.data.success){if(this.options.type===1){let{x:I,y:R,time:N,floor:W}=o.data,Et=this.positionFloor!==W;if(this.positionFloor=o.data.floor,this.dispatchEvent({type:"ws-position",floor:W,x:I,y:R,time:N,_type:"vision"}),!this.options.use_pdr){this.dispatchEvent({type:"position",floor:W,x:I,y:R,time:new Date(N).getTime()});return}if(Et){var Q;if(this.resetPdr(),(Q=this.carInertialPosition)==null||Q.stopPositionTimer(),this.path){let Lt=this.path.findIndex(It=>It.floor===W),Xt=this.path[Lt];if(Xt){var lt;this.resetPdr(),(lt=this.carInertialPosition)==null||lt.setPosition(Xt.points[0],new Date(N).getTime(),o.duration)}else{var at;(at=this.carInertialPosition)==null||at.setPosition([I,R],new Date(N).getTime(),o.duration)}}else{var St;(St=this.carInertialPosition)==null||St.setPosition([I,R],new Date(N).getTime(),o.duration)}}else{var Kt,q;if((Kt=this.carInertialPosition)==null||Kt.setPosition([I,R],new Date(N).getTime(),o.duration),!((q=this.carInertialPosition)!=null&&q.positionTimer)){var ue;(ue=this.carInertialPosition)==null||ue.startPositionTimer()}}if(this.options.upload_position){var Ge;(Ge=this.positionWebSocket)==null||Ge.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:I,y:R,floor:W,type:"vision"}),serverData:JSON.stringify(o)})}}}else this.dispatchEvent({type:"floor",floor:o.data.floor,time:o.data.time})})}initSensorWebSocket(){let t=w({},this.options.ext_sensor_params,{token:this.options.access_token,place_id:this.options.place_id,record_sensor:1}),e=Object.keys(t).filter(i=>!Hr(t[i])).map(i=>i+"="+t[i]).join("&");this.sensorWebSocket=new ni({url:this.options.wss_sensor_url+"?"+e})}initPdr(){this.options.type===1?(this.carInertialPosition=new As,this.carInertialPosition.addEventListener("change-pos",t=>{let{value:e}=t,{pos:i,success:s,speed:o}=e;if(s&&(this.dispatchEvent({type:"position",floor:this.positionFloor,x:i[0],y:i[1],time:Date.now(),speed:o}),this.options.upload_position)){var n;(n=this.positionWebSocket)==null||n.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:i[0],y:i[1],floor:this.positionFloor,type:"vision_pdr"})})}}),this.carInertialPosition.addEventListener("change-compass",t=>{let{value:e}=t;this.dispatchEvent({type:"compass",value:e})})):(this.pdrPosition=new bs(this.bmap,{pdr:{using_gps:this.options.use_gps},sensor:{elements:[O.COMPASS,O.ACCELERATION,O.DEVICE_MOTION].concat(this.options.use_gps?[O.GPS]:[])}}),this.requestDeviceOrientationPermission(),this.options.upload_position&&this.pdrPosition.sensor.addEventListener("sensor-data",t=>{let{data:e}=t;var i;(i=this.positionWebSocket)==null||i.send({command:"UPLOAD_SENSOR",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify(e)})}),this.pdrPosition.sensor.addEventListener("add-data-item",t=>{t.item.type==="compass"&&this.dispatchEvent({type:"compass",value:t.item.res})}),this.pdrPosition.addEventListener("position",t=>{let{x:e,y:i,_type:s}=t;if(console.log("_type",s,e,i,this.positionFloor,this.gpsFloor),s==="gps"&&!this.useGpsFloorTimer){let n=()=>{this.useGpsFloorTimer=this.timer.setTimeout(()=>{this.gpsFloor?this.positionFloor=this.gpsFloor:n()},5e3)};n()}if(this.positionFloor&&(this.dispatchEvent({type:"position",floor:this.positionFloor,x:e,y:i,time:Date.now()}),this.options.upload_position)){var o;(o=this.positionWebSocket)==null||o.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:e,y:i,floor:this.positionFloor,type:s})})}}))}setSensor(t){this.pdrPosition&&this.pdrPosition.setSensor(t)}requestDeviceOrientationPermission(){return f(this,null,function*(){if(this.pdrPosition){let t=yield this.pdrPosition.checkSensor();return t.deviceOrientation?this.pdrPosition.start():(this.dispatchEvent(w({type:"check-sensor"},t)),!t.deviceOrientation&&this.options.use_default_permission),t}else return null})}getGpsFloor(){return f(this,null,function*(){if(this.options.use_gps&&this.options.get_gps_floor_url){let t=yield fetch(this.options.get_gps_floor_url+"/"+this.options.place_id).then(e=>e.json());t.code===200&&(this.gpsFloor=t.data.gps_floor)}})}pausePdr(){if(this.options.type===1){var t;(t=this.carInertialPosition)==null||t.stopPositionTimer()}else{var e;(e=this.pdrPosition)==null||e.pause()}}continuePdr(){if(this.options.type===1)this.carInertialPosition&&(this.carInertialPosition.positionTimer||this.carInertialPosition.startPositionTimer());else{var t;(t=this.pdrPosition)==null||t.continue()}}setPathAngle(t){if(this.options.type===1){var e;(e=this.carInertialPosition)==null||e.setPathAngle(t)}}getForwardAngle(){if(this.options.type===1){var t,e;return(e=(t=this.carInertialPosition)==null?void 0:t.angle)!=null?e:null}else return null}resetPdr(){this.carInertialPosition&&(this.carInertialPosition.history=[],this.carInertialPosition.setPathAngle(0),this.carInertialPosition.speed=0),this.pdrPosition&&this.pdrPosition.pdr.particleFilter.setPosInitFlag(!1)}setPath(t){this.path=t}sendBeacon(t){var e;let i=[];if(Ut)i=t.map(o=>{let[n,r]=Co(o.major);return[o.uuid,r,o.minor,o.rssi,o.accuracy,n]}).filter(o=>o[3]!==0).sort((o,n)=>n[3]-o[3]);else{let o=t.reduce((n,r)=>{var h,c;let[l,p]=Co(r.major),d=""+p+r.minor;return(h=n)[c=d]||(h[c]=[]),n[d].push(w({},r,{battery:l,major:p})),n},{});Object.entries(o).forEach(n=>{let[r,h]=n,{uuid:c,major:l,minor:p,accuracy:d,battery:u}=h[0];if(h.length>1){let m=h.filter(g=>g.rssi<0),v=m.reduce((g,x)=>g+x.rssi,0);i.push([c,l,p,v/m.length,d,u])}else i.push([c,l,p,h[0].rssi,d,u])})}let s={command:"POSITION",index:this.uploadIndex++,ts:Date.now(),beacons:JSON.stringify([{type:"ibeacon",timestamp:Date.now()/1e3,res:i}]),ext_sensors:JSON.stringify({})};(e=this.sensorWebSocket)==null||e.send(s)}dispose(){var t,e,i,s;this.timer.dispose(),(t=this.positionWebSocket)==null||t.dispose(),this.positionWebSocket=null,(e=this.sensorWebSocket)==null||e.dispose(),this.sensorWebSocket=null,(i=this.pdrPosition)==null||i.dispose(),this.pdrPosition=null,(s=this.carInertialPosition)==null||s.dispose(),this.carInertialPosition=null,super.dispose()}constructor(t,e){super(),this.bmap=t,this.positionWebSocket=null,this.sensorWebSocket=null,this.pdrPosition=null,this.carInertialPosition=null,this.gpsFloor="",this.positionFloor="",this.useGpsFloorTimer=null,this.uploadIndex=0,this.path=null,this.timer=new z;let i=location.href.indexOf("?"),s=i!==-1?location.href.slice(i):location.search,o=new URLSearchParams(s),n=o.get("server_env")||"prod",r={test:"nav-test.aibee.cn",prod:"nav.aibee.cn"},h="wss://"+r[n]+"/aether-walker/indoor/position",c="wss://"+r[n]+"/aether-walker/indoor/sensor";this.options=w({place_id:o.get("place_id"),access_token:o.get("access_token"),env:n,wss_position_url:h,wss_sensor_url:c,get_gps_floor_url:"https://"+r[n]+"/aether-walker/indoor/conf",use_sensor:!1,type:-1,use_gps:!0,use_pdr:!0,upload_position:!0,use_default_permission:!0,ext_position_params:{},ext_sensor_params:{}},e),this.initPositionWebSocket(),this.options.use_sensor&&this.initSensorWebSocket(),this.options.use_pdr&&this.initPdr(),this.options.use_gps&&this.getGpsFloor()}};import"core-js/modules/web.dom-collections.iterator.js";var Zr=class extends B{showMyPosition(t,e){var i;let s=(i=this.bmap.context.currentFloor)==null?void 0:i.getGraphicPosition(t);if(s){let o=new be(this.bmap.context,{autoUpdate:!0,appendToBody:!1});o.div.appendChild(e),o.position.copy(this.bmap.mercatorToWorld(s)),this.myPositionOverlay=o,console.log("graphicPos",s,this)}else console.warn("[showMyPosition] \u6CA1\u6709\u627E\u5230\u56FE\u5143\u6240\u5728\u7684\u4F4D\u7F6E")}hideMyPosition(){this.myPositionOverlay&&(this.myPositionOverlay.dispose(),this.myPositionOverlay=null)}dispose(){this.hideMyPosition()}constructor(...t){super(...t),this.myPositionOverlay=null}};var jr=class extends B{highlightPoi(t,e){e===void 0&&(e={icon_size:[40,40],collision_enable:!1}),t.map(s=>this.bmap.getPoiById(s)).filter(s=>!!s).forEach(s=>{var o;(o=s.userData).restore||(o.restore={});for(let h in e)if(h in s.options){var n,r;(n=s.userData.restore)[r=h]||(n[r]=s.options[h]),s.options[h]=e[h]}})}restorePoi(t){t.map(i=>this.bmap.getPoiById(i)).filter(i=>!!i).forEach(i=>{console.log("poi.userData.restore",i.userData.restore);for(let s in i.userData.restore)s in i.options&&(i.options[s]=i.userData.restore[s]);i.userData.restore={}})}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.sort.js";var Vr=class extends B{sortByDistance(t,e,i){return f(this,null,function*(){i===void 0&&(i=!1);let s=[...e];if(i||e.length<20)return yield Promise.all(s.map(o=>f(this,null,function*(){o.distance=yield this._getDistance(t,{floor:o.floor,x:o.center_x,y:o.center_y})}))),s.sort((o,n)=>o.distance-n.distance);{let o=s.sort((r,h)=>{let c=Math.sqrt((r.center_x-t.x)**2+(r.center_y-t.y)**2)+(t.floor===r.floor?0:100),l=Math.sqrt((h.center_x-t.x)**2+(h.center_y-t.y)**2)+(t.floor===h.floor?0:100);return c-l});return[...(yield Promise.all(o.slice(0,20).map(r=>f(this,null,function*(){return r.distance=yield this._getDistance(t,{floor:r.floor,x:r.center_x,y:r.center_y}),r})))).sort((r,h)=>r.distance-h.distance),...o.slice(20)]}})}_getDistance(t,e){return f(this,null,function*(){return this.navPath.getPath({floor:t.floor,coord:[t.x,t.y]},{floor:e.floor,coord:[e.x,e.y]},"",0).then(i=>i.reduce((s,o,n)=>{if(s+=o.distance,n!==i.length-1)switch(o.endType){case"escalator":case"straightLadder":case"staircase":case"ramp":s+=100;break}return s},0)).catch(i=>i==="near"?0:1/0)})}dispose(){super.dispose(),this.needDisposeNavPath&&this.navPath.dispose()}constructor(t,e){if(super(t),this.needDisposeNavPath=!1,e)this.navPath=e;else{this.navPath=new ys;let i=new Ie(t);this.needDisposeNavPath=!0,i.load(t.config.apiPath.loadPlaceInfo+"?place_id="+t.config.placeId+"&env=prod").then(s=>f(this,null,function*(){let[o,n]=yield Promise.all([i.getRoadNetworkData(),i.getFacilitiesData()]);this.navPath.setRoadData(o,n.infrastructures)}))}}};var Kd="https://robot-vr-public.bj.bcebos.com/v1/static_resource/satellite_tiles",Xd={base_url:Kd},Kr=class extends B{setVisible(t){this.tileLayer.setVisibility(t)}dispose(){this.bmap.context.scene.remove(this.tileLayer),this.tileLayer.dispose(),super.dispose()}constructor(t,e){super(t),this.options=w({},Xd,e),this.tileLayer=new pe(t.context,this.options),this.tileLayer.position.z=-1,this.bmap.context.scene.add(this.tileLayer)}};import{Box3 as Yd,Group as qd}from"three";var Xr=class extends B{addHeatmap(t,e){this.heatmap||(this.heatmap=new Wi(this.bmap.context),this.group.add(this.heatmap)),this.heatmap.loadData(t);let i=new Yd().setFromObject(e.graphicLayer);return this.heatmap.position.setZ(i.max.z+.1),this.heatmap}removeHeatMap(){this.heatmap&&(this.group.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=null)}dispose(){this.removeHeatMap(),this.bmap.context.scene.remove(this.group)}constructor(t){super(t),this.heatmap=null,this.group=new qd,this.bmap.context.scene.add(this.group)}};export{Ie as AibeeLoader,xr as BMap,Dr as BMapSelect,vt as BaseSvg,As as CarInertialPosition,yi as ClickHelper,ps as Context,cs as ContextCamera,hs as ContextScene,rs as Control,vr as CrLoader,kr as CrNavPath,wr as Equipment,X as EventDispatcher,Ko as Events,At as Floor,Xn as GlbModel,J as Graphic,Ci as GraphicLayer,he as GroundTexture,Xr as Heatmap,Wi as HeatmapElement,jr as HighlightPoi,it as HooksName,ts as HoverHelper,Se as InstancedGraphic,Oi as InstancedModel,Ke as InstancedParkingSpace,$i as InstancedWall,xi as KalmanFilter,ji as Lane,H as Layer,$e as LineElement,DS as MapTypePolar,Ye as MergeAttributeGraphic,ce as MergeAttributeGroundTexture,Yi as MergeAttributeLane,Ki as MergeAttributeWall,Jn as MergeGraphic,le as MergedAttributeGraphicLine,Ri as MergedGraphicLayer,Ai as MergedModelLayer,Li as Model,zr as MulFloorNavigation,Br as MulFloorSelect,Tr as MulFloors,ys as NavPath,Lr as Navigation,be as Overlay,Di as ParkingLayer,IS as ParkingType,Ht as PathDirection,bs as PdrPosition,ae as Poi,j as Poi2,Ti as PoiLayer,ki as PoiLayer2,Nr as Position,Qe as RENDER_VERSION,Ur as RecommendParkingSpace,as as Renderer,vn as RoadNetwork,xn as RoadNetwork2,O as SENSOR_TYPE,Kr as SatelliteTile,Vn as SelectBox,Qi as Selection,xs as Sensor,Ei as Shadow,ni as Socket,Vr as SortByDistance,Ui as SvgLine,Hi as SvgPolygon,we as TaskQueue,Vi as TextTexture,pe as TileLayer,Gi as TileLoader,z as Timer,Qt as TweenUtil,Vo as UA,Zr as UseMyPosition,Ni as Wall,vi as WorkerPool,Ou as addAlphaToHexColor,me as calc_angle,Us as calc_direction,lC as calculateInstantaneousSpeed,ks as calculateLineDirection,wn as convertToSnakeCase,He as createCircle,ui as createLine,qt as createRect,No as createSvg,di as createSvgElement,of as createThreeBox,sf as createThreeLine,Wt as darkenColor,wp as defaultConfig,Zt as defaultGraphicOptions,po as defaultOptions,sl as defaultTextTextureOptions,vu as deviceToVector3,D as dispose,en as distancePointToSegment,oe as generatorKeyByObj,Ma as getAngle,Xs as getBorderPoints,pi as getCenter,dr as getConfig,am as getDirectPath,Hs as getDirectionByAngle,sn as getDistanceByPathPos,k as getLength,xu as getLongestSideDir,wu as getMinEdgeSquare,ht as getPathLength,Bt as getPointEdgeIndex,ve as getPosByPathDistance,Uo as hasChinese,Bs as hexToRgb,Wo as initDirectionalLight,Bo as initLight,hi as initShape,ng as instancedGeometiesAttributes,Gu as isAndroid,Yt as isContain,ye as isControl,Ut as isIphone,ge as isMac,Ho as isPointInPolygon,rg as isRectangle,gr as loadBuildingGround,hS as loadExternalStreet,yr as loadGraphics,og as mergeGraphicGeometries,Va as mergeGraphicLineGeometries,rm as moveOnRoute,oi as predictFuturePosition,pC as predictFutureSpeed,fe as proxyOptions,dC as removeOutliers,Pa as removeWeightPath,se as setCirclePosition,Mt as setLineStartEnd,ot as setRectPosition,mi as simplifyPath,jo as sleepByRf,Zo as sleepOnePromise,zs as sleepOneRf,tn as smoothPath,Mn as splitStrByBracket,Au as strToNumber,ft as timeoutPromise,Jm as toWebWorker,gi as transformGraphicData,Eo as transformSpeed,xe as translatePosToCenter,F as triggerWorker,C as vector3ToDevice,Ju as xhrGet};
701
+ `};var Ls=class extends Sd{constructor(t){super({type:"ArrowLineMaterial",uniforms:Object.assign({},Rr.clone(Ss["custom-line"].uniforms),{map:{value:null}}),vertexShader:Ss["custom-line"].vertexShader,fragmentShader:Ss["custom-line"].fragmentShader,clipping:!0}),this.dashed=!1,Object.defineProperties(this,{map:{enumerable:!0,get:function(){return this.uniforms.map.value},set:function(e){this.uniforms.map.value=e}},color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},repeat:{enumerable:!0,get:function(){return this.uniforms.repeat.value},set:function(e){this.uniforms.repeat.value.copy(e)}},allDistance:{enumerable:!0,get:function(){return this.uniforms.allDistance.value},set:function(e){this.uniforms.allDistance.value=e}}}),this.setValues(t),this.isLineMaterial=!0}};import{LineGeometry as Od}from"three/examples/jsm/lines/LineGeometry.js";import{Line2 as Id}from"three/examples/jsm/lines/Line2.js";var Gr={texture_url:Pi,lineWidth:8,color:16777215},Cs=class extends Ed{registryEvent(){this.navigation.bmap.context.addEventListener("control-change",this.onControlChange),this.navigation.bmap.context.addEventListener("update",this.onUpdate),this.navigation.bmap.context.addEventListener("resize",this.onResize)}unRegistryEvent(){this.navigation.bmap.context.removeEventListener("control-change",this.onControlChange),this.navigation.bmap.context.removeEventListener("update",this.onUpdate),this.navigation.bmap.context.removeEventListener("resize",this.onResize)}getRepeat(){let{points:t,navigation:{bmap:{context:{camera:e,clientSize:{width:i,height:s}}}}}=this,o=t.map(r=>{let[h,c,l]=r;return C(new Td(h,c,l),e,i,s)}).map(r=>{let{x:h,y:c}=r;return[h,c]});return ht(o)/32}changeRepeat(){if(!this.material)return;let t=this.getRepeat();this.material.repeat=new bo(t,1)}loadTexture(t){return new Promise((e,i)=>{new Ld().load(t,e,void 0,i)})}transformPoints(t){let e=[];for(let i=0;i<t.length;i++)e.push(...t[i]);return e}updatePoints(t){if(this.points=t,this.mesh){var e,i;this.remove(this.mesh),(e=this.material)==null||e.dispose(),(i=this.geometry)==null||i.dispose()}this.geometry=new Od,this.geometry.setPositions(t.flat(2));let s=ht(t.map(r=>{let[h,c]=r;return[h,c]})),o=this.material=new Ls({color:new Cd(this.config.color),transparent:!0,resolution:new bo(this.navigation.bmap.context.clientSize.width,this.navigation.bmap.context.clientSize.height),depthTest:!0,depthWrite:!0,linewidth:this.config.lineWidth,map:this.texture,blending:kd,repeat:new bo(this.getRepeat(),1),allDistance:s}),n=this.mesh=new Id(this.geometry,o);return n.computeLineDistances(),n.renderOrder=9,this.add(n),n}movePath(t){this.material&&(this.material.thresholdRatio=t)}create(t){return f(this,null,function*(){if(!this.texture){let e=this.texture=yield this.loadTexture(this.config.texture_url);e.wrapS=e.wrapT=Dd}return this.updatePoints(t)})}getBoundingBox(){return this.mesh?(this.mesh.geometry.computeBoundingBox(),new Ad().copy(this.mesh.geometry.boundingBox).applyMatrix4(this.mesh.matrixWorld)):null}dispose(){var t,e,i;this.unRegistryEvent(),this.clear(),(t=this.geometry)==null||t.dispose(),(e=this.material)==null||e.dispose(),(i=this.texture)==null||i.dispose(),this.navigation=null}constructor(t,e){super(),this.navigation=t,this.mesh=null,this.geometry=null,this.material=null,this.texture=null,this.config=Gr,this.points=[],this.basicRepeat=1,this.prevCameraZoom=0,this.onControlChange=()=>{let i=this.navigation.bmap.context.camera.zoom;i!==this.prevCameraZoom&&(this.prevCameraZoom=i,this.changeRepeat())},this.onUpdate=()=>{this.texture},this.onResize=()=>{if(this.material){let{width:i,height:s}=this.navigation.bmap.context.clientSize;this.material.resolution.set(i,s)}},this.config=Object.assign({},Gr,e),this.registryEvent(),this.prevCameraZoom=this.navigation.bmap.context.camera.zoom}};import{Tween as Wd}from"@tweenjs/tween.js";import{AnimationMixer as Rd,Box3 as Gd,Object3D as Fr,Vector3 as Fd,Mesh as zd,Euler as Bd}from"three";var Ts=class extends Fr{meshSetMaterial(t){t instanceof zd&&(t.material.emissiveIntensity=.5,t.material.shininess=0,t.material.emissive=t.material.color,t.material.emissiveMap=t.material.map,t.material.transparent=!0,t.material.depthTest=!1,t.renderOrder=1e6),t.children.forEach(i=>{this.meshSetMaterial(i)})}getBaseScale(t){let{clientSize:{height:e},camera:i}=this.bmap.context,o=(i.top-i.bottom)/i.zoom/e;return this.options.size*o/this.modelMaxLength}registryEvent(){this.bmap.context.addEventListener("update",this._update),this.bmap.context.addEventListener("control-zoom-change",this._onChangeZoom)}unRegistryEvent(){this.bmap.context.removeEventListener("update",this._update),this.bmap.context.removeEventListener("control-zoom-change",this._onChangeZoom)}lookAtCamera(){if(this.model&&this.bmap&&this.bmap.context){let t=this.bmap.context.camera,e=new Bd;e.setFromQuaternion(t.quaternion,"ZYX"),this.group.rotation.copy(e)}}setClips(t){this.clearClips(),t.length&&(this.mixer=new Rd(this.model.scene),t.forEach(e=>this.mixer.clipAction(e).play()))}startClips(){var t;this.setClips(((t=this.model)==null?void 0:t.animations)||[])}clearClips(){this.mixer&&(this.mixer.stopAllAction(),this.mixer.uncacheRoot(this.mixer.getRoot()),this.mixer=null)}dispose(){this.unRegistryEvent(),this.clearClips(),this.clear(),this.model&&D(this.model.scene),this.bmap=null}constructor(t,e,i={}){super(),this.bmap=t,this.group=new Fr,this.mixer=null,this.previewTime=0,this.modelMaxLength=0,this.options={size:40},this._update=()=>{let s=Date.now();if(!this.previewTime)this.previewTime=s;else{var o;let n=s-this.previewTime;this.previewTime=s,(o=this.mixer)==null||o.update(n/1e3)}this.lookAtCamera()},this._onChangeZoom=s=>{let{zoom:o}=s;var n;if(!this.model)return;let r=this.getBaseScale(this.model.scene);(n=this.model)==null||n.scene.scale.set(r,r,r)},this.options=w({},this.options,i),this.add(this.group),st.loadModel(e,!1).then(s=>{this.model=s;let n=new Gd().setFromObject(s.scene).getSize(new Fd),r=Math.max(n.x,n.y,n.z);this.modelMaxLength=r;let h=this.getBaseScale(s.scene);s.scene.scale.set(h,h,h),this.meshSetMaterial(s.scene),this.group.add(s.scene),this.setClips(s.animations),this.group.rotation.set(Math.PI/2,Math.PI,0),this.dispatchEvent({type:"loaded"})}),this.registryEvent()}};import{Vector3 as So}from"three";var zr=class extends B{registryEvent(){this.bmap.context.addEventListener("update",this.onUpdate)}pauseAnimation(){this.tweenUtil.pause()}continueAnimation(){this.tweenUtil.continue()}clearTween(){this.tweenUtil.clear(),this.bmap.context.control.enabled=!0}unRegistryEvent(){this.bmap.context.removeEventListener("update",this.onUpdate)}clearPath(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose(),this.path=null,this.movedDistance=0,this.clearTween()),this.startModel&&(this.startModel.visible=!1),this.translatePath=null}addPath(t){this.paths=t;let e=t.map(i=>w({},i,{points:this.translatePoints(i.points)}));if(this.clearTween(),this.movedDistance=0,this.bmap.currentBuildGround)this.renderPath(e);else{let i=()=>{this.bmap.removeEventListener("center-change",i),this.renderPath(e)};this.bmap.addEventListener("center-change",i)}this.dispatchEvent({type:"add-path",paths:t})}translatePoints(t){let[e,i]=this.bmap.buildingCenter;return t.map(s=>[s[0]-e,s[1]-i])}renderPath(t){return f(this,null,function*(){if(!t.length)return this.clearPath();let e=[];t.forEach((i,s,o)=>{let n=this.mulFloor.floors.find(r=>r.name===i.floor);e.push(...i.points.map(r=>{let[h,c]=r;return[h,c,n.position.z+n.groundMaxHeight]}))}),this.cPath=e,this.animationPathOptions={cPathIndex:0},this.path?this.path.updatePoints(e):(this.path=new Cs(this),yield this.path.create(e),this.path.position.z=.5,this.bmap.context.scene.add(this.path)),this.startModel&&(this.startModel.position.set(e[0][0],e[0][1],e[0][2]),this.startModel.visible=!0),this.dispatchEvent({type:"render-path",path:this.path})})}catmullRomCurve3(t){return mi(t,!1,!0,.1,170,2.5)}getPathDirection(t,e){if(t.length<2)return null;let i=Bt(t,e),s=t[i],o=t[i+1],n=new So(o[0]-s[0],o[1]-s[1],0).normalize(),r=new So(0,1,0).normalize(),h=n.angleTo(r),c=new So().crossVectors(r,n);return(Object.is(c.y,0)?-1:1)*h}startSimulation(t){return f(this,null,function*(){t===void 0&&(t=1);let{paths:e,movedDistance:i}=this;if(!e.length)return;let s=e.reduce((n,r)=>n+r.distance,0);if(!s||i>=s)return;this.simulationTween&&this.tweenUtil.remove(this.simulationTween);let o=s/t;return this.startModel.startClips(),new Promise(n=>{let r=this.simulationTween=new Wd({distance:this.movedDistance},this.tweenUtil.group).to({distance:s},o*1e3).onUpdate(h=>{var c;this.movedDistance=h.distance;let l=h.distance,p=0;for(let g=0;g<e.length;g++)if(e[g].distance>=l){p=g;break}else l-=e[g].distance;let d=ve(e[p].points,l);if(d===null)return;this.currentPathPosition=d;let u=this.translatePoints([d])[0],m=this.mulFloor.floors.find(g=>g.name===e[p].floor),v=m?m.position.z+m.groundMaxHeight:(c=this.startModel)==null?void 0:c.position.z;this.startModel&&this.startModel.position.set(u[0],u[1],v)}).onComplete(()=>{if(this.tweenUtil.remove(r),this.startModel.clearClips(),this.startModel){var h,c,l,p;let d=(l=e.slice(-1)[0])==null||(c=l.points)==null||(h=c.slice(-1))==null?void 0:h[0];if(!d)return;let u=this.mulFloor.floors.find(g=>{var x;return g.name===((x=e.slice(-1)[0])==null?void 0:x.floor)});if(!u)return;let m=u?u.position.z+u.groundMaxHeight:(p=this.startModel)==null?void 0:p.position.z,v=this.translatePoints([d])[0];this.startModel.position.set(v[0],v[1],m)}n(!0)}).start()})})}setStartPoiRotate(t){if(this.startPoi){let i=(this.bmap.context.control.getAzimuthalAngle()*180/Math.PI+360)%360;this.startPoi.options.icon_rotate=(360-t-i)%360}}dispose(){this.path&&(this.bmap.context.scene.remove(this.path),this.path.dispose()),this.startModel&&(this.bmap.context.scene.remove(this.startModel),this.startModel.dispose()),this.tweenUtil.dispose(),this.unRegistryEvent(),super.dispose()}constructor(t,e,i={}){super(t),this.mulFloor=e,this.path=null,this.fetchRoadStatus=!1,this.paths=[],this.curFloorPath=null,this.translatePath=null,this.currentPathPosition=null,this.pathTween=null,this.startPoi=null,this.movedDistance=0,this.tweenUtil=new Qt,this.animationPathOptions={cPathIndex:0},this.cPath=[],this.onUpdate=()=>{this.tweenUtil.update()},this.startModel=new Ts(t,Dn,i.startModel),this.startModel.visible=!1,this.bmap.context.scene.add(this.startModel),this.registryEvent()}};import"core-js/modules/es.array.flat.js";import"core-js/modules/es.array.unscopables.flat.js";import{Raycaster as Ud,Vector2 as Hd}from"three";var Br=class extends B{registryEvent(){this.clickHelper.addEventListener("click",this._click)}unRegistryEvent(){this.clickHelper.removeEventListener("click",this._click)}dispose(){this.unRegistryEvent(),this.clickHelper.dispose(),this.mulFloors=null,super.dispose()}constructor(t,e){super(t),this.mulFloors=e,this._click=i=>{let{e:s}=i;if(!this.mulFloors.showStatus)return;let o=new Hd,{offsetX:n,offsetY:r}=s,h=this.mulFloors.floors.map(d=>d.poiLayer2.getPoiByDeviceXy(n,r)).flat(2),{clientSize:c}=this.bmap.context;o.x=n/c.width*2-1,o.y=r/c.height*-2+1;let l=new Ud;l.setFromCamera(o,this.bmap.context.camera),l.ray.origin.sub(l.ray.direction.clone().multiplyScalar(1e4));let p=this.mulFloors.floors.map(d=>d.graphicLayer.getGraphicByRaycaster(l).graphics).flat();this.dispatchEvent({type:"select",pois:h,graphics:p})},this.clickHelper=new yi(this.bmap.context.container),this.registryEvent()}};import"core-js/modules/es.array.find-last-index.js";import"core-js/modules/es.array.find-last.js";import"core-js/modules/es.array.push.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.array.sort.js";import{Vector2 as si}from"three";function Nd(a){let t=a.length,e=0,i=0,s=0,o=0;a.forEach(h=>{e+=h[0],i+=h[1],s+=h[0]*h[1],o+=h[0]*h[0]});let n=(t*s-e*i)/(t*o-e*e),r=(i-n*e)/t;return{m:n,b:r}}function Zd(a,t,e){let i=e[0][0],s=e.slice(-1)[0][0],o=a*i+t,n=a*s+t;return{start:[i,o],end:[s,n]}}function ks(a){if(a.length<2)return null;let t=a.filter((h,c)=>{let l=[...a];return l.splice(c,1),l.every(p=>p[0]!==h[0]&&p[1]!==h[1])});if(t.length<2)return null;let{m:e,b:i}=Nd(t),{start:s,end:o}=Zd(e,i,t),r=360-(new si().subVectors(new si(o[0],o[1]),new si(s[0],s[1])).angle()/Math.PI*180-90+360)%360;return Number.isNaN(r)?null:r}function lC(a){let t=[];for(let e=1;e<a.length;e++){let i=a[e-1],s=a[e],o=s.position[0]-i.position[0],n=s.position[1]-i.position[1],r=Math.sqrt(o**2+n**2),h=s.time-i.time;if(h>0){let c=r/h;console.log("speedDelta",i.type,s.type,Eo(c),r,h),t.push(c)}else t.push(0)}return t}function pC(a,t){let e=a[0],i=a.slice(-1)[0],s=k(i.position,e.position),o=i.time-e.time;return o<100||s<3?null:s/o}function Eo(a){return a*60*60}function oi(a,t,e,i){let s=(e+90)%360*(Math.PI/180),o=t*i,n=new si(a[0],a[1]),r=Math.cos(s),h=Math.sin(s),c=new si(r,h);return n.add(c.normalize().multiplyScalar(o)),[n.x,n.y]}function dC(a){let t=[...a].sort((c,l)=>c-l),e=Wr(t,25),i=Wr(t,75),s=i-e,o=e-1.5*s,n=i+1.5*s,r=t.filter(c=>c>=o&&c<=n);return a.filter(c=>r.includes(c))}function Wr(a,t){let e=t/100*(a.length-1),i=Math.floor(e),s=Math.ceil(e);if(i===s)return a[i];let o=e-i;return a[i]*(1-o)+a[s]*o}import{isNil as Ds}from"lodash";var As=class extends X{setPathAngle(t){this.pathAngle=t,this.dispatchEvent({type:"change-compass",value:this.pathAngle}),Ds(this.angle)&&(this.angle=t)}changeSpeed(){let t=this.history.filter(h=>["vision"].includes(h.type));if(t.length<2){this.speedFilter.filter(0),this.speed=0;return}let e=t[0],i=t.slice(-1)[0],s=k(i.position,e.position),o=i.time-e.time,n=o>0?s/o:0,r=this.speedFilter.filter(n);this.speed=r}changeAngle(t){t===void 0&&(t=this.visionHistory),t.length<2&&(this.angle=null);let e=ks(t.map(i=>i.position));e!==null&&this.setAngle(e)}setAngle(t,e){e===void 0&&(e=!0),this.angle=t,e&&this.dispatchEvent({type:"change-position-compass",value:t})}setPosition(t,e,i){let s={position:t,time:e,clientTime:Date.now()-i,type:"vision"};if(this._setVisionHistoryForAngle(s),Ds(this.angle)||!this.speed){this.addHistory(s);return}let o=this.history.findLastIndex(r=>r.type==="vision"),n=this.history[o];if(n){if(n.time>e)return;let r=ks([this.history.slice(-1)[0].position,t]);if(r&&Math.abs(r-this.angle)<60){this.addHistory(s);return}let h=oi(t,this.speed,360-this.pathAngle,i);k(h,this.history.slice(-1)[0].position)>5?this.visionExcessesCount++:this.visionExcessesCount=0,this.visionExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21\u89C6\u89C9\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528\u89C6\u89C9\u6821\u51C6"),this.addHistory(s),this.visionExcessesCount=0)}}resetPdrPosition(){let t=this.history.findLast(e=>e.type==="vision");if(t&&this.speed){let e=oi(t.position,this.speed,360-this.pathAngle,Date.now()-t.clientTime);e&&this.history.push({position:e,time:Date.now(),clientTime:Date.now(),type:"pdr"})}}getLastVisionPdrPos(){let t=this.history.findLastIndex(i=>i.type==="vision");if(t!==-1){var e;return(e=this.history[t+1])!=null?e:this.history[t]}return null}_setVisionHistoryForAngle(t){if(!this.visionHistory.length){this.visionHistory.push(t);return}let e=ks([this.visionHistory.slice(-1)[0].position,t.position]);if(e!==null&&(this.angle&&Math.abs(this.angle-e)>60?this.angleExcessesCount++:(this.angleExcessesCount=0,this.visionHistory.push(t))),this.angleExcessesCount>3)console.warn("\u8FDE\u7EED\u4E09\u6B21\u89D2\u5EA6\u6BD4\u8F83\u6B6A\uFF0C\u91CD\u65B0\u77EB\u6B63"),this.visionHistory=[t],this.angleExcessesCount=0;else{let i=k(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position);for(;i>5&&this.visionHistory.length>15;)this.visionHistory.shift(),i=k(this.visionHistory[0].position,this.visionHistory.slice(-1)[0].position)}this.changeAngle()}addHistory(t){this.history.push(t);let e=this.history.filter(r=>r.type==="vision"),i=e.length?Date.now()-e.slice(-1)[0].clientTime:0,s=k(this.history[0].position,this.history.slice(-1)[0].position),o=i>5e3?10:3,n=i>5e3?0:5;for(i>5e3&&console.warn("\u89C6\u89C9\u7ED3\u679C\u8D85\u51FA5s\u4E0D\u53EF\u7528\uFF0C\u5168\u90E8\u6E05\u7A7A");e.length>n&&s>o;)this.history.shift(),e=this.history.filter(r=>r.type==="vision"),s=k(this.history[0].position,this.history.slice(-1)[0].position);n===0?this.changeSpeed():t.type==="vision"&&this.changeSpeed(),this.changePosition(t.type)}setBeaconPosition(t,e,i){let s=Date.now()-i,o={position:t,time:e,clientTime:s,type:"beacon"},n=this.history.findLastIndex(l=>l.type!=="pdr"),r=this.history[n];if(!r){this.addHistory(o);return}if(Ds(this.pathAngle)||!this.speed){this.addHistory(o);return}if(r&&r.time>e)return;let h=oi(t,this.speed,360-this.pathAngle,i);k(h,this.history.slice(-1)[0].position)>5?this.beaconExcessesCount++:this.beaconExcessesCount=0,this.beaconExcessesCount>3&&(console.warn("\u8FDE\u7EED\u4E09\u6B21beacon\u548Cpdr\u5DEE\u8DDD\u5927\u4E8E5\u7C73\uFF0C\u4F7F\u7528beacon\u6821\u51C6"),this.addHistory(o),this.beaconExcessesCount=0)}startPositionTimer(){this.positionTimer&&this.timer.clearInterval(this.positionTimer),this.positionTimer=this.timer.setInterval(()=>{this.changePosition()},20)}stopPositionTimer(){this.positionTimer&&(this.timer.clearInterval(this.positionTimer),this.positionTimer=null)}changePosition(t){t===void 0&&(t="pdr");let e=this.getPosition(t);e.success&&(this.history.push({position:e.pos,time:Date.now(),clientTime:Date.now(),type:"pdr"}),this.speed?this.dispatchEvent({type:"change-pos",value:w({},e)}):this.dispatchEvent({type:"change-pos",value:e}))}getPosition(t){if(this.history.length===0)return{success:!1,pos:[0,0],compass:null,speed:0};let e=this.history.slice(-1)[0];if(this.history.length<2)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};if(Ds(this.pathAngle)||!this.speed)return{success:!0,pos:e.position,compass:this.pathAngle,speed:this.speed};let i=e.clientTime,s=Date.now()-i;return{success:!0,pos:this.pathAngle?oi(e.position,this.speed,360-this.pathAngle,s):e.position,compass:this.pathAngle,speed:Eo(this.speed)}}dispose(){this.timer.dispose()}constructor(){super(),this.history=[],this.visionHistory=[],this.speed=0,this.angle=null,this.timer=new z,this.positionTimer=null,this.speedFilter=new xi,this.visionExcessesCount=0,this.beaconExcessesCount=0,this.angleExcessesCount=0,this.pathAngle=0,this.startPositionTimer()}};import"core-js/modules/es.json.stringify.js";function Lo(){return new Worker(new URL("./worker/recommend.worker-SSGBILKT.js",import.meta.url))}var jd={placeId:0,catLotStatusApi:"https://vrapi.aibee.cn/parking/cat-lot-status"},Ur=class{setRoadData(t,e){return F(this.worker,"set_road_info",{roadData:t,facilities:e})}recommend(t){return f(this,null,function*(){let e=yield fetch(this.options.catLotStatusApi,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({place_id:+this.options.placeId})}).then(i=>i.json()).then(i=>i.data.filter(s=>s.status===0)).then(i=>{var s;return i.filter((s=this.options.filterCarLotStatus)!=null?s:()=>!0)});return F(this.worker,"recommend",w({},t,{carLotStatus:e}))})}dispose(){this.worker.terminate()}constructor(t={}){this.worker=Lo(),this.options=w({},jd,t)}};import"core-js/modules/es.json.stringify.js";import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.sort.js";import"core-js/modules/es.array.push.js";import"core-js/modules/es.regexp.exec.js";import"core-js/modules/web.url-search-params.js";import"core-js/modules/web.url-search-params.delete.js";import"core-js/modules/web.url-search-params.has.js";import"core-js/modules/web.url-search-params.size.js";import"core-js/modules/es.json.stringify.js";var Vd={url:"",reconnect:!0,heartBeat:2e3,heartMsg:JSON.stringify({command:"PING"}),reconnectTime:3e3,reconnectMaxCount:1e6,noMessageTime:6e3},ni=class extends X{initWebsocket(){this.ws=new WebSocket(this.options.url),this.ws.onopen=()=>{this.alive=!0,this.startHeart(),this.startOnMessageTimer(),this.stopReconnect(),this.dispatchEvent({type:"open"})},this.ws.onerror=()=>{this.alive=!1,this.ws=null,this.stopHeart(),this.stopOnMessageTimer(),this.startReconnect(),this.registryEvent()},this.ws.onclose=()=>{this.alive=!1,this.ws=null,this.stopHeart(),this.stopOnMessageTimer(),this.startReconnect()},this.ws.onmessage=t=>{this.startOnMessageTimer(),this.dispatchEvent({type:"message",message:t})}}startHeart(){this.stopHeart(),this.heartTimer=this.timer.setInterval(()=>{this.send(this.options.heartMsg)&&this.dispatchEvent({type:"send-heart"})},this.options.heartBeat)}stopHeart(){this.heartTimer&&(this.timer.clearInterval(this.heartTimer),this.heartTimer=null)}startReconnect(t){t===void 0&&(t=this.options.reconnectTime),this.stopReconnect(),this.options.reconnect&&(this.options.reconnectMaxCount--,this.options.reconnectMaxCount>=0&&(this.reconnectTimer=this.timer.setTimeout(()=>{this.initWebsocket()},t)))}stopReconnect(){this.reconnectTimer&&(this.timer.clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}startOnMessageTimer(){this.stopOnMessageTimer(),this.noMessageTimer=this.timer.setTimeout(()=>{var t;(t=this.ws)==null||t.close(),this.dispatchEvent({type:"no-message-timeout"})},this.options.noMessageTime)}stopOnMessageTimer(){this.noMessageTimer&&(this.timer.clearTimeout(this.noMessageTimer),this.noMessageTimer=null)}send(t){var e;let i=typeof t=="string"?t:JSON.stringify(t);return this.alive&&((e=this.ws)==null?void 0:e.readyState)===1?(this.ws.send(i),this.dispatchEvent({type:"send-success",msg:i}),!0):(this.dispatchEvent({type:"send-fail",msg:i}),!1)}registryEvent(){window.addEventListener("online",this.onOnline)}unRegistryEvent(){window.removeEventListener("online",this.onOnline)}close(){var t;this.unRegistryEvent(),this.options.reconnect=!1,this.alive=!1,this.stopHeart(),this.stopReconnect(),this.stopOnMessageTimer(),(t=this.ws)==null||t.close(),this.ws=null,this.dispatchEvent({type:"close"})}dispose(){this.close(),this.timer.dispose(),super.dispose()}constructor(t){super(),this.ws=null,this.alive=!1,this.timer=new z,this.heartTimer=null,this.reconnectTimer=null,this.noMessageTimer=null,this.onOnline=()=>{this.startReconnect()},this.options=w({},Vd,t||{}),this.options.url&&this.initWebsocket()}};import{isNil as Hr}from"lodash";var Co=a=>{let t=a.toString(2),e=""+Array(16-t.length+1).join("0")+t,i=parseInt(e.slice(0,4),2)*10,s=parseInt(e.slice(4,16),2);return[i,s]};var Nr=class extends X{initPositionWebSocket(){let t=w({},this.options.ext_position_params,{place_id:this.options.place_id,token:this.options.access_token}),e=Object.keys(t).filter(i=>!Hr(t[i])).map(i=>i+"="+t[i]).join("&");this.positionWebSocket=new ni({url:this.options.wss_position_url+"?"+e}),this.positionWebSocket.addEventListener("message",i=>{let{message:s}=i,o=(()=>{try{return JSON.parse(s.data)}catch(I){return s.data}})();if(this.dispatchEvent({type:"ws-message",data:o}),o.command==="POSITION_RESULT"&&o.data.success)if(["POSITION","FLOOR","PARK_POSITION","AOA"].includes(o.data.success_type)&&this.useGpsFloorTimer&&(this.positionFloor=o.data.floor,this.timer.clearTimeout(this.useGpsFloorTimer),this.useGpsFloorTimer=null),o.data.success_type==="AOA"){let{x:I,y:R,time:N,floor:W,ts:Et}=o.data,Lt=this.positionFloor!==W;if(this.positionFloor=W,this.dispatchEvent({type:"ws-position",floor:W,x:I,y:R,time:N,_type:"aoa"}),this.options.upload_position){var n;(n=this.positionWebSocket)==null||n.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:I,y:R,floor:W,type:"aoa"}),serverData:JSON.stringify(o)})}if(!this.options.use_pdr){this.dispatchEvent({type:"position",floor:W,x:I,y:R,time:new Date(Et).getTime()-o.lag-o.duration});return}if(this.options.type!==1){var r;if(Lt){var h,c,l;(l=this.pdrPosition)==null||(c=l.pdr)==null||(h=c.particleFilter)==null||h.setPosInitFlag(!1)}(r=this.pdrPosition)==null||r.setBeaconPosition({x:I,y:R},new Date(Et).getTime()-o.lag-o.duration)}else if(Lt){var p;if(this.resetPdr(),(p=this.carInertialPosition)==null||p.stopPositionTimer(),this.path){let Xt=this.path.findIndex(Fe=>Fe.floor===W),It=this.path[Xt];if(It){var d;this.resetPdr(),(d=this.carInertialPosition)==null||d.setBeaconPosition(It.points[0],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}else{var u;(u=this.carInertialPosition)==null||u.setBeaconPosition([I,R],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var m;(m=this.carInertialPosition)==null||m.setBeaconPosition([I,R],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var v;(v=this.carInertialPosition)==null||v.setBeaconPosition([I,R],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}}else if(o.data.success_type==="POSITION"){let{x:I,y:R,time:N,floor:W,ts:Et}=o.data,Lt=this.positionFloor!==W;if(this.positionFloor=W,this.dispatchEvent({type:"ws-position",floor:W,x:I,y:R,time:N,_type:"beacon"}),console.log("positionFloor",W,Lt),this.options.upload_position){var g;(g=this.positionWebSocket)==null||g.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:I,y:R,floor:W,type:"originBeacon"}),serverData:JSON.stringify(o)})}if(!this.options.use_pdr){this.dispatchEvent({type:"position",floor:W,x:I,y:R,time:new Date(Et).getTime()-o.lag-o.duration});return}if(this.options.type!==1){var x;if(Lt){var M,P,E;(E=this.pdrPosition)==null||(P=E.pdr)==null||(M=P.particleFilter)==null||M.setPosInitFlag(!1)}(x=this.pdrPosition)==null||x.setBeaconPosition({x:I,y:R},new Date(Et).getTime()-o.lag-o.duration)}else if(Lt){var b;if(this.resetPdr(),(b=this.carInertialPosition)==null||b.stopPositionTimer(),this.path){let Xt=this.path.findIndex(Fe=>Fe.floor===W),It=this.path[Xt];if(It){var A;this.resetPdr(),(A=this.carInertialPosition)==null||A.setBeaconPosition(It.points[0],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}else{var S;(S=this.carInertialPosition)==null||S.setBeaconPosition([I,R],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var V;(V=this.carInertialPosition)==null||V.setBeaconPosition([I,R],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}}else{var rt;(rt=this.carInertialPosition)==null||rt.setBeaconPosition([I,R],new Date(N).getTime()-o.lag-o.duration,o.lag+o.duration)}}else if(o.data.success_type==="PARK_POSITION"&&o.data.success){if(this.options.type===1){let{x:I,y:R,time:N,floor:W}=o.data,Et=this.positionFloor!==W;if(this.positionFloor=o.data.floor,this.dispatchEvent({type:"ws-position",floor:W,x:I,y:R,time:N,_type:"vision"}),!this.options.use_pdr){this.dispatchEvent({type:"position",floor:W,x:I,y:R,time:new Date(N).getTime()});return}if(Et){var Q;if(this.resetPdr(),(Q=this.carInertialPosition)==null||Q.stopPositionTimer(),this.path){let Lt=this.path.findIndex(It=>It.floor===W),Xt=this.path[Lt];if(Xt){var lt;this.resetPdr(),(lt=this.carInertialPosition)==null||lt.setPosition(Xt.points[0],new Date(N).getTime(),o.duration)}else{var at;(at=this.carInertialPosition)==null||at.setPosition([I,R],new Date(N).getTime(),o.duration)}}else{var St;(St=this.carInertialPosition)==null||St.setPosition([I,R],new Date(N).getTime(),o.duration)}}else{var Kt,q;if((Kt=this.carInertialPosition)==null||Kt.setPosition([I,R],new Date(N).getTime(),o.duration),!((q=this.carInertialPosition)!=null&&q.positionTimer)){var ue;(ue=this.carInertialPosition)==null||ue.startPositionTimer()}}if(this.options.upload_position){var Ge;(Ge=this.positionWebSocket)==null||Ge.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:I,y:R,floor:W,type:"vision"}),serverData:JSON.stringify(o)})}}}else this.dispatchEvent({type:"floor",floor:o.data.floor,time:o.data.time})})}initSensorWebSocket(){let t=w({},this.options.ext_sensor_params,{token:this.options.access_token,place_id:this.options.place_id,record_sensor:1}),e=Object.keys(t).filter(i=>!Hr(t[i])).map(i=>i+"="+t[i]).join("&");this.sensorWebSocket=new ni({url:this.options.wss_sensor_url+"?"+e})}initPdr(){this.options.type===1?(this.carInertialPosition=new As,this.carInertialPosition.addEventListener("change-pos",t=>{let{value:e}=t,{pos:i,success:s,speed:o}=e;if(s&&(this.dispatchEvent({type:"position",floor:this.positionFloor,x:i[0],y:i[1],time:Date.now(),speed:o}),this.options.upload_position)){var n;(n=this.positionWebSocket)==null||n.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:i[0],y:i[1],floor:this.positionFloor,type:"vision_pdr"})})}}),this.carInertialPosition.addEventListener("change-compass",t=>{let{value:e}=t;this.dispatchEvent({type:"compass",value:e})})):(this.pdrPosition=new bs(this.bmap,{pdr:{using_gps:this.options.use_gps},sensor:{elements:[O.COMPASS,O.ACCELERATION,O.DEVICE_MOTION].concat(this.options.use_gps?[O.GPS]:[])}}),this.requestDeviceOrientationPermission(),this.options.upload_position&&this.pdrPosition.sensor.addEventListener("sensor-data",t=>{let{data:e}=t;var i;(i=this.positionWebSocket)==null||i.send({command:"UPLOAD_SENSOR",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify(e)})}),this.pdrPosition.sensor.addEventListener("add-data-item",t=>{t.item.type==="compass"&&this.dispatchEvent({type:"compass",value:t.item.res})}),this.pdrPosition.addEventListener("position",t=>{let{x:e,y:i,_type:s}=t;if(console.log("_type",s,e,i,this.positionFloor,this.gpsFloor),s==="gps"&&!this.useGpsFloorTimer){let n=()=>{this.useGpsFloorTimer=this.timer.setTimeout(()=>{this.gpsFloor?this.positionFloor=this.gpsFloor:n()},5e3)};n()}if(this.positionFloor&&(this.dispatchEvent({type:"position",floor:this.positionFloor,x:e,y:i,time:Date.now()}),this.options.upload_position)){var o;(o=this.positionWebSocket)==null||o.send({command:"UPLOAD_POSITION",ts:Date.now(),index:this.uploadIndex++,data:JSON.stringify({x:e,y:i,floor:this.positionFloor,type:s})})}}))}setSensor(t){this.pdrPosition&&this.pdrPosition.setSensor(t)}requestDeviceOrientationPermission(){return f(this,null,function*(){if(this.pdrPosition){let t=yield this.pdrPosition.checkSensor();return t.deviceOrientation?this.pdrPosition.start():(this.dispatchEvent(w({type:"check-sensor"},t)),!t.deviceOrientation&&this.options.use_default_permission),t}else return null})}getGpsFloor(){return f(this,null,function*(){if(this.options.use_gps&&this.options.get_gps_floor_url){let t=yield fetch(this.options.get_gps_floor_url+"/"+this.options.place_id).then(e=>e.json());t.code===200&&(this.gpsFloor=t.data.gps_floor)}})}pausePdr(){if(this.options.type===1){var t;(t=this.carInertialPosition)==null||t.stopPositionTimer()}else{var e;(e=this.pdrPosition)==null||e.pause()}}continuePdr(){if(this.options.type===1)this.carInertialPosition&&(this.carInertialPosition.positionTimer||this.carInertialPosition.startPositionTimer());else{var t;(t=this.pdrPosition)==null||t.continue()}}setPathAngle(t){if(this.options.type===1){var e;(e=this.carInertialPosition)==null||e.setPathAngle(t)}}getForwardAngle(){if(this.options.type===1){var t,e;return(e=(t=this.carInertialPosition)==null?void 0:t.angle)!=null?e:null}else return null}resetPdr(){this.carInertialPosition&&(this.carInertialPosition.history=[],this.carInertialPosition.setPathAngle(0),this.carInertialPosition.speed=0),this.pdrPosition&&this.pdrPosition.pdr.particleFilter.setPosInitFlag(!1)}setPath(t){this.path=t}sendBeacon(t){var e;let i=[];if(Ut)i=t.map(o=>{let[n,r]=Co(o.major);return[o.uuid,r,o.minor,o.rssi,o.accuracy,n]}).filter(o=>o[3]!==0).sort((o,n)=>n[3]-o[3]);else{let o=t.reduce((n,r)=>{var h,c;let[l,p]=Co(r.major),d=""+p+r.minor;return(h=n)[c=d]||(h[c]=[]),n[d].push(w({},r,{battery:l,major:p})),n},{});Object.entries(o).forEach(n=>{let[r,h]=n,{uuid:c,major:l,minor:p,accuracy:d,battery:u}=h[0];if(h.length>1){let m=h.filter(g=>g.rssi<0),v=m.reduce((g,x)=>g+x.rssi,0);i.push([c,l,p,v/m.length,d,u])}else i.push([c,l,p,h[0].rssi,d,u])})}let s={command:"POSITION",index:this.uploadIndex++,ts:Date.now(),beacons:JSON.stringify([{type:"ibeacon",timestamp:Date.now()/1e3,res:i}]),ext_sensors:JSON.stringify({})};(e=this.sensorWebSocket)==null||e.send(s)}dispose(){var t,e,i,s;this.timer.dispose(),(t=this.positionWebSocket)==null||t.dispose(),this.positionWebSocket=null,(e=this.sensorWebSocket)==null||e.dispose(),this.sensorWebSocket=null,(i=this.pdrPosition)==null||i.dispose(),this.pdrPosition=null,(s=this.carInertialPosition)==null||s.dispose(),this.carInertialPosition=null,super.dispose()}constructor(t,e){super(),this.bmap=t,this.positionWebSocket=null,this.sensorWebSocket=null,this.pdrPosition=null,this.carInertialPosition=null,this.gpsFloor="",this.positionFloor="",this.useGpsFloorTimer=null,this.uploadIndex=0,this.path=null,this.timer=new z;let i=location.href.indexOf("?"),s=i!==-1?location.href.slice(i):location.search,o=new URLSearchParams(s),n=o.get("server_env")||"prod",r={test:"nav-test.aibee.cn",prod:"nav.aibee.cn"},h="wss://"+r[n]+"/aether-walker/indoor/position",c="wss://"+r[n]+"/aether-walker/indoor/sensor";this.options=w({place_id:o.get("place_id"),access_token:o.get("access_token"),env:n,wss_position_url:h,wss_sensor_url:c,get_gps_floor_url:"https://"+r[n]+"/aether-walker/indoor/conf",use_sensor:!1,type:-1,use_gps:!0,use_pdr:!0,upload_position:!0,use_default_permission:!0,ext_position_params:{},ext_sensor_params:{}},e),this.initPositionWebSocket(),this.options.use_sensor&&this.initSensorWebSocket(),this.options.use_pdr&&this.initPdr(),this.options.use_gps&&this.getGpsFloor()}};import"core-js/modules/web.dom-collections.iterator.js";var Zr=class extends B{showMyPosition(t,e){var i;let s=(i=this.bmap.context.currentFloor)==null?void 0:i.getGraphicPosition(t);if(s){let o=new be(this.bmap.context,{autoUpdate:!0,appendToBody:!1});o.div.appendChild(e),o.position.copy(this.bmap.mercatorToWorld(s)),this.myPositionOverlay=o,console.log("graphicPos",s,this)}else console.warn("[showMyPosition] \u6CA1\u6709\u627E\u5230\u56FE\u5143\u6240\u5728\u7684\u4F4D\u7F6E")}hideMyPosition(){this.myPositionOverlay&&(this.myPositionOverlay.dispose(),this.myPositionOverlay=null)}dispose(){this.hideMyPosition()}constructor(...t){super(...t),this.myPositionOverlay=null}};var jr=class extends B{highlightPoi(t,e){e===void 0&&(e={icon_size:[40,40],collision_enable:!1}),t.map(s=>this.bmap.getPoiById(s)).filter(s=>!!s).forEach(s=>{var o;(o=s.userData).restore||(o.restore={});for(let h in e)if(h in s.options){var n,r;(n=s.userData.restore)[r=h]||(n[r]=s.options[h]),s.options[h]=e[h]}})}restorePoi(t){t.map(i=>this.bmap.getPoiById(i)).filter(i=>!!i).forEach(i=>{console.log("poi.userData.restore",i.userData.restore);for(let s in i.userData.restore)s in i.options&&(i.options[s]=i.userData.restore[s]);i.userData.restore={}})}};import"core-js/modules/web.dom-collections.iterator.js";import"core-js/modules/es.array.sort.js";var Vr=class extends B{sortByDistance(t,e,i){return f(this,null,function*(){i===void 0&&(i=!1);let s=[...e];if(i||e.length<20)return yield Promise.all(s.map(o=>f(this,null,function*(){o.distance=yield this._getDistance(t,{floor:o.floor,x:o.center_x,y:o.center_y})}))),s.sort((o,n)=>o.distance-n.distance);{let o=s.sort((r,h)=>{let c=Math.sqrt((r.center_x-t.x)**2+(r.center_y-t.y)**2)+(t.floor===r.floor?0:100),l=Math.sqrt((h.center_x-t.x)**2+(h.center_y-t.y)**2)+(t.floor===h.floor?0:100);return c-l});return[...(yield Promise.all(o.slice(0,20).map(r=>f(this,null,function*(){return r.distance=yield this._getDistance(t,{floor:r.floor,x:r.center_x,y:r.center_y}),r})))).sort((r,h)=>r.distance-h.distance),...o.slice(20)]}})}_getDistance(t,e){return f(this,null,function*(){return this.navPath.getPath({floor:t.floor,coord:[t.x,t.y]},{floor:e.floor,coord:[e.x,e.y]},"",0).then(i=>i.reduce((s,o,n)=>{if(s+=o.distance,n!==i.length-1)switch(o.endType){case"escalator":case"straightLadder":case"staircase":case"ramp":s+=100;break}return s},0)).catch(i=>i==="near"?0:1/0)})}dispose(){super.dispose(),this.needDisposeNavPath&&this.navPath.dispose()}constructor(t,e){if(super(t),this.needDisposeNavPath=!1,e)this.navPath=e;else{this.navPath=new ys;let i=new Ie(t);this.needDisposeNavPath=!0,i.load(t.config.apiPath.loadPlaceInfo+"?place_id="+t.config.placeId+"&env=prod").then(s=>f(this,null,function*(){let[o,n]=yield Promise.all([i.getRoadNetworkData(),i.getFacilitiesData()]);this.navPath.setRoadData(o,n.infrastructures)}))}}};var Kd="https://robot-vr-public.bj.bcebos.com/v1/static_resource/satellite_tiles",Xd={base_url:Kd},Kr=class extends B{setVisible(t){this.tileLayer.setVisibility(t)}dispose(){this.bmap.context.scene.remove(this.tileLayer),this.tileLayer.dispose(),super.dispose()}constructor(t,e){super(t),this.options=w({},Xd,e),this.tileLayer=new pe(t.context,this.options),this.tileLayer.position.z=-1,this.bmap.context.scene.add(this.tileLayer)}};import{Box3 as Yd,Group as qd}from"three";var Xr=class extends B{addHeatmap(t,e){this.heatmap||(this.heatmap=new Wi(this.bmap.context),this.group.add(this.heatmap)),this.heatmap.loadData(t);let i=new Yd().setFromObject(e.graphicLayer);return this.heatmap.position.setZ(i.max.z+.1),this.heatmap}removeHeatMap(){this.heatmap&&(this.group.remove(this.heatmap),this.heatmap.dispose(),this.heatmap=null)}dispose(){this.removeHeatMap(),this.bmap.context.scene.remove(this.group)}constructor(t){super(t),this.heatmap=null,this.group=new qd,this.bmap.context.scene.add(this.group)}};export{Ie as AibeeLoader,xr as BMap,Dr as BMapSelect,vt as BaseSvg,As as CarInertialPosition,yi as ClickHelper,ps as Context,cs as ContextCamera,hs as ContextScene,rs as Control,vr as CrLoader,kr as CrNavPath,wr as Equipment,X as EventDispatcher,Ko as Events,At as Floor,Xn as GlbModel,J as Graphic,Ci as GraphicLayer,he as GroundTexture,Xr as Heatmap,Wi as HeatmapElement,jr as HighlightPoi,it as HooksName,ts as HoverHelper,Se as InstancedGraphic,Oi as InstancedModel,Ke as InstancedParkingSpace,$i as InstancedWall,xi as KalmanFilter,ji as Lane,H as Layer,$e as LineElement,DS as MapTypePolar,Ye as MergeAttributeGraphic,ce as MergeAttributeGroundTexture,Yi as MergeAttributeLane,Ki as MergeAttributeWall,Jn as MergeGraphic,le as MergedAttributeGraphicLine,Ri as MergedGraphicLayer,Ai as MergedModelLayer,Li as Model,zr as MulFloorNavigation,Br as MulFloorSelect,Tr as MulFloors,ys as NavPath,Lr as Navigation,be as Overlay,Di as ParkingLayer,IS as ParkingType,Ht as PathDirection,bs as PdrPosition,ae as Poi,j as Poi2,Ti as PoiLayer,ki as PoiLayer2,Nr as Position,Qe as RENDER_VERSION,Ur as RecommendParkingSpace,as as Renderer,vn as RoadNetwork,xn as RoadNetwork2,O as SENSOR_TYPE,Kr as SatelliteTile,Vn as SelectBox,Qi as Selection,xs as Sensor,Ei as Shadow,ni as Socket,Vr as SortByDistance,Ui as SvgLine,Hi as SvgPolygon,we as TaskQueue,Vi as TextTexture,pe as TileLayer,Gi as TileLoader,z as Timer,Qt as TweenUtil,Vo as UA,Zr as UseMyPosition,Ni as Wall,vi as WorkerPool,Ou as addAlphaToHexColor,me as calc_angle,Us as calc_direction,lC as calculateInstantaneousSpeed,ks as calculateLineDirection,wn as convertToSnakeCase,He as createCircle,ui as createLine,qt as createRect,No as createSvg,di as createSvgElement,of as createThreeBox,sf as createThreeLine,Wt as darkenColor,wp as defaultConfig,Zt as defaultGraphicOptions,po as defaultOptions,sl as defaultTextTextureOptions,vu as deviceToVector3,D as dispose,en as distancePointToSegment,oe as generatorKeyByObj,Ma as getAngle,Xs as getBorderPoints,pi as getCenter,dr as getConfig,am as getDirectPath,Hs as getDirectionByAngle,sn as getDistanceByPathPos,k as getLength,xu as getLongestSideDir,wu as getMinEdgeSquare,ht as getPathLength,Bt as getPointEdgeIndex,ve as getPosByPathDistance,Uo as hasChinese,Bs as hexToRgb,Wo as initDirectionalLight,Bo as initLight,hi as initShape,ng as instancedGeometiesAttributes,Gu as isAndroid,Yt as isContain,ye as isControl,Ut as isIphone,ge as isMac,Ho as isPointInPolygon,rg as isRectangle,gr as loadBuildingGround,hS as loadExternalStreet,yr as loadGraphics,og as mergeGraphicGeometries,Va as mergeGraphicLineGeometries,rm as moveOnRoute,oi as predictFuturePosition,pC as predictFutureSpeed,fe as proxyOptions,dC as removeOutliers,Pa as removeWeightPath,se as setCirclePosition,Mt as setLineStartEnd,ot as setRectPosition,mi as simplifyPath,jo as sleepByRf,Zo as sleepOnePromise,zs as sleepOneRf,tn as smoothPath,Mn as splitStrByBracket,Au as strToNumber,ft as timeoutPromise,Jm as toWebWorker,gi as transformGraphicData,Eo as transformSpeed,xe as translatePosToCenter,F as triggerWorker,C as vector3ToDevice,Ju as xhrGet};