@zonetrix/viewer 2.12.0 → 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 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 () => {
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
- u(!0), i(null);
8
+ S(!0), f(null);
10
9
  try {
11
- const p = await fetch(n);
12
- if (!p.ok)
13
- throw new Error(`Failed to fetch config: ${p.statusText}`);
14
- const s = await p.json();
15
- t(s);
16
- } catch (p) {
17
- const s = p instanceof Error ? p : new Error("Unknown error occurred");
18
- i(s), console.error("Failed to fetch seat map config:", s);
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
- u(!1);
19
+ S(!1);
21
20
  }
22
21
  }
23
22
  }, [n]);
24
- return V(() => {
25
- m();
26
- }, [m]), {
27
- config: o,
23
+ return B(() => {
24
+ x();
25
+ }, [x]), {
26
+ config: u,
28
27
  loading: r,
29
- error: l,
30
- refetch: m
28
+ error: y,
29
+ refetch: x
31
30
  };
32
31
  }
33
- function St(n) {
34
- const [o, t] = z({ width: 0, height: 0 });
35
- return V(() => {
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: 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 });
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 i.observe(r), () => {
47
- i.disconnect();
45
+ return f.observe(r), () => {
46
+ f.disconnect();
48
47
  };
49
- }, [n]), o;
48
+ }, [n]), u;
50
49
  }
51
- function Le(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 Ne(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 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
- onScaleChange: b
68
- } = o;
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;
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
- }, 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
- if (t.current !== null && r.current !== null) {
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
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(k, _), t.current = E, r.current = M;
92
+ p(A, V), e.current = O, r.current = M;
94
93
  }
