@feedmepos/mf-connect 0.1.38-beta.74 → 0.1.38-beta.76

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 (140) hide show
  1. package/dist/Analytic-BrBxRQue.js +761 -0
  2. package/dist/App-CE_19YJc.js +4642 -0
  3. package/dist/AuditLogs-CQtMmVIp.js +1991 -0
  4. package/dist/Bin-D9CHhiUb.js +166 -0
  5. package/dist/Broadcast-Dg6eBL_f.js +267 -0
  6. package/dist/CampaignTypeDialog.vue_vue_type_script_setup_true_lang-CSv0R9XX.js +121 -0
  7. package/dist/Card-BTkf67i1.js +910 -0
  8. package/dist/ChipMenu.vue_vue_type_script_setup_true_lang-BPpZZNkr.js +97 -0
  9. package/dist/Collections-Czq4nsdu.js +541 -0
  10. package/dist/Credit-B3nX8aJA.js +261 -0
  11. package/dist/CustomSelect.vue_vue_type_script_setup_true_lang-Du7fRSZC.js +128 -0
  12. package/dist/DateInput.vue_vue_type_script_setup_true_lang-BN4Q5Y3l.js +54 -0
  13. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-eIoPtgO5.js +58 -0
  14. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-D2gTuN97.js +3120 -0
  15. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-5U6cSZGZ.js +351 -0
  16. package/dist/Experience-B9Vn3NTH.js +260 -0
  17. package/dist/FileSaver.min-CJaOkSQt.js +74 -0
  18. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-DaU-9GzO.js +129 -0
  19. package/dist/Game-DTx_EsM3.js +331 -0
  20. package/dist/GenerateMaterial-C3J9_YHw.js +589 -0
  21. package/dist/Grab-B29W7rka.js +301 -0
  22. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-DyegKNzM.js +145 -0
  23. package/dist/Index-Fk8EP5dG.js +259 -0
  24. package/dist/JsonViewer-v8_C7l5N.js +87 -0
  25. package/dist/LocationPicker.vue_vue_type_script_setup_true_lang-D2XPGgTM.js +48 -0
  26. package/dist/LottieAnimation.vue_vue_type_script_setup_true_lang-K8qUYrPk.js +18737 -0
  27. package/dist/MainLayout-BFmqJkE_.js +41 -0
  28. package/dist/Marketing-BRHQHAWD.js +145 -0
  29. package/dist/MarketingMaterialEdit-7s3WEDyJ.js +746 -0
  30. package/dist/Member-DwPJNAo9.js +280 -0
  31. package/dist/MemberList-mS1W0qHY.js +1601 -0
  32. package/dist/MemberOverview-wL_ailso.js +58 -0
  33. package/dist/MemberTransactions-BV3xvFYS.js +45 -0
  34. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-DzKqVp2O.js +60799 -0
  35. package/dist/Mission-QmoURSu4.js +335 -0
  36. package/dist/Overview-CaTMLlq-.js +1078 -0
  37. package/dist/Point-CjG77Sma.js +263 -0
  38. package/dist/Promotion-C5I-1qPN.js +397 -0
  39. package/dist/Queue-BaIBCCaX.js +259 -0
  40. package/dist/Record-DqpGwZIU.js +341 -0
  41. package/dist/Review-Bq-edSOO.js +621 -0
  42. package/dist/ReviewFacebookCallback-yaC4rLki.js +243 -0
  43. package/dist/ReviewGoogleCallback-uxrrCQdu.js +213 -0
  44. package/dist/Reward-DGP65n5t.js +442 -0
  45. package/dist/RewardGroup.vue_vue_type_script_setup_true_lang-bNMoMZOy.js +149 -0
  46. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-Dgrc6vXF.js +1912 -0
  47. package/dist/Segment-CNz0sR3c.js +881 -0
  48. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-DLZEzpve.js +181 -0
  49. package/dist/SendCollectionSheet.vue_vue_type_script_setup_true_lang-CLdIeyef.js +188 -0
  50. package/dist/SendVoucherSheet.vue_vue_type_script_setup_true_lang-ocCdtbbe.js +147 -0
  51. package/dist/Setting-BKDSGYBR.js +2000 -0
  52. package/dist/SettingAdvertisements-B2GMFfN9.js +264 -0
  53. package/dist/Store-C6uLl_Ue.js +1996 -0
  54. package/dist/StoreRewards-D4728UDf.js +535 -0
  55. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-CG09fJTP.js +1129 -0
  56. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-B0_bMK5u.js +7005 -0
  57. package/dist/Tier-BNzTa1_w.js +970 -0
  58. package/dist/Title-DY5knovF.js +568 -0
  59. package/dist/Transaction-Ct4yAJ9n.js +39 -0
  60. package/dist/UserRuleGroup.vue_vue_type_script_setup_true_lang-CHnxi3XZ.js +130 -0
  61. package/dist/Voucher-DFTMRPT0.js +422 -0
  62. package/dist/VoucherEditor.vue_vue_type_script_setup_true_lang-DZU7XVlZ.js +421 -0
  63. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-BndLHmHB.js +56 -0
  64. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  65. package/dist/app-6lG4w5PT.js +59396 -0
  66. package/dist/app-wDQR6dpb.js +39 -0
  67. package/dist/app.js +7 -0
  68. package/dist/business-CrfQ56D0.js +82 -0
  69. package/dist/campaign-B9fR7RwT.js +100 -0
  70. package/dist/campaign-B_iIaTKz.js +253 -0
  71. package/dist/campaign-CpzFl8Vr.js +4 -0
  72. package/dist/campaign.enum-BAHf0dSv.js +26 -0
  73. package/dist/campaign.fn-DDEgBzH2.js +776 -0
  74. package/dist/collectible.enum-9os2zr5a.js +19 -0
  75. package/dist/collection.fn-7qP_m2MW.js +26 -0
  76. package/dist/dto-C2hLQKuu.js +222 -0
  77. package/dist/duplicateCampaign-C6RXfeWE.js +51 -0
  78. package/dist/effect-DGVfWyIc.js +89 -0
  79. package/dist/email-addresses-BHa_qQBd.js +705 -0
  80. package/dist/export-CRPfo4hq.js +97 -0
  81. package/dist/feedme.ico +0 -0
  82. package/dist/helper-0_zrz4kj.js +86 -0
  83. package/dist/index-4Vl1VXum.js +2639 -0
  84. package/dist/index-4bX0ewBJ.js +31 -0
  85. package/dist/index-Bj0TV_D5.js +36 -0
  86. package/dist/index-BpdSswT6.js +48 -0
  87. package/dist/index-By2wenzb.js +32 -0
  88. package/dist/index-C8L2jQ_6.js +28897 -0
  89. package/dist/index-CO5kQMIK.js +85 -0
  90. package/dist/index-CW_ub4cF.js +8912 -0
  91. package/dist/index-Cp8wkBus.js +124 -0
  92. package/dist/index-CuvNtC_M.js +61 -0
  93. package/dist/index-D6Te1BQZ.js +54 -0
  94. package/dist/index-DbJGJ2fB.js +146 -0
  95. package/dist/index-DeaGdUSH.js +30289 -0
  96. package/dist/index-Dp1J9Fxa.js +3 -0
  97. package/dist/index-QUvYZydO.js +67 -0
  98. package/dist/index-lwxV5iX0.js +3431 -0
  99. package/dist/index-vh86FiIQ.js +10 -0
  100. package/dist/index.esm2017-ofRmIpjY.js +3069 -0
  101. package/dist/loading-8_73fcXo.js +71 -0
  102. package/dist/lodash-Bz_vrY3P.js +3678 -0
  103. package/dist/membership-CpB39vNW.js +235 -0
  104. package/dist/moment-D7p2TMB-.js +2583 -0
  105. package/dist/money-DALHjzjF.js +15 -0
  106. package/dist/number-D_GJahxw.js +12 -0
  107. package/dist/object-qECH92oz.js +26 -0
  108. package/dist/objectId-dwaoBfJX.js +7 -0
  109. package/dist/objectid-BZSH63yc.js +145 -0
  110. package/dist/plugins-A4jDcmfS.js +1817 -0
  111. package/dist/remy-D_Deb3ue.js +13 -0
  112. package/dist/reward-BqFB2Yn2.js +36 -0
  113. package/dist/rule-DNylZfIG.js +1969 -0
  114. package/dist/rule-builder-2iT04EOj.js +102 -0
  115. package/dist/style.css +13 -0
  116. package/dist/template-D7rpG7FN.js +188 -0
  117. package/dist/tier-BJDhpH6X.js +4 -0
  118. package/dist/tiers/tier=1.png +0 -0
  119. package/dist/tiers/tier=2.png +0 -0
  120. package/dist/tiers/tier=3.png +0 -0
  121. package/dist/tiers/tier=4.png +0 -0
  122. package/dist/timezone-BW17tvi2.js +1154 -0
  123. package/dist/titles/type=diamond.png +0 -0
  124. package/dist/titles/type=drinks.png +0 -0
  125. package/dist/titles/type=food.png +0 -0
  126. package/dist/titles/type=heart.png +0 -0
  127. package/dist/titles/type=medal.png +0 -0
  128. package/dist/titles/type=spend.png +0 -0
  129. package/dist/titles/type=thank-you.png +0 -0
  130. package/dist/titles/type=thumbs-up.png +0 -0
  131. package/dist/titles/type=years.png +0 -0
  132. package/dist/trigger-CbVrS2i6.js +213 -0
  133. package/dist/tslib.es6-BCqqvLQ_.js +44 -0
  134. package/dist/type_drinks-D6jnpvwV.js +4 -0
  135. package/dist/usePagination-dXSoqxfG.js +266 -0
  136. package/dist/user-Ck-m3cB3.js +55 -0
  137. package/dist/vue-i18n-BvqmcBWZ.js +2365 -0
  138. package/dist/xlsx-CkqDfUNs.js +15491 -0
  139. package/dist/zod-B0YxCfoE.js +91 -0
  140. package/package.json +1 -1
