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