95
- }, R = (v) => {
96
- v.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 f.addEventListener("touchstart", x, {
97
+ return d.addEventListener("touchstart", I, {
99
98
  passive: !1
100
- }), f.addEventListener("touchmove", y, {
99
+ }), d.addEventListener("touchmove", v, {
101
100
  passive: !1
102
- }), f.addEventListener("touchend", R), () => {
103
- f.removeEventListener("touchstart", x), f.removeEventListener("touchmove", y), f.removeEventListener("touchend", R);
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,
107
- l,
108
- i,
109
- m,
110
- p,
111
- s,
112
- b
106
+ y,
107
+ f,
108
+ x,
109
+ g,
110
+ c,
111
+ p
113
112
  ]);
114
113
  }
115
- const wt = {
114
+ const de = {
116
115
  canvasBackground: "#1a1a1a",
117
116
  stageColor: "#808080",
118
117
  seatAvailable: "#2C2B30",
@@ -122,130 +121,130 @@ const wt = {
122
121
  seatHidden: "#4a4a4a",
123
122
  gridLines: "#404040",
124
123
  currency: "KD"
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
- 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], 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");
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, u, s]
143
- ), f = T(
144
- (y) => {
145
- l();
146
- const R = y.target.getStage();
147
- R && (R.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
- [l]
150
- ), x = {
148
+ [y]
149
+ ), I = {
151
150
  x: n.position.x,
152
151
  y: n.position.y,
153
- fill: p,
152
+ fill: g,
154
153
  stroke: "#ffffff",
155
154
  strokeWidth: 1,
156
- onClick: b,
157
- onTap: b,
158
- onMouseEnter: S,
159
- onMouseLeave: f
155
+ onClick: p,
156
+ onTap: p,
157
+ onMouseEnter: b,
158
+ onMouseLeave: d
160
159
  };
161
- return n.shape === "circle" ? /* @__PURE__ */ h($e, { ...x, radius: i }) : /* @__PURE__ */ h(
162
- We,
160
+ return n.shape === "circle" ? /* @__PURE__ */ a(Dt, { ...I, radius: f }) : /* @__PURE__ */ a(
161
+ Nt,
163
162
  {
164
- ...x,
165
- width: i * 2,
166
- height: i * 2,
167
- offsetX: i,
168
- offsetY: i,
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 = 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(
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(s, x))
182
- ), R = 4, v = Math.max(20, t.width - R * 2), F = (t.width - v) / 2, C = {
183
- fill: l + "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
- }, E = () => {
187
+ }, O = () => {
189
188
  switch (r) {
190
189
  case "circle": {
191
- const M = Math.min(t.width, t.height) / 2;
192
- return /* @__PURE__ */ h(
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,
194
+ x: e.width / 2,
195
+ y: e.height / 2,
197
196
  radius: M,
198
- ...C
197
+ ...W
199
198
  }
200
199
  );
201
200
  }
202
201
  case "triangle": {
203
- const M = Math.min(t.width, t.height) / 2;
204
- return /* @__PURE__ */ h(
205
- bt,
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
209
  radius: M,
211
210
  rotation: -90,
212
- ...C
211
+ ...W
213
212
  }
214
213
  );
215
214
  }
216
215
  case "arrow": {
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 });
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__ */ h(
222
- We,
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
- ...C
226
+ ...W
228
227
  }
229
228
  );
230
229
  }
231
230
  };
232
- return /* @__PURE__ */ N(
233
- gt,
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
- E(),
240
- u && /* @__PURE__ */ h(
241
- ke,
238
+ O(),
239
+ S && /* @__PURE__ */ a(
240
+ Rt,
242
241
  {
243
- text: t.label,
244
- x: F,
245
- y: R,
246
- width: v,
247
- height: t.height - R * 2,
248
- fontSize: y,
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 = J(({ stage: n, stageColor: o }) => {
258
257
  }
259
258
  );
260
259
  });
261
- Ye.displayName = "ViewerStage";
262
- const Ae = J(({ text: n }) => /* @__PURE__ */ h(
263
- ke,
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 = J(({ text: n }) => /* @__PURE__ */ h(
271
270
  listening: !1
272
271
  }
273
272
  ));
274
- Ae.displayName = "ViewerText";
275
- const Be = J(
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: u,
282
- position: l,
283
- className: i
280
+ allLabel: S,
281
+ position: y,
282
+ className: f
284
283
  }) => {
285
- const m = H(
286
- () => [...n].sort((f, x) => f.order - x.order),
284
+ const x = z(
285
+ () => [...n].sort((d, I) => d.order - I.order),
287
286
  [n]
288
- ), s = {
287
+ ), c = {
289
288
  position: "absolute",
290
289
  display: "flex",
291
290
  alignItems: "center",
@@ -300,8 +299,8 @@ const Be = J(
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
- }[l]
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 = J(
313
312
  transition: "all 0.2s ease",
314
313
  minHeight: "44px",
315
314
  touchAction: "manipulation"
316
- }, S = {
317
- ...b,
315
+ }, b = {
316
+ ...p,
318
317
  backgroundColor: "#3A7DE5",
319
318
  borderColor: "#3A7DE5"
320
319
  };
321
- return /* @__PURE__ */ N("div", { className: i, style: s, children: [
322
- r && /* @__PURE__ */ h(
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 ? S : b,
328
- children: u
325
+ onClick: () => e(null),
326
+ style: u === null ? b : p,
327
+ children: S
329
328
  }
330
329
  ),
331
- m.map((f) => /* @__PURE__ */ h(
330
+ x.map((d) => /* @__PURE__ */ a(
332
331
  "button",
333
332
  {
334
333
  type: "button",
335
- onClick: () => t(f.id),
336
- style: o === f.id ? S : b,
337
- children: f.name
334
+ onClick: () => e(d.id),
335
+ style: u === d.id ? b : p,
336
+ children: d.name
338
337
  },
339
- f.id
338
+ d.id
340
339
  ))
341
340
  ] });
342
341
  }
343
342
  );
344
- Be.displayName = "FloorSelectorBar";
345
- const Ue = J(
346
- ({ scale: n, minScale: o, maxScale: t, onZoomIn: r, onZoomOut: u, onFitToScreen: l, position: i, className: m }) => {
347
- const s = {
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,7 +358,7 @@ const Ue = J(
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
- }[i]
361
+ }[x]
363
362
  }, b = {
364
363
  width: "44px",
365
364
  height: "44px",
@@ -377,43 +376,43 @@ const Ue = J(
377
376
  justifyContent: "center",
378
377
  transition: "all 0.2s ease",
379
378
  touchAction: "manipulation"
380
- }, S = {
379
+ }, d = {
381
380
  ...b,
382
381
  opacity: 0.4,
383
382
  cursor: "not-allowed"
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(
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: !f,
392
- style: f ? b : S,
389
+ onClick: S,
390
+ disabled: !I,
391
+ style: I ? b : d,
393
392
  title: "Zoom In",
394
393
  "aria-label": "Zoom In",
395
394
  children: "+"
396
395
  }
397
396
  ),
398
- /* @__PURE__ */ h(
397
+ /* @__PURE__ */ a(
399
398
  "button",
400
399
  {
401
400
  type: "button",
402
- onClick: l,
403
- disabled: y,
404
- style: y ? S : b,
401
+ onClick: f,
402
+ disabled: w,
403
+ style: w ? d : b,
405
404
  title: "Fit to Screen",
406
405
  "aria-label": "Fit to Screen",
407
406
  children: "⤢"
408
407
  }
409
408
  ),
410
- /* @__PURE__ */ h(
409
+ /* @__PURE__ */ a(
411
410
  "button",
412
411
  {
413
412
  type: "button",
414
- onClick: u,
415
- disabled: !x,
416
- style: x ? b : S,
413
+ onClick: y,
414
+ disabled: !v,
415
+ style: v ? b : d,
417
416
  title: "Zoom Out",
418
417
  "aria-label": "Zoom Out",
419
418
  children: "−"
@@ -422,17 +421,17 @@ const Ue = J(
422
421
  ] });
423
422
  }
424
423
  );
425
- Ue.displayName = "ZoomControls";
426
- const He = J(
427
- ({ visible: n, x: o, y: t, seat: r, currency: u, state: l }) => {
424
+ Et.displayName = "ZoomControls";
425
+ const Xt = K(
426
+ ({ visible: n, x: u, y: e, seat: r, currency: S, state: y }) => {
428
427
  if (!n || !r) return null;
429
- const i = r.seatNumber || (r.rowLabel && r.columnLabel ? `${r.rowLabel}-${r.columnLabel}` : "N/A"), m = {
428
+ const f = r.seatNumber || (r.rowLabel && r.columnLabel ? `${r.rowLabel}-${r.columnLabel}` : "N/A"), x = {
430
429
  position: "fixed",
431
- left: `${o + 15}px`,
432
- top: `${t + 15}px`,
430
+ left: `${u + 15}px`,
431
+ top: `${e + 15}px`,
433
432
  zIndex: 1e3,
434
433
  pointerEvents: "none"
435
- }, p = {
434
+ }, g = {
436
435
  backgroundColor: "rgba(26, 26, 26, 0.95)",
437
436
  color: "#fff",
438
437
  border: "1px solid #444",
@@ -441,606 +440,387 @@ const He = J(
441
440
  fontSize: "13px",
442
441
  boxShadow: "0 4px 12px rgba(0, 0, 0, 0.3)",
443
442
  minWidth: "140px"
444
- }, s = {
443
+ }, c = {
445
444
  color: "#9ca3af",
446
445
  marginRight: "4px"
447
- }, b = {
446
+ }, p = {
448
447
  fontWeight: 600
449
- }, S = {
448
+ }, b = {
450
449
  color: "#4ade80",
451
450
  fontWeight: 600
452
- }, f = {
451
+ }, d = {
453
452
  fontSize: "11px",
454
453
  color: "#6b7280",
455
454
  textTransform: "capitalize",
456
455
  marginTop: "4px"
457
456
  };
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 })
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 })
462
461
  ] }),
463
- /* @__PURE__ */ N("div", { style: { marginBottom: "4px" }, children: [
464
- /* @__PURE__ */ h("span", { style: s, children: "Seat:" }),
465
- /* @__PURE__ */ h("span", { style: b, children: i })
462
+ /* @__PURE__ */ k("div", { style: { marginBottom: "4px" }, children: [
463
+ /* @__PURE__ */ a("span", { style: c, children: "Seat:" }),
464
+ /* @__PURE__ */ a("span", { style: p, children: f })
466
465
  ] }),
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,
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,
471
470
  " ",
472
471
  r.price.toFixed(2)
473
472
  ] })
474
473
  ] }),
475
- /* @__PURE__ */ N("div", { style: f, children: [
474
+ /* @__PURE__ */ k("div", { style: d, children: [
476
475
  "Status: ",
477
- l
476
+ y
478
477
  ] })
479
478
  ] }) });
480
479
  }
