@oneclick.dev/cms-core-modules 0.0.52 → 0.0.54

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 (128) hide show
  1. package/dist/CalendarDate-CRT2Viyt.mjs +830 -0
  2. package/dist/CalendarDate-CWtpXgpD.js +1 -0
  3. package/dist/Components-D9yIIosM.mjs +623 -0
  4. package/dist/Components-DXbx0RLV.js +1 -0
  5. package/dist/ContentEditor-DRJFQKCv.mjs +34915 -0
  6. package/dist/ContentEditor-DzTi8fSZ.js +290 -0
  7. package/dist/Create-BP8TX6rj.js +1 -0
  8. package/dist/Create-Bwf1RXdG.mjs +1248 -0
  9. package/dist/DateFormatter-BbcSwTs4.js +1 -0
  10. package/dist/DateFormatter-CbO0PVUK.mjs +99 -0
  11. package/dist/Detail-B-PnkcXD.mjs +3473 -0
  12. package/dist/Detail-BVlGSjOq.mjs +380 -0
  13. package/dist/Detail-C4E1T87K.mjs +26 -0
  14. package/dist/Detail-CNfTDUE5.js +1 -0
  15. package/dist/Detail-Cd5CBVN0.js +1 -0
  16. package/dist/Detail-CpfOQChd.mjs +585 -0
  17. package/dist/Detail-CwagT6gQ.mjs +650 -0
  18. package/dist/Detail-DUo6qKqO.js +1 -0
  19. package/dist/Detail-Dd_OkpcN.js +1 -0
  20. package/dist/Detail-mvSGbnFU.js +1 -0
  21. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-BWuKVkvV.js +1 -0
  22. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-D0-EcU0_.mjs +55 -0
  23. package/dist/Entries-DcpPvlYj.js +1 -0
  24. package/dist/Entries-QLMtTYLX.mjs +713 -0
  25. package/dist/Find-BPR0uU-Z.mjs +229 -0
  26. package/dist/Find-BidEQJxT.js +1 -0
  27. package/dist/GlobalStyling-CMzPRd18.js +17 -0
  28. package/dist/GlobalStyling-DoLHUJeV.mjs +988 -0
  29. package/dist/Overview-BDlBCUI_.js +1 -0
  30. package/dist/Overview-BH3NwvNX.mjs +26 -0
  31. package/dist/Overview-BLsZMHNW.mjs +178 -0
  32. package/dist/Overview-BNMZ9MUK.js +1 -0
  33. package/dist/Overview-BbvfH1u-.js +1 -0
  34. package/dist/Overview-CDN88OSM.mjs +190 -0
  35. package/dist/Overview-CEPodGCn.mjs +311 -0
  36. package/dist/Overview-CvquDPhB.js +1 -0
  37. package/dist/Overview-D54pjmI6.mjs +633 -0
  38. package/dist/Overview-D67UjG6n.mjs +947 -0
  39. package/dist/Overview-KT2Mgfh5.js +1 -0
  40. package/dist/Overview-T-lsy3UZ.js +1 -0
  41. package/dist/RegularSlotEditor.vue_vue_type_script_setup_true_lang-0xZSq0rx.js +1 -0
  42. package/dist/RegularSlotEditor.vue_vue_type_script_setup_true_lang-Bj_PVLLV.mjs +392 -0
  43. package/dist/TableView-CpO53xcX.js +111 -0
  44. package/dist/TableView-D9J5rUls.mjs +72921 -0
  45. package/dist/TemplateList.vue_vue_type_script_setup_true_lang-B_AtWnHa.js +1 -0
  46. package/dist/TemplateList.vue_vue_type_script_setup_true_lang-BiLAkhIA.mjs +40 -0
  47. package/dist/View-DlHBZbFu.js +1 -0
  48. package/dist/View-Dv5QMrSn.mjs +25 -0
  49. package/dist/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
  50. package/dist/_plugin-vue_export-helper-CHgC5LLL.mjs +9 -0
  51. package/dist/agenda-B49oKGeh.mjs +706 -0
  52. package/dist/agenda-DipQ5IWP.js +1 -0
  53. package/dist/availability-C7q9tq6l.js +1 -0
  54. package/dist/availability-DeCkqiu8.mjs +613 -0
  55. package/dist/cms-core-modules.css +1 -1
  56. package/dist/countries-BTPvmrsb.mjs +4 -0
  57. package/dist/countries-CgZ081No.js +1 -0
  58. package/dist/exceptions-D3b18TiY.mjs +647 -0
  59. package/dist/exceptions-DJ9zWX3k.js +1 -0
  60. package/dist/floating-ui.dom-C82nbomj.js +1 -0
  61. package/dist/floating-ui.dom-ouSgPqty.mjs +1133 -0
  62. package/dist/google-CvtuJwgk.mjs +4 -0
  63. package/dist/google-D4N3gb01.js +1 -0
  64. package/dist/index--jjEzba7.mjs +24 -0
  65. package/dist/index-9HVlmvK3.js +1 -0
  66. package/dist/index-BEGU8Kme.mjs +12 -0
  67. package/dist/index-Bwi1mtkq.mjs +24 -0
  68. package/dist/index-BzuHN-r8.mjs +24 -0
  69. package/dist/index-CImCyE3L.mjs +24 -0
  70. package/dist/index-CKPshlZ8-BQiiP6r_.mjs +1264 -0
  71. package/dist/index-CKPshlZ8-CIz1tDwX.js +1 -0
  72. package/dist/index-CQiY-oTN.mjs +24 -0
  73. package/dist/index-CSxYBeVA.js +1 -0
  74. package/dist/index-CkiNvRzs.js +1 -0
  75. package/dist/index-Co4ON2Di.js +1 -0
  76. package/dist/index-CwqrAU-H.js +1 -0
  77. package/dist/index-Cz-baGax.js +1 -0
  78. package/dist/index-D2a6wEPh.js +1 -0
  79. package/dist/index-DFQGVHTs.js +1 -0
  80. package/dist/index-DI6mydpm.mjs +138 -0
  81. package/dist/index-DMoyoaks.mjs +22 -0
  82. package/dist/index-DT1wWnUk.mjs +24 -0
  83. package/dist/index-DUeFrD-B.js +1 -0
  84. package/dist/index-DsnoK4ia.mjs +579 -0
  85. package/dist/index-R2oUDsjx.js +1 -0
  86. package/dist/index-RLz1QPrf.mjs +203 -0
  87. package/dist/index-UtjLbLw-.js +1 -0
  88. package/dist/index-_mG-aU3Z.mjs +87 -0
  89. package/dist/index-_sQDF1pH.js +1 -0
  90. package/dist/index-ijdf0d9-.js +1 -0
  91. package/dist/index-klI238nT.mjs +24 -0
  92. package/dist/index.cjs.js +1 -357
  93. package/dist/index.mjs +287 -69281
  94. package/dist/interpolation-BNUjI7LH.js +1 -0
  95. package/dist/interpolation-BpGXqOz8.mjs +59 -0
  96. package/dist/payment-kTjsV0Jj.js +1 -0
  97. package/dist/payment-zpCM0LD-.mjs +981 -0
  98. package/dist/regular-C4_3YXqx.mjs +602 -0
  99. package/dist/regular-DFwPEbZO.js +1 -0
  100. package/dist/regular-slots-4ooEpICB.mjs +67 -0
  101. package/dist/regular-slots-BAVGbomI.js +1 -0
  102. package/dist/resources-MpQkSstv.mjs +563 -0
  103. package/dist/resources-iM28T3dD.js +1 -0
  104. package/dist/src/appointments/components/edit/PaymentAddons/Addon.vue.d.ts +12 -2
  105. package/dist/src/appointments/index.d.ts +4 -28
  106. package/dist/src/appointments/routes.d.ts +3 -9
  107. package/dist/src/content-manager/index.d.ts +5 -147
  108. package/dist/src/content-manager/routes.d.ts +4 -128
  109. package/dist/src/custom/index.d.ts +2 -2
  110. package/dist/src/custom/routes.d.ts +1 -1
  111. package/dist/src/lib/interpolation.d.ts +2 -2
  112. package/dist/src/mail-templates/index.d.ts +2 -30
  113. package/dist/src/mail-templates/routes.d.ts +1 -11
  114. package/dist/src/product-collections/index.d.ts +2 -30
  115. package/dist/src/product-collections/routes.d.ts +1 -11
  116. package/dist/src/products/index.d.ts +2 -30
  117. package/dist/src/products/routes.d.ts +1 -11
  118. package/dist/src/promo-codes/index.d.ts +2 -30
  119. package/dist/src/promo-codes/routes.d.ts +1 -11
  120. package/dist/src/shipping-options/index.d.ts +2 -30
  121. package/dist/src/shipping-options/routes.d.ts +1 -11
  122. package/dist/src/table/index.d.ts +2 -70
  123. package/dist/src/table/routes.d.ts +1 -51
  124. package/dist/utils-BVKy9S2J.mjs +29 -0
  125. package/dist/utils-D6CaKJbp.js +2 -0
  126. package/dist/vee-validate-zod-BPQyEfpF.js +1 -0
  127. package/dist/vee-validate-zod-IXkfh-6Q.mjs +4402 -0
  128. package/package.json +28 -29
