@feedmepos/mf-hrm-portal 2.3.2-dev.15 → 2.3.2-dev.17

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 (108) hide show
  1. package/dist/{ApprovalCodeList-qB2eycv0.js → ApprovalCodeList-Bo8IbNxV.js} +15 -14
  2. package/dist/{AuditLogList-DaqYMXFA.js → AuditLogList-C7CjPILA.js} +833 -823
  3. package/dist/ConditionBuilderForm.vue_vue_type_script_setup_true_lang-C-4BaMN-.js +438 -0
  4. package/dist/EmployeeList-BOP-gaTp.js +776 -0
  5. package/dist/FormItem.vue_vue_type_script_setup_true_lang-BEOR-8QD.js +45 -0
  6. package/dist/FormSection.vue_vue_type_script_setup_true_lang-DknXTYiK.js +49 -0
  7. package/dist/{GrantUserList-DqeHBPqr.js → GrantUserList-CXWGr3Wo.js} +16 -15
  8. package/dist/Main-BrP1frfO.js +96 -0
  9. package/dist/{Main-8SeOYhVr.js → Main-DeuWov9n.js} +5 -5
  10. package/dist/{Main-DnWIkti6.js → Main-bru10M5U.js} +2097 -2102
  11. package/dist/PasscodePinField.vue_vue_type_script_setup_true_lang-CqG0v0Sz.js +243 -0
  12. package/dist/{PermissionSetList-Bh0o_HFX.js → PermissionSetList--xt0piQz.js} +137 -136
  13. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-D5nvRsW3.js +4167 -0
  14. package/dist/PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-DiNDrCy0.js +35 -0
  15. package/dist/RoleList-BEE-8EQK.js +740 -0
  16. package/dist/{ScheduleAddPositionModal.vue_vue_type_script_setup_true_lang-BSmFLxZS.js → ScheduleAddPositionModal.vue_vue_type_script_setup_true_lang-Cqo5kHcF.js} +1 -1
  17. package/dist/{ScheduleGeneralPage-C0Y9XHXR.js → ScheduleGeneralPage-DxhgBLix.js} +2 -2
  18. package/dist/{ScheduleModal.vue_vue_type_script_setup_true_lang-B1293tLU.js → ScheduleModal.vue_vue_type_script_setup_true_lang-DGPwmNQb.js} +186 -187
  19. package/dist/{SchedulePage-Cqp0mIOQ.js → SchedulePage-oBdEvGWN.js} +20 -20
  20. package/dist/{SchedulePositionPage-DpF7fZ2G.js → SchedulePositionPage-BZps-kKs.js} +3 -3
  21. package/dist/{SelectFilter-jjUAj29l.js → SelectFilter-Bs_LCk3L.js} +1 -1
  22. package/dist/TeamMemberList-DCgNcs4P.js +1154 -0
  23. package/dist/{TimesheetList-CzUVfPGT.js → TimesheetList-BW6iCigo.js} +9 -9
  24. package/dist/{TimesheetList.vue_vue_type_style_index_0_scoped_63294af2_lang-CZ6axjWg.js → TimesheetList.vue_vue_type_style_index_0_scoped_63294af2_lang-Dv66Af5C.js} +3 -3
  25. package/dist/{app-IdmhLBBn.js → app-B8xnhtVI.js} +3706 -7569
  26. package/dist/app.js +3 -3
  27. package/dist/{approval-code-BOfGQEGW.js → approval-code-B0jU1bvk.js} +1 -1
  28. package/dist/{dayjs.min-DkHZ47ah.js → dayjs.min-CdpSCqn1.js} +34 -34
  29. package/dist/{employee-CJXt2fuN.js → employee-DlFGiUgI.js} +47 -48
  30. package/dist/{grant-user-Bj6DpBWc.js → grant-user-C3C6glCk.js} +1 -1
  31. package/dist/{iteration-BRk48OAH.js → iteration-BM0iyDBd.js} +1 -1
  32. package/dist/{lodash-CDREeRGa.js → lodash-KK9U7NAy.js} +1 -1
  33. package/dist/restaurant-C7o2Yk6j.js +2688 -0
  34. package/dist/{role-CtYVs62K.js → role-DYCorsOh.js} +20 -19
  35. package/dist/rule-BhGHZqKO.js +783 -0
  36. package/dist/src/components/CollapsibleWrapper.vue.d.ts +3 -11
  37. package/dist/src/helpers/permission-set.d.ts +102 -1
  38. package/dist/src/helpers/rule.d.ts +2 -2
  39. package/dist/src/helpers/string.d.ts +1 -10
  40. package/dist/src/router/shared.d.ts +1 -3
  41. package/dist/src/stores/restaurant.d.ts +7 -7
  42. package/dist/src/stores/team.d.ts +1 -31
  43. package/dist/src/types/team.d.ts +1 -17
  44. package/dist/src/views/audit-log/locales/index.d.ts +0 -12
  45. package/dist/src/views/audit-log/useTraceIdDeepLink.d.ts +1 -1
  46. package/dist/src/views/hr/locales/index.d.ts +0 -20
  47. package/dist/src/views/hr/role/RoleForm.vue.d.ts +2 -29
  48. package/dist/src/views/scheduling/composables/useScheduleOnboardingAvailability.d.ts +1 -1
  49. package/dist/src/views/scheduling/composables/useScheduleOnboardingWizard.d.ts +1 -1
  50. package/dist/src/views/scheduling/composables/useScheduleShiftDraft.d.ts +1 -1
  51. package/dist/src/views/scheduling/composables/useScheduleShiftPopover.d.ts +1 -1
  52. package/dist/src/views/team/components/BasePermission.vue.d.ts +0 -11
  53. package/dist/src/views/team/components/ConditionPermission.vue.d.ts +0 -11
  54. package/dist/src/views/team/components/PortalPermissionEditor.vue.d.ts +0 -21
  55. package/dist/src/views/team/components/PosRolePermission.vue.d.ts +0 -11
  56. package/dist/src/views/team/locales/index.d.ts +0 -716
  57. package/dist/src/views/team/member/AddMemberForm.vue.d.ts +3 -48
  58. package/dist/src/views/team/{components/MemberStatusBadge.vue.d.ts → member/MemberInfo.vue.d.ts} +2 -2
  59. package/dist/src/views/team/member/TeamMemberList.vue.d.ts +0 -1
  60. package/dist/string-VNuQNweN.js +15 -0
  61. package/dist/style.css +1 -1
  62. package/dist/tsconfig.app.tsbuildinfo +1 -1
  63. package/dist/{useAppStore-DAW1zVPH.js → useAppStore-C1lk2Q2j.js} +1 -1
  64. package/dist/{useLoading-C-AZgSLr.js → useLoading-CXdGsnHm.js} +1 -1
  65. package/dist/useReportPermissions-D_I4rFVo.js +82 -0
  66. package/package.json +3 -3
  67. package/dist/ConditionBuilderForm.vue_vue_type_script_setup_true_lang-orzPqq0L.js +0 -459
  68. package/dist/EmployeeList-h0fWCjea.js +0 -896
  69. package/dist/FormSection.vue_vue_type_script_setup_true_lang-rg4r9aRR.js +0 -90
  70. package/dist/Main-s-s803fq.js +0 -101
  71. package/dist/MyPosProfile-ChVMjpLY.js +0 -360
  72. package/dist/PasscodePinField.vue_vue_type_script_setup_true_lang-TXPEqa46.js +0 -126
  73. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-05XZu7a9.js +0 -4212
  74. package/dist/PortalUserSearcher.vue_vue_type_style_index_0_scoped_827dfd60_lang-rb5MPBnA.js +0 -1797
  75. package/dist/RoleForm.vue_vue_type_script_setup_true_lang-CwzYGZNY.js +0 -547
  76. package/dist/RoleList-BjcuUCyF.js +0 -274
  77. package/dist/TeamMemberList-B2wxF6Yn.js +0 -2082
  78. package/dist/member-grant-BkZ_oF44.js +0 -54
  79. package/dist/restaurant-BEdgW6Se.js +0 -49
  80. package/dist/rule-CWR80AmG.js +0 -839
  81. package/dist/src/api/my-pos-profile/index.d.ts +0 -3
  82. package/dist/src/api/sso-provider/index.d.ts +0 -5
  83. package/dist/src/api/staff-invite/index.d.ts +0 -16
  84. package/dist/src/components/form/SegmentedTabs.vue.d.ts +0 -23
  85. package/dist/src/composables/useMenuAccess.d.ts +0 -56
  86. package/dist/src/composables/useSsoProviders.d.ts +0 -19
  87. package/dist/src/composables/useStaffInviteProviders.d.ts +0 -8
  88. package/dist/src/composables/useTenant.d.ts +0 -11
  89. package/dist/src/helpers/member-grant.d.ts +0 -36
  90. package/dist/src/helpers/my-pos-profile.d.ts +0 -37
  91. package/dist/src/helpers/pos-assignment-rows.d.ts +0 -28
  92. package/dist/src/helpers/staff-invite.d.ts +0 -54
  93. package/dist/src/router/courtGuard.d.ts +0 -4
  94. package/dist/src/router/menu-access-guard.d.ts +0 -17
  95. package/dist/src/types/my-pos-profile.d.ts +0 -24
  96. package/dist/src/types/sso-provider.d.ts +0 -10
  97. package/dist/src/types/staff-invite.d.ts +0 -100
  98. package/dist/src/views/my-pos-profile/MyPosProfile.vue.d.ts +0 -2
  99. package/dist/src/views/my-pos-profile/components/PasscodeChangedDialog.vue.d.ts +0 -4
  100. package/dist/src/views/my-pos-profile/locales/index.d.ts +0 -236
  101. package/dist/src/views/team/components/MemberGrantFields.vue.d.ts +0 -51
  102. package/dist/src/views/team/components/PosAssignmentRows.vue.d.ts +0 -44
  103. package/dist/src/views/team/member/ExistingMemberNotice.vue.d.ts +0 -11
  104. package/dist/src/views/team/member/MemberDetailsCard.vue.d.ts +0 -35
  105. package/dist/src/views/team/member/MemberHeaderCard.vue.d.ts +0 -19
  106. package/dist/string-DZQ1uNjn.js +0 -22
  107. package/dist/useReportPermissions-ld6buoVe.js +0 -80
  108. package/dist/useSsoProviders-DeTogbyW.js +0 -41