481
480
  );
482
- He.displayName = "SeatTooltip";
483
- const Lt = ({
481
+ Xt.displayName = "SeatTooltip";
482
+ const pe = ({
484
483
  config: n,
485
- configUrl: o,
486
- floorId: t,
484
+ configUrl: u,
485
+ floorId: e,
487
486
  onFloorChange: r,
488
- reservedSeats: u = [],
489
- otherReservedSeats: l,
487
+ reservedSeats: S = [],
488
+ otherReservedSeats: y,
490
489
  // v2.4.0: New prop name (preferred)
491
- unavailableSeats: i = [],
492
- selectedSeats: m,
493
- myReservedSeats: p = [],
494
- onSeatSelect: s,
495
- onSeatDeselect: b,
496
- onSelectionChange: S,
497
- colorOverrides: f,
498
- showTooltip: x = !0,
499
- zoomEnabled: y = !0,
500
- className: R = "",
501
- onConfigLoad: v,
502
- onError: F,
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,
503
502
  // Floor selector props
504
- showFloorSelector: C,
505
- floorSelectorPosition: E = "top-left",
503
+ showFloorSelector: W,
504
+ floorSelectorPosition: O = "top-left",
506
505
  floorSelectorClassName: M,
507
- showAllFloorsOption: D = !0,
508
- allFloorsLabel: k = "All",
509
- fitToView: Y = !0,
510
- fitPadding: O = 40,
506
+ showAllFloorsOption: P = !0,
507
+ allFloorsLabel: A = "All",
508
+ fitToView: J = !0,
509
+ fitPadding: j = 40,
511
510
  // Zoom controls
512
- showZoomControls: ie = !0,
513
- zoomControlsPosition: se = "bottom-right",
514
- zoomControlsClassName: ae,
515
- minZoom: ce,
516
- maxZoom: A = 3,
517
- 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,
518
517
  // Touch gestures
519
- touchEnabled: Ve = !0
518
+ touchEnabled: Yt = !0
520
519
  }) => {
521
- const Ee = l !== void 0 ? l : u, be = P(null), Ie = P(null), I = St(Ie), [Z, Te] = z(
520
+ const St = y !== void 0 ? y : S, gt = U(null), wt = U(null), C = le(wt), [Z, Ct] = Y(
522
521
  /* @__PURE__ */ new Set()
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(
524
- (e) => {
525
- 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);
526
525
  },
527
- [ye, r]
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"
536
- )), e;
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)
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)
543
542
  return null;
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;
561
- const e = Math.abs(
562
- I.width - le.current.width
563
- ), a = Math.abs(
564
- I.height - le.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
565
564
  );
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(
572
- (e) => {
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;
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;
575
574
  },
576
- [j, Z]
575
+ [H, Z]
577
576
  );
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]);
585
- const Qe = T(
586
- (e) => {
587
- const a = ne(e);
588
- 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")
589
588
  return;
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));
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));
595
594
  },
