@oneclick.dev/cms-core-modules 0.0.110 → 0.0.111

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.
Files changed (62) hide show
  1. package/dist/{Acquisition-Dt2rREU8.js → Acquisition-DgzDQH51.js} +1 -1
  2. package/dist/{Acquisition-DNCy8nQz.mjs → Acquisition-FV3QpaUX.mjs} +2 -2
  3. package/dist/{Audience-Bs7b0TNm.js → Audience-BSgNvcVb.js} +1 -1
  4. package/dist/{Audience-CUeMVYRy.mjs → Audience-ka0b7YPE.mjs} +2 -2
  5. package/dist/{ContentEditor-D9-1SJ5F.mjs → ContentEditor-pZPfo0qN.mjs} +4384 -4282
  6. package/dist/{ContentEditor-BprPiHMJ.js → ContentEditor-tYkh4vRV.js} +42 -42
  7. package/dist/{Create-89z41K73.js → Create--MOBOTA-.js} +1 -1
  8. package/dist/{Create-BCklc_T1.mjs → Create-BXNLRQag.mjs} +1 -1
  9. package/dist/DateFormatter-CSAbE3BC.js +1 -0
  10. package/dist/{DateFormatter-DUxlo8X8.mjs → DateFormatter-qbhRYxI_.mjs} +226 -222
  11. package/dist/{Detail-CNlljBfH.mjs → Detail-ChD5XurA.mjs} +1 -1
  12. package/dist/{Detail-C857g62L.js → Detail-RISEJJab.js} +1 -1
  13. package/dist/{Find-DIISO5GO.mjs → Find-zN_dKz4p.mjs} +1 -1
  14. package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-Baqy-rTT.js +1 -0
  15. package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-Dx4Bpa2m.mjs +1263 -0
  16. package/dist/{Overview-Di84CsR5.mjs → Overview-98nkJUWN.mjs} +162 -157
  17. package/dist/{Overview-C-Jb_BxY.mjs → Overview-BR_y8x3W.mjs} +1 -1
  18. package/dist/{Overview-DC9io1bk.js → Overview-CX-n6W7d.js} +1 -1
  19. package/dist/Overview-Dl8cMlsr.js +1 -0
  20. package/dist/{Overview-BKAti8nc.mjs → Overview-MpgkLB6m.mjs} +36 -36
  21. package/dist/{SeoHealth-az1YuNF2.js → SeoHealth-C5npw7mE.js} +1 -1
  22. package/dist/{SeoHealth-MC3lSCOY.mjs → SeoHealth-bVQj_Xgm.mjs} +29 -29
  23. package/dist/{TableView-DXHhJ-jm.mjs → TableView-Bf1fdJrD.mjs} +1838 -1822
  24. package/dist/TableView-DNcXyIMu.js +4 -0
  25. package/dist/{agenda-IOqtALWf.js → agenda-BaJu3-1c.js} +1 -1
  26. package/dist/{agenda-DcatSSYQ.mjs → agenda-BwVY_8oM.mjs} +3 -3
  27. package/dist/cms-core-modules.css +1 -1
  28. package/dist/{exceptions-CI0B4xVj.js → exceptions-B6P9UiCj.js} +1 -1
  29. package/dist/{exceptions-YCQkHa6a.mjs → exceptions-De9-FvdP.mjs} +67 -67
  30. package/dist/{index-CpzDEMeC.mjs → index-B8GvmAwh.mjs} +438 -478
  31. package/dist/{index-wjkEPsNx.mjs → index-BIF2RB7k.mjs} +1212 -1316
  32. package/dist/index-ByRsp77L.js +70 -0
  33. package/dist/{index-BhWvXMOp.mjs → index-CFzn2Lus.mjs} +5 -9
  34. package/dist/{index-BFLV54kw.mjs → index-CkVwMqpn.mjs} +1114 -1100
  35. package/dist/index-DL6orwdK.js +35 -0
  36. package/dist/index-DUlYrnXH.js +58 -0
  37. package/dist/index-DZV720u-.mjs +439 -0
  38. package/dist/index-D_nfGegA.js +184 -0
  39. package/dist/index-DtSvAFLL.js +54 -0
  40. package/dist/{index-D30apIn-.mjs → index-L54VBzwJ.mjs} +2 -3
  41. package/dist/{index-BzWmWCo5.mjs → index-hH3e-IYz.mjs} +267 -267
  42. package/dist/index.cjs.js +1 -1
  43. package/dist/index.mjs +15 -15
  44. package/dist/math-BJ-oX_IM.mjs +80 -0
  45. package/dist/math-emotyaF6.js +1 -0
  46. package/dist/{resources-CYOb5Bl6.mjs → resources-DwYxn2Vi.mjs} +1 -1
  47. package/dist/src/contentManager/components/content-editor/tiptap-extensions/ScopedSelectAll.d.ts +1 -2
  48. package/dist/src/contentManager/components/content-editor/tiptap-extensions/helpers/useFocus.d.ts +1 -0
  49. package/package.json +2 -2
  50. package/dist/DateFormatter-CYAD4GBN.js +0 -1
  51. package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-Ceoje52V.js +0 -1
  52. package/dist/NewReservationDialog.vue_vue_type_script_setup_true_lang-Dh9jzvE0.mjs +0 -1255
  53. package/dist/Overview-UoZHUMUz.js +0 -1
  54. package/dist/TableView-DQW0A1oG.js +0 -4
  55. package/dist/array-CbATeQbk.js +0 -1
  56. package/dist/array-DT5pE8Gm.mjs +0 -108
  57. package/dist/index-A2kp8Isi.js +0 -75
  58. package/dist/index-B5aBwdxY.js +0 -54
  59. package/dist/index-BiT55eU0.js +0 -58
  60. package/dist/index-G7cIlnGN.js +0 -158
  61. package/dist/index-V78huaSJ.mjs +0 -442
  62. package/dist/index-vHmvbEwa.js +0 -35
