@feedmepos/mf-connect 0.1.98-beta.40 → 0.1.98-beta.41

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 (151) hide show
  1. package/dist/App-C6JJ9uQ8.js +4785 -0
  2. package/dist/AuditLogs-CAlgtDgx.js +2014 -0
  3. package/dist/Bin-D8jwhwER.js +166 -0
  4. package/dist/Broadcast-CP8DRfkT.js +269 -0
  5. package/dist/CampaignAnalytic-MVjYBFvu.js +1826 -0
  6. package/dist/CampaignTypeDialog.vue_vue_type_script_setup_true_lang-DeLURz87.js +122 -0
  7. package/dist/Card-QribXJwZ.js +911 -0
  8. package/dist/ChipMenu.vue_vue_type_script_setup_true_lang-BPpZZNkr.js +97 -0
  9. package/dist/Collections-X9xbt43V.js +541 -0
  10. package/dist/Credit-QmbsW1eb.js +286 -0
  11. package/dist/CustomSelect.vue_vue_type_script_setup_true_lang-Du7fRSZC.js +128 -0
  12. package/dist/DateRangeChip.vue_vue_type_script_setup_true_lang-eIoPtgO5.js +58 -0
  13. package/dist/EditCampaignSheet.vue_vue_type_script_setup_true_lang-ClNieHSo.js +3382 -0
  14. package/dist/EffectSheet.vue_vue_type_style_index_0_lang-CrGHTNhg.js +351 -0
  15. package/dist/Experience-CPGMg847.js +285 -0
  16. package/dist/FileSaver.min-CK67LsPG.js +74 -0
  17. package/dist/FilterChip.vue_vue_type_script_setup_true_lang-DaU-9GzO.js +129 -0
  18. package/dist/FmTableSelection.vue_vue_type_script_setup_true_lang-DzcUc0_w.js +52 -0
  19. package/dist/Game-BrkiEFCS.js +356 -0
  20. package/dist/GiftCardSetup-DXNBHF1A.js +542 -0
  21. package/dist/Grab-BgtDzK1B.js +301 -0
  22. package/dist/ImageInput.vue_vue_type_script_setup_true_lang-Dzv2AkKN.js +145 -0
  23. package/dist/Index-KJgzalOd.js +259 -0
  24. package/dist/JsonViewer-v8_C7l5N.js +87 -0
  25. package/dist/LocationPicker.vue_vue_type_script_setup_true_lang-C6SBLJGQ.js +48 -0
  26. package/dist/LottieAnimation.vue_vue_type_script_setup_true_lang-Dj74lJ7b.js +18737 -0
  27. package/dist/LoyaltyDashboard-B2JpbC01.js +1345 -0
  28. package/dist/MainLayout-DlfTKHQ-.js +143 -0
  29. package/dist/Marketing-Crx_JQpi.js +236 -0
  30. package/dist/MarketingMaterialEdit-BfsdcMXJ.js +1036 -0
  31. package/dist/Member-C50Nrsko.js +281 -0
  32. package/dist/MemberList-C9uUKw1o.js +1603 -0
  33. package/dist/MemberOverview-wL_ailso.js +58 -0
  34. package/dist/MemberTransactions-DZ7zPOHX.js +45 -0
  35. package/dist/MessageInput.vue_vue_type_script_setup_true_lang-Du_ZGsbX.js +60957 -0
  36. package/dist/MetricInfoTooltip.vue_vue_type_script_setup_true_lang-Bg_0YlwG.js +38 -0
  37. package/dist/Mission-D_km8zi6.js +360 -0
  38. package/dist/Overview-BBieK6qQ.js +1080 -0
  39. package/dist/Overview-B_kmLOcc.js +1316 -0
  40. package/dist/Point-D0q9N7f9.js +288 -0
  41. package/dist/Promotion-DoFTy-NK.js +423 -0
  42. package/dist/Queue-Dh5sDRHW.js +261 -0
  43. package/dist/Record-0owEBKqN.js +342 -0
  44. package/dist/Review-DV2fnpOH.js +45 -0
  45. package/dist/ReviewFacebookCallback-D8mnAPzR.js +238 -0
  46. package/dist/ReviewGoogleCallback-CLzt_ox2.js +213 -0
  47. package/dist/Reward-Co20Xrss.js +442 -0
  48. package/dist/RewardGroup.vue_vue_type_script_setup_true_lang-0qU49c47.js +150 -0
  49. package/dist/RuleGroup.vue_vue_type_script_setup_true_lang-qdvaXPhJ.js +1913 -0
  50. package/dist/Segment-7dQKeHWK.js +1017 -0
  51. package/dist/SelectItems.vue_vue_type_script_setup_true_lang-BUVrUifO.js +181 -0
  52. package/dist/SendCollectionSheet.vue_vue_type_script_setup_true_lang-DDsV9TD9.js +189 -0
  53. package/dist/SendVoucherSheet.vue_vue_type_script_setup_true_lang-DqPZpddc.js +226 -0
  54. package/dist/Setting-Bvahxs-y.js +2047 -0
  55. package/dist/SettingAdvertisements-fbXLRwfb.js +264 -0
  56. package/dist/Settings-C_HWDFN8.js +179 -0
  57. package/dist/Store-8yBKDR1b.js +2413 -0
  58. package/dist/StoreRewards-DKaJvoJs.js +540 -0
  59. package/dist/StoreTransactions.vue_vue_type_script_setup_true_lang-D23XzJD7.js +1075 -0
  60. package/dist/TargetLocationInput.vue_vue_type_script_setup_true_lang-JaFhCK_L.js +7007 -0
  61. package/dist/Tier-CD-CjXC3.js +972 -0
  62. package/dist/Title-C_lcgye8.js +569 -0
  63. package/dist/Transaction-BvUYm-rT.js +39 -0
  64. package/dist/UserRuleGroup.vue_vue_type_script_setup_true_lang-C3Yacz7K.js +130 -0
  65. package/dist/Voucher-CYaG0GLU.js +444 -0
  66. package/dist/VoucherEditor.vue_vue_type_script_setup_true_lang-DF2JqzRe.js +421 -0
  67. package/dist/ZodTextField.vue_vue_type_script_setup_true_lang-B4UPqSNc.js +56 -0
  68. package/dist/_plugin-vue_export-helper-CHgC5LLL.js +9 -0
  69. package/dist/app-CE5hQ4Uq.js +60740 -0
  70. package/dist/app-wDQR6dpb.js +39 -0
  71. package/dist/app.js +7 -0
  72. package/dist/business-CE_4siXc.js +82 -0
  73. package/dist/campaign-BP6rvSpg.js +255 -0
  74. package/dist/campaign-CXQtKpeb.js +100 -0
  75. package/dist/campaign-CpzFl8Vr.js +4 -0
  76. package/dist/campaign.enum-Dx-Zo68Q.js +26 -0
  77. package/dist/campaign.fn-DKnBpE1N.js +776 -0
  78. package/dist/collectible.enum-Liy2wH3s.js +19 -0
  79. package/dist/collection.fn-Cg16QZSp.js +26 -0
  80. package/dist/duplicateCampaign-DbtVAGsT.js +51 -0
  81. package/dist/effect-CLI8NI4O.js +89 -0
  82. package/dist/email-addresses-DlLiZ1io.js +705 -0
  83. package/dist/export-6Hr34dBU.js +97 -0
  84. package/dist/feedme.ico +0 -0
  85. package/dist/google-C3S8u0mT.js +4 -0
  86. package/dist/helper-vkjFqj70.js +86 -0
  87. package/dist/index-BIyKgw4m.js +72 -0
  88. package/dist/index-BLQJ-rv3.js +31 -0
  89. package/dist/index-BbTIqReL.js +67 -0
  90. package/dist/index-BuMfQxMf.js +897 -0
  91. package/dist/index-C8cXXcLk.js +45 -0
  92. package/dist/index-CSVhIZSY.js +8919 -0
  93. package/dist/index-CVHacTbc.js +151 -0
  94. package/dist/index-C_H8jFYf.js +2743 -0
  95. package/dist/index-CmNsGhDf.js +2706 -0
  96. package/dist/index-CnTeeRyJ.js +53 -0
  97. package/dist/index-CuvNtC_M.js +61 -0
  98. package/dist/index-CzbNobLv.js +1139 -0
  99. package/dist/index-D06n1h1b.js +146 -0
  100. package/dist/index-D4SDAfbP.js +27550 -0
  101. package/dist/index-DVnYQ3Hs.js +85 -0
  102. package/dist/index-DcjnS5Sv.js +28900 -0
  103. package/dist/index-Dx9h0FNH.js +3 -0
  104. package/dist/index-YgP4ihQL.js +32 -0
  105. package/dist/index-kedErkLZ.js +2963 -0
  106. package/dist/index-lnQT4P3d.js +55 -0
  107. package/dist/index-vh86FiIQ.js +10 -0
  108. package/dist/index.esm2017-Jhv2lkrq.js +3069 -0
  109. package/dist/loading-NY-FPxVY.js +72 -0
  110. package/dist/lodash-BC_P6kLg.js +3678 -0
  111. package/dist/membership-BWaK-9FY.js +255 -0
  112. package/dist/moment-D7p2TMB-.js +2583 -0
  113. package/dist/money-COoh4GXK.js +15 -0
  114. package/dist/number-BX5OEXgq.js +12 -0
  115. package/dist/object-BYyQ0PZp.js +18 -0
  116. package/dist/objectId-dwaoBfJX.js +7 -0
  117. package/dist/objectid-1SUSRtmY.js +145 -0
  118. package/dist/plugins-ur-FAoye.js +1788 -0
  119. package/dist/remy-Qz_pNsUS.js +13 -0
  120. package/dist/reward-DSsylZ22.js +36 -0
  121. package/dist/rule-BM9GUd1C.js +1969 -0
  122. package/dist/rule-builder-gC9LH2AC.js +126 -0
  123. package/dist/string-Gcy5IM_H.js +32 -0
  124. package/dist/style.css +4 -0
  125. package/dist/template-CUV3AMFI.js +188 -0
  126. package/dist/tier-BJDhpH6X.js +4 -0
  127. package/dist/tiers/tier=1.png +0 -0
  128. package/dist/tiers/tier=2.png +0 -0
  129. package/dist/tiers/tier=3.png +0 -0
  130. package/dist/tiers/tier=4.png +0 -0
  131. package/dist/timezone-BFZhekOU.js +20 -0
  132. package/dist/titles/type=diamond.png +0 -0
  133. package/dist/titles/type=drinks.png +0 -0
  134. package/dist/titles/type=food.png +0 -0
  135. package/dist/titles/type=heart.png +0 -0
  136. package/dist/titles/type=medal.png +0 -0
  137. package/dist/titles/type=spend.png +0 -0
  138. package/dist/titles/type=thank-you.png +0 -0
  139. package/dist/titles/type=thumbs-up.png +0 -0
  140. package/dist/titles/type=years.png +0 -0
  141. package/dist/transaction.fn-C5MlkEIC.js +64 -0
  142. package/dist/trigger-CbjiuoSo.js +213 -0
  143. package/dist/tslib.es6-BCqqvLQ_.js +44 -0
  144. package/dist/type_drinks-D6jnpvwV.js +4 -0
  145. package/dist/useMarketingMaterialActions-BLisTieA.js +96 -0
  146. package/dist/usePagination-Caah4sJr.js +220 -0
  147. package/dist/user-BZC4P_jL.js +55 -0
  148. package/dist/vue-i18n-BYz7XAr_.js +2365 -0
  149. package/dist/xlsx-Bn7BqUFA.js +15491 -0
  150. package/dist/zod-DHH42rXG.js +91 -0
  151. package/package.json +1 -1