@@ -0,0 +1,3120 @@
1
+ import { defineComponent, ref, watch, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, createCommentVNode, computed, onMounted, toDisplayString, createBlock, withCtx, Fragment, renderList, withModifiers, unref, isRef, createTextVNode, normalizeClass, resolveDynamicComponent, toRefs, normalizeStyle, createSlots } from "vue";
2
+ import { _ } from "./lodash-Bz_vrY3P.js";
3
+ import { F as Fh, z } from "./app-6lG4w5PT.js";
4
+ import { Z as ZodHelper } from "./zod-B0YxCfoE.js";
5
+ import { c as campaignRefinement, C as CampaignDtos, a as campaignTransform } from "./dto-C2hLQKuu.js";
6
+ import { u as useMembershipStore } from "./membership-CpB39vNW.js";
7
+ import { u as useBusinessStore } from "./business-CrfQ56D0.js";
8
+ import "./index-CW_ub4cF.js";
9
+ import { R as RuleBuilder, a as isRuleEntry } from "./rule-builder-2iT04EOj.js";
10
+ import { J as JsonViewer } from "./JsonViewer-v8_C7l5N.js";
11
+ import { h as hooks } from "./moment-D7p2TMB-.js";
12
+ import { f as featureVersionMapping } from "./campaign.enum-BAHf0dSv.js";
13
+ import { _ as _sfc_main$u } from "./ImageInput.vue_vue_type_script_setup_true_lang-DyegKNzM.js";
14
+ import { b as _sfc_main$s, a as _sfc_main$v, _ as _sfc_main$x } from "./EffectSheet.vue_vue_type_style_index_0_lang-5U6cSZGZ.js";
15
+ import { _ as _sfc_main$w } from "./TargetLocationInput.vue_vue_type_script_setup_true_lang-B0_bMK5u.js";
16
+ import { c as core, S as SvcConfig } from "./index-C8L2jQ_6.js";
17
+ import { p as prompt, f as firebaseStorage } from "./plugins-A4jDcmfS.js";
18
+ import { _ as _sfc_main$n } from "./SelectItems.vue_vue_type_script_setup_true_lang-DLZEzpve.js";
19
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-CHgC5LLL.js";
20
+ import { _ as _sfc_main$z } from "./UserRuleGroup.vue_vue_type_script_setup_true_lang-CHnxi3XZ.js";
21
+ import { _ as _sfc_main$o, a as _sfc_main$q } from "./RuleGroup.vue_vue_type_script_setup_true_lang-Dgrc6vXF.js";
22
+ import { u as useI18n } from "./vue-i18n-BvqmcBWZ.js";
23
+ import { T as TypeToTriggerOptions, _ as _sfc_main$A, b as _sfc_main$B } from "./trigger-CbVrS2i6.js";
24
+ import { _ as _sfc_main$p } from "./DateInput.vue_vue_type_script_setup_true_lang-BN4Q5Y3l.js";
25
+ import { _ as _sfc_main$y } from "./MessageInput.vue_vue_type_script_setup_true_lang-DzKqVp2O.js";
26
+ import { C as CountryTimezone, m as moment } from "./timezone-BW17tvi2.js";
27
+ import { c as calculateNextScheduleAt, R as RRule, S as SummarizeRrule, g as getRruleAnchorDate } from "./rule-DNylZfIG.js";
28
+ import { useCoreStore } from "@feedmepos/mf-common";
29
+ import { _ as _sfc_main$r, a as _sfc_main$t } from "./VoucherEditor.vue_vue_type_script_setup_true_lang-DZU7XVlZ.js";
30
+ import { T as TEMPLATES } from "./index-4Vl1VXum.js";
31
+ import { u as FdoCreditLoyaltyReward, v as FdtoRandomReward, w as F_MISSION_TYPE, x as FdoThresholdCreditReward, y as FdtoThresholdReward, z as FdoMission } from "./index-lwxV5iX0.js";
32
+ import "./index-DeaGdUSH.js";
33
+ import "./index-D6Te1BQZ.js";
34
+ import { a as F_GAME_TYPE } from "./collectible.enum-9os2zr5a.js";
35
+ import { u as useLoading } from "./loading-8_73fcXo.js";
36
+ import { i as initCollectibleConfig } from "./helper-0_zrz4kj.js";
37
+ import { C as CollectionUtils } from "./collection.fn-7qP_m2MW.js";
38
+ import { s as sentenceCase$1 } from "./index-CuvNtC_M.js";
39
+ import { d as getCampaignSummaryObject } from "./campaign-B_iIaTKz.js";
40
+ import { useDialog } from "@feedmepos/ui-library";
41
+ import { u as useCampaignStore } from "./campaign-B9fR7RwT.js";
42
+ import { a as cleanPF } from "./object-qECH92oz.js";
43
+ function summarizeGrabDiscount(e) {
44
+ if (!e)
45
+ return null;
46
+ const m = core.Config.getCountry().currency.symbol;
47
+ function a(l) {
48
+ switch (l.scope.type) {
49
+ case "order":
50
+ return "Bill discount";
51
+ case "items":
52
+ return l.type.startsWith("bundle") ? u(l.type) : "Item discount";
53
+ case "categories":
54
+ return "Category discount";
55
+ default:
56
+ return "Discount";
57
+ }
58
+ }
59
+ function u(l) {
60
+ switch (l) {
61
+ case "bundleSameFixPrice":
62
+ return "Bundle (same item) - Fixed price";
63
+ case "bundleDiffFixPrice":
64
+ return "Bundle (different items) - Fixed price";
65
+ case "bundleSameNet":
66
+ return "Bundle (same item) - Amount off";
67
+ case "bundleDiffNet":
68
+ return "Bundle (different items) - Amount off";
69
+ case "bundleSamePercentage":
70
+ return "Bundle (same item) - Percentage off";
71
+ case "bundleDiffPercentage":
72
+ return "Bundle (different items) - Percentage off";
73
+ default:
74
+ return "Bundle discount";
75
+ }
76
+ }
77
+ function d(l) {
78
+ switch (l.type) {
79
+ case "percentage":
80
+ case "bundleSamePercentage":
81
+ case "bundleDiffPercentage":
82
+ return `${l.value}% discount`;
83
+ case "net":
84
+ case "bundleSameNet":
85
+ case "bundleDiffNet":
86
+ return `${m}${l.value} discount`;
87
+ case "bundleSameFixPrice":
88
+ case "bundleDiffFixPrice":
89
+ return `${m}${l.value} fixed price`;
90
+ case "delivery":
91
+ return "Delivery fee discount";
92
+ case "freeItem":
93
+ return "Free item";
94
+ default:
95
+ return `${m}${l.value} discount`;
96
+ }
97
+ }
98
+ function s(l) {
99
+ return l.cap && l.cap > 0 ? `capped at ${m}${l.cap}` : null;
100
+ }
101
+ return {
102
+ type: a(e),
103
+ adjustment: d(e),
104
+ cap: s(e)
105
+ };
106
+ }
107
+ const _hoisted_1$l = {
108
+ key: 0,
109
+ class: "bg-fm-color-neutral-gray-50 border border-fm-color-neutral-gray-200 rounded-8 p-16 space-y-16"
110
+ }, _hoisted_2$h = { class: "flex items-center justify-between" }, _hoisted_3$e = { class: "flex items-center gap-8" }, _hoisted_4$d = { class: "bg-white border border-fm-color-neutral-gray-200 rounded-8 p-16" }, _hoisted_5$a = { class: "flex justify-end gap-8 pt-8 border-t border-fm-color-neutral-gray-200" }, _sfc_main$m = /* @__PURE__ */ defineComponent({
111
+ __name: "GrabItemSelectionInline",
112
+ props: {
113
+ visible: { type: Boolean },
114
+ initialValue: {},
115
+ filterItems: { type: Function }
116
+ },
117
+ emits: ["confirm", "cancel"],
118
+ setup(e, { emit: m }) {
119
+ const a = e, u = m, d = ref();
120
+ watch(
121
+ () => a.visible,
122
+ (n) => {
123
+ var r, p;
124
+ !n && d.value && ((p = (r = d.value).setSelectedItems) == null || p.call(r, a.initialValue || []));
125
+ }
126
+ );
127
+ function s() {
128
+ var n;
129
+ (n = d.value) == null || n.onConfirm();
130
+ }
131
+ function l() {
132
+ u("cancel");
133
+ }
134
+ function o(n) {
135
+ u("confirm", n);
136
+ }
137
+ return (n, r) => {
138
+ const p = resolveComponent("FmIcon"), h = resolveComponent("FmButton");
139
+ return e.visible ? (openBlock(), createElementBlock("div", _hoisted_1$l, [
140
+ createElementVNode("div", _hoisted_2$h, [
141
+ createElementVNode("div", _hoisted_3$e, [
142
+ createVNode(p, {
143
+ name: "restaurant",
144
+ size: "md"
145
+ }),
146
+ r[0] || (r[0] = createElementVNode("h3", { class: "fm-typo-en-body-lg-600" }, "Select Items", -1))
147
+ ]),
148
+ createVNode(h, {
149
+ icon: "close",
150
+ variant: "tertiary",
151
+ onClick: l
152
+ })
153
+ ]),
154
+ r[1] || (r[1] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which items this discount applies to. For bundle discounts, select multiple items that can be bundled together. ", -1)),
155
+ createElementVNode("div", _hoisted_4$d, [
156
+ createVNode(_sfc_main$n, {
157
+ ref_key: "selectItemRef",
158
+ ref: d,
159
+ "initial-value": e.initialValue,
160
+ "filter-items": e.filterItems,
161
+ "on-complete": o,
162
+ "max-height": 300
163
+ }, null, 8, ["initial-value", "filter-items"])
164
+ ]),
165
+ createElementVNode("div", _hoisted_5$a, [
166
+ createVNode(h, {
167
+ variant: "secondary",
168
+ label: "Cancel",
169
+ onClick: l
170
+ }),
171
+ createVNode(h, {
172
+ variant: "primary",
173
+ label: "Confirm Selection",
174
+ onClick: s
175
+ })
176
+ ])
177
+ ])) : createCommentVNode("", !0);
178
+ };
179
+ }
180
+ }), _hoisted_1$k = {
181
+ key: 0,
182
+ class: "bg-fm-color-neutral-gray-50 border border-fm-color-neutral-gray-200 rounded-8 p-16 space-y-16"
183
+ }, _hoisted_2$g = { class: "flex items-center justify-between" }, _hoisted_3$d = { class: "flex items-center gap-8" }, _hoisted_4$c = { class: "flex gap-16 items-center flex-wrap" }, _hoisted_5$9 = { class: "flex gap-8 items-center" }, _hoisted_6$5 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_7$5 = { class: "bg-white border border-fm-color-neutral-gray-200 rounded-8 max-h-[300px] overflow-y-auto" }, _hoisted_8$4 = { class: "flex items-center gap-12" }, _hoisted_9$4 = { class: "fm-typo-en-body-md-600" }, _hoisted_10$4 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_11$2 = {
184
+ key: 1,
185
+ class: "p-24 text-center"
186
+ }, _hoisted_12$1 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_13$1 = { class: "flex justify-end gap-8 pt-8 border-t border-fm-color-neutral-gray-200" }, _sfc_main$l = /* @__PURE__ */ defineComponent({
187
+ __name: "GrabCategorySelectionInline",
188
+ props: {
189
+ visible: { type: Boolean },
190
+ initialValue: {}
191
+ },
192
+ emits: ["confirm", "cancel"],
193
+ setup(e, { emit: m }) {
194
+ const a = e, u = m, d = Fh(), s = ref({}), l = ref(""), o = computed(() => {
195
+ const i = d.menu.value;
196
+ return i ? i.modules.category.map((c) => ({
197
+ id: c._id,
198
+ name: c.name
199
+ })) : [];
200
+ }), n = computed(() => {
201
+ if (!l.value) return o.value;
202
+ const i = l.value.toLowerCase();
203
+ return o.value.filter(
204
+ (c) => c.name.toLowerCase().includes(i)
205
+ );
206
+ }), r = computed(() => Object.values(s.value).filter(Boolean).length);
207
+ function p() {
208
+ s.value = o.value.reduce(
209
+ (i, c) => (i[c.id] = a.initialValue.includes(c.id), i),
210
+ {}
211
+ );
212
+ }
213
+ watch([() => a.visible, () => a.initialValue], () => {
214
+ a.visible && p();
215
+ }), onMounted(async () => {
216
+ await d.store.getMenu(), p();
217
+ });
218
+ function h(i) {
219
+ s.value[i] = !s.value[i];
220
+ }
221
+ function y() {
222
+ const i = r.value === n.value.length;
223
+ n.value.forEach((c) => {
224
+ s.value[c.id] = !i;
225
+ });
226
+ }
227
+ function C() {
228
+ Object.keys(s.value).forEach((i) => {
229
+ s.value[i] = !1;
230
+ });
231
+ }
232
+ function x() {
233
+ const i = Object.entries(s.value).filter(([, c]) => c).map(([c]) => c);
234
+ u("confirm", i);
235
+ }
236
+ function v() {
237
+ u("cancel");
238
+ }
239
+ const f = computed(() => n.value.length > 0 && n.value.every(
240
+ (i) => s.value[i.id]
241
+ ));
242
+ return (i, c) => {
243
+ const k = resolveComponent("FmIcon"), b = resolveComponent("FmButton"), E = resolveComponent("FmTextField"), N = resolveComponent("FmCheckbox"), B = resolveComponent("FmListItem"), w = resolveComponent("FmList");
244
+ return e.visible ? (openBlock(), createElementBlock("div", _hoisted_1$k, [
245
+ createElementVNode("div", _hoisted_2$g, [
246
+ createElementVNode("div", _hoisted_3$d, [
247
+ createVNode(k, {
248
+ name: "category",
249
+ size: "md"
250
+ }),
251
+ c[2] || (c[2] = createElementVNode("h3", { class: "fm-typo-en-body-lg-600" }, "Select Categories", -1))
252
+ ]),
253
+ createVNode(b, {
254
+ icon: "close",
255
+ variant: "tertiary",
256
+ onClick: v
257
+ })
258
+ ]),
259
+ c[3] || (c[3] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which categories this discount applies to. The discount will be available for all items within the selected categories. ", -1)),
260
+ createElementVNode("div", _hoisted_4$c, [
261
+ createElementVNode("div", _hoisted_5$9, [
262
+ createVNode(b, {
263
+ icon: "select_all",
264
+ variant: "tertiary",
265
+ size: "small",
266
+ label: `${f.value ? "Deselect" : "Select"} All`,
267
+ onClick: y
268
+ }, null, 8, ["label"]),
269
+ createVNode(b, {
270
+ icon: "sync",
271
+ variant: "tertiary",
272
+ size: "small",
273
+ label: "Clear",
274
+ onClick: C
275
+ }),
276
+ createElementVNode("span", _hoisted_6$5, toDisplayString(r.value) + " selected ", 1)
277
+ ]),
278
+ createVNode(E, {
279
+ modelValue: l.value,
280
+ "onUpdate:modelValue": c[0] || (c[0] = (S) => l.value = S),
281
+ placeholder: "Search categories",
282
+ "leading-icon": { name: "search", color: "" },
283
+ class: "flex-1 min-w-[200px]"
284
+ }, null, 8, ["modelValue"])
285
+ ]),
286
+ createElementVNode("div", _hoisted_7$5, [
287
+ n.value.length > 0 ? (openBlock(), createBlock(w, { key: 0 }, {
288
+ default: withCtx(() => [
289
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(n.value, (S) => (openBlock(), createBlock(B, {
290
+ key: S.id,
291
+ clickable: !0,
292
+ onClick: (F) => h(S.id)
293
+ }, {
294
+ leading: withCtx(() => [
295
+ createVNode(N, {
296
+ "model-value": s.value[S.id] || !1,
297
+ value: S.id,
298
+ "onUpdate:modelValue": (F) => h(S.id),
299
+ onClick: c[1] || (c[1] = withModifiers(() => {
300
+ }, ["stop"]))
301
+ }, null, 8, ["model-value", "value", "onUpdate:modelValue"])
302
+ ]),
303
+ default: withCtx(() => [
304
+ createElementVNode("div", _hoisted_8$4, [
305
+ createVNode(k, {
306
+ name: "category",
307
+ size: "sm",
308
+ class: "text-fm-color-typo-secondary"
309
+ }),
310
+ createElementVNode("div", null, [
311
+ createElementVNode("div", _hoisted_9$4, toDisplayString(S.name), 1),
312
+ createElementVNode("div", _hoisted_10$4, " ID: " + toDisplayString(S.id), 1)
313
+ ])
314
+ ])
315
+ ]),
316
+ _: 2
317
+ }, 1032, ["onClick"]))), 128))
318
+ ]),
319
+ _: 1
320
+ })) : (openBlock(), createElementBlock("div", _hoisted_11$2, [
321
+ createElementVNode("div", _hoisted_12$1, toDisplayString(l.value ? "No categories found matching your search." : "No categories available."), 1)
322
+ ]))
323
+ ]),
324
+ createElementVNode("div", _hoisted_13$1, [
325
+ createVNode(b, {
326
+ variant: "secondary",
327
+ label: "Cancel",
328
+ onClick: v
329
+ }),
330
+ createVNode(b, {
331
+ variant: "primary",
332
+ label: `Confirm Selection (${r.value})`,
333
+ disabled: r.value === 0,
334
+ onClick: x
335
+ }, null, 8, ["label", "disabled"])
336
+ ])
337
+ ])) : createCommentVNode("", !0);
338
+ };
339
+ }
340
+ }), _hoisted_1$j = { class: "space-y-8" }, _hoisted_2$f = {
341
+ key: 1,
342
+ class: "border-1 rounded-md flex gap-16 items-center justify-between px-16 py-12"
343
+ }, _hoisted_3$c = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$b = { class: "text-fm-color-typo-secondary" }, _hoisted_5$8 = { key: 0 }, _hoisted_6$4 = { class: "space-y-24" }, _hoisted_7$4 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mt-4" }, _hoisted_8$3 = { key: 0 }, _hoisted_9$3 = { class: "fm-typo-en-body-md-600 mb-8 block" }, _hoisted_10$3 = { key: 1 }, _hoisted_11$1 = { key: 2 }, _hoisted_12 = { key: 0 }, _hoisted_13 = { class: "space-y-8" }, _hoisted_14 = { class: "flex items-center justify-between p-12 border border-fm-color-neutral-gray-200 fm-corner-radius-md" }, _hoisted_15 = { class: "flex items-center gap-8" }, _hoisted_16 = { class: "fm-typo-en-body-md-400" }, _hoisted_17 = { key: 3 }, _hoisted_18 = { key: 0 }, _hoisted_19 = { class: "space-y-8" }, _hoisted_20 = { class: "flex items-center justify-between p-12 border border-fm-color-neutral-gray-200 fm-corner-radius-md" }, _hoisted_21 = { class: "flex items-center gap-8" }, _hoisted_22 = { class: "fm-typo-en-body-md-400" }, _hoisted_23 = {
344
+ key: 0,
345
+ class: "mt-16 p-12 bg-fm-color-feedback-error-light rounded-8 border border-fm-color-feedback-error-main"
346
+ }, _hoisted_24 = { class: "flex items-center gap-8 mb-8 text-fm-color-system-error-300" }, _hoisted_25 = { class: "space-y-4" }, _hoisted_26 = { class: "flex gap-16" }, _sfc_main$k = /* @__PURE__ */ defineComponent({
347
+ __name: "GrabEffectSheet",
348
+ props: {
349
+ modelValue: { type: Object }
350
+ },
351
+ emits: ["update:model-value"],
352
+ setup(e, { emit: m }) {
353
+ const a = e, u = m, d = Fh(), s = ref(!1), l = ref(!1), o = ref(!1), n = ref({
354
+ type: "net",
355
+ value: 0,
356
+ scope: {
357
+ type: "order"
358
+ }
359
+ });
360
+ watch(
361
+ () => a.modelValue,
362
+ (g) => {
363
+ g && (n.value = { ...g });
364
+ },
365
+ { immediate: !0 }
366
+ ), onMounted(async () => {
367
+ await d.store.getMenu();
368
+ });
369
+ const r = computed(() => {
370
+ var g;
371
+ return !(!n.value.type || !((g = n.value.scope) != null && g.type) || y(n.value.type) && (!n.value.value || n.value.value <= 0) || (n.value.scope.type === "items" || n.value.scope.type === "category") && (!n.value.scope.objectIDs || n.value.scope.objectIDs.length === 0));
372
+ });
373
+ async function p(g) {
374
+ g.stopPropagation(), await prompt.remove("Are you sure you want to remove this discount?") && u("update:model-value", null);
375
+ }
376
+ function h() {
377
+ var g;
378
+ return k(((g = n.value.scope) == null ? void 0 : g.type) || "order");
379
+ }
380
+ function y(g) {
381
+ return g && !["freeItem", "delivery"].includes(g);
382
+ }
383
+ function C(g) {
384
+ return g && ["percentage", "bundleSamePercentage", "bundleDiffPercentage"].includes(
385
+ g
386
+ );
387
+ }
388
+ function x(g) {
389
+ return g != null && g.includes("Percentage") ? "Discount percentage" : g != null && g.includes("FixPrice") ? "Bundle fixed price" : g === "percentage" ? "Discount percentage" : "Discount amount";
390
+ }
391
+ function v(g) {
392
+ return g != null && g.includes("Percentage") || g === "percentage" ? "10" : "5.00";
393
+ }
394
+ function f(g) {
395
+ return g != null && g.includes("Percentage") || g === "percentage" ? "%" : "$";
396
+ }
397
+ function i(g, V) {
398
+ n.value = {
399
+ ...n.value,
400
+ [g]: V
401
+ };
402
+ }
403
+ function c(g, V) {
404
+ var O;
405
+ const $ = {
406
+ ...n.value.scope,
407
+ [g]: V
408
+ };
409
+ if (n.value = {
410
+ ...n.value,
411
+ scope: $
412
+ }, g === "type") {
413
+ const T = k(V);
414
+ T.some(
415
+ (A) => A.value === n.value.type
416
+ ) || (n.value = {
417
+ ...n.value,
418
+ type: ((O = T[0]) == null ? void 0 : O.value) || "net",
419
+ // Reset value and cap when changing to incompatible type
420
+ value: 0,
421
+ cap: void 0
422
+ });
423
+ }
424
+ }
425
+ function k(g) {
426
+ switch (g) {
427
+ case "order":
428
+ return [
429
+ { label: "Amount off", value: "net" },
430
+ { label: "Percentage off", value: "percentage" },
431
+ { label: "Delivery fee off", value: "delivery" }
432
+ ];
433
+ case "category":
434
+ return [
435
+ { label: "Amount off", value: "net" },
436
+ { label: "Percentage off", value: "percentage" }
437
+ ];
438
+ case "items":
439
+ return [
440
+ { label: "Amount off", value: "net" },
441
+ { label: "Percentage off", value: "percentage" },
442
+ { label: "Free item", value: "freeItem" },
443
+ {
444
+ label: "Bundle (same item) - Fixed price",
445
+ value: "bundleSameFixPrice"
446
+ },
447
+ { label: "Bundle (same item) - Amount off", value: "bundleSameNet" },
448
+ {
449
+ label: "Bundle (same item) - Percentage off",
450
+ value: "bundleSamePercentage"
451
+ },
452
+ {
453
+ label: "Bundle (different items) - Fixed price",
454
+ value: "bundleDiffFixPrice"
455
+ },
456
+ {
457
+ label: "Bundle (different items) - Amount off",
458
+ value: "bundleDiffNet"
459
+ },
460
+ {
461
+ label: "Bundle (different items) - Percentage off",
462
+ value: "bundleDiffPercentage"
463
+ }
464
+ ];
465
+ default:
466
+ return [
467
+ { label: "Amount off", value: "net" },
468
+ { label: "Percentage off", value: "percentage" }
469
+ ];
470
+ }
471
+ }
472
+ function b(g) {
473
+ switch (g) {
474
+ case "order":
475
+ return "Applies to entire order. Available: Amount off, Percentage off, Delivery fee discount.";
476
+ case "category":
477
+ return "Applies to specific item categories. Available: Amount off, Percentage off, Free item.";
478
+ case "items":
479
+ return "Applies to specific items. Available: Basic discounts, Bundle offers (same/different items).";
480
+ default:
481
+ return "Select how you want to apply the discount.";
482
+ }
483
+ }
484
+ function E() {
485
+ var g;
486
+ return ((g = n.value.scope) == null ? void 0 : g.type) === "items";
487
+ }
488
+ function N() {
489
+ var g;
490
+ return ((g = n.value.scope) == null ? void 0 : g.type) === "category";
491
+ }
492
+ function B() {
493
+ var $;
494
+ const g = ($ = n.value.scope) == null ? void 0 : $.objectIDs;
495
+ if (!g || g.length === 0)
496
+ return "No items selected";
497
+ const V = d.menu.value;
498
+ return V && g.length <= 3 ? g.map((T) => {
499
+ const D = V.modules.item.find((A) => A._id === T);
500
+ return D ? (D.name2 || D.name).trim() : `Item ${T}`;
501
+ }).join(", ") : g.length === 1 ? "1 item selected" : `${g.length} items selected`;
502
+ }
503
+ function w() {
504
+ var $;
505
+ const g = ($ = n.value.scope) == null ? void 0 : $.objectIDs;
506
+ if (!g || g.length === 0)
507
+ return "No categories selected";
508
+ const V = d.menu.value;
509
+ return V && g.length <= 3 ? g.map((T) => {
510
+ const D = V.modules.category.find((A) => A._id === T);
511
+ return D ? D.name : `Category ${T}`;
512
+ }).join(", ") : g.length === 1 ? "1 category selected" : `${g.length} categories selected`;
513
+ }
514
+ function S() {
515
+ l.value = !0;
516
+ }
517
+ function F() {
518
+ o.value = !0;
519
+ }
520
+ function U(g) {
521
+ c("objectIDs", g), l.value = !1;
522
+ }
523
+ function R(g) {
524
+ c("objectIDs", g), o.value = !1;
525
+ }
526
+ function Y() {
527
+ l.value = !1;
528
+ }
529
+ function G() {
530
+ o.value = !1;
531
+ }
532
+ const j = computed(() => {
533
+ var V, $, O;
534
+ const g = [];
535
+ return n.value.type || g.push("Discount type is required"), (V = n.value.scope) != null && V.type || g.push("Scope type is required"), y(n.value.type) && (!n.value.value || n.value.value <= 0) && g.push("Discount amount must be greater than 0"), (($ = n.value.scope) == null ? void 0 : $.type) === "items" && (!n.value.scope.objectIDs || n.value.scope.objectIDs.length === 0) && g.push("Please select at least one item"), ((O = n.value.scope) == null ? void 0 : O.type) === "category" && (!n.value.scope.objectIDs || n.value.scope.objectIDs.length === 0) && g.push("Please select at least one category"), g;
536
+ });
537
+ function Z() {
538
+ u("update:model-value", n.value), s.value = !1;
539
+ }
540
+ const q = [
541
+ { label: "Bill discount", value: "order" },
542
+ { label: "Item discount", value: "items" },
543
+ { label: "Category discount", value: "category" }
544
+ ];
545
+ return (g, V) => {
546
+ const $ = resolveComponent("FmButton"), O = resolveComponent("FmSelect"), T = resolveComponent("FmStepperField"), D = resolveComponent("FmIcon"), A = resolveComponent("FmSideSheet");
547
+ return openBlock(), createBlock(A, {
548
+ "max-width": 550,
549
+ header: "Apply discount",
550
+ modelValue: unref(s),
551
+ "onUpdate:modelValue": [
552
+ V[5] || (V[5] = (I) => isRef(s) ? s.value = I : null),
553
+ V[6] || (V[6] = (I) => s.value = I)
554
+ ]
555
+ }, {
556
+ "side-sheet-button": withCtx(() => {
557
+ var I, L, H, M;
558
+ return [
559
+ createElementVNode("div", _hoisted_1$j, [
560
+ V[7] || (V[7] = createElementVNode("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Configure the Grab campaign discount you want to offer your customers. ", -1)),
561
+ e.modelValue ? (openBlock(), createElementBlock("div", _hoisted_2$f, [
562
+ createElementVNode("div", _hoisted_3$c, [
563
+ createElementVNode("div", null, toDisplayString((I = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : I.type), 1),
564
+ createElementVNode("div", _hoisted_4$b, [
565
+ createTextVNode(toDisplayString((L = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : L.adjustment) + " ", 1),
566
+ (H = unref(summarizeGrabDiscount)(e.modelValue)) != null && H.cap ? (openBlock(), createElementBlock("span", _hoisted_5$8, toDisplayString((M = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : M.cap), 1)) : createCommentVNode("", !0)
567
+ ])
568
+ ]),
569
+ createVNode($, {
570
+ icon: "delete",
571
+ "icon-color": "neutral-gray-400",
572
+ variant: "tertiary",
573
+ onClick: p
574
+ })
575
+ ])) : (openBlock(), createBlock($, {
576
+ key: 0,
577
+ label: "Apply Grab discount",
578
+ icon: "add",
579
+ "icon-color": "primary",
580
+ variant: "secondary",
581
+ class: "border-fm-color-primary text-fm-color-primary"
582
+ }))
583
+ ])
584
+ ];
585
+ }),
586
+ "side-sheet-footer": withCtx(() => [
587
+ createElementVNode("div", _hoisted_26, [
588
+ createVNode($, {
589
+ variant: "secondary",
590
+ label: "Cancel",
591
+ class: "flex-1",
592
+ onClick: V[4] || (V[4] = (I) => s.value = !1)
593
+ }),
594
+ createVNode($, {
595
+ variant: "primary",
596
+ label: unref(r) ? "Confirm" : "Complete Required Fields",
597
+ class: "flex-1",
598
+ disabled: !unref(r),
599
+ onClick: Z
600
+ }, null, 8, ["label", "disabled"])
601
+ ])
602
+ ]),
603
+ default: withCtx(() => {
604
+ var I, L, H, M;
605
+ return [
606
+ createElementVNode("div", _hoisted_6$4, [
607
+ createElementVNode("div", null, [
608
+ V[8] || (V[8] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Campaign type", -1)),
609
+ createVNode(O, {
610
+ "model-value": ((I = unref(n).scope) == null ? void 0 : I.type) || "order",
611
+ "onUpdate:modelValue": V[0] || (V[0] = (P) => c("type", P)),
612
+ placeholder: "Select campaign type",
613
+ items: q
614
+ }, null, 8, ["model-value"]),
615
+ createElementVNode("div", _hoisted_7$4, toDisplayString(b((L = unref(n).scope) == null ? void 0 : L.type)), 1)
616
+ ]),
617
+ createElementVNode("div", null, [
618
+ V[9] || (V[9] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Discount type", -1)),
619
+ createVNode(O, {
620
+ "model-value": unref(n).type,
621
+ "onUpdate:modelValue": V[1] || (V[1] = (P) => i("type", P)),
622
+ placeholder: "Select discount type",
623
+ items: h()
624
+ }, null, 8, ["model-value", "items"])
625
+ ]),
626
+ y(unref(n).type) ? (openBlock(), createElementBlock("div", _hoisted_8$3, [
627
+ createElementVNode("label", _hoisted_9$3, toDisplayString(x(unref(n).type)), 1),
628
+ createVNode(T, {
629
+ modelValue: unref(n).value,
630
+ "onUpdate:modelValue": V[2] || (V[2] = (P) => unref(n).value = P),
631
+ placeholder: v(unref(n).type),
632
+ suffix: f(unref(n).type),
633
+ type: "number"
634
+ }, null, 8, ["modelValue", "placeholder", "suffix"])
635
+ ])) : createCommentVNode("", !0),
636
+ C(unref(n).type) ? (openBlock(), createElementBlock("div", _hoisted_10$3, [
637
+ V[10] || (V[10] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Discount cap (optional)", -1)),
638
+ createVNode(T, {
639
+ modelValue: unref(n).cap,
640
+ "onUpdate:modelValue": V[3] || (V[3] = (P) => unref(n).cap = P),
641
+ placeholder: "Maximum discount amount",
642
+ type: "number"
643
+ }, null, 8, ["modelValue"])
644
+ ])) : createCommentVNode("", !0),
645
+ E() ? (openBlock(), createElementBlock("div", _hoisted_11$1, [
646
+ unref(l) ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_12, [
647
+ V[12] || (V[12] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Select Items", -1)),
648
+ createElementVNode("div", _hoisted_13, [
649
+ createElementVNode("div", _hoisted_14, [
650
+ createElementVNode("div", _hoisted_15, [
651
+ createVNode(D, {
652
+ name: "restaurant",
653
+ size: "md"
654
+ }),
655
+ createElementVNode("span", _hoisted_16, toDisplayString(B()), 1)
656
+ ]),
657
+ createVNode($, {
658
+ variant: "secondary",
659
+ label: "Select Items",
660
+ icon: "chevron_right",
661
+ onClick: S
662
+ })
663
+ ]),
664
+ V[11] || (V[11] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which items this discount applies to. Bundle discounts require multiple items. ", -1))
665
+ ])
666
+ ])),
667
+ createVNode(_sfc_main$m, {
668
+ visible: unref(l),
669
+ "initial-value": ((H = unref(n).scope) == null ? void 0 : H.objectIDs) || [],
670
+ onConfirm: U,
671
+ onCancel: Y
672
+ }, null, 8, ["visible", "initial-value"])
673
+ ])) : createCommentVNode("", !0),
674
+ N() ? (openBlock(), createElementBlock("div", _hoisted_17, [
675
+ unref(o) ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_18, [
676
+ V[14] || (V[14] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Select Categories", -1)),
677
+ createElementVNode("div", _hoisted_19, [
678
+ createElementVNode("div", _hoisted_20, [
679
+ createElementVNode("div", _hoisted_21, [
680
+ createVNode(D, {
681
+ name: "category",
682
+ size: "md"
683
+ }),
684
+ createElementVNode("span", _hoisted_22, toDisplayString(w()), 1)
685
+ ]),
686
+ createVNode($, {
687
+ variant: "secondary",
688
+ label: "Select Categories",
689
+ icon: "chevron_right",
690
+ onClick: F
691
+ })
692
+ ]),
693
+ V[13] || (V[13] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which categories this discount applies to. ", -1))
694
+ ])
695
+ ])),
696
+ createVNode(_sfc_main$l, {
697
+ visible: unref(o),
698
+ "initial-value": ((M = unref(n).scope) == null ? void 0 : M.objectIDs) || [],
699
+ onConfirm: R,
700
+ onCancel: G
701
+ }, null, 8, ["visible", "initial-value"])
702
+ ])) : createCommentVNode("", !0)
703
+ ]),
704
+ unref(j).length > 0 ? (openBlock(), createElementBlock("div", _hoisted_23, [
705
+ createElementVNode("div", _hoisted_24, [
706
+ createVNode(D, { name: "warning" }),
707
+ V[15] || (V[15] = createElementVNode("span", { class: "fm-typo-en-body-sm-600" }, "Please fix the following issues:", -1))
708
+ ]),
709
+ createElementVNode("ul", _hoisted_25, [
710
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(j), (P) => (openBlock(), createElementBlock("li", {
711
+ key: P,
712
+ class: "fm-typo-en-body-sm-400 text-fm-color-feedback-error-main flex items-start gap-8"
713
+ }, [
714
+ V[16] || (V[16] = createElementVNode("span", { class: "w-4 h-4 bg-fm-color-feedback-error-main rounded-full mt-6 flex-shrink-0" }, null, -1)),
715
+ createTextVNode(" " + toDisplayString(P), 1)
716
+ ]))), 128))
717
+ ])
718
+ ])) : createCommentVNode("", !0)
719
+ ];
720
+ }),
721
+ _: 1
722
+ }, 8, ["modelValue"]);
723
+ };
724
+ }
725
+ }), GrabEffectSheet = /* @__PURE__ */ _export_sfc(_sfc_main$k, [["__scopeId", "data-v-cf604dd7"]]), _hoisted_1$i = { class: "space-y-24" }, _sfc_main$j = /* @__PURE__ */ defineComponent({
726
+ __name: "TimeRuleGroup",
727
+ props: {
728
+ modelValue: {
729
+ type: Object,
730
+ default: () => {
731
+ }
732
+ }
733
+ },
734
+ emits: ["update:model-value"],
735
+ setup(e, { emit: m }) {
736
+ const { t: a } = useI18n(), u = e, d = m, s = ref(
737
+ !u.modelValue || !u.modelValue.rules.g_time ? "all_time" : RuleBuilder.getRules(u.modelValue.rules.g_time).length > 0 ? "custom" : "all_time"
738
+ );
739
+ watch(s, async (o, n) => {
740
+ var r;
741
+ if (n == "custom" && o == "all_time" && RuleBuilder.getRules((r = u.modelValue) == null ? void 0 : r.rules.g_time).length > 0) {
742
+ const p = await prompt.confirm(
743
+ a("connect.template.rule.time.confirm_remove"),
744
+ a("connect.common.confirm"),
745
+ a("connect.common.confirm"),
746
+ a("connect.common.cancel")
747
+ );
748
+ p && d(
749
+ "update:model-value",
750
+ RuleBuilder.setRuleToGroup(
751
+ u.modelValue ?? RuleBuilder.scaffoldGroup(),
752
+ RuleBuilder.scaffoldGroup("g_time")
753
+ )
754
+ ), s.value = p ? o : n;
755
+ }
756
+ });
757
+ async function l(o) {
758
+ var n;
759
+ if (o == "custom" && RuleBuilder.getRules((n = u.modelValue) == null ? void 0 : n.rules.g_time).length > 0) {
760
+ if (!await prompt.confirm(
761
+ a("connect.template.rule.time.confirm_remove"),
762
+ a("connect.common.confirm"),
763
+ a("connect.common.confirm"),
764
+ a("connect.common.cancel")
765
+ )) {
766
+ s.value = "all_time";
767
+ return;
768
+ }
769
+ d(
770
+ "update:model-value",
771
+ RuleBuilder.setRuleToGroup(
772
+ u.modelValue ?? RuleBuilder.scaffoldGroup(),
773
+ RuleBuilder.scaffoldGroup("g_time")
774
+ )
775
+ );
776
+ }
777
+ }
778
+ return (o, n) => {
779
+ var h;
780
+ const r = resolveComponent("FmRadio"), p = resolveComponent("FmRadioGroup");
781
+ return openBlock(), createElementBlock("div", _hoisted_1$i, [
782
+ createVNode(p, {
783
+ modelValue: unref(s),
784
+ "onUpdate:modelValue": [
785
+ n[0] || (n[0] = (y) => isRef(s) ? s.value = y : null),
786
+ n[1] || (n[1] = (y) => l(y))
787
+ ]
788
+ }, {
789
+ default: withCtx(() => [
790
+ createVNode(r, {
791
+ label: unref(a)("connect.template.rule.time.all_time"),
792
+ value: "all_time"
793
+ }, null, 8, ["label"]),
794
+ createVNode(r, {
795
+ label: unref(a)("connect.template.rule.time.custom"),
796
+ value: "custom"
797
+ }, null, 8, ["label"])
798
+ ]),
799
+ _: 1
800
+ }, 8, ["modelValue"]),
801
+ unref(s) == "custom" ? (openBlock(), createBlock(_sfc_main$o, {
802
+ key: 0,
803
+ class: "!mt-[0px]",
804
+ "include-only": "trigger",
805
+ "trigger-type": "SCHEDULE",
806
+ "model-value": ((h = e.modelValue) == null ? void 0 : h.rules.g_time) ?? unref(RuleBuilder).scaffoldGroup("g_time"),
807
+ "onUpdate:modelValue": n[2] || (n[2] = (y) => d(
808
+ "update:model-value",
809
+ unref(RuleBuilder).setRuleToGroup(
810
+ e.modelValue ?? unref(RuleBuilder).scaffoldGroup(),
811
+ y,
812
+ "&&"
813
+ )
814
+ ))
815
+ }, null, 8, ["model-value"])) : createCommentVNode("", !0)
816
+ ]);
817
+ };
818
+ }
819
+ }), _sfc_main$i = /* @__PURE__ */ defineComponent({
820
+ __name: "BirthdayInput",
821
+ props: {
822
+ modelValue: {
823
+ type: Object
824
+ }
825
+ },
826
+ emits: ["update:model-value"],
827
+ setup(e, { emit: m }) {
828
+ const { t: a } = useI18n(), u = e, d = m, s = computed(() => {
829
+ const { property: l, operator: o, equator: n } = RuleBuilder.simplify(
830
+ u.modelValue ?? RuleBuilder.constructEntry("user.birthday", "_isDay", {
831
+ op: "before",
832
+ x: 1
833
+ })
834
+ );
835
+ return {
836
+ property: l,
837
+ operator: o,
838
+ equator: n
839
+ };
840
+ });
841
+ return (l, o) => {
842
+ const n = resolveComponent("FmRadio"), r = resolveComponent("FmStepperField");
843
+ return openBlock(), createElementBlock("div", null, [
844
+ createVNode(n, {
845
+ label: unref(a)("connect.template.rule.birthday.on_birthday"),
846
+ value: "_isRange-day",
847
+ "model-value": `${unref(s).operator}-${unref(s).equator.unit}`,
848
+ "onUpdate:modelValue": o[0] || (o[0] = () => {
849
+ d(
850
+ "update:model-value",
851
+ unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
852
+ op: "this",
853
+ unit: "day",
854
+ ignoreYear: !0
855
+ })
856
+ );
857
+ })
858
+ }, null, 8, ["label", "model-value"]),
859
+ createVNode(n, {
860
+ label: unref(a)("connect.template.rule.birthday.days_before"),
861
+ value: "_isDay",
862
+ "model-value": unref(s).operator,
863
+ "onUpdate:modelValue": o[1] || (o[1] = () => {
864
+ d(
865
+ "update:model-value",
866
+ unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
867
+ op: "after",
868
+ x: 1,
869
+ ignoreYear: !0
870
+ })
871
+ );
872
+ })
873
+ }, null, 8, ["label", "model-value"]),
874
+ unref(s).operator == "_isDay" ? (openBlock(), createBlock(r, {
875
+ key: 0,
876
+ label: unref(a)("connect.template.rule.birthday.days_before_label"),
877
+ "show-steppers": !1,
878
+ "model-value": unref(s).equator.x,
879
+ "onUpdate:modelValue": o[2] || (o[2] = (p) => d(
880
+ "update:model-value",
881
+ unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
882
+ op: "after",
883
+ x: p,
884
+ ignoreYear: !0
885
+ })
886
+ ))
887
+ }, null, 8, ["label", "model-value"])) : createCommentVNode("", !0),
888
+ createVNode(n, {
889
+ label: unref(a)("connect.template.rule.birthday.in_birthday_week"),
890
+ value: "_isRange-week",
891
+ "model-value": `${unref(s).operator}-${unref(s).equator.unit}`,
892
+ "onUpdate:modelValue": o[3] || (o[3] = () => {
893
+ d(
894
+ "update:model-value",
895
+ unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
896
+ op: "this",
897
+ unit: "week",
898
+ ignoreYear: !0
899
+ })
900
+ );
901
+ })
902
+ }, null, 8, ["label", "model-value"]),
903
+ createVNode(n, {
904
+ label: unref(a)("connect.template.rule.birthday.in_birthday_month"),
905
+ value: "_isRange-month",
906
+ "model-value": `${unref(s).operator}-${unref(s).equator.unit}`,
907
+ "onUpdate:modelValue": o[4] || (o[4] = () => {
908
+ d(
909
+ "update:model-value",
910
+ unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
911
+ op: "this",
912
+ unit: "month",
913
+ ignoreYear: !0
914
+ })
915
+ );
916
+ })
917
+ }, null, 8, ["label", "model-value"])
918
+ ]);
919
+ };
920
+ }
921
+ }), _hoisted_1$h = { class: "space-y-16" }, _hoisted_2$e = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$b = { class: "grid grid-cols-3 gap-16" }, _hoisted_4$a = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$7 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$h = /* @__PURE__ */ defineComponent({
922
+ __name: "CampaignTriggerInput",
923
+ props: {
924
+ campaignType: {
925
+ type: String,
926
+ required: !0
927
+ },
928
+ modelValue: {
929
+ type: String
930
+ },
931
+ disabled: {
932
+ type: Boolean,
933
+ default: !1
934
+ }
935
+ },
936
+ emits: ["update:model-value"],
937
+ setup(e, { emit: m }) {
938
+ const { t: a } = useI18n(), u = e, d = m, s = computed(() => u.disabled ? TypeToTriggerOptions[u.campaignType].filter(
939
+ (l) => l.value == u.modelValue
940
+ ) : TypeToTriggerOptions[u.campaignType]);
941
+ return (l, o) => {
942
+ const n = resolveComponent("FmCard");
943
+ return openBlock(), createElementBlock("div", _hoisted_1$h, [
944
+ createElementVNode("div", _hoisted_2$e, toDisplayString(unref(a)("connect.campaign.trigger.description")), 1),
945
+ createElementVNode("div", _hoisted_3$b, [
946
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(s), (r) => (openBlock(), createBlock(n, {
947
+ variant: "outlined",
948
+ disabled: u.disabled,
949
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
950
+ "col-span-3": unref(s).length == 1,
951
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == r.value,
952
+ "hover:bg-fm-color-opacity-sm": e.modelValue != r.value
953
+ }]),
954
+ onClick: () => {
955
+ u.modelValue != r.value && !u.disabled && d("update:model-value", r.value);
956
+ },
957
+ key: r.name
958
+ }, {
959
+ default: withCtx(() => [
960
+ createElementVNode("div", _hoisted_4$a, toDisplayString(r.name), 1),
961
+ createElementVNode("div", _hoisted_5$7, toDisplayString(r.description), 1)
962
+ ]),
963
+ _: 2
964
+ }, 1032, ["disabled", "class", "onClick"]))), 128))
965
+ ])
966
+ ]);
967
+ };
968
+ }
969
+ }), _hoisted_1$g = { class: "flex items-center gap-8 w-full xs:flex-col" }, _hoisted_2$d = { class: "flex-1 xs:w-full" }, _hoisted_3$a = { class: "mt-5 xs:hidden" }, _hoisted_4$9 = { class: "flex-1 xs:w-full" }, _sfc_main$g = /* @__PURE__ */ defineComponent({
970
+ __name: "DateRangeInput",
971
+ props: {
972
+ modelValue: {
973
+ type: Object,
974
+ required: !1
975
+ }
976
+ },
977
+ emits: ["update:model-value"],
978
+ setup(e, { emit: m }) {
979
+ const { t: a } = useI18n(), u = m;
980
+ return (d, s) => {
981
+ var l, o;
982
+ return openBlock(), createElementBlock("div", _hoisted_1$g, [
983
+ createElementVNode("div", _hoisted_2$d, [
984
+ createVNode(_sfc_main$p, {
985
+ "model-value": ((l = e.modelValue) == null ? void 0 : l.startDate) ?? null,
986
+ label: unref(a)("connect.common.startDate"),
987
+ "onUpdate:modelValue": s[0] || (s[0] = (n) => {
988
+ var r;
989
+ return u("update:model-value", {
990
+ startDate: n,
991
+ endDate: ((r = e.modelValue) == null ? void 0 : r.endDate) ?? null
992
+ });
993
+ })
994
+ }, null, 8, ["model-value", "label"])
995
+ ]),
996
+ createElementVNode("div", _hoisted_3$a, toDisplayString(unref(a)("connect.common.to")), 1),
997
+ createElementVNode("div", _hoisted_4$9, [
998
+ createVNode(_sfc_main$p, {
999
+ "model-value": ((o = e.modelValue) == null ? void 0 : o.endDate) ?? null,
1000
+ label: unref(a)("connect.common.endDate"),
1001
+ "onUpdate:modelValue": s[1] || (s[1] = (n) => {
1002
+ var r;
1003
+ return u("update:model-value", {
1004
+ startDate: ((r = e.modelValue) == null ? void 0 : r.startDate) ?? null,
1005
+ endDate: n
1006
+ });
1007
+ })
1008
+ }, null, 8, ["model-value", "label"])
1009
+ ])
1010
+ ]);
1011
+ };
1012
+ }
1013
+ }), _hoisted_1$f = { class: "space-y-8" }, _hoisted_2$c = { class: "grid grid-cols-2 gap-16" }, _hoisted_3$9 = {
1014
+ key: 0,
1015
+ class: "space-y-4"
1016
+ }, _hoisted_4$8 = { class: "fm-typo-en-body-lg-400 class flex items-center justify-between" }, _hoisted_5$6 = { class: "text-ellipsis line-clamp-1" }, _sfc_main$f = /* @__PURE__ */ defineComponent({
1017
+ __name: "ScheduleRuleInput",
1018
+ props: {
1019
+ modelValue: {
1020
+ type: Object,
1021
+ required: !0
1022
+ },
1023
+ startDate: {
1024
+ type: String
1025
+ },
1026
+ endDate: {
1027
+ type: String
1028
+ }
1029
+ },
1030
+ emits: ["update:model-value"],
1031
+ setup(e, { emit: m }) {
1032
+ const { t: a } = useI18n(), u = e, d = m, s = useCoreStore(), l = computed(
1033
+ () => CountryTimezone[s.currentCountry.value || "MY"]
1034
+ );
1035
+ function o() {
1036
+ const i = RuleBuilder.getRules(u.modelValue);
1037
+ return i.length == 0 ? "fixed" : i.some(
1038
+ (c) => isRuleEntry(c) && RuleBuilder.simplify(c).operator == "_rrule"
1039
+ ) ? "repeating" : "fixed";
1040
+ }
1041
+ const n = ref(o()), r = ref(!1), p = ref(!1), h = computed(() => [
1042
+ { label: a("connect.template.rule.schedule.fixed"), value: "fixed" },
1043
+ { label: a("connect.template.rule.schedule.repeating"), value: "repeating" }
1044
+ ]), y = computed(() => {
1045
+ const i = RuleBuilder.getRules(u.modelValue), c = i.find(
1046
+ (b) => isRuleEntry(b) && RuleBuilder.simplify(b).property == "trigger.date"
1047
+ ), k = i.find(
1048
+ (b) => isRuleEntry(b) && RuleBuilder.simplify(b).property == "trigger.time"
1049
+ );
1050
+ return {
1051
+ date: c ? RuleBuilder.simplify(c).equator : null,
1052
+ time: k ? RuleBuilder.simplify(k).equator : null
1053
+ };
1054
+ }), C = computed(
1055
+ () => calculateNextScheduleAt(
1056
+ u.modelValue,
1057
+ /* @__PURE__ */ new Date(),
1058
+ u.startDate ? new Date(u.startDate) : /* @__PURE__ */ new Date(),
1059
+ u.endDate ? new Date(u.endDate) : void 0
1060
+ )
1061
+ );
1062
+ function x(i, c) {
1063
+ d(
1064
+ "update:model-value",
1065
+ RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
1066
+ RuleBuilder.constructEntry("trigger.date", "_rrule", i),
1067
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", c ?? "00:00")
1068
+ ])
1069
+ );
1070
+ }
1071
+ watch(
1072
+ () => u.startDate,
1073
+ (i, c) => {
1074
+ if (!i || i === c || n.value !== "repeating" || !y.value.date) return;
1075
+ const k = RRule.fromString(y.value.date), b = new RRule({
1076
+ ...k.origOptions,
1077
+ dtstart: new Date(i)
1078
+ }).toString();
1079
+ b !== y.value.date && (x(b, y.value.time), p.value = !0);
1080
+ }
1081
+ );
1082
+ function v(i) {
1083
+ const c = i.value, k = getRruleAnchorDate({
1084
+ startDate: u.startDate ? new Date(u.startDate) : void 0
1085
+ }), b = c == "fixed" ? [
1086
+ RuleBuilder.constructEntry(
1087
+ "trigger.date",
1088
+ "_isOnDate",
1089
+ (/* @__PURE__ */ new Date()).toISOString()
1090
+ ),
1091
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
1092
+ ] : [
1093
+ RuleBuilder.constructEntry(
1094
+ "trigger.date",
1095
+ "_rrule",
1096
+ new RRule({
1097
+ dtstart: k,
1098
+ freq: RRule.DAILY,
1099
+ interval: 1,
1100
+ byhour: 0,
1101
+ byminute: 0,
1102
+ bysecond: 0,
1103
+ wkst: RRule.SU
1104
+ }).toString()
1105
+ ),
1106
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
1107
+ ];
1108
+ d(
1109
+ "update:model-value",
1110
+ RuleBuilder.setRuleToGroup(
1111
+ RuleBuilder.scaffoldGroup("g_schedule"),
1112
+ b
1113
+ )
1114
+ ), n.value = c, p.value = !1;
1115
+ }
1116
+ function f(i) {
1117
+ n.value == "fixed" ? d(
1118
+ "update:model-value",
1119
+ RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
1120
+ RuleBuilder.constructEntry(
1121
+ "trigger.date",
1122
+ "_isOnDate",
1123
+ i.date
1124
+ ),
1125
+ RuleBuilder.constructEntry(
1126
+ "trigger.time",
1127
+ "_isOnTime",
1128
+ i.time
1129
+ )
1130
+ ])
1131
+ ) : x(i.date, i.time), p.value = !1;
1132
+ }
1133
+ return (i, c) => {
1134
+ const k = resolveComponent("FmButtonGroup"), b = resolveComponent("FmTimePicker"), E = resolveComponent("FmIcon"), N = resolveComponent("FmTooltip"), B = resolveComponent("FmField"), w = resolveComponent("FmCard"), S = resolveComponent("FmPopover"), F = resolveComponent("FmDatePicker"), U = resolveComponent("FmHelperText");
1135
+ return openBlock(), createElementBlock(Fragment, null, [
1136
+ createVNode(k, {
1137
+ items: unref(h),
1138
+ "model-value": unref(h).find((R) => R.value === unref(n)) ?? null,
1139
+ "onUpdate:modelValue": v,
1140
+ class: "mb-8"
1141
+ }, null, 8, ["items", "model-value"]),
1142
+ createElementVNode("div", _hoisted_1$f, [
1143
+ createElementVNode("div", _hoisted_2$c, [
1144
+ createVNode(b, {
1145
+ label: unref(a)("connect.template.rule.schedule.notify_time"),
1146
+ "model-value": unref(y).time,
1147
+ "onUpdate:modelValue": c[0] || (c[0] = (R) => f({ date: unref(y).date, time: R })),
1148
+ "helper-text": unref(y).time ? void 0 : unref(a)("connect.template.rule.schedule.time_required"),
1149
+ "helper-state": unref(y).time ? void 0 : "error"
1150
+ }, null, 8, ["label", "model-value", "helper-text", "helper-state"]),
1151
+ unref(n) == "repeating" ? (openBlock(), createElementBlock("div", _hoisted_3$9, [
1152
+ createElementVNode("div", _hoisted_4$8, [
1153
+ createElementVNode("div", null, toDisplayString(unref(a)("connect.template.rule.schedule.notify_date")), 1),
1154
+ unref(y).date ? (openBlock(), createBlock(N, {
1155
+ key: 0,
1156
+ "z-index": 9999,
1157
+ content: unref(SummarizeRrule)(unref(RRule).fromString(unref(y).date).options)
1158
+ }, {
1159
+ default: withCtx(() => [
1160
+ createVNode(E, {
1161
+ name: "info",
1162
+ size: "sm",
1163
+ outline: !0
1164
+ })
1165
+ ]),
1166
+ _: 1
1167
+ }, 8, ["content"])) : createCommentVNode("", !0)
1168
+ ]),
1169
+ createVNode(S, {
1170
+ "show-popover": unref(r),
1171
+ onPopoverChanged: c[3] || (c[3] = (R) => r.value = R)
1172
+ }, {
1173
+ "popover-button": withCtx(() => [
1174
+ createVNode(B, {
1175
+ class: "cursor-pointer",
1176
+ "helper-text": unref(y).date ? void 0 : unref(a)("connect.template.rule.schedule.date_required"),
1177
+ "helper-state": unref(y).date ? void 0 : "error"
1178
+ }, {
1179
+ default: withCtx(() => [
1180
+ createElementVNode("div", _hoisted_5$6, toDisplayString(unref(y).date ? unref(SummarizeRrule)(unref(RRule).fromString(unref(y).date).options) : unref(a)("connect.template.rule.schedule.set_repeating_date")), 1)
1181
+ ]),
1182
+ _: 1
1183
+ }, 8, ["helper-text", "helper-state"])
1184
+ ]),
1185
+ default: withCtx(() => [
1186
+ createVNode(w, { class: "elevated p-8 w-[450px]" }, {
1187
+ default: withCtx(() => [
1188
+ createVNode(_sfc_main$q, {
1189
+ "apply-button": !0,
1190
+ "model-value": unref(y).date || "",
1191
+ "start-date": e.startDate ? new Date(e.startDate) : /* @__PURE__ */ new Date(),
1192
+ onCancel: c[1] || (c[1] = (R) => r.value = !1),
1193
+ "onUpdate:modelValue": c[2] || (c[2] = (R) => (f({ date: R, time: unref(y).time }), r.value = !1))
1194
+ }, null, 8, ["model-value", "start-date"])
1195
+ ]),
1196
+ _: 1
1197
+ })
1198
+ ]),
1199
+ _: 1
1200
+ }, 8, ["show-popover"])
1201
+ ])) : (openBlock(), createBlock(F, {
1202
+ key: 1,
1203
+ label: unref(a)("connect.template.rule.schedule.notify_date"),
1204
+ "model-value": unref(y).date || "",
1205
+ "onUpdate:modelValue": c[4] || (c[4] = (R) => f({ date: R, time: unref(y).time })),
1206
+ "helper-text": unref(y).date ? void 0 : unref(a)("connect.template.rule.schedule.date_required"),
1207
+ "helper-state": unref(y).date ? void 0 : "error"
1208
+ }, null, 8, ["label", "model-value", "helper-text", "helper-state"]))
1209
+ ]),
1210
+ unref(y).date && unref(y).time && unref(C) ? (openBlock(), createBlock(U, {
1211
+ key: 0,
1212
+ text: `${unref(moment)(unref(C)).isAfter(unref(moment)()) ? unref(a)("connect.template.rule.schedule.next_notification") : unref(a)("connect.template.rule.schedule.last_trigger_on")} ${unref(moment)(unref(C)).format("dddd, DD MMM YYYY")} at
1213
+ ${unref(moment)(unref(C)).format("hh:mmA")}(UTC${unref(moment).tz(unref(l)).format("Z")}) (${unref(moment)(unref(C)).fromNow()})`
1214
+ }, null, 8, ["text"])) : createCommentVNode("", !0),
1215
+ unref(p) ? (openBlock(), createBlock(U, {
1216
+ key: 1,
1217
+ text: "Repeating schedule was updated to stay anchored to the campaign start date.",
1218
+ state: "warning"
1219
+ })) : createCommentVNode("", !0)
1220
+ ])
1221
+ ], 64);
1222
+ };
1223
+ }
1224
+ }), _hoisted_1$e = { class: "space-y-16" }, _hoisted_2$b = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$8 = { class: "grid grid-cols-2 gap-16" }, _hoisted_4$7 = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$5 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$e = /* @__PURE__ */ defineComponent({
1225
+ __name: "GameTypeInput",
1226
+ props: {
1227
+ modelValue: {
1228
+ type: String
1229
+ }
1230
+ },
1231
+ emits: ["update:model-value"],
1232
+ setup(e, { emit: m }) {
1233
+ const { t: a } = useI18n(), u = e, d = m, s = computed(
1234
+ () => [
1235
+ {
1236
+ label: a("connect.campaign.gameType.option.FORTUNE_WHEEL.label"),
1237
+ description: a("connect.campaign.gameType.option.FORTUNE_WHEEL.description"),
1238
+ value: F_GAME_TYPE.enum.FORTUNE_WHEEL,
1239
+ hidden: !1
1240
+ },
1241
+ {
1242
+ label: a("connect.campaign.gameType.option.ROCK_PAPER_SCISSORS.label"),
1243
+ description: a("connect.campaign.gameType.option.ROCK_PAPER_SCISSORS.description"),
1244
+ value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS,
1245
+ hidden: !0
1246
+ }
1247
+ ].filter((l) => !l.hidden)
1248
+ );
1249
+ return (l, o) => {
1250
+ const n = resolveComponent("FmCard");
1251
+ return openBlock(), createElementBlock("div", _hoisted_1$e, [
1252
+ createElementVNode("div", _hoisted_2$b, toDisplayString(unref(a)("connect.template.select_game")), 1),
1253
+ createElementVNode("div", _hoisted_3$8, [
1254
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(s), (r) => (openBlock(), createBlock(n, {
1255
+ variant: "outlined",
1256
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1257
+ "col-span-2": unref(s).length == 1,
1258
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == r.value,
1259
+ "hover:bg-fm-color-opacity-sm": e.modelValue != r.value
1260
+ }]),
1261
+ onClick: () => {
1262
+ u.modelValue != r.value && d("update:model-value", r.value);
1263
+ },
1264
+ key: r.value
1265
+ }, {
1266
+ default: withCtx(() => [
1267
+ createElementVNode("div", _hoisted_4$7, toDisplayString(r.label), 1),
1268
+ createElementVNode("div", _hoisted_5$5, toDisplayString(r.description), 1)
1269
+ ]),
1270
+ _: 2
1271
+ }, 1032, ["class", "onClick"]))), 128))
1272
+ ])
1273
+ ]);
1274
+ };
1275
+ }
1276
+ }), _hoisted_1$d = {
1277
+ key: 0,
1278
+ class: "flex flex-col gap-y-24"
1279
+ }, _hoisted_2$a = { class: "flex gap-8 items-center justify-start" }, _sfc_main$d = /* @__PURE__ */ defineComponent({
1280
+ __name: "EditRewardPoolSheet",
1281
+ emits: ["update:model-value"],
1282
+ setup(e, { expose: m, emit: a }) {
1283
+ const u = useMembershipStore(), { minor: d } = useLoading, s = ref(!1), l = ref(), o = ref(), n = ref(0), r = computed(() => {
1284
+ var v;
1285
+ return ((v = u.loyaltyRewards.items.find(
1286
+ (f) => {
1287
+ var i;
1288
+ return f.value === ((i = l.value) == null ? void 0 : i.collectible);
1289
+ }
1290
+ )) == null ? void 0 : v.raw.type) === "CREDIT" ? FdoCreditLoyaltyReward : FdtoRandomReward;
1291
+ }), p = computed(() => {
1292
+ const x = r.value.safeParse(l.value);
1293
+ return x.success ? [] : x.error.errors;
1294
+ });
1295
+ function h(x, v, f) {
1296
+ x && (l.value = v, n.value = f), s.value = x;
1297
+ }
1298
+ const y = a;
1299
+ async function C() {
1300
+ const x = r.value.safeParse(l.value);
1301
+ x.success && (await d(
1302
+ async () => {
1303
+ x.data.type === "VOUCHER" && o.value && (x.data.collectibleConfig.image = await firebaseStorage.update(
1304
+ x.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, o.value),
1305
+ o.value
1306
+ ));
1307
+ },
1308
+ {
1309
+ message: "Uploading reward image",
1310
+ successMessage: "Reward image updated"
1311
+ }
1312
+ ), y("update:model-value", x.data, n.value));
1313
+ }
1314
+ return m({
1315
+ showSheet: h
1316
+ }), (x, v) => {
1317
+ const f = resolveComponent("FmSelect"), i = resolveComponent("FmStepperField"), c = resolveComponent("FmButton"), k = resolveComponent("FmSideSheet");
1318
+ return openBlock(), createBlock(k, {
1319
+ "max-width": 560,
1320
+ modelValue: unref(s),
1321
+ "onUpdate:modelValue": [
1322
+ v[9] || (v[9] = (b) => isRef(s) ? s.value = b : null),
1323
+ v[10] || (v[10] = (b) => s.value = b)
1324
+ ],
1325
+ header: "Edit reward",
1326
+ "dismiss-away": ""
1327
+ }, {
1328
+ "side-sheet-footer": withCtx(() => [
1329
+ createElementVNode("div", _hoisted_2$a, [
1330
+ createVNode(c, {
1331
+ variant: "primary",
1332
+ type: "button",
1333
+ disabled: unref(p).length > 0,
1334
+ label: "Confirm",
1335
+ onClick: v[7] || (v[7] = (b) => C())
1336
+ }, null, 8, ["disabled"]),
1337
+ createVNode(c, {
1338
+ variant: "secondary",
1339
+ type: "button",
1340
+ label: "Cancel",
1341
+ onClick: v[8] || (v[8] = (b) => s.value = !1)
1342
+ })
1343
+ ])
1344
+ ]),
1345
+ default: withCtx(() => {
1346
+ var b, E, N;
1347
+ return [
1348
+ unref(l) ? (openBlock(), createElementBlock("div", _hoisted_1$d, [
1349
+ createVNode(f, {
1350
+ label: "Reward Type",
1351
+ items: [
1352
+ { label: "No Reward", value: "NO_REWARD" },
1353
+ { label: "Voucher", value: "VOUCHER" },
1354
+ { label: "Loyalty", value: "LOYALTY" }
1355
+ ],
1356
+ "model-value": unref(l).type,
1357
+ "onUpdate:modelValue": v[0] || (v[0] = (B) => {
1358
+ B == "NO_REWARD" ? l.value = {
1359
+ type: "NO_REWARD",
1360
+ collectible: null,
1361
+ weight: 1
1362
+ } : B === "VOUCHER" ? l.value = {
1363
+ collectible: null,
1364
+ type: "VOUCHER",
1365
+ collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
1366
+ business: unref(useCoreStore)().currentBusiness.value._id
1367
+ }),
1368
+ earningOption: {
1369
+ amount: 1,
1370
+ type: "FIXED"
1371
+ },
1372
+ validityOption: {
1373
+ validForDay: 7
1374
+ },
1375
+ weight: 1
1376
+ } : l.value = {
1377
+ collectible: unref(u).loyaltyRewards.raw[0]._id,
1378
+ type: "LOYALTY",
1379
+ earningOption: {
1380
+ amount: 1,
1381
+ type: "FIXED"
1382
+ },
1383
+ validityOption: {
1384
+ validForDay: 7
1385
+ },
1386
+ weight: 1
1387
+ };
1388
+ })
1389
+ }, null, 8, ["model-value"]),
1390
+ unref(l).type == "LOYALTY" ? (openBlock(), createBlock(f, {
1391
+ key: 0,
1392
+ label: "Loyalty type",
1393
+ rules: [unref(ZodHelper).ruleAtPath(unref(r), "collectible", [unref(l).type])],
1394
+ items: unref(u).loyaltyRewards.items,
1395
+ "model-value": unref(l).collectible,
1396
+ "onUpdate:modelValue": v[1] || (v[1] = (B) => unref(l).collectible = B)
1397
+ }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
1398
+ createVNode(i, {
1399
+ label: "Weight",
1400
+ rules: [unref(ZodHelper).ruleAtPath(unref(r), "weight", [unref(l).type])],
1401
+ "model-value": unref(l).weight,
1402
+ "onUpdate:modelValue": v[2] || (v[2] = (B) => l.value = {
1403
+ ...unref(l),
1404
+ weight: B
1405
+ })
1406
+ }, null, 8, ["rules", "model-value"]),
1407
+ unref(l).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
1408
+ ((b = unref(u).loyaltyRewards.items.find(
1409
+ (B) => {
1410
+ var w;
1411
+ return B.value === ((w = unref(l)) == null ? void 0 : w.collectible);
1412
+ }
1413
+ )) == null ? void 0 : b.raw.type) !== "TITLE" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
1414
+ v[11] || (v[11] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
1415
+ createVNode(_sfc_main$r, {
1416
+ class: "mt-[-8px]",
1417
+ rules: [
1418
+ unref(ZodHelper).ruleAtPath(unref(r), "earningOption", [unref(l).type])
1419
+ ],
1420
+ "helper-state": unref(ZodHelper).helperState(unref(p), "earningOption"),
1421
+ "error-text": unref(ZodHelper).helperText(unref(p), "earningOption"),
1422
+ "fixed-type": !0,
1423
+ "model-value": unref(l).earningOption,
1424
+ "onUpdate:modelValue": v[3] || (v[3] = (B) => l.value = {
1425
+ ...unref(l),
1426
+ earningOption: B
1427
+ })
1428
+ }, null, 8, ["rules", "helper-state", "error-text", "model-value"])
1429
+ ], 64)) : createCommentVNode("", !0),
1430
+ v[12] || (v[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Validity option", -1)),
1431
+ createVNode(_sfc_main$s, {
1432
+ type: unref(l).type === "LOYALTY" ? "custom" : "range",
1433
+ "for-credit": unref(l).type === "LOYALTY" && ((E = unref(u).loyaltyRewards.items.find(
1434
+ (B) => {
1435
+ var w;
1436
+ return B.value === ((w = unref(l)) == null ? void 0 : w.collectible);
1437
+ }
1438
+ )) == null ? void 0 : E.raw.type) === "CREDIT",
1439
+ class: "!gap-24",
1440
+ rules: [unref(ZodHelper).ruleAtPath(unref(r), "validityOption", [unref(l).type])],
1441
+ "model-value": unref(l).validityOption,
1442
+ "onUpdate:modelValue": v[4] || (v[4] = (B) => l.value = {
1443
+ ...unref(l),
1444
+ validityOption: B
1445
+ })
1446
+ }, null, 8, ["type", "for-credit", "rules", "model-value"])
1447
+ ], 64)) : createCommentVNode("", !0),
1448
+ unref(l).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$t, {
1449
+ key: 2,
1450
+ "reward-image": unref(o),
1451
+ "model-value": ((N = unref(l)) == null ? void 0 : N.collectibleConfig) ?? void 0,
1452
+ "onUpdate:modelValue": v[5] || (v[5] = (B) => l.value = {
1453
+ ...unref(l),
1454
+ collectibleConfig: B
1455
+ }),
1456
+ "onUpdate:rewardImage": v[6] || (v[6] = (B) => o.value = B)
1457
+ }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
1458
+ createVNode(JsonViewer, { json: unref(p) }, null, 8, ["json"])
1459
+ ])) : createCommentVNode("", !0)
1460
+ ];
1461
+ }),
1462
+ _: 1
1463
+ }, 8, ["modelValue"]);
1464
+ };
1465
+ }
1466
+ });
1467
+ function isNullOrEmpty(e) {
1468
+ return e == null || e === "";
1469
+ }
1470
+ const _hoisted_1$c = { class: "space-y-16" }, _hoisted_2$9 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$7 = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$6 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _sfc_main$c = /* @__PURE__ */ defineComponent({
1471
+ __name: "RewardPoolInput",
1472
+ props: {
1473
+ modelValue: {
1474
+ type: Array,
1475
+ default: () => [
1476
+ {
1477
+ collectible: null,
1478
+ type: "NO_REWARD",
1479
+ weight: 1
1480
+ }
1481
+ ]
1482
+ }
1483
+ },
1484
+ emits: ["update:model-value"],
1485
+ setup(e, { emit: m }) {
1486
+ const a = e, u = m, d = useMembershipStore(), { t: s } = useI18n(), l = z.array(z.lazy(() => FdtoRandomReward)).min(1, "Requires at least 1 reward"), o = computed(() => a.modelValue ?? []), n = computed(() => {
1487
+ const v = l.safeParse(o.value);
1488
+ return v.success ? [] : v.error.errors;
1489
+ }), r = ref();
1490
+ function p(v, f) {
1491
+ var c;
1492
+ const i = [...o.value];
1493
+ i[f] = v, (c = r.value) == null || c.showSheet(!1), u("update:model-value", i);
1494
+ }
1495
+ function h(v) {
1496
+ const f = v.type == "VOUCHER" ? v.collectibleConfig : d.collectibles.find(
1497
+ (k) => k._id.toString() == v.collectible
1498
+ ), i = CollectionUtils.formattedType((f == null ? void 0 : f.name) || ""), c = v.weight;
1499
+ return {
1500
+ label: isNullOrEmpty(i) ? "NO REWARD" : i,
1501
+ sublabel: `${c} (${(c / o.value.reduce((k, b) => k + b.weight, 0) * 100).toFixed(2)}%)`
1502
+ };
1503
+ }
1504
+ function y(v) {
1505
+ var i;
1506
+ const f = [...o.value];
1507
+ (i = r.value) == null || i.showSheet(!0, f[v], v);
1508
+ }
1509
+ function C(v) {
1510
+ const f = [...o.value];
1511
+ f.splice(v, 1), u("update:model-value", f);
1512
+ }
1513
+ function x() {
1514
+ var v;
1515
+ (v = r.value) == null || v.showSheet(
1516
+ !0,
1517
+ {
1518
+ type: "NO_REWARD",
1519
+ collectible: null,
1520
+ weight: 1
1521
+ },
1522
+ o.value.length
1523
+ );
1524
+ }
1525
+ return (v, f) => {
1526
+ const i = resolveComponent("FmButton"), c = resolveComponent("FmCard"), k = resolveComponent("FmHelperText");
1527
+ return openBlock(), createElementBlock("div", _hoisted_1$c, [
1528
+ createElementVNode("div", _hoisted_2$9, toDisplayString(unref(s)("connect.template.configure_reward_type")), 1),
1529
+ createVNode(i, {
1530
+ label: unref(s)("connect.campaign.rewardPool.addReward"),
1531
+ onClick: f[0] || (f[0] = (b) => x()),
1532
+ variant: "plain",
1533
+ icon: "add"
1534
+ }, null, 8, ["label"]),
1535
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(o), (b, E) => (openBlock(), createBlock(c, {
1536
+ key: E,
1537
+ class: "px-16 py-12 flex items-center justify-between cursor-pointer",
1538
+ variant: "outlined",
1539
+ onClick: (N) => y(E)
1540
+ }, {
1541
+ default: withCtx(() => {
1542
+ var N;
1543
+ return [
1544
+ createElementVNode("div", null, [
1545
+ createElementVNode("div", _hoisted_3$7, toDisplayString(b.type == "LOYALTY" ? (N = b == null ? void 0 : b.earningOption) == null ? void 0 : N.amount : "") + " " + toDisplayString(h(b).label), 1),
1546
+ createElementVNode("div", _hoisted_4$6, toDisplayString(h(b).sublabel), 1)
1547
+ ]),
1548
+ createVNode(i, {
1549
+ icon: "delete",
1550
+ variant: "tertiary",
1551
+ onClick: (B) => (B.stopPropagation(), C(E))
1552
+ }, null, 8, ["onClick"])
1553
+ ];
1554
+ }),
1555
+ _: 2
1556
+ }, 1032, ["onClick"]))), 128)),
1557
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n).filter((b) => b.path.join(".") == ""), (b) => (openBlock(), createBlock(k, {
1558
+ key: b.message,
1559
+ text: b.message,
1560
+ state: "error"
1561
+ }, null, 8, ["text"]))), 128)),
1562
+ createVNode(_sfc_main$d, {
1563
+ ref_key: "sheetRef",
1564
+ ref: r,
1565
+ "onUpdate:modelValue": p
1566
+ }, null, 512)
1567
+ ]);
1568
+ };
1569
+ }
1570
+ }), _hoisted_1$b = { class: "space-y-16" }, _hoisted_2$8 = {
1571
+ key: 0,
1572
+ class: "grid grid-cols-2 gap-16"
1573
+ }, _hoisted_3$6 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$5 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$b = /* @__PURE__ */ defineComponent({
1574
+ __name: "PromotionGameTypeInput",
1575
+ props: {
1576
+ modelValue: {
1577
+ type: Object
1578
+ }
1579
+ },
1580
+ emits: ["update:model-value"],
1581
+ setup(e, { emit: m }) {
1582
+ const { t: a } = useI18n(), u = e, d = m, s = computed(() => [
1583
+ {
1584
+ label: a("connect.template.promotion_game.rock_paper_scissors.label"),
1585
+ description: a("connect.template.promotion_game.rock_paper_scissors.description"),
1586
+ value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS
1587
+ }
1588
+ ]);
1589
+ return (l, o) => {
1590
+ var h, y, C;
1591
+ const n = resolveComponent("FmSwitch"), r = resolveComponent("FmCard"), p = resolveComponent("FmHelperText");
1592
+ return openBlock(), createElementBlock("div", _hoisted_1$b, [
1593
+ createVNode(n, {
1594
+ label: unref(a)("connect.template.promotion_game.enable"),
1595
+ "model-value": !!((h = e.modelValue) != null && h.gameType),
1596
+ "onUpdate:modelValue": o[0] || (o[0] = (x) => x ? d("update:model-value", { gameType: "ROCK_PAPER_SCISSORS" }) : d("update:model-value", null))
1597
+ }, null, 8, ["label", "model-value"]),
1598
+ ((y = e.modelValue) == null ? void 0 : y.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createElementBlock("div", _hoisted_2$8, [
1599
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(s), (x) => {
1600
+ var v, f;
1601
+ return openBlock(), createBlock(r, {
1602
+ variant: "outlined",
1603
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1604
+ "col-span-2": unref(s).length == 1,
1605
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((v = e.modelValue) == null ? void 0 : v.gameType) == x.value,
1606
+ "hover:bg-fm-color-opacity-sm": ((f = e.modelValue) == null ? void 0 : f.gameType) != x.value
1607
+ }]),
1608
+ onClick: () => {
1609
+ var i;
1610
+ ((i = u.modelValue) == null ? void 0 : i.gameType) != x.value && d("update:model-value", { gameType: x.value });
1611
+ },
1612
+ key: x.value
1613
+ }, {
1614
+ default: withCtx(() => [
1615
+ createElementVNode("div", _hoisted_3$6, toDisplayString(x.label), 1),
1616
+ createElementVNode("div", _hoisted_4$5, toDisplayString(x.description), 1)
1617
+ ]),
1618
+ _: 2
1619
+ }, 1032, ["class", "onClick"]);
1620
+ }), 128))
1621
+ ])) : createCommentVNode("", !0),
1622
+ ((C = e.modelValue) == null ? void 0 : C.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createBlock(p, {
1623
+ key: 1,
1624
+ text: unref(a)("connect.template.promotion_game.rock_paper_scissors.warning"),
1625
+ state: "warning"
1626
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
1627
+ ]);
1628
+ };
1629
+ }
1630
+ }), _hoisted_1$a = { class: "space-y-8" }, _hoisted_2$7 = { class: "grid gap-16 grid-cols-2" }, _hoisted_3$5 = { class: "space-y-6" }, _hoisted_4$4 = { class: "space-y-8" }, _hoisted_5$4 = { class: "fm-typo-en-body-lg-600" }, _hoisted_6$3 = { class: "flex items-center space-x-3" }, _hoisted_7$3 = {
1631
+ key: 0,
1632
+ class: "ml-6 space-y-2"
1633
+ }, _sfc_main$a = /* @__PURE__ */ defineComponent({
1634
+ __name: "GrabConditionsInput",
1635
+ props: {
1636
+ modelValue: {
1637
+ type: Object
1638
+ },
1639
+ schema: {
1640
+ type: Object,
1641
+ default: () => z.any()
1642
+ }
1643
+ },
1644
+ emits: ["update:model-value"],
1645
+ setup(e, { emit: m }) {
1646
+ const { t: a } = useI18n(), u = e, d = m, s = ref(u.modelValue ?? {}), l = ref(
1647
+ (() => {
1648
+ const h = {};
1649
+ return s.value.workingHour && Object.keys(s.value.workingHour).forEach((y) => {
1650
+ const C = s.value.workingHour[y];
1651
+ C && "periods" in C && Array.isArray(C.periods) ? h[y] = C.periods : Array.isArray(C) && (h[y] = C);
1652
+ }), h;
1653
+ })()
1654
+ ), o = [
1655
+ { key: "mon", label: "Monday" },
1656
+ { key: "tue", label: "Tuesday" },
1657
+ { key: "wed", label: "Wednesday" },
1658
+ { key: "thu", label: "Thursday" },
1659
+ { key: "fri", label: "Friday" },
1660
+ { key: "sat", label: "Saturday" },
1661
+ { key: "sun", label: "Sunday" }
1662
+ ], n = (h) => {
1663
+ l.value[h] || (l.value[h] = []), l.value[h].push({
1664
+ startTime: "00:00",
1665
+ endTime: "23:59"
1666
+ }), p();
1667
+ }, r = (h, y) => {
1668
+ l.value[h] && l.value[h].length > y && (l.value[h].splice(y, 1), l.value[h].length === 0 && delete l.value[h], p());
1669
+ }, p = () => {
1670
+ const h = Object.keys(l.value).reduce(
1671
+ (y, C) => (l.value[C] && l.value[C].length > 0 && (y[C] = {
1672
+ periods: l.value[C]
1673
+ }), y),
1674
+ {}
1675
+ );
1676
+ s.value.workingHour = Object.keys(h).length > 0 ? h : void 0;
1677
+ };
1678
+ return watch(s, () => d("update:model-value", s.value), { deep: !0 }), watch(l, p, { deep: !0 }), (h, y) => {
1679
+ const C = resolveComponent("FmSelect"), x = resolveComponent("FmStepperField"), v = resolveComponent("FmCheckbox"), f = resolveComponent("FmTimePicker"), i = resolveComponent("FmButton");
1680
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
1681
+ createElementVNode("div", _hoisted_2$7, [
1682
+ createVNode(C, {
1683
+ label: unref(a)("connect.template.eaterType"),
1684
+ modelValue: unref(s).eaterType,
1685
+ "onUpdate:modelValue": y[0] || (y[0] = (c) => unref(s).eaterType = c),
1686
+ items: [
1687
+ { label: unref(a)("connect.template.allEaters"), value: "all" },
1688
+ { label: unref(a)("connect.template.newEatersOnly"), value: "new" },
1689
+ {
1690
+ label: unref(a)("connect.template.existingEatersOnly"),
1691
+ value: "existing"
1692
+ }
1693
+ ],
1694
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "eaterType")]
1695
+ }, null, 8, ["label", "modelValue", "items", "rules"]),
1696
+ createVNode(x, {
1697
+ modelValue: unref(s).minBasketAmount,
1698
+ "onUpdate:modelValue": y[1] || (y[1] = (c) => unref(s).minBasketAmount = c),
1699
+ "show-steppers": !1,
1700
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "minBasketAmount")]
1701
+ }, {
1702
+ label: withCtx(() => [
1703
+ (openBlock(), createBlock(resolveDynamicComponent(
1704
+ unref(ZodHelper).toInputLabel(
1705
+ unref(ZodHelper).typeAtPath(e.schema, "minBasketAmount"),
1706
+ unref(a)("connect.template.minBasketAmount")
1707
+ )
1708
+ )))
1709
+ ]),
1710
+ _: 1
1711
+ }, 8, ["modelValue", "rules"]),
1712
+ createVNode(x, {
1713
+ modelValue: unref(s).bundleQuantity,
1714
+ "onUpdate:modelValue": y[2] || (y[2] = (c) => unref(s).bundleQuantity = c),
1715
+ "show-steppers": !1,
1716
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "bundleQuantity")]
1717
+ }, {
1718
+ label: withCtx(() => [
1719
+ (openBlock(), createBlock(resolveDynamicComponent(
1720
+ unref(ZodHelper).toInputLabel(
1721
+ unref(ZodHelper).typeAtPath(e.schema, "bundleQuantity"),
1722
+ unref(a)("connect.template.bundleQuantity")
1723
+ )
1724
+ )))
1725
+ ]),
1726
+ _: 1
1727
+ }, 8, ["modelValue", "rules"])
1728
+ ]),
1729
+ createElementVNode("div", _hoisted_3$5, [
1730
+ createElementVNode("div", _hoisted_4$4, [
1731
+ createElementVNode("div", _hoisted_5$4, toDisplayString(unref(a)("connect.template.operationHours")), 1),
1732
+ (openBlock(), createElementBlock(Fragment, null, renderList(o, (c) => createElementVNode("div", {
1733
+ key: c.key,
1734
+ class: "space-y-2"
1735
+ }, [
1736
+ createElementVNode("div", _hoisted_6$3, [
1737
+ createVNode(v, {
1738
+ label: c.label,
1739
+ "model-value": !!(unref(l)[c.key] && unref(l)[c.key].length > 0),
1740
+ "onUpdate:modelValue": (k) => {
1741
+ k ? n(c.key) : (unref(l)[c.key] = [], delete unref(l)[c.key], p());
1742
+ }
1743
+ }, null, 8, ["label", "model-value", "onUpdate:modelValue"])
1744
+ ]),
1745
+ unref(l)[c.key] && unref(l)[c.key].length > 0 ? (openBlock(), createElementBlock("div", _hoisted_7$3, [
1746
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(l)[c.key] || [], (k, b) => (openBlock(), createElementBlock("div", {
1747
+ key: b,
1748
+ class: "flex items-center space-x-2 w-100"
1749
+ }, [
1750
+ createVNode(f, {
1751
+ "model-value": k.startTime || "",
1752
+ "onUpdate:modelValue": (E) => {
1753
+ unref(l)[c.key] && unref(l)[c.key][b] && (unref(l)[c.key][b].startTime = E || "", p());
1754
+ }
1755
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
1756
+ y[3] || (y[3] = createElementVNode("span", null, "to", -1)),
1757
+ createVNode(f, {
1758
+ "model-value": k.endTime || "",
1759
+ "onUpdate:modelValue": (E) => {
1760
+ unref(l)[c.key] && unref(l)[c.key][b] && (unref(l)[c.key][b].endTime = E || "", p());
1761
+ }
1762
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
1763
+ createVNode(i, {
1764
+ variant: "tertiary",
1765
+ size: "sm",
1766
+ onClick: (E) => r(c.key, b),
1767
+ icon: "close"
1768
+ }, null, 8, ["onClick"]),
1769
+ b === 0 ? (openBlock(), createBlock(i, {
1770
+ key: 0,
1771
+ onClick: (E) => n(c.key),
1772
+ icon: "add",
1773
+ variant: "plain"
1774
+ }, null, 8, ["onClick"])) : createCommentVNode("", !0)
1775
+ ]))), 128))
1776
+ ])) : createCommentVNode("", !0)
1777
+ ])), 64))
1778
+ ])
1779
+ ])
1780
+ ]);
1781
+ };
1782
+ }
1783
+ }), GrabConditionsInput = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["__scopeId", "data-v-7f17ebe8"]]), _hoisted_1$9 = { class: "space-y-8" }, _hoisted_2$6 = { class: "grid gap-16 grid-cols-2" }, _sfc_main$9 = /* @__PURE__ */ defineComponent({
1784
+ __name: "GrabQuotaInput",
1785
+ props: {
1786
+ modelValue: {
1787
+ type: Object
1788
+ },
1789
+ schema: {
1790
+ type: Object,
1791
+ default: () => z.any()
1792
+ }
1793
+ },
1794
+ emits: ["update:model-value"],
1795
+ setup(e, { emit: m }) {
1796
+ const { t: a } = useI18n(), u = e, d = m, s = ref(u.modelValue ?? {});
1797
+ return watch(s, () => d("update:model-value", s.value)), (l, o) => {
1798
+ const n = resolveComponent("FmStepperField");
1799
+ return openBlock(), createElementBlock("div", _hoisted_1$9, [
1800
+ createElementVNode("div", _hoisted_2$6, [
1801
+ createVNode(n, {
1802
+ modelValue: unref(s).totalCount,
1803
+ "onUpdate:modelValue": o[0] || (o[0] = (r) => unref(s).totalCount = r),
1804
+ "show-steppers": !1,
1805
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "totalCount")]
1806
+ }, {
1807
+ label: withCtx(() => [
1808
+ (openBlock(), createBlock(resolveDynamicComponent(
1809
+ unref(ZodHelper).toInputLabel(
1810
+ unref(ZodHelper).typeAtPath(e.schema, "totalCount"),
1811
+ unref(a)("connect.template.totalCount")
1812
+ )
1813
+ )))
1814
+ ]),
1815
+ _: 1
1816
+ }, 8, ["modelValue", "rules"]),
1817
+ createVNode(n, {
1818
+ modelValue: unref(s).totalCountPerUser,
1819
+ "onUpdate:modelValue": o[1] || (o[1] = (r) => unref(s).totalCountPerUser = r),
1820
+ "show-steppers": !1,
1821
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "totalCountPerUser")]
1822
+ }, {
1823
+ label: withCtx(() => [
1824
+ (openBlock(), createBlock(resolveDynamicComponent(
1825
+ unref(ZodHelper).toInputLabel(
1826
+ unref(ZodHelper).typeAtPath(e.schema, "totalCountPerUser"),
1827
+ unref(a)("connect.template.totalCountPerUser")
1828
+ )
1829
+ )))
1830
+ ]),
1831
+ _: 1
1832
+ }, 8, ["modelValue", "rules"])
1833
+ ])
1834
+ ]);
1835
+ };
1836
+ }
1837
+ }), _hoisted_1$8 = { class: "space-y-16" }, _hoisted_2$5 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$4 = { class: "grid grid-cols-2 gap-16" }, _hoisted_4$3 = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$3 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$8 = /* @__PURE__ */ defineComponent({
1838
+ __name: "MissionTypeInput",
1839
+ props: {
1840
+ modelValue: {
1841
+ type: String
1842
+ }
1843
+ },
1844
+ emits: ["update:model-value"],
1845
+ setup(e, { emit: m }) {
1846
+ const { t: a } = useI18n(), u = e, d = m, s = computed(() => [
1847
+ {
1848
+ label: a("connect.campaign.mission.typeOption.STAMP.label"),
1849
+ description: a("connect.campaign.mission.typeOption.STAMP.description"),
1850
+ value: F_MISSION_TYPE.enum.STAMP
1851
+ },
1852
+ {
1853
+ label: a("connect.campaign.mission.typeOption.PROGRESSIVE.label"),
1854
+ description: a("connect.campaign.mission.typeOption.PROGRESSIVE.description"),
1855
+ value: F_MISSION_TYPE.enum.PROGRESSIVE
1856
+ }
1857
+ ]);
1858
+ return (l, o) => {
1859
+ const n = resolveComponent("FmCard");
1860
+ return openBlock(), createElementBlock("div", _hoisted_1$8, [
1861
+ createElementVNode("div", _hoisted_2$5, toDisplayString(unref(a)("connect.template.select_game")), 1),
1862
+ createElementVNode("div", _hoisted_3$4, [
1863
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(s), (r) => (openBlock(), createBlock(n, {
1864
+ variant: "outlined",
1865
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1866
+ "col-span-2": unref(s).length == 1,
1867
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == r.value,
1868
+ "hover:bg-fm-color-opacity-sm": e.modelValue != r.value
1869
+ }]),
1870
+ onClick: () => {
1871
+ u.modelValue != r.value && d("update:model-value", r.value);
1872
+ },
1873
+ key: r.value
1874
+ }, {
1875
+ default: withCtx(() => [
1876
+ createElementVNode("div", _hoisted_4$3, toDisplayString(r.label), 1),
1877
+ createElementVNode("div", _hoisted_5$3, toDisplayString(r.description), 1)
1878
+ ]),
1879
+ _: 2
1880
+ }, 1032, ["class", "onClick"]))), 128))
1881
+ ])
1882
+ ]);
1883
+ };
1884
+ }
1885
+ }), _hoisted_1$7 = { class: "space-y-16" }, _sfc_main$7 = /* @__PURE__ */ defineComponent({
1886
+ __name: "MissionEndInput",
1887
+ props: {
1888
+ modelValue: {
1889
+ type: [String, Number]
1890
+ },
1891
+ helperText: {
1892
+ type: String
1893
+ },
1894
+ helperState: {
1895
+ type: String
1896
+ }
1897
+ },
1898
+ emits: ["update:model-value"],
1899
+ setup(e, { emit: m }) {
1900
+ const a = m;
1901
+ return (u, d) => {
1902
+ const s = resolveComponent("FmStepperField");
1903
+ return openBlock(), createElementBlock("div", _hoisted_1$7, [
1904
+ d[1] || (d[1] = createElementVNode("div", { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, " Input the total number of stamps needed to complete the mission ", -1)),
1905
+ createVNode(s, {
1906
+ label: "Maximum to collect",
1907
+ "model-value": e.modelValue || null,
1908
+ "onUpdate:modelValue": d[0] || (d[0] = (l) => a("update:model-value", l)),
1909
+ "helper-text": e.helperText || "Set the threshold required for reward eligibility",
1910
+ "helper-state": e.helperState || "none"
1911
+ }, null, 8, ["model-value", "helper-text", "helper-state"])
1912
+ ]);
1913
+ };
1914
+ }
1915
+ }), _hoisted_1$6 = { class: "flex gap-8 items-center justify-start" }, _sfc_main$6 = /* @__PURE__ */ defineComponent({
1916
+ __name: "EditMissionPoolSheet",
1917
+ props: {
1918
+ maxThreshold: {
1919
+ type: Number,
1920
+ required: !0
1921
+ }
1922
+ },
1923
+ emits: ["update:model-value"],
1924
+ setup(e, { expose: m, emit: a }) {
1925
+ const u = e, d = useMembershipStore(), { minor: s } = useLoading, l = ref(!1), o = ref(), n = ref(), r = ref(0), p = computed(() => {
1926
+ var i;
1927
+ return ((i = d.loyaltyRewards.items.find(
1928
+ (c) => {
1929
+ var k;
1930
+ return c.value === ((k = o.value) == null ? void 0 : k.collectible);
1931
+ }
1932
+ )) == null ? void 0 : i.raw.type) === "CREDIT" ? FdoThresholdCreditReward : FdtoThresholdReward;
1933
+ }), h = computed(() => {
1934
+ const f = p.value.safeParse(o.value);
1935
+ return f.success ? [] : f.error.errors;
1936
+ });
1937
+ function y(f, i, c) {
1938
+ f && (o.value = i, r.value = c), l.value = f;
1939
+ }
1940
+ const C = a;
1941
+ async function x() {
1942
+ const f = p.value.safeParse(o.value);
1943
+ f.success && (await s(
1944
+ async () => {
1945
+ f.data.type === "VOUCHER" && n.value && (f.data.collectibleConfig.image = await firebaseStorage.update(
1946
+ f.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, n.value),
1947
+ n.value
1948
+ ));
1949
+ },
1950
+ {
1951
+ message: "Uploading reward image",
1952
+ successMessage: "Reward image updated"
1953
+ }
1954
+ ), C("update:model-value", f.data, r.value));
1955
+ }
1956
+ const v = ref();
1957
+ return m({
1958
+ showSheet: y
1959
+ }), (f, i) => {
1960
+ const c = resolveComponent("FmStepperField"), k = resolveComponent("FmSelect"), b = resolveComponent("FmForm"), E = resolveComponent("FmButton"), N = resolveComponent("FmSideSheet");
1961
+ return openBlock(), createBlock(N, {
1962
+ "max-width": 560,
1963
+ modelValue: unref(l),
1964
+ "onUpdate:modelValue": [
1965
+ i[10] || (i[10] = (B) => isRef(l) ? l.value = B : null),
1966
+ i[11] || (i[11] = (B) => l.value = B)
1967
+ ],
1968
+ header: "Edit reward",
1969
+ "dismiss-away": ""
1970
+ }, {
1971
+ "side-sheet-footer": withCtx(() => [
1972
+ createElementVNode("div", _hoisted_1$6, [
1973
+ createVNode(E, {
1974
+ variant: "primary",
1975
+ type: "button",
1976
+ label: "Confirm",
1977
+ disabled: unref(h).length > 0,
1978
+ onClick: i[8] || (i[8] = async () => {
1979
+ var B;
1980
+ return (B = unref(v)) == null ? void 0 : B.validateInputs();
1981
+ })
1982
+ }, null, 8, ["disabled"]),
1983
+ createVNode(E, {
1984
+ variant: "secondary",
1985
+ type: "button",
1986
+ label: "Cancel",
1987
+ onClick: i[9] || (i[9] = (B) => l.value = !1)
1988
+ })
1989
+ ])
1990
+ ]),
1991
+ default: withCtx(() => [
1992
+ createVNode(JsonViewer, { json: unref(o) }, null, 8, ["json"]),
1993
+ unref(o) ? (openBlock(), createBlock(b, {
1994
+ key: 0,
1995
+ class: "flex flex-col gap-y-24",
1996
+ ref_key: "formRef",
1997
+ ref: v,
1998
+ onValidationSuccess: i[7] || (i[7] = (B) => x())
1999
+ }, {
2000
+ default: withCtx(() => {
2001
+ var B, w;
2002
+ return [
2003
+ unref(o).type ? (openBlock(), createBlock(c, {
2004
+ key: 0,
2005
+ label: "Threshold",
2006
+ rules: [
2007
+ unref(ZodHelper).toRule(
2008
+ unref(z).number().min(1).max(
2009
+ u.maxThreshold,
2010
+ `Number cannot be more than ${u.maxThreshold}`
2011
+ )
2012
+ )
2013
+ ],
2014
+ "model-value": unref(o).threshold,
2015
+ "onUpdate:modelValue": i[0] || (i[0] = (S) => o.value = {
2016
+ ...unref(o),
2017
+ threshold: S
2018
+ })
2019
+ }, null, 8, ["rules", "model-value"])) : createCommentVNode("", !0),
2020
+ createVNode(k, {
2021
+ label: "Reward Type",
2022
+ items: [
2023
+ { label: "Voucher", value: "VOUCHER" },
2024
+ { label: "Loyalty", value: "LOYALTY" }
2025
+ ],
2026
+ "model-value": unref(o).type,
2027
+ "onUpdate:modelValue": i[1] || (i[1] = (S) => {
2028
+ var F, U;
2029
+ S === "VOUCHER" ? o.value = {
2030
+ collectible: null,
2031
+ type: "VOUCHER",
2032
+ collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
2033
+ business: unref(useCoreStore)().currentBusiness.value._id
2034
+ }),
2035
+ earningOption: {
2036
+ amount: 1,
2037
+ type: "FIXED"
2038
+ },
2039
+ validityOption: {
2040
+ validForDay: 7
2041
+ },
2042
+ threshold: (F = unref(o)) == null ? void 0 : F.threshold
2043
+ } : o.value = {
2044
+ collectible: unref(d).loyaltyRewards.raw[0]._id,
2045
+ type: "LOYALTY",
2046
+ earningOption: {
2047
+ amount: 1,
2048
+ type: "FIXED"
2049
+ },
2050
+ validityOption: {
2051
+ validForDay: 7
2052
+ },
2053
+ threshold: (U = unref(o)) == null ? void 0 : U.threshold
2054
+ };
2055
+ })
2056
+ }, null, 8, ["model-value"]),
2057
+ unref(o).type == "LOYALTY" ? (openBlock(), createBlock(k, {
2058
+ key: 1,
2059
+ label: "Loyalty type",
2060
+ rules: [unref(ZodHelper).ruleAtPath(unref(p), "collectible", [unref(o).type])],
2061
+ items: unref(d).loyaltyRewards.items,
2062
+ "model-value": unref(o).collectible,
2063
+ "onUpdate:modelValue": i[2] || (i[2] = (S) => unref(o).collectible = S)
2064
+ }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
2065
+ unref(o).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
2066
+ i[12] || (i[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
2067
+ createVNode(_sfc_main$r, {
2068
+ class: "mt-[-8px]",
2069
+ rules: [unref(ZodHelper).ruleAtPath(unref(p), "earningOption", [unref(o).type])],
2070
+ "helper-state": unref(ZodHelper).helperState(unref(h), "earningOption"),
2071
+ "error-text": unref(ZodHelper).helperText(unref(h), "earningOption"),
2072
+ "fixed-type": !0,
2073
+ "model-value": unref(o).earningOption,
2074
+ "onUpdate:modelValue": i[3] || (i[3] = (S) => o.value = {
2075
+ ...unref(o),
2076
+ earningOption: S
2077
+ })
2078
+ }, null, 8, ["rules", "helper-state", "error-text", "model-value"]),
2079
+ createVNode(_sfc_main$s, {
2080
+ class: "!gap-24",
2081
+ type: unref(o).type === "LOYALTY" ? "custom" : "range",
2082
+ "for-credit": unref(o).type === "LOYALTY" && ((B = unref(d).loyaltyRewards.items.find(
2083
+ (S) => {
2084
+ var F;
2085
+ return S.value === ((F = unref(o)) == null ? void 0 : F.collectible);
2086
+ }
2087
+ )) == null ? void 0 : B.raw.type) === "CREDIT",
2088
+ rules: [unref(ZodHelper).ruleAtPath(unref(p), "validityOption", [unref(o).type])],
2089
+ "model-value": unref(o).validityOption,
2090
+ "onUpdate:modelValue": i[4] || (i[4] = (S) => o.value = {
2091
+ ...unref(o),
2092
+ validityOption: S
2093
+ })
2094
+ }, null, 8, ["type", "for-credit", "rules", "model-value"])
2095
+ ], 64)) : createCommentVNode("", !0),
2096
+ unref(o).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$t, {
2097
+ key: 3,
2098
+ "reward-image": unref(n),
2099
+ "model-value": ((w = unref(o)) == null ? void 0 : w.collectibleConfig) ?? void 0,
2100
+ "onUpdate:modelValue": i[5] || (i[5] = (S) => o.value = {
2101
+ ...unref(o),
2102
+ collectibleConfig: S
2103
+ }),
2104
+ "onUpdate:rewardImage": i[6] || (i[6] = (S) => n.value = S)
2105
+ }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
2106
+ createVNode(JsonViewer, { json: unref(h) }, null, 8, ["json"])
2107
+ ];
2108
+ }),
2109
+ _: 1
2110
+ }, 512)) : createCommentVNode("", !0)
2111
+ ]),
2112
+ _: 1
2113
+ }, 8, ["modelValue"]);
2114
+ };
2115
+ }
2116
+ }), _hoisted_1$5 = {
2117
+ key: 0,
2118
+ class: "grid grid-cols-5 text-center gap-8 justify-between items-center w-full"
2119
+ }, _hoisted_2$4 = { class: "flex flex-col gap-0 items-center justify-center" }, _sfc_main$5 = /* @__PURE__ */ defineComponent({
2120
+ __name: "MissionProgress",
2121
+ props: {
2122
+ type: {
2123
+ type: String,
2124
+ required: !0
2125
+ },
2126
+ maxRange: {
2127
+ type: Number,
2128
+ required: !0
2129
+ },
2130
+ currentRange: {
2131
+ type: Number,
2132
+ default: 0
2133
+ },
2134
+ markers: {
2135
+ type: Array,
2136
+ default: () => []
2137
+ }
2138
+ },
2139
+ setup(e) {
2140
+ const m = e, { maxRange: a, currentRange: u, markers: d } = toRefs(m), s = computed(
2141
+ () => Math.min(u.value / a.value * 100, 100)
2142
+ ), l = (o) => o / a.value * 100;
2143
+ return (o, n) => {
2144
+ const r = resolveComponent("FmIcon");
2145
+ return e.type === "STAMP" ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
2146
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(Math.min(unref(a), 40), (p) => (openBlock(), createBlock(r, {
2147
+ class: normalizeClass(
2148
+ unref(u) >= p ? "text-fm-color-primary" : "text-fm-color-neutral-gray-200"
2149
+ ),
2150
+ outline: unref(u) < p,
2151
+ key: p,
2152
+ name: unref(d).some((h) => h === p) ? "featured_seasonal_and_gifts" : "check_circle"
2153
+ }, null, 8, ["class", "outline", "name"]))), 128))
2154
+ ])) : (openBlock(), createElementBlock("div", {
2155
+ key: 1,
2156
+ class: normalizeClass(["relative w-full h-4 rounded-lg", "bg-fm-color-system-warning-100"])
2157
+ }, [
2158
+ createElementVNode("div", {
2159
+ class: normalizeClass(["bg-fm-color-primary", "absolute top-0 left-0 h-full rounded-lg"]),
2160
+ style: normalizeStyle({ width: unref(s) + "%" })
2161
+ }, null, 4),
2162
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(d), (p, h) => (openBlock(), createElementBlock("div", {
2163
+ key: h,
2164
+ class: "absolute -top-1.5 flex flex-col items-center -translate-x-1/2",
2165
+ style: normalizeStyle({ left: l(p) + "%" })
2166
+ }, [
2167
+ createElementVNode("div", _hoisted_2$4, [
2168
+ createElementVNode("div", {
2169
+ class: normalizeClass(["h-16 w-[2px]", "bg-fm-color-system-warning-300"])
2170
+ }),
2171
+ n[0] || (n[0] = createElementVNode("div", null, "🎁", -1))
2172
+ ])
2173
+ ], 4))), 128))
2174
+ ]));
2175
+ };
2176
+ }
2177
+ }), isObject = (e) => e !== null && typeof e == "object";
2178
+ function changeKeysFactory(e) {
2179
+ return function m(a, u = 1, d) {
2180
+ if (u === 0 || !isObject(a))
2181
+ return a;
2182
+ if (Array.isArray(a))
2183
+ return a.map((l) => m(l, u - 1, d));
2184
+ const s = Object.create(Object.getPrototypeOf(a));
2185
+ return Object.keys(a).forEach((l) => {
2186
+ const o = a[l], n = e(l, d), r = m(o, u - 1, d);
2187
+ s[n] = r;
2188
+ }), s;
2189
+ };
2190
+ }
2191
+ const sentenceCase = changeKeysFactory(sentenceCase$1), _hoisted_1$4 = { class: "space-y-16" }, _hoisted_2$3 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$3 = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$2 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_5$2 = { class: "fm-typo-en-title-sm-800" }, _hoisted_6$2 = { class: "flex items-center gap-4" }, _hoisted_7$2 = { class: "fm-typo-en-body-lg-600" }, _hoisted_8$2 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_9$2 = { class: "flex items-center gap-16" }, _hoisted_10$2 = { key: 0 }, _sfc_main$4 = /* @__PURE__ */ defineComponent({
2192
+ __name: "MissionPoolInput",
2193
+ props: {
2194
+ modelValue: {
2195
+ type: Array,
2196
+ default: () => []
2197
+ },
2198
+ mission: {
2199
+ type: Object,
2200
+ required: !0
2201
+ }
2202
+ },
2203
+ emits: ["update:model-value"],
2204
+ setup(e, { emit: m }) {
2205
+ const { t: a } = useI18n(), u = e, d = m, s = useMembershipStore(), l = z.array(z.lazy(() => FdtoThresholdReward)).min(1, "Requires at least 1 reward"), o = computed(
2206
+ () => u.modelValue.sort((f, i) => f.threshold - i.threshold) ?? []
2207
+ ), n = computed(() => {
2208
+ const f = l.safeParse(o.value);
2209
+ return f.success ? [] : f.error.errors;
2210
+ }), r = ref();
2211
+ function p(f, i) {
2212
+ var k;
2213
+ const c = [...o.value];
2214
+ c[i] = f, (k = r.value) == null || k.showSheet(!1), d("update:model-value", c);
2215
+ }
2216
+ function h(f) {
2217
+ const i = f.type == "VOUCHER" ? f.collectibleConfig : s.collectibles.find(
2218
+ (b) => b._id.toString() == f.collectible
2219
+ ), c = CollectionUtils.formattedType((i == null ? void 0 : i.name) || ""), k = f.earningOption.type == "FIXED" ? a("connect.template.mission_pool.reward_sublabel_fixed", {
2220
+ threshold: f.threshold,
2221
+ amount: f.earningOption.amount
2222
+ }) : a("connect.template.mission_pool.reward_sublabel_per_spend", {
2223
+ threshold: f.threshold,
2224
+ amount: f.earningOption.amount,
2225
+ every: f.earningOption.every
2226
+ });
2227
+ return {
2228
+ label: isNullOrEmpty(c) ? a("connect.template.mission_pool.no_reward") : c,
2229
+ sublabel: k
2230
+ };
2231
+ }
2232
+ function y(f) {
2233
+ var c;
2234
+ const i = [...o.value];
2235
+ (c = r.value) == null || c.showSheet(!0, i[f], f);
2236
+ }
2237
+ function C(f) {
2238
+ const i = [...o.value];
2239
+ i.splice(f, 1), d("update:model-value", i);
2240
+ }
2241
+ function x() {
2242
+ var f;
2243
+ (f = r.value) == null || f.showSheet(
2244
+ !0,
2245
+ {
2246
+ type: "LOYALTY",
2247
+ collectible: s.loyaltyRewards.items[0].value,
2248
+ threshold: null,
2249
+ validityOption: {
2250
+ validForDay: 7
2251
+ },
2252
+ earningOption: {
2253
+ type: "FIXED",
2254
+ amount: 1
2255
+ }
2256
+ },
2257
+ o.value.length
2258
+ );
2259
+ }
2260
+ function v(f) {
2261
+ var i, c;
2262
+ return f.type == "VOUCHER" ? (i = f.collectibleConfig) == null ? void 0 : i.name : sentenceCase(
2263
+ ((c = s.loyaltyRewards.items.find(
2264
+ (k) => k.value == f.collectible
2265
+ )) == null ? void 0 : c.label) || ""
2266
+ );
2267
+ }
2268
+ return (f, i) => {
2269
+ const c = resolveComponent("FmButton"), k = resolveComponent("FmCard"), b = resolveComponent("FmHelperText");
2270
+ return openBlock(), createElementBlock("div", _hoisted_1$4, [
2271
+ createElementVNode("div", _hoisted_2$3, toDisplayString(unref(a)("connect.template.configure_reward_customer")), 1),
2272
+ createVNode(c, {
2273
+ label: unref(a)("connect.template.mission_pool.add_reward"),
2274
+ onClick: i[0] || (i[0] = (E) => x()),
2275
+ variant: "plain",
2276
+ icon: "add"
2277
+ }, null, 8, ["label"]),
2278
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(o), (E, N) => (openBlock(), createBlock(k, {
2279
+ key: N,
2280
+ class: "px-16 py-12 flex items-center justify-between cursor-pointer",
2281
+ variant: "outlined",
2282
+ onClick: (B) => y(N)
2283
+ }, {
2284
+ default: withCtx(() => [
2285
+ createElementVNode("div", null, [
2286
+ createElementVNode("div", _hoisted_3$3, toDisplayString(h(E).label), 1),
2287
+ createElementVNode("div", _hoisted_4$2, toDisplayString(h(E).sublabel), 1)
2288
+ ]),
2289
+ createVNode(c, {
2290
+ icon: "delete",
2291
+ variant: "tertiary",
2292
+ onClick: (B) => (B.stopPropagation(), C(N))
2293
+ }, null, 8, ["onClick"])
2294
+ ]),
2295
+ _: 2
2296
+ }, 1032, ["onClick"]))), 128)),
2297
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n).filter((E) => E.path.join(".") == ""), (E) => (openBlock(), createBlock(b, {
2298
+ key: E.message,
2299
+ text: E.message,
2300
+ state: "error"
2301
+ }, null, 8, ["text"]))), 128)),
2302
+ createElementVNode("div", _hoisted_5$2, toDisplayString(unref(a)("connect.template.mission_pool.preview")), 1),
2303
+ (openBlock(), createBlock(k, {
2304
+ key: 0,
2305
+ variant: "outlined",
2306
+ class: "p-24 space-y-16 w-fit"
2307
+ }, {
2308
+ default: withCtx(() => {
2309
+ var E, N;
2310
+ return [
2311
+ createElementVNode("div", _hoisted_6$2, [
2312
+ createElementVNode("div", null, [
2313
+ createElementVNode("div", _hoisted_7$2, toDisplayString(unref(a)("connect.template.mission_pool.collect_stamps", { end: e.mission.end })) + " " + toDisplayString(((E = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : E.earningOption.amount) > 1 ? (N = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : N.earningOption.amount : "") + " " + toDisplayString(e.modelValue[e.modelValue.length - 1] ? v(e.modelValue[e.modelValue.length - 1]) : ""), 1),
2314
+ createElementVNode("div", _hoisted_8$2, toDisplayString(unref(a)("connect.template.mission_pool.earn_stamp")), 1)
2315
+ ])
2316
+ ]),
2317
+ createElementVNode("div", _hoisted_9$2, [
2318
+ createVNode(_sfc_main$5, {
2319
+ type: e.mission.type,
2320
+ "max-range": e.mission.end,
2321
+ currentRange: e.mission.end / 4,
2322
+ markers: e.modelValue.map((B) => B.threshold)
2323
+ }, null, 8, ["type", "max-range", "currentRange", "markers"]),
2324
+ e.mission.type == "PROGRESSIVE" ? (openBlock(), createElementBlock("div", _hoisted_10$2, " 0/" + toDisplayString(e.mission.end.toLocaleString()), 1)) : createCommentVNode("", !0)
2325
+ ])
2326
+ ];
2327
+ }),
2328
+ _: 1
2329
+ })),
2330
+ createVNode(_sfc_main$6, {
2331
+ ref_key: "sheetRef",
2332
+ ref: r,
2333
+ "onUpdate:modelValue": p,
2334
+ "max-threshold": e.mission.end
2335
+ }, null, 8, ["max-threshold"])
2336
+ ]);
2337
+ };
2338
+ }
2339
+ }), _hoisted_1$3 = { class: "space-y-16" }, _hoisted_2$2 = { class: "space-y-8" }, _hoisted_3$2 = { class: "fm-typo-en-title-sm-800" }, _hoisted_4$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_5$1 = { class: "grid grid-cols-2 gap-16" }, _hoisted_6$1 = { class: "fm-typo-en-title-sm-800" }, _hoisted_7$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_8$1 = { class: "space-y-8" }, _hoisted_9$1 = { class: "fm-typo-en-title-sm-800" }, _hoisted_10$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$3 = /* @__PURE__ */ defineComponent({
2340
+ __name: "MissionInput",
2341
+ props: {
2342
+ modelValue: Object
2343
+ },
2344
+ emits: ["update:model-value"],
2345
+ setup(e, { emit: m }) {
2346
+ const { t: a } = useI18n(), u = e, d = computed(() => {
2347
+ const o = FdoMission.safeParse(u.modelValue);
2348
+ return o.success ? [] : o.error.errors;
2349
+ }), s = computed(() => [
2350
+ {
2351
+ label: a("connect.campaign.mission.typeOption.STAMP.label"),
2352
+ description: a("connect.campaign.mission.typeOption.STAMP.description"),
2353
+ value: F_MISSION_TYPE.enum.STAMP
2354
+ },
2355
+ {
2356
+ label: a("connect.campaign.mission.typeOption.PROGRESSIVE.label"),
2357
+ description: a("connect.campaign.mission.typeOption.PROGRESSIVE.description"),
2358
+ value: F_MISSION_TYPE.enum.PROGRESSIVE
2359
+ }
2360
+ ]), l = m;
2361
+ return (o, n) => {
2362
+ var h;
2363
+ const r = resolveComponent("FmCard"), p = resolveComponent("FmStepperField");
2364
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
2365
+ createElementVNode("div", _hoisted_2$2, [
2366
+ createElementVNode("div", _hoisted_3$2, toDisplayString(unref(a)("connect.campaign.mission.missionType")), 1),
2367
+ createElementVNode("div", _hoisted_4$1, toDisplayString(unref(a)("connect.template.select_game")), 1),
2368
+ createElementVNode("div", _hoisted_5$1, [
2369
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(s), (y) => {
2370
+ var C, x;
2371
+ return openBlock(), createBlock(r, {
2372
+ variant: "outlined",
2373
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
2374
+ "col-span-2": unref(s).length == 1,
2375
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((C = e.modelValue) == null ? void 0 : C.type) == y.value,
2376
+ "hover:bg-fm-color-opacity-sm": ((x = e.modelValue) == null ? void 0 : x.type) != y.value
2377
+ }]),
2378
+ onClick: () => {
2379
+ var v, f;
2380
+ ((v = e.modelValue) == null ? void 0 : v.type) != y.value && l("update:model-value", {
2381
+ ...e.modelValue,
2382
+ type: y.value,
2383
+ end: ((f = e.modelValue) == null ? void 0 : f.end) || 1
2384
+ });
2385
+ },
2386
+ key: y.value
2387
+ }, {
2388
+ default: withCtx(() => [
2389
+ createElementVNode("div", _hoisted_6$1, toDisplayString(y.label), 1),
2390
+ createElementVNode("div", _hoisted_7$1, toDisplayString(y.description), 1)
2391
+ ]),
2392
+ _: 2
2393
+ }, 1032, ["class", "onClick"]);
2394
+ }), 128))
2395
+ ])
2396
+ ]),
2397
+ createElementVNode("div", _hoisted_8$1, [
2398
+ createElementVNode("div", _hoisted_9$1, toDisplayString(unref(a)("connect.campaign.mission.collectionsRequired")), 1),
2399
+ createElementVNode("div", _hoisted_10$1, toDisplayString(unref(a)("connect.campaign.mission.collectionsRequiredDescription")), 1),
2400
+ createVNode(p, {
2401
+ label: unref(a)("connect.campaign.mission.maximumToCollect"),
2402
+ "model-value": ((h = e.modelValue) == null ? void 0 : h.end) || null,
2403
+ "onUpdate:modelValue": n[0] || (n[0] = (y) => {
2404
+ var C;
2405
+ return l("update:model-value", {
2406
+ ...e.modelValue,
2407
+ type: ((C = e.modelValue) == null ? void 0 : C.type) || "STAMP",
2408
+ end: y
2409
+ });
2410
+ }),
2411
+ "helper-text": unref(ZodHelper).helperText(unref(d), "end") || unref(a)("connect.campaign.mission.thresholdHelperText"),
2412
+ "helper-state": unref(ZodHelper).helperState(unref(d), "end") || "none"
2413
+ }, null, 8, ["label", "model-value", "helper-text", "helper-state"])
2414
+ ])
2415
+ ]);
2416
+ };
2417
+ }
2418
+ });
2419
+ function useLocaleText() {
2420
+ const { locale: e, t: m } = useI18n();
2421
+ function a(u, d) {
2422
+ return u ? u[e.value] ?? u["en-US"] ?? m(d) : m(d);
2423
+ }
2424
+ return { getLocaleText: a };
2425
+ }
2426
+ const _hoisted_1$2 = { key: 29 }, _sfc_main$2 = /* @__PURE__ */ defineComponent({
2427
+ __name: "TemplateInput",
2428
+ props: {
2429
+ field: { type: Object, required: !0 },
2430
+ modelValue: {
2431
+ type: Object
2432
+ },
2433
+ schema: {
2434
+ type: Object
2435
+ },
2436
+ extras: {
2437
+ type: Object
2438
+ },
2439
+ helperText: {
2440
+ type: String
2441
+ },
2442
+ disabled: {
2443
+ type: Boolean,
2444
+ default: !1
2445
+ },
2446
+ campaignType: {
2447
+ type: String,
2448
+ default: void 0
2449
+ }
2450
+ },
2451
+ emits: ["update:model-value", "update:file"],
2452
+ setup(e, { emit: m }) {
2453
+ const { t: a } = useI18n(), { getLocaleText: u } = useLocaleText(), d = e, s = m;
2454
+ function l(p) {
2455
+ switch (d.field.type) {
2456
+ case "timeframe":
2457
+ const h = p.startDate ? hooks(p.startDate).startOf("day").toISOString() : void 0, y = p.endDate ? hooks(p.endDate).endOf("day").toISOString() : void 0;
2458
+ s("update:model-value", {
2459
+ type: "timeframe",
2460
+ property: "__now",
2461
+ start: h,
2462
+ end: y
2463
+ });
2464
+ break;
2465
+ case "image": {
2466
+ s(
2467
+ "update:file",
2468
+ p,
2469
+ o.value || firebaseStorage.collectibleImagePath(void 0, p)
2470
+ );
2471
+ break;
2472
+ }
2473
+ default:
2474
+ s("update:model-value", p);
2475
+ break;
2476
+ }
2477
+ }
2478
+ const o = computed(() => {
2479
+ switch (d.field.type) {
2480
+ case "timeframe": {
2481
+ const p = d.modelValue;
2482
+ return {
2483
+ startDate: p != null && p.start ? hooks(p == null ? void 0 : p.start).format("YYYY-MM-DD") : null,
2484
+ endDate: p != null && p.end ? hooks(p == null ? void 0 : p.end).format("YYYY-MM-DD") : null
2485
+ };
2486
+ }
2487
+ default:
2488
+ return d.modelValue;
2489
+ }
2490
+ });
2491
+ function n() {
2492
+ if (!r.value.schema) return [];
2493
+ const p = r.value.schema.safeParse(d.modelValue);
2494
+ return p.success ? [] : p.error.errors;
2495
+ }
2496
+ const r = computed(() => ({
2497
+ schema: d.schema,
2498
+ unwrapped: d.schema ? ZodHelper.unwrap(d.schema) : void 0,
2499
+ rules: d.schema ? [ZodHelper.ruleAtPath(d.schema, "")] : void 0,
2500
+ labelMark: d.schema && ZodHelper.isRequired(d.schema) == !1 ? "optional" : void 0,
2501
+ zodLabel: d.schema ? ZodHelper.toInputLabel(
2502
+ d.schema,
2503
+ u(d.field.label_locale, d.field.label ?? "")
2504
+ ) : void 0
2505
+ }));
2506
+ return (p, h) => {
2507
+ var i, c, k, b, E;
2508
+ const y = resolveComponent("FmTextField"), C = resolveComponent("FmStepperField"), x = resolveComponent("FmTextarea"), v = resolveComponent("FmHelperText"), f = resolveComponent("FmSwitch");
2509
+ return e.field.type === "text" ? (openBlock(), createBlock(y, {
2510
+ key: 0,
2511
+ label: unref(u)(e.field.label_locale, e.field.label ?? ""),
2512
+ "label-mark": unref(r).labelMark,
2513
+ rules: unref(r).rules,
2514
+ "model-value": unref(o),
2515
+ "onUpdate:modelValue": l,
2516
+ "helper-state": e.helperText ? "error" : void 0,
2517
+ "helper-text": e.helperText
2518
+ }, null, 8, ["label", "label-mark", "rules", "model-value", "helper-state", "helper-text"])) : e.field.type === "number" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2519
+ createVNode(JsonViewer, {
2520
+ json: { schema: unref(r).unwrapped, props: d }
2521
+ }, null, 8, ["json"]),
2522
+ createVNode(C, {
2523
+ label: unref(u)(e.field.label_locale, e.field.label ?? ""),
2524
+ "label-mark": e.field.isRuleChildren ? void 0 : unref(r).labelMark,
2525
+ "model-value": unref(o),
2526
+ rules: e.field.isRuleChildren ? [] : unref(r).rules,
2527
+ "onUpdate:modelValue": l,
2528
+ "helper-state": e.field.isRuleChildren && e.helperText ? "error" : void 0,
2529
+ "helper-text": e.field.isRuleChildren ? e.helperText : void 0
2530
+ }, null, 8, ["label", "label-mark", "model-value", "rules", "helper-state", "helper-text"])
2531
+ ], 64)) : e.field.type === "textarea" ? (openBlock(), createBlock(x, {
2532
+ key: 2,
2533
+ label: unref(u)(e.field.label_locale, e.field.label ?? ""),
2534
+ "label-mark": unref(r).labelMark,
2535
+ rules: unref(r).rules,
2536
+ "model-value": unref(o),
2537
+ "onUpdate:modelValue": l,
2538
+ "show-word-count": "",
2539
+ "max-length": (E = (b = (k = (c = (i = unref(r)) == null ? void 0 : i.unwrapped) == null ? void 0 : c._def) == null ? void 0 : k.checks) == null ? void 0 : b.find((N) => N.kind == "max")) == null ? void 0 : E.value
2540
+ }, null, 8, ["label", "label-mark", "rules", "model-value", "max-length"])) : e.field.type === "trigger" ? (openBlock(), createBlock(_sfc_main$h, {
2541
+ key: 3,
2542
+ "campaign-type": e.extras,
2543
+ "model-value": unref(o),
2544
+ disabled: e.disabled,
2545
+ "onUpdate:modelValue": l
2546
+ }, null, 8, ["campaign-type", "model-value", "disabled"])) : e.field.type === "timeframe" ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
2547
+ createVNode(_sfc_main$g, {
2548
+ "model-value": unref(o),
2549
+ "onUpdate:modelValue": l
2550
+ }, null, 8, ["model-value"]),
2551
+ createVNode(v, {
2552
+ class: "!mt-[8px]",
2553
+ text: unref(ZodHelper).helperText(n(), ""),
2554
+ state: unref(ZodHelper).helperState(n(), "")
2555
+ }, null, 8, ["text", "state"])
2556
+ ], 64)) : e.field.type === "image" ? (openBlock(), createBlock(_sfc_main$u, {
2557
+ key: 5,
2558
+ thumbnail: unref(o),
2559
+ "aspect-ratio": "16 / 9",
2560
+ class: "w-1/2 xs:w-2/3",
2561
+ "onUpdate:file": l
2562
+ }, {
2563
+ label: withCtx(() => [
2564
+ (openBlock(), createBlock(resolveDynamicComponent(unref(r).zodLabel)))
2565
+ ]),
2566
+ _: 1
2567
+ }, 8, ["thumbnail"])) : e.field.type === "switch" ? (openBlock(), createBlock(f, {
2568
+ key: 6,
2569
+ label: unref(u)(e.field.label_locale, e.field.label ?? ""),
2570
+ "label-placement": "right",
2571
+ sublabel: e.field.property == "campaign.notify" ? "Notify customer when customer receives the reward" : void 0,
2572
+ "label-mark": unref(r).labelMark,
2573
+ rules: unref(r).rules,
2574
+ "model-value": unref(o),
2575
+ "onUpdate:modelValue": l
2576
+ }, null, 8, ["label", "sublabel", "label-mark", "rules", "model-value"])) : e.field.type === "collectible_options" ? (openBlock(), createBlock(_sfc_main$v, {
2577
+ key: 7,
2578
+ "model-value": unref(o),
2579
+ "onUpdate:modelValue": l,
2580
+ "no-campaign": !1,
2581
+ schema: unref(r).schema,
2582
+ "is-mission": e.extras === "MISSION"
2583
+ }, null, 8, ["model-value", "schema", "is-mission"])) : e.field.type === "grab_conditions" ? (openBlock(), createBlock(GrabConditionsInput, {
2584
+ key: 8,
2585
+ "model-value": unref(o),
2586
+ "onUpdate:modelValue": l,
2587
+ schema: unref(r).schema
2588
+ }, null, 8, ["model-value", "schema"])) : e.field.type === "grab_quota" ? (openBlock(), createBlock(_sfc_main$9, {
2589
+ key: 9,
2590
+ "model-value": unref(o),
2591
+ "onUpdate:modelValue": l,
2592
+ schema: unref(r).schema
2593
+ }, null, 8, ["model-value", "schema"])) : e.field.type === "target_location" ? (openBlock(), createBlock(_sfc_main$w, {
2594
+ key: 10,
2595
+ "model-value": unref(o),
2596
+ "onUpdate:modelValue": l
2597
+ }, null, 8, ["model-value"])) : e.field.type == "effect" ? (openBlock(), createElementBlock(Fragment, { key: 11 }, [
2598
+ createVNode(_sfc_main$x, {
2599
+ "model-value": unref(o),
2600
+ "onUpdate:modelValue": l,
2601
+ "can-set-auto-apply": e.field.property == "campaign.effect"
2602
+ }, null, 8, ["model-value", "can-set-auto-apply"]),
2603
+ unref(o) ? createCommentVNode("", !0) : (openBlock(), createBlock(v, {
2604
+ key: 0,
2605
+ class: "!mt-[8px]",
2606
+ text: unref(a)("connect.campaign.common.effect_required"),
2607
+ state: "error"
2608
+ }, null, 8, ["text"]))
2609
+ ], 64)) : e.field.type == "grab_effect" ? (openBlock(), createElementBlock(Fragment, { key: 12 }, [
2610
+ createVNode(GrabEffectSheet, {
2611
+ "model-value": unref(o),
2612
+ "onUpdate:modelValue": l
2613
+ }, null, 8, ["model-value"]),
2614
+ unref(o) ? createCommentVNode("", !0) : (openBlock(), createBlock(v, {
2615
+ key: 0,
2616
+ class: "!mt-[8px]",
2617
+ text: unref(a)("connect.campaign.common.effect_required"),
2618
+ state: "error"
2619
+ }, null, 8, ["text"]))
2620
+ ], 64)) : e.field.type === "message" ? (openBlock(), createBlock(_sfc_main$y, {
2621
+ key: 13,
2622
+ "allow-email": !0,
2623
+ "allow-whatsapp": !0,
2624
+ "model-value": unref(o),
2625
+ "onUpdate:modelValue": l,
2626
+ "helper-text": unref(ZodHelper).helperText(n(), ""),
2627
+ "trigger-type": e.field.extras,
2628
+ "helper-state": unref(ZodHelper).helperState(n(), "")
2629
+ }, null, 8, ["model-value", "helper-text", "trigger-type", "helper-state"])) : e.field.type === "earning_option" ? (openBlock(), createBlock(_sfc_main$r, {
2630
+ key: 14,
2631
+ "model-value": unref(o),
2632
+ "onUpdate:modelValue": l,
2633
+ extras: e.extras,
2634
+ "error-text": e.helperText
2635
+ }, null, 8, ["model-value", "extras", "error-text"])) : e.field.type === "validity_option" ? (openBlock(), createBlock(_sfc_main$s, {
2636
+ key: 15,
2637
+ type: "custom",
2638
+ "model-value": unref(o),
2639
+ "onUpdate:modelValue": l,
2640
+ "helper-text": e.helperText || unref(ZodHelper).helperText(n(), ""),
2641
+ "for-credit": d.campaignType === "CREDIT"
2642
+ }, null, 8, ["model-value", "helper-text", "for-credit"])) : e.field.type === "game_type" ? (openBlock(), createBlock(_sfc_main$e, {
2643
+ key: 16,
2644
+ "model-value": unref(o),
2645
+ "onUpdate:modelValue": l
2646
+ }, null, 8, ["model-value"])) : e.field.type === "reward_pool" ? (openBlock(), createBlock(_sfc_main$c, {
2647
+ key: 17,
2648
+ "model-value": unref(o),
2649
+ "onUpdate:modelValue": l
2650
+ }, null, 8, ["model-value"])) : e.field.type === "mission" ? (openBlock(), createBlock(_sfc_main$3, {
2651
+ key: 18,
2652
+ "model-value": unref(o),
2653
+ "onUpdate:modelValue": l
2654
+ }, null, 8, ["model-value"])) : e.field.type === "mission_type" ? (openBlock(), createBlock(_sfc_main$8, {
2655
+ key: 19,
2656
+ "model-value": unref(o),
2657
+ "onUpdate:modelValue": l
2658
+ }, null, 8, ["model-value"])) : e.field.type === "mission_end" ? (openBlock(), createBlock(_sfc_main$7, {
2659
+ key: 20,
2660
+ "model-value": unref(o),
2661
+ "onUpdate:modelValue": l,
2662
+ "helper-text": unref(ZodHelper).helperText(n(), ""),
2663
+ "helper-state": unref(ZodHelper).helperState(n(), "")
2664
+ }, null, 8, ["model-value", "helper-text", "helper-state"])) : e.field.type === "mission_pool" ? (openBlock(), createBlock(_sfc_main$4, {
2665
+ key: 21,
2666
+ "model-value": unref(o),
2667
+ "onUpdate:modelValue": l,
2668
+ mission: e.extras.mission
2669
+ }, null, 8, ["model-value", "mission"])) : e.field.type === "rule_schedule" ? (openBlock(), createElementBlock(Fragment, { key: 22 }, [
2670
+ createVNode(_sfc_main$f, {
2671
+ "model-value": unref(o),
2672
+ "onUpdate:modelValue": l,
2673
+ "start-date": e.extras.start,
2674
+ "end-date": e.extras.end
2675
+ }, null, 8, ["model-value", "start-date", "end-date"]),
2676
+ e.helperText ? (openBlock(), createBlock(v, {
2677
+ key: 0,
2678
+ class: "!mt-[8px]",
2679
+ text: e.helperText,
2680
+ state: "error"
2681
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2682
+ ], 64)) : e.field.type === "rule_user" ? (openBlock(), createElementBlock(Fragment, { key: 23 }, [
2683
+ createVNode(_sfc_main$z, {
2684
+ "model-value": unref(o),
2685
+ "onUpdate:modelValue": l
2686
+ }, null, 8, ["model-value"]),
2687
+ e.helperText ? (openBlock(), createBlock(v, {
2688
+ key: 0,
2689
+ class: "!mt-[8px]",
2690
+ text: e.helperText,
2691
+ state: "error"
2692
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2693
+ ], 64)) : e.field.type === "rule_time" ? (openBlock(), createElementBlock(Fragment, { key: 24 }, [
2694
+ e.extras == "PROMOTION" && unref(RuleBuilder).getRules(unref(o).rules.g_time).length > 0 ? (openBlock(), createBlock(v, {
2695
+ key: 0,
2696
+ state: "warning",
2697
+ text: `Time based rule only work for POS >= v${unref(featureVersionMapping).TIME_BASED_PROMOTION}`
2698
+ }, null, 8, ["text"])) : createCommentVNode("", !0),
2699
+ createVNode(_sfc_main$j, {
2700
+ "model-value": unref(o),
2701
+ "onUpdate:modelValue": l
2702
+ }, null, 8, ["model-value"]),
2703
+ e.helperText ? (openBlock(), createBlock(v, {
2704
+ key: 1,
2705
+ class: "!mt-[8px]",
2706
+ text: e.helperText,
2707
+ state: "error"
2708
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2709
+ ], 64)) : e.field.type === "rule_bill" ? (openBlock(), createElementBlock(Fragment, { key: 25 }, [
2710
+ createVNode(_sfc_main$A, {
2711
+ "model-value": unref(o),
2712
+ "onUpdate:modelValue": l
2713
+ }, null, 8, ["model-value"]),
2714
+ e.helperText ? (openBlock(), createBlock(v, {
2715
+ key: 0,
2716
+ class: "!mt-[8px]",
2717
+ text: e.helperText,
2718
+ state: "error"
2719
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2720
+ ], 64)) : e.field.type === "rule_feedback" ? (openBlock(), createElementBlock(Fragment, { key: 26 }, [
2721
+ createVNode(_sfc_main$B, {
2722
+ "model-value": unref(o),
2723
+ "onUpdate:modelValue": l
2724
+ }, null, 8, ["model-value"]),
2725
+ e.helperText ? (openBlock(), createBlock(v, {
2726
+ key: 0,
2727
+ class: "!mt-[8px]",
2728
+ text: e.helperText,
2729
+ state: "error"
2730
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2731
+ ], 64)) : e.field.type === "rule_birthday" ? (openBlock(), createElementBlock(Fragment, { key: 27 }, [
2732
+ createVNode(_sfc_main$i, {
2733
+ "model-value": unref(o),
2734
+ "onUpdate:modelValue": l
2735
+ }, null, 8, ["model-value"]),
2736
+ e.helperText ? (openBlock(), createBlock(v, {
2737
+ key: 0,
2738
+ class: "!mt-[8px]",
2739
+ text: e.helperText,
2740
+ state: "error"
2741
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2742
+ ], 64)) : e.field.type === "promotion_game_type" ? (openBlock(), createElementBlock(Fragment, { key: 28 }, [
2743
+ createVNode(_sfc_main$b, {
2744
+ "model-value": unref(o),
2745
+ "onUpdate:modelValue": l
2746
+ }, null, 8, ["model-value"]),
2747
+ e.helperText ? (openBlock(), createBlock(v, {
2748
+ key: 0,
2749
+ class: "!mt-[8px]",
2750
+ text: e.helperText,
2751
+ state: "error"
2752
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2753
+ ], 64)) : (openBlock(), createElementBlock("pre", _hoisted_1$2, toDisplayString(d.field), 1));
2754
+ };
2755
+ }
2756
+ }), _hoisted_1$1 = { class: "fm-typo-en-body-lg-600" }, _hoisted_2$1 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$1 = { class: "fm-typo-en-body-lg-600" }, _sfc_main$1 = /* @__PURE__ */ defineComponent({
2757
+ __name: "CampaignSummary",
2758
+ props: {
2759
+ data: {
2760
+ type: Object,
2761
+ required: !0
2762
+ }
2763
+ },
2764
+ setup(e) {
2765
+ const { t: m, te: a } = useI18n();
2766
+ return (u, d) => {
2767
+ const s = resolveComponent("FmCard");
2768
+ return openBlock(), createBlock(s, {
2769
+ variant: "outlined",
2770
+ class: "p-16 space-y-8"
2771
+ }, {
2772
+ default: withCtx(() => [
2773
+ createElementVNode("div", _hoisted_1$1, toDisplayString(unref(m)("connect.campaign.common.summary")), 1),
2774
+ d[0] || (d[0] = createElementVNode("div", { class: "h-[1px] bg-fm-color-neutral-gray-100 w-full" }, null, -1)),
2775
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(getCampaignSummaryObject)(e.data), (l, o) => (openBlock(), createElementBlock("div", {
2776
+ class: "space-y-4",
2777
+ key: o
2778
+ }, [
2779
+ l ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2780
+ createElementVNode("div", _hoisted_2$1, toDisplayString(unref(m)(`${o}`)), 1),
2781
+ createElementVNode("div", _hoisted_3$1, toDisplayString(unref(a)(`${l}`) ? unref(m)(`${l}`) : l), 1)
2782
+ ], 64)) : createCommentVNode("", !0)
2783
+ ]))), 128))
2784
+ ]),
2785
+ _: 1
2786
+ });
2787
+ };
2788
+ }
2789
+ }), _hoisted_1 = { class: "xs:hidden px-24 pb-[14px] pt-[22px] flex items-center justify-between w-full border-b" }, _hoisted_2 = { class: "flex items-center gap-8" }, _hoisted_3 = {
2790
+ key: 0,
2791
+ class: "max-w-6xl mx-auto"
2792
+ }, _hoisted_4 = { class: "hidden xs:!flex gap-8 items-center w-full px-16 py-8 border-b border-fm-color-neutral-gray-100" }, _hoisted_5 = { class: "grid grid-cols-3 gap-40" }, _hoisted_6 = { class: "col-span-2 space-y-40 xs:col-span-3 xs:px-16 xs:pt-16" }, _hoisted_7 = { class: "fm-typo-en-title-sm-800 !mb-[-8px]" }, _hoisted_8 = { class: "w-full flex items-center justify-end gap-8 pb-24" }, _hoisted_9 = { class: "max-w-6xl mx-auto rounded-md p-4 w-full" }, _hoisted_10 = { class: "animate-pulse flex space-x-4 pt-16" }, _hoisted_11 = { class: "grid grid-cols-3 w-full gap-40" }, _sfc_main = /* @__PURE__ */ defineComponent({
2793
+ __name: "EditCampaignSheet",
2794
+ emits: ["submit:model-value"],
2795
+ setup(__props, { expose: __expose, emit: __emit }) {
2796
+ const Dialog = useDialog(), sheetVisible = ref(!1), { t } = useI18n(), { getLocaleText } = useLocaleText(), currentStep = ref(1), data = ref(), schema = ref(z.any()), template = ref(
2797
+ TEMPLATES.VOUCHER
2798
+ ), { minor } = useLoading, isLoading = ref(!1), sheetTitle = ref("Create Campaign"), campaignType = ref("VOUCHER");
2799
+ async function showSheet(visible, type, campaign, selectedTemplate) {
2800
+ var e, m, a;
2801
+ if (sheetVisible.value = visible, campaignType.value = type, visible == !0) {
2802
+ try {
2803
+ isLoading.value = visible, await useMembershipStore().readRewards(), await useBusinessStore().readLocations(), await useMembershipStore().readSegments(), await useMembershipStore().readMembership();
2804
+ } catch {
2805
+ } finally {
2806
+ await new Promise((u) => setTimeout(u, 120)), isLoading.value = !1;
2807
+ }
2808
+ console.log(
2809
+ TEMPLATES[type],
2810
+ "base template"
2811
+ ), template.value = selectedTemplate ?? TEMPLATES[type], schema.value = CampaignDtos[type], type === "VOUCHER" && (await useCampaignStore().read(), schema.value = schema.value.superRefine((u, d) => {
2812
+ var s;
2813
+ if (u.campaign.type === "VOUCHER" && u.campaign.code) {
2814
+ const l = (s = u.campaign._id) == null ? void 0 : s.toString();
2815
+ useCampaignStore().campaigns.voucher.some(
2816
+ (o) => o.code === u.campaign.code && o._id.toString() !== l
2817
+ ) && d.addIssue({
2818
+ code: "custom",
2819
+ message: "Code already exists, please use another code",
2820
+ path: ["campaign", "code"]
2821
+ });
2822
+ }
2823
+ })), data.value = campaign != null ? { ...campaign, templateId: (e = campaign.template) == null ? void 0 : e._id } : _.cloneDeep({
2824
+ ...(m = template.value) == null ? void 0 : m.defaultValue
2825
+ }), "configs" in data.value && typeof data.value.configs == "string" && (data.value.configs = eval(data.value.configs)), data.value = cleanPF(data.value), data.value.templateId = SvcConfig.getBusinessId(), data.value.campaign.business = SvcConfig.getBusinessId(), data.value.campaign.templateId = SvcConfig.getBusinessId(), "configs" in data.value && (data.value.configs.business = SvcConfig.getBusinessId()), currentStep.value = 1, sheetTitle.value = (a = campaign == null ? void 0 : campaign.campaign) != null && a._id ? t("connect.campaign.common.edit_campaign_title", {
2826
+ typeName: t(`connect.campaign.common.typeName.${type}`)
2827
+ }) : t("connect.campaign.common.create_campaign_title", {
2828
+ typeName: t(`connect.campaign.common.typeName.${type}`)
2829
+ });
2830
+ }
2831
+ }
2832
+ async function hideSheet() {
2833
+ Dialog.open({
2834
+ title: t("connect.campaign.common.unsaved_changes"),
2835
+ message: t("connect.campaign.common.unsaved_changes"),
2836
+ primaryActions: {
2837
+ text: t("connect.campaign.common.unsaved_changes_confirm"),
2838
+ close: !0
2839
+ },
2840
+ secondaryActions: {
2841
+ text: t("connect.campaign.common.unsaved_changes_cancel"),
2842
+ close: !1
2843
+ }
2844
+ }).onPrimary(() => {
2845
+ sheetVisible.value = !1;
2846
+ }).onSecondary(() => {
2847
+ Dialog.close();
2848
+ });
2849
+ }
2850
+ const emits = __emit, errors = computed(() => {
2851
+ const e = schema.value.superRefine(campaignRefinement).safeParse(data.value);
2852
+ return e.success ? [] : e.error.errors;
2853
+ });
2854
+ function stepErrors(e = currentStep.value - 1) {
2855
+ const m = template.value.steps[e].groups.flatMap(
2856
+ (a) => a.fields.map((u) => u.property)
2857
+ );
2858
+ return errors.value.filter(
2859
+ (a) => m.some((u) => a.path.join(".").includes(u))
2860
+ );
2861
+ }
2862
+ __expose({ showSheet });
2863
+ function showSummaryDialog() {
2864
+ Dialog.open({
2865
+ title: "",
2866
+ dialogComponent: _sfc_main$1,
2867
+ dialogComponentProps: {
2868
+ data: data.value
2869
+ }
2870
+ });
2871
+ }
2872
+ function onUpdateProperty(e, m) {
2873
+ var a, u, d, s, l, o, n, r;
2874
+ if (_.set(data.value, e, m), e == "campaign.event.type") {
2875
+ const h = ((s = (d = (u = (a = template.value) == null ? void 0 : a.defaultValue) == null ? void 0 : u.campaign) == null ? void 0 : d.event) == null ? void 0 : s.rule) ? _.cloneDeep({
2876
+ ...(r = (n = (o = (l = template.value) == null ? void 0 : l.defaultValue) == null ? void 0 : o.campaign) == null ? void 0 : n.event) == null ? void 0 : r.rule
2877
+ }) : RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup(), [
2878
+ RuleBuilder.scaffoldGroup("g_schedule"),
2879
+ RuleBuilder.scaffoldGroup("g_time"),
2880
+ RuleBuilder.scaffoldGroup("g_user"),
2881
+ RuleBuilder.scaffoldGroup("g_bill")
2882
+ ]), y = RuleBuilder.setRuleToGroup(
2883
+ RuleBuilder.scaffoldGroup("g_schedule"),
2884
+ [
2885
+ RuleBuilder.constructEntry(
2886
+ "trigger.date",
2887
+ "_rrule",
2888
+ "RRULE:FREQ=DAILY;INTERVAL=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0;WKST=SU"
2889
+ ),
2890
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
2891
+ ],
2892
+ "&&"
2893
+ );
2894
+ if (m != "SCHEDULE") {
2895
+ _.set(data.value, "campaign.event.rule", h);
2896
+ return;
2897
+ }
2898
+ _.set(
2899
+ data.value,
2900
+ "campaign.event.rule",
2901
+ RuleBuilder.setRuleToGroup(h, y)
2902
+ );
2903
+ }
2904
+ e == "campaign.notify" && m == !1 && _.set(data.value, "campaign.notifyMessage", void 0);
2905
+ }
2906
+ async function onUpdateFile(e, m) {
2907
+ return e ? await minor(async () => firebaseStorage.update(m, e), {
2908
+ message: `${e ? "Uploading" : "Removing"} file`,
2909
+ successMessage: `File ${e ? "uploaded" : "removed"} successfully`
2910
+ }) : "";
2911
+ }
2912
+ function isDisable(e) {
2913
+ var m, a;
2914
+ switch (e == null ? void 0 : e.property) {
2915
+ case "campaign.event.type":
2916
+ return ((a = (m = data.value) == null ? void 0 : m.campaign) == null ? void 0 : a._id) || !1;
2917
+ default:
2918
+ return !1;
2919
+ }
2920
+ }
2921
+ async function onSubmit() {
2922
+ const e = schema.value.superRefine(campaignRefinement).transform(campaignTransform).safeParse(data.value);
2923
+ if (!e.success)
2924
+ return;
2925
+ const m = await emits(
2926
+ "submit:model-value",
2927
+ cleanPF(JSON.parse(JSON.stringify(e.data)))
2928
+ );
2929
+ (m || m === void 0) && (sheetVisible.value = !1);
2930
+ }
2931
+ return (e, m) => {
2932
+ const a = resolveComponent("FmButton"), u = resolveComponent("FmStep"), d = resolveComponent("FmStepper"), s = resolveComponent("FmCard"), l = resolveComponent("FmTopSheet");
2933
+ return openBlock(), createBlock(l, {
2934
+ "fullscreen-size": "lg",
2935
+ modelValue: unref(sheetVisible),
2936
+ "onUpdate:modelValue": [
2937
+ m[7] || (m[7] = (o) => isRef(sheetVisible) ? sheetVisible.value = o : null),
2938
+ m[8] || (m[8] = (o) => sheetVisible.value = o)
2939
+ ]
2940
+ }, createSlots({
2941
+ "top-sheet-header": withCtx(() => [
2942
+ createElementVNode("div", _hoisted_1, [
2943
+ createElementVNode("div", null, toDisplayString(unref(sheetTitle)), 1),
2944
+ createElementVNode("div", _hoisted_2, [
2945
+ createVNode(a, {
2946
+ onClick: m[0] || (m[0] = (o) => hideSheet()),
2947
+ label: unref(t)("connect.campaign.common.cancel"),
2948
+ variant: "tertiary"
2949
+ }, null, 8, ["label"]),
2950
+ createVNode(a, {
2951
+ onClick: onSubmit,
2952
+ label: unref(t)("connect.campaign.common.save"),
2953
+ disabled: unref(errors).length > 0
2954
+ }, null, 8, ["label", "disabled"])
2955
+ ])
2956
+ ])
2957
+ ]),
2958
+ _: 2
2959
+ }, [
2960
+ unref(isLoading) ? {
2961
+ name: "default",
2962
+ fn: withCtx(() => [
2963
+ createElementVNode("div", _hoisted_9, [
2964
+ createElementVNode("div", _hoisted_10, [
2965
+ createElementVNode("div", _hoisted_11, [
2966
+ m[9] || (m[9] = createElementVNode("div", { class: "col-span-2 space-y-80 xs:col-span-3 xs:px-16 xs:pt-16" }, [
2967
+ createElementVNode("div", { class: "flex-1 space-y-6 py-1" }, [
2968
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
2969
+ createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
2970
+ createElementVNode("div", { class: "space-y-3" }, [
2971
+ createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
2972
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
2973
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2974
+ ]),
2975
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2976
+ ]),
2977
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
2978
+ createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
2979
+ createElementVNode("div", { class: "space-y-3" }, [
2980
+ createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
2981
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
2982
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2983
+ ]),
2984
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
2985
+ ])
2986
+ ])
2987
+ ], -1)),
2988
+ createVNode(s, { class: "h-[150px] bg-fm-color-neutral-gray-100" })
2989
+ ])
2990
+ ])
2991
+ ])
2992
+ ]),
2993
+ key: "1"
2994
+ } : {
2995
+ name: "default",
2996
+ fn: withCtx(() => [
2997
+ unref(data) ? (openBlock(), createElementBlock("div", _hoisted_3, [
2998
+ createVNode(d, {
2999
+ modelValue: unref(currentStep),
3000
+ "onUpdate:modelValue": m[1] || (m[1] = (o) => isRef(currentStep) ? currentStep.value = o : null),
3001
+ orientation: "horizontal",
3002
+ class: "xs:hidden mx-[-24px] mt-16 mb-24 flex-1"
3003
+ }, {
3004
+ default: withCtx(() => [
3005
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (o, n) => (openBlock(), createBlock(u, {
3006
+ key: o.name,
3007
+ title: unref(getLocaleText)(o.name_locale, o.name),
3008
+ value: n + 1,
3009
+ error: () => stepErrors(n).length > 0,
3010
+ complete: () => n + 1 <= unref(currentStep)
3011
+ }, null, 8, ["title", "value", "error", "complete"]))), 128))
3012
+ ]),
3013
+ _: 1
3014
+ }, 8, ["modelValue"]),
3015
+ createElementVNode("div", _hoisted_4, [
3016
+ createVNode(a, {
3017
+ icon: "close",
3018
+ variant: "tertiary",
3019
+ onClick: m[2] || (m[2] = (o) => sheetVisible.value = !1)
3020
+ }),
3021
+ createVNode(d, {
3022
+ modelValue: unref(currentStep),
3023
+ "onUpdate:modelValue": m[3] || (m[3] = (o) => isRef(currentStep) ? currentStep.value = o : null),
3024
+ orientation: "horizontal",
3025
+ class: "flex-1"
3026
+ }, {
3027
+ default: withCtx(() => [
3028
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (o, n) => (openBlock(), createBlock(u, {
3029
+ key: o.name,
3030
+ title: unref(sheetTitle),
3031
+ description: unref(getLocaleText)(o.name_locale, o.name),
3032
+ value: n + 1,
3033
+ error: () => stepErrors(n).length > 0,
3034
+ complete: () => n + 1 <= unref(currentStep) && stepErrors(unref(currentStep) - 1).length == 0
3035
+ }, null, 8, ["title", "description", "value", "error", "complete"]))), 128))
3036
+ ]),
3037
+ _: 1
3038
+ }, 8, ["modelValue"]),
3039
+ createVNode(a, {
3040
+ icon: "info",
3041
+ variant: "tertiary",
3042
+ onClick: m[4] || (m[4] = () => showSummaryDialog())
3043
+ })
3044
+ ]),
3045
+ createElementVNode("div", _hoisted_5, [
3046
+ createElementVNode("div", _hoisted_6, [
3047
+ createVNode(JsonViewer, {
3048
+ json: {
3049
+ data: unref(data),
3050
+ errors: unref(errors).map(
3051
+ (o) => `${o.path.join(".")} - ${o.message}`
3052
+ ),
3053
+ stepErrors: stepErrors().map(
3054
+ (o) => `${o.path.join(".")} - ${o.message}`
3055
+ ),
3056
+ schema: unref(schema)
3057
+ }
3058
+ }, null, 8, ["json"]),
3059
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps[unref(currentStep) - 1].groups.filter(
3060
+ (o) => o.fields.length && (!o.condition || (Array.isArray(o.condition) ? o.condition.every((n) => unref(_).get(unref(data), n.property) == n.value == (n.not != !0)) : unref(_).get(unref(data), o.condition.property) == o.condition.value == (o.condition.not != !0)))
3061
+ ), (o, n) => (openBlock(), createElementBlock("div", {
3062
+ key: n,
3063
+ class: "space-y-24"
3064
+ }, [
3065
+ createElementVNode("div", _hoisted_7, toDisplayString(unref(getLocaleText)(o.name_locale, o.name ?? "")), 1),
3066
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(o.fields, (r, p) => (openBlock(), createElementBlock("div", { key: p }, [
3067
+ (openBlock(), createBlock(_sfc_main$2, {
3068
+ key: p,
3069
+ field: r,
3070
+ modelValue: unref(_).get(unref(data), r.property),
3071
+ disabled: isDisable(r),
3072
+ "campaign-type": unref(campaignType),
3073
+ "onUpdate:modelValue": (h) => onUpdateProperty(r.property, h),
3074
+ "onUpdate:file": async (h, y) => {
3075
+ const C = await onUpdateFile(h, y);
3076
+ onUpdateProperty(r.property, C || "");
3077
+ },
3078
+ schema: unref(ZodHelper).typeAtPath(
3079
+ unref(schema),
3080
+ r.property,
3081
+ unref(data).campaign.type != "MISSION" ? [unref(data).campaign.type] : ["STAMP", "MISSION"]
3082
+ ),
3083
+ "helper-state": unref(ZodHelper).helperState(unref(errors), r.property),
3084
+ "helper-text": unref(ZodHelper).helperText(unref(errors), r.property),
3085
+ extras: r.extras != null ? r.extras == "" ? unref(data) : unref(_).get(unref(data), r.extras) : void 0
3086
+ }, null, 8, ["field", "modelValue", "disabled", "campaign-type", "onUpdate:modelValue", "onUpdate:file", "schema", "helper-state", "helper-text", "extras"]))
3087
+ ]))), 128))
3088
+ ]))), 128)),
3089
+ createElementVNode("div", _hoisted_8, [
3090
+ createVNode(a, {
3091
+ label: unref(t)("connect.common.back"),
3092
+ variant: "tertiary",
3093
+ disabled: unref(currentStep) == 1,
3094
+ onClick: m[5] || (m[5] = (o) => currentStep.value--)
3095
+ }, null, 8, ["label", "disabled"]),
3096
+ createVNode(a, {
3097
+ disabled: unref(currentStep) - 1 < unref(template).steps.length - 1 ? stepErrors().length > 0 : unref(errors).length > 0,
3098
+ label: unref(currentStep) - 1 < unref(template).steps.length - 1 ? unref(t)("connect.common.next") : unref(t)("connect.common.submit"),
3099
+ onClick: m[6] || (m[6] = (o) => unref(currentStep) - 1 < unref(template).steps.length - 1 ? currentStep.value++ : onSubmit())
3100
+ }, null, 8, ["disabled", "label"])
3101
+ ])
3102
+ ]),
3103
+ createVNode(_sfc_main$1, {
3104
+ data: unref(data),
3105
+ class: "xs:hidden"
3106
+ }, null, 8, ["data"])
3107
+ ])
3108
+ ])) : createCommentVNode("", !0)
3109
+ ]),
3110
+ key: "0"
3111
+ }
3112
+ ]), 1032, ["modelValue"]);
3113
+ };
3114
+ }
3115
+ });
3116
+ export {
3117
+ _sfc_main as _,
3118
+ summarizeGrabDiscount as s,
3119
+ useLocaleText as u
3120
+ };