@burdenoff/microfe-eventfullymanaged 2026.1030.2 → 2026.1101.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/eventfullymanaged/api/eventApi.d.ts.map +1 -1
  2. package/dist/eventfullymanaged/api/eventApi.js +2 -0
  3. package/dist/eventfullymanaged/api/eventApi.js.map +1 -1
  4. package/dist/eventfullymanaged/components/FloorPlanZoneEditor.d.ts +24 -0
  5. package/dist/eventfullymanaged/components/FloorPlanZoneEditor.d.ts.map +1 -0
  6. package/dist/eventfullymanaged/components/FloorPlanZoneEditor.js +65 -0
  7. package/dist/eventfullymanaged/components/FloorPlanZoneEditor.js.map +1 -0
  8. package/dist/eventfullymanaged/components/floorPlanEditor/ZoneCanvas.d.ts +24 -0
  9. package/dist/eventfullymanaged/components/floorPlanEditor/ZoneCanvas.d.ts.map +1 -0
  10. package/dist/eventfullymanaged/components/floorPlanEditor/ZoneCanvas.js +169 -0
  11. package/dist/eventfullymanaged/components/floorPlanEditor/ZoneCanvas.js.map +1 -0
  12. package/dist/eventfullymanaged/components/floorPlanEditor/ZonePanels.d.ts +33 -0
  13. package/dist/eventfullymanaged/components/floorPlanEditor/ZonePanels.d.ts.map +1 -0
  14. package/dist/eventfullymanaged/components/floorPlanEditor/ZonePanels.js +248 -0
  15. package/dist/eventfullymanaged/components/floorPlanEditor/ZonePanels.js.map +1 -0
  16. package/dist/eventfullymanaged/components/floorPlanEditor/useZoneEditorState.d.ts +33 -0
  17. package/dist/eventfullymanaged/components/floorPlanEditor/useZoneEditorState.d.ts.map +1 -0
  18. package/dist/eventfullymanaged/components/floorPlanEditor/useZoneEditorState.js +78 -0
  19. package/dist/eventfullymanaged/components/floorPlanEditor/useZoneEditorState.js.map +1 -0
  20. package/dist/eventfullymanaged/lib/floorPlanZones.d.ts +148 -0
  21. package/dist/eventfullymanaged/lib/floorPlanZones.d.ts.map +1 -0
  22. package/dist/eventfullymanaged/lib/floorPlanZones.js +239 -0
  23. package/dist/eventfullymanaged/lib/floorPlanZones.js.map +1 -0
  24. package/dist/eventfullymanaged/pages/venues/FloorPlansPage.d.ts.map +1 -1
  25. package/dist/eventfullymanaged/pages/venues/FloorPlansPage.js +367 -291
  26. package/dist/eventfullymanaged/pages/venues/FloorPlansPage.js.map +1 -1
  27. package/dist/eventfullymanaged/types/index.d.ts.map +1 -1
  28. package/dist/utils/pageContext.js +1 -1
  29. package/package.json +1 -1