@@ -0,0 +1,1017 @@
1
+ import { defineComponent as le, ref as W, resolveComponent as S, openBlock as r, createElementBlock as k, createElementVNode as s, createVNode as d, unref as e, createCommentVNode as J, withCtx as $, Fragment as Z, renderList as me, createBlock as V, toDisplayString as D, normalizeClass as ce, computed as O, onMounted as we, isRef as Te, createSlots as Ee, h as B, onBeforeMount as De } from "vue";
2
+ import { _ as $e } from "./campaign-CpzFl8Vr.js";
3
+ import { n as Ae, p as Pe } from "./plugins-ur-FAoye.js";
4
+ import { u as Re } from "./loading-NY-FPxVY.js";
5
+ import { FmButtonVariant as re, useSnackbar as Ne, components as ae } from "@feedmepos/ui-library";
6
+ import { u as Fe, _ as Ce } from "./usePagination-Caah4sJr.js";
7
+ import { u as pe } from "./vue-i18n-BYz7XAr_.js";
8
+ import "./index-CmNsGhDf.js";
9
+ import { g as Be, h as U, D as Ue, i as Ve } from "./index-kedErkLZ.js";
10
+ import "./index-CSVhIZSY.js";
11
+ import { F as ye } from "./index-D4SDAfbP.js";
12
+ import { a as ge } from "./index-BuMfQxMf.js";
13
+ import "./index-lnQT4P3d.js";
14
+ import { u as de, w as ke } from "./xlsx-Bn7BqUFA.js";
15
+ import { e as Le, M as Ye } from "./email-addresses-DlLiZ1io.js";
16
+ import { Z as ze } from "./zod-DHH42rXG.js";
17
+ import { u as Oe } from "./app-wDQR6dpb.js";
18
+ import { z as je } from "./index-C_H8jFYf.js";
19
+ import { R as ve } from "./rule-builder-gC9LH2AC.js";
20
+ import { _ as qe } from "./ZodTextField.vue_vue_type_script_setup_true_lang-B4UPqSNc.js";
21
+ import { _ as Ge } from "./RuleGroup.vue_vue_type_script_setup_true_lang-qdvaXPhJ.js";
22
+ import { u as He, v as Je, w as Ke } from "./index.esm2017-Jhv2lkrq.js";
23
+ import { F as Qe } from "./FileSaver.min-CK67LsPG.js";
24
+ import { h as se } from "./moment-D7p2TMB-.js";
25
+ import { s as z, u as We } from "./membership-BWaK-9FY.js";
26
+ import { o as Ze } from "./objectId-dwaoBfJX.js";
27
+ import { J as Xe } from "./JsonViewer-v8_C7l5N.js";
28
+ import { u as Ie } from "./business-CE_4siXc.js";
29
+ import { f as et } from "./number-BX5OEXgq.js";
30
+ import { t as tt } from "./money-COoh4GXK.js";
31
+ import "./index-Dx9h0FNH.js";
32
+ import { useRouter as ot } from "vue-router";
33
+ import { m as _e } from "./index-DVnYQ3Hs.js";
34
+ import { R as xe } from "./app-CE5hQ4Uq.js";
35
+ const nt = Be.extend({
36
+ _id: ye.optional(),
37
+ business: ye.optional(),
38
+ file: je.any().nullish()
39
+ });
40
+ var at = { firebase: { apiKey: "AIzaSyAj8JdCHtP0Vc5vZobCfgoLzWxPIn0WUG4", authDomain: "feedme-dev-4c3ef.firebaseapp.com", databaseURL: "https://feedme-dev-4c3ef.firebaseio.com", projectId: "feedme-dev-4c3ef", storageBucket: "feedme-dev-4c3ef.appspot.com", messagingSenderId: "458797803788", appId: "1:458797803788:web:37f2af2926a84288f0c129", measurementId: "G-J2QG09D2Q7" }, assetBucketUrl: "feedme-dev-4c3ef.appspot.com", importFilesBucketUrl: "feedme-dev-4c3ef.appspot.com", clientId: "1a362d621873497b277ea55258cc82594ba148d235257f7bd44ea2acc132d8a4" };
41
+ const st = { class: "flex flex-col space-y-16" }, lt = {
42
+ key: 0,
43
+ class: /* @__PURE__ */ ce([
44
+ "p-16 pl-24 space-x-8",
45
+ "bg-fm-color-primary-oats rounded-lg",
46
+ "flex items-center",
47
+ "justify-between"
48
+ ])
49
+ }, it = { class: "flex justify-end" }, ct = {
50
+ key: 1,
51
+ class: /* @__PURE__ */ ce([
52
+ "flex items-center",
53
+ "border border-fm-color-neutral-gray-300",
54
+ "p-16 space-x-16 rounded-md"
55
+ ])
56
+ }, rt = { class: "fm-typo-en-body-lg-400 flex-1 truncate" }, dt = /* @__PURE__ */ le({
57
+ __name: "ImportSegment",
58
+ props: {
59
+ importFile: {}
60
+ },
61
+ emits: ["update:file"],
62
+ setup(t, { emit: f }) {
63
+ const c = t, M = f, { t: b } = pe(), _ = W(null), u = W(null), T = ["Id"], E = [
64
+ {
65
+ label: "CSV",
66
+ icon: "csv",
67
+ value: "csv"
68
+ },
69
+ {
70
+ label: "Excel",
71
+ icon: "description",
72
+ value: "xlsx"
73
+ }
74
+ ];
75
+ async function a() {
76
+ if (c.importFile)
77
+ try {
78
+ const y = He(void 0, at.importFilesBucketUrl), p = Je(y, c.importFile), g = await Ke(p);
79
+ window.open(g, "_blank");
80
+ } catch (y) {
81
+ console.log(y), Ae.error("Failed to download uploaded file");
82
+ }
83
+ }
84
+ async function m(y) {
85
+ switch (y) {
86
+ case "csv":
87
+ const p = new Blob([T.join(",")], {
88
+ type: "text/csv;charset=utf-8;"
89
+ });
90
+ Qe.saveAs(p, "ImportSegmentTemplate.csv");
91
+ break;
92
+ case "xlsx":
93
+ const g = de.aoa_to_sheet([T]), x = de.book_new();
94
+ de.book_append_sheet(x, g, "Sheet1"), ke(x, "ImportSegmentTemplate.xlsx");
95
+ break;
96
+ }
97
+ }
98
+ function i(y) {
99
+ _.value = y, M("update:file", _.value);
100
+ }
101
+ function A(y) {
102
+ var g, x;
103
+ const p = ((x = (g = y.target) == null ? void 0 : g.files) == null ? void 0 : x[0]) ?? null;
104
+ i(p);
105
+ }
106
+ return (y, p) => {
107
+ const g = S("FmButton"), x = S("FmMenuItem"), j = S("FmMenu"), q = S("FmDropField");
108
+ return r(), k("div", st, [
109
+ p[2] || (p[2] = s("div", { class: "fm-typo-en-title-sm-800" }, "Upload File", -1)),
110
+ t.importFile ? (r(), k("div", lt, [
111
+ d(g, {
112
+ label: e(b)("View uploaded file"),
113
+ variant: e(re).Plain,
114
+ icon: "file_present",
115
+ onClick: a
116
+ }, null, 8, ["label", "variant"])
117
+ ])) : J("", !0),
118
+ s("div", null, [
119
+ s("div", it, [
120
+ d(j, { class: "" }, {
121
+ "menu-button": $(() => [
122
+ d(g, {
123
+ variant: "tertiary",
124
+ icon: "download",
125
+ label: "Download Template"
126
+ })
127
+ ]),
128
+ default: $(() => [
129
+ (r(), k(Z, null, me(E, (I) => d(x, {
130
+ key: I.value,
131
+ icon: I.icon,
132
+ label: I.label,
133
+ onClick: (G) => m(I.value),
134
+ selectable: ""
135
+ }, null, 8, ["icon", "label", "onClick"])), 64))
136
+ ]),
137
+ _: 1
138
+ })
139
+ ]),
140
+ _.value ? (r(), k("div", ct, [
141
+ d(g, {
142
+ variant: e(re).Tertiary,
143
+ "prepend-icon": "attach_file"
144
+ }, null, 8, ["variant"]),
145
+ s("p", rt, D(_.value.name), 1),
146
+ s("label", {
147
+ ref_key: "fileLabelRef",
148
+ ref: u,
149
+ htmlFor: "file"
150
+ }, [
151
+ d(g, {
152
+ variant: e(re).Plain,
153
+ label: e(b)("Replace File"),
154
+ onClick: p[1] || (p[1] = () => {
155
+ var I;
156
+ return (I = u.value) == null ? void 0 : I.click();
157
+ })
158
+ }, null, 8, ["variant", "label"]),
159
+ s("input", {
160
+ id: "file",
161
+ accept: ".csv",
162
+ class: "hidden",
163
+ type: "file",
164
+ multiple: "",
165
+ onChange: A
166
+ }, null, 32)
167
+ ], 512)
168
+ ])) : (r(), V(q, {
169
+ key: 0,
170
+ onFileUpload: p[0] || (p[0] = (I) => i(I)),
171
+ accept: ".csv, .xlsx",
172
+ "max-file-size": 2e7
173
+ }))
174
+ ])
175
+ ]);
176
+ };
177
+ }
178
+ }), ut = { class: "space-y-16 pr-12" }, mt = { class: "fm-typo-en-title-md-800" }, pt = { class: "flex space-x-8" }, ft = { class: "fm-typo-en-title-md-800 text-fm-color-primary" }, yt = { class: "text-fm-color-typo-secondary" }, Se = /* @__PURE__ */ le({
179
+ __name: "ReviewSegment",
180
+ props: {
181
+ title: {},
182
+ segment: {}
183
+ },
184
+ setup(t) {
185
+ const f = t, c = O(
186
+ () => f.segment.memberCount ?? f.segment.members.length
187
+ ), M = O(
188
+ () => f.segment.lastUpdated ? se(f.segment.lastUpdated).format("DD MMM YYYY") : "Not refreshed yet"
189
+ ), b = [
190
+ {
191
+ header: "Name",
192
+ accessorFn: (i) => i.name
193
+ },
194
+ {
195
+ header: "Id",
196
+ accessorFn: (i) => i._id
197
+ },
198
+ {
199
+ header: "Customer Since",
200
+ accessorFn: (i) => se(Ze(i._id.toString())).format("DD MMM YYYY")
201
+ },
202
+ {
203
+ header: "Phone",
204
+ accessorFn: (i) => i.phoneNumber
205
+ },
206
+ {
207
+ header: "Birthday",
208
+ accessorFn: (i) => se(i.birthday).format("DD MMM YYYY")
209
+ },
210
+ {
211
+ header: "Last Visit",
212
+ accessorFn: (i) => se(i.stats.lastVisit).format("DD MMM YYYY")
213
+ }
214
+ ];
215
+ async function _(i) {
216
+ return f.segment._id ? (console.log(i), await z.paginateSegmentUsers(
217
+ f.segment._id,
218
+ i
219
+ )) : {
220
+ resources: [],
221
+ meta: {
222
+ totalResources: 0,
223
+ totalPages: 0,
224
+ skip: i.skip,
225
+ limit: i.limit,
226
+ sortBy: i.sortBy
227
+ }
228
+ };
229
+ }
230
+ const { tableMeta: u, rowData: T, onSort: E, debouncedFetchData: a, onSearch: m } = Fe(_);
231
+ return we(async () => {
232
+ await a();
233
+ }), (i, A) => (r(), k("div", ut, [
234
+ s("div", mt, D(f.title), 1),
235
+ s("div", pt, [
236
+ s("div", ft, D(e(c)), 1),
237
+ s("div", yt, [
238
+ A[1] || (A[1] = s("div", null, "contacts in your segment", -1)),
239
+ s("div", null, "as of " + D(e(M)), 1)
240
+ ])
241
+ ]),
242
+ d(Ce, {
243
+ loading: e(u).isLoading,
244
+ "row-data": e(T),
245
+ "row-count": e(u).totalRows,
246
+ "column-defs": b,
247
+ "page-size": e(u).pageSize,
248
+ "page-count": e(u).pageCount,
249
+ "page-index": e(u).pageIndex,
250
+ onSortChange: e(E),
251
+ onPageChange: A[0] || (A[0] = (y) => e(a)({ pageSize: y.pageSize, pageIndex: y.pageIndex }))
252
+ }, null, 8, ["loading", "row-data", "row-count", "page-size", "page-count", "page-index", "onSortChange"])
253
+ ]));
254
+ }
255
+ }), gt = { class: "space-y-24" }, vt = { class: "grid grid-cols-2 gap-16" }, _t = { class: "fm-typo-en-title-sm-800" }, xt = { class: "fm-typo-en-body-lg-400 text-fm-color-typo-secondary" }, St = /* @__PURE__ */ le({
256
+ __name: "SegmentTypeOption",
257
+ props: {
258
+ modelValue: {},
259
+ errorText: {}
260
+ },
261
+ emits: ["update:model-value"],
262
+ setup(t, { emit: f }) {
263
+ const c = t, M = f, b = [
264
+ {
265
+ label: "Dynamic",
266
+ sublabel: "Segment statistics are based on rules configured and will be recalculated automatically when rule changes.",
267
+ value: U.enum.DYNAMIC
268
+ },
269
+ {
270
+ label: "Static",
271
+ sublabel: "Segment statistics are based on imported data and will not be recalculated.",
272
+ value: U.enum.STATIC
273
+ }
274
+ ];
275
+ function _(u) {
276
+ u !== c.modelValue && M("update:model-value", u);
277
+ }
278
+ return (u, T) => {
279
+ const E = S("FmCard"), a = S("FmHelperText");
280
+ return r(), k("div", gt, [
281
+ s("div", vt, [
282
+ (r(), k(Z, null, me(b, (m) => d(E, {
283
+ variant: "outlined",
284
+ class: ce(["p-16 space-y-8 h-full cursor-pointer select-none xs:col-span-2", {
285
+ "col-span-2": b.length == 1,
286
+ "border-fm-color-primary bg-fm-color-system-warning-100 hover:border-[var(--fm-color-system-orange-300)]": t.modelValue === m.value,
287
+ "hover:bg-fm-color-opacity-sm": t.modelValue !== m.value
288
+ }]),
289
+ onClick: (i) => _(m.value),
290
+ key: m.value
291
+ }, {
292
+ default: $(() => [
293
+ s("div", _t, D(m.label), 1),
294
+ s("div", xt, D(m.sublabel), 1)
295
+ ]),
296
+ _: 2
297
+ }, 1032, ["class", "onClick"])), 64))
298
+ ]),
299
+ t.errorText ? (r(), V(a, {
300
+ key: 0,
301
+ class: "!mt-4",
302
+ text: t.errorText,
303
+ state: "error"
304
+ }, null, 8, ["text"])) : J("", !0)
305
+ ]);
306
+ };
307
+ }
308
+ }), ht = { class: "flex items-center gap-x-8" }, bt = {
309
+ key: 0,
310
+ class: "space-y-16 pr-12"
311
+ }, wt = {
312
+ key: 0,
313
+ class: "flex flex-col gap-12"
314
+ }, Ft = { class: "flex flex-wrap items-center gap-8" }, Ct = { class: "fm-typo-en-title-sm-800" }, kt = { class: "flex flex-col gap-4" }, It = { class: "fm-typo-en-body-md-600 text-fm-color-typo-primary" }, Mt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, Tt = {
315
+ key: 2,
316
+ class: "flex flex-col space-y-16"
317
+ }, Et = {
318
+ key: 3,
319
+ class: "flex flex-col space-y-16"
320
+ }, Dt = {
321
+ key: 4,
322
+ class: "flex flex-col space-y-16"
323
+ }, $t = {
324
+ key: 5,
325
+ class: "flex flex-col space-y-16"
326
+ }, At = { class: "flex items-center gap-8" }, Pt = /* @__PURE__ */ le({
327
+ __name: "SegmentSheet",
328
+ emits: ["update:model-value"],
329
+ setup(t, { expose: f, emit: c }) {
330
+ const M = Oe(), { t: b } = pe(), _ = W(!1), u = W(!1), T = {
331
+ name: "",
332
+ isActive: !0,
333
+ type: U.enum.DYNAMIC,
334
+ rule: ve.scaffoldGroup(),
335
+ members: []
336
+ }, E = nt, a = W(T), m = O(() => !!a.value.defaultKey), i = O(
337
+ () => a.value.defaultKey ? `connect.loyalty.segment.default_segments.${a.value.defaultKey.toLowerCase()}` : void 0
338
+ ), A = O(
339
+ () => i.value ? b(`${i.value}.name`) : a.value.name
340
+ ), y = O(() => {
341
+ const v = a.value.defaultKey;
342
+ return v ? b(Ue[v]) : a.value.description ?? "";
343
+ }), p = O(() => {
344
+ const v = E.safeParse(a.value);
345
+ return v.success ? [] : v.error.errors;
346
+ });
347
+ function g(v) {
348
+ _.value = !0, u.value = !1, v ? a.value = {
349
+ ...v,
350
+ isActive: v.isActive !== !1,
351
+ type: v.type ?? (v.importFile ? U.enum.STATIC : U.enum.DYNAMIC)
352
+ } : a.value = { ...T };
353
+ }
354
+ function x() {
355
+ _.value = !1;
356
+ }
357
+ async function j() {
358
+ E.safeParse(a.value).success && (u.value = !0);
359
+ }
360
+ function q(v) {
361
+ v === U.enum.STATIC ? x() : u.value = !1;
362
+ }
363
+ async function I() {
364
+ a.value.type === U.enum.STATIC ? (a.value.rule = ve.scaffoldGroup(), a.value.isActive = !0) : a.value.file = void 0, K("update:model-value", a.value);
365
+ }
366
+ async function G(v) {
367
+ a.value.type = v;
368
+ }
369
+ we(async () => {
370
+ });
371
+ const K = c;
372
+ return f({
373
+ showSheet: g,
374
+ hideSheet: x
375
+ }), (v, l) => {
376
+ const P = S("FmButton"), X = S("FmChip"), ee = S("FmCard"), te = S("FmSwitch"), o = S("FmSideSheet");
377
+ return r(), V(o, {
378
+ modelValue: e(_),
379
+ "onUpdate:modelValue": l[9] || (l[9] = (n) => Te(_) ? _.value = n : null),
380
+ header: e(m) ? e(b)("connect.loyalty.segment.default_segments.default_segment") : e(a)._id ? "Edit segment" : "Add segment",
381
+ "dismiss-away": "",
382
+ "close-button": !0,
383
+ "max-width": 1100
384
+ }, Ee({
385
+ "side-sheet-footer": $(() => [
386
+ s("div", At, [
387
+ e(m) ? (r(), V(P, {
388
+ key: 0,
389
+ label: e(b)("connect.loyalty.segment.default_segments.close"),
390
+ onClick: l[6] || (l[6] = (n) => x()),
391
+ variant: "tertiary"
392
+ }, null, 8, ["label"])) : e(u) || e(a).type === e(U).enum.STATIC ? (r(), k(Z, { key: 1 }, [
393
+ d(P, {
394
+ label: "Save Segment",
395
+ onClick: I,
396
+ loading: e(M).isLoading,
397
+ disabled: e(p).length > 0 || e(M).isLoading
398
+ }, null, 8, ["loading", "disabled"]),
399
+ d(P, {
400
+ label: "Cancel",
401
+ onClick: l[7] || (l[7] = (n) => q(e(a).type)),
402
+ variant: "tertiary"
403
+ })
404
+ ], 64)) : (r(), k(Z, { key: 2 }, [
405
+ d(P, {
406
+ label: "Review Segment",
407
+ disabled: e(p).length > 0 || e(M).isLoading,
408
+ onClick: j
409
+ }, null, 8, ["disabled"]),
410
+ d(P, {
411
+ label: "Cancel",
412
+ onClick: l[8] || (l[8] = (n) => x()),
413
+ variant: "tertiary"
414
+ })
415
+ ], 64))
416
+ ])
417
+ ]),
418
+ default: $(() => {
419
+ var n, F;
420
+ return [
421
+ d(Xe, { json: e(a) }, null, 8, ["json"]),
422
+ e(u) ? (r(), V(Se, {
423
+ key: 1,
424
+ title: e(a).name,
425
+ segment: e(a)
426
+ }, null, 8, ["title", "segment"])) : (r(), k("div", bt, [
427
+ e(m) ? (r(), k("div", wt, [
428
+ s("div", Ft, [
429
+ s("div", Ct, D(e(A)), 1),
430
+ d(X, {
431
+ label: e(b)("connect.loyalty.segment.default_segments.system"),
432
+ compact: "",
433
+ class: "text-fm-color-typo-info bg-fm-color-system-info-100"
434
+ }, null, 8, ["label"])
435
+ ]),
436
+ d(ee, {
437
+ variant: "outlined",
438
+ class: "p-16"
439
+ }, {
440
+ default: $(() => [
441
+ s("div", kt, [
442
+ s("div", It, D(e(b)("connect.loyalty.segment.default_segments.description")), 1),
443
+ s("div", Mt, D(e(y)), 1)
444
+ ])
445
+ ]),
446
+ _: 1
447
+ })
448
+ ])) : (r(), V(qe, {
449
+ key: 1,
450
+ modelValue: e(a).name,
451
+ "onUpdate:modelValue": l[1] || (l[1] = (w) => e(a).name = w),
452
+ label: "Segment title",
453
+ schema: e(ze).typeAtPath(e(E), "name")
454
+ }, null, 8, ["modelValue", "schema"])),
455
+ e(m) ? J("", !0) : (r(), k("div", Tt, [
456
+ l[11] || (l[11] = s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Type", -1)),
457
+ d(St, {
458
+ "model-value": e(a).type,
459
+ "onUpdate:modelValue": l[2] || (l[2] = (w) => {
460
+ G(w);
461
+ })
462
+ }, null, 8, ["model-value"])
463
+ ])),
464
+ e(a).type === e(U).enum.DYNAMIC && !e(m) ? (r(), k("div", Et, [
465
+ l[12] || (l[12] = s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Filter", -1)),
466
+ d(Ge, {
467
+ "trigger-type": "MEMBERSHIP_JOINED",
468
+ includeOnly: "user",
469
+ "model-value": (n = e(a)) == null ? void 0 : n.rule,
470
+ "onUpdate:modelValue": l[3] || (l[3] = (w) => {
471
+ e(a).rule = w;
472
+ })
473
+ }, null, 8, ["model-value"])
474
+ ])) : e(m) ? J("", !0) : (r(), k("div", Dt, [
475
+ d(dt, {
476
+ importFile: e(a).importFile,
477
+ "onUpdate:file": l[4] || (l[4] = (w) => {
478
+ e(a).file = w;
479
+ })
480
+ }, null, 8, ["importFile"])
481
+ ])),
482
+ e(a).type === e(U).enum.DYNAMIC && !e(m) ? (r(), k("div", $t, [
483
+ l[13] || (l[13] = s("div", { class: "fm-typo-en-title-sm-800" }, "Segment Status", -1)),
484
+ d(te, {
485
+ "model-value": e(a).isActive ?? !0,
486
+ "onUpdate:modelValue": l[5] || (l[5] = (w) => e(a).isActive = w),
487
+ label: "Active",
488
+ sublabel: "When enabled, this will recalculate the segment statistics daily.",
489
+ "label-placement": "right"
490
+ }, null, 8, ["model-value"])
491
+ ])) : J("", !0),
492
+ e(m) ? (r(), V(Se, {
493
+ key: (F = e(a)._id) == null ? void 0 : F.toString(),
494
+ title: e(b)("connect.loyalty.segment.default_segments.members"),
495
+ segment: e(a)
496
+ }, null, 8, ["title", "segment"])) : J("", !0)
497
+ ]))
498
+ ];
499
+ }),
500
+ _: 2
501
+ }, [
502
+ e(u) && !e(m) ? {
503
+ name: "side-sheet-header",
504
+ fn: $(() => [
505
+ s("div", ht, [
506
+ d(P, {
507
+ icon: "arrow_back",
508
+ variant: "tertiary",
509
+ onClick: l[0] || (l[0] = (n) => u.value = !1)
510
+ }),
511
+ l[10] || (l[10] = s("div", null, "Review segment", -1))
512
+ ])
513
+ ]),
514
+ key: "0"
515
+ } : void 0
516
+ ]), 1032, ["modelValue", "header"]);
517
+ };
518
+ }
519
+ }), he = We(), Rt = Ie();
520
+ function ue(t) {
521
+ const f = se(t);
522
+ return f.isValid() ? f.format("DD/MM/YYYY") : "";
523
+ }
524
+ const Nt = {
525
+ mapMemberExportRow: (t) => {
526
+ var a, m, i, A, y, p, g, x, j, q, I, G, K, v, l, P, X, ee, te, o, n, F, w, R, H, L, oe, ne;
527
+ const f = O(() => Rt.locations.map((C) => ({
528
+ label: C.name,
529
+ value: C._id
530
+ }))), c = (a = Le.parseOneAddress(
531
+ t == null ? void 0 : t.email
532
+ )) != null && a.domain.includes("feedmepos.com") ? void 0 : t.email, M = (i = ((m = t == null ? void 0 : t.collection) == null ? void 0 : m.TITLE) || []) == null ? void 0 : i.reduce(
533
+ (C, N) => {
534
+ var h, Y;
535
+ const Q = (Y = (h = he.sortedTitles) == null ? void 0 : h.find(
536
+ (ie) => ie._id === N.collectible
537
+ )) == null ? void 0 : Y.name;
538
+ return !Q || N.balance <= 0 || C.push(Q), C;
539
+ },
540
+ []
541
+ ), b = (he.sortedTitles || []).reduce(
542
+ (C, N) => {
543
+ var h, Y, ie, fe;
544
+ const Q = (fe = (ie = (Y = (((h = t == null ? void 0 : t.collection) == null ? void 0 : h.TITLE) || []).find(
545
+ (Me) => Me.collectible === N._id
546
+ )) == null ? void 0 : Y.expiryBalance) == null ? void 0 : ie[0]) == null ? void 0 : fe.expiredAt;
547
+ return C[N.name] = Q ? se(Q).format("DD/MM/YYYY") : "", C;
548
+ },
549
+ {}
550
+ ), _ = ((p = (y = (A = t.collection) == null ? void 0 : A.CREDIT) == null ? void 0 : y.at(0)) == null ? void 0 : p.balance) || 0, u = ((q = (j = (x = (g = t.collection) == null ? void 0 : g.CREDIT) == null ? void 0 : x.at(0)) == null ? void 0 : j.expiryBalance) == null ? void 0 : q.reduce(
551
+ (C, N) => C + N.amount,
552
+ 0
553
+ )) || 0, T = et(_, 2);
554
+ return {
555
+ ID: t._id.toString(),
556
+ Name: ((I = t.name) == null ? void 0 : I.trim()) || "",
557
+ Phone: ((G = t == null ? void 0 : t.phoneNumber) == null ? void 0 : G.trim()) || "",
558
+ Email: c || "",
559
+ Gender: t.gender || "",
560
+ CardNo: t.cardNo || "",
561
+ Birthday: t != null && t.birthday ? ue(t == null ? void 0 : t.birthday) : "",
562
+ Credit: parseFloat((Number(T) - Number(u)).toFixed(2)),
563
+ FreeCredit: Number(u.toFixed(2)),
564
+ TotalCredit: Number(T),
565
+ Exp: t != null && t.collection ? ((l = (v = (K = t.collection) == null ? void 0 : K.POINT) == null ? void 0 : v.at(0)) == null ? void 0 : l.balance) ?? 0 : 0,
566
+ Point: t != null && t.collection ? ((ee = (X = (P = t.collection) == null ? void 0 : P.COIN) == null ? void 0 : X.at(0)) == null ? void 0 : ee.balance) ?? 0 : 0,
567
+ Level: t != null && t.collection ? ((n = (o = (te = t.collection) == null ? void 0 : te.TIER) == null ? void 0 : o.at(0)) == null ? void 0 : n.balance) ?? 0 : 0,
568
+ Tier: t != null && t.collection ? ((R = (w = (F = t.collection) == null ? void 0 : F.TIER) == null ? void 0 : w.at(0)) == null ? void 0 : R.balance) ?? 0 : 0,
569
+ Titles: M.join(","),
570
+ ...b,
571
+ TotalTransaction: t.stats.visitCount,
572
+ AvgSpent: tt(Number(t.stats.avgBillSize || 0)).toFormat(
573
+ !1
574
+ ),
575
+ TotalSpent: t.stats.avgBillSize * t.stats.visitCount,
576
+ LastVisit: ue(t.stats.lastVisit),
577
+ Feedback: ((H = t.stats) == null ? void 0 : H.feedbackCount) || 0,
578
+ LastSeasonTierEarned: ((L = t.stats) == null ? void 0 : L.lastSeasonTierEarned) || 0,
579
+ LastSeasonPointEarned: ((oe = t.stats) == null ? void 0 : oe.lastSeasonPointEarned) || 0,
580
+ JoinedAt: ue(t.joinAt || void 0),
581
+ JoinedAtLocation: t.location && ((ne = f.value.find((C) => C.value == t.location)) == null ? void 0 : ne.label) || "-",
582
+ VisitFrequency: `${Number(
583
+ Math.ceil(t.stats.avgVisitFrequency).toFixed(0)
584
+ )}`
585
+ };
586
+ }
587
+ }, Bt = { class: "flex items-center" }, Ut = { class: "fm-typo-en-title-md-600 fm-step-title line-clamp-2 mr-8" }, Vt = { class: "px-24 flex flex-col gap-y-16" }, Lt = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, Yt = { class: "flex flex-wrap items-center gap-8" }, zt = { class: "fm-typo-en-body-md-600" }, Ot = { class: "fm-typo-en-body-md-600 text-fm-color-typo-secondary" }, jt = { class: "flex flex-col gap-16 text-center" }, qt = { class: "fm-typo-en-title-sm-800" }, Gt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, be = "text-fm-color-typo-info bg-fm-color-system-info-100", Mo = /* @__PURE__ */ le({
588
+ __name: "Segment",
589
+ setup(t) {
590
+ const { minor: f } = Re, { t: c } = pe(), M = Ie(), { mapMemberExportRow: b } = Nt, _ = Ne(), u = ot(), T = W(0);
591
+ function E(o) {
592
+ return !!o.defaultKey;
593
+ }
594
+ function a(o) {
595
+ return o ? `connect.loyalty.segment.default_segments.${o.toLowerCase()}` : void 0;
596
+ }
597
+ function m(o) {
598
+ const n = a(o.defaultKey);
599
+ return n ? c(`${n}.name`) : o.name;
600
+ }
601
+ function i(o) {
602
+ return T.value <= 0 ? "0.00" : ((o ?? 0) * 100 / T.value).toFixed(2);
603
+ }
604
+ const A = [
605
+ {
606
+ header: c("connect.loyalty.segment.table.name"),
607
+ accessorFn: (o) => o.name,
608
+ cell(o) {
609
+ return B("div", { class: "flex flex-wrap items-center gap-8" }, [
610
+ B("span", m(o.row.original)),
611
+ ...E(o.row.original) ? [
612
+ B(ae.FmChip, {
613
+ class: be,
614
+ label: c("connect.loyalty.segment.default_segments.system"),
615
+ compact: !0
616
+ })
617
+ ] : []
618
+ ]);
619
+ }
620
+ },
621
+ {
622
+ header: c("connect.loyalty.segment.table.status"),
623
+ enableSorting: !1,
624
+ cell(o) {
625
+ const n = o.row.original.isActive === !1 ? "Inactive" : "Active";
626
+ return B(ae.FmChip, {
627
+ class: o.row.original.isActive === !1 ? "text-fm-color-typo-error bg-fm-color-system-error-100" : "text-fm-color-typo-success bg-fm-color-system-success-100",
628
+ label: n,
629
+ compact: !0
630
+ });
631
+ }
632
+ },
633
+ {
634
+ header: c("connect.loyalty.segment.table.total_customers"),
635
+ accessorFn: (o) => o.memberCount ?? 0
636
+ },
637
+ {
638
+ header: c("connect.loyalty.segment.table.customer_percentage"),
639
+ accessorFn: (o) => i(o.memberCount)
640
+ },
641
+ {
642
+ header: c("connect.loyalty.segment.table.actions"),
643
+ meta: {
644
+ maxWidth: "100px"
645
+ },
646
+ cell(o) {
647
+ return B("div", { class: "flex items-center justify-end" }, [
648
+ B(
649
+ ae.FmMenu,
650
+ {
651
+ placement: "bottom-end",
652
+ onClick: (n) => {
653
+ n.stopPropagation();
654
+ }
655
+ },
656
+ {
657
+ "menu-button": () => B(ae.FmButton, {
658
+ icon: "more_vert",
659
+ iconColor: "neutral-gray-400",
660
+ variant: "tertiary"
661
+ }),
662
+ default: () => [
663
+ B(
664
+ ae.FmMenuItem,
665
+ {
666
+ onClick: async (n) => {
667
+ n.stopPropagation(), K(o.row.original);
668
+ }
669
+ },
670
+ {
671
+ label: B(
672
+ "div",
673
+ {
674
+ class: "fm-typo-en-body-md-400"
675
+ },
676
+ "Export"
677
+ )
678
+ }
679
+ ),
680
+ ...E(o.row.original) ? [] : [
681
+ B(
682
+ ae.FmMenuItem,
683
+ {
684
+ onClick: async (n) => {
685
+ n.stopPropagation(), G(o.row.original);
686
+ }
687
+ },
688
+ {
689
+ label: B(
690
+ "div",
691
+ {
692
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400"
693
+ },
694
+ "Remove"
695
+ )
696
+ }
697
+ )
698
+ ]
699
+ ]
700
+ }
701
+ )
702
+ ]);
703
+ }
704
+ }
705
+ ], y = W(null), { tableMeta: p, rowData: g, debouncedFetchData: x } = Fe(
706
+ z.readAll
707
+ ), j = O(() => g.value.length === 0 ? !1 : Ve.some(
708
+ (o) => !g.value.some((n) => n.defaultKey === o)
709
+ ));
710
+ async function q() {
711
+ var o;
712
+ try {
713
+ await z.refreshSegments(), _.open({ type: "info", title: "Segment refresh queued" });
714
+ } catch (n) {
715
+ if (((n == null ? void 0 : n.status) ?? ((o = n == null ? void 0 : n.response) == null ? void 0 : o.status)) === 409) {
716
+ _.open({
717
+ type: "info",
718
+ title: "Segment refresh already in progress"
719
+ });
720
+ return;
721
+ }
722
+ _.open({
723
+ type: "error",
724
+ title: (n == null ? void 0 : n.message) ?? "Failed to queue segment refresh"
725
+ });
726
+ }
727
+ }
728
+ async function I() {
729
+ await f(
730
+ async () => {
731
+ await z.startDefaultSegments(), await x({ pageSize: 10, pageIndex: 0 });
732
+ },
733
+ {
734
+ message: c(
735
+ "connect.loyalty.segment.default_segments.get_started.loading"
736
+ ),
737
+ successMessage: c(
738
+ "connect.loyalty.segment.default_segments.get_started.success"
739
+ )
740
+ }
741
+ );
742
+ }
743
+ async function G(o) {
744
+ await Pe.remove(`Are you sure you want to remove ${o.name}?`) && await f(
745
+ async () => {
746
+ await z.delete(o._id), await x({ pageSize: 10, pageIndex: 0 });
747
+ },
748
+ {
749
+ message: `Removing ${o.name}`,
750
+ successMessage: `Removed ${o.name} successfully`
751
+ }
752
+ );
753
+ }
754
+ async function K(o) {
755
+ const n = {
756
+ sortBy: "_id",
757
+ descending: !1,
758
+ rowsPerPage: 1e3,
759
+ page: 1,
760
+ rowsNumber: 0
761
+ }, F = new Ye(), w = m(o), R = (await _e.read({
762
+ limit: 1,
763
+ skip: 0,
764
+ sortBy: n.sortBy,
765
+ descending: n.descending
766
+ })).meta.totalResources ?? 0, H = n.rowsPerPage;
767
+ await f(
768
+ async () => {
769
+ for (let L = 0; L < R; L += H) {
770
+ const oe = {
771
+ ...n,
772
+ limit: H,
773
+ skip: n.page - 1,
774
+ sortBy: n.sortBy,
775
+ descending: n.descending
776
+ }, ne = await z.paginateSegmentUsers(
777
+ o._id,
778
+ oe
779
+ );
780
+ for (const C of ne.resources) {
781
+ const N = b(C);
782
+ F.addRecord(N);
783
+ }
784
+ n.page++;
785
+ }
786
+ await ke(
787
+ F.buildExcel(),
788
+ `[${w}]-members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
789
+ {
790
+ bookType: "xlsx",
791
+ bookSST: !1,
792
+ type: "array"
793
+ }
794
+ ), n.page = 1;
795
+ },
796
+ {
797
+ message: "Exporting member...",
798
+ successMessage: "Member exported successfully"
799
+ }
800
+ );
801
+ }
802
+ async function v(o) {
803
+ await f(
804
+ async () => {
805
+ var n;
806
+ if (o.type === U.enum.STATIC) {
807
+ const F = new FormData();
808
+ if (F.append("file", o.file), o._id) {
809
+ const { members: w, _id: R, file: H, ...L } = o;
810
+ F.append("segment", JSON.stringify(L)), await z.updateStatic(o._id, F);
811
+ } else {
812
+ const { file: w, ...R } = o;
813
+ F.append("segment", JSON.stringify(R)), await z.createStatic(F);
814
+ }
815
+ o.file && _.open({
816
+ type: "info",
817
+ title: "Import begins soon. Check Queue for updates.",
818
+ action: "View",
819
+ onAction: async () => {
820
+ await u.push({
821
+ name: xe["$connect-QUEUE"],
822
+ query: { type: [ge.enum.SEGMENTATION_IMPORTED] }
823
+ });
824
+ }
825
+ });
826
+ } else if (o._id) {
827
+ const { members: F, _id: w, ...R } = o;
828
+ await z.update(o._id, R);
829
+ } else
830
+ await z.create(o);
831
+ await x({ pageSize: 10, pageIndex: 0 }), (n = y.value) == null || n.hideSheet();
832
+ },
833
+ {
834
+ message: "Saving segment",
835
+ successMessage: "Segment saved"
836
+ }
837
+ );
838
+ }
839
+ function l(o) {
840
+ var n;
841
+ (n = y.value) == null || n.showSheet(o);
842
+ }
843
+ const P = {
844
+ label: c("connect.navigation.queue"),
845
+ value: "queue",
846
+ isPrimary: !1,
847
+ prependIcon: "work_history"
848
+ }, X = {
849
+ label: c("connect.loyalty.segment.default_segments.get_started.action"),
850
+ value: "start-default-segments",
851
+ isPrimary: !1,
852
+ prependIcon: "auto_awesome"
853
+ }, ee = O(() => {
854
+ if (!M.isPremium)
855
+ return [];
856
+ const o = [P];
857
+ return j.value && o.push(X), o.push(
858
+ {
859
+ label: c("connect.loyalty.segment.actions.refresh"),
860
+ value: "refresh",
861
+ prependIcon: "refresh"
862
+ },
863
+ {
864
+ label: c("connect.loyalty.segment.actions.add"),
865
+ value: "add",
866
+ isPrimary: !0,
867
+ prependIcon: "add"
868
+ }
869
+ ), o;
870
+ });
871
+ function te(o) {
872
+ switch (o) {
873
+ case "add":
874
+ l();
875
+ break;
876
+ case "refresh":
877
+ q();
878
+ break;
879
+ case "queue":
880
+ u.push({
881
+ name: xe["$connect-QUEUE"],
882
+ query: { type: [ge.enum.SEGMENTATION_IMPORTED] }
883
+ });
884
+ break;
885
+ case "start-default-segments":
886
+ I();
887
+ break;
888
+ }
889
+ }
890
+ return De(async () => {
891
+ const { meta: o } = await _e.read({
892
+ limit: 1,
893
+ skip: 0,
894
+ sortBy: "_id",
895
+ search: void 0,
896
+ descending: !1
897
+ });
898
+ T.value = o.totalResources ?? 0, await x({ pageSize: 10, pageIndex: 0 }), await M.readPremium(), await M.readLocations();
899
+ }), (o, n) => {
900
+ const F = S("FmPill"), w = S("FmPageHead"), R = S("FmChip"), H = S("FmIcon"), L = S("FmMenuItem"), oe = S("FmMenu"), ne = S("FmListItem"), C = S("FmList"), N = S("FmButton"), Q = S("FmCard");
901
+ return r(), k(Z, null, [
902
+ d(w, {
903
+ title: "Segments",
904
+ actions: e(ee),
905
+ "onClick:action": n[0] || (n[0] = (h) => te(h))
906
+ }, {
907
+ title: $(() => [
908
+ s("div", Bt, [
909
+ s("span", Ut, D(e(c)("connect.loyalty.segment.title")), 1),
910
+ d(F, { variant: "premium" })
911
+ ])
912
+ ]),
913
+ _: 1
914
+ }, 8, ["actions"]),
915
+ s("div", Vt, [
916
+ e(g).length > 0 || e(p).searchValue || e(p).isLoading ? (r(), k(Z, { key: 0 }, [
917
+ d(Ce, {
918
+ loading: e(p).isLoading,
919
+ "row-data": e(g),
920
+ "row-count": e(p).totalRows,
921
+ "column-defs": A,
922
+ "shrink-at": !1,
923
+ "page-count": e(p).pageCount,
924
+ "page-index": e(p).pageIndex,
925
+ "page-size": e(p).pageSize,
926
+ onRowClick: n[1] || (n[1] = (h) => {
927
+ l(h.original);
928
+ }),
929
+ onPageChange: e(x)
930
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onPageChange"]),
931
+ d(C, { class: "w-full hidden xs:!block" }, {
932
+ default: $(() => [
933
+ (r(!0), k(Z, null, me(e(g), (h) => (r(), V(ne, {
934
+ key: h._id.toString(),
935
+ tag: "label",
936
+ onClick: (Y) => l(h)
937
+ }, {
938
+ default: $(() => [
939
+ s("div", null, [
940
+ s("div", Lt, D((h.memberCount ?? 0).toLocaleString()) + " total customers ", 1),
941
+ s("div", Yt, [
942
+ s("span", zt, D(m(h)), 1),
943
+ E(h) ? (r(), V(R, {
944
+ key: 0,
945
+ class: ce(be),
946
+ label: e(c)("connect.loyalty.segment.default_segments.system"),
947
+ compact: ""
948
+ }, null, 8, ["label"])) : J("", !0)
949
+ ]),
950
+ s("div", Ot, D(i(h.memberCount)) + "% of customers ", 1)
951
+ ])
952
+ ]),
953
+ append: $(() => [
954
+ d(oe, { "stop-click-propagation": !0 }, {
955
+ "menu-button": $(() => [
956
+ d(H, { name: "more_vert" })
957
+ ]),
958
+ default: $(() => [
959
+ d(L, {
960
+ class: "fm-typo-en-body-md-400",
961
+ label: "Export",
962
+ "onUpdate:modelValue": (Y) => Y && K(h)
963
+ }, null, 8, ["onUpdate:modelValue"]),
964
+ E(h) ? J("", !0) : (r(), V(L, {
965
+ key: 0,
966
+ class: "text-fm-color-typo-error fm-typo-en-body-md-400",
967
+ label: "Remove",
968
+ "onUpdate:modelValue": (Y) => Y && G(h)
969
+ }, null, 8, ["onUpdate:modelValue"]))
970
+ ]),
971
+ _: 2
972
+ }, 1024)
973
+ ]),
974
+ _: 2
975
+ }, 1032, ["onClick"]))), 128))
976
+ ]),
977
+ _: 1
978
+ })
979
+ ], 64)) : (r(), V(Q, {
980
+ key: 1,
981
+ variant: "outlined",
982
+ class: "w-full flex flex-col items-center justify-center gap-y-24 p-24"
983
+ }, {
984
+ default: $(() => [
985
+ n[3] || (n[3] = s("img", {
986
+ src: $e,
987
+ class: "aspect-square w-[150px]"
988
+ }, null, -1)),
989
+ s("div", jt, [
990
+ s("div", qt, D(e(c)("connect.loyalty.segment.default_segments.get_started.title")), 1),
991
+ s("div", Gt, D(e(c)(
992
+ "connect.loyalty.segment.default_segments.get_started.description"
993
+ )), 1)
994
+ ]),
995
+ d(N, {
996
+ variant: "primary",
997
+ label: e(c)("connect.loyalty.segment.default_segments.get_started.action"),
998
+ disabled: !e(M).isPremium,
999
+ icon: "auto_awesome",
1000
+ onClick: n[2] || (n[2] = (h) => I())
1001
+ }, null, 8, ["label", "disabled"])
1002
+ ]),
1003
+ _: 1
1004
+ })),
1005
+ d(Pt, {
1006
+ ref_key: "sheetRef",
1007
+ ref: y,
1008
+ "onUpdate:modelValue": v
1009
+ }, null, 512)
1010
+ ])
1011
+ ], 64);
1012
+ };
1013
+ }
1014
+ });
1015
+ export {
1016
+ Mo as default
1017
+ };