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

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 (44) hide show
  1. package/dist/{AuditLogList-COq6WH3T.js → AuditLogList-BWzKxoBK.js} +24 -23
  2. package/dist/{EmployeeList-CtosIPFL.js → EmployeeList-CPvHmCle.js} +164 -169
  3. package/dist/FormSection.vue_vue_type_script_setup_true_lang-BVb8c4YU.js +71 -0
  4. package/dist/HorizontalSplitter-o860F4xM.js +12 -0
  5. package/dist/{Main-B4YdcrGe.js → Main-BEj_iUkZ.js} +8 -7
  6. package/dist/{Main-CdsqeB2G.js → Main-BNywXKr0.js} +11 -10
  7. package/dist/Main-BkIzKoHQ.js +560 -0
  8. package/dist/PermissionSetList-B8jSoL19.js +338 -0
  9. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-Ddnj8eg_.js +3356 -0
  10. package/dist/{RoleList-D1NGE2IC.js → RoleList-BEx1B8PE.js} +26 -24
  11. package/dist/TeamMemberList-BEDwcjeT.js +989 -0
  12. package/dist/{TimesheetList-B8yCkaxb.js → TimesheetList-CqZG4xmE.js} +11 -10
  13. package/dist/{app-CB3ye-CT.js → app-DHtKeCwy.js} +1333 -1060
  14. package/dist/app.js +2 -2
  15. package/dist/{dayjs.min-DOxEzdpe.js → dayjs.min-BWWy9u8p.js} +1 -1
  16. package/dist/{employee-G0pQg8_6.js → employee-C2ys9jf0.js} +21 -20
  17. package/dist/index-BwYlZrxP.js +968 -0
  18. package/dist/{index-DQArLkVB.js → index-O9ipnK-U.js} +1 -1
  19. package/dist/{index-Beu6IuhT.js → iteration-BdhU8jGb.js} +3444 -4352
  20. package/dist/{lodash-COjtwv4w.js → lodash-CDSEYvRz.js} +1 -1
  21. package/dist/src/api/grant-user/index.d.ts +8 -0
  22. package/dist/src/api/index.d.ts +3 -1
  23. package/dist/src/api/permission-assignment/index.d.ts +1 -1
  24. package/dist/src/helpers/permission-set.d.ts +26 -4
  25. package/dist/src/helpers/permission-set.test.d.ts +1 -0
  26. package/dist/src/router/shared.d.ts +2 -1
  27. package/dist/src/stores/grant-user.d.ts +86 -0
  28. package/dist/src/types/grant-user.d.ts +27 -0
  29. package/dist/src/views/grant/GrantUserList.vue.d.ts +17 -0
  30. package/dist/src/views/grant/Main.vue.d.ts +2 -0
  31. package/dist/src/views/grant/components/GrantUserForm.vue.d.ts +17 -0
  32. package/dist/src/views/grant/locales/index.d.ts +232 -0
  33. package/dist/{team-CEtKQK6n.js → team-9CwJsJGX.js} +1 -1
  34. package/dist/{timesheet-DZF9D3QQ.js → timesheet-ChKYJtjK.js} +10 -9
  35. package/dist/tsconfig.app.tsbuildinfo +1 -1
  36. package/dist/{useAppStore-9lbKMy_9.js → useAppStore-DGzBzMIR.js} +1 -1
  37. package/dist/{useLoading-BIIvuJcM.js → useLoading-CzteZR_c.js} +1 -1
  38. package/dist/{useReportPermissions-BXQ0-WwK.js → useReportPermissions-CaY_wr2l.js} +12 -11
  39. package/dist/useRestaurantMap-e9fQJiLC.js +39 -0
  40. package/package.json +2 -2
  41. package/dist/PermissionSetList-BUORArci.js +0 -327
  42. package/dist/PortalPermissionEditor.vue_vue_type_script_setup_true_lang-ChqCTn1L.js +0 -3333
  43. package/dist/TeamMemberList-auSjZRNz.js +0 -979
  44. package/dist/useRestaurantMap-D5BNPLKh.js +0 -107
