@oneclick.dev/cms-core-modules 0.0.83 → 0.0.84

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 (63) hide show
  1. package/dist/{ContentEditor-CxKirDdL.mjs → ContentEditor-DPhhOkx3.mjs} +7068 -5926
  2. package/dist/{ContentEditor-CRFkD4tE.js → ContentEditor-DrxtH_Hq.js} +42 -42
  3. package/dist/{Create-CsqVYhPO.mjs → Create-6uT9HWar.mjs} +35 -35
  4. package/dist/{Create-ip0MnS0o.js → Create-DuZ5nZrX.js} +1 -1
  5. package/dist/{DateFormatter-CvOfaUnU.mjs → DateFormatter-2B0R-DY4.mjs} +204 -400
  6. package/dist/DateFormatter-DbtOLV0L.js +1 -0
  7. package/dist/{Detail-RMXFuSRQ.js → Detail-BZ-iE9vf.js} +1 -1
  8. package/dist/{Detail-B4b_FLDa.mjs → Detail-C1Blq61w.mjs} +90 -90
  9. package/dist/{Detail-BayNaAg9.js → Detail-C8wQiDcv.js} +1 -1
  10. package/dist/{Detail-CbLk1v37.mjs → Detail-CJVMJDP7.mjs} +17 -17
  11. package/dist/{Detail-CnK-qbhE.js → Detail-CPqug27l.js} +1 -1
  12. package/dist/Detail-CjuhjPby.js +1 -0
  13. package/dist/{Detail-U0mgLKt6.mjs → Detail-CtItxMX4.mjs} +62 -63
  14. package/dist/{Detail-CVgWHbMC.mjs → Detail-Dnpnmy4-.mjs} +158 -158
  15. package/dist/{Entries-D7MHylQE.mjs → Entries-BkOPae4R.mjs} +49 -49
  16. package/dist/Entries-CcEW98F5.js +1 -0
  17. package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-CDc8MIq2.mjs → NewReservationDialog.vue_vue_type_script_setup_true_lang-Bc946oSc.mjs} +1 -1
  18. package/dist/{NewReservationDialog.vue_vue_type_script_setup_true_lang-StaNp-3y.js → NewReservationDialog.vue_vue_type_script_setup_true_lang-CqERfyYb.js} +1 -1
  19. package/dist/{Overview-CwCAeBnX.js → Overview-CA8wh_BI.js} +1 -1
  20. package/dist/{Overview-CgViRnNc.mjs → Overview-D4MFwRI_.mjs} +67 -68
  21. package/dist/{Overview-B2bFNGhH.js → Overview-Da0XexiT.js} +1 -1
  22. package/dist/Overview-DeQQ0FY3.js +1 -0
  23. package/dist/{Overview--XpvBbqz.mjs → Overview-DoOASlNz.mjs} +1 -3
  24. package/dist/{Overview-Cczt_dcE.mjs → Overview-gJSvftdE.mjs} +34 -34
  25. package/dist/{ReservationDetailDialog.vue_vue_type_script_setup_true_lang-B7ks5mbf.mjs → ReservationDetailDialog.vue_vue_type_script_setup_true_lang-Cohhnd5x.mjs} +0 -1
  26. package/dist/{ReservationDetailDialog.vue_vue_type_script_setup_true_lang-Vxubki_v.js → ReservationDetailDialog.vue_vue_type_script_setup_true_lang-VWVIxIr6.js} +1 -1
  27. package/dist/{SeoHealth-ZpvB7CS2.mjs → SeoHealth-Bc5chnaa.mjs} +14 -14
  28. package/dist/{SeoHealth-DFZ0LLBH.js → SeoHealth-BkpJ1F2Y.js} +1 -1
  29. package/dist/TableView-BPWAx--G.mjs +5743 -0
  30. package/dist/TableView-D63QrVlK.js +4 -0
  31. package/dist/View-BL70u98U.js +1 -0
  32. package/dist/{View-DDXN0tKD.mjs → View-BO5N911y.mjs} +5 -5
  33. package/dist/{agenda-Cl3s_FIE.mjs → agenda-C5grvzSa.mjs} +166 -169
  34. package/dist/agenda-DXMwVWpN.js +1 -0
  35. package/dist/{availability-B-tRp8hB.mjs → availability-C1NqOFsQ.mjs} +81 -81
  36. package/dist/{availability-BiBbzEIM.js → availability-D_wnfLsH.js} +1 -1
  37. package/dist/cms-core-modules.css +1 -1
  38. package/dist/{exceptions-DQPSFSj7.mjs → exceptions-BIwMhYa4.mjs} +1 -1
  39. package/dist/{exceptions-BA3PsW4n.js → exceptions-Cn7zooEu.js} +1 -1
  40. package/dist/{index-CBC9dWZ9.js → index-C9pSS15N.js} +2 -2
  41. package/dist/{index-YOOlBEZB.mjs → index-MwjeLHPP.mjs} +3 -3
  42. package/dist/index.cjs.js +1 -1
  43. package/dist/index.mjs +22 -22
  44. package/dist/orders-CG1QUCN8.js +1 -0
  45. package/dist/{orders-DZzdsHOW.mjs → orders-CeixEBcU.mjs} +57 -58
  46. package/dist/server-handlers.cjs.js +1 -1
  47. package/dist/server-handlers.mjs +142 -147
  48. package/package.json +2 -2
  49. package/dist/DateFormatter-ls6HfWpS.js +0 -1
  50. package/dist/Detail-BcboL7NF.js +0 -1
  51. package/dist/Entries-BPkZ7Jg5.js +0 -1
  52. package/dist/Overview-B-8TLLjh.js +0 -1
  53. package/dist/TableView-BUPPcHUW.mjs +0 -89505
  54. package/dist/TableView-CksiPsTL.js +0 -586
  55. package/dist/View-DfzaVOzS.js +0 -1
  56. package/dist/agenda-rlFma_wn.js +0 -1
  57. package/dist/floating-ui.dom-B9WYoHj2.js +0 -1
  58. package/dist/floating-ui.dom-fpIfhXTZ.mjs +0 -1291
  59. package/dist/index-DYpruS-A-Cw57iwdY.mjs +0 -4210
  60. package/dist/index-DYpruS-A-DwDXo9Tq.js +0 -88
  61. package/dist/index-YMaY4uuk-BgpTtr73.js +0 -1
  62. package/dist/index-YMaY4uuk-C_xV5K9Z.mjs +0 -1300
  63. package/dist/orders-tP4WdF5q.js +0 -1
@@ -1,16 +1,16 @@
1
- import { defineComponent as z, inject as L, resolveComponent as o, openBlock as p, createElementBlock as S, Fragment as E, createVNode as e, withCtx as t, createTextVNode as a, unref as n, createElementVNode as s, ref as A, createBlock as U, toDisplayString as T, createCommentVNode as F, useTemplateRef as ue, renderList as le, computed as ie, normalizeClass as Q, withAsyncContext as de, provide as X } from "vue";
1
+ import { defineComponent as z, inject as L, resolveComponent as o, openBlock as p, createElementBlock as $, Fragment as E, createVNode as e, withCtx as t, createTextVNode as a, unref as n, createElementVNode as s, ref as A, createBlock as U, toDisplayString as T, createCommentVNode as F, useTemplateRef as ue, renderList as le, computed as ie, normalizeClass as Q, withAsyncContext as de, provide as X } from "vue";
2
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
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
4
  import { c as ee } from "./utils-BVKy9S2J.mjs";
5
- import { h as Ve, g as te, o as Ue } from "./DateFormatter-CvOfaUnU.mjs";
5
+ import { $ as Ve, b as te, c as Ue } from "./DateFormatter-2B0R-DY4.mjs";
6
6
  import { t as I } from "./index-RLz1QPrf.mjs";