596
595
  [
597
- ne,
596
+ nt,
598
597
  Z,
599
- de,
600
- s,
601
- b
598
+ lt,
599
+ c,
600
+ p
602
601
  ]
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;
609
- const e = Math.min($ + _, A);
610
- if (e !== $) {
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) / $
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
614
613
  };
615
- Q(e), q({
616
- x: w - L.x * e,
617
- y: c - L.y * e
614
+ Q(t), _({
615
+ x: h - F.x * t,
616
+ y: o - F.y * t
618
617
  });
619
618
  }
620
619
  }, [
621
- y,
620
+ v,
621
+ R,
622
+ V,
622
623
  $,
623
- _,
624
- A,
625
- I,
626
- d,
627
- X
628
- ]), tt = T(() => {
629
- if (!y) return;
630
- const e = Math.max($ - _, K);
631
- if (e !== $) {
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) / $
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
635
634
  };
636
- Q(e), q({
637
- x: w - L.x * e,
638
- y: c - L.y * e
635
+ Q(t), _({
636
+ x: h - F.x * t,
637
+ y: o - F.y * t
639
638
  });
640
639
  }
641
640
  }, [
642
- y,
643
- $,
644
- _,
645
- K,
646
- I,
647
- d,
648
- X
649
- ]), nt = T((e) => {
650
- q({
651
- x: e.target.x(),
652
- 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()
653
652
  });
654
- }, []), rt = T(
655
- (e) => {
656
- if (!y) return;
657
- e.evt.preventDefault();
658
- const a = be.current;
659
- if (!a) return;
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
665
- }, xe = {
666
- x: w.x - ge.x * U,
667
- y: w.y - ge.y * U
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
668
667
  };
669
- Q(U), q(xe);
668
+ Q(X), _(mt);
670
669
  },
