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