UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 12.1 kB
import{__decorate as i}from"tslib";import{action as s,computed as m,observable as u,runInAction as S}from"mobx";import{LANGUAGE_TYPE as d}from"../constants";import{RendererService as y}from"../renderer";import{URLFilterManager as w}from"../services/URLFilterManager";import{GaEventActions as b}from"../tools/gtag";import g from"../tools/logger";import{isWebGlSupported as v}from"../utils";import{resetLocale as k}from"../utils/i18n";import h from"../utils/is-mobile";import n from"../utils/is-webview";import{sanitizeSearch as x}from"../utils/sanitizeText";import B from"./BookmarksStore";import _,{BoothBase as c,RegularBooth as L}from"./BoothStore";import C from"./CategoryFilterStore";import E,{Category as T}from"./CategoryStore";import I,{EventItem as F}from"./EventStore";import M,{Exhibitor as p}from"./ExhibitorStore";import O from"./FuzzySearchEngineStore";import z from"./HeatmapStore";import R from"./IntercomStore";import A,{LayersMode as f}from"./LayerStore";import P from"./MaplibreStore";import V from"./PoiMarkerStore";import G from"./PoiTypeStore";import{SearchShortcutProvider as q}from"./providers/SearchShortcutProvider";import{SessionsShortcutProvider as N}from"./providers/SessionsShortcutProvider";import{SpeakerShortcutProvider as U}from"./providers/SpeakerShortcutProvider";import W from"./RoutePlannerStore";import j from"./RouteStore";import H from"./SearchButtonsStore";import K from"./SearchStore";import Y from"./SessionsFilterStore";import{ShortcutRegistry as $}from"./ShortcutRegistry";import D from"./SpeakerFilterStore";import J from"./SpeakerStore";import{SpeakerItem as Q}from"./SpeakerStore";import X from"./ToursStore";import Z from"./UIState";export default class e{setResetCameraFn(t){this.resetCameraFn=t}constructor(){this.rendererService=new y,this.initialized=!1,this.categoryStore=new E(this),this.exhibitorStore=new M(this),this.boothStore=new _(this),this.routeStore=new j(this),this.routePlannerStore=new W(this),this.toursStore=new X(this),this.uiState=new Z(this),this.maplibreStore=new P(this),this.layerStore=new A,this.intercomStore=new R,this.eventStore=new I(this),this.heatmapStore=new z,this.poiTypeStore=new G(this),this.poiMarkerStore=new V(this),this.fuzzySearchEngineStore=new O(["name","title","fullName","booths.name"]),this.categoryFilterStore=new C(this),this.sessionsFilterStore=new Y(this),this.speakerStore=new J(this),this.speakerFilterStore=new D(this),this.searchStore=new K(this),this.searchButtonsStore=new H(this),this.bookmarksStore=new B(this),this.urlFilterManager=new w(this),this.shortcutRegistry=new $,this.registerShortcutProviders()}selectExhibitor(t,r=!0){this.uiState.hoveredExhibitor=null,this.uiState.details=t;var o=t.booths.filter(a=>a.visible),l=t.booths.filter(a=>!a.visible);!o.length&&l.length&&this.layerStore.updateVisibility(l[0].layer,!0),r&&setTimeout(()=>this.moveToList(t.booths.filter(a=>a.visible)),n||h?500:50)}selectBooth(t,r=!0){let o=Array.isArray(t)?t:[t];this.uiState.details=o[0],o.length===1&&o[0].schedule?.length&&(this.uiState.desiredOverlaySize="medium"),o.length===1&&o[0].layer&&!o[0].visible&&this.layerStore.mode===f.Radio&&this.layerStore.updateVisibility(o[0].layer,!0),r&&setTimeout(()=>this.moveToList(o),n||h?500:50)}reset(){const t=window.__searchi;t&&t.querySelector&&t.querySelector("input[type=search]")&&t.querySelector("input[type=search]").blur&&t.querySelector("input[type=search]").blur(),window.setTimeout(()=>{this.uiState.setKioskModeEnabled||k().then(()=>{S(()=>{this.selectSearch(""),this.uiState.details=null,this.resetCameraFn?.(),this.uiState.menu=!1,this.searchStore.resetSearchBox(),this.searchButtonsStore.clearAllFilters()}),setTimeout(()=>{S(()=>{this.uiState.inIdle=!0})},100)})},1e3)}selectNone(){window.__resett&&window.__resett(),this.uiState.details=this.uiState.selectedCategory}selectBookmarks(){this.uiState.details=null,this.uiState.list={type:"bookmarks"}}selectVisited(){this.uiState.details=null,this.uiState.list={type:"visited"}}selectLanguage(){this.uiState.details=null,this.uiState.list={type:d}}selectCategory(t){window.__resett&&window.__resett(),this.uiState.details=t,this.uiState.list={type:"category",category:t},this.uiState.desiredOverlaySize="full",t.exhibitors.find(o=>o.booths.find(l=>l.visible))||this.layerStore.updateVisibility(t.exhibitors[0]?.booths[0]?.layer,!0),setTimeout(()=>{this.uiState.moveToBooths=t.exhibitors.filter(o=>o.booths.find(l=>l.visible)).flatMap(o=>o.booths)},200)}selectEventItem(t,r=!0){if(this.uiState.hoveredExhibitor=null,this.uiState.details=t,this.uiState.desiredOverlaySize="medium",t.boothId){const o=this.boothStore.booths.find(l=>l.id===t.boothId);o&&o.layer&&!o.visible&&this.layerStore.mode===f.Radio&&this.layerStore.updateVisibility(o.layer,!0)}r&&setTimeout(()=>{if(t.boothId){const o=this.boothStore.booths.find(l=>l.id===t.boothId);o&&this.moveToList([o])}},n||h?500:50)}selectSearch(t){window.__resett&&window.__resett(),this.uiState.details=null,this.speakerStore.clearSelectedSpeaker(),this.uiState.list={type:"search",text:x(t,Object.keys(this.uiState.mapSettings).map(r=>`${r}=`)),focused:!1},this.uiState.activeListIndex=-1}clickBookmarks(){window.__resett&&window.__resett(),this.uiState.menu=!1,this.selectBookmarks(),this.moveToList(),this.showMap()}clickVisited(){window.__resett&&window.__resett(),this.uiState.menu=!1,this.selectVisited(),this.moveToList(),this.showMap()}clickLanguage(){window.__resett&&window.__resett(),this.uiState.menu=!1,this.selectLanguage()}clickCategory(t){window.__resett&&window.__resett(),this.uiState.menu=!1,this.selectCategory(t),this.uiState.onCategoryClick&&this.uiState.onCategoryClick({id:t.id,name:t.name,exhibitors:t.exhibitors.map(r=>r.id)}),setTimeout(()=>{this.moveToList(),this.showMap()},100)}clickSeminars(){this.clickCategory(this.categoryStore.seminarsCategory)}clickBoothInList(t){window.__resett&&window.__resett(),this.uiState.hoveredBooth=null,this.selectBooth(t),this.moveToList([t]),this.showMap()}clickBoothInList2(t){window.__resett&&window.__resett(),this.uiState.hoveredBooth=null,this.selectBooth(t,!1),window.setTimeout(()=>{this.moveToList([t]),this.showMap()},navigator.userAgent.toLowerCase().indexOf("android")>-1?400:50)}clickBooth(t){if(this.uiState.menu=!1,this.uiState.list.type==="sessions"&&this.searchStore.selectSearch(),this.uiState.list.type==="speakers"&&this.searchStore.selectSearch(),this.uiState.list.type==="tours"&&this.searchStore.selectSearch(),this.uiState.list.type==="multi-point-tour"&&this.searchStore.selectSearch(),!(this.uiState.selectedRoute?.from&&this.uiState.selectedRoute?.to)){if(this.uiState.selectedRoute?.to&&!this.uiState.selectedRoute?.from&&t){this.routeStore.setStartPoint(t);return}if(t)this.routeStore.tempToBooth=t;else{this.uiState.details=null,this.fp.hidePathways(),this.uiState.list={type:"search",text:"",focused:!1},this.uiState.onBoothClick&&this.uiState.onBoothClick({target:null});return}if(this.uiState.onBoothClick){const r={name:"",description:""},o={target:{...t,layer:t.layer||r}};this.uiState.onBoothClick(o)}t.exhibitors.length===1&&t instanceof L?(this.heatmapStore.forceTrack={action:b.ViewBooth,label:t.name},this.selectExhibitor(t.exhibitors[0],!1)):this.selectBooth(t,!1),this.showMap()}}clickExhibitor2(t){this.selectExhibitor(t,!0),this.showMap()}clickExhibitor(t){window.setTimeout(()=>{this.clickExhibitor2(t)},navigator.userAgent.toLowerCase().indexOf("android")>-1?400:50)}showMap(){this.uiState.overlayPosition==="bottom"&&v&&(this.uiState.desiredOverlaySize="medium")}showOverlay(){this.uiState.overlayPosition==="bottom"&&(this.uiState.desiredOverlaySize="full")}toggleMapOverlay(){this.uiState.overlayPosition==="bottom"&&this.uiState.overlaySize==="full"?this.uiState.desiredOverlaySize="medium":this.uiState.overlayPosition==="bottom"&&this.uiState.overlaySize!=="full"&&(this.uiState.desiredOverlaySize="full")}moveToList(t){t=t||this.uiState.listItems;const r=[];t.forEach(o=>{if(o instanceof p)r.push(...o.booths.filter(l=>l.visible));else if(o instanceof c)o.visible&&r.push(o);else if(o instanceof F&&o.boothId){const l=this.boothStore.boothById.get(o.boothId);l?.visible&&r.push(l)}else o instanceof Q&&this.speakerStore.getEventsBySpeaker(o.id).forEach(l=>{if(!l.boothId)return;const a=this.boothStore.boothById.get(l.boothId);a?.visible&&r.push(a)})}),this.uiState.moveToBooths=r}moveToExhibitor(t){this.moveToList([t])}changeActiveListIndex(t){let r=this.uiState.activeListIndex+t;r=Math.max(0,Math.min(this.uiState.listItems.length-1,r)),this.uiState.activeListIndex=r}toggleModal(t){this.uiState.modalActive[t]=!this.uiState.modalActive[t]}openGallery(){this.uiState.galleryActive=!0}closeGallery(){this.uiState.galleryActive=!1}openActiveListItem(){const t=this.uiState.listItems[this.uiState.activeListIndex];t&&(g.log("Opening",t),t instanceof p?this.clickExhibitor(t):t instanceof T?this.clickCategory(t):t instanceof c&&this.clickBoothInList2(t))}toggleCategoryFilter(){this.uiState.categoryFilterOpen=!this.uiState.categoryFilterOpen}applyCategoryFilters(t){this.uiState.selectedCategoryFilters=t,this.uiState.categoryFilterOpen=!1}get filteredExhibitors(){return this.uiState.selectedCategoryFilters.length===0?this.exhibitorStore.exhibitors:this.exhibitorStore.exhibitors.filter(t=>this.uiState.selectedCategoryFilters.some(r=>t.categories.some(o=>o.id===r.id)))}selectSessions(){this.uiState.list={type:"sessions",text:"",focused:!1},this.uiState.menu=!1,this.uiState.selectedTrack=null,this.searchButtonsStore.setSubButtonId(null),this.searchButtonsStore.subButtonsEnabled&&this.searchButtonsStore.showSubButtons("sessions"),h&&(this.uiState.desiredOverlaySize="full")}selectExhibitors(){this.uiState.list={type:"exhibitors",text:"",focused:!1},this.uiState.menu=!1,h&&(this.uiState.desiredOverlaySize="full")}selectTours(){this.uiState.list={type:"tours",text:"",focused:!1},this.uiState.menu=!1,h&&(this.uiState.desiredOverlaySize="full")}selectSpeakers(){this.uiState.list={type:"speakers",text:"",focused:!1},this.uiState.menu=!1,h&&(this.uiState.desiredOverlaySize="full")}selectSpeaker(t,r=!0){this.speakerStore.selectSpeaker(t,r)}resetFilters(){this.searchButtonsStore.clearAllFilters()}registerShortcutProviders(){this.shortcutRegistry.register(new N(this)),this.shortcutRegistry.register(new U(this)),this.shortcutRegistry.register(new q(this))}}i([u],e.prototype,"initialized",void 0),i([u],e.prototype,"resetCameraFn",void 0),i([s],e.prototype,"setResetCameraFn",null),i([s],e.prototype,"selectExhibitor",null),i([s],e.prototype,"selectBooth",null),i([s],e.prototype,"reset",null),i([s],e.prototype,"selectNone",null),i([s],e.prototype,"selectBookmarks",null),i([s],e.prototype,"selectVisited",null),i([s],e.prototype,"selectLanguage",null),i([s],e.prototype,"selectCategory",null),i([s],e.prototype,"selectEventItem",null),i([s],e.prototype,"selectSearch",null),i([s],e.prototype,"clickBookmarks",null),i([s],e.prototype,"clickVisited",null),i([s],e.prototype,"clickLanguage",null),i([s],e.prototype,"clickCategory",null),i([s],e.prototype,"clickSeminars",null),i([s],e.prototype,"clickBoothInList",null),i([s],e.prototype,"clickBoothInList2",null),i([s],e.prototype,"clickBooth",null),i([s],e.prototype,"clickExhibitor2",null),i([s],e.prototype,"clickExhibitor",null),i([s],e.prototype,"showMap",null),i([s],e.prototype,"showOverlay",null),i([s],e.prototype,"toggleMapOverlay",null),i([s],e.prototype,"moveToList",null),i([s],e.prototype,"moveToExhibitor",null),i([s],e.prototype,"changeActiveListIndex",null),i([s],e.prototype,"toggleModal",null),i([s],e.prototype,"openGallery",null),i([s],e.prototype,"closeGallery",null),i([s],e.prototype,"openActiveListItem",null),i([s],e.prototype,"toggleCategoryFilter",null),i([s],e.prototype,"applyCategoryFilters",null),i([m],e.prototype,"filteredExhibitors",null),i([s],e.prototype,"selectSessions",null),i([s],e.prototype,"selectExhibitors",null),i([s],e.prototype,"selectTours",null),i([s],e.prototype,"selectSpeakers",null),i([s],e.prototype,"selectSpeaker",null),i([s],e.prototype,"resetFilters",null);