wcz-layout 10.2.2 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/dist/{ChatLayout-CkS9oyPp.mjs → ChatLayout-B0MBrI-Y.mjs} +839 -371
  2. package/dist/ChatLayout-B0MBrI-Y.mjs.map +1 -0
  3. package/dist/{ExtractFile-ClTc-e1H.d.mts → ExtractFile-BQUXpuBS.d.mts} +27 -3
  4. package/dist/FileMeta-B5VU-eCi.d.mts +55 -0
  5. package/dist/FileMeta-BexXC_45.mjs +35 -0
  6. package/dist/FileMeta-BexXC_45.mjs.map +1 -0
  7. package/dist/QueryClientParam-BG9Q_9XU.d.mts +6 -0
  8. package/dist/{Translate-BiCjnlyx.mjs → Translate-C43AmXYW.mjs} +25 -37
  9. package/dist/Translate-C43AmXYW.mjs.map +1 -0
  10. package/dist/User-CvLutatT.d.mts +10 -0
  11. package/dist/ai.d.mts +1 -1
  12. package/dist/ai.mjs +2 -2
  13. package/dist/ai.mjs.map +1 -1
  14. package/dist/auth.d.mts +6 -14
  15. package/dist/auth.mjs +15 -38
  16. package/dist/auth.mjs.map +1 -1
  17. package/dist/{authMiddleware-D4GSt7m9.mjs → authMiddleware-ANa9Tlmp.mjs} +10 -15
  18. package/dist/authMiddleware-ANa9Tlmp.mjs.map +1 -0
  19. package/dist/{ChatLayout-BmLySLXy.d.mts → components-2HKj8GpC.d.mts} +219 -255
  20. package/dist/components.d.mts +2 -126
  21. package/dist/components.mjs +871 -919
  22. package/dist/components.mjs.map +1 -1
  23. package/dist/data/client.d.mts +299 -57
  24. package/dist/data/client.mjs +5 -6
  25. package/dist/data/client.mjs.map +1 -1
  26. package/dist/data/server.d.mts +6 -5
  27. package/dist/data/server.mjs +3 -5
  28. package/dist/data/server.mjs.map +1 -1
  29. package/dist/env-C4WLVJMm.mjs +32 -0
  30. package/dist/env-C4WLVJMm.mjs.map +1 -0
  31. package/dist/file-DBqTibcr.mjs +176 -0
  32. package/dist/file-DBqTibcr.mjs.map +1 -0
  33. package/dist/file-hecCQszp.mjs +114 -0
  34. package/dist/file-hecCQszp.mjs.map +1 -0
  35. package/dist/hooks.d.mts +11 -91
  36. package/dist/hooks.mjs +152 -960
  37. package/dist/hooks.mjs.map +1 -1
  38. package/dist/i18n-ZRiIIdpb.mjs +563 -0
  39. package/dist/i18n-ZRiIIdpb.mjs.map +1 -0
  40. package/dist/index.d.mts +3 -35
  41. package/dist/index.mjs +409 -510
  42. package/dist/index.mjs.map +1 -1
  43. package/dist/layout-DeTB6Ai1.mjs +224 -0
  44. package/dist/layout-DeTB6Ai1.mjs.map +1 -0
  45. package/dist/middleware.d.mts +1 -1
  46. package/dist/middleware.mjs +2 -2
  47. package/dist/models.d.mts +34 -42
  48. package/dist/models.mjs +4 -6
  49. package/dist/models.mjs.map +1 -1
  50. package/dist/oidc--D2ox365.mjs +97 -0
  51. package/dist/oidc--D2ox365.mjs.map +1 -0
  52. package/dist/peoplesoft-DhwB8jrM.d.mts +204 -0
  53. package/dist/tokens-C4djIAhl.mjs +97 -0
  54. package/dist/tokens-C4djIAhl.mjs.map +1 -0
  55. package/dist/useDialogs-QER-2rVG.mjs +297 -0
  56. package/dist/useDialogs-QER-2rVG.mjs.map +1 -0
  57. package/dist/{user-Bc2nLjAG.mjs → user-DQx1BanQ.mjs} +4 -20
  58. package/dist/user-DQx1BanQ.mjs.map +1 -0
  59. package/dist/{utils-CNYCSgip.d.mts → utils-BnyAEKW7.d.mts} +7 -9
  60. package/dist/{utils-CgabUlDD.mjs → utils-H4BskGF8.mjs} +21 -20
  61. package/dist/utils-H4BskGF8.mjs.map +1 -0
  62. package/dist/utils.d.mts +21 -4
  63. package/dist/utils.mjs +5 -4
  64. package/dist/vite.mjs +98 -32
  65. package/dist/vite.mjs.map +1 -1
  66. package/package.json +16 -43
  67. package/skills/ai/SKILL.md +1 -4
  68. package/skills/general/SKILL.md +15 -8
  69. package/skills/general/references/auth.md +10 -16
  70. package/skills/general/references/languages.md +56 -0
  71. package/skills/migrations/versions/migrate-v10-to-v11.md +98 -22
  72. package/skills/migrations/versions/migrate-v9-to-v10.md +22 -22
  73. package/skills/services/SKILL.md +1 -1
  74. package/skills/services/docs/email.md +2 -2
  75. package/skills/services/docs/file.md +100 -85
  76. package/skills/services/docs/layout.md +2 -3
  77. package/skills/start/steps/02-project-name-setup.md +1 -1
  78. package/skills/start/steps/06-entra-setup.md +1 -1
  79. package/skills/start/steps/08-generate-favicon.md +1 -1
  80. package/skills/table/SKILL.md +18 -5
  81. package/src/lib/locales/cs.json +120 -0
  82. package/src/lib/locales/en.json +119 -0
  83. package/src/lib/locales/uk.json +121 -0
  84. package/src/lib/locales/zh-TW.json +118 -0
  85. package/dist/ChatLayout-CkS9oyPp.mjs.map +0 -1
  86. package/dist/DialogsContext-D23fJjYR.mjs +0 -6
  87. package/dist/DialogsContext-D23fJjYR.mjs.map +0 -1
  88. package/dist/FileMeta-B39e2FLC.d.mts +0 -17
  89. package/dist/FileMeta-CPBWI_jA.mjs +0 -18
  90. package/dist/FileMeta-CPBWI_jA.mjs.map +0 -1
  91. package/dist/QueryClientParam-CTV1vj76.d.mts +0 -8
  92. package/dist/RouterListItemButton-CF-8w-08.mjs +0 -62
  93. package/dist/RouterListItemButton-CF-8w-08.mjs.map +0 -1
  94. package/dist/Translate-BiCjnlyx.mjs.map +0 -1
  95. package/dist/User-aJksXItw.d.mts +0 -12
  96. package/dist/authMiddleware-D4GSt7m9.mjs.map +0 -1
  97. package/dist/createApi-CF4ZL82B.mjs +0 -24
  98. package/dist/createApi-CF4ZL82B.mjs.map +0 -1
  99. package/dist/env-Cddts_dn.mjs +0 -49
  100. package/dist/env-Cddts_dn.mjs.map +0 -1
  101. package/dist/file-D4kSR_lC.mjs +0 -149
  102. package/dist/file-D4kSR_lC.mjs.map +0 -1
  103. package/dist/file-DcwYjofa.mjs +0 -150
  104. package/dist/file-DcwYjofa.mjs.map +0 -1
  105. package/dist/layout-6We_KFgN.mjs +0 -107
  106. package/dist/layout-6We_KFgN.mjs.map +0 -1
  107. package/dist/peoplesoft-DH31FCMC.mjs +0 -125
  108. package/dist/peoplesoft-DH31FCMC.mjs.map +0 -1
  109. package/dist/peoplesoft-DXukeeFr.d.mts +0 -161
  110. package/dist/providers-DOFje2P6.mjs +0 -56
  111. package/dist/providers-DOFje2P6.mjs.map +0 -1
  112. package/dist/tokens-DNe_Qifk.mjs +0 -204
  113. package/dist/tokens-DNe_Qifk.mjs.map +0 -1
  114. package/dist/user-Bc2nLjAG.mjs.map +0 -1
  115. package/dist/utils-CgabUlDD.mjs.map +0 -1