@@ -1,839 +0,0 @@
1
- import { s as W, c as ne, e as j } from "./iteration-BRk48OAH.js";
2
- import { D as _, k as h, j as z, E as re, C as K, g, b, u as V, F as L, H as ie, h as x, I as y, n as F } from "./app-IdmhLBBn.js";
3
- import { s as oe } from "./utils-BZkjJbju.js";
4
- import { defineStore as H, storeToRefs as Q } from "pinia";
5
- import { ref as v, computed as C } from "vue";
6
- import { u as ae } from "./restaurant-BEdgW6Se.js";
7
- function k(e) {
8
- if (e) {
9
- if (typeof e == "string") {
10
- if (e === "{}") return;
11
- try {
12
- return JSON.parse(e);
13
- } catch {
14
- return;
15
- }
16
- }
17
- if (typeof e == "object")
18
- return Object.keys(e).length > 0 ? e : void 0;
19
- }
20
- }
21
- function w(e) {
22
- return e ? Object.values(e).every(
23
- (t) => t !== null && typeof t == "object" && !Array.isArray(t) && Object.keys(t).length === 1 && Array.isArray(t.$in)
24
- ) : !0;
25
- }
26
- function Y(e) {
27
- const t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), r = (n, s, a) => {
28
- var o, c;
29
- const u = k(s.conditions);
30
- let l = `${s.subject}::${JSON.stringify([...s.actions].sort())}`;
31
- w(u) || (l += `::${JSON.stringify(u)}`);
32
- const m = n.get(l);
33
- if (!m) {
34
- n.set(l, { ...s, setNames: [a.name], setId: a._id });
35
- return;
36
- }
37
- m.setNames.push(a.name);
38
- const d = k(m.conditions);
39
- if (!d || !u) {
40
- m.conditions = void 0;
41
- return;
42
- }
43
- for (const f in u)
44
- (o = d[f]) != null && o.$in && (c = u[f]) != null && c.$in ? d[f].$in = Array.from(
45
- /* @__PURE__ */ new Set([...d[f].$in, ...u[f].$in])
46
- ) : d[f] || (d[f] = u[f]);
47
- m.conditions = JSON.stringify(d);
48
- };
49
- for (const n of e)
50
- for (const s of n.permissions)
51
- r(s.inverted ? i : t, s, n);
52
- return [...Array.from(t.values()), ...Array.from(i.values())];
53
- }
54
- function E(e, t) {
55
- return `${e}::${[...t].sort().join(",")}`;
56
- }
57
- function G(e, t) {
58
- const i = [...e], r = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
59
- for (const o of e) {
60
- const c = _(o.subject);
61
- r.add(E(c, o.actions)), o.inverted && o.actions.includes("manage") && n.add(`set_${c}`), !o.inverted && o.actions.includes("manage") && s.add(c);
62
- }
63
- const a = [...e];
64
- for (; a.length > 0; ) {
65
- const o = a.shift(), c = `set_${_(o.subject)}`, u = t[c];
66
- if (!u || n.has(c) || !o.actions.includes("manage") || o.inverted) continue;
67
- n.add(c);
68
- const l = ue(o);
69
- o.source && !o.source.trace && (o.source = { ...o.source, trace: l });
70
- const m = [...l, `${u.name} (system)`];
71
- for (const d of u.permissions ?? []) {
72
- const f = _(d.subject), p = E(f, d.actions);
73
- r.has(p) || s.has(f) || (r.add(p), i.push({
74
- ...d,
75
- // FdoPermissionRule.fields is string[] | null; RawRule expects string[] | undefined
76
- fields: d.fields ?? void 0,
77
- source: {
78
- type: "systemPermissionSet",
79
- permissionSetId: u.key,
80
- permissionSetName: u.name,
81
- trace: m
82
- }
83
- }));
84
- }
85
- for (const d of u.permissionSets ?? []) {
86
- const f = _(d), p = E(f, ["manage"]), S = {
87
- subject: f,
88
- actions: ["manage"],
89
- source: {
90
- type: "systemPermissionSet",
91
- permissionSetId: u.key,
92
- permissionSetName: u.name,
93
- trace: m
94
- }
95
- };
96
- r.has(p) || (r.add(p), i.push(S)), a.push(S);
97
- }
98
- }
99
- return [...i.filter((o) => !o.inverted), ...i.filter((o) => o.inverted)];
100
- }
101
- function ue(e) {
102
- if (!e.source) return [];
103
- const { type: t, trace: i, permissionSetName: r } = e.source;
104
- if (i && i.length > 0) return i;
105
- switch (t) {
106
- case "permissionSet":
107
- return r ? [r] : [];
108
- case "custom":
109
- return ["custom"];
110
- default:
111
- return [];
112
- }
113
- }
114
- function X(e, t) {
115
- return Array.isArray(e) ? e.includes(t) : e === t;
116
- }
117
- function ce(e) {
118
- return Array.isArray(e) ? e[0] : e;
119
- }
120
- function Fe(e, t) {
121
- const i = t.find((n) => X(n.subject, e));
122
- if (!(i != null && i.category) || i.isCategoryCover) return;
123
- const r = t.find((n) => n.category === i.category && n.isCategoryCover);
124
- if (r)
125
- return ce(r.subject);
126
- }
127
- function Te(e, t) {
128
- const i = t.find((r) => X(r.subject, e));
129
- return !!(i != null && i.isCategoryCover);
130
- }
131
- function Z(e, t, i = /* @__PURE__ */ new Set()) {
132
- var r;
133
- const n = [];
134
- for (const s of e) {
135
- if (i.has(s)) continue;
136
- i.add(s);
137
- const a = t.find((o) => o.id === s);
138
- a && (n.push(a), (r = a.permissionSetIds) != null && r.length && n.push(...Z(a.permissionSetIds, t, i)));
139
- }
140
- return n;
141
- }
142
- function le(e) {
143
- const t = Y(e).map(
144
- ({ setNames: n, setId: s, ...a }) => a
145
- ), i = t.filter((n) => !n.inverted), r = t.filter((n) => n.inverted);
146
- return T(i, r);
147
- }
148
- function de(e, t) {
149
- const i = (o, c) => {
150
- const u = { ...o }, l = JSON.parse(u.conditions || "{}");
151
- if (c)
152
- if (c.length > 0) {
153
- const m = Object.keys(l)[0];
154
- l[m].$in = c;
155
- } else
156
- delete u.conditions;
157
- return {
158
- ...u,
159
- inverted: !0,
160
- ...u.conditions && { conditions: JSON.stringify(l) }
161
- };
162
- }, r = new Map(e.map((o) => [o.subject, o])), n = new Map(t.map((o) => [o.subject, o])), s = [], a = /* @__PURE__ */ new Set([...r.keys(), ...n.keys()]);
163
- for (const o of a) {
164
- const c = r.get(o), u = n.get(o);
165
- if (c && u) {
166
- if (c.conditions && u.conditions) {
167
- const l = JSON.parse(c.conditions), m = JSON.parse(u.conditions);
168
- if (!w(l) || !w(m)) {
169
- JSON.stringify(l) !== JSON.stringify(m) && s.push(u);
170
- continue;
171
- }
172
- const d = Object.keys(l)[0], f = l[d].$in.filter(
173
- (p) => !m[d].$in.includes(p)
174
- );
175
- f.length > 0 && s.push(i(c, f)), m[d].$in.filter(
176
- (p) => !l[d].$in.includes(p)
177
- ).length > 0 && s.push(u);
178
- } else if (!c.conditions && u.conditions)
179
- s.push(u);
180
- else if (c.conditions && !u.conditions)
181
- w(JSON.parse(c.conditions)) || s.push(u);
182
- else if (!c.conditions && !u.conditions) {
183
- const l = new Set(c.actions), m = new Set(u.actions), d = u.actions.some((p) => !l.has(p)), f = c.actions.filter((p) => !m.has(p));
184
- if (d) {
185
- const p = u.actions.filter((S) => !l.has(S));
186
- s.push({
187
- ...u,
188
- actions: p
189
- });
190
- }
191
- f.length > 0 && s.push({
192
- ...c,
193
- actions: f,
194
- inverted: !0
195
- });
196
- }
197
- continue;
198
- }
199
- if (c) {
200
- s.push(
201
- i(
202
- c,
203
- // If base has conditions, set diffIds to empty array, disallow all access to collection
204
- // otherwise, invert directly
205
- c.conditions && []
206
- )
207
- );
208
- continue;
209
- }
210
- u && s.push(u);
211
- }
212
- return s;
213
- }
214
- function me(e) {
215
- const t = G(
216
- e,
217
- K
218
- ), i = new Set(
219
- t.filter((n) => {
220
- var s;
221
- return ((s = n.source) == null ? void 0 : s.type) === "systemPermissionSet" && !n.inverted;
222
- }).map((n) => n.subject)
223
- ), r = new Set(
224
- t.filter(
225
- (n) => {
226
- var s;
227
- return ((s = n.source) == null ? void 0 : s.type) === "systemPermissionSet" && !n.inverted && n.actions.includes("manage");
228
- }
229
- ).map((n) => n.subject)
230
- );
231
- return e.filter((n) => n.inverted ? !(i.has(n.subject) && !r.has(n.subject)) : !i.has(n.subject));
232
- }
233
- const fe = "business::report::";
234
- function pe(e, t) {
235
- const i = [], r = e.filter((n) => {
236
- const s = n.subject;
237
- return !s.startsWith(fe) || t.has(s) ? !0 : (i.push(s), !1);
238
- });
239
- return i.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", i), r;
240
- }
241
- const ge = "business::report::reports::", be = h.Subject.Business.report_reports_allDefaultReports, he = h.Subject.Business.report_reports_allCustomReports;
242
- function ve(e, t) {
243
- return e.conditions ? !!t.conditions && e.conditions === t.conditions : !t.conditions;
244
- }
245
- function Se(e, t) {
246
- const i = e.find(
247
- (a) => !a.inverted && a.subject === be
248
- ), r = e.find(
249
- (a) => !a.inverted && a.subject === he
250
- );
251
- if (!i && !r) return e;
252
- const n = i ? new Set(i.actions) : null, s = r ? new Set(r.actions) : null;
253
- return e.reduce((a, o) => {
254
- if (o.inverted)
255
- return a.push(o), a;
256
- const c = o.subject;
257
- if (!c.startsWith(ge))
258
- return a.push(o), a;
259
- const u = t.has(c), l = u ? n : s, m = u ? i : r;
260
- if (!l || !m || !ve(m, o))
261
- return a.push(o), a;
262
- if (l.has("manage")) return a;
263
- const d = o.actions;
264
- if (d.includes("manage"))
265
- return a.push(o), a;
266
- const f = new Set(d);
267
- for (const p of l)
268
- f.delete(p);
269
- return f.size === 0 || a.push({ ...o, actions: Array.from(f) }), a;
270
- }, []);
271
- }
272
- function T(e, t) {
273
- var i, r;
274
- const n = new Map(e.map((s) => [s.subject, s]));
275
- for (const s of t) {
276
- if (s.inverted) {
277
- const o = n.get(s.subject);
278
- if (s.conditions) {
279
- if (o != null && o.conditions) {
280
- const c = JSON.parse(o.conditions), u = JSON.parse(s.conditions);
281
- if (!w(c) || !w(u)) {
282
- n.delete(s.subject);
283
- continue;
284
- }
285
- const l = Object.keys(u)[0], m = ((i = u[l]) == null ? void 0 : i.$in) ?? [], d = (((r = c[l]) == null ? void 0 : r.$in) ?? []).filter((f) => !m.includes(f));
286
- d.length > 0 ? n.set(s.subject, {
287
- ...o,
288
- conditions: JSON.stringify({ [l]: { $in: d } })
289
- }) : n.delete(s.subject);
290
- } else
291
- n.delete(s.subject);
292
- continue;
293
- }
294
- if (o) {
295
- const c = new Set(s.actions), u = o.actions.filter((l) => !c.has(l));
296
- u.length > 0 ? n.set(s.subject, { ...o, actions: u }) : n.delete(s.subject);
297
- continue;
298
- }
299
- continue;
300
- }
301
- if (s.conditions) {
302
- n.set(s.subject, s);
303
- continue;
304
- }
305
- const a = n.get(s.subject);
306
- if (a != null && a.conditions && !w(JSON.parse(a.conditions))) {
307
- n.set(s.subject, s);
308
- continue;
309
- }
310
- if (a) {
311
- const o = [
312
- .../* @__PURE__ */ new Set([...a.actions, ...s.actions])
313
- ];
314
- n.set(s.subject, {
315
- ...a,
316
- actions: o
317
- });
318
- } else
319
- n.set(s.subject, s);
320
- }
321
- return Array.from(n.values());
322
- }
323
- function ye(e, t) {
324
- const i = T(e, t), r = new Set(e.map((s) => s.subject)), n = t.filter(
325
- (s) => s.inverted && !r.has(s.subject)
326
- );
327
- return [...i, ...n];
328
- }
329
- const q = (e) => JSON.parse(JSON.stringify(e));
330
- function ee(e) {
331
- const t = e.find(
332
- (i) => i.subject === h.Subject.Restaurant.restaurant
333
- );
334
- return t ? t.conditions ? JSON.parse(t.conditions).restaurantId.$in : null : [];
335
- }
336
- function te(e) {
337
- const t = e.find((i) => i.subject === h.Subject.Business.role);
338
- return t ? t.conditions ? JSON.parse(t.conditions).roleId.$in : null : [];
339
- }
340
- function je(e, t) {
341
- const i = q(
342
- e.filter((r) => r.subject !== h.Subject.Business.role)
343
- );
344
- return t && t.length > 0 && i.push({
345
- actions: [h.Action.manage],
346
- subject: h.Subject.Business.role,
347
- conditions: JSON.stringify({ roleId: { $in: t } })
348
- }), i;
349
- }
350
- function Le(e, t, { restaurantRoles: i, allRoleIds: r }) {
351
- let n = q(
352
- e.filter(
353
- (s) => s.subject !== h.Subject.Business.restaurant && s.subject !== h.Subject.Restaurant.restaurant
354
- )
355
- );
356
- if (!t || t.length > 0) {
357
- const {
358
- category: s,
359
- showByFeatureFlag: a,
360
- ...o
361
- } = z.restaurant;
362
- n.push(o);
363
- const c = {
364
- actions: [h.Action.manage],
365
- subject: h.Subject.Restaurant.restaurant
366
- };
367
- t && (c.conditions = JSON.stringify({ restaurantId: { $in: t } })), n.push(c);
368
- }
369
- if (t) {
370
- const s = [
371
- ...new Set(t.map((a) => i[a] ?? []).flatMap((a) => a))
372
- ];
373
- s.length !== r.length && (n = je(
374
- n,
375
- (te(e) || r).filter((a) => s.includes(a))
376
- ));
377
- }
378
- return n;
379
- }
380
- function xe(e) {
381
- let t = e.userPermissions;
382
- return e.reportSubjects && (t = pe(t, e.reportSubjects)), e.defaultReportSubjects && (t = Se(t, e.defaultReportSubjects)), {
383
- customPermissions: de(
384
- le(e.inheritedPermissions),
385
- me(t)
386
- ),
387
- permissions: t.filter((i) => !i.inverted).map((i) => ({ ...i, subject: re(i.subject) }))
388
- };
389
- }
390
- const J = "/permission-sets", U = {
391
- async read() {
392
- return g(await b().get(J));
393
- },
394
- async create(e) {
395
- return g(await b().post(J, e));
396
- },
397
- async update(e, t) {
398
- return g(await b().put(`${J}/${e}`, t));
399
- },
400
- async delete(e) {
401
- return g(await b().delete(`${J}/${e}`));
402
- }
403
- }, we = H("hrm-permission-set", () => {
404
- const e = V(), t = v([]), i = v(!1), r = v(null);
405
- async function n() {
406
- const u = e.id.value ?? null;
407
- if (r.value !== u)
408
- try {
409
- i.value = !0;
410
- const l = await U.read();
411
- t.value = c(l), r.value = u;
412
- } finally {
413
- i.value = !1;
414
- }
415
- }
416
- async function s(u) {
417
- const l = await U.create(u);
418
- t.value = c([...t.value, l]);
419
- }
420
- async function a(u, l) {
421
- const m = await U.update(u, l);
422
- t.value = c(t.value.map((d) => d.id === u ? m : d));
423
- }
424
- async function o(u) {
425
- await U.delete(u), t.value = c(t.value.filter((l) => l.id !== u));
426
- }
427
- function c(u) {
428
- return u.sort((l, m) => l.name.localeCompare(m.name));
429
- }
430
- return {
431
- permissionSets: t,
432
- isLoading: i,
433
- readPermissionSets: n,
434
- createPermissionSet: s,
435
- updatePermissionSet: a,
436
- deletePermissionSet: o
437
- };
438
- }), Pe = () => {
439
- const e = we();
440
- return {
441
- ...e,
442
- ...Q(e)
443
- };
444
- }, P = "/permission-assignments", I = {
445
- async readAll() {
446
- return g(await b().get(P));
447
- },
448
- async readByUserId(e) {
449
- return g(await b().get(`${P}/user/${e}`));
450
- },
451
- async readById(e) {
452
- return g(await b().get(`${P}/${e}`));
453
- },
454
- async create(e) {
455
- return g(await b().post(P, e));
456
- },
457
- async update(e, t) {
458
- return g(await b().put(`${P}/${e}`, t));
459
- },
460
- async delete(e) {
461
- return g(await b().delete(`${P}/${e}`));
462
- },
463
- async addReportManagePermission(e, t) {
464
- return g(
465
- await b().post("/my-permissions/report-manage", { permissionKey: e, label: t })
466
- );
467
- }
468
- }, $e = H("hrm-permission-assignment", () => {
469
- const e = v([]);
470
- async function t() {
471
- const o = await I.readAll();
472
- e.value = o;
473
- }
474
- async function i(o) {
475
- return await I.readByUserId(o);
476
- }
477
- async function r(o) {
478
- const c = await I.create(o);
479
- e.value = [...e.value, c];
480
- }
481
- async function n(o, c) {
482
- const u = await I.update(o, c);
483
- e.value = e.value.map((l) => l.id === o ? u : l);
484
- }
485
- async function s(o) {
486
- await I.delete(o), e.value = e.value.filter((c) => c.id !== o);
487
- }
488
- function a(o) {
489
- return e.value.find((c) => c.userId === o);
490
- }
491
- return {
492
- permissionAssignments: e,
493
- readPermissionAssignments: t,
494
- readPermissionAssignmentByUserId: i,
495
- createPermissionAssignment: r,
496
- updatePermissionAssignment: n,
497
- deletePermissionAssignment: s,
498
- getPermissionAssignmentByUserId: a
499
- };
500
- }), Ie = () => {
501
- const e = $e();
502
- return {
503
- ...e,
504
- ...Q(e)
505
- };
506
- }, Oe = {
507
- async fetchReportPermissions(e, t) {
508
- const i = t ? { lang: t } : {};
509
- return g(
510
- await L().get(`/report-query/hrm/${e}/reports`, { params: i })
511
- );
512
- },
513
- async fetchReportPermissionsForPortal(e, t) {
514
- const i = t ? { isSupportPos: !1, lang: t } : { isSupportPos: !1 };
515
- return g(
516
- await L().get(`/report-query/hrm/${e}/reports`, { params: i })
517
- );
518
- }
519
- }, O = v([]), B = v(!1), R = v(!1), A = v(null), D = v(null), M = v(!1);
520
- function Re() {
521
- const e = V();
522
- async function t() {
523
- const r = e.id.value;
524
- if (!r) return;
525
- const n = localStorage.getItem("locale");
526
- if (A.value !== r && (O.value = [], B.value = !1, R.value = !1, A.value = r, M.value = !1), !(B.value && D.value === n)) {
527
- if (R.value) {
528
- M.value = !0;
529
- return;
530
- }
531
- R.value = !0;
532
- try {
533
- const s = await Oe.fetchReportPermissionsForPortal(r, n);
534
- if (A.value !== r) return;
535
- O.value = s, B.value = !0, D.value = n;
536
- } catch (s) {
537
- if (A.value !== r) return;
538
- console.warn("Failed to fetch custom report permissions:", s), O.value = [];
539
- } finally {
540
- A.value === r && (R.value = !1, M.value && (M.value = !1, await t()));
541
- }
542
- }
543
- }
544
- const i = C(() => (e.isFoodCourt.value ? O.value.filter((n) => !n.isDefault || ie.has(n.permissionKey)) : O.value).map(
545
- (n) => n.isDefault ? {
546
- label: n.name,
547
- subject: `business::report::reports::${n.permissionKey}`,
548
- actions: [y.manage, y.read, y.create],
549
- category: x.reports
550
- } : {
551
- label: n.name,
552
- subject: `business::report::reports::${n.permissionKey}`,
553
- actions: [
554
- y.manage,
555
- y.read,
556
- y.create,
557
- y.update,
558
- y.delete
559
- ],
560
- category: x.customReports
561
- }
562
- ));
563
- return {
564
- fetchCustomReportPermissions: t,
565
- customReportPermissions: i,
566
- isLoading: C(() => R.value),
567
- isLoaded: C(() => B.value)
568
- };
569
- }
570
- function N(e) {
571
- const t = Pe(), i = Ie(), r = ae().restaurants, { customReportPermissions: n } = Re(), s = i.getPermissionAssignmentByUserId(e.id), a = Z(
572
- (s == null ? void 0 : s.permissionSetIds) ?? e.permissionSetIds ?? [],
573
- t.permissionSets.value
574
- ), o = Y(a).map(
575
- ({ setNames: p, ...S }) => S
576
- ), c = s == null ? void 0 : s.customPermissions, u = c ?? e.permissions.map((p) => ({
577
- ...p,
578
- subject: _(p.subject)
579
- })), l = T(o, u), m = G(
580
- ye(o, u),
581
- K
582
- ).filter((p) => !p.inverted), d = ee(m), f = d ?? r.value.map((p) => p._id);
583
- return {
584
- doc: e,
585
- id: e.id,
586
- // An invite's name is the admin's, or its sign-in key when it has none.
587
- name: e.status === "invited" ? e.name || "-" : e.name && e.name !== e.email && e.name !== e.phoneNumber ? e.name : "-",
588
- phoneNumber: e.phoneNumber,
589
- email: e.email,
590
- restaurants: W(
591
- f.map((p) => {
592
- var S;
593
- return ((S = r.value.find((se) => se._id === p)) == null ? void 0 : S.profile.name) ?? "";
594
- })
595
- ),
596
- managableRestaurantIds: d,
597
- permissionLabels: _e(m, n.value),
598
- permissions: l,
599
- status: e.status ?? "active",
600
- loginMethod: e.loginMethod ?? "feedme"
601
- };
602
- }
603
- const Ae = Object.freeze(
604
- Object.values(z)
605
- ), ke = {
606
- async readTeamMembers() {
607
- return g(
608
- await b().get("/portal-users")
609
- ).map(N);
610
- },
611
- async readTeamMembersPage(e) {
612
- var i, r, n, s, a;
613
- const t = g(
614
- await b().get("/portal-users/paged", {
615
- params: {
616
- limit: e.limit,
617
- offset: e.offset,
618
- search: e.search,
619
- restaurantIds: (i = e.restaurantIds) != null && i.length ? e.restaurantIds : void 0,
620
- permissionSubjects: (r = e.permissionSubjects) != null && r.length ? e.permissionSubjects : void 0,
621
- permissionSetIds: (n = e.permissionSetIds) != null && n.length ? e.permissionSetIds : void 0,
622
- statuses: (s = e.statuses) != null && s.length ? e.statuses : void 0,
623
- loginMethods: (a = e.loginMethods) != null && a.length ? e.loginMethods : void 0
624
- }
625
- })
626
- );
627
- return {
628
- items: t.items.map(N),
629
- total: t.total
630
- };
631
- },
632
- async readTeamMember(e) {
633
- return N(
634
- g(await b().get(`/portal-users/${e}`))
635
- );
636
- },
637
- async createTeamMember(e) {
638
- return N(
639
- g(await b().post("/portal-users", e))
640
- );
641
- },
642
- async updateTeamMember(e, t) {
643
- return N(
644
- g(await b().put(`/portal-users/${e}`, t))
645
- );
646
- },
647
- async deleteTeamMember(e) {
648
- return g(await b().delete(`/portal-users/${e}`));
649
- },
650
- async readTeamMemberPosUserIds() {
651
- return g(await b().get("/portal-users")).map((t) => t.posUserId);
652
- },
653
- async generateMasterUserPasscode(e) {
654
- return `${g(
655
- await b().post("/portal-users/generate-passcode", {
656
- restaurantIds: e.restaurantIds,
657
- excludePosUserId: e.excludePosUserId
658
- })
659
- )}`;
660
- }
661
- };
662
- function De(e, t, i) {
663
- if (e.some((a) => a.subject === "all")) return "All";
664
- const r = (i ?? F).filter(
665
- (a) => a.subject === t
666
- ), n = new Set(r.map((a) => $(a).value)), s = e.filter((a) => a.subject === t).filter((a) => n.has($(a).value));
667
- return s.length === r.length ? "All" : s.length === 0 ? "-" : `${s.length} permission allow`;
668
- }
669
- function $(e) {
670
- const t = ne(e), i = t.subject;
671
- return {
672
- ...t,
673
- get conditions() {
674
- if (typeof t.conditions != "string") return t.conditions;
675
- try {
676
- return JSON.parse(t.conditions);
677
- } catch {
678
- return;
679
- }
680
- },
681
- get isDiscountOperation() {
682
- var r;
683
- return i === j.F_RULE_SUBJECT.enum.order && ((r = this.conditions) == null ? void 0 : r.operation) === j.F_RULE_ORDER_OPERATION.enum.discount;
684
- },
685
- get isOrderOperation() {
686
- return i === j.F_RULE_SUBJECT.enum.order;
687
- },
688
- get isReportPermission() {
689
- return i === j.F_RULE_SUBJECT.enum.report;
690
- },
691
- /**
692
- * Order and report rules are only meaningful together with the condition
693
- * that names them. A rule missing it cannot be rendered or matched against
694
- * the available permission list, so callers must preserve it verbatim —
695
- * see `splitRoleFormPermissions`, which routes it to `passthrough`, not
696
- * `dropped`. Dropping it would silently revoke a grant the portal cannot
697
- * display (HRM-0027).
698
- */
699
- get isResolvable() {
700
- return this.discriminator !== void 0;
701
- },
702
- /**
703
- * The condition value that identifies this rule, if the subject needs one.
704
- * An empty condition counts as missing: `{ name: '' }` is a known corrupted
705
- * shape that used to resolve to the first hardcoded report permission on
706
- * save (HRM-0027), so it must not look resolvable here either.
707
- */
708
- get discriminator() {
709
- var r, n;
710
- return this.isOrderOperation ? ((r = this.conditions) == null ? void 0 : r.operation) || void 0 : this.isReportPermission ? ((n = this.conditions) == null ? void 0 : n.name) || void 0 : i.toString();
711
- },
712
- get formatted() {
713
- const r = this.discriminator;
714
- return r === void 0 ? i.toString() : r.endsWith("_") ? r.slice(0, r.length - 1) : r;
715
- },
716
- get label() {
717
- return t.label || oe(this.formatted);
718
- },
719
- get value() {
720
- const r = this.discriminator;
721
- return this.isOrderOperation || this.isReportPermission ? r === void 0 ? i.toString() : `${i}:${r}` : i.toString();
722
- }
723
- };
724
- }
725
- function We(e) {
726
- var r, n;
727
- const t = e.map((s) => $(s)).find((s) => s.isDiscountOperation);
728
- if (!t) return 100;
729
- const i = Number((n = (r = t.conditions) == null ? void 0 : r.adjustment) == null ? void 0 : n.$lte);
730
- return Number.isFinite(i) ? parseInt((i * 100).toFixed(0)) : 0;
731
- }
732
- function ze(e, t) {
733
- return t.isOwner ? { restaurantIds: null, roleIds: null } : { restaurantIds: ee(e), roleIds: te(e) };
734
- }
735
- function Ke(e) {
736
- return (e == null ? void 0 : e.some((t) => t.subject === "all")) ?? !1;
737
- }
738
- function Ve(e) {
739
- const t = $(e);
740
- if (!t.isReportPermission) return;
741
- const { name: i, ...r } = t.conditions ?? {};
742
- return Object.keys(r).length > 0 ? r : void 0;
743
- }
744
- function He(e, t, i) {
745
- return e.flatMap((r) => {
746
- const n = Ne(r);
747
- if (!n) return [];
748
- const s = n.isReportPermission ? i == null ? void 0 : i.get(r) : void 0;
749
- return [
750
- {
751
- subject: n.subject,
752
- actions: n.actions,
753
- conditions: {
754
- ...n.conditions,
755
- ...s ?? {},
756
- adjustment: n.isDiscountOperation ? { $lte: parseFloat((t / 100).toFixed(2)) } : void 0
757
- }
758
- }
759
- ];
760
- });
761
- }
762
- function Ne(e) {
763
- const t = e.indexOf(":"), i = t === -1 ? e : e.slice(0, t), r = t === -1 ? void 0 : e.slice(t + 1);
764
- if (t !== -1 && !r) return;
765
- let n;
766
- return r ? (n = F.find((s) => {
767
- if (s.subject !== i) return !1;
768
- const a = typeof s.conditions == "string" ? JSON.parse(s.conditions) : s.conditions;
769
- return [a == null ? void 0 : a.operation, a == null ? void 0 : a.name].includes(r);
770
- }), !n && i === j.F_RULE_SUBJECT.enum.report && (n = {
771
- label: "",
772
- subject: j.F_RULE_SUBJECT.enum.report,
773
- actions: ["read"],
774
- conditions: { name: r },
775
- inverted: !1,
776
- reason: ""
777
- })) : n = F.find((s) => s.subject === i), n ? $(n) : void 0;
778
- }
779
- function Qe(e, t) {
780
- const i = { values: [], passthrough: [], dropped: [] };
781
- for (const r of e) {
782
- const n = r == null ? void 0 : r.actions;
783
- if (typeof (r == null ? void 0 : r.subject) != "string" || r.subject.trim().length === 0 || !Array.isArray(n) || n.length === 0 || n.some((c) => typeof c != "string" || c.trim().length === 0)) {
784
- i.dropped.push(r);
785
- continue;
786
- }
787
- const s = $(r).value, a = `${j.F_RULE_SUBJECT.enum.report}:`, o = s.startsWith(a) ? s.slice(a.length) : "";
788
- t.has(s) || o && o !== "undefined" ? i.values.push(s) : i.passthrough.push(r);
789
- }
790
- return i;
791
- }
792
- function _e(e, t = []) {
793
- return W(
794
- e.reduce((i, r) => {
795
- const n = Ae.find(
796
- (s) => s.subject === r.subject && r.actions.includes("manage")
797
- ) || t.find((s) => s.subject === r.subject);
798
- if (n) {
799
- const s = n.subject === h.Subject.Business.inventory_stock ? "Warehouse Management" : n.label;
800
- i.push(s);
801
- }
802
- return i;
803
- }, [])
804
- );
805
- }
806
- export {
807
- fe as $,
808
- te as A,
809
- pe as B,
810
- je as C,
811
- Le as D,
812
- de as E,
813
- ye as H,
814
- G as N,
815
- Z as P,
816
- ee as Q,
817
- le as R,
818
- me as T,
819
- Fe as V,
820
- Te as Y,
821
- Re as a,
822
- ze as b,
823
- Ie as c,
824
- He as d,
825
- Ve as e,
826
- De as f,
827
- We as g,
828
- Ke as h,
829
- Oe as i,
830
- Y as j,
831
- _e as m,
832
- Ae as p,
833
- $ as r,
834
- Qe as s,
835
- ke as t,
836
- Pe as u,
837
- Se as x,
838
- xe as z
839
- };