@feedmepos/mf-connect 0.1.38-beta.74 → 0.1.38-beta.75

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