@@ -0,0 +1,1248 @@
1
+ import { defineComponent as z, inject as L, resolveComponent as o, createElementBlock as $, openBlock as p, Fragment as E, createVNode as e, withCtx as t, createTextVNode as a, unref as n, createElementVNode as s, ref as A, createBlock as U, createCommentVNode as F, toDisplayString as T, useTemplateRef as ue, renderList as le, computed as ie, normalizeClass as Q, withAsyncContext as de, provide as X } from "vue";
2
+ import { Import as re, DollarSign as oe, Percent as ne, Truck as se, Info as me, Loader2 as K, UserCog as pe, Plus as Z, Pencil as fe, Trash2 as ve, CalendarIcon as h, List as ce } from "lucide-vue-next";
3
+ import { useModulePermissions as j, useModuleStorage as W, useConfirmation as _e, useModuleRoute as ge, useProjectSettings as xe, useLogs as ye, useModuleBreadcrumbs as be, useFirebaseIntegration as we } from "@oneclick.dev/cms-kit";
4
+ import { c as ee } from "./utils-BVKy9S2J.mjs";
5
+ import { g as te, n as Ve } from "./CalendarDate-CRT2Viyt.mjs";
6
+ import { $ as Ue } from "./DateFormatter-CbO0PVUK.mjs";
7
+ import { t as I } from "./index-RLz1QPrf.mjs";
8
+ const Ce = /* @__PURE__ */ z({
9
+ __name: "SingleCode",
10
+ setup(N) {
11
+ const d = L("newCoupon");
12
+ return (S, r) => {
13
+ const f = o("Label"), c = o("Input");
14
+ return p(), $(E, null, [
15
+ e(f, {
16
+ class: "text-muted-foreground mb-2",
17
+ for: "code"
18
+ }, {
19
+ default: t(() => [...r[1] || (r[1] = [
20
+ a("Enter the coupon code", -1)
21
+ ])]),
22
+ _: 1
23
+ }),
24
+ e(c, {
25
+ modelValue: n(d).code,
26
+ "onUpdate:modelValue": r[0] || (r[0] = (u) => n(d).code = u),
27
+ id: "code"
28
+ }, null, 8, ["modelValue"])
29
+ ], 64);
30
+ };
31
+ }
32
+ }), De = { class: "flex items-center space-x-2" }, ke = { class: "flex items-center space-x-2" }, $e = {
33
+ key: 0,
34
+ class: "flex items-end w-full gap-4"
35
+ }, Se = { class: "relative w-full" }, Te = { key: 1 }, Pe = /* @__PURE__ */ z({
36
+ __name: "MultiCodes",
37
+ setup(N) {
38
+ const d = L("newCoupon");
39
+ return (S, r) => {
40
+ const f = o("RadioGroupItem"), c = o("Label"), u = o("RadioGroup"), x = o("NumberFieldDecrement"), k = o("NumberFieldInput"), _ = o("NumberFieldIncrement"), i = o("NumberFieldContent"), y = o("NumberField"), w = o("Input"), m = o("Textarea");
41
+ return p(), $(E, null, [
42
+ r[8] || (r[8] = s("p", { class: "text-sm text-muted-foreground mb-2" }, "How do you want to create the codes?", -1)),
43
+ e(u, {
44
+ modelValue: n(d).generationMode,
45
+ "onUpdate:modelValue": r[0] || (r[0] = (C) => n(d).generationMode = C),
46
+ orientation: "vertical",
47
+ class: "mb-6"
48
+ }, {
49
+ default: t(() => [
50
+ s("div", De, [
51
+ e(f, {
52
+ id: "generation_mode_generate",
53
+ value: "generate"
54
+ }),
55
+ e(c, { for: "generation_mode_generate" }, {
56
+ default: t(() => [...r[3] || (r[3] = [
57
+ a("Generate random codes", -1)
58
+ ])]),
59
+ _: 1
60
+ })
61
+ ]),
62
+ s("div", ke, [
63
+ e(f, {
64
+ id: "generation_mode_input",
65
+ value: "input"
66
+ }),
67
+ e(c, { for: "generation_mode_input" }, {
68
+ default: t(() => [...r[4] || (r[4] = [
69
+ a("Provide specific codes", -1)
70
+ ])]),
71
+ _: 1
72
+ })
73
+ ])
74
+ ]),
75
+ _: 1
76
+ }, 8, ["modelValue"]),
77
+ n(d).generationMode == "generate" ? (p(), $("div", $e, [
78
+ e(y, {
79
+ id: "age",
80
+ "default-value": 1,
81
+ min: 1,
82
+ class: "w-full"
83
+ }, {
84
+ default: t(() => [
85
+ e(c, {
86
+ for: "age",
87
+ class: "text-muted-foreground mb-2"
88
+ }, {
89
+ default: t(() => [...r[5] || (r[5] = [
90
+ a("Number of codes to generate", -1)
91
+ ])]),
92
+ _: 1
93
+ }),
94
+ e(i, null, {
95
+ default: t(() => [
96
+ e(x),
97
+ e(k),
98
+ e(_)
99
+ ]),
100
+ _: 1
101
+ })
102
+ ]),
103
+ _: 1
104
+ }),
105
+ s("div", Se, [
106
+ e(w, {
107
+ modelValue: n(d).prefix,
108
+ "onUpdate:modelValue": r[1] || (r[1] = (C) => n(d).prefix = C),
109
+ placeholder: "Prefix",
110
+ class: "pr-42"
111
+ }, null, 8, ["modelValue"]),
112
+ r[6] || (r[6] = s("span", { class: "absolute right-2 top-1/2 transform -translate-y-1/2 text-muted-foreground/80 pointer-events-none" }, "- GENERATED CODE", -1))
113
+ ])
114
+ ])) : (p(), $("div", Te, [
115
+ e(c, {
116
+ class: "text-muted-foreground mb-2",
117
+ for: "codes"
118
+ }, {
119
+ default: t(() => [...r[7] || (r[7] = [
120
+ a("Enter the codes you want to create (one per line)", -1)
121
+ ])]),
122
+ _: 1
123
+ }),
124
+ e(m, {
125
+ modelValue: n(d).codes,
126
+ "onUpdate:modelValue": r[2] || (r[2] = (C) => n(d).codes = C),
127
+ id: "codes",
128
+ class: "max-h-48"
129
+ }, null, 8, ["modelValue"])
130
+ ]))
131
+ ], 64);
132
+ };
133
+ }
134
+ }), Fe = { class: "grid gap-6 py-4" }, Ae = { class: "flex items-center" }, Me = { class: "flex items-center gap-2" }, Ne = { class: "flex items-center gap-2" }, Ie = { class: "flex items-center gap-2" }, Le = { class: "flex items-center gap-2" }, ze = { class: "flex items-center space-x-2 mb-2" }, Oe = {
135
+ key: 0,
136
+ class: "text-xs text-blue-600 bg-blue-500/10 p-2 rounded border border-blue-500 mt-1 flex items-start gap-1"
137
+ }, Be = { class: "flex items-center space-x-2 mb-2" }, Ge = /* @__PURE__ */ z({
138
+ __name: "TypeDetailDialog",
139
+ setup(N, { expose: d }) {
140
+ const { isAdmin: S } = j(), { getModuleData: r, setModuleData: f } = W(), c = L("promoTypes", A([])), u = A({
141
+ id: "",
142
+ label: "",
143
+ key: "",
144
+ allowUnlimitedUses: !1,
145
+ hasValueField: !1,
146
+ valueLabel: "",
147
+ valuePrefix: "",
148
+ valueSuffix: ""
149
+ }), x = A(!1), k = A("add"), _ = A(!1), i = (b) => {
150
+ x.value = !0, _.value = !1, b ? (k.value = "edit", u.value = JSON.parse(JSON.stringify(b))) : (k.value = "add", u.value = {
151
+ id: crypto.randomUUID(),
152
+ label: "",
153
+ key: "",
154
+ allowUnlimitedUses: !1,
155
+ hasValueField: !1,
156
+ valueLabel: "",
157
+ valuePrefix: "",
158
+ valueSuffix: ""
159
+ });
160
+ }, y = (b) => {
161
+ x.value = !0, _.value = !1, k.value = "add", C(b);
162
+ }, w = async () => {
163
+ _.value = !0;
164
+ let b = await r("promo-types") || [];
165
+ b.push(JSON.parse(JSON.stringify(u.value))), f("promo-types", b), c.value = JSON.parse(JSON.stringify(b)), x.value = !1;
166
+ }, m = async () => {
167
+ _.value = !0;
168
+ let b = await r("promo-types") || [];
169
+ b = b.map((l) => l.id === u.value.id ? u.value : l), f("promo-types", b), c.value = JSON.parse(JSON.stringify(b)), x.value = !1;
170
+ }, C = (b) => {
171
+ switch (b) {
172
+ case "fixed":
173
+ u.value = {
174
+ id: crypto.randomUUID(),
175
+ label: "Fixed Amount",
176
+ key: "fixed",
177
+ allowUnlimitedUses: !1,
178
+ hasValueField: !0,
179
+ valueLabel: "Amount",
180
+ valuePrefix: "$",
181
+ valueSuffix: ""
182
+ };
183
+ break;
184
+ case "percentage":
185
+ u.value = {
186
+ id: crypto.randomUUID(),
187
+ label: "Percentage",
188
+ key: "percentage",
189
+ allowUnlimitedUses: !1,
190
+ hasValueField: !0,
191
+ valueLabel: "Percentage",
192
+ valuePrefix: "",
193
+ valueSuffix: "%"
194
+ };
195
+ break;
196
+ case "free_shipping":
197
+ u.value = {
198
+ id: crypto.randomUUID(),
199
+ label: "Free Shipping",
200
+ key: "free_shipping",
201
+ allowUnlimitedUses: !1,
202
+ hasValueField: !1,
203
+ valueLabel: "",
204
+ valuePrefix: "",
205
+ valueSuffix: ""
206
+ };
207
+ break;
208
+ }
209
+ };
210
+ return d({
211
+ open: i,
212
+ openFromTemplate: y
213
+ }), (b, l) => {
214
+ const V = o("DialogTitle"), g = o("DialogHeader"), M = o("Button"), B = o("DropdownMenuTrigger"), P = o("DropdownMenuItem"), G = o("DropdownMenuContent"), R = o("DropdownMenu"), D = o("Label"), O = o("Input"), J = o("Switch"), H = o("DialogFooter"), Y = o("DialogScrollContent"), q = o("Dialog");
215
+ return p(), U(q, {
216
+ open: x.value,
217
+ "onUpdate:open": l[11] || (l[11] = (v) => x.value = v)
218
+ }, {
219
+ default: t(() => [
220
+ n(S)() ? (p(), U(Y, {
221
+ key: 0,
222
+ class: "sm:max-w-[475px]"
223
+ }, {
224
+ default: t(() => [
225
+ e(g, null, {
226
+ default: t(() => [
227
+ e(V, null, {
228
+ default: t(() => [
229
+ a(T(k.value === "add" ? "Add Promo Type" : "Edit Promo Type"), 1)
230
+ ]),
231
+ _: 1
232
+ })
233
+ ]),
234
+ _: 1
235
+ }),
236
+ s("div", Fe, [
237
+ s("div", Ae, [
238
+ k.value === "add" ? (p(), U(R, { key: 0 }, {
239
+ default: t(() => [
240
+ e(B, null, {
241
+ default: t(() => [
242
+ e(M, { variant: "outline" }, {
243
+ default: t(() => [
244
+ s("div", Me, [
245
+ e(n(re), { class: "size-4" }),
246
+ l[12] || (l[12] = a(" Load pre-defined type ", -1))
247
+ ])
248
+ ]),
249
+ _: 1
250
+ })
251
+ ]),
252
+ _: 1
253
+ }),
254
+ e(G, null, {
255
+ default: t(() => [
256
+ e(P, {
257
+ onClick: l[0] || (l[0] = (v) => C("fixed"))
258
+ }, {
259
+ default: t(() => [
260
+ s("div", Ne, [
261
+ e(n(oe), { class: "size-4" }),
262
+ l[13] || (l[13] = a(" Fixed Amount ", -1))
263
+ ])
264
+ ]),
265
+ _: 1
266
+ }),
267
+ e(P, {
268
+ onClick: l[1] || (l[1] = (v) => C("percentage"))
269
+ }, {
270
+ default: t(() => [
271
+ s("div", Ie, [
272
+ e(n(ne), { class: "size-4" }),
273
+ l[14] || (l[14] = a(" Percentage ", -1))
274
+ ])
275
+ ]),
276
+ _: 1
277
+ }),
278
+ e(P, {
279
+ onClick: l[2] || (l[2] = (v) => C("free_shipping"))
280
+ }, {
281
+ default: t(() => [
282
+ s("div", Le, [
283
+ e(n(se), { class: "size-4" }),
284
+ l[15] || (l[15] = a(" Free Shipping ", -1))
285
+ ])
286
+ ]),
287
+ _: 1
288
+ })
289
+ ]),
290
+ _: 1
291
+ })
292
+ ]),
293
+ _: 1
294
+ })) : F("", !0)
295
+ ]),
296
+ s("div", null, [
297
+ e(D, {
298
+ for: "label",
299
+ class: "mb-2"
300
+ }, {
301
+ default: t(() => [...l[16] || (l[16] = [
302
+ a("Display Name", -1)
303
+ ])]),
304
+ _: 1
305
+ }),
306
+ e(O, {
307
+ modelValue: u.value.label,
308
+ "onUpdate:modelValue": l[3] || (l[3] = (v) => u.value.label = v),
309
+ id: "label"
310
+ }, null, 8, ["modelValue"]),
311
+ l[17] || (l[17] = s("p", { class: "text-xs text-muted-foreground mt-1" }, 'Shown in the Studio UI. e.g. "VIP Shipping"', -1))
312
+ ]),
313
+ s("div", null, [
314
+ e(D, {
315
+ for: "key",
316
+ class: "mb-2"
317
+ }, {
318
+ default: t(() => [...l[18] || (l[18] = [
319
+ a("Internal Key", -1)
320
+ ])]),
321
+ _: 1
322
+ }),
323
+ e(O, {
324
+ modelValue: u.value.key,
325
+ "onUpdate:modelValue": l[4] || (l[4] = (v) => u.value.key = v),
326
+ id: "key"
327
+ }, null, 8, ["modelValue"]),
328
+ l[19] || (l[19] = s("p", { class: "text-xs text-muted-foreground mt-1" }, [
329
+ a("Used in logic. Must be unique, lowercase, no spaces. e.g. "),
330
+ s("span", { class: "font-mono bg-muted-foreground/20 px-1 py-0.5 rounded" }, "vip_shipping")
331
+ ], -1))
332
+ ]),
333
+ s("div", null, [
334
+ e(D, {
335
+ for: "allowUnlimitedUses",
336
+ class: "mb-4"
337
+ }, {
338
+ default: t(() => [...l[20] || (l[20] = [
339
+ a("Allow Unlimited Uses", -1)
340
+ ])]),
341
+ _: 1
342
+ }),
343
+ s("div", ze, [
344
+ e(J, {
345
+ id: "allowUnlimitedUses",
346
+ modelValue: u.value.allowUnlimitedUses,
347
+ "onUpdate:modelValue": l[5] || (l[5] = (v) => u.value.allowUnlimitedUses = v)
348
+ }, null, 8, ["modelValue"]),
349
+ e(D, { for: "allowUnlimitedUses" }, {
350
+ default: t(() => [
351
+ a(T(u.value.allowUnlimitedUses ? "Yes" : "No"), 1)
352
+ ]),
353
+ _: 1
354
+ })
355
+ ]),
356
+ l[22] || (l[22] = s("p", { class: "text-xs text-muted-foreground mt-1" }, 'Show the "Unlimited uses" toggle when creating a promo code.', -1)),
357
+ u.value.allowUnlimitedUses ? (p(), $("p", Oe, [
358
+ e(n(me), { class: "size-4" }),
359
+ l[21] || (l[21] = a(" This option is always hidden when generating multiple codes. ", -1))
360
+ ])) : F("", !0)
361
+ ]),
362
+ s("div", null, [
363
+ e(D, {
364
+ for: "hasValueField",
365
+ class: "mb-4"
366
+ }, {
367
+ default: t(() => [...l[23] || (l[23] = [
368
+ a("Has Value Field", -1)
369
+ ])]),
370
+ _: 1
371
+ }),
372
+ s("div", Be, [
373
+ e(J, {
374
+ id: "hasValueField",
375
+ modelValue: u.value.hasValueField,
376
+ "onUpdate:modelValue": l[6] || (l[6] = (v) => u.value.hasValueField = v)
377
+ }, null, 8, ["modelValue"]),
378
+ e(D, { for: "hasValueField" }, {
379
+ default: t(() => [
380
+ a(T(u.value.hasValueField ? "Yes" : "No"), 1)
381
+ ]),
382
+ _: 1
383
+ })
384
+ ]),
385
+ l[24] || (l[24] = s("p", { class: "text-xs text-muted-foreground mt-1" }, "Show a numeric value input when using this type.", -1))
386
+ ]),
387
+ s("div", null, [
388
+ e(D, {
389
+ for: "valueLabel",
390
+ class: "mb-2"
391
+ }, {
392
+ default: t(() => [...l[25] || (l[25] = [
393
+ a("Value Field Label", -1)
394
+ ])]),
395
+ _: 1
396
+ }),
397
+ e(O, {
398
+ modelValue: u.value.valueLabel,
399
+ "onUpdate:modelValue": l[7] || (l[7] = (v) => u.value.valueLabel = v),
400
+ id: "valueLabel"
401
+ }, null, 8, ["modelValue"]),
402
+ l[26] || (l[26] = s("p", { class: "text-xs text-muted-foreground mt-1" }, 'e.g. "Gift amount", "Shipping cost"', -1))
403
+ ]),
404
+ s("div", null, [
405
+ e(D, {
406
+ for: "valuePrefix",
407
+ class: "mb-2"
408
+ }, {
409
+ default: t(() => [...l[27] || (l[27] = [
410
+ a("Value Field Prefix", -1)
411
+ ])]),
412
+ _: 1
413
+ }),
414
+ e(O, {
415
+ modelValue: u.value.valuePrefix,
416
+ "onUpdate:modelValue": l[8] || (l[8] = (v) => u.value.valuePrefix = v),
417
+ id: "valuePrefix"
418
+ }, null, 8, ["modelValue"]),
419
+ l[28] || (l[28] = s("p", { class: "text-xs text-muted-foreground mt-1" }, "e.g. € or $", -1))
420
+ ]),
421
+ s("div", null, [
422
+ e(D, {
423
+ for: "valueSuffix",
424
+ class: "mb-2"
425
+ }, {
426
+ default: t(() => [...l[29] || (l[29] = [
427
+ a("Value Field Suffix", -1)
428
+ ])]),
429
+ _: 1
430
+ }),
431
+ e(O, {
432
+ modelValue: u.value.valueSuffix,
433
+ "onUpdate:modelValue": l[9] || (l[9] = (v) => u.value.valueSuffix = v),
434
+ id: "valueSuffix"
435
+ }, null, 8, ["modelValue"]),
436
+ l[30] || (l[30] = s("p", { class: "text-xs text-muted-foreground mt-1" }, "e.g. %, credits", -1))
437
+ ])
438
+ ]),
439
+ e(H, null, {
440
+ default: t(() => [
441
+ e(M, {
442
+ variant: "outline",
443
+ onClick: l[10] || (l[10] = (v) => x.value = !1)
444
+ }, {
445
+ default: t(() => [...l[31] || (l[31] = [
446
+ a("Cancel", -1)
447
+ ])]),
448
+ _: 1
449
+ }),
450
+ k.value === "add" ? (p(), U(M, {
451
+ key: 0,
452
+ disabled: _.value,
453
+ onClick: w
454
+ }, {
455
+ default: t(() => [
456
+ _.value ? (p(), U(n(K), {
457
+ key: 0,
458
+ class: "size-4 animate-spin"
459
+ })) : F("", !0),
460
+ l[32] || (l[32] = a(" Add Type ", -1))
461
+ ]),
462
+ _: 1
463
+ }, 8, ["disabled"])) : (p(), U(M, {
464
+ key: 1,
465
+ disabled: _.value,
466
+ onClick: m
467
+ }, {
468
+ default: t(() => [
469
+ _.value ? (p(), U(n(K), {
470
+ key: 0,
471
+ class: "size-4 animate-spin"
472
+ })) : F("", !0),
473
+ l[33] || (l[33] = a(" Save Changes ", -1))
474
+ ]),
475
+ _: 1
476
+ }, 8, ["disabled"]))
477
+ ]),
478
+ _: 1
479
+ })
480
+ ]),
481
+ _: 1
482
+ })) : F("", !0)
483
+ ]),
484
+ _: 1
485
+ }, 8, ["open"]);
486
+ };
487
+ }
488
+ }), Re = { class: "grid gap-4 py-4" }, Ee = {
489
+ key: 0,
490
+ class: "flex flex-col gap-2 items-center text-muted-foreground border rounded p-4"
491
+ }, Je = { class: "flex gap-2 items-center" }, je = { key: 1 }, He = { class: "flex justify-end w-full mb-2" }, Ye = { class: "flex items-center gap-2" }, qe = { class: "flex items-center gap-2" }, Ke = { class: "flex items-center gap-2" }, We = { class: "flex items-center gap-2" }, Qe = { class: "flex items-center gap-2" }, Xe = { class: "font-mono bg-muted-foreground/20 px-1 py-0.5 rounded" }, Ze = /* @__PURE__ */ z({
492
+ __name: "TypeManageDialog",
493
+ setup(N) {
494
+ const { isAdmin: d } = j(), { getModuleData: S, setModuleData: r } = W(), { confirm: f } = _e(), c = L("promoTypes", A([])), u = ue("typeDetailDialog"), x = async (_) => {
495
+ if (!await f(`Are you sure you want to delete the type "${_.label}"?`)) return;
496
+ let y = await S("promo-types") || [];
497
+ y = y.filter((w) => w.id !== _.id), r("promo-types", y), c.value = JSON.parse(JSON.stringify(y));
498
+ }, k = async () => {
499
+ const _ = [
500
+ {
501
+ id: crypto.randomUUID(),
502
+ label: "Fixed Amount",
503
+ key: "fixed",
504
+ allowUnlimitedUses: !1,
505
+ hasValueField: !0,
506
+ valueLabel: "Amount",
507
+ valuePrefix: "$",
508
+ valueSuffix: ""
509
+ },
510
+ {
511
+ id: crypto.randomUUID(),
512
+ label: "Percentage",
513
+ key: "percentage",
514
+ allowUnlimitedUses: !1,
515
+ hasValueField: !0,
516
+ valueLabel: "Percentage",
517
+ valuePrefix: "",
518
+ valueSuffix: "%"
519
+ },
520
+ {
521
+ id: crypto.randomUUID(),
522
+ label: "Free Shipping",
523
+ key: "free_shipping",
524
+ allowUnlimitedUses: !1,
525
+ hasValueField: !1,
526
+ valueLabel: "",
527
+ valuePrefix: "",
528
+ valueSuffix: ""
529
+ }
530
+ ];
531
+ r("promo-types", _), c.value = JSON.parse(JSON.stringify(_));
532
+ };
533
+ return (_, i) => {
534
+ const y = o("Button"), w = o("DialogTrigger"), m = o("DialogTitle"), C = o("DialogDescription"), b = o("DialogHeader"), l = o("DropdownMenuTrigger"), V = o("DropdownMenuItem"), g = o("DropdownMenuSeparator"), M = o("DropdownMenuContent"), B = o("DropdownMenu"), P = o("TableHead"), G = o("TableRow"), R = o("TableHeader"), D = o("TableCell"), O = o("TableBody"), J = o("Table"), H = o("DialogFooter"), Y = o("DialogScrollContent"), q = o("Dialog");
535
+ return p(), $(E, null, [
536
+ e(q, null, {
537
+ default: t(() => [
538
+ e(w, { "as-child": "" }, {
539
+ default: t(() => [
540
+ e(y, null, {
541
+ default: t(() => [
542
+ e(n(pe), { class: "size-4" }),
543
+ i[6] || (i[6] = a(" Edit Promo Types ", -1))
544
+ ]),
545
+ _: 1
546
+ })
547
+ ]),
548
+ _: 1
549
+ }),
550
+ n(d)() ? (p(), U(Y, {
551
+ key: 0,
552
+ class: "sm:max-w-2xl"
553
+ }, {
554
+ default: t(() => [
555
+ e(b, null, {
556
+ default: t(() => [
557
+ e(m, null, {
558
+ default: t(() => [...i[7] || (i[7] = [
559
+ a("Edit Promo Types", -1)
560
+ ])]),
561
+ _: 1
562
+ }),
563
+ e(C, null, {
564
+ default: t(() => [...i[8] || (i[8] = [
565
+ a(" Define reusable custom promo types to use in discount codes. You can configure how they behave and what fields are shown. ", -1)
566
+ ])]),
567
+ _: 1
568
+ })
569
+ ]),
570
+ _: 1
571
+ }),
572
+ s("div", Re, [
573
+ n(c).length === 0 ? (p(), $("div", Ee, [
574
+ i[12] || (i[12] = s("p", null, "You haven't created any custom types yet.", -1)),
575
+ s("p", Je, [
576
+ e(y, {
577
+ variant: "link",
578
+ onClick: i[0] || (i[0] = (v) => u.value?.open())
579
+ }, {
580
+ default: t(() => [...i[9] || (i[9] = [
581
+ a("Create a custom type", -1)
582
+ ])]),
583
+ _: 1
584
+ }),
585
+ i[11] || (i[11] = a(" or ", -1)),
586
+ e(y, {
587
+ variant: "link",
588
+ onClick: i[1] || (i[1] = (v) => k())
589
+ }, {
590
+ default: t(() => [...i[10] || (i[10] = [
591
+ a("Import Default Types", -1)
592
+ ])]),
593
+ _: 1
594
+ })
595
+ ])
596
+ ])) : (p(), $("div", je, [
597
+ s("div", He, [
598
+ e(B, null, {
599
+ default: t(() => [
600
+ e(l, null, {
601
+ default: t(() => [
602
+ e(y, { variant: "outline" }, {
603
+ default: t(() => [
604
+ s("div", Ye, [
605
+ e(n(Z), { class: "size-4" }),
606
+ i[13] || (i[13] = a(" Create new Promo Type ", -1))
607
+ ])
608
+ ]),
609
+ _: 1
610
+ })
611
+ ]),
612
+ _: 1
613
+ }),
614
+ e(M, null, {
615
+ default: t(() => [
616
+ e(V, {
617
+ onClick: i[2] || (i[2] = (v) => u.value?.open())
618
+ }, {
619
+ default: t(() => [
620
+ s("div", qe, [
621
+ e(n(Z), { class: "size-4" }),
622
+ i[14] || (i[14] = a(" New Type ", -1))
623
+ ])
624
+ ]),
625
+ _: 1
626
+ }),
627
+ e(g),
628
+ e(V, {
629
+ onClick: i[3] || (i[3] = (v) => u.value?.openFromTemplate("fixed"))
630
+ }, {
631
+ default: t(() => [
632
+ s("div", Ke, [
633
+ e(n(oe), { class: "size-4" }),
634
+ i[15] || (i[15] = a(" Fixed Amount ", -1))
635
+ ])
636
+ ]),
637
+ _: 1
638
+ }),
639
+ e(V, {
640
+ onClick: i[4] || (i[4] = (v) => u.value?.openFromTemplate("percentage"))
641
+ }, {
642
+ default: t(() => [
643
+ s("div", We, [
644
+ e(n(ne), { class: "size-4" }),
645
+ i[16] || (i[16] = a(" Percentage ", -1))
646
+ ])
647
+ ]),
648
+ _: 1
649
+ }),
650
+ e(V, {
651
+ onClick: i[5] || (i[5] = (v) => u.value?.openFromTemplate("free_shipping"))
652
+ }, {
653
+ default: t(() => [
654
+ s("div", Qe, [
655
+ e(n(se), { class: "size-4" }),
656
+ i[17] || (i[17] = a(" Free Shipping ", -1))
657
+ ])
658
+ ]),
659
+ _: 1
660
+ })
661
+ ]),
662
+ _: 1
663
+ })
664
+ ]),
665
+ _: 1
666
+ })
667
+ ]),
668
+ e(J, null, {
669
+ default: t(() => [
670
+ e(R, null, {
671
+ default: t(() => [
672
+ e(G, null, {
673
+ default: t(() => [
674
+ e(P, null, {
675
+ default: t(() => [...i[18] || (i[18] = [
676
+ a("Name (label)", -1)
677
+ ])]),
678
+ _: 1
679
+ }),
680
+ e(P, null, {
681
+ default: t(() => [...i[19] || (i[19] = [
682
+ a("Key", -1)
683
+ ])]),
684
+ _: 1
685
+ }),
686
+ e(P, null, {
687
+ default: t(() => [...i[20] || (i[20] = [
688
+ a("Value Field", -1)
689
+ ])]),
690
+ _: 1
691
+ }),
692
+ e(P, null, {
693
+ default: t(() => [...i[21] || (i[21] = [
694
+ a("Unlimited Uses", -1)
695
+ ])]),
696
+ _: 1
697
+ }),
698
+ e(P, { class: "text-right" }, {
699
+ default: t(() => [...i[22] || (i[22] = [
700
+ a("Actions", -1)
701
+ ])]),
702
+ _: 1
703
+ })
704
+ ]),
705
+ _: 1
706
+ })
707
+ ]),
708
+ _: 1
709
+ }),
710
+ e(O, null, {
711
+ default: t(() => [
712
+ (p(!0), $(E, null, le(n(c), (v) => (p(), U(G, {
713
+ key: v.key
714
+ }, {
715
+ default: t(() => [
716
+ e(D, null, {
717
+ default: t(() => [
718
+ a(T(v.label), 1)
719
+ ]),
720
+ _: 2
721
+ }, 1024),
722
+ e(D, null, {
723
+ default: t(() => [
724
+ s("span", Xe, T(v.key), 1)
725
+ ]),
726
+ _: 2
727
+ }, 1024),
728
+ e(D, null, {
729
+ default: t(() => [
730
+ a(T(v.hasValueField ? "Yes" : "No"), 1)
731
+ ]),
732
+ _: 2
733
+ }, 1024),
734
+ e(D, null, {
735
+ default: t(() => [
736
+ a(T(v.allowUnlimitedUses ? "Yes" : "No"), 1)
737
+ ]),
738
+ _: 2
739
+ }, 1024),
740
+ e(D, { class: "text-right" }, {
741
+ default: t(() => [
742
+ e(y, {
743
+ variant: "ghost",
744
+ size: "icon",
745
+ onClick: (ae) => u.value?.open(v)
746
+ }, {
747
+ default: t(() => [
748
+ e(n(fe), { class: "size-4" })
749
+ ]),
750
+ _: 1
751
+ }, 8, ["onClick"]),
752
+ e(y, {
753
+ variant: "ghost",
754
+ size: "icon",
755
+ onClick: (ae) => x(v)
756
+ }, {
757
+ default: t(() => [
758
+ e(n(ve), { class: "size-4 text-red-500" })
759
+ ]),
760
+ _: 1
761
+ }, 8, ["onClick"])
762
+ ]),
763
+ _: 2
764
+ }, 1024)
765
+ ]),
766
+ _: 2
767
+ }, 1024))), 128))
768
+ ]),
769
+ _: 1
770
+ })
771
+ ]),
772
+ _: 1
773
+ })
774
+ ]))
775
+ ]),
776
+ e(H, null, {
777
+ default: t(() => [
778
+ e(y, {
779
+ variant: "outline",
780
+ disabled: ""
781
+ }, {
782
+ default: t(() => [...i[23] || (i[23] = [
783
+ a(" Auto-saved ", -1)
784
+ ])]),
785
+ _: 1
786
+ })
787
+ ]),
788
+ _: 1
789
+ })
790
+ ]),
791
+ _: 1
792
+ })) : F("", !0)
793
+ ]),
794
+ _: 1
795
+ }),
796
+ e(Ge, {
797
+ ref_key: "typeDetailDialog",
798
+ ref: u
799
+ }, null, 512)
800
+ ], 64);
801
+ };
802
+ }
803
+ }), he = { class: "flex justify-between items-center" }, et = { class: "grid gap-2" }, tt = { class: "flex flex-wrap gap-12" }, lt = {
804
+ key: 0,
805
+ class: "grid gap-2"
806
+ }, ot = { class: "flex items-center gap-2" }, nt = {
807
+ key: 1,
808
+ class: "grid gap-2"
809
+ }, st = { class: "flex items-center space-x-2" }, at = /* @__PURE__ */ z({
810
+ __name: "index",
811
+ setup(N) {
812
+ const d = L("newCoupon"), S = L("promoTypes", A([])), r = ie(() => S.value.find((c) => c.key === d.value?.type) || null), { isAdmin: f } = j();
813
+ return (c, u) => {
814
+ const x = o("Label"), k = o("SelectValue"), _ = o("SelectTrigger"), i = o("SelectItem"), y = o("SelectGroup"), w = o("SelectContent"), m = o("Select"), C = o("Input"), b = o("Switch"), l = o("Card");
815
+ return p(), U(l, { class: "p-4" }, {
816
+ default: t(() => [
817
+ s("div", he, [
818
+ u[3] || (u[3] = s("h2", { class: "font-medium" }, "Value", -1)),
819
+ n(f)() ? (p(), U(Ze, { key: 0 })) : F("", !0)
820
+ ]),
821
+ s("div", et, [
822
+ e(x, { class: "text-muted-foreground" }, {
823
+ default: t(() => [...u[4] || (u[4] = [
824
+ a("Promo Type", -1)
825
+ ])]),
826
+ _: 1
827
+ }),
828
+ e(m, {
829
+ modelValue: n(d).type,
830
+ "onUpdate:modelValue": u[0] || (u[0] = (V) => n(d).type = V)
831
+ }, {
832
+ default: t(() => [
833
+ e(_, { class: "w-[200px]" }, {
834
+ default: t(() => [
835
+ e(k, { placeholder: "Select a promo type" })
836
+ ]),
837
+ _: 1
838
+ }),
839
+ e(w, null, {
840
+ default: t(() => [
841
+ e(y, null, {
842
+ default: t(() => [
843
+ (p(!0), $(E, null, le(n(S), (V) => (p(), U(i, {
844
+ key: V.key,
845
+ value: V.key
846
+ }, {
847
+ default: t(() => [
848
+ a(T(V.label), 1)
849
+ ]),
850
+ _: 2
851
+ }, 1032, ["value"]))), 128))
852
+ ]),
853
+ _: 1
854
+ })
855
+ ]),
856
+ _: 1
857
+ })
858
+ ]),
859
+ _: 1
860
+ }, 8, ["modelValue"])
861
+ ]),
862
+ s("div", tt, [
863
+ r.value?.hasValueField ? (p(), $("div", lt, [
864
+ e(x, {
865
+ for: "discountValue",
866
+ class: "text-muted-foreground"
867
+ }, {
868
+ default: t(() => [
869
+ a(T(r.value?.valueLabel || "Value"), 1)
870
+ ]),
871
+ _: 1
872
+ }),
873
+ s("div", ot, [
874
+ r.value?.valuePrefix ? (p(), U(x, {
875
+ key: 0,
876
+ for: "discountValue",
877
+ class: "text-lg"
878
+ }, {
879
+ default: t(() => [
880
+ a(T(r.value?.valuePrefix), 1)
881
+ ]),
882
+ _: 1
883
+ })) : F("", !0),
884
+ e(C, {
885
+ modelValue: n(d).value,
886
+ "onUpdate:modelValue": u[1] || (u[1] = (V) => n(d).value = V),
887
+ id: "discountValue"
888
+ }, null, 8, ["modelValue"]),
889
+ r.value?.valueSuffix ? (p(), U(x, {
890
+ key: 1,
891
+ for: "discountValue",
892
+ class: "text-lg"
893
+ }, {
894
+ default: t(() => [
895
+ a(T(r.value?.valueSuffix), 1)
896
+ ]),
897
+ _: 1
898
+ })) : F("", !0)
899
+ ])
900
+ ])) : F("", !0),
901
+ r.value?.allowUnlimitedUses && n(d).creationMode !== "multi" ? (p(), $("div", nt, [
902
+ e(x, {
903
+ for: "unlimitedUses",
904
+ class: "text-muted-foreground"
905
+ }, {
906
+ default: t(() => [...u[5] || (u[5] = [
907
+ a("Unlimited Uses", -1)
908
+ ])]),
909
+ _: 1
910
+ }),
911
+ s("div", st, [
912
+ e(b, {
913
+ id: "unlimitedUses",
914
+ modelValue: n(d).unlimitedUses,
915
+ "onUpdate:modelValue": u[2] || (u[2] = (V) => n(d).unlimitedUses = V)
916
+ }, null, 8, ["modelValue"]),
917
+ e(x, { for: "unlimitedUses" }, {
918
+ default: t(() => [
919
+ a(T(n(d).unlimitedUses ? "Yes" : "No"), 1)
920
+ ]),
921
+ _: 1
922
+ })
923
+ ])
924
+ ])) : F("", !0)
925
+ ])
926
+ ]),
927
+ _: 1
928
+ });
929
+ };
930
+ }
931
+ }), ut = { class: "flex gap-4" }, it = { class: "flex flex-col" }, dt = {
932
+ key: 0,
933
+ class: "-ml-2"
934
+ }, rt = {
935
+ key: 1,
936
+ class: "text-xs text-muted-foreground mt-2"
937
+ }, mt = { class: "flex flex-col" }, pt = {
938
+ key: 0,
939
+ class: "-ml-2"
940
+ }, ft = {
941
+ key: 1,
942
+ class: "text-xs text-muted-foreground mt-2"
943
+ }, vt = /* @__PURE__ */ z({
944
+ __name: "DateRange",
945
+ setup(N) {
946
+ const d = L("newCoupon"), S = new Ue("en-US", {
947
+ dateStyle: "long"
948
+ });
949
+ return (r, f) => {
950
+ const c = o("Label"), u = o("Button"), x = o("PopoverTrigger"), k = o("Calendar"), _ = o("PopoverContent"), i = o("Popover"), y = o("Card");
951
+ return p(), U(y, { class: "p-4" }, {
952
+ default: t(() => [
953
+ f[8] || (f[8] = s("div", null, [
954
+ s("h2", { class: "font-medium mb-2" }, "Availability"),
955
+ s("p", { class: "text-muted-foreground" }, "When will this code be available?")
956
+ ], -1)),
957
+ s("div", ut, [
958
+ s("div", it, [
959
+ e(c, { class: "text-muted-foreground mb-2" }, {
960
+ default: t(() => [...f[4] || (f[4] = [
961
+ a("Available from", -1)
962
+ ])]),
963
+ _: 1
964
+ }),
965
+ e(i, null, {
966
+ default: t(() => [
967
+ e(x, { "as-child": "" }, {
968
+ default: t(() => [
969
+ e(u, {
970
+ variant: "outline",
971
+ class: Q(n(ee)(
972
+ "w-[280px] justify-start text-left font-normal",
973
+ !n(d).startsAt && "text-muted-foreground"
974
+ ))
975
+ }, {
976
+ default: t(() => [
977
+ e(n(h), { class: "mr-2 h-4 w-4" }),
978
+ a(" " + T(n(d).startsAt ? n(S).format(n(d).startsAt.toDate(n(te)())) : "Pick a date"), 1)
979
+ ]),
980
+ _: 1
981
+ }, 8, ["class"])
982
+ ]),
983
+ _: 1
984
+ }),
985
+ e(_, { class: "w-auto p-0" }, {
986
+ default: t(() => [
987
+ e(k, {
988
+ modelValue: n(d).startsAt,
989
+ "onUpdate:modelValue": f[0] || (f[0] = (w) => n(d).startsAt = w),
990
+ "initial-focus": "",
991
+ minValue: n(Ve)()
992
+ }, null, 8, ["modelValue", "minValue"])
993
+ ]),
994
+ _: 1
995
+ })
996
+ ]),
997
+ _: 1
998
+ }),
999
+ n(d).startsAt ? (p(), $("div", dt, [
1000
+ e(u, {
1001
+ onClick: f[1] || (f[1] = (w) => n(d).startsAt = void 0),
1002
+ variant: "link"
1003
+ }, {
1004
+ default: t(() => [...f[5] || (f[5] = [
1005
+ a("Clear", -1)
1006
+ ])]),
1007
+ _: 1
1008
+ })
1009
+ ])) : (p(), $("p", rt, "Not set - codes will be available immediately"))
1010
+ ]),
1011
+ s("div", mt, [
1012
+ e(c, { class: "text-muted-foreground mb-2" }, {
1013
+ default: t(() => [...f[6] || (f[6] = [
1014
+ a("Until", -1)
1015
+ ])]),
1016
+ _: 1
1017
+ }),
1018
+ e(i, null, {
1019
+ default: t(() => [
1020
+ e(x, { "as-child": "" }, {
1021
+ default: t(() => [
1022
+ e(u, {
1023
+ variant: "outline",
1024
+ class: Q(n(ee)(
1025
+ "w-[280px] justify-start text-left font-normal",
1026
+ !n(d).expiresAt && "text-muted-foreground"
1027
+ ))
1028
+ }, {
1029
+ default: t(() => [
1030
+ e(n(h), { class: "mr-2 h-4 w-4" }),
1031
+ a(" " + T(n(d).expiresAt ? n(S).format(n(d).expiresAt.toDate(n(te)())) : "Pick a date"), 1)
1032
+ ]),
1033
+ _: 1
1034
+ }, 8, ["class"])
1035
+ ]),
1036
+ _: 1
1037
+ }),
1038
+ e(_, { class: "w-auto p-0" }, {
1039
+ default: t(() => [
1040
+ e(k, {
1041
+ modelValue: n(d).expiresAt,
1042
+ "onUpdate:modelValue": f[2] || (f[2] = (w) => n(d).expiresAt = w),
1043
+ "initial-focus": "",
1044
+ minValue: n(d).startsAt
1045
+ }, null, 8, ["modelValue", "minValue"])
1046
+ ]),
1047
+ _: 1
1048
+ })
1049
+ ]),
1050
+ _: 1
1051
+ }),
1052
+ n(d).expiresAt ? (p(), $("div", pt, [
1053
+ e(u, {
1054
+ onClick: f[3] || (f[3] = (w) => n(d).expiresAt = void 0),
1055
+ variant: "link"
1056
+ }, {
1057
+ default: t(() => [...f[7] || (f[7] = [
1058
+ a("Clear", -1)
1059
+ ])]),
1060
+ _: 1
1061
+ })
1062
+ ])) : (p(), $("p", ft, "Not set - codes will never expire"))
1063
+ ])
1064
+ ])
1065
+ ]),
1066
+ _: 1
1067
+ });
1068
+ };
1069
+ }
1070
+ }), ct = /* @__PURE__ */ z({
1071
+ __name: "Note",
1072
+ setup(N) {
1073
+ const d = L("newCoupon");
1074
+ return (S, r) => {
1075
+ const f = o("Textarea"), c = o("Card");
1076
+ return p(), U(c, { class: "p-4" }, {
1077
+ default: t(() => [
1078
+ s("div", null, [
1079
+ r[1] || (r[1] = s("h2", { class: "font-medium mb-2" }, "Note", -1)),
1080
+ r[2] || (r[2] = s("p", { class: "text-sm text-muted-foreground mb-2" }, "Used internally. It's a good idea to write down why you're creating this promo code.", -1)),
1081
+ e(f, {
1082
+ modelValue: n(d).note,
1083
+ "onUpdate:modelValue": r[0] || (r[0] = (u) => n(d).note = u)
1084
+ }, null, 8, ["modelValue"])
1085
+ ])
1086
+ ]),
1087
+ _: 1
1088
+ });
1089
+ };
1090
+ }
1091
+ }), _t = { class: "relative" }, gt = {
1092
+ ref: "container",
1093
+ class: "flex flex-col gap-4 w-full max-w-5xl mx-auto"
1094
+ }, xt = { class: "flex justify-between items-center mb-4" }, yt = { class: "w-full max-w-2xl" }, bt = { class: "flex items-center space-x-2" }, wt = { class: "flex items-center space-x-2" }, Vt = { class: "flex justify-end w-full" }, Pt = /* @__PURE__ */ z({
1095
+ __name: "Create",
1096
+ props: {
1097
+ config: {
1098
+ type: Object,
1099
+ required: !0
1100
+ }
1101
+ },
1102
+ async setup(N) {
1103
+ let d, S;
1104
+ const r = N, { hasPermission: f } = j(), { navigateTo: c } = ge(), { getTimezone: u } = xe(), { log: x, logError: k } = ye(), { getModuleData: _, setModuleData: i } = W();
1105
+ be(() => []);
1106
+ const y = we(r.config.project), w = A(!1), m = A({
1107
+ creationMode: "single",
1108
+ generationMode: "generate",
1109
+ quantity: 1,
1110
+ prefix: "",
1111
+ codes: "",
1112
+ code: "",
1113
+ type: void 0,
1114
+ value: void 0,
1115
+ unlimitedUses: !1,
1116
+ startsAt: void 0,
1117
+ expiresAt: void 0,
1118
+ minOrderAmount: 0,
1119
+ note: ""
1120
+ }), C = A([]);
1121
+ C.value = ([d, S] = de(() => _("promo-types")), d = await d, S(), d || []), X("newCoupon", m), X("promoTypes", C);
1122
+ const b = () => {
1123
+ if (m.value.creationMode == "single") {
1124
+ if (m.value.code = m.value.code?.trim().toUpperCase(), !m.value.code)
1125
+ return I.error("Please enter a code"), !1;
1126
+ } else if (m.value.generationMode == "generate") {
1127
+ if (m.value.prefix = m.value.prefix?.trim().toUpperCase(), !m.value.prefix)
1128
+ return I.error("Please enter a prefix"), !1;
1129
+ if (!m.value.quantity || m.value.quantity < 1)
1130
+ return I.error("Generate at least 1 code"), !1;
1131
+ } else if (m.value.generationMode == "input" && (m.value.codes = m.value.codes?.trim().toUpperCase(), !m.value.codes || m.value.codes.length < 1))
1132
+ return I.error("Please enter some codes"), !1;
1133
+ return m.value.type ? C.value.find((V) => V.key === m.value.type)?.hasValueField && !m.value.value ? (I.error("Please enter a value"), !1) : (m.value.creationMode === "multi" && (m.value.unlimitedUses = !1), !0) : (I.error("Please select a type"), !1);
1134
+ }, l = async () => {
1135
+ try {
1136
+ if (!b()) return;
1137
+ if (w.value = !0, m.value.creationMode == "single") {
1138
+ let V = {
1139
+ code: m.value.code,
1140
+ type: m.value.type,
1141
+ value: m.value.value,
1142
+ minOrderAmount: m.value.minOrderAmount,
1143
+ usageLimit: m.value.unlimitedUses ? 0 : 1,
1144
+ usageCount: 0,
1145
+ lastUsedAt: null,
1146
+ startsAt: m.value.startsAt ? m.value.startsAt.toDate(u()) : null,
1147
+ expiresAt: m.value.expiresAt ? m.value.expiresAt.toDate(u()) : null,
1148
+ disabled: !1,
1149
+ note: m.value.note,
1150
+ createdAt: /* @__PURE__ */ new Date(),
1151
+ updatedAt: /* @__PURE__ */ new Date()
1152
+ };
1153
+ const g = await y.add(r.config.promoCodeCollection, V);
1154
+ x("Promo code created", { id: g.id, code: g.code, note: g.note }), I.success("Promo code created");
1155
+ }
1156
+ } catch {
1157
+ k("Failed to create promo code"), I.error("Failed to create promo code");
1158
+ } finally {
1159
+ w.value = !1;
1160
+ }
1161
+ };
1162
+ return (V, g) => {
1163
+ const M = o("Button"), B = o("RadioGroupItem"), P = o("Label"), G = o("RadioGroup"), R = o("Card");
1164
+ return p(), $("div", _t, [
1165
+ s("div", gt, [
1166
+ s("div", xt, [
1167
+ g[3] || (g[3] = s("h1", { class: "text-2xl font-bold" }, "New Promo Code", -1)),
1168
+ e(M, {
1169
+ onClick: g[0] || (g[0] = (D) => n(c)("promo-codes")),
1170
+ variant: "outline",
1171
+ disabled: w.value
1172
+ }, {
1173
+ default: t(() => [
1174
+ e(n(ce), { class: "size-4" }),
1175
+ g[2] || (g[2] = a(" View Promo Codes ", -1))
1176
+ ]),
1177
+ _: 1
1178
+ }, 8, ["disabled"])
1179
+ ]),
1180
+ e(R, { class: "p-4" }, {
1181
+ default: t(() => [
1182
+ s("div", yt, [
1183
+ g[6] || (g[6] = s("h2", { class: "font-medium mb-4" }, "Codes", -1)),
1184
+ e(G, {
1185
+ modelValue: m.value.creationMode,
1186
+ "onUpdate:modelValue": g[1] || (g[1] = (D) => m.value.creationMode = D),
1187
+ orientation: "horizontal",
1188
+ class: "mb-6"
1189
+ }, {
1190
+ default: t(() => [
1191
+ s("div", bt, [
1192
+ e(B, {
1193
+ id: "creation_mode_single",
1194
+ value: "single"
1195
+ }),
1196
+ e(P, { for: "creation_mode_single" }, {
1197
+ default: t(() => [...g[4] || (g[4] = [
1198
+ a("Create 1 code", -1)
1199
+ ])]),
1200
+ _: 1
1201
+ })
1202
+ ]),
1203
+ s("div", wt, [
1204
+ e(B, {
1205
+ id: "creation_mode_multi",
1206
+ value: "multi"
1207
+ }),
1208
+ e(P, { for: "creation_mode_multi" }, {
1209
+ default: t(() => [...g[5] || (g[5] = [
1210
+ a("Create multiple codes", -1)
1211
+ ])]),
1212
+ _: 1
1213
+ })
1214
+ ])
1215
+ ]),
1216
+ _: 1
1217
+ }, 8, ["modelValue"]),
1218
+ m.value.creationMode == "single" ? (p(), U(Ce, { key: 0 })) : (p(), U(Pe, { key: 1 }))
1219
+ ])
1220
+ ]),
1221
+ _: 1
1222
+ }),
1223
+ e(at),
1224
+ e(vt),
1225
+ e(ct),
1226
+ s("div", Vt, [
1227
+ e(M, {
1228
+ disabled: w.value,
1229
+ onClick: l
1230
+ }, {
1231
+ default: t(() => [
1232
+ w.value ? (p(), U(n(K), {
1233
+ key: 0,
1234
+ class: "size-4 animate-spin"
1235
+ })) : F("", !0),
1236
+ g[7] || (g[7] = a(" Create Promo Code ", -1))
1237
+ ]),
1238
+ _: 1
1239
+ }, 8, ["disabled"])
1240
+ ])
1241
+ ], 512)
1242
+ ]);
1243
+ };
1244
+ }
1245
+ });
1246
+ export {
1247
+ Pt as default
1248
+ };