@@ -1,1255 +0,0 @@
1
- import { defineComponent as le, ref as F, reactive as we, computed as W, watch as ie, resolveComponent as _, openBlock as i, createElementBlock as f, createElementVNode as p, Fragment as Y, renderList as J, normalizeClass as ae, createVNode as o, withCtx as d, createTextVNode as T, toDisplayString as k, createCommentVNode as H, createBlock as se, onMounted as be, onBeforeUnmount as $e, nextTick as ye, unref as c, isRef as ce, markRaw as Te, inject as Re } from "vue";
2
- import { CalendarIcon as De, ChevronLeft as Ie, Check as Ce, ChevronRight as Ne, X as Ve, Zap as Oe, Plus as xe, Pencil as Le, Users as Fe, Tag as Pe, Trash2 as ge } from "lucide-vue-next";
3
- import { useModuleRoute as Ee, useModule as Me, useFirebaseIntegration as Ue } from "@oneclick.dev/cms-kit";
4
- import { c as pe } from "./utils-CanmrIWO.mjs";
5
- import { $ as Ae, e as _e, d as me } from "./DateFormatter-DUxlo8X8.mjs";
6
- import { _ as Se } from "./_plugin-vue_export-helper-CHgC5LLL.mjs";
7
- const ze = { class: "space-y-3" }, qe = { class: "grid gap-4 @md/modal:grid-cols-2 @2xl/modal:grid-cols-3 @4xl/modal:grid-cols-4 overflow-hidden p-1" }, je = {
8
- key: 0,
9
- class: "flex items-center gap-3 min-h-9"
10
- }, Be = {
11
- key: 0,
12
- class: "italic text-xs opacity-50"
13
- }, He = {
14
- key: 0,
15
- class: "italic text-xs opacity-50"
16
- }, Qe = {
17
- key: 0,
18
- class: "italic text-xs opacity-50"
19
- }, Ye = {
20
- key: 0,
21
- class: "italic text-xs opacity-50"
22
- }, Ge = {
23
- key: 0,
24
- class: "text-red-400"
25
- }, Xe = { class: "list-disc pl-4" }, We = /* @__PURE__ */ le({
26
- __name: "CustomerInformation",
27
- props: {
28
- agendaData: {}
29
- },
30
- setup(L, { expose: U }) {
31
- const V = [
32
- {
33
- id: "firstName",
34
- fieldName: "First Name",
35
- fieldType: "text",
36
- required: !0,
37
- visible: !0
38
- },
39
- {
40
- id: "lastName",
41
- fieldName: "Last Name",
42
- fieldType: "text",
43
- required: !0,
44
- visible: !0
45
- },
46
- {
47
- id: "phone",
48
- fieldName: "Phone No",
49
- fieldType: "tel",
50
- required: !0,
51
- visible: !0
52
- },
53
- {
54
- id: "email",
55
- fieldName: "Email",
56
- fieldType: "email",
57
- required: !0,
58
- visible: !0
59
- },
60
- {
61
- id: "birthdate",
62
- fieldName: "Birthdate",
63
- fieldType: "date",
64
- required: !0,
65
- visible: !0
66
- }
67
- ], E = /* @__PURE__ */ new Set(["firstName", "email"]), A = L, M = F([]), b = we({}), C = W(() => {
68
- const v = A.agendaData?.customerInformationFields, g = (Array.isArray(v) && v.length > 0 ? v : V).filter((N) => N?.id && (N.visible !== !1 || E.has(N.id))).map((N) => ({
69
- ...N,
70
- required: E.has(N.id),
71
- visible: !0
72
- })), w = V.filter((N) => E.has(N.id) && !g.some((X) => X.id === N.id)).map((N) => ({
73
- ...N,
74
- required: !0,
75
- visible: !0
76
- }));
77
- return [...g, ...w];
78
- }), D = (v) => v.fieldName || v.id, q = (v) => v.replace(/[^A-Za-z0-9_-]/g, "-"), y = (v, S) => ["new-res-customer-info", v.id, S].filter(Boolean).map((w) => q(w)).join("-"), R = (v) => v.fieldType === "email" || v.fieldType === "tel" || v.fieldType === "date" ? v.fieldType : "text", x = (v) => Array.isArray(v.options) ? v.options.filter(Boolean) : [], z = (v) => v.fieldType === "checkbox" ? !1 : "", j = (v = !1) => {
79
- const S = new Set(C.value.map((g) => g.id));
80
- Object.keys(b).forEach((g) => {
81
- S.has(g) || delete b[g];
82
- }), C.value.forEach((g) => {
83
- const w = z(g);
84
- (v || b[g.id] === void 0 || typeof b[g.id] != typeof w) && (b[g.id] = w);
85
- });
86
- }, G = () => {
87
- const v = C.value.reduce((S, g) => {
88
- const w = b[g.id];
89
- return S[g.id] = typeof w == "string" ? w.trim() : !!w, S;
90
- }, {});
91
- return Object.entries(v).forEach(([S, g]) => {
92
- b[S] = g;
93
- }), v;
94
- }, Q = (v, S) => v.fieldType === "checkbox" ? S === !0 : typeof S == "string" ? S.trim().length > 0 : S != null, K = () => {
95
- M.value = [], j(!0);
96
- }, B = () => {
97
- const v = [], S = G();
98
- return C.value.forEach((g) => {
99
- const w = S[g.id], N = D(g);
100
- g.required && !Q(g, w) && v.push(`Please fill in ${N}.`), g.fieldType === "email" && Q(g, w) && typeof w == "string" && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w) === !1 && v.push(`Please fill in a correct ${N}.`);
101
- }), M.value = v, v.length === 0;
102
- };
103
- return ie(C, () => {
104
- j();
105
- }, { immediate: !0 }), U({
106
- getCustomerInfo: G,
107
- reset: K,
108
- validateForm: B
109
- }), (v, S) => {
110
- const g = _("Checkbox"), w = _("Label"), N = _("SelectValue"), X = _("SelectTrigger"), ee = _("SelectItem"), te = _("SelectGroup"), ne = _("SelectContent"), Z = _("Select"), l = _("RadioGroupItem"), e = _("RadioGroup"), s = _("Input");
111
- return i(), f("div", ze, [
112
- S[0] || (S[0] = p("h2", { class: "text-sm font-medium" }, "Customer Information", -1)),
113
- p("div", qe, [
114
- (i(!0), f(Y, null, J(C.value, (n) => (i(), f("div", {
115
- key: n.id,
116
- class: ae(["grid gap-2", n.fieldType === "checkbox" ? "@md/modal:col-span-2" : ""])
117
- }, [
118
- n.fieldType === "checkbox" ? (i(), f("div", je, [
119
- o(g, {
120
- id: y(n),
121
- modelValue: b[n.id],
122
- "onUpdate:modelValue": (a) => b[n.id] = a
123
- }, null, 8, ["id", "modelValue", "onUpdate:modelValue"]),
124
- o(w, {
125
- for: y(n),
126
- class: "font-normal cursor-pointer"
127
- }, {
128
- default: d(() => [
129
- T(k(D(n)) + " ", 1),
130
- n.required ? H("", !0) : (i(), f("span", Be, "optional"))
131
- ]),
132
- _: 2
133
- }, 1032, ["for"])
134
- ])) : n.fieldType === "select" ? (i(), f(Y, { key: 1 }, [
135
- o(w, {
136
- for: y(n)
137
- }, {
138
- default: d(() => [
139
- T(k(D(n)) + " ", 1),
140
- n.required ? H("", !0) : (i(), f("span", He, "optional"))
141
- ]),
142
- _: 2
143
- }, 1032, ["for"]),
144
- o(Z, {
145
- modelValue: b[n.id],
146
- "onUpdate:modelValue": (a) => b[n.id] = a
147
- }, {
148
- default: d(() => [
149
- o(X, {
150
- id: y(n),
151
- class: "w-full"
152
- }, {
153
- default: d(() => [
154
- o(N, {
155
- placeholder: `Select ${D(n)}`
156
- }, null, 8, ["placeholder"])
157
- ]),
158
- _: 2
159
- }, 1032, ["id"]),
160
- o(ne, null, {
161
- default: d(() => [
162
- o(te, null, {
163
- default: d(() => [
164
- (i(!0), f(Y, null, J(x(n), (a) => (i(), se(ee, {
165
- key: a,
166
- value: a
167
- }, {
168
- default: d(() => [
169
- T(k(a), 1)
170
- ]),
171
- _: 2
172
- }, 1032, ["value"]))), 128))
173
- ]),
174
- _: 2
175
- }, 1024)
176
- ]),
177
- _: 2
178
- }, 1024)
179
- ]),
180
- _: 2
181
- }, 1032, ["modelValue", "onUpdate:modelValue"])
182
- ], 64)) : n.fieldType === "radio" ? (i(), f(Y, { key: 2 }, [
183
- o(w, null, {
184
- default: d(() => [
185
- T(k(D(n)) + " ", 1),
186
- n.required ? H("", !0) : (i(), f("span", Qe, "optional"))
187
- ]),
188
- _: 2
189
- }, 1024),
190
- o(e, {
191
- modelValue: b[n.id],
192
- "onUpdate:modelValue": (a) => b[n.id] = a,
193
- class: "grid gap-2"
194
- }, {
195
- default: d(() => [
196
- (i(!0), f(Y, null, J(x(n), (a) => (i(), f("div", {
197
- key: a,
198
- class: "flex items-center gap-2"
199
- }, [
200
- o(l, {
201
- id: y(n, a),
202
- value: a
203
- }, null, 8, ["id", "value"]),
204
- o(w, {
205
- for: y(n, a),
206
- class: "font-normal cursor-pointer"
207
- }, {
208
- default: d(() => [
209
- T(k(a), 1)
210
- ]),
211
- _: 2
212
- }, 1032, ["for"])
213
- ]))), 128))
214
- ]),
215
- _: 2
216
- }, 1032, ["modelValue", "onUpdate:modelValue"])
217
- ], 64)) : (i(), f(Y, { key: 3 }, [
218
- o(w, {
219
- for: y(n)
220
- }, {
221
- default: d(() => [
222
- T(k(D(n)) + " ", 1),
223
- n.required ? H("", !0) : (i(), f("span", Ye, "optional"))
224
- ]),
225
- _: 2
226
- }, 1032, ["for"]),
227
- o(s, {
228
- modelValue: b[n.id],
229
- "onUpdate:modelValue": (a) => b[n.id] = a,
230
- id: y(n),
231
- type: R(n),
232
- autocomplete: "off"
233
- }, null, 8, ["modelValue", "onUpdate:modelValue", "id", "type"])
234
- ], 64))
235
- ], 2))), 128))
236
- ]),
237
- M.value.length > 0 ? (i(), f("div", Ge, [
238
- p("ul", Xe, [
239
- (i(!0), f(Y, null, J(M.value, (n) => (i(), f("li", { key: n }, k(n), 1))), 128))
240
- ])
241
- ])) : H("", !0)
242
- ]);
243
- };
244
- }
245
- });
246
- function Ze(L = {}) {
247
- const U = F(null), V = F(!1), E = F(!1), A = F(!1), M = F(!1), b = L.dragSpeed ?? 1.1, C = L.dragThreshold ?? 10, D = L.edgeThreshold ?? 10, q = L.ignoreDragSelector ?? 'input, select, textarea, [contenteditable="true"], [data-horizontal-scroll-ignore-drag]';
248
- let y = null, R = 0, x = 0, z = !1, j = null, G = null, Q = null;
249
- const K = () => {
250
- j === null || typeof window > "u" || (window.clearTimeout(j), j = null);
251
- }, B = () => {
252
- const t = U.value;
253
- if (!t) {
254
- E.value = !1, A.value = !1, M.value = !1;
255
- return;
256
- }
257
- const m = Math.max(t.scrollWidth - t.clientWidth, 0);
258
- E.value = m > D, A.value = E.value && t.scrollLeft > D, M.value = E.value && t.scrollLeft < m - D;
259
- }, v = () => {
260
- ye(() => {
261
- if (typeof window > "u") {
262
- B();
263
- return;
264
- }
265
- window.requestAnimationFrame(() => B());
266
- });
267
- }, S = () => {
268
- if (typeof L.scrollStep == "number") return L.scrollStep;
269
- const t = U.value;
270
- return t ? Math.max(Math.floor(t.clientWidth * 0.72), 180) : 240;
271
- }, g = (t, m = "smooth") => {
272
- const r = U.value;
273
- if (r) {
274
- if (r.scrollBy({ left: t, behavior: m }), m === "auto") {
275
- B();
276
- return;
277
- }
278
- v();
279
- }
280
- }, w = () => {
281
- g(-S());
282
- }, N = () => {
283
- g(S());
284
- }, X = () => {
285
- const t = U.value;
286
- y !== null && t?.hasPointerCapture?.(y) && t.releasePointerCapture(y), V.value && (z = !0, K(), typeof window < "u" && (j = window.setTimeout(() => {
287
- z = !1, j = null;
288
- }, 0))), y = null, V.value = !1, t && (t.style.userSelect = "", t.style.cursor = ""), B();
289
- }, ee = () => {
290
- B();
291
- }, te = (t) => {
292
- const m = U.value;
293
- if (!m || !E.value || Math.abs(t.deltaY) <= Math.abs(t.deltaX)) return;
294
- const r = t.deltaY < 0, O = t.deltaY > 0;
295
- r && !A.value || O && !M.value || (t.preventDefault(), m.scrollLeft += t.deltaY, B());
296
- }, ne = (t) => t instanceof Element ? !!t.closest(q) : !1, Z = (t) => {
297
- const m = U.value;
298
- !m || !E.value || t.pointerType !== "touch" && t.button === 0 && (ne(t.target) || (y = t.pointerId, R = t.clientX, x = m.scrollLeft, z = !1));
299
- }, l = (t) => {
300
- const m = U.value;
301
- if (!m || y !== t.pointerId) return;
302
- const r = t.clientX - R;
303
- !V.value && Math.abs(r) < C || (V.value || (V.value = !0, m.style.userSelect = "none", m.style.cursor = "grabbing", m.setPointerCapture?.(t.pointerId)), t.preventDefault(), m.scrollLeft = x - r * b, B());
304
- }, e = (t) => {
305
- y === t.pointerId && X();
306
- }, s = () => {
307
- y !== null && X();
308
- }, n = (t) => {
309
- z && (t.preventDefault(), t.stopPropagation(), z = !1);
310
- }, a = (t) => {
311
- typeof ResizeObserver < "u" && (G = new ResizeObserver(() => B()), G.observe(t)), L.observeMutations !== !1 && typeof MutationObserver < "u" && (Q = new MutationObserver(() => v()), Q.observe(t, {
312
- childList: !0,
313
- subtree: !0,
314
- characterData: !0
315
- }));
316
- }, P = () => {
317
- G?.disconnect(), Q?.disconnect(), G = null, Q = null;
318
- }, $ = (t) => {
319
- t.addEventListener("scroll", ee), t.addEventListener("wheel", te, { passive: !1 }), t.addEventListener("pointerdown", Z), t.addEventListener("pointermove", l), t.addEventListener("pointerup", e), t.addEventListener("pointercancel", s), t.addEventListener("lostpointercapture", s), t.addEventListener("click", n, !0), a(t), v();
320
- }, u = (t) => {
321
- t.removeEventListener("scroll", ee), t.removeEventListener("wheel", te), t.removeEventListener("pointerdown", Z), t.removeEventListener("pointermove", l), t.removeEventListener("pointerup", e), t.removeEventListener("pointercancel", s), t.removeEventListener("lostpointercapture", s), t.removeEventListener("click", n, !0), P();
322
- };
323
- return ie(U, (t, m) => {
324
- m && u(m), t ? $(t) : B();
325
- }), be(() => {
326
- v();
327
- }), $e(() => {
328
- K(), U.value && u(U.value), z = !1, X();
329
- }), {
330
- canScrollLeft: W(() => A.value),
331
- canScrollRight: W(() => M.value),
332
- containerRef: U,
333
- isDragging: V,
334
- isScrollable: E,
335
- refresh: v,
336
- scrollNext: N,
337
- scrollPrev: w,
338
- showLeftShadow: A,
339
- showRightShadow: M
340
- };
341
- }
342
- const Je = { class: "flex items-start justify-between gap-3" }, Ke = { class: "text-sm font-medium" }, et = {
343
- key: 0,
344
- class: "mt-1 text-xs text-muted-foreground"
345
- }, tt = { class: "grid gap-4 @md/quick-adder:grid-cols-2 @2xl/quick-adder:grid-cols-3 @4xl/quick-adder:grid-cols-4" }, nt = { class: "grid gap-2" }, st = {
346
- key: 0,
347
- class: "grid gap-2"
348
- }, ot = {
349
- key: 1,
350
- class: "grid gap-2"
351
- }, at = {
352
- key: 2,
353
- class: "grid gap-2"
354
- }, rt = { class: "grid gap-2" }, lt = {
355
- key: 0,
356
- class: "rounded-md border border-dashed bg-muted/20 px-4 py-4 text-sm text-muted-foreground"
357
- }, it = {
358
- key: 1,
359
- class: "relative flex items-center gap-2 overflow-hidden"
360
- }, ut = { class: "relative min-w-0 flex-1 overflow-hidden" }, dt = {
361
- key: 0,
362
- class: "pointer-events-none absolute inset-y-0 left-0 z-10 w-10 md:w-20 bg-gradient-to-r from-background via-background/95 to-transparent"
363
- }, ct = {
364
- key: 1,
365
- class: "pointer-events-none absolute inset-y-0 right-0 z-10 w-10 md:w-20 bg-gradient-to-l from-background via-background/95 to-transparent"
366
- }, pt = {
367
- key: 0,
368
- class: "absolute -top-1 -right-1 flex items-center justify-center bg-primary rounded-full text-background size-4"
369
- }, mt = { class: "flex flex-wrap gap-2" }, ft = ["onClick"], vt = { key: 0 }, gt = { key: 1 }, _t = { key: 2 }, ht = /* @__PURE__ */ le({
370
- __name: "QuickReservationAdder",
371
- props: {
372
- agendaData: {},
373
- surface: { default: "card" }
374
- },
375
- emits: ["add"],
376
- setup(L, { emit: U }) {
377
- const V = L, E = U, A = new Ae("en-US", {
378
- dateStyle: "long"
379
- }), M = _e(me()), b = W(() => V.surface === "popover"), C = F(""), D = F(void 0), q = F(""), y = F(""), R = F([]), x = F(1), z = W(() => V.agendaData?.resources?.find((u) => u.id === q.value)), j = (u) => {
380
- const [t, m] = u.split(":").map(Number);
381
- return t * 60 + m;
382
- }, G = (u) => {
383
- const t = Math.floor(u / 60), m = u % 60;
384
- return `${t.toString().padStart(2, "0")}:${m.toString().padStart(2, "0")}`;
385
- }, Q = () => {
386
- if (!z.value) return [];
387
- const u = z.value.interval || 60;
388
- let t = null, m = null;
389
- for (const O of Object.values(z.value.openingHours || {}))
390
- for (const h of O) {
391
- const oe = j(h.start), re = j(h.end);
392
- (t === null || oe < t) && (t = oe), (m === null || re > m) && (m = re);
393
- }
394
- if (t === null || m === null) return [];
395
- const r = [];
396
- for (let O = t; O < m; O += u)
397
- r.push(G(O));
398
- return r;
399
- }, K = W(() => D.value && q.value && y.value && R.value.length > 0), B = W(() => Q()), {
400
- canScrollLeft: v,
401
- canScrollRight: S,
402
- containerRef: g,
403
- isDragging: w,
404
- isScrollable: N,
405
- scrollNext: X,
406
- scrollPrev: ee,
407
- showLeftShadow: te,
408
- showRightShadow: ne
409
- } = Ze(), Z = (u) => R.value.includes(u), l = (u) => {
410
- if (Z(u)) {
411
- R.value = R.value.filter((t) => t !== u);
412
- return;
413
- }
414
- R.value = [...R.value, u].sort((t, m) => j(t) - j(m));
415
- }, e = (u, t) => {
416
- D.value = u ? Te(u) : void 0, C.value = u ? `${u}` : "", t();
417
- }, s = F(""), n = F(""), a = F([]), P = () => {
418
- E("add", {
419
- date: D.value,
420
- resourceId: q.value,
421
- pricingOptionId: y.value,
422
- startTimes: R.value,
423
- spots: x.value
424
- }), R.value = [], a.value = [], n.value = "", s.value = "";
425
- }, $ = () => {
426
- C.value = M.toString(), D.value = M, q.value = V.agendaData?.resources?.[0]?.id || "", y.value = V.agendaData?.pricingOptions?.find((u) => u.isDefault)?.id || V.agendaData?.pricingOptions?.[0]?.id || "", R.value = [], x.value = 1, s.value = "";
427
- };
428
- return be(() => {
429
- $();
430
- }), (u, t) => {
431
- const m = _("Label"), r = _("Button"), O = _("PopoverTrigger"), h = _("Calendar"), oe = _("PopoverContent"), re = _("Popover"), fe = _("DynamicSelectOption"), ve = _("DynamicSelect"), ke = _("Input");
432
- return i(), f("div", {
433
- class: ae(c(pe)(
434
- "@container/quick-adder grid gap-4 overflow-hidden bg-background",
435
- c(b) ? "p-5 sm:p-6" : "rounded-md border p-4"
436
- ))
437
- }, [
438
- p("div", Je, [
439
- p("div", null, [
440
- p("h3", Ke, k(c(b) ? "Quick add reservations" : "Add reservations"), 1),
441
- c(b) ? (i(), f("p", et, " Choose one date and add multiple timeslots in one pass. ")) : H("", !0)
442
- ])
443
- ]),
444
- p("div", tt, [
445
- p("div", nt, [
446
- o(m, null, {
447
- default: d(() => [...t[3] || (t[3] = [
448
- T("Date", -1)
449
- ])]),
450
- _: 1
451
- }),
452
- o(re, null, {
453
- default: d(({ close: I }) => [
454
- o(O, { "as-child": "" }, {
455
- default: d(() => [
456
- o(r, {
457
- type: "button",
458
- variant: "outline",
459
- class: ae(c(pe)("w-full justify-start text-left font-normal", !c(D) && "text-muted-foreground"))
460
- }, {
461
- default: d(() => [
462
- o(c(De)),
463
- T(" " + k(c(D) ? c(A).format(c(D).toDate(c(me)())) : "Pick a date"), 1)
464
- ]),
465
- _: 1
466
- }, 8, ["class"])
467
- ]),
468
- _: 1
469
- }),
470
- o(oe, {
471
- class: "w-auto p-0",
472
- align: "start"
473
- }, {
474
- default: d(() => [
475
- o(h, {
476
- "model-value": c(D),
477
- "default-placeholder": c(M),
478
- layout: "month-and-year",
479
- "initial-focus": "",
480
- "onUpdate:modelValue": (ue) => e(ue, I),
481
- minValue: c(_e)(c(me)())
482
- }, null, 8, ["model-value", "default-placeholder", "onUpdate:modelValue", "minValue"])
483
- ]),
484
- _: 2
485
- }, 1024)
486
- ]),
487
- _: 1
488
- })
489
- ]),
490
- L.agendaData.resources?.length > 1 ? (i(), f("div", st, [
491
- o(m, null, {
492
- default: d(() => [...t[4] || (t[4] = [
493
- T("Resource", -1)
494
- ])]),
495
- _: 1
496
- }),
497
- o(ve, {
498
- modelValue: c(q),
499
- "onUpdate:modelValue": t[0] || (t[0] = (I) => ce(q) ? q.value = I : null),
500
- "wrapper-class": "w-full",
501
- class: "w-full",
502
- placeholder: "Select resource"
503
- }, {
504
- default: d(() => [
505
- (i(!0), f(Y, null, J(L.agendaData.resources || [], (I) => (i(), se(fe, {
506
- key: I.id,
507
- value: I.id
508
- }, {
509
- default: d(() => [
510
- T(k(I.name), 1)
511
- ]),
512
- _: 2
513
- }, 1032, ["value"]))), 128))
514
- ]),
515
- _: 1
516
- }, 8, ["modelValue"])
517
- ])) : H("", !0),
518
- L.agendaData.pricingOptions?.length > 1 ? (i(), f("div", ot, [
519
- o(m, null, {
520
- default: d(() => [...t[5] || (t[5] = [
521
- T("Type", -1)
522
- ])]),
523
- _: 1
524
- }),
525
- o(ve, {
526
- modelValue: c(y),
527
- "onUpdate:modelValue": t[1] || (t[1] = (I) => ce(y) ? y.value = I : null),
528
- "wrapper-class": "w-full",
529
- class: "w-full",
530
- placeholder: "Select type"
531
- }, {
532
- default: d(() => [
533
- (i(!0), f(Y, null, J(L.agendaData.pricingOptions || [], (I) => (i(), se(fe, {
534
- key: I.id,
535
- value: I.id
536
- }, {
537
- default: d(() => [
538
- T(k(I.name) + " (" + k(I.duration) + "min) ", 1)
539
- ]),
540
- _: 2
541
- }, 1032, ["value"]))), 128))
542
- ]),
543
- _: 1
544
- }, 8, ["modelValue"])
545
- ])) : H("", !0),
546
- L.agendaData?.maxTicketsPerReservation > 1 ? (i(), f("div", at, [
547
- o(m, null, {
548
- default: d(() => [...t[6] || (t[6] = [
549
- T("Spots/tickets", -1)
550
- ])]),
551
- _: 1
552
- }),
553
- o(ke, {
554
- modelValue: c(x),
555
- "onUpdate:modelValue": t[2] || (t[2] = (I) => ce(x) ? x.value = I : null),
556
- modelModifiers: { number: !0 },
557
- type: "number",
558
- min: "1",
559
- class: "no-spinner",
560
- autocomplete: "off"
561
- }, null, 8, ["modelValue"])
562
- ])) : H("", !0)
563
- ]),
564
- p("div", rt, [
565
- o(m, null, {
566
- default: d(() => [...t[7] || (t[7] = [
567
- T("Available hours", -1)
568
- ])]),
569
- _: 1
570
- }),
571
- c(B).length === 0 ? (i(), f("div", lt, " No preset hours are available for this resource. You can still add a custom time below. ")) : (i(), f("div", it, [
572
- c(v) ? (i(), se(r, {
573
- key: 0,
574
- type: "button",
575
- size: "icon",
576
- variant: "outline",
577
- class: "hidden absolute size-8 shrink-0 rounded-full shadow-sm md:inline-flex z-[11] left-0.5",
578
- onClick: c(ee)
579
- }, {
580
- default: d(() => [
581
- o(c(Ie), { class: "size-4" })
582
- ]),
583
- _: 1
584
- }, 8, ["onClick"])) : H("", !0),
585
- p("div", ut, [
586
- c(te) ? (i(), f("div", dt)) : H("", !0),
587
- c(ne) ? (i(), f("div", ct)) : H("", !0),
588
- p("div", {
589
- ref_key: "hourScrollContainer",
590
- ref: g,
591
- class: ae(c(pe)(
592
- "hour-scroll-track flex w-full min-w-0 gap-2 overflow-x-auto overscroll-contain py-2",
593
- c(N) && !c(w) && "cursor-grab",
594
- c(w) && "cursor-grabbing select-none"
595
- ))
596
- }, [
597
- (i(!0), f(Y, null, J(c(B), (I) => (i(), se(r, {
598
- key: I,
599
- type: "button",
600
- variant: "outline",
601
- class: ae(["relative h-12 shrink-0", Z(I) ? "border-primary!" : ""]),
602
- onClick: (ue) => l(I)
603
- }, {
604
- default: d(() => [
605
- T(k(I) + " ", 1),
606
- Z(I) ? (i(), f("div", pt, [
607
- o(c(Ce), { class: "size-3" })
608
- ])) : H("", !0)
609
- ]),
610
- _: 2
611
- }, 1032, ["class", "onClick"]))), 128))
612
- ], 2)
613
- ]),
614
- c(S) ? (i(), se(r, {
615
- key: 1,
616
- type: "button",
617
- size: "icon",
618
- variant: "outline",
619
- class: "hidden absolute size-8 shrink-0 rounded-full shadow-sm md:inline-flex z-[11] right-0.5",
620
- onClick: c(X)
621
- }, {
622
- default: d(() => [
623
- o(c(Ne), { class: "size-4" })
624
- ]),
625
- _: 1
626
- }, 8, ["onClick"])) : H("", !0)
627
- ])),
628
- p("div", mt, [
629
- (i(!0), f(Y, null, J(c(a), (I) => (i(), f("div", {
630
- key: I,
631
- class: "relative"
632
- }, [
633
- o(r, {
634
- type: "button",
635
- variant: "outline",
636
- class: "h-12 px-4 py-2"
637
- }, {
638
- default: d(() => [
639
- T(k(I), 1)
640
- ]),
641
- _: 2
642
- }, 1024),
643
- p("div", {
644
- class: "absolute -top-1 -right-1 flex items-center justify-center bg-red-500 rounded-full text-white size-4 cursor-pointer",
645
- onClick: (ue) => {
646
- a.value = c(a).filter((de) => de !== I), R.value = c(R).filter((de) => de !== I);
647
- }
648
- }, [
649
- o(c(Ve), { class: "size-3" })
650
- ], 8, ft)
651
- ]))), 128))
652
- ])
653
- ]),
654
- p("div", null, [
655
- o(r, {
656
- disabled: !c(K),
657
- onClick: P
658
- }, {
659
- default: d(() => [
660
- c(R).length === 0 ? (i(), f("span", vt, "Select at least one timeslot")) : c(R).length === 1 ? (i(), f("span", gt, "Add 1 reservation")) : (i(), f("span", _t, "Add " + k(c(R).length) + " reservations", 1))
661
- ]),
662
- _: 1
663
- }, 8, ["disabled"])
664
- ])
665
- ], 2);
666
- };
667
- }
668
- }), bt = /* @__PURE__ */ Se(ht, [["__scopeId", "data-v-c7529556"]]), yt = { class: "space-y-3" }, xt = { class: "flex flex-wrap items-center justify-between gap-3" }, St = { class: "text-xs text-muted-foreground" }, kt = { class: "flex flex-wrap items-center gap-2" }, wt = {
669
- key: 0,
670
- class: "rounded-md border border-dashed bg-muted/20 px-4 py-6 text-sm text-muted-foreground"
671
- }, $t = {
672
- key: 1,
673
- class: "space-y-3"
674
- }, Tt = { class: "flex items-start gap-2 p-3 md:hidden" }, Rt = ["aria-expanded", "onClick"], Dt = { class: "mt-0.5 flex size-10 shrink-0 items-center justify-center rounded-full bg-muted text-sm font-semibold text-muted-foreground" }, It = { class: "min-w-0 flex-1" }, Ct = { class: "flex items-start justify-between gap-3" }, Nt = { class: "min-w-0" }, Vt = { class: "block truncate text-base font-semibold" }, Ot = { class: "mt-1 block truncate text-xs text-muted-foreground" }, Lt = { class: "mt-1 block truncate text-xs text-muted-foreground" }, Ft = { class: "flex size-10 shrink-0 items-center justify-center rounded-xl border border-border/70 text-muted-foreground" }, Pt = { class: "mt-3 flex flex-wrap items-center gap-x-4 gap-y-1 text-sm text-muted-foreground" }, Et = { class: "inline-flex items-center gap-1.5" }, Mt = { class: "inline-flex items-center gap-1.5" }, Ut = { class: "hidden items-start justify-between gap-3 p-4 pb-0 md:flex" }, At = { class: "text-sm font-medium" }, zt = { class: "text-xs text-muted-foreground" }, qt = { class: "grid gap-4 border-t pt-3 md:grid-cols-2 md:border-0 md:pt-4 xl:grid-cols-5" }, jt = { class: "grid gap-2" }, Bt = {
675
- key: 0,
676
- class: "text-xs text-orange-500"
677
- }, Ht = { class: "grid gap-2" }, Qt = { class: "grid gap-2" }, Yt = { class: "grid gap-2" }, Gt = {
678
- key: 0,
679
- class: "grid gap-2"
680
- }, Xt = /* @__PURE__ */ le({
681
- __name: "ReservationLines",
682
- props: {
683
- modelValue: {},
684
- agendaData: {}
685
- },
686
- emits: ["add", "quick-add", "update:modelValue"],
687
- setup(L, { emit: U }) {
688
- const V = L, E = U, A = W(() => V.modelValue ?? []), M = W(() => Number(V.agendaData?.maxTicketsPerReservation) > 1), b = F(null), C = F(!1), D = W(() => String(V.agendaData?.currency || "EUR").toUpperCase()), q = W(() => {
689
- try {
690
- return new Intl.NumberFormat("en-US", {
691
- style: "currency",
692
- currency: D.value,
693
- minimumFractionDigits: 2,
694
- maximumFractionDigits: 2
695
- });
696
- } catch {
697
- return new Intl.NumberFormat("en-US", {
698
- minimumFractionDigits: 2,
699
- maximumFractionDigits: 2
700
- });
701
- }
702
- }), y = (l) => {
703
- E("update:modelValue", l);
704
- }, R = (l, e, s) => {
705
- y(A.value.map((n) => n.id !== l ? n : e === "date" ? {
706
- ...n,
707
- date: String(s ?? ""),
708
- dateValue: s || void 0
709
- } : {
710
- ...n,
711
- [e]: s
712
- }));
713
- }, x = (l, e) => {
714
- const s = Number(e);
715
- R(l, "paid", Number.isFinite(s) ? s : 0);
716
- }, z = (l, e) => {
717
- const s = Number(e);
718
- R(l, "spots", Number.isFinite(s) && s > 0 ? s : 1);
719
- }, j = (l) => {
720
- y(A.value.filter((e) => e.id !== l));
721
- }, G = (l) => {
722
- E("quick-add", l), C.value = !1;
723
- }, Q = (l) => V.agendaData?.pricingOptions?.find((e) => e.id === l.pricingOption), K = (l) => {
724
- const e = Q(l);
725
- return e ? e.duration ? `${e.name} (${e.duration}min)` : e.name : "Reservation";
726
- }, B = (l) => V.agendaData?.resources?.find((e) => e.id === l.resourceId), v = (l) => B(l)?.name || "Unknown resource", S = (l) => {
727
- if (!l.startTime) return "";
728
- const e = Number(Q(l)?.duration);
729
- if (!Number.isFinite(e) || e <= 0) return "";
730
- const [s, n] = l.startTime.split(":").map(Number);
731
- if (!Number.isFinite(s) || !Number.isFinite(n)) return "";
732
- const a = s * 60 + n + e, P = Math.floor(a / 60) % 24, $ = a % 60;
733
- return `${P.toString().padStart(2, "0")}:${$.toString().padStart(2, "0")}`;
734
- }, g = (l) => {
735
- if (!l.startTime) return "Select time";
736
- const e = S(l);
737
- return e ? `${l.startTime} - ${e}` : l.startTime;
738
- }, w = (l) => {
739
- const e = Number(l);
740
- if (!Number.isFinite(e)) return D.value === "EUR" ? "€0.00" : "0.00";
741
- try {
742
- return q.value.format(e);
743
- } catch {
744
- return `${e.toFixed(2)}`;
745
- }
746
- }, N = (l) => {
747
- const e = Number(l.spots), s = Number.isFinite(e) && e > 0 ? e : 1;
748
- return s === 1 ? "1 spot" : `${s} spots`;
749
- }, X = (l) => {
750
- if (!/^\d{4}-\d{2}-\d{2}$/.test(l)) return null;
751
- const [e, s, n] = l.split("-").map(Number), a = new Date(e, s - 1, n);
752
- return Number.isNaN(a.getTime()) || a.getFullYear() !== e || a.getMonth() !== s - 1 || a.getDate() !== n ? null : (a.setHours(0, 0, 0, 0), a);
753
- }, ee = (l) => {
754
- const e = X(String(l.date || "").trim());
755
- if (!e) return "";
756
- const s = /* @__PURE__ */ new Date();
757
- if (s.setHours(0, 0, 0, 0), e < s)
758
- return "This date is in the past. Double-check it before saving.";
759
- const n = new Date(s);
760
- return n.setFullYear(n.getFullYear() + 1), e > n ? "This date is more than a year ahead. Double-check it before saving." : "";
761
- }, te = (l) => !l.date || !l.startTime || !l.resourceId || !l.pricingOption, ne = (l) => b.value === l, Z = (l) => {
762
- b.value = b.value === l ? null : l;
763
- };
764
- return ie(A, (l) => {
765
- const e = new Set(l.map((s) => s.id));
766
- if (b.value && !e.has(b.value) && (b.value = null), !b.value) {
767
- const s = l.find(te);
768
- s && (b.value = s.id);
769
- }
770
- }, { immediate: !0 }), (l, e) => {
771
- const s = _("Button"), n = _("PopoverTrigger"), a = _("PopoverContent"), P = _("Popover"), $ = _("Label"), u = _("Input"), t = _("DynamicSelectOption"), m = _("DynamicSelect");
772
- return i(), f("div", yt, [
773
- p("div", xt, [
774
- p("p", St, k(A.value.length === 1 ? "1 reservation line" : `${A.value.length} reservation lines`), 1),
775
- p("div", kt, [
776
- o(P, {
777
- open: C.value,
778
- "onUpdate:open": e[0] || (e[0] = (r) => C.value = r)
779
- }, {
780
- default: d(() => [
781
- o(n, { "as-child": "" }, {
782
- default: d(() => [
783
- o(s, {
784
- type: "button",
785
- variant: "outline",
786
- size: "sm",
787
- class: "gap-2"
788
- }, {
789
- default: d(() => [
790
- o(c(Oe), { class: "size-4 text-primary" }),
791
- e[2] || (e[2] = T(" Quick add ", -1))
792
- ]),
793
- _: 1
794
- })
795
- ]),
796
- _: 1
797
- }),
798
- o(a, {
799
- align: "end",
800
- class: "max-h-[80vh] w-[min(34rem,calc(100vw-2rem))] overflow-y-auto p-0"
801
- }, {
802
- default: d(() => [
803
- C.value ? (i(), se(bt, {
804
- key: 0,
805
- surface: "popover",
806
- agendaData: L.agendaData,
807
- onAdd: G
808
- }, null, 8, ["agendaData"])) : H("", !0)
809
- ]),
810
- _: 1
811
- })
812
- ]),
813
- _: 1
814
- }, 8, ["open"]),
815
- o(s, {
816
- type: "button",
817
- variant: "outline",
818
- size: "sm",
819
- onClick: e[1] || (e[1] = (r) => E("add"))
820
- }, {
821
- default: d(() => [
822
- o(c(xe), { class: "size-4" }),
823
- e[3] || (e[3] = T(" Add line ", -1))
824
- ]),
825
- _: 1
826
- })
827
- ])
828
- ]),
829
- A.value.length === 0 ? (i(), f("div", wt, " Use Quick add to create filled reservation lines, or add an empty line manually. ")) : (i(), f("div", $t, [
830
- (i(!0), f(Y, null, J(A.value, (r, O) => (i(), f("div", {
831
- key: r.id,
832
- class: "rounded-xl border bg-background"
833
- }, [
834
- p("div", Tt, [
835
- p("button", {
836
- type: "button",
837
- class: "flex min-w-0 flex-1 items-start gap-3 rounded-lg px-1 py-1 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-ring/50",
838
- "aria-expanded": ne(r.id),
839
- onClick: (h) => Z(r.id)
840
- }, [
841
- p("span", Dt, k(O + 1), 1),
842
- p("span", It, [
843
- p("span", Ct, [
844
- p("span", Nt, [
845
- p("span", Vt, k(g(r)), 1),
846
- p("span", Ot, k(r.date || "No date selected"), 1),
847
- p("span", Lt, k(v(r)) + " · " + k(K(r)), 1)
848
- ]),
849
- p("span", Ft, [
850
- o(c(Le), { class: "size-4" })
851
- ])
852
- ]),
853
- p("span", Pt, [
854
- p("span", Et, [
855
- o(c(Fe), { class: "size-4" }),
856
- T(" " + k(N(r)), 1)
857
- ]),
858
- p("span", Mt, [
859
- o(c(Pe), { class: "size-4" }),
860
- T(" " + k(w(r.paid)), 1)
861
- ])
862
- ])
863
- ])
864
- ], 8, Rt),
865
- o(s, {
866
- type: "button",
867
- variant: "ghost",
868
- size: "icon",
869
- class: "mt-1 shrink-0",
870
- onClick: (h) => j(r.id)
871
- }, {
872
- default: d(() => [
873
- o(c(ge), { class: "size-4" })
874
- ]),
875
- _: 1
876
- }, 8, ["onClick"])
877
- ]),
878
- p("div", Ut, [
879
- p("div", null, [
880
- p("p", At, "Reservation " + k(O + 1), 1),
881
- p("p", zt, k(v(r)) + " · " + k(K(r)), 1)
882
- ]),
883
- o(s, {
884
- type: "button",
885
- variant: "ghost",
886
- size: "icon",
887
- class: "shrink-0",
888
- onClick: (h) => j(r.id)
889
- }, {
890
- default: d(() => [
891
- o(c(ge), { class: "size-4" })
892
- ]),
893
- _: 1
894
- }, 8, ["onClick"])
895
- ]),
896
- p("div", {
897
- class: ae(["px-3 pb-3 md:px-4 md:pb-4 overflow-hidden", ne(r.id) ? "block" : "hidden md:block"])
898
- }, [
899
- p("div", qt, [
900
- p("div", jt, [
901
- o($, null, {
902
- default: d(() => [...e[4] || (e[4] = [
903
- T("Date", -1)
904
- ])]),
905
- _: 1
906
- }),
907
- o(u, {
908
- "model-value": r.date,
909
- type: "date",
910
- "onUpdate:modelValue": (h) => R(r.id, "date", String(h ?? ""))
911
- }, null, 8, ["model-value", "onUpdate:modelValue"]),
912
- ee(r) ? (i(), f("p", Bt, k(ee(r)), 1)) : H("", !0)
913
- ]),
914
- p("div", Ht, [
915
- o($, {
916
- for: `new_reservation_res_line_${O}_time`
917
- }, {
918
- default: d(() => [...e[5] || (e[5] = [
919
- T("Time", -1)
920
- ])]),
921
- _: 1
922
- }, 8, ["for"]),
923
- o(u, {
924
- id: `new_reservation_res_line_${O}_time`,
925
- "model-value": r.startTime,
926
- type: "time",
927
- class: "reservation-time-input",
928
- "onUpdate:modelValue": (h) => R(r.id, "startTime", String(h ?? ""))
929
- }, null, 8, ["id", "model-value", "onUpdate:modelValue"])
930
- ]),
931
- p("div", Qt, [
932
- o($, null, {
933
- default: d(() => [...e[6] || (e[6] = [
934
- T("Resource", -1)
935
- ])]),
936
- _: 1
937
- }),
938
- o(m, {
939
- "model-value": r.resourceId,
940
- "wrapper-class": "w-full",
941
- class: "w-full",
942
- placeholder: "Select resource",
943
- "onUpdate:modelValue": (h) => R(r.id, "resourceId", String(h ?? ""))
944
- }, {
945
- default: d(() => [
946
- (i(!0), f(Y, null, J(L.agendaData?.resources || [], (h) => (i(), se(t, {
947
- key: h.id,
948
- value: h.id
949
- }, {
950
- default: d(() => [
951
- T(k(h.name), 1)
952
- ]),
953
- _: 2
954
- }, 1032, ["value"]))), 128))
955
- ]),
956
- _: 1
957
- }, 8, ["model-value", "onUpdate:modelValue"])
958
- ]),
959
- p("div", Yt, [
960
- o($, null, {
961
- default: d(() => [...e[7] || (e[7] = [
962
- T("Type", -1)
963
- ])]),
964
- _: 1
965
- }),
966
- o(m, {
967
- "model-value": r.pricingOption,
968
- "wrapper-class": "w-full",
969
- class: "w-full",
970
- placeholder: "Select type",
971
- "onUpdate:modelValue": (h) => R(r.id, "pricingOption", String(h ?? ""))
972
- }, {
973
- default: d(() => [
974
- (i(!0), f(Y, null, J(L.agendaData?.pricingOptions || [], (h) => (i(), se(t, {
975
- key: h.id,
976
- value: h.id
977
- }, {
978
- default: d(() => [
979
- T(k(h.name), 1)
980
- ]),
981
- _: 2
982
- }, 1032, ["value"]))), 128))
983
- ]),
984
- _: 1
985
- }, 8, ["model-value", "onUpdate:modelValue"])
986
- ]),
987
- p("div", {
988
- class: ae(["grid gap-4", M.value ? "md:grid-cols-2 xl:grid-cols-2 xl:col-span-1" : ""])
989
- }, [
990
- M.value ? (i(), f("div", Gt, [
991
- o($, null, {
992
- default: d(() => [...e[8] || (e[8] = [
993
- T("Spots", -1)
994
- ])]),
995
- _: 1
996
- }),
997
- o(u, {
998
- "model-value": r.spots,
999
- type: "number",
1000
- min: "1",
1001
- class: "no-spinner",
1002
- "onUpdate:modelValue": (h) => z(r.id, h)
1003
- }, null, 8, ["model-value", "onUpdate:modelValue"])
1004
- ])) : H("", !0),
1005
- p("div", {
1006
- class: ae(["grid gap-2", M.value ? "" : "md:col-span-2 xl:col-span-1"])
1007
- }, [
1008
- o($, null, {
1009
- default: d(() => [...e[9] || (e[9] = [
1010
- T("Paid", -1)
1011
- ])]),
1012
- _: 1
1013
- }),
1014
- o(u, {
1015
- "model-value": r.paid,
1016
- type: "number",
1017
- min: "0",
1018
- step: "1",
1019
- class: "no-spinner",
1020
- "onUpdate:modelValue": (h) => x(r.id, h)
1021
- }, null, 8, ["model-value", "onUpdate:modelValue"])
1022
- ], 2)
1023
- ], 2)
1024
- ])
1025
- ], 2)
1026
- ]))), 128))
1027
- ]))
1028
- ]);
1029
- };
1030
- }
1031
- }), Wt = /* @__PURE__ */ Se(Xt, [["__scopeId", "data-v-9b860aae"]]), Zt = { class: "space-y-5 md:mt-5" }, Jt = { class: "space-y-3" }, Kt = { class: "mt-4 text-red-400" }, en = { class: "list-disc pl-4" }, tn = { key: 0 }, nn = { key: 1 }, he = "00:00", dn = /* @__PURE__ */ le({
1032
- __name: "NewReservationDialog",
1033
- props: {
1034
- agendaData: {}
1035
- },
1036
- setup(L) {
1037
- const U = L, { params: V } = Ee(), { config: E } = Me(), A = Ue(E.project), M = W(() => V.value?.id ?? V.id ?? ""), b = Re("agendaData", F({})), C = W(() => U.agendaData ?? b.value ?? {}), D = F(!1), q = F(!1), y = F([]), R = /^([01]\d|2[0-3]):[0-5]\d$/, x = F([]), z = F(null), j = () => C.value?.resources?.[0]?.id ?? "", G = () => C.value?.pricingOptions?.find((e) => e.isDefault === !0)?.id ?? C.value?.pricingOptions?.[0]?.id ?? "", Q = (e) => {
1038
- let s = e?.pricingOption ?? G(), n = C.value?.pricingOptions?.find((P) => P.id === s)?.price ?? 0;
1039
- typeof n == "string" && (n = Number(n));
1040
- let a = e?.paid ?? n;
1041
- return typeof a == "string" && (a = Number(a)), {
1042
- id: `reservation_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
1043
- spots: Number(e?.spots) || 1,
1044
- paid: Number.isFinite(a) ? a : 0,
1045
- resourceId: e?.resourceId ?? j(),
1046
- pricingOption: s,
1047
- date: e?.date ?? "",
1048
- dateValue: e?.dateValue,
1049
- startTime: e?.startTime ?? he
1050
- };
1051
- }, K = () => {
1052
- x.value = [Q()];
1053
- }, B = (e) => !e.date && e.startTime === he, v = () => {
1054
- const e = x.value[x.value.length - 1];
1055
- x.value = [...x.value, Q(e ? { ...e } : void 0)];
1056
- }, S = (e) => C.value?.pricingOptions?.find((s) => s.id === e.pricingOption), g = (e) => C.value?.resources?.find((s) => s.id === e.resourceId), w = () => {
1057
- const e = Number(C.value?.maxTicketsPerReservation);
1058
- return Number.isFinite(e) && e > 0 ? e : null;
1059
- }, N = (e) => `Reservation ${e + 1}`, X = (e) => {
1060
- const s = String(e.date || "").trim(), n = String(e.startTime || "").trim(), a = String(e.resourceId || "").trim();
1061
- return !s || !n || !a ? "" : `${a}_${s}_${n}`;
1062
- }, ee = () => {
1063
- const e = [], s = /* @__PURE__ */ new Map(), n = w();
1064
- return x.value.forEach((a, P) => {
1065
- const $ = N(P), u = String(a.date || "").trim(), t = String(a.startTime || "").trim(), m = String(a.resourceId || "").trim(), r = String(a.pricingOption || "").trim(), O = Number(a.spots), h = Number(a.paid);
1066
- u || e.push(`${$}: please select a date.`), t ? R.test(t) || e.push(`${$}: please enter a valid time.`) : e.push(`${$}: please select a time.`), m ? g(a) || e.push(`${$}: the selected resource is no longer available.`) : e.push(`${$}: please select a resource.`), r ? S(a) || e.push(`${$}: the selected type is no longer available.`) : e.push(`${$}: please select a type.`), !Number.isFinite(O) || O <= 0 ? e.push(`${$}: spots must be at least 1.`) : n !== null && O > n && e.push(`${$}: spots cannot be more than ${n}.`), (!Number.isFinite(h) || h < 0) && e.push(`${$}: paid amount must be 0 or higher.`);
1067
- const oe = X(a);
1068
- if (oe) {
1069
- const re = s.get(oe);
1070
- re !== void 0 ? e.push(`${$}: duplicate of ${N(re).toLowerCase()}.`) : s.set(oe, P);
1071
- }
1072
- }), e;
1073
- }, te = (e) => {
1074
- const s = e.startTimes.map((n) => Q({
1075
- date: e.date ? `${e.date}` : "",
1076
- dateValue: e.date,
1077
- pricingOption: e.pricingOptionId,
1078
- resourceId: e.resourceId,
1079
- spots: e.spots,
1080
- startTime: n
1081
- }));
1082
- if (s.length !== 0) {
1083
- if (x.value.length === 1 && B(x.value[0])) {
1084
- x.value = s;
1085
- return;
1086
- }
1087
- x.value = [...x.value, ...s];
1088
- }
1089
- }, ne = (e) => {
1090
- if (!e.startTime || !e.pricingOption) return "";
1091
- const s = S(e);
1092
- if (!s?.duration) return e.startTime;
1093
- const [n, a] = e.startTime.split(":").map(Number);
1094
- if (isNaN(n) || isNaN(a)) return "";
1095
- const P = n * 60 + a + s.duration, $ = Math.floor(P / 60) % 24, u = P % 60;
1096
- return `${$.toString().padStart(2, "0")}:${u.toString().padStart(2, "0")}`;
1097
- };
1098
- ie(D, async (e) => {
1099
- e && (y.value = [], K(), await ye(), z.value?.reset());
1100
- });
1101
- const Z = () => {
1102
- const e = [];
1103
- y.value = [];
1104
- const s = z.value, n = s ? s.validateForm() : !1;
1105
- return s || e.push("Customer information form is unavailable."), x.value.length === 0 && e.push("Please add at least one reservation."), e.push(...ee()), y.value = e, e.length === 0 && n;
1106
- }, l = async () => {
1107
- const e = z.value;
1108
- if (!e || !Z()) return;
1109
- let s = !1;
1110
- try {
1111
- q.value = !0;
1112
- const n = e.getCustomerInfo(), a = x.value.map((u) => {
1113
- const t = Number(u.paid) || 0, m = Number(u.spots) || 1, r = S(u), O = g(u), h = u.date;
1114
- return {
1115
- paidAmount: t,
1116
- flattenedReservationDate: `${u.resourceId}_${h}`,
1117
- flattenedReservation: `${u.resourceId}_${h}_${u.startTime.replace(":", "")}`,
1118
- reservation: {
1119
- status: "approved",
1120
- totalPrice: Number(t.toFixed(2)),
1121
- basePrice: Number((t / m).toFixed(2)),
1122
- addOnsPrice: 0,
1123
- addOns: [],
1124
- date: h,
1125
- id: `res_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
1126
- pricingOption: {
1127
- duration: r?.duration || "",
1128
- id: r?.id || "",
1129
- name: r?.name || "",
1130
- price: r?.price || ""
1131
- },
1132
- pricingOptionId: u.pricingOption,
1133
- resource: {
1134
- avatarLabel: O?.avatarLabel || "",
1135
- color: O?.color || "",
1136
- description: O?.description || "",
1137
- id: O?.id || "",
1138
- name: O?.name || ""
1139
- },
1140
- resourceId: u.resourceId,
1141
- spots: m,
1142
- timeslot: {
1143
- startTime: u.startTime,
1144
- endTime: ne(u)
1145
- }
1146
- }
1147
- };
1148
- }), P = Number(a.reduce((u, t) => u + t.paidAmount, 0).toFixed(2)), $ = {
1149
- agendaId: M.value,
1150
- customerInfo: n,
1151
- metadata: {},
1152
- amountPaid: P,
1153
- amountDue: 0,
1154
- subtotal: P,
1155
- total: P,
1156
- createdAt: /* @__PURE__ */ new Date(),
1157
- updatedAt: /* @__PURE__ */ new Date(),
1158
- discount: 0,
1159
- flattenedReservationDates: Array.from(new Set(a.map((u) => u.flattenedReservationDate))),
1160
- flattenedReservations: a.map((u) => u.flattenedReservation),
1161
- paymentStatus: "paid",
1162
- paymentType: "full",
1163
- reservations: a.map((u) => u.reservation),
1164
- status: "confirmed"
1165
- };
1166
- await A.add(E.reservationsCollection, $), s = !0;
1167
- } catch (n) {
1168
- console.error("Error creating reservation:", n);
1169
- } finally {
1170
- q.value = !1, s && (D.value = !1);
1171
- }
1172
- };
1173
- return (e, s) => {
1174
- const n = _("Button"), a = _("ResponsiveModalTrigger"), P = _("ResponsiveModalTitle"), $ = _("ResponsiveModalHeader"), u = _("ResponsiveModalFooter"), t = _("ResponsiveModalScrollContent"), m = _("ResponsiveModal");
1175
- return i(), se(m, {
1176
- open: D.value,
1177
- "onUpdate:open": s[1] || (s[1] = (r) => D.value = r)
1178
- }, {
1179
- default: d(() => [
1180
- o(a, { "as-child": "" }, {
1181
- default: d(() => [
1182
- o(n, null, {
1183
- default: d(() => [
1184
- o(c(xe), { class: "size-4" }),
1185
- s[2] || (s[2] = T(" Add Reservation ", -1))
1186
- ]),
1187
- _: 1
1188
- })
1189
- ]),
1190
- _: 1
1191
- }),
1192
- o(t, { class: "@container/modal sm:max-w-7xl" }, {
1193
- default: d(() => [
1194
- o($, null, {
1195
- default: d(() => [
1196
- o(P, null, {
1197
- default: d(() => [...s[3] || (s[3] = [
1198
- T("Create new reservation", -1)
1199
- ])]),
1200
- _: 1
1201
- })
1202
- ]),
1203
- _: 1
1204
- }),
1205
- p("div", Zt, [
1206
- o(We, {
1207
- ref_key: "customerInformationRef",
1208
- ref: z,
1209
- agendaData: C.value
1210
- }, null, 8, ["agendaData"]),
1211
- s[5] || (s[5] = p("div", { class: "w-full h-[1px] bg-border my-8" }, null, -1)),
1212
- p("div", Jt, [
1213
- s[4] || (s[4] = p("div", { class: "flex items-center justify-between gap-3" }, [
1214
- p("h2", { class: "text-sm font-medium" }, "Reservations")
1215
- ], -1)),
1216
- o(Wt, {
1217
- modelValue: x.value,
1218
- "onUpdate:modelValue": s[0] || (s[0] = (r) => x.value = r),
1219
- agendaData: C.value,
1220
- onAdd: v,
1221
- onQuickAdd: te
1222
- }, null, 8, ["modelValue", "agendaData"])
1223
- ]),
1224
- p("div", Kt, [
1225
- p("ul", en, [
1226
- (i(!0), f(Y, null, J(y.value, (r) => (i(), f("li", { key: r }, k(r), 1))), 128))
1227
- ])
1228
- ])
1229
- ]),
1230
- o(u, { class: "gap-2" }, {
1231
- default: d(() => [
1232
- o(n, {
1233
- onClick: l,
1234
- disabled: q.value
1235
- }, {
1236
- default: d(() => [
1237
- q.value ? (i(), f("span", tn, "Creating...")) : (i(), f("span", nn, k(x.value.length > 1 ? `Create ${x.value.length} reservations` : "Create reservation"), 1))
1238
- ]),
1239
- _: 1
1240
- }, 8, ["disabled"])
1241
- ]),
1242
- _: 1
1243
- })
1244
- ]),
1245
- _: 1
1246
- })
1247
- ]),
1248
- _: 1
1249
- }, 8, ["open"]);
1250
- };
1251
- }
1252
- });
1253
- export {
1254
- dn as _
1255
- };