@zonetrix/viewer 2.11.0 → 2.11.2

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