@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 4.3 kB
JavaScript
import{__esDecorate as i,__runInitializers as l}from"tslib";import{registerEnumSetting as I}from"@expofp/debug";import{action as o,computed as r,observable as d}from"mobx";import n from"../data";import{fpGeo as z}from"../data/fpGeo";const A=import.meta.env?.VITE_EXPOFP_USE_MAPLIBRE_MAP==="true",B=import.meta.env?.VITE_EXPOFP_DISABLE_3D_TOGGLE!=="false";function L(){return typeof window>"u"||window.navigator.onLine}let x=(()=>{let a=[],p,m=[],c=[],f,h=[],u=[],b,M=[],_=[],w,v,g,O,S,E,V,k;return class{static{const t=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;p=[d],f=[d],b=[d],w=[o],v=[o],g=[o],O=[r({keepAlive:!0})],S=[r({keepAlive:!0})],E=[r({keepAlive:!0})],V=[r({keepAlive:!0})],k=[r({keepAlive:!0})],i(this,null,w,{kind:"method",name:"setOnline",static:!1,private:!1,access:{has:e=>"setOnline"in e,get:e=>e.setOnline},metadata:t},null,a),i(this,null,v,{kind:"method",name:"activateMaplibre",static:!1,private:!1,access:{has:e=>"activateMaplibre"in e,get:e=>e.activateMaplibre},metadata:t},null,a),i(this,null,g,{kind:"method",name:"deactivateMaplibre",static:!1,private:!1,access:{has:e=>"deactivateMaplibre"in e,get:e=>e.deactivateMaplibre},metadata:t},null,a),i(this,null,O,{kind:"getter",name:"hideModeSwitchButton",static:!1,private:!1,access:{has:e=>"hideModeSwitchButton"in e,get:e=>e.hideModeSwitchButton},metadata:t},null,a),i(this,null,S,{kind:"getter",name:"maplibreEnabled",static:!1,private:!1,access:{has:e=>"maplibreEnabled"in e,get:e=>e.maplibreEnabled},metadata:t},null,a),i(this,null,E,{kind:"getter",name:"useMaplibreMap",static:!1,private:!1,access:{has:e=>"useMaplibreMap"in e,get:e=>e.useMaplibreMap},metadata:t},null,a),i(this,null,V,{kind:"getter",name:"showMaplibre",static:!1,private:!1,access:{has:e=>"showMaplibre"in e,get:e=>e.showMaplibre},metadata:t},null,a),i(this,null,k,{kind:"getter",name:"isMap3d",static:!1,private:!1,access:{has:e=>"isMap3d"in e,get:e=>e.isMap3d},metadata:t},null,a),i(null,null,p,{kind:"field",name:"mapViewMode",static:!1,private:!1,access:{has:e=>"mapViewMode"in e,get:e=>e.mapViewMode,set:(e,s)=>{e.mapViewMode=s}},metadata:t},m,c),i(null,null,f,{kind:"field",name:"maplibreSelected",static:!1,private:!1,access:{has:e=>"maplibreSelected"in e,get:e=>e.maplibreSelected,set:(e,s)=>{e.maplibreSelected=s}},metadata:t},h,u),i(null,null,b,{kind:"field",name:"isOnline",static:!1,private:!1,access:{has:e=>"isOnline"in e,get:e=>e.isOnline,set:(e,s)=>{e.isOnline=s}},metadata:t},M,_),t&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:t})}rootStore=l(this,a);mapViewMode=l(this,m,"floorplan");maplibreSelected=(l(this,c),l(this,h,!1));isOnline=(l(this,u),l(this,M,L()));handleOnline=(l(this,_),()=>this.setOnline(!0));handleOffline=()=>this.setOnline(!1);constructor(t){this.rootStore=t,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(t){this.isOnline=t}activateMaplibre(){this.maplibreEnabled&&(this.mapViewMode=n.allow3dView&&this.mapViewMode!=="map3d"?"map3d":"map2d",this.maplibreSelected=!0)}deactivateMaplibre(){this.mapViewMode="floorplan",this.maplibreSelected=!1}get hideModeSwitchButton(){return!this.maplibreEnabled||!n.allow3dView||B||n.hideModeSwitchButton}get maplibreEnabled(){const t=this.rootStore.fp?.maplibre??window.__efpMaplibre,e=!!t?.offline&&(!!t.style||!!t.styleUrl);return this.useMaplibreMap&&!!z?.properties?.config&&!this.rootStore.uiState.kiosk&&(this.isOnline||e)}get useMaplibreMap(){if(y.get()==="on")return!0;if(y.get()==="off")return!1;const t=n.flags?.enableExperimentalMaplibre;return typeof t=="boolean"?t:A}get showMaplibre(){return this.maplibreEnabled&&(this.mapViewMode==="map2d"||this.mapViewMode==="map3d")}get isMap3d(){return this.maplibreEnabled&&this.mapViewMode==="map3d"}getInitialViewMode(){return this.maplibreEnabled?n.allow3dView&&!n.hide3dMapDefault?"map3d":"map2d":"floorplan"}}})();export default x;const y=I({key:"efp:maplibre:override",values:["default","on","off"],default:"default"});