671
- [y, X, K, A]
670
+ [v, T, G, $]
672
671
  );
673
- xt(be, {
674
- enabled: Ve && y,
675
- minScale: K,
676
- maxScale: A,
677
- currentScale: $,
678
- currentPosition: X,
679
- onScaleChange: (e, a) => {
680
- Q(e), q(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);
681
680
  }
682
681
  });
683
- const ot = T(
684
- (e, a) => {
685
- if (!x) return;
686
- const g = a.target.getStage();
687
- if (!g) return;
688
- const w = g.getPointerPosition();
689
- if (!w) return;
690
- const c = g.container().getBoundingClientRect();
691
- De({
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({
692
691
  visible: !0,
693
- x: c.left + w.x,
694
- y: c.top + w.y,
695
- seat: e,
696
- state: ne(e)
692
+ x: o.left + h.x,
693
+ y: o.top + h.y,
694
+ seat: t,
695
+ state: nt(t)
697
696
  });
698
697
  },
699
- [x, ne]
700
- ), it = T(() => {
701
- De((e) => ({ ...e, visible: !1 }));
698
+ [I, nt]
699
+ ), Kt = N(() => {
700
+ It((t) => ({ ...t, visible: !1 }));
702
701
  }, []);
703
- if (Ge)
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: [
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: [
707
706
  "Error loading seat map: ",
708
- te.message
707
+ et.message
709
708
  ] }) });
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(
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(
714
713
  "div",
715
714
  {
716
- ref: Ie,
717
- className: `relative ${R}`,
715
+ ref: wt,
716
+ className: `relative ${w}`,
718
717
  style: { width: "100%", height: "100%" },
719
718
  children: [
720
- Je && ve.length > 0 && /* @__PURE__ */ h(
721
- Be,
719
+ jt && yt.length > 0 && /* @__PURE__ */ a(
720
+ $t,
722
721
  {
723
- floors: ve,
724
- currentFloorId: W,
725
- onFloorChange: Ke,
726
- showAllOption: D,
727
- allLabel: k,
728
- position: E,
722
+ floors: yt,
723
+ currentFloorId: D,
724
+ onFloorChange: Ot,
725
+ showAllOption: P,
726
+ allLabel: A,
727
+ position: O,
729
728
  className: M
730
729
  }
731
730
  ),
732
- /* @__PURE__ */ N(
733
- ft,
731
+ /* @__PURE__ */ k(
732
+ oe,
734
733
  {
735
- ref: be,
736
- width: st,
737
- height: at,
738
- scaleX: $,
739
- scaleY: $,
740
- x: X.x,
741
- 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,
742
741
  draggable: !0,
743
- onDragEnd: nt,
744
- onWheel: rt,
742
+ onDragEnd: qt,
743
+ onWheel: Gt,
745
744
  style: {
746
- backgroundColor: d.canvas.backgroundColor,
745
+ backgroundColor: s.canvas.backgroundColor,
747
746
  cursor: "grab"
748
747
  },
749
748
  children: [
750
- /* @__PURE__ */ h(we, { listening: !1, children: ue.map((e) => /* @__PURE__ */ h(
751
- Ye,
749
+ /* @__PURE__ */ a(vt, { listening: !1, children: dt.map((t) => /* @__PURE__ */ a(
750
+ Tt,
752
751
  {
753
- stage: e,
754
- stageColor: he.stageColor
752
+ stage: t,
753
+ stageColor: ht.stageColor
755
754
  },
756
- e.id
755
+ t.id
757
756
  )) }),
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(
760
- 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,
761
760
  {
762
- seat: e,
763
- state: ne(e),
764
- colors: he,
765
- onClick: Qe,
766
- onMouseEnter: ot,
767
- onMouseLeave: it
761
+ seat: t,
762
+ state: nt(t),
763
+ colors: ht,
764
+ onClick: Vt,
765
+ onMouseEnter: Ut,
766
+ onMouseLeave: Kt
768
767
  },
769
- e.id
768
+ t.id
770
769
  )) })
771
770
  ]
772
771
  }
773
772
  ),
774
- x && /* @__PURE__ */ h(
775
- He,
773
+ I && /* @__PURE__ */ a(
774
+ Xt,
776
775
  {
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
+ visible: tt.visible,
777
+ x: tt.x,
778
+ y: tt.y,
779
+ seat: tt.seat,
780
+ currency: ht.currency,
781
+ state: tt.state
783
782
  }
784
783
  ),
785
- ie && y && /* @__PURE__ */ h(
786
- Ue,
784
+ ot && v && /* @__PURE__ */ a(
785
+ Et,
787
786
  {
788
- scale: $,
789
- minScale: K,
790
- maxScale: A,
791
- onZoomIn: et,
792
- onZoomOut: tt,
793
- onFitToScreen: me,
794
- position: se,
795
- className: ae
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
796
796
  }
797
797
  ),
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: [
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: [
800
800
  "Selected Seats (",
801
- re.length,
801
+ it.length,
802
802
  ")"
803
803
  ] }),
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: [
805
- e.seatNumber,
806
- e.price && ` - ${he.currency} ${e.price.toFixed(2)}`
807
- ] }, 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)) })
808
808
  ] })
