@zonetrix/viewer 2.8.0 → 2.9.0

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.
package/dist/index.mjs CHANGED
@@ -1,97 +1,99 @@
1
- import { jsx as h, jsxs as w } from "react/jsx-runtime";
2
- import { useState as E, useEffect as T, useRef as F, useCallback as N, useMemo as Y, memo as Z } from "react";
3
- import { Stage as te, Layer as bt, Group as ee, Rect as Ct, Text as vt, Circle as ne } from "react-konva";
4
- function oe(e) {
5
- const [i, a] = E(null), [n, x] = E(!1), [m, u] = E(null), v = async () => {
1
+ import { jsx as p, jsxs as k } from "react/jsx-runtime";
2
+ import { useState as M, useEffect as Y, useRef as W, useCallback as D, useMemo as $, memo as it } from "react";
3
+ import { Stage as se, Layer as Et, Group as ae, Rect as kt, Text as Ft, Circle as ce } from "react-konva";
4
+ import { ref as mt, onValue as Lt, off as Dt, get as le } from "firebase/database";
5
+ import { fromFirebaseSeatMap as ue } from "@zonetrix/shared";
6
+ function de(e) {
7
+ const [n, s] = M(null), [o, h] = M(!1), [f, l] = M(null), m = async () => {
6
8
  if (e) {
7
- x(!0), u(null);
9
+ h(!0), l(null);
8
10
  try {
9
- const y = await fetch(e);
10
- if (!y.ok)
11
- throw new Error(`Failed to fetch config: ${y.statusText}`);
12
- const s = await y.json();
13
- a(s);
14
- } catch (y) {
15
- const s = y instanceof Error ? y : new Error("Unknown error occurred");
16
- u(s), console.error("Failed to fetch seat map config:", s);
11
+ const u = await fetch(e);
12
+ if (!u.ok)
13
+ throw new Error(`Failed to fetch config: ${u.statusText}`);
14
+ const i = await u.json();
15
+ s(i);
16
+ } catch (u) {
17
+ const i = u instanceof Error ? u : new Error("Unknown error occurred");
18
+ l(i), console.error("Failed to fetch seat map config:", i);
17
19
  } finally {
18
- x(!1);
20
+ h(!1);
19
21
  }
20
22
  }
21
23
  };
22
- return T(() => {
23
- v();
24
+ return Y(() => {
25
+ m();
24
26
  }, [e]), {
25
- config: i,
26
- loading: n,
27
- error: m,
28
- refetch: v
27
+ config: n,
28
+ loading: o,
29
+ error: f,
30
+ refetch: m
29
31
  };
30
32
  }
31
- function ie(e) {
32
- const [i, a] = E({ width: 0, height: 0 });
33
- return T(() => {
34
- const n = e.current;
35
- if (!n) return;
36
- const { width: x, height: m } = n.getBoundingClientRect();
37
- x > 0 && m > 0 && a({ width: x, height: m });
38
- const u = new ResizeObserver((v) => {
39
- const y = v[0];
40
- if (!y) return;
41
- const { width: s, height: o } = y.contentRect;
42
- s > 0 && o > 0 && a((g) => g.width === s && g.height === o ? g : { width: s, height: o });
33
+ function he(e) {
34
+ const [n, s] = M({ width: 0, height: 0 });
35
+ return Y(() => {
36
+ const o = e.current;
37
+ if (!o) return;
38
+ const { width: h, height: f } = o.getBoundingClientRect();
39
+ h > 0 && f > 0 && s({ width: h, height: f });
40
+ const l = new ResizeObserver((m) => {
41
+ const u = m[0];
42
+ if (!u) return;
43
+ const { width: i, height: r } = u.contentRect;
44
+ i > 0 && r > 0 && s((d) => d.width === i && d.height === r ? d : { width: i, height: r });
43
45
  });
44
- return u.observe(n), () => {
45
- u.disconnect();
46
+ return l.observe(o), () => {
47
+ l.disconnect();
46
48
  };
47
- }, [e]), i;
49
+ }, [e]), n;
48
50
  }
49
- function St(e, i) {
50
- return Math.sqrt(Math.pow(i.x - e.x, 2) + Math.pow(i.y - e.y, 2));
51
+ function It(e, n) {
52
+ return Math.sqrt(Math.pow(n.x - e.x, 2) + Math.pow(n.y - e.y, 2));
51
53
  }
52
- function wt(e, i) {
54
+ function Rt(e, n) {
53
55
  return {
54
- x: (e.x + i.x) / 2,
55
- y: (e.y + i.y) / 2
56
+ x: (e.x + n.x) / 2,
57
+ y: (e.y + n.y) / 2
56
58
  };
57
59
  }
58
- function re(e, i) {
59
- const a = F(null), n = F(null), x = F(1);
60
- T(() => {
61
- const m = e.current;
62
- if (!m || !i.enabled) return;
63
- const u = m.container(), v = (o) => {
64
- if (o.touches.length === 2) {
65
- o.preventDefault();
66
- const g = { x: o.touches[0].clientX, y: o.touches[0].clientY }, l = { x: o.touches[1].clientX, y: o.touches[1].clientY };
67
- a.current = St(g, l), n.current = wt(g, l), x.current = i.currentScale;
60
+ function fe(e, n) {
61
+ const s = W(null), o = W(null), h = W(1);
62
+ Y(() => {
63
+ const f = e.current;
64
+ if (!f || !n.enabled) return;
65
+ const l = f.container(), m = (r) => {
66
+ if (r.touches.length === 2) {
67
+ r.preventDefault();
68
+ const d = { x: r.touches[0].clientX, y: r.touches[0].clientY }, a = { x: r.touches[1].clientX, y: r.touches[1].clientY };
69
+ s.current = It(d, a), o.current = Rt(d, a), h.current = n.currentScale;
68
70
  }
69
- }, y = (o) => {
70
- if (o.touches.length !== 2) return;
71
- o.preventDefault();
72
- const g = { x: o.touches[0].clientX, y: o.touches[0].clientY }, l = { x: o.touches[1].clientX, y: o.touches[1].clientY }, k = St(g, l), C = wt(g, l);
73
- if (a.current !== null && n.current !== null) {
74
- const D = k / a.current, P = Math.min(
75
- Math.max(i.currentScale * D, i.minScale),
76
- i.maxScale
77
- ), K = u.getBoundingClientRect(), J = C.x - K.left, Q = C.y - K.top, tt = i.currentScale, z = {
78
- x: (J - i.currentPosition.x) / tt,
79
- y: (Q - i.currentPosition.y) / tt
80
- }, $ = C.x - n.current.x, at = C.y - n.current.y, lt = {
81
- x: J - z.x * P + $,
82
- y: Q - z.y * P + at
71
+ }, u = (r) => {
72
+ if (r.touches.length !== 2) return;
73
+ r.preventDefault();
74
+ const d = { x: r.touches[0].clientX, y: r.touches[0].clientY }, a = { x: r.touches[1].clientX, y: r.touches[1].clientY }, w = It(d, a), S = Rt(d, a);
75
+ if (s.current !== null && o.current !== null) {
76
+ const C = w / s.current, F = Math.min(
77
+ Math.max(n.currentScale * C, n.minScale),
78
+ n.maxScale
79
+ ), I = l.getBoundingClientRect(), R = S.x - I.left, z = S.y - I.top, A = n.currentScale, H = {
80
+ x: (R - n.currentPosition.x) / A,
81
+ y: (z - n.currentPosition.y) / A
82
+ }, O = S.x - o.current.x, j = S.y - o.current.y, st = {
83
+ x: R - H.x * F + O,
84
+ y: z - H.y * F + j
83
85
  };
84
- i.onScaleChange(P, lt), a.current = k, n.current = C;
86
+ n.onScaleChange(F, st), s.current = w, o.current = S;
85
87
  }
86
- }, s = (o) => {
87
- o.touches.length < 2 && (a.current = null, n.current = null);
88
+ }, i = (r) => {
89
+ r.touches.length < 2 && (s.current = null, o.current = null);
88
90
  };
89
- return u.addEventListener("touchstart", v, { passive: !1 }), u.addEventListener("touchmove", y, { passive: !1 }), u.addEventListener("touchend", s), () => {
90
- u.removeEventListener("touchstart", v), u.removeEventListener("touchmove", y), u.removeEventListener("touchend", s);
91
+ return l.addEventListener("touchstart", m, { passive: !1 }), l.addEventListener("touchmove", u, { passive: !1 }), l.addEventListener("touchend", i), () => {
92
+ l.removeEventListener("touchstart", m), l.removeEventListener("touchmove", u), l.removeEventListener("touchend", i);
91
93
  };
92
- }, [e, i]);
94
+ }, [e, n]);
93
95
  }
94
- const se = {
96
+ const ge = {
95
97
  canvasBackground: "#1a1a1a",
96
98
  stageColor: "#808080",
97
99
  seatAvailable: "#2C2B30",
@@ -101,45 +103,45 @@ const se = {
101
103
  seatHidden: "#4a4a4a",
102
104
  gridLines: "#404040",
103
105
  currency: "KD"
104
- }, Mt = Z(({ seat: e, state: i, colors: a, onClick: n, onMouseEnter: x, onMouseLeave: m }) => {
105
- const y = {
106
- available: a.seatAvailable,
107
- reserved: a.seatReserved,
108
- selected: a.seatSelected,
109
- unavailable: a.seatUnavailable,
110
- hidden: a.seatHidden
106
+ }, Nt = it(({ seat: e, state: n, colors: s, onClick: o, onMouseEnter: h, onMouseLeave: f }) => {
107
+ const u = {
108
+ available: s.seatAvailable,
109
+ reserved: s.seatReserved,
110
+ selected: s.seatSelected,
111
+ unavailable: s.seatUnavailable,
112
+ hidden: s.seatHidden
111
113
  // Hidden seats are filtered out, but included for type safety
112
- }[i], s = i === "available" || i === "selected", o = N(() => {
113
- s && n(e);
114
- }, [e, n, s]), g = N((C) => {
115
- x(e, C);
116
- const D = C.target.getStage();
117
- D && s && (D.container().style.cursor = "pointer");
118
- }, [e, x, s]), l = N((C) => {
119
- m();
120
- const D = C.target.getStage();
121
- D && (D.container().style.cursor = "grab");
122
- }, [m]), k = {
114
+ }[n], i = n === "available" || n === "selected", r = D(() => {
115
+ i && o(e);
116
+ }, [e, o, i]), d = D((S) => {
117
+ h(e, S);
118
+ const C = S.target.getStage();
119
+ C && i && (C.container().style.cursor = "pointer");
120
+ }, [e, h, i]), a = D((S) => {
121
+ f();
122
+ const C = S.target.getStage();
123
+ C && (C.container().style.cursor = "grab");
124
+ }, [f]), w = {
123
125
  x: e.position.x,
124
126
  y: e.position.y,
125
- fill: y,
127
+ fill: u,
126
128
  stroke: "#ffffff",
127
129
  strokeWidth: 1,
128
- onClick: o,
129
- onTap: o,
130
- onMouseEnter: g,
131
- onMouseLeave: l
130
+ onClick: r,
131
+ onTap: r,
132
+ onMouseEnter: d,
133
+ onMouseLeave: a
132
134
  };
133
- return e.shape === "circle" ? /* @__PURE__ */ h(
134
- ne,
135
+ return e.shape === "circle" ? /* @__PURE__ */ p(
136
+ ce,
135
137
  {
136
- ...k,
138
+ ...w,
137
139
  radius: 12
138
140
  }
139
- ) : /* @__PURE__ */ h(
140
- Ct,
141
+ ) : /* @__PURE__ */ p(
142
+ kt,
141
143
  {
142
- ...k,
144
+ ...w,
143
145
  width: 24,
144
146
  height: 24,
145
147
  offsetX: 12,
@@ -148,9 +150,9 @@ const se = {
148
150
  }
149
151
  );
150
152
  });
151
- Mt.displayName = "ViewerSeat";
152
- const kt = Z(({ stage: e, stageColor: i }) => {
153
- const a = (m) => ({
153
+ Nt.displayName = "ViewerSeat";
154
+ const zt = it(({ stage: e, stageColor: n }) => {
155
+ const s = (f) => ({
154
156
  stage: "🎭",
155
157
  table: "⬜",
156
158
  wall: "▬",
@@ -159,23 +161,23 @@ const kt = Z(({ stage: e, stageColor: i }) => {
159
161
  bar: "🍷",
160
162
  "entry-exit": "🚪",
161
163
  custom: "➕"
162
- })[m || "stage"] || "🎭", n = e.config.color || i, x = a(e.config.objectType);
163
- return /* @__PURE__ */ w(ee, { x: e.position.x, y: e.position.y, rotation: e.config.rotation || 0, children: [
164
- /* @__PURE__ */ h(
165
- Ct,
164
+ })[f || "stage"] || "🎭", o = e.config.color || n, h = s(e.config.objectType);
165
+ return /* @__PURE__ */ k(ae, { x: e.position.x, y: e.position.y, rotation: e.config.rotation || 0, children: [
166
+ /* @__PURE__ */ p(
167
+ kt,
166
168
  {
167
169
  width: e.config.width,
168
170
  height: e.config.height,
169
- fill: n + "80",
171
+ fill: o + "80",
170
172
  stroke: "#ffffff",
171
173
  strokeWidth: 2,
172
174
  cornerRadius: 10
173
175
  }
174
176
  ),
175
- /* @__PURE__ */ h(
176
- vt,
177
+ /* @__PURE__ */ p(
178
+ Ft,
177
179
  {
178
- text: x,
180
+ text: h,
179
181
  x: 0,
180
182
  y: 0,
181
183
  width: e.config.width,
@@ -186,8 +188,8 @@ const kt = Z(({ stage: e, stageColor: i }) => {
186
188
  verticalAlign: "middle"
187
189
  }
188
190
  ),
189
- /* @__PURE__ */ h(
190
- vt,
191
+ /* @__PURE__ */ p(
192
+ Ft,
191
193
  {
192
194
  text: e.config.label,
193
195
  x: 0,
@@ -203,20 +205,20 @@ const kt = Z(({ stage: e, stageColor: i }) => {
203
205
  )
204
206
  ] });
205
207
  });
206
- kt.displayName = "ViewerStage";
207
- const It = Z(({
208
+ zt.displayName = "ViewerStage";
209
+ const Tt = it(({
208
210
  floors: e,
209
- currentFloorId: i,
210
- onFloorChange: a,
211
- showAllOption: n,
212
- allLabel: x,
213
- position: m,
214
- className: u
211
+ currentFloorId: n,
212
+ onFloorChange: s,
213
+ showAllOption: o,
214
+ allLabel: h,
215
+ position: f,
216
+ className: l
215
217
  }) => {
216
- const v = Y(
217
- () => [...e].sort((l, k) => l.order - k.order),
218
+ const m = $(
219
+ () => [...e].sort((a, w) => a.order - w.order),
218
220
  [e]
219
- ), s = {
221
+ ), i = {
220
222
  position: "absolute",
221
223
  display: "flex",
222
224
  alignItems: "center",
@@ -231,8 +233,8 @@ const It = Z(({
231
233
  "top-right": { top: 0, right: 0 },
232
234
  "bottom-left": { bottom: 0, left: 0 },
233
235
  "bottom-right": { bottom: 0, right: 0 }
234
- }[m]
235
- }, o = {
236
+ }[f]
237
+ }, r = {
236
238
  padding: "10px 16px",
237
239
  fontSize: "14px",
238
240
  fontWeight: 500,
@@ -244,44 +246,44 @@ const It = Z(({
244
246
  transition: "all 0.2s ease",
245
247
  minHeight: "44px",
246
248
  touchAction: "manipulation"
247
- }, g = {
248
- ...o,
249
+ }, d = {
250
+ ...r,
249
251
  backgroundColor: "#3A7DE5",
250
252
  borderColor: "#3A7DE5"
251
253
  };
252
- return /* @__PURE__ */ w("div", { className: u, style: s, children: [
253
- n && /* @__PURE__ */ h(
254
+ return /* @__PURE__ */ k("div", { className: l, style: i, children: [
255
+ o && /* @__PURE__ */ p(
254
256
  "button",
255
257
  {
256
258
  type: "button",
257
- onClick: () => a(null),
258
- style: i === null ? g : o,
259
- children: x
259
+ onClick: () => s(null),
260
+ style: n === null ? d : r,
261
+ children: h
260
262
  }
261
263
  ),
262
- v.map((l) => /* @__PURE__ */ h(
264
+ m.map((a) => /* @__PURE__ */ p(
263
265
  "button",
264
266
  {
265
267
  type: "button",
266
- onClick: () => a(l.id),
267
- style: i === l.id ? g : o,
268
- children: l.name
268
+ onClick: () => s(a.id),
269
+ style: n === a.id ? d : r,
270
+ children: a.name
269
271
  },
270
- l.id
272
+ a.id
271
273
  ))
272
274
  ] });
273
275
  });
274
- It.displayName = "FloorSelectorBar";
275
- const Nt = Z(({
276
+ Tt.displayName = "FloorSelectorBar";
277
+ const Xt = it(({
276
278
  scale: e,
277
- minScale: i,
278
- maxScale: a,
279
- onZoomIn: n,
280
- onZoomOut: x,
281
- position: m,
282
- className: u
279
+ minScale: n,
280
+ maxScale: s,
281
+ onZoomIn: o,
282
+ onZoomOut: h,
283
+ position: f,
284
+ className: l
283
285
  }) => {
284
- const y = {
286
+ const u = {
285
287
  position: "absolute",
286
288
  display: "flex",
287
289
  flexDirection: "column",
@@ -296,8 +298,8 @@ const Nt = Z(({
296
298
  "top-right": { top: 0, right: 0 },
297
299
  "bottom-left": { bottom: 0, left: 0 },
298
300
  "bottom-right": { bottom: 0, right: 0 }
299
- }[m]
300
- }, s = {
301
+ }[f]
302
+ }, i = {
301
303
  width: "44px",
302
304
  height: "44px",
303
305
  minWidth: "44px",
@@ -314,53 +316,53 @@ const Nt = Z(({
314
316
  justifyContent: "center",
315
317
  transition: "all 0.2s ease",
316
318
  touchAction: "manipulation"
317
- }, o = {
318
- ...s,
319
+ }, r = {
320
+ ...i,
319
321
  opacity: 0.4,
320
322
  cursor: "not-allowed"
321
- }, g = e < a, l = e > i;
322
- return /* @__PURE__ */ w("div", { className: u, style: y, children: [
323
- /* @__PURE__ */ h(
323
+ }, d = e < s, a = e > n;
324
+ return /* @__PURE__ */ k("div", { className: l, style: u, children: [
325
+ /* @__PURE__ */ p(
324
326
  "button",
325
327
  {
326
328
  type: "button",
327
- onClick: n,
328
- disabled: !g,
329
- style: g ? s : o,
329
+ onClick: o,
330
+ disabled: !d,
331
+ style: d ? i : r,
330
332
  title: "Zoom In",
331
333
  children: "+"
332
334
  }
333
335
  ),
334
- /* @__PURE__ */ h(
336
+ /* @__PURE__ */ p(
335
337
  "button",
336
338
  {
337
339
  type: "button",
338
- onClick: x,
339
- disabled: !l,
340
- style: l ? s : o,
340
+ onClick: h,
341
+ disabled: !a,
342
+ style: a ? i : r,
341
343
  title: "Zoom Out",
342
344
  children: "−"
343
345
  }
344
346
  )
345
347
  ] });
346
348
  });
347
- Nt.displayName = "ZoomControls";
348
- const Dt = Z(({
349
+ Xt.displayName = "ZoomControls";
350
+ const Yt = it(({
349
351
  visible: e,
350
- x: i,
351
- y: a,
352
- seat: n,
353
- currency: x,
354
- state: m
352
+ x: n,
353
+ y: s,
354
+ seat: o,
355
+ currency: h,
356
+ state: f
355
357
  }) => {
356
- if (!e || !n) return null;
357
- const u = n.seatNumber || (n.rowLabel && n.columnLabel ? `${n.rowLabel}-${n.columnLabel}` : "N/A"), v = {
358
+ if (!e || !o) return null;
359
+ const l = o.seatNumber || (o.rowLabel && o.columnLabel ? `${o.rowLabel}-${o.columnLabel}` : "N/A"), m = {
358
360
  position: "fixed",
359
- left: `${i + 15}px`,
360
- top: `${a + 15}px`,
361
+ left: `${n + 15}px`,
362
+ top: `${s + 15}px`,
361
363
  zIndex: 1e3,
362
364
  pointerEvents: "none"
363
- }, y = {
365
+ }, u = {
364
366
  backgroundColor: "rgba(26, 26, 26, 0.95)",
365
367
  color: "#fff",
366
368
  border: "1px solid #444",
@@ -369,324 +371,479 @@ const Dt = Z(({
369
371
  fontSize: "13px",
370
372
  boxShadow: "0 4px 12px rgba(0, 0, 0, 0.3)",
371
373
  minWidth: "140px"
372
- }, s = {
374
+ }, i = {
373
375
  color: "#9ca3af",
374
376
  marginRight: "4px"
375
- }, o = {
377
+ }, r = {
376
378
  fontWeight: 600
377
- }, g = {
379
+ }, d = {
378
380
  color: "#4ade80",
379
381
  fontWeight: 600
380
- }, l = {
382
+ }, a = {
381
383
  fontSize: "11px",
382
384
  color: "#6b7280",
383
385
  textTransform: "capitalize",
384
386
  marginTop: "4px"
385
387
  };
386
- return /* @__PURE__ */ h("div", { style: v, children: /* @__PURE__ */ w("div", { style: y, children: [
387
- n.sectionName && /* @__PURE__ */ w("div", { style: { marginBottom: "4px" }, children: [
388
- /* @__PURE__ */ h("span", { style: s, children: "Section:" }),
389
- /* @__PURE__ */ h("span", { style: { ...o, color: "#3b82f6" }, children: n.sectionName })
388
+ return /* @__PURE__ */ p("div", { style: m, children: /* @__PURE__ */ k("div", { style: u, children: [
389
+ o.sectionName && /* @__PURE__ */ k("div", { style: { marginBottom: "4px" }, children: [
390
+ /* @__PURE__ */ p("span", { style: i, children: "Section:" }),
391
+ /* @__PURE__ */ p("span", { style: { ...r, color: "#3b82f6" }, children: o.sectionName })
390
392
  ] }),
391
- /* @__PURE__ */ w("div", { style: { marginBottom: "4px" }, children: [
392
- /* @__PURE__ */ h("span", { style: s, children: "Seat:" }),
393
- /* @__PURE__ */ h("span", { style: o, children: u })
393
+ /* @__PURE__ */ k("div", { style: { marginBottom: "4px" }, children: [
394
+ /* @__PURE__ */ p("span", { style: i, children: "Seat:" }),
395
+ /* @__PURE__ */ p("span", { style: r, children: l })
394
396
  ] }),
395
- n.price !== void 0 && n.price > 0 && /* @__PURE__ */ w("div", { style: { marginBottom: "4px" }, children: [
396
- /* @__PURE__ */ h("span", { style: s, children: "Price:" }),
397
- /* @__PURE__ */ w("span", { style: g, children: [
398
- x,
397
+ o.price !== void 0 && o.price > 0 && f === "available" && /* @__PURE__ */ k("div", { style: { marginBottom: "4px" }, children: [
398
+ /* @__PURE__ */ p("span", { style: i, children: "Price:" }),
399
+ /* @__PURE__ */ k("span", { style: d, children: [
400
+ h,
399
401
  " ",
400
- n.price.toFixed(2)
402
+ o.price.toFixed(2)
401
403
  ] })
402
404
  ] }),
403
- /* @__PURE__ */ w("div", { style: l, children: [
405
+ /* @__PURE__ */ k("div", { style: a, children: [
404
406
  "Status: ",
405
- m
407
+ f
406
408
  ] })
407
409
  ] }) });
408
410
  });
409
- Dt.displayName = "SeatTooltip";
410
- const he = ({
411
+ Yt.displayName = "SeatTooltip";
412
+ const we = ({
411
413
  config: e,
412
- configUrl: i,
413
- floorId: a,
414
- onFloorChange: n,
415
- reservedSeats: x = [],
416
- unavailableSeats: m = [],
417
- selectedSeats: u,
418
- onSeatSelect: v,
419
- onSeatDeselect: y,
420
- onSelectionChange: s,
421
- colorOverrides: o,
422
- showTooltip: g = !0,
423
- zoomEnabled: l = !0,
424
- className: k = "",
425
- onConfigLoad: C,
426
- onError: D,
414
+ configUrl: n,
415
+ floorId: s,
416
+ onFloorChange: o,
417
+ reservedSeats: h = [],
418
+ unavailableSeats: f = [],
419
+ selectedSeats: l,
420
+ onSeatSelect: m,
421
+ onSeatDeselect: u,
422
+ onSelectionChange: i,
423
+ colorOverrides: r,
424
+ showTooltip: d = !0,
425
+ zoomEnabled: a = !0,
426
+ className: w = "",
427
+ onConfigLoad: S,
428
+ onError: C,
427
429
  // Floor selector props
428
- showFloorSelector: P,
429
- floorSelectorPosition: K = "top-left",
430
- floorSelectorClassName: J,
431
- showAllFloorsOption: Q = !0,
432
- allFloorsLabel: tt = "All",
433
- fitToView: z = !0,
434
- fitPadding: $ = 40,
430
+ showFloorSelector: F,
431
+ floorSelectorPosition: I = "top-left",
432
+ floorSelectorClassName: R,
433
+ showAllFloorsOption: z = !0,
434
+ allFloorsLabel: A = "All",
435
+ fitToView: H = !0,
436
+ fitPadding: O = 40,
435
437
  // Zoom controls
436
- showZoomControls: at = !0,
437
- zoomControlsPosition: lt = "bottom-right",
438
- zoomControlsClassName: Rt,
439
- minZoom: gt,
440
- maxZoom: L = 3,
441
- zoomStep: et = 0.25,
438
+ showZoomControls: j = !0,
439
+ zoomControlsPosition: st = "bottom-right",
440
+ zoomControlsClassName: G,
441
+ minZoom: Z,
442
+ maxZoom: T = 3,
443
+ zoomStep: B = 0.25,
442
444
  // Touch gestures
443
- touchEnabled: Et = !0
445
+ touchEnabled: at = !0
444
446
  }) => {
445
- const ht = F(null), yt = F(null), S = ie(yt), [j, xt] = E(/* @__PURE__ */ new Set()), [M, H] = E(1), [I, W] = E({ x: 0, y: 0 }), [Lt, Xt] = E(null), [Yt, Tt] = E(1), nt = F({ width: 0, height: 0 }), [O, mt] = E({ visible: !1, x: 0, y: 0, seat: null, state: "available" }), { config: Wt, loading: Pt, error: V } = oe(i), c = e || Wt, dt = a !== void 0, R = dt ? a || null : Lt, ot = u !== void 0, jt = N((t) => {
446
- dt || Xt(t), n?.(t);
447
- }, [dt, n]), ut = c?.floors || [], At = P !== void 0 ? P : ut.length > 1, it = Y(
448
- () => c ? { ...c.colors, ...o } : { ...se, ...o },
449
- [c, o]
450
- ), A = Y(() => {
451
- if (!c) return [];
452
- let t = c.seats.filter((r) => r.state !== "hidden");
453
- return R && (t = t.filter(
454
- (r) => r.floorId === R || !r.floorId && R === "floor_default"
447
+ const gt = W(null), wt = W(null), E = he(wt), [U, Ct] = M(/* @__PURE__ */ new Set()), [L, K] = M(1), [N, V] = M({ x: 0, y: 0 }), [Wt, jt] = M(null), [Pt, $t] = M(1), ct = W({ width: 0, height: 0 }), [J, Mt] = M({ visible: !1, x: 0, y: 0, seat: null, state: "available" }), { config: At, loading: Bt, error: Q } = de(n), g = e || At, pt = s !== void 0, X = pt ? s || null : Wt, lt = l !== void 0, Vt = D((t) => {
448
+ pt || jt(t), o?.(t);
449
+ }, [pt, o]), bt = g?.floors || [], Ht = F !== void 0 ? F : bt.length > 1, ut = $(
450
+ () => g ? { ...g.colors, ...r } : { ...ge, ...r },
451
+ [g, r]
452
+ ), _ = $(() => {
453
+ if (!g) return [];
454
+ let t = g.seats.filter((c) => c.state !== "hidden");
455
+ return X && (t = t.filter(
456
+ (c) => c.floorId === X || !c.floorId && X === "floor_default"
455
457
  )), t;
456
- }, [c, R]), rt = Y(() => c?.stages ? R ? c.stages.filter(
457
- (t) => t.floorId === R || !t.floorId && R === "floor_default"
458
- ) : c.stages : [], [c, R]), X = Y(() => {
459
- if (!c || A.length === 0 && rt.length === 0)
458
+ }, [g, X]), dt = $(() => g?.stages ? X ? g.stages.filter(
459
+ (t) => t.floorId === X || !t.floorId && X === "floor_default"
460
+ ) : g.stages : [], [g, X]), P = $(() => {
461
+ if (!g || _.length === 0 && dt.length === 0)
460
462
  return null;
461
463
  const t = 12;
462
- let r = 1 / 0, f = 1 / 0, d = -1 / 0, p = -1 / 0;
463
- return A.forEach((b) => {
464
- r = Math.min(r, b.position.x - t), f = Math.min(f, b.position.y - t), d = Math.max(d, b.position.x + t), p = Math.max(p, b.position.y + t);
465
- }), rt.forEach((b) => {
466
- r = Math.min(r, b.position.x), f = Math.min(f, b.position.y), d = Math.max(d, b.position.x + (b.config?.width || 200)), p = Math.max(p, b.position.y + (b.config?.height || 100));
467
- }), { minX: r, minY: f, maxX: d, maxY: p, width: d - r, height: p - f };
468
- }, [c, A, rt]);
469
- T(() => {
470
- if (!z || !c || !X || S.width === 0 || S.height === 0) return;
471
- const t = Math.abs(S.width - nt.current.width), r = Math.abs(S.height - nt.current.height);
472
- if (!(nt.current.width === 0) && t < 10 && r < 10) return;
473
- nt.current = S;
474
- const d = S.width, p = S.height, b = d - $ * 2, U = p - $ * 2, st = b / X.width, pt = U / X.height, ct = Math.min(st, pt, L), Gt = X.minX + X.width / 2, Ut = X.minY + X.height / 2, Zt = d / 2, Kt = p / 2, Jt = Zt - Gt * ct, Qt = Kt - Ut * ct;
475
- H(ct), W({ x: Jt, y: Qt }), Tt(ct);
476
- }, [z, c, X, $, L, S, R]);
477
- const _ = Y(() => {
478
- const t = new Set(x), r = new Set(m);
479
- return { reserved: t, unavailable: r };
480
- }, [x, m]), ft = Y(() => u ? new Set(u) : null, [u]), q = N((t) => {
481
- const r = t.id, f = t.seatNumber || "";
482
- return _.unavailable.has(r) || _.unavailable.has(f) ? "unavailable" : _.reserved.has(r) || _.reserved.has(f) ? "reserved" : j.has(r) ? "selected" : t.state;
483
- }, [_, j]);
484
- T(() => {
485
- c && C && C(c);
486
- }, [c, C]), T(() => {
487
- V && D && D(V);
488
- }, [V, D]), T(() => {
489
- ot && ft && xt(ft);
490
- }, [ot, ft]);
491
- const Bt = N((t) => {
492
- const r = q(t);
493
- if (r !== "available" && r !== "selected")
464
+ let c = 1 / 0, y = 1 / 0, b = -1 / 0, x = -1 / 0;
465
+ return _.forEach((v) => {
466
+ c = Math.min(c, v.position.x - t), y = Math.min(y, v.position.y - t), b = Math.max(b, v.position.x + t), x = Math.max(x, v.position.y + t);
467
+ }), dt.forEach((v) => {
468
+ c = Math.min(c, v.position.x), y = Math.min(y, v.position.y), b = Math.max(b, v.position.x + (v.config?.width || 200)), x = Math.max(x, v.position.y + (v.config?.height || 100));
469
+ }), { minX: c, minY: y, maxX: b, maxY: x, width: b - c, height: x - y };
470
+ }, [g, _, dt]);
471
+ Y(() => {
472
+ if (!H || !g || !P || E.width === 0 || E.height === 0) return;
473
+ const t = Math.abs(E.width - ct.current.width), c = Math.abs(E.height - ct.current.height);
474
+ if (!(ct.current.width === 0) && t < 10 && c < 10) return;
475
+ ct.current = E;
476
+ const b = E.width, x = E.height, v = b - O * 2, ot = x - O * 2, ht = v / P.width, xt = ot / P.height, ft = Math.min(ht, xt, T), te = P.minX + P.width / 2, ee = P.minY + P.height / 2, ne = b / 2, oe = x / 2, re = ne - te * ft, ie = oe - ee * ft;
477
+ K(ft), V({ x: re, y: ie }), $t(ft);
478
+ }, [H, g, P, O, T, E, X]);
479
+ const tt = $(() => {
480
+ const t = new Set(h), c = new Set(f);
481
+ return { reserved: t, unavailable: c };
482
+ }, [h, f]), yt = $(() => l ? new Set(l) : null, [l]), et = D((t) => {
483
+ const c = t.id, y = t.seatNumber || "";
484
+ return tt.unavailable.has(c) || tt.unavailable.has(y) ? "unavailable" : tt.reserved.has(c) || tt.reserved.has(y) ? "reserved" : U.has(c) ? "selected" : t.state;
485
+ }, [tt, U]);
486
+ Y(() => {
487
+ g && S && S(g);
488
+ }, [g, S]), Y(() => {
489
+ Q && C && C(Q);
490
+ }, [Q, C]), Y(() => {
491
+ lt && yt && Ct(yt);
492
+ }, [lt, yt]);
493
+ const Ot = D((t) => {
494
+ const c = et(t);
495
+ if (c !== "available" && c !== "selected")
494
496
  return;
495
- const f = j.has(t.id);
496
- ot || xt((d) => {
497
- const p = new Set(d);
498
- return f ? p.delete(t.id) : p.add(t.id), p;
499
- }), f ? y?.(t) : (v?.(t), v || console.log("Seat selected:", t));
500
- }, [q, j, ot, v, y]), G = Y(() => c ? A.filter((t) => j.has(t.id)) : [], [A, j]);
501
- T(() => {
502
- s?.(G);
503
- }, [G, s]);
504
- const B = gt !== void 0 ? gt : Yt, Ft = N(() => {
505
- if (!l) return;
506
- const t = Math.min(M + et, L);
507
- if (t !== M) {
508
- const r = S.width || c?.canvas.width || 800, f = S.height || c?.canvas.height || 600, d = r / 2, p = f / 2, b = {
509
- x: (d - I.x) / M,
510
- y: (p - I.y) / M
497
+ const y = U.has(t.id);
498
+ lt || Ct((b) => {
499
+ const x = new Set(b);
500
+ return y ? x.delete(t.id) : x.add(t.id), x;
501
+ }), y ? u?.(t) : (m?.(t), m || console.log("Seat selected:", t));
502
+ }, [et, U, lt, m, u]), nt = $(() => g ? _.filter((t) => U.has(t.id)) : [], [_, U]);
503
+ Y(() => {
504
+ i?.(nt);
505
+ }, [nt, i]);
506
+ const q = Z !== void 0 ? Z : Pt, Ut = D(() => {
507
+ if (!a) return;
508
+ const t = Math.min(L + B, T);
509
+ if (t !== L) {
510
+ const c = E.width || g?.canvas.width || 800, y = E.height || g?.canvas.height || 600, b = c / 2, x = y / 2, v = {
511
+ x: (b - N.x) / L,
512
+ y: (x - N.y) / L
511
513
  };
512
- H(t), W({
513
- x: d - b.x * t,
514
- y: p - b.y * t
514
+ K(t), V({
515
+ x: b - v.x * t,
516
+ y: x - v.y * t
515
517
  });
516
518
  }
517
- }, [l, M, et, L, S, c, I]), zt = N(() => {
518
- if (!l) return;
519
- const t = Math.max(M - et, B);
520
- if (t !== M) {
521
- const r = S.width || c?.canvas.width || 800, f = S.height || c?.canvas.height || 600, d = r / 2, p = f / 2, b = {
522
- x: (d - I.x) / M,
523
- y: (p - I.y) / M
519
+ }, [a, L, B, T, E, g, N]), _t = D(() => {
520
+ if (!a) return;
521
+ const t = Math.max(L - B, q);
522
+ if (t !== L) {
523
+ const c = E.width || g?.canvas.width || 800, y = E.height || g?.canvas.height || 600, b = c / 2, x = y / 2, v = {
524
+ x: (b - N.x) / L,
525
+ y: (x - N.y) / L
524
526
  };
525
- H(t), W({
526
- x: d - b.x * t,
527
- y: p - b.y * t
527
+ K(t), V({
528
+ x: b - v.x * t,
529
+ y: x - v.y * t
528
530
  });
529
531
  }
530
- }, [l, M, et, B, S, c, I]), $t = N((t) => {
531
- W({
532
+ }, [a, L, B, q, E, g, N]), qt = D((t) => {
533
+ V({
532
534
  x: t.target.x(),
533
535
  y: t.target.y()
534
536
  });
535
- }, []), Ht = N((t) => {
536
- if (!l) return;
537
+ }, []), Gt = D((t) => {
538
+ if (!a) return;
537
539
  t.evt.preventDefault();
538
- const r = ht.current;
539
- if (!r) return;
540
- const f = r.scaleX(), d = r.getPointerPosition();
541
- if (!d) return;
542
- const p = 1.1, b = t.evt.deltaY > 0 ? f / p : f * p, U = Math.min(Math.max(b, B), L), st = {
543
- x: (d.x - I.x) / f,
544
- y: (d.y - I.y) / f
545
- }, pt = {
546
- x: d.x - st.x * U,
547
- y: d.y - st.y * U
540
+ const c = gt.current;
541
+ if (!c) return;
542
+ const y = c.scaleX(), b = c.getPointerPosition();
543
+ if (!b) return;
544
+ const x = 1.1, v = t.evt.deltaY > 0 ? y / x : y * x, ot = Math.min(Math.max(v, q), T), ht = {
545
+ x: (b.x - N.x) / y,
546
+ y: (b.y - N.y) / y
547
+ }, xt = {
548
+ x: b.x - ht.x * ot,
549
+ y: b.y - ht.y * ot
548
550
  };
549
- H(U), W(pt);
550
- }, [l, I, B, L]);
551
- re(ht, {
552
- enabled: Et && l,
553
- minScale: B,
554
- maxScale: L,
555
- currentScale: M,
556
- currentPosition: I,
557
- onScaleChange: (t, r) => {
558
- H(t), W(r);
551
+ K(ot), V(xt);
552
+ }, [a, N, q, T]);
553
+ fe(gt, {
554
+ enabled: at && a,
555
+ minScale: q,
556
+ maxScale: T,
557
+ currentScale: L,
558
+ currentPosition: N,
559
+ onScaleChange: (t, c) => {
560
+ K(t), V(c);
559
561
  },
560
562
  onPositionChange: (t) => {
561
- W(t);
563
+ V(t);
562
564
  }
563
565
  });
564
- const Ot = N((t, r) => {
565
- if (!g) return;
566
- const f = r.target.getStage();
567
- if (!f) return;
568
- const d = f.getPointerPosition();
566
+ const Zt = D((t, c) => {
569
567
  if (!d) return;
570
- const p = f.container().getBoundingClientRect();
571
- mt({
568
+ const y = c.target.getStage();
569
+ if (!y) return;
570
+ const b = y.getPointerPosition();
571
+ if (!b) return;
572
+ const x = y.container().getBoundingClientRect();
573
+ Mt({
572
574
  visible: !0,
573
- x: p.left + d.x,
574
- y: p.top + d.y,
575
+ x: x.left + b.x,
576
+ y: x.top + b.y,
575
577
  seat: t,
576
- state: q(t)
578
+ state: et(t)
577
579
  });
578
- }, [g, q]), Vt = N(() => {
579
- mt((t) => ({ ...t, visible: !1 }));
580
+ }, [d, et]), Kt = D(() => {
581
+ Mt((t) => ({ ...t, visible: !1 }));
580
582
  }, []);
581
- if (Pt)
582
- return /* @__PURE__ */ h("div", { className: `flex items-center justify-center h-full ${k}`, children: /* @__PURE__ */ h("p", { children: "Loading seat map..." }) });
583
- if (V)
584
- return /* @__PURE__ */ h("div", { className: `flex items-center justify-center h-full ${k}`, children: /* @__PURE__ */ w("p", { className: "text-red-500", children: [
583
+ if (Bt)
584
+ return /* @__PURE__ */ p("div", { className: `flex items-center justify-center h-full ${w}`, children: /* @__PURE__ */ p("p", { children: "Loading seat map..." }) });
585
+ if (Q)
586
+ return /* @__PURE__ */ p("div", { className: `flex items-center justify-center h-full ${w}`, children: /* @__PURE__ */ k("p", { className: "text-red-500", children: [
585
587
  "Error loading seat map: ",
586
- V.message
588
+ Q.message
587
589
  ] }) });
588
- if (!c)
589
- return /* @__PURE__ */ h("div", { className: `flex items-center justify-center h-full ${k}`, children: /* @__PURE__ */ h("p", { children: "No configuration provided" }) });
590
- const _t = S.width || c.canvas.width, qt = S.height || c.canvas.height;
591
- return /* @__PURE__ */ w(
590
+ if (!g)
591
+ return /* @__PURE__ */ p("div", { className: `flex items-center justify-center h-full ${w}`, children: /* @__PURE__ */ p("p", { children: "No configuration provided" }) });
592
+ const Jt = E.width || g.canvas.width, Qt = E.height || g.canvas.height;
593
+ return /* @__PURE__ */ k(
592
594
  "div",
593
595
  {
594
- ref: yt,
595
- className: `relative ${k}`,
596
+ ref: wt,
597
+ className: `relative ${w}`,
596
598
  style: { width: "100%", height: "100%" },
597
599
  children: [
598
- At && ut.length > 0 && /* @__PURE__ */ h(
599
- It,
600
+ Ht && bt.length > 0 && /* @__PURE__ */ p(
601
+ Tt,
600
602
  {
601
- floors: ut,
602
- currentFloorId: R,
603
- onFloorChange: jt,
604
- showAllOption: Q,
605
- allLabel: tt,
606
- position: K,
607
- className: J
603
+ floors: bt,
604
+ currentFloorId: X,
605
+ onFloorChange: Vt,
606
+ showAllOption: z,
607
+ allLabel: A,
608
+ position: I,
609
+ className: R
608
610
  }
609
611
  ),
610
- /* @__PURE__ */ w(
611
- te,
612
+ /* @__PURE__ */ k(
613
+ se,
612
614
  {
613
- ref: ht,
614
- width: _t,
615
- height: qt,
616
- scaleX: M,
617
- scaleY: M,
618
- x: I.x,
619
- y: I.y,
615
+ ref: gt,
616
+ width: Jt,
617
+ height: Qt,
618
+ scaleX: L,
619
+ scaleY: L,
620
+ x: N.x,
621
+ y: N.y,
620
622
  draggable: !0,
621
- onDragEnd: $t,
622
- onWheel: Ht,
623
- style: { backgroundColor: c.canvas.backgroundColor, cursor: "grab" },
623
+ onDragEnd: qt,
624
+ onWheel: Gt,
625
+ style: { backgroundColor: g.canvas.backgroundColor, cursor: "grab" },
624
626
  children: [
625
- /* @__PURE__ */ h(bt, { listening: !1, children: rt.map((t) => /* @__PURE__ */ h(
626
- kt,
627
+ /* @__PURE__ */ p(Et, { listening: !1, children: dt.map((t) => /* @__PURE__ */ p(
628
+ zt,
627
629
  {
628
630
  stage: t,
629
- stageColor: it.stageColor
631
+ stageColor: ut.stageColor
630
632
  },
631
633
  t.id
632
634
  )) }),
633
- /* @__PURE__ */ h(bt, { children: A.map((t) => /* @__PURE__ */ h(
634
- Mt,
635
+ /* @__PURE__ */ p(Et, { children: _.map((t) => /* @__PURE__ */ p(
636
+ Nt,
635
637
  {
636
638
  seat: t,
637
- state: q(t),
638
- colors: it,
639
- onClick: Bt,
640
- onMouseEnter: Ot,
641
- onMouseLeave: Vt
639
+ state: et(t),
640
+ colors: ut,
641
+ onClick: Ot,
642
+ onMouseEnter: Zt,
643
+ onMouseLeave: Kt
642
644
  },
643
645
  t.id
644
646
  )) })
645
647
  ]
646
648
  }
647
649
  ),
648
- g && /* @__PURE__ */ h(
649
- Dt,
650
+ d && /* @__PURE__ */ p(
651
+ Yt,
650
652
  {
651
- visible: O.visible,
652
- x: O.x,
653
- y: O.y,
654
- seat: O.seat,
655
- currency: it.currency,
656
- state: O.state
653
+ visible: J.visible,
654
+ x: J.x,
655
+ y: J.y,
656
+ seat: J.seat,
657
+ currency: ut.currency,
658
+ state: J.state
657
659
  }
658
660
  ),
659
- at && l && /* @__PURE__ */ h(
660
- Nt,
661
+ j && a && /* @__PURE__ */ p(
662
+ Xt,
661
663
  {
662
- scale: M,
663
- minScale: B,
664
- maxScale: L,
665
- onZoomIn: Ft,
666
- onZoomOut: zt,
667
- position: lt,
668
- className: Rt
664
+ scale: L,
665
+ minScale: q,
666
+ maxScale: T,
667
+ onZoomIn: Ut,
668
+ onZoomOut: _t,
669
+ position: st,
670
+ className: G
669
671
  }
670
672
  ),
671
- G.length > 0 && /* @__PURE__ */ w("div", { className: "absolute top-4 right-4 bg-white dark:bg-gray-800 p-4 rounded shadow-lg", children: [
672
- /* @__PURE__ */ w("h3", { className: "font-semibold mb-2", children: [
673
+ nt.length > 0 && /* @__PURE__ */ k("div", { className: "absolute top-4 right-4 bg-white dark:bg-gray-800 p-4 rounded shadow-lg", children: [
674
+ /* @__PURE__ */ k("h3", { className: "font-semibold mb-2", children: [
673
675
  "Selected Seats (",
674
- G.length,
676
+ nt.length,
675
677
  ")"
676
678
  ] }),
677
- /* @__PURE__ */ h("div", { className: "max-h-48 overflow-y-auto space-y-1", children: G.map((t) => /* @__PURE__ */ w("div", { className: "text-sm", children: [
679
+ /* @__PURE__ */ p("div", { className: "max-h-48 overflow-y-auto space-y-1", children: nt.map((t) => /* @__PURE__ */ k("div", { className: "text-sm", children: [
678
680
  t.seatNumber,
679
- t.price && ` - ${it.currency} ${t.price.toFixed(2)}`
681
+ t.price && ` - ${ut.currency} ${t.price.toFixed(2)}`
680
682
  ] }, t.id)) })
681
683
  ] })
682
684
  ]
683
685
  }
684
686
  );
685
687
  };
688
+ let rt = null;
689
+ function Ce(e) {
690
+ rt = e;
691
+ }
692
+ function St() {
693
+ if (!rt)
694
+ throw new Error(
695
+ "Firebase database not initialized. Call initializeFirebaseForViewer(db) first."
696
+ );
697
+ return rt;
698
+ }
699
+ function vt() {
700
+ return rt !== null;
701
+ }
702
+ function Me() {
703
+ rt = null;
704
+ }
705
+ function pe(e) {
706
+ const { seatMapId: n, enabled: s = !0, onStateChange: o, onError: h } = e, [f, l] = M(null), [m, u] = M(!0), [i, r] = M(null), [d, a] = M(null), [w, S] = M([]), [C, F] = M([]), I = W(o), R = W(h);
707
+ return I.current = o, R.current = h, Y(() => {
708
+ if (!s || !n) {
709
+ u(!1);
710
+ return;
711
+ }
712
+ if (!vt()) {
713
+ u(!1), r(new Error("Firebase not initialized. Call initializeFirebaseForViewer first."));
714
+ return;
715
+ }
716
+ const z = St(), A = mt(z, `seat_states/${n}`);
717
+ return u(!0), r(null), Lt(A, (j) => {
718
+ const G = j.val() || {};
719
+ l(G), u(!1), a(Date.now());
720
+ const Z = [], T = [];
721
+ Object.entries(G).forEach(([B, at]) => {
722
+ at === "reserved" ? Z.push(B) : at === "unavailable" && T.push(B);
723
+ }), S(Z), F(T), I.current?.(G);
724
+ }, (j) => {
725
+ r(j), u(!1), R.current?.(j);
726
+ }), () => {
727
+ Dt(A);
728
+ };
729
+ }, [n, s]), {
730
+ states: f,
731
+ loading: m,
732
+ error: i,
733
+ lastUpdated: d,
734
+ reservedSeats: w,
735
+ unavailableSeats: C
736
+ };
737
+ }
738
+ function be(e) {
739
+ const {
740
+ seatMapId: n,
741
+ enabled: s = !0,
742
+ subscribeToChanges: o = !1,
743
+ onConfigLoad: h,
744
+ onError: f
745
+ } = e, [l, m] = M(null), [u, i] = M(!0), [r, d] = M(null), a = W(h), w = W(f);
746
+ a.current = h, w.current = f;
747
+ const S = D(async () => {
748
+ if (!n) return;
749
+ if (!vt()) {
750
+ d(new Error("Firebase not initialized. Call initializeFirebaseForViewer first.")), i(!1);
751
+ return;
752
+ }
753
+ const C = St(), F = mt(C, `seatmaps/${n}`);
754
+ try {
755
+ i(!0), d(null);
756
+ const R = (await le(F)).val();
757
+ if (R) {
758
+ const z = ue(R);
759
+ m(z), a.current?.(z);
760
+ } else
761
+ d(new Error(`Seat map ${n} not found in Firebase`));
762
+ } catch (I) {
763
+ const R = I instanceof Error ? I : new Error("Unknown error");
764
+ d(R), w.current?.(R);
765
+ } finally {
766
+ i(!1);
767
+ }
768
+ }, [n]);
769
+ return Y(() => {
770
+ if (!s || !n) {
771
+ i(!1);
772
+ return;
773
+ }
774
+ if (S(), o && vt()) {
775
+ const C = St(), F = mt(C, `seatmaps/${n}/meta/updated_at`);
776
+ let I = !0;
777
+ return Lt(F, (z) => {
778
+ if (I) {
779
+ I = !1;
780
+ return;
781
+ }
782
+ z.exists() && S();
783
+ }), () => {
784
+ Dt(F);
785
+ };
786
+ }
787
+ }, [n, s, o, S]), {
788
+ config: l,
789
+ loading: u,
790
+ error: r,
791
+ refetch: S
792
+ };
793
+ }
794
+ function Ee(e) {
795
+ const {
796
+ seatMapId: n,
797
+ enabled: s = !0,
798
+ subscribeToDesignChanges: o = !1,
799
+ onConfigLoad: h,
800
+ onStateChange: f,
801
+ onError: l
802
+ } = e, {
803
+ config: m,
804
+ loading: u,
805
+ error: i,
806
+ refetch: r
807
+ } = be({
808
+ seatMapId: n,
809
+ enabled: s,
810
+ subscribeToChanges: o,
811
+ onConfigLoad: h,
812
+ onError: l
813
+ }), {
814
+ states: d,
815
+ loading: a,
816
+ error: w,
817
+ lastUpdated: S,
818
+ reservedSeats: C,
819
+ unavailableSeats: F
820
+ } = pe({
821
+ seatMapId: n,
822
+ enabled: s,
823
+ onStateChange: f,
824
+ onError: l
825
+ });
826
+ return {
827
+ config: m,
828
+ loading: u || a,
829
+ error: i || w,
830
+ reservedSeats: C,
831
+ unavailableSeats: F,
832
+ seatStates: d,
833
+ lastUpdated: S,
834
+ refetch: r
835
+ };
836
+ }
686
837
  export {
687
- se as DEFAULT_COLORS,
688
- he as SeatMapViewer,
689
- oe as useConfigFetcher,
690
- ie as useContainerSize,
691
- re as useTouchGestures
838
+ ge as DEFAULT_COLORS,
839
+ we as SeatMapViewer,
840
+ Me as clearFirebaseInstance,
841
+ Ce as initializeFirebaseForViewer,
842
+ vt as isFirebaseInitialized,
843
+ de as useConfigFetcher,
844
+ he as useContainerSize,
845
+ be as useFirebaseConfig,
846
+ pe as useFirebaseSeatStates,
847
+ Ee as useRealtimeSeatMap,
848
+ fe as useTouchGestures
692
849
  };