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