@@ -0,0 +1,78 @@
1
+ import { DEFAULT_ZONE_TYPE as e, defaultPlacedRect as t, moveRect as n, newZoneId as r, nextZoneLabel as i, parseCapacity as a, summarizeZones as o, validateZones as s, zonesEqual as c } from "../../lib/floorPlanZones.js";
2
+ import { useCallback as l, useMemo as u, useState as d } from "react";
3
+ //#region src/eventfullymanaged/components/floorPlanEditor/useZoneEditorState.ts
4
+ var f = 3;
5
+ function p(p = []) {
6
+ let [m, h] = d(p), [g, _] = d(p), [v, y] = d(null), [b, x] = d(p.length === 0 ? "draw" : "select"), [S, C] = d({}), [w, T] = d([]), E = u(() => new Map(g.map((e) => [e.id, e])), [g]), D = v ? E.get(v) ?? null : null, O = u(() => o(g), [g]), k = u(() => g.filter((e) => !e.rect).length, [g]), A = u(() => new Set(Object.entries(S).filter(([e, t]) => E.has(e) && !a(t).ok).map(([e]) => e)), [S, E]), j = u(() => A.size > 0 || !c(g, m), [
7
+ g,
8
+ m,
9
+ A
10
+ ]), M = l((e, t) => {
11
+ _((n) => n.map((n) => n.id === e ? {
12
+ ...n,
13
+ ...t
14
+ } : n)), T([]);
15
+ }, []), N = l((e) => {
16
+ _((t) => t.filter((t) => t.id !== e)), C((t) => {
17
+ let n = { ...t };
18
+ return delete n[e], n;
19
+ }), y((t) => t === e ? null : t), T([]);
20
+ }, []), P = l((a) => {
21
+ let o = r();
22
+ _((r) => {
23
+ let s = r.length % 5 * f;
24
+ return [...r, {
25
+ id: o,
26
+ label: i(r, e),
27
+ type: e,
28
+ rect: a ?? n(t(), s, s)
29
+ }];
30
+ }), y(o), x("select"), T([]);
31
+ }, []);
32
+ return {
33
+ zones: g,
34
+ selected: D,
35
+ selectedId: v,
36
+ mode: b,
37
+ summary: O,
38
+ unplacedCount: k,
39
+ errors: w,
40
+ dirty: j,
41
+ invalidCapacityIds: A,
42
+ setMode: l((e) => {
43
+ x(e), e === "draw" && y(null);
44
+ }, []),
45
+ select: y,
46
+ updateZone: M,
47
+ removeZone: N,
48
+ addZone: P,
49
+ capacityValue: l((e) => S[e.id] ?? (e.capacity === void 0 ? "" : String(e.capacity)), [S]),
50
+ setCapacityText: l((e, t) => {
51
+ C((n) => ({
52
+ ...n,
53
+ [e]: t
54
+ }));
55
+ let n = a(t);
56
+ n.ok && M(e, { capacity: n.value });
57
+ }, [M]),
58
+ validateForSave: l(() => {
59
+ let e = s(g).map((e) => e.message);
60
+ for (let t of A) {
61
+ let n = E.get(t)?.label ?? "A zone";
62
+ e.push(`"${n}" needs a whole-number capacity (or leave it empty).`);
63
+ }
64
+ return T(e), e;
65
+ }, [
66
+ g,
67
+ E,
68
+ A
69
+ ]),
70
+ reset: l((e) => {
71
+ h(e), _(e), y(null), x(e.length === 0 ? "draw" : "select"), C({}), T([]);
72
+ }, [])
73
+ };
74
+ }
75
+ //#endregion
76
+ export { p as useZoneEditorState };
77
+
78
+ //# sourceMappingURL=useZoneEditorState.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useZoneEditorState.js","names":[],"sources":["../../../../src/eventfullymanaged/components/floorPlanEditor/useZoneEditorState.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react';\n\nimport {\n DEFAULT_ZONE_TYPE,\n defaultPlacedRect,\n moveRect,\n newZoneId,\n nextZoneLabel,\n parseCapacity,\n summarizeZones,\n validateZones,\n zonesEqual,\n} from '../../lib/floorPlanZones';\nimport type { Zone, ZoneRect, ZoneSummary } from '../../lib/floorPlanZones';\n\nexport type EditorMode = 'select' | 'draw';\n\n/** Offset (percent) between successive keyboard-added zones so they don't stack exactly. */\nconst ADD_ZONE_CASCADE = 3;\n\nexport type ZoneEditorState = {\n zones: Zone[];\n selected: Zone | null;\n selectedId: string | null;\n mode: EditorMode;\n summary: ZoneSummary;\n unplacedCount: number;\n errors: string[];\n dirty: boolean;\n invalidCapacityIds: ReadonlySet<string>;\n setMode: (mode: EditorMode) => void;\n select: (zoneId: string | null) => void;\n updateZone: (zoneId: string, patch: Partial<Zone>) => void;\n removeZone: (zoneId: string) => void;\n /** Add a zone at `rect` (or a default centred rectangle) and select it. */\n addZone: (rect?: ZoneRect) => void;\n capacityValue: (zone: Zone) => string;\n setCapacityText: (zoneId: string, text: string) => void;\n /** Validate for saving: returns the messages to show, or an empty list when the zones can be saved. */\n validateForSave: () => string[];\n /** Start a fresh editing session from `zones` (the saved state that `dirty` compares against). */\n reset: (zones: Zone[]) => void;\n};\n\n/**\n * All editor state and its mutations, kept apart from the pointer/canvas wiring.\n * The page owns this hook (so it can read `dirty` to guard navigation without\n * an effect) and starts each editing session with `reset(zonesOfThePlan)`.\n */\nexport function useZoneEditorState(seedZones: Zone[] = []): ZoneEditorState {\n const [initialZones, setInitialZones] = useState<Zone[]>(seedZones);\n const [zones, setZones] = useState<Zone[]>(seedZones);\n const [selectedId, setSelectedId] = useState<string | null>(null);\n const [mode, setModeState] = useState<EditorMode>(seedZones.length === 0 ? 'draw' : 'select');\n const [capacityText, setCapacityTextState] = useState<Record<string, string>>({});\n const [errors, setErrors] = useState<string[]>([]);\n\n const zonesById = useMemo(() => new Map(zones.map((zone) => [zone.id, zone])), [zones]);\n const selected = selectedId ? (zonesById.get(selectedId) ?? null) : null;\n const summary = useMemo(() => summarizeZones(zones), [zones]);\n const unplacedCount = useMemo(() => zones.filter((zone) => !zone.rect).length, [zones]);\n const invalidCapacityIds = useMemo(\n () =>\n new Set(\n Object.entries(capacityText)\n .filter(([zoneId, text]) => zonesById.has(zoneId) && !parseCapacity(text).ok)\n .map(([zoneId]) => zoneId)\n ),\n [capacityText, zonesById]\n );\n const dirty = useMemo(\n () => invalidCapacityIds.size > 0 || !zonesEqual(zones, initialZones),\n [zones, initialZones, invalidCapacityIds]\n );\n\n const updateZone = useCallback((zoneId: string, patch: Partial<Zone>) => {\n setZones((current) => current.map((zone) => (zone.id === zoneId ? { ...zone, ...patch } : zone)));\n setErrors([]);\n }, []);\n\n const removeZone = useCallback((zoneId: string) => {\n setZones((current) => current.filter((zone) => zone.id !== zoneId));\n setCapacityTextState((current) => {\n const next = { ...current };\n delete next[zoneId];\n return next;\n });\n setSelectedId((current) => (current === zoneId ? null : current));\n setErrors([]);\n }, []);\n\n const addZone = useCallback((rect?: ZoneRect) => {\n const id = newZoneId();\n // Label and cascade offset derive from the latest list, not a render-time snapshot.\n setZones((current) => {\n const cascade = (current.length % 5) * ADD_ZONE_CASCADE;\n return [\n ...current,\n {\n id,\n label: nextZoneLabel(current, DEFAULT_ZONE_TYPE),\n type: DEFAULT_ZONE_TYPE,\n rect: rect ?? moveRect(defaultPlacedRect(), cascade, cascade),\n },\n ];\n });\n setSelectedId(id);\n setModeState('select');\n setErrors([]);\n }, []);\n\n const setMode = useCallback((next: EditorMode) => {\n setModeState(next);\n if (next === 'draw') {\n setSelectedId(null);\n }\n }, []);\n\n const capacityValue = useCallback(\n (zone: Zone) => capacityText[zone.id] ?? (zone.capacity !== undefined ? String(zone.capacity) : ''),\n [capacityText]\n );\n\n const setCapacityText = useCallback(\n (zoneId: string, text: string) => {\n setCapacityTextState((current) => ({ ...current, [zoneId]: text }));\n const parsed = parseCapacity(text);\n if (parsed.ok) {\n updateZone(zoneId, { capacity: parsed.value });\n }\n },\n [updateZone]\n );\n\n const validateForSave = useCallback((): string[] => {\n const messages = validateZones(zones).map((error) => error.message);\n for (const zoneId of invalidCapacityIds) {\n const label = zonesById.get(zoneId)?.label ?? 'A zone';\n messages.push(`\"${label}\" needs a whole-number capacity (or leave it empty).`);\n }\n setErrors(messages);\n return messages;\n }, [zones, zonesById, invalidCapacityIds]);\n\n const reset = useCallback((next: Zone[]) => {\n setInitialZones(next);\n setZones(next);\n setSelectedId(null);\n setModeState(next.length === 0 ? 'draw' : 'select');\n setCapacityTextState({});\n setErrors([]);\n }, []);\n\n return {\n zones,\n selected,\n selectedId,\n mode,\n summary,\n unplacedCount,\n errors,\n dirty,\n invalidCapacityIds,\n setMode,\n select: setSelectedId,\n updateZone,\n removeZone,\n addZone,\n capacityValue,\n setCapacityText,\n validateForSave,\n reset,\n };\n}\n"],"mappings":";;;AAkBA,IAAM,IAAmB;AA+BzB,SAAgB,EAAmB,IAAoB,EAAE,EAAmB;CAC1E,IAAM,CAAC,GAAc,KAAmB,EAAiB,EAAU,EAC7D,CAAC,GAAO,KAAY,EAAiB,EAAU,EAC/C,CAAC,GAAY,KAAiB,EAAwB,KAAK,EAC3D,CAAC,GAAM,KAAgB,EAAqB,EAAU,WAAW,IAAI,SAAS,SAAS,EACvF,CAAC,GAAc,KAAwB,EAAiC,EAAE,CAAC,EAC3E,CAAC,GAAQ,KAAa,EAAmB,EAAE,CAAC,EAE5C,IAAY,QAAc,IAAI,IAAI,EAAM,KAAK,MAAS,CAAC,EAAK,IAAI,EAAK,CAAC,CAAC,EAAE,CAAC,EAAM,CAAC,EACjF,IAAW,IAAc,EAAU,IAAI,EAAW,IAAI,OAAQ,MAC9D,IAAU,QAAc,EAAe,EAAM,EAAE,CAAC,EAAM,CAAC,EACvD,IAAgB,QAAc,EAAM,QAAQ,MAAS,CAAC,EAAK,KAAK,CAAC,QAAQ,CAAC,EAAM,CAAC,EACjF,IAAqB,QAEvB,IAAI,IACF,OAAO,QAAQ,EAAa,CACzB,QAAQ,CAAC,GAAQ,OAAU,EAAU,IAAI,EAAO,IAAI,CAAC,EAAc,EAAK,CAAC,GAAG,CAC5E,KAAK,CAAC,OAAY,EAAO,CAC7B,EACH,CAAC,GAAc,EAAU,CAC1B,EACK,IAAQ,QACN,EAAmB,OAAO,KAAK,CAAC,EAAW,GAAO,EAAa,EACrE;EAAC;EA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AAClC,GAAI,EAAO,MACT,EAAW,GAAQ,EAAE,UAAU,EAAO,OAAO,CAAC;KAGlD,CAAC,EAAW,CACb;EAsCC,iBApCsB,QAA4B;GAClD,IAAM,IAAW,EAAc,EAAM,CAAC,KAAK,MAAU,EAAM,QAAQ;AACnE,QAAK,IAAM,KAAU,GAAoB;IACvC,IAAM,IAAQ,EAAU,IAAI,EAAO,EAAE,SAAS;AAC9C,MAAS,KAAK,IAAI,EAAM,sDAAsD;;AAGhF,UADA,EAAU,EAAS,EACZ;KACN;GAAC;GAAO;GAAW;GAAmB,CAAC;EA6BxC,OA3BY,GAAa,MAAiB;AAM1C,GALA,EAAgB,EAAK,EACrB,EAAS,EAAK,EACd,EAAc,KAAK,EACnB,EAAa,EAAK,WAAW,IAAI,SAAS,SAAS,EACnD,EAAqB,EAAE,CAAC,EACxB,EAAU,EAAE,CAAC;KACZ,EAAE,CAAC;EAqBL"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Floor-plan zone model shared by the floor-plan viewer and the interactive
3
+ * zone/booth editor.
4
+ *
5
+ * The backend persists `FloorPlan.interactiveAreas` as free-form JSON, so this
6
+ * module owns the contract on the client side:
7
+ *
8
+ * - **Reading** (`extractZones`) is deliberately lenient. Plans created before
9
+ * the editor existed (or imported from elsewhere) may hold a bare array, a
10
+ * `{ zones | areas | booths: [...] }` wrapper or a keyed object, with
11
+ * coordinates as fractions (0–1) or percentages (0–100). Whatever real shape a
12
+ * plan holds is rendered; nothing is fabricated.
13
+ * - **Writing** (`serializeZones`) always emits the canonical v1 shape:
14
+ *
15
+ * ```json
16
+ * {
17
+ * "version": 1,
18
+ * "unit": "percent",
19
+ * "zones": [
20
+ * { "id": "…", "label": "Booth A1", "type": "booth", "capacity": 12,
21
+ * "x": 10.5, "y": 20, "w": 8, "h": 6 }
22
+ * ]
23
+ * }
24
+ * ```
25
+ *
26
+ * `x`/`y` are the top-left corner and `w`/`h` the size, all as a percentage of
27
+ * the floor-plan image, so zones stay aligned at any rendered size. Unknown
28
+ * top-level keys already stored on the plan are preserved.
29
+ */
30
+ export type JsonObject = Record<string, unknown>;
31
+ export type InteractiveAreasJson = JsonObject | unknown[] | null | undefined;
32
+ /** A rectangle in percent of the floor-plan image (top-left origin). */
33
+ export type ZoneRect = {
34
+ x: number;
35
+ y: number;
36
+ w: number;
37
+ h: number;
38
+ };
39
+ export type Zone = {
40
+ /** Stable identifier — persisted ids are kept, legacy entries get a derived one. */
41
+ id: string;
42
+ label: string;
43
+ type?: string;
44
+ capacity?: number;
45
+ /** Absent when the stored entry carried no usable coordinates ("unplaced"). */
46
+ rect?: ZoneRect;
47
+ };
48
+ export declare const ZONE_TYPES: readonly [{
49
+ readonly value: "booth";
50
+ readonly label: "Booth";
51
+ }, {
52
+ readonly value: "stage";
53
+ readonly label: "Stage";
54
+ }, {
55
+ readonly value: "seating";
56
+ readonly label: "Seating";
57
+ }, {
58
+ readonly value: "entrance";
59
+ readonly label: "Entrance";
60
+ }, {
61
+ readonly value: "exit";
62
+ readonly label: "Exit";
63
+ }, {
64
+ readonly value: "registration";
65
+ readonly label: "Registration desk";
66
+ }, {
67
+ readonly value: "catering";
68
+ readonly label: "Catering";
69
+ }, {
70
+ readonly value: "lounge";
71
+ readonly label: "Lounge";
72
+ }, {
73
+ readonly value: "restroom";
74
+ readonly label: "Restroom";
75
+ }, {
76
+ readonly value: "storage";
77
+ readonly label: "Storage";
78
+ }, {
79
+ readonly value: "other";
80
+ readonly label: "Other";
81
+ }];
82
+ export type ZoneType = (typeof ZONE_TYPES)[number]['value'];
83
+ export declare const DEFAULT_ZONE_TYPE: ZoneType;
84
+ /** Smallest zone (in percent of either axis) the editor will keep. */
85
+ export declare const MIN_ZONE_SIZE = 1;
86
+ /** Size of a zone placed with "Place on map" (percent). */
87
+ export declare const DEFAULT_PLACED_SIZE = 12;
88
+ export declare const MAX_LABEL_LENGTH = 60;
89
+ export declare const MAX_ZONES = 500;
90
+ export declare function zoneTypeLabel(type: string | undefined): string | undefined;
91
+ /** A finite number from a number or numeric string, else undefined. */
92
+ export declare function asNumber(value: unknown): number | undefined;
93
+ /** A trimmed non-empty string, else undefined. */
94
+ export declare function asString(value: unknown): string | undefined;
95
+ export declare function clamp(value: number, min: number, max: number): number;
96
+ /** Parse whatever shape `interactiveAreas` holds into zones. Never throws. */
97
+ export declare function extractZones(interactiveAreas: InteractiveAreasJson): Zone[];
98
+ /**
99
+ * Build the canonical v1 `interactiveAreas` payload. Unknown top-level keys of
100
+ * the previously stored object (e.g. legend or metadata a plan was imported
101
+ * with) are carried over; legacy list keys are replaced by `zones`.
102
+ */
103
+ export declare function serializeZones(zones: Zone[], previous?: InteractiveAreasJson): JsonObject;
104
+ /** Round a rectangle to 0.01% so floating-point drag noise never reaches the UI or the stored JSON. */
105
+ export declare function roundRect(rect: ZoneRect): ZoneRect;
106
+ /** Normalise two drag points (percent) into a rectangle clamped to the image. */
107
+ export declare function rectFromPoints(a: {
108
+ x: number;
109
+ y: number;
110
+ }, b: {
111
+ x: number;
112
+ y: number;
113
+ }): ZoneRect;
114
+ export declare function isUsableRect(rect: ZoneRect): boolean;
115
+ /** Translate a rectangle, keeping it fully inside the image. */
116
+ export declare function moveRect(rect: ZoneRect, dx: number, dy: number): ZoneRect;
117
+ /** Grow/shrink from the bottom-right corner, keeping a minimum size and the image bounds. */
118
+ export declare function resizeRect(rect: ZoneRect, dw: number, dh: number): ZoneRect;
119
+ /** A rectangle of the default size centred on the image, for placing an unplaced zone. */
120
+ export declare function defaultPlacedRect(): ZoneRect;
121
+ /** Next free "<Type> N" label, so freshly drawn zones are distinguishable. */
122
+ export declare function nextZoneLabel(zones: Zone[], type?: string): string;
123
+ export declare function newZoneId(): string;
124
+ /**
125
+ * Parse the capacity input. Empty means "not set"; anything else must be a
126
+ * non-negative whole number.
127
+ */
128
+ export declare function parseCapacity(input: string): {
129
+ ok: true;
130
+ value: number | undefined;
131
+ } | {
132
+ ok: false;
133
+ };
134
+ export type ZoneValidationError = {
135
+ zoneId: string;
136
+ message: string;
137
+ };
138
+ /** Validate zones before persisting. Returns one message per offending zone. */
139
+ export declare function validateZones(zones: Zone[]): ZoneValidationError[];
140
+ export type ZoneSummary = {
141
+ zones: number;
142
+ booths: number;
143
+ capacity: number;
144
+ };
145
+ export declare function summarizeZones(zones: Zone[]): ZoneSummary;
146
+ /** Structural equality used to track unsaved editor changes. */
147
+ export declare function zonesEqual(a: Zone[], b: Zone[]): boolean;
148
+ //# sourceMappingURL=floorPlanZones.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"floorPlanZones.d.ts","sourceRoot":"","sources":["../../../src/eventfullymanaged/lib/floorPlanZones.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACjD,MAAM,MAAM,oBAAoB,GAAG,UAAU,GAAG,OAAO,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAE7E,wEAAwE;AACxE,MAAM,MAAM,QAAQ,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtE,MAAM,MAAM,IAAI,GAAG;IACjB,oFAAoF;IACpF,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYb,CAAC;AAEX,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC;AAE5D,eAAO,MAAM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stage",
9
+ label: "Stage"
10
+ },
11
+ {
12
+ value: "seating",
13
+ label: "Seating"
14
+ },
15
+ {
16
+ value: "entrance",
17
+ label: "Entrance"
18
+ },
19
+ {
20
+ value: "exit",
21
+ label: "Exit"
22
+ },
23
+ {
24
+ value: "registration",
25
+ label: "Registration desk"
26
+ },
27
+ {
28
+ value: "catering",
29
+ label: "Catering"
30
+ },
31
+ {
32
+ value: "lounge",
33
+ label: "Lounge"
34
+ },
35
+ {
36
+ value: "restroom",
37
+ label: "Restroom"
38
+ },
39
+ {
40
+ value: "storage",
41
+ label: "Storage"
42
+ },
43
+ {
44
+ value: "other",
45
+ label: "Other"
46
+ }
47
+ ], t = "booth";
48
+ function n(t) {
49
+ if (!t) return;
50
+ let n = e.find((e) => e.value === t.toLowerCase());
51
+ return n ? n.label : t;
52
+ }
53
+ function r(e) {
54
+ if (typeof e == "number" && Number.isFinite(e)) return e;
55
+ if (typeof e == "string" && e.trim() !== "" && Number.isFinite(Number(e))) return Number(e);
56
+ }
57
+ function i(e) {
58
+ return typeof e == "string" && e.trim() !== "" ? e.trim() : void 0;
59
+ }
60
+ function a(e, t, n) {
61
+ return Math.min(Math.max(e, t), n);
62
+ }
63
+ function o(e) {
64
+ return Math.round(e * 100) / 100;
65
+ }
66
+ function s(e) {
67
+ return typeof e == "object" && !!e && !Array.isArray(e);
68
+ }
69
+ function c(e) {
70
+ if (!s(e)) return e;
71
+ for (let t of [
72
+ "zones",
73
+ "areas",
74
+ "booths"
75
+ ]) if (Array.isArray(e[t])) return e[t];
76
+ return "version" in e || Object.keys(e).length === 0 ? [] : e;
77
+ }
78
+ function l(e) {
79
+ if (!s(e)) return;
80
+ let t = i(e.unit)?.toLowerCase();
81
+ if (t === "percent" || t === "%") return "percent";
82
+ if (t === "fraction" || t === "ratio") return "fraction";
83
+ }
84
+ var u = .05;
85
+ function d(e, t) {
86
+ let n = r(e.x), i = r(e.y), a = r(e.w) ?? r(e.width), o = r(e.h) ?? r(e.height);
87
+ if (n === void 0 || i === void 0 || a === void 0 || o === void 0 || a <= 0 || o <= 0) return;
88
+ let s = t === "fraction" || t === void 0 && n <= 1 && i <= 1 && a <= 1 && o <= 1 ? 100 : 1, c = {
89
+ x: n * s,
90
+ y: i * s,
91
+ w: a * s,
92
+ h: o * s
93
+ };
94
+ if (!(c.x < 0 || c.y < 0 || c.x + c.w > 100 + u || c.y + c.h > 100 + u)) return {
95
+ ...c,
96
+ w: Math.min(c.w, 100 - c.x),
97
+ h: Math.min(c.h, 100 - c.y)
98
+ };
99
+ }
100
+ function f(e) {
101
+ if (!e) return [];
102
+ let t = c(e), n = l(e), a = Array.isArray(t) ? t.map((e, t) => [String(t), e]) : s(t) ? Object.entries(t) : [], o = [], u = /* @__PURE__ */ new Set();
103
+ for (let [e, t] of a) {
104
+ if (!s(t)) continue;
105
+ let a = i(t.label) ?? i(t.name) ?? i(t.title) ?? i(t.id) ?? e, c = i(t.id) ?? `zone-${e}`;
106
+ for (; u.has(c);) c = `${c}-${e}`;
107
+ u.add(c);
108
+ let l = r(t.capacity) ?? r(t.seats);
109
+ o.push({
110
+ id: c,
111
+ label: a,
112
+ type: i(t.type) ?? i(t.kind),
113
+ capacity: l !== void 0 && l >= 0 ? Math.floor(l) : void 0,
114
+ rect: d(t, n)
115
+ });
116
+ }
117
+ return o;
118
+ }
119
+ function p(e, t) {
120
+ let n = {}, r = s(t) ? t : {}, i = s(t) && c(t) === t;
121
+ for (let [e, t] of Object.entries(r)) [
122
+ "zones",
123
+ "areas",
124
+ "booths",
125
+ "version",
126
+ "unit"
127
+ ].includes(e) || i && s(t) || (n[e] = t);
128
+ return {
129
+ ...n,
130
+ version: 1,
131
+ unit: "percent",
132
+ zones: e.map((e) => {
133
+ let t = {
134
+ id: e.id,
135
+ label: e.label.trim()
136
+ };
137
+ return e.type && (t.type = e.type), e.capacity !== void 0 && (t.capacity = e.capacity), e.rect && (t.x = o(e.rect.x), t.y = o(e.rect.y), t.w = o(e.rect.w), t.h = o(e.rect.h)), t;
138
+ })
139
+ };
140
+ }
141
+ function m(e) {
142
+ let t = o(e.x), n = o(e.y);
143
+ return {
144
+ x: t,
145
+ y: n,
146
+ w: Math.min(o(e.w), o(100 - t)),
147
+ h: Math.min(o(e.h), o(100 - n))
148
+ };
149
+ }
150
+ function h(e, t) {
151
+ let n = a(Math.min(e.x, t.x), 0, 100), r = a(Math.min(e.y, t.y), 0, 100), i = a(Math.max(e.x, t.x), 0, 100), o = a(Math.max(e.y, t.y), 0, 100);
152
+ return m({
153
+ x: n,
154
+ y: r,
155
+ w: i - n,
156
+ h: o - r
157
+ });
158
+ }
159
+ function g(e) {
160
+ return e.w >= 1 && e.h >= 1;
161
+ }
162
+ function _(e, t, n) {
163
+ return m({
164
+ ...e,
165
+ x: a(e.x + t, 0, 100 - e.w),
166
+ y: a(e.y + n, 0, 100 - e.h)
167
+ });
168
+ }
169
+ function v(e, t, n) {
170
+ return m({
171
+ ...e,
172
+ w: a(e.w + t, 1, 100 - e.x),
173
+ h: a(e.h + n, 1, 100 - e.y)
174
+ });
175
+ }
176
+ function y() {
177
+ return {
178
+ x: 44,
179
+ y: 44,
180
+ w: 12,
181
+ h: 12
182
+ };
183
+ }
184
+ function b(e, r = t) {
185
+ let i = n(r) ?? "Zone", a = new Set(e.map((e) => e.label.trim().toLowerCase())), o = e.filter((e) => (e.type ?? "") === r).length + 1;
186
+ for (; a.has(`${i} ${o}`.toLowerCase());) o += 1;
187
+ return `${i} ${o}`;
188
+ }
189
+ function x() {
190
+ return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `zone-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
191
+ }
192
+ function S(e) {
193
+ let t = e.trim();
194
+ if (t === "") return {
195
+ ok: !0,
196
+ value: void 0
197
+ };
198
+ if (!/^\d+$/.test(t)) return { ok: !1 };
199
+ let n = Number(t);
200
+ return Number.isSafeInteger(n) ? {
201
+ ok: !0,
202
+ value: n
203
+ } : { ok: !1 };
204
+ }
205
+ function C(e) {
206
+ let t = [];
207
+ e.length > 500 && t.push({
208
+ zoneId: "",
209
+ message: "A floor plan can hold at most 500 zones."
210
+ });
211
+ for (let n of e) {
212
+ let e = n.label.trim();
213
+ e === "" ? t.push({
214
+ zoneId: n.id,
215
+ message: "Every zone needs a label."
216
+ }) : e.length > 60 ? t.push({
217
+ zoneId: n.id,
218
+ message: `"${e.slice(0, 20)}…" is longer than 60 characters.`
219
+ }) : n.capacity !== void 0 && (!Number.isSafeInteger(n.capacity) || n.capacity < 0) && t.push({
220
+ zoneId: n.id,
221
+ message: `"${e}" has an invalid capacity.`
222
+ });
223
+ }
224
+ return t;
225
+ }
226
+ function w(e) {
227
+ return {
228
+ zones: e.length,
229
+ booths: e.filter((e) => (e.type ?? "").toLowerCase().includes("booth")).length,
230
+ capacity: e.reduce((e, t) => e + (t.capacity ?? 0), 0)
231
+ };
232
+ }
233
+ function T(e, t) {
234
+ return JSON.stringify(p(e)) === JSON.stringify(p(t));
235
+ }
236
+ //#endregion
237
+ export { t as DEFAULT_ZONE_TYPE, e as ZONE_TYPES, r as asNumber, i as asString, y as defaultPlacedRect, f as extractZones, g as isUsableRect, _ as moveRect, x as newZoneId, b as nextZoneLabel, S as parseCapacity, h as rectFromPoints, v as resizeRect, p as serializeZones, w as summarizeZones, C as validateZones, n as zoneTypeLabel, T as zonesEqual };
238
+
239
+ //# sourceMappingURL=floorPlanZones.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"floorPlanZones.js","names":[],"sources":["../../../src/eventfullymanaged/lib/floorPlanZones.ts"],"sourcesContent":["/**\n * Floor-plan zone model shared by the floor-plan viewer and the interactive\n * zone/booth editor.\n *\n * The backend persists `FloorPlan.interactiveAreas` as free-form JSON, so this\n * module owns the contract on the client side:\n *\n * - **Reading** (`extractZones`) is deliberately lenient. Plans created before\n * the editor existed (or imported from elsewhere) may hold a bare array, a\n * `{ zones | areas | booths: [...] }` wrapper or a keyed object, with\n * coordinates as fractions (0–1) or percentages (0–100). Whatever real shape a\n * plan holds is rendered; nothing is fabricated.\n * - **Writing** (`serializeZones`) always emits the canonical v1 shape:\n *\n * ```json\n * {\n * \"version\": 1,\n * \"unit\": \"percent\",\n * \"zones\": [\n * { \"id\": \"…\", \"label\": \"Booth A1\", \"type\": \"booth\", \"capacity\": 12,\n * \"x\": 10.5, \"y\": 20, \"w\": 8, \"h\": 6 }\n * ]\n * }\n * ```\n *\n * `x`/`y` are the top-left corner and `w`/`h` the size, all as a percentage of\n * the floor-plan image, so zones stay aligned at any rendered size. Unknown\n * top-level keys already stored on the plan are preserved.\n */\n\nexport type JsonObject = Record<string, unknown>;\nexport type InteractiveAreasJson = JsonObject | unknown[] | null | undefined;\n\n/** A rectangle in percent of the floor-plan image (top-left origin). */\nexport type ZoneRect = { x: number; y: number; w: number; h: number };\n\nexport type Zone = {\n /** Stable identifier — persisted ids are kept, legacy entries get a derived one. */\n id: string;\n label: string;\n type?: string;\n capacity?: number;\n /** Absent when the stored entry carried no usable coordinates (\"unplaced\"). */\n rect?: ZoneRect;\n};\n\nexport const ZONE_TYPES = [\n { value: 'booth', label: 'Booth' },\n { value: 'stage', label: 'Stage' },\n { value: 'seating', label: 'Seating' },\n { value: 'entrance', label: 'Entrance' },\n { value: 'exit', label: 'Exit' },\n { value: 'registration', label: 'Registration desk' },\n { value: 'catering', label: 'Catering' },\n { value: 'lounge', label: 'Lounge' },\n { value: 'restroom', label: 'Restroom' },\n { value: 'storage', label: 'Storage' },\n { value: 'other', label: 'Other' },\n] as const;\n\nexport type ZoneType = (typeof ZONE_TYPES)[number]['value'];\n\nexport const DEFAULT_ZONE_TYPE: ZoneType = 'booth';\n\n/** Smallest zone (in percent of either axis) the editor will keep. */\nexport const MIN_ZONE_SIZE = 1;\n\n/** Size of a zone placed with \"Place on map\" (percent). */\nexport const DEFAULT_PLACED_SIZE = 12;\n\nexport const MAX_LABEL_LENGTH = 60;\n\nexport const MAX_ZONES = 500;\n\nexport function zoneTypeLabel(type: string | undefined): string | undefined {\n if (!type) {\n return undefined;\n }\n const known = ZONE_TYPES.find((entry) => entry.value === type.toLowerCase());\n return known ? known.label : type;\n}\n\n/** A finite number from a number or numeric string, else undefined. */\nexport function asNumber(value: unknown): number | undefined {\n if (typeof value === 'number' && Number.isFinite(value)) {\n return value;\n }\n if (typeof value === 'string' && value.trim() !== '' && Number.isFinite(Number(value))) {\n return Number(value);\n }\n return undefined;\n}\n\n/** A trimmed non-empty string, else undefined. */\nexport function asString(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined;\n}\n\nexport function clamp(value: number, min: number, max: number): number {\n return Math.min(Math.max(value, min), max);\n}\n\nfunction round2(value: number): number {\n return Math.round(value * 100) / 100;\n}\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction unwrapZoneList(interactiveAreas: InteractiveAreasJson): unknown {\n if (!isObject(interactiveAreas)) {\n return interactiveAreas;\n }\n for (const key of ['zones', 'areas', 'booths'] as const) {\n if (Array.isArray(interactiveAreas[key])) {\n return interactiveAreas[key];\n }\n }\n // Canonical v1 with an empty/missing list, or an empty object: no zones.\n if ('version' in interactiveAreas || Object.keys(interactiveAreas).length === 0) {\n return [];\n }\n return interactiveAreas;\n}\n\nfunction declaredUnit(interactiveAreas: InteractiveAreasJson): 'percent' | 'fraction' | undefined {\n if (!isObject(interactiveAreas)) {\n return undefined;\n }\n const unit = asString(interactiveAreas.unit)?.toLowerCase();\n if (unit === 'percent' || unit === '%') {\n return 'percent';\n }\n if (unit === 'fraction' || unit === 'ratio') {\n return 'fraction';\n }\n return undefined;\n}\n\n/**\n * How far past the right/bottom edge a stored zone may reach and still be\n * placed. Values written by other tools may carry rounding overshoot (two\n * independently rounded numbers can exceed 100 by up to 0.01); anything beyond\n * this is treated as out of range.\n */\nconst EDGE_TOLERANCE = 0.05;\n\nfunction readRect(item: JsonObject, unit: 'percent' | 'fraction' | undefined): ZoneRect | undefined {\n const x = asNumber(item.x);\n const y = asNumber(item.y);\n const w = asNumber(item.w) ?? asNumber(item.width);\n const h = asNumber(item.h) ?? asNumber(item.height);\n if (x === undefined || y === undefined || w === undefined || h === undefined || w <= 0 || h <= 0) {\n return undefined;\n }\n // Without a declared unit, infer it: all values within 0–1 means fractions.\n const scale = unit === 'fraction' || (unit === undefined && x <= 1 && y <= 1 && w <= 1 && h <= 1) ? 100 : 1;\n const rect = { x: x * scale, y: y * scale, w: w * scale, h: h * scale };\n if (rect.x < 0 || rect.y < 0 || rect.x + rect.w > 100 + EDGE_TOLERANCE || rect.y + rect.h > 100 + EDGE_TOLERANCE) {\n // Pixel coordinates (or otherwise out of range) cannot be placed without the\n // source image size — keep the zone, but unplaced, rather than mis-draw it.\n return undefined;\n }\n // Absorb rounding overshoot at the right/bottom edge so the zone stays inside the image.\n return { ...rect, w: Math.min(rect.w, 100 - rect.x), h: Math.min(rect.h, 100 - rect.y) };\n}\n\n/** Parse whatever shape `interactiveAreas` holds into zones. Never throws. */\nexport function extractZones(interactiveAreas: InteractiveAreasJson): Zone[] {\n if (!interactiveAreas) {\n return [];\n }\n const raw = unwrapZoneList(interactiveAreas);\n const unit = declaredUnit(interactiveAreas);\n\n const entries: Array<[string, unknown]> = Array.isArray(raw)\n ? raw.map((item, index) => [String(index), item])\n : isObject(raw)\n ? Object.entries(raw)\n : [];\n\n const zones: Zone[] = [];\n const seen = new Set<string>();\n for (const [key, value] of entries) {\n if (!isObject(value)) {\n continue;\n }\n const label = asString(value.label) ?? asString(value.name) ?? asString(value.title) ?? asString(value.id) ?? key;\n let id = asString(value.id) ?? `zone-${key}`;\n while (seen.has(id)) {\n id = `${id}-${key}`;\n }\n seen.add(id);\n const capacity = asNumber(value.capacity) ?? asNumber(value.seats);\n zones.push({\n id,\n label,\n type: asString(value.type) ?? asString(value.kind),\n capacity: capacity !== undefined && capacity >= 0 ? Math.floor(capacity) : undefined,\n rect: readRect(value, unit),\n });\n }\n return zones;\n}\n\n/**\n * Build the canonical v1 `interactiveAreas` payload. Unknown top-level keys of\n * the previously stored object (e.g. legend or metadata a plan was imported\n * with) are carried over; legacy list keys are replaced by `zones`.\n */\nexport function serializeZones(zones: Zone[], previous?: InteractiveAreasJson): JsonObject {\n const preserved: JsonObject = {};\n const source: JsonObject = isObject(previous) ? previous : {};\n // A legacy keyed-object plan stores each zone as a top-level object; those\n // are superseded by `zones`, so only its scalar metadata is carried over.\n const legacyKeyed = isObject(previous) && unwrapZoneList(previous) === previous;\n for (const [key, value] of Object.entries(source)) {\n if (['zones', 'areas', 'booths', 'version', 'unit'].includes(key)) {\n continue;\n }\n if (legacyKeyed && isObject(value)) {\n continue;\n }\n preserved[key] = value;\n }\n\n return {\n ...preserved,\n version: 1,\n unit: 'percent',\n zones: zones.map((zone) => {\n const entry: JsonObject = { id: zone.id, label: zone.label.trim() };\n if (zone.type) {\n entry.type = zone.type;\n }\n if (zone.capacity !== undefined) {\n entry.capacity = zone.capacity;\n }\n if (zone.rect) {\n entry.x = round2(zone.rect.x);\n entry.y = round2(zone.rect.y);\n entry.w = round2(zone.rect.w);\n entry.h = round2(zone.rect.h);\n }\n return entry;\n }),\n };\n}\n\n/** Round a rectangle to 0.01% so floating-point drag noise never reaches the UI or the stored JSON. */\nexport function roundRect(rect: ZoneRect): ZoneRect {\n const x = round2(rect.x);\n const y = round2(rect.y);\n // Size is capped against the rounded origin so x + w never exceeds 100 after rounding.\n return { x, y, w: Math.min(round2(rect.w), round2(100 - x)), h: Math.min(round2(rect.h), round2(100 - y)) };\n}\n\n/** Normalise two drag points (percent) into a rectangle clamped to the image. */\nexport function rectFromPoints(a: { x: number; y: number }, b: { x: number; y: number }): ZoneRect {\n const x1 = clamp(Math.min(a.x, b.x), 0, 100);\n const y1 = clamp(Math.min(a.y, b.y), 0, 100);\n const x2 = clamp(Math.max(a.x, b.x), 0, 100);\n const y2 = clamp(Math.max(a.y, b.y), 0, 100);\n return roundRect({ x: x1, y: y1, w: x2 - x1, h: y2 - y1 });\n}\n\nexport function isUsableRect(rect: ZoneRect): boolean {\n return rect.w >= MIN_ZONE_SIZE && rect.h >= MIN_ZONE_SIZE;\n}\n\n/** Translate a rectangle, keeping it fully inside the image. */\nexport function moveRect(rect: ZoneRect, dx: number, dy: number): ZoneRect {\n return roundRect({\n ...rect,\n x: clamp(rect.x + dx, 0, 100 - rect.w),\n y: clamp(rect.y + dy, 0, 100 - rect.h),\n });\n}\n\n/** Grow/shrink from the bottom-right corner, keeping a minimum size and the image bounds. */\nexport function resizeRect(rect: ZoneRect, dw: number, dh: number): ZoneRect {\n return roundRect({\n ...rect,\n w: clamp(rect.w + dw, MIN_ZONE_SIZE, 100 - rect.x),\n h: clamp(rect.h + dh, MIN_ZONE_SIZE, 100 - rect.y),\n });\n}\n\n/** A rectangle of the default size centred on the image, for placing an unplaced zone. */\nexport function defaultPlacedRect(): ZoneRect {\n const half = DEFAULT_PLACED_SIZE / 2;\n return { x: 50 - half, y: 50 - half, w: DEFAULT_PLACED_SIZE, h: DEFAULT_PLACED_SIZE };\n}\n\n/** Next free \"<Type> N\" label, so freshly drawn zones are distinguishable. */\nexport function nextZoneLabel(zones: Zone[], type: string = DEFAULT_ZONE_TYPE): string {\n const base = zoneTypeLabel(type) ?? 'Zone';\n const taken = new Set(zones.map((zone) => zone.label.trim().toLowerCase()));\n let n = zones.filter((zone) => (zone.type ?? '') === type).length + 1;\n while (taken.has(`${base} ${n}`.toLowerCase())) {\n n += 1;\n }\n return `${base} ${n}`;\n}\n\nexport function newZoneId(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return crypto.randomUUID();\n }\n return `zone-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;\n}\n\n/**\n * Parse the capacity input. Empty means \"not set\"; anything else must be a\n * non-negative whole number.\n */\nexport function parseCapacity(input: string): { ok: true; value: number | undefined } | { ok: false } {\n const trimmed = input.trim();\n if (trimmed === '') {\n return { ok: true, value: undefined };\n }\n if (!/^\\d+$/.test(trimmed)) {\n return { ok: false };\n }\n const value = Number(trimmed);\n return Number.isSafeInteger(value) ? { ok: true, value } : { ok: false };\n}\n\nexport type ZoneValidationError = { zoneId: string; message: string };\n\n/** Validate zones before persisting. Returns one message per offending zone. */\nexport function validateZones(zones: Zone[]): ZoneValidationError[] {\n const errors: ZoneValidationError[] = [];\n if (zones.length > MAX_ZONES) {\n errors.push({ zoneId: '', message: `A floor plan can hold at most ${MAX_ZONES} zones.` });\n }\n for (const zone of zones) {\n const label = zone.label.trim();\n if (label === '') {\n errors.push({ zoneId: zone.id, message: 'Every zone needs a label.' });\n } else if (label.length > MAX_LABEL_LENGTH) {\n errors.push({\n zoneId: zone.id,\n message: `\"${label.slice(0, 20)}…\" is longer than ${MAX_LABEL_LENGTH} characters.`,\n });\n } else if (zone.capacity !== undefined && (!Number.isSafeInteger(zone.capacity) || zone.capacity < 0)) {\n errors.push({ zoneId: zone.id, message: `\"${label}\" has an invalid capacity.` });\n }\n }\n return errors;\n}\n\nexport type ZoneSummary = { zones: number; booths: number; capacity: number };\n\nexport function summarizeZones(zones: Zone[]): ZoneSummary {\n return {\n zones: zones.length,\n booths: zones.filter((zone) => (zone.type ?? '').toLowerCase().includes('booth')).length,\n capacity: zones.reduce((sum, zone) => sum + (zone.capacity ?? 0), 0),\n };\n}\n\n/** Structural equality used to track unsaved editor changes. */\nexport function zonesEqual(a: Zone[], b: Zone[]): boolean {\n return JSON.stringify(serializeZones(a)) === JSON.stringify(serializeZones(b));\n}\n"],"mappings":";AA8CA,IAAa,IAAa;CACxB;EAAE,OAAO;EAAS,OAAO;EAAS;CAClC;EAAE,OAAO;EAAS,OAAO;EAAS;CAClC;EAAE,OAAO;EAAW,OAAO;EAAW;CACtC;EAAE,OAAO;EAAY,OAAO;EAAY;CACxC;EAAE,OAAO;EAAQ,OAAO;EAAQ;CAChC;EAAE,OAAO;EAAgB,OAAO;EAAqB;CACrD;EAAE,OAAO;EAAY,OAAO;EAAY;CACxC;EAAE,OAAO;EAA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,CAAC,GAC7D,EAAM,SAAA,KACf,EAAO,KAAK;GACV,QAAQ,EAAK;GACb,SAAS,IAAI,EAAM,MAAM,GAAG,GAAG,CAAC;GACjC,CAAC,GACO,EAAK,aAAa,KAAA,MAAc,CAAC,OAAO,cAAc,EAAK,SAAS,IAAI,EAAK,WAAW,MACjG,EAAO,KAAK;GAAE,QAAQ,EAAK;GAAI,SAAS,IAAI,EAAM;GAA6B,CAAC;;AAGpF,QAAO;;AAKT,SAAgB,EAAe,GAA4B;AACzD,QAAO;EACL,OAAO,EAAM;EACb,QAAQ,EAAM,QAAQ,OAAU,EAAK,QAAQ,IAAI,aAAa,CAAC,SAAS,QAAQ,CAAC,CAAC;EAClF,UAAU,EAAM,QAAQ,GAAK,MAAS,KAAO,EAAK,YAAY,IAAI,EAAE;EACrE;;AAIH,SAAgB,EAAW,GAAW,GAAoB;AACxD,QAAO,KAAK,UAAU,EAAe,EAAE,CAAC,KAAK,KAAK,UAAU,EAAe,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"FloorPlansPage.d.ts","sourceRoot":"","sources":["../../../../src/eventfullymanaged/pages/venues/FloorPlansPage.tsx"],"names":[],"mappings":"AA+NA,MAAM,CAAC,OAAO,UAAU,cAAc,4CA8PrC"}
1
+ {"version":3,"file":"FloorPlansPage.d.ts","sourceRoot":"","sources":["../../../../src/eventfullymanaged/pages/venues/FloorPlansPage.tsx"],"names":[],"mappings":"AA0NA,MAAM,CAAC,OAAO,UAAU,cAAc,4CA4XrC"}