7
7
  const Ce = /* @__PURE__ */ z({
8
8
  __name: "SingleCode",
9
9
  setup(N) {
10
10
  const d = L("newCoupon");
11
- return ($, r) => {
11
+ return (S, r) => {
12
12
  const f = o("Label"), c = o("Input");
13
- return p(), S(E, null, [
13
+ return p(), $(E, null, [
14
14
  e(f, {
15
15
  class: "text-muted-foreground mb-2",
16
16
  for: "code"
@@ -28,16 +28,16 @@ const Ce = /* @__PURE__ */ z({
28
28
  ], 64);
29
29
  };
30
30
  }
31
- }), De = { class: "flex items-center space-x-2" }, ke = { class: "flex items-center space-x-2" }, Se = {
31
+ }), De = { class: "flex items-center space-x-2" }, ke = { class: "flex items-center space-x-2" }, $e = {
32
32
  key: 0,
33
33
  class: "flex items-end w-full gap-4"
34
- }, $e = { class: "relative w-full" }, Te = { key: 1 }, Pe = /* @__PURE__ */ z({
34
+ }, Se = { class: "relative w-full" }, Te = { key: 1 }, Pe = /* @__PURE__ */ z({
35
35
  __name: "MultiCodes",
36
36
  setup(N) {
37
37
  const d = L("newCoupon");
38
- return ($, r) => {
38
+ return (S, r) => {
39
39
  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");
40
- return p(), S(E, null, [
40
+ return p(), $(E, null, [
41
41
  r[8] || (r[8] = s("p", { class: "text-sm text-muted-foreground mb-2" }, "How do you want to create the codes?", -1)),
42
42
  e(u, {
43
43
  modelValue: n(d).generationMode,
@@ -73,7 +73,7 @@ const Ce = /* @__PURE__ */ z({
73
73
  ]),
74
74
  _: 1
75
75
  }, 8, ["modelValue"]),
76
- n(d).generationMode == "generate" ? (p(), S("div", Se, [
76
+ n(d).generationMode == "generate" ? (p(), $("div", $e, [
77
77
  e(y, {
78
78
  id: "age",
79
79
  "default-value": 1,
@@ -101,7 +101,7 @@ const Ce = /* @__PURE__ */ z({
101
101
  ]),
102
102
  _: 1
103
103
  }),
104
- s("div", $e, [
104
+ s("div", Se, [
105
105
  e(w, {
106
106
  modelValue: n(d).prefix,
107
107
  "onUpdate:modelValue": r[1] || (r[1] = (C) => n(d).prefix = C),
@@ -110,7 +110,7 @@ const Ce = /* @__PURE__ */ z({
110
110
  }, null, 8, ["modelValue"]),
111
111
  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))
112
112
  ])
113
- ])) : (p(), S("div", Te, [
113
+ ])) : (p(), $("div", Te, [
114
114
  e(c, {
115
115
  class: "text-muted-foreground mb-2",
116
116
  for: "codes"
@@ -136,7 +136,7 @@ const Ce = /* @__PURE__ */ z({
136
136
  }, Be = { class: "flex items-center space-x-2 mb-2" }, Ge = /* @__PURE__ */ z({
137
137
  __name: "TypeDetailDialog",
138
138
  setup(N, { expose: d }) {
139
- const { isAdmin: $ } = j(), { getModuleData: r, setModuleData: f } = W(), c = L("promoTypes", A([])), u = A({
139
+ const { isAdmin: S } = j(), { getModuleData: r, setModuleData: f } = W(), c = L("promoTypes", A([])), u = A({
140
140
  id: "",
141
141
  label: "",
142
142
  key: "",
@@ -216,7 +216,7 @@ const Ce = /* @__PURE__ */ z({
216
216
  "onUpdate:open": l[11] || (l[11] = (v) => x.value = v)
217
217
  }, {
218
218
  default: t(() => [
219
- n($)() ? (p(), U(Y, {
219
+ n(S)() ? (p(), U(Y, {
220
220
  key: 0,
221
221
  class: "sm:max-w-[475px]"
222
222
  }, {
@@ -353,7 +353,7 @@ const Ce = /* @__PURE__ */ z({
353
353
  })
354
354
  ]),
355
355
  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)),
356
- u.value.allowUnlimitedUses ? (p(), S("p", Oe, [
356
+ u.value.allowUnlimitedUses ? (p(), $("p", Oe, [
357
357
  e(n(me), { class: "size-4" }),
358
358
  l[21] || (l[21] = a(" This option is always hidden when generating multiple codes. ", -1))
359
359
  ])) : F("", !0)
@@ -490,9 +490,9 @@ const Ce = /* @__PURE__ */ z({
490
490
  }, 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({
491
491
  __name: "TypeManageDialog",
492
492
  setup(N) {
493
- const { isAdmin: d } = j(), { getModuleData: $, setModuleData: r } = W(), { confirm: f } = _e(), c = L("promoTypes", A([])), u = ue("typeDetailDialog"), x = async (_) => {
493
+ const { isAdmin: d } = j(), { getModuleData: S, setModuleData: r } = W(), { confirm: f } = _e(), c = L("promoTypes", A([])), u = ue("typeDetailDialog"), x = async (_) => {
494
494
  if (!await f(`Are you sure you want to delete the type "${_.label}"?`)) return;
495
- let y = await $("promo-types") || [];
495
+ let y = await S("promo-types") || [];
496
496
  y = y.filter((w) => w.id !== _.id), r("promo-types", y), c.value = JSON.parse(JSON.stringify(y));
497
497
  }, k = async () => {
498
498
  const _ = [
@@ -531,7 +531,7 @@ const Ce = /* @__PURE__ */ z({
531
531
  };
532
532
  return (_, i) => {
533
533
  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");
534
- return p(), S(E, null, [
534
+ return p(), $(E, null, [
535
535
  e(q, null, {
536
536
  default: t(() => [
537
537
  e(w, { "as-child": "" }, {
@@ -569,7 +569,7 @@ const Ce = /* @__PURE__ */ z({
569
569
  _: 1
570
570
  }),
571
571
  s("div", Re, [
572
- n(c).length === 0 ? (p(), S("div", Ee, [
572
+ n(c).length === 0 ? (p(), $("div", Ee, [
573
573
  i[12] || (i[12] = s("p", null, "You haven't created any custom types yet.", -1)),
574
574
  s("p", Je, [
575
575
  e(y, {
@@ -592,7 +592,7 @@ const Ce = /* @__PURE__ */ z({
592
592
  _: 1
593
593
  })
594
594
  ])
595
- ])) : (p(), S("div", je, [
595
+ ])) : (p(), $("div", je, [
596
596
  s("div", He, [
597
597
  e(B, null, {
598
598
  default: t(() => [
@@ -708,7 +708,7 @@ const Ce = /* @__PURE__ */ z({
708
708
  }),
709
709
  e(O, null, {
710
710
  default: t(() => [
711
- (p(!0), S(E, null, le(n(c), (v) => (p(), U(G, {
711
+ (p(!0), $(E, null, le(n(c), (v) => (p(), U(G, {
712
712
  key: v.key
713
713
  }, {
714
714
  default: t(() => [
@@ -808,7 +808,7 @@ const Ce = /* @__PURE__ */ z({
808
808
  }, st = { class: "flex items-center space-x-2" }, at = /* @__PURE__ */ z({
809
809
  __name: "index",
810
810
  setup(N) {
811
- const d = L("newCoupon"), $ = L("promoTypes", A([])), r = ie(() => $.value.find((c) => c.key === d.value?.type) || null), { isAdmin: f } = j();
811
+ const d = L("newCoupon"), S = L("promoTypes", A([])), r = ie(() => S.value.find((c) => c.key === d.value?.type) || null), { isAdmin: f } = j();
812
812
  return (c, u) => {
813
813
  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");
814
814
  return p(), U(l, { class: "p-4" }, {
@@ -839,7 +839,7 @@ const Ce = /* @__PURE__ */ z({
839
839
  default: t(() => [
840
840
  e(y, null, {
841
841
  default: t(() => [
842
- (p(!0), S(E, null, le(n($), (V) => (p(), U(i, {
842
+ (p(!0), $(E, null, le(n(S), (V) => (p(), U(i, {
843
843
  key: V.key,
844
844
  value: V.key
845
845
  }, {
@@ -859,7 +859,7 @@ const Ce = /* @__PURE__ */ z({
859
859
  }, 8, ["modelValue"])
860
860
  ]),
861
861
  s("div", tt, [
862
- r.value?.hasValueField ? (p(), S("div", lt, [
862
+ r.value?.hasValueField ? (p(), $("div", lt, [
863
863
  e(x, {
864
864
  for: "discountValue",
865
865
  class: "text-muted-foreground"
@@ -897,7 +897,7 @@ const Ce = /* @__PURE__ */ z({
897
897
  })) : F("", !0)
898
898
  ])
899
899
  ])) : F("", !0),
900
- r.value?.allowUnlimitedUses && n(d).creationMode !== "multi" ? (p(), S("div", nt, [
900
+ r.value?.allowUnlimitedUses && n(d).creationMode !== "multi" ? (p(), $("div", nt, [
901
901
  e(x, {
902
902
  for: "unlimitedUses",
903
903
  class: "text-muted-foreground"
@@ -942,7 +942,7 @@ const Ce = /* @__PURE__ */ z({
942
942
  }, vt = /* @__PURE__ */ z({
943
943
  __name: "DateRange",
944
944
  setup(N) {
945
- const d = L("newCoupon"), $ = new Ve("en-US", {
945
+ const d = L("newCoupon"), S = new Ve("en-US", {
946
946
  dateStyle: "long"
947
947
  });
948
948
  return (r, f) => {
@@ -974,7 +974,7 @@ const Ce = /* @__PURE__ */ z({
974
974
  }, {
975
975
  default: t(() => [
976
976
  e(n(h), { class: "mr-2 h-4 w-4" }),
977
- a(" " + T(n(d).startsAt ? n($).format(n(d).startsAt.toDate(n(te)())) : "Pick a date"), 1)
977
+ a(" " + T(n(d).startsAt ? n(S).format(n(d).startsAt.toDate(n(te)())) : "Pick a date"), 1)
978
978
  ]),
979
979
  _: 1
980
980
  }, 8, ["class"])
@@ -995,7 +995,7 @@ const Ce = /* @__PURE__ */ z({
995
995
  ]),
996
996
  _: 1
997
997
  }),
998
- n(d).startsAt ? (p(), S("div", dt, [
998
+ n(d).startsAt ? (p(), $("div", dt, [
999
999
  e(u, {
1000
1000
  onClick: f[1] || (f[1] = (w) => n(d).startsAt = void 0),
1001
1001
  variant: "link"
@@ -1005,7 +1005,7 @@ const Ce = /* @__PURE__ */ z({
1005
1005
  ])]),
1006
1006
  _: 1
1007
1007
  })
1008
- ])) : (p(), S("p", rt, "Not set - codes will be available immediately"))
1008
+ ])) : (p(), $("p", rt, "Not set - codes will be available immediately"))
1009
1009
  ]),
1010
1010
  s("div", mt, [
1011
1011
  e(c, { class: "text-muted-foreground mb-2" }, {
@@ -1027,7 +1027,7 @@ const Ce = /* @__PURE__ */ z({
1027
1027
  }, {
1028
1028
  default: t(() => [
1029
1029
  e(n(h), { class: "mr-2 h-4 w-4" }),
1030
- a(" " + T(n(d).expiresAt ? n($).format(n(d).expiresAt.toDate(n(te)())) : "Pick a date"), 1)
1030
+ a(" " + T(n(d).expiresAt ? n(S).format(n(d).expiresAt.toDate(n(te)())) : "Pick a date"), 1)
1031
1031
  ]),
1032
1032
  _: 1
1033
1033
  }, 8, ["class"])
@@ -1048,7 +1048,7 @@ const Ce = /* @__PURE__ */ z({
1048
1048
  ]),
1049
1049
  _: 1
1050
1050
  }),
1051
- n(d).expiresAt ? (p(), S("div", pt, [
1051
+ n(d).expiresAt ? (p(), $("div", pt, [
1052
1052
  e(u, {
1053
1053
  onClick: f[3] || (f[3] = (w) => n(d).expiresAt = void 0),
1054
1054
  variant: "link"
@@ -1058,7 +1058,7 @@ const Ce = /* @__PURE__ */ z({
1058
1058
  ])]),
1059
1059
  _: 1
1060
1060
  })
1061
- ])) : (p(), S("p", ft, "Not set - codes will never expire"))
1061
+ ])) : (p(), $("p", ft, "Not set - codes will never expire"))
1062
1062
  ])
1063
1063
  ])
1064
1064
  ]),
@@ -1070,7 +1070,7 @@ const Ce = /* @__PURE__ */ z({
1070
1070
  __name: "Note",
1071
1071
  setup(N) {
1072
1072
  const d = L("newCoupon");
1073
- return ($, r) => {
1073
+ return (S, r) => {
1074
1074
  const f = o("Textarea"), c = o("Card");
1075
1075
  return p(), U(c, { class: "p-4" }, {
1076
1076
  default: t(() => [
@@ -1099,7 +1099,7 @@ const Ce = /* @__PURE__ */ z({
1099
1099
  }
1100
1100
  },
1101
1101
  async setup(N) {
1102
- let d, $;
1102
+ let d, S;
1103
1103
  const r = N, { hasPermission: f } = j(), { navigateTo: c } = ge(), { getTimezone: u } = xe(), { log: x, logError: k } = ye(), { getModuleData: _, setModuleData: i } = W();
1104
1104
  be(() => []);
1105
1105
  const y = we(r.config.project), w = A(!1), m = A({
@@ -1117,7 +1117,7 @@ const Ce = /* @__PURE__ */ z({
1117
1117
  minOrderAmount: 0,
1118
1118
  note: ""
1119
1119
  }), C = A([]);
1120
- C.value = ([d, $] = de(() => _("promo-types")), d = await d, $(), d || []), X("newCoupon", m), X("promoTypes", C);
1120
+ C.value = ([d, S] = de(() => _("promo-types")), d = await d, S(), d || []), X("newCoupon", m), X("promoTypes", C);
1121
1121
  const b = () => {
1122
1122
  if (m.value.creationMode == "single") {
1123
1123
  if (m.value.code = m.value.code?.trim().toUpperCase(), !m.value.code)
@@ -1160,7 +1160,7 @@ const Ce = /* @__PURE__ */ z({
1160
1160
  };
1161
1161
  return (V, g) => {
1162
1162
  const M = o("Button"), B = o("RadioGroupItem"), P = o("Label"), G = o("RadioGroup"), R = o("Card");
1163
- return p(), S("div", _t, [
1163
+ return p(), $("div", _t, [
1164
1164
  s("div", gt, [
1165
1165
  s("div", xt, [
1166
1166
  g[3] || (g[3] = s("h1", { class: "text-2xl font-bold" }, "New Promo Code", -1)),
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),v=require("lucide-vue-next"),w=require("@oneclick.dev/cms-kit"),h=require("./utils-D6CaKJbp.js"),$=require("./DateFormatter-ls6HfWpS.js"),T=require("./index-ijdf0d9-.js"),I=e.defineComponent({__name:"SingleCode",setup(b){const n=e.inject("newCoupon");return(_,a)=>{const s=e.resolveComponent("Label"),i=e.resolveComponent("Input");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(s,{class:"text-muted-foreground mb-2",for:"code"},{default:e.withCtx(()=>[...a[1]||(a[1]=[e.createTextVNode("Enter the coupon code",-1)])]),_:1}),e.createVNode(i,{modelValue:e.unref(n).code,"onUpdate:modelValue":a[0]||(a[0]=o=>e.unref(n).code=o),id:"code"},null,8,["modelValue"])],64)}}}),L={class:"flex items-center space-x-2"},z={class:"flex items-center space-x-2"},O={key:0,class:"flex items-end w-full gap-4"},j={class:"relative w-full"},G={key:1},R=e.defineComponent({__name:"MultiCodes",setup(b){const n=e.inject("newCoupon");return(_,a)=>{const s=e.resolveComponent("RadioGroupItem"),i=e.resolveComponent("Label"),o=e.resolveComponent("RadioGroup"),m=e.resolveComponent("NumberFieldDecrement"),g=e.resolveComponent("NumberFieldInput"),u=e.resolveComponent("NumberFieldIncrement"),l=e.resolveComponent("NumberFieldContent"),p=e.resolveComponent("NumberField"),V=e.resolveComponent("Input"),r=e.resolveComponent("Textarea");return e.openBlock(),e.createElementBlock(e.Fragment,null,[a[8]||(a[8]=e.createElementVNode("p",{class:"text-sm text-muted-foreground mb-2"},"How do you want to create the codes?",-1)),e.createVNode(o,{modelValue:e.unref(n).generationMode,"onUpdate:modelValue":a[0]||(a[0]=N=>e.unref(n).generationMode=N),orientation:"vertical",class:"mb-6"},{default:e.withCtx(()=>[e.createElementVNode("div",L,[e.createVNode(s,{id:"generation_mode_generate",value:"generate"}),e.createVNode(i,{for:"generation_mode_generate"},{default:e.withCtx(()=>[...a[3]||(a[3]=[e.createTextVNode("Generate random codes",-1)])]),_:1})]),e.createElementVNode("div",z,[e.createVNode(s,{id:"generation_mode_input",value:"input"}),e.createVNode(i,{for:"generation_mode_input"},{default:e.withCtx(()=>[...a[4]||(a[4]=[e.createTextVNode("Provide specific codes",-1)])]),_:1})])]),_:1},8,["modelValue"]),e.unref(n).generationMode=="generate"?(e.openBlock(),e.createElementBlock("div",O,[e.createVNode(p,{id:"age","default-value":1,min:1,class:"w-full"},{default:e.withCtx(()=>[e.createVNode(i,{for:"age",class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...a[5]||(a[5]=[e.createTextVNode("Number of codes to generate",-1)])]),_:1}),e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(m),e.createVNode(g),e.createVNode(u)]),_:1})]),_:1}),e.createElementVNode("div",j,[e.createVNode(V,{modelValue:e.unref(n).prefix,"onUpdate:modelValue":a[1]||(a[1]=N=>e.unref(n).prefix=N),placeholder:"Prefix",class:"pr-42"},null,8,["modelValue"]),a[6]||(a[6]=e.createElementVNode("span",{class:"absolute right-2 top-1/2 transform -translate-y-1/2 text-muted-foreground/80 pointer-events-none"},"- GENERATED CODE",-1))])])):(e.openBlock(),e.createElementBlock("div",G,[e.createVNode(i,{class:"text-muted-foreground mb-2",for:"codes"},{default:e.withCtx(()=>[...a[7]||(a[7]=[e.createTextVNode("Enter the codes you want to create (one per line)",-1)])]),_:1}),e.createVNode(r,{modelValue:e.unref(n).codes,"onUpdate:modelValue":a[2]||(a[2]=N=>e.unref(n).codes=N),id:"codes",class:"max-h-48"},null,8,["modelValue"])]))],64)}}}),J={class:"grid gap-6 py-4"},q={class:"flex items-center"},H={class:"flex items-center gap-2"},Y={class:"flex items-center gap-2"},K={class:"flex items-center gap-2"},W={class:"flex items-center gap-2"},Q={class:"flex items-center space-x-2 mb-2"},X={key:0,class:"text-xs text-blue-600 bg-blue-500/10 p-2 rounded border border-blue-500 mt-1 flex items-start gap-1"},Z={class:"flex items-center space-x-2 mb-2"},ee=e.defineComponent({__name:"TypeDetailDialog",setup(b,{expose:n}){const{isAdmin:_}=w.useModulePermissions(),{getModuleData:a,setModuleData:s}=w.useModuleStorage(),i=e.inject("promoTypes",e.ref([])),o=e.ref({id:"",label:"",key:"",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""}),m=e.ref(!1),g=e.ref("add"),u=e.ref(!1),l=f=>{m.value=!0,u.value=!1,f?(g.value="edit",o.value=JSON.parse(JSON.stringify(f))):(g.value="add",o.value={id:crypto.randomUUID(),label:"",key:"",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""})},p=f=>{m.value=!0,u.value=!1,g.value="add",N(f)},V=async()=>{u.value=!0;let f=await a("promo-types")||[];f.push(JSON.parse(JSON.stringify(o.value))),s("promo-types",f),i.value=JSON.parse(JSON.stringify(f)),m.value=!1},r=async()=>{u.value=!0;let f=await a("promo-types")||[];f=f.map(t=>t.id===o.value.id?o.value:t),s("promo-types",f),i.value=JSON.parse(JSON.stringify(f)),m.value=!1},N=f=>{switch(f){case"fixed":o.value={id:crypto.randomUUID(),label:"Fixed Amount",key:"fixed",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Amount",valuePrefix:"$",valueSuffix:""};break;case"percentage":o.value={id:crypto.randomUUID(),label:"Percentage",key:"percentage",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Percentage",valuePrefix:"",valueSuffix:"%"};break;case"free_shipping":o.value={id:crypto.randomUUID(),label:"Free Shipping",key:"free_shipping",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""};break}};return n({open:l,openFromTemplate:p}),(f,t)=>{const x=e.resolveComponent("DialogTitle"),c=e.resolveComponent("DialogHeader"),k=e.resolveComponent("Button"),U=e.resolveComponent("DropdownMenuTrigger"),y=e.resolveComponent("DropdownMenuItem"),E=e.resolveComponent("DropdownMenuContent"),S=e.resolveComponent("DropdownMenu"),C=e.resolveComponent("Label"),D=e.resolveComponent("Input"),B=e.resolveComponent("Switch"),P=e.resolveComponent("DialogFooter"),F=e.resolveComponent("DialogScrollContent"),M=e.resolveComponent("Dialog");return e.openBlock(),e.createBlock(M,{open:m.value,"onUpdate:open":t[11]||(t[11]=d=>m.value=d)},{default:e.withCtx(()=>[e.unref(_)()?(e.openBlock(),e.createBlock(F,{key:0,class:"sm:max-w-[475px]"},{default:e.withCtx(()=>[e.createVNode(c,null,{default:e.withCtx(()=>[e.createVNode(x,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(g.value==="add"?"Add Promo Type":"Edit Promo Type"),1)]),_:1})]),_:1}),e.createElementVNode("div",J,[e.createElementVNode("div",q,[g.value==="add"?(e.openBlock(),e.createBlock(S,{key:0},{default:e.withCtx(()=>[e.createVNode(U,null,{default:e.withCtx(()=>[e.createVNode(k,{variant:"outline"},{default:e.withCtx(()=>[e.createElementVNode("div",H,[e.createVNode(e.unref(v.Import),{class:"size-4"}),t[12]||(t[12]=e.createTextVNode(" Load pre-defined type ",-1))])]),_:1})]),_:1}),e.createVNode(E,null,{default:e.withCtx(()=>[e.createVNode(y,{onClick:t[0]||(t[0]=d=>N("fixed"))},{default:e.withCtx(()=>[e.createElementVNode("div",Y,[e.createVNode(e.unref(v.DollarSign),{class:"size-4"}),t[13]||(t[13]=e.createTextVNode(" Fixed Amount ",-1))])]),_:1}),e.createVNode(y,{onClick:t[1]||(t[1]=d=>N("percentage"))},{default:e.withCtx(()=>[e.createElementVNode("div",K,[e.createVNode(e.unref(v.Percent),{class:"size-4"}),t[14]||(t[14]=e.createTextVNode(" Percentage ",-1))])]),_:1}),e.createVNode(y,{onClick:t[2]||(t[2]=d=>N("free_shipping"))},{default:e.withCtx(()=>[e.createElementVNode("div",W,[e.createVNode(e.unref(v.Truck),{class:"size-4"}),t[15]||(t[15]=e.createTextVNode(" Free Shipping ",-1))])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0)]),e.createElementVNode("div",null,[e.createVNode(C,{for:"label",class:"mb-2"},{default:e.withCtx(()=>[...t[16]||(t[16]=[e.createTextVNode("Display Name",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.label,"onUpdate:modelValue":t[3]||(t[3]=d=>o.value.label=d),id:"label"},null,8,["modelValue"]),t[17]||(t[17]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},'Shown in the Studio UI. e.g. "VIP Shipping"',-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"key",class:"mb-2"},{default:e.withCtx(()=>[...t[18]||(t[18]=[e.createTextVNode("Internal Key",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.key,"onUpdate:modelValue":t[4]||(t[4]=d=>o.value.key=d),id:"key"},null,8,["modelValue"]),t[19]||(t[19]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},[e.createTextVNode("Used in logic. Must be unique, lowercase, no spaces. e.g. "),e.createElementVNode("span",{class:"font-mono bg-muted-foreground/20 px-1 py-0.5 rounded"},"vip_shipping")],-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"allowUnlimitedUses",class:"mb-4"},{default:e.withCtx(()=>[...t[20]||(t[20]=[e.createTextVNode("Allow Unlimited Uses",-1)])]),_:1}),e.createElementVNode("div",Q,[e.createVNode(B,{id:"allowUnlimitedUses",modelValue:o.value.allowUnlimitedUses,"onUpdate:modelValue":t[5]||(t[5]=d=>o.value.allowUnlimitedUses=d)},null,8,["modelValue"]),e.createVNode(C,{for:"allowUnlimitedUses"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.value.allowUnlimitedUses?"Yes":"No"),1)]),_:1})]),t[22]||(t[22]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},'Show the "Unlimited uses" toggle when creating a promo code.',-1)),o.value.allowUnlimitedUses?(e.openBlock(),e.createElementBlock("p",X,[e.createVNode(e.unref(v.Info),{class:"size-4"}),t[21]||(t[21]=e.createTextVNode(" This option is always hidden when generating multiple codes. ",-1))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",null,[e.createVNode(C,{for:"hasValueField",class:"mb-4"},{default:e.withCtx(()=>[...t[23]||(t[23]=[e.createTextVNode("Has Value Field",-1)])]),_:1}),e.createElementVNode("div",Z,[e.createVNode(B,{id:"hasValueField",modelValue:o.value.hasValueField,"onUpdate:modelValue":t[6]||(t[6]=d=>o.value.hasValueField=d)},null,8,["modelValue"]),e.createVNode(C,{for:"hasValueField"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.value.hasValueField?"Yes":"No"),1)]),_:1})]),t[24]||(t[24]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},"Show a numeric value input when using this type.",-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"valueLabel",class:"mb-2"},{default:e.withCtx(()=>[...t[25]||(t[25]=[e.createTextVNode("Value Field Label",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.valueLabel,"onUpdate:modelValue":t[7]||(t[7]=d=>o.value.valueLabel=d),id:"valueLabel"},null,8,["modelValue"]),t[26]||(t[26]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},'e.g. "Gift amount", "Shipping cost"',-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"valuePrefix",class:"mb-2"},{default:e.withCtx(()=>[...t[27]||(t[27]=[e.createTextVNode("Value Field Prefix",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.valuePrefix,"onUpdate:modelValue":t[8]||(t[8]=d=>o.value.valuePrefix=d),id:"valuePrefix"},null,8,["modelValue"]),t[28]||(t[28]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},"e.g. € or $",-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"valueSuffix",class:"mb-2"},{default:e.withCtx(()=>[...t[29]||(t[29]=[e.createTextVNode("Value Field Suffix",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.valueSuffix,"onUpdate:modelValue":t[9]||(t[9]=d=>o.value.valueSuffix=d),id:"valueSuffix"},null,8,["modelValue"]),t[30]||(t[30]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},"e.g. %, credits",-1))])]),e.createVNode(P,null,{default:e.withCtx(()=>[e.createVNode(k,{variant:"outline",onClick:t[10]||(t[10]=d=>m.value=!1)},{default:e.withCtx(()=>[...t[31]||(t[31]=[e.createTextVNode("Cancel",-1)])]),_:1}),g.value==="add"?(e.openBlock(),e.createBlock(k,{key:0,disabled:u.value,onClick:V},{default:e.withCtx(()=>[u.value?(e.openBlock(),e.createBlock(e.unref(v.Loader2),{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),t[32]||(t[32]=e.createTextVNode(" Add Type ",-1))]),_:1},8,["disabled"])):(e.openBlock(),e.createBlock(k,{key:1,disabled:u.value,onClick:r},{default:e.withCtx(()=>[u.value?(e.openBlock(),e.createBlock(e.unref(v.Loader2),{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),t[33]||(t[33]=e.createTextVNode(" Save Changes ",-1))]),_:1},8,["disabled"]))]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:1},8,["open"])}}}),te={class:"grid gap-4 py-4"},oe={key:0,class:"flex flex-col gap-2 items-center text-muted-foreground border rounded p-4"},le={class:"flex gap-2 items-center"},ne={key:1},ae={class:"flex justify-end w-full mb-2"},re={class:"flex items-center gap-2"},se={class:"flex items-center gap-2"},de={class:"flex items-center gap-2"},ie={class:"flex items-center gap-2"},ue={class:"flex items-center gap-2"},ce={class:"font-mono bg-muted-foreground/20 px-1 py-0.5 rounded"},me=e.defineComponent({__name:"TypeManageDialog",setup(b){const{isAdmin:n}=w.useModulePermissions(),{getModuleData:_,setModuleData:a}=w.useModuleStorage(),{confirm:s}=w.useConfirmation(),i=e.inject("promoTypes",e.ref([])),o=e.useTemplateRef("typeDetailDialog"),m=async u=>{if(!await s(`Are you sure you want to delete the type "${u.label}"?`))return;let p=await _("promo-types")||[];p=p.filter(V=>V.id!==u.id),a("promo-types",p),i.value=JSON.parse(JSON.stringify(p))},g=async()=>{const u=[{id:crypto.randomUUID(),label:"Fixed Amount",key:"fixed",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Amount",valuePrefix:"$",valueSuffix:""},{id:crypto.randomUUID(),label:"Percentage",key:"percentage",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Percentage",valuePrefix:"",valueSuffix:"%"},{id:crypto.randomUUID(),label:"Free Shipping",key:"free_shipping",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""}];a("promo-types",u),i.value=JSON.parse(JSON.stringify(u))};return(u,l)=>{const p=e.resolveComponent("Button"),V=e.resolveComponent("DialogTrigger"),r=e.resolveComponent("DialogTitle"),N=e.resolveComponent("DialogDescription"),f=e.resolveComponent("DialogHeader"),t=e.resolveComponent("DropdownMenuTrigger"),x=e.resolveComponent("DropdownMenuItem"),c=e.resolveComponent("DropdownMenuSeparator"),k=e.resolveComponent("DropdownMenuContent"),U=e.resolveComponent("DropdownMenu"),y=e.resolveComponent("TableHead"),E=e.resolveComponent("TableRow"),S=e.resolveComponent("TableHeader"),C=e.resolveComponent("TableCell"),D=e.resolveComponent("TableBody"),B=e.resolveComponent("Table"),P=e.resolveComponent("DialogFooter"),F=e.resolveComponent("DialogScrollContent"),M=e.resolveComponent("Dialog");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(M,null,{default:e.withCtx(()=>[e.createVNode(V,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(p,null,{default:e.withCtx(()=>[e.createVNode(e.unref(v.UserCog),{class:"size-4"}),l[6]||(l[6]=e.createTextVNode(" Edit Promo Types ",-1))]),_:1})]),_:1}),e.unref(n)()?(e.openBlock(),e.createBlock(F,{key:0,class:"sm:max-w-2xl"},{default:e.withCtx(()=>[e.createVNode(f,null,{default:e.withCtx(()=>[e.createVNode(r,null,{default:e.withCtx(()=>[...l[7]||(l[7]=[e.createTextVNode("Edit Promo Types",-1)])]),_:1}),e.createVNode(N,null,{default:e.withCtx(()=>[...l[8]||(l[8]=[e.createTextVNode(" Define reusable custom promo types to use in discount codes. You can configure how they behave and what fields are shown. ",-1)])]),_:1})]),_:1}),e.createElementVNode("div",te,[e.unref(i).length===0?(e.openBlock(),e.createElementBlock("div",oe,[l[12]||(l[12]=e.createElementVNode("p",null,"You haven't created any custom types yet.",-1)),e.createElementVNode("p",le,[e.createVNode(p,{variant:"link",onClick:l[0]||(l[0]=d=>o.value?.open())},{default:e.withCtx(()=>[...l[9]||(l[9]=[e.createTextVNode("Create a custom type",-1)])]),_:1}),l[11]||(l[11]=e.createTextVNode(" or ",-1)),e.createVNode(p,{variant:"link",onClick:l[1]||(l[1]=d=>g())},{default:e.withCtx(()=>[...l[10]||(l[10]=[e.createTextVNode("Import Default Types",-1)])]),_:1})])])):(e.openBlock(),e.createElementBlock("div",ne,[e.createElementVNode("div",ae,[e.createVNode(U,null,{default:e.withCtx(()=>[e.createVNode(t,null,{default:e.withCtx(()=>[e.createVNode(p,{variant:"outline"},{default:e.withCtx(()=>[e.createElementVNode("div",re,[e.createVNode(e.unref(v.Plus),{class:"size-4"}),l[13]||(l[13]=e.createTextVNode(" Create new Promo Type ",-1))])]),_:1})]),_:1}),e.createVNode(k,null,{default:e.withCtx(()=>[e.createVNode(x,{onClick:l[2]||(l[2]=d=>o.value?.open())},{default:e.withCtx(()=>[e.createElementVNode("div",se,[e.createVNode(e.unref(v.Plus),{class:"size-4"}),l[14]||(l[14]=e.createTextVNode(" New Type ",-1))])]),_:1}),e.createVNode(c),e.createVNode(x,{onClick:l[3]||(l[3]=d=>o.value?.openFromTemplate("fixed"))},{default:e.withCtx(()=>[e.createElementVNode("div",de,[e.createVNode(e.unref(v.DollarSign),{class:"size-4"}),l[15]||(l[15]=e.createTextVNode(" Fixed Amount ",-1))])]),_:1}),e.createVNode(x,{onClick:l[4]||(l[4]=d=>o.value?.openFromTemplate("percentage"))},{default:e.withCtx(()=>[e.createElementVNode("div",ie,[e.createVNode(e.unref(v.Percent),{class:"size-4"}),l[16]||(l[16]=e.createTextVNode(" Percentage ",-1))])]),_:1}),e.createVNode(x,{onClick:l[5]||(l[5]=d=>o.value?.openFromTemplate("free_shipping"))},{default:e.withCtx(()=>[e.createElementVNode("div",ue,[e.createVNode(e.unref(v.Truck),{class:"size-4"}),l[17]||(l[17]=e.createTextVNode(" Free Shipping ",-1))])]),_:1})]),_:1})]),_:1})]),e.createVNode(B,null,{default:e.withCtx(()=>[e.createVNode(S,null,{default:e.withCtx(()=>[e.createVNode(E,null,{default:e.withCtx(()=>[e.createVNode(y,null,{default:e.withCtx(()=>[...l[18]||(l[18]=[e.createTextVNode("Name (label)",-1)])]),_:1}),e.createVNode(y,null,{default:e.withCtx(()=>[...l[19]||(l[19]=[e.createTextVNode("Key",-1)])]),_:1}),e.createVNode(y,null,{default:e.withCtx(()=>[...l[20]||(l[20]=[e.createTextVNode("Value Field",-1)])]),_:1}),e.createVNode(y,null,{default:e.withCtx(()=>[...l[21]||(l[21]=[e.createTextVNode("Unlimited Uses",-1)])]),_:1}),e.createVNode(y,{class:"text-right"},{default:e.withCtx(()=>[...l[22]||(l[22]=[e.createTextVNode("Actions",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(D,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i),d=>(e.openBlock(),e.createBlock(E,{key:d.key},{default:e.withCtx(()=>[e.createVNode(C,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.label),1)]),_:2},1024),e.createVNode(C,null,{default:e.withCtx(()=>[e.createElementVNode("span",ce,e.toDisplayString(d.key),1)]),_:2},1024),e.createVNode(C,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.hasValueField?"Yes":"No"),1)]),_:2},1024),e.createVNode(C,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.allowUnlimitedUses?"Yes":"No"),1)]),_:2},1024),e.createVNode(C,{class:"text-right"},{default:e.withCtx(()=>[e.createVNode(p,{variant:"ghost",size:"icon",onClick:A=>o.value?.open(d)},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Pencil),{class:"size-4"})]),_:1},8,["onClick"]),e.createVNode(p,{variant:"ghost",size:"icon",onClick:A=>m(d)},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Trash2),{class:"size-4 text-red-500"})]),_:1},8,["onClick"])]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})]))]),e.createVNode(P,null,{default:e.withCtx(()=>[e.createVNode(p,{variant:"outline",disabled:""},{default:e.withCtx(()=>[...l[23]||(l[23]=[e.createTextVNode(" Auto-saved ",-1)])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:1}),e.createVNode(ee,{ref_key:"typeDetailDialog",ref:o},null,512)],64)}}}),pe={class:"flex justify-between items-center"},fe={class:"grid gap-2"},Ve={class:"flex flex-wrap gap-12"},xe={key:0,class:"grid gap-2"},ve={class:"flex items-center gap-2"},Ne={key:1,class:"grid gap-2"},Ce={class:"flex items-center space-x-2"},ge=e.defineComponent({__name:"index",setup(b){const n=e.inject("newCoupon"),_=e.inject("promoTypes",e.ref([])),a=e.computed(()=>_.value.find(i=>i.key===n.value?.type)||null),{isAdmin:s}=w.useModulePermissions();return(i,o)=>{const m=e.resolveComponent("Label"),g=e.resolveComponent("SelectValue"),u=e.resolveComponent("SelectTrigger"),l=e.resolveComponent("SelectItem"),p=e.resolveComponent("SelectGroup"),V=e.resolveComponent("SelectContent"),r=e.resolveComponent("Select"),N=e.resolveComponent("Input"),f=e.resolveComponent("Switch"),t=e.resolveComponent("Card");return e.openBlock(),e.createBlock(t,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",pe,[o[3]||(o[3]=e.createElementVNode("h2",{class:"font-medium"},"Value",-1)),e.unref(s)()?(e.openBlock(),e.createBlock(me,{key:0})):e.createCommentVNode("",!0)]),e.createElementVNode("div",fe,[e.createVNode(m,{class:"text-muted-foreground"},{default:e.withCtx(()=>[...o[4]||(o[4]=[e.createTextVNode("Promo Type",-1)])]),_:1}),e.createVNode(r,{modelValue:e.unref(n).type,"onUpdate:modelValue":o[0]||(o[0]=x=>e.unref(n).type=x)},{default:e.withCtx(()=>[e.createVNode(u,{class:"w-[200px]"},{default:e.withCtx(()=>[e.createVNode(g,{placeholder:"Select a promo type"})]),_:1}),e.createVNode(V,null,{default:e.withCtx(()=>[e.createVNode(p,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),x=>(e.openBlock(),e.createBlock(l,{key:x.key,value:x.key},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.label),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1})]),_:1},8,["modelValue"])]),e.createElementVNode("div",Ve,[a.value?.hasValueField?(e.openBlock(),e.createElementBlock("div",xe,[e.createVNode(m,{for:"discountValue",class:"text-muted-foreground"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value?.valueLabel||"Value"),1)]),_:1}),e.createElementVNode("div",ve,[a.value?.valuePrefix?(e.openBlock(),e.createBlock(m,{key:0,for:"discountValue",class:"text-lg"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value?.valuePrefix),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(N,{modelValue:e.unref(n).value,"onUpdate:modelValue":o[1]||(o[1]=x=>e.unref(n).value=x),id:"discountValue"},null,8,["modelValue"]),a.value?.valueSuffix?(e.openBlock(),e.createBlock(m,{key:1,for:"discountValue",class:"text-lg"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value?.valueSuffix),1)]),_:1})):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),a.value?.allowUnlimitedUses&&e.unref(n).creationMode!=="multi"?(e.openBlock(),e.createElementBlock("div",Ne,[e.createVNode(m,{for:"unlimitedUses",class:"text-muted-foreground"},{default:e.withCtx(()=>[...o[5]||(o[5]=[e.createTextVNode("Unlimited Uses",-1)])]),_:1}),e.createElementVNode("div",Ce,[e.createVNode(f,{id:"unlimitedUses",modelValue:e.unref(n).unlimitedUses,"onUpdate:modelValue":o[2]||(o[2]=x=>e.unref(n).unlimitedUses=x)},null,8,["modelValue"]),e.createVNode(m,{for:"unlimitedUses"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n).unlimitedUses?"Yes":"No"),1)]),_:1})])])):e.createCommentVNode("",!0)])]),_:1})}}}),_e={class:"flex gap-4"},we={class:"flex flex-col"},ye={key:0,class:"-ml-2"},ke={key:1,class:"text-xs text-muted-foreground mt-2"},be={class:"flex flex-col"},Te={key:0,class:"-ml-2"},De={key:1,class:"text-xs text-muted-foreground mt-2"},Ue=e.defineComponent({__name:"DateRange",setup(b){const n=e.inject("newCoupon"),_=new $.$fb18d541ea1ad717$export$ad991b66133851cf("en-US",{dateStyle:"long"});return(a,s)=>{const i=e.resolveComponent("Label"),o=e.resolveComponent("Button"),m=e.resolveComponent("PopoverTrigger"),g=e.resolveComponent("Calendar"),u=e.resolveComponent("PopoverContent"),l=e.resolveComponent("Popover"),p=e.resolveComponent("Card");return e.openBlock(),e.createBlock(p,{class:"p-4"},{default:e.withCtx(()=>[s[8]||(s[8]=e.createElementVNode("div",null,[e.createElementVNode("h2",{class:"font-medium mb-2"},"Availability"),e.createElementVNode("p",{class:"text-muted-foreground"},"When will this code be available?")],-1)),e.createElementVNode("div",_e,[e.createElementVNode("div",we,[e.createVNode(i,{class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...s[4]||(s[4]=[e.createTextVNode("Available from",-1)])]),_:1}),e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(m,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(o,{variant:"outline",class:e.normalizeClass(e.unref(h.classNames)("w-[280px] justify-start text-left font-normal",!e.unref(n).startsAt&&"text-muted-foreground"))},{default:e.withCtx(()=>[e.createVNode(e.unref(v.CalendarIcon),{class:"mr-2 h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(n).startsAt?e.unref(_).format(e.unref(n).startsAt.toDate(e.unref($.$14e0f24ef4ac5c92$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class"])]),_:1}),e.createVNode(u,{class:"w-auto p-0"},{default:e.withCtx(()=>[e.createVNode(g,{modelValue:e.unref(n).startsAt,"onUpdate:modelValue":s[0]||(s[0]=V=>e.unref(n).startsAt=V),"initial-focus":"",minValue:e.unref($.$14e0f24ef4ac5c92$export$d0bdf45af03a6ea3)()},null,8,["modelValue","minValue"])]),_:1})]),_:1}),e.unref(n).startsAt?(e.openBlock(),e.createElementBlock("div",ye,[e.createVNode(o,{onClick:s[1]||(s[1]=V=>e.unref(n).startsAt=void 0),variant:"link"},{default:e.withCtx(()=>[...s[5]||(s[5]=[e.createTextVNode("Clear",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("p",ke,"Not set - codes will be available immediately"))]),e.createElementVNode("div",be,[e.createVNode(i,{class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...s[6]||(s[6]=[e.createTextVNode("Until",-1)])]),_:1}),e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(m,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(o,{variant:"outline",class:e.normalizeClass(e.unref(h.classNames)("w-[280px] justify-start text-left font-normal",!e.unref(n).expiresAt&&"text-muted-foreground"))},{default:e.withCtx(()=>[e.createVNode(e.unref(v.CalendarIcon),{class:"mr-2 h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(n).expiresAt?e.unref(_).format(e.unref(n).expiresAt.toDate(e.unref($.$14e0f24ef4ac5c92$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class"])]),_:1}),e.createVNode(u,{class:"w-auto p-0"},{default:e.withCtx(()=>[e.createVNode(g,{modelValue:e.unref(n).expiresAt,"onUpdate:modelValue":s[2]||(s[2]=V=>e.unref(n).expiresAt=V),"initial-focus":"",minValue:e.unref(n).startsAt},null,8,["modelValue","minValue"])]),_:1})]),_:1}),e.unref(n).expiresAt?(e.openBlock(),e.createElementBlock("div",Te,[e.createVNode(o,{onClick:s[3]||(s[3]=V=>e.unref(n).expiresAt=void 0),variant:"link"},{default:e.withCtx(()=>[...s[7]||(s[7]=[e.createTextVNode("Clear",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("p",De,"Not set - codes will never expire"))])])]),_:1})}}}),Ee=e.defineComponent({__name:"Note",setup(b){const n=e.inject("newCoupon");return(_,a)=>{const s=e.resolveComponent("Textarea"),i=e.resolveComponent("Card");return e.openBlock(),e.createBlock(i,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",null,[a[1]||(a[1]=e.createElementVNode("h2",{class:"font-medium mb-2"},"Note",-1)),a[2]||(a[2]=e.createElementVNode("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)),e.createVNode(s,{modelValue:e.unref(n).note,"onUpdate:modelValue":a[0]||(a[0]=o=>e.unref(n).note=o)},null,8,["modelValue"])])]),_:1})}}}),Se={class:"relative"},Be={ref:"container",class:"flex flex-col gap-4 w-full max-w-5xl mx-auto"},$e={class:"flex justify-between items-center mb-4"},Pe={class:"w-full max-w-2xl"},Fe={class:"flex items-center space-x-2"},Me={class:"flex items-center space-x-2"},he={class:"flex justify-end w-full"},Ae=e.defineComponent({__name:"Create",props:{config:{type:Object,required:!0}},async setup(b){let n,_;const a=b,{hasPermission:s}=w.useModulePermissions(),{navigateTo:i}=w.useModuleRoute(),{getTimezone:o}=w.useProjectSettings(),{log:m,logError:g}=w.useLogs(),{getModuleData:u,setModuleData:l}=w.useModuleStorage();w.useModuleBreadcrumbs(()=>[]);const p=w.useFirebaseIntegration(a.config.project),V=e.ref(!1),r=e.ref({creationMode:"single",generationMode:"generate",quantity:1,prefix:"",codes:"",code:"",type:void 0,value:void 0,unlimitedUses:!1,startsAt:void 0,expiresAt:void 0,minOrderAmount:0,note:""}),N=e.ref([]);N.value=([n,_]=e.withAsyncContext(()=>u("promo-types")),n=await n,_(),n||[]),e.provide("newCoupon",r),e.provide("promoTypes",N);const f=()=>{if(r.value.creationMode=="single"){if(r.value.code=r.value.code?.trim().toUpperCase(),!r.value.code)return T.toast.error("Please enter a code"),!1}else if(r.value.generationMode=="generate"){if(r.value.prefix=r.value.prefix?.trim().toUpperCase(),!r.value.prefix)return T.toast.error("Please enter a prefix"),!1;if(!r.value.quantity||r.value.quantity<1)return T.toast.error("Generate at least 1 code"),!1}else if(r.value.generationMode=="input"&&(r.value.codes=r.value.codes?.trim().toUpperCase(),!r.value.codes||r.value.codes.length<1))return T.toast.error("Please enter some codes"),!1;return r.value.type?N.value.find(x=>x.key===r.value.type)?.hasValueField&&!r.value.value?(T.toast.error("Please enter a value"),!1):(r.value.creationMode==="multi"&&(r.value.unlimitedUses=!1),!0):(T.toast.error("Please select a type"),!1)},t=async()=>{try{if(!f())return;if(V.value=!0,r.value.creationMode=="single"){let x={code:r.value.code,type:r.value.type,value:r.value.value,minOrderAmount:r.value.minOrderAmount,usageLimit:r.value.unlimitedUses?0:1,usageCount:0,lastUsedAt:null,startsAt:r.value.startsAt?r.value.startsAt.toDate(o()):null,expiresAt:r.value.expiresAt?r.value.expiresAt.toDate(o()):null,disabled:!1,note:r.value.note,createdAt:new Date,updatedAt:new Date};const c=await p.add(a.config.promoCodeCollection,x);m("Promo code created",{id:c.id,code:c.code,note:c.note}),T.toast.success("Promo code created")}}catch{g("Failed to create promo code"),T.toast.error("Failed to create promo code")}finally{V.value=!1}};return(x,c)=>{const k=e.resolveComponent("Button"),U=e.resolveComponent("RadioGroupItem"),y=e.resolveComponent("Label"),E=e.resolveComponent("RadioGroup"),S=e.resolveComponent("Card");return e.openBlock(),e.createElementBlock("div",Se,[e.createElementVNode("div",Be,[e.createElementVNode("div",$e,[c[3]||(c[3]=e.createElementVNode("h1",{class:"text-2xl font-bold"},"New Promo Code",-1)),e.createVNode(k,{onClick:c[0]||(c[0]=C=>e.unref(i)("promo-codes")),variant:"outline",disabled:V.value},{default:e.withCtx(()=>[e.createVNode(e.unref(v.List),{class:"size-4"}),c[2]||(c[2]=e.createTextVNode(" View Promo Codes ",-1))]),_:1},8,["disabled"])]),e.createVNode(S,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",Pe,[c[6]||(c[6]=e.createElementVNode("h2",{class:"font-medium mb-4"},"Codes",-1)),e.createVNode(E,{modelValue:r.value.creationMode,"onUpdate:modelValue":c[1]||(c[1]=C=>r.value.creationMode=C),orientation:"horizontal",class:"mb-6"},{default:e.withCtx(()=>[e.createElementVNode("div",Fe,[e.createVNode(U,{id:"creation_mode_single",value:"single"}),e.createVNode(y,{for:"creation_mode_single"},{default:e.withCtx(()=>[...c[4]||(c[4]=[e.createTextVNode("Create 1 code",-1)])]),_:1})]),e.createElementVNode("div",Me,[e.createVNode(U,{id:"creation_mode_multi",value:"multi"}),e.createVNode(y,{for:"creation_mode_multi"},{default:e.withCtx(()=>[...c[5]||(c[5]=[e.createTextVNode("Create multiple codes",-1)])]),_:1})])]),_:1},8,["modelValue"]),r.value.creationMode=="single"?(e.openBlock(),e.createBlock(I,{key:0})):(e.openBlock(),e.createBlock(R,{key:1}))])]),_:1}),e.createVNode(ge),e.createVNode(Ue),e.createVNode(Ee),e.createElementVNode("div",he,[e.createVNode(k,{disabled:V.value,onClick:t},{default:e.withCtx(()=>[V.value?(e.openBlock(),e.createBlock(e.unref(v.Loader2),{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),c[7]||(c[7]=e.createTextVNode(" Create Promo Code ",-1))]),_:1},8,["disabled"])])],512)])}}});exports.default=Ae;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),v=require("lucide-vue-next"),w=require("@oneclick.dev/cms-kit"),h=require("./utils-D6CaKJbp.js"),$=require("./DateFormatter-DbtOLV0L.js"),T=require("./index-ijdf0d9-.js"),I=e.defineComponent({__name:"SingleCode",setup(b){const n=e.inject("newCoupon");return(_,a)=>{const s=e.resolveComponent("Label"),i=e.resolveComponent("Input");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(s,{class:"text-muted-foreground mb-2",for:"code"},{default:e.withCtx(()=>[...a[1]||(a[1]=[e.createTextVNode("Enter the coupon code",-1)])]),_:1}),e.createVNode(i,{modelValue:e.unref(n).code,"onUpdate:modelValue":a[0]||(a[0]=o=>e.unref(n).code=o),id:"code"},null,8,["modelValue"])],64)}}}),L={class:"flex items-center space-x-2"},z={class:"flex items-center space-x-2"},O={key:0,class:"flex items-end w-full gap-4"},j={class:"relative w-full"},G={key:1},R=e.defineComponent({__name:"MultiCodes",setup(b){const n=e.inject("newCoupon");return(_,a)=>{const s=e.resolveComponent("RadioGroupItem"),i=e.resolveComponent("Label"),o=e.resolveComponent("RadioGroup"),m=e.resolveComponent("NumberFieldDecrement"),g=e.resolveComponent("NumberFieldInput"),u=e.resolveComponent("NumberFieldIncrement"),l=e.resolveComponent("NumberFieldContent"),p=e.resolveComponent("NumberField"),V=e.resolveComponent("Input"),r=e.resolveComponent("Textarea");return e.openBlock(),e.createElementBlock(e.Fragment,null,[a[8]||(a[8]=e.createElementVNode("p",{class:"text-sm text-muted-foreground mb-2"},"How do you want to create the codes?",-1)),e.createVNode(o,{modelValue:e.unref(n).generationMode,"onUpdate:modelValue":a[0]||(a[0]=N=>e.unref(n).generationMode=N),orientation:"vertical",class:"mb-6"},{default:e.withCtx(()=>[e.createElementVNode("div",L,[e.createVNode(s,{id:"generation_mode_generate",value:"generate"}),e.createVNode(i,{for:"generation_mode_generate"},{default:e.withCtx(()=>[...a[3]||(a[3]=[e.createTextVNode("Generate random codes",-1)])]),_:1})]),e.createElementVNode("div",z,[e.createVNode(s,{id:"generation_mode_input",value:"input"}),e.createVNode(i,{for:"generation_mode_input"},{default:e.withCtx(()=>[...a[4]||(a[4]=[e.createTextVNode("Provide specific codes",-1)])]),_:1})])]),_:1},8,["modelValue"]),e.unref(n).generationMode=="generate"?(e.openBlock(),e.createElementBlock("div",O,[e.createVNode(p,{id:"age","default-value":1,min:1,class:"w-full"},{default:e.withCtx(()=>[e.createVNode(i,{for:"age",class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...a[5]||(a[5]=[e.createTextVNode("Number of codes to generate",-1)])]),_:1}),e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(m),e.createVNode(g),e.createVNode(u)]),_:1})]),_:1}),e.createElementVNode("div",j,[e.createVNode(V,{modelValue:e.unref(n).prefix,"onUpdate:modelValue":a[1]||(a[1]=N=>e.unref(n).prefix=N),placeholder:"Prefix",class:"pr-42"},null,8,["modelValue"]),a[6]||(a[6]=e.createElementVNode("span",{class:"absolute right-2 top-1/2 transform -translate-y-1/2 text-muted-foreground/80 pointer-events-none"},"- GENERATED CODE",-1))])])):(e.openBlock(),e.createElementBlock("div",G,[e.createVNode(i,{class:"text-muted-foreground mb-2",for:"codes"},{default:e.withCtx(()=>[...a[7]||(a[7]=[e.createTextVNode("Enter the codes you want to create (one per line)",-1)])]),_:1}),e.createVNode(r,{modelValue:e.unref(n).codes,"onUpdate:modelValue":a[2]||(a[2]=N=>e.unref(n).codes=N),id:"codes",class:"max-h-48"},null,8,["modelValue"])]))],64)}}}),J={class:"grid gap-6 py-4"},q={class:"flex items-center"},H={class:"flex items-center gap-2"},Y={class:"flex items-center gap-2"},K={class:"flex items-center gap-2"},W={class:"flex items-center gap-2"},Q={class:"flex items-center space-x-2 mb-2"},X={key:0,class:"text-xs text-blue-600 bg-blue-500/10 p-2 rounded border border-blue-500 mt-1 flex items-start gap-1"},Z={class:"flex items-center space-x-2 mb-2"},ee=e.defineComponent({__name:"TypeDetailDialog",setup(b,{expose:n}){const{isAdmin:_}=w.useModulePermissions(),{getModuleData:a,setModuleData:s}=w.useModuleStorage(),i=e.inject("promoTypes",e.ref([])),o=e.ref({id:"",label:"",key:"",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""}),m=e.ref(!1),g=e.ref("add"),u=e.ref(!1),l=f=>{m.value=!0,u.value=!1,f?(g.value="edit",o.value=JSON.parse(JSON.stringify(f))):(g.value="add",o.value={id:crypto.randomUUID(),label:"",key:"",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""})},p=f=>{m.value=!0,u.value=!1,g.value="add",N(f)},V=async()=>{u.value=!0;let f=await a("promo-types")||[];f.push(JSON.parse(JSON.stringify(o.value))),s("promo-types",f),i.value=JSON.parse(JSON.stringify(f)),m.value=!1},r=async()=>{u.value=!0;let f=await a("promo-types")||[];f=f.map(t=>t.id===o.value.id?o.value:t),s("promo-types",f),i.value=JSON.parse(JSON.stringify(f)),m.value=!1},N=f=>{switch(f){case"fixed":o.value={id:crypto.randomUUID(),label:"Fixed Amount",key:"fixed",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Amount",valuePrefix:"$",valueSuffix:""};break;case"percentage":o.value={id:crypto.randomUUID(),label:"Percentage",key:"percentage",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Percentage",valuePrefix:"",valueSuffix:"%"};break;case"free_shipping":o.value={id:crypto.randomUUID(),label:"Free Shipping",key:"free_shipping",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""};break}};return n({open:l,openFromTemplate:p}),(f,t)=>{const x=e.resolveComponent("DialogTitle"),c=e.resolveComponent("DialogHeader"),k=e.resolveComponent("Button"),U=e.resolveComponent("DropdownMenuTrigger"),y=e.resolveComponent("DropdownMenuItem"),E=e.resolveComponent("DropdownMenuContent"),S=e.resolveComponent("DropdownMenu"),C=e.resolveComponent("Label"),D=e.resolveComponent("Input"),B=e.resolveComponent("Switch"),P=e.resolveComponent("DialogFooter"),F=e.resolveComponent("DialogScrollContent"),M=e.resolveComponent("Dialog");return e.openBlock(),e.createBlock(M,{open:m.value,"onUpdate:open":t[11]||(t[11]=d=>m.value=d)},{default:e.withCtx(()=>[e.unref(_)()?(e.openBlock(),e.createBlock(F,{key:0,class:"sm:max-w-[475px]"},{default:e.withCtx(()=>[e.createVNode(c,null,{default:e.withCtx(()=>[e.createVNode(x,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(g.value==="add"?"Add Promo Type":"Edit Promo Type"),1)]),_:1})]),_:1}),e.createElementVNode("div",J,[e.createElementVNode("div",q,[g.value==="add"?(e.openBlock(),e.createBlock(S,{key:0},{default:e.withCtx(()=>[e.createVNode(U,null,{default:e.withCtx(()=>[e.createVNode(k,{variant:"outline"},{default:e.withCtx(()=>[e.createElementVNode("div",H,[e.createVNode(e.unref(v.Import),{class:"size-4"}),t[12]||(t[12]=e.createTextVNode(" Load pre-defined type ",-1))])]),_:1})]),_:1}),e.createVNode(E,null,{default:e.withCtx(()=>[e.createVNode(y,{onClick:t[0]||(t[0]=d=>N("fixed"))},{default:e.withCtx(()=>[e.createElementVNode("div",Y,[e.createVNode(e.unref(v.DollarSign),{class:"size-4"}),t[13]||(t[13]=e.createTextVNode(" Fixed Amount ",-1))])]),_:1}),e.createVNode(y,{onClick:t[1]||(t[1]=d=>N("percentage"))},{default:e.withCtx(()=>[e.createElementVNode("div",K,[e.createVNode(e.unref(v.Percent),{class:"size-4"}),t[14]||(t[14]=e.createTextVNode(" Percentage ",-1))])]),_:1}),e.createVNode(y,{onClick:t[2]||(t[2]=d=>N("free_shipping"))},{default:e.withCtx(()=>[e.createElementVNode("div",W,[e.createVNode(e.unref(v.Truck),{class:"size-4"}),t[15]||(t[15]=e.createTextVNode(" Free Shipping ",-1))])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0)]),e.createElementVNode("div",null,[e.createVNode(C,{for:"label",class:"mb-2"},{default:e.withCtx(()=>[...t[16]||(t[16]=[e.createTextVNode("Display Name",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.label,"onUpdate:modelValue":t[3]||(t[3]=d=>o.value.label=d),id:"label"},null,8,["modelValue"]),t[17]||(t[17]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},'Shown in the Studio UI. e.g. "VIP Shipping"',-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"key",class:"mb-2"},{default:e.withCtx(()=>[...t[18]||(t[18]=[e.createTextVNode("Internal Key",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.key,"onUpdate:modelValue":t[4]||(t[4]=d=>o.value.key=d),id:"key"},null,8,["modelValue"]),t[19]||(t[19]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},[e.createTextVNode("Used in logic. Must be unique, lowercase, no spaces. e.g. "),e.createElementVNode("span",{class:"font-mono bg-muted-foreground/20 px-1 py-0.5 rounded"},"vip_shipping")],-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"allowUnlimitedUses",class:"mb-4"},{default:e.withCtx(()=>[...t[20]||(t[20]=[e.createTextVNode("Allow Unlimited Uses",-1)])]),_:1}),e.createElementVNode("div",Q,[e.createVNode(B,{id:"allowUnlimitedUses",modelValue:o.value.allowUnlimitedUses,"onUpdate:modelValue":t[5]||(t[5]=d=>o.value.allowUnlimitedUses=d)},null,8,["modelValue"]),e.createVNode(C,{for:"allowUnlimitedUses"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.value.allowUnlimitedUses?"Yes":"No"),1)]),_:1})]),t[22]||(t[22]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},'Show the "Unlimited uses" toggle when creating a promo code.',-1)),o.value.allowUnlimitedUses?(e.openBlock(),e.createElementBlock("p",X,[e.createVNode(e.unref(v.Info),{class:"size-4"}),t[21]||(t[21]=e.createTextVNode(" This option is always hidden when generating multiple codes. ",-1))])):e.createCommentVNode("",!0)]),e.createElementVNode("div",null,[e.createVNode(C,{for:"hasValueField",class:"mb-4"},{default:e.withCtx(()=>[...t[23]||(t[23]=[e.createTextVNode("Has Value Field",-1)])]),_:1}),e.createElementVNode("div",Z,[e.createVNode(B,{id:"hasValueField",modelValue:o.value.hasValueField,"onUpdate:modelValue":t[6]||(t[6]=d=>o.value.hasValueField=d)},null,8,["modelValue"]),e.createVNode(C,{for:"hasValueField"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.value.hasValueField?"Yes":"No"),1)]),_:1})]),t[24]||(t[24]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},"Show a numeric value input when using this type.",-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"valueLabel",class:"mb-2"},{default:e.withCtx(()=>[...t[25]||(t[25]=[e.createTextVNode("Value Field Label",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.valueLabel,"onUpdate:modelValue":t[7]||(t[7]=d=>o.value.valueLabel=d),id:"valueLabel"},null,8,["modelValue"]),t[26]||(t[26]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},'e.g. "Gift amount", "Shipping cost"',-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"valuePrefix",class:"mb-2"},{default:e.withCtx(()=>[...t[27]||(t[27]=[e.createTextVNode("Value Field Prefix",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.valuePrefix,"onUpdate:modelValue":t[8]||(t[8]=d=>o.value.valuePrefix=d),id:"valuePrefix"},null,8,["modelValue"]),t[28]||(t[28]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},"e.g. € or $",-1))]),e.createElementVNode("div",null,[e.createVNode(C,{for:"valueSuffix",class:"mb-2"},{default:e.withCtx(()=>[...t[29]||(t[29]=[e.createTextVNode("Value Field Suffix",-1)])]),_:1}),e.createVNode(D,{modelValue:o.value.valueSuffix,"onUpdate:modelValue":t[9]||(t[9]=d=>o.value.valueSuffix=d),id:"valueSuffix"},null,8,["modelValue"]),t[30]||(t[30]=e.createElementVNode("p",{class:"text-xs text-muted-foreground mt-1"},"e.g. %, credits",-1))])]),e.createVNode(P,null,{default:e.withCtx(()=>[e.createVNode(k,{variant:"outline",onClick:t[10]||(t[10]=d=>m.value=!1)},{default:e.withCtx(()=>[...t[31]||(t[31]=[e.createTextVNode("Cancel",-1)])]),_:1}),g.value==="add"?(e.openBlock(),e.createBlock(k,{key:0,disabled:u.value,onClick:V},{default:e.withCtx(()=>[u.value?(e.openBlock(),e.createBlock(e.unref(v.Loader2),{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),t[32]||(t[32]=e.createTextVNode(" Add Type ",-1))]),_:1},8,["disabled"])):(e.openBlock(),e.createBlock(k,{key:1,disabled:u.value,onClick:r},{default:e.withCtx(()=>[u.value?(e.openBlock(),e.createBlock(e.unref(v.Loader2),{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),t[33]||(t[33]=e.createTextVNode(" Save Changes ",-1))]),_:1},8,["disabled"]))]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:1},8,["open"])}}}),te={class:"grid gap-4 py-4"},oe={key:0,class:"flex flex-col gap-2 items-center text-muted-foreground border rounded p-4"},le={class:"flex gap-2 items-center"},ne={key:1},ae={class:"flex justify-end w-full mb-2"},re={class:"flex items-center gap-2"},se={class:"flex items-center gap-2"},de={class:"flex items-center gap-2"},ie={class:"flex items-center gap-2"},ue={class:"flex items-center gap-2"},ce={class:"font-mono bg-muted-foreground/20 px-1 py-0.5 rounded"},me=e.defineComponent({__name:"TypeManageDialog",setup(b){const{isAdmin:n}=w.useModulePermissions(),{getModuleData:_,setModuleData:a}=w.useModuleStorage(),{confirm:s}=w.useConfirmation(),i=e.inject("promoTypes",e.ref([])),o=e.useTemplateRef("typeDetailDialog"),m=async u=>{if(!await s(`Are you sure you want to delete the type "${u.label}"?`))return;let p=await _("promo-types")||[];p=p.filter(V=>V.id!==u.id),a("promo-types",p),i.value=JSON.parse(JSON.stringify(p))},g=async()=>{const u=[{id:crypto.randomUUID(),label:"Fixed Amount",key:"fixed",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Amount",valuePrefix:"$",valueSuffix:""},{id:crypto.randomUUID(),label:"Percentage",key:"percentage",allowUnlimitedUses:!1,hasValueField:!0,valueLabel:"Percentage",valuePrefix:"",valueSuffix:"%"},{id:crypto.randomUUID(),label:"Free Shipping",key:"free_shipping",allowUnlimitedUses:!1,hasValueField:!1,valueLabel:"",valuePrefix:"",valueSuffix:""}];a("promo-types",u),i.value=JSON.parse(JSON.stringify(u))};return(u,l)=>{const p=e.resolveComponent("Button"),V=e.resolveComponent("DialogTrigger"),r=e.resolveComponent("DialogTitle"),N=e.resolveComponent("DialogDescription"),f=e.resolveComponent("DialogHeader"),t=e.resolveComponent("DropdownMenuTrigger"),x=e.resolveComponent("DropdownMenuItem"),c=e.resolveComponent("DropdownMenuSeparator"),k=e.resolveComponent("DropdownMenuContent"),U=e.resolveComponent("DropdownMenu"),y=e.resolveComponent("TableHead"),E=e.resolveComponent("TableRow"),S=e.resolveComponent("TableHeader"),C=e.resolveComponent("TableCell"),D=e.resolveComponent("TableBody"),B=e.resolveComponent("Table"),P=e.resolveComponent("DialogFooter"),F=e.resolveComponent("DialogScrollContent"),M=e.resolveComponent("Dialog");return e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(M,null,{default:e.withCtx(()=>[e.createVNode(V,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(p,null,{default:e.withCtx(()=>[e.createVNode(e.unref(v.UserCog),{class:"size-4"}),l[6]||(l[6]=e.createTextVNode(" Edit Promo Types ",-1))]),_:1})]),_:1}),e.unref(n)()?(e.openBlock(),e.createBlock(F,{key:0,class:"sm:max-w-2xl"},{default:e.withCtx(()=>[e.createVNode(f,null,{default:e.withCtx(()=>[e.createVNode(r,null,{default:e.withCtx(()=>[...l[7]||(l[7]=[e.createTextVNode("Edit Promo Types",-1)])]),_:1}),e.createVNode(N,null,{default:e.withCtx(()=>[...l[8]||(l[8]=[e.createTextVNode(" Define reusable custom promo types to use in discount codes. You can configure how they behave and what fields are shown. ",-1)])]),_:1})]),_:1}),e.createElementVNode("div",te,[e.unref(i).length===0?(e.openBlock(),e.createElementBlock("div",oe,[l[12]||(l[12]=e.createElementVNode("p",null,"You haven't created any custom types yet.",-1)),e.createElementVNode("p",le,[e.createVNode(p,{variant:"link",onClick:l[0]||(l[0]=d=>o.value?.open())},{default:e.withCtx(()=>[...l[9]||(l[9]=[e.createTextVNode("Create a custom type",-1)])]),_:1}),l[11]||(l[11]=e.createTextVNode(" or ",-1)),e.createVNode(p,{variant:"link",onClick:l[1]||(l[1]=d=>g())},{default:e.withCtx(()=>[...l[10]||(l[10]=[e.createTextVNode("Import Default Types",-1)])]),_:1})])])):(e.openBlock(),e.createElementBlock("div",ne,[e.createElementVNode("div",ae,[e.createVNode(U,null,{default:e.withCtx(()=>[e.createVNode(t,null,{default:e.withCtx(()=>[e.createVNode(p,{variant:"outline"},{default:e.withCtx(()=>[e.createElementVNode("div",re,[e.createVNode(e.unref(v.Plus),{class:"size-4"}),l[13]||(l[13]=e.createTextVNode(" Create new Promo Type ",-1))])]),_:1})]),_:1}),e.createVNode(k,null,{default:e.withCtx(()=>[e.createVNode(x,{onClick:l[2]||(l[2]=d=>o.value?.open())},{default:e.withCtx(()=>[e.createElementVNode("div",se,[e.createVNode(e.unref(v.Plus),{class:"size-4"}),l[14]||(l[14]=e.createTextVNode(" New Type ",-1))])]),_:1}),e.createVNode(c),e.createVNode(x,{onClick:l[3]||(l[3]=d=>o.value?.openFromTemplate("fixed"))},{default:e.withCtx(()=>[e.createElementVNode("div",de,[e.createVNode(e.unref(v.DollarSign),{class:"size-4"}),l[15]||(l[15]=e.createTextVNode(" Fixed Amount ",-1))])]),_:1}),e.createVNode(x,{onClick:l[4]||(l[4]=d=>o.value?.openFromTemplate("percentage"))},{default:e.withCtx(()=>[e.createElementVNode("div",ie,[e.createVNode(e.unref(v.Percent),{class:"size-4"}),l[16]||(l[16]=e.createTextVNode(" Percentage ",-1))])]),_:1}),e.createVNode(x,{onClick:l[5]||(l[5]=d=>o.value?.openFromTemplate("free_shipping"))},{default:e.withCtx(()=>[e.createElementVNode("div",ue,[e.createVNode(e.unref(v.Truck),{class:"size-4"}),l[17]||(l[17]=e.createTextVNode(" Free Shipping ",-1))])]),_:1})]),_:1})]),_:1})]),e.createVNode(B,null,{default:e.withCtx(()=>[e.createVNode(S,null,{default:e.withCtx(()=>[e.createVNode(E,null,{default:e.withCtx(()=>[e.createVNode(y,null,{default:e.withCtx(()=>[...l[18]||(l[18]=[e.createTextVNode("Name (label)",-1)])]),_:1}),e.createVNode(y,null,{default:e.withCtx(()=>[...l[19]||(l[19]=[e.createTextVNode("Key",-1)])]),_:1}),e.createVNode(y,null,{default:e.withCtx(()=>[...l[20]||(l[20]=[e.createTextVNode("Value Field",-1)])]),_:1}),e.createVNode(y,null,{default:e.withCtx(()=>[...l[21]||(l[21]=[e.createTextVNode("Unlimited Uses",-1)])]),_:1}),e.createVNode(y,{class:"text-right"},{default:e.withCtx(()=>[...l[22]||(l[22]=[e.createTextVNode("Actions",-1)])]),_:1})]),_:1})]),_:1}),e.createVNode(D,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i),d=>(e.openBlock(),e.createBlock(E,{key:d.key},{default:e.withCtx(()=>[e.createVNode(C,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.label),1)]),_:2},1024),e.createVNode(C,null,{default:e.withCtx(()=>[e.createElementVNode("span",ce,e.toDisplayString(d.key),1)]),_:2},1024),e.createVNode(C,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.hasValueField?"Yes":"No"),1)]),_:2},1024),e.createVNode(C,null,{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.allowUnlimitedUses?"Yes":"No"),1)]),_:2},1024),e.createVNode(C,{class:"text-right"},{default:e.withCtx(()=>[e.createVNode(p,{variant:"ghost",size:"icon",onClick:A=>o.value?.open(d)},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Pencil),{class:"size-4"})]),_:1},8,["onClick"]),e.createVNode(p,{variant:"ghost",size:"icon",onClick:A=>m(d)},{default:e.withCtx(()=>[e.createVNode(e.unref(v.Trash2),{class:"size-4 text-red-500"})]),_:1},8,["onClick"])]),_:2},1024)]),_:2},1024))),128))]),_:1})]),_:1})]))]),e.createVNode(P,null,{default:e.withCtx(()=>[e.createVNode(p,{variant:"outline",disabled:""},{default:e.withCtx(()=>[...l[23]||(l[23]=[e.createTextVNode(" Auto-saved ",-1)])]),_:1})]),_:1})]),_:1})):e.createCommentVNode("",!0)]),_:1}),e.createVNode(ee,{ref_key:"typeDetailDialog",ref:o},null,512)],64)}}}),pe={class:"flex justify-between items-center"},fe={class:"grid gap-2"},Ve={class:"flex flex-wrap gap-12"},xe={key:0,class:"grid gap-2"},ve={class:"flex items-center gap-2"},Ne={key:1,class:"grid gap-2"},Ce={class:"flex items-center space-x-2"},ge=e.defineComponent({__name:"index",setup(b){const n=e.inject("newCoupon"),_=e.inject("promoTypes",e.ref([])),a=e.computed(()=>_.value.find(i=>i.key===n.value?.type)||null),{isAdmin:s}=w.useModulePermissions();return(i,o)=>{const m=e.resolveComponent("Label"),g=e.resolveComponent("SelectValue"),u=e.resolveComponent("SelectTrigger"),l=e.resolveComponent("SelectItem"),p=e.resolveComponent("SelectGroup"),V=e.resolveComponent("SelectContent"),r=e.resolveComponent("Select"),N=e.resolveComponent("Input"),f=e.resolveComponent("Switch"),t=e.resolveComponent("Card");return e.openBlock(),e.createBlock(t,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",pe,[o[3]||(o[3]=e.createElementVNode("h2",{class:"font-medium"},"Value",-1)),e.unref(s)()?(e.openBlock(),e.createBlock(me,{key:0})):e.createCommentVNode("",!0)]),e.createElementVNode("div",fe,[e.createVNode(m,{class:"text-muted-foreground"},{default:e.withCtx(()=>[...o[4]||(o[4]=[e.createTextVNode("Promo Type",-1)])]),_:1}),e.createVNode(r,{modelValue:e.unref(n).type,"onUpdate:modelValue":o[0]||(o[0]=x=>e.unref(n).type=x)},{default:e.withCtx(()=>[e.createVNode(u,{class:"w-[200px]"},{default:e.withCtx(()=>[e.createVNode(g,{placeholder:"Select a promo type"})]),_:1}),e.createVNode(V,null,{default:e.withCtx(()=>[e.createVNode(p,null,{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),x=>(e.openBlock(),e.createBlock(l,{key:x.key,value:x.key},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.label),1)]),_:2},1032,["value"]))),128))]),_:1})]),_:1})]),_:1},8,["modelValue"])]),e.createElementVNode("div",Ve,[a.value?.hasValueField?(e.openBlock(),e.createElementBlock("div",xe,[e.createVNode(m,{for:"discountValue",class:"text-muted-foreground"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value?.valueLabel||"Value"),1)]),_:1}),e.createElementVNode("div",ve,[a.value?.valuePrefix?(e.openBlock(),e.createBlock(m,{key:0,for:"discountValue",class:"text-lg"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value?.valuePrefix),1)]),_:1})):e.createCommentVNode("",!0),e.createVNode(N,{modelValue:e.unref(n).value,"onUpdate:modelValue":o[1]||(o[1]=x=>e.unref(n).value=x),id:"discountValue"},null,8,["modelValue"]),a.value?.valueSuffix?(e.openBlock(),e.createBlock(m,{key:1,for:"discountValue",class:"text-lg"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(a.value?.valueSuffix),1)]),_:1})):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),a.value?.allowUnlimitedUses&&e.unref(n).creationMode!=="multi"?(e.openBlock(),e.createElementBlock("div",Ne,[e.createVNode(m,{for:"unlimitedUses",class:"text-muted-foreground"},{default:e.withCtx(()=>[...o[5]||(o[5]=[e.createTextVNode("Unlimited Uses",-1)])]),_:1}),e.createElementVNode("div",Ce,[e.createVNode(f,{id:"unlimitedUses",modelValue:e.unref(n).unlimitedUses,"onUpdate:modelValue":o[2]||(o[2]=x=>e.unref(n).unlimitedUses=x)},null,8,["modelValue"]),e.createVNode(m,{for:"unlimitedUses"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(e.unref(n).unlimitedUses?"Yes":"No"),1)]),_:1})])])):e.createCommentVNode("",!0)])]),_:1})}}}),_e={class:"flex gap-4"},we={class:"flex flex-col"},ye={key:0,class:"-ml-2"},ke={key:1,class:"text-xs text-muted-foreground mt-2"},be={class:"flex flex-col"},Te={key:0,class:"-ml-2"},De={key:1,class:"text-xs text-muted-foreground mt-2"},Ue=e.defineComponent({__name:"DateRange",setup(b){const n=e.inject("newCoupon"),_=new $.$fb18d541ea1ad717$export$ad991b66133851cf("en-US",{dateStyle:"long"});return(a,s)=>{const i=e.resolveComponent("Label"),o=e.resolveComponent("Button"),m=e.resolveComponent("PopoverTrigger"),g=e.resolveComponent("Calendar"),u=e.resolveComponent("PopoverContent"),l=e.resolveComponent("Popover"),p=e.resolveComponent("Card");return e.openBlock(),e.createBlock(p,{class:"p-4"},{default:e.withCtx(()=>[s[8]||(s[8]=e.createElementVNode("div",null,[e.createElementVNode("h2",{class:"font-medium mb-2"},"Availability"),e.createElementVNode("p",{class:"text-muted-foreground"},"When will this code be available?")],-1)),e.createElementVNode("div",_e,[e.createElementVNode("div",we,[e.createVNode(i,{class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...s[4]||(s[4]=[e.createTextVNode("Available from",-1)])]),_:1}),e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(m,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(o,{variant:"outline",class:e.normalizeClass(e.unref(h.classNames)("w-[280px] justify-start text-left font-normal",!e.unref(n).startsAt&&"text-muted-foreground"))},{default:e.withCtx(()=>[e.createVNode(e.unref(v.CalendarIcon),{class:"mr-2 h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(n).startsAt?e.unref(_).format(e.unref(n).startsAt.toDate(e.unref($.$14e0f24ef4ac5c92$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class"])]),_:1}),e.createVNode(u,{class:"w-auto p-0"},{default:e.withCtx(()=>[e.createVNode(g,{modelValue:e.unref(n).startsAt,"onUpdate:modelValue":s[0]||(s[0]=V=>e.unref(n).startsAt=V),"initial-focus":"",minValue:e.unref($.$14e0f24ef4ac5c92$export$d0bdf45af03a6ea3)()},null,8,["modelValue","minValue"])]),_:1})]),_:1}),e.unref(n).startsAt?(e.openBlock(),e.createElementBlock("div",ye,[e.createVNode(o,{onClick:s[1]||(s[1]=V=>e.unref(n).startsAt=void 0),variant:"link"},{default:e.withCtx(()=>[...s[5]||(s[5]=[e.createTextVNode("Clear",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("p",ke,"Not set - codes will be available immediately"))]),e.createElementVNode("div",be,[e.createVNode(i,{class:"text-muted-foreground mb-2"},{default:e.withCtx(()=>[...s[6]||(s[6]=[e.createTextVNode("Until",-1)])]),_:1}),e.createVNode(l,null,{default:e.withCtx(()=>[e.createVNode(m,{"as-child":""},{default:e.withCtx(()=>[e.createVNode(o,{variant:"outline",class:e.normalizeClass(e.unref(h.classNames)("w-[280px] justify-start text-left font-normal",!e.unref(n).expiresAt&&"text-muted-foreground"))},{default:e.withCtx(()=>[e.createVNode(e.unref(v.CalendarIcon),{class:"mr-2 h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(n).expiresAt?e.unref(_).format(e.unref(n).expiresAt.toDate(e.unref($.$14e0f24ef4ac5c92$export$aa8b41735afcabd2)())):"Pick a date"),1)]),_:1},8,["class"])]),_:1}),e.createVNode(u,{class:"w-auto p-0"},{default:e.withCtx(()=>[e.createVNode(g,{modelValue:e.unref(n).expiresAt,"onUpdate:modelValue":s[2]||(s[2]=V=>e.unref(n).expiresAt=V),"initial-focus":"",minValue:e.unref(n).startsAt},null,8,["modelValue","minValue"])]),_:1})]),_:1}),e.unref(n).expiresAt?(e.openBlock(),e.createElementBlock("div",Te,[e.createVNode(o,{onClick:s[3]||(s[3]=V=>e.unref(n).expiresAt=void 0),variant:"link"},{default:e.withCtx(()=>[...s[7]||(s[7]=[e.createTextVNode("Clear",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("p",De,"Not set - codes will never expire"))])])]),_:1})}}}),Ee=e.defineComponent({__name:"Note",setup(b){const n=e.inject("newCoupon");return(_,a)=>{const s=e.resolveComponent("Textarea"),i=e.resolveComponent("Card");return e.openBlock(),e.createBlock(i,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",null,[a[1]||(a[1]=e.createElementVNode("h2",{class:"font-medium mb-2"},"Note",-1)),a[2]||(a[2]=e.createElementVNode("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)),e.createVNode(s,{modelValue:e.unref(n).note,"onUpdate:modelValue":a[0]||(a[0]=o=>e.unref(n).note=o)},null,8,["modelValue"])])]),_:1})}}}),Se={class:"relative"},Be={ref:"container",class:"flex flex-col gap-4 w-full max-w-5xl mx-auto"},$e={class:"flex justify-between items-center mb-4"},Pe={class:"w-full max-w-2xl"},Fe={class:"flex items-center space-x-2"},Me={class:"flex items-center space-x-2"},he={class:"flex justify-end w-full"},Ae=e.defineComponent({__name:"Create",props:{config:{type:Object,required:!0}},async setup(b){let n,_;const a=b,{hasPermission:s}=w.useModulePermissions(),{navigateTo:i}=w.useModuleRoute(),{getTimezone:o}=w.useProjectSettings(),{log:m,logError:g}=w.useLogs(),{getModuleData:u,setModuleData:l}=w.useModuleStorage();w.useModuleBreadcrumbs(()=>[]);const p=w.useFirebaseIntegration(a.config.project),V=e.ref(!1),r=e.ref({creationMode:"single",generationMode:"generate",quantity:1,prefix:"",codes:"",code:"",type:void 0,value:void 0,unlimitedUses:!1,startsAt:void 0,expiresAt:void 0,minOrderAmount:0,note:""}),N=e.ref([]);N.value=([n,_]=e.withAsyncContext(()=>u("promo-types")),n=await n,_(),n||[]),e.provide("newCoupon",r),e.provide("promoTypes",N);const f=()=>{if(r.value.creationMode=="single"){if(r.value.code=r.value.code?.trim().toUpperCase(),!r.value.code)return T.toast.error("Please enter a code"),!1}else if(r.value.generationMode=="generate"){if(r.value.prefix=r.value.prefix?.trim().toUpperCase(),!r.value.prefix)return T.toast.error("Please enter a prefix"),!1;if(!r.value.quantity||r.value.quantity<1)return T.toast.error("Generate at least 1 code"),!1}else if(r.value.generationMode=="input"&&(r.value.codes=r.value.codes?.trim().toUpperCase(),!r.value.codes||r.value.codes.length<1))return T.toast.error("Please enter some codes"),!1;return r.value.type?N.value.find(x=>x.key===r.value.type)?.hasValueField&&!r.value.value?(T.toast.error("Please enter a value"),!1):(r.value.creationMode==="multi"&&(r.value.unlimitedUses=!1),!0):(T.toast.error("Please select a type"),!1)},t=async()=>{try{if(!f())return;if(V.value=!0,r.value.creationMode=="single"){let x={code:r.value.code,type:r.value.type,value:r.value.value,minOrderAmount:r.value.minOrderAmount,usageLimit:r.value.unlimitedUses?0:1,usageCount:0,lastUsedAt:null,startsAt:r.value.startsAt?r.value.startsAt.toDate(o()):null,expiresAt:r.value.expiresAt?r.value.expiresAt.toDate(o()):null,disabled:!1,note:r.value.note,createdAt:new Date,updatedAt:new Date};const c=await p.add(a.config.promoCodeCollection,x);m("Promo code created",{id:c.id,code:c.code,note:c.note}),T.toast.success("Promo code created")}}catch{g("Failed to create promo code"),T.toast.error("Failed to create promo code")}finally{V.value=!1}};return(x,c)=>{const k=e.resolveComponent("Button"),U=e.resolveComponent("RadioGroupItem"),y=e.resolveComponent("Label"),E=e.resolveComponent("RadioGroup"),S=e.resolveComponent("Card");return e.openBlock(),e.createElementBlock("div",Se,[e.createElementVNode("div",Be,[e.createElementVNode("div",$e,[c[3]||(c[3]=e.createElementVNode("h1",{class:"text-2xl font-bold"},"New Promo Code",-1)),e.createVNode(k,{onClick:c[0]||(c[0]=C=>e.unref(i)("promo-codes")),variant:"outline",disabled:V.value},{default:e.withCtx(()=>[e.createVNode(e.unref(v.List),{class:"size-4"}),c[2]||(c[2]=e.createTextVNode(" View Promo Codes ",-1))]),_:1},8,["disabled"])]),e.createVNode(S,{class:"p-4"},{default:e.withCtx(()=>[e.createElementVNode("div",Pe,[c[6]||(c[6]=e.createElementVNode("h2",{class:"font-medium mb-4"},"Codes",-1)),e.createVNode(E,{modelValue:r.value.creationMode,"onUpdate:modelValue":c[1]||(c[1]=C=>r.value.creationMode=C),orientation:"horizontal",class:"mb-6"},{default:e.withCtx(()=>[e.createElementVNode("div",Fe,[e.createVNode(U,{id:"creation_mode_single",value:"single"}),e.createVNode(y,{for:"creation_mode_single"},{default:e.withCtx(()=>[...c[4]||(c[4]=[e.createTextVNode("Create 1 code",-1)])]),_:1})]),e.createElementVNode("div",Me,[e.createVNode(U,{id:"creation_mode_multi",value:"multi"}),e.createVNode(y,{for:"creation_mode_multi"},{default:e.withCtx(()=>[...c[5]||(c[5]=[e.createTextVNode("Create multiple codes",-1)])]),_:1})])]),_:1},8,["modelValue"]),r.value.creationMode=="single"?(e.openBlock(),e.createBlock(I,{key:0})):(e.openBlock(),e.createBlock(R,{key:1}))])]),_:1}),e.createVNode(ge),e.createVNode(Ue),e.createVNode(Ee),e.createElementVNode("div",he,[e.createVNode(k,{disabled:V.value,onClick:t},{default:e.withCtx(()=>[V.value?(e.openBlock(),e.createBlock(e.unref(v.Loader2),{key:0,class:"size-4 animate-spin"})):e.createCommentVNode("",!0),c[7]||(c[7]=e.createTextVNode(" Create Promo Code ",-1))]),_:1},8,["disabled"])])],512)])}}});exports.default=Ae;