@zonetrix/viewer 2.11.1 → 2.11.2

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,101 +1,116 @@
1
- import { jsx as u, jsxs as D } from "react/jsx-runtime";
2
- import { useState as k, useEffect as B, useRef as X, useCallback as z, useMemo as A, memo as J, useSyncExternalStore as gt } from "react";
3
- import { Stage as pt, Layer as ye, Group as bt, Text as Te, Circle as ze, Rect as De, Path as vt, RegularPolygon as yt } from "react-konva";
4
- import { ref as Se, onValue as Ne, off as $e, get as mt } from "firebase/database";
1
+ import { jsx as f, jsxs as D } from "react/jsx-runtime";
2
+ import { useState as W, useCallback as T, useEffect as U, useRef as P, useMemo as B, memo as Q, useSyncExternalStore as gt } from "react";
3
+ import { Stage as pt, Layer as we, Group as bt, Text as Ne, Circle as $e, Rect as ke, Path as vt, RegularPolygon as yt } from "react-konva";
4
+ import { ref as Re, onValue as We, off as Xe, get as mt } from "firebase/database";
5
5
  import { fromFirebaseSeatMap as St } from "@zonetrix/shared";
6
6
  function xt(n) {
7
- const [r, t] = k(null), [o, d] = k(!1), [l, i] = k(null), S = async () => {
7
+ const [o, t] = W(null), [r, d] = W(!1), [c, s] = W(null), v = T(async () => {
8
8
  if (n) {
9
- d(!0), i(null);
9
+ d(!0), s(null);
10
10
  try {
11
- const p = await fetch(n);
12
- if (!p.ok)
13
- throw new Error(`Failed to fetch config: ${p.statusText}`);
14
- const s = await p.json();
15
- t(s);
16
- } catch (p) {
17
- const s = p instanceof Error ? p : new Error("Unknown error occurred");
18
- i(s), console.error("Failed to fetch seat map config:", s);
11
+ const h = await fetch(n);
12
+ if (!h.ok)
13
+ throw new Error(`Failed to fetch config: ${h.statusText}`);
14
+ const i = await h.json();
15
+ t(i);
16
+ } catch (h) {
17
+ const i = h instanceof Error ? h : new Error("Unknown error occurred");
18
+ s(i), console.error("Failed to fetch seat map config:", i);
19
19
  } finally {
20
20
  d(!1);
21
21
  }
22
22
  }
23
- };
24
- return B(() => {
25
- S();
26
- }, [n]), {
27
- config: r,
28
- loading: o,
29
- error: l,
30
- refetch: S
23
+ }, [n]);
24
+ return U(() => {
25
+ v();
26
+ }, [v]), {
27
+ config: o,
28
+ loading: r,
29
+ error: c,
30
+ refetch: v
31
31
  };
32
32
  }
33
33
  function wt(n) {
34
- const [r, t] = k({ width: 0, height: 0 });
35
- return B(() => {
36
- const o = n.current;
37
- if (!o) return;
38
- const { width: d, height: l } = o.getBoundingClientRect();
39
- d > 0 && l > 0 && t({ width: d, height: l });
40
- const i = new ResizeObserver((S) => {
41
- const p = S[0];
42
- if (!p) return;
43
- const { width: s, height: a } = p.contentRect;
44
- s > 0 && a > 0 && t((f) => f.width === s && f.height === a ? f : { width: s, height: a });
34
+ const [o, t] = W({ width: 0, height: 0 });
35
+ return U(() => {
36
+ const r = n.current;
37
+ if (!r) return;
38
+ const { width: d, height: c } = r.getBoundingClientRect();
39
+ d > 0 && c > 0 && t({ width: d, height: c });
40
+ const s = new ResizeObserver((v) => {
41
+ const h = v[0];
42
+ if (!h) return;
43
+ const { width: i, height: b } = h.contentRect;
44
+ i > 0 && b > 0 && t((y) => y.width === i && y.height === b ? y : { width: i, height: b });
45
45
  });
46
- return i.observe(o), () => {
47
- i.disconnect();
46
+ return s.observe(r), () => {
47
+ s.disconnect();
48
48
  };
49
- }, [n]), r;
49
+ }, [n]), o;
50
50
  }
51
- function Fe(n, r) {
52
- return Math.sqrt(Math.pow(r.x - n.x, 2) + Math.pow(r.y - n.y, 2));
51
+ function ze(n, o) {
52
+ return Math.sqrt(Math.pow(o.x - n.x, 2) + Math.pow(o.y - n.y, 2));
53
53
  }
54
- function Le(n, r) {
54
+ function De(n, o) {
55
55
  return {
56
- x: (n.x + r.x) / 2,
57
- y: (n.y + r.y) / 2
56
+ x: (n.x + o.x) / 2,
57
+ y: (n.y + o.y) / 2
58
58
  };
59
59
  }
60
- function Ct(n, r) {
61
- const t = X(null), o = X(null), d = X(1);
62
- B(() => {
63
- const l = n.current;
64
- if (!l || !r.enabled) return;
65
- const i = l.container(), S = (a) => {
66
- if (a.touches.length === 2) {
67
- a.preventDefault();
68
- const f = { x: a.touches[0].clientX, y: a.touches[0].clientY }, b = { x: a.touches[1].clientX, y: a.touches[1].clientY };
69
- t.current = Fe(f, b), o.current = Le(f, b), d.current = r.currentScale;
60
+ function Ct(n, o) {
61
+ const t = P(null), r = P(null), d = P(1), {
62
+ enabled: c,
63
+ minScale: s,
64
+ maxScale: v,
65
+ currentScale: h,
66
+ currentPosition: i,
67
+ onScaleChange: b
68
+ } = o;
69
+ U(() => {
70
+ const y = n.current;
71
+ if (!y || !c) return;
72
+ const u = y.container(), w = (g) => {
73
+ if (g.touches.length === 2) {
74
+ g.preventDefault();
75
+ const I = { x: g.touches[0].clientX, y: g.touches[0].clientY }, R = { x: g.touches[1].clientX, y: g.touches[1].clientY };
76
+ t.current = ze(I, R), r.current = De(I, R), d.current = h;
70
77
  }
71
- }, p = (a) => {
72
- if (a.touches.length !== 2) return;
73
- a.preventDefault();
74
- const f = { x: a.touches[0].clientX, y: a.touches[0].clientY }, b = { x: a.touches[1].clientX, y: a.touches[1].clientY }, x = Fe(f, b), g = Le(f, b);
75
- if (t.current !== null && o.current !== null) {
76
- const C = x / t.current, E = Math.min(
77
- Math.max(r.currentScale * C, r.minScale),
78
- r.maxScale
79
- ), F = i.getBoundingClientRect(), R = g.x - F.left, I = g.y - F.top, M = r.currentScale, L = {
80
- x: (R - r.currentPosition.x) / M,
81
- y: (I - r.currentPosition.y) / M
82
- }, W = g.x - o.current.x, Y = g.y - o.current.y, _ = {
83
- x: R - L.x * E + W,
84
- y: I - L.y * E + Y
78
+ }, m = (g) => {
79
+ if (g.touches.length !== 2) return;
80
+ g.preventDefault();
81
+ const I = { x: g.touches[0].clientX, y: g.touches[0].clientY }, R = { x: g.touches[1].clientX, y: g.touches[1].clientY }, F = ze(I, R), E = De(I, R);
82
+ if (t.current !== null && r.current !== null) {
83
+ const L = F / t.current, N = Math.min(
84
+ Math.max(h * L, s),
85
+ v
86
+ ), Y = u.getBoundingClientRect(), V = E.x - Y.left, se = E.y - Y.top, ae = h, ce = {
87
+ x: (V - i.x) / ae,
88
+ y: (se - i.y) / ae
89
+ }, le = E.x - r.current.x, A = E.y - r.current.y, _ = {
90
+ x: V - ce.x * N + le,
91
+ y: se - ce.y * N + A
85
92
  };
86
- r.onScaleChange(E, _), t.current = x, o.current = g;
93
+ b(N, _), t.current = F, r.current = E;
87
94
  }
88
- }, s = (a) => {
89
- a.touches.length < 2 && (t.current = null, o.current = null);
95
+ }, M = (g) => {
96
+ g.touches.length < 2 && (t.current = null, r.current = null);
90
97
  };
91
- return i.addEventListener("touchstart", S, {
98
+ return u.addEventListener("touchstart", w, {
92
99
  passive: !1
93
- }), i.addEventListener("touchmove", p, {
100
+ }), u.addEventListener("touchmove", m, {
94
101
  passive: !1
95
- }), i.addEventListener("touchend", s), () => {
96
- i.removeEventListener("touchstart", S), i.removeEventListener("touchmove", p), i.removeEventListener("touchend", s);
102
+ }), u.addEventListener("touchend", M), () => {
103
+ u.removeEventListener("touchstart", w), u.removeEventListener("touchmove", m), u.removeEventListener("touchend", M);
97
104
  };
98
- }, [n, r]);
105
+ }, [
106
+ n,
107
+ c,
108
+ s,
109
+ v,
110
+ h,
111
+ i,
112
+ b
113
+ ]);
99
114
  }
100
115
  const Rt = {
101
116
  canvasBackground: "#1a1a1a",
@@ -107,46 +122,46 @@ const Rt = {
107
122
  seatHidden: "#4a4a4a",
108
123
  gridLines: "#404040",
109
124
  currency: "KD"
110
- }, ke = J(
111
- ({ seat: n, state: r, colors: t, onClick: o, onMouseEnter: d, onMouseLeave: l }) => {
112
- const p = {
125
+ }, Pe = Q(
126
+ ({ seat: n, state: o, colors: t, onClick: r, onMouseEnter: d, onMouseLeave: c }) => {
127
+ const h = {
113
128
  available: t.seatAvailable,
114
129
  reserved: t.seatReserved,
115
130
  selected: t.seatSelected,
116
131
  unavailable: t.seatUnavailable,
117
132
  hidden: t.seatHidden
118
133
  // Hidden seats are filtered out, but included for type safety
119
- }[r], s = r === "available" || r === "selected", a = z(() => {
120
- s && o(n);
121
- }, [n, o, s]), f = z(
122
- (g) => {
123
- d(n, g);
124
- const C = g.target.getStage();
125
- C && s && (C.container().style.cursor = "pointer");
134
+ }[o], i = o === "available" || o === "selected", b = T(() => {
135
+ i && r(n);
136
+ }, [n, r, i]), y = T(
137
+ (m) => {
138
+ d(n, m);
139
+ const M = m.target.getStage();
140
+ M && i && (M.container().style.cursor = "pointer");
126
141
  },
127
- [n, d, s]
128
- ), b = z(
129
- (g) => {
130
- l();
131
- const C = g.target.getStage();
132
- C && (C.container().style.cursor = "grab");
142
+ [n, d, i]
143
+ ), u = T(
144
+ (m) => {
145
+ c();
146
+ const M = m.target.getStage();
147
+ M && (M.container().style.cursor = "grab");
133
148
  },
134
- [l]
135
- ), x = {
149
+ [c]
150
+ ), w = {
136
151
  x: n.position.x,
137
152
  y: n.position.y,
138
- fill: p,
153
+ fill: h,
139
154
  stroke: "#ffffff",
140
155
  strokeWidth: 1,
141
- onClick: a,
142
- onTap: a,
143
- onMouseEnter: f,
144
- onMouseLeave: b
156
+ onClick: b,
157
+ onTap: b,
158
+ onMouseEnter: y,
159
+ onMouseLeave: u
145
160
  };
146
- return n.shape === "circle" ? /* @__PURE__ */ u(ze, { ...x, radius: 12 }) : /* @__PURE__ */ u(
147
- De,
161
+ return n.shape === "circle" ? /* @__PURE__ */ f($e, { ...w, radius: 12 }) : /* @__PURE__ */ f(
162
+ ke,
148
163
  {
149
- ...x,
164
+ ...w,
150
165
  width: 24,
151
166
  height: 24,
152
167
  offsetX: 12,
@@ -156,55 +171,55 @@ const Rt = {
156
171
  );
157
172
  }
158
173
  );
159
- ke.displayName = "ViewerSeat";
160
- const We = J(({ stage: n, stageColor: r }) => {
161
- const t = n.config, o = t.shape || "rectangle", d = t.showLabel !== !1, l = t.color || r, i = t.width / t.height, S = i < 0.5, p = i > 2;
162
- let s;
163
- S ? s = t.width * 0.25 : p ? s = t.height * 0.35 : s = Math.min(t.width, t.height) * 0.25;
164
- const a = t.label?.length || 6, x = t.width * 0.85 / a * 1.5, g = Math.max(
174
+ Pe.displayName = "ViewerSeat";
175
+ const Ye = Q(({ stage: n, stageColor: o }) => {
176
+ const t = n.config, r = t.shape || "rectangle", d = t.showLabel !== !1, c = t.color || o, s = t.width / t.height, v = s < 0.5, h = s > 2;
177
+ let i;
178
+ v ? i = t.width * 0.25 : h ? i = t.height * 0.35 : i = Math.min(t.width, t.height) * 0.25;
179
+ const b = t.label?.length || 6, w = t.width * 0.85 / b * 1.5, m = Math.max(
165
180
  10,
166
- Math.min(24, Math.min(s, x))
167
- ), C = 4, E = Math.max(20, t.width - C * 2), F = (t.width - E) / 2, R = {
168
- fill: l + "80",
181
+ Math.min(24, Math.min(i, w))
182
+ ), M = 4, g = Math.max(20, t.width - M * 2), I = (t.width - g) / 2, R = {
183
+ fill: c + "80",
169
184
  stroke: "#ffffff",
170
185
  strokeWidth: 2,
171
186
  perfectDrawEnabled: !1,
172
187
  hitStrokeWidth: 0
173
- }, I = () => {
174
- switch (o) {
188
+ }, F = () => {
189
+ switch (r) {
175
190
  case "circle": {
176
- const M = Math.min(t.width, t.height) / 2;
177
- return /* @__PURE__ */ u(
178
- ze,
191
+ const E = Math.min(t.width, t.height) / 2;
192
+ return /* @__PURE__ */ f(
193
+ $e,
179
194
  {
180
195
  x: t.width / 2,
181
196
  y: t.height / 2,
182
- radius: M,
197
+ radius: E,
183
198
  ...R
184
199
  }
185
200
  );
186
201
  }
187
202
  case "triangle": {
188
- const M = Math.min(t.width, t.height) / 2;
189
- return /* @__PURE__ */ u(
203
+ const E = Math.min(t.width, t.height) / 2;
204
+ return /* @__PURE__ */ f(
190
205
  yt,
191
206
  {
192
207
  x: t.width / 2,
193
208
  y: t.height / 2,
194
209
  sides: 3,
195
- radius: M,
210
+ radius: E,
196
211
  rotation: -90,
197
212
  ...R
198
213
  }
199
214
  );
200
215
  }
201
216
  case "arrow": {
202
- const M = t.width / 24, L = t.height / 24, W = `M${9 * M},${18 * L} v${-8 * L} H${5 * M} l${7 * M},${-7 * L} l${7 * M},${7 * L} h${-4 * M} v${8 * L} Z`;
203
- return /* @__PURE__ */ u(vt, { data: W, ...R });
217
+ const E = t.width / 24, L = t.height / 24, N = `M${9 * E},${18 * L} v${-8 * L} H${5 * E} l${7 * E},${-7 * L} l${7 * E},${7 * L} h${-4 * E} v${8 * L} Z`;
218
+ return /* @__PURE__ */ f(vt, { data: N, ...R });
204
219
  }
205
220
  default:
206
- return /* @__PURE__ */ u(
207
- De,
221
+ return /* @__PURE__ */ f(
222
+ ke,
208
223
  {
209
224
  width: t.width,
210
225
  height: t.height,
@@ -221,16 +236,16 @@ const We = J(({ stage: n, stageColor: r }) => {
221
236
  y: n.position.y,
222
237
  rotation: t.rotation || 0,
223
238
  children: [
224
- I(),
225
- d && /* @__PURE__ */ u(
226
- Te,
239
+ F(),
240
+ d && /* @__PURE__ */ f(
241
+ Ne,
227
242
  {
228
243
  text: t.label,
229
- x: F,
230
- y: C,
231
- width: E,
232
- height: t.height - C * 2,
233
- fontSize: g,
244
+ x: I,
245
+ y: M,
246
+ width: g,
247
+ height: t.height - M * 2,
248
+ fontSize: m,
234
249
  fontStyle: "bold",
235
250
  fill: "#ffffff",
236
251
  align: "center",
@@ -243,9 +258,9 @@ const We = J(({ stage: n, stageColor: r }) => {
243
258
  }
244
259
  );
245
260
  });
246
- We.displayName = "ViewerStage";
247
- const Pe = J(({ text: n }) => /* @__PURE__ */ u(
248
- Te,
261
+ Ye.displayName = "ViewerStage";
262
+ const Ae = Q(({ text: n }) => /* @__PURE__ */ f(
263
+ Ne,
249
264
  {
250
265
  x: n.position.x,
251
266
  y: n.position.y,
@@ -256,21 +271,21 @@ const Pe = J(({ text: n }) => /* @__PURE__ */ u(
256
271
  listening: !1
257
272
  }
258
273
  ));
259
- Pe.displayName = "ViewerText";
260
- const Xe = J(
274
+ Ae.displayName = "ViewerText";
275
+ const Be = Q(
261
276
  ({
262
277
  floors: n,
263
- currentFloorId: r,
278
+ currentFloorId: o,
264
279
  onFloorChange: t,
265
- showAllOption: o,
280
+ showAllOption: r,
266
281
  allLabel: d,
267
- position: l,
268
- className: i
282
+ position: c,
283
+ className: s
269
284
  }) => {
270
- const S = A(
271
- () => [...n].sort((b, x) => b.order - x.order),
285
+ const v = B(
286
+ () => [...n].sort((u, w) => u.order - w.order),
272
287
  [n]
273
- ), s = {
288
+ ), i = {
274
289
  position: "absolute",
275
290
  display: "flex",
276
291
  alignItems: "center",
@@ -285,8 +300,8 @@ const Xe = J(
285
300
  "top-right": { top: 0, right: 0 },
286
301
  "bottom-left": { bottom: 0, left: 0 },
287
302
  "bottom-right": { bottom: 0, right: 0 }
288
- }[l]
289
- }, a = {
303
+ }[c]
304
+ }, b = {
290
305
  padding: "10px 16px",
291
306
  fontSize: "14px",
292
307
  fontWeight: 500,
@@ -298,38 +313,38 @@ const Xe = J(
298
313
  transition: "all 0.2s ease",
299
314
  minHeight: "44px",
300
315
  touchAction: "manipulation"
301
- }, f = {
302
- ...a,
316
+ }, y = {
317
+ ...b,
303
318
  backgroundColor: "#3A7DE5",
304
319
  borderColor: "#3A7DE5"
305
320
  };
306
- return /* @__PURE__ */ D("div", { className: i, style: s, children: [
307
- o && /* @__PURE__ */ u(
321
+ return /* @__PURE__ */ D("div", { className: s, style: i, children: [
322
+ r && /* @__PURE__ */ f(
308
323
  "button",
309
324
  {
310
325
  type: "button",
311
326
  onClick: () => t(null),
312
- style: r === null ? f : a,
327
+ style: o === null ? y : b,
313
328
  children: d
314
329
  }
315
330
  ),
316
- S.map((b) => /* @__PURE__ */ u(
331
+ v.map((u) => /* @__PURE__ */ f(
317
332
  "button",
318
333
  {
319
334
  type: "button",
320
- onClick: () => t(b.id),
321
- style: r === b.id ? f : a,
322
- children: b.name
335
+ onClick: () => t(u.id),
336
+ style: o === u.id ? y : b,
337
+ children: u.name
323
338
  },
324
- b.id
339
+ u.id
325
340
  ))
326
341
  ] });
327
342
  }
328
343
  );
329
- Xe.displayName = "FloorSelectorBar";
330
- const Ye = J(
331
- ({ scale: n, minScale: r, maxScale: t, onZoomIn: o, onZoomOut: d, position: l, className: i }) => {
332
- const p = {
344
+ Be.displayName = "FloorSelectorBar";
345
+ const Ue = Q(
346
+ ({ scale: n, minScale: o, maxScale: t, onZoomIn: r, onZoomOut: d, position: c, className: s }) => {
347
+ const h = {
333
348
  position: "absolute",
334
349
  display: "flex",
335
350
  flexDirection: "column",
@@ -344,8 +359,8 @@ const Ye = J(
344
359
  "top-right": { top: 0, right: 0 },
345
360
  "bottom-left": { bottom: 0, left: 0 },
346
361
  "bottom-right": { bottom: 0, right: 0 }
347
- }[l]
348
- }, s = {
362
+ }[c]
363
+ }, i = {
349
364
  width: "44px",
350
365
  height: "44px",
351
366
  minWidth: "44px",
@@ -362,30 +377,30 @@ const Ye = J(
362
377
  justifyContent: "center",
363
378
  transition: "all 0.2s ease",
364
379
  touchAction: "manipulation"
365
- }, a = {
366
- ...s,
380
+ }, b = {
381
+ ...i,
367
382
  opacity: 0.4,
368
383
  cursor: "not-allowed"
369
- }, f = n < t, b = n > r;
370
- return /* @__PURE__ */ D("div", { className: i, style: p, children: [
371
- /* @__PURE__ */ u(
384
+ }, y = n < t, u = n > o;
385
+ return /* @__PURE__ */ D("div", { className: s, style: h, children: [
386
+ /* @__PURE__ */ f(
372
387
  "button",
373
388
  {
374
389
  type: "button",
375
- onClick: o,
376
- disabled: !f,
377
- style: f ? s : a,
390
+ onClick: r,
391
+ disabled: !y,
392
+ style: y ? i : b,
378
393
  title: "Zoom In",
379
394
  children: "+"
380
395
  }
381
396
  ),
382
- /* @__PURE__ */ u(
397
+ /* @__PURE__ */ f(
383
398
  "button",
384
399
  {
385
400
  type: "button",
386
401
  onClick: d,
387
- disabled: !b,
388
- style: b ? s : a,
402
+ disabled: !u,
403
+ style: u ? i : b,
389
404
  title: "Zoom Out",
390
405
  children: "−"
391
406
  }
@@ -393,17 +408,17 @@ const Ye = J(
393
408
  ] });
394
409
  }
395
410
  );
396
- Ye.displayName = "ZoomControls";
397
- const Ae = J(
398
- ({ visible: n, x: r, y: t, seat: o, currency: d, state: l }) => {
399
- if (!n || !o) return null;
400
- const i = o.seatNumber || (o.rowLabel && o.columnLabel ? `${o.rowLabel}-${o.columnLabel}` : "N/A"), S = {
411
+ Ue.displayName = "ZoomControls";
412
+ const He = Q(
413
+ ({ visible: n, x: o, y: t, seat: r, currency: d, state: c }) => {
414
+ if (!n || !r) return null;
415
+ const s = r.seatNumber || (r.rowLabel && r.columnLabel ? `${r.rowLabel}-${r.columnLabel}` : "N/A"), v = {
401
416
  position: "fixed",
402
- left: `${r + 15}px`,
417
+ left: `${o + 15}px`,
403
418
  top: `${t + 15}px`,
404
419
  zIndex: 1e3,
405
420
  pointerEvents: "none"
406
- }, p = {
421
+ }, h = {
407
422
  backgroundColor: "rgba(26, 26, 26, 0.95)",
408
423
  color: "#fff",
409
424
  border: "1px solid #444",
@@ -412,337 +427,334 @@ const Ae = J(
412
427
  fontSize: "13px",
413
428
  boxShadow: "0 4px 12px rgba(0, 0, 0, 0.3)",
414
429
  minWidth: "140px"
415
- }, s = {
430
+ }, i = {
416
431
  color: "#9ca3af",
417
432
  marginRight: "4px"
418
- }, a = {
433
+ }, b = {
419
434
  fontWeight: 600
420
- }, f = {
435
+ }, y = {
421
436
  color: "#4ade80",
422
437
  fontWeight: 600
423
- }, b = {
438
+ }, u = {
424
439
  fontSize: "11px",
425
440
  color: "#6b7280",
426
441
  textTransform: "capitalize",
427
442
  marginTop: "4px"
428
443
  };
429
- return /* @__PURE__ */ u("div", { style: S, children: /* @__PURE__ */ D("div", { style: p, children: [
430
- o.sectionName && /* @__PURE__ */ D("div", { style: { marginBottom: "4px" }, children: [
431
- /* @__PURE__ */ u("span", { style: s, children: "Section:" }),
432
- /* @__PURE__ */ u("span", { style: { ...a, color: "#3b82f6" }, children: o.sectionName })
444
+ return /* @__PURE__ */ f("div", { style: v, children: /* @__PURE__ */ D("div", { style: h, children: [
445
+ r.sectionName && /* @__PURE__ */ D("div", { style: { marginBottom: "4px" }, children: [
446
+ /* @__PURE__ */ f("span", { style: i, children: "Section:" }),
447
+ /* @__PURE__ */ f("span", { style: { ...b, color: "#3b82f6" }, children: r.sectionName })
433
448
  ] }),
434
449
  /* @__PURE__ */ D("div", { style: { marginBottom: "4px" }, children: [
435
- /* @__PURE__ */ u("span", { style: s, children: "Seat:" }),
436
- /* @__PURE__ */ u("span", { style: a, children: i })
450
+ /* @__PURE__ */ f("span", { style: i, children: "Seat:" }),
451
+ /* @__PURE__ */ f("span", { style: b, children: s })
437
452
  ] }),
438
- o.price !== void 0 && o.price > 0 && l === "available" && /* @__PURE__ */ D("div", { style: { marginBottom: "4px" }, children: [
439
- /* @__PURE__ */ u("span", { style: s, children: "Price:" }),
440
- /* @__PURE__ */ D("span", { style: f, children: [
453
+ r.price !== void 0 && r.price > 0 && c === "available" && /* @__PURE__ */ D("div", { style: { marginBottom: "4px" }, children: [
454
+ /* @__PURE__ */ f("span", { style: i, children: "Price:" }),
455
+ /* @__PURE__ */ D("span", { style: y, children: [
441
456
  d,
442
457
  " ",
443
- o.price.toFixed(2)
458
+ r.price.toFixed(2)
444
459
  ] })
445
460
  ] }),
446
- /* @__PURE__ */ D("div", { style: b, children: [
461
+ /* @__PURE__ */ D("div", { style: u, children: [
447
462
  "Status: ",
448
- l
463
+ c
449
464
  ] })
450
465
  ] }) });
451
466
  }
452
467
  );
453
- Ae.displayName = "SeatTooltip";
468
+ He.displayName = "SeatTooltip";
454
469
  const Nt = ({
455
470
  config: n,
456
- configUrl: r,
471
+ configUrl: o,
457
472
  floorId: t,
458
- onFloorChange: o,
473
+ onFloorChange: r,
459
474
  reservedSeats: d = [],
460
- otherReservedSeats: l,
475
+ otherReservedSeats: c,
461
476
  // v2.4.0: New prop name (preferred)
462
- unavailableSeats: i = [],
463
- selectedSeats: S,
464
- myReservedSeats: p = [],
465
- onSeatSelect: s,
466
- onSeatDeselect: a,
467
- onSelectionChange: f,
468
- colorOverrides: b,
469
- showTooltip: x = !0,
470
- zoomEnabled: g = !0,
471
- className: C = "",
472
- onConfigLoad: E,
473
- onError: F,
477
+ unavailableSeats: s = [],
478
+ selectedSeats: v,
479
+ myReservedSeats: h = [],
480
+ onSeatSelect: i,
481
+ onSeatDeselect: b,
482
+ onSelectionChange: y,
483
+ colorOverrides: u,
484
+ showTooltip: w = !0,
485
+ zoomEnabled: m = !0,
486
+ className: M = "",
487
+ onConfigLoad: g,
488
+ onError: I,
474
489
  // Floor selector props
475
490
  showFloorSelector: R,
476
- floorSelectorPosition: I = "top-left",
477
- floorSelectorClassName: M,
491
+ floorSelectorPosition: F = "top-left",
492
+ floorSelectorClassName: E,
478
493
  showAllFloorsOption: L = !0,
479
- allFloorsLabel: W = "All",
494
+ allFloorsLabel: N = "All",
480
495
  fitToView: Y = !0,
481
- fitPadding: _ = 40,
496
+ fitPadding: V = 40,
482
497
  // Zoom controls
483
- showZoomControls: Be = !0,
484
- zoomControlsPosition: Ue = "bottom-right",
485
- zoomControlsClassName: He,
486
- minZoom: Ce,
487
- maxZoom: U = 3,
488
- zoomStep: ie = 0.25,
498
+ showZoomControls: se = !0,
499
+ zoomControlsPosition: ae = "bottom-right",
500
+ zoomControlsClassName: ce,
501
+ minZoom: le,
502
+ maxZoom: A = 3,
503
+ zoomStep: _ = 0.25,
489
504
  // Touch gestures
490
505
  touchEnabled: Ve = !0
491
506
  }) => {
492
- const Re = l !== void 0 ? l : d, fe = X(null), Me = X(null), T = wt(Me), [q, Ee] = k(
507
+ const Ie = c !== void 0 ? c : d, ve = P(null), Fe = P(null), z = wt(Fe), [q, Le] = W(
493
508
  /* @__PURE__ */ new Set()
494
- ), [N, Q] = k(1), [P, V] = k({ x: 0, y: 0 }), [Oe, je] = k(null), [_e, qe] = k(1), se = X({ width: 0, height: 0 }), [ee, Ie] = k({ visible: !1, x: 0, y: 0, seat: null, state: "available" }), { config: Ze, loading: Ge, error: te } = xt(r), h = n || Ze, ge = t !== void 0, $ = ge ? t || null : Oe, ae = S !== void 0, Ke = z(
509
+ ), [$, ee] = W(1), [X, Z] = W({ x: 0, y: 0 }), [Oe, je] = W(null), [_e, qe] = W(1), de = P({ width: 0, height: 0 }), [te, Te] = W({ visible: !1, x: 0, y: 0, seat: null, state: "available" }), { config: Ze, loading: Ge, error: ne } = xt(o), l = n || Ze, ye = t !== void 0, k = ye ? t || null : Oe, he = v !== void 0, Ke = T(
495
510
  (e) => {
496
- ge || je(e), o?.(e);
511
+ ye || je(e), r?.(e);
497
512
  },
498
- [ge, o]
499
- ), pe = h?.floors || [], Je = R !== void 0 ? R : pe.length > 1, ce = A(
500
- () => h ? { ...h.colors, ...b } : { ...Rt, ...b },
501
- [h, b]
502
- ), Z = A(() => {
503
- if (!h) return [];
504
- let e = h.seats.filter((c) => c.state !== "hidden");
505
- return $ && (e = e.filter(
506
- (c) => c.floorId === $ || !c.floorId && $ === "floor_default"
513
+ [ye, r]
514
+ ), me = l?.floors || [], Je = R !== void 0 ? R : me.length > 1, ue = B(
515
+ () => l ? { ...l.colors, ...u } : { ...Rt, ...u },
516
+ [l, u]
517
+ ), G = B(() => {
518
+ if (!l) return [];
519
+ let e = l.seats.filter((a) => a.state !== "hidden");
520
+ return k && (e = e.filter(
521
+ (a) => a.floorId === k || !a.floorId && k === "floor_default"
507
522
  )), e;
508
- }, [h, $]), le = A(() => h?.stages ? $ ? h.stages.filter(
509
- (e) => e.floorId === $ || !e.floorId && $ === "floor_default"
510
- ) : h.stages : [], [h, $]), de = A(() => h?.texts ? $ ? h.texts.filter(
511
- (e) => e.floorId === $ || !e.floorId && $ === "floor_default"
512
- ) : h.texts : [], [h, $]), H = A(() => {
513
- if (!h || Z.length === 0 && le.length === 0 && de.length === 0)
523
+ }, [l, k]), fe = B(() => l?.stages ? k ? l.stages.filter(
524
+ (e) => e.floorId === k || !e.floorId && k === "floor_default"
525
+ ) : l.stages : [], [l, k]), ge = B(() => l?.texts ? k ? l.texts.filter(
526
+ (e) => e.floorId === k || !e.floorId && k === "floor_default"
527
+ ) : l.texts : [], [l, k]), H = B(() => {
528
+ if (!l || G.length === 0 && fe.length === 0 && ge.length === 0)
514
529
  return null;
515
530
  const e = 12;
516
- let c = 1 / 0, v = 1 / 0, y = -1 / 0, w = -1 / 0;
517
- return Z.forEach((m) => {
518
- c = Math.min(c, m.position.x - e), v = Math.min(v, m.position.y - e), y = Math.max(y, m.position.x + e), w = Math.max(w, m.position.y + e);
519
- }), le.forEach((m) => {
520
- c = Math.min(c, m.position.x), v = Math.min(v, m.position.y), y = Math.max(y, m.position.x + (m.config?.width || 200)), w = Math.max(w, m.position.y + (m.config?.height || 100));
521
- }), de.forEach((m) => {
522
- const j = m.config.text.length * m.config.fontSize * 0.6, K = m.config.fontSize;
523
- c = Math.min(c, m.position.x), v = Math.min(v, m.position.y), y = Math.max(y, m.position.x + j), w = Math.max(w, m.position.y + K);
524
- }), { minX: c, minY: v, maxX: y, maxY: w, width: y - c, height: w - v };
525
- }, [h, Z, le, de]);
526
- B(() => {
527
- if (!Y || !h || !H || T.width === 0 || T.height === 0) return;
531
+ let a = 1 / 0, p = 1 / 0, S = -1 / 0, C = -1 / 0;
532
+ return G.forEach((x) => {
533
+ a = Math.min(a, x.position.x - e), p = Math.min(p, x.position.y - e), S = Math.max(S, x.position.x + e), C = Math.max(C, x.position.y + e);
534
+ }), fe.forEach((x) => {
535
+ a = Math.min(a, x.position.x), p = Math.min(p, x.position.y), S = Math.max(S, x.position.x + (x.config?.width || 200)), C = Math.max(C, x.position.y + (x.config?.height || 100));
536
+ }), ge.forEach((x) => {
537
+ const j = x.config.text.length * x.config.fontSize * 0.6, J = x.config.fontSize;
538
+ a = Math.min(a, x.position.x), p = Math.min(p, x.position.y), S = Math.max(S, x.position.x + j), C = Math.max(C, x.position.y + J);
539
+ }), { minX: a, minY: p, maxX: S, maxY: C, width: S - a, height: C - p };
540
+ }, [l, G, fe, ge]);
541
+ U(() => {
542
+ if (!Y || !l || !H || z.width === 0 || z.height === 0) return;
528
543
  const e = Math.abs(
529
- T.width - se.current.width
530
- ), c = Math.abs(
531
- T.height - se.current.height
544
+ z.width - de.current.width
545
+ ), a = Math.abs(
546
+ z.height - de.current.height
532
547
  );
533
- if (!(se.current.width === 0) && e < 10 && c < 10) return;
534
- se.current = T;
535
- const y = T.width, w = T.height, m = y - _ * 2, j = w - _ * 2, K = m / H.width, ve = j / H.height, he = Math.min(K, ve, U), ct = H.minX + H.width / 2, lt = H.minY + H.height / 2, dt = y / 2, ht = w / 2, ut = dt - ct * he, ft = ht - lt * he;
536
- Q(he), V({ x: ut, y: ft }), qe(he);
548
+ if (!(de.current.width === 0) && e < 10 && a < 10) return;
549
+ de.current = z;
550
+ const S = z.width, C = z.height, x = S - V * 2, j = C - V * 2, J = x / H.width, xe = j / H.height, pe = Math.min(J, xe, A), ct = H.minX + H.width / 2, lt = H.minY + H.height / 2, dt = S / 2, ht = C / 2, ut = dt - ct * pe, ft = ht - lt * pe;
551
+ ee(pe), Z({ x: ut, y: ft }), qe(pe);
537
552
  }, [
538
553
  Y,
539
- h,
554
+ l,
540
555
  H,
541
- _,
542
- U,
543
- T,
544
- $
556
+ V,
557
+ A,
558
+ z,
559
+ k
545
560
  ]);
546
- const O = A(() => {
547
- const e = new Set(Re), c = new Set(i), v = new Set(p);
548
- return { reserved: e, unavailable: c, myReserved: v };
549
- }, [Re, i, p]), be = A(() => S ? new Set(S) : null, [S]), ne = z(
561
+ const O = B(() => {
562
+ const e = new Set(Ie), a = new Set(s), p = new Set(h);
563
+ return { reserved: e, unavailable: a, myReserved: p };
564
+ }, [Ie, s, h]), Se = B(() => v ? new Set(v) : null, [v]), re = T(
550
565
  (e) => {
551
- const c = e.id, v = e.seatNumber || "";
552
- return O.unavailable.has(c) || O.unavailable.has(v) ? "unavailable" : O.reserved.has(c) || O.reserved.has(v) ? "reserved" : O.myReserved.has(c) || O.myReserved.has(v) || q.has(c) ? "selected" : e.state;
566
+ const a = e.id, p = e.seatNumber || "";
567
+ return O.unavailable.has(a) || O.unavailable.has(p) ? "unavailable" : O.reserved.has(a) || O.reserved.has(p) ? "reserved" : O.myReserved.has(a) || O.myReserved.has(p) || q.has(a) ? "selected" : e.state;
553
568
  },
554
569
  [O, q]
555
570
  );
556
- B(() => {
557
- h && E && E(h);
558
- }, [h, E]), B(() => {
559
- te && F && F(te);
560
- }, [te, F]), B(() => {
561
- ae && be && Ee(be);
562
- }, [ae, be]);
563
- const Qe = z(
571
+ U(() => {
572
+ l && g && g(l);
573
+ }, [l, g]), U(() => {
574
+ ne && I && I(ne);
575
+ }, [ne, I]), U(() => {
576
+ he && Se && Le(Se);
577
+ }, [he, Se]);
578
+ const Qe = T(
564
579
  (e) => {
565
- const c = ne(e);
566
- if (c !== "available" && c !== "selected")
580
+ const a = re(e);
581
+ if (a !== "available" && a !== "selected")
567
582
  return;
568
- const v = q.has(e.id);
569
- ae || Ee((y) => {
570
- const w = new Set(y);
571
- return v ? w.delete(e.id) : w.add(e.id), w;
572
- }), v ? a?.(e) : (s?.(e), s || console.log("Seat selected:", e));
583
+ const p = q.has(e.id);
584
+ he || Le((S) => {
585
+ const C = new Set(S);
586
+ return p ? C.delete(e.id) : C.add(e.id), C;
587
+ }), p ? b?.(e) : (i?.(e), i || console.log("Seat selected:", e));
573
588
  },
574
589
  [
575
- ne,
590
+ re,
576
591
  q,
577
- ae,
578
- s,
579
- a
592
+ he,
593
+ i,
594
+ b
580
595
  ]
581
- ), re = A(() => h ? Z.filter((e) => q.has(e.id)) : [], [Z, q]);
582
- B(() => {
583
- f?.(re);
584
- }, [re, f]);
585
- const G = Ce !== void 0 ? Ce : _e, et = z(() => {
586
- if (!g) return;
587
- const e = Math.min(N + ie, U);
588
- if (e !== N) {
589
- const c = T.width || h?.canvas.width || 800, v = T.height || h?.canvas.height || 600, y = c / 2, w = v / 2, m = {
590
- x: (y - P.x) / N,
591
- y: (w - P.y) / N
596
+ ), oe = B(() => l ? G.filter((e) => q.has(e.id)) : [], [l, G, q]);
597
+ U(() => {
598
+ y?.(oe);
599
+ }, [oe, y]);
600
+ const K = le !== void 0 ? le : _e, et = T(() => {
601
+ if (!m) return;
602
+ const e = Math.min($ + _, A);
603
+ if (e !== $) {
604
+ const a = z.width || l?.canvas.width || 800, p = z.height || l?.canvas.height || 600, S = a / 2, C = p / 2, x = {
605
+ x: (S - X.x) / $,
606
+ y: (C - X.y) / $
592
607
  };
593
- Q(e), V({
594
- x: y - m.x * e,
595
- y: w - m.y * e
608
+ ee(e), Z({
609
+ x: S - x.x * e,
610
+ y: C - x.y * e
596
611
  });
597
612
  }
598
613
  }, [
599
- g,
600
- N,
601
- ie,
602
- U,
603
- T,
604
- h,
605
- P
606
- ]), tt = z(() => {
607
- if (!g) return;
608
- const e = Math.max(N - ie, G);
609
- if (e !== N) {
610
- const c = T.width || h?.canvas.width || 800, v = T.height || h?.canvas.height || 600, y = c / 2, w = v / 2, m = {
611
- x: (y - P.x) / N,
612
- y: (w - P.y) / N
614
+ m,
615
+ $,
616
+ _,
617
+ A,
618
+ z,
619
+ l,
620
+ X
621
+ ]), tt = T(() => {
622
+ if (!m) return;
623
+ const e = Math.max($ - _, K);
624
+ if (e !== $) {
625
+ const a = z.width || l?.canvas.width || 800, p = z.height || l?.canvas.height || 600, S = a / 2, C = p / 2, x = {
626
+ x: (S - X.x) / $,
627
+ y: (C - X.y) / $
613
628
  };
614
- Q(e), V({
615
- x: y - m.x * e,
616
- y: w - m.y * e
629
+ ee(e), Z({
630
+ x: S - x.x * e,
631
+ y: C - x.y * e
617
632
  });
618
633
  }
619
634
  }, [
620
- g,
621
- N,
622
- ie,
623
- G,
624
- T,
625
- h,
626
- P
627
- ]), nt = z((e) => {
628
- V({
635
+ m,
636
+ $,
637
+ _,
638
+ K,
639
+ z,
640
+ l,
641
+ X
642
+ ]), nt = T((e) => {
643
+ Z({
629
644
  x: e.target.x(),
630
645
  y: e.target.y()
631
646
  });
632
- }, []), rt = z(
647
+ }, []), rt = T(
633
648
  (e) => {
634
- if (!g) return;
649
+ if (!m) return;
635
650
  e.evt.preventDefault();
636
- const c = fe.current;
637
- if (!c) return;
638
- const v = c.scaleX(), y = c.getPointerPosition();
639
- if (!y) return;
640
- const w = 1.1, m = e.evt.deltaY > 0 ? v / w : v * w, j = Math.min(Math.max(m, G), U), K = {
641
- x: (y.x - P.x) / v,
642
- y: (y.y - P.y) / v
643
- }, ve = {
644
- x: y.x - K.x * j,
645
- y: y.y - K.y * j
651
+ const a = ve.current;
652
+ if (!a) return;
653
+ const p = a.scaleX(), S = a.getPointerPosition();
654
+ if (!S) return;
655
+ const C = 1.1, x = e.evt.deltaY > 0 ? p / C : p * C, j = Math.min(Math.max(x, K), A), J = {
656
+ x: (S.x - X.x) / p,
657
+ y: (S.y - X.y) / p
658
+ }, xe = {
659
+ x: S.x - J.x * j,
660
+ y: S.y - J.y * j
646
661
  };
647
- Q(j), V(ve);
662
+ ee(j), Z(xe);
648
663
  },
649
- [g, P, G, U]
664
+ [m, X, K, A]
650
665
  );
651
- Ct(fe, {
652
- enabled: Ve && g,
653
- minScale: G,
654
- maxScale: U,
655
- currentScale: N,
656
- currentPosition: P,
657
- onScaleChange: (e, c) => {
658
- Q(e), V(c);
659
- },
660
- onPositionChange: (e) => {
661
- V(e);
666
+ Ct(ve, {
667
+ enabled: Ve && m,
668
+ minScale: K,
669
+ maxScale: A,
670
+ currentScale: $,
671
+ currentPosition: X,
672
+ onScaleChange: (e, a) => {
673
+ ee(e), Z(a);
662
674
  }
663
675
  });
664
- const ot = z(
665
- (e, c) => {
666
- if (!x) return;
667
- const v = c.target.getStage();
668
- if (!v) return;
669
- const y = v.getPointerPosition();
670
- if (!y) return;
671
- const w = v.container().getBoundingClientRect();
672
- Ie({
676
+ const ot = T(
677
+ (e, a) => {
678
+ if (!w) return;
679
+ const p = a.target.getStage();
680
+ if (!p) return;
681
+ const S = p.getPointerPosition();
682
+ if (!S) return;
683
+ const C = p.container().getBoundingClientRect();
684
+ Te({
673
685
  visible: !0,
674
- x: w.left + y.x,
675
- y: w.top + y.y,
686
+ x: C.left + S.x,
687
+ y: C.top + S.y,
676
688
  seat: e,
677
- state: ne(e)
689
+ state: re(e)
678
690
  });
679
691
  },
680
- [x, ne]
681
- ), it = z(() => {
682
- Ie((e) => ({ ...e, visible: !1 }));
692
+ [w, re]
693
+ ), it = T(() => {
694
+ Te((e) => ({ ...e, visible: !1 }));
683
695
  }, []);
684
696
  if (Ge)
685
- return /* @__PURE__ */ u("div", { className: `flex items-center justify-center h-full ${C}`, children: /* @__PURE__ */ u("p", { children: "Loading seat map..." }) });
686
- if (te)
687
- return /* @__PURE__ */ u("div", { className: `flex items-center justify-center h-full ${C}`, children: /* @__PURE__ */ D("p", { className: "text-red-500", children: [
697
+ return /* @__PURE__ */ f("div", { className: `flex items-center justify-center h-full ${M}`, children: /* @__PURE__ */ f("p", { children: "Loading seat map..." }) });
698
+ if (ne)
699
+ return /* @__PURE__ */ f("div", { className: `flex items-center justify-center h-full ${M}`, children: /* @__PURE__ */ D("p", { className: "text-red-500", children: [
688
700
  "Error loading seat map: ",
689
- te.message
701
+ ne.message
690
702
  ] }) });
691
- if (!h)
692
- return /* @__PURE__ */ u("div", { className: `flex items-center justify-center h-full ${C}`, children: /* @__PURE__ */ u("p", { children: "No configuration provided" }) });
693
- const st = T.width || h.canvas.width, at = T.height || h.canvas.height;
703
+ if (!l)
704
+ return /* @__PURE__ */ f("div", { className: `flex items-center justify-center h-full ${M}`, children: /* @__PURE__ */ f("p", { children: "No configuration provided" }) });
705
+ const st = z.width || l.canvas.width, at = z.height || l.canvas.height;
694
706
  return /* @__PURE__ */ D(
695
707
  "div",
696
708
  {
697
- ref: Me,
698
- className: `relative ${C}`,
709
+ ref: Fe,
710
+ className: `relative ${M}`,
699
711
  style: { width: "100%", height: "100%" },
700
712
  children: [
701
- Je && pe.length > 0 && /* @__PURE__ */ u(
702
- Xe,
713
+ Je && me.length > 0 && /* @__PURE__ */ f(
714
+ Be,
703
715
  {
704
- floors: pe,
705
- currentFloorId: $,
716
+ floors: me,
717
+ currentFloorId: k,
706
718
  onFloorChange: Ke,
707
719
  showAllOption: L,
708
- allLabel: W,
709
- position: I,
710
- className: M
720
+ allLabel: N,
721
+ position: F,
722
+ className: E
711
723
  }
712
724
  ),
713
725
  /* @__PURE__ */ D(
714
726
  pt,
715
727
  {
716
- ref: fe,
728
+ ref: ve,
717
729
  width: st,
718
730
  height: at,
719
- scaleX: N,
720
- scaleY: N,
721
- x: P.x,
722
- y: P.y,
731
+ scaleX: $,
732
+ scaleY: $,
733
+ x: X.x,
734
+ y: X.y,
723
735
  draggable: !0,
724
736
  onDragEnd: nt,
725
737
  onWheel: rt,
726
738
  style: {
727
- backgroundColor: h.canvas.backgroundColor,
739
+ backgroundColor: l.canvas.backgroundColor,
728
740
  cursor: "grab"
729
741
  },
730
742
  children: [
731
- /* @__PURE__ */ u(ye, { listening: !1, children: le.map((e) => /* @__PURE__ */ u(
732
- We,
743
+ /* @__PURE__ */ f(we, { listening: !1, children: fe.map((e) => /* @__PURE__ */ f(
744
+ Ye,
733
745
  {
734
746
  stage: e,
735
- stageColor: ce.stageColor
747
+ stageColor: ue.stageColor
736
748
  },
737
749
  e.id
738
750
  )) }),
739
- /* @__PURE__ */ u(ye, { listening: !1, children: de.map((e) => /* @__PURE__ */ u(Pe, { text: e }, e.id)) }),
740
- /* @__PURE__ */ u(ye, { children: Z.map((e) => /* @__PURE__ */ u(
741
- ke,
751
+ /* @__PURE__ */ f(we, { listening: !1, children: ge.map((e) => /* @__PURE__ */ f(Ae, { text: e }, e.id)) }),
752
+ /* @__PURE__ */ f(we, { children: G.map((e) => /* @__PURE__ */ f(
753
+ Pe,
742
754
  {
743
755
  seat: e,
744
- state: ne(e),
745
- colors: ce,
756
+ state: re(e),
757
+ colors: ue,
746
758
  onClick: Qe,
747
759
  onMouseEnter: ot,
748
760
  onMouseLeave: it
@@ -752,77 +764,77 @@ const Nt = ({
752
764
  ]
753
765
  }
754
766
  ),
755
- x && /* @__PURE__ */ u(
756
- Ae,
767
+ w && /* @__PURE__ */ f(
768
+ He,
757
769
  {
758
- visible: ee.visible,
759
- x: ee.x,
760
- y: ee.y,
761
- seat: ee.seat,
762
- currency: ce.currency,
763
- state: ee.state
770
+ visible: te.visible,
771
+ x: te.x,
772
+ y: te.y,
773
+ seat: te.seat,
774
+ currency: ue.currency,
775
+ state: te.state
764
776
  }
765
777
  ),
766
- Be && g && /* @__PURE__ */ u(
767
- Ye,
778
+ se && m && /* @__PURE__ */ f(
779
+ Ue,
768
780
  {
769
- scale: N,
770
- minScale: G,
771
- maxScale: U,
781
+ scale: $,
782
+ minScale: K,
783
+ maxScale: A,
772
784
  onZoomIn: et,
773
785
  onZoomOut: tt,
774
- position: Ue,
775
- className: He
786
+ position: ae,
787
+ className: ce
776
788
  }
777
789
  ),
778
- re.length > 0 && /* @__PURE__ */ D("div", { className: "absolute top-4 right-4 bg-white dark:bg-gray-800 p-4 rounded shadow-lg", children: [
790
+ oe.length > 0 && /* @__PURE__ */ D("div", { className: "absolute top-4 right-4 bg-white dark:bg-gray-800 p-4 rounded shadow-lg", children: [
779
791
  /* @__PURE__ */ D("h3", { className: "font-semibold mb-2", children: [
780
792
  "Selected Seats (",
781
- re.length,
793
+ oe.length,
782
794
  ")"
783
795
  ] }),
784
- /* @__PURE__ */ u("div", { className: "max-h-48 overflow-y-auto space-y-1", children: re.map((e) => /* @__PURE__ */ D("div", { className: "text-sm", children: [
796
+ /* @__PURE__ */ f("div", { className: "max-h-48 overflow-y-auto space-y-1", children: oe.map((e) => /* @__PURE__ */ D("div", { className: "text-sm", children: [
785
797
  e.seatNumber,
786
- e.price && ` - ${ce.currency} ${e.price.toFixed(2)}`
798
+ e.price && ` - ${ue.currency} ${e.price.toFixed(2)}`
787
799
  ] }, e.id)) })
788
800
  ] })
789
801
  ]
790
802
  }
791
803
  );
792
804
  };
793
- let oe = null;
805
+ let ie = null;
794
806
  function $t(n) {
795
- oe = n;
807
+ ie = n;
796
808
  }
797
- function xe() {
798
- if (!oe)
809
+ function Me() {
810
+ if (!ie)
799
811
  throw new Error(
800
812
  "Firebase database not initialized. Call initializeFirebaseForViewer(db) first."
801
813
  );
802
- return oe;
814
+ return ie;
803
815
  }
804
- function we() {
805
- return oe !== null;
816
+ function Ee() {
817
+ return ie !== null;
806
818
  }
807
819
  function kt() {
808
- oe = null;
820
+ ie = null;
809
821
  }
810
- function me(n, r) {
811
- if (n.length !== r.length) return !1;
812
- const t = [...n].sort(), o = [...r].sort();
813
- return t.every((d, l) => d === o[l]);
822
+ function Ce(n, o) {
823
+ if (n.length !== o.length) return !1;
824
+ const t = [...n].sort(), r = [...o].sort();
825
+ return t.every((d, c) => d === r[c]);
814
826
  }
815
- function Mt(n, r) {
816
- const t = [], o = [], d = [];
817
- return Object.entries(n).forEach(([l, i]) => {
818
- i && typeof i == "object" && i.state && (i.state === "unavailable" ? d.push(l) : i.state === "reserved" && (r && i.userId === r ? t.push(l) : o.push(l)));
827
+ function Mt(n, o) {
828
+ const t = [], r = [], d = [];
829
+ return Object.entries(n).forEach(([c, s]) => {
830
+ s && typeof s == "object" && s.state && (s.state === "unavailable" ? d.push(c) : s.state === "reserved" && (o && s.userId === o ? t.push(c) : r.push(c)));
819
831
  }), {
820
832
  myReserved: t.sort(),
821
- otherReserved: o.sort(),
833
+ otherReserved: r.sort(),
822
834
  unavailable: d.sort()
823
835
  };
824
836
  }
825
- const ue = {
837
+ const be = {
826
838
  states: null,
827
839
  loading: !0,
828
840
  error: null,
@@ -833,182 +845,182 @@ const ue = {
833
845
  };
834
846
  function Et(n) {
835
847
  const {
836
- seatMapId: r,
848
+ seatMapId: o,
837
849
  currentUserId: t,
838
- enabled: o = !0,
850
+ enabled: r = !0,
839
851
  onStateChange: d,
840
- onError: l
841
- } = n, i = X({ ...ue }), S = X(d), p = X(l), s = X(t);
842
- S.current = d, p.current = l, s.current = t;
843
- const a = z(
844
- (g) => {
845
- if (!o || !r)
846
- return (i.current.loading !== !1 || i.current.states !== null) && (i.current = { ...ue, loading: !1 }, g()), () => {
852
+ onError: c
853
+ } = n, s = P({ ...be }), v = P(d), h = P(c), i = P(t);
854
+ v.current = d, h.current = c, i.current = t;
855
+ const b = T(
856
+ (m) => {
857
+ if (!r || !o)
858
+ return (s.current.loading !== !1 || s.current.states !== null) && (s.current = { ...be, loading: !1 }, m()), () => {
847
859
  };
848
- if (!we()) {
849
- const I = "Firebase not initialized. Call initializeFirebaseForViewer first.";
850
- return i.current.error?.message !== I && (i.current = {
851
- ...ue,
860
+ if (!Ee()) {
861
+ const F = "Firebase not initialized. Call initializeFirebaseForViewer first.";
862
+ return s.current.error?.message !== F && (s.current = {
863
+ ...be,
852
864
  loading: !1,
853
- error: new Error(I)
854
- }, g()), () => {
865
+ error: new Error(F)
866
+ }, m()), () => {
855
867
  };
856
868
  }
857
- const C = xe(), E = Se(C, `seatmaps/${r}/seat_states`);
858
- return Ne(E, (I) => {
859
- const L = I.val() || {}, W = Mt(
869
+ const M = Me(), g = Re(M, `seatmaps/${o}/seat_states`);
870
+ return We(g, (F) => {
871
+ const L = F.val() || {}, N = Mt(
860
872
  L,
861
- s.current
862
- ), Y = i.current;
863
- (Y.loading || !me(Y.myReservedSeats, W.myReserved) || !me(
873
+ i.current
874
+ ), Y = s.current;
875
+ (Y.loading || !Ce(Y.myReservedSeats, N.myReserved) || !Ce(
864
876
  Y.otherReservedSeats,
865
- W.otherReserved
866
- ) || !me(Y.unavailableSeats, W.unavailable)) && (i.current = {
877
+ N.otherReserved
878
+ ) || !Ce(Y.unavailableSeats, N.unavailable)) && (s.current = {
867
879
  states: L,
868
880
  loading: !1,
869
881
  error: null,
870
882
  lastUpdated: Date.now(),
871
- myReservedSeats: W.myReserved,
872
- otherReservedSeats: W.otherReserved,
873
- unavailableSeats: W.unavailable
874
- }, S.current?.(L), g());
875
- }, (I) => {
876
- i.current = {
877
- ...i.current,
883
+ myReservedSeats: N.myReserved,
884
+ otherReservedSeats: N.otherReserved,
885
+ unavailableSeats: N.unavailable
886
+ }, v.current?.(L), m());
887
+ }, (F) => {
888
+ s.current = {
889
+ ...s.current,
878
890
  loading: !1,
879
- error: I
880
- }, p.current?.(I), g();
891
+ error: F
892
+ }, h.current?.(F), m();
881
893
  }), () => {
882
- $e(E);
894
+ Xe(g);
883
895
  };
884
896
  },
885
- [r, o]
897
+ [o, r]
886
898
  // Don't include currentUserId - we use currentUserIdRef.current which is always up-to-date
887
- ), f = z(() => i.current, []), b = z(() => ue, []), x = gt(
888
- a,
889
- f,
890
- b
899
+ ), y = T(() => s.current, []), u = T(() => be, []), w = gt(
900
+ b,
901
+ y,
902
+ u
891
903
  );
892
904
  return {
893
- states: x.states,
894
- loading: x.loading,
895
- error: x.error,
896
- lastUpdated: x.lastUpdated,
897
- myReservedSeats: x.myReservedSeats,
898
- otherReservedSeats: x.otherReservedSeats,
899
- unavailableSeats: x.unavailableSeats,
905
+ states: w.states,
906
+ loading: w.loading,
907
+ error: w.error,
908
+ lastUpdated: w.lastUpdated,
909
+ myReservedSeats: w.myReservedSeats,
910
+ otherReservedSeats: w.otherReservedSeats,
911
+ unavailableSeats: w.unavailableSeats,
900
912
  // Legacy alias
901
- reservedSeats: x.otherReservedSeats
913
+ reservedSeats: w.otherReservedSeats
902
914
  };
903
915
  }
904
916
  function It(n) {
905
917
  const {
906
- seatMapId: r,
918
+ seatMapId: o,
907
919
  enabled: t = !0,
908
- subscribeToChanges: o = !1,
920
+ subscribeToChanges: r = !1,
909
921
  onConfigLoad: d,
910
- onError: l
911
- } = n, [i, S] = k(null), [p, s] = k(!0), [a, f] = k(null), b = X(d), x = X(l);
912
- b.current = d, x.current = l;
913
- const g = z(async () => {
914
- if (!r) return;
915
- if (!we()) {
916
- f(
922
+ onError: c
923
+ } = n, [s, v] = W(null), [h, i] = W(!0), [b, y] = W(null), u = P(d), w = P(c);
924
+ u.current = d, w.current = c;
925
+ const m = T(async () => {
926
+ if (!o) return;
927
+ if (!Ee()) {
928
+ y(
917
929
  new Error(
918
930
  "Firebase not initialized. Call initializeFirebaseForViewer first."
919
931
  )
920
- ), s(!1);
932
+ ), i(!1);
921
933
  return;
922
934
  }
923
- const C = xe(), E = Se(C, `seatmaps/${r}`);
935
+ const M = Me(), g = Re(M, `seatmaps/${o}`);
924
936
  try {
925
- s(!0), f(null);
926
- const R = (await mt(E)).val();
937
+ i(!0), y(null);
938
+ const R = (await mt(g)).val();
927
939
  if (R) {
928
- const I = St(R);
929
- S(I), b.current?.(I);
940
+ const F = St(R);
941
+ v(F), u.current?.(F);
930
942
  } else
931
- f(new Error(`Seat map ${r} not found in Firebase`));
932
- } catch (F) {
933
- const R = F instanceof Error ? F : new Error("Unknown error");
934
- f(R), x.current?.(R);
943
+ y(new Error(`Seat map ${o} not found in Firebase`));
944
+ } catch (I) {
945
+ const R = I instanceof Error ? I : new Error("Unknown error");
946
+ y(R), w.current?.(R);
935
947
  } finally {
936
- s(!1);
948
+ i(!1);
937
949
  }
938
- }, [r]);
939
- return B(() => {
940
- if (!t || !r) {
941
- s(!1);
950
+ }, [o]);
951
+ return U(() => {
952
+ if (!t || !o) {
953
+ i(!1);
942
954
  return;
943
955
  }
944
- if (g(), o && we()) {
945
- const C = xe(), E = Se(C, `seatmaps/${r}/meta/updated_at`);
946
- let F = !0, R = null;
947
- return Ne(E, (M) => {
948
- if (F) {
949
- F = !1, R = M.val();
956
+ if (m(), r && Ee()) {
957
+ const M = Me(), g = Re(M, `seatmaps/${o}/meta/updated_at`);
958
+ let I = !0, R = null;
959
+ return We(g, (E) => {
960
+ if (I) {
961
+ I = !1, R = E.val();
950
962
  return;
951
963
  }
952
- const L = M.val();
953
- M.exists() && L !== R && (R = L, g());
964
+ const L = E.val();
965
+ E.exists() && L !== R && (R = L, m());
954
966
  }), () => {
955
- $e(E);
967
+ Xe(g);
956
968
  };
957
969
  }
958
- }, [r, t, o]), {
959
- config: i,
960
- loading: p,
961
- error: a,
962
- refetch: g
970
+ }, [o, t, r]), {
971
+ config: s,
972
+ loading: h,
973
+ error: b,
974
+ refetch: m
963
975
  };
964
976
  }
965
977
  function Wt(n) {
966
978
  const {
967
- seatMapId: r,
979
+ seatMapId: o,
968
980
  userId: t,
969
- enabled: o = !0,
981
+ enabled: r = !0,
970
982
  subscribeToDesignChanges: d = !1,
971
- onConfigLoad: l,
972
- onStateChange: i,
973
- onError: S
983
+ onConfigLoad: c,
984
+ onStateChange: s,
985
+ onError: v
974
986
  } = n, {
975
- config: p,
976
- loading: s,
977
- error: a,
978
- refetch: f
987
+ config: h,
988
+ loading: i,
989
+ error: b,
990
+ refetch: y
979
991
  } = It({
980
- seatMapId: r,
981
- enabled: o,
992
+ seatMapId: o,
993
+ enabled: r,
982
994
  subscribeToChanges: d,
983
- onConfigLoad: l,
984
- onError: S
995
+ onConfigLoad: c,
996
+ onError: v
985
997
  }), {
986
- states: b,
987
- loading: x,
988
- error: g,
989
- lastUpdated: C,
990
- myReservedSeats: E,
991
- otherReservedSeats: F,
998
+ states: u,
999
+ loading: w,
1000
+ error: m,
1001
+ lastUpdated: M,
1002
+ myReservedSeats: g,
1003
+ otherReservedSeats: I,
992
1004
  unavailableSeats: R,
993
- reservedSeats: I
1005
+ reservedSeats: F
994
1006
  } = Et({
995
- seatMapId: r,
1007
+ seatMapId: o,
996
1008
  currentUserId: t,
997
- enabled: o,
998
- onStateChange: i,
999
- onError: S
1009
+ enabled: r,
1010
+ onStateChange: s,
1011
+ onError: v
1000
1012
  });
1001
1013
  return {
1002
- config: p,
1003
- loading: s || x,
1004
- error: a || g,
1005
- myReservedSeats: E,
1006
- otherReservedSeats: F,
1014
+ config: h,
1015
+ loading: i || w,
1016
+ error: b || m,
1017
+ myReservedSeats: g,
1018
+ otherReservedSeats: I,
1007
1019
  unavailableSeats: R,
1008
- reservedSeats: I,
1009
- seatStates: b,
1010
- lastUpdated: C,
1011
- refetch: f
1020
+ reservedSeats: F,
1021
+ seatStates: u,
1022
+ lastUpdated: M,
1023
+ refetch: y
1012
1024
  };
1013
1025
  }
1014
1026
  export {
@@ -1016,7 +1028,7 @@ export {
1016
1028
  Nt as SeatMapViewer,
1017
1029
  kt as clearFirebaseInstance,
1018
1030
  $t as initializeFirebaseForViewer,
1019
- we as isFirebaseInitialized,
1031
+ Ee as isFirebaseInitialized,
1020
1032
  xt as useConfigFetcher,
1021
1033
  wt as useContainerSize,
1022
1034
  It as useFirebaseConfig,