@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,1603 @@
1
+ import { defineComponent as be, computed as H, ref as G, resolveComponent as V, openBlock as u, createElementBlock as A, Fragment as q, createElementVNode as n, unref as t, createBlock as U, createCommentVNode as le, createVNode as _, renderList as ie, withCtx as xe, createTextVNode as Me, toDisplayString as $, withDirectives as Re, vShow as Le, watch as ze, onBeforeMount as at, h as K, onMounted as je, isRef as rt, normalizeClass as st } from "vue";
2
+ import { h as C } from "./moment-D7p2TMB-.js";
3
+ import { useDialog as Ve, components as ve } from "@feedmepos/ui-library";
4
+ import { e as it, M as lt } from "./email-addresses-DlLiZ1io.js";
5
+ import { w as ct } from "./xlsx-Bn7BqUFA.js";
6
+ import "./index-Dx9h0FNH.js";
7
+ import "./index-D4SDAfbP.js";
8
+ import { u as Ie, C as Be, s as dt } from "./membership-BWaK-9FY.js";
9
+ import { c as mt } from "./index-DcjnS5Sv.js";
10
+ import { _ as Ye } from "./lodash-BC_P6kLg.js";
11
+ import { D as ut } from "./type_drinks-D6jnpvwV.js";
12
+ import { b as pt, c as ft, d as bt, e as yt, f as gt } from "./index-kedErkLZ.js";
13
+ import { c as Pe, f as Oe } from "./string-Gcy5IM_H.js";
14
+ import { u as qe } from "./loading-NY-FPxVY.js";
15
+ import { p as Ue } from "./plugins-ur-FAoye.js";
16
+ import { C as Ee } from "./collection.fn-Cg16QZSp.js";
17
+ import { u as Ke } from "./business-CE_4siXc.js";
18
+ import { defineStore as vt } from "pinia";
19
+ import { f as ee } from "./number-BX5OEXgq.js";
20
+ import "./index-CmNsGhDf.js";
21
+ import "./index-CSVhIZSY.js";
22
+ import "./index-BuMfQxMf.js";
23
+ import "./index-lnQT4P3d.js";
24
+ import { s as xt } from "./index-CuvNtC_M.js";
25
+ import { u as Ge, _ as He } from "./usePagination-Caah4sJr.js";
26
+ import { B as ht, e as _t } from "./export-6Hr34dBU.js";
27
+ import { m as Te } from "./index-CVHacTbc.js";
28
+ import { o as he } from "./objectId-dwaoBfJX.js";
29
+ import { F as Ae } from "./collectible.enum-Liy2wH3s.js";
30
+ import { a as St, c as Ct } from "./campaign-BP6rvSpg.js";
31
+ import { useRouter as We } from "vue-router";
32
+ import { m as fe } from "./index-DVnYQ3Hs.js";
33
+ import { t as wt } from "./index-BbTIqReL.js";
34
+ import { R as Je } from "./app-CE5hQ4Uq.js";
35
+ import { t as Ft } from "./money-COoh4GXK.js";
36
+ import { g as Mt, a as Tt, b as kt } from "./user-BZC4P_jL.js";
37
+ const At = { class: "flex flex-col" }, Et = { key: 1 }, Vt = { class: "flex flex-nowrap gap-4 items-center my-[-4px]" }, It = { class: "flex flex-nowrap gap-8 items-center pt-24 w-full" }, $t = /* @__PURE__ */ be({
38
+ __name: "MemberStatsDialog",
39
+ props: {
40
+ member: {
41
+ type: Object,
42
+ required: !0
43
+ },
44
+ onSubmit: {
45
+ type: Function,
46
+ required: !0
47
+ }
48
+ },
49
+ setup(y) {
50
+ var ce, ae, W, re;
51
+ const k = Ve(), p = Ie(), x = y, s = H(
52
+ () => {
53
+ var f;
54
+ return (((f = x.member.collection) == null ? void 0 : f.TITLE) ?? []).reduce(
55
+ (c, M) => {
56
+ var S, T, O, E, R;
57
+ const r = p.sortedTitles.find(
58
+ (te) => te._id.toString() === M.collectible
59
+ );
60
+ if (!r) return c;
61
+ const i = [...M.expiryBalance ?? []].sort(
62
+ (te, z) => C(te.expiredAt).isAfter(C(z.expiredAt)) ? -1 : 1
63
+ );
64
+ return (S = i[0]) != null && S.expiredAt && C((T = i[0]) == null ? void 0 : T.expiredAt).isBefore(C()) || c.push({
65
+ _id: r._id,
66
+ name: r.name,
67
+ expiredAt: (O = i[0]) != null && O.expiredAt ? C((E = i[0]) == null ? void 0 : E.expiredAt).toISOString() : "",
68
+ expiresIn: C((R = i[0]) == null ? void 0 : R.expiredAt).diff(C(), "days")
69
+ }), c;
70
+ },
71
+ []
72
+ );
73
+ }
74
+ ), o = G({
75
+ cardNo: x.member.cardNo,
76
+ experience: ((ae = (ce = x.member.collection) == null ? void 0 : ce.POINT) == null ? void 0 : ae[0].balance) ?? 0,
77
+ tier: ((re = (W = x.member.collection) == null ? void 0 : W.TIER) == null ? void 0 : re[0].balance) ?? -1,
78
+ titles: s.value.map((f) => ({ expiredAt: f.expiresIn, id: f._id })) ?? void 0
79
+ }), g = H(
80
+ () => (p.sortedTitles ?? []).map((f) => ({
81
+ label: f.name,
82
+ value: f._id.toString(),
83
+ sublabel: s.value.some((c) => c._id === f._id) ? "Owned" : void 0
84
+ }))
85
+ ), d = H(() => (p.sortedTiers ?? []).map((f, c) => ({
86
+ label: f.name,
87
+ sublabel: `${f.option.from} - ${f.option.to}`,
88
+ from: f.option.from,
89
+ to: f.option.to,
90
+ value: c + 1
91
+ })));
92
+ function w() {
93
+ var M, r;
94
+ const f = ((M = d.value[(o.value.tier ?? 1) - 1]) == null ? void 0 : M.from) ?? 0, c = (r = d.value[(o.value.tier ?? 1) - 1]) == null ? void 0 : r.to;
95
+ o.value.experience = Math.min(
96
+ c ?? f,
97
+ Math.max(f, o.value.experience ?? 0)
98
+ );
99
+ }
100
+ const m = H(() => {
101
+ var M, r, i, S, T, O;
102
+ const f = ((r = (M = x.member.collection) == null ? void 0 : M.TIER) == null ? void 0 : r[0].balance) ?? -1, c = ((S = (i = x.member.collection) == null ? void 0 : i.POINT) == null ? void 0 : S[0].balance) ?? 0;
103
+ if (f != o.value.tier) return !0;
104
+ if (o.value.experience && o.value.experience != c) {
105
+ const E = ((T = d.value[f - 1]) == null ? void 0 : T.from) ?? 0, R = ((O = d.value[f - 1]) == null ? void 0 : O.to) ?? 0;
106
+ if (o.value.experience < E || R && o.value.experience > R)
107
+ return !0;
108
+ }
109
+ return !1;
110
+ });
111
+ function v(f) {
112
+ var c;
113
+ return (c = s.value.find((M) => M._id === f)) == null ? void 0 : c.expiresIn;
114
+ }
115
+ const I = H(() => {
116
+ const f = pt.safeParse(o.value);
117
+ return f.success ? void 0 : f.error.errors;
118
+ });
119
+ function N(f) {
120
+ var c, M;
121
+ return (M = (c = I.value) == null ? void 0 : c.find((r) => r.path.join(".") === f)) == null ? void 0 : M.message;
122
+ }
123
+ function L(f) {
124
+ var c;
125
+ return (c = I.value) == null ? void 0 : c.filter((M) => M.path.join(".").startsWith(f)).map((M) => M.message);
126
+ }
127
+ async function P() {
128
+ await x.onSubmit(o.value), k.close();
129
+ }
130
+ return (f, c) => {
131
+ var te, z;
132
+ const M = V("FmSelect"), r = V("FmStepperField"), i = V("FmTextField"), S = V("FmField"), T = V("FmFormGroup"), O = V("FmButton"), E = V("FmHelperText"), R = V("FmSpacer");
133
+ return u(), A(q, null, [
134
+ n("div", At, [
135
+ c[6] || (c[6] = n("div", { class: "fm-typo-en-title-sm-800 mb-8" }, "Member tiering", -1)),
136
+ t(d).length ? (u(), U(M, {
137
+ key: 0,
138
+ modelValue: t(o).tier,
139
+ "onUpdate:modelValue": [
140
+ c[0] || (c[0] = (F) => t(o).tier = F),
141
+ w
142
+ ],
143
+ label: "Member Tier",
144
+ items: t(d),
145
+ "helper-text": N("tier"),
146
+ "helper-state": N("tier") ? "error" : void 0
147
+ }, null, 8, ["modelValue", "items", "helper-text", "helper-state"])) : le("", !0),
148
+ _(r, {
149
+ "model-value": t(o).experience ?? 0,
150
+ "onUpdate:modelValue": c[1] || (c[1] = (F) => t(o).experience = F),
151
+ label: "Member Experience",
152
+ "max-fraction-digits": 0,
153
+ "helper-text": N("experience"),
154
+ "helper-state": N("experience") ? "error" : void 0
155
+ }, null, 8, ["model-value", "helper-text", "helper-state"]),
156
+ c[7] || (c[7] = n("div", { class: "fm-typo-en-title-sm-800 mt-16 mb-8" }, "Member Card", -1)),
157
+ _(i, {
158
+ modelValue: t(o).cardNo,
159
+ "onUpdate:modelValue": c[2] || (c[2] = (F) => t(o).cardNo = F),
160
+ label: "Card number",
161
+ "helper-text": N("cardNo"),
162
+ "helper-state": N("cardNo") ? "error" : void 0
163
+ }, null, 8, ["modelValue", "helper-text", "helper-state"]),
164
+ c[8] || (c[8] = n("div", { class: "fm-typo-en-title-sm-800 mt-16 mb-8" }, "Titles", -1)),
165
+ (te = t(o).titles) != null && te.length ? (u(), A("div", Et, [...c[5] || (c[5] = [
166
+ n("div", { class: "flex flex-nowrap gap-4 items-center" }, [
167
+ n("div", { class: "flex-1" }, "Title"),
168
+ n("div", { class: "flex-1" }, "Expires in days"),
169
+ n("div", { class: "w-24 h-1" })
170
+ ], -1)
171
+ ])])) : le("", !0),
172
+ (u(!0), A(q, null, ie(t(o).titles ?? [], (F, J) => (u(), A("div", { key: J }, [
173
+ n("div", Vt, [
174
+ t(s).some((a) => a._id === F.id) ? (u(), U(T, {
175
+ key: 1,
176
+ "model-value": "",
177
+ class: "flex-1"
178
+ }, {
179
+ default: xe(() => [
180
+ _(S, {
181
+ disabled: !0,
182
+ class: "text-fm-color-typo-secondary"
183
+ }, {
184
+ default: xe(() => {
185
+ var a;
186
+ return [
187
+ Me($((a = t(g).find((e) => e.value === F.id)) == null ? void 0 : a.label), 1)
188
+ ];
189
+ }),
190
+ _: 2
191
+ }, 1024)
192
+ ]),
193
+ _: 2
194
+ }, 1024)) : (u(), U(M, {
195
+ key: 0,
196
+ modelValue: F.id,
197
+ "onUpdate:modelValue": [(a) => F.id = a, (a) => F.expiredAt = v(a) ?? 1],
198
+ class: "flex-1",
199
+ items: t(g).filter(
200
+ (a) => {
201
+ var e;
202
+ return !((e = t(o).titles) != null && e.map((b) => b.id).includes(a.value)) || F.id === a.value;
203
+ }
204
+ )
205
+ }, null, 8, ["modelValue", "onUpdate:modelValue", "items"])),
206
+ _(r, {
207
+ modelValue: F.expiredAt,
208
+ "onUpdate:modelValue": (a) => F.expiredAt = a,
209
+ class: "flex-1",
210
+ label: "",
211
+ "max-fraction-digits": 0,
212
+ min: 0,
213
+ max: 9999,
214
+ step: 1
215
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
216
+ _(O, {
217
+ class: "w-24 h-24",
218
+ icon: "close",
219
+ variant: "tertiary",
220
+ onClick: (a) => {
221
+ var e;
222
+ return (e = t(o).titles) == null ? void 0 : e.splice(J, 1);
223
+ }
224
+ }, null, 8, ["onClick"])
225
+ ]),
226
+ (u(!0), A(q, null, ie(L(`titles.${J}`), (a, e) => (u(), U(E, {
227
+ key: e,
228
+ class: "items-center",
229
+ state: "error",
230
+ text: a.toString()
231
+ }, null, 8, ["text"]))), 128))
232
+ ]))), 128)),
233
+ t(g).length && (((z = t(o).titles) == null ? void 0 : z.length) ?? 0) < t(g).length ? (u(), U(O, {
234
+ key: 2,
235
+ icon: "add",
236
+ label: "Give title",
237
+ variant: "plain",
238
+ onClick: c[3] || (c[3] = (F) => {
239
+ var J;
240
+ return t(o).titles = [
241
+ ...t(o).titles ?? [],
242
+ {
243
+ id: ((J = t(g).find(
244
+ (a) => {
245
+ var e;
246
+ return !((e = t(o).titles) != null && e.map((b) => b.id).includes(a.value));
247
+ }
248
+ )) == null ? void 0 : J.value) || t(g)[0].value,
249
+ expiredAt: 0
250
+ }
251
+ ];
252
+ })
253
+ })) : le("", !0)
254
+ ]),
255
+ n("div", It, [
256
+ Re(_(E, {
257
+ state: "warning",
258
+ text: "Updating member will cause tier to change"
259
+ }, null, 512), [
260
+ [Le, t(m)]
261
+ ]),
262
+ _(R),
263
+ _(O, {
264
+ variant: "secondary",
265
+ label: "Cancel",
266
+ size: "md",
267
+ onClick: c[4] || (c[4] = (F) => t(k).close())
268
+ }),
269
+ _(O, {
270
+ disabled: !!t(I),
271
+ variant: "primary",
272
+ label: "Submit",
273
+ size: "md",
274
+ onClick: P
275
+ }, null, 8, ["disabled"])
276
+ ])
277
+ ], 64);
278
+ };
279
+ }
280
+ }), Dt = { class: "fm-typo-en-title-sm-800" }, Nt = { class: "space-y-16" }, Bt = { class: "flex flex-nowrap gap-8 items-center justify-end pt-24 w-full" }, Yt = /* @__PURE__ */ be({
281
+ __name: "CreditCoinDialog",
282
+ props: {
283
+ type: { type: String, required: !0 },
284
+ action: { type: String, required: !0 },
285
+ onSubmit: {
286
+ type: Function,
287
+ required: !0
288
+ }
289
+ },
290
+ setup(y) {
291
+ const k = Ve(), p = y, x = G({
292
+ amount: 1,
293
+ day: 1,
294
+ remark: void 0
295
+ }), s = G(!0), o = H(() => Ee.formattedType(p.type.toUpperCase()));
296
+ function g(m) {
297
+ s.value = m, !m && p.type === "coin" && (x.value.day = void 0);
298
+ }
299
+ async function d() {
300
+ if (p.action === "send") {
301
+ const m = x.value.day ? `, expire in ${x.value.day} days` : "";
302
+ Ue.confirm(
303
+ `Are you sure to send ${x.value.amount} ${o.value.toLowerCase()}${m}? This action cannot be reversed.`
304
+ ).then(async (v) => {
305
+ v && await p.onSubmit(x.value);
306
+ });
307
+ } else
308
+ Ue.confirm(
309
+ `Are you sure to deduct ${x.value.amount} ${o.value.toLowerCase()}? This action cannot be reversed.`
310
+ ).then(async (m) => {
311
+ m && await p.onSubmit(x.value);
312
+ });
313
+ }
314
+ const w = H(() => {
315
+ const v = (p.action === "send" ? p.type === "coin" ? ft : bt : p.type === "coin" ? yt : gt).safeParse(x.value);
316
+ return v.success == !1 ? v.error.flatten().fieldErrors : void 0;
317
+ });
318
+ return (m, v) => {
319
+ const I = V("FmStepperField"), N = V("FmSwitch"), L = V("FmTextarea"), P = V("FmButton"), ce = V("FmCard");
320
+ return u(), U(ce, { class: "flex flex-col gap-16 p-16" }, {
321
+ default: xe(() => {
322
+ var ae, W, re, f, c, M;
323
+ return [
324
+ n("div", Dt, $(p.action == "send" ? "Send" : "Deduct") + " " + $(t(Be)[p.type.toUpperCase()].name), 1),
325
+ Me(" " + $(t(w)) + " ", 1),
326
+ n("div", Nt, [
327
+ _(I, {
328
+ modelValue: t(x).amount,
329
+ "onUpdate:modelValue": v[0] || (v[0] = (r) => t(x).amount = r),
330
+ label: `${t(Be)[p.type.toUpperCase()].name} amount`,
331
+ "is-currency": !0,
332
+ "max-fraction-digits": 2,
333
+ "helper-state": (ae = t(w)) != null && ae.amount ? "error" : void 0,
334
+ "helper-text": (re = (W = t(w)) == null ? void 0 : W.amount) == null ? void 0 : re[0]
335
+ }, null, 8, ["modelValue", "label", "helper-state", "helper-text"]),
336
+ y.action === "send" && p.type === "coin" ? (u(), U(N, {
337
+ key: 0,
338
+ "model-value": t(s),
339
+ label: `${t(o)} expires`,
340
+ "label-placement": "right",
341
+ "onUpdate:modelValue": v[1] || (v[1] = (r) => g(r))
342
+ }, null, 8, ["model-value", "label"])) : le("", !0),
343
+ y.action === "send" && t(s) ? (u(), U(I, {
344
+ key: 1,
345
+ modelValue: t(x).day,
346
+ "onUpdate:modelValue": v[2] || (v[2] = (r) => t(x).day = r),
347
+ label: `${t(o)} expires in`,
348
+ "max-fraction-digits": 0,
349
+ "append-text": "day(s)",
350
+ max: 9999,
351
+ min: 0,
352
+ "helper-state": (f = t(w)) != null && f.day ? "error" : void 0,
353
+ "helper-text": (M = (c = t(w)) == null ? void 0 : c.day) == null ? void 0 : M[0]
354
+ }, null, 8, ["modelValue", "label", "helper-state", "helper-text"])) : le("", !0),
355
+ _(L, {
356
+ modelValue: t(x).remark,
357
+ "onUpdate:modelValue": v[3] || (v[3] = (r) => t(x).remark = r),
358
+ label: "Remark"
359
+ }, null, 8, ["modelValue"])
360
+ ]),
361
+ n("div", Bt, [
362
+ _(P, {
363
+ variant: "secondary",
364
+ label: "Cancel",
365
+ size: "md",
366
+ onClick: v[4] || (v[4] = (r) => t(k).close())
367
+ }),
368
+ _(P, {
369
+ disabled: !!t(w),
370
+ variant: "primary",
371
+ label: "Submit",
372
+ size: "md",
373
+ onClick: v[5] || (v[5] = async () => d())
374
+ }, null, 8, ["disabled"])
375
+ ])
376
+ ];
377
+ }),
378
+ _: 1
379
+ });
380
+ };
381
+ }
382
+ }), Xe = vt("segment", () => {
383
+ const y = G([]);
384
+ async function k() {
385
+ const p = await dt.readAll({
386
+ limit: 1e3,
387
+ skip: 0,
388
+ sortBy: "_id",
389
+ descending: !0
390
+ });
391
+ y.value = p.resources;
392
+ }
393
+ return {
394
+ segments: y,
395
+ read: k
396
+ };
397
+ });
398
+ class Pt extends ht {
399
+ }
400
+ const Ot = { class: "border border-fm-color-neutral-gray-100 rounded-lg p-16" }, Ut = { class: "hidden xs:!flex items-center justify-end" }, Rt = { class: "flex items-center justify-between mb-4" }, Lt = { class: "flex items-center justify-between gap-x-8" }, zt = { class: "fm-typo-en-body-lg-600" }, jt = { class: "px-4 py-0.5 rounded-md bg-fm-color-neutral-gray-100 fm-typo-en-body-md-600" }, qt = { class: "xs:hidden flex justify-between gap-x-4" }, ke = /* @__PURE__ */ be({
401
+ __name: "MemberCollectionTable",
402
+ props: {
403
+ member: {
404
+ type: Object,
405
+ required: !0
406
+ },
407
+ title: {
408
+ type: String,
409
+ default: ""
410
+ },
411
+ columns: {
412
+ type: Array,
413
+ default: [],
414
+ required: !0
415
+ },
416
+ filters: {
417
+ type: Object,
418
+ default: {}
419
+ },
420
+ withExport: {
421
+ type: Boolean,
422
+ default: !1
423
+ },
424
+ transformExportRecord: {
425
+ type: Function
426
+ }
427
+ },
428
+ setup(y) {
429
+ const k = y, p = G({
430
+ search: ""
431
+ }), x = G(!1), { tableMeta: s, rowData: o, onSort: g, debouncedFetchData: d, onSearch: w } = Ge(async (v) => {
432
+ const I = {
433
+ ...p.value,
434
+ ...k.filters
435
+ };
436
+ return await Te.readCollectionsByMemberId(
437
+ k.member._id.toString(),
438
+ v,
439
+ I
440
+ );
441
+ });
442
+ ze(
443
+ p,
444
+ () => {
445
+ d();
446
+ },
447
+ { deep: !0 }
448
+ );
449
+ async function m() {
450
+ try {
451
+ x.value = !0;
452
+ const v = {
453
+ ...p.value,
454
+ ...k.filters
455
+ };
456
+ await _t({
457
+ exporter: new Pt(),
458
+ readFunction: (I) => Te.readCollectionsByMemberId(
459
+ k.member._id.toString(),
460
+ I,
461
+ v
462
+ ),
463
+ transformRecord: k.transformExportRecord,
464
+ filename: `${k.member._id.toString()}-${k.title.replace(" ", "-").toLowerCase()}`
465
+ });
466
+ } catch (v) {
467
+ console.error(v);
468
+ } finally {
469
+ x.value = !1;
470
+ }
471
+ }
472
+ return at(async () => {
473
+ await d();
474
+ }), (v, I) => {
475
+ const N = V("FmSearch"), L = V("FmButton");
476
+ return u(), A("div", Ot, [
477
+ n("div", Ut, [
478
+ _(N, {
479
+ class: "hidden xs:!flex",
480
+ modelValue: t(p).search,
481
+ "onUpdate:modelValue": [
482
+ I[0] || (I[0] = (P) => t(p).search = P),
483
+ t(w)
484
+ ],
485
+ placeholder: "Search",
486
+ collapsible: ""
487
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
488
+ y.withExport ? (u(), U(L, {
489
+ key: 0,
490
+ icon: "ios_share",
491
+ variant: "tertiary",
492
+ onClick: m
493
+ })) : le("", !0)
494
+ ]),
495
+ n("div", Rt, [
496
+ n("div", Lt, [
497
+ n("div", zt, $(k.title), 1),
498
+ n("div", jt, $(t(s).totalRows), 1)
499
+ ]),
500
+ n("div", qt, [
501
+ _(N, {
502
+ modelValue: t(p).search,
503
+ "onUpdate:modelValue": [
504
+ I[1] || (I[1] = (P) => t(p).search = P),
505
+ t(w)
506
+ ],
507
+ placeholder: "Search"
508
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
509
+ y.withExport ? (u(), U(L, {
510
+ key: 0,
511
+ icon: "ios_share",
512
+ variant: "tertiary",
513
+ onClick: m
514
+ })) : le("", !0)
515
+ ])
516
+ ]),
517
+ _(He, {
518
+ loading: t(s).isLoading,
519
+ "row-data": t(o),
520
+ "row-count": t(s).totalRows,
521
+ "column-defs": y.columns,
522
+ "page-count": t(s).pageCount,
523
+ "page-index": t(s).pageIndex,
524
+ "page-size": t(s).pageSize,
525
+ "shrink-at": !1,
526
+ onSortChange: t(g),
527
+ onPageChange: I[2] || (I[2] = (P) => t(d)({
528
+ pageSize: P.pageSize,
529
+ pageIndex: P.pageIndex
530
+ }))
531
+ }, null, 8, ["loading", "row-data", "row-count", "column-defs", "page-count", "page-index", "page-size", "onSortChange"])
532
+ ]);
533
+ };
534
+ }
535
+ }), Kt = /* @__PURE__ */ be({
536
+ __name: "MemberVouchers",
537
+ props: {
538
+ member: {
539
+ type: Object,
540
+ required: !0
541
+ }
542
+ },
543
+ setup(y) {
544
+ const k = y, p = [
545
+ {
546
+ header: "Voucher title",
547
+ meta: {
548
+ maxWidth: "300px"
549
+ },
550
+ cell(o) {
551
+ var g;
552
+ return K(
553
+ "div",
554
+ { class: "text-ellipsis truncate" },
555
+ ((g = o.row.original.pf_collectible) == null ? void 0 : g.name) || "-"
556
+ );
557
+ },
558
+ enableSorting: !1
559
+ },
560
+ {
561
+ header: "Claimed at",
562
+ accessorKey: "_id",
563
+ accessorFn: (o) => C(he(o._id.toString())).format("D MMM YYYY"),
564
+ enableSorting: !1
565
+ },
566
+ {
567
+ header: "Expired at",
568
+ cell(o) {
569
+ var d, w, m, v;
570
+ const g = (w = (d = o.row.original.expiryBalance) == null ? void 0 : d[0]) != null && w.expiredAt ? C((v = (m = o.row.original.expiryBalance) == null ? void 0 : m[0]) == null ? void 0 : v.expiredAt).format(
571
+ "D MMM YYYY"
572
+ ) : "-";
573
+ return K("div", {}, g);
574
+ },
575
+ enableSorting: !0
576
+ },
577
+ {
578
+ header: "Transfer open",
579
+ accessorFn: (o) => {
580
+ var g, d, w;
581
+ return xt((w = (d = (g = o.pf_collectible) == null ? void 0 : g.options) == null ? void 0 : d.enableTransfer) == null ? void 0 : w.toString());
582
+ },
583
+ enableSorting: !1
584
+ }
585
+ ], x = (o) => ({
586
+ type: Ae.enum.VOUCHER,
587
+ isActive: o
588
+ }), s = (o) => {
589
+ var g, d, w, m, v, I, N;
590
+ return {
591
+ CollectionID: o._id,
592
+ Title: (g = o.pf_collectible) == null ? void 0 : g.name,
593
+ ClaimedAt: C(he(o._id.toString())).format(
594
+ "D MMM YYYY, hh:mmA"
595
+ ),
596
+ ExpiredAt: (w = (d = o.expiryBalance) == null ? void 0 : d[0]) != null && w.expiredAt ? C((v = (m = o.expiryBalance) == null ? void 0 : m[0]) == null ? void 0 : v.expiredAt).format("D MMM YYYY") : "",
597
+ TransferOpen: ((N = (I = o.pf_collectible) == null ? void 0 : I.options) == null ? void 0 : N.enableTransfer) || !1
598
+ };
599
+ };
600
+ return (o, g) => (u(), A(q, null, [
601
+ g[0] || (g[0] = n("div", { class: "fm-typo-en-title-sm-600 mb-16" }, "Voucher Collections", -1)),
602
+ _(ke, {
603
+ member: k.member,
604
+ columns: p,
605
+ title: "Active voucher",
606
+ filters: x(!0),
607
+ withExport: !0,
608
+ transformExportRecord: s
609
+ }, null, 8, ["member", "filters"]),
610
+ _(ke, {
611
+ member: k.member,
612
+ columns: p,
613
+ title: "Past voucher",
614
+ filters: x(!1),
615
+ withExport: !0,
616
+ transformExportRecord: s
617
+ }, null, 8, ["member", "filters"])
618
+ ], 64));
619
+ }
620
+ }), Gt = /* @__PURE__ */ be({
621
+ __name: "MemberMissions",
622
+ props: {
623
+ member: {
624
+ type: Object,
625
+ required: !0
626
+ }
627
+ },
628
+ setup(y) {
629
+ const k = y, p = [
630
+ {
631
+ header: "Mission title",
632
+ meta: {
633
+ maxWidth: "300px"
634
+ },
635
+ cell(s) {
636
+ var o;
637
+ return K(
638
+ "div",
639
+ { class: "text-ellipsis truncate" },
640
+ ((o = s.row.original.pf_campaign) == null ? void 0 : o.name) || "Deleted Campaign"
641
+ );
642
+ },
643
+ enableSorting: !1
644
+ },
645
+ {
646
+ header: "Type",
647
+ accessorFn: (s) => {
648
+ var o, g, d;
649
+ return Pe.title(((d = (g = (o = s == null ? void 0 : s.pf_collectible) == null ? void 0 : o.extras) == null ? void 0 : g.mission) == null ? void 0 : d.type) || "-");
650
+ },
651
+ enableSorting: !1
652
+ },
653
+ {
654
+ header: "Status",
655
+ cell(s) {
656
+ var o;
657
+ if (s.row.original.pf_campaign) {
658
+ const g = {
659
+ active: "text-fm-color-typo-warning bg-fm-color-system-warning-100",
660
+ upcoming: "text-fm-color-typo-info bg-fm-color-system-info-100",
661
+ completed: "text-fm-color-typo-success bg-fm-color-system-success-100",
662
+ expired: "text-fm-color-typo-error bg-fm-color-system-error-100"
663
+ }, d = St(
664
+ s.row.original.pf_campaign
665
+ ), m = s.row.original.balance === s.row.original.pf_collectible.extras.mission.end && d === "active" ? "completed" : (o = s.row.original) != null && o.deactivatedAt ? "expired" : d;
666
+ return K(ve.FmChip, {
667
+ class: g[m],
668
+ label: Pe.title(m),
669
+ compact: !0
670
+ });
671
+ }
672
+ return K(ve.FmChip, {
673
+ class: "",
674
+ label: "-",
675
+ compact: !0
676
+ });
677
+ },
678
+ enableSorting: !1
679
+ },
680
+ {
681
+ header: "Summary",
682
+ accessorFn: (s) => s != null && s.pf_campaign ? Ct(s.pf_campaign) : "Deleted Campaign",
683
+ enableSorting: !1
684
+ },
685
+ {
686
+ header: "Current Step",
687
+ accessorKey: "balance",
688
+ enableSorting: !1
689
+ },
690
+ {
691
+ header: "Total Step",
692
+ accessorFn: (s) => {
693
+ var o, g, d;
694
+ return ((d = (g = (o = s == null ? void 0 : s.pf_collectible) == null ? void 0 : o.extras) == null ? void 0 : g.mission) == null ? void 0 : d.end) ?? 0;
695
+ },
696
+ enableSorting: !1
697
+ }
698
+ ], x = {
699
+ type: Ae.enum.STAMP
700
+ };
701
+ return (s, o) => (u(), A(q, null, [
702
+ o[0] || (o[0] = n("div", { class: "fm-typo-en-title-sm-600 mb-16" }, "Mission", -1)),
703
+ _(ke, {
704
+ member: k.member,
705
+ columns: p,
706
+ title: "Mission",
707
+ filters: x
708
+ }, null, 8, ["member"])
709
+ ], 64));
710
+ }
711
+ }), Ht = /* @__PURE__ */ be({
712
+ __name: "MemberGames",
713
+ props: {
714
+ member: {
715
+ type: Object,
716
+ required: !0
717
+ }
718
+ },
719
+ setup(y) {
720
+ const k = y, p = [
721
+ {
722
+ header: "Game title",
723
+ meta: {
724
+ maxWidth: "300px"
725
+ },
726
+ cell(s) {
727
+ var o;
728
+ return K(
729
+ "div",
730
+ { class: "text-ellipsis truncate" },
731
+ ((o = s.row.original.pf_campaign) == null ? void 0 : o.name) || "-"
732
+ );
733
+ },
734
+ enableSorting: !1
735
+ },
736
+ {
737
+ header: "Claimed at",
738
+ accessorKey: "_id",
739
+ accessorFn: (s) => C(he(s._id.toString())).format("D MMM YYYY"),
740
+ enableSorting: !1
741
+ },
742
+ {
743
+ header: "Expired at",
744
+ cell(s) {
745
+ var g, d, w, m;
746
+ const o = (d = (g = s.row.original.expiryBalance) == null ? void 0 : g[0]) != null && d.expiredAt ? C((m = (w = s.row.original.expiryBalance) == null ? void 0 : w[0]) == null ? void 0 : m.expiredAt).format(
747
+ "D MMM YYYY"
748
+ ) : "-";
749
+ return K("div", {}, o);
750
+ },
751
+ enableSorting: !1
752
+ },
753
+ {
754
+ header: "Token received",
755
+ accessorKey: "balance",
756
+ enableSorting: !1
757
+ }
758
+ ], x = (s) => ({
759
+ type: Ae.enum.GAME,
760
+ isActive: s
761
+ });
762
+ return (s, o) => (u(), A(q, null, [
763
+ o[0] || (o[0] = n("div", { class: "fm-typo-en-title-sm-600 mb-16" }, "Game program", -1)),
764
+ _(ke, {
765
+ member: k.member,
766
+ columns: p,
767
+ title: "Active game token",
768
+ filters: x(!0)
769
+ }, null, 8, ["member", "filters"])
770
+ ], 64));
771
+ }
772
+ }), Wt = { class: "flex flex-col flex-nowrap gap-y-24 max-h-full" }, Jt = { class: "grid md:grid-cols-2 lg:grid-cols-2 gap-x-36 gap-y-24" }, Xt = { class: "space-y-16" }, Qt = { class: "flex gap-16 items-center" }, Zt = { class: "flex-auto" }, eo = { class: "fm-typo-en-body-md-600" }, to = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, oo = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, no = { class: "fm-typo-en-body-md-800" }, ao = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, ro = { class: "fm-typo-en-body-md-800" }, so = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, io = { class: "fm-typo-en-body-md-600" }, lo = { class: "gap-16 grid grid-cols-1" }, co = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, mo = { class: "fm-typo-en-body-md-600" }, uo = { class: "p-16 grid md:grid-cols-3 lg:grid-cols-3 border-2 border-fm-color-neutral-gray-100 rounded-lg gap-16 divide-y md:divide-y-0 lg:divide-y-0 md:divide-x lg:divide-x divide-fm-color-neutral-gray-100" }, po = { class: "flex justify-between mb-16" }, fo = { class: "fm-typo-en-title-sm-600" }, bo = ["onClick"], yo = { class: "flex flex-col gap-y-16" }, go = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, vo = { class: "fm-typo-en-body-md-600" }, xo = { class: "space-y-8" }, ho = {
773
+ key: 0,
774
+ class: "space-x-8"
775
+ }, _o = {
776
+ key: 1,
777
+ class: "text-fm-color-typo-secondary"
778
+ }, So = { class: "space-y-8" }, Co = ["src"], wo = { class: "fm-typo-en-body-md-600" }, Fo = { class: "fm-typo-en-body-sm-400 text-fm-color-typo-secondary" }, Mo = {
779
+ key: 1,
780
+ class: "text-fm-color-typo-secondary"
781
+ }, To = {
782
+ key: 1,
783
+ class: "space-y-24"
784
+ }, ko = { class: "space-y-8" }, Ao = { class: "fm-typo-en-title-md-800" }, Eo = { class: "space-y-4" }, Vo = { class: "fm-typo-en-body-md-600" }, Io = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, $o = { class: "space-y-8" }, Do = { class: "fm-typo-en-title-md-800" }, No = { class: "space-y-4" }, Bo = { class: "fm-typo-en-body-md-600" }, Yo = { class: "flex gap-24 items-center xs:flex-col xs:items-start" }, Po = /* @__PURE__ */ be({
785
+ __name: "MemberDetailSheet",
786
+ props: {
787
+ member: {
788
+ type: Object,
789
+ required: !0
790
+ }
791
+ },
792
+ emits: ["update:member"],
793
+ setup(y, { expose: k, emit: p }) {
794
+ const x = We(), s = Ke(), o = Ie(), g = Xe(), d = Ve(), { minor: w } = qe, m = y, v = p, I = H(() => s.locations.map((a) => ({
795
+ label: a.name,
796
+ value: a._id
797
+ }))), N = H(() => (m.member.segment || []).map((a) => {
798
+ var e;
799
+ return ((e = g.segments.find((b) => b._id === a)) == null ? void 0 : e.name) || "";
800
+ }).filter(Boolean)), L = [
801
+ {
802
+ label: "Loyalty",
803
+ stats: [
804
+ {
805
+ label: "Experiences",
806
+ getter: (a) => {
807
+ var e, b, D;
808
+ return ee(((D = (b = (e = a.collection) == null ? void 0 : e.POINT) == null ? void 0 : b[0]) == null ? void 0 : D.balance) ?? 0, 2);
809
+ }
810
+ },
811
+ {
812
+ label: "Credits",
813
+ getter: (a) => {
814
+ var e, b, D;
815
+ return ee(((D = (b = (e = a.collection) == null ? void 0 : e.CREDIT) == null ? void 0 : b[0]) == null ? void 0 : D.balance) ?? 0, 2);
816
+ }
817
+ }
818
+ ]
819
+ },
820
+ {
821
+ label: "Voucher",
822
+ stats: [
823
+ {
824
+ label: "Active vouchers",
825
+ getter: () => ee(S.value.active, 0)
826
+ },
827
+ {
828
+ label: "Past vouchers",
829
+ getter: () => ee(S.value.past, 0)
830
+ }
831
+ ]
832
+ },
833
+ {
834
+ label: "Mission",
835
+ stats: [
836
+ {
837
+ label: "Stamp missions",
838
+ getter: () => ee(i.value.stamp, 0)
839
+ },
840
+ {
841
+ label: "Progress missions",
842
+ getter: () => ee(i.value.progressive, 0)
843
+ }
844
+ ]
845
+ },
846
+ {
847
+ label: "Game",
848
+ stats: [
849
+ {
850
+ label: "Tokens",
851
+ getter: (a) => {
852
+ var e, b;
853
+ return ee(
854
+ ((b = (e = a.collection) == null ? void 0 : e.GAME) == null ? void 0 : b.reduce(
855
+ (D, B) => D + B.balance,
856
+ 0
857
+ )) || 0,
858
+ 0
859
+ );
860
+ }
861
+ }
862
+ ]
863
+ },
864
+ {
865
+ label: "Store bundle",
866
+ stats: [
867
+ {
868
+ label: "Bundle purchased",
869
+ getter: () => ee(O.value, 0)
870
+ }
871
+ ]
872
+ }
873
+ ], ce = (() => {
874
+ const e = [];
875
+ for (let b = 0; b < L.length; b += 3)
876
+ e.push(L.slice(b, b + 3));
877
+ return e;
878
+ })();
879
+ async function ae(a, e) {
880
+ switch (a.stopPropagation(), e) {
881
+ case "Store bundle":
882
+ await x.push({
883
+ name: Je["$connect-LOYALTY_MEMBER_TRANSACTIONS"],
884
+ params: { id: m.member._id.toString() },
885
+ query: { tab: "store" }
886
+ });
887
+ break;
888
+ default:
889
+ F.value = z.find((b) => b.label === e) || z[0];
890
+ break;
891
+ }
892
+ }
893
+ async function W(a, e) {
894
+ d.open({
895
+ title: "",
896
+ dialogComponent: Yt,
897
+ dialogComponentProps: {
898
+ type: a,
899
+ action: e,
900
+ onSubmit: async (b) => {
901
+ await w(
902
+ async () => {
903
+ const D = {
904
+ "credit-send": fe.sendCredit,
905
+ "credit-deduct": fe.deductCredit,
906
+ "coin-send": fe.sendCoin,
907
+ "coin-deduct": fe.deductCoin
908
+ }, B = `${a}-${e}`, X = D[B];
909
+ X && await X(m.member._id, b), v("update:member"), d.close();
910
+ },
911
+ {
912
+ message: `Adjusting ${Ee.formattedType(
913
+ a.toUpperCase()
914
+ ).toLowerCase()}`,
915
+ successMessage: `${b.amount} ${Ee.formattedType(
916
+ a.toUpperCase()
917
+ ).toLowerCase()} ${e} ${e == "send" ? "to" : "from"} ${m.member.phoneNumber}`
918
+ }
919
+ );
920
+ }
921
+ }
922
+ });
923
+ }
924
+ async function re() {
925
+ d.open({
926
+ title: "Update member statistics",
927
+ contentComponent: $t,
928
+ contentComponentProps: {
929
+ member: m.member,
930
+ onSubmit: async (a) => {
931
+ await w(
932
+ async () => {
933
+ await fe.updateMember(m.member._id, a), v("update:member"), d.close();
934
+ },
935
+ {
936
+ message: "Updating member stats",
937
+ successMessage: `Updated member ${m.member.phoneNumber} stats successfully`
938
+ }
939
+ );
940
+ }
941
+ }
942
+ });
943
+ }
944
+ const f = [
945
+ {
946
+ label: "Mobile No.",
947
+ key: "phoneNumber"
948
+ },
949
+ {
950
+ label: "Tier",
951
+ getter: (a) => {
952
+ var se, de, ye, h, Y;
953
+ const e = (((de = Ye.first((se = m.member.collection) == null ? void 0 : se.TIER)) == null ? void 0 : de.balance) || 0) - 1, b = M.value.name, D = ((h = (ye = a.collection) == null ? void 0 : ye.POINT) == null ? void 0 : h[0].balance) ?? 0, B = o.sortedTiers[e + 1], X = ((Y = B == null ? void 0 : B.option) == null ? void 0 : Y.from) ?? 1 / 0;
954
+ return `${b} (${D}/${X})`;
955
+ }
956
+ },
957
+ {
958
+ label: "Email",
959
+ key: "email"
960
+ },
961
+ {
962
+ label: "Birthday",
963
+ getter: (a) => a.birthday ? C(a.birthday).format("D MMM YYYY") : "-"
964
+ }
965
+ ], c = [
966
+ {
967
+ label: "Customer since",
968
+ getter: (a) => C(he(a._id.toString())).format("D MMM YYYY")
969
+ },
970
+ {
971
+ label: "Joined at location",
972
+ getter: (a) => {
973
+ var e;
974
+ return a != null && a.location && ((e = I.value.find((b) => b.value == a.location)) == null ? void 0 : e.label) || "-";
975
+ }
976
+ },
977
+ {
978
+ label: "Total visit(s)",
979
+ getter: (a) => Oe.singularOrPlural(a.stats.visitCount, "bill")
980
+ },
981
+ {
982
+ label: "Last visit",
983
+ getter: (a) => C(a.stats.lastVisit).fromNow()
984
+ },
985
+ {
986
+ label: "Frequency",
987
+ getter: (a) => `Every ${Oe.singularOrPlural(
988
+ Number(Math.ceil(a.stats.avgVisitFrequency).toFixed(0)),
989
+ "day"
990
+ )}`
991
+ },
992
+ {
993
+ label: "Average spend",
994
+ getter: (a) => mt.Dinero.fromNumber({ number: Number(a.stats.avgBillSize || 0) }).toFormat(
995
+ !0
996
+ )
997
+ }
998
+ // {
999
+ // label: 'Feedback',
1000
+ // key: 'feedbackCount',
1001
+ // },
1002
+ // {
1003
+ // label: 'Tier Earned this season',
1004
+ // key: 'lastSeasonTierEarned',
1005
+ // },
1006
+ // {
1007
+ // label: 'Point Earned this season',
1008
+ // key: 'lastSeasonPointEarned',
1009
+ // },
1010
+ ], M = H(() => {
1011
+ var b, D;
1012
+ const a = (((D = Ye.first((b = m.member.collection) == null ? void 0 : b.TIER)) == null ? void 0 : D.balance) || 0) - 1, e = o.sortedTiers[a];
1013
+ return { name: (e == null ? void 0 : e.name) || "-", tier: a, config: e };
1014
+ }), r = H(() => {
1015
+ var a;
1016
+ return (((a = m.member.collection) == null ? void 0 : a.TITLE) || []).map((e) => {
1017
+ var D, B, X;
1018
+ const b = (D = o.sortedTitles) == null ? void 0 : D.find(
1019
+ (se) => se._id == e.collectible
1020
+ );
1021
+ return {
1022
+ name: b == null ? void 0 : b.name,
1023
+ expiredAt: (X = (B = e.expiryBalance) == null ? void 0 : B.at(-1)) == null ? void 0 : X.expiredAt,
1024
+ collectible: b
1025
+ };
1026
+ }).filter(
1027
+ (e) => e.expiredAt ? C(e.expiredAt).isAfter(C()) : !0
1028
+ );
1029
+ }), i = G({ stamp: 0, progressive: 0 }), S = G({ active: 0, past: 0 }), T = G([]), O = H(
1030
+ () => T.value.reduce((a, e) => a + e.count, 0)
1031
+ ), E = G(!0);
1032
+ function R() {
1033
+ E.value = !0, F.value = z[0];
1034
+ }
1035
+ function te() {
1036
+ E.value = !1;
1037
+ }
1038
+ const z = [
1039
+ {
1040
+ label: "Overview",
1041
+ value: "overview"
1042
+ },
1043
+ {
1044
+ label: "Loyalty",
1045
+ value: "loyalty"
1046
+ },
1047
+ {
1048
+ label: "Voucher",
1049
+ value: "voucher"
1050
+ },
1051
+ {
1052
+ label: "Mission",
1053
+ value: "mission"
1054
+ },
1055
+ {
1056
+ label: "Game",
1057
+ value: "game"
1058
+ }
1059
+ ], F = G(z[0]), J = async () => {
1060
+ S.value = await Te.readCollectionCountByMemberId(
1061
+ m.member._id.toString(),
1062
+ Ae.enum.VOUCHER
1063
+ ), T.value = await wt.readPurchaseCountByMember(
1064
+ m.member._id.toString()
1065
+ ), i.value = await Te.readMissionCountByMemberId(
1066
+ m.member._id.toString()
1067
+ );
1068
+ };
1069
+ return je(async () => {
1070
+ await o.readMembership(), await J(), s.locations.length || await s.readLocations();
1071
+ }), ze(E, async () => {
1072
+ await J();
1073
+ }), k({
1074
+ showSheet: R,
1075
+ hideSheet: te
1076
+ }), (a, e) => {
1077
+ const b = V("FmTabs"), D = V("FmAvatar"), B = V("FmButton"), X = V("FmIcon"), se = V("FmChip"), de = V("FmCard"), ye = V("FmSideSheet");
1078
+ return u(), U(ye, {
1079
+ modelValue: t(E),
1080
+ "onUpdate:modelValue": e[5] || (e[5] = (h) => rt(E) ? E.value = h : null),
1081
+ header: "Member Detail",
1082
+ "dismiss-away": "",
1083
+ "close-button": !0,
1084
+ "max-width": 1100
1085
+ }, {
1086
+ "side-sheet-footer": xe(() => [...e[19] || (e[19] = [])]),
1087
+ default: xe(() => [
1088
+ n("div", Wt, [
1089
+ n("div", null, [
1090
+ _(b, {
1091
+ "model-value": t(F).value,
1092
+ items: z,
1093
+ class: "overflow-x-auto",
1094
+ "onUpdate:modelValue": e[0] || (e[0] = (h) => F.value = z.find((Y) => Y.value === h))
1095
+ }, null, 8, ["model-value"])
1096
+ ]),
1097
+ t(F).value == "overview" ? (u(), A(q, { key: 0 }, [
1098
+ n("div", Jt, [
1099
+ n("div", null, [
1100
+ e[9] || (e[9] = n("div", { class: "fm-typo-en-title-sm-800 mb-16" }, "Profile Information", -1)),
1101
+ n("div", Xt, [
1102
+ n("div", Qt, [
1103
+ _(D, {
1104
+ name: y.member.photoUrl ? void 0 : y.member.name,
1105
+ src: y.member.photoUrl || void 0
1106
+ }, null, 8, ["name", "src"]),
1107
+ n("div", Zt, [
1108
+ e[8] || (e[8] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Member Name ", -1)),
1109
+ n("div", eo, $(y.member.name), 1),
1110
+ n("div", to, $(y.member._id), 1),
1111
+ n("div", oo, [
1112
+ e[6] || (e[6] = Me(" Member Card: ", -1)),
1113
+ n("span", no, $(y.member.cardNo ? y.member.cardNo : "-"), 1)
1114
+ ]),
1115
+ n("div", ao, [
1116
+ e[7] || (e[7] = Me(" Referral Code: ", -1)),
1117
+ n("span", ro, $(y.member.referralCode ? y.member.referralCode : "-"), 1)
1118
+ ])
1119
+ ]),
1120
+ _(B, {
1121
+ variant: "tertiary",
1122
+ icon: "settings",
1123
+ onClick: re
1124
+ })
1125
+ ]),
1126
+ (u(), A(q, null, ie(f, (h, Y) => n("div", { key: Y }, [
1127
+ n("div", so, $(h.label), 1),
1128
+ n("div", io, $(h.key ? y.member[h.key] : h.getter(y.member)), 1)
1129
+ ])), 64))
1130
+ ])
1131
+ ]),
1132
+ n("div", null, [
1133
+ e[10] || (e[10] = n("div", { class: "fm-typo-en-title-sm-800 mb-16" }, "Activities", -1)),
1134
+ n("div", lo, [
1135
+ (u(), A(q, null, ie(c, (h) => n("div", {
1136
+ key: h.key
1137
+ }, [
1138
+ n("div", co, $(h.label), 1),
1139
+ n("div", mo, $(h.key ? m.member.stats[h.key] || "-" : h.getter(y.member)), 1)
1140
+ ])), 64))
1141
+ ])
1142
+ ])
1143
+ ]),
1144
+ e[13] || (e[13] = n("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1)),
1145
+ (u(!0), A(q, null, ie(t(ce), (h) => (u(), A("div", uo, [
1146
+ (u(!0), A(q, null, ie(h, (Y, oe) => (u(), A("div", { key: oe }, [
1147
+ n("div", {
1148
+ class: st(oe !== 0 ? "pt-12 md:pt-0 lg:pt-0 md:pl-12 lg:pl-12" : "")
1149
+ }, [
1150
+ n("div", po, [
1151
+ n("div", fo, $(Y.label), 1),
1152
+ n("button", {
1153
+ onClick: (j) => ae(j, Y.label)
1154
+ }, [
1155
+ _(X, {
1156
+ name: "chevron_right",
1157
+ outline: "",
1158
+ size: "md"
1159
+ })
1160
+ ], 8, bo)
1161
+ ]),
1162
+ n("div", yo, [
1163
+ (u(!0), A(q, null, ie(Y.stats, (j) => (u(), A("div", {
1164
+ key: j.key
1165
+ }, [
1166
+ n("div", go, $(j.label), 1),
1167
+ n("div", vo, $(j.getter(y.member)), 1)
1168
+ ]))), 128))
1169
+ ])
1170
+ ], 2)
1171
+ ]))), 128))
1172
+ ]))), 256)),
1173
+ n("div", xo, [
1174
+ e[11] || (e[11] = n("div", { class: "fm-typo-en-title-sm-800" }, "Segments", -1)),
1175
+ t(N).length ? (u(), A("div", ho, [
1176
+ (u(!0), A(q, null, ie(t(N), (h) => (u(), U(se, {
1177
+ label: h.toString()
1178
+ }, null, 8, ["label"]))), 256))
1179
+ ])) : (u(), A("div", _o, "No titles"))
1180
+ ]),
1181
+ e[14] || (e[14] = n("div", { class: "border-fm-color-neutral-gray-100 rounded-sm border-t" }, null, -1)),
1182
+ n("div", So, [
1183
+ e[12] || (e[12] = n("div", { class: "fm-typo-en-title-sm-800" }, "Title badge", -1)),
1184
+ t(r).length ? (u(!0), A(q, { key: 0 }, ie(t(r).filter((h) => h.collectible), (h) => (u(), A("div", {
1185
+ class: "flex items-center gap-x-8 h-48",
1186
+ key: h.name
1187
+ }, [
1188
+ n("img", {
1189
+ src: h.collectible.image || t(ut),
1190
+ class: "aspect-square h-full object-contain"
1191
+ }, null, 8, Co),
1192
+ n("div", null, [
1193
+ n("div", wo, $(h.name), 1),
1194
+ n("div", Fo, " Expired on " + $(t(C)(h.expiredAt).format("MMM D, Y")), 1)
1195
+ ])
1196
+ ]))), 128)) : (u(), A("div", Mo, "No titles"))
1197
+ ])
1198
+ ], 64)) : t(F).value == "loyalty" ? (u(), A("div", To, [
1199
+ _(de, {
1200
+ class: "p-16 space-y-24",
1201
+ variant: "outlined"
1202
+ }, {
1203
+ default: xe(() => {
1204
+ var h, Y, oe, j, me, ue, pe;
1205
+ return [
1206
+ n("div", ko, [
1207
+ e[15] || (e[15] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit ", -1)),
1208
+ n("div", Ao, $(((oe = (Y = (h = y.member.collection) == null ? void 0 : h.CREDIT) == null ? void 0 : Y[0]) == null ? void 0 : oe.balance) ?? 0), 1)
1209
+ ]),
1210
+ n("div", Eo, [
1211
+ e[16] || (e[16] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Credit(s) to be expired in 30 days ", -1)),
1212
+ n("div", Vo, $(((pe = (ue = (me = (j = y.member.collection) == null ? void 0 : j.CREDIT) == null ? void 0 : me[0]) == null ? void 0 : ue.expiryBalance) == null ? void 0 : pe.reduce(
1213
+ (Q, Z) => Z.expiredAt && t(C)(Z.expiredAt).isAfter(t(C)()) && t(C)(Z.expiredAt).isBefore(t(C)().add(30, "days")) ? Q + Z.amount : Q,
1214
+ 0
1215
+ )) ?? 0), 1)
1216
+ ]),
1217
+ n("div", Io, [
1218
+ _(B, {
1219
+ label: "Add credit",
1220
+ icon: "add",
1221
+ variant: "plain",
1222
+ onClick: e[1] || (e[1] = (Q) => W("credit", "send"))
1223
+ }),
1224
+ _(B, {
1225
+ label: "Deduct credit",
1226
+ icon: "remove",
1227
+ variant: "plain",
1228
+ onClick: e[2] || (e[2] = (Q) => W("credit", "deduct"))
1229
+ })
1230
+ ])
1231
+ ];
1232
+ }),
1233
+ _: 1
1234
+ }),
1235
+ _(de, {
1236
+ class: "p-16 space-y-24",
1237
+ variant: "outlined"
1238
+ }, {
1239
+ default: xe(() => {
1240
+ var h, Y, oe, j, me, ue, pe;
1241
+ return [
1242
+ n("div", $o, [
1243
+ e[17] || (e[17] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point ", -1)),
1244
+ n("div", Do, $(((oe = (Y = (h = y.member.collection) == null ? void 0 : h.COIN) == null ? void 0 : Y[0]) == null ? void 0 : oe.balance) ?? 0), 1)
1245
+ ]),
1246
+ n("div", No, [
1247
+ e[18] || (e[18] = n("div", { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, " Point(s) to be expired in 30 days ", -1)),
1248
+ n("div", Bo, $(((pe = (ue = (me = (j = y.member.collection) == null ? void 0 : j.COIN) == null ? void 0 : me[0]) == null ? void 0 : ue.expiryBalance) == null ? void 0 : pe.reduce(
1249
+ (Q, Z) => Z.expiredAt && t(C)(Z.expiredAt).isAfter(t(C)()) && t(C)(Z.expiredAt).isBefore(t(C)().add(30, "days")) ? Q + Z.amount : Q,
1250
+ 0
1251
+ )) ?? 0), 1)
1252
+ ]),
1253
+ n("div", Yo, [
1254
+ _(B, {
1255
+ label: "Add point",
1256
+ icon: "add",
1257
+ variant: "plain",
1258
+ onClick: e[3] || (e[3] = (Q) => W("coin", "send"))
1259
+ }),
1260
+ _(B, {
1261
+ label: "Deduct point",
1262
+ icon: "remove",
1263
+ variant: "plain",
1264
+ onClick: e[4] || (e[4] = (Q) => W("coin", "deduct"))
1265
+ })
1266
+ ])
1267
+ ];
1268
+ }),
1269
+ _: 1
1270
+ })
1271
+ ])) : t(F).value == "voucher" ? (u(), U(Kt, {
1272
+ key: 2,
1273
+ member: m.member
1274
+ }, null, 8, ["member"])) : t(F).value == "mission" ? (u(), U(Gt, {
1275
+ key: 3,
1276
+ member: m.member
1277
+ }, null, 8, ["member"])) : t(F).value == "game" ? (u(), U(Ht, {
1278
+ key: 4,
1279
+ member: m.member
1280
+ }, null, 8, ["member"])) : le("", !0)
1281
+ ])
1282
+ ]),
1283
+ _: 1
1284
+ }, 8, ["modelValue"]);
1285
+ };
1286
+ }
1287
+ }), Oo = { class: "flex items-center justify-end" }, Cn = /* @__PURE__ */ be({
1288
+ __name: "MemberList",
1289
+ setup(y) {
1290
+ const k = Xe(), p = Ie(), x = Ke(), { minor: s } = qe, o = We(), g = [
1291
+ {
1292
+ header: "Name",
1293
+ enableSorting: !0,
1294
+ accessorKey: "name",
1295
+ cell(r) {
1296
+ return Mt(r.row.original);
1297
+ }
1298
+ },
1299
+ {
1300
+ header: "Phone",
1301
+ enableSorting: !0,
1302
+ accessorKey: "phoneNumber"
1303
+ },
1304
+ {
1305
+ accessorFn: (r) => C(he(r._id.toString())).format("D MMM YYYY"),
1306
+ header: "Customer Since",
1307
+ accessorKey: "_id",
1308
+ id: "_id"
1309
+ },
1310
+ {
1311
+ accessorKey: "collection_TIER_0_balance",
1312
+ header: "Tier",
1313
+ enableSorting: !0,
1314
+ cell(r) {
1315
+ return Tt(
1316
+ r.row.original,
1317
+ p.sortedTiers
1318
+ );
1319
+ }
1320
+ },
1321
+ {
1322
+ header: "Title",
1323
+ enableSorting: !1,
1324
+ cell(r) {
1325
+ return kt(
1326
+ r.row.original,
1327
+ p.sortedTitles
1328
+ );
1329
+ }
1330
+ },
1331
+ {
1332
+ accessorKey: "collection_CREDIT_0_balance",
1333
+ accessorFn: (r) => {
1334
+ var i, S, T;
1335
+ return ee(((T = (S = (i = r.collection) == null ? void 0 : i.CREDIT) == null ? void 0 : S[0]) == null ? void 0 : T.balance) ?? 0, 2);
1336
+ },
1337
+ header: "Credit(s)",
1338
+ enableSorting: !0
1339
+ },
1340
+ {
1341
+ accessorKey: "collection_POINT_0_balance",
1342
+ accessorFn: (r) => {
1343
+ var i, S, T;
1344
+ return ee(((T = (S = (i = r.collection) == null ? void 0 : i.POINT) == null ? void 0 : S[0]) == null ? void 0 : T.balance) ?? 0, 2);
1345
+ },
1346
+ header: "Experience(s)",
1347
+ enableSorting: !0
1348
+ },
1349
+ {
1350
+ accessorKey: "collection_COIN_0_balance",
1351
+ accessorFn: (r) => {
1352
+ var i, S, T;
1353
+ return ee(((T = (S = (i = r.collection) == null ? void 0 : i.COIN) == null ? void 0 : S[0]) == null ? void 0 : T.balance) ?? 0, 2);
1354
+ },
1355
+ header: "Point(s)",
1356
+ enableSorting: !0
1357
+ },
1358
+ {
1359
+ accessorFn: (r) => {
1360
+ var i;
1361
+ return ((i = r.stats) == null ? void 0 : i.visitCount) ?? 0;
1362
+ },
1363
+ header: "Total visit",
1364
+ accessorKey: "stats.visitCount",
1365
+ id: "stats.visitCount"
1366
+ },
1367
+ {
1368
+ accessorFn: (r) => {
1369
+ var i;
1370
+ return (i = r.stats) == null ? void 0 : i.lastVisit;
1371
+ },
1372
+ sortingFn: (r, i) => {
1373
+ var S, T;
1374
+ return new Date((S = r.original.stats) == null ? void 0 : S.lastVisit).getTime() - new Date((T = i.original.stats) == null ? void 0 : T.lastVisit).getTime();
1375
+ },
1376
+ id: "stats.lastVisit",
1377
+ header: "Last visit",
1378
+ cell(r) {
1379
+ var i, S;
1380
+ return K("div", { class: "flex items-center justify-end gap-4" }, [
1381
+ K(
1382
+ "span",
1383
+ (i = r.row.original.stats) != null && i.lastVisit ? C((S = r.row.original.stats) == null ? void 0 : S.lastVisit).fromNow() : "NA"
1384
+ ),
1385
+ K(
1386
+ ve.FmTooltip,
1387
+ {
1388
+ content: C(r.row.original.stats.lastVisit).format(
1389
+ "D MMM YYYY - hh:mmA"
1390
+ )
1391
+ },
1392
+ [K(ve.FmIcon, { name: "info", outline: !0, size: "sm" })]
1393
+ )
1394
+ ]);
1395
+ }
1396
+ },
1397
+ {
1398
+ id: "actions",
1399
+ cell(r) {
1400
+ return K(
1401
+ ve.FmMenu,
1402
+ {
1403
+ placement: "bottom-end",
1404
+ onClick: (i) => {
1405
+ i.stopPropagation();
1406
+ }
1407
+ },
1408
+ {
1409
+ "menu-button": () => K(ve.FmButton, { icon: "more_vert", variant: "tertiary" }),
1410
+ default: () => [
1411
+ K(ve.FmMenuItem, {
1412
+ label: "Transaction details",
1413
+ onClick: async (i) => {
1414
+ i.stopPropagation(), await re(r.row.original._id);
1415
+ }
1416
+ })
1417
+ ]
1418
+ }
1419
+ );
1420
+ }
1421
+ }
1422
+ ], { tableMeta: d, rowData: w, onSort: m, debouncedFetchData: v, onSearch: I } = Ge(fe.read), N = G(), L = G(!1), P = G(), ce = H(() => x.locations.map((r) => ({
1423
+ label: r.name,
1424
+ value: r._id
1425
+ })));
1426
+ async function ae() {
1427
+ P.value = await fe.readById(
1428
+ P.value._id.toString()
1429
+ ), L.value = !0;
1430
+ }
1431
+ async function W() {
1432
+ await v(), L.value = !1;
1433
+ }
1434
+ async function re(r) {
1435
+ await o.push({
1436
+ name: Je["$connect-LOYALTY_MEMBER_TRANSACTIONS"],
1437
+ params: { id: r }
1438
+ });
1439
+ }
1440
+ const f = {
1441
+ sortBy: "_id",
1442
+ descending: !1,
1443
+ rowsPerPage: 1e3
1444
+ };
1445
+ function c(r) {
1446
+ const i = C(r);
1447
+ return i.isValid() ? i.format("DD/MM/YYYY") : "";
1448
+ }
1449
+ async function M() {
1450
+ const r = new lt(), i = f.rowsPerPage;
1451
+ await s(
1452
+ async () => {
1453
+ var O, E, R, te, z, F, J, a, e, b, D, B, X, se, de, ye, h, Y, oe, j, me, ue, pe, Q, Z;
1454
+ let S, T = !0;
1455
+ for (; T; ) {
1456
+ const we = await fe.readCursor({
1457
+ limit: i,
1458
+ sortBy: f.sortBy,
1459
+ descending: f.descending,
1460
+ ...S ? { cursor: S } : {}
1461
+ });
1462
+ if (!we.resources.length)
1463
+ break;
1464
+ for (const l of we.resources) {
1465
+ const Qe = (O = it.parseOneAddress(
1466
+ l == null ? void 0 : l.email
1467
+ )) != null && O.domain.includes("feedmepos.com") ? void 0 : l.email, Ze = (R = ((E = l == null ? void 0 : l.collection) == null ? void 0 : E.TITLE) || []) == null ? void 0 : R.reduce(
1468
+ (ne, ge) => {
1469
+ var Se, Ce;
1470
+ const _e = (Ce = (Se = p.sortedTitles) == null ? void 0 : Se.find(
1471
+ (Fe) => Fe._id === ge.collectible
1472
+ )) == null ? void 0 : Ce.name;
1473
+ return !_e || ge.balance <= 0 || ne.push(_e), ne;
1474
+ },
1475
+ []
1476
+ ), et = (p.sortedTitles || []).reduce(
1477
+ (ne, ge) => {
1478
+ var Se, Ce, Fe, Ne;
1479
+ const _e = (Ne = (Fe = (Ce = (((Se = l == null ? void 0 : l.collection) == null ? void 0 : Se.TITLE) || []).find(
1480
+ (nt) => nt.collectible === ge._id
1481
+ )) == null ? void 0 : Ce.expiryBalance) == null ? void 0 : Fe[0]) == null ? void 0 : Ne.expiredAt;
1482
+ return ne[ge.name] = _e ? C(_e).format("DD/MM/YYYY") : "", ne;
1483
+ },
1484
+ {}
1485
+ ), tt = ((F = (z = (te = l.collection) == null ? void 0 : te.CREDIT) == null ? void 0 : z.at(0)) == null ? void 0 : F.balance) || 0, $e = ((b = (e = (a = (J = l.collection) == null ? void 0 : J.CREDIT) == null ? void 0 : a.at(0)) == null ? void 0 : e.expiryBalance) == null ? void 0 : b.reduce(
1486
+ (ne, ge) => ne + ge.amount,
1487
+ 0
1488
+ )) || 0, De = ee(tt, 2), ot = {
1489
+ ID: l._id.toString(),
1490
+ Name: ((D = l.name) == null ? void 0 : D.trim()) || "",
1491
+ Phone: ((B = l == null ? void 0 : l.phoneNumber) == null ? void 0 : B.trim()) || "",
1492
+ Email: Qe || "",
1493
+ Gender: l.gender || "",
1494
+ CardNo: l.cardNo || "",
1495
+ Birthday: l != null && l.birthday ? c(l == null ? void 0 : l.birthday) : "",
1496
+ Credit: (Number(De) - Number($e)).toFixed(2),
1497
+ FreeCredit: Number($e.toFixed(2)),
1498
+ TotalCredit: Number(De),
1499
+ Exp: l != null && l.collection ? ((de = (se = (X = l.collection) == null ? void 0 : X.POINT) == null ? void 0 : se.at(0)) == null ? void 0 : de.balance) ?? 0 : 0,
1500
+ Point: l != null && l.collection ? ((Y = (h = (ye = l.collection) == null ? void 0 : ye.COIN) == null ? void 0 : h.at(0)) == null ? void 0 : Y.balance) ?? 0 : 0,
1501
+ Tier: l != null && l.collection ? ((me = (j = (oe = l.collection) == null ? void 0 : oe.TIER) == null ? void 0 : j.at(0)) == null ? void 0 : me.balance) ?? 0 : 0,
1502
+ Titles: Ze.join(","),
1503
+ ...et,
1504
+ TotalTransaction: l.stats.visitCount,
1505
+ AvgSpent: Ft(Number(l.stats.avgBillSize || 0)).toFormat(
1506
+ !1
1507
+ ),
1508
+ TotalSpent: l.stats.avgBillSize * l.stats.visitCount,
1509
+ LastVisit: c(l.stats.lastVisit),
1510
+ Feedback: ((ue = l.stats) == null ? void 0 : ue.feedbackCount) || 0,
1511
+ LastSeasonTierEarned: ((pe = l.stats) == null ? void 0 : pe.lastSeasonTierEarned) || 0,
1512
+ LastSeasonPointEarned: ((Q = l.stats) == null ? void 0 : Q.lastSeasonPointEarned) || 0,
1513
+ JoinedAt: c(l.joinAt || he(l._id)),
1514
+ JoinedAtLocation: l.location && ((Z = ce.value.find((ne) => ne.value == l.location)) == null ? void 0 : Z.label) || "-",
1515
+ VisitFrequency: `${Number(
1516
+ Math.ceil(l.stats.avgVisitFrequency).toFixed(0)
1517
+ )}`
1518
+ };
1519
+ r.addRecord(ot);
1520
+ }
1521
+ S = we.meta.nextCursor ?? void 0, T = we.meta.hasNext && !!S;
1522
+ }
1523
+ await ct(
1524
+ r.buildExcel(),
1525
+ `members-${(/* @__PURE__ */ new Date()).toISOString()}.xlsx`,
1526
+ {
1527
+ bookType: "xlsx",
1528
+ bookSST: !1,
1529
+ type: "array"
1530
+ }
1531
+ );
1532
+ },
1533
+ {
1534
+ message: "Exporting member...",
1535
+ successMessage: "Member exported successfully"
1536
+ }
1537
+ );
1538
+ }
1539
+ return je(async () => {
1540
+ await p.readMembership(), await x.readLocations(), await k.read(), await x.readLocations(), await v();
1541
+ }), (r, i) => {
1542
+ const S = V("FmSearch"), T = V("FmButton"), O = V("FmSnackbar");
1543
+ return u(), A("div", null, [
1544
+ n("div", Oo, [
1545
+ _(S, {
1546
+ class: "mt-4",
1547
+ modelValue: t(d).searchValue,
1548
+ "onUpdate:modelValue": [
1549
+ i[0] || (i[0] = (E) => t(d).searchValue = E),
1550
+ t(I)
1551
+ ],
1552
+ placeholder: "Search",
1553
+ collapsible: ""
1554
+ }, null, 8, ["modelValue", "onUpdate:modelValue"]),
1555
+ _(T, {
1556
+ icon: "ios_share",
1557
+ variant: "tertiary",
1558
+ onClick: M
1559
+ })
1560
+ ]),
1561
+ Re(_(O, {
1562
+ "z-index": 0,
1563
+ class: "!max-w-full my-16",
1564
+ title: "Info",
1565
+ description: "Current list is not up to date, please refresh table for latest data.",
1566
+ variant: "info",
1567
+ dismissable: "",
1568
+ onOnDismiss: i[1] || (i[1] = (E) => L.value = !1),
1569
+ action: "Refresh",
1570
+ onOnAction: W
1571
+ }, null, 512), [
1572
+ [Le, t(L)]
1573
+ ]),
1574
+ _(He, {
1575
+ loading: t(d).isLoading,
1576
+ "row-data": t(w),
1577
+ "row-count": t(d).totalRows,
1578
+ "column-defs": g,
1579
+ "shrink-at": !1,
1580
+ "page-count": t(d).pageCount,
1581
+ "page-index": t(d).pageIndex,
1582
+ "page-size": t(d).pageSize,
1583
+ onSortChange: t(m),
1584
+ onPageChange: i[2] || (i[2] = (E) => t(v)({ pageSize: E.pageSize, pageIndex: E.pageIndex })),
1585
+ onRowClick: i[3] || (i[3] = (E) => {
1586
+ var R;
1587
+ P.value = E.original, (R = t(N)) == null || R.showSheet();
1588
+ })
1589
+ }, null, 8, ["loading", "row-data", "row-count", "page-count", "page-index", "page-size", "onSortChange"]),
1590
+ t(P) ? (u(), U(Po, {
1591
+ key: 0,
1592
+ ref_key: "sheetRef",
1593
+ ref: N,
1594
+ member: t(P),
1595
+ "onUpdate:member": ae
1596
+ }, null, 8, ["member"])) : le("", !0)
1597
+ ]);
1598
+ };
1599
+ }
1600
+ });
1601
+ export {
1602
+ Cn as default
1603
+ };