@expofp/floorplan 3.0.0-alpha.11 → 3.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/{Debug-CdG24TNO.js → Debug-DfbBpzaA.js} +2 -2
- package/dist/browser/{Demo-orSDDEhp.js → Demo-9nX3Ze8t.js} +3 -3
- package/dist/browser/{Free-CVkfvG88.js → Free-CcNlU68J.js} +3 -3
- package/dist/browser/{Gallery-byAt942-.js → Gallery-BZojDfZ5.js} +3 -3
- package/dist/browser/{GpsLoader-Bdm0xIOk.js → GpsLoader-DtvpmRK_.js} +3 -3
- package/dist/browser/KioskStore-9CgKZ7_Y.js +216 -0
- package/dist/browser/{Mapbox-DloFGenX.js → Mapbox-DNt1naKj.js} +4 -4
- package/dist/browser/{SetKioskMode-CSGLnvuM.js → SetKioskMode-D-4L7JoE.js} +4 -4
- package/dist/browser/{ShowKiosk-DFZZ3UF3.js → ShowKiosk-ULNAsz__.js} +3 -3
- package/dist/browser/{ThreeComponent-DDjYQPXG.js → ThreeComponent-BStWIWLA.js} +4 -4
- package/dist/browser/{boolean-editor-BDA6-EZk.js → boolean-editor-CSqyOu_X.js} +3 -3
- package/dist/browser/bundle.json +26 -29
- package/dist/browser/{client-CIaQNg0L.js → client-Ca3SQ9bO.js} +2 -2
- package/dist/browser/{data-DeojhQ9l.js → data-BiWncDmi.js} +2 -2
- package/dist/browser/{debug-overlay-BMxh17e5.js → debug-overlay-CzQ4hWUN.js} +4 -4
- package/dist/browser/{debug-ui-DG09ZPYf.js → debug-ui-DMGPYlVK.js} +3 -3
- package/dist/browser/{fetch-retry.umd-Djerm8iU.js → fetch-retry.umd-CYEtSlH7.js} +1 -1
- package/dist/browser/{flex-RkXbYeB3.js → flex-BFGvV1iS.js} +2 -2
- package/dist/browser/{floorplan.ready-DOocUJOv.js → floorplan.ready-BrEhyuTm.js} +18008 -17968
- package/dist/browser/{index-CUwIlhvm.js → index-BC6Y3-P3.js} +1 -1
- package/dist/browser/{index-CsH1M7pW.js → index-BeFIoJ6b.js} +2 -2
- package/dist/browser/{index-jlJdZcGv.js → index-BqB89tei.js} +3 -3
- package/dist/browser/{index-BFfFTwRU.js → index-BuqxEypR.js} +4 -4
- package/dist/browser/{index-B7HWgssM.js → index-DGktAn6-.js} +1 -1
- package/dist/browser/{index-t2Qtb-FM.js → index-Du62yX73.js} +2 -2
- package/dist/browser/index-k8Qo-0Dy.js +10220 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/{particles.min-DU4QgXsV.js → particles.min-Bo4ztMtY.js} +1 -1
- package/dist/esm/components/Bookmarks.d.ts +0 -1
- package/dist/esm/components/Bookmarks.js +1 -1
- package/dist/esm/components/Kiosk/KioskStore.d.ts +3 -3
- package/dist/esm/components/Kiosk/KioskStore.js +1 -1
- package/dist/esm/components/Map/Map.d.ts +0 -23
- package/dist/esm/components/Map/Map.js +1 -1
- package/dist/esm/components/Map/drawing/config/TextFitter.d.ts +1 -1
- package/dist/esm/components/Map/drawing/config/config-all.d.ts +2 -3
- package/dist/esm/components/Map/drawing/config/config-all.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-bg.d.ts +1 -1
- package/dist/esm/components/Map/drawing/config/config-bg.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booth-bg.d.ts +5 -5
- package/dist/esm/components/Map/drawing/config/config-booth-bg.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booth-bookmark.d.ts +5 -5
- package/dist/esm/components/Map/drawing/config/config-booth-bookmark.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booth-border.d.ts +3 -3
- package/dist/esm/components/Map/drawing/config/config-booth-border.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booth-labels-special.d.ts +6 -6
- package/dist/esm/components/Map/drawing/config/config-booth-labels-special.js +2 -2
- package/dist/esm/components/Map/drawing/config/config-booth-labels.d.ts +5 -5
- package/dist/esm/components/Map/drawing/config/config-booth-labels.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booth-scaled.d.ts +3 -3
- package/dist/esm/components/Map/drawing/config/config-booth-scaled.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-booths.d.ts +2 -2
- package/dist/esm/components/Map/drawing/config/config-booths.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-load-layer.d.ts +2 -2
- package/dist/esm/components/Map/drawing/config/config-load-layer.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-markers.d.ts +2 -3
- package/dist/esm/components/Map/drawing/config/config-markers.js +1 -1
- package/dist/esm/components/Map/drawing/config/config-wf.d.ts +2 -3
- package/dist/esm/components/Map/drawing/config/config-wf.js +1 -1
- package/dist/esm/components/Map/drawing/config/loadBoothsImages.d.ts +2 -3
- package/dist/esm/components/Map/drawing/config/loadBoothsImages.js +1 -1
- package/dist/esm/components/Map/traffic/useBuildRoute.d.ts +3 -5
- package/dist/esm/components/Map/traffic/useBuildRoute.js +6 -6
- package/dist/esm/components/Map/traffic/useManageTraffic.d.ts +3 -5
- package/dist/esm/components/Map/traffic/useManageTraffic.js +1 -1
- package/dist/esm/components/SidebarActions.d.ts +3 -0
- package/dist/esm/components/SidebarActions.js +1 -1
- package/dist/esm/components/Wayfinding.js +1 -1
- package/dist/esm/data/tours.json +74 -0
- package/dist/esm/floorplan.ready.d.ts +2 -2
- package/dist/esm/floorplan.ready.js +1 -1
- package/dist/esm/index.d.ts +0 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/offline/offlineManager.js +1 -1
- package/dist/esm/renderer/HandlerRegistry.d.ts +18 -0
- package/dist/esm/renderer/HandlerRegistry.js +1 -0
- package/dist/esm/renderer/RendererService.d.ts +26 -0
- package/dist/esm/renderer/RendererService.js +1 -0
- package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/canvases.d.ts +1 -1
- package/dist/esm/renderer/engine-core/canvases.js +1 -0
- package/dist/esm/renderer/engine-core/fonts.js +1 -0
- package/dist/esm/{components/Map/drawing/config/engine-core → renderer}/index.d.ts +10 -10
- package/dist/esm/renderer/index.js +1 -0
- package/dist/esm/store/BookmarksStore.d.ts +1 -2
- package/dist/esm/store/BookmarksStore.js +2 -2
- package/dist/esm/store/LayerStore.js +1 -1
- package/dist/esm/store/RootStore.d.ts +6 -8
- package/dist/esm/store/RootStore.js +1 -1
- package/dist/esm/store/RouteStore.js +1 -1
- package/dist/esm/store/UIState.d.ts +3 -3
- package/dist/esm/store/UIState.js +1 -1
- package/dist/esm/utils/mapEntity.js +1 -1
- package/dist/esm/utils/shortenName.js +1 -1
- package/dist/esm/utils/useRenderTarget.js +1 -1
- package/dist/esm/utils/wayfinding.d.ts +1 -1
- package/dist/esm/utils/wayfinding.js +1 -1
- package/package.json +3 -7
- package/dist/browser/KioskStore-D2NCiJjy.js +0 -216
- package/dist/browser/index-yzyqTrur.js +0 -12540
- package/dist/browser/sw.js +0 -2
- package/dist/esm/components/Map/drawing/config/engine-core/canvases.js +0 -1
- package/dist/esm/components/Map/drawing/config/engine-core/fonts.js +0 -1
- package/dist/esm/components/Map/drawing/config/engine-core/index.js +0 -1
- package/dist/esm/components/Map/drawing/config/engine-core/renderer.d.ts +0 -4
- package/dist/esm/components/Map/drawing/config/engine-core/renderer.js +0 -1
- package/dist/esm/expofp-debug.d.ts +0 -5
- package/dist/esm/expofp-debug.js +0 -1
- package/dist/esm/offline/sw.d.ts +0 -2
- package/dist/esm/offline/sw.js +0 -1
- package/dist/stats.html +0 -4950
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/animation.d.ts +0 -0
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/animation.js +0 -0
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/defs.d.ts +0 -0
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/defs.js +0 -0
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/fonts.d.ts +0 -0
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/settings.d.ts +0 -0
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/settings.js +0 -0
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/types.d.ts +0 -0
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/types.js +0 -0
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/update-def.d.ts +0 -0
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/update-def.js +0 -0
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/utils/rotation.d.ts +0 -0
- /package/dist/esm/{components/Map/drawing/config → renderer}/engine-core/utils/rotation.js +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MapRenderer } from "../../Map";
|
|
1
|
+
import { RendererService } from "../../../../renderer";
|
|
3
2
|
export declare const MARKER_LAYER_NAME = "markers";
|
|
4
|
-
export declare function configMarkers(
|
|
3
|
+
export declare function configMarkers(rendererService: RendererService): () => void;
|
|
5
4
|
export declare function getMarkerFromClick(x: number, y: number, scale: number): import("../../../../store/RouteStore").Marker | null;
|
|
6
5
|
//# sourceMappingURL=config-markers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import u,{layersStore as
|
|
1
|
+
import u,{layersStore as I}from"../../../../store";import{reaction as v}from"mobx";import{createImageCanvas as C}from"./canvases";import{createImageDef as x,getBounds as R}from"../../../../renderer";import{toRadians as F}from"../../../../utils/toRadians";const L="_selected";export const MARKER_LAYER_NAME="markers";export function configMarkers(a){const h=[],l=new Map,s=new Map;let n=[];const m=a.scene.rootLayer.children.find(e=>e.name===MARKER_LAYER_NAME);async function k(e){const o=[];e.forEach(c=>{const{name:i,content:t,width:r,height:g,scale:y}=c;if(l.has(i))return;const f=new Image,M=new Promise((D,w)=>{f.onload=()=>{l.set(i,{img:f,width:r,height:g,scale:y}),D()},f.onerror=S=>{w(S)}});o.push(M),f.src=t,f.crossOrigin="anonymous"}),await Promise.all(o)}const d=e=>`marker-ptScaleHandlers-${e.id}`,E=e=>`marker-rollHandlers-${e.id}`,P=(e,o)=>{a.onPtScale(o,c=>{const{center:i,rotation:t}=e.bounds,{width:r,height:g}=e.source;return e.bounds=R(i.x,i.y,r,g,c,t),e})},H=(e,o)=>{a.onRoll(o,c=>(e.bounds.rotation=c,e))};function $(){const e=u.routeStore.markersData.markers;if(!e.length)return;n=[];const o=a.getCameraState(),c=o?.ptScale||1,i=F(o?.roll)||0;e.forEach(t=>{const r=l.get(t.icon);if(!r)return;const g=r.scale||window.devicePixelRatio,y=t.icon;if(!s.has(y)){const b=C(r.img,r.width,r.height,g);s.set(y,b)}const f=s.get(y),M=l.get(t.selectedIcon),D=t.selectedIcon;if(!s.has(D)){const b=C(r.img,M.width,M.height,g);s.set(D,b)}const w=s.get(D),S=I.findLayer(t.z)?.visible??!0,_=R(t.x,t.y,f.width,f.height,c,i),z=R(t.x,t.y,w.width,w.height,c,i);let p;switch(t.position){case"lefttop":p=[0,0];break;case"centertop":p=[.5,0];break;case"centerbottom":p=[.5,1];break;default:p=[.5,.5]}const A={...x(f,_,{hidden:!S,origin:p}),id:t.id,scale:g},K={...x(w,z,{hidden:!(S&&t.active),origin:p}),id:`${t.id}${L}`,scale:g};n.push(A,K)}),m.children=n,n.forEach(t=>{P(t,d(t)),H(t,E(t))})}function B(){n.forEach(e=>{a.ptScaleRegistry.unregisterByName(d(e)),a.rollRegistry.unregisterByName(E(e))}),m.children=[],n=[]}function N(){const e=u.routeStore.markersData.markers;e.length&&e.forEach(o=>{const c=n.find(r=>r.id===o.id),i=n.find(r=>r.id===`${o.id}${L}`);if(!c)return;const t=I.findLayer(o.z)?.visible??!0;o.active?(c.hidden=!0,i.hidden=!(t&&o.active)):(c.hidden=!t,i.hidden=!0)})}return h.push(v(()=>[u.routeStore.selectedMarkers,u.layerStore.visible],()=>{if(!u.routeStore.markersData.markers.length){B(),a.update(m);return}N(),a.update(...n)})),h.push(v(()=>u.routeStore.markersData.markers,()=>{k(u.routeStore.markersData.icons).then(()=>{$(),a.update(m)})})),function(){h.forEach(o=>o()),h.length=0}}export function getMarkerFromClick(a,h,l){for(const s of u.routeStore.markersData.markers){const n=u.routeStore.markersData.icons.find(d=>d.name===s.icon);if(!n)continue;const m=n.width*l*devicePixelRatio,k=n.height*l*devicePixelRatio;if(O(a,h,s.x,s.y,m,k)){const d=u.layerStore.findLayer(s.z);if(!d||d&&d.visible)return s}}return null}function O(a,h,l,s,n,m){const k=a>=l-n&&a<=l+n,d=h>=s-m&&h<=s+m;return k&&d}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Point, Line } from "simple-geometry";
|
|
2
|
-
import {
|
|
3
|
-
import { MapRenderer } from "../../Map";
|
|
2
|
+
import { RendererService } from "../../../../renderer";
|
|
4
3
|
export declare const WF_TRAIL_LAYER_NAME = "wf-trail-points";
|
|
5
4
|
export declare const WF_POINTS_LAYER_NAME = "wf-points";
|
|
6
5
|
export declare const WF_CURRENT_POSITION_NAME = "wf-current-position";
|
|
7
6
|
export declare const WF_LINES_LAYER_NAME = "wf-lines";
|
|
8
7
|
export declare const WF_LINES_ANIMATED_LAYER_NAME = "wf-lines-animated";
|
|
9
|
-
export default function configWf(
|
|
8
|
+
export default function configWf(rendererService: RendererService): () => void;
|
|
10
9
|
export declare function splitPolyLine(lines: Line[], interval: number): Point[];
|
|
11
10
|
//# sourceMappingURL=config-wf.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import ft from"color";import{observable as pt,reaction as st}from"mobx";import{lineLength as bt}from"simple-geometry";import Ot from"../../../../core/Rect";import s,{layersStore as vt,uiState as g}from"../../../../store";import{LayersMode as Ct}from"../../../../store/LayerStore";import{getGraphLines as kt,getRouteLength as gt,RoutePoint as ht}from"../../../../utils/wayfinding";import{strEqual as k}from"../../../../utils/strEqual";import{createArrowCurrentCanvas as It,createCurrentCanvas as xt,createImageCanvas as et,createTargetCanvas as qt,createYahCanvas as Ut}from"./canvases";import{toRadians as Et}from"../../../../utils/toRadians";import{areLayersEnabled as Tt}from"../../../../utils/areLayersEnabled";import{createImageDef as nt,createLineDef as Rt,updateRenderer as K,createCircleCanvas as Wt,getBounds as b,getRotation as Xt}from"./engine-core";import{animateLineSegments as $t}from"./engine-core/animation";import{splitRouteByPoint as Gt,snapPositionToRoute as Kt,getThresholdSafe as jt,getThresholdFromMetersToSvg as Jt,SNAP_THRESHOLD_METERS as Qt}from"./route-snapping";import{fpGeo as At}from"../../../Mapbox/utils/fpGeo";const C=devicePixelRatio;let z=[],at=null,F=[],yt=ft("#00A2FF"),Vt=ft("#FF9F06"),_t="#A4CCE2",Zt="#0794EA";const ct=34;let j,J,Q,V,ot,Lt,Dt,Mt,dt,T,A,q,U,Z,St=[];function te(){z=[];const t=s.routeStore.currentRouteLayer?.name;at=oe();const o=at&&(Tt()?k(t,at.destination?.layer):!0);if(at){const d=at?.routePoint;d&&k(t,d.layer)&&(z=ie(d,z))}let n=[],i=[];for(let d=0;d<F.length;d++){let L=F[d],y=s.layerStore.mode==Ct.Default?!0:s.layerStore.layers.find(a=>a.name==t&&t===L.p0.layer)?.visible||!1;!L.virtual&&y&&n.push(L),(L.virtual||!y||d===F.length-1)&&n.length&&(i=n.map(({p0:a,p1:r})=>(z.push({x:a.x,y:a.y},{x:r.x,y:r.y}),{p0:a,p1:r})))}z.length||(A.hidden=!0,T.hidden=!0);let l=1e6,u=1e6,p=0,m=0;z.forEach(d=>{d.x<l&&(l=d.x),d.y<u&&(u=d.y),d.x>p&&(p=d.x),d.y>m&&(m=d.y)});const h=Ot.fromX1y1x2y2(l,u,p,m);return{rect:z.length&&(h.w||h.h)?h.withPadding(h.w,h.h):null,lines:i,addTrailPoints:o}}export const WF_TRAIL_LAYER_NAME="wf-trail-points",WF_POINTS_LAYER_NAME="wf-points",WF_CURRENT_POSITION_NAME="wf-current-position",WF_LINES_LAYER_NAME="wf-lines",WF_LINES_ANIMATED_LAYER_NAME="wf-lines-animated";export default function ee(t,o){let n=null;const i=[];let l=null,u=pt.box([]),p=pt.box([],{deep:!1}),m=pt.box([],{deep:!1});const h=o.rootLayer.children,d=h.find(e=>e.name===WF_POINTS_LAYER_NAME),L=h.find(e=>e.name===WF_CURRENT_POSITION_NAME),y=h.find(e=>e.name===WF_LINES_LAYER_NAME),a=h.find(e=>e.name===WF_TRAIL_LAYER_NAME),r=h.find(e=>e.name===WF_LINES_ANIMATED_LAYER_NAME),x=jt(At?.properties?.config?.snapThreshold)||Qt,S=Jt({thresholdInMeters:x,gpsConfig:At?.properties?.config});let v=[];const W=s.fp.icons.get("destination");W?(W.id="destination",J=et(W,ct,ct,C)):J=qt(C,Vt.hex()),A=nt(J,b(0,0,J.width,J.height),{hidden:!0});const I=s.fp.icons.get("departure");I?(I.id="departure",j=et(I,ct,ct,C)):j=xt(C,yt.hex()),T=nt(j,b(0,0,j.width,j.height),{hidden:!0}),Q=xt(C,yt.hex()),Q.id="current-location",q=nt(Q,b(0,0,Q.width,Q.height),{hidden:!0,origin:[.5,.5]});const R=s.fp.icons.get("transition");R?(R.id="transition",Lt=et(R,34,34,C)):Lt=xt(C,yt.hex());const _=s.fp.icons.get("transition_up");_&&(_.id="transition_up",Dt=et(_,56,34,C));const Y=s.fp.icons.get("transition_down");Y&&(Y.id="transition_down",Mt=et(Y,56,34,C));const tt=s.fp.icons.get("direction");tt?(tt.id="direction",V=et(tt,ct,ct,C)):V=It(C,yt.hex()),U=nt(V,b(0,0,V.width,V.height),{hidden:!0});const B=s.fp.icons.get("yah");B?ot=et(B,mt(64,32),mt(90,32),C):ot=Ut(C,"#ff4343"),ot.id="current-location-2",Z=nt(ot,b(0,0,ot.width,ot.height),{hidden:!0,origin:[.5,1]}),dt=Wt(4,ft("#b5b7bc").hex());function N(e=null){const f=s.layerStore.visible.map(c=>c.name);if(z=[],u.set([]),e||(F=[]),f.length&&g.selectedRoute?.from?.rect&&g.selectedRoute?.to?.rect){let c=g.selectedRoute.from,w=g.selectedRoute.to;if(!F.length&&!e&&(F=kt(c,w,s.routeStore.onlyAccessible,g.selectedRoute.waypoints)),!F.length){if(s.routeStore.updateRoute(F),s.routeStore.updateRouteDistance(0),c.name!==w.name)throw new Error(`Route not found. From: ${c.name} to: ${w.name}`);return}const{rect:E,lines:O,addTrailPoints:P}=te();O.length&&(ne(t.scale),re(t.scale,p),Ft(t,a,!P)),v=O,ut(),E&&(g.moveToRect=E)}else T.hidden=!0,A.hidden=!0;s.routeStore.updateRoute(F.filter(c=>!c.virtual)),u.get()||(T.hidden=!0,A.hidden=!0)}function X(){const e=s.routeStore.currentPosition,f=e?.angle?Et(e.angle):null,c=s.routeStore.currentRouteLayer?.name,w=F.filter(M=>s.layerStore.mode==Ct.Default?!0:s.layerStore.layers.find(Bt=>Bt.name==c&&c===M.p0.layer)?.visible).filter(M=>!M.virtual);if(g.kioskData&&g.selectedRoute?.from){const M=s.routeStore.currentRouteLayer;T.hidden=g.selectedRoute?.from?.entity?.type==="route-cut-in"&&M?.name===g.selectedRoute?.from?.layer?.name,A.hidden=g.selectedRoute?.to?.entity?.type==="route-cut-in"&&M?.name===g.selectedRoute?.to?.layer?.name}if(e){const M=vt.findLayer(e.z)?.visible??!0;s.routeStore.iconType===0||g.selectedRoute?.from&&g.selectedRoute?.to?(Z.hidden=!0,q.hidden=!M,q.dim=!M,q.bounds=b(e.x,e.y,Q.width,Q.height,t.scale),f!=null?(q.hidden=!0,U.hidden=!M,U.dim=!M,U.bounds=b(e.x,e.y,V.width,V.height,t.scale,f)):U.hidden=!0):(q.hidden=!0,U.hidden=!0,Z.dim=!M,Z.hidden=!M,Z.bounds=b(e.x,e.y,ot.width,ot.height,t.scale))}else q.hidden=!0,Z.hidden=!0,U.hidden=!0,it(),ut();if(!e||!z.length){K(t,U,q,Z);return}const E=g.selectedRoute?.to,O=g.selectedRoute?.from,P=new ht(O?.layer?.name,T.bounds.center.x,T.bounds.center.y),D=new ht(E?.layer?.name,A.bounds.center.x,A.bounds.center.y),$=Kt(e,w,{snapThreshold:S,fromPoint:P,toPoint:D,fromRect:O?.rect,toRect:E?.rect}),G=$.snapped?$.snappedPoint:e;ut($,!0),U.bounds=b(G.x,G.y,V.width,V.height,t.scale,f),q.bounds=b(G.x,G.y,Q.width,Q.height,t.scale,f),K(t,U,q,Z)}function lt(){const e=[U,q,Z];L.children=e,e.forEach(f=>rt(f)),K(t,L)}function H(e=!1){const f=[T,A,...p.get(),...m.get()];e&&(Ht(!0),a.children=[],f.forEach(c=>{c.source.id.includes("kiosk")||(c.hidden=!0)})),d.children=f,K(t,d,a)}function it(e,f){const c=F.filter(D=>!D.virtual),w=gt(c);if(!e?.snapped){s.routeStore.updateRouteDistance(w);return}const E=g.selectedRoute?.to,O=gt(f);let P;if(e.snappedPoint?.layer===E?.layer?.name||E?.layer?.name===s.routeStore.currentRouteLayer?.name)P=O;else if(e.snappedPoint?.layer!==E?.layer?.name&&e.snappedPoint?.layer===s.routeStore.currentRouteLayer?.name){const D=c.filter(G=>G.p0.layer!==e?.snappedPoint?.layer&&G.p1.layer!==e?.snappedPoint?.layer),$=gt(D);P=O+$}P&&s.routeStore.updateRouteDistance(P)}function ut(e,f=!1){const c=g.selectedRoute?.from,w=g.selectedRoute?.to;if(!c||!w)return;const E=ae(F,v,new ht(c?.layer?.name,c?.rect.cx,c?.rect.cy),new ht(w?.layer?.name,w?.rect.cx,w?.rect.cy));if(!e?.snapped){const D=E.map($=>Rt($,_t));s.routeStore.currentPosition&&s.routeStore.currentRouteLayer&&s.routeStore.currentPosition?.z?.toString()===s.routeStore.currentRouteLayer?.name.toString()&&it(),Pt([],D,f);return}const{passed:O,remaining:P}=Gt(E,e.snappedPoint);P.length&&(P[0]={...P[0],p0:e.snappedPoint}),it(e,P),Pt(O.map(D=>Rt(D,"#B5B7BC")),P.map(D=>Rt(D,_t)),f)}const rt=(e,f)=>{t.ptScaleHandlers.push({fn:c=>(e.hidden||(e.bounds=b(e.bounds.center.x,e.bounds.center.y,e.source.width,e.source.height,c,e.bounds.rotation)),e),name:f})},wt=(e,f)=>{t.rollHandlers.push({fn:c=>{const w=Xt(c,e.bounds.rotation);return w!==void 0&&(e.bounds.rotation=e.bounds.rotation+w),e},name:f})};function Ht(e){n&&(n.stop(),n=null),r.children=[],e&&(y.children=[]),K(t,r,y)}function Pt(e=[],f=[],c=!1){let w=0;if(n&&(c&&(w=n.getProgress()),n.stop(),n=null),y.children=[...e,...f],!f.length){r.children=[],K(t,r,y);return}const E=f.map(P=>({...P,color:Zt}));n=$t(E,(P,D,$)=>{if($)r.children=[];else{const G=E.slice(0,D);r.children=[...G,P]}K(t,r)},()=>t.scale,w)??null,K(t,y)}i.push(st(()=>[s.layerStore.layersLoaded],()=>{N(),X(),H()}));const zt=st(()=>[s.routeStore.currentRouteLayer,g.getRouteNextFloor],()=>{s.layerStore.layersLoaded&&(l!==null&&clearTimeout(l),l=setTimeout(()=>{N(s.routeStore.currentRouteLayer),X(),H(),l=null},0))});i.push(()=>{l!==null&&(clearTimeout(l),l=null),zt()}),i.push(st(()=>[g.selectedRoute,s.routeStore.onlyAccessible],()=>{N(),X(),H(!g.selectedRoute)})),i.push(st(()=>s.routeStore.currentPosition,()=>{X(),H()})),i.push(st(()=>p.get(),e=>{const f="transitionPoints";t.ptScaleHandlers=t.ptScaleHandlers.filter(c=>c.name!==f),e.length&&e.forEach(c=>{rt(c,f),wt(c,f)})})),i.push(st(()=>[m.get()],()=>{const e=m.get(),f="kioskArrows";t.ptScaleHandlers=t.ptScaleHandlers.filter(c=>c.name!==f),e.length&&e.forEach(c=>rt(c,f))})),i.push(st(()=>[g.kioskData,vt.floors.find(e=>e.active),g.selectedRoute],([e,f])=>{m.set([]);const c=Tt()?e?.z===f?.name:!0;e&&c&&se(e,{skipdim:!0,visible:!0,pixelRatio:C},t.scale,m),H()})),[T,A].forEach(e=>{rt(e),wt(e)}),H(),X(),lt();function Yt(){n&&(n.stop(),n=null),i.forEach(e=>e()),i.length=0}return Yt}function ne(t){const o=s.routeStore.currentRouteLayer?.name,n=z;let i=g.selectedRoute?.from,l=g.selectedRoute?.to;const u=g.selectedRoute?.waypoints;if(i?.entity.type==="route-cut-in"&&(i=null),l?.entity.type==="route-cut-in"&&(l=null),!n.length)return;const p=[{key:"sourceLocation",rect:i?.rect,index:void 0},{key:"destinationLocation",rect:l?.rect,index:void 0}];u&&p.push(...u?.map((y,a)=>({key:`waypoint-${y.externalId}`,index:a,rect:y.rect})));const m=o?k(o,i?.layer?.name):!0,h=o?k(o,l?.layer?.name):!0;let d=!1,L=!1;n.forEach(({x:y,y:a})=>{for(const{key:r,rect:x,index:S}of p)if(x?.containsPoint(y,a)){r==="sourceLocation"&&(T.bounds=b(y,a,j.width,j.height,t),T.hidden=!m,T.dim=!m,d=m),r==="destinationLocation"&&(A.bounds=b(y,a,J.width,J.height,t),A.hidden=!h,A.dim=!h,L=h);break}}),d||(T.bounds=b(n[n.length-1].x,n[n.length-1].y,j.width,j.height,t),T.hidden=!1,T.dim=!1),L||(A.bounds=b(n[0].x,n[0].y,J.width,J.height,t),A.hidden=!h,A.dim=!h)}function oe(){const{from:t,to:o}=s.uiState.selectedRoute||{},n="route-cut-in";return t&&t?.entity.type===n||o&&o?.entity.type===n?s.routeStore.defaultFrom:null}function ie(t,o){if(!t||!o.length)return o;const n=o.reduce((i,l,u)=>bt(t,l)<bt(t,o[i])?u:i,0);return n<=o.length/2?o.slice(n):o.slice(0,n)}function re(t,o){const n=s.routeStore.currentRouteLayer?.name,i=g.getRouteNextFloor,l=s.layerStore.floors.map(a=>a.name),u=(a,r)=>a.findIndex(x=>k(x,r)),p=u(l,n),m=u(l,i),h=m!==-1,d=F.filter(a=>n?a.virtual&&(k(a.p0.layer,n)||k(a.p1.layer,n))&&(k(a.p0.layer,i)||k(a.p1.layer,i)):a.virtual).flatMap(a=>[a.p0,a.p1]),L=[];let y;d.forEach(a=>{if(i&&!k(a.layer,i)&&(h&&m>p&&s.fp.icons.get("transition_up")?y=Mt:h&&m<p&&s.fp.icons.get("transition_down")?y=Dt:y=Lt),y){const r=k(n,a.layer),x=b(a.x,a.y,y.width,y.height,t),S=nt(y,x,{hidden:!r,dim:!1});L.push(S)}}),o.set(L)}function se(t,o,n=1,i){if(!t)return;const l=s.fp.icons.get("kiosk");l.id="kiosk";let u;if(l){const m=t?.iconSizePercent?t.iconSizePercent/100:1,h=55;u=et(l,mt(199*m,h),mt(152*m,h),C)}else u=It(C,ft("#ee4422").hex());const p=nt(u,b(t.x,t.y,u.width,u.height,n,Et(t.heading||0)),{hidden:!o.visible,dim:!o.skipdim});i.set([...i.get(),p])}function mt(t,o){return t*(1-o/100)}function Ft(t,o,n=!1){t.ptScaleHandlers=t.ptScaleHandlers.filter(S=>S.name!==o.name);let i=z.length-1;if(g.selectedRoute?.to?.entity.type==="route-cut-in"&&(i=0),n){St=[],o.children=[],K(t,o);return}const l=t.scale,u=z[i],p=at?.destination;if(!u||!p)return;const m=dt.width,h=splitPolyLine([{p0:u,p1:p}],m*2*l);if(h.length<2)return;const d=p.x-u.x,L=p.y-u.y,y=Math.hypot(d,L),a={x:(u.x+p.x)/2,y:(u.y+p.y)/2-y*.2},r=[u,a,p],x=h.map((S,v,W)=>{const I=(v+1)/(W.length+1),R=Nt(r,I);return nt(dt,b(R.x,R.y,dt.width,dt.height,l),{hidden:!1,dim:!1})})||[];return o.children=x,t.ptScaleHandlers.push({fn:S=>{t.scale=S;const v=Ft(t,o)||[];return o.children=v,St=v,o},name:o.name}),St=x,x}function Nt(t,o){if(t.length===1)return t[0];const n=[];for(let i=0;i<t.length-1;i++){const l=(1-o)*t[i].x+o*t[i+1].x,u=(1-o)*t[i].y+o*t[i+1].y;n.push({x:l,y:u})}return Nt(n,o)}export function splitPolyLine(t,o){if(t.length===0)return[];const n=[];let i=0;for(let m=0;m<t.length;m++){const h=t[m],d=h.p0,L=h.p1,y=L.x-d.x,a=L.y-d.y,r=Math.sqrt(y*y+a*a);if(r===0)continue;const x=y/r,S=a/r;let v=0;for(;i+v*o<=r;){const R=i+v*o,_=d.x+x*R,Y=d.y+S*R;n.push({x:_,y:Y}),v++}const W=i+(v-1)*o;let I=r-W;if(I=Math.max(I,0),m<t.length-1){const R=t[m+1],_=R.p0,Y=R.p1,tt=Y.x-_.x,B=Y.y-_.y,N=Math.sqrt(tt*tt+B*B);if(N===0)i=0;else{const X=tt/N,lt=B/N,H=x*X+S*lt,it=I*H;i=o-it}}else i=o-I;i=Math.max(i,0)}const l=t[0].p0;(n.length===0||!n[0]||n[0].x!==l.x||n[0].y!==l.y)&&n.unshift(l);const u=t[t.length-1].p1,p=n[n.length-1];return(n.length===0||!p||p.x!==u.x||p.y!==u.y)&&n.push(u),n}function ae(t,o,n,i){if(!o.length)return o;const l=new Array(t.length);let u=0;for(let r=0;r<t.length;r++){const x=t[r],S=Math.hypot(x.p1.x-x.p0.x,x.p1.y-x.p0.y);l[r]=S,u+=S}const p=r=>r?String(r):null;function m(r){let x=0,S=1/0,v=1/0;const W=p(r.layer);for(let I=0;I<t.length;I++){const R=t[I],_=l[I],Y=p(R.p0.layer);if(!(W===null||Y===null||Y===W)){x+=_;continue}const B=R.p1.x-R.p0.x,N=R.p1.y-R.p0.y,X=B*B+N*N;if(X===0){x+=_;continue}const lt=((r.x-R.p0.x)*B+(r.y-R.p0.y)*N)/X,H=Math.max(0,Math.min(1,lt)),it=R.p0.x+B*H,ut=R.p0.y+N*H,rt=Math.hypot(r.x-it,r.y-ut);rt<S&&(S=rt,v=x+_*H),x+=_}return{found:v!==1/0,fromStart:v,total:u}}const h=m(n),d=h.found?h:m(i);if(!d.found)return o;const L=d.fromStart,y=d.total-d.fromStart;return(h.found?y<L:L<y)?o.slice().reverse().map(r=>({...r,p0:r.p1,p1:r.p0})):o}
|
|
1
|
+
import dt from"color";import{observable as mt,reaction as it}from"mobx";import{lineLength as Pt}from"simple-geometry";import Yt from"../../../../core/Rect";import s,{layersStore as bt,uiState as g}from"../../../../store";import{LayersMode as St}from"../../../../store/LayerStore";import{getGraphLines as $t,getRouteLength as pt,RoutePoint as ft}from"../../../../utils/wayfinding";import{strEqual as O}from"../../../../utils/strEqual";import{createArrowCurrentCanvas as Ct,createCurrentCanvas as gt,createImageCanvas as Z,createTargetCanvas as Ot,createYahCanvas as kt}from"./canvases";import{toRadians as It}from"../../../../utils/toRadians";import{areLayersEnabled as Et}from"../../../../utils/areLayersEnabled";import{createImageDef as tt,createLineDef as xt,createCircleCanvas as Ht,getBounds as S,getRotation as qt}from"../../../../renderer";import{animateLineSegments as Ut}from"../../../../renderer/engine-core/animation";import{splitRouteByPoint as Wt,snapPositionToRoute as Xt,getThresholdSafe as Gt,getThresholdFromMetersToSvg as Kt,SNAP_THRESHOLD_METERS as jt}from"./route-snapping";import{fpGeo as Tt}from"../../../Mapbox/utils/fpGeo";const I=devicePixelRatio;let z=[],at=null,v=[],ht=dt("#00A2FF"),Jt=dt("#FF9F06"),At="#A4CCE2",Qt="#0794EA";const ct=34;let K,j,J,Q,et,Rt,_t,Dt,lt,A,_,k,H,V,Lt=[];function Vt(){z=[];const t=s.routeStore.currentRouteLayer?.name;at=ee();const n=at&&(Et()?O(t,at.destination?.layer):!0);if(at){const l=at?.routePoint;l&&O(t,l.layer)&&(z=ne(l,z))}let o=[],i=[];for(let l=0;l<v.length;l++){let x=v[l],d=s.layerStore.mode==St.Default?!0:s.layerStore.layers.find(r=>r.name==t&&t===x.p0.layer)?.visible||!1;!x.virtual&&d&&o.push(x),(x.virtual||!d||l===v.length-1)&&o.length&&(i=o.map(({p0:r,p1:u})=>(z.push({x:r.x,y:r.y},{x:u.x,y:u.y}),{p0:r,p1:u})))}z.length||(_.hidden=!0,A.hidden=!0);let h=1e6,c=1e6,y=0,m=0;z.forEach(l=>{l.x<h&&(h=l.x),l.y<c&&(c=l.y),l.x>y&&(y=l.x),l.y>m&&(m=l.y)});const p=Yt.fromX1y1x2y2(h,c,y,m);return{rect:z.length&&(p.w||p.h)?p.withPadding(p.w,p.h):null,lines:i,addTrailPoints:n}}export const WF_TRAIL_LAYER_NAME="wf-trail-points",WF_POINTS_LAYER_NAME="wf-points",WF_CURRENT_POSITION_NAME="wf-current-position",WF_LINES_LAYER_NAME="wf-lines",WF_LINES_ANIMATED_LAYER_NAME="wf-lines-animated";export default function Zt(t){let n=null;const o=[];let i=null,h=mt.box([]),c=mt.box([],{deep:!1}),y=mt.box([],{deep:!1});const m=t.scene.rootLayer.children,p=m.find(e=>e.name===WF_POINTS_LAYER_NAME),l=m.find(e=>e.name===WF_CURRENT_POSITION_NAME),x=m.find(e=>e.name===WF_LINES_LAYER_NAME),d=m.find(e=>e.name===WF_TRAIL_LAYER_NAME),r=m.find(e=>e.name===WF_LINES_ANIMATED_LAYER_NAME),u=Gt(Tt?.properties?.config?.snapThreshold)||jt,R=Kt({thresholdInMeters:u,gpsConfig:Tt?.properties?.config});let E=[];const D=s.fp.icons.get("destination");D?(D.id="destination",j=Z(D,ct,ct,I)):j=Ot(I,Jt.hex()),_=tt(j,S(0,0,j.width,j.height),{hidden:!0});const q=s.fp.icons.get("departure");q?(q.id="departure",K=Z(q,ct,ct,I)):K=gt(I,ht.hex()),A=tt(K,S(0,0,K.width,K.height),{hidden:!0}),J=gt(I,ht.hex()),J.id="current-location",k=tt(J,S(0,0,J.width,J.height),{hidden:!0,origin:[.5,.5]});const T=s.fp.icons.get("transition");T?(T.id="transition",Rt=Z(T,34,34,I)):Rt=gt(I,ht.hex());const L=s.fp.icons.get("transition_up");L&&(L.id="transition_up",_t=Z(L,56,34,I));const M=s.fp.icons.get("transition_down");M&&(M.id="transition_down",Dt=Z(M,56,34,I));const Y=s.fp.icons.get("direction");Y?(Y.id="direction",Q=Z(Y,ct,ct,I)):Q=Ct(I,ht.hex()),H=tt(Q,S(0,0,Q.width,Q.height),{hidden:!0});const nt=s.fp.icons.get("yah");nt?et=Z(nt,yt(64,32),yt(90,32),I):et=kt(I,"#ff4343"),et.id="current-location-2",V=tt(et,S(0,0,et.width,et.height),{hidden:!0,origin:[.5,1]}),lt=Ht(4,dt("#b5b7bc").hex());function B(e=null){const a=s.layerStore.visible.map(f=>f.name);if(z=[],h.set([]),e||(v=[]),a.length&&g.selectedRoute?.from?.rect&&g.selectedRoute?.to?.rect){let f=g.selectedRoute.from,w=g.selectedRoute.to;if(!v.length&&!e&&(v=$t(f,w,s.routeStore.onlyAccessible,g.selectedRoute.waypoints)),!v.length){if(s.routeStore.updateRoute(v),s.routeStore.updateRouteDistance(0),f.name!==w.name)throw new Error(`Route not found. From: ${f.name} to: ${w.name}`);return}const{rect:b,lines:$,addTrailPoints:P}=Vt();$.length?(te(t.scale),oe(t.scale,c),Nt(t,d,!P),t.ptScaleRegistry.unregisterByName(d.name),P&&t.onPtScale(d.name,()=>{const C=Nt(t,d)||[];return d.children=C,Lt=C,d})):t.ptScaleRegistry.unregisterByName(d.name),E=$,ot(),b&&(g.moveToRect=b)}else A.hidden=!0,_.hidden=!0;s.routeStore.updateRoute(v.filter(f=>!f.virtual)),h.get()||(A.hidden=!0,_.hidden=!0)}function N(){const e=s.routeStore.currentPosition,a=e?.angle?It(e.angle):null,f=s.routeStore.currentRouteLayer?.name,w=v.filter(F=>s.layerStore.mode==St.Default?!0:s.layerStore.layers.find(zt=>zt.name==f&&f===F.p0.layer)?.visible).filter(F=>!F.virtual);if(g.kioskData&&g.selectedRoute?.from){const F=s.routeStore.currentRouteLayer;A.hidden=g.selectedRoute?.from?.entity?.type==="route-cut-in"&&F?.name===g.selectedRoute?.from?.layer?.name,_.hidden=g.selectedRoute?.to?.entity?.type==="route-cut-in"&&F?.name===g.selectedRoute?.to?.layer?.name}if(e){const F=bt.findLayer(e.z)?.visible??!0;s.routeStore.iconType===0||g.selectedRoute?.from&&g.selectedRoute?.to?(V.hidden=!0,k.hidden=!F,k.dim=!F,k.bounds=S(e.x,e.y,J.width,J.height,t.scale),a!=null?(k.hidden=!0,H.hidden=!F,H.dim=!F,H.bounds=S(e.x,e.y,Q.width,Q.height,t.scale,a)):H.hidden=!0):(k.hidden=!0,H.hidden=!0,V.dim=!F,V.hidden=!F,V.bounds=S(e.x,e.y,et.width,et.height,t.scale))}else k.hidden=!0,V.hidden=!0,H.hidden=!0,W(),ot();if(!e||!z.length){t.update(H,k,V);return}const b=g.selectedRoute?.to,$=g.selectedRoute?.from,P=new ft($?.layer?.name,A.bounds.center.x,A.bounds.center.y),C=new ft(b?.layer?.name,_.bounds.center.x,_.bounds.center.y),X=Xt(e,w,{snapThreshold:R,fromPoint:P,toPoint:C,fromRect:$?.rect,toRect:b?.rect}),G=X.snapped?X.snappedPoint:e;ot(X,!0),H.bounds=S(G.x,G.y,Q.width,Q.height,t.scale,a),k.bounds=S(G.x,G.y,J.width,J.height,t.scale,a),t.update(H,k,V)}function rt(){const e=[{point:H,name:"wf-current-arrow"},{point:k,name:"wf-current-location"},{point:V,name:"wf-current-location-2"}];l.children=e.map(({point:a})=>a),e.forEach(({point:a,name:f})=>st(a,f)),t.update(l)}function U(e=!1){const a=[A,_,...c.get(),...y.get()];e&&(Ft(!0),d.children=[],a.forEach(f=>{f.source.id.includes("kiosk")||(f.hidden=!0)})),p.children=a,t.update(p,d)}function W(e,a){const f=v.filter(C=>!C.virtual),w=pt(f);if(!e?.snapped){s.routeStore.updateRouteDistance(w);return}const b=g.selectedRoute?.to,$=pt(a);let P;if(e.snappedPoint?.layer===b?.layer?.name||b?.layer?.name===s.routeStore.currentRouteLayer?.name)P=$;else if(e.snappedPoint?.layer!==b?.layer?.name&&e.snappedPoint?.layer===s.routeStore.currentRouteLayer?.name){const C=f.filter(G=>G.p0.layer!==e?.snappedPoint?.layer&&G.p1.layer!==e?.snappedPoint?.layer),X=pt(C);P=$+X}P&&s.routeStore.updateRouteDistance(P)}function ot(e,a=!1){const f=g.selectedRoute?.from,w=g.selectedRoute?.to;if(!f||!w)return;const b=re(v,E,new ft(f?.layer?.name,f?.rect.cx,f?.rect.cy),new ft(w?.layer?.name,w?.rect.cx,w?.rect.cy));if(!e?.snapped){const C=b.map(X=>xt(X,At));s.routeStore.currentPosition&&s.routeStore.currentRouteLayer&&s.routeStore.currentPosition?.z?.toString()===s.routeStore.currentRouteLayer?.name.toString()&&W(),wt([],C,a);return}const{passed:$,remaining:P}=Wt(b,e.snappedPoint);P.length&&(P[0]={...P[0],p0:e.snappedPoint}),W(e,P),wt($.map(C=>xt(C,"#B5B7BC")),P.map(C=>xt(C,At)),a)}const st=(e,a)=>t.onPtScale(a,f=>(e.hidden||(e.bounds=S(e.bounds.center.x,e.bounds.center.y,e.source.width,e.source.height,f,e.bounds.rotation)),e)),ut=(e,a)=>t.onRoll(a,f=>{const w=qt(f,e.bounds.rotation);return w!==void 0&&(e.bounds.rotation=e.bounds.rotation+w),e});function Ft(e){n&&(n.stop(),n=null),r.children=[],e&&(x.children=[]),t.update(r,x)}function wt(e=[],a=[],f=!1){let w=0;if(n&&(f&&(w=n.getProgress()),n.stop(),n=null),x.children=[...e,...a],!a.length){r.children=[],t.update(r,x);return}const b=a.map(P=>({...P,color:Qt}));n=Ut(b,(P,C,X)=>{if(X)r.children=[];else{const G=b.slice(0,C);r.children=[...G,P]}t.update(r)},()=>t.scale,w)??null,t.update(x)}o.push(it(()=>[s.layerStore.layersLoaded],()=>{B(),N(),U()}));const vt=it(()=>[s.routeStore.currentRouteLayer,g.getRouteNextFloor],()=>{s.layerStore.layersLoaded&&(i!==null&&clearTimeout(i),i=setTimeout(()=>{B(s.routeStore.currentRouteLayer),N(),U(),i=null},0))});o.push(()=>{i!==null&&(clearTimeout(i),i=null),vt()}),o.push(it(()=>[g.selectedRoute,s.routeStore.onlyAccessible],()=>{B(),N(),U(!g.selectedRoute)})),o.push(it(()=>s.routeStore.currentPosition,()=>{N(),U()})),o.push(it(()=>c.get(),e=>{const a="transitionPoints";t.ptScaleRegistry.unregisterByPrefix(a),t.rollRegistry.unregisterByPrefix(a),e.length&&e.forEach((f,w)=>{const b=`${a}-${w}`;st(f,b),ut(f,b)})})),o.push(it(()=>[y.get()],()=>{const e=y.get(),a="kioskArrows";t.ptScaleRegistry.unregisterByPrefix(a),e.length&&e.forEach((f,w)=>st(f,`${a}-${w}`))})),o.push(it(()=>[g.kioskData,bt.floors.find(e=>e.active),g.selectedRoute],([e,a])=>{y.set([]);const f=Et()?e?.z===a?.name:!0;e&&f&&ie(e,{skipdim:!0,visible:!0,pixelRatio:I},t.scale,y),U()})),[{point:A,name:"wf-source"},{point:_,name:"wf-destination"}].forEach(({point:e,name:a})=>{st(e,a),ut(e,a)}),U(),N(),rt();function Bt(){n&&(n.stop(),n=null),o.forEach(e=>e()),o.length=0}return Bt}function te(t){const n=s.routeStore.currentRouteLayer?.name,o=z;let i=g.selectedRoute?.from,h=g.selectedRoute?.to;const c=g.selectedRoute?.waypoints;if(i?.entity.type==="route-cut-in"&&(i=null),h?.entity.type==="route-cut-in"&&(h=null),!o.length)return;const y=[{key:"sourceLocation",rect:i?.rect,index:void 0},{key:"destinationLocation",rect:h?.rect,index:void 0}];c&&y.push(...c?.map((d,r)=>({key:`waypoint-${d.externalId}`,index:r,rect:d.rect})));const m=n?O(n,i?.layer?.name):!0,p=n?O(n,h?.layer?.name):!0;let l=!1,x=!1;o.forEach(({x:d,y:r})=>{for(const{key:u,rect:R,index:E}of y)if(R?.containsPoint(d,r)){u==="sourceLocation"&&(A.bounds=S(d,r,K.width,K.height,t),A.hidden=!m,A.dim=!m,l=m),u==="destinationLocation"&&(_.bounds=S(d,r,j.width,j.height,t),_.hidden=!p,_.dim=!p,x=p);break}}),l||(A.bounds=S(o[o.length-1].x,o[o.length-1].y,K.width,K.height,t),A.hidden=!1,A.dim=!1),x||(_.bounds=S(o[0].x,o[0].y,j.width,j.height,t),_.hidden=!p,_.dim=!p)}function ee(){const{from:t,to:n}=s.uiState.selectedRoute||{},o="route-cut-in";return t&&t?.entity.type===o||n&&n?.entity.type===o?s.routeStore.defaultFrom:null}function ne(t,n){if(!t||!n.length)return n;const o=n.reduce((i,h,c)=>Pt(t,h)<Pt(t,n[i])?c:i,0);return o<=n.length/2?n.slice(o):n.slice(0,o)}function oe(t,n){const o=s.routeStore.currentRouteLayer?.name,i=g.getRouteNextFloor,h=s.layerStore.floors.map(r=>r.name),c=(r,u)=>r.findIndex(R=>O(R,u)),y=c(h,o),m=c(h,i),p=m!==-1,l=v.filter(r=>o?r.virtual&&(O(r.p0.layer,o)||O(r.p1.layer,o))&&(O(r.p0.layer,i)||O(r.p1.layer,i)):r.virtual).flatMap(r=>[r.p0,r.p1]),x=[];let d;l.forEach(r=>{if(i&&!O(r.layer,i)&&(p&&m>y&&s.fp.icons.get("transition_up")?d=Dt:p&&m<y&&s.fp.icons.get("transition_down")?d=_t:d=Rt),d){const u=O(o,r.layer),R=S(r.x,r.y,d.width,d.height,t),E=tt(d,R,{hidden:!u,dim:!1});x.push(E)}}),n.set(x)}function ie(t,n,o=1,i){if(!t)return;const h=s.fp.icons.get("kiosk");h.id="kiosk";let c;if(h){const m=t?.iconSizePercent?t.iconSizePercent/100:1,p=55;c=Z(h,yt(199*m,p),yt(152*m,p),I)}else c=Ct(I,dt("#ee4422").hex());const y=tt(c,S(t.x,t.y,c.width,c.height,o,It(t.heading||0)),{hidden:!n.visible,dim:!n.skipdim});i.set([...i.get(),y])}function yt(t,n){return t*(1-n/100)}function Nt(t,n,o=!1){let i=z.length-1;if(g.selectedRoute?.to?.entity.type==="route-cut-in"&&(i=0),o){Lt=[],n.children=[],t.update(n);return}const h=t.scale,c=z[i],y=at?.destination;if(!c||!y)return;const m=lt.width,p=splitPolyLine([{p0:c,p1:y}],m*2*h);if(p.length<2)return;const l=y.x-c.x,x=y.y-c.y,d=Math.hypot(l,x),r={x:(c.x+y.x)/2,y:(c.y+y.y)/2-d*.2},u=[c,r,y],R=p.map((E,D,q)=>{const T=(D+1)/(q.length+1),L=Mt(u,T);return tt(lt,S(L.x,L.y,lt.width,lt.height,h),{hidden:!1,dim:!1})})||[];return n.children=R,Lt=R,R}function Mt(t,n){if(t.length===1)return t[0];const o=[];for(let i=0;i<t.length-1;i++){const h=(1-n)*t[i].x+n*t[i+1].x,c=(1-n)*t[i].y+n*t[i+1].y;o.push({x:h,y:c})}return Mt(o,n)}export function splitPolyLine(t,n){if(t.length===0)return[];const o=[];let i=0;for(let m=0;m<t.length;m++){const p=t[m],l=p.p0,x=p.p1,d=x.x-l.x,r=x.y-l.y,u=Math.sqrt(d*d+r*r);if(u===0)continue;const R=d/u,E=r/u;let D=0;for(;i+D*n<=u;){const L=i+D*n,M=l.x+R*L,Y=l.y+E*L;o.push({x:M,y:Y}),D++}const q=i+(D-1)*n;let T=u-q;if(T=Math.max(T,0),m<t.length-1){const L=t[m+1],M=L.p0,Y=L.p1,nt=Y.x-M.x,B=Y.y-M.y,N=Math.sqrt(nt*nt+B*B);if(N===0)i=0;else{const rt=nt/N,U=B/N,W=R*rt+E*U,ot=T*W;i=n-ot}}else i=n-T;i=Math.max(i,0)}const h=t[0].p0;(o.length===0||!o[0]||o[0].x!==h.x||o[0].y!==h.y)&&o.unshift(h);const c=t[t.length-1].p1,y=o[o.length-1];return(o.length===0||!y||y.x!==c.x||y.y!==c.y)&&o.push(c),o}function re(t,n,o,i){if(!n.length)return n;const h=new Array(t.length);let c=0;for(let u=0;u<t.length;u++){const R=t[u],E=Math.hypot(R.p1.x-R.p0.x,R.p1.y-R.p0.y);h[u]=E,c+=E}const y=u=>u?String(u):null;function m(u){let R=0,E=1/0,D=1/0;const q=y(u.layer);for(let T=0;T<t.length;T++){const L=t[T],M=h[T],Y=y(L.p0.layer);if(!(q===null||Y===null||Y===q)){R+=M;continue}const B=L.p1.x-L.p0.x,N=L.p1.y-L.p0.y,rt=B*B+N*N;if(rt===0){R+=M;continue}const U=((u.x-L.p0.x)*B+(u.y-L.p0.y)*N)/rt,W=Math.max(0,Math.min(1,U)),ot=L.p0.x+B*W,st=L.p0.y+N*W,ut=Math.hypot(u.x-ot,u.y-st);ut<E&&(E=ut,D=R+M*W),R+=M}return{found:D!==1/0,fromStart:D,total:c}}const p=m(o),l=p.found?p:m(i);if(!l.found)return n;const x=l.fromStart,d=l.total-l.fromStart;return(p.found?d<x:x<d)?n.slice().reverse().map(u=>({...u,p0:u.p1,p1:u.p0})):n}
|
|
@@ -2,9 +2,8 @@ import { ImageUrls } from "../../../../utils/loadImagesInBatches";
|
|
|
2
2
|
import { Img } from "../../../../utils/imageloader";
|
|
3
3
|
import type { Booth } from "../../../../store/BoothStore";
|
|
4
4
|
import type { Layer } from "../../../../store/LayerStore";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export declare function loadLayersImages(renderer: MapRenderer, scene: SceneDef): Promise<void>;
|
|
5
|
+
import { RendererService } from "../../../../renderer";
|
|
6
|
+
export declare function loadLayersImages(rendererService: RendererService): Promise<void>;
|
|
8
7
|
export declare const getImageLayerName: (layerName: string) => string;
|
|
9
8
|
export declare function mapBoothsLogos(booths: Booth[]): Map<number, ImageUrls>;
|
|
10
9
|
export declare function getLayerIcons(layer: Layer): SVGImageElement[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getLayerSvg as
|
|
1
|
+
import{getLayerSvg as f}from"../../../../data/svg";import{select as h}from"d3";import{getLogoUrl as d}from"../../../../utils/getLogoUrl";import{flipImageDef as u,isInnerInsideOuter as y}from"../../../../renderer";import{SEPARATOR as w}from"../../../../constants";import{rotateImageDef as x}from"../../../../renderer/engine-core/utils/rotation";export async function loadLayersImages(t){const n=t.layerImagesRegistry.invoke();await Promise.all(n.map(async e=>{const l=await e;if(!l)return;const{layer:i,children:o}=l;if(o.length){const a=[];for(let r=0;r<o.length;r++){const{shape:s,parentRect:c}=o[r],g=y(s.bounds,c);if(!i.name.includes("Pathway_")){const m=g?"image-rotate":"image-flip";t.onRoll(`${m}-${name}-${r}`,g?p=>x(s,p):p=>u(s,p))}a.push(s)}i.children.push(...a),t.update(i)}}))}export const getImageLayerName=t=>`${t}${w}images`;export function mapBoothsLogos(t){return new Map(t.map(n=>{const e=n.rect&&n.exhibitors.find(l=>l.logoInBooth&&l.logo);return e?[n.id,{preferred:d(e.logo),fallback:e.logo}]:null}).filter(Boolean))}export function getLayerIcons(t){const n=h(f(t)).select(`[data-layer="${t.name}"]`);return(window.__fpVersion>5?n.selectAll(":scope > image, :scope > g:not([data-layer]) image").nodes():n.selectAll(":scope > g[data-is-editable='false'] image").nodes()).filter(Boolean)}export function createBoothImg(t,n){const e=t.rect,l=e.h?e.w/e.h:1,i=n.height?n.width/n.height:1;let o,a,r;const s=.9;l>i?(a=e.h*s,o=a*i):(o=e.w*s,a=o/i);const c=t.rotate||0;i>=2&&!c&&e.h>=e.w*2?(a=e.w*s,o=a*i,r=-90):r=-c*180/Math.PI,o>e.w&&(o=e.w,a=o/i),a>e.h&&(a=e.h,o=a*i);const g=e.cx-o/2,m=e.cy-a/2;return{name:t.slug,bounds:{x:g,y:m,width:o,height:a,angle:r},htmlImage:n,booth:t}}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RendererService } from "../../../renderer";
|
|
2
2
|
export interface BuildRouteParams {
|
|
3
3
|
enabled: boolean;
|
|
4
|
-
|
|
5
|
-
scene: SceneDef;
|
|
6
|
-
initialScale: number;
|
|
4
|
+
rendererService: RendererService;
|
|
7
5
|
cb?: () => void;
|
|
8
6
|
}
|
|
9
|
-
export declare function useBuildRoute({ enabled,
|
|
7
|
+
export declare function useBuildRoute({ enabled, rendererService }: BuildRouteParams): void;
|
|
10
8
|
//# sourceMappingURL=useBuildRoute.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{useCallback as
|
|
1
|
+
import{useCallback as x,useEffect as M,useMemo as _,useRef as v}from"react";import{BUILD_ROUTE_DOTS as U,BUILD_ROUTE_LINES as $}from"./trafficLayers";import{createCircleCanvas as S,getBounds as I}from"../../../renderer/engine-core/canvases";import{UpdateQueue as A}from"./UpdateQueue";const E=49,C=`hsl(257, 76%, ${E}%)`,K=`hsl(339.903, 82%, ${E}%)`,T=`hsl(257, 76%, ${Math.round(E*1.82)}%)`,O=4,H=O,R="U",D="R",b="S",N="P";class Y{_state=[[]];index=0;pointHashSet=new Set;locked=!1;storageKey="expofp_build_route_state";_selected=0;get points(){return this._state[this.index]}set points(t){this._state.push(t),this.setIndex(),this.save()}setIndex(){this.index=Math.max(this._state.length-1,0)}genPointHash(t){return`${t.x},${t.y}`}add(t){const a=this.genPointHash(t);this.pointHashSet.has(a)||(this.pointHashSet.add(a),this.points=[...this.points,t])}undo(){this.index&&(this._state.pop(),this.setIndex(),this.save(),this.select(this.points.length-1))}execute(t){try{if(this.locked)return;this.locked=!0,t()}finally{requestAnimationFrame(()=>{this.locked=!1})}}log(t,a=12){console.log(`%c${t}`,`color: black; font-size: ${a}px; background: LemonChiffon;`)}instruct(){this.log(`How to Build a Route:
|
|
2
2
|
Add Point: Click on the map.
|
|
3
|
-
Apply Smoothing: Press ${
|
|
4
|
-
Apply Simplification: Press ${
|
|
5
|
-
Undo: Press ${
|
|
6
|
-
Enable/Disable Preview: Press ${
|
|
7
|
-
`,16)}applyChaikinSmoothing(t,
|
|
3
|
+
Apply Smoothing: Press ${D}.
|
|
4
|
+
Apply Simplification: Press ${b}.
|
|
5
|
+
Undo: Press ${R}.
|
|
6
|
+
Enable/Disable Preview: Press ${N}.
|
|
7
|
+
`,16)}applyChaikinSmoothing(t,a,d){let c=[];if(d>=1&&t.length>=2){c=[t[0]];for(let h=1;h<t.length;h++){const s=t[h-1],u=t[h];for(let o=1;o<=d;o++){const n=o/(d+1);c.push({x:s.x+(u.x-s.x)*n,y:s.y+(u.y-s.y)*n})}c.push(u)}}else c=t.slice();for(let h=0;h<a&&!(c.length<2);h++){const s=[{...c[0]}];for(let u=1;u<c.length;u++){const o=c[u-1],n=c[u];s.push({x:.75*o.x+.25*n.x,y:.75*o.y+.25*n.y}),s.push({x:.25*o.x+.75*n.x,y:.25*o.y+.75*n.y})}s.push({...c[c.length-1]}),c=s}return c}applySmoothing(){this.points.length<3||(this.points=this.applyChaikinSmoothing(this.points,1,0),this.select(this.points.length-1))}save(){try{this.points.length?sessionStorage.setItem(this.storageKey,JSON.stringify(this.points)):sessionStorage.removeItem(this.storageKey)}catch(t){console.warn(t)}}restore(){try{const t=sessionStorage.getItem(this.storageKey);if(!t)return;const a=JSON.parse(t);if(!Array.isArray(a))return;a.forEach(d=>this.add(d)),this.select(this.points.length-1)}catch(t){console.warn(t)}}topologyPreservingSimplify(t,a){if(t.length<=2)return t.map(o=>({...o}));const d=(o,n,y)=>{const g=o.x,f=o.y,e=n.x,i=n.y,r=y.x,l=y.y,m=Math.abs((l-i)*g-(r-e)*f+r*i-l*e),p=Math.sqrt((l-i)**2+(r-e)**2);return m/(p||1e-10)},c=(o,n,y,g)=>{const f=(e,i,r)=>(r.y-e.y)*(i.x-e.x)-(i.y-e.y)*(r.x-e.x);return f(o,y,g)*f(n,y,g)<0&&f(y,o,n)*f(g,o,n)<0},h=new Array(t.length).fill(!1);h[0]=h[h.length-1]=!0;const s=[],u=(o,n)=>{if(n<=o+1)return;const y=t[o],g=t[n];let f=0,e=0;for(let i=o+1;i<n;i++){const r=d(t[i],y,g);r>f&&(f=r,e=i)}if(f>a){const i=t[e];let r=!0;for(let l=0;l<s.length-1;l++)if(c(s[l],s[l+1],y,i)||c(s[l],s[l+1],i,g)){r=!1;break}r&&(h[e]=!0,u(o,e),u(e,n))}};return u(0,t.length-1),t.filter((o,n)=>h[n])}applySimplification(){this.points=this.topologyPreservingSimplify(this.points,.5),this.select(this.points.length-1)}get selected(){return this._selected}select(t){this._selected=Math.max(0,Math.min(t,this.points.length-1))}}export function useBuildRoute({enabled:w,rendererService:t}){const a=v(!1),d=v(),c=_(()=>S(O,C),[]),h=_(()=>S(O,K),[]),s=_(()=>new Y,[]),u=v(new A),o=_(()=>{if(!t.scene)return{};const e=t.scene.rootLayer.children,i=e.find(l=>l.name===$),r=e.find(l=>l.name===U);return{linesLayer:i,pointsLayer:r}},[t.scene]),n=x(()=>{if(!t?.renderer||!o||!c||!h)return;const{linesLayer:e,pointsLayer:i}=o;if(!e||!i)return;const r=s.points,l=a.current;l?i.children.length=0:i.children=r.map(({x:p,y:L},k)=>{const P=k==s.selected?h:c;return{source:P,bounds:I(p,L,P.width,P.height,d.current)}});const m=[];for(let p=1;p<r.length;p++){const L=r[p-1],k=r[p];m.push({points:[L,k],color:l?C:T,width:H})}m.length?e.children=m:e.children.length=0,u.current.add(()=>t.update(i,e)),s.instruct(),s.log(JSON.stringify(s.points))},[t,s,o,c,h]),y=x(e=>{const i=e.key.toUpperCase();s.execute(()=>{switch(i){case R:e.preventDefault(),s.undo(),a.current=!1,n();break;case D:e.preventDefault(),s.applySmoothing(),a.current=!1,n();break;case b:e.preventDefault(),s.applySimplification(),a.current=!1,n();break;case N:e.preventDefault(),a.current=!a.current,n();break}})},[s,n]),g=x(e=>{if(!t?.renderer||!o)return;const{pointsLayer:i}=o;i&&(d.current=e,s.execute(()=>{const r=i.children,l=[];for(let m=0;m<r.length;m++){const p=r[m];p.bounds=I(p.bounds.center.x,p.bounds.center.y,p.source.width,p.source.height,d.current),l.push(p)}u.current.add(()=>t.update(...l))}))},[t,o,s]),f=x(e=>{s.execute(()=>{s.add({x:e.point.x,y:e.point.y}),s.select(s.points.length-1),n()})},[s,n]);M(()=>{const e=t.renderer;if(!(!w||!e))return d.current=t.getCameraState().ptScale||window.devicePixelRatio,s.execute(()=>{s.restore(),n()}),e.events.addEventListener("pointer:click",f),e.events.addEventListener("viewport:ptscale",g),window.addEventListener("keyup",y),()=>{window.removeEventListener("keyup",y),e.events.removeEventListener("pointer:click",f),e.events.removeEventListener("viewport:ptscale",g),u.current.destroy()}},[w,t,s,n,f,g,y])}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RendererService } from "../../../renderer";
|
|
2
2
|
export interface ManageTrafficParams {
|
|
3
3
|
permission: boolean;
|
|
4
|
-
|
|
5
|
-
scene: SceneDef;
|
|
4
|
+
rendererService: RendererService;
|
|
6
5
|
dataJsonUrl: string;
|
|
7
6
|
websocketUrl: string;
|
|
8
|
-
initialScale: number;
|
|
9
7
|
}
|
|
10
|
-
export declare function useManageTraffic({ permission,
|
|
8
|
+
export declare function useManageTraffic({ permission, rendererService, dataJsonUrl, websocketUrl }: ManageTrafficParams): void;
|
|
11
9
|
//# sourceMappingURL=useManageTraffic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as
|
|
1
|
+
import{useEffect as yt,useRef as L}from"react";import{getBounds as k}from"../../../renderer";import{getRouteLayerRegex as pt,getRouteStopLayerRegex as wt,TRAFFIC_VEHICLES as xt}from"./trafficLayers";import{loadImage as Et}from"../../../utils/loadImage";import{createImageCanvas as It}from"../drawing/config/canvases";import{UpdateQueue as Mt}from"./UpdateQueue";import Lt from"../../../tools/base-runtime-url";import{toRadians as bt}from"../../../utils/toRadians";const tt=2,Rt=tt*3.5,G=tt*12,at=G*.7,Ft=8,At="transport_locations",Tt=150,et="#a4aab6",it=1e3,Pt=2e4,ut=500;export function useManageTraffic({permission:e,rendererService:n,dataJsonUrl:c,websocketUrl:a}){const t=L(window.devicePixelRatio),s=L(new Map),o=L(new Map),r=L(),d=L(),f=L(performance.now()),M=L(1),x=L(new Mt),A=L(new Map),I=L(),g=L(it),y=L(new Map),i=L();yt(()=>{async function O(){if(!(!e||!n.scene))try{let h;try{h=await(await fetch(c,{method:"GET",headers:{"Content-Type":"application/json"}})).json()}catch(u){console.warn("useManageTraffic failed to get JSON",u)}if(!h||h?.disabled||h?.error)return;t.current=lt(n.getCameraState().ptScale);const V=new Map(h.routes.map(({id:u,color:m})=>[u,m])),_=n.scene.rootLayer.children,W=new Map;V.forEach(u=>{W.set(u,Ct({radius:Rt,color:u,scale:window.devicePixelRatio}))});const z=pt(),Y=_.filter(u=>z.test(u.name)),B=wt(),U=_.filter(u=>B.test(u.name));h.routes.slice(0,Y.length).forEach(({id:u,color:m,path:T,stops:R,hiddenPoints:p},w)=>{A.current.set(u,T);const E=Y[w];if(E){const S=new Map(p?.map(l=>[ot(l),l])??[]);for(let l=1;l<T.length;l++){const D=T[l-1],H=T[l];S.has(ot(D))||S.has(ot(H))||E.children.push({points:[D,H],color:m,width:tt})}E.children.length&&x.current.add(()=>n.update(E))}const N=U[w];if(N&&R?.length){const S=W.get(m);R.forEach(l=>{N.children.push({source:S,bounds:k(l.x,l.y,S.width,S.height,t.current)})}),N.children.length&&x.current.add(()=>n.update(N))}});const $=_.find(u=>u.name===xt),X=new Map;I.current=u=>{try{t.current=lt(u);const m=[];for(let R=0;R<U.length;R++){const p=U[R].children;for(let w=0;w<p.length;w++){const E=p[w];E.bounds=k(E.bounds.center.x,E.bounds.center.y,E.source.width,E.source.height,t.current,E.bounds.rotation),m.push(E)}}const T=[...s.current.values()];for(let R=0;R<T.length;R++){const p=T[R];p.bounds=k(p.bounds.center.x,p.bounds.center.y,p.source.width,p.source.height,t.current,p.bounds.rotation)}x.current.add(()=>n.update(...m,...T))}catch(m){console.error("ptscale",m)}},n.renderer.events.addEventListener("viewport:ptscale",I.current),V.forEach((u,m)=>{X.set(m,ht({id:m,width:G,height:G,color:u,scale:window.devicePixelRatio}))}),X.set(et,ht({id:"orphan",width:G,height:G,color:et,scale:window.devicePixelRatio}));let j=null;try{const u=await Et(`${Lt}icons/bus-white.svg`);j=It(u,at,at,window.devicePixelRatio)}catch(u){console.error(u)}d.current=u=>{try{const m=JSON.parse(u.data);if(m.type!==At)return;const T=u.timeStamp||performance.now();M.current=Math.round(T-f.current),f.current=T;const R=Math.max(M.current??ut,ut),p=o.current,w=s.current,E=$.children,N=x.current;let S=!1;m.data.forEach(({id:l,x:D,y:H,route_id:ct,hidden:gt})=>{if(p.has(l)&&(p.get(l)?.(),p.delete(l)),gt&&w.has(l)&&w.has(Q(l))){const P=w.get(l);P.hidden=!0;const F=w.get(Q(l));F.hidden=!0,N.add(()=>n.update(P,F));return}if(y.current.set(l,performance.now()),!w.has(l)){const P=X.get(ct)||X.get(et),F={id:l,source:P,bounds:k(D,H,P.width,P.height,t.current,0)};if(w.set(l,F),j){const q=Q(l),rt={id:q,source:j,bounds:k(D,H,j.width,j.height,t.current,0)};j.setAttribute("id",q),w.set(q,rt),E.push(F,rt)}else E.push(F);S=!0;return}const Z=w.get(l),st=w.get(Q(l)),mt=Z.bounds.center,K=Nt(mt,{x:D,y:H},A.current.get(ct));if(K.reduce((P,F,q)=>q===0?P:P+nt(K[q-1],F),0)>=Tt||document.hidden)dt({rendererService:n,updateQueue:N,vehicle:Z,vehicleFinery:st,x:D,y:H,scale:t.current,angle:vt(Z.bounds.center,{x:D,y:H})});else{const P=St(K,R,F=>{dt({rendererService:n,updateQueue:N,vehicle:Z,vehicleFinery:st,x:F.x,y:F.y,scale:t.current,angle:F.angle})});p.set(l,P)}}),S&&N.add(()=>n.update($))}catch(m){console.error("handleSocketMessage",m)}},v(),C(h.config?(Number(h.config.vehicle_inactive_interval)||20)*1e3:Pt)}catch(h){console.warn(h)}}O();function v(){r.current?.readyState===WebSocket.OPEN||r.current?.readyState===WebSocket.CONNECTING||(r.current=new WebSocket(a),r.current.onmessage=d.current,r.current.onopen=()=>{g.current=it},r.current.onclose=()=>{if(!navigator.onLine)return;setTimeout(v,g.current);const h=3e4;g.current=Math.min(g.current*2,h)})}function b(){v()}window.addEventListener("online",b);function C(h){clearInterval(i.current),i.current=window.setInterval(()=>{const V=performance.now(),_=[],W=[];y.current.forEach((z,Y)=>{if(V-z<h)return;const B=s.current.get(Y);B&&(B.hidden=!0,W.push(B),_.push(Y));const U=Q(Y),$=s.current.get(U);$&&($.hidden=!0,W.push($),_.push(U))}),W.length&&x.current.add(()=>n.update(...W)),_.forEach(z=>y.current.delete(z))},h)}return()=>{I.current&&n.renderer&&n.renderer.events.removeEventListener("viewport:ptscale",I.current),o.current.forEach(h=>h?.()),o.current.clear(),s.current.clear(),x.current.destroy(),window.removeEventListener("online",b),clearInterval(i.current)}},[e,n,c,a])}function lt(e){return Math.min(e||window.devicePixelRatio,Ft)}function vt(e,n){return Math.atan2(n.y-e.y,n.x-e.x)}function Ct({radius:e,scale:n,color:c}){const a=document.createElement("canvas"),t=a.getContext("2d");t.imageSmoothingEnabled=!1;const s=Math.ceil(e*2*n),o=s/2,r=e*.78,d=e*.33;return a.width=s,a.height=s,t.translate(o,o),t.scale(n,n),t.beginPath(),t.arc(0,0,e,0,2*Math.PI),t.fillStyle="#FFFFFF",t.fill(),t.beginPath(),t.arc(0,0,r,0,2*Math.PI),t.fillStyle=c,t.fill(),t.beginPath(),t.arc(0,0,d,0,2*Math.PI),t.fillStyle="#FFFFFF",t.fill(),a}function ht({id:e,width:n,height:c,color:a,scale:t}){const s=2*t,o=n/2*t,r=c*t,d=.6,f=.01,M=r*d,x=r,A=8*t,I=x+s+M/2+A*2,g=o*2+M+s+A*2,y=document.createElement("canvas");y.setAttribute("id",e),y.width=I,y.height=g;const i=y.getContext("2d"),O=I/2,v=g/2;i.save(),i.translate(O,v),i.rotate(-Math.PI/2),i.translate(-O,-v);const b=O,C=v-x/2+o,h=C+M;return i.shadowColor="rgba(16, 24, 40, 0.2)",i.shadowBlur=A/2,i.beginPath(),i.arc(b,C,o,Math.PI,0,!1),i.bezierCurveTo(b+o,C+r*.3,b+f*o,h,b,h),i.bezierCurveTo(b-f*o,h,b-o,C+r*.3,b-o,C),i.closePath(),i.fillStyle=a,i.fill(),i.strokeStyle="#FFFFFF",i.lineWidth=s,i.stroke(),i.restore(),y}function nt(e,n){return Math.hypot(e.x-n.x,e.y-n.y)}function Q(e){return`${e}_finery`}function dt({rendererService:e,updateQueue:n,vehicle:c,vehicleFinery:a,x:t,y:s,scale:o,angle:r}){if(c.bounds=k(t,s,c.source.width,c.source.height,o,r),c.hidden=!1,a){const d=e.getCameraState();a.bounds=k(t,s,a.source.width,a.source.height,o,bt(d.roll||0)),a.hidden=!1,n.add(()=>e.update(a,c))}else n.add(()=>e.update(c))}function J(e,n,c){return{x:e.x+(n.x-e.x)*c,y:e.y+(n.y-e.y)*c}}function ft(e,n){let c=1/0,a={index:0,t:0};for(let t=0;t<n.length-1;t++){const s=n[t],o=n[t+1],r=o.x-s.x,d=o.y-s.y,f=r*r+d*d,M=f?((e.x-s.x)*r+(e.y-s.y)*d)/f:0,x=Math.max(0,Math.min(1,M)),A=J(s,o,x),I=nt(e,A);I<c&&(c=I,a={index:t,t:x})}return a}function _t(e,n,c){const a=nt(e,n),t=Math.max(2,Math.ceil(a/c)+1),s=[];for(let o=0;o<t;o++){const r=o/(t-1),d=J(e,n,r);s.push({x:d.x,y:d.y})}return s}function Nt(e,n,c){if(!c||!c.length)return _t(e,n,10);const a=ft(e,c),t=ft(n,c),s=[],o=r=>s.push({x:r.x,y:r.y});a.index+1<c.length?o(J(c[a.index],c[a.index+1],a.t)):o(c[a.index]);for(let r=a.index+1;r<=t.index&&r<c.length;r++)o(c[r]);return t.index+1<c.length?o(J(c[t.index],c[t.index+1],t.t)):o(c[t.index]),s}function St(e,n,c,a){if(e.length<2)return()=>{};let t=null,s;const o=[];let r=0;for(let f=0;f<e.length-1;f++){const M=Math.hypot(e[f+1].x-e[f].x,e[f+1].y-e[f].y);o.push(M),r+=M}const d=f=>{t||(t=f);const M=f-t,x=Math.min(M/n,1),A=x*r;let I=0,g=0;for(;g<o.length&&I+o[g]<A;)I+=o[g],g++;g>=o.length&&(g=o.length-1);const y=e[g],i=e[Math.min(g+1,e.length-1)],O=o[g]||0,v=O===0?0:(A-I)/O,b=y.x+(i.x-y.x)*v,C=y.y+(i.y-y.y)*v,h=i.x-y.x,V=i.y-y.y,_=h===0&&V===0?0:Math.atan2(V,h);c({x:b,y:C,angle:_}),x<1?s=requestAnimationFrame(d):a&&a()};return s=requestAnimationFrame(d),()=>{s&&cancelAnimationFrame(s)}}function ot(e){return`${e.x},${e.y}`}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import "./SidebarActions.scss";
|
|
3
3
|
export interface SidebarActionsProps {
|
|
4
|
+
className?: string;
|
|
4
5
|
inBookmark?: boolean;
|
|
5
6
|
visited?: boolean;
|
|
6
7
|
showVisited?: boolean;
|
|
7
8
|
showBookmark?: boolean;
|
|
8
9
|
showDirections?: boolean;
|
|
10
|
+
showRoutePlanner?: boolean;
|
|
9
11
|
showShare?: boolean;
|
|
10
12
|
onClickBookmark?: () => void;
|
|
11
13
|
onClickVisited?: () => void;
|
|
12
14
|
onClickDirections?: () => void;
|
|
15
|
+
onClickRoutePlanner?: () => void;
|
|
13
16
|
onClickShare?: () => void;
|
|
14
17
|
}
|
|
15
18
|
declare const SidebarActions: React.FC<SidebarActionsProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as t,jsxs as
|
|
1
|
+
import{jsx as t,jsxs as i}from"react/jsx-runtime";import{useState as C}from"react";import s from"classnames";import"./SidebarActions.scss";import{t as e}from"../utils/i18n";import r from"i18next";import S from"./CheckboxButton";const v=({className:l,inBookmark:a=!1,visited:o=!1,showVisited:c=!1,showBookmark:m=!0,showDirections:u=!0,showRoutePlanner:d=!1,showShare:p=!0,onClickBookmark:f,onClickVisited:b,onClickDirections:h,onClickRoutePlanner:k,onClickShare:N})=>{const[B,n]=C(!1),x=()=>{n(!0),f(),setTimeout(()=>{n(!1)},320)};return i("div",{className:s("efp-sidebarActions",l),role:"toolbar","aria-label":e("Sidebar Actions"),children:[u&&i("button",{type:"button",className:"efp-actionButton efp-actionButton--directions",onClick:h,title:e("Directions"),"aria-label":e("Directions"),children:[t("i",{className:"icon-directions","aria-hidden":"true"}),e("Directions")]}),c&&t(S,{className:"efp-visited-btn","aria-label":o?r.t("Visited"):r.t("Not visited"),"aria-pressed":o,checked:o,label:r.t("Visited"),onClick:b??(()=>{})}),m&&t("button",{type:"button",className:s("efp-actionButton","efp-actionButton--bookmark",{isActive:a,animate:B}),title:a?e("Remove from Bookmarks"):e("Save to Bookmarks"),"aria-label":a?e("Remove from Bookmarks"):e("Save to Bookmarks"),"aria-pressed":a,onClick:x,children:t("i",{className:a?"icon-bookmark-solid":"icon-bookmark","aria-hidden":"true"})}),d&&i("button",{type:"button",className:"efp-actionButton efp-actionButton--route-planner",title:e("Route planner"),"aria-label":e("Route planner"),onClick:k,children:[t("i",{className:"icon-route-solid","aria-hidden":"true"}),e("Route planner")]}),p&&t("button",{type:"button",className:"efp-actionButton efp-actionButton--share",title:e("Share"),"aria-label":e("Share"),onClick:N,children:t("i",{className:"icon-share","aria-hidden":"true"})})]})};export default v;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as f,jsxs as U}from"react/jsx-runtime";import x from"classnames";import{useObserver as C}from"mobx-react-lite";import{useEffect as m,useMemo as B,useState as V,useRef as _}from"react";import z from"../data";import{getLayerSvg as $}from"../data/svg";import r,{boothStore as F,exhibitorStore as K,uiState as e}from"../store";import{RegularBooth as L}from"../store/BoothStore";import{Route as S}from"../store/RouteStore";import I from"../tools/settings";import{t as y}from"../utils/i18n";import Q from"./EntityList";import X from"./WayfindingTemplate";import{calcSpeed as q}from"../utils/calcSpeed";import{calcTravelTime as G}from"../utils/calcTravelTime";import{DEFAULT_UNITS as H}from"../constants";import"./Wayfinding.scss";function J(){const k=_(null),a=B(()=>r.routeStore.pathLayers.map(i=>({id:i.id,name:i.layer?.shortName,description:i.layer?.description,basePriority:i.layer?.basePriority??0})),[r.routeStore.pathLayers]),[b,R]=V();m(()=>{b||R(a[0])},[r.routeStore.pathLayers,a]),m(()=>{const i=a.find(u=>u.description?.toLowerCase()===r.routeStore.currentRouteLayer?.description?.toLowerCase());i&&R(i)},[r.routeStore.currentRouteLayer,a]),m(()=>{const i=e.selectedRoute;if(!i){e.setIsMultiPointRoute(!1);return}const c=(i.waypoints?.length||0)>0;e.setIsMultiPointRoute(c)},[e.selectedRoute]);const T=()=>{const{from:i,to:u}=e.selectedRoute;return!!(i&&u)},N=()=>e.overlaySize==="full",D=()=>!!(T()&&!N()),g=()=>{const i=e.selectedRoute;return i?(i.waypoints?.length||0)>0?"multi":"simple":"none"},M=()=>e.routeTitle;return m(()=>{g()==="multi"&&e.selectedRoute},[e.selectedRoute]),C(()=>{const i=g(),u=M();if(i==="multi")return U("div",{className:x("main-wayfinding",{hidden:e.kiosk&&e.selectedRoute?.from&&e.selectedRoute?.to}),children:[e.routeDescription&&f("div",{className:"efp-wayfinding-description",children:e.routeDescription}),f(Q,{updatedScrollableRef:k})]});const c=[],p=()=>r.routeStore.defaultFrom?F.booths.concat([r.routeStore.defaultFrom]):F.booths,A=p().filter(t=>t instanceof L),E=p().filter(t=>!(t instanceof L)),w=()=>{let t=[];return K.exhibitors.forEach(o=>{c.push(...o.booths.map(s=>s.id)),t.push(...o.booths.map(s=>({value:s.id.toString(),label:o.name+" - "+s.fullName})))}),E.filter(o=>c.indexOf(o.id)===-1).forEach(o=>{t.push({value:o.id.toString(),label:o.fullName})}),t=t.sort((o,s)=>o.label.localeCompare(s.label,void 0,{sensitivity:"base"})),A.filter(o=>c.indexOf(o.id)===-1).forEach(o=>{t.push({value:o.id.toString(),label:o.fullName})}),t},v=(t,o=!0)=>{const s=p().filter(d=>d.id.toString()===t)[0],{from:n,to:l}=e.selectedRoute;o?r.routeStore.selectRoute(new S(s||null,l)):r.routeStore.selectRoute(new S(n,s||null))},O=t=>{const o=[],s=$().getAttribute("units")||H,n=G(t,q(s));let l=new Date;l.setMinutes(l.getMinutes()+n/60);const d=l.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});return o.push({title:y("Travel time"),text:n<60?"< 1 min":`~ ${Math.round(n/60)} min`},{title:y("Distance"),text:Math.round(t)+` ${s}`},{title:y("Est arrival"),text:d}),o},W=()=>{const{from:t,to:o}=e.selectedRoute;r.routeStore.selectRoute(new S(o,t))},P=e.selectedRoute?.from&&e.selectedRoute?.to&&!r.routeStore.routeLines.length;return f("div",{className:x("main-wayfinding",{hidden:e.kiosk&&e.selectedRoute?.from&&e.selectedRoute?.to}),children:f(X,{showForm:!D(),showInfo:!!(!z.hideWayInformation&&I.EXPO!=="bloomberg"&&e.selectedRoute?.from&&e.selectedRoute?.to),floors:a,currentFloor:b,onClickFloor:t=>{const o=r.routeStore.pathLayers.find(s=>s.id===t.id);o?.layer&&r.layerStore.updateVisibility(o.layer,!0)},routeFound:!P,options:w(),fromValue:e.selectedRoute?.from?.id?.toString()||"",toValue:e.selectedRoute?.to?.id?.toString()||"",onChangeFrom:t=>v(t,!0),onChangeTo:t=>v(t,!1),onSwitch:W,infoItems:O(r.routeStore.routeDistance),infoAccessible:r.routeStore.onlyAccessible,showAccessible:r.routeStore.showAccessible,onAccessibleCheck:t=>r.routeStore.onlyAccessible=t,onClickInfo:()=>r.showOverlay(),routeUrl:e.routeQRCodeUrl,isKiosk:e.kiosk,showDetailsIcon:e.showRouteInstantly,onDetailsIconClick:()=>{const t=r.routeStore.defaultFrom?.id,{from:o,to:s}=e.selectedRoute||{},n=[s,o].find(l=>l?.id!==t);if(n){const d=w().find(h=>h.value===n.id.toString()),j=n.exhibitors.find(h=>d.label.includes(h.name));e.details=j||n}}})})})}function Y(){return C(()=>I.wayfinding&&!e.menu&&e.selectedRoute&&e.list.type!=="route-planner"&&f(J,{}))}export default Y;
|
package/dist/esm/data/tours.json
CHANGED
|
@@ -144,5 +144,79 @@
|
|
|
144
144
|
"15552470"
|
|
145
145
|
]
|
|
146
146
|
}
|
|
147
|
+
],
|
|
148
|
+
"fdhw2026": [
|
|
149
|
+
{
|
|
150
|
+
"id": "association-of-convenience-stores-trail",
|
|
151
|
+
"layers": [{ "floor": "1", "id": "Pathway_1" }],
|
|
152
|
+
"name": "Association of Convenience Stores Trail",
|
|
153
|
+
"description": "Show: IFE.\nData Types Allowed to View: IFE Visitors / IFE Suppliers / IFE Press / IFEM Visitors / IFEM Suppliers / IFEM Press.",
|
|
154
|
+
"points": ["16282530", "16282664", "16572191", "16282882", "16572254", "16282294", "16282527", "16282319", "16445163"]
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"id": "newbies-at-the-pub-show",
|
|
158
|
+
"layers": [{ "floor": "1", "id": "Pathway_2" }],
|
|
159
|
+
"name": "Newbies at The Pub Show",
|
|
160
|
+
"description": "Show: The Pub Show.\nData Types Allowed to View: Pub Visitor / Pub Supplier / Pub Press / HRC Visitor / HRC Supplier / HRC Press.",
|
|
161
|
+
"points": [
|
|
162
|
+
"16282289",
|
|
163
|
+
"16282507",
|
|
164
|
+
"16282613",
|
|
165
|
+
"16282283",
|
|
166
|
+
"16282382",
|
|
167
|
+
"16282792",
|
|
168
|
+
"16830654",
|
|
169
|
+
"16282656",
|
|
170
|
+
"16282309",
|
|
171
|
+
"16282902",
|
|
172
|
+
"16282450",
|
|
173
|
+
"16283034",
|
|
174
|
+
"16282743",
|
|
175
|
+
"16572201",
|
|
176
|
+
"16282279",
|
|
177
|
+
"16369552",
|
|
178
|
+
"16282392",
|
|
179
|
+
"16282603"
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"id": "chef-steve-munkley-mbe-s-top-picks",
|
|
184
|
+
"layers": [{ "floor": "1", "id": "Pathway_3" }],
|
|
185
|
+
"name": "Chef Steve Munkley MBE's Top Picks",
|
|
186
|
+
"description": "Show: HRC.\nData Types Allowed to View: Pub Visitor / Pub Supplier / Pub Press / HRC Visitor / HRC Supplier / HRC Press.",
|
|
187
|
+
"points": [
|
|
188
|
+
"16282438",
|
|
189
|
+
"16282525",
|
|
190
|
+
"16282753",
|
|
191
|
+
"16282554",
|
|
192
|
+
"16282784",
|
|
193
|
+
"16282440",
|
|
194
|
+
"16282479",
|
|
195
|
+
"16282833",
|
|
196
|
+
"PastryHQ | S1290",
|
|
197
|
+
"16282914",
|
|
198
|
+
"16282776"
|
|
199
|
+
]
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"id": "radford-chancellor-s-must-see-exhibitors",
|
|
203
|
+
"layers": [{ "floor": "1", "id": "Pathway_4" }],
|
|
204
|
+
"name": "Radford Chancellor's Must See Exhibitors",
|
|
205
|
+
"description": "Show: HRC.\nData Types Allowed to View: Pub Visitor / Pub Supplier / Pub Press / HRC Visitor / HRC Supplier / HRC Press.",
|
|
206
|
+
"points": ["16282429", "16283073", "16600529"]
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"id": "anna-sebastian-s-top-tipples",
|
|
210
|
+
"layers": [{ "floor": "1", "id": "Pathway_5" }],
|
|
211
|
+
"name": "Anna Sebastian's Top Tipples",
|
|
212
|
+
"description": "Show: HRC & The Pub Show.\nData Types Allowed to View: Pub Visitor / Pub Supplier / Pub Press / HRC Visitor / HRC Supplier / HRC Press.",
|
|
213
|
+
"points": ["16282311", "16445141", "16837929", "16369552", "16282279", "16282289", "16282603"]
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"id": "fcsi-members-trail",
|
|
217
|
+
"layers": [{ "floor": "1", "id": "Pathway_6" }],
|
|
218
|
+
"name": " FCSI Members Trail",
|
|
219
|
+
"points": ["16282429", "16600529", "16282606", "16282806", "16282745", "16282964"]
|
|
220
|
+
}
|
|
147
221
|
]
|
|
148
222
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRoot } from "react-dom/client";
|
|
2
2
|
import FloorPlanLoader from "./floorplan.loader";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import { CurrentPosition, MarkersData } from "./store/RouteStore";
|
|
4
|
+
import { Visibility } from "./store/types";
|
|
5
5
|
import Rect from "./core/Rect";
|
|
6
6
|
import { Bounds, POISelectors } from "./types/sdk.types";
|
|
7
7
|
export default class FloorPlanReady extends FloorPlanLoader {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as p,Fragment as L,jsxs as T}from"react/jsx-runtime";import{reaction as C}from"mobx";import{createRoot as R}from"react-dom/client";import{install as I}from"resize-observer";import V from"./components/Layout";import $ from"./floorplan.loader";import{applyParameters as M,destroyHistory as j,initRouting as z}from"./services/routing";import t from"./store";import{Route as S,findBooth as x,separateExternalIds as E}from"./store/RouteStore";import{destroyUiHandlers as G}from"./store/init/init-ui";import{GaEventActions as P,destroyGtag as _,sendEventToGa as w,setConsentSettings as q}from"./tools/gtag";import N from"./tools/report-error";import{resetGlobalVariables as Y}from"./tools/reset";import H from"./tools/track-event";import{fpGeo as v}from"./components/Mapbox/utils/fpGeo";import{convertLocalToGps as O,isValidPointCoords as d}from"./utils/gps";import m from"./core/Rect";import{mapEntity as y}from"./utils/mapEntity";import{LANG_KEY as X,MAX_ROUTE_WAYPOINTS as g,PATHWAY_KEY as U}from"./constants";import{getStorage as B}from"./utils/entity-storage";import{ErrorBoundary as K}from"@sentry/react";import{POISelectorsSchema as F,BoundsSchema as D,ZoomToOptionsSchema as A}from"./schemas/sdk.schemas";import W from"debug";import{buildOptimizedRoute as Q}from"./utils/buildOptimizedRoute";const b=W("efp:api");I();export default class Z extends ${root;init(){this.ignoreQuery||z(this.offHistory),H("load"),t.fp=this,q(this.allowConsent),w(P.Load,""),this.root=R(this.renderTarget),this.root.render(p(K,{children:p(V,{offHistory:this.offHistory,allowConsent:this.allowConsent})})),w(P.Rendered,""),C(()=>t.layerStore.layersLoaded,()=>{this.resolveReady(),t.initialized||this.onInit?.(this),t.initialized=!0})}selectBooth(e){if(typeof e!="string"&&!Array.isArray(e)){a("selectBooth","Parameter must be a string or an array of strings.","EFP000000");return}const i=t.boothStore.booths.filter(o=>typeof e=="string"?o.name===e||o.externalId===e:e.includes(o.name)||e.includes(o.externalId));t.selectBooth(i)}selectExhibitor(e){if(typeof e!="string"&&!Array.isArray(e)){a("selectExhibitor","Parameter must be a string or an array of strings.","EFP000100");return}if(!e?.length){t.uiState.menu=!1,t.searchStore.resetSearchBox(),t.uiState.details=null;return}const i=t.exhibitorStore.exhibitors.filter(s=>typeof e=="string"?s.name===e||s.externalId===e:e.includes(s.name)||e.includes(s.externalId));if(!i?.length)return;if(typeof e=="string"){t.selectExhibitor(i[0]),t.moveToList([i[0]]);return}const o=i.flatMap(s=>s.booths.map(r=>r.layer)),{description:n}=o.reduce((s,r)=>(s.freq[r.description]=(s.freq[r.description]||0)+1,s.freq[r.description]>s.maxCount&&(s.maxCount=s.freq[r.description],s.mostFrequent=r),s),{freq:{},mostFrequent:o[0],maxCount:0}).mostFrequent;t.layerStore.updateVisibility(n,!0),t.uiState.menu=!1,t.searchStore.resetSearchBox(),t.uiState.details=null,t.uiState.list={type:"filter",items:i,query:{key:"exhibitors",value:i.map(s=>s.externalId).join(",")}},t.moveToList()}highlightExhibitors(e){Array.isArray(e)||a("highlightExhibitors","Parameter must be an array of strings.","EFP000200"),t.boothStore.highlightedByExternalIds=[],t.exhibitorStore.highlightedByExternalIds=[...e]}highlightBooths(e){Array.isArray(e)||a("highlightBooths","Parameter must be an array of strings.","EFP000300"),t.exhibitorStore.highlightedByExternalIds=[],t.boothStore.highlightedByExternalIds=[...e]}highlightEntities(e){Array.isArray(e)||a("highlightEntities","Parameter must be an array of strings.","EFP000400");const{boothExternalIds:i,exhibitorExternalIds:o}=E(e);t.boothStore.highlightedByExternalIds=[...i],t.exhibitorStore.highlightedByExternalIds=[...o]}selectRoute(e,i){if(Array.isArray(e)){let o=[...e];const n=o.shift(),s=o.pop();if(o.length>g)throw new Error(`The maximum number of waypoints is ${g}.`);if(!n||!s){a("selectRoute","Invalid route format: When providing an array, it must include at least two points: a start and a destination.","EFP000401");return}t.routeStore.selectRoute(new S(f(n),f(s),o.map(f)));return}e||a("selectRoute","At a minimum, the starting point must be passed.","EFP000402"),t.routeStore.selectRoute(new S(f(e),f(i)))}getOptimizedRoutes(e){if(!Array.isArray(e))return a("getOptimizedRoutes","Parameter must be an array.","EFP000500"),[];if(e.length>g)throw new Error(`The maximum number of waypoints is ${g}.`);const i=e.map(f).filter(n=>!!n);if(!i.length)throw new Error("No booths found for the provided waypoints.");const o=new Map;for(const n of i){const s=n.layer?.name??"",r=o.get(s);r?r.push(n):o.set(s,[n])}return Array.from(o.values()).map(n=>({waypoints:Q(n.map(s=>[s.name,{cx:s.rect.cx,cy:s.rect.cy}]))}))}selectCurrentPosition(e,i,o){const n=d(e.x)&&d(e.y),s=d(e.lng)&&d(e.lat);!n&&!s&&a("selectCurrentPosition","A point must be passed. Either (x,y) or (lat,lng) are required.","EFP000600"),t.routeStore.selectCurrentPosition(e,i,o),this.onCurrentPositionChanged?.(e)}setBookmarks(e){(!Array.isArray(e)||!e.length)&&a("setBookmarks","Parameter must be an array.","EFP000700"),e.forEach(i=>{const o=t.exhibitorStore.exhibitors.find(n=>n.name===i.name||n.externalId===i.externalId);o&&(o.bookmarked=i.bookmarked)})}setEntitiesBookmarks(e){if(!Array.isArray(e)||!e.length){a("setEntitiesBookmarks","Parameter must be an array.","EFP000701");return}const i=["exhibitor","event","speaker","booth"],o=e.find(r=>!r.type||!i.includes(r.type));if(o){a("setEntitiesBookmarks",`Invalid entity type: ${o.type}. Must be one of: ${i.join(", ")}.`,"EFP000702");return}const n=B("bookmarked"),s={exhibitor:{existingIds:new Set(n.exhibitors||[]),finder:r=>t.exhibitorStore.findExhibitor(r),replacer:r=>t.exhibitorStore.replaceBookmarked(r)},event:{existingIds:new Set(n.events||[]),finder:r=>t.eventStore.findByNameOrSlug(r),replacer:r=>t.eventStore.replaceBookmarked(r)},speaker:{existingIds:new Set(n.speakers||[]),finder:r=>t.speakerStore.speakers.find(l=>l.name===r||l.externalId===r||l.slug===r),replacer:r=>t.speakerStore.replaceBookmarked(r)},booth:{existingIds:new Set(n.booths||[]),finder:r=>{const l=t.boothStore.findBooth(r);return l?.exhibitors.length===0?l:void 0},replacer:r=>t.boothStore.replaceBookmarked(r)}};e.forEach(r=>{const l=s[r.type],h=r.name||r.externalId||"",c=l.finder(h);c?r.bookmarked?l.existingIds.add(c.id):l.existingIds.delete(c.id):console.warn(`Entity not found: ${r.type} with query "${h}"`)}),Object.values(s).forEach(r=>{r.replacer(Array.from(r.existingIds))})}setEntitiesVisited(e){if(!Array.isArray(e)||!e.length){a("setEntitiesVisited","Parameter must be an array.","EFP000703");return}const i=["exhibitor","event"],o=e.find(r=>!r.type||!i.includes(r.type));if(o){a("setEntitiesVisited",`Invalid entity type: ${o.type}. Must be one of: ${i.join(", ")}.`,"EFP000704");return}const n=B("visited"),s={exhibitor:{existingIds:new Set(n.exhibitors||[]),finder:r=>t.exhibitorStore.findExhibitor(r),replacer:r=>t.exhibitorStore.replaceVisited(r)},event:{existingIds:new Set(n.events||[]),finder:r=>t.eventStore.findByNameOrSlug(r),replacer:r=>t.eventStore.replaceVisited(r)}};e.forEach(r=>{const l=s[r.type],h=r.name||r.externalId||"",c=l.finder(h);c?r.visited?l.existingIds.add(c.id):l.existingIds.delete(c.id):console.warn(`Entity not found: ${r.type} with query "${h}"`)}),Object.values(s).forEach(r=>{r.replacer(Array.from(r.existingIds))})}setMarkers(e){if(!e||!Array.isArray(e.icons)||!Array.isArray(e.markers)){a("setMarkers","Invalid input.","EFP000800");return}t.routeStore.setMarkers(e)}selectMarker(e,i=!0){return typeof e!="string"&&a("selectMarker","The identifier must be passed.","EFP000900"),t.routeStore.selectMarker(e,i)}drawCircles(e){Array.isArray(e)||a("drawCircles","Invalid input.","EFP000A00"),t.uiState.debugCircles=e}checkRoutes(){t.routeStore.checkRoutes()}updateLayerVisibility(e,i){typeof e!="string"&&a("updateLayerVisibility","The layer name (string) must be passed.","EFP000B00"),i||a("updateLayerVisibility","Passing a false value to visible will have no effect.","EFP000B01"),t.layerStore.updateVisibility(e,i)}getCenterCoordinates(){return t.fp.getCenterCoordinates()}exhibitorsList(){return t.exhibitorStore.exhibitors.map(e=>y(e))}boothsList(){return t.boothStore.booths.map(e=>y(e))}categoriesList(){return t.categoryStore.categories.map(e=>y(e))}selectCategory(e){if(e==null||typeof e!="string"){t.searchStore.selectSearch();return}const i=e?.toLowerCase(),o=t.categoryStore.categories.find(({name:n,slug:s})=>n?.toLowerCase()===i||s?.toLowerCase()===i);if(!o){a("selectCategory",`Category ${e} not found.`,"EFP000C01");return}t.selectCategory(o)}applyParameters(e){typeof e!="string"&&a("applyParameters","A query string must be passed.","EFP000D00"),M(e)}getVisibility(){return t.uiState.visibility}setVisibility(e){(typeof e!="object"||!Object.keys(e).length)&&a("setVisibility","The parameter must be passed.","EFP000E00"),t.uiState.setVisibility(e)}findLocation(){t.routeStore.findLocation()}zoomIn(){t.uiState.zoomIn()}zoomOut(){t.uiState.zoomOut()}switchView(){t.mapboxStore.activateMapbox()}zoomTo(e,i){b("zoomTo called with selectors=%O options=%O",e,i);const o=F.safeParse(e);if(!o.success){a("zoomTo",o.error.message,"EFP001600");return}const n=A.safeParse(i);if(!n.success){a("zoomTo",n.error.message,"EFP001601");return}const s=this.getBounds(e);s&&this.fitBounds(s,i)}getBounds(e){b("getBounds called with selectors=%O",e);const i=F.safeParse(e);if(!i.success){a("getBounds",i.error.message,"EFP001400");return}const o=[];if(e.booths?.forEach(s=>{let r;s.externalId?r=t.boothStore.boothByExternalId.get(s.externalId):s.name&&(r=t.boothStore.boothByName.get(s.name.toLowerCase())),r?.rect&&o.push(r.rect)}),e.exhibitors?.forEach(s=>{let r;s.externalId?r=t.exhibitorStore.exhibitorByExternalId.get(s.externalId):s.name&&(r=t.exhibitorStore.exhibitorByName.get(s.name.toLowerCase())),r?.booths?.forEach(l=>{l.rect&&o.push(l.rect)})}),o.length===0)return;const n=m.fromMultiple(o);return{leftTop:{x:n.x1,y:n.y1},rightBottom:{x:n.x2,y:n.y2}}}fitBounds(e,i){if(b("fitBounds called with bounds=%O options=%O",e,i),!e){t.uiState.fitBounds();return}const o=D.safeParse(e);if(!o.success){a("fitBounds",o.error.message,"EFP001500");return}const n=A.safeParse(i);if(!n.success){a("fitBounds",n.error.message,"EFP001501");return}let s;if(i?.padding){const r=i.padding;s=m.fromX1y1x2y2(e.leftTop.x-r,e.leftTop.y-r,e.rightBottom.x+r,e.rightBottom.y+r)}else s=m.fromX1y1x2y2(e.leftTop.x,e.leftTop.y,e.rightBottom.x,e.rightBottom.y);t.uiState.moveToRect=s}getBoothRect(e){return typeof e!="string"&&a("getBoothRect","A booth name must be passed.","EFP000F00"),x(e)?.rect}convertToGeo(e,i){if(!v?.properties?.config){a("convertToGeo","The coordinates cannot be converted because the GPS configuration is not defined.","EFP001000");return}if(!e||!i){a("convertToGeo","Both coordinates must be passed.","EFP001001");return}return O(e,i,v.properties.config)}unstable_destroy(){let e=window.__efpElement.firstChild;Y(),window.removeEventListener("__efpStyleLoad",this.efpStyleLoadHandler),window.removeEventListener("error",N),j(),G(),_(),[...document.getElementsByTagName("script")].filter(o=>o.src.indexOf("/fp.svg")>-1||o.src.indexOf("/wf.data.js")>-1||o.src.indexOf("/data.js")>-1).forEach(o=>o.remove()),this.root.unmount(),e.remove()}search(e){return typeof e!="string"&&a("search","A search string must be passed.","EFP001100"),t.fuzzySearchEngineStore.loadEngine().then(()=>(t.searchStore.selectSearch(e),t.uiState.fuzzySearchItems.map(i=>({item:y(i.item),score:i.score}))))}getFloors(){return t.layerStore.floors.map(e=>({name:e.name,shortName:e.shortName,description:e.description,active:e.active,disabled:e.disabled,index:e.index}))}activateFloor(e){if(!e?.name&&e?.index==null){a("activateFloor","Invalid floorId. It must contain either a name or an index.","EFP001200");return}const i=this.getFloors();if(e.name){const o=i.find(n=>n.name===e.name||n.shortName===e.name);if(!o){a("activateFloor",`Floor with name "${e.name}" not found.`,"EFP001201");return}if(o.active)return;this.updateLayerVisibility(o.name,!0);return}if(e.index!==null){const o=i[e.index]?.name;if(!o){a("activateFloor",`Floor at index ${e.index} does not exist.`,"EFP001203");return}if(i[e.index].active)return;this.updateLayerVisibility(o,!0);return}}showPathway(e,i){const o=new URLSearchParams;if(o.set(U,e),i?.length){const{boothExternalIds:n,exhibitorExternalIds:s}=E(i);n.length>0&&o.set("booths",n.join(",")),s.length>0&&o.set("exhibitors",s.join(","))}this.applyParameters(o.toString())}showPathwayOnly(e,i){this.activateFloor({name:i}),t.layerStore.showPathWay(e),t.uiState.setPathwayOnlyMode(!0);const o=t.layerStore.findLayer(e),n=t.layerStore.findLayer(i),s=o?.rect||o?.viewbox?o:n;if(s?.rect||s?.viewbox){const r=s.viewbox??s.rect;t.uiState.moveToRect=m.fromX1y1x2y2(r.x1,r.y1,r.x2,r.y2)}}hidePathways(){this.highlightBooths([]),t.layerStore.hidePathways(),t.uiState.setPathwayOnlyMode(!1)}showSearch(){t.selectSearch("")}changeLanguage(e){const i=e?.toLowerCase?.();if(!t.languageStore.languageIds.has(i)){a("changeLanguage",`Language "${e}" was not found. Available languages: ${[...t.languageStore.languageIds].join(",")}`,"EFP001300");return}const o=new URLSearchParams;o.set(X,i),this.applyParameters(o.toString())}isGpsTrackingEnabled(){return t.routeStore.gpsEnabled}setGpsTrackingEnabled(e){t.routeStore.setGpsTrackingEnabled(e)}deselectCurrentPosition(){t.routeStore.selectCurrentPosition(null,!1)}deselectRoute(){t.routeStore.selectRoute(null)}reset(){this.selectBooth(""),this.selectExhibitor(""),this.selectCategory(),this.deselectCurrentPosition(),this.deselectRoute(),this.highlightEntities([])}}function f(u){return typeof u=="string"?x(u):t.routeStore.getNearestBooth(u)}let k=0;function a(u,e,i){const o=`Error calling "${u}" SDK method.`,n=`${e.endsWith(".")?e:e+"."} More information at`;let s="https://developer.expofp.com/guide/java-script-api-reference";if(i&&(s+=`#error-${i}`),console.error(`${o} ${n} ${s}`),t.fp.disableRuntimeAlerts)return;t.uiState.setGlobalErrorMessage({title:o,body:T(L,{children:[n," ",p("a",{href:s,target:"_blank",rel:"noreferrer",children:s})]})}),clearTimeout(k);const r=8e3;k=window.setTimeout(()=>{const l=async()=>{t.uiState.globalErrorMessages.length>0&&(t.uiState.popGlobalErrorMessage(),await new Promise(h=>setTimeout(h,r/2)),l())};l()},r)}
|
|
1
|
+
import{jsx as p,Fragment as L,jsxs as T}from"react/jsx-runtime";import{reaction as C}from"mobx";import{createRoot as R}from"react-dom/client";import{install as I}from"resize-observer";import V from"./components/Layout";import $ from"./floorplan.loader";import{applyParameters as M,destroyHistory as j,initRouting as z}from"./services/routing";import t from"./store";import{Route as S,findBooth as x,separateExternalIds as E}from"./store/RouteStore";import{destroyUiHandlers as G}from"./store/init/init-ui";import{GaEventActions as P,destroyGtag as _,sendEventToGa as w,setConsentSettings as q}from"./tools/gtag";import N from"./tools/report-error";import{resetGlobalVariables as Y}from"./tools/reset";import H from"./tools/track-event";import{fpGeo as v}from"./components/Mapbox/utils/fpGeo";import{convertLocalToGps as O,isValidPointCoords as d}from"./utils/gps";import m from"./core/Rect";import{mapEntity as y}from"./utils/mapEntity";import{LANG_KEY as X,MAX_ROUTE_WAYPOINTS as g,PATHWAY_KEY as U}from"./constants";import{getStorage as B}from"./utils/entity-storage";import{ErrorBoundary as K}from"@sentry/react";import{POISelectorsSchema as F,BoundsSchema as D,ZoomToOptionsSchema as A}from"./schemas/sdk.schemas";import W from"debug";import{buildOptimizedRoute as Q}from"./utils/buildOptimizedRoute";const b=W("efp:api");I();export default class Z extends ${root;init(){this.ignoreQuery||z(this.offHistory),H("load"),t.fp=this,q(this.allowConsent),w(P.Load,""),this.root=R(this.renderTarget),this.root.render(p(K,{children:p(V,{offHistory:this.offHistory,allowConsent:this.allowConsent})})),w(P.Rendered,""),C(()=>t.layerStore.layersLoaded,()=>{this.resolveReady(),t.initialized||this.onInit?.(this),t.initialized=!0})}selectBooth(e){if(typeof e!="string"&&!Array.isArray(e)){a("selectBooth","Parameter must be a string or an array of strings.","EFP000000");return}const i=t.boothStore.booths.filter(o=>typeof e=="string"?o.name===e||o.externalId===e:e.includes(o.name)||e.includes(o.externalId));t.selectBooth(i)}selectExhibitor(e){if(typeof e!="string"&&!Array.isArray(e)){a("selectExhibitor","Parameter must be a string or an array of strings.","EFP000100");return}if(!e?.length){t.uiState.menu=!1,t.searchStore.resetSearchBox(),t.uiState.details=null;return}const i=t.exhibitorStore.exhibitors.filter(s=>typeof e=="string"?s.name===e||s.externalId===e:e.includes(s.name)||e.includes(s.externalId));if(!i?.length)return;if(typeof e=="string"){t.selectExhibitor(i[0]),t.moveToList([i[0]]);return}const o=i.flatMap(s=>s.booths.map(r=>r.layer)),{description:n}=o.reduce((s,r)=>(s.freq[r.description]=(s.freq[r.description]||0)+1,s.freq[r.description]>s.maxCount&&(s.maxCount=s.freq[r.description],s.mostFrequent=r),s),{freq:{},mostFrequent:o[0],maxCount:0}).mostFrequent;t.layerStore.updateVisibility(n,!0),t.uiState.menu=!1,t.searchStore.resetSearchBox(),t.uiState.details=null,t.uiState.list={type:"filter",items:i,query:{key:"exhibitors",value:i.map(s=>s.externalId).join(",")}},t.moveToList()}highlightExhibitors(e){Array.isArray(e)||a("highlightExhibitors","Parameter must be an array of strings.","EFP000200"),t.boothStore.highlightedByExternalIds=[],t.exhibitorStore.highlightedByExternalIds=[...e]}highlightBooths(e){Array.isArray(e)||a("highlightBooths","Parameter must be an array of strings.","EFP000300"),t.exhibitorStore.highlightedByExternalIds=[],t.boothStore.highlightedByExternalIds=[...e]}highlightEntities(e){Array.isArray(e)||a("highlightEntities","Parameter must be an array of strings.","EFP000400");const{boothExternalIds:i,exhibitorExternalIds:o}=E(e);t.boothStore.highlightedByExternalIds=[...i],t.exhibitorStore.highlightedByExternalIds=[...o]}selectRoute(e,i){if(Array.isArray(e)){let o=[...e];const n=o.shift(),s=o.pop();if(o.length>g)throw new Error(`The maximum number of waypoints is ${g}.`);if(!n||!s){a("selectRoute","Invalid route format: When providing an array, it must include at least two points: a start and a destination.","EFP000401");return}t.routeStore.selectRoute(new S(f(n),f(s),o.map(f)));return}e||a("selectRoute","At a minimum, the starting point must be passed.","EFP000402"),t.routeStore.selectRoute(new S(f(e),f(i)))}getOptimizedRoutes(e){if(!Array.isArray(e))return a("getOptimizedRoutes","Parameter must be an array.","EFP000500"),[];if(e.length>g)throw new Error(`The maximum number of waypoints is ${g}.`);const i=e.map(f).filter(n=>!!n);if(!i.length)throw new Error("No booths found for the provided waypoints.");const o=new Map;for(const n of i){const s=n.layer?.name??"",r=o.get(s);r?r.push(n):o.set(s,[n])}return Array.from(o.values()).map(n=>({waypoints:Q(n.map(s=>[s.name,{cx:s.rect.cx,cy:s.rect.cy}]))}))}selectCurrentPosition(e,i,o){const n=d(e.x)&&d(e.y),s=d(e.lng)&&d(e.lat);!n&&!s&&a("selectCurrentPosition","A point must be passed. Either (x,y) or (lat,lng) are required.","EFP000600"),t.routeStore.selectCurrentPosition(e,i,o),this.onCurrentPositionChanged?.(e)}setBookmarks(e){(!Array.isArray(e)||!e.length)&&a("setBookmarks","Parameter must be an array.","EFP000700"),e.forEach(i=>{const o=t.exhibitorStore.exhibitors.find(n=>n.name===i.name||n.externalId===i.externalId);o&&(o.bookmarked=i.bookmarked)})}setEntitiesBookmarks(e){if(!Array.isArray(e)||!e.length){a("setEntitiesBookmarks","Parameter must be an array.","EFP000701");return}const i=["exhibitor","event","speaker","booth"],o=e.find(r=>!r.type||!i.includes(r.type));if(o){a("setEntitiesBookmarks",`Invalid entity type: ${o.type}. Must be one of: ${i.join(", ")}.`,"EFP000702");return}const n=B("bookmarked"),s={exhibitor:{existingIds:new Set(n.exhibitors||[]),finder:r=>t.exhibitorStore.findExhibitor(r),replacer:r=>t.exhibitorStore.replaceBookmarked(r)},event:{existingIds:new Set(n.events||[]),finder:r=>t.eventStore.findByNameOrSlug(r),replacer:r=>t.eventStore.replaceBookmarked(r)},speaker:{existingIds:new Set(n.speakers||[]),finder:r=>t.speakerStore.speakers.find(l=>l.name===r||l.externalId===r||l.slug===r),replacer:r=>t.speakerStore.replaceBookmarked(r)},booth:{existingIds:new Set(n.booths||[]),finder:r=>{const l=t.boothStore.findBooth(r);return l?.exhibitors.length===0?l:void 0},replacer:r=>t.boothStore.replaceBookmarked(r)}};e.forEach(r=>{const l=s[r.type],h=r.name||r.externalId||"",c=l.finder(h);c?r.bookmarked?l.existingIds.add(c.id):l.existingIds.delete(c.id):console.warn(`Entity not found: ${r.type} with query "${h}"`)}),Object.values(s).forEach(r=>{r.replacer(Array.from(r.existingIds))})}setEntitiesVisited(e){if(!Array.isArray(e)||!e.length){a("setEntitiesVisited","Parameter must be an array.","EFP000703");return}const i=["exhibitor","event"],o=e.find(r=>!r.type||!i.includes(r.type));if(o){a("setEntitiesVisited",`Invalid entity type: ${o.type}. Must be one of: ${i.join(", ")}.`,"EFP000704");return}const n=B("visited"),s={exhibitor:{existingIds:new Set(n.exhibitors||[]),finder:r=>t.exhibitorStore.findExhibitor(r),replacer:r=>t.exhibitorStore.replaceVisited(r)},event:{existingIds:new Set(n.events||[]),finder:r=>t.eventStore.findByNameOrSlug(r),replacer:r=>t.eventStore.replaceVisited(r)}};e.forEach(r=>{const l=s[r.type],h=r.name||r.externalId||"",c=l.finder(h);c?r.visited?l.existingIds.add(c.id):l.existingIds.delete(c.id):console.warn(`Entity not found: ${r.type} with query "${h}"`)}),Object.values(s).forEach(r=>{r.replacer(Array.from(r.existingIds))})}setMarkers(e){if(!e||!Array.isArray(e.icons)||!Array.isArray(e.markers)){a("setMarkers","Invalid input.","EFP000800");return}t.routeStore.setMarkers(e)}selectMarker(e,i=!0){return typeof e!="string"&&a("selectMarker","The identifier must be passed.","EFP000900"),t.routeStore.selectMarker(e,i)}drawCircles(e){Array.isArray(e)||a("drawCircles","Invalid input.","EFP000A00"),t.uiState.debugCircles=e}checkRoutes(){t.routeStore.checkRoutes()}updateLayerVisibility(e,i){typeof e!="string"&&a("updateLayerVisibility","The layer name (string) must be passed.","EFP000B00"),i||a("updateLayerVisibility","Passing a false value to visible will have no effect.","EFP000B01"),t.layerStore.updateVisibility(e,i)}getCenterCoordinates(){return t.fp.getCenterCoordinates()}exhibitorsList(){return t.exhibitorStore.exhibitors.map(e=>y(e))}boothsList(){return t.boothStore.booths.map(e=>y(e))}categoriesList(){return t.categoryStore.categories.map(e=>y(e))}selectCategory(e){if(e==null||typeof e!="string"){t.searchStore.selectSearch();return}const i=e?.toLowerCase(),o=t.categoryStore.categories.find(({name:n,slug:s})=>n?.toLowerCase()===i||s?.toLowerCase()===i);if(!o){a("selectCategory",`Category ${e} not found.`,"EFP000C01");return}t.selectCategory(o)}applyParameters(e){typeof e!="string"&&a("applyParameters","A query string must be passed.","EFP000D00"),M(e)}getVisibility(){return t.uiState.visibility}setVisibility(e){(typeof e!="object"||!Object.keys(e).length)&&a("setVisibility","The parameter must be passed.","EFP000E00"),t.uiState.setVisibility(e)}findLocation(){t.routeStore.findLocation()}zoomIn(){t.uiState.zoomIn()}zoomOut(){t.uiState.zoomOut()}switchView(){t.mapboxStore.activateMapbox()}zoomTo(e,i){b("zoomTo called with selectors=%O options=%O",e,i);const o=F.safeParse(e);if(!o.success){a("zoomTo",o.error.message,"EFP001600");return}const n=A.safeParse(i);if(!n.success){a("zoomTo",n.error.message,"EFP001601");return}const s=this.getBounds(e);s&&this.fitBounds(s,i)}getBounds(e){b("getBounds called with selectors=%O",e);const i=F.safeParse(e);if(!i.success){a("getBounds",i.error.message,"EFP001400");return}const o=[];if(e.booths?.forEach(s=>{let r;s.externalId?r=t.boothStore.boothByExternalId.get(s.externalId):s.name&&(r=t.boothStore.boothByName.get(s.name.toLowerCase())),r?.rect&&o.push(r.rect)}),e.exhibitors?.forEach(s=>{let r;s.externalId?r=t.exhibitorStore.exhibitorByExternalId.get(s.externalId):s.name&&(r=t.exhibitorStore.exhibitorByName.get(s.name.toLowerCase())),r?.booths?.forEach(l=>{l.rect&&o.push(l.rect)})}),o.length===0)return;const n=m.fromMultiple(o);return{leftTop:{x:n.x1,y:n.y1},rightBottom:{x:n.x2,y:n.y2}}}fitBounds(e,i){if(b("fitBounds called with bounds=%O options=%O",e,i),!e){t.uiState.fitBounds();return}const o=D.safeParse(e);if(!o.success){a("fitBounds",o.error.message,"EFP001500");return}const n=A.safeParse(i);if(!n.success){a("fitBounds",n.error.message,"EFP001501");return}let s;if(i?.padding){const r=i.padding;s=m.fromX1y1x2y2(e.leftTop.x-r,e.leftTop.y-r,e.rightBottom.x+r,e.rightBottom.y+r)}else s=m.fromX1y1x2y2(e.leftTop.x,e.leftTop.y,e.rightBottom.x,e.rightBottom.y);t.uiState.moveToRect=s}getBoothRect(e){return typeof e!="string"&&a("getBoothRect","A booth name must be passed.","EFP000F00"),x(e)?.rect}convertToGeo(e,i){if(!v?.properties?.config){a("convertToGeo","The coordinates cannot be converted because the GPS configuration is not defined.","EFP001000");return}if(!e||!i){a("convertToGeo","Both coordinates must be passed.","EFP001001");return}return O(e,i,v.properties.config)}unstable_destroy(){let e=window.__efpElement.firstChild;Y(),window.removeEventListener("__efpStyleLoad",this.efpStyleLoadHandler),window.removeEventListener("error",N),j(),G(),_(),[...document.getElementsByTagName("script")].filter(o=>o.src.indexOf("/fp.svg")>-1||o.src.indexOf("/wf.data.js")>-1||o.src.indexOf("/data.js")>-1).forEach(o=>o.remove()),this.root.unmount(),e.remove()}search(e){return typeof e!="string"&&a("search","A search string must be passed.","EFP001100"),t.fuzzySearchEngineStore.loadEngine().then(()=>(t.searchStore.selectSearch(e),t.uiState.fuzzySearchItems.map(i=>({item:y(i.item),score:i.score}))))}getFloors(){return t.layerStore.floors.map(e=>({name:e.name,shortName:e.shortName,description:e.description,active:e.active,disabled:e.disabled,index:e.index}))}activateFloor(e){if(!e?.name&&e?.index==null){a("activateFloor","Invalid floorId. It must contain either a name or an index.","EFP001200");return}const i=this.getFloors();if(e.name){const o=i.find(n=>n.name===e.name||n.shortName===e.name);if(!o){a("activateFloor",`Floor with name "${e.name}" not found.`,"EFP001201");return}if(o.active)return;this.updateLayerVisibility(o.name,!0);return}if(e.index!==null){const o=i.find(s=>s.index===e.index),n=o?.name;if(!n){a("activateFloor",`Floor at index ${e.index} does not exist.`,"EFP001203");return}if(o.active)return;this.updateLayerVisibility(n,!0);return}}showPathway(e,i){const o=new URLSearchParams;if(o.set(U,e),i?.length){const{boothExternalIds:n,exhibitorExternalIds:s}=E(i);n.length>0&&o.set("booths",n.join(",")),s.length>0&&o.set("exhibitors",s.join(","))}this.applyParameters(o.toString())}showPathwayOnly(e,i){this.activateFloor({name:i}),t.layerStore.showPathWay(e),t.uiState.setPathwayOnlyMode(!0);const o=t.layerStore.findLayer(e),n=t.layerStore.findLayer(i),s=o?.rect||o?.viewbox?o:n;if(s?.rect||s?.viewbox){const r=s.viewbox??s.rect;t.uiState.moveToRect=m.fromX1y1x2y2(r.x1,r.y1,r.x2,r.y2)}}hidePathways(){this.highlightBooths([]),t.layerStore.hidePathways(),t.uiState.setPathwayOnlyMode(!1)}showSearch(){t.selectSearch("")}changeLanguage(e){const i=e?.toLowerCase?.();if(!t.languageStore.languageIds.has(i)){a("changeLanguage",`Language "${e}" was not found. Available languages: ${[...t.languageStore.languageIds].join(",")}`,"EFP001300");return}const o=new URLSearchParams;o.set(X,i),this.applyParameters(o.toString())}isGpsTrackingEnabled(){return t.routeStore.gpsEnabled}setGpsTrackingEnabled(e){t.routeStore.setGpsTrackingEnabled(e)}deselectCurrentPosition(){t.routeStore.selectCurrentPosition(null,!1)}deselectRoute(){t.routeStore.selectRoute(null)}reset(){this.selectBooth(""),this.selectExhibitor(""),this.selectCategory(),this.deselectCurrentPosition(),this.deselectRoute(),this.highlightEntities([]),this.fitBounds()}}function f(u){return typeof u=="string"?x(u):t.routeStore.getNearestBooth(u)}let k=0;function a(u,e,i){const o=`Error calling "${u}" SDK method.`,n=`${e.endsWith(".")?e:e+"."} More information at`;let s="https://developer.expofp.com/guide/java-script-api-reference";if(i&&(s+=`#error-${i}`),console.error(`${o} ${n} ${s}`),t.fp.disableRuntimeAlerts)return;t.uiState.setGlobalErrorMessage({title:o,body:T(L,{children:[n," ",p("a",{href:s,target:"_blank",children:s})]})}),clearTimeout(k);const r=8e3;k=window.setTimeout(()=>{const l=async()=>{t.uiState.globalErrorMessages.length>0&&(t.uiState.popGlobalErrorMessage(),await new Promise(h=>setTimeout(h,r/2)),l())};l()},r)}
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import r from"./tools/report-error";window.addEventListener("error",r),window.__efpStyleElements=[];export{load}from"./load";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import v from"../utils/is-webview";import{BROADCAST_CHANNEL_NAME as f,MESSAGE_CACHE as p,MESSAGE_CACHE_BUNDLE as y,MESSAGE_REFRESH as E}from"./constants";export async function initOfflineManager(r,t,i=[]){try{let c=function(e){o.has(e.data?.type)&&e.data?.payload&&o.delete(e.data?.type)},g=function(e){return r?`${r}${e}`:e},d=function(){if(navigator.serviceWorker.controller){const e="expofp_cache_refresh_ready";localStorage.getItem(e)==="1"?n({type:E}):localStorage.setItem(e,"1")}};if(!("serviceWorker"in navigator)||v||!await navigator.serviceWorker.getRegistration())return;navigator.serviceWorker.controller||await navigator.serviceWorker.ready;const a=new BroadcastChannel(f),o=new Set;u(),a.removeEventListener("message",c),a.addEventListener("message",c),n({type:p,payload:t}),n({type:y,payload:g("bundle.json")}),d();async function n(e){const l=()=>{!navigator.serviceWorker.controller||o.has(e.type)||!navigator.onLine||(a.postMessage(e),o.add(e.type))};l(),navigator.serviceWorker.controller||navigator.serviceWorker.addEventListener("controllerchange",l,{once:!0})}}catch(s){console.error(s)}}function u(){const r="expofp_persisted_storage_requested";if(sessionStorage.getItem(r)||!navigator.storage)return;const t=()=>{navigator.storage.persisted().then(i=>!i&&navigator.storage.persist()).catch(console.warn).finally(()=>{sessionStorage.setItem(r,"true"),window.removeEventListener("click",t)})};window.addEventListener("click",t)}
|