@feedmepos/mf-connect 0.1.98-beta.15 → 0.1.98-beta.16

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