UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

252 lines (251 loc) • 10.1 kB
(function() { try { var e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {}; e.SENTRY_RELEASE = { id: "3.47.0" }; var t = new e.Error().stack; t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "4ebc218d-86d5-4750-a72d-2d4a5f930a96", e._sentryDebugIdIdentifier = "sentry-dbid-4ebc218d-86d5-4750-a72d-2d4a5f930a96"); } catch {} })(); import { E as e, Ot as t, l as n, s as r } from "./i18n-DlquqKCP.js"; import { a as i, c as a, f as o, h as s, n as c } from "./mobx.module-BTnTbXnp.js"; import { a as l, i as u, n as d, r as f } from "./kioskApi-CG3QGuUx.js"; import { l as p } from "./store-DTvNQcN7.js"; import { Bt as m, Xt as h } from "./LayerStore-DCg-juRT.js"; import { r as g } from "./viewport-DBuFXrrj.js"; import { i as _ } from "./kiosk-mode-zD8K_fUT.js"; import { n as v, t as y } from "./kiosk-record-Ckxa0L0B.js"; //#region src/components/Kiosk/KioskStore.ts var b, x, S, C, w; function T(e, t, n, r) { n && Object.defineProperty(e, t, { enumerable: n.enumerable, configurable: n.configurable, writable: n.writable, value: n.initializer ? n.initializer.call(r) : void 0 }); } function E(e, t, n, r, i) { var a = {}; return Object.keys(r).forEach(function(e) { a[e] = r[e]; }), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = !0), a = n.slice().reverse().reduce(function(n, r) { return r(e, t, n) || n; }, a), i && a.initializer !== void 0 && (a.value = a.initializer ? a.initializer.call(i) : void 0, a.initializer = void 0), a.initializer === void 0 ? (Object.defineProperty(e, t, a), null) : a; } var D = 2e4, O = new (b = i({ keepAlive: !0 }), x = i({ keepAlive: !0 }), S = class { constructor() { T(this, "savedKiosk", C, this), T(this, "statusMessages", w, this), this.statusMessageTimer = 0, this.isResettingCamera = !1, this.isRestoringFraming = !1, this.initialPtScale = void 0; } get kiosk() { return p.uiState.kioskData; } setKiosk(e) { p.uiState.setKioskData(e); } getCameraState() { var e; if (p.maplibreStore.showMaplibre) { var t; let e = (t = p.maplibreStore.cameraPort) == null ? void 0 : t.getCameraState(); return e ? { mapCenterLng: e.lng, mapCenterLat: e.lat, mapZoom: e.zoom, mapBearingDegrees: e.bearing, mapPitchDegrees: e.pitch } : {}; } let n = (e = h()) == null ? void 0 : e.state(); return n ? { mapInitialPtScale: this.initialPtScale, mapPtScale: n.pixelSize, mapCenterX: n.center.x, mapCenterY: n.center.y, mapRollDegrees: n.roll, mapPitch: n.pitch } : {}; } get hasUnsavedChanges() { let e = this.savedKiosk, t = o(this.kiosk); if (!t || !e) return !!t != !!e; let n = Object.keys(e), r = Object.keys(t); if (n.length !== r.length) return !0; for (let r of n) if (!(r in t) || e[r] !== t[r]) return !0; return !1; } addStatusMessage(e) { this.statusMessages = [{ ...e, id: Date.now() }], this.startCleanupMessages(); } clearStatusMessages() { this.statusMessages = []; } startCleanupMessages() { clearTimeout(this.statusMessageTimer), this.statusMessageTimer = window.setTimeout(() => this.clearStatusMessages(), 1e3); } async resetCamera() { if (!this.isResettingCamera) { this.isResettingCamera = !0; try { if (p.maplibreStore.showMaplibre && await this.resetMaplibreCamera()) { this.isRestoringFraming = !0; return; } this.isRestoringFraming = await this.resetPlanCamera(); } finally { this.isResettingCamera = !1; } } } async resetMaplibreCamera() { let e = await this.waitForMaplibreCameraPort(); if (!e) return !1; let t = this.kiosk; (t == null ? void 0 : t.z) != null && p.fp.activateFloor({ name: String(t.z) }); let n = v(t == null ? void 0 : t.mapCenterLng), r = v(t == null ? void 0 : t.mapCenterLat), i = v(t == null ? void 0 : t.mapZoom); return n === void 0 || r === void 0 || i === void 0 ? (e.resetPitch(), p.uiState.fitBounds(), !0) : (e.applyCameraState({ lng: n, lat: r, zoom: i, bearing: v(t == null ? void 0 : t.mapBearingDegrees), pitch: v(t == null ? void 0 : t.mapPitchDegrees) }), !0); } async waitForMaplibreCameraPort() { let { maplibreStore: e } = p; if (e.cameraPort) return e.cameraPort; try { await s(() => !!e.cameraPort || !e.showMaplibre, { timeout: D }); } catch { return null; } return e.cameraPort; } async resetPlanCamera() { let e = h(); if (!e) return !1; let t = this.kiosk; await e.api.reset({ pan: !0, zoom: !0, roll: !0, pitch: !0 }, { immediate: !0 }), (t == null ? void 0 : t.z) != null && p.fp.activateFloor({ name: String(t.z) }); let n = y(t); n !== void 0 && await e.api.zoomBy(n, { immediate: !0 }); let r = v(t == null ? void 0 : t.mapCenterX), i = v(t == null ? void 0 : t.mapCenterY); r !== void 0 && i !== void 0 && await e.api.panTo({ x: r, y: i }, { immediate: !0 }); let a = v(t == null ? void 0 : t.mapRollDegrees); a !== void 0 && await e.api.rollTo(a, { immediate: !0 }); let o = v(t == null ? void 0 : t.mapPitch); return o !== void 0 && await e.api.pitchTo(o, { immediate: !0 }), !0; } restoreData() { let e = f(); this.savedKiosk = e == null ? null : e, e && (this.setKiosk(e), p.uiState.kiosk = !0); } handleSetupReady() { this.restoreData(), p.uiState.kiosk = !0, p.uiState.hideFreeOrDemo = !0, p.uiState.setForceDim(!0), p.searchStore.setSearchText(""), p.searchStore.setFocused(!1), this.resetCamera(); } handleClose() { _(t()) || (p.uiState.kiosk = !1), p.uiState.restoreUIScale(), this.setKiosk(null), p.uiState.setForceDim(!1), p.uiState.enableSetKioskMode(!1), p.searchStore.closeSearch(); } handleDelete() { n && localStorage.getItem("expofp-kiosk") !== null && localStorage.getItem("kiosk") === "1" && localStorage.removeItem(e), u(), this.savedKiosk = null, this.setKiosk(null), p.uiState.resetMapSettings(), p.uiState.resetUIScale(), this.addStatusMessage({ variant: "success", title: r("Deleted") }); } handleSave() { let t = g(); if (!t) return; let i = o(this.kiosk); if (!i) return; let a = this.getCameraState(), s = { ...i, ...a }; if (!t.isVisible({ x: s.x, y: s.y })) { this.addStatusMessage({ variant: "error", title: r("Kiosk not visible") }); return; } this.setKiosk(s), l(s), n && localStorage.setItem(e, "1"), d(s, "https://app.expofp.com/"), p.uiState.setKioskUIScale(s.uiScale, !0), this.addStatusMessage({ variant: "success", title: r("Saved") }), this.savedKiosk = s; } delayChange(e) { requestAnimationFrame(() => e == null ? void 0 : e()); } handleChange(e) { let t = o(this.kiosk); t && (Number.isFinite(e.angle) && this.setKiosk({ ...t, heading: e.angle }), Number.isFinite(e.scale) && (this.setKiosk({ ...t, uiScale: e.scale }), this.delayChange(() => p.uiState.setKioskUIScale(e.scale, !1))), Number.isFinite(e.percent) && this.setKiosk({ ...t, iconSizePercent: e.percent })); } setInitialPtScale(e) { this.initialPtScale || (this.initialPtScale = e); } handleClick(e) { var t, n; let r = o(this.kiosk), i = p.fp.getFloors(), a = m() ? (t = (n = i.find((e) => e.active)) == null ? void 0 : n.name) == null ? null : t : null, s = p.uiState.uiScale; this.setKiosk({ ...r, x: e.x, y: e.y, z: a, uiScale: (r == null ? void 0 : r.uiScale) || s, heading: (r == null ? void 0 : r.heading) || 0, iconSizePercent: (r == null ? void 0 : r.iconSizePercent) || 100, ...this.getCameraState() }); } handleNavigationChange() { let e = this.isRestoringFraming; this.isRestoringFraming = !1; let t = o(this.kiosk); if (!t) return; let n = this.getCameraState(); this.setKiosk({ ...t, ...n }), e && this.savedKiosk && (this.savedKiosk = { ...this.savedKiosk, ...n }); } }, E(S.prototype, "kiosk", [b], Object.getOwnPropertyDescriptor(S.prototype, "kiosk"), S.prototype), E(S.prototype, "setKiosk", [c], Object.getOwnPropertyDescriptor(S.prototype, "setKiosk"), S.prototype), C = E(S.prototype, "savedKiosk", [a], { configurable: !0, enumerable: !0, writable: !0, initializer: function() { return null; } }), E(S.prototype, "hasUnsavedChanges", [x], Object.getOwnPropertyDescriptor(S.prototype, "hasUnsavedChanges"), S.prototype), w = E(S.prototype, "statusMessages", [a], { configurable: !0, enumerable: !0, writable: !0, initializer: function() { return []; } }), E(S.prototype, "addStatusMessage", [c], Object.getOwnPropertyDescriptor(S.prototype, "addStatusMessage"), S.prototype), E(S.prototype, "clearStatusMessages", [c], Object.getOwnPropertyDescriptor(S.prototype, "clearStatusMessages"), S.prototype), E(S.prototype, "startCleanupMessages", [c], Object.getOwnPropertyDescriptor(S.prototype, "startCleanupMessages"), S.prototype), E(S.prototype, "resetCamera", [c], Object.getOwnPropertyDescriptor(S.prototype, "resetCamera"), S.prototype), E(S.prototype, "restoreData", [c], Object.getOwnPropertyDescriptor(S.prototype, "restoreData"), S.prototype), E(S.prototype, "handleSetupReady", [c], Object.getOwnPropertyDescriptor(S.prototype, "handleSetupReady"), S.prototype), E(S.prototype, "handleClose", [c], Object.getOwnPropertyDescriptor(S.prototype, "handleClose"), S.prototype), E(S.prototype, "handleDelete", [c], Object.getOwnPropertyDescriptor(S.prototype, "handleDelete"), S.prototype), E(S.prototype, "handleSave", [c], Object.getOwnPropertyDescriptor(S.prototype, "handleSave"), S.prototype), E(S.prototype, "handleChange", [c], Object.getOwnPropertyDescriptor(S.prototype, "handleChange"), S.prototype), E(S.prototype, "setInitialPtScale", [c], Object.getOwnPropertyDescriptor(S.prototype, "setInitialPtScale"), S.prototype), E(S.prototype, "handleClick", [c], Object.getOwnPropertyDescriptor(S.prototype, "handleClick"), S.prototype), E(S.prototype, "handleNavigationChange", [c], Object.getOwnPropertyDescriptor(S.prototype, "handleNavigationChange"), S.prototype), S)(); //#endregion export { O as t };