@@ -0,0 +1,204 @@
1
+ import { t as FileMeta } from "./FileMeta-B5VU-eCi.mjs";
2
+ import { C as WithdrawApprovalSchema, _ as CancelApprovalSchema, c as Department, h as ApproveApprovalSchema, i as Employee, u as Approval, x as ResubmitApprovalSchema, y as CreateApprovalSchema } from "./ExtractFile-BQUXpuBS.mjs";
3
+ import { z as z$1 } from "zod";
4
+ declare const GetFileMetasSchema: z$1.ZodObject<{
5
+ subId: z$1.ZodString;
6
+ appName: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string, string | undefined>>;
7
+ }, z$1.core.$strip>;
8
+ declare const FileSchema: z$1.ZodObject<{
9
+ id: z$1.ZodUUID;
10
+ }, z$1.core.$strip>;
11
+ /** Each field sent replaces its value; `permissions` as a whole. `fileName` is the base name. */
12
+ declare const UpdateFileMetaSchema: z$1.ZodObject<{
13
+ id: z$1.ZodUUID;
14
+ fileName: z$1.ZodOptional<z$1.ZodString>;
15
+ subId: z$1.ZodOptional<z$1.ZodString>;
16
+ public: z$1.ZodOptional<z$1.ZodBoolean>;
17
+ permissions: z$1.ZodOptional<z$1.ZodObject<{
18
+ read: z$1.ZodNullable<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodObject<{
19
+ group: z$1.ZodString;
20
+ }, z$1.core.$strict>, z$1.ZodObject<{
21
+ employeeId: z$1.ZodString;
22
+ }, z$1.core.$strict>]>>>;
23
+ write: z$1.ZodNullable<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodObject<{
24
+ group: z$1.ZodString;
25
+ }, z$1.core.$strict>, z$1.ZodObject<{
26
+ employeeId: z$1.ZodString;
27
+ }, z$1.core.$strict>]>>>;
28
+ }, z$1.core.$strip>>;
29
+ }, z$1.core.$strip>;
30
+ /** `public` and `permissions` decide who reads and changes the file; omitted: every employee. */
31
+ declare const CreateUploadSchema: z$1.ZodObject<{
32
+ id: z$1.ZodUUID;
33
+ subId: z$1.ZodString;
34
+ appName: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string, string | undefined>>;
35
+ fileName: z$1.ZodString;
36
+ size: z$1.ZodNumber;
37
+ public: z$1.ZodOptional<z$1.ZodBoolean>;
38
+ permissions: z$1.ZodOptional<z$1.ZodObject<{
39
+ read: z$1.ZodNullable<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodObject<{
40
+ group: z$1.ZodString;
41
+ }, z$1.core.$strict>, z$1.ZodObject<{
42
+ employeeId: z$1.ZodString;
43
+ }, z$1.core.$strict>]>>>;
44
+ write: z$1.ZodNullable<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodObject<{
45
+ group: z$1.ZodString;
46
+ }, z$1.core.$strict>, z$1.ZodObject<{
47
+ employeeId: z$1.ZodString;
48
+ }, z$1.core.$strict>]>>>;
49
+ }, z$1.core.$strip>>;
50
+ }, z$1.core.$strip>;
51
+ declare const UploadFileSchema: z$1.ZodObject<{
52
+ subId: z$1.ZodString;
53
+ appName: z$1.ZodPipe<z$1.ZodOptional<z$1.ZodString>, z$1.ZodTransform<string, string | undefined>>;
54
+ public: z$1.ZodOptional<z$1.ZodBoolean>;
55
+ permissions: z$1.ZodOptional<z$1.ZodObject<{
56
+ read: z$1.ZodNullable<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodObject<{
57
+ group: z$1.ZodString;
58
+ }, z$1.core.$strict>, z$1.ZodObject<{
59
+ employeeId: z$1.ZodString;
60
+ }, z$1.core.$strict>]>>>;
61
+ write: z$1.ZodNullable<z$1.ZodArray<z$1.ZodUnion<readonly [z$1.ZodObject<{
62
+ group: z$1.ZodString;
63
+ }, z$1.core.$strict>, z$1.ZodObject<{
64
+ employeeId: z$1.ZodString;
65
+ }, z$1.core.$strict>]>>>;
66
+ }, z$1.core.$strip>>;
67
+ id: z$1.ZodDefault<z$1.ZodUUID>;
68
+ file: z$1.ZodInstanceOf<File>;
69
+ }, z$1.core.$strip>;
70
+ /** The browser sends the bytes to `uploadUrl` itself, signed for this one upload for 24 h. */
71
+ interface UploadSession {
72
+ uploadUrl: string;
73
+ chunkSize: number;
74
+ }
75
+ /** What one chunk `PUT` answered; `status` 0 means no answer arrived. */
76
+ interface ChunkResponse {
77
+ status: number;
78
+ body: unknown;
79
+ }
80
+ /** Sends one chunk: `Content-Range` header and body; `offset` is where the chunk starts. */
81
+ type PutChunk = (range: string, chunk: Blob | null, offset: number) => Promise<ChunkResponse>;
82
+ /**
83
+ * Sends `file` to an upload session in chunks and returns the created file. A failed chunk is
84
+ * sent again after a back-off (about 2 minutes in total): when the service already has its
85
+ * bytes it answers 409 with its offset, and the upload continues from there.
86
+ */
87
+ declare function sendChunks(file: Blob, chunkSize: number, put: PutChunk, signal?: AbortSignal): Promise<FileMeta>;
88
+ declare const getFileMetas: ({ data }: {
89
+ data: z$1.input<typeof GetFileMetasSchema>;
90
+ }) => Promise<Array<FileMeta>>;
91
+ declare const getFileMeta: ({ data }: {
92
+ data: z$1.input<typeof FileSchema>;
93
+ }) => Promise<FileMeta>;
94
+ declare const updateFileMeta: ({ data }: {
95
+ data: z$1.input<typeof UpdateFileMetaSchema>;
96
+ }) => Promise<FileMeta>;
97
+ declare const deleteFile: ({ data }: {
98
+ data: z$1.input<typeof FileSchema>;
99
+ }) => Promise<void>;
100
+ /** Deletes every file under `subId`, or none when the user can't delete one of them. */
101
+ declare const batchDeleteFiles: ({ data }: {
102
+ data: z$1.input<typeof GetFileMetasSchema>;
103
+ }) => Promise<void>;
104
+ /** Starts an upload; the bytes go to the returned `uploadUrl` (see `sendChunks`). */
105
+ declare const createUpload: ({ data }: {
106
+ data: z$1.input<typeof CreateUploadSchema>;
107
+ }) => Promise<UploadSession>;
108
+ /** Uploads from the server, e.g. a generated report. Browsers use `uploadFileMutationOptions`. */
109
+ declare const uploadFile: ({ data }: {
110
+ data: z$1.input<typeof UploadFileSchema>;
111
+ }) => Promise<FileMeta>;
112
+ declare const GetApprovalsSchema: z$1.ZodObject<{
113
+ appName: z$1.ZodString;
114
+ status: z$1.ZodOptional<z$1.ZodEnum<{
115
+ Approved: "Approved";
116
+ Cancelled: "Cancelled";
117
+ Rejected: "Rejected";
118
+ WaitingForApproval: "WaitingForApproval";
119
+ Withdrawn: "Withdrawn";
120
+ }>>;
121
+ approverEmployeeId: z$1.ZodOptional<z$1.ZodString>;
122
+ stepResult: z$1.ZodOptional<z$1.ZodEnum<{
123
+ Approved: "Approved";
124
+ Cancelled: "Cancelled";
125
+ FutureApproval: "FutureApproval";
126
+ NotAvailable: "NotAvailable";
127
+ Rejected: "Rejected";
128
+ Skipped: "Skipped";
129
+ WaitingForApproval: "WaitingForApproval";
130
+ Withdrawn: "Withdrawn";
131
+ }>>;
132
+ }, z$1.core.$strip>;
133
+ declare const GetApprovalSchema: z$1.ZodObject<{
134
+ id: z$1.ZodUUID;
135
+ }, z$1.core.$strip>;
136
+ declare const getApprovals: ({ data }: {
137
+ data: z$1.input<typeof GetApprovalsSchema>;
138
+ }) => Promise<Array<Approval>>;
139
+ declare const getApproval: ({ data }: {
140
+ data: z$1.input<typeof GetApprovalSchema>;
141
+ }) => Promise<Approval>;
142
+ declare const createApproval: ({ data }: {
143
+ data: z$1.input<typeof CreateApprovalSchema>;
144
+ }) => Promise<Approval>;
145
+ declare const approveApproval: ({ data }: {
146
+ data: z$1.input<typeof ApproveApprovalSchema>;
147
+ }) => Promise<Approval>;
148
+ declare const resubmitApproval: ({ data }: {
149
+ data: z$1.input<typeof ResubmitApprovalSchema>;
150
+ }) => Promise<Approval>;
151
+ declare const withdrawApproval: ({ data }: {
152
+ data: z$1.input<typeof WithdrawApprovalSchema>;
153
+ }) => Promise<void>;
154
+ declare const cancelApproval: ({ data }: {
155
+ data: z$1.input<typeof CancelApprovalSchema>;
156
+ }) => Promise<void>;
157
+ declare const SearchEmployeesSchema: z$1.ZodObject<{
158
+ searchTerm: z$1.ZodString;
159
+ }, z$1.core.$strip>;
160
+ declare const EmployeeIdSchema: z$1.ZodObject<{
161
+ employeeId: z$1.ZodString;
162
+ }, z$1.core.$strip>;
163
+ declare const DepartmentIdSchema: z$1.ZodObject<{
164
+ departmentId: z$1.ZodString;
165
+ }, z$1.core.$strip>;
166
+ declare const CompanyCodeSchema: z$1.ZodObject<{
167
+ companyCode: z$1.ZodString;
168
+ }, z$1.core.$strip>;
169
+ declare const searchEmployees: ({ data }: {
170
+ data: z$1.input<typeof SearchEmployeesSchema>;
171
+ }) => Promise<Array<Employee>>;
172
+ declare const getEmployees: () => Promise<Array<Employee>>;
173
+ declare const getActiveEmployees: () => Promise<Array<Employee>>;
174
+ declare const getEmployeeByEmployeeId: ({ data }: {
175
+ data: z$1.input<typeof EmployeeIdSchema>;
176
+ }) => Promise<Employee>;
177
+ declare const getPreviousEmployeeIds: () => Promise<Array<Employee>>;
178
+ declare const getEmployeeSupervisor: ({ data }: {
179
+ data: z$1.input<typeof EmployeeIdSchema>;
180
+ }) => Promise<Employee>;
181
+ declare const getEmployeeSubordinates: ({ data }: {
182
+ data: z$1.input<typeof EmployeeIdSchema>;
183
+ }) => Promise<Array<Employee>>;
184
+ declare const getEmployeeManager: ({ data }: {
185
+ data: z$1.input<typeof EmployeeIdSchema>;
186
+ }) => Promise<Employee>;
187
+ declare const getEmployeeGeneralManager: ({ data }: {
188
+ data: z$1.input<typeof EmployeeIdSchema>;
189
+ }) => Promise<Employee>;
190
+ declare const getDepartments: () => Promise<Array<Department>>;
191
+ declare const getDepartmentById: ({ data }: {
192
+ data: z$1.input<typeof DepartmentIdSchema>;
193
+ }) => Promise<Department>;
194
+ declare const getDepartmentManager: ({ data }: {
195
+ data: z$1.input<typeof DepartmentIdSchema>;
196
+ }) => Promise<Employee>;
197
+ declare const getDepartmentEmployees: ({ data }: {
198
+ data: z$1.input<typeof DepartmentIdSchema>;
199
+ }) => Promise<Array<Employee>>;
200
+ declare const getCompanyGeneralManager: ({ data }: {
201
+ data: z$1.input<typeof CompanyCodeSchema>;
202
+ }) => Promise<Employee>;
203
+ export { FileSchema as A, getFileMetas as B, createApproval as C, withdrawApproval as D, resubmitApproval as E, UploadSession as F, updateFileMeta as H, batchDeleteFiles as I, createUpload as L, PutChunk as M, UpdateFileMetaSchema as N, ChunkResponse as O, UploadFileSchema as P, deleteFile as R, cancelApproval as S, getApprovals as T, uploadFile as U, sendChunks as V, getPreviousEmployeeIds as _, getActiveEmployees as a, GetApprovalsSchema as b, getDepartmentEmployees as c, getEmployeeByEmployeeId as d, getEmployeeGeneralManager as f, getEmployees as g, getEmployeeSupervisor as h, SearchEmployeesSchema as i, GetFileMetasSchema as j, CreateUploadSchema as k, getDepartmentManager as l, getEmployeeSubordinates as m, DepartmentIdSchema as n, getCompanyGeneralManager as o, getEmployeeManager as p, EmployeeIdSchema as r, getDepartmentById as s, CompanyCodeSchema as t, getDepartments as u, searchEmployees as v, getApproval as w, approveApproval as x, GetApprovalSchema as y, getFileMeta as z };
204
+ //# sourceMappingURL=peoplesoft-DhwB8jrM.d.mts.map
@@ -0,0 +1,97 @@
1
+ import { i as __exportAll } from "./env-C4WLVJMm.mjs";
2
+ import { d as refreshTokens, r as clientCredentials, s as issuer, t as SessionExpiredError, u as onBehalfOf } from "./oidc--D2ox365.mjs";
3
+ import { i as getAppSession, t as getSessionUser } from "./user-DQx1BanQ.mjs";
4
+ import { scopes } from "virtual:wcz-layout";
5
+ import { createServerOnlyFn } from "@tanstack/react-start";
6
+ import * as jose from "jose";
7
+ // src/lib/auth/tokens.ts
8
+ var tokens_exports = /* @__PURE__ */ __exportAll({
9
+ getAccessToken: () => getAccessToken,
10
+ getApiToken: () => getApiToken,
11
+ getAppToken: () => getAppToken,
12
+ hasUser: () => hasUser
13
+ });
14
+ /**
15
+ * The request's Bearer token when it is an Entra user token: a sibling service calling for a
16
+ * user. Entra checks its signature and audience in the on-behalf-of exchange. `undefined`
17
+ * outside a request and for a malformed token.
18
+ */
19
+ async function getBearerUserToken() {
20
+ try {
21
+ const { getRequestHeader } = await import("@tanstack/react-start/server");
22
+ const token = getRequestHeader("authorization")?.match(/^Bearer (.+)$/)?.[1];
23
+ if (!token) return void 0;
24
+ const { iss, scp } = jose.decodeJwt(token);
25
+ return iss === issuer && scp ? token : void 0;
26
+ } catch {
27
+ return;
28
+ }
29
+ }
30
+ /**
31
+ * shortcut: one Entra round trip per call, no cache; cache by assertion and scope if a request
32
+ * ever calls the same API many times.
33
+ */
34
+ async function getOnBehalfOfToken(assertion, scopeKey) {
35
+ try {
36
+ return (await onBehalfOf({
37
+ assertion,
38
+ scope: scopes[scopeKey]
39
+ })).access_token;
40
+ } catch (error) {
41
+ if (error instanceof SessionExpiredError) throw Response.json({ message: "Unauthorized: Access token expired" }, { status: 401 });
42
+ throw error;
43
+ }
44
+ }
45
+ /** Whether a user is behind the request: a session, or a sibling service's Bearer user token. */
46
+ const hasUser = createServerOnlyFn(async () => Boolean(await getSessionUser() ?? await getBearerUserToken()));
47
+ /**
48
+ * Delegated access token for the user behind the request. From a session it is minted from
49
+ * the session refresh token, and a rotated refresh token is persisted back. For a sibling
50
+ * service's Bearer user token it is exchanged on behalf of that user. Server-only — stripped
51
+ * from the client bundle.
52
+ */
53
+ const getAccessToken = createServerOnlyFn(async (scopeKey) => {
54
+ const session = await getAppSession();
55
+ const { refreshToken } = session;
56
+ if (!refreshToken) {
57
+ const assertion = await getBearerUserToken();
58
+ if (!assertion) throw new Error("No active session. User not signed in.");
59
+ return getOnBehalfOfToken(assertion, scopeKey);
60
+ }
61
+ try {
62
+ const result = await refreshTokens({
63
+ refreshToken,
64
+ scope: scopes[scopeKey]
65
+ });
66
+ if (result.refresh_token && result.refresh_token !== refreshToken) {
67
+ session.refreshToken = result.refresh_token;
68
+ await session.save();
69
+ }
70
+ return result.access_token;
71
+ } catch (error) {
72
+ if (error instanceof SessionExpiredError) {
73
+ session.destroy();
74
+ throw Response.json({ message: "Unauthorized: Session expired, sign in again" }, { status: 401 });
75
+ }
76
+ throw error;
77
+ }
78
+ });
79
+ const appTokens = /* @__PURE__ */ new Map();
80
+ /** Client-credentials (app-only) token, for background jobs with no user. */
81
+ const getAppToken = createServerOnlyFn(async (scopeKey) => {
82
+ const cached = appTokens.get(scopeKey);
83
+ if (cached && cached.expiresAt > Date.now()) return cached.token;
84
+ const scope = scopes[scopeKey];
85
+ const defaultScope = `${scope.slice(0, scope.lastIndexOf("/"))}/.default`;
86
+ const result = await clientCredentials({ scope: defaultScope });
87
+ appTokens.set(scopeKey, {
88
+ token: result.access_token,
89
+ expiresAt: Date.now() + (result.expires_in - 60) * 1e3
90
+ });
91
+ return result.access_token;
92
+ });
93
+ /** The user's token when a user is behind the request (see `hasUser`), else the app token. */
94
+ const getApiToken = createServerOnlyFn(async (scopeKey) => await hasUser() ? await getAccessToken(scopeKey) : await getAppToken(scopeKey));
95
+ export { tokens_exports as i, getApiToken as n, getAppToken as r, getAccessToken as t };
96
+
97
+ //# sourceMappingURL=tokens-C4djIAhl.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokens-C4djIAhl.mjs","names":["definedScopes"],"sources":["../src/lib/auth/tokens.ts"],"sourcesContent":["import { createServerOnlyFn } from \"@tanstack/react-start\";\nimport * as jose from \"jose\";\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\nimport { SessionExpiredError, clientCredentials, issuer, onBehalfOf, refreshTokens } from \"./oidc\";\nimport { getAppSession } from \"./session\";\nimport { getSessionUser } from \"./user\";\n\nexport type ScopeKey = keyof typeof definedScopes;\n\n/**\n * The request's Bearer token when it is an Entra user token: a sibling service calling for a\n * user. Entra checks its signature and audience in the on-behalf-of exchange. `undefined`\n * outside a request and for a malformed token.\n */\nasync function getBearerUserToken(): Promise<string | undefined> {\n try {\n const { getRequestHeader } = await import(\"@tanstack/react-start/server\");\n const token = getRequestHeader(\"authorization\")?.match(/^Bearer (.+)$/)?.[1];\n if (!token) return undefined;\n const { iss, scp } = jose.decodeJwt(token);\n return iss === issuer && scp ? token : undefined;\n } catch {\n return undefined;\n }\n}\n\n/**\n * shortcut: one Entra round trip per call, no cache; cache by assertion and scope if a request\n * ever calls the same API many times.\n */\nasync function getOnBehalfOfToken(assertion: string, scopeKey: ScopeKey): Promise<string> {\n try {\n const result = await onBehalfOf({ assertion, scope: definedScopes[scopeKey] });\n return result.access_token;\n } catch (error) {\n if (error instanceof SessionExpiredError)\n throw Response.json({ message: \"Unauthorized: Access token expired\" }, { status: 401 });\n throw error;\n }\n}\n\n/** Whether a user is behind the request: a session, or a sibling service's Bearer user token. */\nexport const hasUser = createServerOnlyFn(async (): Promise<boolean> =>\n Boolean((await getSessionUser()) ?? (await getBearerUserToken())),\n);\n\n/**\n * Delegated access token for the user behind the request. From a session it is minted from\n * the session refresh token, and a rotated refresh token is persisted back. For a sibling\n * service's Bearer user token it is exchanged on behalf of that user. Server-only — stripped\n * from the client bundle.\n */\nexport const getAccessToken = createServerOnlyFn(async (scopeKey: ScopeKey): Promise<string> => {\n const session = await getAppSession();\n const { refreshToken } = session;\n if (!refreshToken) {\n const assertion = await getBearerUserToken();\n if (!assertion) throw new Error(\"No active session. User not signed in.\");\n return getOnBehalfOfToken(assertion, scopeKey);\n }\n\n try {\n const result = await refreshTokens({ refreshToken, scope: definedScopes[scopeKey] });\n if (result.refresh_token && result.refresh_token !== refreshToken) {\n session.refreshToken = result.refresh_token;\n await session.save();\n }\n return result.access_token;\n } catch (error) {\n // Revoked/expired refresh token: clear the dead session and answer 401 so the\n // client can sign in again, instead of surfacing a 500.\n if (error instanceof SessionExpiredError) {\n session.destroy();\n throw Response.json(\n { message: \"Unauthorized: Session expired, sign in again\" },\n { status: 401 },\n );\n }\n throw error;\n }\n});\n\n// MSAL used to cache these in memory; without it, a small TTL map keeps parity.\nconst appTokens = new Map<ScopeKey, { token: string; expiresAt: number }>();\n\n/** Client-credentials (app-only) token, for background jobs with no user. */\nexport const getAppToken = createServerOnlyFn(async (scopeKey: ScopeKey): Promise<string> => {\n const cached = appTokens.get(scopeKey);\n if (cached && cached.expiresAt > Date.now()) return cached.token;\n\n // Client credentials only accept `<resource>/.default`, not user scopes.\n const scope: string = definedScopes[scopeKey];\n const defaultScope = `${scope.slice(0, scope.lastIndexOf(\"/\"))}/.default`;\n\n const result = await clientCredentials({ scope: defaultScope });\n appTokens.set(scopeKey, {\n token: result.access_token,\n expiresAt: Date.now() + (result.expires_in - 60) * 1000,\n });\n return result.access_token;\n});\n\n/** The user's token when a user is behind the request (see `hasUser`), else the app token. */\nexport const getApiToken = createServerOnlyFn(async (scopeKey: ScopeKey): Promise<string> =>\n (await hasUser()) ? await getAccessToken(scopeKey) : await getAppToken(scopeKey),\n);\n"],"mappings":";;;;;;;;;;;;;;;;;;AAcA,eAAe,qBAAkD;CAC/D,IAAI;EACF,MAAM,EAAE,qBAAqB,MAAM,OAAO;EAC1C,MAAM,QAAQ,iBAAiB,eAAe,CAAC,EAAE,MAAM,eAAe,CAAC,GAAG;EAC1E,IAAI,CAAC,OAAO,OAAO,KAAA;EACnB,MAAM,EAAE,KAAK,QAAQ,KAAK,UAAU,KAAK;EACzC,OAAO,QAAQ,UAAU,MAAM,QAAQ,KAAA;CACzC,QAAQ;EACN;CACF;AACF;;;;;AAMA,eAAe,mBAAmB,WAAmB,UAAqC;CACxF,IAAI;EAEF,QAAO,MADc,WAAW;GAAE;GAAW,OAAOA,OAAc;EAAU,CAAC,EAAA,CAC/D;CAChB,SAAS,OAAO;EACd,IAAI,iBAAiB,qBACnB,MAAM,SAAS,KAAK,E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AAO;AAChB,CAAC;;AAGD,MAAa,cAAc,mBAAmB,OAAO,aAClD,MAAM,QAAQ,IAAK,MAAM,eAAe,QAAQ,IAAI,MAAM,YAAY,QAAQ,CACjF"}
@@ -0,0 +1,297 @@
1
+ import { r as getI18n } from "./i18n-ZRiIIdpb.mjs";
2
+ import { c } from "react/compiler-runtime";
3
+ import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Fab, IconButton, Link, ListItemButton, Tab, useEventCallback } from "@mui/material";
4
+ import { createContext, useContext, useId } from "react";
5
+ import { useTranslation } from "react-i18next";
6
+ import { createLink } from "@tanstack/react-router";
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ // src/components/router/RouterLink.tsx
9
+ const RouterButton = createLink((props) => /* @__PURE__ */ jsx(Button, {
10
+ component: "a",
11
+ ...props
12
+ }));
13
+ const RouterFab = createLink((props) => /* @__PURE__ */ jsx(Fab, {
14
+ component: "a",
15
+ ...props
16
+ }));
17
+ const RouterIconButton = createLink((props) => /* @__PURE__ */ jsx(IconButton, {
18
+ component: "a",
19
+ ...props
20
+ }));
21
+ const RouterLink = createLink((props) => /* @__PURE__ */ jsx(Link, { ...props }));
22
+ const RouterListItemButton = createLink((props) => /* @__PURE__ */ jsx(ListItemButton, {
23
+ component: "a",
24
+ ...props
25
+ }));
26
+ const RouterTab = createLink((props) => /* @__PURE__ */ jsx(Tab, {
27
+ component: "a",
28
+ ...props
29
+ }));
30
+ // src/hooks/useTranslation.ts
31
+ /**
32
+ * react-i18next's `useTranslation` on the request's instance during SSR, so a component
33
+ * above `LayoutProvider` (the root shell) renders the request's language too.
34
+ */
35
+ const useTranslation$1 = (ns, options) => {
36
+ const $ = c(3);
37
+ let t0;
38
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
39
+ t0 = getI18n();
40
+ $[0] = t0;
41
+ } else t0 = $[0];
42
+ let t1;
43
+ if ($[1] !== options) {
44
+ t1 = {
45
+ i18n: t0,
46
+ ...options
47
+ };
48
+ $[1] = options;
49
+ $[2] = t1;
50
+ } else t1 = $[2];
51
+ return useTranslation(ns, t1);
52
+ };
53
+ // src/hooks/useDialogs.tsx
54
+ function AlertDialog(t0) {
55
+ const $ = c(24);
56
+ const { open, payload, onClose } = t0;
57
+ const { t } = useTranslation();
58
+ const messageId = useId();
59
+ let t1;
60
+ if ($[0] !== onClose) {
61
+ t1 = () => onClose();
62
+ $[0] = onClose;
63
+ $[1] = t1;
64
+ } else t1 = $[1];
65
+ let t2;
66
+ if ($[2] !== payload.title || $[3] !== t) {
67
+ t2 = payload.title ?? t("Layout.Dialog.Alert");
68
+ $[2] = payload.title;
69
+ $[3] = t;
70
+ $[4] = t2;
71
+ } else t2 = $[4];
72
+ let t3;
73
+ if ($[5] !== t2) {
74
+ t3 = /* @__PURE__ */ jsx(DialogTitle, { children: t2 });
75
+ $[5] = t2;
76
+ $[6] = t3;
77
+ } else t3 = $[6];
78
+ let t4;
79
+ if ($[7] !== messageId || $[8] !== payload.message) {
80
+ t4 = /* @__PURE__ */ jsx(DialogContent, {
81
+ id: messageId,
82
+ children: payload.message
83
+ });
84
+ $[7] = messageId;
85
+ $[8] = payload.message;
86
+ $[9] = t4;
87
+ } else t4 = $[9];
88
+ let t5;
89
+ if ($[10] !== onClose) {
90
+ t5 = () => onClose();
91
+ $[10] = onClose;
92
+ $[11] = t5;
93
+ } else t5 = $[11];
94
+ let t6;
95
+ if ($[12] !== t) {
96
+ t6 = t("Layout.Dialog.Confirm");
97
+ $[12] = t;
98
+ $[13] = t6;
99
+ } else t6 = $[13];
100
+ let t7;
101
+ if ($[14] !== t5 || $[15] !== t6) {
102
+ t7 = /* @__PURE__ */ jsx(DialogActions, { children: /* @__PURE__ */ jsx(Button, {
103
+ onClick: t5,
104
+ autoFocus: true,
105
+ children: t6
106
+ }) });
107
+ $[14] = t5;
108
+ $[15] = t6;
109
+ $[16] = t7;
110
+ } else t7 = $[16];
111
+ let t8;
112
+ if ($[17] !== messageId || $[18] !== open || $[19] !== t1 || $[20] !== t3 || $[21] !== t4 || $[22] !== t7) {
113
+ t8 = /* @__PURE__ */ jsxs(Dialog, {
114
+ maxWidth: "xs",
115
+ fullWidth: true,
116
+ open,
117
+ onClose: t1,
118
+ role: "alertdialog",
119
+ "aria-describedby": messageId,
120
+ children: [
121
+ t3,
122
+ t4,
123
+ t7
124
+ ]
125
+ });
126
+ $[17] = messageId;
127
+ $[18] = open;
128
+ $[19] = t1;
129
+ $[20] = t3;
130
+ $[21] = t4;
131
+ $[22] = t7;
132
+ $[23] = t8;
133
+ } else t8 = $[23];
134
+ return t8;
135
+ }
136
+ function ConfirmDialog(t0) {
137
+ const $ = c(36);
138
+ const { open, payload, onClose } = t0;
139
+ const { t } = useTranslation();
140
+ const messageId = useId();
141
+ let t1;
142
+ if ($[0] !== onClose) {
143
+ t1 = () => onClose(false);
144
+ $[0] = onClose;
145
+ $[1] = t1;
146
+ } else t1 = $[1];
147
+ let t2;
148
+ if ($[2] !== payload.title || $[3] !== t) {
149
+ t2 = payload.title ?? t("Layout.Dialog.Confirm");
150
+ $[2] = payload.title;
151
+ $[3] = t;
152
+ $[4] = t2;
153
+ } else t2 = $[4];
154
+ let t3;
155
+ if ($[5] !== t2) {
156
+ t3 = /* @__PURE__ */ jsx(DialogTitle, { children: t2 });
157
+ $[5] = t2;
158
+ $[6] = t3;
159
+ } else t3 = $[6];
160
+ let t4;
161
+ if ($[7] !== messageId || $[8] !== payload.message) {
162
+ t4 = /* @__PURE__ */ jsx(DialogContent, {
163
+ id: messageId,
164
+ children: payload.message
165
+ });
166
+ $[7] = messageId;
167
+ $[8] = payload.message;
168
+ $[9] = t4;
169
+ } else t4 = $[9];
170
+ let t5;
171
+ if ($[10] !== onClose) {
172
+ t5 = () => onClose(false);
173
+ $[10] = onClose;
174
+ $[11] = t5;
175
+ } else t5 = $[11];
176
+ let t6;
177
+ if ($[12] !== payload.cancelText || $[13] !== t) {
178
+ t6 = payload.cancelText ?? t("Layout.Dialog.Cancel");
179
+ $[12] = payload.cancelText;
180
+ $[13] = t;
181
+ $[14] = t6;
182
+ } else t6 = $[14];
183
+ let t7;
184
+ if ($[15] !== t5 || $[16] !== t6) {
185
+ t7 = /* @__PURE__ */ jsx(Button, {
186
+ onClick: t5,
187
+ children: t6
188
+ });
189
+ $[15] = t5;
190
+ $[16] = t6;
191
+ $[17] = t7;
192
+ } else t7 = $[17];
193
+ let t8;
194
+ if ($[18] !== onClose) {
195
+ t8 = () => onClose(true);
196
+ $[18] = onClose;
197
+ $[19] = t8;
198
+ } else t8 = $[19];
199
+ let t9;
200
+ if ($[20] !== payload.confirmText || $[21] !== t) {
201
+ t9 = payload.confirmText ?? t("Layout.Dialog.Confirm");
202
+ $[20] = payload.confirmText;
203
+ $[21] = t;
204
+ $[22] = t9;
205
+ } else t9 = $[22];
206
+ let t10;
207
+ if ($[23] !== t8 || $[24] !== t9) {
208
+ t10 = /* @__PURE__ */ jsx(Button, {
209
+ onClick: t8,
210
+ autoFocus: true,
211
+ children: t9
212
+ });
213
+ $[23] = t8;
214
+ $[24] = t9;
215
+ $[25] = t10;
216
+ } else t10 = $[25];
217
+ let t11;
218
+ if ($[26] !== t10 || $[27] !== t7) {
219
+ t11 = /* @__PURE__ */ jsxs(DialogActions, { children: [t7, t10] });
220
+ $[26] = t10;
221
+ $[27] = t7;
222
+ $[28] = t11;
223
+ } else t11 = $[28];
224
+ let t12;
225
+ if ($[29] !== messageId || $[30] !== open || $[31] !== t1 || $[32] !== t11 || $[33] !== t3 || $[34] !== t4) {
226
+ t12 = /* @__PURE__ */ jsxs(Dialog, {
227
+ maxWidth: "xs",
228
+ fullWidth: true,
229
+ open,
230
+ onClose: t1,
231
+ role: "alertdialog",
232
+ "aria-describedby": messageId,
233
+ children: [
234
+ t3,
235
+ t4,
236
+ t11
237
+ ]
238
+ });
239
+ $[29] = messageId;
240
+ $[30] = open;
241
+ $[31] = t1;
242
+ $[32] = t11;
243
+ $[33] = t3;
244
+ $[34] = t4;
245
+ $[35] = t12;
246
+ } else t12 = $[35];
247
+ return t12;
248
+ }
249
+ const DialogsContext = createContext({});
250
+ function useDialogs() {
251
+ const $ = c(9);
252
+ const { open, close } = useContext(DialogsContext);
253
+ let t0;
254
+ if ($[0] !== open) {
255
+ t0 = (message, t1) => {
256
+ const { ...options } = t1 === void 0 ? {} : t1;
257
+ return open(AlertDialog, {
258
+ ...options,
259
+ message
260
+ });
261
+ };
262
+ $[0] = open;
263
+ $[1] = t0;
264
+ } else t0 = $[1];
265
+ const alert = useEventCallback(t0);
266
+ let t1;
267
+ if ($[2] !== open) {
268
+ t1 = (message_0, t2) => {
269
+ const { ...options_0 } = t2 === void 0 ? {} : t2;
270
+ return open(ConfirmDialog, {
271
+ ...options_0,
272
+ message: message_0
273
+ });
274
+ };
275
+ $[2] = open;
276
+ $[3] = t1;
277
+ } else t1 = $[3];
278
+ const confirm = useEventCallback(t1);
279
+ let t2;
280
+ if ($[4] !== alert || $[5] !== close || $[6] !== confirm || $[7] !== open) {
281
+ t2 = {
282
+ alert,
283
+ confirm,
284
+ open,
285
+ close
286
+ };
287
+ $[4] = alert;
288
+ $[5] = close;
289
+ $[6] = confirm;
290
+ $[7] = open;
291
+ $[8] = t2;
292
+ } else t2 = $[8];
293
+ return t2;
294
+ }
295
+ export { RouterFab as a, RouterListItemButton as c, RouterButton as i, RouterTab as l, useDialogs as n, RouterIconButton as o, useTranslation$1 as r, RouterLink as s, DialogsContext as t };
296
+
297
+ //# sourceMappingURL=useDialogs-QER-2rVG.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDialogs-QER-2rVG.mjs","names":["getI18n()","{ i18n: getI18n(), ...options }","useTranslation","useI18nextTranslation","{ open, payload, onClose }: Readonly<AlertDialogProps>","() => onClose()","payload.title ?? t(\"Layout.Dialog.Alert\")","title","<DialogTitle>{payload.title ?? t(\"Layout.Dialog.Alert\")}</DialogTitle>","<DialogContent id={messageId}>{payload.message}</DialogContent>","message","t(\"Layout.Dialog.Confirm\")","<DialogActions>\n <Button onClick={() => onClose()} autoFocus>\n {t(\"Layout.Dialog.Confirm\")}\n </Button>\n </DialogActions>","<Dialog\n maxWidth=\"xs\"\n fullWidth\n open={open}\n onClose={() => onClose()}\n role=\"alertdialog\"\n aria-describedby={messageId}\n >\n <DialogTitle>{payload.title ?? t(\"Layout.Dialog.Alert\")}</DialogTitle>\n <DialogContent id={messageId}>{payload.message}</DialogContent>\n <DialogActions>\n <Button onClick={() => onClose()} autoFocus>\n {t(\"Layout.Dialog.Confirm\")}\n </Button>\n </DialogActions>\n </Dialog>","{ open, payload, onClose }: Readonly<ConfirmDialogProps>","() => onClose(false)","payload.title ?? t(\"Layout.Dialog.Confirm\")","<DialogTitle>{payload.title ?? t(\"Layout.Dialog.Confirm\")}</DialogTitle>","payload.cancelText ?? t(\"Layout.Dialog.Cancel\")","cancelText","<Button onClick={() => onClose(false)}>\n {payload.cancelText ?? t(\"Layout.Dialog.Cancel\")}\n </Button>","() => onClose(true)","payload.confirmText ?? t(\"Layout.Dialog.Confirm\")","confirmText","<Button onClick={() => onClose(true)} autoFocus>\n {payload.confirmText ?? t(\"Layout.Dialog.Confirm\")}\n </Button>","<DialogActions>\n <Button onClick={() => onClose(false)}>\n {payload.cancelText ?? t(\"Layout.Dialog.Cancel\")}\n </Button>\n <Button onClick={() => onClose(true)} autoFocus>\n {payload.confirmText ?? t(\"Layout.Dialog.Confirm\")}\n </Button>\n </DialogActions>","<Dialog\n maxWidth=\"xs\"\n fullWidth\n open={open}\n onClose={() => onClose(false)}\n role=\"alertdialog\"\n aria-describedby={messageId}\n >\n <DialogTitle>{payload.title ?? t(\"Layout.Dialog.Confirm\")}</DialogTitle>\n <DialogContent id={messageId}>{payload.message}</DialogContent>\n <DialogActions>\n <Button onClick={() => onClose(false)}>\n {payload.cancelText ?? t(\"Layout.Dialog.Cancel\")}\n </Button>\n <Button onClick={() => onClose(true)} autoFocus>\n {payload.confirmText ?? t(\"Layout.Dialog.Confirm\")}\n </Button>\n </DialogActions>\n </Dialog>","(message, { ...options } = {}) =>\n open(AlertDialog, { ...options, message })","{ ...options } = {}","(message, { ...options } = {}) =>\n open(ConfirmDialog, { ...options, message })","options","{ alert, confirm, open, close }"],"sources":["../src/components/router/RouterLink.tsx","../src/hooks/useTranslation.ts","../src/hooks/useDialogs.tsx"],"sourcesContent":["import type {\n ButtonProps,\n FabProps,\n IconButtonProps,\n LinkProps,\n ListItemButtonProps,\n TabProps,\n} from \"@mui/material\";\nimport { Button, Fab, IconButton, Link, ListItemButton, Tab } from \"@mui/material\";\nimport { createLink } from \"@tanstack/react-router\";\n\n// MUI components as router links. React 19 passes `ref` as a prop, so no forwardRef.\nexport const RouterButton = createLink((props: ButtonProps<\"a\">) => (\n <Button component=\"a\" {...props} />\n));\n\nexport const RouterFab = createLink((props: FabProps<\"a\">) => <Fab component=\"a\" {...props} />);\n\nexport const RouterIconButton = createLink((props: IconButtonProps<\"a\">) => (\n <IconButton component=\"a\" {...props} />\n));\n\nexport const RouterLink = createLink((props: LinkProps) => <Link {...props} />);\n\nexport const RouterListItemButton = createLink((props: ListItemButtonProps<\"a\">) => (\n <ListItemButton component=\"a\" {...props} />\n));\n\nexport const RouterTab = createLink((props: TabProps<\"a\">) => <Tab component=\"a\" {...props} />);\n","import { useTranslation as useI18nextTranslation } from \"react-i18next\";\nimport { getI18n } from \"~/lib/i18n\";\n\n/**\n * react-i18next's `useTranslation` on the request's instance during SSR, so a component\n * above `LayoutProvider` (the root shell) renders the request's language too.\n */\nexport const useTranslation: typeof useI18nextTranslation = (ns, options) =>\n useI18nextTranslation(ns, { i18n: getI18n(), ...options });\n","import {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n useEventCallback,\n} from \"@mui/material\";\nimport { createContext, useContext, useId } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport type { ReactNode } from \"react\";\n\nexport interface OpenDialogOptions<TResult> {\n onClose?: (result: TResult) => Promise<void>;\n}\n\nexport interface AlertOptions {\n title?: ReactNode;\n}\n\nexport interface ConfirmOptions {\n title?: ReactNode;\n confirmText?: ReactNode;\n cancelText?: ReactNode;\n}\n\nexport interface DialogProps<TPayload = undefined, TResult = void> {\n payload: TPayload;\n open: boolean;\n onClose: (result: TResult) => Promise<void>;\n}\n\nexport type OpenAlertDialog = (message: ReactNode, options?: AlertOptions) => Promise<void>;\n\nexport type OpenConfirmDialog = (message: ReactNode, options?: ConfirmOptions) => Promise<boolean>;\n\nexport type DialogComponent<TPayload, TResult> = React.ComponentType<\n DialogProps<TPayload, TResult>\n>;\n\nexport interface OpenDialog {\n <TPayload extends undefined, TResult>(\n Component: DialogComponent<TPayload, TResult>,\n payload?: TPayload,\n options?: OpenDialogOptions<TResult>,\n ): Promise<TResult>;\n <TPayload, TResult>(\n Component: DialogComponent<TPayload, TResult>,\n payload: TPayload,\n options?: OpenDialogOptions<TResult>,\n ): Promise<TResult>;\n}\n\nexport type CloseDialog = <TResult>(dialog: Promise<TResult>, result: TResult) => Promise<TResult>;\n\nexport interface AlertDialogPayload extends AlertOptions {\n message: ReactNode;\n}\n\nexport type AlertDialogProps = DialogProps<AlertDialogPayload, void>;\n\nexport function AlertDialog({ open, payload, onClose }: Readonly<AlertDialogProps>) {\n const { t } = useTranslation();\n const messageId = useId();\n\n return (\n <Dialog\n maxWidth=\"xs\"\n fullWidth\n open={open}\n onClose={() => onClose()}\n role=\"alertdialog\"\n aria-describedby={messageId}\n >\n <DialogTitle>{payload.title ?? t(\"Layout.Dialog.Alert\")}</DialogTitle>\n <DialogContent id={messageId}>{payload.message}</DialogContent>\n <DialogActions>\n <Button onClick={() => onClose()} autoFocus>\n {t(\"Layout.Dialog.Confirm\")}\n </Button>\n </DialogActions>\n </Dialog>\n );\n}\n\nexport interface ConfirmDialogPayload extends ConfirmOptions {\n message: ReactNode;\n}\n\nexport type ConfirmDialogProps = DialogProps<ConfirmDialogPayload, boolean>;\n\nexport function ConfirmDialog({ open, payload, onClose }: Readonly<ConfirmDialogProps>) {\n const { t } = useTranslation();\n const messageId = useId();\n\n return (\n <Dialog\n maxWidth=\"xs\"\n fullWidth\n open={open}\n onClose={() => onClose(false)}\n role=\"alertdialog\"\n aria-describedby={messageId}\n >\n <DialogTitle>{payload.title ?? t(\"Layout.Dialog.Confirm\")}</DialogTitle>\n <DialogContent id={messageId}>{payload.message}</DialogContent>\n <DialogActions>\n <Button onClick={() => onClose(false)}>\n {payload.cancelText ?? t(\"Layout.Dialog.Cancel\")}\n </Button>\n <Button onClick={() => onClose(true)} autoFocus>\n {payload.confirmText ?? t(\"Layout.Dialog.Confirm\")}\n </Button>\n </DialogActions>\n </Dialog>\n );\n}\n\nexport const DialogsContext = createContext<Pick<DialogHook, \"open\" | \"close\">>(\n {} as Pick<DialogHook, \"open\" | \"close\">,\n);\n\ninterface DialogHook {\n alert: OpenAlertDialog;\n confirm: OpenConfirmDialog;\n open: OpenDialog;\n close: CloseDialog;\n}\n\nexport function useDialogs(): DialogHook {\n const { open, close } = useContext(DialogsContext);\n\n const alert = useEventCallback<OpenAlertDialog>((message, { ...options } = {}) =>\n open(AlertDialog, { ...options, message }),\n );\n\n const confirm = useEventCallback<OpenConfirmDialog>((message, { ...options } = {}) =>\n open(ConfirmDialog, { ...options, message }),\n );\n\n return { alert, confirm, open, close };\n}\n"],"mappings":";;;;;;;;AAYA,MAAa,eAAe,YAAY,UACtC,oBAAC,QAAD;CAAQ,WAAA;CAAc,GAAI;AAAK,CAAA,CAChC;AAED,MAAa,YAAY,YAAY,UAAyB,oBAAC,KAAD;CAAK,WAAA;CAAc,GAAI;AAAK,CAAA,CAAI;AAE9F,MAAa,mBAAmB,YAAY,UAC1C,oBAAC,YAAD;CAAY,WAAA;CAAc,GAAI;AAAK,CAAA,CACpC;AAED,MAAa,aAAa,YAAY,UAAqB,oBAAC,MAAD,EAAM,GAAI,MAAK,CAAA,CAAI;AAE9E,MAAa,uBAAuB,YAAY,UAC9C,oBAAC,gBAAD;CAAgB,WAAA;CAAc,GAAI;AAAK,CAAA,CACxC;AAED,MAAa,Y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