UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) • 2.62 kB
import{__decorate as t}from"tslib";import{action as r,computed as o,observable as l}from"mobx";import a from"../data";import{fpGeo as n}from"../data/fpGeo";const s=import.meta.env?.VITE_EXPOFP_DISABLE_3D_TOGGLE!=="false";function d(){return typeof window>"u"||window.navigator.onLine}export default class e{constructor(i){this.mapViewMode="floorplan",this.maplibreSelected=!1,this.isOnline=d(),this.cameraPortBox=l.box(null,{deep:!1}),this.handleOnline=()=>this.setOnline(!0),this.handleOffline=()=>this.setOnline(!1),this.rootStore=i,this.mapViewMode=this.getInitialViewMode(),this.maplibreSelected=this.mapViewMode!=="floorplan",typeof window<"u"&&(window.addEventListener("online",this.handleOnline),window.addEventListener("offline",this.handleOffline))}dispose(){typeof window>"u"||(window.removeEventListener("online",this.handleOnline),window.removeEventListener("offline",this.handleOffline))}setOnline(i){this.isOnline=i}get cameraPort(){return this.cameraPortBox.get()}setCameraPort(i){this.cameraPortBox.set(i)}clearCameraPortIfCurrent(i){this.cameraPortBox.get()===i&&this.cameraPortBox.set(null)}activateMaplibre(){this.maplibreEnabled&&(this.mapViewMode=a.allow3dView&&this.mapViewMode!=="map3d"?"map3d":"map2d",this.maplibreSelected=!0)}deactivateMaplibre(){this.mapViewMode="floorplan",this.maplibreSelected=!1}get hideModeSwitchButton(){return!this.maplibreEnabled||!a.allow3dView||s||a.hideModeSwitchButton}get maplibreEnabled(){const i=this.rootStore.fp?.maplibre??window.__efpMaplibre,p=!!i?.offline&&(!!i.style||!!i.styleUrl);return this.useMaplibreMap&&!!n?.properties?.config&&(this.isOnline||p)}get useMaplibreMap(){return a.enableExperimentalMaplibre??n?.properties?.config?.type==="maplibre"}get showMaplibre(){return this.maplibreEnabled&&(this.mapViewMode==="map2d"||this.mapViewMode==="map3d")}get isMap3d(){return this.maplibreEnabled&&this.mapViewMode==="map3d"}getInitialViewMode(){return this.maplibreEnabled?this.rootStore.uiState.is3DView?"map3d":"map2d":"floorplan"}}t([l],e.prototype,"mapViewMode",void 0),t([l],e.prototype,"maplibreSelected",void 0),t([l],e.prototype,"isOnline",void 0),t([r],e.prototype,"setOnline",null),t([r],e.prototype,"setCameraPort",null),t([r],e.prototype,"clearCameraPortIfCurrent",null),t([r],e.prototype,"activateMaplibre",null),t([r],e.prototype,"deactivateMaplibre",null),t([o({keepAlive:!0})],e.prototype,"hideModeSwitchButton",null),t([o({keepAlive:!0})],e.prototype,"maplibreEnabled",null),t([o({keepAlive:!0})],e.prototype,"useMaplibreMap",null),t([o({keepAlive:!0})],e.prototype,"showMaplibre",null),t([o({keepAlive:!0})],e.prototype,"isMap3d",null);