@expofp/floorplan
Version:
Interactive floor plan library for expos and events
254 lines (253 loc) • 10 kB
JavaScript
(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.39.1" };
var t = new e.Error().stack;
t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "c3c5c8c0-8850-4a26-852c-67f76eb59319", e._sentryDebugIdIdentifier = "sentry-dbid-c3c5c8c0-8850-4a26-852c-67f76eb59319");
} catch {}
})();
import { Bt as e, H as t, _ as n, d as r, l as i, m as a, s as o, w as s, x as c } from "./i18n-BVE2kS7w.js";
import { c as l, et as u, ft as d, gn as f, gt as p, ht as m, mt as h, pt as g, z as _ } from "./store-CARxK2Ft.js";
import { r as v } from "./viewport-CN0fRYhD.js";
import { n as y, t as b } from "./kiosk-record-Bcyr4YeZ.js";
//#region src/components/Kiosk/KioskStore.ts
var x, S, C, w, T;
function E(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 D(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 O = 2e4, k = new (x = a({ keepAlive: !0 }), S = a({ keepAlive: !0 }), C = class {
constructor() {
E(this, "savedKiosk", w, this), E(this, "statusMessages", T, this), this.statusMessageTimer = 0, this.isResettingCamera = !1, this.isRestoringFraming = !1, this.initialPtScale = void 0;
}
get kiosk() {
return l.uiState.kioskData;
}
setKiosk(e) {
l.uiState.setKioskData(e);
}
getCameraState() {
var e;
if (l.maplibreStore.showMaplibre) {
var t;
let e = (t = l.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 = _()) == 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 = c(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 (l.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 && l.fp.activateFloor({ name: String(t.z) });
let n = y(t == null ? void 0 : t.mapCenterLng), r = y(t == null ? void 0 : t.mapCenterLat), i = y(t == null ? void 0 : t.mapZoom);
return n === void 0 || r === void 0 || i === void 0 ? (e.resetPitch(), l.uiState.fitBounds(), !0) : (e.applyCameraState({
lng: n,
lat: r,
zoom: i,
bearing: y(t == null ? void 0 : t.mapBearingDegrees),
pitch: y(t == null ? void 0 : t.mapPitchDegrees)
}), !0);
}
async waitForMaplibreCameraPort() {
let { maplibreStore: e } = l;
if (e.cameraPort) return e.cameraPort;
try {
await s(() => !!e.cameraPort || !e.showMaplibre, { timeout: O });
} catch {
return null;
}
return e.cameraPort;
}
async resetPlanCamera() {
let e = _();
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 && l.fp.activateFloor({ name: String(t.z) });
let n = b(t);
n !== void 0 && await e.api.zoomBy(n, { immediate: !0 });
let r = y(t == null ? void 0 : t.mapCenterX), i = y(t == null ? void 0 : t.mapCenterY);
r !== void 0 && i !== void 0 && await e.api.panTo({
x: r,
y: i
}, { immediate: !0 });
let a = y(t == null ? void 0 : t.mapRollDegrees);
a !== void 0 && await e.api.rollTo(a, { immediate: !0 });
let o = y(t == null ? void 0 : t.mapPitch);
return o !== void 0 && await e.api.pitchTo(o, { immediate: !0 }), !0;
}
restoreData() {
let e = h();
this.savedKiosk = e == null ? null : e, e && (this.setKiosk(e), l.uiState.kiosk = !0);
}
handleSetupReady() {
this.restoreData(), l.uiState.kiosk = !0, l.uiState.hideFreeOrDemo = !0, l.uiState.setForceDim(!0), l.searchStore.setSearchText(""), l.searchStore.setFocused(!1), this.resetCamera();
}
handleClose() {
d(l.uiState) && g(e()) || (l.uiState.kiosk = !1), l.uiState.restoreUIScale(), this.setKiosk(null), l.uiState.setForceDim(!1), l.uiState.enableSetKioskMode(!1), l.searchStore.closeSearch();
}
handleDelete() {
i && localStorage.getItem("expofp-kiosk") !== null && localStorage.getItem("kiosk") === "1" && localStorage.removeItem(t), m(), this.savedKiosk = null, this.setKiosk(null), l.uiState.resetMapSettings(), l.uiState.resetUIScale(), this.addStatusMessage({
variant: "success",
title: o("Deleted")
});
}
handleSave() {
let e = v();
if (!e) return;
let n = c(this.kiosk);
if (!n) return;
let r = this.getCameraState(), a = {
...n,
...r
};
if (!e.isVisible({
x: a.x,
y: a.y
})) {
this.addStatusMessage({
variant: "error",
title: o("Kiosk not visible")
});
return;
}
this.setKiosk(a), p(a), i && localStorage.setItem(t, "1"), u(a, "https://app.expofp.com/"), l.uiState.setUIScale(a.uiScale, !0), this.addStatusMessage({
variant: "success",
title: o("Saved")
}), this.savedKiosk = a;
}
delayChange(e) {
requestAnimationFrame(() => e == null ? void 0 : e());
}
handleChange(e) {
let t = c(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(() => l.uiState.setUIScale(e.scale, !1))), Number.isFinite(e.percent) && this.setKiosk({
...t,
iconSizePercent: e.percent
}));
}
setInitialPtScale(e) {
if (this.initialPtScale) return;
this.initialPtScale = e;
let t = c(this.kiosk);
t && this.setKiosk({
...t,
mapInitialPtScale: e
});
}
handleClick(e) {
var t, n;
let r = c(this.kiosk), i = l.fp.getFloors(), a = f() ? (t = (n = i.find((e) => e.active)) == null ? void 0 : n.name) == null ? null : t : null, o = l.uiState.uiScale;
this.setKiosk({
...r,
x: e.x,
y: e.y,
z: a,
uiScale: (r == null ? void 0 : r.uiScale) || o,
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 = c(this.kiosk);
if (!t) return;
let n = this.getCameraState();
this.setKiosk({
...t,
...n
}), e && this.savedKiosk && (this.savedKiosk = {
...this.savedKiosk,
...n
});
}
}, D(C.prototype, "kiosk", [x], Object.getOwnPropertyDescriptor(C.prototype, "kiosk"), C.prototype), D(C.prototype, "setKiosk", [r], Object.getOwnPropertyDescriptor(C.prototype, "setKiosk"), C.prototype), w = D(C.prototype, "savedKiosk", [n], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return null;
}
}), D(C.prototype, "hasUnsavedChanges", [S], Object.getOwnPropertyDescriptor(C.prototype, "hasUnsavedChanges"), C.prototype), T = D(C.prototype, "statusMessages", [n], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return [];
}
}), D(C.prototype, "addStatusMessage", [r], Object.getOwnPropertyDescriptor(C.prototype, "addStatusMessage"), C.prototype), D(C.prototype, "clearStatusMessages", [r], Object.getOwnPropertyDescriptor(C.prototype, "clearStatusMessages"), C.prototype), D(C.prototype, "startCleanupMessages", [r], Object.getOwnPropertyDescriptor(C.prototype, "startCleanupMessages"), C.prototype), D(C.prototype, "resetCamera", [r], Object.getOwnPropertyDescriptor(C.prototype, "resetCamera"), C.prototype), D(C.prototype, "restoreData", [r], Object.getOwnPropertyDescriptor(C.prototype, "restoreData"), C.prototype), D(C.prototype, "handleSetupReady", [r], Object.getOwnPropertyDescriptor(C.prototype, "handleSetupReady"), C.prototype), D(C.prototype, "handleClose", [r], Object.getOwnPropertyDescriptor(C.prototype, "handleClose"), C.prototype), D(C.prototype, "handleDelete", [r], Object.getOwnPropertyDescriptor(C.prototype, "handleDelete"), C.prototype), D(C.prototype, "handleSave", [r], Object.getOwnPropertyDescriptor(C.prototype, "handleSave"), C.prototype), D(C.prototype, "handleChange", [r], Object.getOwnPropertyDescriptor(C.prototype, "handleChange"), C.prototype), D(C.prototype, "setInitialPtScale", [r], Object.getOwnPropertyDescriptor(C.prototype, "setInitialPtScale"), C.prototype), D(C.prototype, "handleClick", [r], Object.getOwnPropertyDescriptor(C.prototype, "handleClick"), C.prototype), D(C.prototype, "handleNavigationChange", [r], Object.getOwnPropertyDescriptor(C.prototype, "handleNavigationChange"), C.prototype), C)();
//#endregion
export { k as t };