@feedmepos/mf-hrm-portal 2.1.0-dev.2 → 2.1.0

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 (43) hide show
  1. package/dist/AuditLogList-Rrg_dNYp.js +1149 -0
  2. package/dist/{ConditionFormHost.vue_vue_type_script_setup_true_lang-BYHKFwRm.js → ConditionFormHost.vue_vue_type_script_setup_true_lang-CJEkZVoJ.js} +104 -100
  3. package/dist/{EmployeeList-KvjoGI87.js → EmployeeList-CckyPQlP.js} +9 -10
  4. package/dist/{Main-Dn1TfDRj.js → Main-BUvX24j0.js} +9 -9
  5. package/dist/{Main-BLh16xRg.js → Main-BdPIZkik.js} +4 -4
  6. package/dist/{Main-D3TSdtSE.js → Main-C4cSWAts.js} +6 -6
  7. package/dist/{PermissionSetList-Ds69m9UU.js → PermissionSetList-CP8J9Prx.js} +6 -6
  8. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-C7X69eQq.js +4121 -0
  9. package/dist/{PortalUserSearcher.vue_vue_type_style_index_0_scoped_a439fdd8_lang-BHxCP_uW.js → PortalUserSearcher.vue_vue_type_style_index_0_scoped_79737e32_lang-ZAEcrK9Q.js} +2 -1
  10. package/dist/{RoleList-v8McRCnz.js → RoleList-BHvGGF82.js} +8 -8
  11. package/dist/TeamMemberList-DPkocw3U.js +1185 -0
  12. package/dist/{TimesheetList-C1OWa6kf.js → TimesheetList-mOWHmWwo.js} +6 -6
  13. package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-CLu9gzzi.js → TimesheetList.vue_vue_type_style_index_0_scoped_2c7a177a_lang-CpUHcGUj.js} +2 -2
  14. package/dist/{app-CJouCBgi.js → app-DnaRDAJY.js} +394 -674
  15. package/dist/app.js +1 -1
  16. package/dist/{dayjs.min-DUugkgDM.js → dayjs.min-NAaPKajp.js} +1 -1
  17. package/dist/{employee-D5rEVmge.js → employee-CILPIL-b.js} +3 -3
  18. package/dist/{iteration-QRRNYlps.js → iteration-B7PEDIWb.js} +3 -3
  19. package/dist/{lodash-BlZhpHhM.js → lodash-CgE5OnVa.js} +1 -1
  20. package/dist/{rule-Dy7eMChN.js → rule-BmSYQ3Op.js} +17 -13
  21. package/dist/src/api/audit-log/index.d.ts +0 -6
  22. package/dist/src/composables/useBasePermission.d.ts +1 -1
  23. package/dist/src/helpers/filter.d.ts +15 -0
  24. package/dist/src/helpers/permission-reconcile.d.ts +15 -0
  25. package/dist/src/helpers/permission-reconcile.test.d.ts +1 -0
  26. package/dist/src/helpers/permission-set.d.ts +4 -2
  27. package/dist/src/types/audit-log.d.ts +1 -1
  28. package/dist/src/views/audit-log/locales/index.d.ts +0 -296
  29. package/dist/src/views/team/locales/index.d.ts +4 -0
  30. package/dist/style.css +1 -1
  31. package/dist/tsconfig.app.tsbuildinfo +1 -1
  32. package/dist/{useAppStore-CtMoad7V.js → useAppStore-DMmL9JnJ.js} +1 -1
  33. package/dist/useDebounce-CWb5QR9G.js +28 -0
  34. package/dist/{useLoading-CNqlchYO.js → useLoading-D56E7ykF.js} +1 -1
  35. package/dist/{useReportPermissions-C5wGC9bf.js → useReportPermissions-BKj02rVj.js} +3 -3
  36. package/package.json +2 -2
  37. package/dist/AuditLogList-AGlAsWwd.js +0 -1608
  38. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-Bk6ub3Dv.js +0 -4030
  39. package/dist/Skeleton.vue_vue_type_script_setup_true_lang-B4PxNMwq.js +0 -16
  40. package/dist/TeamMemberList-BYQnNIhT.js +0 -1169
  41. package/dist/src/views/audit-log/event-line.d.ts +0 -13
  42. package/dist/src/views/audit-log/snapshot-diff.d.ts +0 -11
  43. package/dist/useDebounce-B8ZPVS5C.js +0 -15
