@feedmepos/mf-hrm-portal 2.4.2-dev → 2.4.2

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