@feedmepos/mf-connect 0.1.98-beta.7 → 0.1.98-beta.72

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 (152) hide show
  1. package/dist/{App-BonFFUVJ.js → App-DpYceiwG.js} +812 -666
  2. package/dist/{AuditLogs-CaQisyMC.js → AuditLogs-CG98b2qE.js} +14 -13
  3. package/dist/{Bin-Mu8gAiHw.js → Bin-vdipv2fF.js} +8 -8
  4. package/dist/Broadcast-ChwVqheE.js +303 -0
  5. package/dist/CampaignAnalytic-4PHO849x.js +1830 -0
  6. package/dist/{CampaignTypeDialog.vue_vue_type_script_setup_true_lang-BoLZVrCU.js → CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DmnN4pjm.js} +6 -5
  7. package/dist/Card-B6ol3PQw.js +1084 -0
  8. package/dist/{Collections-CByXxRW_.js → Collections-DodNIUr1.js} +14 -13
  9. package/dist/Credit-CJQyAZYw.js +286 -0
  10. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang--FqHJ7Ez.js +53 -0
  11. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-CA31QP-A.js +4277 -0
  12. package/dist/{EffectSheet.vue_vue_type_style_index_0_lang-BXsAX1Xa.js → EffectSheet.vue_vue_type_style_index_0_lang-DkKhdp7G.js} +35 -35
  13. package/dist/{Experience-B7J-aqPK.js → Experience-iLAKddx_.js} +112 -86
  14. package/dist/{FileSaver.min-D_F_MSZt.js → FileSaver.min-w_ExQ0py.js} +1 -1
  15. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-3bH-tZAm.js +138 -0
  16. package/dist/Game-DWdUbsAg.js +356 -0
  17. package/dist/GiftCardSetup-DnQ5vwxu.js +736 -0
  18. package/dist/{Grab-C45MmlD9.js → Grab-CFLRHs5w.js} +33 -32
  19. package/dist/{ImageInput.vue_vue_type_script_setup_true_lang-CPPcB3PC.js → ImageInput.vue_vue_type_script_setup_true_lang-uQJvjvTe.js} +1 -1
  20. package/dist/{Index-vQ6uP49O.js → Index-CUy4z2tS.js} +10 -10
  21. package/dist/{LocationPicker.vue_vue_type_script_setup_true_lang-Cj3hN3tg.js → LocationPicker.vue_vue_type_script_setup_true_lang-hKJ41Fe_.js} +1 -1
  22. package/dist/{LottieAnimation.vue_vue_type_script_setup_true_lang-DU9eIein.js → LottieAnimation.vue_vue_type_script_setup_true_lang-BDmtqTVC.js} +1 -1
  23. package/dist/LoyaltyDashboard-C5o7KriA.js +2865 -0
  24. package/dist/MainLayout-Dt0ywph3.js +143 -0
  25. package/dist/{Marketing-B6xMdQvW.js → Marketing-BHwxzBZ0.js} +7 -6
  26. package/dist/{MarketingMaterialEdit-0cZN4bek.js → MarketingMaterialEdit-B6k4ceGx.js} +15 -14
  27. package/dist/Member-DcPZfTj6.js +654 -0
  28. package/dist/MemberDetailSheet.vue_vue_type_script_setup_true_lang-CiiBrlHY.js +1279 -0
  29. package/dist/MemberImportHistory-DmPMuu1g.js +187 -0
  30. package/dist/MemberList-f9JejfNW.js +334 -0
  31. package/dist/{MemberTransactions-Bg-ziZy8.js → MemberTransactions-D1YSXeX-.js} +1 -1
  32. package/dist/{MessageInput.vue_vue_type_script_setup_true_lang-jbDJkbZh.js → MessageInput.vue_vue_type_script_setup_true_lang-freeE-DP.js} +5928 -5644
  33. package/dist/MetricInfoTooltip.vue_vue_type_script_setup_true_lang-m7ytg0ok.js +40 -0
  34. package/dist/Mission-BaaEl5BV.js +360 -0
  35. package/dist/Overview-CviY55Gs.js +1316 -0
  36. package/dist/{Overview-nsyJGSCq.js → Overview-fx-0E3b8.js} +21 -20
  37. package/dist/Point-BfqtflbC.js +288 -0
  38. package/dist/Promotion-Be2ogRYt.js +423 -0
  39. package/dist/{Queue-Dkipt6fw.js → Queue-CLSUL-Cx.js} +14 -13
  40. package/dist/{Record-BFqx6vM-.js → Record-CpTMQT7B.js} +9 -9
  41. package/dist/Review-DzSDx7dY.js +45 -0
  42. package/dist/ReviewFacebookCallback-CvbPJADM.js +238 -0
  43. package/dist/ReviewGoogleCallback-DJlqMbh3.js +213 -0
  44. package/dist/{Reward-DjFEE7I_.js → Reward-DJOmd6Z5.js} +35 -35
  45. package/dist/{RewardGroup.vue_vue_type_script_setup_true_lang-BzZ6VH80.js → RewardGroup.vue_vue_type_script_setup_true_lang-DY9fYxwc.js} +14 -13
  46. package/dist/{RuleGroup.vue_vue_type_script_setup_true_lang-A9jQX4jt.js → RuleGroup.vue_vue_type_script_setup_true_lang-BgYK4hpo.js} +196 -186
  47. package/dist/{Segment-BAjdUfZ6.js → Segment-G6xmeEaq.js} +275 -276
  48. package/dist/{SendCollectionSheet.vue_vue_type_script_setup_true_lang-CAQPFzRH.js → SendCollectionSheet.vue_vue_type_script_setup_true_lang-C3O0biLZ.js} +37 -36
  49. package/dist/{SendVoucherSheet.vue_vue_type_script_setup_true_lang-Gkz8jhES.js → SendVoucherSheet.vue_vue_type_script_setup_true_lang-CWP5sGT7.js} +4 -4
  50. package/dist/{Setting-BK7y0XC-.js → Setting-CKp441AW.js} +14 -14
  51. package/dist/{SettingAdvertisements-DfQ645xr.js → SettingAdvertisements-C4Uf-DgK.js} +12 -12
  52. package/dist/Settings-CTvMVwp6.js +230 -0
  53. package/dist/Store-Bzei6Xev.js +2612 -0
  54. package/dist/{StoreRewards-usHKOGmB.js → StoreRewards-DMQNIpF5.js} +15 -15
  55. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-mm1jbcvo.js +1329 -0
  56. package/dist/{TargetLocationInput.vue_vue_type_script_setup_true_lang-DrcWUZuR.js → TargetLocationInput.vue_vue_type_script_setup_true_lang-BspBXIO2.js} +2 -2
  57. package/dist/{Tier-BF3V430O.js → Tier-BN32RwYr.js} +2580 -754
  58. package/dist/{Title-DwPuqKfJ.js → Title-BIhgfRUI.js} +39 -37
  59. package/dist/Transaction-CPjA7IN9.js +45 -0
  60. package/dist/{UserRuleGroup.vue_vue_type_script_setup_true_lang-DToNRTJS.js → UserRuleGroup.vue_vue_type_script_setup_true_lang-DSutMvfk.js} +26 -26
  61. package/dist/{Voucher-DnhVIl_o.js → Voucher-CGJtn9bC.js} +156 -133
  62. package/dist/{VoucherEditor.vue_vue_type_script_setup_true_lang-Btb3UZCn.js → VoucherEditor.vue_vue_type_script_setup_true_lang-B-IwtPvx.js} +118 -124
  63. package/dist/{ZodTextField.vue_vue_type_script_setup_true_lang-EFUW9DMY.js → ZodTextField.vue_vue_type_script_setup_true_lang-Ce9xPwqA.js} +2 -2
  64. package/dist/{app-i3r-6ZVm.js → app-DAtx6aZ4.js} +45039 -37428
  65. package/dist/app.js +1 -1
  66. package/dist/base.export-BtRC4aWM.js +75 -0
  67. package/dist/{business-i0Gxk7gG.js → business-BZUIs8Ub.js} +5 -5
  68. package/dist/campaign-B6I6PuY4.js +100 -0
  69. package/dist/campaign-DKjBjV2k.js +398 -0
  70. package/dist/{campaign.enum-CbUTfxek.js → campaign.enum-BQy3e845.js} +1 -1
  71. package/dist/{campaign.fn-BjHSIDd1.js → campaign.fn--qVJ3jeH.js} +77 -77
  72. package/dist/{collectible.enum-DN7E_kHg.js → collectible.enum-vcvRFGl0.js} +1 -1
  73. package/dist/collection.fn-C3bMPBkC.js +26 -0
  74. package/dist/currency--R6VPInw.js +7 -0
  75. package/dist/{duplicateCampaign-DmdJQEIA.js → duplicateCampaign-aIsX9cCi.js} +11 -11
  76. package/dist/{effect-DM4AzeQl.js → effect-CbjmtRph.js} +1 -1
  77. package/dist/{email-addresses-BlqVJhwZ.js → email-addresses-DZKMnoKf.js} +209 -201
  78. package/dist/google-C3S8u0mT.js +4 -0
  79. package/dist/{helper-CkdISSVP.js → helper-BGqw2-RO.js} +1 -1
  80. package/dist/index-7TKoSEJ2.js +14550 -0
  81. package/dist/index-B9DM5Vuv.js +32437 -0
  82. package/dist/index-BWlfW4Kr.js +137 -0
  83. package/dist/{index-Cl8t41Sk.js → index-Bb4TieR_.js} +5 -5
  84. package/dist/{index-D6qeYVNz.js → index-BbpqZrkB.js} +1 -1
  85. package/dist/{index-4EtrCy_K.js → index-C22GPEM-.js} +4 -4
  86. package/dist/{index-FD50UHqf.js → index-CVYbfRGO.js} +105 -123
  87. package/dist/index-CVvSd60O.js +53 -0
  88. package/dist/{index-vI-ndGu_.js → index-CXL5WAH0.js} +5 -5
  89. package/dist/{index-B6xi1soU.js → index-ClP7Xy6Q.js} +1 -1
  90. package/dist/{index-BWsj6lCJ.js → index-D-P90w8K.js} +14 -14
  91. package/dist/{index-CxdLExX0.js → index-D_o9LsHU.js} +24 -9
  92. package/dist/{index-BrboOmPq.js → index-DcA0B-Y5.js} +347 -216
  93. package/dist/index-FnsjvtSo.js +901 -0
  94. package/dist/{index-DgzNGQgE.js → index-LlFZ5kxi.js} +2083 -2559
  95. package/dist/{index-CB7ytKOE.js → index-LnCoUCnx.js} +1588 -1522
  96. package/dist/index-kkhrPH6s.js +151 -0
  97. package/dist/index-v8Zv-2ko.js +72 -0
  98. package/dist/{index.esm2017-BX5CyKoc.js → index.esm2017-DO7bbE7J.js} +132 -132
  99. package/dist/{loading-DTKDhqew.js → loading-CzWOx4tE.js} +1 -1
  100. package/dist/{lodash-CCPBsqhe.js → lodash-B_gr6Ayu.js} +1 -1
  101. package/dist/member-import-BxCrd9tq.js +187 -0
  102. package/dist/membership-ILB4aB4h.js +274 -0
  103. package/dist/{money-wMK3QkZ5.js → money-CpIK1N_r.js} +1 -1
  104. package/dist/{number-DjKVlWn0.js → number-leVwmDCm.js} +1 -1
  105. package/dist/objectid-8hKuNcMN.js +145 -0
  106. package/dist/{plugins-D25PaNJk.js → plugins-DLIgnFIF.js} +13 -12
  107. package/dist/remy-Qz_pNsUS.js +13 -0
  108. package/dist/{reward-E63jqJHm.js → reward-DqT0zF01.js} +1 -1
  109. package/dist/{rule-RVvPtAnk.js → rule-DBtMGLxD.js} +335 -275
  110. package/dist/style.css +1 -1
  111. package/dist/{template-zNxOQaqe.js → template-CYKGCWY4.js} +6 -6
  112. package/dist/timezone-Brs5nrTL.js +20 -0
  113. package/dist/transaction.fn-0ZZcVp-j.js +71 -0
  114. package/dist/{trigger-BXV02FhP.js → trigger-LhNre1L9.js} +17 -17
  115. package/dist/useMarketingMaterialActions-DbDRMmhM.js +96 -0
  116. package/dist/{usePagination-BPcPhEnp.js → usePagination-DmZX0V64.js} +1 -1
  117. package/dist/{user-Bd8S7R5u.js → user-CBPsvnx9.js} +1 -1
  118. package/dist/vue-i18n-BPeSHE3c.js +2365 -0
  119. package/dist/{xlsx-_tQC9Ezf.js → xlsx-Cm3vGmLN.js} +440 -440
  120. package/dist/{zod-C1j2GLZP.js → zod-GTEcy37q.js} +1 -1
  121. package/package.json +10 -6
  122. package/dist/Broadcast-Cy-i-WOT.js +0 -266
  123. package/dist/Card-f2XOtWxp.js +0 -910
  124. package/dist/Credit-CcZF4aQS.js +0 -260
  125. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-eIoPtgO5.js +0 -58
  126. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-C7KZ8GMx.js +0 -3377
  127. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-DaU-9GzO.js +0 -129
  128. package/dist/Game-CUW7NeVG.js +0 -330
  129. package/dist/LoyaltyDashboard-GqyUwvXz.js +0 -1082
  130. package/dist/MainLayout-R5NxIBR-.js +0 -41
  131. package/dist/Member-CC5F6Bmz.js +0 -280
  132. package/dist/MemberList-Cq4zxopX.js +0 -1601
  133. package/dist/Mission-DcCZ6tAG.js +0 -334
  134. package/dist/Point-D1vLd5hL.js +0 -262
  135. package/dist/Promotion-Cv7MW5RJ.js +0 -397
  136. package/dist/Review-CKhakUMe.js +0 -1123
  137. package/dist/ReviewFacebookCallback-xgRpXQAg.js +0 -243
  138. package/dist/ReviewGoogleCallback-Cqi_43qi.js +0 -208
  139. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-DDqK4kV1.js +0 -181
  140. package/dist/Store-uTRQ6KbC.js +0 -1996
  141. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-Bb2sTsuA.js +0 -1130
  142. package/dist/Transaction-CnTEfMGU.js +0 -39
  143. package/dist/campaign-CbMlARNI.js +0 -219
  144. package/dist/campaign-f7FT91GR.js +0 -277
  145. package/dist/export-DQR-0lmK.js +0 -97
  146. package/dist/index-COrXX9MR.js +0 -52
  147. package/dist/index-CWiaP-aV.js +0 -28900
  148. package/dist/index-jVfDVEtz.js +0 -85
  149. package/dist/membership-rifuatxU.js +0 -255
  150. package/dist/objectid-DjpWkCxH.js +0 -145
  151. package/dist/useMarketingMaterialActions-5TFNqZVo.js +0 -107
  152. package/dist/vue-i18n-CgMK-TaC.js +0 -2365
