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