UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

255 lines (248 loc) • 9.45 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] = "9b2d1f23-6adf-4e78-baef-91d672aacc41", e._sentryDebugIdIdentifier = "sentry-dbid-9b2d1f23-6adf-4e78-baef-91d672aacc41"); } catch {} })(); import { r as e } from "./rolldown-runtime-5rOLGCTp.js"; import { c as t, o as n, s as r, t as i } from "./floorplan.loader-DEaS-fgT.js"; import { At as a, H as o, R as s, V as c, W as l, k as u, l as d, rt as f, st as p, z as m } from "./i18n-DlquqKCP.js"; import { o as h, s as g } from "./efp-debug-init-D3gNE8Zq.js"; import { r as _ } from "./adopt-global-settings-BerG23m2.js"; import "./settings-DgySPhLO.js"; import { a as v, n as y, o as b, r as x } from "./is-debug-IkNSAGo8.js"; import { n as S, t as C } from "./is-own-domain-yrTLx04R.js"; import { n as w, t as T } from "./event-head-C5Pqy8aE.js"; //#region src/tools/report-error.ts var E; function D(e) { E || e.filename.indexOf("expofp.com") === -1 || [ /loading chunk \d{1,2}\b/i, /zaloJS/i, /e.target.name/i, /ResizeObserver loop/i, /ChunkLoadError/i, /FloorPlan not ready/i ].some((t) => t.test(e.message)) || (E = window.setTimeout(async function() { var t; let n = navigator.languages && navigator.languages.length ? navigator.languages[0] : navigator.language, r = { host: document.location.host, message: e.message, filename: e.filename, lineno: e.lineno, colno: e.colno, stack: (t = e.error) == null ? void 0 : t.stack, log: b.messages.join("\n"), userAgent: navigator.userAgent, language: n, group: "FP", url: document.location, subject: "FP JS error: " + document.location.host }; b.info("Sending error report", r), await Promise.all([O(r), k(r)]); }, 2e3)); } async function O(e) { let t = await fetch("https://app.expofp.com/api/report-error", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(e) }); b.log("Reporter response: ", await t.text()); } async function k(e) { let t = A(e), n = await fetch("https://msg.expofp.com/v1/post-message/" + window.location.hostname, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(t) }); b.log("Slack reporter response: ", await n.text()); } function A(e) { let t = JSON.parse(JSON.stringify(e)); delete t.subject, delete t.message, delete t.stack, delete t.log; let n = []; return n.push({ type: "section", text: { type: "mrkdwn", text: `:warning:* ${e.subject}*` } }), n.push({ type: "section", text: { type: "plain_text", text: e.message + " → " + (e.stack || "").split("\n")[0] } }), { channel: "#fp-errors", username: "error-reporter-bot", type: "mrkdwn", text: e.subject, blocks: n }; } //#endregion //#region src/utils/silence-mobx-react-lite-warning.ts if (typeof console < "u" && typeof console.error == "function") { let e = console.error.bind(console); console.error = (...t) => { typeof t[0] == "string" && t[0].includes("Can't perform a React state update on a component that hasn't mounted yet") || e(...t); }; } //#endregion //#region src/_misc_to_move/initHtmlHead.ts var j = /* @__PURE__ */ e(g(), 1); function M() { if (typeof window > "u" || typeof document > "u") return; if (!document.querySelector("meta[name=\"viewport\"]")) { let e = document.createElement("meta"); e.name = "viewport", e.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no", document.head.appendChild(e); } let e = () => !!document.querySelector("link[rel=\"icon\"]"); e() || import("./favicon-DtPw8IL3.js").then(({ default: t }) => { if (e()) return; let n = document.createElement("link"); n.rel = "icon", n.type = "image/png", n.href = t, document.head.appendChild(n); }), C && (!document.title || document.title === "Document") && (document.title = r(window.location.hostname, S)); } //#endregion //#region src/_misc_to_move/logBuildInfo.ts function N() { let e = { version: "3.47.0", commit: "460b51a28", branch: "main", built: "2026-11-03T11:44:33.581Z" }; if (e) { let t = new Date(e.built); console.info("%c⚡️[efp-runtime]%c v%c%s%c commit=%c%s%c branch=%c%s%c built=%c%s%c (%s)", "color:#2382f4;font-weight:600", "color:inherit", "color:#dcdcaa;font-weight:600", e.version, "color:inherit", "color:#9cdcfe", e.commit, "color:inherit", "color:#ce9178", e.branch, "color:inherit", "color:#b5cea8", e.built, "color:inherit", P(t)); } } function P(e) { let t = (/* @__PURE__ */ new Date()).getTime() - e.getTime(), n = Math.floor(t / (1e3 * 60 * 60 * 24)), r = Math.floor(t / (1e3 * 60 * 60) % 24), i = Math.floor(t / (1e3 * 60) % 60), a = []; return n > 0 && a.push(`${n} day${n === 1 ? "" : "s"}`), r > 0 && a.push(`${r} hour${r === 1 ? "" : "s"}`), i > 0 && a.push(`${i} minute${i === 1 ? "" : "s"}`), a.length === 0 ? "just now" : a.join(" ") + " ago"; } //#endregion //#region src/utils/legacy-storage-keys.ts function F(e = d ? localStorage : void 0) { if (!e) return; e.getItem("___viewer_mode") === "1" && e.getItem("efp-viewerMode") === null && e.setItem(o, "true"), e.getItem("___preview_mode") === "1" && e.getItem("efp-previewMode") === null && e.setItem(s, "true"); let t = e.getItem(u); t !== null && e.getItem("efp-uiScale") === null && e.setItem(c, t); } //#endregion //#region src/load.ts var I = (0, j.default)("efp:load"); async function L(e, t = {}) { y(); try { return await R(e, t); } catch (e) { try { x(); } catch (e) { I("teardown after a failed load:", e); } throw e; } } async function R(e, r = {}) { var o, s; window.addEventListener("error", D), v(() => window.removeEventListener("error", D)), M(), N(), (0, j.default)("efp:device").enabled && import("./logDeviceInfo-DhvfxT2K.js").then((e) => e.logDeviceInfo()).catch(() => {}); let c = r.element, u; if (typeof c == "string") { let e = document.querySelector(c); if (!e) throw Error(`Element not found for selector: ${c}`); u = e; } else c ? u = c : (u = document.getElementById("floorplan"), u || (u = document.createElement("div"), B(u), document.body.appendChild(u))); z(), u.setAttribute("data-efp-floorplan-defaults", ""), (o = document.documentElement.style).overscrollBehavior || (o.overscrollBehavior = "none"), (s = document.body.style).overscrollBehavior || (s.overscrollBehavior = "none"), requestAnimationFrame(() => { u.style.backgroundColor = "#ebebeb"; }), F(); let d; try { var f; if (d = await l(e, r, window.location.search, (f = h()) == null ? void 0 : f), !d.fpSvgJsRef) throw Error("No floor plan drawing: the manifest must set `legacyDataUrlBase` (live event) or `fpSvgJsRef` (offline copy)"); } catch (e) { let { showEventNotFound: t } = await import("./event-not-found-y-baKtlx.js"); throw t(u), e; } if (I("config", d), a(d), C) { let e = n(d, S); e && (document.title = e), T(document, w(d), `${window.location.origin}/`); } let p = new i(r, u), m = window.___fpResolve; return window.___fp = p, m && (p.ready.then(() => m(p)).catch((e) => I("placeholder resolve skipped:", e)), delete window.___fpResolve), p.ready.then(() => { let e = new CustomEvent("expofp:ready", { detail: { floorplan: p } }); window.__expofpReady = e, window.dispatchEvent(e); }).catch((e) => I("ready event skipped:", e)), p.ready.then(() => t(p, d.intents)).catch((e) => I("config intents skipped:", e)), p; } function z() { let e = "efp-floorplan-defaults"; if (document.getElementById(e)) return; let t = document.createElement("style"); t.id = e, t.textContent = "\n[data-efp-floorplan-defaults] {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n overflow: hidden;\n touch-action: none;\n overscroll-behavior: none;\n background: #fff;\n transition: background-color 2s ease;\n}", document.head.prepend(t); } function B(e) { if (!document.adoptedStyleSheets) return; let t = m, n = ` .${t} { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: 0; z-index: 5; display: flex; align-items: center; justify-content: center; pointer-events: none; transition: all 1s ease; } .${t} > svg { width: 60px; transform-origin: center; animation: ${t}-rotate 2s linear infinite; } .${t} > svg > circle { fill: none; stroke: var(--color-primary, #2382f4); stroke-dasharray: 1, 200; stroke-dashoffset: 0; stroke-linecap: round; stroke-width: 2; animation: ${t}-dash 1.5s ease-in-out infinite; } @keyframes ${t}-rotate { 100% { transform: rotate(360deg); } } @keyframes ${t}-dash { 0% { stroke-dasharray: 1, 200; stroke-dashoffset: 0; } 50% { stroke-dasharray: 90, 200; stroke-dashoffset: -35px; } 100% { stroke-dashoffset: -125px; } }`, r = new CSSStyleSheet(); r.replaceSync(n), document.adoptedStyleSheets = [...document.adoptedStyleSheets, r], e.innerHTML = `<div class="${t}"> <svg viewBox="25 25 50 50"> <circle r="20" cy="50" cx="50"></circle> </svg> </div>`, requestAnimationFrame(() => { let n = e.querySelector(`.${t}`); n == null || n.style.setProperty("opacity", "1"); }); } window.addEventListener("error", D), window.__efpStyleElements = [], _(p(f)); //#endregion export { L as load };