@@ -0,0 +1,4277 @@
1
+ import { defineComponent, ref, watch, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, unref, createCommentVNode, computed, onMounted, toDisplayString, createBlock, withCtx, Fragment, renderList, withModifiers, isRef, createTextVNode, normalizeClass, watchEffect, resolveDynamicComponent, toRefs, normalizeStyle, createSlots } from "vue";
2
+ import { _ } from "./lodash-B_gr6Ayu.js";
3
+ import { S as S6, f as Zh, z as z$1 } from "./app-DAtx6aZ4.js";
4
+ import { Z as ZodHelper } from "./zod-GTEcy37q.js";
5
+ import { F as FdoObjectId, z } from "./index-Bb4TieR_.js";
6
+ import { e as FdoGroup, F as F_RUNNABLE_CAMPAIGN_TYPE, f as FdtoRunnableCampaign, g as FdoCreditLoyaltyReward, h as FdtoRandomReward, i as F_MISSION_TYPE, j as FdoThresholdCreditReward, k as FdtoThresholdReward, l as FdoMission } from "./index-FnsjvtSo.js";
7
+ import { F as FdtoCollectibleConfig } from "./index-LnCoUCnx.js";
8
+ import { a as isRuleGroup, R as RuleBuilder, s as stripRruleDtstartExceptSchedule, i as isRuleEntry, T as TEMPLATES } from "./index-DcA0B-Y5.js";
9
+ import { g as F_APP_INBOX_DESTINATION, A as APP_INBOX_BODY_LIMIT, t as toDelivery, h as toLegacyMessage } from "./index-7TKoSEJ2.js";
10
+ import { e as CHANNEL_DISPLAY_ORDER, i as isPaidChannel, f as isChannelComplete, h as addChannel, j as setMode, k as hasDraft, l as setPrimaryChannel, r as removeChannel, m as moveChannel, n as setChannelContent, o as getCampaignSummaryObject, p as normaliseBroadcastDelivery } from "./campaign-DKjBjV2k.js";
11
+ import { u as useMembershipStore } from "./membership-ILB4aB4h.js";
12
+ import { u as useBusinessStore } from "./business-BZUIs8Ub.js";
13
+ import { J as JsonViewer } from "./JsonViewer-v8_C7l5N.js";
14
+ import { h as hooks } from "./moment-D7p2TMB-.js";
15
+ import { f as featureVersionMapping } from "./campaign.enum-BQy3e845.js";
16
+ import { _ as _sfc_main$C } from "./ImageInput.vue_vue_type_script_setup_true_lang-uQJvjvTe.js";
17
+ import { b as _sfc_main$A, a as _sfc_main$D, _ as _sfc_main$F } from "./EffectSheet.vue_vue_type_style_index_0_lang-DkKhdp7G.js";
18
+ import { _ as _sfc_main$E } from "./TargetLocationInput.vue_vue_type_script_setup_true_lang-BspBXIO2.js";
19
+ import { c as core, S as SvcConfig } from "./index-B9DM5Vuv.js";
20
+ import { p as prompt, f as firebaseStorage } from "./plugins-DLIgnFIF.js";
21
+ import { _ as _export_sfc } from "./_plugin-vue_export-helper-CHgC5LLL.js";
22
+ import { _ as _sfc_main$G } from "./UserRuleGroup.vue_vue_type_script_setup_true_lang-DSutMvfk.js";
23
+ import { a as _sfc_main$u, _ as _sfc_main$y } from "./RuleGroup.vue_vue_type_script_setup_true_lang-BgYK4hpo.js";
24
+ import { u as useI18n } from "./vue-i18n-BPeSHE3c.js";
25
+ import { T as TypeToTriggerOptions, _ as _sfc_main$H, b as _sfc_main$I } from "./trigger-LhNre1L9.js";
26
+ import { D as DEFAULT_MESSAGE_VARIABLES, b as _sfc_main$v, g as getSmsMessageMetrics, _ as _sfc_main$w, a as _sfc_main$x } from "./MessageInput.vue_vue_type_script_setup_true_lang-freeE-DP.js";
27
+ import { useCoreStore } from "@feedmepos/mf-common";
28
+ import { c as campaignApi } from "./index-kkhrPH6s.js";
29
+ import { m as membershipApi } from "./index-D_o9LsHU.js";
30
+ import { m as moment } from "./index-CVYbfRGO.js";
31
+ import { c as calculateNextScheduleAt, R as RRule, S as SummarizeRrule, g as getRruleAnchorDate } from "./rule-DBtMGLxD.js";
32
+ import { C as CountryTimezone } from "./timezone-Brs5nrTL.js";
33
+ import { _ as _sfc_main$z, a as _sfc_main$B } from "./VoucherEditor.vue_vue_type_script_setup_true_lang-B-IwtPvx.js";
34
+ import "./index-LlFZ5kxi.js";
35
+ import "./index-CXL5WAH0.js";
36
+ import { a as F_GAME_TYPE } from "./collectible.enum-vcvRFGl0.js";
37
+ import { u as useLoading } from "./loading-CzWOx4tE.js";
38
+ import { i as initCollectibleConfig } from "./helper-BGqw2-RO.js";
39
+ import { C as CollectionUtils } from "./collection.fn-C3bMPBkC.js";
40
+ import { s as sentenceCase$1 } from "./index-CuvNtC_M.js";
41
+ import { useDialog } from "@feedmepos/ui-library";
42
+ import { u as useCampaignStore } from "./campaign-B6I6PuY4.js";
43
+ import { a as cleanPF } from "./object-BYyQ0PZp.js";
44
+ function campaignRefinement(e, s) {
45
+ var i, c;
46
+ if (console.log(e, s), !e) return;
47
+ const o = e.campaign;
48
+ if (!o) return;
49
+ const d = o.event.rule;
50
+ if (!d || !isRuleGroup(d)) {
51
+ s.addIssue({
52
+ code: "custom",
53
+ path: ["campaign", "event", "rule"],
54
+ params: {
55
+ i18n: "connectZodCustom:campaign.rule_required",
56
+ type: o.event.type
57
+ }
58
+ });
59
+ return;
60
+ }
61
+ switch (o.type) {
62
+ case "MISSION": {
63
+ o.earningOption.amount > o.mission.end && s.addIssue({
64
+ code: "custom",
65
+ path: ["campaign", "earningOption"],
66
+ params: {
67
+ i18n: "connectZodCustom:campaign.earning_amount_exceed",
68
+ max: o.mission.end
69
+ }
70
+ });
71
+ break;
72
+ }
73
+ case "CREDIT": {
74
+ const l = (i = o.config) == null ? void 0 : i.validityOption;
75
+ (!l || ["validForDay", "validBefore"].every((a) => l[a] == null)) && s.addIssue({
76
+ code: "custom",
77
+ path: ["campaign", "config", "validityOption"],
78
+ params: {
79
+ i18n: "connectZodCustom:campaign.credit_validity_required"
80
+ }
81
+ });
82
+ }
83
+ }
84
+ switch (o.event.type) {
85
+ case "BILL_COMPLETED":
86
+ o.type === "MISSION" && o.rewards.length && (o.rewards.forEach((l, n) => {
87
+ (l.threshold < 0 || l.threshold > o.mission.end) && s.addIssue({
88
+ code: "custom",
89
+ path: ["campaign", "rewards", n, "threshold"],
90
+ params: {
91
+ i18n: "connectZodCustom:campaign.reward_threshold_range"
92
+ }
93
+ });
94
+ }), (c = o.config) != null && c.validityOption.followFirstReceive || s.addIssue({
95
+ code: "custom",
96
+ path: ["campaign", "config", "validityOption"],
97
+ params: {
98
+ i18n: "connectZodCustom:campaign.mission_first_receive"
99
+ }
100
+ }));
101
+ break;
102
+ case "SCHEDULE": {
103
+ if (!d.rules.g_schedule) {
104
+ s.addIssue({
105
+ code: "custom",
106
+ path: ["campaign", "event", "rule"],
107
+ params: {
108
+ i18n: "connectZodCustom:campaign.schedule_period_required"
109
+ },
110
+ fatal: !0
111
+ });
112
+ return;
113
+ }
114
+ const l = RuleBuilder.getRules(
115
+ d.rules.g_schedule
116
+ ), n = [
117
+ {
118
+ property: "trigger.date",
119
+ operator: ["_isOnDate", "_rrule"]
120
+ },
121
+ {
122
+ property: "trigger.time",
123
+ operator: ["_isOnTime"]
124
+ }
125
+ ];
126
+ n.length == l.length && n.every((r) => l.some((p) => {
127
+ const h = RuleBuilder.simplify(p);
128
+ return h.property === r.property && r.operator.includes(h.operator);
129
+ })) || s.addIssue({
130
+ code: "custom",
131
+ path: ["campaign", "event", "rule"],
132
+ params: {
133
+ i18n: "connectZodCustom:campaign.active_period_invalid"
134
+ }
135
+ });
136
+ break;
137
+ }
138
+ default: {
139
+ "earningOption" in o && o.earningOption.type != "FIXED" && s.addIssue({
140
+ code: "custom",
141
+ path: ["campaign", "earningOption"],
142
+ params: {
143
+ i18n: "connectZodCustom:campaign.fixed_earning_required"
144
+ }
145
+ });
146
+ break;
147
+ }
148
+ }
149
+ }
150
+ function campaignTransform(e) {
151
+ var o;
152
+ if (e.campaign.type === "VOUCHER" && "configs" in e) {
153
+ const d = e.configs;
154
+ d.extras.targetLocation = e.campaign.targetLocation;
155
+ const i = Math.max(
156
+ e.campaign.earningOption.amount,
157
+ d.options.maxUse ?? 1
158
+ );
159
+ e.campaign.earningOption.amount = i, d.options.maxUse = i, e.campaign.earningOption = {
160
+ type: "FIXED",
161
+ amount: 1
162
+ };
163
+ }
164
+ if (e.campaign.type == "MISSION" && "configs" in e) {
165
+ const d = e.configs;
166
+ d.options.validityOption = (o = e.campaign.config) == null ? void 0 : o.validityOption;
167
+ }
168
+ const s = e.campaign.event;
169
+ return s.type != "BILL_COMPLETED" && s.rule && isRuleGroup(s.rule) && (s.rule = RuleBuilder.removeEntry(s.rule, "g_bill"), e.campaign.event = s), s.rule && isRuleGroup(s.rule) && (s.rule = stripRruleDtstartExceptSchedule(s.rule), e.campaign.event = s), e;
170
+ }
171
+ function GenerateCampaignReq(e) {
172
+ const s = FdtoRunnableCampaign.optionsMap.get(e).extend({
173
+ _id: FdoObjectId.optional(),
174
+ collectible: z.string().nullish()
175
+ });
176
+ switch (e) {
177
+ case "VOUCHER":
178
+ return z.object({
179
+ campaign: s,
180
+ templateId: FdoObjectId,
181
+ configs: FdtoCollectibleConfig,
182
+ updateCollections: z.boolean().optional(),
183
+ code: z.string().optional()
184
+ });
185
+ case "PROMOTION":
186
+ return z.object({
187
+ campaign: s,
188
+ templateId: FdoObjectId
189
+ });
190
+ case "POINT":
191
+ return z.object({
192
+ campaign: s,
193
+ templateId: FdoObjectId
194
+ });
195
+ case "CREDIT":
196
+ return z.object({
197
+ campaign: s,
198
+ templateId: FdoObjectId
199
+ });
200
+ case "BROADCAST":
201
+ return z.object({
202
+ campaign: s.refine((o) => !!o.delivery || !!o.message, {
203
+ path: ["delivery"],
204
+ message: "A broadcast requires a message or delivery configuration."
205
+ }),
206
+ templateId: FdoObjectId
207
+ });
208
+ case "COIN":
209
+ return z.object({
210
+ campaign: s,
211
+ templateId: FdoObjectId
212
+ });
213
+ case "REWARD_POOL":
214
+ return z.object({
215
+ campaign: s,
216
+ templateId: FdoObjectId,
217
+ updateCollections: z.boolean().optional()
218
+ });
219
+ case "GAME":
220
+ return z.object({
221
+ campaign: s,
222
+ configs: FdtoCollectibleConfig,
223
+ templateId: FdoObjectId,
224
+ updateCollections: z.boolean().optional()
225
+ });
226
+ case "MISSION":
227
+ return z.object({
228
+ campaign: s,
229
+ configs: FdtoCollectibleConfig,
230
+ templateId: FdoObjectId,
231
+ updateCollections: z.boolean().optional()
232
+ });
233
+ case "GRAB":
234
+ return z.object({
235
+ campaign: s,
236
+ templateId: FdoObjectId
237
+ });
238
+ default:
239
+ throw new Error("Not implemented");
240
+ }
241
+ }
242
+ FdoGroup.extend({
243
+ _id: FdoObjectId.optional(),
244
+ name: z.string().min(1).max(300),
245
+ business: FdoObjectId.optional(),
246
+ campaigns: z.array(FdoObjectId).optional()
247
+ });
248
+ const CampaignDtos = {
249
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.VOUCHER]: GenerateCampaignReq("VOUCHER"),
250
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.PROMOTION]: GenerateCampaignReq("PROMOTION"),
251
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.POINT]: GenerateCampaignReq("POINT"),
252
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.CREDIT]: GenerateCampaignReq("CREDIT"),
253
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.BROADCAST]: GenerateCampaignReq("BROADCAST"),
254
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.COIN]: GenerateCampaignReq("COIN"),
255
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.REWARD_POOL]: GenerateCampaignReq("REWARD_POOL"),
256
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.GAME]: GenerateCampaignReq("GAME"),
257
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.MISSION]: GenerateCampaignReq("MISSION"),
258
+ [F_RUNNABLE_CAMPAIGN_TYPE.enum.GRAB]: GenerateCampaignReq("GRAB")
259
+ };
260
+ function summarizeGrabDiscount(e) {
261
+ if (!e)
262
+ return null;
263
+ const s = core.Config.getCountry().currency.symbol;
264
+ function o(l) {
265
+ switch (l.scope.type) {
266
+ case "order":
267
+ return "Bill discount";
268
+ case "items":
269
+ return l.type.startsWith("bundle") ? d(l.type) : "Item discount";
270
+ case "categories":
271
+ return "Category discount";
272
+ default:
273
+ return "Discount";
274
+ }
275
+ }
276
+ function d(l) {
277
+ switch (l) {
278
+ case "bundleSameFixPrice":
279
+ return "Bundle (same item) - Fixed price";
280
+ case "bundleDiffFixPrice":
281
+ return "Bundle (different items) - Fixed price";
282
+ case "bundleSameNet":
283
+ return "Bundle (same item) - Amount off";
284
+ case "bundleDiffNet":
285
+ return "Bundle (different items) - Amount off";
286
+ case "bundleSamePercentage":
287
+ return "Bundle (same item) - Percentage off";
288
+ case "bundleDiffPercentage":
289
+ return "Bundle (different items) - Percentage off";
290
+ default:
291
+ return "Bundle discount";
292
+ }
293
+ }
294
+ function i(l) {
295
+ switch (l.type) {
296
+ case "percentage":
297
+ case "bundleSamePercentage":
298
+ case "bundleDiffPercentage":
299
+ return `${l.value}% discount`;
300
+ case "net":
301
+ case "bundleSameNet":
302
+ case "bundleDiffNet":
303
+ return `${s}${l.value} discount`;
304
+ case "bundleSameFixPrice":
305
+ case "bundleDiffFixPrice":
306
+ return `${s}${l.value} fixed price`;
307
+ case "delivery":
308
+ return "Delivery fee discount";
309
+ case "freeItem":
310
+ return "Free item";
311
+ default:
312
+ return `${s}${l.value} discount`;
313
+ }
314
+ }
315
+ function c(l) {
316
+ return l.cap && l.cap > 0 ? `capped at ${s}${l.cap}` : null;
317
+ }
318
+ return {
319
+ type: o(e),
320
+ adjustment: i(e),
321
+ cap: c(e)
322
+ };
323
+ }
324
+ const _hoisted_1$r = {
325
+ key: 0,
326
+ class: "bg-fm-color-neutral-gray-50 border border-fm-color-neutral-gray-200 rounded-8 p-16 space-y-16"
327
+ }, _hoisted_2$n = { class: "flex items-center justify-between" }, _hoisted_3$k = { class: "flex items-center gap-8" }, _hoisted_4$j = { class: "bg-white border border-fm-color-neutral-gray-200 rounded-8 p-16" }, _hoisted_5$g = { class: "flex justify-end gap-8 pt-8 border-t border-fm-color-neutral-gray-200" }, _sfc_main$t = /* @__PURE__ */ defineComponent({
328
+ __name: "GrabItemSelectionInline",
329
+ props: {
330
+ visible: { type: Boolean },
331
+ initialValue: {},
332
+ filterItems: { type: Function }
333
+ },
334
+ emits: ["confirm", "cancel"],
335
+ setup(e, { emit: s }) {
336
+ const o = e, d = s, i = ref();
337
+ watch(
338
+ () => o.visible,
339
+ (a) => {
340
+ var r, p;
341
+ !a && i.value && ((p = (r = i.value).setSelectedItems) == null || p.call(r, o.initialValue || []));
342
+ }
343
+ );
344
+ function c() {
345
+ var a;
346
+ (a = i.value) == null || a.onConfirm();
347
+ }
348
+ function l() {
349
+ d("cancel");
350
+ }
351
+ function n(a) {
352
+ d("confirm", a);
353
+ }
354
+ return (a, r) => {
355
+ const p = resolveComponent("FmIcon"), h = resolveComponent("FmButton");
356
+ return e.visible ? (openBlock(), createElementBlock("div", _hoisted_1$r, [
357
+ createElementVNode("div", _hoisted_2$n, [
358
+ createElementVNode("div", _hoisted_3$k, [
359
+ createVNode(p, {
360
+ name: "restaurant",
361
+ size: "md"
362
+ }),
363
+ r[0] || (r[0] = createElementVNode("h3", { class: "fm-typo-en-body-lg-600" }, "Select Items", -1))
364
+ ]),
365
+ createVNode(h, {
366
+ icon: "close",
367
+ variant: "tertiary",
368
+ onClick: l
369
+ })
370
+ ]),
371
+ 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)),
372
+ createElementVNode("div", _hoisted_4$j, [
373
+ createVNode(unref(S6), {
374
+ ref_key: "selectItemRef",
375
+ ref: i,
376
+ "initial-value": e.initialValue,
377
+ "filter-items": e.filterItems,
378
+ "on-complete": n,
379
+ "max-height": 300
380
+ }, null, 8, ["initial-value", "filter-items"])
381
+ ]),
382
+ createElementVNode("div", _hoisted_5$g, [
383
+ createVNode(h, {
384
+ variant: "secondary",
385
+ label: "Cancel",
386
+ onClick: l
387
+ }),
388
+ createVNode(h, {
389
+ variant: "primary",
390
+ label: "Confirm Selection",
391
+ onClick: c
392
+ })
393
+ ])
394
+ ])) : createCommentVNode("", !0);
395
+ };
396
+ }
397
+ }), _hoisted_1$q = {
398
+ key: 0,
399
+ class: "bg-fm-color-neutral-gray-50 border border-fm-color-neutral-gray-200 rounded-8 p-16 space-y-16"
400
+ }, _hoisted_2$m = { class: "flex items-center justify-between" }, _hoisted_3$j = { class: "flex items-center gap-8" }, _hoisted_4$i = { class: "flex gap-16 items-center flex-wrap" }, _hoisted_5$f = { class: "flex gap-8 items-center" }, _hoisted_6$b = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_7$a = { class: "bg-white border border-fm-color-neutral-gray-200 rounded-8 max-h-[300px] overflow-y-auto" }, _hoisted_8$8 = { class: "flex items-center gap-12" }, _hoisted_9$8 = { class: "fm-typo-en-body-md-600" }, _hoisted_10$8 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_11$6 = {
401
+ key: 1,
402
+ class: "p-24 text-center"
403
+ }, _hoisted_12$5 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_13$5 = { class: "flex justify-end gap-8 pt-8 border-t border-fm-color-neutral-gray-200" }, _sfc_main$s = /* @__PURE__ */ defineComponent({
404
+ __name: "GrabCategorySelectionInline",
405
+ props: {
406
+ visible: { type: Boolean },
407
+ initialValue: {}
408
+ },
409
+ emits: ["confirm", "cancel"],
410
+ setup(e, { emit: s }) {
411
+ const o = e, d = s, i = Zh(), c = ref({}), l = ref(""), n = computed(() => {
412
+ const u = i.menu.value;
413
+ return u ? u.modules.category.map((m) => ({
414
+ id: m._id,
415
+ name: m.name
416
+ })) : [];
417
+ }), a = computed(() => {
418
+ if (!l.value) return n.value;
419
+ const u = l.value.toLowerCase();
420
+ return n.value.filter(
421
+ (m) => m.name.toLowerCase().includes(u)
422
+ );
423
+ }), r = computed(() => Object.values(c.value).filter(Boolean).length);
424
+ function p() {
425
+ c.value = n.value.reduce(
426
+ (u, m) => (u[m.id] = o.initialValue.includes(m.id), u),
427
+ {}
428
+ );
429
+ }
430
+ watch([() => o.visible, () => o.initialValue], () => {
431
+ o.visible && p();
432
+ }), onMounted(async () => {
433
+ await i.store.getMenu(), p();
434
+ });
435
+ function h(u) {
436
+ c.value[u] = !c.value[u];
437
+ }
438
+ function y() {
439
+ const u = r.value === a.value.length;
440
+ a.value.forEach((m) => {
441
+ c.value[m.id] = !u;
442
+ });
443
+ }
444
+ function V() {
445
+ Object.keys(c.value).forEach((u) => {
446
+ c.value[u] = !1;
447
+ });
448
+ }
449
+ function x() {
450
+ const u = Object.entries(c.value).filter(([, m]) => m).map(([m]) => m);
451
+ d("confirm", u);
452
+ }
453
+ function f() {
454
+ d("cancel");
455
+ }
456
+ const v = computed(() => a.value.length > 0 && a.value.every(
457
+ (u) => c.value[u.id]
458
+ ));
459
+ return (u, m) => {
460
+ const C = resolveComponent("FmIcon"), k = resolveComponent("FmButton"), $ = resolveComponent("FmTextField"), F = resolveComponent("FmCheckbox"), N = resolveComponent("FmListItem"), D = resolveComponent("FmList");
461
+ return e.visible ? (openBlock(), createElementBlock("div", _hoisted_1$q, [
462
+ createElementVNode("div", _hoisted_2$m, [
463
+ createElementVNode("div", _hoisted_3$j, [
464
+ createVNode(C, {
465
+ name: "category",
466
+ size: "md"
467
+ }),
468
+ m[2] || (m[2] = createElementVNode("h3", { class: "fm-typo-en-body-lg-600" }, "Select Categories", -1))
469
+ ]),
470
+ createVNode(k, {
471
+ icon: "close",
472
+ variant: "tertiary",
473
+ onClick: f
474
+ })
475
+ ]),
476
+ m[3] || (m[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)),
477
+ createElementVNode("div", _hoisted_4$i, [
478
+ createElementVNode("div", _hoisted_5$f, [
479
+ createVNode(k, {
480
+ icon: "select_all",
481
+ variant: "tertiary",
482
+ size: "small",
483
+ label: `${v.value ? "Deselect" : "Select"} All`,
484
+ onClick: y
485
+ }, null, 8, ["label"]),
486
+ createVNode(k, {
487
+ icon: "sync",
488
+ variant: "tertiary",
489
+ size: "small",
490
+ label: "Clear",
491
+ onClick: V
492
+ }),
493
+ createElementVNode("span", _hoisted_6$b, toDisplayString(r.value) + " selected ", 1)
494
+ ]),
495
+ createVNode($, {
496
+ modelValue: l.value,
497
+ "onUpdate:modelValue": m[0] || (m[0] = (w) => l.value = w),
498
+ placeholder: "Search categories",
499
+ "leading-icon": { name: "search", color: "" },
500
+ class: "flex-1 min-w-[200px]"
501
+ }, null, 8, ["modelValue"])
502
+ ]),
503
+ createElementVNode("div", _hoisted_7$a, [
504
+ a.value.length > 0 ? (openBlock(), createBlock(D, { key: 0 }, {
505
+ default: withCtx(() => [
506
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(a.value, (w) => (openBlock(), createBlock(N, {
507
+ key: w.id,
508
+ clickable: !0,
509
+ onClick: (O) => h(w.id)
510
+ }, {
511
+ leading: withCtx(() => [
512
+ createVNode(F, {
513
+ "model-value": c.value[w.id] || !1,
514
+ value: w.id,
515
+ "onUpdate:modelValue": (O) => h(w.id),
516
+ onClick: m[1] || (m[1] = withModifiers(() => {
517
+ }, ["stop"]))
518
+ }, null, 8, ["model-value", "value", "onUpdate:modelValue"])
519
+ ]),
520
+ default: withCtx(() => [
521
+ createElementVNode("div", _hoisted_8$8, [
522
+ createVNode(C, {
523
+ name: "category",
524
+ size: "sm",
525
+ class: "text-fm-color-typo-secondary"
526
+ }),
527
+ createElementVNode("div", null, [
528
+ createElementVNode("div", _hoisted_9$8, toDisplayString(w.name), 1),
529
+ createElementVNode("div", _hoisted_10$8, " ID: " + toDisplayString(w.id), 1)
530
+ ])
531
+ ])
532
+ ]),
533
+ _: 2
534
+ }, 1032, ["onClick"]))), 128))
535
+ ]),
536
+ _: 1
537
+ })) : (openBlock(), createElementBlock("div", _hoisted_11$6, [
538
+ createElementVNode("div", _hoisted_12$5, toDisplayString(l.value ? "No categories found matching your search." : "No categories available."), 1)
539
+ ]))
540
+ ]),
541
+ createElementVNode("div", _hoisted_13$5, [
542
+ createVNode(k, {
543
+ variant: "secondary",
544
+ label: "Cancel",
545
+ onClick: f
546
+ }),
547
+ createVNode(k, {
548
+ variant: "primary",
549
+ label: `Confirm Selection (${r.value})`,
550
+ disabled: r.value === 0,
551
+ onClick: x
552
+ }, null, 8, ["label", "disabled"])
553
+ ])
554
+ ])) : createCommentVNode("", !0);
555
+ };
556
+ }
557
+ }), _hoisted_1$p = { class: "space-y-8" }, _hoisted_2$l = {
558
+ key: 1,
559
+ class: "border-1 rounded-md flex gap-16 items-center justify-between px-16 py-12"
560
+ }, _hoisted_3$i = { class: "fm-typo-en-body-lg-400" }, _hoisted_4$h = { class: "text-fm-color-typo-secondary" }, _hoisted_5$e = { key: 0 }, _hoisted_6$a = { class: "space-y-24" }, _hoisted_7$9 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary mt-4" }, _hoisted_8$7 = { key: 0 }, _hoisted_9$7 = { class: "fm-typo-en-body-md-600 mb-8 block" }, _hoisted_10$7 = { key: 1 }, _hoisted_11$5 = { key: 2 }, _hoisted_12$4 = { key: 0 }, _hoisted_13$4 = { class: "space-y-8" }, _hoisted_14$4 = { class: "flex items-center justify-between p-12 border border-fm-color-neutral-gray-200 fm-corner-radius-md" }, _hoisted_15$3 = { class: "flex items-center gap-8" }, _hoisted_16$2 = { class: "fm-typo-en-body-md-400" }, _hoisted_17$2 = { key: 3 }, _hoisted_18$2 = { key: 0 }, _hoisted_19$2 = { class: "space-y-8" }, _hoisted_20$2 = { class: "flex items-center justify-between p-12 border border-fm-color-neutral-gray-200 fm-corner-radius-md" }, _hoisted_21$1 = { class: "flex items-center gap-8" }, _hoisted_22$1 = { class: "fm-typo-en-body-md-400" }, _hoisted_23$1 = {
561
+ key: 0,
562
+ class: "mt-16 p-12 bg-fm-color-feedback-error-light rounded-8 border border-fm-color-feedback-error-main"
563
+ }, _hoisted_24$1 = { 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$r = /* @__PURE__ */ defineComponent({
564
+ __name: "GrabEffectSheet",
565
+ props: {
566
+ modelValue: { type: Object }
567
+ },
568
+ emits: ["update:model-value"],
569
+ setup(e, { emit: s }) {
570
+ const o = e, d = s, i = Zh(), c = ref(!1), l = ref(!1), n = ref(!1), a = ref({
571
+ type: "net",
572
+ value: 0,
573
+ scope: {
574
+ type: "order"
575
+ }
576
+ });
577
+ watch(
578
+ () => o.modelValue,
579
+ (b) => {
580
+ b && (a.value = { ...b });
581
+ },
582
+ { immediate: !0 }
583
+ ), onMounted(async () => {
584
+ await i.store.getMenu();
585
+ });
586
+ const r = computed(() => {
587
+ var b;
588
+ return !(!a.value.type || !((b = a.value.scope) != null && b.type) || y(a.value.type) && (!a.value.value || a.value.value <= 0) || (a.value.scope.type === "items" || a.value.scope.type === "category") && (!a.value.scope.objectIDs || a.value.scope.objectIDs.length === 0));
589
+ });
590
+ async function p(b) {
591
+ b.stopPropagation(), await prompt.remove("Are you sure you want to remove this discount?") && d("update:model-value", null);
592
+ }
593
+ function h() {
594
+ var b;
595
+ return C(((b = a.value.scope) == null ? void 0 : b.type) || "order");
596
+ }
597
+ function y(b) {
598
+ return b && !["freeItem", "delivery"].includes(b);
599
+ }
600
+ function V(b) {
601
+ return b && ["percentage", "bundleSamePercentage", "bundleDiffPercentage"].includes(
602
+ b
603
+ );
604
+ }
605
+ function x(b) {
606
+ return b != null && b.includes("Percentage") ? "Discount percentage" : b != null && b.includes("FixPrice") ? "Bundle fixed price" : b === "percentage" ? "Discount percentage" : "Discount amount";
607
+ }
608
+ function f(b) {
609
+ return b != null && b.includes("Percentage") || b === "percentage" ? "10" : "5.00";
610
+ }
611
+ function v(b) {
612
+ return b != null && b.includes("Percentage") || b === "percentage" ? "%" : "$";
613
+ }
614
+ function u(b, B) {
615
+ a.value = {
616
+ ...a.value,
617
+ [b]: B
618
+ };
619
+ }
620
+ function m(b, B) {
621
+ var U;
622
+ const T = {
623
+ ...a.value.scope,
624
+ [b]: B
625
+ };
626
+ if (a.value = {
627
+ ...a.value,
628
+ scope: T
629
+ }, b === "type") {
630
+ const P = C(B);
631
+ P.some(
632
+ (g) => g.value === a.value.type
633
+ ) || (a.value = {
634
+ ...a.value,
635
+ type: ((U = P[0]) == null ? void 0 : U.value) || "net",
636
+ // Reset value and cap when changing to incompatible type
637
+ value: 0,
638
+ cap: void 0
639
+ });
640
+ }
641
+ }
642
+ function C(b) {
643
+ switch (b) {
644
+ case "order":
645
+ return [
646
+ { label: "Amount off", value: "net" },
647
+ { label: "Percentage off", value: "percentage" },
648
+ { label: "Delivery fee off", value: "delivery" }
649
+ ];
650
+ case "category":
651
+ return [
652
+ { label: "Amount off", value: "net" },
653
+ { label: "Percentage off", value: "percentage" }
654
+ ];
655
+ case "items":
656
+ return [
657
+ { label: "Amount off", value: "net" },
658
+ { label: "Percentage off", value: "percentage" },
659
+ { label: "Free item", value: "freeItem" },
660
+ {
661
+ label: "Bundle (same item) - Fixed price",
662
+ value: "bundleSameFixPrice"
663
+ },
664
+ { label: "Bundle (same item) - Amount off", value: "bundleSameNet" },
665
+ {
666
+ label: "Bundle (same item) - Percentage off",
667
+ value: "bundleSamePercentage"
668
+ },
669
+ {
670
+ label: "Bundle (different items) - Fixed price",
671
+ value: "bundleDiffFixPrice"
672
+ },
673
+ {
674
+ label: "Bundle (different items) - Amount off",
675
+ value: "bundleDiffNet"
676
+ },
677
+ {
678
+ label: "Bundle (different items) - Percentage off",
679
+ value: "bundleDiffPercentage"
680
+ }
681
+ ];
682
+ default:
683
+ return [
684
+ { label: "Amount off", value: "net" },
685
+ { label: "Percentage off", value: "percentage" }
686
+ ];
687
+ }
688
+ }
689
+ function k(b) {
690
+ switch (b) {
691
+ case "order":
692
+ return "Applies to entire order. Available: Amount off, Percentage off, Delivery fee discount.";
693
+ case "category":
694
+ return "Applies to specific item categories. Available: Amount off, Percentage off, Free item.";
695
+ case "items":
696
+ return "Applies to specific items. Available: Basic discounts, Bundle offers (same/different items).";
697
+ default:
698
+ return "Select how you want to apply the discount.";
699
+ }
700
+ }
701
+ function $() {
702
+ var b;
703
+ return ((b = a.value.scope) == null ? void 0 : b.type) === "items";
704
+ }
705
+ function F() {
706
+ var b;
707
+ return ((b = a.value.scope) == null ? void 0 : b.type) === "category";
708
+ }
709
+ function N() {
710
+ var T;
711
+ const b = (T = a.value.scope) == null ? void 0 : T.objectIDs;
712
+ if (!b || b.length === 0)
713
+ return "No items selected";
714
+ const B = i.menu.value;
715
+ return B && b.length <= 3 ? b.map((P) => {
716
+ const A = B.modules.item.find((g) => g._id === P);
717
+ return A ? (A.name2 || A.name).trim() : `Item ${P}`;
718
+ }).join(", ") : b.length === 1 ? "1 item selected" : `${b.length} items selected`;
719
+ }
720
+ function D() {
721
+ var T;
722
+ const b = (T = a.value.scope) == null ? void 0 : T.objectIDs;
723
+ if (!b || b.length === 0)
724
+ return "No categories selected";
725
+ const B = i.menu.value;
726
+ return B && b.length <= 3 ? b.map((P) => {
727
+ const A = B.modules.category.find((g) => g._id === P);
728
+ return A ? A.name : `Category ${P}`;
729
+ }).join(", ") : b.length === 1 ? "1 category selected" : `${b.length} categories selected`;
730
+ }
731
+ function w() {
732
+ l.value = !0;
733
+ }
734
+ function O() {
735
+ n.value = !0;
736
+ }
737
+ function j(b) {
738
+ m("objectIDs", b), l.value = !1;
739
+ }
740
+ function I(b) {
741
+ m("objectIDs", b), n.value = !1;
742
+ }
743
+ function H() {
744
+ l.value = !1;
745
+ }
746
+ function q() {
747
+ n.value = !1;
748
+ }
749
+ const G = computed(() => {
750
+ var B, T, U;
751
+ const b = [];
752
+ return a.value.type || b.push("Discount type is required"), (B = a.value.scope) != null && B.type || b.push("Scope type is required"), y(a.value.type) && (!a.value.value || a.value.value <= 0) && b.push("Discount amount must be greater than 0"), ((T = a.value.scope) == null ? void 0 : T.type) === "items" && (!a.value.scope.objectIDs || a.value.scope.objectIDs.length === 0) && b.push("Please select at least one item"), ((U = a.value.scope) == null ? void 0 : U.type) === "category" && (!a.value.scope.objectIDs || a.value.scope.objectIDs.length === 0) && b.push("Please select at least one category"), b;
753
+ });
754
+ function Y() {
755
+ d("update:model-value", a.value), c.value = !1;
756
+ }
757
+ const Z = [
758
+ { label: "Bill discount", value: "order" },
759
+ { label: "Item discount", value: "items" },
760
+ { label: "Category discount", value: "category" }
761
+ ];
762
+ return (b, B) => {
763
+ const T = resolveComponent("FmButton"), U = resolveComponent("FmSelect"), P = resolveComponent("FmStepperField"), A = resolveComponent("FmIcon"), g = resolveComponent("FmSideSheet");
764
+ return openBlock(), createBlock(g, {
765
+ "max-width": 550,
766
+ header: "Apply discount",
767
+ modelValue: unref(c),
768
+ "onUpdate:modelValue": [
769
+ B[5] || (B[5] = (E) => isRef(c) ? c.value = E : null),
770
+ B[6] || (B[6] = (E) => c.value = E)
771
+ ]
772
+ }, {
773
+ "side-sheet-button": withCtx(() => {
774
+ var E, R, M, S;
775
+ return [
776
+ createElementVNode("div", _hoisted_1$p, [
777
+ B[7] || (B[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)),
778
+ e.modelValue ? (openBlock(), createElementBlock("div", _hoisted_2$l, [
779
+ createElementVNode("div", _hoisted_3$i, [
780
+ createElementVNode("div", null, toDisplayString((E = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : E.type), 1),
781
+ createElementVNode("div", _hoisted_4$h, [
782
+ createTextVNode(toDisplayString((R = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : R.adjustment) + " ", 1),
783
+ (M = unref(summarizeGrabDiscount)(e.modelValue)) != null && M.cap ? (openBlock(), createElementBlock("span", _hoisted_5$e, toDisplayString((S = unref(summarizeGrabDiscount)(e.modelValue)) == null ? void 0 : S.cap), 1)) : createCommentVNode("", !0)
784
+ ])
785
+ ]),
786
+ createVNode(T, {
787
+ icon: "delete",
788
+ "icon-color": "neutral-gray-400",
789
+ variant: "tertiary",
790
+ onClick: p
791
+ })
792
+ ])) : (openBlock(), createBlock(T, {
793
+ key: 0,
794
+ label: "Apply Grab discount",
795
+ icon: "add",
796
+ "icon-color": "primary",
797
+ variant: "secondary",
798
+ class: "border-fm-color-primary text-fm-color-primary"
799
+ }))
800
+ ])
801
+ ];
802
+ }),
803
+ "side-sheet-footer": withCtx(() => [
804
+ createElementVNode("div", _hoisted_26, [
805
+ createVNode(T, {
806
+ variant: "secondary",
807
+ label: "Cancel",
808
+ class: "flex-1",
809
+ onClick: B[4] || (B[4] = (E) => c.value = !1)
810
+ }),
811
+ createVNode(T, {
812
+ variant: "primary",
813
+ label: unref(r) ? "Confirm" : "Complete Required Fields",
814
+ class: "flex-1",
815
+ disabled: !unref(r),
816
+ onClick: Y
817
+ }, null, 8, ["label", "disabled"])
818
+ ])
819
+ ]),
820
+ default: withCtx(() => {
821
+ var E, R, M, S;
822
+ return [
823
+ createElementVNode("div", _hoisted_6$a, [
824
+ createElementVNode("div", null, [
825
+ B[8] || (B[8] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Campaign type", -1)),
826
+ createVNode(U, {
827
+ "model-value": ((E = unref(a).scope) == null ? void 0 : E.type) || "order",
828
+ "onUpdate:modelValue": B[0] || (B[0] = (L) => m("type", L)),
829
+ placeholder: "Select campaign type",
830
+ items: Z
831
+ }, null, 8, ["model-value"]),
832
+ createElementVNode("div", _hoisted_7$9, toDisplayString(k((R = unref(a).scope) == null ? void 0 : R.type)), 1)
833
+ ]),
834
+ createElementVNode("div", null, [
835
+ B[9] || (B[9] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Discount type", -1)),
836
+ createVNode(U, {
837
+ "model-value": unref(a).type,
838
+ "onUpdate:modelValue": B[1] || (B[1] = (L) => u("type", L)),
839
+ placeholder: "Select discount type",
840
+ items: h()
841
+ }, null, 8, ["model-value", "items"])
842
+ ]),
843
+ y(unref(a).type) ? (openBlock(), createElementBlock("div", _hoisted_8$7, [
844
+ createElementVNode("label", _hoisted_9$7, toDisplayString(x(unref(a).type)), 1),
845
+ createVNode(P, {
846
+ modelValue: unref(a).value,
847
+ "onUpdate:modelValue": B[2] || (B[2] = (L) => unref(a).value = L),
848
+ placeholder: f(unref(a).type),
849
+ suffix: v(unref(a).type),
850
+ type: "number"
851
+ }, null, 8, ["modelValue", "placeholder", "suffix"])
852
+ ])) : createCommentVNode("", !0),
853
+ V(unref(a).type) ? (openBlock(), createElementBlock("div", _hoisted_10$7, [
854
+ B[10] || (B[10] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Discount cap (optional)", -1)),
855
+ createVNode(P, {
856
+ modelValue: unref(a).cap,
857
+ "onUpdate:modelValue": B[3] || (B[3] = (L) => unref(a).cap = L),
858
+ placeholder: "Maximum discount amount",
859
+ type: "number"
860
+ }, null, 8, ["modelValue"])
861
+ ])) : createCommentVNode("", !0),
862
+ $() ? (openBlock(), createElementBlock("div", _hoisted_11$5, [
863
+ unref(l) ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_12$4, [
864
+ B[12] || (B[12] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Select Items", -1)),
865
+ createElementVNode("div", _hoisted_13$4, [
866
+ createElementVNode("div", _hoisted_14$4, [
867
+ createElementVNode("div", _hoisted_15$3, [
868
+ createVNode(A, {
869
+ name: "restaurant",
870
+ size: "md"
871
+ }),
872
+ createElementVNode("span", _hoisted_16$2, toDisplayString(N()), 1)
873
+ ]),
874
+ createVNode(T, {
875
+ variant: "secondary",
876
+ label: "Select Items",
877
+ icon: "chevron_right",
878
+ onClick: w
879
+ })
880
+ ]),
881
+ B[11] || (B[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))
882
+ ])
883
+ ])),
884
+ createVNode(_sfc_main$t, {
885
+ visible: unref(l),
886
+ "initial-value": ((M = unref(a).scope) == null ? void 0 : M.objectIDs) || [],
887
+ onConfirm: j,
888
+ onCancel: H
889
+ }, null, 8, ["visible", "initial-value"])
890
+ ])) : createCommentVNode("", !0),
891
+ F() ? (openBlock(), createElementBlock("div", _hoisted_17$2, [
892
+ unref(n) ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_18$2, [
893
+ B[14] || (B[14] = createElementVNode("label", { class: "fm-typo-en-body-md-600 mb-8 block" }, "Select Categories", -1)),
894
+ createElementVNode("div", _hoisted_19$2, [
895
+ createElementVNode("div", _hoisted_20$2, [
896
+ createElementVNode("div", _hoisted_21$1, [
897
+ createVNode(A, {
898
+ name: "category",
899
+ size: "md"
900
+ }),
901
+ createElementVNode("span", _hoisted_22$1, toDisplayString(D()), 1)
902
+ ]),
903
+ createVNode(T, {
904
+ variant: "secondary",
905
+ label: "Select Categories",
906
+ icon: "chevron_right",
907
+ onClick: O
908
+ })
909
+ ]),
910
+ B[13] || (B[13] = createElementVNode("div", { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, " Choose which categories this discount applies to. ", -1))
911
+ ])
912
+ ])),
913
+ createVNode(_sfc_main$s, {
914
+ visible: unref(n),
915
+ "initial-value": ((S = unref(a).scope) == null ? void 0 : S.objectIDs) || [],
916
+ onConfirm: I,
917
+ onCancel: q
918
+ }, null, 8, ["visible", "initial-value"])
919
+ ])) : createCommentVNode("", !0)
920
+ ]),
921
+ unref(G).length > 0 ? (openBlock(), createElementBlock("div", _hoisted_23$1, [
922
+ createElementVNode("div", _hoisted_24$1, [
923
+ createVNode(A, { name: "warning" }),
924
+ B[15] || (B[15] = createElementVNode("span", { class: "fm-typo-en-body-sm-600" }, "Please fix the following issues:", -1))
925
+ ]),
926
+ createElementVNode("ul", _hoisted_25, [
927
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(G), (L) => (openBlock(), createElementBlock("li", {
928
+ key: L,
929
+ class: "fm-typo-en-body-sm-400 text-fm-color-feedback-error-main flex items-start gap-8"
930
+ }, [
931
+ B[16] || (B[16] = createElementVNode("span", { class: "w-4 h-4 bg-fm-color-feedback-error-main rounded-full mt-6 flex-shrink-0" }, null, -1)),
932
+ createTextVNode(" " + toDisplayString(L), 1)
933
+ ]))), 128))
934
+ ])
935
+ ])) : createCommentVNode("", !0)
936
+ ];
937
+ }),
938
+ _: 1
939
+ }, 8, ["modelValue"]);
940
+ };
941
+ }
942
+ }), GrabEffectSheet = /* @__PURE__ */ _export_sfc(_sfc_main$r, [["__scopeId", "data-v-cf604dd7"]]), _hoisted_1$o = { class: "space-y-24" }, _sfc_main$q = /* @__PURE__ */ defineComponent({
943
+ __name: "TimeRuleGroup",
944
+ props: {
945
+ modelValue: {
946
+ type: Object,
947
+ default: () => {
948
+ }
949
+ }
950
+ },
951
+ emits: ["update:model-value"],
952
+ setup(e, { emit: s }) {
953
+ const { t: o } = useI18n(), d = e, i = s, c = ref(
954
+ !d.modelValue || !d.modelValue.rules.g_time ? "all_time" : RuleBuilder.getRules(d.modelValue.rules.g_time).length > 0 ? "custom" : "all_time"
955
+ );
956
+ watch(c, async (n, a) => {
957
+ var r;
958
+ if (a == "custom" && n == "all_time" && RuleBuilder.getRules((r = d.modelValue) == null ? void 0 : r.rules.g_time).length > 0) {
959
+ const p = await prompt.confirm(
960
+ o("connect.template.rule.time.confirm_remove"),
961
+ o("connect.common.confirm"),
962
+ o("connect.common.confirm"),
963
+ o("connect.common.cancel")
964
+ );
965
+ p && i(
966
+ "update:model-value",
967
+ RuleBuilder.setRuleToGroup(
968
+ d.modelValue ?? RuleBuilder.scaffoldGroup(),
969
+ RuleBuilder.scaffoldGroup("g_time")
970
+ )
971
+ ), c.value = p ? n : a;
972
+ }
973
+ });
974
+ async function l(n) {
975
+ var a;
976
+ if (n == "custom" && RuleBuilder.getRules((a = d.modelValue) == null ? void 0 : a.rules.g_time).length > 0) {
977
+ if (!await prompt.confirm(
978
+ o("connect.template.rule.time.confirm_remove"),
979
+ o("connect.common.confirm"),
980
+ o("connect.common.confirm"),
981
+ o("connect.common.cancel")
982
+ )) {
983
+ c.value = "all_time";
984
+ return;
985
+ }
986
+ i(
987
+ "update:model-value",
988
+ RuleBuilder.setRuleToGroup(
989
+ d.modelValue ?? RuleBuilder.scaffoldGroup(),
990
+ RuleBuilder.scaffoldGroup("g_time")
991
+ )
992
+ );
993
+ }
994
+ }
995
+ return (n, a) => {
996
+ var h;
997
+ const r = resolveComponent("FmRadio"), p = resolveComponent("FmRadioGroup");
998
+ return openBlock(), createElementBlock("div", _hoisted_1$o, [
999
+ createVNode(p, {
1000
+ modelValue: unref(c),
1001
+ "onUpdate:modelValue": [
1002
+ a[0] || (a[0] = (y) => isRef(c) ? c.value = y : null),
1003
+ a[1] || (a[1] = (y) => l(y))
1004
+ ]
1005
+ }, {
1006
+ default: withCtx(() => [
1007
+ createVNode(r, {
1008
+ label: unref(o)("connect.template.rule.time.all_time"),
1009
+ value: "all_time"
1010
+ }, null, 8, ["label"]),
1011
+ createVNode(r, {
1012
+ label: unref(o)("connect.template.rule.time.custom"),
1013
+ value: "custom"
1014
+ }, null, 8, ["label"])
1015
+ ]),
1016
+ _: 1
1017
+ }, 8, ["modelValue"]),
1018
+ unref(c) == "custom" ? (openBlock(), createBlock(_sfc_main$u, {
1019
+ key: 0,
1020
+ class: "!mt-[0px]",
1021
+ "include-only": "trigger",
1022
+ "trigger-type": "SCHEDULE",
1023
+ "model-value": ((h = e.modelValue) == null ? void 0 : h.rules.g_time) ?? unref(RuleBuilder).scaffoldGroup("g_time"),
1024
+ "onUpdate:modelValue": a[2] || (a[2] = (y) => i(
1025
+ "update:model-value",
1026
+ unref(RuleBuilder).setRuleToGroup(
1027
+ e.modelValue ?? unref(RuleBuilder).scaffoldGroup(),
1028
+ y,
1029
+ "&&"
1030
+ )
1031
+ ))
1032
+ }, null, 8, ["model-value"])) : createCommentVNode("", !0)
1033
+ ]);
1034
+ };
1035
+ }
1036
+ }), _sfc_main$p = /* @__PURE__ */ defineComponent({
1037
+ __name: "BirthdayInput",
1038
+ props: {
1039
+ modelValue: {
1040
+ type: Object
1041
+ }
1042
+ },
1043
+ emits: ["update:model-value"],
1044
+ setup(e, { emit: s }) {
1045
+ const { t: o } = useI18n(), d = e, i = s, c = computed(() => {
1046
+ const { property: l, operator: n, equator: a } = RuleBuilder.simplify(
1047
+ d.modelValue ?? RuleBuilder.constructEntry("user.birthday", "_isDay", {
1048
+ op: "before",
1049
+ x: 1
1050
+ })
1051
+ );
1052
+ return {
1053
+ property: l,
1054
+ operator: n,
1055
+ equator: a
1056
+ };
1057
+ });
1058
+ return (l, n) => {
1059
+ const a = resolveComponent("FmRadio"), r = resolveComponent("FmStepperField");
1060
+ return openBlock(), createElementBlock("div", null, [
1061
+ createVNode(a, {
1062
+ label: unref(o)("connect.template.rule.birthday.on_birthday"),
1063
+ value: "_isRange-day",
1064
+ "model-value": `${unref(c).operator}-${unref(c).equator.unit}`,
1065
+ "onUpdate:modelValue": n[0] || (n[0] = () => {
1066
+ i(
1067
+ "update:model-value",
1068
+ unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
1069
+ op: "this",
1070
+ unit: "day",
1071
+ ignoreYear: !0
1072
+ })
1073
+ );
1074
+ })
1075
+ }, null, 8, ["label", "model-value"]),
1076
+ createVNode(a, {
1077
+ label: unref(o)("connect.template.rule.birthday.days_before"),
1078
+ value: "_isDay",
1079
+ "model-value": unref(c).operator,
1080
+ "onUpdate:modelValue": n[1] || (n[1] = () => {
1081
+ i(
1082
+ "update:model-value",
1083
+ unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
1084
+ op: "after",
1085
+ x: 1,
1086
+ ignoreYear: !0
1087
+ })
1088
+ );
1089
+ })
1090
+ }, null, 8, ["label", "model-value"]),
1091
+ unref(c).operator == "_isDay" ? (openBlock(), createBlock(r, {
1092
+ key: 0,
1093
+ label: unref(o)("connect.template.rule.birthday.days_before_label"),
1094
+ "show-steppers": !1,
1095
+ "model-value": unref(c).equator.x,
1096
+ "onUpdate:modelValue": n[2] || (n[2] = (p) => i(
1097
+ "update:model-value",
1098
+ unref(RuleBuilder).constructEntry("user.birthday", "_isDay", {
1099
+ op: "after",
1100
+ x: p,
1101
+ ignoreYear: !0
1102
+ })
1103
+ ))
1104
+ }, null, 8, ["label", "model-value"])) : createCommentVNode("", !0),
1105
+ createVNode(a, {
1106
+ label: unref(o)("connect.template.rule.birthday.in_birthday_week"),
1107
+ value: "_isRange-week",
1108
+ "model-value": `${unref(c).operator}-${unref(c).equator.unit}`,
1109
+ "onUpdate:modelValue": n[3] || (n[3] = () => {
1110
+ i(
1111
+ "update:model-value",
1112
+ unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
1113
+ op: "this",
1114
+ unit: "week",
1115
+ ignoreYear: !0
1116
+ })
1117
+ );
1118
+ })
1119
+ }, null, 8, ["label", "model-value"]),
1120
+ createVNode(a, {
1121
+ label: unref(o)("connect.template.rule.birthday.in_birthday_month"),
1122
+ value: "_isRange-month",
1123
+ "model-value": `${unref(c).operator}-${unref(c).equator.unit}`,
1124
+ "onUpdate:modelValue": n[4] || (n[4] = () => {
1125
+ i(
1126
+ "update:model-value",
1127
+ unref(RuleBuilder).constructEntry("user.birthday", "_isRange", {
1128
+ op: "this",
1129
+ unit: "month",
1130
+ ignoreYear: !0
1131
+ })
1132
+ );
1133
+ })
1134
+ }, null, 8, ["label", "model-value"])
1135
+ ]);
1136
+ };
1137
+ }
1138
+ }), _hoisted_1$n = { class: "space-y-16" }, _hoisted_2$k = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_3$h = { class: "grid grid-cols-3 gap-16" }, _hoisted_4$g = { class: "fm-typo-en-title-sm-800" }, _hoisted_5$d = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _sfc_main$o = /* @__PURE__ */ defineComponent({
1139
+ __name: "CampaignTriggerInput",
1140
+ props: {
1141
+ campaignType: {
1142
+ type: String,
1143
+ required: !0
1144
+ },
1145
+ modelValue: {
1146
+ type: String
1147
+ },
1148
+ disabled: {
1149
+ type: Boolean,
1150
+ default: !1
1151
+ }
1152
+ },
1153
+ emits: ["update:model-value"],
1154
+ setup(e, { emit: s }) {
1155
+ const { t: o } = useI18n(), d = e, i = s, c = computed(() => d.disabled ? TypeToTriggerOptions[d.campaignType].filter(
1156
+ (l) => l.value == d.modelValue
1157
+ ) : TypeToTriggerOptions[d.campaignType]);
1158
+ return (l, n) => {
1159
+ const a = resolveComponent("FmCard");
1160
+ return openBlock(), createElementBlock("div", _hoisted_1$n, [
1161
+ createElementVNode("div", _hoisted_2$k, toDisplayString(unref(o)("connect.campaign.trigger.description")), 1),
1162
+ createElementVNode("div", _hoisted_3$h, [
1163
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(c), (r) => (openBlock(), createBlock(a, {
1164
+ variant: "outlined",
1165
+ disabled: d.disabled,
1166
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
1167
+ "col-span-3": unref(c).length == 1,
1168
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == r.value,
1169
+ "hover:bg-fm-color-opacity-sm": e.modelValue != r.value
1170
+ }]),
1171
+ onClick: () => {
1172
+ d.modelValue != r.value && !d.disabled && i("update:model-value", r.value);
1173
+ },
1174
+ key: r.name
1175
+ }, {
1176
+ default: withCtx(() => [
1177
+ createElementVNode("div", _hoisted_4$g, toDisplayString(r.name), 1),
1178
+ createElementVNode("div", _hoisted_5$d, toDisplayString(r.description), 1)
1179
+ ]),
1180
+ _: 2
1181
+ }, 1032, ["disabled", "class", "onClick"]))), 128))
1182
+ ])
1183
+ ]);
1184
+ };
1185
+ }
1186
+ }), _sfc_main$n = /* @__PURE__ */ defineComponent({
1187
+ __name: "DateInput",
1188
+ props: {
1189
+ label: {
1190
+ type: String,
1191
+ required: !1
1192
+ },
1193
+ modelValue: {
1194
+ type: Object,
1195
+ required: !1
1196
+ }
1197
+ },
1198
+ emits: ["update:model-value"],
1199
+ setup(e, { emit: s }) {
1200
+ const o = s;
1201
+ return (d, i) => {
1202
+ const c = resolveComponent("FmButton"), l = resolveComponent("FmField"), n = resolveComponent("FmDatePicker");
1203
+ return openBlock(), createBlock(n, {
1204
+ label: e.label,
1205
+ "model-value": e.modelValue || "",
1206
+ "onUpdate:modelValue": i[1] || (i[1] = (a) => o("update:model-value", a))
1207
+ }, {
1208
+ "trigger-button": withCtx(({ opened: a }) => [
1209
+ createVNode(l, {
1210
+ class: "flex items-center",
1211
+ "prepend-icon": "calendar_month",
1212
+ "icon-outlined": !a
1213
+ }, {
1214
+ append: withCtx(() => [
1215
+ e.modelValue ? (openBlock(), createBlock(c, {
1216
+ key: 0,
1217
+ variant: "tertiary",
1218
+ icon: "clear",
1219
+ onClick: i[0] || (i[0] = (r) => (r.stopPropagation(), o("update:model-value", null)))
1220
+ })) : createCommentVNode("", !0)
1221
+ ]),
1222
+ default: withCtx(() => [
1223
+ createElementVNode("div", {
1224
+ class: normalizeClass(["fm-typo-en-body-lg-400", { "text-fm-color-typo-secondary": !e.modelValue }])
1225
+ }, toDisplayString(e.modelValue ? unref(hooks)(e.modelValue).format("DD MMM YYYY") : "DD MM YYYY"), 3)
1226
+ ]),
1227
+ _: 1
1228
+ }, 8, ["icon-outlined"])
1229
+ ]),
1230
+ _: 1
1231
+ }, 8, ["label", "model-value"]);
1232
+ };
1233
+ }
1234
+ }), _hoisted_1$m = { class: "flex items-center gap-8 w-full xs:flex-col" }, _hoisted_2$j = { class: "flex-1 xs:w-full" }, _hoisted_3$g = { class: "mt-5 xs:hidden" }, _hoisted_4$f = { class: "flex-1 xs:w-full" }, _sfc_main$m = /* @__PURE__ */ defineComponent({
1235
+ __name: "DateRangeInput",
1236
+ props: {
1237
+ modelValue: {
1238
+ type: Object,
1239
+ required: !1
1240
+ }
1241
+ },
1242
+ emits: ["update:model-value"],
1243
+ setup(e, { emit: s }) {
1244
+ const { t: o } = useI18n(), d = s;
1245
+ return (i, c) => {
1246
+ var l, n;
1247
+ return openBlock(), createElementBlock("div", _hoisted_1$m, [
1248
+ createElementVNode("div", _hoisted_2$j, [
1249
+ createVNode(_sfc_main$n, {
1250
+ "model-value": ((l = e.modelValue) == null ? void 0 : l.startDate) ?? null,
1251
+ label: unref(o)("connect.common.startDate"),
1252
+ "onUpdate:modelValue": c[0] || (c[0] = (a) => {
1253
+ var r;
1254
+ return d("update:model-value", {
1255
+ startDate: a,
1256
+ endDate: ((r = e.modelValue) == null ? void 0 : r.endDate) ?? null
1257
+ });
1258
+ })
1259
+ }, null, 8, ["model-value", "label"])
1260
+ ]),
1261
+ createElementVNode("div", _hoisted_3$g, toDisplayString(unref(o)("connect.common.to")), 1),
1262
+ createElementVNode("div", _hoisted_4$f, [
1263
+ createVNode(_sfc_main$n, {
1264
+ "model-value": ((n = e.modelValue) == null ? void 0 : n.endDate) ?? null,
1265
+ label: unref(o)("connect.common.endDate"),
1266
+ "onUpdate:modelValue": c[1] || (c[1] = (a) => {
1267
+ var r;
1268
+ return d("update:model-value", {
1269
+ startDate: ((r = e.modelValue) == null ? void 0 : r.startDate) ?? null,
1270
+ endDate: a
1271
+ });
1272
+ })
1273
+ }, null, 8, ["model-value", "label"])
1274
+ ])
1275
+ ]);
1276
+ };
1277
+ }
1278
+ }), _hoisted_1$l = { class: "flex flex-col gap-16" }, _hoisted_2$i = { class: "mb-[6px] flex items-baseline justify-between" }, _hoisted_3$f = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, _hoisted_4$e = { class: "mb-[6px] flex items-baseline justify-between" }, _hoisted_5$c = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, _hoisted_6$9 = { class: "flex items-center justify-between gap-8" }, _hoisted_7$8 = { class: "fm-typo-en-body-lg-400" }, _hoisted_8$6 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_9$6 = { class: "flex flex-col gap-8" }, _hoisted_10$6 = { class: "flex items-baseline justify-between" }, _hoisted_11$4 = { class: "fm-typo-en-body-lg-400" }, _hoisted_12$3 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_13$3 = { class: "min-w-[160px] flex-1" }, _hoisted_14$3 = { class: "min-w-[180px] flex-1" }, TITLE_LIMIT$1 = 40, PREVIEW_LIMIT = 120, MAX_BUTTONS = 2, TITLE_WARN_AT$1 = 34, PREVIEW_WARN_AT = 110, _sfc_main$l = /* @__PURE__ */ defineComponent({
1279
+ __name: "AppInboxInput",
1280
+ props: {
1281
+ modelValue: {
1282
+ type: Object,
1283
+ required: !0
1284
+ },
1285
+ variables: {
1286
+ type: Array,
1287
+ default: () => [...DEFAULT_MESSAGE_VARIABLES]
1288
+ }
1289
+ },
1290
+ emits: ["update:model-value"],
1291
+ setup(e, { emit: s }) {
1292
+ const { t: o } = useI18n(), d = e, i = s, c = F_APP_INBOX_DESTINATION.options;
1293
+ function l(V) {
1294
+ i("update:model-value", { ...d.modelValue, ...V });
1295
+ }
1296
+ function n(V, x) {
1297
+ return V >= x ? "text-fm-color-system-warning-400" : "text-fm-color-typo-secondary";
1298
+ }
1299
+ const a = computed(() => d.modelValue.buttons ?? []), r = computed(() => {
1300
+ var V;
1301
+ return ((V = d.modelValue.content) == null ? void 0 : V.length) ?? 0;
1302
+ });
1303
+ function p(V, x) {
1304
+ l({
1305
+ buttons: a.value.map(
1306
+ (f, v) => v === V ? { ...f, ...x } : f
1307
+ )
1308
+ });
1309
+ }
1310
+ function h() {
1311
+ a.value.length >= MAX_BUTTONS || l({ buttons: [...a.value, { label: "", destination: "NONE" }] });
1312
+ }
1313
+ function y(V) {
1314
+ l({ buttons: a.value.filter((x, f) => f !== V) });
1315
+ }
1316
+ return (V, x) => {
1317
+ const f = resolveComponent("FmTextField"), v = resolveComponent("FmSelect"), u = resolveComponent("FmButton");
1318
+ return openBlock(), createElementBlock("div", _hoisted_1$l, [
1319
+ createElementVNode("div", null, [
1320
+ createElementVNode("div", _hoisted_2$i, [
1321
+ createElementVNode("span", _hoisted_3$f, toDisplayString(unref(o)("connect.campaign.appInbox.title")), 1),
1322
+ createElementVNode("span", {
1323
+ class: normalizeClass(["fm-typo-en-body-sm-400", n(e.modelValue.title.length, TITLE_WARN_AT$1)])
1324
+ }, toDisplayString(e.modelValue.title.length) + " / " + toDisplayString(TITLE_LIMIT$1), 3)
1325
+ ]),
1326
+ createVNode(f, {
1327
+ "model-value": e.modelValue.title,
1328
+ "max-length": TITLE_LIMIT$1,
1329
+ placeholder: unref(o)("connect.campaign.appInbox.titlePlaceholder"),
1330
+ "onUpdate:modelValue": x[0] || (x[0] = (m) => l({ title: m }))
1331
+ }, null, 8, ["model-value", "placeholder"])
1332
+ ]),
1333
+ createElementVNode("div", null, [
1334
+ createElementVNode("div", _hoisted_4$e, [
1335
+ createElementVNode("span", _hoisted_5$c, toDisplayString(unref(o)("connect.campaign.appInbox.previewText")), 1),
1336
+ createElementVNode("span", {
1337
+ class: normalizeClass(["fm-typo-en-body-sm-400", n(e.modelValue.previewText.length, PREVIEW_WARN_AT)])
1338
+ }, toDisplayString(e.modelValue.previewText.length) + " / " + toDisplayString(PREVIEW_LIMIT), 3)
1339
+ ]),
1340
+ createVNode(f, {
1341
+ "model-value": e.modelValue.previewText,
1342
+ "max-length": PREVIEW_LIMIT,
1343
+ placeholder: unref(o)("connect.campaign.appInbox.previewTextPlaceholder"),
1344
+ "onUpdate:modelValue": x[1] || (x[1] = (m) => l({ previewText: m }))
1345
+ }, null, 8, ["model-value", "placeholder"])
1346
+ ]),
1347
+ createElementVNode("div", _hoisted_6$9, [
1348
+ createElementVNode("div", null, [
1349
+ createElementVNode("div", _hoisted_7$8, toDisplayString(unref(o)("connect.campaign.appInbox.bodyMessage")), 1),
1350
+ createElementVNode("div", _hoisted_8$6, toDisplayString(unref(o)("connect.campaign.appInbox.bodyMessageDescription")), 1),
1351
+ createElementVNode("div", {
1352
+ class: normalizeClass([
1353
+ "mt-[2px] fm-typo-en-body-sm-400",
1354
+ unref(r) > unref(APP_INBOX_BODY_LIMIT) ? "text-fm-color-system-error-400" : "text-fm-color-typo-secondary"
1355
+ ])
1356
+ }, toDisplayString(unref(r)) + " / " + toDisplayString(unref(APP_INBOX_BODY_LIMIT)), 3)
1357
+ ]),
1358
+ createVNode(_sfc_main$v, {
1359
+ html: e.modelValue.content,
1360
+ variables: e.variables,
1361
+ "media-limit": 1,
1362
+ "button-label": unref(o)("connect.campaign.appInbox.editBodyMessage"),
1363
+ "onUpdate:html": x[2] || (x[2] = (m) => l({ content: m.html }))
1364
+ }, null, 8, ["html", "variables", "button-label"])
1365
+ ]),
1366
+ createElementVNode("div", _hoisted_9$6, [
1367
+ createElementVNode("div", _hoisted_10$6, [
1368
+ createElementVNode("span", _hoisted_11$4, toDisplayString(unref(o)("connect.campaign.appInbox.buttons")), 1),
1369
+ createElementVNode("span", _hoisted_12$3, toDisplayString(unref(a).length) + " / " + toDisplayString(MAX_BUTTONS), 1)
1370
+ ]),
1371
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(a), (m, C) => (openBlock(), createElementBlock("div", {
1372
+ key: C,
1373
+ class: "flex flex-wrap items-start gap-8"
1374
+ }, [
1375
+ createElementVNode("div", _hoisted_13$3, [
1376
+ createVNode(f, {
1377
+ "model-value": m.label,
1378
+ placeholder: unref(o)("connect.campaign.appInbox.buttonLabel"),
1379
+ "onUpdate:modelValue": (k) => p(C, { label: k })
1380
+ }, null, 8, ["model-value", "placeholder", "onUpdate:modelValue"])
1381
+ ]),
1382
+ createElementVNode("div", _hoisted_14$3, [
1383
+ createVNode(v, {
1384
+ "model-value": m.destination,
1385
+ items: unref(c).map((k) => ({
1386
+ label: unref(o)(`connect.campaign.appInbox.destination.${k}`),
1387
+ value: k
1388
+ })),
1389
+ "onUpdate:modelValue": (k) => p(C, { destination: k })
1390
+ }, null, 8, ["model-value", "items", "onUpdate:modelValue"])
1391
+ ]),
1392
+ createVNode(u, {
1393
+ icon: "delete",
1394
+ "icon-color": "neutral-gray-400",
1395
+ variant: "tertiary",
1396
+ onClick: (k) => y(C)
1397
+ }, null, 8, ["onClick"])
1398
+ ]))), 128)),
1399
+ unref(a).length < MAX_BUTTONS ? (openBlock(), createBlock(u, {
1400
+ key: 0,
1401
+ variant: "tertiary",
1402
+ icon: "add",
1403
+ label: unref(o)("connect.campaign.appInbox.addButton"),
1404
+ onClick: h
1405
+ }, null, 8, ["label"])) : createCommentVNode("", !0)
1406
+ ])
1407
+ ]);
1408
+ };
1409
+ }
1410
+ }), _hoisted_1$k = { class: "flex flex-col gap-16" }, _hoisted_2$h = { class: "mb-[6px] flex items-baseline justify-between" }, _hoisted_3$e = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, _hoisted_4$d = { class: "mb-[6px] flex items-baseline justify-between" }, _hoisted_5$b = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, _hoisted_6$8 = { class: "mb-[6px] fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, _hoisted_7$7 = { class: "mt-4 fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, TITLE_LIMIT = 40, BODY_LIMIT = 120, TITLE_WARN_AT = 34, BODY_WARN_AT = 110, _sfc_main$k = /* @__PURE__ */ defineComponent({
1411
+ __name: "PushInput",
1412
+ props: {
1413
+ modelValue: {
1414
+ type: Object,
1415
+ required: !0
1416
+ }
1417
+ },
1418
+ emits: ["update:model-value"],
1419
+ setup(e, { emit: s }) {
1420
+ const { t: o } = useI18n(), d = e, i = s, c = F_APP_INBOX_DESTINATION.options;
1421
+ function l(a) {
1422
+ i("update:model-value", { ...d.modelValue, ...a });
1423
+ }
1424
+ function n(a, r) {
1425
+ return a >= r ? "text-fm-color-system-warning-400" : "text-fm-color-typo-secondary";
1426
+ }
1427
+ return (a, r) => {
1428
+ const p = resolveComponent("FmTextField"), h = resolveComponent("FmTextarea"), y = resolveComponent("FmSelect");
1429
+ return openBlock(), createElementBlock("div", _hoisted_1$k, [
1430
+ createElementVNode("div", null, [
1431
+ createElementVNode("div", _hoisted_2$h, [
1432
+ createElementVNode("span", _hoisted_3$e, toDisplayString(unref(o)("connect.campaign.push.title")), 1),
1433
+ createElementVNode("span", {
1434
+ class: normalizeClass(["fm-typo-en-body-sm-400", n(e.modelValue.title.length, TITLE_WARN_AT)])
1435
+ }, toDisplayString(e.modelValue.title.length) + " / " + toDisplayString(TITLE_LIMIT), 3)
1436
+ ]),
1437
+ createVNode(p, {
1438
+ "model-value": e.modelValue.title,
1439
+ "max-length": TITLE_LIMIT,
1440
+ placeholder: unref(o)("connect.campaign.push.titlePlaceholder"),
1441
+ "onUpdate:modelValue": r[0] || (r[0] = (V) => l({ title: V }))
1442
+ }, null, 8, ["model-value", "placeholder"])
1443
+ ]),
1444
+ createElementVNode("div", null, [
1445
+ createElementVNode("div", _hoisted_4$d, [
1446
+ createElementVNode("span", _hoisted_5$b, toDisplayString(unref(o)("connect.campaign.push.body")), 1),
1447
+ createElementVNode("span", {
1448
+ class: normalizeClass(["fm-typo-en-body-sm-400", n(e.modelValue.body.length, BODY_WARN_AT)])
1449
+ }, toDisplayString(e.modelValue.body.length) + " / " + toDisplayString(BODY_LIMIT), 3)
1450
+ ]),
1451
+ createVNode(h, {
1452
+ "model-value": e.modelValue.body,
1453
+ "max-length": BODY_LIMIT,
1454
+ placeholder: unref(o)("connect.campaign.push.bodyPlaceholder"),
1455
+ "onUpdate:modelValue": r[1] || (r[1] = (V) => l({ body: V }))
1456
+ }, null, 8, ["model-value", "placeholder"])
1457
+ ]),
1458
+ createElementVNode("div", null, [
1459
+ createElementVNode("div", _hoisted_6$8, toDisplayString(unref(o)("connect.campaign.push.link")), 1),
1460
+ createVNode(y, {
1461
+ "model-value": e.modelValue.destination ?? "NONE",
1462
+ items: unref(c).map((V) => ({
1463
+ label: unref(o)(`connect.campaign.appInbox.destination.${V}`),
1464
+ value: V
1465
+ })),
1466
+ "onUpdate:modelValue": r[2] || (r[2] = (V) => l({ destination: V }))
1467
+ }, null, 8, ["model-value", "items"]),
1468
+ createElementVNode("div", _hoisted_7$7, toDisplayString(unref(o)("connect.campaign.push.linkHelper")), 1)
1469
+ ])
1470
+ ]);
1471
+ };
1472
+ }
1473
+ }), _hoisted_1$j = { class: "flex items-stretch overflow-x-auto pb-4" }, _hoisted_2$g = {
1474
+ key: 0,
1475
+ class: "flex flex-none items-center px-8 fm-typo-en-body-lg-600 text-fm-color-neutral-gray-300",
1476
+ "aria-hidden": "true"
1477
+ }, _hoisted_3$d = ["aria-current", "onClick"], _hoisted_4$c = { class: "flex items-center gap-[6px]" }, _hoisted_5$a = ["title"], _hoisted_6$7 = { class: "mt-[3px] block text-[11px] leading-[1.3] text-fm-color-typo-secondary" }, _sfc_main$j = /* @__PURE__ */ defineComponent({
1478
+ __name: "ChannelContentTabs",
1479
+ props: {
1480
+ tabs: {},
1481
+ modelValue: {}
1482
+ },
1483
+ emits: ["update:model-value"],
1484
+ setup(e) {
1485
+ const { t: s } = useI18n();
1486
+ return (o, d) => (openBlock(), createElementBlock("div", _hoisted_1$j, [
1487
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(e.tabs, (i) => (openBlock(), createElementBlock("div", {
1488
+ key: i.key,
1489
+ class: "flex flex-none items-center"
1490
+ }, [
1491
+ i.connector ? (openBlock(), createElementBlock("span", _hoisted_2$g, toDisplayString(i.connector), 1)) : createCommentVNode("", !0),
1492
+ createElementVNode("button", {
1493
+ type: "button",
1494
+ class: normalizeClass([
1495
+ "min-w-[132px] flex-none rounded-[10px] border px-[14px] py-[10px] text-left transition-colors",
1496
+ e.modelValue === i.key ? "border-fm-color-primary bg-fm-color-system-warning-100" : "border-fm-color-neutral-gray-100 bg-fm-color-neutral-white hover:border-fm-color-neutral-gray-200"
1497
+ ]),
1498
+ "aria-current": e.modelValue === i.key ? "true" : void 0,
1499
+ onClick: (c) => o.$emit("update:model-value", i.key)
1500
+ }, [
1501
+ createElementVNode("span", _hoisted_4$c, [
1502
+ i.step ? (openBlock(), createElementBlock("span", {
1503
+ key: 0,
1504
+ class: normalizeClass([
1505
+ "flex h-[18px] w-[18px] flex-none items-center justify-center rounded-full text-[10.5px] font-semibold leading-[18px]",
1506
+ e.modelValue === i.key ? "bg-fm-color-primary text-fm-color-typo-white" : "bg-fm-color-neutral-gray-100 text-fm-color-typo-secondary"
1507
+ ])
1508
+ }, toDisplayString(i.step), 3)) : createCommentVNode("", !0),
1509
+ createElementVNode("span", {
1510
+ class: normalizeClass([
1511
+ "truncate text-[12.5px] font-semibold leading-[1.3]",
1512
+ e.modelValue === i.key ? "text-fm-color-primary" : "text-fm-color-typo-primary"
1513
+ ])
1514
+ }, toDisplayString(i.label), 3),
1515
+ i.complete ? createCommentVNode("", !0) : (openBlock(), createElementBlock("span", {
1516
+ key: 1,
1517
+ class: "h-[7px] w-[7px] flex-none rounded-full bg-fm-color-system-error-400",
1518
+ title: unref(s)("connect.campaign.broadcast.messageMissing")
1519
+ }, null, 8, _hoisted_5$a))
1520
+ ]),
1521
+ createElementVNode("span", _hoisted_6$7, toDisplayString(i.sub), 1)
1522
+ ], 10, _hoisted_3$d)
1523
+ ]))), 128))
1524
+ ]));
1525
+ }
1526
+ }), _hoisted_1$i = {
1527
+ key: 0,
1528
+ class: "flex w-[264px] shrink-0 flex-col gap-8"
1529
+ }, _hoisted_2$f = { class: "fm-typo-en-body-md-600" }, _hoisted_3$c = { class: "flex justify-center py-8" }, _hoisted_4$b = {
1530
+ key: 0,
1531
+ class: "px-12 pb-16 pt-16"
1532
+ }, _hoisted_5$9 = { class: "mb-12 text-center text-[11px] text-[rgba(255,255,255,0.6)]" }, _hoisted_6$6 = { class: "rounded-[14px] border border-[rgba(255,255,255,0.12)] bg-[rgba(255,255,255,0.14)] p-12 backdrop-blur" }, _hoisted_7$6 = { class: "fm-typo-en-body-md-600 text-fm-color-typo-white line-clamp-2" }, _hoisted_8$5 = { class: "mt-[2px] fm-typo-en-body-sm-400 text-[rgba(255,255,255,0.72)] line-clamp-3" }, _hoisted_9$5 = {
1533
+ key: 1,
1534
+ class: "px-12 pb-16"
1535
+ }, _hoisted_10$5 = { class: "fm-typo-en-body-md-600 mb-8" }, _hoisted_11$3 = { class: "rounded-[12px] border border-fm-color-neutral-gray-100 p-12" }, _hoisted_12$2 = { class: "fm-typo-en-body-md-600 line-clamp-2" }, _hoisted_13$2 = { class: "mt-[2px] fm-typo-en-body-sm-400 text-fm-color-typo-secondary line-clamp-3" }, _hoisted_14$2 = ["src"], _hoisted_15$2 = ["srcdoc", "title"], _hoisted_16$1 = {
1536
+ key: 2,
1537
+ class: "mt-12 flex flex-col gap-[6px]"
1538
+ }, _hoisted_17$1 = {
1539
+ key: 2,
1540
+ class: "px-12 pb-16"
1541
+ }, _hoisted_18$1 = { class: "fm-typo-en-body-md-600 mb-8" }, _hoisted_19$1 = { class: "whitespace-pre-wrap break-words rounded-[12px] bg-fm-color-neutral-gray-100 p-12 fm-typo-en-body-sm-400" }, _hoisted_20$1 = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _sfc_main$i = /* @__PURE__ */ defineComponent({
1542
+ __name: "ChannelPreview",
1543
+ props: {
1544
+ target: {},
1545
+ content: {},
1546
+ senderPrefix: {}
1547
+ },
1548
+ setup(e) {
1549
+ const { t: s } = useI18n(), o = e, d = computed(
1550
+ () => o.target === "PUSH" ? o.content : void 0
1551
+ ), i = computed(
1552
+ () => o.target === "APP_INBOX" ? o.content : void 0
1553
+ ), c = computed(
1554
+ () => o.target === "SMS" || o.target === "WHATSAPP" ? o.content : void 0
1555
+ ), l = computed(() => {
1556
+ var h, y;
1557
+ const p = (y = (h = c.value) == null ? void 0 : h.content) == null ? void 0 : y.trim();
1558
+ return p ? o.senderPrefix ? `${o.senderPrefix}${p}` : p : s("connect.campaign.broadcast.preview.emptyText");
1559
+ }), n = computed(() => {
1560
+ var h;
1561
+ const p = ((h = i.value) == null ? void 0 : h.content) ?? "";
1562
+ return p.trim() ? `<!doctype html><meta charset="utf-8"><base target="_blank"><style>
1563
+ html,body{margin:0;font:400 12px/1.5 Inter,system-ui,sans-serif;color:#1C1C1E;word-break:break-word}
1564
+ img{max-width:100%;height:auto}
1565
+ </style>${p}` : "";
1566
+ }), a = computed(() => {
1567
+ const p = /* @__PURE__ */ new Date(), h = p.toLocaleDateString(void 0, {
1568
+ weekday: "short",
1569
+ day: "2-digit",
1570
+ month: "short"
1571
+ }), y = p.toLocaleTimeString(void 0, {
1572
+ hour: "2-digit",
1573
+ minute: "2-digit"
1574
+ });
1575
+ return `${h} · ${y}`;
1576
+ }), r = computed(() => o.target === "PUSH" ? s("connect.campaign.broadcast.preview.note.push") : o.target === "APP_INBOX" ? s("connect.campaign.broadcast.preview.note.inbox") : s("connect.campaign.broadcast.preview.note.text"));
1577
+ return (p, h) => {
1578
+ var y, V, x, f, v, u, m, C, k, $, F;
1579
+ return e.target !== "EMAIL" ? (openBlock(), createElementBlock("div", _hoisted_1$i, [
1580
+ createElementVNode("div", _hoisted_2$f, toDisplayString(unref(s)("connect.campaign.broadcast.preview.title")), 1),
1581
+ createElementVNode("div", {
1582
+ class: normalizeClass([
1583
+ "overflow-hidden rounded-[22px] border border-fm-color-neutral-gray-100",
1584
+ e.target === "PUSH" ? "bg-fm-color-neutral-black" : "bg-fm-color-neutral-white"
1585
+ ])
1586
+ }, [
1587
+ createElementVNode("div", _hoisted_3$c, [
1588
+ createElementVNode("div", {
1589
+ class: normalizeClass([
1590
+ "h-4 w-40 rounded-full",
1591
+ e.target === "PUSH" ? "bg-fm-color-neutral-gray-400" : "bg-fm-color-neutral-gray-100"
1592
+ ])
1593
+ }, null, 2)
1594
+ ]),
1595
+ e.target === "PUSH" ? (openBlock(), createElementBlock("div", _hoisted_4$b, [
1596
+ createElementVNode("div", _hoisted_5$9, toDisplayString(unref(a)), 1),
1597
+ createElementVNode("div", _hoisted_6$6, [
1598
+ createElementVNode("div", _hoisted_7$6, toDisplayString(((V = (y = unref(d)) == null ? void 0 : y.title) == null ? void 0 : V.trim()) || unref(s)("connect.campaign.broadcast.preview.emptyTitle")), 1),
1599
+ createElementVNode("div", _hoisted_8$5, toDisplayString(((f = (x = unref(d)) == null ? void 0 : x.body) == null ? void 0 : f.trim()) || unref(s)("connect.campaign.broadcast.preview.emptyBody")), 1)
1600
+ ])
1601
+ ])) : e.target === "APP_INBOX" ? (openBlock(), createElementBlock("div", _hoisted_9$5, [
1602
+ createElementVNode("div", _hoisted_10$5, toDisplayString(unref(s)("connect.campaign.broadcast.preview.inboxHeading")), 1),
1603
+ createElementVNode("div", _hoisted_11$3, [
1604
+ createElementVNode("div", _hoisted_12$2, toDisplayString(((u = (v = unref(i)) == null ? void 0 : v.title) == null ? void 0 : u.trim()) || unref(s)("connect.campaign.broadcast.preview.emptyTitle")), 1),
1605
+ createElementVNode("div", _hoisted_13$2, toDisplayString(((C = (m = unref(i)) == null ? void 0 : m.previewText) == null ? void 0 : C.trim()) || unref(s)("connect.campaign.broadcast.preview.emptyBody")), 1),
1606
+ (k = unref(i)) != null && k.imageUrl ? (openBlock(), createElementBlock("img", {
1607
+ key: 0,
1608
+ src: unref(i).imageUrl,
1609
+ alt: "",
1610
+ class: "mt-8 w-full rounded-[8px]"
1611
+ }, null, 8, _hoisted_14$2)) : createCommentVNode("", !0),
1612
+ unref(n) ? (openBlock(), createElementBlock("iframe", {
1613
+ key: 1,
1614
+ srcdoc: unref(n),
1615
+ sandbox: "",
1616
+ referrerpolicy: "no-referrer",
1617
+ class: "mt-8 h-[120px] w-full border-0",
1618
+ title: unref(s)("connect.campaign.broadcast.preview.bodyFrameTitle")
1619
+ }, null, 8, _hoisted_15$2)) : createCommentVNode("", !0),
1620
+ (F = ($ = unref(i)) == null ? void 0 : $.buttons) != null && F.length ? (openBlock(), createElementBlock("div", _hoisted_16$1, [
1621
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(i).buttons, (N, D) => (openBlock(), createElementBlock("div", {
1622
+ key: D,
1623
+ class: "rounded-[8px] bg-fm-color-primary px-12 py-8 text-center fm-typo-en-body-sm-400 text-fm-color-typo-white"
1624
+ }, toDisplayString(N.label || unref(s)("connect.campaign.appInbox.buttonLabel")), 1))), 128))
1625
+ ])) : createCommentVNode("", !0)
1626
+ ])
1627
+ ])) : (openBlock(), createElementBlock("div", _hoisted_17$1, [
1628
+ createElementVNode("div", _hoisted_18$1, toDisplayString(unref(s)(`connect.campaign.broadcast.channel.${e.target}`)), 1),
1629
+ createElementVNode("div", _hoisted_19$1, toDisplayString(unref(l)), 1)
1630
+ ]))
1631
+ ], 2),
1632
+ createElementVNode("div", _hoisted_20$1, toDisplayString(unref(r)), 1)
1633
+ ])) : createCommentVNode("", !0);
1634
+ };
1635
+ }
1636
+ }), _hoisted_1$h = { class: "flex flex-col gap-12 pt-8" }, _hoisted_2$e = { class: "flex flex-wrap items-baseline justify-between gap-16" }, _hoisted_3$b = { class: "fm-typo-en-body-lg-600" }, _hoisted_4$a = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, _hoisted_5$8 = { class: "h-24 w-24 flex-none rounded-full bg-fm-color-neutral-gray-100 text-center fm-typo-en-body-sm-400 leading-[24px]" }, _hoisted_6$5 = { class: "min-w-0 flex-1" }, _hoisted_7$5 = { class: "flex flex-wrap items-center gap-[10px]" }, _hoisted_8$4 = { class: "fm-typo-en-body-md-600" }, _hoisted_9$4 = {
1637
+ key: 0,
1638
+ class: "inline-flex items-center gap-[5px] fm-typo-en-body-sm-400 text-fm-color-system-error-400"
1639
+ }, _hoisted_10$4 = { class: "ml-auto flex flex-none items-center gap-[2px] border-l border-fm-color-neutral-gray-100 pl-4" }, _hoisted_11$2 = ["title"], _hoisted_12$1 = ["title"], _hoisted_13$1 = ["title"], _hoisted_14$1 = {
1640
+ type: "button",
1641
+ class: "w-full rounded-[8px] border-2 border-dashed border-fm-color-neutral-gray-200 p-[20px] fm-typo-en-body-lg-600 text-fm-color-typo-secondary transition-colors hover:border-fm-color-primary hover:text-fm-color-primary"
1642
+ }, _hoisted_15$1 = {
1643
+ key: 1,
1644
+ class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1645
+ }, _sfc_main$h = /* @__PURE__ */ defineComponent({
1646
+ __name: "FallbackChannelList",
1647
+ props: {
1648
+ rows: {},
1649
+ addable: {}
1650
+ },
1651
+ emits: ["move", "remove", "add"],
1652
+ setup(e) {
1653
+ const { t: s } = useI18n(), o = e, d = computed(() => o.addable.length > 0);
1654
+ return (i, c) => {
1655
+ const l = resolveComponent("FmButton"), n = resolveComponent("FmMenuItem"), a = resolveComponent("FmMenu");
1656
+ return openBlock(), createElementBlock("div", _hoisted_1$h, [
1657
+ createElementVNode("div", _hoisted_2$e, [
1658
+ createElementVNode("span", _hoisted_3$b, toDisplayString(unref(s)("connect.campaign.broadcast.fallbackChannels")), 1),
1659
+ createElementVNode("span", _hoisted_4$a, toDisplayString(unref(s)("connect.campaign.broadcast.fallbackChannelsHint")), 1)
1660
+ ]),
1661
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(e.rows, (r, p) => (openBlock(), createElementBlock("div", {
1662
+ key: r.channel,
1663
+ class: "flex flex-wrap items-center gap-12 rounded-[8px] border border-fm-color-neutral-gray-100 px-16 py-[14px]"
1664
+ }, [
1665
+ createElementVNode("span", _hoisted_5$8, toDisplayString(r.position), 1),
1666
+ createElementVNode("span", _hoisted_6$5, [
1667
+ createElementVNode("span", _hoisted_7$5, [
1668
+ createElementVNode("span", _hoisted_8$4, toDisplayString(r.label), 1),
1669
+ r.complete ? createCommentVNode("", !0) : (openBlock(), createElementBlock("span", _hoisted_9$4, [
1670
+ c[0] || (c[0] = createElementVNode("span", { class: "h-[6px] w-[6px] rounded-full bg-fm-color-system-error-400" }, null, -1)),
1671
+ createTextVNode(" " + toDisplayString(unref(s)("connect.campaign.broadcast.messageMissing")), 1)
1672
+ ]))
1673
+ ])
1674
+ ]),
1675
+ createElementVNode("span", _hoisted_10$4, [
1676
+ createElementVNode("span", {
1677
+ title: unref(s)("connect.campaign.broadcast.moveUp"),
1678
+ class: "flex"
1679
+ }, [
1680
+ createVNode(l, {
1681
+ icon: "arrow_upward",
1682
+ "icon-color": "neutral-gray-400",
1683
+ variant: "tertiary",
1684
+ disabled: p === 0,
1685
+ onClick: (h) => i.$emit("move", r.channel, -1)
1686
+ }, null, 8, ["disabled", "onClick"])
1687
+ ], 8, _hoisted_11$2),
1688
+ createElementVNode("span", {
1689
+ title: unref(s)("connect.campaign.broadcast.moveDown"),
1690
+ class: "flex"
1691
+ }, [
1692
+ createVNode(l, {
1693
+ icon: "arrow_downward",
1694
+ "icon-color": "neutral-gray-400",
1695
+ variant: "tertiary",
1696
+ disabled: p === e.rows.length - 1,
1697
+ onClick: (h) => i.$emit("move", r.channel, 1)
1698
+ }, null, 8, ["disabled", "onClick"])
1699
+ ], 8, _hoisted_12$1),
1700
+ createElementVNode("span", {
1701
+ title: unref(s)("connect.campaign.broadcast.removeChannel"),
1702
+ class: "flex"
1703
+ }, [
1704
+ createVNode(l, {
1705
+ icon: "delete",
1706
+ "icon-color": "neutral-gray-400",
1707
+ variant: "tertiary",
1708
+ onClick: (h) => i.$emit("remove", r.channel)
1709
+ }, null, 8, ["onClick"])
1710
+ ], 8, _hoisted_13$1)
1711
+ ])
1712
+ ]))), 128)),
1713
+ unref(d) ? (openBlock(), createBlock(a, {
1714
+ key: 0,
1715
+ placement: "bottom-start"
1716
+ }, {
1717
+ "menu-button": withCtx(() => [
1718
+ createElementVNode("button", _hoisted_14$1, " + " + toDisplayString(unref(s)("connect.campaign.broadcast.addFallbackChannel")), 1)
1719
+ ]),
1720
+ default: withCtx(() => [
1721
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(e.addable, (r) => (openBlock(), createBlock(n, {
1722
+ key: r.channel,
1723
+ label: r.label,
1724
+ onClick: (p) => i.$emit("add", r.channel)
1725
+ }, null, 8, ["label", "onClick"]))), 128))
1726
+ ]),
1727
+ _: 1
1728
+ })) : (openBlock(), createElementBlock("div", _hoisted_15$1, toDisplayString(unref(s)("connect.campaign.broadcast.allChannelsAdded")), 1))
1729
+ ]);
1730
+ };
1731
+ }
1732
+ });
1733
+ var define_appEndpoint_default = { authUrl: "https://portal-v2-dev.feedmeapi.com/", slackWebhookUrl: "https://hooks.slack.com/services/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", appUrl: "feedmedev.vip", crmUrl: "crm.feedmedev.cc", paymentPortalUrl: "https://portal.feedmedev.cc/payment/payout-account", licensePortalUrl: "https://license.feedmedev.cc/", marketingV1Portal: "https://marketing-v1.feedmedev.cc", voucherAppUrl: "https://voucher.feedmedev.cc/" };
1734
+ const _hoisted_1$g = { class: "flex flex-col gap-[28px]" }, _hoisted_2$d = { class: "flex flex-col gap-[14px]" }, _hoisted_3$a = { class: "fm-typo-en-body-lg-600" }, _hoisted_4$9 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_5$7 = { class: "grid gap-12 md:grid-cols-2 lg:grid-cols-2" }, _hoisted_6$4 = { class: "flex items-start justify-between gap-12" }, _hoisted_7$4 = { class: "fm-typo-en-title-sm-800" }, _hoisted_8$3 = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, _hoisted_9$3 = {
1735
+ key: 0,
1736
+ class: "flex items-start gap-8 fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1737
+ }, _hoisted_10$3 = { class: "flex flex-col gap-12" }, _hoisted_11$1 = { class: "fm-typo-en-body-lg-600" }, _hoisted_12 = { class: "grid items-stretch gap-12 sm:grid-cols-2 md:grid-cols-4 lg:grid-cols-4" }, _hoisted_13 = { class: "flex items-start justify-between gap-12" }, _hoisted_14 = {
1738
+ key: 1,
1739
+ class: "h-[8px] w-[8px] rounded-full bg-fm-color-neutral-white"
1740
+ }, _hoisted_15 = {
1741
+ key: 0,
1742
+ class: "mt-[3px] fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1743
+ }, _hoisted_16 = {
1744
+ key: 1,
1745
+ class: "mt-[6px] inline-flex rounded-[6px] bg-fm-color-system-warning-100 px-8 py-[3px] fm-typo-en-body-sm-400 text-fm-color-system-warning-400"
1746
+ }, _hoisted_17 = {
1747
+ key: 2,
1748
+ class: "mt-[6px] inline-flex rounded-[6px] bg-fm-color-neutral-gray-100 px-8 py-[3px] fm-typo-en-body-sm-400 text-fm-color-typo-secondary"
1749
+ }, _hoisted_18 = {
1750
+ key: 0,
1751
+ class: "fm-typo-en-body-sm-400 text-fm-color-system-error-400"
1752
+ }, _hoisted_19 = { class: "flex flex-col gap-[14px]" }, _hoisted_20 = { class: "fm-typo-en-body-lg-600" }, _hoisted_21 = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, _hoisted_22 = {
1753
+ key: 1,
1754
+ class: "rounded-[8px] border border-dashed border-fm-color-neutral-gray-200 p-24 text-center fm-typo-en-body-md-400 text-fm-color-typo-secondary"
1755
+ }, _hoisted_23 = {
1756
+ key: 3,
1757
+ class: "flex flex-wrap items-start gap-24"
1758
+ }, _hoisted_24 = { class: "min-w-0 flex-1 basis-[340px]" }, _sfc_main$g = /* @__PURE__ */ defineComponent({
1759
+ __name: "BroadcastDeliveryInput",
1760
+ props: {
1761
+ /** Either the new delivery shape or a legacy single-channel message. */
1762
+ modelValue: {
1763
+ type: Object,
1764
+ default: void 0
1765
+ },
1766
+ triggerType: {
1767
+ type: String,
1768
+ default: () => "SCHEDULE"
1769
+ },
1770
+ variables: {
1771
+ type: Object,
1772
+ default: () => [...DEFAULT_MESSAGE_VARIABLES]
1773
+ },
1774
+ helperText: { type: String },
1775
+ /**
1776
+ * False until the merchant tries to proceed. Broadcasts validate on submit,
1777
+ * so incomplete-channel markers stay hidden while the form is being filled.
1778
+ */
1779
+ showValidation: { type: Boolean, default: !0 },
1780
+ helperState: { type: String },
1781
+ placeholder: { type: String }
1782
+ },
1783
+ emits: ["update:model-value"],
1784
+ setup(e, { emit: s }) {
1785
+ const { t: o } = useI18n(), d = useCoreStore(), i = useMembershipStore(), c = e, l = s, n = ref(!1), a = ref("SMS"), r = computed(() => {
1786
+ const g = c.modelValue;
1787
+ return g && "channels" in g ? g : toDelivery({ message: g });
1788
+ });
1789
+ function p(g) {
1790
+ l("update:model-value", g);
1791
+ }
1792
+ function h(g) {
1793
+ return o(`connect.campaign.broadcast.channel.${g}`);
1794
+ }
1795
+ const y = {
1796
+ SMS: "chat",
1797
+ WHATSAPP: "chat",
1798
+ EMAIL: "mail",
1799
+ APP_INBOX: "inbox",
1800
+ PUSH: "notifications"
1801
+ };
1802
+ function V(g) {
1803
+ return y[g];
1804
+ }
1805
+ const x = computed(() => r.value.mode === "fallback"), f = computed(
1806
+ () => c.variables.filter(
1807
+ (g) => c.triggerType == "SCHEDULE" ? !g.startsWith("transaction.") : !0
1808
+ )
1809
+ );
1810
+ function v(g) {
1811
+ return g === "WHATSAPP" ? n.value : !0;
1812
+ }
1813
+ const u = ["fallback", "all"];
1814
+ function m(g) {
1815
+ g !== r.value.mode && p(setMode(r.value, g));
1816
+ }
1817
+ const C = ref(null);
1818
+ function k(g) {
1819
+ var R;
1820
+ const E = (R = C.value) == null ? void 0 : R[g];
1821
+ return E ? new Intl.NumberFormat(void 0, {
1822
+ style: "currency",
1823
+ currency: E.currency,
1824
+ minimumFractionDigits: E.precision,
1825
+ maximumFractionDigits: E.precision
1826
+ }).format(E.amount / 10 ** E.precision) : null;
1827
+ }
1828
+ const $ = computed(
1829
+ () => CHANNEL_DISPLAY_ORDER.map((g) => {
1830
+ const E = r.value.channels.includes(g), R = k(g);
1831
+ return {
1832
+ channel: g,
1833
+ label: h(g),
1834
+ selected: E,
1835
+ available: v(g),
1836
+ rateNote: isPaidChannel(g) ? R ? o("connect.campaign.broadcast.perMessage", { price: R }) : null : o("connect.campaign.broadcast.freeChannel"),
1837
+ // In fallback mode the grid is a radio for the primary channel, so only
1838
+ // the primary reads as checked; a fallback is tagged instead.
1839
+ checked: x.value ? r.value.channels[0] === g : E,
1840
+ usedAsFallback: x.value && r.value.channels.indexOf(g) > 0
1841
+ };
1842
+ })
1843
+ );
1844
+ async function F(g) {
1845
+ if (v(g)) {
1846
+ if (x.value) {
1847
+ await N(g);
1848
+ return;
1849
+ }
1850
+ if (r.value.channels.includes(g)) {
1851
+ await D(g);
1852
+ return;
1853
+ }
1854
+ p(addChannel(r.value, g, f.value));
1855
+ }
1856
+ }
1857
+ async function N(g) {
1858
+ const E = r.value.channels[0];
1859
+ E !== g && (E && hasDraft(r.value, E) && !await prompt.remove(
1860
+ o("connect.campaign.broadcast.replaceChannelConfirm", {
1861
+ channel: h(E),
1862
+ next: h(g)
1863
+ })
1864
+ ) || (p(setPrimaryChannel(r.value, g, f.value)), a.value = g));
1865
+ }
1866
+ async function D(g) {
1867
+ if (hasDraft(r.value, g) && !await prompt.remove(
1868
+ o("connect.campaign.broadcast.removeChannelConfirm", {
1869
+ channel: h(g)
1870
+ })
1871
+ ))
1872
+ return;
1873
+ const E = removeChannel(r.value, g);
1874
+ p(E), a.value === g && (a.value = E.channels[0] ?? "SMS");
1875
+ }
1876
+ function w(g, E) {
1877
+ p(moveChannel(r.value, g, E));
1878
+ }
1879
+ const O = computed(
1880
+ () => r.value.channels.slice(1).map((g, E) => ({
1881
+ channel: g,
1882
+ label: h(g),
1883
+ position: E + 2,
1884
+ complete: !c.showValidation || isChannelComplete(r.value, g)
1885
+ }))
1886
+ ), j = computed(
1887
+ () => CHANNEL_DISPLAY_ORDER.filter(
1888
+ (g) => !r.value.channels.includes(g) && v(g)
1889
+ ).map((g) => ({
1890
+ channel: g,
1891
+ label: h(g)
1892
+ }))
1893
+ ), I = computed(
1894
+ () => r.value.channels.map((g, E) => ({
1895
+ key: g,
1896
+ label: h(g),
1897
+ sub: x.value ? o(E === 0 ? "connect.campaign.broadcast.tab.firstAttempt" : "connect.campaign.broadcast.tab.ifNotReached") : o("connect.campaign.broadcast.tab.sendsToEligible"),
1898
+ complete: !c.showValidation || isChannelComplete(r.value, g),
1899
+ step: x.value ? E + 1 : void 0,
1900
+ connector: E === 0 ? void 0 : x.value ? "→" : "+"
1901
+ }))
1902
+ );
1903
+ watchEffect(() => {
1904
+ const g = I.value.map((E) => E.key);
1905
+ g.length && !g.includes(a.value) && (a.value = g[0]);
1906
+ });
1907
+ const H = computed(() => a.value), q = computed(() => {
1908
+ const g = H.value;
1909
+ if (!(g === "APP_INBOX" || g === "PUSH"))
1910
+ return r.value.content[g];
1911
+ }), G = computed(
1912
+ () => r.value.content.APP_INBOX
1913
+ ), Y = computed(
1914
+ () => r.value.content.PUSH
1915
+ );
1916
+ function Z(g) {
1917
+ p(setChannelContent(r.value, "APP_INBOX", g));
1918
+ }
1919
+ function b(g) {
1920
+ p(setChannelContent(r.value, "PUSH", g));
1921
+ }
1922
+ function B(g, E) {
1923
+ g === "APP_INBOX" || g === "PUSH" || p(setChannelContent(r.value, g, { ...E, channel: g }));
1924
+ }
1925
+ const T = computed(
1926
+ () => r.value.channels.filter(isPaidChannel)
1927
+ ), U = computed(() => {
1928
+ var E, R, M;
1929
+ const g = ((E = i.membership) == null ? void 0 : E.brand) || ((M = (R = d.currentBusiness) == null ? void 0 : R.value) == null ? void 0 : M.name) || "";
1930
+ return getSmsMessageMetrics({ brandName: g, content: "" }).prefix;
1931
+ }), P = `${define_appEndpoint_default.licensePortalUrl}settings?businessId=${SvcConfig.businessId}`;
1932
+ async function A() {
1933
+ try {
1934
+ const g = await membershipApi.getWhatsappNumbers();
1935
+ n.value = g.some(
1936
+ (E) => {
1937
+ var R;
1938
+ return (R = E == null ? void 0 : E.default) == null ? void 0 : R.includes("Marketing");
1939
+ }
1940
+ );
1941
+ } catch (g) {
1942
+ console.error("Failed to fetch WhatsApp numbers:", g);
1943
+ }
1944
+ }
1945
+ return onMounted(async () => {
1946
+ const g = r.value.channels[0];
1947
+ g && (a.value = g), campaignApi.readBroadcastCreditSummary().then((E) => C.value = E.prices).catch(() => C.value = null), await A();
1948
+ }), (g, E) => {
1949
+ const R = resolveComponent("FmIcon"), M = resolveComponent("FmCard");
1950
+ return openBlock(), createElementBlock("div", _hoisted_1$g, [
1951
+ createElementVNode("div", _hoisted_2$d, [
1952
+ createElementVNode("div", null, [
1953
+ createElementVNode("div", _hoisted_3$a, toDisplayString(unref(o)("connect.campaign.broadcast.delivery")), 1),
1954
+ createElementVNode("div", _hoisted_4$9, toDisplayString(unref(o)("connect.campaign.broadcast.deliveryDescription")), 1)
1955
+ ]),
1956
+ createElementVNode("div", _hoisted_5$7, [
1957
+ (openBlock(), createElementBlock(Fragment, null, renderList(u, (S) => createVNode(M, {
1958
+ key: S,
1959
+ variant: "outlined",
1960
+ class: normalizeClass(["h-full cursor-pointer select-none p-16 space-y-8", {
1961
+ "border-fm-color-primary bg-fm-color-system-warning-100": unref(r).mode === S,
1962
+ "hover:bg-fm-color-opacity-sm": unref(r).mode !== S
1963
+ }]),
1964
+ onClick: (L) => m(S)
1965
+ }, {
1966
+ default: withCtx(() => [
1967
+ createElementVNode("div", _hoisted_6$4, [
1968
+ createElementVNode("div", _hoisted_7$4, toDisplayString(unref(o)(`connect.campaign.broadcast.mode.${S}.label`)), 1),
1969
+ unref(r).mode === S ? (openBlock(), createBlock(R, {
1970
+ key: 0,
1971
+ name: "check_circle",
1972
+ size: "md",
1973
+ class: "shrink-0 text-fm-color-primary"
1974
+ })) : createCommentVNode("", !0)
1975
+ ]),
1976
+ createElementVNode("div", _hoisted_8$3, toDisplayString(unref(o)(`connect.campaign.broadcast.mode.${S}.description`)), 1)
1977
+ ]),
1978
+ _: 2
1979
+ }, 1032, ["class", "onClick"])), 64))
1980
+ ]),
1981
+ unref(r).channels.length < 2 ? (openBlock(), createElementBlock("div", _hoisted_9$3, [
1982
+ createVNode(R, {
1983
+ name: "info",
1984
+ size: "sm",
1985
+ class: "mt-[2px]"
1986
+ }),
1987
+ createElementVNode("span", null, toDisplayString(unref(o)("connect.campaign.broadcast.singleChannelNote")), 1)
1988
+ ])) : createCommentVNode("", !0)
1989
+ ]),
1990
+ createElementVNode("div", _hoisted_10$3, [
1991
+ createElementVNode("div", _hoisted_11$1, toDisplayString(unref(x) ? unref(o)("connect.campaign.broadcast.primaryChannel") : unref(o)("connect.campaign.broadcast.channels")), 1),
1992
+ createElementVNode("div", _hoisted_12, [
1993
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref($), (S) => (openBlock(), createBlock(M, {
1994
+ key: S.channel,
1995
+ variant: "outlined",
1996
+ class: normalizeClass(["flex h-full flex-col gap-12 p-16", [
1997
+ S.checked ? "!border-fm-color-primary bg-fm-color-system-warning-100" : "",
1998
+ S.available ? "cursor-pointer" : "cursor-not-allowed bg-fm-color-neutral-gray-100"
1999
+ ]]),
2000
+ "aria-disabled": !S.available,
2001
+ onClick: (L) => F(S.channel)
2002
+ }, {
2003
+ default: withCtx(() => [
2004
+ createElementVNode("div", _hoisted_13, [
2005
+ createElementVNode("span", {
2006
+ class: normalizeClass([
2007
+ "flex h-[34px] w-[34px] flex-none items-center justify-center rounded-[8px]",
2008
+ S.available ? "bg-fm-color-primary-oats text-fm-color-primary" : "bg-fm-color-neutral-gray-200 text-fm-color-neutral-gray-400"
2009
+ ])
2010
+ }, [
2011
+ createVNode(R, {
2012
+ name: V(S.channel),
2013
+ size: "md"
2014
+ }, null, 8, ["name"])
2015
+ ], 2),
2016
+ S.available ? (openBlock(), createElementBlock("span", {
2017
+ key: 0,
2018
+ class: normalizeClass(["flex h-[22px] w-[22px] flex-none items-center justify-center border-2 transition-colors", [
2019
+ unref(x) ? "rounded-full" : "rounded-[4px]",
2020
+ S.checked ? "border-fm-color-primary bg-fm-color-primary text-fm-color-typo-white" : "border-fm-color-neutral-gray-300 bg-fm-color-neutral-white"
2021
+ ]])
2022
+ }, [
2023
+ S.checked && !unref(x) ? (openBlock(), createBlock(R, {
2024
+ key: 0,
2025
+ name: "check",
2026
+ size: "sm"
2027
+ })) : S.checked ? (openBlock(), createElementBlock("span", _hoisted_14)) : createCommentVNode("", !0)
2028
+ ], 2)) : createCommentVNode("", !0)
2029
+ ]),
2030
+ createElementVNode("div", null, [
2031
+ createElementVNode("div", {
2032
+ class: normalizeClass(["fm-typo-en-body-md-600", S.available ? "" : "text-fm-color-typo-disabled"])
2033
+ }, toDisplayString(S.label), 3),
2034
+ S.available && S.rateNote ? (openBlock(), createElementBlock("div", _hoisted_15, toDisplayString(S.rateNote), 1)) : createCommentVNode("", !0),
2035
+ S.available ? S.usedAsFallback ? (openBlock(), createElementBlock("div", _hoisted_17, toDisplayString(unref(o)("connect.campaign.broadcast.usedAsFallback")), 1)) : createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_16, toDisplayString(unref(o)("connect.campaign.broadcast.notSetUp")), 1))
2036
+ ]),
2037
+ S.available ? createCommentVNode("", !0) : (openBlock(), createElementBlock("a", {
2038
+ key: 0,
2039
+ href: P,
2040
+ target: "_blank",
2041
+ class: "mt-auto fm-typo-en-body-sm-400 text-fm-color-secondary-blueberry underline",
2042
+ onClick: E[0] || (E[0] = withModifiers(() => {
2043
+ }, ["stop"]))
2044
+ }, toDisplayString(unref(o)("connect.campaign.messageInput.manageWhatsappChannel")), 1))
2045
+ ]),
2046
+ _: 2
2047
+ }, 1032, ["class", "aria-disabled", "onClick"]))), 128))
2048
+ ]),
2049
+ e.showValidation && !unref(r).channels.length ? (openBlock(), createElementBlock("div", _hoisted_18, toDisplayString(unref(o)("connect.campaign.broadcast.selectChannelRequired")), 1)) : createCommentVNode("", !0),
2050
+ unref(x) && unref(r).channels.length ? (openBlock(), createBlock(_sfc_main$h, {
2051
+ key: 1,
2052
+ rows: unref(O),
2053
+ addable: unref(j),
2054
+ onMove: w,
2055
+ onRemove: D,
2056
+ onAdd: E[1] || (E[1] = (S) => p(unref(addChannel)(unref(r), S, unref(f))))
2057
+ }, null, 8, ["rows", "addable"])) : createCommentVNode("", !0)
2058
+ ]),
2059
+ createElementVNode("div", _hoisted_19, [
2060
+ createElementVNode("div", null, [
2061
+ createElementVNode("div", _hoisted_20, toDisplayString(unref(o)("connect.campaign.broadcast.content")), 1),
2062
+ createElementVNode("div", _hoisted_21, toDisplayString(unref(o)("connect.campaign.broadcast.contentDescription")), 1)
2063
+ ]),
2064
+ unref(T).length ? (openBlock(), createBlock(_sfc_main$w, {
2065
+ key: 0,
2066
+ channels: unref(T)
2067
+ }, null, 8, ["channels"])) : createCommentVNode("", !0),
2068
+ unref(r).channels.length ? createCommentVNode("", !0) : (openBlock(), createElementBlock("div", _hoisted_22, toDisplayString(unref(o)("connect.campaign.broadcast.noChannelContent")), 1)),
2069
+ unref(r).channels.length ? (openBlock(), createBlock(_sfc_main$j, {
2070
+ key: 2,
2071
+ modelValue: unref(a),
2072
+ "onUpdate:modelValue": E[2] || (E[2] = (S) => isRef(a) ? a.value = S : null),
2073
+ tabs: unref(I)
2074
+ }, null, 8, ["modelValue", "tabs"])) : createCommentVNode("", !0),
2075
+ unref(r).channels.includes(unref(a)) ? (openBlock(), createElementBlock("div", _hoisted_23, [
2076
+ createElementVNode("div", _hoisted_24, [
2077
+ unref(a) === "PUSH" && unref(Y) ? (openBlock(), createBlock(_sfc_main$k, {
2078
+ key: 0,
2079
+ "model-value": unref(Y),
2080
+ "onUpdate:modelValue": b
2081
+ }, null, 8, ["model-value"])) : unref(a) === "APP_INBOX" && unref(G) ? (openBlock(), createBlock(_sfc_main$l, {
2082
+ key: 1,
2083
+ "model-value": unref(G),
2084
+ variables: unref(f),
2085
+ "onUpdate:modelValue": Z
2086
+ }, null, 8, ["model-value", "variables"])) : unref(a) !== "APP_INBOX" && unref(a) !== "PUSH" ? (openBlock(), createBlock(_sfc_main$x, {
2087
+ key: unref(a),
2088
+ "model-value": unref(q),
2089
+ "allow-email": !1,
2090
+ "allow-whatsapp": !1,
2091
+ "hide-credit-card": !0,
2092
+ "trigger-type": e.triggerType,
2093
+ variables: unref(f),
2094
+ placeholder: e.placeholder,
2095
+ "onUpdate:modelValue": E[3] || (E[3] = (S) => B(unref(H), S))
2096
+ }, null, 8, ["model-value", "trigger-type", "variables", "placeholder"])) : createCommentVNode("", !0)
2097
+ ]),
2098
+ createVNode(_sfc_main$i, {
2099
+ target: unref(a),
2100
+ content: unref(r).content[unref(H)],
2101
+ "sender-prefix": unref(U)
2102
+ }, null, 8, ["target", "content", "sender-prefix"])
2103
+ ])) : createCommentVNode("", !0)
2104
+ ])
2105
+ ]);
2106
+ };
2107
+ }
2108
+ }), _hoisted_1$f = { class: "space-y-8" }, _hoisted_2$c = { class: "grid grid-cols-2 gap-16" }, _hoisted_3$9 = {
2109
+ key: 0,
2110
+ class: "space-y-4"
2111
+ }, _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({
2112
+ __name: "ScheduleRuleInput",
2113
+ props: {
2114
+ modelValue: {
2115
+ type: Object,
2116
+ required: !0
2117
+ },
2118
+ startDate: {
2119
+ type: String
2120
+ },
2121
+ endDate: {
2122
+ type: String
2123
+ }
2124
+ },
2125
+ emits: ["update:model-value"],
2126
+ setup(e, { emit: s }) {
2127
+ const { t: o } = useI18n(), d = e, i = s, c = useCoreStore(), l = computed(
2128
+ () => CountryTimezone[c.currentCountry.value || "MY"]
2129
+ );
2130
+ function n() {
2131
+ const u = RuleBuilder.getRules(d.modelValue);
2132
+ return u.length == 0 ? "fixed" : u.some(
2133
+ (m) => isRuleEntry(m) && RuleBuilder.simplify(m).operator == "_rrule"
2134
+ ) ? "repeating" : "fixed";
2135
+ }
2136
+ const a = ref(n()), r = ref(!1), p = ref(!1), h = computed(() => [
2137
+ { label: o("connect.template.rule.schedule.fixed"), value: "fixed" },
2138
+ { label: o("connect.template.rule.schedule.repeating"), value: "repeating" }
2139
+ ]), y = computed(() => {
2140
+ const u = RuleBuilder.getRules(d.modelValue), m = u.find(
2141
+ (k) => isRuleEntry(k) && RuleBuilder.simplify(k).property == "trigger.date"
2142
+ ), C = u.find(
2143
+ (k) => isRuleEntry(k) && RuleBuilder.simplify(k).property == "trigger.time"
2144
+ );
2145
+ return {
2146
+ date: m ? RuleBuilder.simplify(m).equator : null,
2147
+ time: C ? RuleBuilder.simplify(C).equator : null
2148
+ };
2149
+ }), V = computed(
2150
+ () => calculateNextScheduleAt(
2151
+ d.modelValue,
2152
+ /* @__PURE__ */ new Date(),
2153
+ d.startDate ? new Date(d.startDate) : /* @__PURE__ */ new Date(),
2154
+ d.endDate ? new Date(d.endDate) : void 0
2155
+ )
2156
+ );
2157
+ function x(u, m) {
2158
+ i(
2159
+ "update:model-value",
2160
+ RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
2161
+ RuleBuilder.constructEntry("trigger.date", "_rrule", u),
2162
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", m ?? "00:00")
2163
+ ])
2164
+ );
2165
+ }
2166
+ watch(
2167
+ () => d.startDate,
2168
+ (u, m) => {
2169
+ if (!u || u === m || a.value !== "repeating" || !y.value.date) return;
2170
+ const C = RRule.fromString(y.value.date), k = new RRule({
2171
+ ...C.origOptions,
2172
+ dtstart: new Date(u)
2173
+ }).toString();
2174
+ k !== y.value.date && (x(k, y.value.time), p.value = !0);
2175
+ }
2176
+ );
2177
+ function f(u) {
2178
+ const m = u.value, C = getRruleAnchorDate({
2179
+ startDate: d.startDate ? new Date(d.startDate) : void 0
2180
+ }), k = m == "fixed" ? [
2181
+ RuleBuilder.constructEntry(
2182
+ "trigger.date",
2183
+ "_isOnDate",
2184
+ (/* @__PURE__ */ new Date()).toISOString()
2185
+ ),
2186
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
2187
+ ] : [
2188
+ RuleBuilder.constructEntry(
2189
+ "trigger.date",
2190
+ "_rrule",
2191
+ new RRule({
2192
+ dtstart: C,
2193
+ freq: RRule.DAILY,
2194
+ interval: 1,
2195
+ byhour: 0,
2196
+ byminute: 0,
2197
+ bysecond: 0,
2198
+ wkst: RRule.SU
2199
+ }).toString()
2200
+ ),
2201
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
2202
+ ];
2203
+ i(
2204
+ "update:model-value",
2205
+ RuleBuilder.setRuleToGroup(
2206
+ RuleBuilder.scaffoldGroup("g_schedule"),
2207
+ k
2208
+ )
2209
+ ), a.value = m, p.value = !1;
2210
+ }
2211
+ function v(u) {
2212
+ a.value == "fixed" ? i(
2213
+ "update:model-value",
2214
+ RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup("g_schedule"), [
2215
+ RuleBuilder.constructEntry(
2216
+ "trigger.date",
2217
+ "_isOnDate",
2218
+ u.date
2219
+ ),
2220
+ RuleBuilder.constructEntry(
2221
+ "trigger.time",
2222
+ "_isOnTime",
2223
+ u.time
2224
+ )
2225
+ ])
2226
+ ) : x(u.date, u.time), p.value = !1;
2227
+ }
2228
+ return (u, m) => {
2229
+ const C = resolveComponent("FmButtonGroup"), k = resolveComponent("FmTimePicker"), $ = resolveComponent("FmIcon"), F = resolveComponent("FmTooltip"), N = resolveComponent("FmField"), D = resolveComponent("FmCard"), w = resolveComponent("FmPopover"), O = resolveComponent("FmDatePicker"), j = resolveComponent("FmHelperText");
2230
+ return openBlock(), createElementBlock(Fragment, null, [
2231
+ createVNode(C, {
2232
+ items: unref(h),
2233
+ "model-value": unref(h).find((I) => I.value === unref(a)) ?? null,
2234
+ "onUpdate:modelValue": f,
2235
+ class: "mb-8"
2236
+ }, null, 8, ["items", "model-value"]),
2237
+ createElementVNode("div", _hoisted_1$f, [
2238
+ createElementVNode("div", _hoisted_2$c, [
2239
+ createVNode(k, {
2240
+ label: unref(o)("connect.template.rule.schedule.notify_time"),
2241
+ "model-value": unref(y).time,
2242
+ "onUpdate:modelValue": m[0] || (m[0] = (I) => v({ date: unref(y).date, time: I })),
2243
+ "helper-text": unref(y).time ? void 0 : unref(o)("connect.template.rule.schedule.time_required"),
2244
+ "helper-state": unref(y).time ? void 0 : "error"
2245
+ }, null, 8, ["label", "model-value", "helper-text", "helper-state"]),
2246
+ unref(a) == "repeating" ? (openBlock(), createElementBlock("div", _hoisted_3$9, [
2247
+ createElementVNode("div", _hoisted_4$8, [
2248
+ createElementVNode("div", null, toDisplayString(unref(o)("connect.template.rule.schedule.notify_date")), 1),
2249
+ unref(y).date ? (openBlock(), createBlock(F, {
2250
+ key: 0,
2251
+ "z-index": 9999,
2252
+ content: unref(SummarizeRrule)(unref(RRule).fromString(unref(y).date).options)
2253
+ }, {
2254
+ default: withCtx(() => [
2255
+ createVNode($, {
2256
+ name: "info",
2257
+ size: "sm",
2258
+ outline: !0
2259
+ })
2260
+ ]),
2261
+ _: 1
2262
+ }, 8, ["content"])) : createCommentVNode("", !0)
2263
+ ]),
2264
+ createVNode(w, {
2265
+ "show-popover": unref(r),
2266
+ onPopoverChanged: m[3] || (m[3] = (I) => r.value = I)
2267
+ }, {
2268
+ "popover-button": withCtx(() => [
2269
+ createVNode(N, {
2270
+ class: "cursor-pointer",
2271
+ "helper-text": unref(y).date ? void 0 : unref(o)("connect.template.rule.schedule.date_required"),
2272
+ "helper-state": unref(y).date ? void 0 : "error"
2273
+ }, {
2274
+ default: withCtx(() => [
2275
+ createElementVNode("div", _hoisted_5$6, toDisplayString(unref(y).date ? unref(SummarizeRrule)(unref(RRule).fromString(unref(y).date).options) : unref(o)("connect.template.rule.schedule.set_repeating_date")), 1)
2276
+ ]),
2277
+ _: 1
2278
+ }, 8, ["helper-text", "helper-state"])
2279
+ ]),
2280
+ default: withCtx(() => [
2281
+ createVNode(D, { class: "elevated p-8 w-[450px]" }, {
2282
+ default: withCtx(() => [
2283
+ createVNode(_sfc_main$y, {
2284
+ "apply-button": !0,
2285
+ "model-value": unref(y).date || "",
2286
+ "start-date": e.startDate ? new Date(e.startDate) : /* @__PURE__ */ new Date(),
2287
+ onCancel: m[1] || (m[1] = (I) => r.value = !1),
2288
+ "onUpdate:modelValue": m[2] || (m[2] = (I) => (v({ date: I, time: unref(y).time }), r.value = !1))
2289
+ }, null, 8, ["model-value", "start-date"])
2290
+ ]),
2291
+ _: 1
2292
+ })
2293
+ ]),
2294
+ _: 1
2295
+ }, 8, ["show-popover"])
2296
+ ])) : (openBlock(), createBlock(O, {
2297
+ key: 1,
2298
+ label: unref(o)("connect.template.rule.schedule.notify_date"),
2299
+ "model-value": unref(y).date || "",
2300
+ "onUpdate:modelValue": m[4] || (m[4] = (I) => v({ date: I, time: unref(y).time })),
2301
+ "helper-text": unref(y).date ? void 0 : unref(o)("connect.template.rule.schedule.date_required"),
2302
+ "helper-state": unref(y).date ? void 0 : "error"
2303
+ }, null, 8, ["label", "model-value", "helper-text", "helper-state"]))
2304
+ ]),
2305
+ unref(y).date && unref(y).time && unref(V) ? (openBlock(), createBlock(j, {
2306
+ key: 0,
2307
+ text: `${unref(moment)(unref(V)).isAfter(unref(moment)()) ? unref(o)("connect.template.rule.schedule.next_notification") : unref(o)("connect.template.rule.schedule.last_trigger_on")} ${unref(moment)(unref(V)).format("dddd, DD MMM YYYY")} at
2308
+ ${unref(moment)(unref(V)).format("hh:mmA")}(UTC${unref(moment).tz(unref(l)).format("Z")}) (${unref(moment)(unref(V)).fromNow()})`
2309
+ }, null, 8, ["text"])) : createCommentVNode("", !0),
2310
+ unref(p) ? (openBlock(), createBlock(j, {
2311
+ key: 1,
2312
+ text: "Repeating schedule was updated to stay anchored to the campaign start date.",
2313
+ state: "warning"
2314
+ })) : createCommentVNode("", !0)
2315
+ ])
2316
+ ], 64);
2317
+ };
2318
+ }
2319
+ }), _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({
2320
+ __name: "GameTypeInput",
2321
+ props: {
2322
+ modelValue: {
2323
+ type: String
2324
+ }
2325
+ },
2326
+ emits: ["update:model-value"],
2327
+ setup(e, { emit: s }) {
2328
+ const { t: o } = useI18n(), d = e, i = s, c = computed(
2329
+ () => [
2330
+ {
2331
+ label: o("connect.campaign.gameType.option.FORTUNE_WHEEL.label"),
2332
+ description: o("connect.campaign.gameType.option.FORTUNE_WHEEL.description"),
2333
+ value: F_GAME_TYPE.enum.FORTUNE_WHEEL,
2334
+ hidden: !1
2335
+ },
2336
+ {
2337
+ label: o("connect.campaign.gameType.option.ROCK_PAPER_SCISSORS.label"),
2338
+ description: o("connect.campaign.gameType.option.ROCK_PAPER_SCISSORS.description"),
2339
+ value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS,
2340
+ hidden: !0
2341
+ }
2342
+ ].filter((l) => !l.hidden)
2343
+ );
2344
+ return (l, n) => {
2345
+ const a = resolveComponent("FmCard");
2346
+ return openBlock(), createElementBlock("div", _hoisted_1$e, [
2347
+ createElementVNode("div", _hoisted_2$b, toDisplayString(unref(o)("connect.template.select_game")), 1),
2348
+ createElementVNode("div", _hoisted_3$8, [
2349
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(c), (r) => (openBlock(), createBlock(a, {
2350
+ variant: "outlined",
2351
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
2352
+ "col-span-2": unref(c).length == 1,
2353
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == r.value,
2354
+ "hover:bg-fm-color-opacity-sm": e.modelValue != r.value
2355
+ }]),
2356
+ onClick: () => {
2357
+ d.modelValue != r.value && i("update:model-value", r.value);
2358
+ },
2359
+ key: r.value
2360
+ }, {
2361
+ default: withCtx(() => [
2362
+ createElementVNode("div", _hoisted_4$7, toDisplayString(r.label), 1),
2363
+ createElementVNode("div", _hoisted_5$5, toDisplayString(r.description), 1)
2364
+ ]),
2365
+ _: 2
2366
+ }, 1032, ["class", "onClick"]))), 128))
2367
+ ])
2368
+ ]);
2369
+ };
2370
+ }
2371
+ }), _hoisted_1$d = {
2372
+ key: 0,
2373
+ class: "flex flex-col gap-y-24"
2374
+ }, _hoisted_2$a = { class: "flex gap-8 items-center justify-start" }, _sfc_main$d = /* @__PURE__ */ defineComponent({
2375
+ __name: "EditRewardPoolSheet",
2376
+ emits: ["update:model-value"],
2377
+ setup(e, { expose: s, emit: o }) {
2378
+ const d = useMembershipStore(), { minor: i } = useLoading, c = ref(!1), l = ref(), n = ref(), a = ref(0), r = computed(() => {
2379
+ var f;
2380
+ return ((f = d.loyaltyRewards.items.find(
2381
+ (v) => {
2382
+ var u;
2383
+ return v.value === ((u = l.value) == null ? void 0 : u.collectible);
2384
+ }
2385
+ )) == null ? void 0 : f.raw.type) === "CREDIT" ? FdoCreditLoyaltyReward : FdtoRandomReward;
2386
+ }), p = computed(() => {
2387
+ const x = r.value.safeParse(l.value);
2388
+ return x.success ? [] : x.error.errors;
2389
+ });
2390
+ function h(x, f, v) {
2391
+ x && (l.value = f, a.value = v), c.value = x;
2392
+ }
2393
+ const y = o;
2394
+ async function V() {
2395
+ const x = r.value.safeParse(l.value);
2396
+ x.success && (await i(
2397
+ async () => {
2398
+ x.data.type === "VOUCHER" && n.value && (x.data.collectibleConfig.image = await firebaseStorage.update(
2399
+ x.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, n.value),
2400
+ n.value
2401
+ ));
2402
+ },
2403
+ {
2404
+ message: "Uploading reward image",
2405
+ successMessage: "Reward image updated"
2406
+ }
2407
+ ), y("update:model-value", x.data, a.value));
2408
+ }
2409
+ return s({
2410
+ showSheet: h
2411
+ }), (x, f) => {
2412
+ const v = resolveComponent("FmSelect"), u = resolveComponent("FmStepperField"), m = resolveComponent("FmButton"), C = resolveComponent("FmSideSheet");
2413
+ return openBlock(), createBlock(C, {
2414
+ "max-width": 560,
2415
+ modelValue: unref(c),
2416
+ "onUpdate:modelValue": [
2417
+ f[9] || (f[9] = (k) => isRef(c) ? c.value = k : null),
2418
+ f[10] || (f[10] = (k) => c.value = k)
2419
+ ],
2420
+ header: "Edit reward",
2421
+ "dismiss-away": ""
2422
+ }, {
2423
+ "side-sheet-footer": withCtx(() => [
2424
+ createElementVNode("div", _hoisted_2$a, [
2425
+ createVNode(m, {
2426
+ variant: "primary",
2427
+ type: "button",
2428
+ disabled: unref(p).length > 0,
2429
+ label: "Confirm",
2430
+ onClick: f[7] || (f[7] = (k) => V())
2431
+ }, null, 8, ["disabled"]),
2432
+ createVNode(m, {
2433
+ variant: "secondary",
2434
+ type: "button",
2435
+ label: "Cancel",
2436
+ onClick: f[8] || (f[8] = (k) => c.value = !1)
2437
+ })
2438
+ ])
2439
+ ]),
2440
+ default: withCtx(() => {
2441
+ var k, $, F;
2442
+ return [
2443
+ unref(l) ? (openBlock(), createElementBlock("div", _hoisted_1$d, [
2444
+ createVNode(v, {
2445
+ label: "Reward Type",
2446
+ items: [
2447
+ { label: "No Reward", value: "NO_REWARD" },
2448
+ { label: "Voucher", value: "VOUCHER" },
2449
+ { label: "Loyalty", value: "LOYALTY" }
2450
+ ],
2451
+ "model-value": unref(l).type,
2452
+ "onUpdate:modelValue": f[0] || (f[0] = (N) => {
2453
+ N == "NO_REWARD" ? l.value = {
2454
+ type: "NO_REWARD",
2455
+ collectible: null,
2456
+ weight: 1
2457
+ } : N === "VOUCHER" ? l.value = {
2458
+ collectible: null,
2459
+ type: "VOUCHER",
2460
+ collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
2461
+ business: unref(useCoreStore)().currentBusiness.value._id
2462
+ }),
2463
+ earningOption: {
2464
+ amount: 1,
2465
+ type: "FIXED"
2466
+ },
2467
+ validityOption: {
2468
+ validForDay: 7
2469
+ },
2470
+ weight: 1
2471
+ } : l.value = {
2472
+ collectible: unref(d).loyaltyRewards.raw[0]._id,
2473
+ type: "LOYALTY",
2474
+ earningOption: {
2475
+ amount: 1,
2476
+ type: "FIXED"
2477
+ },
2478
+ validityOption: {
2479
+ validForDay: 7
2480
+ },
2481
+ weight: 1
2482
+ };
2483
+ })
2484
+ }, null, 8, ["model-value"]),
2485
+ unref(l).type == "LOYALTY" ? (openBlock(), createBlock(v, {
2486
+ key: 0,
2487
+ label: "Loyalty type",
2488
+ rules: [unref(ZodHelper).ruleAtPath(unref(r), "collectible", [unref(l).type])],
2489
+ items: unref(d).loyaltyRewards.items,
2490
+ "model-value": unref(l).collectible,
2491
+ "onUpdate:modelValue": f[1] || (f[1] = (N) => unref(l).collectible = N)
2492
+ }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
2493
+ createVNode(u, {
2494
+ label: "Weight",
2495
+ rules: [unref(ZodHelper).ruleAtPath(unref(r), "weight", [unref(l).type])],
2496
+ "model-value": unref(l).weight,
2497
+ "onUpdate:modelValue": f[2] || (f[2] = (N) => l.value = {
2498
+ ...unref(l),
2499
+ weight: N
2500
+ })
2501
+ }, null, 8, ["rules", "model-value"]),
2502
+ unref(l).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
2503
+ ((k = unref(d).loyaltyRewards.items.find(
2504
+ (N) => {
2505
+ var D;
2506
+ return N.value === ((D = unref(l)) == null ? void 0 : D.collectible);
2507
+ }
2508
+ )) == null ? void 0 : k.raw.type) !== "TITLE" ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
2509
+ f[11] || (f[11] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
2510
+ createVNode(_sfc_main$z, {
2511
+ class: "mt-[-8px]",
2512
+ rules: [
2513
+ unref(ZodHelper).ruleAtPath(unref(r), "earningOption", [unref(l).type])
2514
+ ],
2515
+ "helper-state": unref(ZodHelper).helperState(unref(p), "earningOption"),
2516
+ "error-text": unref(ZodHelper).helperText(unref(p), "earningOption"),
2517
+ "fixed-type": !0,
2518
+ "model-value": unref(l).earningOption,
2519
+ "onUpdate:modelValue": f[3] || (f[3] = (N) => l.value = {
2520
+ ...unref(l),
2521
+ earningOption: N
2522
+ })
2523
+ }, null, 8, ["rules", "helper-state", "error-text", "model-value"])
2524
+ ], 64)) : createCommentVNode("", !0),
2525
+ f[12] || (f[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Validity option", -1)),
2526
+ createVNode(_sfc_main$A, {
2527
+ type: unref(l).type === "LOYALTY" ? "custom" : "range",
2528
+ "for-credit": unref(l).type === "LOYALTY" && (($ = unref(d).loyaltyRewards.items.find(
2529
+ (N) => {
2530
+ var D;
2531
+ return N.value === ((D = unref(l)) == null ? void 0 : D.collectible);
2532
+ }
2533
+ )) == null ? void 0 : $.raw.type) === "CREDIT",
2534
+ class: "!gap-24",
2535
+ rules: [unref(ZodHelper).ruleAtPath(unref(r), "validityOption", [unref(l).type])],
2536
+ "model-value": unref(l).validityOption,
2537
+ "onUpdate:modelValue": f[4] || (f[4] = (N) => l.value = {
2538
+ ...unref(l),
2539
+ validityOption: N
2540
+ })
2541
+ }, null, 8, ["type", "for-credit", "rules", "model-value"])
2542
+ ], 64)) : createCommentVNode("", !0),
2543
+ unref(l).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$B, {
2544
+ key: 2,
2545
+ "reward-image": unref(n),
2546
+ "model-value": ((F = unref(l)) == null ? void 0 : F.collectibleConfig) ?? void 0,
2547
+ "onUpdate:modelValue": f[5] || (f[5] = (N) => l.value = {
2548
+ ...unref(l),
2549
+ collectibleConfig: N
2550
+ }),
2551
+ "onUpdate:rewardImage": f[6] || (f[6] = (N) => n.value = N)
2552
+ }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
2553
+ createVNode(JsonViewer, { json: unref(p) }, null, 8, ["json"])
2554
+ ])) : createCommentVNode("", !0)
2555
+ ];
2556
+ }),
2557
+ _: 1
2558
+ }, 8, ["modelValue"]);
2559
+ };
2560
+ }
2561
+ });
2562
+ function isNullOrEmpty(e) {
2563
+ return e == null || e === "";
2564
+ }
2565
+ 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({
2566
+ __name: "RewardPoolInput",
2567
+ props: {
2568
+ modelValue: {
2569
+ type: Array,
2570
+ default: () => [
2571
+ {
2572
+ collectible: null,
2573
+ type: "NO_REWARD",
2574
+ weight: 1
2575
+ }
2576
+ ]
2577
+ }
2578
+ },
2579
+ emits: ["update:model-value"],
2580
+ setup(e, { emit: s }) {
2581
+ const o = e, d = s, i = useMembershipStore(), { t: c } = useI18n(), l = z$1.array(z$1.lazy(() => FdtoRandomReward)).min(1, "Requires at least 1 reward"), n = computed(() => o.modelValue ?? []), a = computed(() => {
2582
+ const f = l.safeParse(n.value);
2583
+ return f.success ? [] : f.error.errors;
2584
+ }), r = ref();
2585
+ function p(f, v) {
2586
+ var m;
2587
+ const u = [...n.value];
2588
+ u[v] = f, (m = r.value) == null || m.showSheet(!1), d("update:model-value", u);
2589
+ }
2590
+ function h(f) {
2591
+ const v = f.type == "VOUCHER" ? f.collectibleConfig : i.collectibles.find(
2592
+ (C) => C._id.toString() == f.collectible
2593
+ ), u = CollectionUtils.formattedType((v == null ? void 0 : v.name) || ""), m = f.weight;
2594
+ return {
2595
+ label: isNullOrEmpty(u) ? "NO REWARD" : u,
2596
+ sublabel: `${m} (${(m / n.value.reduce((C, k) => C + k.weight, 0) * 100).toFixed(2)}%)`
2597
+ };
2598
+ }
2599
+ function y(f) {
2600
+ var u;
2601
+ const v = [...n.value];
2602
+ (u = r.value) == null || u.showSheet(!0, v[f], f);
2603
+ }
2604
+ function V(f) {
2605
+ const v = [...n.value];
2606
+ v.splice(f, 1), d("update:model-value", v);
2607
+ }
2608
+ function x() {
2609
+ var f;
2610
+ (f = r.value) == null || f.showSheet(
2611
+ !0,
2612
+ {
2613
+ type: "NO_REWARD",
2614
+ collectible: null,
2615
+ weight: 1
2616
+ },
2617
+ n.value.length
2618
+ );
2619
+ }
2620
+ return (f, v) => {
2621
+ const u = resolveComponent("FmButton"), m = resolveComponent("FmCard"), C = resolveComponent("FmHelperText");
2622
+ return openBlock(), createElementBlock("div", _hoisted_1$c, [
2623
+ createElementVNode("div", _hoisted_2$9, toDisplayString(unref(c)("connect.template.configure_reward_type")), 1),
2624
+ createVNode(u, {
2625
+ label: unref(c)("connect.campaign.rewardPool.addReward"),
2626
+ onClick: v[0] || (v[0] = (k) => x()),
2627
+ variant: "plain",
2628
+ icon: "add"
2629
+ }, null, 8, ["label"]),
2630
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n), (k, $) => (openBlock(), createBlock(m, {
2631
+ key: $,
2632
+ class: "px-16 py-12 flex items-center justify-between cursor-pointer",
2633
+ variant: "outlined",
2634
+ onClick: (F) => y($)
2635
+ }, {
2636
+ default: withCtx(() => {
2637
+ var F;
2638
+ return [
2639
+ createElementVNode("div", null, [
2640
+ createElementVNode("div", _hoisted_3$7, toDisplayString(k.type == "LOYALTY" ? (F = k == null ? void 0 : k.earningOption) == null ? void 0 : F.amount : "") + " " + toDisplayString(h(k).label), 1),
2641
+ createElementVNode("div", _hoisted_4$6, toDisplayString(h(k).sublabel), 1)
2642
+ ]),
2643
+ createVNode(u, {
2644
+ icon: "delete",
2645
+ variant: "tertiary",
2646
+ onClick: (N) => (N.stopPropagation(), V($))
2647
+ }, null, 8, ["onClick"])
2648
+ ];
2649
+ }),
2650
+ _: 2
2651
+ }, 1032, ["onClick"]))), 128)),
2652
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(a).filter((k) => k.path.join(".") == ""), (k) => (openBlock(), createBlock(C, {
2653
+ key: k.message,
2654
+ text: k.message,
2655
+ state: "error"
2656
+ }, null, 8, ["text"]))), 128)),
2657
+ createVNode(_sfc_main$d, {
2658
+ ref_key: "sheetRef",
2659
+ ref: r,
2660
+ "onUpdate:modelValue": p
2661
+ }, null, 512)
2662
+ ]);
2663
+ };
2664
+ }
2665
+ }), _hoisted_1$b = { class: "space-y-16" }, _hoisted_2$8 = {
2666
+ key: 0,
2667
+ class: "grid grid-cols-2 gap-16"
2668
+ }, _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({
2669
+ __name: "PromotionGameTypeInput",
2670
+ props: {
2671
+ modelValue: {
2672
+ type: Object
2673
+ }
2674
+ },
2675
+ emits: ["update:model-value"],
2676
+ setup(e, { emit: s }) {
2677
+ const { t: o } = useI18n(), d = e, i = s, c = computed(() => [
2678
+ {
2679
+ label: o("connect.template.promotion_game.rock_paper_scissors.label"),
2680
+ description: o("connect.template.promotion_game.rock_paper_scissors.description"),
2681
+ value: F_GAME_TYPE.enum.ROCK_PAPER_SCISSORS
2682
+ }
2683
+ ]);
2684
+ return (l, n) => {
2685
+ var h, y, V;
2686
+ const a = resolveComponent("FmSwitch"), r = resolveComponent("FmCard"), p = resolveComponent("FmHelperText");
2687
+ return openBlock(), createElementBlock("div", _hoisted_1$b, [
2688
+ createVNode(a, {
2689
+ label: unref(o)("connect.template.promotion_game.enable"),
2690
+ "model-value": !!((h = e.modelValue) != null && h.gameType),
2691
+ "onUpdate:modelValue": n[0] || (n[0] = (x) => x ? i("update:model-value", { gameType: "ROCK_PAPER_SCISSORS" }) : i("update:model-value", null))
2692
+ }, null, 8, ["label", "model-value"]),
2693
+ ((y = e.modelValue) == null ? void 0 : y.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createElementBlock("div", _hoisted_2$8, [
2694
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(c), (x) => {
2695
+ var f, v;
2696
+ return openBlock(), createBlock(r, {
2697
+ variant: "outlined",
2698
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
2699
+ "col-span-2": unref(c).length == 1,
2700
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((f = e.modelValue) == null ? void 0 : f.gameType) == x.value,
2701
+ "hover:bg-fm-color-opacity-sm": ((v = e.modelValue) == null ? void 0 : v.gameType) != x.value
2702
+ }]),
2703
+ onClick: () => {
2704
+ var u;
2705
+ ((u = d.modelValue) == null ? void 0 : u.gameType) != x.value && i("update:model-value", { gameType: x.value });
2706
+ },
2707
+ key: x.value
2708
+ }, {
2709
+ default: withCtx(() => [
2710
+ createElementVNode("div", _hoisted_3$6, toDisplayString(x.label), 1),
2711
+ createElementVNode("div", _hoisted_4$5, toDisplayString(x.description), 1)
2712
+ ]),
2713
+ _: 2
2714
+ }, 1032, ["class", "onClick"]);
2715
+ }), 128))
2716
+ ])) : createCommentVNode("", !0),
2717
+ ((V = e.modelValue) == null ? void 0 : V.gameType) == "ROCK_PAPER_SCISSORS" ? (openBlock(), createBlock(p, {
2718
+ key: 1,
2719
+ text: unref(o)("connect.template.promotion_game.rock_paper_scissors.warning"),
2720
+ state: "warning"
2721
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
2722
+ ]);
2723
+ };
2724
+ }
2725
+ }), _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 = {
2726
+ key: 0,
2727
+ class: "ml-6 space-y-2"
2728
+ }, _sfc_main$a = /* @__PURE__ */ defineComponent({
2729
+ __name: "GrabConditionsInput",
2730
+ props: {
2731
+ modelValue: {
2732
+ type: Object
2733
+ },
2734
+ schema: {
2735
+ type: Object,
2736
+ default: () => z$1.any()
2737
+ }
2738
+ },
2739
+ emits: ["update:model-value"],
2740
+ setup(e, { emit: s }) {
2741
+ const { t: o } = useI18n(), d = e, i = s, c = ref(d.modelValue ?? {}), l = ref(
2742
+ (() => {
2743
+ const h = {};
2744
+ return c.value.workingHour && Object.keys(c.value.workingHour).forEach((y) => {
2745
+ const V = c.value.workingHour[y];
2746
+ V && "periods" in V && Array.isArray(V.periods) ? h[y] = V.periods : Array.isArray(V) && (h[y] = V);
2747
+ }), h;
2748
+ })()
2749
+ ), n = [
2750
+ { key: "mon", label: "Monday" },
2751
+ { key: "tue", label: "Tuesday" },
2752
+ { key: "wed", label: "Wednesday" },
2753
+ { key: "thu", label: "Thursday" },
2754
+ { key: "fri", label: "Friday" },
2755
+ { key: "sat", label: "Saturday" },
2756
+ { key: "sun", label: "Sunday" }
2757
+ ], a = (h) => {
2758
+ l.value[h] || (l.value[h] = []), l.value[h].push({
2759
+ startTime: "00:00",
2760
+ endTime: "23:59"
2761
+ }), p();
2762
+ }, r = (h, y) => {
2763
+ l.value[h] && l.value[h].length > y && (l.value[h].splice(y, 1), l.value[h].length === 0 && delete l.value[h], p());
2764
+ }, p = () => {
2765
+ const h = Object.keys(l.value).reduce(
2766
+ (y, V) => (l.value[V] && l.value[V].length > 0 && (y[V] = {
2767
+ periods: l.value[V]
2768
+ }), y),
2769
+ {}
2770
+ );
2771
+ c.value.workingHour = Object.keys(h).length > 0 ? h : void 0;
2772
+ };
2773
+ return watch(c, () => i("update:model-value", c.value), { deep: !0 }), watch(l, p, { deep: !0 }), (h, y) => {
2774
+ const V = resolveComponent("FmSelect"), x = resolveComponent("FmStepperField"), f = resolveComponent("FmCheckbox"), v = resolveComponent("FmTimePicker"), u = resolveComponent("FmButton");
2775
+ return openBlock(), createElementBlock("div", _hoisted_1$a, [
2776
+ createElementVNode("div", _hoisted_2$7, [
2777
+ createVNode(V, {
2778
+ label: unref(o)("connect.template.eaterType"),
2779
+ modelValue: unref(c).eaterType,
2780
+ "onUpdate:modelValue": y[0] || (y[0] = (m) => unref(c).eaterType = m),
2781
+ items: [
2782
+ { label: unref(o)("connect.template.allEaters"), value: "all" },
2783
+ { label: unref(o)("connect.template.newEatersOnly"), value: "new" },
2784
+ {
2785
+ label: unref(o)("connect.template.existingEatersOnly"),
2786
+ value: "existing"
2787
+ }
2788
+ ],
2789
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "eaterType")]
2790
+ }, null, 8, ["label", "modelValue", "items", "rules"]),
2791
+ createVNode(x, {
2792
+ modelValue: unref(c).minBasketAmount,
2793
+ "onUpdate:modelValue": y[1] || (y[1] = (m) => unref(c).minBasketAmount = m),
2794
+ "show-steppers": !1,
2795
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "minBasketAmount")]
2796
+ }, {
2797
+ label: withCtx(() => [
2798
+ (openBlock(), createBlock(resolveDynamicComponent(
2799
+ unref(ZodHelper).toInputLabel(
2800
+ unref(ZodHelper).typeAtPath(e.schema, "minBasketAmount"),
2801
+ unref(o)("connect.template.minBasketAmount")
2802
+ )
2803
+ )))
2804
+ ]),
2805
+ _: 1
2806
+ }, 8, ["modelValue", "rules"]),
2807
+ createVNode(x, {
2808
+ modelValue: unref(c).bundleQuantity,
2809
+ "onUpdate:modelValue": y[2] || (y[2] = (m) => unref(c).bundleQuantity = m),
2810
+ "show-steppers": !1,
2811
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "bundleQuantity")]
2812
+ }, {
2813
+ label: withCtx(() => [
2814
+ (openBlock(), createBlock(resolveDynamicComponent(
2815
+ unref(ZodHelper).toInputLabel(
2816
+ unref(ZodHelper).typeAtPath(e.schema, "bundleQuantity"),
2817
+ unref(o)("connect.template.bundleQuantity")
2818
+ )
2819
+ )))
2820
+ ]),
2821
+ _: 1
2822
+ }, 8, ["modelValue", "rules"])
2823
+ ]),
2824
+ createElementVNode("div", _hoisted_3$5, [
2825
+ createElementVNode("div", _hoisted_4$4, [
2826
+ createElementVNode("div", _hoisted_5$4, toDisplayString(unref(o)("connect.template.operationHours")), 1),
2827
+ (openBlock(), createElementBlock(Fragment, null, renderList(n, (m) => createElementVNode("div", {
2828
+ key: m.key,
2829
+ class: "space-y-2"
2830
+ }, [
2831
+ createElementVNode("div", _hoisted_6$3, [
2832
+ createVNode(f, {
2833
+ label: m.label,
2834
+ "model-value": !!(unref(l)[m.key] && unref(l)[m.key].length > 0),
2835
+ "onUpdate:modelValue": (C) => {
2836
+ C ? a(m.key) : (unref(l)[m.key] = [], delete unref(l)[m.key], p());
2837
+ }
2838
+ }, null, 8, ["label", "model-value", "onUpdate:modelValue"])
2839
+ ]),
2840
+ unref(l)[m.key] && unref(l)[m.key].length > 0 ? (openBlock(), createElementBlock("div", _hoisted_7$3, [
2841
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(l)[m.key] || [], (C, k) => (openBlock(), createElementBlock("div", {
2842
+ key: k,
2843
+ class: "flex items-center space-x-2 w-100"
2844
+ }, [
2845
+ createVNode(v, {
2846
+ "model-value": C.startTime || "",
2847
+ "onUpdate:modelValue": ($) => {
2848
+ unref(l)[m.key] && unref(l)[m.key][k] && (unref(l)[m.key][k].startTime = $ || "", p());
2849
+ }
2850
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2851
+ y[3] || (y[3] = createElementVNode("span", null, "to", -1)),
2852
+ createVNode(v, {
2853
+ "model-value": C.endTime || "",
2854
+ "onUpdate:modelValue": ($) => {
2855
+ unref(l)[m.key] && unref(l)[m.key][k] && (unref(l)[m.key][k].endTime = $ || "", p());
2856
+ }
2857
+ }, null, 8, ["model-value", "onUpdate:modelValue"]),
2858
+ createVNode(u, {
2859
+ variant: "tertiary",
2860
+ size: "sm",
2861
+ onClick: ($) => r(m.key, k),
2862
+ icon: "close"
2863
+ }, null, 8, ["onClick"]),
2864
+ k === 0 ? (openBlock(), createBlock(u, {
2865
+ key: 0,
2866
+ onClick: ($) => a(m.key),
2867
+ icon: "add",
2868
+ variant: "plain"
2869
+ }, null, 8, ["onClick"])) : createCommentVNode("", !0)
2870
+ ]))), 128))
2871
+ ])) : createCommentVNode("", !0)
2872
+ ])), 64))
2873
+ ])
2874
+ ])
2875
+ ]);
2876
+ };
2877
+ }
2878
+ }), 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({
2879
+ __name: "GrabQuotaInput",
2880
+ props: {
2881
+ modelValue: {
2882
+ type: Object
2883
+ },
2884
+ schema: {
2885
+ type: Object,
2886
+ default: () => z$1.any()
2887
+ }
2888
+ },
2889
+ emits: ["update:model-value"],
2890
+ setup(e, { emit: s }) {
2891
+ const { t: o } = useI18n(), d = e, i = s, c = ref(d.modelValue ?? {});
2892
+ return watch(c, () => i("update:model-value", c.value)), (l, n) => {
2893
+ const a = resolveComponent("FmStepperField");
2894
+ return openBlock(), createElementBlock("div", _hoisted_1$9, [
2895
+ createElementVNode("div", _hoisted_2$6, [
2896
+ createVNode(a, {
2897
+ modelValue: unref(c).totalCount,
2898
+ "onUpdate:modelValue": n[0] || (n[0] = (r) => unref(c).totalCount = r),
2899
+ "show-steppers": !1,
2900
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "totalCount")]
2901
+ }, {
2902
+ label: withCtx(() => [
2903
+ (openBlock(), createBlock(resolveDynamicComponent(
2904
+ unref(ZodHelper).toInputLabel(
2905
+ unref(ZodHelper).typeAtPath(e.schema, "totalCount"),
2906
+ unref(o)("connect.template.totalCount")
2907
+ )
2908
+ )))
2909
+ ]),
2910
+ _: 1
2911
+ }, 8, ["modelValue", "rules"]),
2912
+ createVNode(a, {
2913
+ modelValue: unref(c).totalCountPerUser,
2914
+ "onUpdate:modelValue": n[1] || (n[1] = (r) => unref(c).totalCountPerUser = r),
2915
+ "show-steppers": !1,
2916
+ rules: [unref(ZodHelper).ruleAtPath(e.schema, "totalCountPerUser")]
2917
+ }, {
2918
+ label: withCtx(() => [
2919
+ (openBlock(), createBlock(resolveDynamicComponent(
2920
+ unref(ZodHelper).toInputLabel(
2921
+ unref(ZodHelper).typeAtPath(e.schema, "totalCountPerUser"),
2922
+ unref(o)("connect.template.totalCountPerUser")
2923
+ )
2924
+ )))
2925
+ ]),
2926
+ _: 1
2927
+ }, 8, ["modelValue", "rules"])
2928
+ ])
2929
+ ]);
2930
+ };
2931
+ }
2932
+ }), _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({
2933
+ __name: "MissionTypeInput",
2934
+ props: {
2935
+ modelValue: {
2936
+ type: String
2937
+ }
2938
+ },
2939
+ emits: ["update:model-value"],
2940
+ setup(e, { emit: s }) {
2941
+ const { t: o } = useI18n(), d = e, i = s, c = computed(() => [
2942
+ {
2943
+ label: o("connect.campaign.mission.typeOption.STAMP.label"),
2944
+ description: o("connect.campaign.mission.typeOption.STAMP.description"),
2945
+ value: F_MISSION_TYPE.enum.STAMP
2946
+ },
2947
+ {
2948
+ label: o("connect.campaign.mission.typeOption.PROGRESSIVE.label"),
2949
+ description: o("connect.campaign.mission.typeOption.PROGRESSIVE.description"),
2950
+ value: F_MISSION_TYPE.enum.PROGRESSIVE
2951
+ }
2952
+ ]);
2953
+ return (l, n) => {
2954
+ const a = resolveComponent("FmCard");
2955
+ return openBlock(), createElementBlock("div", _hoisted_1$8, [
2956
+ createElementVNode("div", _hoisted_2$5, toDisplayString(unref(o)("connect.template.select_game")), 1),
2957
+ createElementVNode("div", _hoisted_3$4, [
2958
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(c), (r) => (openBlock(), createBlock(a, {
2959
+ variant: "outlined",
2960
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
2961
+ "col-span-2": unref(c).length == 1,
2962
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": e.modelValue == r.value,
2963
+ "hover:bg-fm-color-opacity-sm": e.modelValue != r.value
2964
+ }]),
2965
+ onClick: () => {
2966
+ d.modelValue != r.value && i("update:model-value", r.value);
2967
+ },
2968
+ key: r.value
2969
+ }, {
2970
+ default: withCtx(() => [
2971
+ createElementVNode("div", _hoisted_4$3, toDisplayString(r.label), 1),
2972
+ createElementVNode("div", _hoisted_5$3, toDisplayString(r.description), 1)
2973
+ ]),
2974
+ _: 2
2975
+ }, 1032, ["class", "onClick"]))), 128))
2976
+ ])
2977
+ ]);
2978
+ };
2979
+ }
2980
+ }), _hoisted_1$7 = { class: "space-y-16" }, _sfc_main$7 = /* @__PURE__ */ defineComponent({
2981
+ __name: "MissionEndInput",
2982
+ props: {
2983
+ modelValue: {
2984
+ type: [String, Number]
2985
+ },
2986
+ helperText: {
2987
+ type: String
2988
+ },
2989
+ helperState: {
2990
+ type: String
2991
+ }
2992
+ },
2993
+ emits: ["update:model-value"],
2994
+ setup(e, { emit: s }) {
2995
+ const o = s;
2996
+ return (d, i) => {
2997
+ const c = resolveComponent("FmStepperField");
2998
+ return openBlock(), createElementBlock("div", _hoisted_1$7, [
2999
+ 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)),
3000
+ createVNode(c, {
3001
+ label: "Maximum to collect",
3002
+ "model-value": e.modelValue || null,
3003
+ "onUpdate:modelValue": i[0] || (i[0] = (l) => o("update:model-value", l)),
3004
+ "helper-text": e.helperText || "Set the threshold required for reward eligibility",
3005
+ "helper-state": e.helperState || "none"
3006
+ }, null, 8, ["model-value", "helper-text", "helper-state"])
3007
+ ]);
3008
+ };
3009
+ }
3010
+ }), _hoisted_1$6 = { class: "flex gap-8 items-center justify-start" }, _sfc_main$6 = /* @__PURE__ */ defineComponent({
3011
+ __name: "EditMissionPoolSheet",
3012
+ props: {
3013
+ maxThreshold: {
3014
+ type: Number,
3015
+ required: !0
3016
+ }
3017
+ },
3018
+ emits: ["update:model-value"],
3019
+ setup(e, { expose: s, emit: o }) {
3020
+ const d = e, i = useMembershipStore(), { minor: c } = useLoading, l = ref(!1), n = ref(), a = ref(), r = ref(0), p = computed(() => {
3021
+ var u;
3022
+ return ((u = i.loyaltyRewards.items.find(
3023
+ (m) => {
3024
+ var C;
3025
+ return m.value === ((C = n.value) == null ? void 0 : C.collectible);
3026
+ }
3027
+ )) == null ? void 0 : u.raw.type) === "CREDIT" ? FdoThresholdCreditReward : FdtoThresholdReward;
3028
+ }), h = computed(() => {
3029
+ const v = p.value.safeParse(n.value);
3030
+ return v.success ? [] : v.error.errors;
3031
+ });
3032
+ function y(v, u, m) {
3033
+ v && (n.value = u, r.value = m), l.value = v;
3034
+ }
3035
+ const V = o;
3036
+ async function x() {
3037
+ const v = p.value.safeParse(n.value);
3038
+ v.success && (await c(
3039
+ async () => {
3040
+ v.data.type === "VOUCHER" && a.value && (v.data.collectibleConfig.image = await firebaseStorage.update(
3041
+ v.data.collectibleConfig.image || firebaseStorage.collectibleImagePath(void 0, a.value),
3042
+ a.value
3043
+ ));
3044
+ },
3045
+ {
3046
+ message: "Uploading reward image",
3047
+ successMessage: "Reward image updated"
3048
+ }
3049
+ ), V("update:model-value", v.data, r.value));
3050
+ }
3051
+ const f = ref();
3052
+ return s({
3053
+ showSheet: y
3054
+ }), (v, u) => {
3055
+ const m = resolveComponent("FmStepperField"), C = resolveComponent("FmSelect"), k = resolveComponent("FmForm"), $ = resolveComponent("FmButton"), F = resolveComponent("FmSideSheet");
3056
+ return openBlock(), createBlock(F, {
3057
+ "max-width": 560,
3058
+ modelValue: unref(l),
3059
+ "onUpdate:modelValue": [
3060
+ u[10] || (u[10] = (N) => isRef(l) ? l.value = N : null),
3061
+ u[11] || (u[11] = (N) => l.value = N)
3062
+ ],
3063
+ header: "Edit reward",
3064
+ "dismiss-away": ""
3065
+ }, {
3066
+ "side-sheet-footer": withCtx(() => [
3067
+ createElementVNode("div", _hoisted_1$6, [
3068
+ createVNode($, {
3069
+ variant: "primary",
3070
+ type: "button",
3071
+ label: "Confirm",
3072
+ disabled: unref(h).length > 0,
3073
+ onClick: u[8] || (u[8] = async () => {
3074
+ var N;
3075
+ return (N = unref(f)) == null ? void 0 : N.validateInputs();
3076
+ })
3077
+ }, null, 8, ["disabled"]),
3078
+ createVNode($, {
3079
+ variant: "secondary",
3080
+ type: "button",
3081
+ label: "Cancel",
3082
+ onClick: u[9] || (u[9] = (N) => l.value = !1)
3083
+ })
3084
+ ])
3085
+ ]),
3086
+ default: withCtx(() => [
3087
+ createVNode(JsonViewer, { json: unref(n) }, null, 8, ["json"]),
3088
+ unref(n) ? (openBlock(), createBlock(k, {
3089
+ key: 0,
3090
+ class: "flex flex-col gap-y-24",
3091
+ ref_key: "formRef",
3092
+ ref: f,
3093
+ onValidationSuccess: u[7] || (u[7] = (N) => x())
3094
+ }, {
3095
+ default: withCtx(() => {
3096
+ var N, D;
3097
+ return [
3098
+ unref(n).type ? (openBlock(), createBlock(m, {
3099
+ key: 0,
3100
+ label: "Threshold",
3101
+ rules: [
3102
+ unref(ZodHelper).toRule(
3103
+ unref(z$1).number().min(1).max(
3104
+ d.maxThreshold,
3105
+ `Number cannot be more than ${d.maxThreshold}`
3106
+ )
3107
+ )
3108
+ ],
3109
+ "model-value": unref(n).threshold,
3110
+ "onUpdate:modelValue": u[0] || (u[0] = (w) => n.value = {
3111
+ ...unref(n),
3112
+ threshold: w
3113
+ })
3114
+ }, null, 8, ["rules", "model-value"])) : createCommentVNode("", !0),
3115
+ createVNode(C, {
3116
+ label: "Reward Type",
3117
+ items: [
3118
+ { label: "Voucher", value: "VOUCHER" },
3119
+ { label: "Loyalty", value: "LOYALTY" }
3120
+ ],
3121
+ "model-value": unref(n).type,
3122
+ "onUpdate:modelValue": u[1] || (u[1] = (w) => {
3123
+ var O, j;
3124
+ w === "VOUCHER" ? n.value = {
3125
+ collectible: null,
3126
+ type: "VOUCHER",
3127
+ collectibleConfig: unref(initCollectibleConfig)("VOUCHER", {
3128
+ business: unref(useCoreStore)().currentBusiness.value._id
3129
+ }),
3130
+ earningOption: {
3131
+ amount: 1,
3132
+ type: "FIXED"
3133
+ },
3134
+ validityOption: {
3135
+ validForDay: 7
3136
+ },
3137
+ threshold: (O = unref(n)) == null ? void 0 : O.threshold
3138
+ } : n.value = {
3139
+ collectible: unref(i).loyaltyRewards.raw[0]._id,
3140
+ type: "LOYALTY",
3141
+ earningOption: {
3142
+ amount: 1,
3143
+ type: "FIXED"
3144
+ },
3145
+ validityOption: {
3146
+ validForDay: 7
3147
+ },
3148
+ threshold: (j = unref(n)) == null ? void 0 : j.threshold
3149
+ };
3150
+ })
3151
+ }, null, 8, ["model-value"]),
3152
+ unref(n).type == "LOYALTY" ? (openBlock(), createBlock(C, {
3153
+ key: 1,
3154
+ label: "Loyalty type",
3155
+ rules: [unref(ZodHelper).ruleAtPath(unref(p), "collectible", [unref(n).type])],
3156
+ items: unref(i).loyaltyRewards.items,
3157
+ "model-value": unref(n).collectible,
3158
+ "onUpdate:modelValue": u[2] || (u[2] = (w) => unref(n).collectible = w)
3159
+ }, null, 8, ["rules", "items", "model-value"])) : createCommentVNode("", !0),
3160
+ unref(n).type === "LOYALTY" ? (openBlock(), createElementBlock(Fragment, { key: 2 }, [
3161
+ u[12] || (u[12] = createElementVNode("div", { class: "fm-typo-en-title-sm-800" }, "Earning option", -1)),
3162
+ createVNode(_sfc_main$z, {
3163
+ class: "mt-[-8px]",
3164
+ rules: [unref(ZodHelper).ruleAtPath(unref(p), "earningOption", [unref(n).type])],
3165
+ "helper-state": unref(ZodHelper).helperState(unref(h), "earningOption"),
3166
+ "error-text": unref(ZodHelper).helperText(unref(h), "earningOption"),
3167
+ "fixed-type": !0,
3168
+ "model-value": unref(n).earningOption,
3169
+ "onUpdate:modelValue": u[3] || (u[3] = (w) => n.value = {
3170
+ ...unref(n),
3171
+ earningOption: w
3172
+ })
3173
+ }, null, 8, ["rules", "helper-state", "error-text", "model-value"]),
3174
+ createVNode(_sfc_main$A, {
3175
+ class: "!gap-24",
3176
+ type: unref(n).type === "LOYALTY" ? "custom" : "range",
3177
+ "for-credit": unref(n).type === "LOYALTY" && ((N = unref(i).loyaltyRewards.items.find(
3178
+ (w) => {
3179
+ var O;
3180
+ return w.value === ((O = unref(n)) == null ? void 0 : O.collectible);
3181
+ }
3182
+ )) == null ? void 0 : N.raw.type) === "CREDIT",
3183
+ rules: [unref(ZodHelper).ruleAtPath(unref(p), "validityOption", [unref(n).type])],
3184
+ "model-value": unref(n).validityOption,
3185
+ "onUpdate:modelValue": u[4] || (u[4] = (w) => n.value = {
3186
+ ...unref(n),
3187
+ validityOption: w
3188
+ })
3189
+ }, null, 8, ["type", "for-credit", "rules", "model-value"])
3190
+ ], 64)) : createCommentVNode("", !0),
3191
+ unref(n).type === "VOUCHER" ? (openBlock(), createBlock(_sfc_main$B, {
3192
+ key: 3,
3193
+ "reward-image": unref(a),
3194
+ "model-value": ((D = unref(n)) == null ? void 0 : D.collectibleConfig) ?? void 0,
3195
+ "onUpdate:modelValue": u[5] || (u[5] = (w) => n.value = {
3196
+ ...unref(n),
3197
+ collectibleConfig: w
3198
+ }),
3199
+ "onUpdate:rewardImage": u[6] || (u[6] = (w) => a.value = w)
3200
+ }, null, 8, ["reward-image", "model-value"])) : createCommentVNode("", !0),
3201
+ createVNode(JsonViewer, { json: unref(h) }, null, 8, ["json"])
3202
+ ];
3203
+ }),
3204
+ _: 1
3205
+ }, 512)) : createCommentVNode("", !0)
3206
+ ]),
3207
+ _: 1
3208
+ }, 8, ["modelValue"]);
3209
+ };
3210
+ }
3211
+ }), _hoisted_1$5 = {
3212
+ key: 0,
3213
+ class: "grid grid-cols-5 text-center gap-8 justify-between items-center w-full"
3214
+ }, _hoisted_2$4 = { class: "flex flex-col gap-0 items-center justify-center" }, _sfc_main$5 = /* @__PURE__ */ defineComponent({
3215
+ __name: "MissionProgress",
3216
+ props: {
3217
+ type: {
3218
+ type: String,
3219
+ required: !0
3220
+ },
3221
+ maxRange: {
3222
+ type: Number,
3223
+ required: !0
3224
+ },
3225
+ currentRange: {
3226
+ type: Number,
3227
+ default: 0
3228
+ },
3229
+ markers: {
3230
+ type: Array,
3231
+ default: () => []
3232
+ }
3233
+ },
3234
+ setup(e) {
3235
+ const s = e, { maxRange: o, currentRange: d, markers: i } = toRefs(s), c = computed(
3236
+ () => Math.min(d.value / o.value * 100, 100)
3237
+ ), l = (n) => n / o.value * 100;
3238
+ return (n, a) => {
3239
+ const r = resolveComponent("FmIcon");
3240
+ return e.type === "STAMP" ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
3241
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(Math.min(unref(o), 40), (p) => (openBlock(), createBlock(r, {
3242
+ class: normalizeClass(
3243
+ unref(d) >= p ? "text-fm-color-primary" : "text-fm-color-neutral-gray-200"
3244
+ ),
3245
+ outline: unref(d) < p,
3246
+ key: p,
3247
+ name: unref(i).some((h) => h === p) ? "featured_seasonal_and_gifts" : "check_circle"
3248
+ }, null, 8, ["class", "outline", "name"]))), 128))
3249
+ ])) : (openBlock(), createElementBlock("div", {
3250
+ key: 1,
3251
+ class: normalizeClass(["relative w-full h-4 rounded-lg", "bg-fm-color-system-warning-100"])
3252
+ }, [
3253
+ createElementVNode("div", {
3254
+ class: normalizeClass(["bg-fm-color-primary", "absolute top-0 left-0 h-full rounded-lg"]),
3255
+ style: normalizeStyle({ width: unref(c) + "%" })
3256
+ }, null, 4),
3257
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(i), (p, h) => (openBlock(), createElementBlock("div", {
3258
+ key: h,
3259
+ class: "absolute -top-1.5 flex flex-col items-center -translate-x-1/2",
3260
+ style: normalizeStyle({ left: l(p) + "%" })
3261
+ }, [
3262
+ createElementVNode("div", _hoisted_2$4, [
3263
+ createElementVNode("div", {
3264
+ class: normalizeClass(["h-16 w-[2px]", "bg-fm-color-system-warning-300"])
3265
+ }),
3266
+ a[0] || (a[0] = createElementVNode("div", null, "🎁", -1))
3267
+ ])
3268
+ ], 4))), 128))
3269
+ ]));
3270
+ };
3271
+ }
3272
+ }), isObject = (e) => e !== null && typeof e == "object";
3273
+ function changeKeysFactory(e) {
3274
+ return function s(o, d = 1, i) {
3275
+ if (d === 0 || !isObject(o))
3276
+ return o;
3277
+ if (Array.isArray(o))
3278
+ return o.map((l) => s(l, d - 1, i));
3279
+ const c = Object.create(Object.getPrototypeOf(o));
3280
+ return Object.keys(o).forEach((l) => {
3281
+ const n = o[l], a = e(l, i), r = s(n, d - 1, i);
3282
+ c[a] = r;
3283
+ }), c;
3284
+ };
3285
+ }
3286
+ 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({
3287
+ __name: "MissionPoolInput",
3288
+ props: {
3289
+ modelValue: {
3290
+ type: Array,
3291
+ default: () => []
3292
+ },
3293
+ mission: {
3294
+ type: Object,
3295
+ required: !0
3296
+ }
3297
+ },
3298
+ emits: ["update:model-value"],
3299
+ setup(e, { emit: s }) {
3300
+ const { t: o } = useI18n(), d = e, i = s, c = useMembershipStore(), l = z$1.array(z$1.lazy(() => FdtoThresholdReward)).min(1, "Requires at least 1 reward"), n = computed(
3301
+ () => d.modelValue.sort((v, u) => v.threshold - u.threshold) ?? []
3302
+ ), a = computed(() => {
3303
+ const v = l.safeParse(n.value);
3304
+ return v.success ? [] : v.error.errors;
3305
+ }), r = ref();
3306
+ function p(v, u) {
3307
+ var C;
3308
+ const m = [...n.value];
3309
+ m[u] = v, (C = r.value) == null || C.showSheet(!1), i("update:model-value", m);
3310
+ }
3311
+ function h(v) {
3312
+ const u = v.type == "VOUCHER" ? v.collectibleConfig : c.collectibles.find(
3313
+ (k) => k._id.toString() == v.collectible
3314
+ ), m = CollectionUtils.formattedType((u == null ? void 0 : u.name) || ""), C = v.earningOption.type == "FIXED" ? o("connect.template.mission_pool.reward_sublabel_fixed", {
3315
+ threshold: v.threshold,
3316
+ amount: v.earningOption.amount
3317
+ }) : o("connect.template.mission_pool.reward_sublabel_per_spend", {
3318
+ threshold: v.threshold,
3319
+ amount: v.earningOption.amount,
3320
+ every: v.earningOption.every
3321
+ });
3322
+ return {
3323
+ label: isNullOrEmpty(m) ? o("connect.template.mission_pool.no_reward") : m,
3324
+ sublabel: C
3325
+ };
3326
+ }
3327
+ function y(v) {
3328
+ var m;
3329
+ const u = [...n.value];
3330
+ (m = r.value) == null || m.showSheet(!0, u[v], v);
3331
+ }
3332
+ function V(v) {
3333
+ const u = [...n.value];
3334
+ u.splice(v, 1), i("update:model-value", u);
3335
+ }
3336
+ function x() {
3337
+ var v;
3338
+ (v = r.value) == null || v.showSheet(
3339
+ !0,
3340
+ {
3341
+ type: "LOYALTY",
3342
+ collectible: c.loyaltyRewards.items[0].value,
3343
+ threshold: null,
3344
+ validityOption: {
3345
+ validForDay: 7
3346
+ },
3347
+ earningOption: {
3348
+ type: "FIXED",
3349
+ amount: 1
3350
+ }
3351
+ },
3352
+ n.value.length
3353
+ );
3354
+ }
3355
+ function f(v) {
3356
+ var u, m;
3357
+ return v.type == "VOUCHER" ? (u = v.collectibleConfig) == null ? void 0 : u.name : sentenceCase(
3358
+ ((m = c.loyaltyRewards.items.find(
3359
+ (C) => C.value == v.collectible
3360
+ )) == null ? void 0 : m.label) || ""
3361
+ );
3362
+ }
3363
+ return (v, u) => {
3364
+ const m = resolveComponent("FmButton"), C = resolveComponent("FmCard"), k = resolveComponent("FmHelperText");
3365
+ return openBlock(), createElementBlock("div", _hoisted_1$4, [
3366
+ createElementVNode("div", _hoisted_2$3, toDisplayString(unref(o)("connect.template.configure_reward_customer")), 1),
3367
+ createVNode(m, {
3368
+ label: unref(o)("connect.template.mission_pool.add_reward"),
3369
+ onClick: u[0] || (u[0] = ($) => x()),
3370
+ variant: "plain",
3371
+ icon: "add"
3372
+ }, null, 8, ["label"]),
3373
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(n), ($, F) => (openBlock(), createBlock(C, {
3374
+ key: F,
3375
+ class: "px-16 py-12 flex items-center justify-between cursor-pointer",
3376
+ variant: "outlined",
3377
+ onClick: (N) => y(F)
3378
+ }, {
3379
+ default: withCtx(() => [
3380
+ createElementVNode("div", null, [
3381
+ createElementVNode("div", _hoisted_3$3, toDisplayString(h($).label), 1),
3382
+ createElementVNode("div", _hoisted_4$2, toDisplayString(h($).sublabel), 1)
3383
+ ]),
3384
+ createVNode(m, {
3385
+ icon: "delete",
3386
+ variant: "tertiary",
3387
+ onClick: (N) => (N.stopPropagation(), V(F))
3388
+ }, null, 8, ["onClick"])
3389
+ ]),
3390
+ _: 2
3391
+ }, 1032, ["onClick"]))), 128)),
3392
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(a).filter(($) => $.path.join(".") == ""), ($) => (openBlock(), createBlock(k, {
3393
+ key: $.message,
3394
+ text: $.message,
3395
+ state: "error"
3396
+ }, null, 8, ["text"]))), 128)),
3397
+ createElementVNode("div", _hoisted_5$2, toDisplayString(unref(o)("connect.template.mission_pool.preview")), 1),
3398
+ (openBlock(), createBlock(C, {
3399
+ key: 0,
3400
+ variant: "outlined",
3401
+ class: "p-24 space-y-16 w-fit"
3402
+ }, {
3403
+ default: withCtx(() => {
3404
+ var $, F;
3405
+ return [
3406
+ createElementVNode("div", _hoisted_6$2, [
3407
+ createElementVNode("div", null, [
3408
+ createElementVNode("div", _hoisted_7$2, toDisplayString(unref(o)("connect.template.mission_pool.collect_stamps", { end: e.mission.end })) + " " + toDisplayString((($ = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : $.earningOption.amount) > 1 ? (F = e.modelValue[e.modelValue.length - 1]) == null ? void 0 : F.earningOption.amount : "") + " " + toDisplayString(e.modelValue[e.modelValue.length - 1] ? f(e.modelValue[e.modelValue.length - 1]) : ""), 1),
3409
+ createElementVNode("div", _hoisted_8$2, toDisplayString(unref(o)("connect.template.mission_pool.earn_stamp")), 1)
3410
+ ])
3411
+ ]),
3412
+ createElementVNode("div", _hoisted_9$2, [
3413
+ createVNode(_sfc_main$5, {
3414
+ type: e.mission.type,
3415
+ "max-range": e.mission.end,
3416
+ currentRange: e.mission.end / 4,
3417
+ markers: e.modelValue.map((N) => N.threshold)
3418
+ }, null, 8, ["type", "max-range", "currentRange", "markers"]),
3419
+ e.mission.type == "PROGRESSIVE" ? (openBlock(), createElementBlock("div", _hoisted_10$2, " 0/" + toDisplayString(e.mission.end.toLocaleString()), 1)) : createCommentVNode("", !0)
3420
+ ])
3421
+ ];
3422
+ }),
3423
+ _: 1
3424
+ })),
3425
+ createVNode(_sfc_main$6, {
3426
+ ref_key: "sheetRef",
3427
+ ref: r,
3428
+ "onUpdate:modelValue": p,
3429
+ "max-threshold": e.mission.end
3430
+ }, null, 8, ["max-threshold"])
3431
+ ]);
3432
+ };
3433
+ }
3434
+ }), _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({
3435
+ __name: "MissionInput",
3436
+ props: {
3437
+ modelValue: Object
3438
+ },
3439
+ emits: ["update:model-value"],
3440
+ setup(e, { emit: s }) {
3441
+ const { t: o } = useI18n(), d = e, i = computed(() => {
3442
+ const n = FdoMission.safeParse(d.modelValue);
3443
+ return n.success ? [] : n.error.errors;
3444
+ }), c = computed(() => [
3445
+ {
3446
+ label: o("connect.campaign.mission.typeOption.STAMP.label"),
3447
+ description: o("connect.campaign.mission.typeOption.STAMP.description"),
3448
+ value: F_MISSION_TYPE.enum.STAMP
3449
+ },
3450
+ {
3451
+ label: o("connect.campaign.mission.typeOption.PROGRESSIVE.label"),
3452
+ description: o("connect.campaign.mission.typeOption.PROGRESSIVE.description"),
3453
+ value: F_MISSION_TYPE.enum.PROGRESSIVE
3454
+ }
3455
+ ]), l = s;
3456
+ return (n, a) => {
3457
+ var h;
3458
+ const r = resolveComponent("FmCard"), p = resolveComponent("FmStepperField");
3459
+ return openBlock(), createElementBlock("div", _hoisted_1$3, [
3460
+ createElementVNode("div", _hoisted_2$2, [
3461
+ createElementVNode("div", _hoisted_3$2, toDisplayString(unref(o)("connect.campaign.mission.missionType")), 1),
3462
+ createElementVNode("div", _hoisted_4$1, toDisplayString(unref(o)("connect.template.select_game")), 1),
3463
+ createElementVNode("div", _hoisted_5$1, [
3464
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(c), (y) => {
3465
+ var V, x;
3466
+ return openBlock(), createBlock(r, {
3467
+ variant: "outlined",
3468
+ class: normalizeClass(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-3", {
3469
+ "col-span-2": unref(c).length == 1,
3470
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": ((V = e.modelValue) == null ? void 0 : V.type) == y.value,
3471
+ "hover:bg-fm-color-opacity-sm": ((x = e.modelValue) == null ? void 0 : x.type) != y.value
3472
+ }]),
3473
+ onClick: () => {
3474
+ var f, v;
3475
+ ((f = e.modelValue) == null ? void 0 : f.type) != y.value && l("update:model-value", {
3476
+ ...e.modelValue,
3477
+ type: y.value,
3478
+ end: ((v = e.modelValue) == null ? void 0 : v.end) || 1
3479
+ });
3480
+ },
3481
+ key: y.value
3482
+ }, {
3483
+ default: withCtx(() => [
3484
+ createElementVNode("div", _hoisted_6$1, toDisplayString(y.label), 1),
3485
+ createElementVNode("div", _hoisted_7$1, toDisplayString(y.description), 1)
3486
+ ]),
3487
+ _: 2
3488
+ }, 1032, ["class", "onClick"]);
3489
+ }), 128))
3490
+ ])
3491
+ ]),
3492
+ createElementVNode("div", _hoisted_8$1, [
3493
+ createElementVNode("div", _hoisted_9$1, toDisplayString(unref(o)("connect.campaign.mission.collectionsRequired")), 1),
3494
+ createElementVNode("div", _hoisted_10$1, toDisplayString(unref(o)("connect.campaign.mission.collectionsRequiredDescription")), 1),
3495
+ createVNode(p, {
3496
+ label: unref(o)("connect.campaign.mission.maximumToCollect"),
3497
+ "model-value": ((h = e.modelValue) == null ? void 0 : h.end) || null,
3498
+ "onUpdate:modelValue": a[0] || (a[0] = (y) => {
3499
+ var V;
3500
+ return l("update:model-value", {
3501
+ ...e.modelValue,
3502
+ type: ((V = e.modelValue) == null ? void 0 : V.type) || "STAMP",
3503
+ end: y
3504
+ });
3505
+ }),
3506
+ "helper-text": unref(ZodHelper).helperText(unref(i), "end") || unref(o)("connect.campaign.mission.thresholdHelperText"),
3507
+ "helper-state": unref(ZodHelper).helperState(unref(i), "end") || "none"
3508
+ }, null, 8, ["label", "model-value", "helper-text", "helper-state"])
3509
+ ])
3510
+ ]);
3511
+ };
3512
+ }
3513
+ });
3514
+ function useLocaleText() {
3515
+ const { locale: e, t: s } = useI18n();
3516
+ function o(d, i) {
3517
+ return d ? d[e.value] ?? d["en-US"] ?? s(i) : s(i);
3518
+ }
3519
+ return { getLocaleText: o };
3520
+ }
3521
+ const _hoisted_1$2 = { key: 29 }, _sfc_main$2 = /* @__PURE__ */ defineComponent({
3522
+ __name: "TemplateInput",
3523
+ props: {
3524
+ field: { type: Object, required: !0 },
3525
+ modelValue: {
3526
+ type: Object
3527
+ },
3528
+ schema: {
3529
+ type: Object
3530
+ },
3531
+ extras: {
3532
+ type: Object
3533
+ },
3534
+ helperText: {
3535
+ type: String
3536
+ },
3537
+ disabled: {
3538
+ type: Boolean,
3539
+ default: !1
3540
+ },
3541
+ campaignType: {
3542
+ type: String,
3543
+ default: void 0
3544
+ },
3545
+ /** False until the form has been submitted, for fields that validate late. */
3546
+ showValidation: {
3547
+ type: Boolean,
3548
+ default: !0
3549
+ }
3550
+ },
3551
+ emits: ["update:model-value", "update:file"],
3552
+ setup(e, { emit: s }) {
3553
+ const { t: o } = useI18n(), { getLocaleText: d } = useLocaleText(), i = e, c = s;
3554
+ function l(p) {
3555
+ switch (i.field.type) {
3556
+ case "timeframe":
3557
+ const h = p.startDate ? hooks(p.startDate).startOf("day").toISOString() : void 0, y = p.endDate ? hooks(p.endDate).endOf("day").toISOString() : void 0;
3558
+ c("update:model-value", {
3559
+ type: "timeframe",
3560
+ property: "__now",
3561
+ start: h,
3562
+ end: y
3563
+ });
3564
+ break;
3565
+ case "image": {
3566
+ c(
3567
+ "update:file",
3568
+ p,
3569
+ n.value || firebaseStorage.collectibleImagePath(void 0, p)
3570
+ );
3571
+ break;
3572
+ }
3573
+ default:
3574
+ c("update:model-value", p);
3575
+ break;
3576
+ }
3577
+ }
3578
+ const n = computed(() => {
3579
+ switch (i.field.type) {
3580
+ case "timeframe": {
3581
+ const p = i.modelValue;
3582
+ return {
3583
+ startDate: p != null && p.start ? hooks(p == null ? void 0 : p.start).format("YYYY-MM-DD") : null,
3584
+ endDate: p != null && p.end ? hooks(p == null ? void 0 : p.end).format("YYYY-MM-DD") : null
3585
+ };
3586
+ }
3587
+ default:
3588
+ return i.modelValue;
3589
+ }
3590
+ });
3591
+ function a() {
3592
+ if (!r.value.schema) return [];
3593
+ const p = r.value.schema.safeParse(i.modelValue);
3594
+ return p.success ? [] : p.error.errors;
3595
+ }
3596
+ const r = computed(() => ({
3597
+ schema: i.schema,
3598
+ unwrapped: i.schema ? ZodHelper.unwrap(i.schema) : void 0,
3599
+ rules: i.schema ? [ZodHelper.ruleAtPath(i.schema, "")] : void 0,
3600
+ labelMark: i.schema && ZodHelper.isRequired(i.schema) == !1 ? "optional" : void 0,
3601
+ zodLabel: i.schema ? ZodHelper.toInputLabel(
3602
+ i.schema,
3603
+ d(i.field.label_locale, i.field.label ?? "")
3604
+ ) : void 0
3605
+ }));
3606
+ return (p, h) => {
3607
+ var u, m, C, k, $;
3608
+ const y = resolveComponent("FmTextField"), V = resolveComponent("FmStepperField"), x = resolveComponent("FmTextarea"), f = resolveComponent("FmHelperText"), v = resolveComponent("FmSwitch");
3609
+ return e.field.type === "text" ? (openBlock(), createBlock(y, {
3610
+ key: 0,
3611
+ label: unref(d)(e.field.label_locale, e.field.label ?? ""),
3612
+ "label-mark": unref(r).labelMark,
3613
+ rules: unref(r).rules,
3614
+ "model-value": unref(n),
3615
+ "onUpdate:modelValue": l,
3616
+ "helper-state": e.helperText ? "error" : void 0,
3617
+ "helper-text": e.helperText
3618
+ }, null, 8, ["label", "label-mark", "rules", "model-value", "helper-state", "helper-text"])) : e.field.type === "number" ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
3619
+ createVNode(JsonViewer, {
3620
+ json: { schema: unref(r).unwrapped, props: i }
3621
+ }, null, 8, ["json"]),
3622
+ createVNode(V, {
3623
+ label: unref(d)(e.field.label_locale, e.field.label ?? ""),
3624
+ "label-mark": e.field.isRuleChildren ? void 0 : unref(r).labelMark,
3625
+ "model-value": unref(n),
3626
+ rules: e.field.isRuleChildren ? [] : unref(r).rules,
3627
+ "onUpdate:modelValue": l,
3628
+ "helper-state": e.field.isRuleChildren && e.helperText ? "error" : void 0,
3629
+ "helper-text": e.field.isRuleChildren ? e.helperText : void 0
3630
+ }, null, 8, ["label", "label-mark", "model-value", "rules", "helper-state", "helper-text"])
3631
+ ], 64)) : e.field.type === "textarea" ? (openBlock(), createBlock(x, {
3632
+ key: 2,
3633
+ label: unref(d)(e.field.label_locale, e.field.label ?? ""),
3634
+ "label-mark": unref(r).labelMark,
3635
+ rules: unref(r).rules,
3636
+ "model-value": unref(n),
3637
+ "onUpdate:modelValue": l,
3638
+ "show-word-count": "",
3639
+ "max-length": ($ = (k = (C = (m = (u = unref(r)) == null ? void 0 : u.unwrapped) == null ? void 0 : m._def) == null ? void 0 : C.checks) == null ? void 0 : k.find((F) => F.kind == "max")) == null ? void 0 : $.value
3640
+ }, null, 8, ["label", "label-mark", "rules", "model-value", "max-length"])) : e.field.type === "trigger" ? (openBlock(), createBlock(_sfc_main$o, {
3641
+ key: 3,
3642
+ "campaign-type": e.extras,
3643
+ "model-value": unref(n),
3644
+ disabled: e.disabled,
3645
+ "onUpdate:modelValue": l
3646
+ }, null, 8, ["campaign-type", "model-value", "disabled"])) : e.field.type === "timeframe" ? (openBlock(), createElementBlock(Fragment, { key: 4 }, [
3647
+ createVNode(_sfc_main$m, {
3648
+ "model-value": unref(n),
3649
+ "onUpdate:modelValue": l
3650
+ }, null, 8, ["model-value"]),
3651
+ createVNode(f, {
3652
+ class: "!mt-[8px]",
3653
+ text: unref(ZodHelper).helperText(a(), ""),
3654
+ state: unref(ZodHelper).helperState(a(), "")
3655
+ }, null, 8, ["text", "state"])
3656
+ ], 64)) : e.field.type === "image" ? (openBlock(), createBlock(_sfc_main$C, {
3657
+ key: 5,
3658
+ thumbnail: unref(n),
3659
+ "aspect-ratio": "16 / 9",
3660
+ class: "w-1/2 xs:w-2/3",
3661
+ "onUpdate:file": l
3662
+ }, {
3663
+ label: withCtx(() => [
3664
+ (openBlock(), createBlock(resolveDynamicComponent(unref(r).zodLabel)))
3665
+ ]),
3666
+ _: 1
3667
+ }, 8, ["thumbnail"])) : e.field.type === "switch" ? (openBlock(), createBlock(v, {
3668
+ key: 6,
3669
+ label: unref(d)(e.field.label_locale, e.field.label ?? ""),
3670
+ "label-placement": "right",
3671
+ sublabel: e.field.property == "campaign.notify" ? "Notify customer when customer receives the reward" : void 0,
3672
+ "label-mark": unref(r).labelMark,
3673
+ rules: unref(r).rules,
3674
+ "model-value": unref(n),
3675
+ "onUpdate:modelValue": l
3676
+ }, null, 8, ["label", "sublabel", "label-mark", "rules", "model-value"])) : e.field.type === "collectible_options" ? (openBlock(), createBlock(_sfc_main$D, {
3677
+ key: 7,
3678
+ "model-value": unref(n),
3679
+ "onUpdate:modelValue": l,
3680
+ "no-campaign": !1,
3681
+ schema: unref(r).schema,
3682
+ "is-mission": e.extras === "MISSION"
3683
+ }, null, 8, ["model-value", "schema", "is-mission"])) : e.field.type === "grab_conditions" ? (openBlock(), createBlock(GrabConditionsInput, {
3684
+ key: 8,
3685
+ "model-value": unref(n),
3686
+ "onUpdate:modelValue": l,
3687
+ schema: unref(r).schema
3688
+ }, null, 8, ["model-value", "schema"])) : e.field.type === "grab_quota" ? (openBlock(), createBlock(_sfc_main$9, {
3689
+ key: 9,
3690
+ "model-value": unref(n),
3691
+ "onUpdate:modelValue": l,
3692
+ schema: unref(r).schema
3693
+ }, null, 8, ["model-value", "schema"])) : e.field.type === "target_location" ? (openBlock(), createBlock(_sfc_main$E, {
3694
+ key: 10,
3695
+ "model-value": unref(n),
3696
+ "onUpdate:modelValue": l
3697
+ }, null, 8, ["model-value"])) : e.field.type == "effect" ? (openBlock(), createElementBlock(Fragment, { key: 11 }, [
3698
+ createVNode(_sfc_main$F, {
3699
+ "model-value": unref(n),
3700
+ "onUpdate:modelValue": l,
3701
+ "can-set-auto-apply": e.field.property == "campaign.effect"
3702
+ }, null, 8, ["model-value", "can-set-auto-apply"]),
3703
+ unref(n) ? createCommentVNode("", !0) : (openBlock(), createBlock(f, {
3704
+ key: 0,
3705
+ class: "!mt-[8px]",
3706
+ text: unref(o)("connect.campaign.common.effect_required"),
3707
+ state: "error"
3708
+ }, null, 8, ["text"]))
3709
+ ], 64)) : e.field.type == "grab_effect" ? (openBlock(), createElementBlock(Fragment, { key: 12 }, [
3710
+ createVNode(GrabEffectSheet, {
3711
+ "model-value": unref(n),
3712
+ "onUpdate:modelValue": l
3713
+ }, null, 8, ["model-value"]),
3714
+ unref(n) ? createCommentVNode("", !0) : (openBlock(), createBlock(f, {
3715
+ key: 0,
3716
+ class: "!mt-[8px]",
3717
+ text: unref(o)("connect.campaign.common.effect_required"),
3718
+ state: "error"
3719
+ }, null, 8, ["text"]))
3720
+ ], 64)) : e.field.type === "message" ? (openBlock(), createElementBlock(Fragment, { key: 13 }, [
3721
+ e.field.property === "campaign.message" ? (openBlock(), createBlock(_sfc_main$g, {
3722
+ key: 0,
3723
+ "show-validation": e.showValidation,
3724
+ "model-value": unref(n),
3725
+ "onUpdate:modelValue": l,
3726
+ "helper-text": unref(ZodHelper).helperText(a(), ""),
3727
+ "trigger-type": e.field.extras,
3728
+ "helper-state": unref(ZodHelper).helperState(a(), "")
3729
+ }, null, 8, ["show-validation", "model-value", "helper-text", "trigger-type", "helper-state"])) : (openBlock(), createBlock(_sfc_main$x, {
3730
+ key: 1,
3731
+ "allow-email": !0,
3732
+ "allow-whatsapp": !0,
3733
+ "model-value": unref(n),
3734
+ "onUpdate:modelValue": l,
3735
+ "helper-text": unref(ZodHelper).helperText(a(), ""),
3736
+ "trigger-type": e.field.extras,
3737
+ "helper-state": unref(ZodHelper).helperState(a(), "")
3738
+ }, null, 8, ["model-value", "helper-text", "trigger-type", "helper-state"]))
3739
+ ], 64)) : e.field.type === "earning_option" ? (openBlock(), createBlock(_sfc_main$z, {
3740
+ key: 14,
3741
+ "model-value": unref(n),
3742
+ "onUpdate:modelValue": l,
3743
+ extras: e.extras,
3744
+ "error-text": e.helperText
3745
+ }, null, 8, ["model-value", "extras", "error-text"])) : e.field.type === "validity_option" ? (openBlock(), createBlock(_sfc_main$A, {
3746
+ key: 15,
3747
+ type: "custom",
3748
+ "model-value": unref(n),
3749
+ "onUpdate:modelValue": l,
3750
+ "helper-text": e.helperText || unref(ZodHelper).helperText(a(), ""),
3751
+ "for-credit": i.campaignType === "CREDIT"
3752
+ }, null, 8, ["model-value", "helper-text", "for-credit"])) : e.field.type === "game_type" ? (openBlock(), createBlock(_sfc_main$e, {
3753
+ key: 16,
3754
+ "model-value": unref(n),
3755
+ "onUpdate:modelValue": l
3756
+ }, null, 8, ["model-value"])) : e.field.type === "reward_pool" ? (openBlock(), createBlock(_sfc_main$c, {
3757
+ key: 17,
3758
+ "model-value": unref(n),
3759
+ "onUpdate:modelValue": l
3760
+ }, null, 8, ["model-value"])) : e.field.type === "mission" ? (openBlock(), createBlock(_sfc_main$3, {
3761
+ key: 18,
3762
+ "model-value": unref(n),
3763
+ "onUpdate:modelValue": l
3764
+ }, null, 8, ["model-value"])) : e.field.type === "mission_type" ? (openBlock(), createBlock(_sfc_main$8, {
3765
+ key: 19,
3766
+ "model-value": unref(n),
3767
+ "onUpdate:modelValue": l
3768
+ }, null, 8, ["model-value"])) : e.field.type === "mission_end" ? (openBlock(), createBlock(_sfc_main$7, {
3769
+ key: 20,
3770
+ "model-value": unref(n),
3771
+ "onUpdate:modelValue": l,
3772
+ "helper-text": unref(ZodHelper).helperText(a(), ""),
3773
+ "helper-state": unref(ZodHelper).helperState(a(), "")
3774
+ }, null, 8, ["model-value", "helper-text", "helper-state"])) : e.field.type === "mission_pool" ? (openBlock(), createBlock(_sfc_main$4, {
3775
+ key: 21,
3776
+ "model-value": unref(n),
3777
+ "onUpdate:modelValue": l,
3778
+ mission: e.extras.mission
3779
+ }, null, 8, ["model-value", "mission"])) : e.field.type === "rule_schedule" ? (openBlock(), createElementBlock(Fragment, { key: 22 }, [
3780
+ createVNode(_sfc_main$f, {
3781
+ "model-value": unref(n),
3782
+ "onUpdate:modelValue": l,
3783
+ "start-date": e.extras.start,
3784
+ "end-date": e.extras.end
3785
+ }, null, 8, ["model-value", "start-date", "end-date"]),
3786
+ e.helperText ? (openBlock(), createBlock(f, {
3787
+ key: 0,
3788
+ class: "!mt-[8px]",
3789
+ text: e.helperText,
3790
+ state: "error"
3791
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3792
+ ], 64)) : e.field.type === "rule_user" ? (openBlock(), createElementBlock(Fragment, { key: 23 }, [
3793
+ createVNode(_sfc_main$G, {
3794
+ "model-value": unref(n),
3795
+ "onUpdate:modelValue": l
3796
+ }, null, 8, ["model-value"]),
3797
+ e.helperText ? (openBlock(), createBlock(f, {
3798
+ key: 0,
3799
+ class: "!mt-[8px]",
3800
+ text: e.helperText,
3801
+ state: "error"
3802
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3803
+ ], 64)) : e.field.type === "rule_time" ? (openBlock(), createElementBlock(Fragment, { key: 24 }, [
3804
+ e.extras == "PROMOTION" && unref(RuleBuilder).getRules(unref(n).rules.g_time).length > 0 ? (openBlock(), createBlock(f, {
3805
+ key: 0,
3806
+ state: "warning",
3807
+ text: `Time based rule only work for POS >= v${unref(featureVersionMapping).TIME_BASED_PROMOTION}`
3808
+ }, null, 8, ["text"])) : createCommentVNode("", !0),
3809
+ createVNode(_sfc_main$q, {
3810
+ "model-value": unref(n),
3811
+ "onUpdate:modelValue": l
3812
+ }, null, 8, ["model-value"]),
3813
+ e.helperText ? (openBlock(), createBlock(f, {
3814
+ key: 1,
3815
+ class: "!mt-[8px]",
3816
+ text: e.helperText,
3817
+ state: "error"
3818
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3819
+ ], 64)) : e.field.type === "rule_bill" ? (openBlock(), createElementBlock(Fragment, { key: 25 }, [
3820
+ createVNode(_sfc_main$H, {
3821
+ "model-value": unref(n),
3822
+ "onUpdate:modelValue": l
3823
+ }, null, 8, ["model-value"]),
3824
+ e.helperText ? (openBlock(), createBlock(f, {
3825
+ key: 0,
3826
+ class: "!mt-[8px]",
3827
+ text: e.helperText,
3828
+ state: "error"
3829
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3830
+ ], 64)) : e.field.type === "rule_feedback" ? (openBlock(), createElementBlock(Fragment, { key: 26 }, [
3831
+ createVNode(_sfc_main$I, {
3832
+ "model-value": unref(n),
3833
+ "onUpdate:modelValue": l
3834
+ }, null, 8, ["model-value"]),
3835
+ e.helperText ? (openBlock(), createBlock(f, {
3836
+ key: 0,
3837
+ class: "!mt-[8px]",
3838
+ text: e.helperText,
3839
+ state: "error"
3840
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3841
+ ], 64)) : e.field.type === "rule_birthday" ? (openBlock(), createElementBlock(Fragment, { key: 27 }, [
3842
+ createVNode(_sfc_main$p, {
3843
+ "model-value": unref(n),
3844
+ "onUpdate:modelValue": l
3845
+ }, null, 8, ["model-value"]),
3846
+ e.helperText ? (openBlock(), createBlock(f, {
3847
+ key: 0,
3848
+ class: "!mt-[8px]",
3849
+ text: e.helperText,
3850
+ state: "error"
3851
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3852
+ ], 64)) : e.field.type === "promotion_game_type" ? (openBlock(), createElementBlock(Fragment, { key: 28 }, [
3853
+ createVNode(_sfc_main$b, {
3854
+ "model-value": unref(n),
3855
+ "onUpdate:modelValue": l
3856
+ }, null, 8, ["model-value"]),
3857
+ e.helperText ? (openBlock(), createBlock(f, {
3858
+ key: 0,
3859
+ class: "!mt-[8px]",
3860
+ text: e.helperText,
3861
+ state: "error"
3862
+ }, null, 8, ["text"])) : createCommentVNode("", !0)
3863
+ ], 64)) : (openBlock(), createElementBlock("pre", _hoisted_1$2, toDisplayString(i.field), 1));
3864
+ };
3865
+ }
3866
+ }), _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({
3867
+ __name: "CampaignSummary",
3868
+ props: {
3869
+ data: {
3870
+ type: Object,
3871
+ required: !0
3872
+ }
3873
+ },
3874
+ setup(e) {
3875
+ const { t: s, te: o } = useI18n();
3876
+ function d(i) {
3877
+ return o(i) || o(i, "en-US");
3878
+ }
3879
+ return (i, c) => {
3880
+ const l = resolveComponent("FmCard");
3881
+ return openBlock(), createBlock(l, {
3882
+ variant: "outlined",
3883
+ class: "p-16 space-y-8"
3884
+ }, {
3885
+ default: withCtx(() => [
3886
+ createElementVNode("div", _hoisted_1$1, toDisplayString(unref(s)("connect.campaign.common.summary")), 1),
3887
+ c[0] || (c[0] = createElementVNode("div", { class: "h-[1px] bg-fm-color-neutral-gray-100 w-full" }, null, -1)),
3888
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(getCampaignSummaryObject)(e.data), (n, a) => (openBlock(), createElementBlock("div", {
3889
+ class: "space-y-4",
3890
+ key: a
3891
+ }, [
3892
+ n ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
3893
+ createElementVNode("div", _hoisted_2$1, toDisplayString(unref(s)(`${a}`)), 1),
3894
+ createElementVNode("div", _hoisted_3$1, toDisplayString(d(`${n}`) ? unref(s)(`${n}`) : n), 1)
3895
+ ], 64)) : createCommentVNode("", !0)
3896
+ ]))), 128))
3897
+ ]),
3898
+ _: 1
3899
+ });
3900
+ };
3901
+ }
3902
+ }), _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 = {
3903
+ key: 0,
3904
+ class: "max-w-6xl mx-auto"
3905
+ }, _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({
3906
+ __name: "EditCampaignSheet",
3907
+ emits: ["submit:model-value"],
3908
+ setup(__props, { expose: __expose, emit: __emit }) {
3909
+ const Dialog = useDialog(), sheetVisible = ref(!1), { t } = useI18n(), { getLocaleText } = useLocaleText(), currentStep = ref(1), data = ref(), schema = ref(z$1.any()), template = ref(
3910
+ TEMPLATES.VOUCHER
3911
+ ), { minor } = useLoading, isLoading = ref(!1), sheetTitle = ref("Create Campaign"), campaignType = ref("VOUCHER");
3912
+ async function showSheet(visible, type, campaign, selectedTemplate) {
3913
+ var e, s, o;
3914
+ if (sheetVisible.value = visible, campaignType.value = type, visible == !0) {
3915
+ try {
3916
+ isLoading.value = visible, await useMembershipStore().readRewards(), await useBusinessStore().readLocations(), await useMembershipStore().readSegments(), await useMembershipStore().readMembership();
3917
+ } catch {
3918
+ } finally {
3919
+ await new Promise((d) => setTimeout(d, 120)), isLoading.value = !1;
3920
+ }
3921
+ console.log(
3922
+ TEMPLATES[type],
3923
+ "base template"
3924
+ ), template.value = selectedTemplate ?? TEMPLATES[type], schema.value = CampaignDtos[type], type === "VOUCHER" && (await useCampaignStore().read(), schema.value = schema.value.superRefine((d, i) => {
3925
+ var c;
3926
+ if (d.campaign.type === "VOUCHER" && d.campaign.code) {
3927
+ const l = (c = d.campaign._id) == null ? void 0 : c.toString();
3928
+ useCampaignStore().campaigns.voucher.some(
3929
+ (n) => n.code === d.campaign.code && n._id.toString() !== l
3930
+ ) && i.addIssue({
3931
+ code: "custom",
3932
+ message: "Code already exists, please use another code",
3933
+ path: ["campaign", "code"]
3934
+ });
3935
+ }
3936
+ })), data.value = campaign != null ? { ...campaign, templateId: (e = campaign.template) == null ? void 0 : e._id } : _.cloneDeep({
3937
+ ...(s = template.value) == null ? void 0 : s.defaultValue
3938
+ }), "configs" in data.value && typeof data.value.configs == "string" && (data.value.configs = eval(data.value.configs)), data.value = cleanPF(data.value), type === "BROADCAST" && normaliseBroadcastDelivery(data.value.campaign), 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, submitAttempted.value = !1, sheetTitle.value = (o = campaign == null ? void 0 : campaign.campaign) != null && o._id ? t("connect.campaign.common.edit_campaign_title", {
3939
+ typeName: t(`connect.campaign.common.typeName.${type}`)
3940
+ }) : t("connect.campaign.common.create_campaign_title", {
3941
+ typeName: t(`connect.campaign.common.typeName.${type}`)
3942
+ });
3943
+ }
3944
+ }
3945
+ async function hideSheet() {
3946
+ Dialog.open({
3947
+ title: t("connect.campaign.common.unsaved_changes"),
3948
+ message: t("connect.campaign.common.unsaved_changes"),
3949
+ primaryActions: {
3950
+ text: t("connect.campaign.common.unsaved_changes_confirm"),
3951
+ close: !0
3952
+ },
3953
+ secondaryActions: {
3954
+ text: t("connect.campaign.common.unsaved_changes_cancel"),
3955
+ close: !1
3956
+ }
3957
+ }).onPrimary(() => {
3958
+ sheetVisible.value = !1;
3959
+ }).onSecondary(() => {
3960
+ Dialog.close();
3961
+ });
3962
+ }
3963
+ const emits = __emit, errors = computed(() => {
3964
+ const e = schema.value.superRefine(campaignRefinement).safeParse(data.value);
3965
+ return e.success ? [] : e.error.errors;
3966
+ });
3967
+ function stepErrors(e = currentStep.value - 1) {
3968
+ const s = template.value.steps[e].groups.flatMap(
3969
+ (o) => o.fields.map((d) => schemaPathForField(d.property))
3970
+ );
3971
+ return errors.value.filter(
3972
+ (o) => s.some((d) => o.path.join(".").includes(d))
3973
+ );
3974
+ }
3975
+ const validateOnSubmit = computed(() => campaignType.value === "BROADCAST"), submitAttempted = ref(!1), showValidation = computed(
3976
+ () => !validateOnSubmit.value || submitAttempted.value
3977
+ ), visibleErrors = computed(
3978
+ () => showValidation.value ? errors.value : []
3979
+ );
3980
+ function hasVisibleStepErrors(e) {
3981
+ return showValidation.value && stepErrors(e).length > 0;
3982
+ }
3983
+ function isNextDisabled() {
3984
+ return validateOnSubmit.value ? !1 : currentStep.value - 1 < template.value.steps.length - 1 ? stepErrors().length > 0 : errors.value.length > 0;
3985
+ }
3986
+ function onNext() {
3987
+ if (stepErrors().length > 0) {
3988
+ submitAttempted.value = !0;
3989
+ return;
3990
+ }
3991
+ submitAttempted.value = !1, currentStep.value++;
3992
+ }
3993
+ __expose({ showSheet });
3994
+ function showSummaryDialog() {
3995
+ Dialog.open({
3996
+ title: "",
3997
+ dialogComponent: _sfc_main$1,
3998
+ dialogComponentProps: {
3999
+ data: data.value
4000
+ }
4001
+ });
4002
+ }
4003
+ const broadcastDelivery = computed(
4004
+ () => {
4005
+ var e;
4006
+ return (e = data.value) != null && e.campaign ? toDelivery(data.value.campaign) : void 0;
4007
+ }
4008
+ );
4009
+ function valueForField(e) {
4010
+ return e === "campaign.message" ? broadcastDelivery.value : _.get(data.value, e);
4011
+ }
4012
+ function schemaPathForField(e) {
4013
+ return e === "campaign.message" ? "campaign.delivery" : e;
4014
+ }
4015
+ function onUpdateProperty(e, s) {
4016
+ var o, d, i, c, l, n, a, r;
4017
+ if (e === "campaign.message" && s && "channels" in s) {
4018
+ _.set(data.value, "campaign.delivery", s);
4019
+ const p = toLegacyMessage(s);
4020
+ p ? _.set(data.value, "campaign.message", p) : delete data.value.campaign.message;
4021
+ return;
4022
+ }
4023
+ if (_.set(data.value, e, s), e == "campaign.event.type") {
4024
+ const h = ((c = (i = (d = (o = template.value) == null ? void 0 : o.defaultValue) == null ? void 0 : d.campaign) == null ? void 0 : i.event) == null ? void 0 : c.rule) ? _.cloneDeep({
4025
+ ...(r = (a = (n = (l = template.value) == null ? void 0 : l.defaultValue) == null ? void 0 : n.campaign) == null ? void 0 : a.event) == null ? void 0 : r.rule
4026
+ }) : RuleBuilder.setRuleToGroup(RuleBuilder.scaffoldGroup(), [
4027
+ RuleBuilder.scaffoldGroup("g_schedule"),
4028
+ RuleBuilder.scaffoldGroup("g_time"),
4029
+ RuleBuilder.scaffoldGroup("g_user"),
4030
+ RuleBuilder.scaffoldGroup("g_bill")
4031
+ ]), y = RuleBuilder.setRuleToGroup(
4032
+ RuleBuilder.scaffoldGroup("g_schedule"),
4033
+ [
4034
+ RuleBuilder.constructEntry(
4035
+ "trigger.date",
4036
+ "_rrule",
4037
+ "RRULE:FREQ=DAILY;INTERVAL=1;BYHOUR=0;BYMINUTE=0;BYSECOND=0;WKST=SU"
4038
+ ),
4039
+ RuleBuilder.constructEntry("trigger.time", "_isOnTime", "00:00")
4040
+ ],
4041
+ "&&"
4042
+ );
4043
+ if (s != "SCHEDULE") {
4044
+ _.set(data.value, "campaign.event.rule", h);
4045
+ return;
4046
+ }
4047
+ _.set(
4048
+ data.value,
4049
+ "campaign.event.rule",
4050
+ RuleBuilder.setRuleToGroup(h, y)
4051
+ );
4052
+ }
4053
+ e == "campaign.notify" && s == !1 && _.set(data.value, "campaign.notifyMessage", void 0);
4054
+ }
4055
+ async function onUpdateFile(e, s) {
4056
+ return e ? await minor(async () => firebaseStorage.update(s, e), {
4057
+ message: `${e ? "Uploading" : "Removing"} file`,
4058
+ successMessage: `File ${e ? "uploaded" : "removed"} successfully`
4059
+ }) : "";
4060
+ }
4061
+ function isDisable(e) {
4062
+ var s, o;
4063
+ switch (e == null ? void 0 : e.property) {
4064
+ case "campaign.event.type":
4065
+ return ((o = (s = data.value) == null ? void 0 : s.campaign) == null ? void 0 : o._id) || !1;
4066
+ default:
4067
+ return !1;
4068
+ }
4069
+ }
4070
+ async function onSubmit() {
4071
+ submitAttempted.value = !0;
4072
+ const e = schema.value.superRefine(campaignRefinement).transform(campaignTransform).safeParse(data.value);
4073
+ if (!e.success)
4074
+ return;
4075
+ const s = await emits(
4076
+ "submit:model-value",
4077
+ cleanPF(JSON.parse(JSON.stringify(e.data)))
4078
+ );
4079
+ (s || s === void 0) && (sheetVisible.value = !1);
4080
+ }
4081
+ return (e, s) => {
4082
+ const o = resolveComponent("FmButton"), d = resolveComponent("FmStep"), i = resolveComponent("FmStepper"), c = resolveComponent("FmCard"), l = resolveComponent("FmTopSheet");
4083
+ return openBlock(), createBlock(l, {
4084
+ "fullscreen-size": "lg",
4085
+ modelValue: unref(sheetVisible),
4086
+ "onUpdate:modelValue": [
4087
+ s[7] || (s[7] = (n) => isRef(sheetVisible) ? sheetVisible.value = n : null),
4088
+ s[8] || (s[8] = (n) => sheetVisible.value = n)
4089
+ ]
4090
+ }, createSlots({
4091
+ "top-sheet-header": withCtx(() => [
4092
+ createElementVNode("div", _hoisted_1, [
4093
+ createElementVNode("div", null, toDisplayString(unref(sheetTitle)), 1),
4094
+ createElementVNode("div", _hoisted_2, [
4095
+ createVNode(o, {
4096
+ onClick: s[0] || (s[0] = (n) => hideSheet()),
4097
+ label: unref(t)("connect.campaign.common.cancel"),
4098
+ variant: "tertiary"
4099
+ }, null, 8, ["label"]),
4100
+ createVNode(o, {
4101
+ onClick: onSubmit,
4102
+ label: unref(t)("connect.campaign.common.save"),
4103
+ disabled: !unref(validateOnSubmit) && unref(errors).length > 0
4104
+ }, null, 8, ["label", "disabled"])
4105
+ ])
4106
+ ])
4107
+ ]),
4108
+ _: 2
4109
+ }, [
4110
+ unref(isLoading) ? {
4111
+ name: "default",
4112
+ fn: withCtx(() => [
4113
+ createElementVNode("div", _hoisted_9, [
4114
+ createElementVNode("div", _hoisted_10, [
4115
+ createElementVNode("div", _hoisted_11, [
4116
+ s[9] || (s[9] = createElementVNode("div", { class: "col-span-2 space-y-80 xs:col-span-3 xs:px-16 xs:pt-16" }, [
4117
+ createElementVNode("div", { class: "flex-1 space-y-6 py-1" }, [
4118
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
4119
+ createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
4120
+ createElementVNode("div", { class: "space-y-3" }, [
4121
+ createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
4122
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
4123
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
4124
+ ]),
4125
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
4126
+ ]),
4127
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100 rounded" }),
4128
+ createElementVNode("div", { class: "h-[80px] bg-fm-color-neutral-gray-100 rounded" }),
4129
+ createElementVNode("div", { class: "space-y-3" }, [
4130
+ createElementVNode("div", { class: "grid grid-cols-2 gap-4" }, [
4131
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" }),
4132
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
4133
+ ]),
4134
+ createElementVNode("div", { class: "h-32 bg-fm-color-neutral-gray-100" })
4135
+ ])
4136
+ ])
4137
+ ], -1)),
4138
+ createVNode(c, { class: "h-[150px] bg-fm-color-neutral-gray-100" })
4139
+ ])
4140
+ ])
4141
+ ])
4142
+ ]),
4143
+ key: "1"
4144
+ } : {
4145
+ name: "default",
4146
+ fn: withCtx(() => [
4147
+ unref(data) ? (openBlock(), createElementBlock("div", _hoisted_3, [
4148
+ createVNode(i, {
4149
+ modelValue: unref(currentStep),
4150
+ "onUpdate:modelValue": s[1] || (s[1] = (n) => isRef(currentStep) ? currentStep.value = n : null),
4151
+ orientation: "horizontal",
4152
+ class: "xs:hidden mx-[-24px] mt-16 mb-24 flex-1"
4153
+ }, {
4154
+ default: withCtx(() => [
4155
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (n, a) => (openBlock(), createBlock(d, {
4156
+ key: n.name,
4157
+ title: unref(getLocaleText)(n.name_locale, n.name),
4158
+ value: a + 1,
4159
+ error: () => hasVisibleStepErrors(a),
4160
+ complete: () => a + 1 <= unref(currentStep)
4161
+ }, null, 8, ["title", "value", "error", "complete"]))), 128))
4162
+ ]),
4163
+ _: 1
4164
+ }, 8, ["modelValue"]),
4165
+ createElementVNode("div", _hoisted_4, [
4166
+ createVNode(o, {
4167
+ icon: "close",
4168
+ variant: "tertiary",
4169
+ onClick: s[2] || (s[2] = (n) => sheetVisible.value = !1)
4170
+ }),
4171
+ createVNode(i, {
4172
+ modelValue: unref(currentStep),
4173
+ "onUpdate:modelValue": s[3] || (s[3] = (n) => isRef(currentStep) ? currentStep.value = n : null),
4174
+ orientation: "horizontal",
4175
+ class: "flex-1"
4176
+ }, {
4177
+ default: withCtx(() => [
4178
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps, (n, a) => (openBlock(), createBlock(d, {
4179
+ key: n.name,
4180
+ title: unref(sheetTitle),
4181
+ description: unref(getLocaleText)(n.name_locale, n.name),
4182
+ value: a + 1,
4183
+ error: () => hasVisibleStepErrors(a),
4184
+ complete: () => a + 1 <= unref(currentStep) && stepErrors(unref(currentStep) - 1).length == 0
4185
+ }, null, 8, ["title", "description", "value", "error", "complete"]))), 128))
4186
+ ]),
4187
+ _: 1
4188
+ }, 8, ["modelValue"]),
4189
+ createVNode(o, {
4190
+ icon: "info",
4191
+ variant: "tertiary",
4192
+ onClick: s[4] || (s[4] = () => showSummaryDialog())
4193
+ })
4194
+ ]),
4195
+ createElementVNode("div", _hoisted_5, [
4196
+ createElementVNode("div", _hoisted_6, [
4197
+ createVNode(JsonViewer, {
4198
+ json: {
4199
+ data: unref(data),
4200
+ errors: unref(errors).map(
4201
+ (n) => `${n.path.join(".")} - ${n.message}`
4202
+ ),
4203
+ stepErrors: stepErrors().map(
4204
+ (n) => `${n.path.join(".")} - ${n.message}`
4205
+ ),
4206
+ schema: unref(schema)
4207
+ }
4208
+ }, null, 8, ["json"]),
4209
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(unref(template).steps[unref(currentStep) - 1].groups.filter(
4210
+ (n) => n.fields.length && (!n.condition || (Array.isArray(n.condition) ? n.condition.every((a) => unref(_).get(unref(data), a.property) == a.value == (a.not != !0)) : unref(_).get(unref(data), n.condition.property) == n.condition.value == (n.condition.not != !0)))
4211
+ ), (n, a) => (openBlock(), createElementBlock("div", {
4212
+ key: a,
4213
+ class: "space-y-24"
4214
+ }, [
4215
+ createElementVNode("div", _hoisted_7, toDisplayString(unref(getLocaleText)(n.name_locale, n.name ?? "")), 1),
4216
+ (openBlock(!0), createElementBlock(Fragment, null, renderList(n.fields, (r, p) => (openBlock(), createElementBlock("div", { key: p }, [
4217
+ (openBlock(), createBlock(_sfc_main$2, {
4218
+ key: p,
4219
+ field: r,
4220
+ modelValue: valueForField(r.property),
4221
+ disabled: isDisable(r),
4222
+ "campaign-type": unref(campaignType),
4223
+ "show-validation": unref(showValidation),
4224
+ "onUpdate:modelValue": (h) => onUpdateProperty(r.property, h),
4225
+ "onUpdate:file": async (h, y) => {
4226
+ const V = await onUpdateFile(h, y);
4227
+ onUpdateProperty(r.property, V || "");
4228
+ },
4229
+ schema: unref(ZodHelper).typeAtPath(
4230
+ unref(schema),
4231
+ schemaPathForField(r.property),
4232
+ unref(data).campaign.type != "MISSION" ? [unref(data).campaign.type] : ["STAMP", "MISSION"]
4233
+ ),
4234
+ "helper-state": unref(ZodHelper).helperState(
4235
+ unref(visibleErrors),
4236
+ schemaPathForField(r.property)
4237
+ ),
4238
+ "helper-text": unref(ZodHelper).helperText(
4239
+ unref(visibleErrors),
4240
+ schemaPathForField(r.property)
4241
+ ),
4242
+ extras: r.extras != null ? r.extras == "" ? unref(data) : unref(_).get(unref(data), r.extras) : void 0
4243
+ }, null, 8, ["field", "modelValue", "disabled", "campaign-type", "show-validation", "onUpdate:modelValue", "onUpdate:file", "schema", "helper-state", "helper-text", "extras"]))
4244
+ ]))), 128))
4245
+ ]))), 128)),
4246
+ createElementVNode("div", _hoisted_8, [
4247
+ createVNode(o, {
4248
+ label: unref(t)("connect.common.back"),
4249
+ variant: "tertiary",
4250
+ disabled: unref(currentStep) == 1,
4251
+ onClick: s[5] || (s[5] = (n) => currentStep.value--)
4252
+ }, null, 8, ["label", "disabled"]),
4253
+ createVNode(o, {
4254
+ disabled: isNextDisabled(),
4255
+ label: unref(currentStep) - 1 < unref(template).steps.length - 1 ? unref(t)("connect.common.next") : unref(t)("connect.common.submit"),
4256
+ onClick: s[6] || (s[6] = (n) => unref(currentStep) - 1 < unref(template).steps.length - 1 ? onNext() : onSubmit())
4257
+ }, null, 8, ["disabled", "label"])
4258
+ ])
4259
+ ]),
4260
+ createVNode(_sfc_main$1, {
4261
+ data: unref(data),
4262
+ class: "xs:hidden"
4263
+ }, null, 8, ["data"])
4264
+ ])
4265
+ ])) : createCommentVNode("", !0)
4266
+ ]),
4267
+ key: "0"
4268
+ }
4269
+ ]), 1032, ["modelValue"]);
4270
+ };
4271
+ }
4272
+ });
4273
+ export {
4274
+ _sfc_main as _,
4275
+ summarizeGrabDiscount as s,
4276
+ useLocaleText as u
4277
+ };