@@ -0,0 +1,1185 @@
1
+ import { defineComponent as we, resolveComponent as V, createElementBlock as D, openBlock as h, createElementVNode as m, createVNode as c, toDisplayString as R, unref as o, computed as k, ref as v, createCommentVNode as K, withCtx as ie, createBlock as z, watch as pe, Fragment as De, renderList as us, withKeys as qe, withModifiers as Fe, nextTick as ms, onUnmounted as ds, h as cs, createTextVNode as ps } from "vue";
2
+ import { useI18n as Ie, useCoreStore as Oe, baseClientInstance as Ke } from "@feedmepos/mf-common";
3
+ import { useSnackbar as He, useDialog as es, useBreakpoints as ss, components as Be } from "@feedmepos/ui-library";
4
+ import { u as fs, _ as vs } from "./useDebounce-CWb5QR9G.js";
5
+ import { _ as bs, S as be } from "./SelectFilter-ATOm0hdn.js";
6
+ import { v as ze, m as hs, b as ys, _ as _s, a as gs } from "./app-DnaRDAJY.js";
7
+ import { u as xs, _ as Ss } from "./useDiscardConfirm-DPhEV6v0.js";
8
+ import { _ as Us } from "./TableEmptyState.vue_vue_type_script_setup_true_lang-Ci_MVqGK.js";
9
+ import { u as Fs } from "./useLoading-D56E7ykF.js";
10
+ import { l as Se } from "./lodash-CgE5OnVa.js";
11
+ import { g as Ge, d as fe, u as ts } from "./iteration-B7PEDIWb.js";
12
+ import { u as as, c as je, d as We, m as Ae, i as ls, p as Je, j as Vs, k as Xe, l as Ze, n as ws, o as Is, s as Ps, q as ks, v as Rs, t as Ue } from "./rule-BmSYQ3Op.js";
13
+ import { u as os } from "./useAppStore-DMmL9JnJ.js";
14
+ import { u as ns, i as $s } from "./PortalUserSearcher.vue_vue_type_style_index_0_scoped_79737e32_lang-ZAEcrK9Q.js";
15
+ import { _ as Cs } from "./PortalPermissionEditor.vue_vue_type_script_setup_true_lang-C7X69eQq.js";
16
+ var ye = /* @__PURE__ */ ((i) => (i.Update = "Update", i.Remove = "Remove", i))(ye || {});
17
+ const Ve = "__unassigned__";
18
+ function Qe(i) {
19
+ if (!(i != null && i.length) || i[0] === Ve) return i;
20
+ const $ = i.filter((n) => n !== Ve);
21
+ return $.length === i.length ? i : [Ve, ...$];
22
+ }
23
+ const Ms = { class: "w-full flex flex-col gap-16" }, Ns = { class: "flex items-center gap-16" }, As = { class: "space-y-4 min-w-0 flex-1" }, Ds = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, Os = { class: "fm-typo-en-body-lg-600 truncate" }, Es = { class: "w-full flex gap-16 items-center" }, Bs = { class: "flex-1 flex flex-col gap-4 min-w-0" }, js = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, Ls = { class: "fm-typo-en-body-lg-600 truncate" }, Ts = { class: "flex-1 flex flex-col gap-4 min-w-0" }, qs = { class: "text-fm-color-typo-secondary fm-typo-en-body-lg-400" }, Ks = { class: "fm-typo-en-body-lg-600 truncate" }, zs = /* @__PURE__ */ we({
24
+ __name: "MemberInfo",
25
+ props: {
26
+ data: {}
27
+ },
28
+ setup(i) {
29
+ const { t: $ } = Ie();
30
+ return (n, a) => {
31
+ const f = V("FmAvatar");
32
+ return h(), D("div", Ms, [
33
+ m("div", Ns, [
34
+ c(f, {
35
+ size: "xl",
36
+ name: i.data.name
37
+ }, null, 8, ["name"]),
38
+ m("div", As, [
39
+ m("p", Ds, R(o($)("team.memberForm.memberInfo.memberName")), 1),
40
+ m("p", Os, R(i.data.name || "--"), 1)
41
+ ])
42
+ ]),
43
+ m("div", Es, [
44
+ m("div", Bs, [
45
+ m("p", js, R(o($)("team.memberForm.memberInfo.mobileNumber")), 1),
46
+ m("p", Ls, R(i.data.phoneNumber || "--"), 1)
47
+ ]),
48
+ m("div", Ts, [
49
+ m("p", qs, R(o($)("team.memberForm.memberInfo.emailAddress")), 1),
50
+ m("p", Ks, R(i.data.email || "--"), 1)
51
+ ])
52
+ ])
53
+ ]);
54
+ };
55
+ }
56
+ }), Ye = {
57
+ async readPermissionUserByPhoneNo(i) {
58
+ var n;
59
+ const { currentBusiness: $ } = Oe();
60
+ return Ge(
61
+ await Ke("/").get(`/user/b/${(n = $.value) == null ? void 0 : n._id}/phone/${i}`)
62
+ );
63
+ },
64
+ async readPermissionUserByEmail(i) {
65
+ var n;
66
+ const { currentBusiness: $ } = Oe();
67
+ return Ge(
68
+ await Ke("/").get(`/user/b/${(n = $.value) == null ? void 0 : n._id}/email/${i}`)
69
+ );
70
+ }
71
+ }, Gs = { class: "flex flex-col gap-24 w-full" }, Ws = {
72
+ key: 0,
73
+ class: "flex flex-col gap-8"
74
+ }, Js = { class: "user-info-icon user-info-icon--lg" }, Xs = { class: "flex-1 overflow-hidden" }, Zs = { class: "profile-displayName" }, Qs = { class: "profile-email" }, Ys = { class: "profile-phone" }, Hs = { key: 2 }, et = /* @__PURE__ */ we({
75
+ __name: "PortalUserSearcher",
76
+ emits: ["invite"],
77
+ setup(i, { emit: $ }) {
78
+ const n = $, { t: a } = Ie(), f = He(), O = Oe(), { supportedCountries: w, ready: C } = ns(), le = k(() => {
79
+ var F;
80
+ const U = (F = O.currentCountry.value) == null ? void 0 : F.toUpperCase();
81
+ return U && $s(U) ? U : void 0;
82
+ }), x = v("phone"), S = v(""), p = v(""), b = v();
83
+ async function ue() {
84
+ if (!S.value && !p.value) {
85
+ f.open({
86
+ type: "error",
87
+ title: a("team.memberForm.searchUser.emptyError")
88
+ });
89
+ return;
90
+ }
91
+ const U = x.value === "phone" ? await Ye.readPermissionUserByPhoneNo(S.value.replace(/ /g, "")) : await Ye.readPermissionUserByEmail(p.value);
92
+ U || f.open({
93
+ type: "error",
94
+ title: a("team.memberForm.searchUser.userNotFound")
95
+ }), b.value = U;
96
+ }
97
+ const G = k(() => {
98
+ var l;
99
+ let U = ((l = b.value) == null ? void 0 : l.displayName) ?? "";
100
+ U || (U = "Feed Me");
101
+ const [F, r] = U.split(" ");
102
+ return r ? `${F[0]}${r[0]}` : F.slice(0, 2);
103
+ }), A = v(!1);
104
+ function M(U) {
105
+ n("invite", U), A.value = !0;
106
+ }
107
+ function W() {
108
+ A.value = !1;
109
+ }
110
+ return (U, F) => {
111
+ var E, B, L;
112
+ const r = V("FmRadio"), l = V("FmPhoneNumber"), y = V("FmCircularProgress"), I = V("FmTextField"), Z = V("FmRadioGroup"), J = V("FmButton");
113
+ return h(), D("div", Gs, [
114
+ A.value ? K("", !0) : (h(), D("div", Ws, [
115
+ c(Z, {
116
+ modelValue: x.value,
117
+ "onUpdate:modelValue": F[2] || (F[2] = (u) => x.value = u)
118
+ }, {
119
+ default: ie(() => [
120
+ c(r, {
121
+ value: "phone",
122
+ label: o(a)("team.memberForm.searchUser.phoneNumber")
123
+ }, null, 8, ["label"]),
124
+ x.value === "phone" && o(C) ? (h(), z(l, {
125
+ key: 0,
126
+ modelValue: S.value,
127
+ "onUpdate:modelValue": F[0] || (F[0] = (u) => S.value = u),
128
+ "default-country": le.value,
129
+ "extra-country-codes": o(w),
130
+ class: "ml-8"
131
+ }, null, 8, ["modelValue", "default-country", "extra-country-codes"])) : x.value === "phone" ? (h(), z(y, {
132
+ key: 1,
133
+ class: "ml-8"
134
+ })) : K("", !0),
135
+ c(r, {
136
+ value: "email",
137
+ label: o(a)("team.memberForm.searchUser.email")
138
+ }, null, 8, ["label"]),
139
+ x.value === "email" ? (h(), z(I, {
140
+ key: 2,
141
+ modelValue: p.value,
142
+ "onUpdate:modelValue": F[1] || (F[1] = (u) => p.value = u),
143
+ placeholder: o(a)("team.memberForm.searchUser.emailPlaceholder"),
144
+ class: "ml-8"
145
+ }, null, 8, ["modelValue", "placeholder"])) : K("", !0)
146
+ ]),
147
+ _: 1
148
+ }, 8, ["modelValue"]),
149
+ c(J, {
150
+ label: o(a)("team.memberForm.searchUser.search"),
151
+ variant: "secondary",
152
+ onClick: ue
153
+ }, null, 8, ["label"])
154
+ ])),
155
+ b.value ? (h(), D("div", {
156
+ key: 1,
157
+ class: "profile-menu--profile cursor-pointer hover:bg-fm-color-opacity-sm",
158
+ onClick: F[3] || (F[3] = (u) => M(b.value))
159
+ }, [
160
+ m("div", Js, R(G.value), 1),
161
+ m("div", Xs, [
162
+ m("p", Zs, R((E = b.value) == null ? void 0 : E.displayName), 1),
163
+ m("p", Qs, R((B = b.value) == null ? void 0 : B.email), 1),
164
+ m("p", Ys, R((L = b.value) == null ? void 0 : L.phoneNumber), 1)
165
+ ])
166
+ ])) : K("", !0),
167
+ A.value ? (h(), D("div", Hs, [
168
+ c(J, {
169
+ label: o(a)("team.memberForm.searchUser.changeUser"),
170
+ variant: "secondary",
171
+ onClick: W
172
+ }, null, 8, ["label"])
173
+ ])) : K("", !0)
174
+ ]);
175
+ };
176
+ }
177
+ }), st = /* @__PURE__ */ bs(et, [["__scopeId", "data-v-79737e32"]]), tt = { class: "flex flex-col gap-40" }, at = { class: "flex items-center" }, lt = { class: "flex-1 flex flex-col" }, ot = { class: "fm-typo-en-title-sm-600" }, nt = { class: "fm-typo-en-body-md-400 text-fm-color-typo-secondary" }, rt = { class: "flex flex-row gap-16" }, it = { class: "flex flex-col gap-8" }, ut = { class: "fm-typo-en-body-lg-400" }, mt = { class: "space-y-16 rounded-lg border border-fm-color-neutral-gray-200 p-16" }, dt = { class: "fm-typo-en-title-sm-600" }, ct = { class: "space-y-16" }, pt = { class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] gap-16" }, ft = { class: "text-sm font-semibold text-fm-color-typo-primary" }, vt = { class: "text-sm font-semibold text-fm-color-typo-primary" }, bt = { class: "flex justify-self-end" }, ht = ["aria-label", "onClick", "onKeydown"], Le = 4, yt = /* @__PURE__ */ we({
178
+ __name: "TeamMemberMasterUser",
179
+ props: {
180
+ modelValue: {
181
+ type: Object,
182
+ default: void 0
183
+ },
184
+ fallbackName: {
185
+ type: String,
186
+ required: !0
187
+ },
188
+ fallbackPasscode: {
189
+ type: String,
190
+ default: void 0
191
+ },
192
+ restaurants: {
193
+ type: Array,
194
+ required: !0
195
+ },
196
+ roles: {
197
+ type: Array,
198
+ required: !0
199
+ }
200
+ },
201
+ emits: ["update:model-value"],
202
+ setup(i, { emit: $ }) {
203
+ const n = i, a = $, { t: f } = Ie(), O = v(!0), w = v([]);
204
+ function C() {
205
+ return { restaurantId: "", roleId: "" };
206
+ }
207
+ const le = k(
208
+ () => {
209
+ var r;
210
+ return ((r = n.modelValue) == null ? void 0 : r.roles.map((l) => l.restaurantId).filter(Boolean)) ?? [];
211
+ }
212
+ );
213
+ function x(r) {
214
+ r ? n.modelValue || a("update:model-value", {
215
+ code: "",
216
+ name: n.fallbackName,
217
+ roles: [C()],
218
+ passcode: n.fallbackPasscode || ""
219
+ }) : a("update:model-value", null);
220
+ }
221
+ function S(r, l) {
222
+ if (!n.modelValue || r === "passcode" && n.modelValue.passcode === l) return;
223
+ const y = fe(n.modelValue);
224
+ y[r] = l, a("update:model-value", y);
225
+ }
226
+ function p(r = "") {
227
+ return n.restaurants.filter((l) => l.managable || l._id === r).map((l) => ({
228
+ label: `${l.profile.code ? `${l.profile.code} - ` : ""}${l.profile.name}`,
229
+ value: l._id,
230
+ disabled: le.value.includes(l._id) && l._id !== r
231
+ }));
232
+ }
233
+ function b(r = "") {
234
+ return n.roles.map((l) => ({
235
+ label: l.label,
236
+ value: l.value,
237
+ disabled: !!l.disabled && l.value !== r
238
+ }));
239
+ }
240
+ function ue(r, l) {
241
+ var E, B, L;
242
+ if (!n.modelValue) return;
243
+ const y = n.modelValue.roles.length > 0 ? [...n.modelValue.roles] : [C()], I = ((E = y[r]) == null ? void 0 : E.roleId) ?? "", Z = b(I), J = ((B = Z.find((u) => u.value === I && !u.disabled)) == null ? void 0 : B.value) ?? ((L = Z.find((u) => !u.disabled)) == null ? void 0 : L.value) ?? "";
244
+ y[r] = { restaurantId: l, roleId: J }, S("roles", y);
245
+ }
246
+ function G(r, l) {
247
+ var I;
248
+ if (!n.modelValue) return;
249
+ const y = n.modelValue.roles.length > 0 ? [...n.modelValue.roles] : [C()];
250
+ y[r] = {
251
+ restaurantId: ((I = y[r]) == null ? void 0 : I.restaurantId) ?? "",
252
+ roleId: l
253
+ }, S("roles", y);
254
+ }
255
+ function A() {
256
+ n.modelValue && S("roles", [...n.modelValue.roles, C()]);
257
+ }
258
+ function M(r) {
259
+ if (!n.modelValue) return;
260
+ const l = n.modelValue.roles.length > 0 ? [...n.modelValue.roles] : [C()];
261
+ S(
262
+ "roles",
263
+ l.length === 1 ? [C()] : l.filter((y, I) => I !== r)
264
+ );
265
+ }
266
+ const W = k(() => {
267
+ if (!n.modelValue) return !1;
268
+ const r = n.restaurants.some(
269
+ (y) => y.managable && !le.value.includes(y._id)
270
+ ), l = n.modelValue.roles.every(
271
+ (y) => y.restaurantId && y.roleId
272
+ );
273
+ return r && l;
274
+ });
275
+ function U() {
276
+ O.value && (O.value = !1, w.value = [], S("passcode", ""));
277
+ }
278
+ pe(
279
+ () => {
280
+ var r;
281
+ return (r = n.modelValue) == null ? void 0 : r.passcode;
282
+ },
283
+ (r) => {
284
+ r && r.length === Le ? (w.value = r.split(""), O.value = !0) : (w.value = [], O.value = !1);
285
+ },
286
+ { immediate: !0 }
287
+ ), pe(
288
+ () => {
289
+ var r;
290
+ return (r = n.modelValue) == null ? void 0 : r.roles;
291
+ },
292
+ (r) => {
293
+ n.modelValue && (!r || r.length === 0) && S("roles", [C()]);
294
+ },
295
+ { immediate: !0, deep: !0 }
296
+ );
297
+ const F = k({
298
+ get: () => {
299
+ var r;
300
+ return ((r = n.modelValue) == null ? void 0 : r.roles) ?? [];
301
+ },
302
+ set: () => {
303
+ }
304
+ });
305
+ return (r, l) => {
306
+ const y = V("FmSwitch"), I = V("FmTextField"), Z = V("FmPinField"), J = V("FmFormGroup"), E = V("FmSelect"), B = V("FmIcon"), L = V("FmButton");
307
+ return h(), D("div", tt, [
308
+ m("div", at, [
309
+ m("div", lt, [
310
+ m("div", ot, R(o(f)("team.memberForm.masterUser.title")), 1),
311
+ m("div", nt, R(o(f)("team.memberForm.masterUser.sublabel")), 1)
312
+ ]),
313
+ m("div", null, [
314
+ c(y, {
315
+ "model-value": !!i.modelValue,
316
+ value: "master-user",
317
+ "onUpdate:modelValue": x
318
+ }, null, 8, ["model-value"])
319
+ ])
320
+ ]),
321
+ i.modelValue ? (h(), D(De, { key: 0 }, [
322
+ m("div", rt, [
323
+ c(I, {
324
+ "model-value": i.modelValue.code,
325
+ label: o(f)("team.memberForm.masterUser.code"),
326
+ "onUpdate:modelValue": l[0] || (l[0] = (u) => S("code", u))
327
+ }, null, 8, ["model-value", "label"]),
328
+ c(I, {
329
+ "model-value": i.modelValue.name,
330
+ class: "w-full",
331
+ label: o(f)("team.memberForm.masterUser.name"),
332
+ rules: [(u) => !!u || o(f)("team.memberForm.masterUser.nameEmptyError")],
333
+ "onUpdate:modelValue": l[1] || (l[1] = (u) => S("name", u))
334
+ }, null, 8, ["model-value", "label", "rules"])
335
+ ]),
336
+ m("div", it, [
337
+ m("div", ut, R(o(f)("team.memberForm.masterUser.passcode")), 1),
338
+ c(J, {
339
+ modelValue: w.value,
340
+ "onUpdate:modelValue": l[4] || (l[4] = (u) => w.value = u),
341
+ rules: [
342
+ (u) => (u == null ? void 0 : u.filter((_) => !!_).length) !== Le ? o(f)("team.memberForm.masterUser.passcodeRequired") : !0
343
+ ]
344
+ }, {
345
+ default: ie(() => [
346
+ (h(), z(Z, {
347
+ key: `pin-field-${O.value}`,
348
+ modelValue: w.value,
349
+ "onUpdate:modelValue": l[2] || (l[2] = (u) => w.value = u),
350
+ length: Le,
351
+ masked: O.value,
352
+ onComplete: l[3] || (l[3] = (u) => S("passcode", u)),
353
+ onFocus: U
354
+ }, null, 8, ["modelValue", "masked"]))
355
+ ]),
356
+ _: 1
357
+ }, 8, ["modelValue", "rules"])
358
+ ]),
359
+ c(J, {
360
+ tag: "div",
361
+ modelValue: F.value,
362
+ "onUpdate:modelValue": l[5] || (l[5] = (u) => F.value = u),
363
+ rules: [
364
+ (u) => !u || u.length === 0 || u.every((_) => !_.restaurantId) ? o(f)("team.memberForm.masterUser.restaurantRequired") : u.some((_) => !_.restaurantId || !_.roleId) ? o(f)("team.memberForm.masterUser.roleRequired") : !0
365
+ ]
366
+ }, {
367
+ default: ie(() => [
368
+ m("div", mt, [
369
+ m("div", dt, R(o(f)("team.memberForm.masterUser.assignmentSection")), 1),
370
+ m("div", ct, [
371
+ m("div", pt, [
372
+ m("div", ft, R(o(f)("team.table.columns.restaurant")), 1),
373
+ m("div", vt, R(o(f)("team.memberForm.masterUser.role")), 1),
374
+ l[6] || (l[6] = m("div", null, null, -1))
375
+ ]),
376
+ (h(!0), D(De, null, us(i.modelValue.roles, (u, _) => (h(), D("div", {
377
+ key: `${u.restaurantId || "new"}-${_}`,
378
+ class: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-16"
379
+ }, [
380
+ c(E, {
381
+ class: "min-w-0",
382
+ "model-value": u.restaurantId,
383
+ items: p(u.restaurantId),
384
+ multiselect: !1,
385
+ placeholder: o(f)("team.table.columns.restaurant"),
386
+ "onUpdate:modelValue": (X) => ue(_, X)
387
+ }, null, 8, ["model-value", "items", "placeholder", "onUpdate:modelValue"]),
388
+ c(E, {
389
+ class: "min-w-0",
390
+ "model-value": u.roleId,
391
+ items: b(u.roleId),
392
+ multiselect: !1,
393
+ placeholder: o(f)("team.memberForm.masterUser.role"),
394
+ disabled: !u.restaurantId,
395
+ "onUpdate:modelValue": (X) => G(_, X)
396
+ }, null, 8, ["model-value", "items", "placeholder", "disabled", "onUpdate:modelValue"]),
397
+ m("div", bt, [
398
+ i.modelValue.roles.length > 1 ? (h(), D("div", {
399
+ key: 0,
400
+ role: "button",
401
+ tabindex: "0",
402
+ class: "inline-flex h-40 w-40 shrink-0 cursor-pointer items-center justify-center rounded-lg text-fm-color-neutral-gray-400 transition-colors hover:bg-fm-color-neutral-gray-100 focus:outline-none focus:ring-2 focus:ring-fm-color-primary",
403
+ "aria-label": o(f)("common.remove"),
404
+ onClick: Fe((X) => M(_), ["stop"]),
405
+ onKeydown: [
406
+ qe(Fe((X) => M(_), ["prevent", "stop"]), ["enter"]),
407
+ qe(Fe((X) => M(_), ["prevent", "stop"]), ["space"])
408
+ ]
409
+ }, [
410
+ c(B, {
411
+ name: "delete",
412
+ size: "md"
413
+ })
414
+ ], 40, ht)) : K("", !0)
415
+ ])
416
+ ]))), 128))
417
+ ]),
418
+ c(L, {
419
+ type: "button",
420
+ variant: "secondary",
421
+ "text-color": "primary",
422
+ "border-color": "primary",
423
+ "prepend-icon": "add",
424
+ label: o(f)("team.memberForm.masterUser.addAnother"),
425
+ size: "md",
426
+ disabled: !W.value,
427
+ onClick: Fe(A, ["stop"])
428
+ }, null, 8, ["label", "disabled"])
429
+ ])
430
+ ]),
431
+ _: 1
432
+ }, 8, ["modelValue", "rules"])
433
+ ], 64)) : K("", !0)
434
+ ]);
435
+ };
436
+ }
437
+ }), _t = { class: "flex flex-col gap-32" }, gt = { class: "flex w-full" }, xt = {
438
+ key: 0,
439
+ class: "space-y-24"
440
+ }, St = { class: "space-y-16 rounded-lg border border-fm-color-neutral-gray-200 p-16" }, Ut = { class: "fm-typo-en-title-sm-600" }, Ft = { class: "space-y-16" }, Vt = { class: "fm-typo-en-title-sm-600" }, wt = {
441
+ key: 1,
442
+ class: "flex items-center justify-center py-64"
443
+ }, It = /* @__PURE__ */ we({
444
+ __name: "AddMemberForm",
445
+ props: {
446
+ initialValue: {
447
+ type: Object
448
+ },
449
+ roleErrorMessage: {
450
+ type: String,
451
+ default: ""
452
+ },
453
+ loading: {
454
+ type: Boolean,
455
+ default: !1
456
+ }
457
+ },
458
+ setup(i, { expose: $ }) {
459
+ var $e, Ce, oe;
460
+ const n = i, { t: a } = Ie(), f = es(), { breakpoints: O } = ss(), w = v(), C = as(), le = k(
461
+ () => C.permissionSets.value.map((s) => ({
462
+ label: s.name,
463
+ value: s.id
464
+ }))
465
+ ), x = v((($e = n.initialValue) == null ? void 0 : $e.permissionSetIds) || []), S = k(
466
+ () => je(x.value, C.permissionSets.value)
467
+ ), p = v((Ce = n.initialValue) == null ? void 0 : Ce.posUser), b = v(
468
+ We(
469
+ Ae(S.value),
470
+ ((oe = n.initialValue) == null ? void 0 : oe.permissions) || []
471
+ )
472
+ ), { customReportPermissions: ue, isLoaded: G } = ls(), A = new Set(
473
+ Je.filter((s) => s.subject.startsWith(Vs)).map((s) => s.subject)
474
+ ), M = k(() => {
475
+ const s = new Set(A);
476
+ for (const d of ue.value) s.add(d.subject);
477
+ return s;
478
+ }), W = k(() => {
479
+ const s = /* @__PURE__ */ new Set();
480
+ for (const d of Je)
481
+ d.category === ze.reports && s.add(d.subject);
482
+ for (const d of ue.value)
483
+ d.category === ze.reports && s.add(d.subject);
484
+ return s;
485
+ }), U = ts(), F = os().roles, r = k(() => Xe(b.value)), l = k(() => {
486
+ const s = Ze(b.value);
487
+ return s === null ? U.restaurants.value : U.restaurants.value.filter((d) => s.includes(d._id));
488
+ }), y = k(() => {
489
+ const s = r.value;
490
+ return F.value.map(
491
+ (d) => ({
492
+ label: d.name,
493
+ value: d._id,
494
+ disabled: !!s && !s.includes(d._id)
495
+ })
496
+ );
497
+ }), I = v({ permissionSetIds: [], userPermissions: [], posUser: void 0 });
498
+ function Z(s) {
499
+ w.value = void 0, x.value = [...(s == null ? void 0 : s.permissionSetIds) ?? []], b.value = We(
500
+ Ae(
501
+ je(
502
+ x.value,
503
+ C.permissionSets.value
504
+ )
505
+ ),
506
+ (s == null ? void 0 : s.permissions) || []
507
+ ), p.value = s != null && s.posUser ? Q(fe(s.posUser), b.value) : void 0, ve.value = !!p.value, I.value = {
508
+ permissionSetIds: [...x.value],
509
+ userPermissions: fe(b.value),
510
+ posUser: p.value ? fe(p.value) : void 0
511
+ };
512
+ }
513
+ function J() {
514
+ return !n.initialValue && w.value ? !0 : !Se.isEqual(x.value, I.value.permissionSetIds) || !Se.isEqual(b.value, I.value.userPermissions) || !Se.isEqual(p.value, I.value.posUser);
515
+ }
516
+ function E(s) {
517
+ w.value = s;
518
+ }
519
+ function B(s) {
520
+ p.value = Q(p.value, s);
521
+ }
522
+ function L(s) {
523
+ return Ae(
524
+ je(s, C.permissionSets.value)
525
+ );
526
+ }
527
+ function u(s) {
528
+ b.value = L(s);
529
+ }
530
+ function _(s) {
531
+ const d = [...s ?? []];
532
+ if (Se.isEqual(d, x.value)) return;
533
+ const j = !Se.isEqual(
534
+ b.value,
535
+ L(x.value)
536
+ );
537
+ if (x.value = d, !j) {
538
+ u(d);
539
+ return;
540
+ }
541
+ f.open({
542
+ title: a("permissionSet.form.overrideInherited.title"),
543
+ message: a("permissionSet.form.overrideInherited.message"),
544
+ minWidth: O.value.lg ? 588 : 0,
545
+ primaryActions: {
546
+ text: a("permissionSet.form.overrideInherited.override"),
547
+ close: !1
548
+ },
549
+ secondaryActions: {
550
+ text: a("permissionSet.form.overrideInherited.keepCurrent"),
551
+ close: !0
552
+ }
553
+ }).onPrimary(() => {
554
+ u(d), f.close();
555
+ });
556
+ }
557
+ function X() {
558
+ const s = Ae(S.value), d = G.value ? M.value : A, j = ws(b.value, d), T = Is(j, W.value), q = Ps(T);
559
+ return ks(s, q);
560
+ }
561
+ function Pe() {
562
+ var j, T, q, Y, H, de, ee, se, te, Me;
563
+ const s = X(), d = b.value.filter((ce) => !ce.inverted);
564
+ return {
565
+ email: ((j = w.value) == null ? void 0 : j.email) ?? void 0,
566
+ phoneNumber: ((T = w.value) == null ? void 0 : T.phoneNumber) ?? void 0,
567
+ customPermissions: s,
568
+ permissions: d.map((ce) => ({
569
+ ...ce,
570
+ subject: hs(ce.subject)
571
+ })),
572
+ permissionSetIds: x.value,
573
+ name: ((q = w.value) == null ? void 0 : q.displayName) || ((Y = n.initialValue) == null ? void 0 : Y.name) || "",
574
+ posUser: p.value ? {
575
+ ...p.value,
576
+ name: p.value.name || ((de = (H = n.initialValue) == null ? void 0 : H.posUser) == null ? void 0 : de.name) || ((ee = n.initialValue) == null ? void 0 : ee.name) || ((se = w.value) == null ? void 0 : se.displayName) || "",
577
+ code: p.value.code || ((Me = (te = n.initialValue) == null ? void 0 : te.posUser) == null ? void 0 : Me.code) || "",
578
+ passcode: p.value.passcode,
579
+ roles: p.value.roles.filter((ce) => !!ce.roleId)
580
+ } : p.value === null ? null : void 0
581
+ };
582
+ }
583
+ const _e = v();
584
+ function Q(s, d) {
585
+ if (!s) return s;
586
+ const j = Xe(d), T = Ze(d);
587
+ if (j === null && T === null) return s;
588
+ const q = fe(s);
589
+ return q.roles = q.roles.filter(
590
+ (Y) => (j === null || j.includes(Y.roleId)) && (T === null || T.includes(Y.restaurantId))
591
+ ), q;
592
+ }
593
+ const ve = v(!!p.value), me = v(!1);
594
+ function ge(s) {
595
+ p.value = s, me.value = !0;
596
+ }
597
+ pe(
598
+ () => !!p.value,
599
+ async (s) => {
600
+ s && !ve.value && me.value && (await ms(), _e.value && _e.value.$el.scrollIntoView({ behavior: "smooth", block: "start" })), ve.value = s;
601
+ }
602
+ );
603
+ const ke = v();
604
+ async function Re() {
605
+ return (await ke.value.validateInputsWithoutSubmit()).length ? null : Pe();
606
+ }
607
+ return pe(
608
+ () => n.initialValue,
609
+ (s, d) => {
610
+ if (!d || !s || d.id !== s.id) {
611
+ me.value = !1, Z(s);
612
+ return;
613
+ }
614
+ s.posUser !== void 0 && !me.value && (p.value = s.posUser ? Q(fe(s.posUser), b.value) : void 0, I.value = {
615
+ ...I.value,
616
+ posUser: p.value ? fe(p.value) : void 0
617
+ });
618
+ },
619
+ { immediate: !0 }
620
+ ), pe(
621
+ b,
622
+ (s) => {
623
+ p.value = Q(p.value, s);
624
+ },
625
+ { deep: !0 }
626
+ ), $({
627
+ readFormData: Pe,
628
+ validate: Re,
629
+ isModified: J
630
+ }), (s, d) => {
631
+ const j = V("FmSelect"), T = V("FmCircularProgress"), q = V("FmForm");
632
+ return h(), z(q, {
633
+ ref_key: "formRef",
634
+ ref: ke,
635
+ class: "mx-4"
636
+ }, {
637
+ default: ie(() => {
638
+ var Y, H, de, ee, se;
639
+ return [
640
+ m("div", _t, [
641
+ m("div", gt, [
642
+ i.initialValue ? (h(), z(zs, {
643
+ key: 1,
644
+ data: i.initialValue
645
+ }, null, 8, ["data"])) : (h(), z(st, {
646
+ key: 0,
647
+ onInvite: d[0] || (d[0] = (te) => E(te))
648
+ }))
649
+ ]),
650
+ w.value || i.initialValue ? (h(), D(De, { key: 0 }, [
651
+ (Y = i.initialValue) != null && Y.isOwner ? K("", !0) : (h(), D("div", xt, [
652
+ m("div", St, [
653
+ m("div", Ut, R(o(a)("team.memberForm.permissionSet.title")), 1),
654
+ c(j, {
655
+ "model-value": x.value,
656
+ multiselect: "",
657
+ searchable: "",
658
+ "search-debounce": 300,
659
+ items: le.value,
660
+ placeholder: o(a)("team.memberForm.permissionSet.selectPlaceholder"),
661
+ "onUpdate:modelValue": _
662
+ }, null, 8, ["model-value", "items", "placeholder"])
663
+ ]),
664
+ m("div", Ft, [
665
+ m("div", Vt, R(o(a)("team.memberForm.permissions.title")), 1),
666
+ c(Cs, {
667
+ modelValue: b.value,
668
+ "onUpdate:modelValue": d[1] || (d[1] = (te) => b.value = te),
669
+ "inherit-permissions": S.value,
670
+ onPermissionChanged: B
671
+ }, null, 8, ["modelValue", "inherit-permissions"])
672
+ ])
673
+ ])),
674
+ i.loading ? (h(), D("div", wt, [
675
+ c(T, { size: "xl" })
676
+ ])) : (h(), z(yt, {
677
+ key: 2,
678
+ ref_key: "masterUserContentRef",
679
+ ref: _e,
680
+ "model-value": p.value,
681
+ "fallback-name": ((H = i.initialValue) == null ? void 0 : H.name) || ((de = w.value) == null ? void 0 : de.displayName) || "",
682
+ "fallback-passcode": (se = (ee = i.initialValue) == null ? void 0 : ee.posUser) == null ? void 0 : se.passcode,
683
+ roles: y.value,
684
+ restaurants: l.value,
685
+ "onUpdate:modelValue": ge
686
+ }, null, 8, ["model-value", "fallback-name", "fallback-passcode", "roles", "restaurants"]))
687
+ ], 64)) : K("", !0)
688
+ ])
689
+ ];
690
+ }),
691
+ _: 1
692
+ }, 512);
693
+ };
694
+ }
695
+ }), Pt = {
696
+ class: "space-y-24"
697
+ }, kt = {
698
+ class: "space-y-8"
699
+ }, Rt = {
700
+ key: 0,
701
+ class: "flex w-full items-start justify-between px-16"
702
+ }, $t = {
703
+ class: "flex items-start gap-8"
704
+ }, Ct = {
705
+ key: 1,
706
+ class: "space-y-4 px-16"
707
+ }, Mt = {
708
+ class: "flex items-start gap-8"
709
+ }, Nt = {
710
+ class: "flex h-full flex-col overflow-auto"
711
+ }, At = {
712
+ class: "flex w-full items-center justify-between"
713
+ }, Dt = {
714
+ class: "fm-typo-en-title-md-600"
715
+ }, Ot = {
716
+ class: "flex items-center justify-start gap-8"
717
+ }, he = 100;
718
+ var ae = /* @__PURE__ */ function(i) {
719
+ return i[i.ADD = 0] = "ADD", i[i.UPDATE = 1] = "UPDATE", i[i.CLOSED = 2] = "CLOSED", i;
720
+ }(ae || {});
721
+ const Ht = /* @__PURE__ */ we({
722
+ __name: "TeamMemberList",
723
+ setup(i, {
724
+ expose: $
725
+ }) {
726
+ const {
727
+ fetchCustomReportPermissions: n
728
+ } = ls();
729
+ ns();
730
+ const {
731
+ t: a
732
+ } = Ie(), f = Oe(), O = ts(), w = os(), C = He(), le = Fs(C), x = as(), S = Rs(), p = v(!0), b = v(!1), ue = k(() => O.isLoading.value), G = v([]), A = v(0), M = v(1), W = v(""), U = v("");
733
+ pe(O.restaurants, (e) => {
734
+ if (e.length > 0 && G.value.length > 0) {
735
+ const t = new Map(e.map((P) => [P._id, P.profile.name])), g = e.map((P) => P.profile.name).sort();
736
+ G.value = G.value.map((P) => ({
737
+ ...P,
738
+ restaurants: P.managableRestaurantIds === null ? g : P.managableRestaurantIds.map((ne) => t.get(ne) ?? "").filter(Boolean).sort()
739
+ }));
740
+ }
741
+ });
742
+ const F = k(() => [{
743
+ label: a("team.filter.unassigned_label"),
744
+ value: Ve
745
+ }, ...O.restaurants.value.map((e) => ({
746
+ label: `${e.profile.code ? `${e.profile.code} - ` : ""}${e.profile.name}`,
747
+ value: e._id
748
+ }))]), r = ({
749
+ member: e,
750
+ className: t = ""
751
+ }) => {
752
+ const g = {
753
+ label: a("team.actions.updateMember"),
754
+ onClick: () => L(ye.Update, e)
755
+ }, P = {
756
+ label: a("team.actions.removeMember"),
757
+ onClick: () => L(ye.Remove, e),
758
+ itemClass: "text-fm-color-typo-error"
759
+ }, ne = e.doc.isOwner ? [g] : [g, P];
760
+ return c(Ss, {
761
+ class: t,
762
+ items: ne
763
+ }, null);
764
+ }, l = (e) => e.doc.isOwner ? a("team.labels.businessOwner") : e.restaurants.join(", "), y = [{
765
+ accessorKey: "name",
766
+ header: () => a("team.table.columns.name"),
767
+ enableSorting: !1,
768
+ cell(e) {
769
+ const t = e.row.original;
770
+ return c("div", {
771
+ class: "flex items-center gap-8"
772
+ }, [c(Be.FmAvatar, {
773
+ name: t.name,
774
+ size: "sm",
775
+ class: "shrink-0"
776
+ }, null), c("span", {
777
+ class: "truncate"
778
+ }, [t.name])]);
779
+ }
780
+ }, {
781
+ accessorKey: "phoneNumber",
782
+ header: () => a("team.table.columns.phoneNumber"),
783
+ enableSorting: !1
784
+ }, {
785
+ accessorKey: "restaurant",
786
+ header: () => a("team.table.columns.restaurant"),
787
+ enableSorting: !1,
788
+ cell(e) {
789
+ if (ue.value)
790
+ return cs(vs);
791
+ const t = e.row.original;
792
+ return l(t);
793
+ }
794
+ }, {
795
+ accessorKey: "assignedRoles",
796
+ header: () => a("team.table.columns.assignedRoles"),
797
+ enableSorting: !1,
798
+ cell(e) {
799
+ const t = e.row.original, g = S.getPermissionAssignmentByUserId(t.id), P = (g == null ? void 0 : g.permissionSetIds) || t.doc.permissionSetIds || [];
800
+ return x.permissionSets.value.filter((re) => P.includes(re.id)).map((re) => re.name).join(", ");
801
+ }
802
+ }, {
803
+ accessorKey: "permission",
804
+ header: () => a("team.table.columns.permission"),
805
+ enableSorting: !1,
806
+ cell(e) {
807
+ const t = e.row.original;
808
+ return I(t);
809
+ },
810
+ meta: {
811
+ width: "200px"
812
+ }
813
+ }, {
814
+ id: "action",
815
+ meta: {
816
+ cellClass: "pl-16",
817
+ headerContentClass: "-mx-16"
818
+ },
819
+ cell(e) {
820
+ const t = e.row.original;
821
+ return r({
822
+ member: t,
823
+ className: "flex justify-end w-full"
824
+ });
825
+ },
826
+ enableSorting: !1
827
+ }];
828
+ function I(e) {
829
+ if (e.doc.isOwner)
830
+ return a("team.labels.businessOwner");
831
+ const t = c(Be.FmTooltip, {
832
+ variant: "plain",
833
+ placement: "top"
834
+ }, {
835
+ default: () => c(Be.FmIcon, {
836
+ name: "info",
837
+ class: "cursor-pointer text-fm-color-neutral-gray-300"
838
+ }, null),
839
+ content: () => c("div", null, [a("team.labels.permission"), e.permissionLabels.map((g) => c("div", null, [ps("- "), g]))])
840
+ });
841
+ return c("div", {
842
+ class: "flex flex-row items-center gap-8"
843
+ }, [c("span", null, [a("team.labels.allowed", {
844
+ count: e.permissionLabels.length
845
+ })]), e.permissionLabels.length > 0 && t]);
846
+ }
847
+ function Z(e) {
848
+ var ne, re, Ne, xe;
849
+ const t = S.getPermissionAssignmentByUserId(e.id), g = (t == null ? void 0 : t.customPermissions) ?? e.permissions ?? [], P = (t == null ? void 0 : t.permissionSetIds) ?? e.doc.permissionSetIds ?? [];
850
+ return {
851
+ id: e.id,
852
+ isOwner: e.doc.isOwner,
853
+ name: e.name,
854
+ phoneNumber: e.phoneNumber,
855
+ email: e.email,
856
+ permissions: g,
857
+ permissionSetIds: P,
858
+ posUser: e.doc.posUser ? {
859
+ code: ((ne = e.doc.posUser) == null ? void 0 : ne.code) ?? "",
860
+ name: ((re = e.doc.posUser) == null ? void 0 : re.name) ?? e.name,
861
+ passcode: ((Ne = e.doc.posUser) == null ? void 0 : Ne.passcode) ?? "",
862
+ roles: ((xe = e.doc.posUser) == null ? void 0 : xe.roles) ?? []
863
+ } : void 0
864
+ };
865
+ }
866
+ function J(e) {
867
+ const t = S.getPermissionAssignmentByUserId(e.id), g = (t == null ? void 0 : t.customPermissions) ?? e.permissions ?? [], P = (t == null ? void 0 : t.permissionSetIds) ?? e.doc.permissionSetIds ?? [];
868
+ return {
869
+ id: e.id,
870
+ isOwner: e.doc.isOwner,
871
+ name: e.name,
872
+ phoneNumber: e.phoneNumber,
873
+ email: e.email,
874
+ permissions: g,
875
+ permissionSetIds: P,
876
+ posUser: void 0
877
+ };
878
+ }
879
+ const E = v(!1);
880
+ let B = 0;
881
+ const L = async (e, t) => {
882
+ if (e == ye.Update) {
883
+ const g = ++B;
884
+ Q.value = J(t), _.value = ae.UPDATE, E.value = t.doc.hasPosUser === !0;
885
+ try {
886
+ const P = await Ue.readTeamMember(t.id);
887
+ if (g !== B) return;
888
+ Q.value = Z(P);
889
+ } catch {
890
+ if (g !== B) return;
891
+ C.open({
892
+ message: a("common.error"),
893
+ type: "error"
894
+ }), ge();
895
+ } finally {
896
+ g === B && (E.value = !1);
897
+ }
898
+ }
899
+ e == ye.Remove && $e(t);
900
+ }, u = es(), _ = v(ae.CLOSED), X = k(() => _.value !== ae.CLOSED), Pe = k(() => _.value === ae.ADD ? a("common.add") : a("common.update")), _e = k(() => _.value === ae.ADD ? a("team.actions.addMember") : a("team.actions.updateMember")), Q = v();
901
+ function ve() {
902
+ B++, E.value = !1, _.value = ae.CLOSED;
903
+ }
904
+ const me = xs(() => {
905
+ var e;
906
+ return ((e = ee.value) == null ? void 0 : e.isModified()) ?? !1;
907
+ }, ve);
908
+ function ge() {
909
+ me();
910
+ }
911
+ function ke(e) {
912
+ e || ge();
913
+ }
914
+ const {
915
+ breakpoints: Re
916
+ } = ss(), $e = (e) => {
917
+ u.open({
918
+ title: a("team.actions.removeMember"),
919
+ message: a("team.removeMember.confirmationMessage", {
920
+ memberName: e.name
921
+ }),
922
+ minWidth: Re.value.lg ? 588 : 0,
923
+ primaryActions: {
924
+ text: "Remove",
925
+ close: !1,
926
+ variant: "destructive",
927
+ isLoading: te
928
+ },
929
+ secondaryActions: {
930
+ text: "Cancel",
931
+ close: !0
932
+ }
933
+ }).onPrimary(async () => {
934
+ te.value || (await le.minor(async () => {
935
+ await Ue.deleteTeamMember(e.id), await de();
936
+ }, {
937
+ isLoading: te,
938
+ successMessage: a("team.removeMember.successMessage", {
939
+ memberName: e.name
940
+ })
941
+ }), u.close());
942
+ });
943
+ }, Ce = () => {
944
+ Q.value = null, _.value = ae.ADD;
945
+ }, oe = v(), s = v(), d = v(), j = k(() => {
946
+ var e;
947
+ return JSON.stringify({
948
+ businessId: ((e = f.currentBusiness.value) == null ? void 0 : e._id) ?? "",
949
+ search: U.value.trim(),
950
+ restaurantIds: [...oe.value ?? []].sort(),
951
+ permissionSubjects: [...s.value ?? []].sort(),
952
+ permissionSetIds: [...d.value ?? []].sort()
953
+ });
954
+ }), T = k(() => Object.values(ys).map((e) => ({
955
+ label: e.label,
956
+ value: e.subject
957
+ }))), q = k(() => [{
958
+ label: a("team.filter.unassigned_label"),
959
+ value: Ve
960
+ }, ...x.permissionSets.value.map((e) => ({
961
+ label: e.name,
962
+ value: e.id
963
+ }))]);
964
+ async function Y() {
965
+ await w.readRoles();
966
+ }
967
+ async function H(e = M.value) {
968
+ var t;
969
+ p.value = !0;
970
+ try {
971
+ const g = await Ue.readTeamMembersPage({
972
+ limit: he,
973
+ offset: (e - 1) * he,
974
+ search: U.value.trim() || void 0,
975
+ restaurantIds: Qe(oe.value),
976
+ permissionSubjects: (t = s.value) != null && t.length ? s.value : void 0,
977
+ permissionSetIds: Qe(d.value)
978
+ });
979
+ G.value = g.items, A.value = g.total;
980
+ } finally {
981
+ p.value = !1;
982
+ }
983
+ }
984
+ async function de() {
985
+ var t;
986
+ if (!((t = f.currentBusiness.value) != null && t._id)) return;
987
+ await H(M.value);
988
+ const e = Math.max(1, Math.ceil(A.value / he));
989
+ M.value > e && (M.value = e, await H(M.value));
990
+ }
991
+ const ee = v(), se = v(!1), te = v(!1);
992
+ async function Me() {
993
+ if (!ee.value) return;
994
+ const e = await ee.value.validate();
995
+ if (!e) return;
996
+ const t = _.value === ae.ADD;
997
+ await le.minor(async () => {
998
+ await (t ? Ue.createTeamMember(e) : Ue.updateTeamMember(Q.value.id, e)), ve(), await Te(), await de();
999
+ }, {
1000
+ successMessage: t ? a("team.addMember.successMessage", {
1001
+ memberName: e.name
1002
+ }) : a("team.updateMember.successMessage", {
1003
+ memberName: e.name
1004
+ }),
1005
+ isLoading: se
1006
+ }), _.value = ae.CLOSED;
1007
+ }
1008
+ async function ce() {
1009
+ await x.readPermissionSets();
1010
+ }
1011
+ async function Te() {
1012
+ await S.readPermissionAssignments();
1013
+ }
1014
+ let Ee = !1;
1015
+ async function rs({
1016
+ pageIndex: e
1017
+ }) {
1018
+ var t;
1019
+ if ((t = f.currentBusiness.value) != null && t._id && !Ee && !(e === 0 && M.value === 1 && G.value.length > 0)) {
1020
+ Ee = !0, M.value = e + 1;
1021
+ try {
1022
+ await H(M.value);
1023
+ } finally {
1024
+ Ee = !1;
1025
+ }
1026
+ }
1027
+ }
1028
+ const is = fs(W, () => {
1029
+ U.value = W.value;
1030
+ });
1031
+ return ds(is), pe(j, async () => {
1032
+ var e;
1033
+ M.value = 1, b.value = !1, (e = f.currentBusiness.value) != null && e._id && (await H(1), b.value = !0);
1034
+ }, {
1035
+ immediate: !0
1036
+ }), pe(f.currentBusiness, async () => {
1037
+ var e;
1038
+ if ((e = f.currentBusiness.value) != null && e._id)
1039
+ try {
1040
+ await Promise.all([O.readRestaurants(), ce(), Te(), n(), Y()]);
1041
+ } catch (t) {
1042
+ console.error("Failed to load team member dependencies:", t), C.open({
1043
+ message: t instanceof Error ? t.message : String(t),
1044
+ type: "error"
1045
+ });
1046
+ }
1047
+ }, {
1048
+ immediate: !0
1049
+ }), $({
1050
+ create: Ce
1051
+ }), (e, t) => {
1052
+ var xe;
1053
+ const g = V("FmSearch"), P = V("FmTable"), ne = V("FmIcon"), re = V("FmButton"), Ne = V("FmSideSheet");
1054
+ return h(), D(De, null, [m("div", Pt, [m("div", kt, [o(Re).xs ? (h(), D("div", Ct, [c(g, {
1055
+ modelValue: W.value,
1056
+ "onUpdate:modelValue": t[4] || (t[4] = (N) => W.value = N),
1057
+ class: "w-[320px] xs:w-full xs:mt-8",
1058
+ placeholder: o(a)("team.search.placeholder")
1059
+ }, null, 8, ["modelValue", "placeholder"]), m("div", Mt, [c(be, {
1060
+ modelValue: oe.value,
1061
+ "onUpdate:modelValue": t[5] || (t[5] = (N) => oe.value = N),
1062
+ multiple: "",
1063
+ items: F.value,
1064
+ variant: "dark",
1065
+ "selected-prefix": o(a)("team.table.columns.restaurant"),
1066
+ placeholder: o(a)("team.table.columns.restaurant"),
1067
+ class: "!w-auto"
1068
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), c(be, {
1069
+ modelValue: s.value,
1070
+ "onUpdate:modelValue": t[6] || (t[6] = (N) => s.value = N),
1071
+ multiple: "",
1072
+ variant: "dark",
1073
+ items: T.value,
1074
+ "selected-prefix": o(a)("team.filter.selected_permission_prefix"),
1075
+ placeholder: o(a)("team.filter.permission_placeholder")
1076
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), c(be, {
1077
+ modelValue: d.value,
1078
+ "onUpdate:modelValue": t[7] || (t[7] = (N) => d.value = N),
1079
+ multiple: "",
1080
+ variant: "dark",
1081
+ items: q.value,
1082
+ "selected-prefix": o(a)("team.filter.selected_assigned_role_prefix"),
1083
+ placeholder: o(a)("team.filter.assigned_role_placeholder")
1084
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])])])) : (h(), D("div", Rt, [m("div", $t, [c(be, {
1085
+ modelValue: oe.value,
1086
+ "onUpdate:modelValue": t[0] || (t[0] = (N) => oe.value = N),
1087
+ multiple: "",
1088
+ items: F.value,
1089
+ variant: "dark",
1090
+ "selected-prefix": o(a)("team.table.columns.restaurant"),
1091
+ placeholder: o(a)("team.table.columns.restaurant"),
1092
+ class: "!w-auto"
1093
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), c(be, {
1094
+ modelValue: s.value,
1095
+ "onUpdate:modelValue": t[1] || (t[1] = (N) => s.value = N),
1096
+ multiple: "",
1097
+ variant: "dark",
1098
+ items: T.value,
1099
+ "selected-prefix": o(a)("team.filter.selected_permission_prefix"),
1100
+ placeholder: o(a)("team.filter.permission_placeholder")
1101
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"]), c(be, {
1102
+ modelValue: d.value,
1103
+ "onUpdate:modelValue": t[2] || (t[2] = (N) => d.value = N),
1104
+ multiple: "",
1105
+ variant: "dark",
1106
+ items: q.value,
1107
+ "selected-prefix": o(a)("team.filter.selected_assigned_role_prefix"),
1108
+ placeholder: o(a)("team.filter.assigned_role_placeholder")
1109
+ }, null, 8, ["modelValue", "items", "selected-prefix", "placeholder"])]), c(g, {
1110
+ modelValue: W.value,
1111
+ "onUpdate:modelValue": t[3] || (t[3] = (N) => W.value = N),
1112
+ class: "w-[320px] xs:w-full xs:mt-8",
1113
+ autofocus: "",
1114
+ placeholder: o(a)("team.search.placeholder")
1115
+ }, null, 8, ["modelValue", "placeholder"])])), (xe = o(f).currentBusiness.value) != null && xe._id ? (h(), z(_s, {
1116
+ key: 2
1117
+ }, {
1118
+ default: ie(() => [m("div", Nt, [b.value ? K("", !0) : (h(), z(gs, {
1119
+ key: 0
1120
+ })), b.value ? (h(), z(Us, {
1121
+ key: 1,
1122
+ "is-loading": p.value,
1123
+ "is-empty": A.value === 0,
1124
+ title: o(a)("team.emptyState.title"),
1125
+ subtitle: o(a)("team.emptyState.description")
1126
+ }, {
1127
+ default: ie(() => [(h(), z(P, {
1128
+ key: j.value,
1129
+ "column-defs": y,
1130
+ "row-data": G.value,
1131
+ "page-size": he,
1132
+ "page-count": Math.ceil(A.value / he),
1133
+ "row-count": A.value,
1134
+ "fetch-fn": rs,
1135
+ "hide-footer": A.value <= he,
1136
+ loading: p.value,
1137
+ "pin-header-row": "",
1138
+ onRowClick: t[8] || (t[8] = (N) => L(o(ye).Update, N.original))
1139
+ }, null, 8, ["row-data", "page-count", "row-count", "hide-footer", "loading"]))]),
1140
+ _: 1
1141
+ }, 8, ["is-loading", "is-empty", "title", "subtitle"])) : K("", !0)])]),
1142
+ _: 1
1143
+ })) : K("", !0)])]), c(Ne, {
1144
+ "model-value": X.value,
1145
+ "max-width": 960,
1146
+ "close-button": !1,
1147
+ "onUpdate:modelValue": ke,
1148
+ "onOn:clickedAway": o(me)
1149
+ }, {
1150
+ "side-sheet-header": ie(() => [m("div", At, [m("p", Dt, R(_e.value), 1), c(ne, {
1151
+ name: "close",
1152
+ size: "md",
1153
+ class: "cursor-pointer",
1154
+ onClick: o(me)
1155
+ }, null, 8, ["onClick"])])]),
1156
+ "side-sheet-footer": ie(() => [m("div", Ot, [c(re, {
1157
+ label: Pe.value,
1158
+ size: "md",
1159
+ variant: "primary",
1160
+ "is-loading": se.value,
1161
+ disabled: se.value,
1162
+ onClick: Fe(Me, ["prevent"])
1163
+ }, null, 8, ["label", "is-loading", "disabled"]), c(re, {
1164
+ label: o(a)("common.cancel"),
1165
+ size: "md",
1166
+ variant: "secondary",
1167
+ disabled: se.value,
1168
+ onClick: ge
1169
+ }, null, 8, ["label", "disabled"])])]),
1170
+ default: ie(() => [X.value ? (h(), z(It, {
1171
+ key: 0,
1172
+ ref_key: "memberForm",
1173
+ ref: ee,
1174
+ initialValue: Q.value,
1175
+ loading: E.value,
1176
+ class: "gap-8"
1177
+ }, null, 8, ["initialValue", "loading"])) : K("", !0)]),
1178
+ _: 1
1179
+ }, 8, ["model-value", "onOn:clickedAway"])], 64);
1180
+ };
1181
+ }
1182
+ });
1183
+ export {
1184
+ Ht as default
1185
+ };