@@ -0,0 +1,968 @@
1
+ import { g as b, b as g, d as X, e as j, s as L, q as M } from "./iteration-BdhU8jGb.js";
2
+ import { d as J, u as R, a as F, i as D, b as S, N as Q } from "./app-DHtKeCwy.js";
3
+ import { defineStore as x, storeToRefs as k } from "pinia";
4
+ import { ref as h, computed as N } from "vue";
5
+ import { useCoreStore as q } from "@feedmepos/mf-common";
6
+ const T = [
7
+ {
8
+ label: "",
9
+ subject: "order",
10
+ actions: ["update"],
11
+ conditions: {
12
+ operation: "discount",
13
+ adjustment: {
14
+ $lte: 1
15
+ }
16
+ },
17
+ inverted: !1,
18
+ reason: null
19
+ },
20
+ {
21
+ label: "",
22
+ subject: "order",
23
+ actions: ["update"],
24
+ conditions: { operation: "changePrice" },
25
+ inverted: !1,
26
+ reason: null
27
+ },
28
+ {
29
+ label: "",
30
+ subject: "order",
31
+ actions: ["update"],
32
+ conditions: { operation: "void" },
33
+ inverted: !1,
34
+ reason: null
35
+ },
36
+ {
37
+ label: "",
38
+ subject: "order",
39
+ actions: ["update"],
40
+ conditions: { operation: "payment" },
41
+ inverted: !1,
42
+ reason: null
43
+ },
44
+ {
45
+ label: "",
46
+ subject: "order",
47
+ actions: ["update"],
48
+ conditions: { operation: "claimDeposit" },
49
+ inverted: !1,
50
+ reason: null
51
+ },
52
+ {
53
+ label: "",
54
+ subject: "order",
55
+ actions: ["update"],
56
+ conditions: { operation: "resend" },
57
+ inverted: !1,
58
+ reason: null
59
+ },
60
+ {
61
+ label: "",
62
+ subject: "order",
63
+ actions: ["update"],
64
+ conditions: { operation: "changePaymentType" },
65
+ inverted: !1,
66
+ reason: null
67
+ },
68
+ {
69
+ label: "",
70
+ subject: "refund",
71
+ actions: ["create"],
72
+ conditions: null,
73
+ inverted: !1,
74
+ reason: null
75
+ },
76
+ {
77
+ label: "",
78
+ subject: "counter",
79
+ actions: ["manage"],
80
+ conditions: null,
81
+ inverted: !1,
82
+ reason: null
83
+ },
84
+ {
85
+ label: "",
86
+ subject: "mallIntegration",
87
+ actions: ["manage"],
88
+ conditions: null,
89
+ inverted: !1,
90
+ reason: null
91
+ },
92
+ {
93
+ label: "",
94
+ subject: "drawer",
95
+ actions: ["manage"],
96
+ conditions: null,
97
+ inverted: !1,
98
+ reason: null
99
+ },
100
+ {
101
+ label: "",
102
+ subject: "menu",
103
+ actions: ["manage"],
104
+ conditions: null,
105
+ inverted: !1,
106
+ reason: null
107
+ },
108
+ {
109
+ label: "",
110
+ subject: "inventory",
111
+ actions: ["manage"],
112
+ conditions: null,
113
+ inverted: !1,
114
+ reason: null
115
+ },
116
+ {
117
+ label: "",
118
+ subject: "deposit",
119
+ actions: ["manage"],
120
+ conditions: null,
121
+ inverted: !1,
122
+ reason: null
123
+ },
124
+ {
125
+ label: "",
126
+ subject: "delivery",
127
+ actions: ["manage"],
128
+ conditions: null,
129
+ inverted: !1,
130
+ reason: null
131
+ },
132
+ {
133
+ label: "",
134
+ subject: "counterRecord",
135
+ actions: ["manage"],
136
+ conditions: null,
137
+ inverted: !1,
138
+ reason: null
139
+ },
140
+ {
141
+ label: "",
142
+ subject: "restaurantSetting",
143
+ actions: ["manage"],
144
+ conditions: null,
145
+ inverted: !1,
146
+ reason: null
147
+ },
148
+ {
149
+ label: "",
150
+ subject: "display",
151
+ actions: ["manage"],
152
+ conditions: null,
153
+ inverted: !1,
154
+ reason: null
155
+ },
156
+ {
157
+ label: "",
158
+ subject: "printer",
159
+ actions: ["manage"],
160
+ conditions: null,
161
+ inverted: !1,
162
+ reason: null
163
+ },
164
+ {
165
+ label: "",
166
+ subject: "table",
167
+ actions: ["manage"],
168
+ conditions: null,
169
+ inverted: !1,
170
+ reason: null
171
+ },
172
+ {
173
+ label: "",
174
+ subject: "employee",
175
+ actions: ["manage"],
176
+ conditions: null,
177
+ inverted: !1,
178
+ reason: null
179
+ },
180
+ {
181
+ label: "",
182
+ subject: "system",
183
+ actions: ["manage"],
184
+ conditions: null,
185
+ inverted: !1,
186
+ reason: null
187
+ },
188
+ {
189
+ label: "",
190
+ subject: "tax",
191
+ actions: ["manage"],
192
+ conditions: null,
193
+ inverted: !1,
194
+ reason: null
195
+ },
196
+ {
197
+ label: "",
198
+ subject: "paymentType",
199
+ actions: ["manage"],
200
+ conditions: null,
201
+ inverted: !1,
202
+ reason: null
203
+ },
204
+ {
205
+ label: "",
206
+ subject: "faceId",
207
+ actions: ["manage"],
208
+ conditions: null,
209
+ inverted: !1,
210
+ reason: null
211
+ },
212
+ {
213
+ label: "",
214
+ subject: "report",
215
+ actions: ["read"],
216
+ conditions: { name: "closeup" },
217
+ inverted: !1,
218
+ reason: ""
219
+ },
220
+ {
221
+ label: "",
222
+ subject: "report",
223
+ actions: ["read"],
224
+ conditions: { name: "counter" },
225
+ inverted: !1,
226
+ reason: ""
227
+ },
228
+ {
229
+ label: "",
230
+ subject: "report",
231
+ actions: ["read"],
232
+ conditions: { name: "hourlySales" },
233
+ inverted: !1,
234
+ reason: ""
235
+ },
236
+ {
237
+ label: "",
238
+ subject: "report",
239
+ actions: ["read"],
240
+ conditions: { name: "dailySales" },
241
+ inverted: !1,
242
+ reason: ""
243
+ },
244
+ {
245
+ label: "",
246
+ subject: "report",
247
+ actions: ["read"],
248
+ conditions: { name: "productSales" },
249
+ inverted: !1,
250
+ reason: ""
251
+ },
252
+ {
253
+ label: "",
254
+ subject: "report",
255
+ actions: ["read"],
256
+ conditions: { name: "sourceProductSales" },
257
+ inverted: !1,
258
+ reason: ""
259
+ },
260
+ {
261
+ label: "",
262
+ subject: "report",
263
+ actions: ["read"],
264
+ conditions: { name: "userProductSales" },
265
+ inverted: !1,
266
+ reason: ""
267
+ },
268
+ {
269
+ label: "",
270
+ subject: "report",
271
+ actions: ["read"],
272
+ conditions: { name: "categorySales" },
273
+ inverted: !1,
274
+ reason: ""
275
+ },
276
+ {
277
+ label: "",
278
+ subject: "report",
279
+ actions: ["read"],
280
+ conditions: { name: "addonSales" },
281
+ inverted: !1,
282
+ reason: ""
283
+ },
284
+ {
285
+ label: "",
286
+ subject: "report",
287
+ actions: ["read"],
288
+ conditions: { name: "slotSales" },
289
+ inverted: !1,
290
+ reason: ""
291
+ },
292
+ {
293
+ label: "",
294
+ subject: "report",
295
+ actions: ["read"],
296
+ conditions: { name: "drawer" },
297
+ inverted: !1,
298
+ reason: ""
299
+ },
300
+ {
301
+ label: "",
302
+ subject: "report",
303
+ actions: ["read"],
304
+ conditions: { name: "discount" },
305
+ inverted: !1,
306
+ reason: ""
307
+ },
308
+ {
309
+ label: "",
310
+ subject: "report",
311
+ actions: ["read"],
312
+ conditions: { name: "refund" },
313
+ inverted: !1,
314
+ reason: ""
315
+ },
316
+ {
317
+ label: "",
318
+ subject: "report",
319
+ actions: ["read"],
320
+ conditions: { name: "void" },
321
+ inverted: !1,
322
+ reason: ""
323
+ },
324
+ {
325
+ label: "",
326
+ subject: "report",
327
+ actions: ["read"],
328
+ conditions: { name: "timesheet" },
329
+ inverted: !1,
330
+ reason: ""
331
+ },
332
+ {
333
+ label: "",
334
+ subject: "report",
335
+ actions: ["read"],
336
+ conditions: { name: "counterPayment" },
337
+ inverted: !1,
338
+ reason: ""
339
+ }
340
+ ], A = "/permission-sets", I = {
341
+ async read() {
342
+ return b(await g().get(A));
343
+ },
344
+ async create(e) {
345
+ return b(await g().post(A, e));
346
+ },
347
+ async update(e, n) {
348
+ return b(await g().put(`${A}/${e}`, n));
349
+ },
350
+ async delete(e) {
351
+ return b(await g().delete(`${A}/${e}`));
352
+ }
353
+ }, Z = x("permissionSet", () => {
354
+ const e = h([]);
355
+ async function n() {
356
+ const r = await I.read();
357
+ e.value = s(r);
358
+ }
359
+ async function o(r) {
360
+ const i = await I.create(r);
361
+ e.value = s([...e.value, i]);
362
+ }
363
+ async function t(r, i) {
364
+ const c = await I.update(r, i);
365
+ e.value = s(e.value.map((u) => u.id === r ? c : u));
366
+ }
367
+ async function a(r) {
368
+ await I.delete(r), e.value = s(e.value.filter((i) => i.id !== r));
369
+ }
370
+ function s(r) {
371
+ return r.sort((i, c) => i.name.localeCompare(c.name));
372
+ }
373
+ return {
374
+ permissionSets: e,
375
+ readPermissionSets: n,
376
+ createPermissionSet: o,
377
+ updatePermissionSet: t,
378
+ deletePermissionSet: a
379
+ };
380
+ }), G = () => {
381
+ const e = Z();
382
+ return {
383
+ ...e,
384
+ ...k(e)
385
+ };
386
+ };
387
+ function Se(e) {
388
+ let n = e.substring(e.indexOf("_") + 1);
389
+ return n.includes("_") && (n = n.substring(0, n.lastIndexOf("_"))), Number.isNaN(Date.parse(n)) ? null : new Date(n).toISOString();
390
+ }
391
+ function je(e) {
392
+ const n = Math.floor(e / 60), o = e % 60;
393
+ return `${n}h ${o.toString().padStart(2, "0")}m`;
394
+ }
395
+ function H(e) {
396
+ const n = e.replace(/([A-Z])/g, " $1");
397
+ return n.charAt(0).toUpperCase() + n.slice(1);
398
+ }
399
+ function ye(e, n, o) {
400
+ if (e.some((r) => r.subject === "all")) return "All";
401
+ const t = (o ?? T).filter(
402
+ (r) => r.subject === n
403
+ ), a = new Set(t.map((r) => E(r).value)), s = e.filter((r) => r.subject === n).filter((r) => a.has(E(r).value));
404
+ return s.length === t.length ? "All" : s.length === 0 ? "-" : `${s.length} permission allow`;
405
+ }
406
+ function E(e) {
407
+ const n = X(e), o = n.subject;
408
+ return {
409
+ ...n,
410
+ get conditions() {
411
+ return typeof n.conditions == "string" ? JSON.parse(n.conditions) : n.conditions;
412
+ },
413
+ get isDiscountOperation() {
414
+ var t;
415
+ return o === j.F_RULE_SUBJECT.enum.order && ((t = this.conditions) == null ? void 0 : t.operation) === j.F_RULE_ORDER_OPERATION.enum.discount;
416
+ },
417
+ get isOrderOperation() {
418
+ return o === j.F_RULE_SUBJECT.enum.order;
419
+ },
420
+ get isReportPermission() {
421
+ return o === j.F_RULE_SUBJECT.enum.report;
422
+ },
423
+ get formatted() {
424
+ const t = (a) => a.endsWith("_") ? a.slice(0, a.length - 1) : a;
425
+ return this.isOrderOperation ? t(this.conditions.operation) : this.isReportPermission ? t(this.conditions.name) : o.toString();
426
+ },
427
+ get label() {
428
+ return n.label || H(this.formatted);
429
+ },
430
+ get value() {
431
+ return this.isOrderOperation ? `${o}:${this.conditions.operation}` : this.isReportPermission ? `${o}:${this.conditions.name}` : o.toString();
432
+ }
433
+ };
434
+ }
435
+ function he(e) {
436
+ const n = e.map((o) => E(o)).find((o) => o.isDiscountOperation);
437
+ return n ? parseInt((n.conditions.adjustment.$lte * 100).toFixed(0)) : 100;
438
+ }
439
+ function Y(e) {
440
+ const n = e.find(
441
+ (o) => o.subject === J.Subject.Restaurant.restaurant
442
+ );
443
+ return n ? n.conditions ? JSON.parse(n.conditions).restaurantId.$in : null : [];
444
+ }
445
+ function Pe(e) {
446
+ return (e == null ? void 0 : e.some((n) => n.subject === "all")) ?? !1;
447
+ }
448
+ function we(e) {
449
+ const n = e.find((o) => o.subject === J.Subject.Business.role);
450
+ return n ? n.conditions ? JSON.parse(n.conditions).roleId.$in : null : [];
451
+ }
452
+ function $e(e, n) {
453
+ return e.map((o) => {
454
+ const t = ee(o);
455
+ return {
456
+ subject: t.subject,
457
+ actions: t.actions,
458
+ conditions: {
459
+ ...t.conditions,
460
+ adjustment: t.isDiscountOperation ? { $lte: parseFloat((n / 100).toFixed(2)) } : void 0
461
+ }
462
+ };
463
+ });
464
+ }
465
+ function ee(e) {
466
+ const [n, o] = e.split(":");
467
+ let t;
468
+ return o ? (t = T.find(
469
+ (a) => a.subject === n && [
470
+ (typeof a.conditions == "object" ? a.conditions : JSON.parse(a.conditions)).operation,
471
+ a.conditions.name
472
+ ].includes(o)
473
+ ), !t && n === j.F_RULE_SUBJECT.enum.report && (t = {
474
+ label: "",
475
+ subject: j.F_RULE_SUBJECT.enum.report,
476
+ actions: ["read"],
477
+ conditions: { name: o },
478
+ inverted: !1,
479
+ reason: ""
480
+ })) : t = T.find((a) => a.subject === n), E(t || { subject: j.F_RULE_SUBJECT.enum.order, actions: [], label: "" });
481
+ }
482
+ function ne(e, n = []) {
483
+ return L(
484
+ e.reduce((o, t) => {
485
+ const a = me.find((s) => s.subject === t.subject) || n.find((s) => s.subject === t.subject);
486
+ if (a) {
487
+ const s = a.subject === J.Subject.Business.inventory_stock ? "Warehouse Management" : a.label;
488
+ o.push(s);
489
+ }
490
+ return o;
491
+ }, [])
492
+ );
493
+ }
494
+ function W(e) {
495
+ const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), t = (a, s, r) => {
496
+ var i, c;
497
+ const u = `${s.subject}::${JSON.stringify([...s.actions].sort())}`, l = a.get(u);
498
+ if (!l) {
499
+ a.set(u, { ...s, setNames: [r.name], setId: r._id });
500
+ return;
501
+ }
502
+ if (l.setNames.push(r.name), l.conditions && s.conditions) {
503
+ const d = typeof l.conditions == "string" ? JSON.parse(l.conditions) : l.conditions, p = typeof s.conditions == "string" ? JSON.parse(s.conditions) : s.conditions;
504
+ for (const m in p)
505
+ (i = d[m]) != null && i.$in && (c = p[m]) != null && c.$in ? d[m].$in = Array.from(/* @__PURE__ */ new Set([...d[m].$in, ...p[m].$in])) : d[m] || (d[m] = p[m]);
506
+ l.conditions = JSON.stringify(d);
507
+ }
508
+ };
509
+ for (const a of e)
510
+ for (const s of a.permissions)
511
+ t(s.inverted ? o : n, s, a);
512
+ return [...Array.from(n.values()), ...Array.from(o.values())];
513
+ }
514
+ function C(e, n) {
515
+ return `${e}::${[...n].sort().join(",")}`;
516
+ }
517
+ function z(e, n) {
518
+ const o = [...e], t = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
519
+ for (const i of e) {
520
+ const c = R(i.subject);
521
+ t.add(C(c, i.actions)), i.inverted && i.actions.includes("manage") && a.add(`set_${c}`), !i.inverted && i.actions.includes("manage") && s.add(c);
522
+ }
523
+ const r = [...e];
524
+ for (; r.length > 0; ) {
525
+ const i = r.shift(), c = `set_${R(i.subject)}`, u = n[c];
526
+ if (!u || a.has(c) || !i.actions.includes("manage") || i.inverted) continue;
527
+ a.add(c);
528
+ const l = te(i);
529
+ i.source && !i.source.trace && (i.source = { ...i.source, trace: l });
530
+ const d = [...l, `${u.name} (system)`];
531
+ for (const p of u.permissions ?? []) {
532
+ const m = R(p.subject), f = C(m, p.actions);
533
+ t.has(f) || s.has(m) || (t.add(f), o.push({
534
+ ...p,
535
+ // FdoPermissionRule.fields is string[] | null; RawRule expects string[] | undefined
536
+ fields: p.fields ?? void 0,
537
+ source: {
538
+ type: "systemPermissionSet",
539
+ permissionSetId: u.key,
540
+ permissionSetName: u.name,
541
+ trace: d
542
+ }
543
+ }));
544
+ }
545
+ for (const p of u.permissionSets ?? []) {
546
+ const m = R(p), f = C(m, ["manage"]), v = {
547
+ subject: m,
548
+ actions: ["manage"],
549
+ source: {
550
+ type: "systemPermissionSet",
551
+ permissionSetId: u.key,
552
+ permissionSetName: u.name,
553
+ trace: d
554
+ }
555
+ };
556
+ t.has(f) || (t.add(f), o.push(v)), r.push(v);
557
+ }
558
+ }
559
+ return [...o.filter((i) => !i.inverted), ...o.filter((i) => i.inverted)];
560
+ }
561
+ function te(e) {
562
+ if (!e.source) return [];
563
+ const { type: n, trace: o, permissionSetName: t } = e.source;
564
+ if (o && o.length > 0) return o;
565
+ switch (n) {
566
+ case "permissionSet":
567
+ return t ? [t] : [];
568
+ case "custom":
569
+ return ["custom"];
570
+ default:
571
+ return [];
572
+ }
573
+ }
574
+ function V(e, n, o = /* @__PURE__ */ new Set()) {
575
+ var a;
576
+ const t = [];
577
+ for (const s of e) {
578
+ if (o.has(s)) continue;
579
+ o.add(s);
580
+ const r = n.find((i) => i.id === s);
581
+ r && (t.push(r), (a = r.permissionSetIds) != null && a.length && t.push(...V(r.permissionSetIds, n, o)));
582
+ }
583
+ return t;
584
+ }
585
+ function Re(e) {
586
+ const n = W(e).map(
587
+ ({ setNames: a, setId: s, ...r }) => r
588
+ ), o = n.filter((a) => !a.inverted), t = n.filter((a) => a.inverted);
589
+ return B(o, t);
590
+ }
591
+ function Ae(e, n, o) {
592
+ const t = /* @__PURE__ */ new Map();
593
+ return e.forEach(
594
+ ({ name: a, permissions: s }) => s.forEach(({ conditions: r, actions: i }) => {
595
+ var u, l;
596
+ const c = JSON.parse(r || "{}");
597
+ (u = c[n]) != null && u.$in ? (l = c[n]) == null || l.$in.forEach(
598
+ (d) => (t.get(d) ?? t.set(d, /* @__PURE__ */ new Set()).get(d)).add(a)
599
+ ) : i[0] === "manage" && o.forEach((d) => {
600
+ (t.get(d) ?? t.set(d, /* @__PURE__ */ new Set()).get(d)).add(a);
601
+ });
602
+ })
603
+ ), [...t].map(([a, s]) => ({
604
+ id: a,
605
+ setNames: [...s]
606
+ }));
607
+ }
608
+ function Ie(e, n) {
609
+ const o = (i, c) => {
610
+ const u = { ...i }, l = JSON.parse(u.conditions || "{}");
611
+ if (c)
612
+ if (c.length > 0) {
613
+ const d = Object.keys(l)[0];
614
+ l[d].$in = c;
615
+ } else
616
+ delete u.conditions;
617
+ return {
618
+ ...u,
619
+ inverted: !0,
620
+ ...u.conditions && { conditions: JSON.stringify(l) }
621
+ };
622
+ }, t = new Map(e.map((i) => [i.subject, i])), a = new Map(n.map((i) => [i.subject, i])), s = [], r = /* @__PURE__ */ new Set([...t.keys(), ...a.keys()]);
623
+ for (const i of r) {
624
+ const c = t.get(i), u = a.get(i);
625
+ if (c && u) {
626
+ if (c.conditions && u.conditions) {
627
+ const l = JSON.parse(c.conditions), d = JSON.parse(u.conditions), p = Object.keys(l)[0], m = l[p].$in.filter(
628
+ (v) => !d[p].$in.includes(v)
629
+ );
630
+ m.length > 0 && s.push(o(c, m)), d[p].$in.filter(
631
+ (v) => !l[p].$in.includes(v)
632
+ ).length > 0 && s.push(u);
633
+ } else if (!c.conditions && u.conditions)
634
+ s.push(u);
635
+ else if (!c.conditions && !u.conditions) {
636
+ const l = new Set(c.actions), d = new Set(u.actions), p = u.actions.some((f) => !l.has(f)), m = c.actions.filter((f) => !d.has(f));
637
+ if (p) {
638
+ const f = u.actions.filter((v) => !l.has(v));
639
+ s.push({
640
+ ...u,
641
+ actions: f
642
+ });
643
+ }
644
+ m.length > 0 && s.push({
645
+ ...c,
646
+ actions: m,
647
+ inverted: !0
648
+ });
649
+ }
650
+ continue;
651
+ }
652
+ if (c) {
653
+ s.push(
654
+ o(
655
+ c,
656
+ // If base has conditions, set diffIds to empty array, disallow all access to collection
657
+ // otherwise, invert directly
658
+ c.conditions && []
659
+ )
660
+ );
661
+ continue;
662
+ }
663
+ u && s.push(u);
664
+ }
665
+ return s;
666
+ }
667
+ function Oe(e) {
668
+ const n = z(
669
+ e,
670
+ F
671
+ ), o = new Set(
672
+ n.filter((t) => {
673
+ var a;
674
+ return ((a = t.source) == null ? void 0 : a.type) === "systemPermissionSet" && !t.inverted;
675
+ }).map((t) => t.subject)
676
+ );
677
+ return e.filter((t) => t.inverted || !o.has(t.subject));
678
+ }
679
+ const se = "business::report::";
680
+ function _e(e, n) {
681
+ const o = [], t = e.filter((a) => {
682
+ const s = a.subject;
683
+ return !s.startsWith(se) || n.has(s) ? !0 : (o.push(s), !1);
684
+ });
685
+ return o.length > 0 && console.warn("[filterStalePermissions] dropped stale report permissions:", o), t;
686
+ }
687
+ const oe = "business::report::reports::", ie = "business::report::allDefaultReports", re = "business::report::allCustomReports";
688
+ function Ee(e, n) {
689
+ const o = e.find(
690
+ (r) => !r.inverted && r.subject === ie
691
+ ), t = e.find(
692
+ (r) => !r.inverted && r.subject === re
693
+ );
694
+ if (!o && !t) return e;
695
+ const a = o ? new Set(o.actions) : null, s = t ? new Set(t.actions) : null;
696
+ return e.reduce((r, i) => {
697
+ if (i.inverted)
698
+ return r.push(i), r;
699
+ const c = i.subject;
700
+ if (!c.startsWith(oe))
701
+ return r.push(i), r;
702
+ const l = n.has(c) ? a : s;
703
+ if (!l)
704
+ return r.push(i), r;
705
+ if (l.has("manage")) return r;
706
+ const d = new Set(i.actions), p = d.has("manage");
707
+ let m = !1;
708
+ for (const f of l)
709
+ f !== "manage" && d.delete(f) && (m = !0);
710
+ return p && m && d.delete("manage"), d.size === 0 || r.push({ ...i, actions: Array.from(d) }), r;
711
+ }, []);
712
+ }
713
+ function B(e, n) {
714
+ var t, a;
715
+ const o = new Map(e.map((s) => [s.subject, s]));
716
+ for (const s of n) {
717
+ if (s.inverted) {
718
+ const i = o.get(s.subject);
719
+ if (s.conditions) {
720
+ if (i != null && i.conditions) {
721
+ const c = JSON.parse(i.conditions), u = JSON.parse(s.conditions), l = Object.keys(u)[0], d = ((t = u[l]) == null ? void 0 : t.$in) ?? [], m = (((a = c[l]) == null ? void 0 : a.$in) ?? []).filter((f) => !d.includes(f));
722
+ m.length > 0 ? o.set(s.subject, {
723
+ ...i,
724
+ conditions: JSON.stringify({ [l]: { $in: m } })
725
+ }) : o.delete(s.subject);
726
+ } else
727
+ o.delete(s.subject);
728
+ continue;
729
+ }
730
+ if (i) {
731
+ const c = new Set(s.actions), u = i.actions.filter((l) => !c.has(l));
732
+ u.length > 0 ? o.set(s.subject, { ...i, actions: u }) : o.delete(s.subject);
733
+ continue;
734
+ }
735
+ continue;
736
+ }
737
+ if (s.conditions) {
738
+ o.set(s.subject, s);
739
+ continue;
740
+ }
741
+ const r = o.get(s.subject);
742
+ if (r) {
743
+ const i = [
744
+ .../* @__PURE__ */ new Set([
745
+ ...r.actions,
746
+ ...s.actions
747
+ ])
748
+ ];
749
+ o.set(s.subject, { ...r, actions: i });
750
+ } else
751
+ o.set(s.subject, s);
752
+ }
753
+ return Array.from(o.values());
754
+ }
755
+ function ae(e, n) {
756
+ const o = B(e, n), t = new Set(e.map((s) => s.subject)), a = n.filter(
757
+ (s) => s.inverted && !t.has(s.subject)
758
+ );
759
+ return [...o, ...a];
760
+ }
761
+ const y = "/permission-assignments", P = {
762
+ async readAll() {
763
+ return b(await g().get(y));
764
+ },
765
+ async readByUserId(e) {
766
+ return b(await g().get(`${y}/user/${e}`));
767
+ },
768
+ async readById(e) {
769
+ return b(await g().get(`${y}/${e}`));
770
+ },
771
+ async create(e) {
772
+ return b(await g().post(y, e));
773
+ },
774
+ async update(e, n) {
775
+ return b(await g().put(`${y}/${e}`, n));
776
+ },
777
+ async delete(e) {
778
+ return b(await g().delete(`${y}/${e}`));
779
+ },
780
+ async addReportManagePermission(e, n) {
781
+ return b(
782
+ await g().post("/my-permissions/report-manage", { permissionKey: e, label: n })
783
+ );
784
+ }
785
+ }, ce = x("permissionAssignment", () => {
786
+ const e = h([]);
787
+ async function n() {
788
+ const i = await P.readAll();
789
+ e.value = i;
790
+ }
791
+ async function o(i) {
792
+ return await P.readByUserId(i);
793
+ }
794
+ async function t(i) {
795
+ const c = await P.create(i);
796
+ e.value = [...e.value, c];
797
+ }
798
+ async function a(i, c) {
799
+ const u = await P.update(i, c);
800
+ e.value = e.value.map((l) => l.id === i ? u : l);
801
+ }
802
+ async function s(i) {
803
+ await P.delete(i), e.value = e.value.filter((c) => c.id !== i);
804
+ }
805
+ function r(i) {
806
+ return e.value.find((c) => c.userId === i);
807
+ }
808
+ return {
809
+ permissionAssignments: e,
810
+ readPermissionAssignments: n,
811
+ readPermissionAssignmentByUserId: o,
812
+ createPermissionAssignment: t,
813
+ updatePermissionAssignment: a,
814
+ deletePermissionAssignment: s,
815
+ getPermissionAssignmentByUserId: r
816
+ };
817
+ }), ue = () => {
818
+ const e = ce();
819
+ return {
820
+ ...e,
821
+ ...k(e)
822
+ };
823
+ }, le = {
824
+ async fetchReportPermissions(e) {
825
+ return b(
826
+ await M().get(`/report-query/hrm/${e}/reports`)
827
+ );
828
+ },
829
+ async fetchReportPermissionsForPortal(e) {
830
+ return b(
831
+ await M().get(
832
+ `/report-query/hrm/${e}/reports?isSupportPos=false`
833
+ )
834
+ );
835
+ }
836
+ }, O = h([]), _ = h(!1), w = h(!1), $ = h(null);
837
+ function de() {
838
+ const e = q();
839
+ async function n() {
840
+ var a;
841
+ const t = (a = e.currentBusiness.value) == null ? void 0 : a.id;
842
+ if (t && ($.value !== t && (O.value = [], _.value = !1, w.value = !1, $.value = t), !(_.value || w.value))) {
843
+ w.value = !0;
844
+ try {
845
+ const s = await le.fetchReportPermissionsForPortal(t);
846
+ if ($.value !== t) return;
847
+ O.value = s, _.value = !0;
848
+ } catch (s) {
849
+ if ($.value !== t) return;
850
+ console.warn("Failed to fetch custom report permissions:", s), O.value = [];
851
+ } finally {
852
+ $.value === t && (w.value = !1);
853
+ }
854
+ }
855
+ }
856
+ const o = N(() => O.value.map(
857
+ (t) => t.isDefault ? {
858
+ label: t.name,
859
+ subject: `business::report::reports::${t.permissionKey}`,
860
+ actions: [S.manage, S.read, S.create],
861
+ category: D.reports
862
+ } : {
863
+ label: t.name,
864
+ subject: `business::report::reports::${t.permissionKey}`,
865
+ actions: [
866
+ S.manage,
867
+ S.read,
868
+ S.create,
869
+ S.update,
870
+ S.delete
871
+ ],
872
+ category: D.customReports
873
+ }
874
+ ));
875
+ return {
876
+ fetchCustomReportPermissions: n,
877
+ customReportPermissions: o,
878
+ isLoading: N(() => w.value),
879
+ isLoaded: N(() => _.value)
880
+ };
881
+ }
882
+ function U(e) {
883
+ const n = q(), o = G(), t = ue(), a = n.restaurants, { customReportPermissions: s } = de(), r = t.getPermissionAssignmentByUserId(e.id), i = V(
884
+ (r == null ? void 0 : r.permissionSetIds) ?? [],
885
+ o.permissionSets.value
886
+ ), c = W(i).map(
887
+ ({ setNames: f, ...v }) => v
888
+ ), u = r == null ? void 0 : r.customPermissions, l = u ?? e.permissions.map((f) => ({
889
+ ...f,
890
+ subject: R(f.subject)
891
+ })), d = B(c, l), p = z(
892
+ ae(c, l),
893
+ F
894
+ ).filter((f) => !f.inverted), m = Y(p) || a.value.map((f) => f._id);
895
+ return {
896
+ doc: e,
897
+ id: e.id,
898
+ name: e.name || "-",
899
+ phoneNumber: e.phoneNumber,
900
+ email: e.email,
901
+ restaurants: L(
902
+ m.map(
903
+ (f) => {
904
+ var v;
905
+ return ((v = a.value.find((K) => K._id === f)) == null ? void 0 : v.profile.name) ?? "";
906
+ }
907
+ )
908
+ ),
909
+ managableRestaurantIds: m,
910
+ permissionLabels: ne(p, s.value),
911
+ permissions: d
912
+ };
913
+ }
914
+ const me = Object.freeze(
915
+ Object.values(Q)
916
+ ), Ne = {
917
+ async readTeamMembers() {
918
+ return b(
919
+ await g().get("/portal-users")
920
+ ).map(U);
921
+ },
922
+ async createTeamMember(e) {
923
+ return U(
924
+ b(await g().post("/portal-users", e))
925
+ );
926
+ },
927
+ async updateTeamMember(e, n) {
928
+ return U(
929
+ b(await g().put(`/portal-users/${e}`, n))
930
+ );
931
+ },
932
+ async deleteTeamMember(e) {
933
+ return b(await g().delete(`/portal-users/${e}`));
934
+ },
935
+ async readTeamMemberPosUserIds() {
936
+ return b(await g().get("/portal-users")).map((n) => n.posUserId);
937
+ }
938
+ };
939
+ export {
940
+ z as $,
941
+ le as R,
942
+ ye as a,
943
+ je as b,
944
+ V as c,
945
+ ae as d,
946
+ T as e,
947
+ $e as f,
948
+ he as g,
949
+ Pe as h,
950
+ Se as i,
951
+ de as j,
952
+ se as k,
953
+ we as l,
954
+ Re as m,
955
+ _e as n,
956
+ Ee as o,
957
+ me as p,
958
+ Ie as q,
959
+ E as r,
960
+ Oe as s,
961
+ Ne as t,
962
+ G as u,
963
+ ue as v,
964
+ ne as w,
965
+ W as x,
966
+ Ae as y,
967
+ Y as z
968
+ };