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