809
809
  ]
810
810
  }
811
811
  );
812
812
  };
813
- let oe = null;
814
- function Nt(n) {
815
- oe = n;
816
- }
817
- function Me() {
818
- if (!oe)
819
- throw new Error(
820
- "Firebase database not initialized. Call initializeFirebaseForViewer(db) first."
821
- );
822
- return oe;
823
- }
824
- function Fe() {
825
- return oe !== null;
826
- }
827
- function kt() {
828
- oe = null;
829
- }
830
- function Ce(n, o) {
831
- if (n.length !== o.length) return !1;
832
- const t = [...n].sort(), r = [...o].sort();
833
- return t.every((u, l) => u === r[l]);
834
- }
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)));
839
- }), {
840
- myReserved: t.sort(),
841
- otherReserved: r.sort(),
842
- unavailable: u.sort()
843
- };
844
- }
845
- const pe = {
846
- states: null,
847
- loading: !0,
848
- error: null,
849
- lastUpdated: null,
850
- myReservedSeats: [],
851
- otherReservedSeats: [],
852
- unavailableSeats: []
853
- };
854
- function Rt(n) {
855
- const {
856
- seatMapId: o,
857
- currentUserId: t,
858
- enabled: r = !0,
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;
863
- const b = T(
864
- (y) => {
865
- if (!r || !o)
866
- return (i.current.loading !== !1 || i.current.states !== null) && (i.current = { ...pe, loading: !1 }, y()), () => {
867
- };
868
- if (!Fe()) {
869
- const E = "Firebase not initialized. Call initializeFirebaseForViewer first.";
870
- return i.current.error?.message !== E && (i.current = {
871
- ...pe,
872
- loading: !1,
873
- error: new Error(E)
874
- }, y()), () => {
875
- };
876
- }
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(
884
- Y.otherReservedSeats,
885
- k.otherReserved
886
- ) || !Ce(Y.unavailableSeats, k.unavailable)) && (i.current = {
887
- states: D,
888
- loading: !1,
889
- error: null,
890
- lastUpdated: Date.now(),
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,
898
- loading: !1,
899
- error: E
900
- }, p.current?.(E), y();
901
- }), () => {
902
- Xe(v);
903
- };
904
- },
905
- [o, r]
906
- // Don't include currentUserId - we use currentUserIdRef.current which is always up-to-date
907
- ), S = T(() => i.current, []), f = T(() => pe, []), x = ut(
908
- b,
909
- S,
910
- f
911
- );
912
- return {
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,
920
- // Legacy alias
921
- reservedSeats: x.otherReservedSeats
922
- };
923
- }
924
- function Mt(n) {
925
- const {
926
- seatMapId: o,
927
- enabled: t = !0,
928
- subscribeToChanges: r = !1,
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 () => {
934
- if (!o) return;
935
- if (!Fe()) {
936
- S(
937
- new Error(
938
- "Firebase not initialized. Call initializeFirebaseForViewer first."
939
- )
940
- ), s(!1);
941
- return;
942
- }
943
- const R = Me(), v = Re(R, `seatmaps/${o}`);
944
- try {
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);
950
- } else
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);
955
- } finally {
956
- s(!1);
957
- }
958
- }, [o]);
959
- return V(() => {
960
- if (!t || !o) {
961
- s(!1);
962
- return;
963
- }
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();
970
- return;
971
- }
972
- const D = M.val();
973
- M.exists() && D !== C && (C = D, y());
974
- }), () => {
975
- Xe(v);
976
- };
977
- }
978
- }, [o, t, r]), {
979
- config: i,
980
- loading: p,
981
- error: b,
982
- refetch: y
983
- };
984
- }
985
- function $t(n) {
986
- const {
987
- seatMapId: o,
988
- userId: t,
989
- enabled: r = !0,
990
- subscribeToDesignChanges: u = !1,
991
- onConfigLoad: l,
992
- onStateChange: i,
993
- onError: m
994
- } = n, {
995
- config: p,
996
- loading: s,
997
- error: b,
998
- refetch: S
999
- } = Mt({
1000
- seatMapId: o,
1001
- enabled: r,
1002
- subscribeToChanges: u,
1003
- onConfigLoad: l,
1004
- onError: m
1005
- }), {
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({
1015
- seatMapId: o,
1016
- currentUserId: t,
1017
- enabled: r,
1018
- onStateChange: i,
1019
- onError: m
1020
- });
1021
- return {
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
1032
- };
1033
- }
1034
813
  export {
1035
- wt as DEFAULT_COLORS,
1036
- Lt as SeatMapViewer,
1037
- kt as clearFirebaseInstance,
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
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
1046
826
  };