@feedmepos/mf-connect 0.1.38-beta.60 → 0.1.38-beta.62

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