wcz-layout 10.2.1 → 10.2.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 (73) hide show
  1. package/dist/{ChatLayout-BpRj5rlH.mjs → ChatLayout-CkS9oyPp.mjs} +557 -270
  2. package/dist/ChatLayout-CkS9oyPp.mjs.map +1 -0
  3. package/dist/{Employee-C8xIlBxY.d.mts → ExtractFile-ClTc-e1H.d.mts} +20 -3
  4. package/dist/RouterListItemButton-CF-8w-08.mjs.map +1 -1
  5. package/dist/Translate-Ad784Dps.d.mts +24 -0
  6. package/dist/{Approval-D1TfISUL.mjs → Translate-BiCjnlyx.mjs} +22 -2
  7. package/dist/Translate-BiCjnlyx.mjs.map +1 -0
  8. package/dist/ai.d.mts +31 -4
  9. package/dist/ai.mjs +154 -10
  10. package/dist/ai.mjs.map +1 -1
  11. package/dist/auth.d.mts +4 -3
  12. package/dist/auth.mjs +5 -5
  13. package/dist/authMiddleware-D4GSt7m9.mjs +50 -0
  14. package/dist/authMiddleware-D4GSt7m9.mjs.map +1 -0
  15. package/dist/components.mjs +13 -5
  16. package/dist/components.mjs.map +1 -1
  17. package/dist/{createApi-BXjkj4fM.mjs → createApi-CF4ZL82B.mjs} +3 -4
  18. package/dist/createApi-CF4ZL82B.mjs.map +1 -0
  19. package/dist/data/client.d.mts +17 -1
  20. package/dist/data/client.mjs +11 -5
  21. package/dist/data/client.mjs.map +1 -1
  22. package/dist/data/server.d.mts +18 -3
  23. package/dist/data/server.mjs +5 -5
  24. package/dist/{env-BwFl7nWc.mjs → env-Cddts_dn.mjs} +2 -1
  25. package/dist/env-Cddts_dn.mjs.map +1 -0
  26. package/dist/{file-BQ-Bu2g8.mjs → file-D4kSR_lC.mjs} +5 -6
  27. package/dist/file-D4kSR_lC.mjs.map +1 -0
  28. package/dist/{file-DZ0KYhoB.mjs → file-DcwYjofa.mjs} +5 -6
  29. package/dist/file-DcwYjofa.mjs.map +1 -0
  30. package/dist/generatedChart-k7NEdi5Z.mjs.map +1 -1
  31. package/dist/hooks.d.mts +2 -2
  32. package/dist/hooks.mjs +294 -192
  33. package/dist/hooks.mjs.map +1 -1
  34. package/dist/index.mjs +224 -173
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/{approval-B3ZQn9aH.mjs → layout-6We_KFgN.mjs} +28 -4
  37. package/dist/layout-6We_KFgN.mjs.map +1 -0
  38. package/dist/middleware.mjs +1 -45
  39. package/dist/middleware.mjs.map +1 -1
  40. package/dist/models.d.mts +3 -3
  41. package/dist/models.mjs +2 -2
  42. package/dist/{peoplesoft-CvwdApCK.mjs → peoplesoft-DH31FCMC.mjs} +3 -3
  43. package/dist/{peoplesoft-CvwdApCK.mjs.map → peoplesoft-DH31FCMC.mjs.map} +1 -1
  44. package/dist/{peoplesoft-C-zPdRVj.d.mts → peoplesoft-DXukeeFr.d.mts} +2 -2
  45. package/dist/{providers-BfFg_3eo.mjs → providers-DOFje2P6.mjs} +7 -7
  46. package/dist/providers-DOFje2P6.mjs.map +1 -0
  47. package/dist/{tokens-CkWpu7Qp.mjs → tokens-DNe_Qifk.mjs} +63 -9
  48. package/dist/tokens-DNe_Qifk.mjs.map +1 -0
  49. package/dist/user-Bc2nLjAG.mjs +136 -0
  50. package/dist/user-Bc2nLjAG.mjs.map +1 -0
  51. package/dist/utils-CgabUlDD.mjs +131 -0
  52. package/dist/utils-CgabUlDD.mjs.map +1 -0
  53. package/dist/utils.mjs +1 -1
  54. package/package.json +34 -13
  55. package/skills/ai/SKILL.md +108 -75
  56. package/skills/general/references/auth.md +7 -3
  57. package/skills/services/SKILL.md +41 -7
  58. package/skills/services/docs/layout.md +130 -0
  59. package/skills/start/steps/03-apm-setup.md +8 -1
  60. package/dist/Approval-D1TfISUL.mjs.map +0 -1
  61. package/dist/ChatLayout-BpRj5rlH.mjs.map +0 -1
  62. package/dist/Email-Dz5k0UWE.d.mts +0 -15
  63. package/dist/approval-B3ZQn9aH.mjs.map +0 -1
  64. package/dist/createApi-BXjkj4fM.mjs.map +0 -1
  65. package/dist/env-BwFl7nWc.mjs.map +0 -1
  66. package/dist/file-BQ-Bu2g8.mjs.map +0 -1
  67. package/dist/file-DZ0KYhoB.mjs.map +0 -1
  68. package/dist/providers-BfFg_3eo.mjs.map +0 -1
  69. package/dist/session-B_jK90RC.mjs +0 -23
  70. package/dist/session-B_jK90RC.mjs.map +0 -1
  71. package/dist/tokens-CkWpu7Qp.mjs.map +0 -1
  72. package/dist/utils-DJx-7b4M.mjs +0 -244
  73. package/dist/utils-DJx-7b4M.mjs.map +0 -1
@@ -0,0 +1,130 @@
1
+ # layout
2
+
3
+ Features served by the layout app, currently AI (`POST /api/ai/*`). The app needs no AI packages or AI
4
+ gateway env of its own for them.
5
+
6
+ ## Notes
7
+
8
+ - **Setup:** add `LAYOUT_BASE_URL: z.url()` to the `server` block of `src/env.ts` with the layout
9
+ app's URL in `.env`, and `layout: "api://wistron.com/devportal/access_as_user"` to the app's
10
+ scopes. `AI_BASE_URL` is a different thing: the AI gateway `chatAdapter` calls (see the `ai` skill).
11
+ - **Translate instead of prompting:** text a user typed (a name, a question, a description) gets
12
+ its other languages from `translate`; never write a translation prompt in the app.
13
+ - **Detected language:** `detected` is the language the text is written in, even one outside
14
+ `languages`. When it is one of them, its field is the text exactly as typed (trimmed), never
15
+ reworded; compare it with the field the user typed into to repair a wrong language toggle.
16
+ - One call per text, not streamed. Translate several texts with one call each, in parallel.
17
+ - **Extract instead of prompting:** data read from a document or photo (an invoice, a label, a
18
+ form) comes from `extractFile`; never send a file to a model from the app. Upload the file with
19
+ the file service first, then pass its `appName` and `fileId`.
20
+ - **File access:** the layout app downloads the file on behalf of the signed-in user (OBO), so it
21
+ reads only files that user can open. A call without a user (a background job on the server
22
+ `extractFile`) reads the file with the layout app's own token instead.
23
+ - **Fields:** each field is a name (letters, digits, `_`), a `type` (`string` by default,
24
+ `number`, `boolean` or `date`) and a `description` that says what to read and in what form,
25
+ e.g. "ISO 4217 code of the invoiced currency". Every field is `null` when the file does not
26
+ show it; a `date` is `YYYY-MM-DD`. Values are copied as printed: conversions and calculations
27
+ (currency, totals, thresholds) stay in the app's code.
28
+ - **Instructions:** optional context the model compares against, e.g. the approved items, with a
29
+ field such as `note` that describes what to report.
30
+ - PDFs and images (PNG, JPEG, WebP, GIF) up to 20 MB; other types answer 415.
31
+
32
+ ## Client
33
+
34
+ `import { ... } from "wcz-layout/data/client";`
35
+
36
+ - Mutation:
37
+ `translateMutationOptions()` → `mutate(TranslateSchema)` → `Translation` // the text in every language of `languages`, and the language it is written in; signed-in users only
38
+ - Mutation:
39
+ `extractFileMutationOptions()` → `mutate(ExtractFileSchema)` → `FileExtraction` // the value of each field read from the file; signed-in users only
40
+
41
+ ## Server
42
+
43
+ `import { ... } from "wcz-layout/data/server";`
44
+
45
+ - `translate({ data: TranslateSchema })` → `Translation` // same, inside another server function
46
+ - `extractFile({ data: ExtractFileSchema })` → `FileExtraction` // same, inside another server function or a background job
47
+
48
+ ## Schemas/Models
49
+
50
+ `import { TranslateSchema, ExtractFileSchema, type Translation, type FileExtraction } from "wcz-layout/models";`
51
+
52
+ ```ts
53
+ const TranslateSchema = z.object({
54
+ text: z.string().trim().min(1).max(4000),
55
+ languages: z // BCP 47 tags: en, cs, zh-TW
56
+ .array(z.string().regex(/^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/))
57
+ .min(1)
58
+ .max(20),
59
+ });
60
+
61
+ type Translation = { detected: string } & Record<string, string>; // { detected: "cs", en, cs, uk }
62
+
63
+ const ExtractFileSchema = z.object({
64
+ appName: z.string().min(1).max(255),
65
+ fileId: z.uuid(),
66
+ fields: z.record(
67
+ z.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,63}$/), // 1 to 50 fields
68
+ z.object({
69
+ type: z.enum(["string", "number", "boolean", "date"]).default("string"),
70
+ description: z.string().trim().min(1).max(1000),
71
+ }),
72
+ ),
73
+ instructions: z.string().trim().max(4000).optional(),
74
+ });
75
+
76
+ type FileExtraction = Record<string, string | number | boolean | null>; // keyed by field name
77
+ ```
78
+
79
+ ## Examples
80
+
81
+ ```tsx
82
+ // client
83
+ import { useMutation } from "@tanstack/react-query";
84
+ import { translateMutationOptions } from "wcz-layout/data/client";
85
+
86
+ const { mutateAsync: translate, isPending } = useMutation(translateMutationOptions());
87
+
88
+ const { detected, ...name } = await translate({
89
+ text: form.getFieldValue("name.en"),
90
+ languages: ["en", "cs", "uk", "zh-TW"],
91
+ });
92
+ form.setFieldValue("name", name); // { en, cs, uk, "zh-TW" }
93
+
94
+ // server (inside another server function)
95
+ import { translate } from "wcz-layout/data/server";
96
+
97
+ const translations = await Promise.all(
98
+ tasks.map((task) => translate({ data: { text: task.text, languages: ["cs", "en", "uk"] } })),
99
+ );
100
+ ```
101
+
102
+ ```ts
103
+ // server: read an uploaded invoice, then convert and compare in code
104
+ import { extractFile } from "wcz-layout/data/server";
105
+
106
+ const invoice = await extractFile({
107
+ data: {
108
+ appName: "cid",
109
+ fileId,
110
+ fields: {
111
+ invoice: {
112
+ description:
113
+ "Invoice number exactly as printed; the primary document number on a debit note or RMA",
114
+ },
115
+ total: {
116
+ type: "number",
117
+ description: "Grand total exactly as printed, in the document's own currency",
118
+ },
119
+ currency: { description: "ISO 4217 code of the invoiced currency (TWD for NTD)" },
120
+ note: {
121
+ description:
122
+ "Discrepancies against the approved items: unexpected part numbers, quantities, supplier",
123
+ },
124
+ },
125
+ instructions: `Approved items:\n${items.map((item) => `- ${item.pn}: qty ${item.quantity}`).join("\n")}`,
126
+ },
127
+ });
128
+ const totalNtd =
129
+ invoice.total === null ? null : await toNtd(Number(invoice.total), String(invoice.currency));
130
+ ```
@@ -20,7 +20,14 @@ Register the app in **Application Portfolio Management** (https://apm.wistron.co
20
20
 
21
21
  - `Create` → dismiss the notice with `OK`. Tab 1 opens in edit mode. Every other section opens with its pencil and saves with its ✓. After a save, check for the `Update successful` toast.
22
22
  - Dropdown option refs change every time a dropdown opens. Open it, find the option, then click.
23
- - Person fields: type the full name, click the suggestion, and verify the row (job number, name, email).
23
+ - Dropdowns: click the select component itself, not its placeholder text (a hidden search input intercepts the click). Options often render in a body-level popup missing from the snapshot diff; find them with a visible-option selector (e.g. `.ant-select-item-option:visible`) filtered by text. Inspect the DOM once to learn the class names, then reuse them.
24
+ - Refs inside a section go stale when an earlier field re-renders it (e.g. picking a value rebuilds the rows below). Re-read the refs from the latest diff, or use label-based locators.
25
+ - Prefer one Playwright script per section: locate fields by label (form item containing the label text), fill them all, then return the values read back. This is faster and far cheaper than one tool call per field. Avoid full page reads; the sidebar alone is tens of KB.
26
+ - Type-ahead searches sometimes return nothing on the first try. Clear the field, retype more slowly, and wait up to ~10 s for the options before retrying (max 3 attempts).
27
+ - Person fields: type the job number or full name, click the suggestion, and verify the row (job number, name, email). For several people, loop: add row → type → wait for the suggestion → click → read back.
28
+ - Do not navigate back to fix an earlier section after moving on; verify the summary/view mode instead, and if values were lost, re-enter them rather than trusting the earlier save.
29
+ - A Playwright `check()` on a styled radio/checkbox can report failure while the click worked. Verify by the UI effect (a dependent field appearing) rather than `isChecked()`.
30
+ - An auth error toast (e.g. `Unauthorized`, `socket hang up`) on save is usually transient: retry once, then confirm that no duplicate record was created.
24
31
  - A ✓ that stays disabled means a required field is unset. After a failed save, change any dropdown and change it back to re-enable the ✓.
25
32
 
26
33
  ## Tab 1 — Application Information
@@ -1 +0,0 @@
1
- {"version":3,"file":"Approval-D1TfISUL.mjs","names":["z","z","z","z","z"],"sources":["../src/models/approval/ApprovalCoRequestor.ts","../src/models/approval/ApprovalEmployee.ts","../src/models/approval/StepApprovalOrder.ts","../src/models/approval/ApprovalFlow.ts","../src/models/approval/ApprovalStepResult.ts","../src/models/approval/ApprovalFlowStep.ts","../src/models/approval/ApprovalRequestType.ts","../src/models/approval/ApprovalStatus.ts","../src/models/approval/HqApprovalRequest.ts","../src/models/approval/Approval.ts"],"sourcesContent":["import { z } from \"zod\";\n\nexport const ApprovalCoRequestorGroupSchema = z.object({\n role: z.string().trim().min(1),\n email: z.email(),\n});\n\nexport type ApprovalCoRequestorGroup = z.infer<typeof ApprovalCoRequestorGroupSchema>;\n\nexport const ApprovalCoRequestorEmployeeSchema = z.object({\n employeeId: z.string().trim().min(1),\n name: z.string().trim().min(1),\n email: z.email(),\n});\n\nexport type ApprovalCoRequestorEmployee = z.infer<typeof ApprovalCoRequestorEmployeeSchema>;\n\nexport const ApprovalCoRequestorPrincipalSchema = z.union([\n ApprovalCoRequestorGroupSchema,\n ApprovalCoRequestorEmployeeSchema,\n]);\n\nexport type ApprovalCoRequestorPrincipal = z.infer<typeof ApprovalCoRequestorPrincipalSchema>;\n\nexport const ApprovalCoRequestorPermissionsSchema = z.object({\n withdraw: z.boolean().default(false).optional(),\n cancel: z.boolean().default(false).optional(),\n});\n\nexport type ApprovalCoRequestorPermissions = z.infer<typeof ApprovalCoRequestorPermissionsSchema>;\n\nexport const ApprovalCoRequestorSchema = z.object({\n id: z.uuid(),\n principal: ApprovalCoRequestorPrincipalSchema,\n permissions: ApprovalCoRequestorPermissionsSchema,\n});\n\nexport type ApprovalCoRequestor = z.infer<typeof ApprovalCoRequestorSchema>;\n","import { z } from \"zod\";\n\nexport const ApprovalEmployeeSchema = z.object({\n employeeId: z.string().trim().min(1).max(20),\n name: z.string().trim().min(1).max(50),\n email: z.email().min(1).max(100),\n});\n\nexport type ApprovalEmployee = z.infer<typeof ApprovalEmployeeSchema>;\n\nexport const ApprovalProxySchema = z.object({\n proxy: ApprovalEmployeeSchema,\n});\n\nexport type ApprovalProxy = z.infer<typeof ApprovalProxySchema>;\n","import z from \"zod\";\n\nexport const StepApprovalOrder = z.enum([\"Serial\", \"Parallel\", \"OneOfThem\"]);\n","import { z } from \"zod\";\nimport { StepApprovalOrder } from \"./StepApprovalOrder\";\nimport type { ApprovalFlowStep } from \"./ApprovalFlowStep\";\n\nexport const ApprovalFlowSchema = z.object({\n id: z.uuid(),\n approvalStage: z.number(),\n batchSequence: z.number().optional(),\n approvalSequence: z.number(),\n stepApprovalOrder: StepApprovalOrder,\n steps: z.array(z.custom<ApprovalFlowStep>()),\n isActive: z.boolean().default(false).optional(),\n});\n\nexport type ApprovalFlow = z.infer<typeof ApprovalFlowSchema>;\n","import z from \"zod\";\n\nexport const ApprovalStepResult = z.enum([\n \"NotAvailable\",\n \"FutureApproval\",\n \"WaitingForApproval\",\n \"Approved\",\n \"Rejected\",\n \"Skipped\",\n \"Withdrawn\",\n \"Cancelled\",\n]);\n","import { z } from \"zod\";\nimport { ApprovalEmployeeSchema, ApprovalProxySchema } from \"./ApprovalEmployee\";\nimport { ApprovalStepResult } from \"./ApprovalStepResult\";\n\nexport const ApprovalFlowStepSchema = z.object({\n id: z.uuid(),\n order: z.number(),\n approverRole: z.string().trim().min(1).max(100).default(\"Approver\").optional(),\n approver: ApprovalEmployeeSchema,\n actualApprover: ApprovalEmployeeSchema.optional(),\n proxies: z.array(ApprovalProxySchema),\n result: ApprovalStepResult.default(\"NotAvailable\").optional(),\n resultDate: z.date().optional(),\n resultComment: z.string().trim().max(2000).optional(),\n});\n\nexport type ApprovalFlowStep = z.infer<typeof ApprovalFlowStepSchema>;\n","import z from \"zod\";\n\nexport const ApprovalRequestType = z.enum([\"Single\", \"Batch\"]);\n","import z from \"zod\";\n\nexport const ApprovalStatus = z.enum([\n \"WaitingForApproval\",\n \"Approved\",\n \"Rejected\",\n \"Withdrawn\",\n \"Cancelled\",\n]);\n","import { z } from \"zod\";\n\nexport const HqApprovalColSchema = z.object({\n title: z.string().optional(),\n text: z.string().optional(),\n textColor: z.string().optional(),\n textSize: z.string().optional(),\n});\n\nexport type HqApprovalCol = z.infer<typeof HqApprovalColSchema>;\n\nexport const HqApprovalRowSchema = z.object({\n col: z.array(HqApprovalColSchema),\n});\n\nexport type HqApprovalRow = z.infer<typeof HqApprovalRowSchema>;\n\nexport const HqApprovalSectionSchema = z.object({\n row: z.array(HqApprovalRowSchema),\n title: z.string().optional(),\n type: z.string().optional(),\n text: z.string().optional(),\n});\n\nexport type HqApprovalSection = z.infer<typeof HqApprovalSectionSchema>;\n\nexport const HqApprovalPageSchema = z.object({\n section: z.array(HqApprovalSectionSchema),\n});\n\nexport type HqApprovalPage = z.infer<typeof HqApprovalPageSchema>;\n\nexport const HqApprovalSummarySchema = z.object({\n page: z.array(HqApprovalPageSchema),\n});\n\nexport type HqApprovalSummary = z.infer<typeof HqApprovalSummarySchema>;\n\nexport const HqApprovalFormDataSchema = z.object({\n systemId: z.string().optional(),\n formType: z.string().optional(),\n formId: z.string().optional(),\n stepName: z.string().optional(),\n userId: z.string().optional(),\n title: z.string().optional(),\n subject: z.string().optional(),\n summary: HqApprovalSummarySchema.optional(),\n messageId: z.string().optional(),\n attachList: z.string().optional(),\n chkResult: z.string().optional(),\n apprSummary: z.string().optional(),\n approvalComment: z.string().optional(),\n});\n\nexport type HqApprovalFormData = z.infer<typeof HqApprovalFormDataSchema>;\n\nexport const HqApprovalHeaderSchema = z.object({\n serviceId: z.string().optional(),\n authorizationCode: z.string().optional(),\n dataCreatedTime: z.string().optional(),\n characterEnable: z.boolean().default(false).optional(),\n});\n\nexport type HqApprovalHeader = z.infer<typeof HqApprovalHeaderSchema>;\n\nexport const HqApprovalRequestSchema = z.object({\n header: HqApprovalHeaderSchema.optional(),\n formData: HqApprovalFormDataSchema.optional(),\n});\n\nexport type HqApprovalRequest = z.infer<typeof HqApprovalRequestSchema>;\n","import z from \"zod\";\nimport { ApprovalCoRequestorSchema } from \"./ApprovalCoRequestor\";\nimport {\n type ApprovalEmployee,\n ApprovalEmployeeSchema,\n ApprovalProxySchema,\n} from \"./ApprovalEmployee\";\nimport type { ApprovalFlow } from \"./ApprovalFlow\";\nimport { ApprovalFlowSchema } from \"./ApprovalFlow\";\nimport { ApprovalFlowStepSchema } from \"./ApprovalFlowStep\";\nimport { ApprovalRequestType } from \"./ApprovalRequestType\";\nimport { ApprovalStatus } from \"./ApprovalStatus\";\nimport { ApprovalStepResult } from \"./ApprovalStepResult\";\nimport { HqApprovalRequestSchema } from \"./HqApprovalRequest\";\n\nexport const ApprovalSchema = z.object({\n id: z.uuid(),\n number: z.string().trim().min(1).max(30),\n applicationName: z.string().trim().min(1).max(50),\n type: ApprovalRequestType.default(\"Single\").optional(),\n status: ApprovalStatus,\n created: z.date(),\n createdBy: z.custom<ApprovalEmployee>(),\n updated: z.date().optional(),\n updatedBy: z.custom<ApprovalEmployee>().optional(),\n approvalFlows: z.array(z.custom<ApprovalFlow>()).min(1),\n currentApprovers: z.array(\n ApprovalEmployeeSchema.extend({ proxies: z.array(ApprovalProxySchema) }),\n ),\n coRequestors: z.array(ApprovalCoRequestorSchema).optional(),\n});\n\nexport type Approval = z.infer<typeof ApprovalSchema>;\n\n// Create Approval\nexport const CreateApprovalSchema = ApprovalSchema.pick({\n id: true,\n number: true,\n applicationName: true,\n type: true,\n status: true,\n approvalFlows: true,\n}).extend({\n emailBody: z.string().trim().min(1),\n hqApprovalRequest: HqApprovalRequestSchema.optional(),\n approvalFlows: z\n .array(\n ApprovalFlowSchema.pick({\n approvalStage: true,\n batchSequence: true,\n stepApprovalOrder: true,\n steps: true,\n }).extend({\n steps: z\n .array(\n ApprovalFlowStepSchema.pick({\n approverRole: true,\n approver: true,\n }),\n )\n .min(1),\n }),\n )\n .min(1),\n coRequestors: z.array(ApprovalCoRequestorSchema).optional(),\n});\n\nexport type CreateApproval = z.infer<typeof CreateApprovalSchema>;\n\n// Single Approval\nexport const ApproveApprovalSchema = z.object({\n id: z.uuid(),\n result: ApprovalStepResult,\n resultComment: z.string().trim().max(2000).optional(),\n emailBody: z.string().trim().min(1),\n});\n\nexport type ApproveApproval = z.infer<typeof ApproveApprovalSchema>;\n\n// Resubmit Approval\nexport const ResubmitApprovalSchema = ApprovalSchema.pick({\n id: true,\n approvalFlows: true,\n}).extend({\n emailBody: z.string().trim().min(1),\n approvalFlows: z\n .array(\n ApprovalFlowSchema.pick({\n approvalStage: true,\n batchSequence: true,\n stepApprovalOrder: true,\n steps: true,\n }).extend({\n steps: z\n .array(\n ApprovalFlowStepSchema.pick({\n approverRole: true,\n approver: true,\n }),\n )\n .min(1),\n }),\n )\n .min(1),\n});\n\nexport type ResubmitApproval = z.infer<typeof ResubmitApprovalSchema>;\n\n// Cancel Approval\nexport const CancelApprovalSchema = z.object({\n id: z.uuid(),\n comment: z.string().trim().min(1).max(2000),\n emailBody: z.string().trim().min(1),\n});\n\nexport type CancelApproval = z.infer<typeof CancelApprovalSchema>;\n\n// Withdraw Approval\nexport const WithdrawApprovalSchema = z.object({\n id: z.uuid(),\n comment: z.string().trim().min(1).max(2000),\n emailBody: z.string().trim().min(1),\n});\n\nexport type WithdrawApproval = z.infer<typeof WithdrawApprovalSchema>;\n"],"mappings":";;AAEA,MAAa,iCAAiCA,IAAE,OAAO;CACrD,MAAMA,IAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;CAC7B,OAAOA,IAAE,MAAM;AACjB,CAAC;AAID,MAAa,oCAAoCA,IAAE,OAAO;CACxD,YAAYA,IAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;CACnC,MAAMA,IAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;CAC7B,OAAOA,IAAE,MAAM;AACjB,CAAC;AAID,MAAa,qCAAqCA,IAAE,MAAM,CACxD,gCACA,iCACF,CAAC;AAID,MAAa,uCAAuCA,IAAE,OAAO;CAC3D,UAAUA,IAAE,QAAQ,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,SAAS;CAC9C,QAAQA,IAAE,QAAQ,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,SAAS;AAC9C,CAAC;AAID,MAAa,4BAA4BA,IAAE,OAAO;CAChD,IAAIA,IAAE,KAAK;CACX,WAAW;CACX,aAAa;AACf,CAAC;;ACjCD,MAAa,yBAAyBC,IAAE,OAAO;CAC7C,YAAYA,IAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,E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AAC,IAAI,GAAI;CAC1C,WAAW,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;AACpC,CAAC;AAKD,MAAa,yBAAyB,EAAE,OAAO;CAC7C,IAAI,EAAE,KAAK;CACX,SAAS,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAI;CAC1C,WAAW,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;AACpC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChatLayout-BpRj5rlH.mjs","names":["{ 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 }","_c","<Link ref={reference} {...props} />","<CreatedComponent {...props} />","_c","prefix = \"\"","{ prefix = \"\", options, dateFormat, ...props }","Typography","\"body2\"","\"text.secondary\"","noWrap","props","prefix","Array.isArray(value) ? value.map(format).join(\" – \") : format(value)","(entry: unknown) =>\n typeof entry === \"number\"\n ? entry.toLocaleString(undefined, options)\n : formatValue(entry, dateFormat)","<Typography variant=\"body2\" color=\"text.secondary\" noWrap {...props}>\n {prefix}\n {/* `extent` — the default aggregate for anything non-numeric — is a [min, max] pair. */}\n {Array.isArray(value) ? value.map(format).join(\" – \") : format(value)}\n </Typography>","_c","z","{ node }: Readonly<{ node: Record<string, unknown> }>","isRecord(node.props) ? node.props : {}","props","<Skeleton variant=\"rounded\" height={typeof height === \"number\" ? height : 280} />","typeof height === \"number\" ? height : 280","streaming ? (\n placeholder\n ) : (\n <Suspense fallback={placeholder}>\n <GeneratedChart node={node} />\n </Suspense>\n )","{ part }: Readonly<{ part: ToolCallPart }>","part.input ?? (parsePartialJSON(part.arguments) as unknown)","arguments","input","{ overflowX: \"auto\", m: -0.5, p: 0.5 }","() => part.arguments","() => <Alert severity=\"warning\">{t(\"Layout.Chat.RenderFailed\")}</Alert>","renderGeneratedUi(input?.ui)","input?.ui","<Streaming value={part.input === undefined}>{renderGeneratedUi(input?.ui)}</Streaming>","part.input === undefined","<Box sx={{ overflowX: \"auto\", m: -0.5, p: 0.5 }}>\n <CatchBoundary\n getResetKey={() => part.arguments}\n errorComponent={() => <Alert severity=\"warning\">{t(\"Layout.Chat.RenderFailed\")}</Alert>}\n >\n <Streaming value={part.input === undefined}>{renderGeneratedUi(input?.ui)}</Streaming>\n </CatchBoundary>\n </Box>","{\n part,\n disabled,\n onAnswer,\n}: Readonly<{\n part: ToolCallPart;\n disabled: boolean;\n onAnswer: (values: Record<string, unknown>) => void;\n}>","(event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n const { submitter } = event.nativeEvent as SubmitEvent;\n const values: Record<string, unknown> = {};\n for (const [name, value] of new FormData(event.currentTarget, submitter)) {\n const previous = values[name];\n values[name] = previous === undefined ? value : [previous, value].flat();\n }\n onAnswer(values);\n }","{\n border: 0,\n m: 0,\n p: 0,\n minWidth: 0,\n opacity: answer === undefined ? 1 : 0.6,\n pointerEvents: disabled ? \"none\" : undefined,\n }","answer === undefined ? 1 : 0.6","disabled ? \"none\" : undefined","<GeneratedUi part={part} />","<Box\n component=\"fieldset\"\n disabled={disabled}\n sx={{\n border: 0,\n m: 0,\n p: 0,\n minWidth: 0,\n opacity: answer === undefined ? 1 : 0.6,\n pointerEvents: disabled ? \"none\" : undefined,\n }}\n >\n <GeneratedUi part={part} />\n </Box>","isRecord(answer) && (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {Object.entries(answer)\n .map(([name, value]) => `${name}: ${String(value)}`)\n .join(\", \")}\n </Typography>\n )","([name, value]) => `${name}: ${String(value)}`","<Box component=\"form\" onSubmit={submit}>\n <Box\n component=\"fieldset\"\n disabled={disabled}\n sx={{\n border: 0,\n m: 0,\n p: 0,\n minWidth: 0,\n opacity: answer === undefined ? 1 : 0.6,\n pointerEvents: disabled ? \"none\" : undefined,\n }}\n >\n <GeneratedUi part={part} />\n </Box>\n {isRecord(answer) && (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {Object.entries(answer)\n .map(([name, value]) => `${name}: ${String(value)}`)\n .join(\", \")}\n </Typography>\n )}\n </Box>","name","value","[name, value]","_c","_temp","{ href = \"\", children }: ComponentPropsWithoutRef<\"a\">","href = \"\"","href.startsWith(\"/\") && !href.startsWith(\"//\") ? (\n <RouterLink to={href}>{children}</RouterLink>\n ) : (\n <Link href={href} target=\"_blank\" rel=\"noreferrer\">\n {children}\n </Link>\n )","() => {\n const scroller = ref.current;\n if (!scroller) return;\n let previousTop = scroller.scrollTop;\n\n const onScroll = () => {\n following.current = keepsFollowing(following.current, previousTop, scroller);\n previousTop = scroller.scrollTop;\n };\n const observer = new ResizeObserver(() => {\n if (!following.current) return;\n scroller.scrollTop = scroller.scrollHeight;\n previousTop = scroller.scrollTop;\n });\n\n scroller.addEventListener(\"scroll\", onScroll, { passive: true });\n observer.observe(scroller);\n for (const child of scroller.children) observer.observe(child);\n return () => {\n scroller.removeEventListener(\"scroll\", onScroll);\n observer.disconnect();\n };\n }","[]","{ ref, following }","t(\"Layout.Chat.Reasoning\")","<Typography role=\"status\" className={statusClass} sx={shimmerSx}>\n {t(\"Layout.Chat.Reasoning\")}\n </Typography>","{ part, live }: Readonly<{ part: ToolCallPart; live: boolean }>","running ? shimmerSx : { color: \"text.secondary\" }","activityOf(part, live)","t(`Layout.Chat.${activityOf(part, live)}`, { name: part.name, target: targetOf(part) })","`Layout.Chat.${activityOf(part, live)}`","<Typography\n variant=\"body2\"\n role={running ? \"status\" : undefined}\n className={statusClass}\n sx={running ? shimmerSx : { color: \"text.secondary\" }}\n >\n {t(`Layout.Chat.${activityOf(part, live)}`, { name: part.name, target: targetOf(part) })}\n </Typography>","running ? \"status\" : undefined","{\n message,\n live,\n canAnswer,\n addToolResult,\n}: Readonly<{\n message: UIMessage;\n live: boolean;\n canAnswer: boolean;\n addToolResult: Chat[\"addToolResult\"];\n}>","{\n alignSelf: \"flex-end\",\n maxWidth: \"80%\",\n px: 2,\n py: 1.25,\n borderRadius: 4.5,\n bgcolor: \"action.hover\",\n whiteSpace: \"pre-wrap\",\n overflowWrap: \"anywhere\",\n }","message.parts.map((part) => (part.type === \"text\" ? part.content : null))","parts","(part) => (part.type === \"text\" ? part.content : null)","<Typography\n sx={{\n alignSelf: \"flex-end\",\n maxWidth: \"80%\",\n px: 2,\n py: 1.25,\n borderRadius: 4.5,\n bgcolor: \"action.hover\",\n whiteSpace: \"pre-wrap\",\n overflowWrap: \"anywhere\",\n }}\n >\n {message.parts.map((part) => (part.type === \"text\" ? part.content : null))}\n </Typography>","message.parts.map((part, index) => {\n if (part.type === \"text\")\n return part.content ? (\n <Box key={index} sx={markdownSx}>\n <Markdown extensions={markdownExtensions} components={markdownComponents}>\n {part.content}\n </Markdown>\n </Box>\n ) : null;\n if (part.type !== \"tool-call\") return null;\n const ui = part.name === \"show_ui\" || part.name === \"ask_user\";\n // The model draws a UI whose input failed again.\n if (ui && part.state === \"error\") return null;\n if (part.name === \"show_ui\") return <GeneratedUi key={part.id} part={part} />;\n if (part.name === \"ask_user\")\n return (\n <AskUser\n key={part.id}\n part={part}\n disabled={!canAnswer || part.output !== undefined}\n onAnswer={(output) =>\n void addToolResult({ toolCallId: part.id, tool: part.name, output })\n }\n />\n );\n return <ToolActivity key={part.id} part={part} live={live} />;\n })","(part, index) => {\n if (part.type === \"text\")\n return part.content ? (\n <Box key={index} sx={markdownSx}>\n <Markdown extensions={markdownExtensions} components={markdownComponents}>\n {part.content}\n </Markdown>\n </Box>\n ) : null;\n if (part.type !== \"tool-call\") return null;\n const ui = part.name === \"show_ui\" || part.name === \"ask_user\";\n // The model draws a UI whose input failed again.\n if (ui && part.state === \"error\") return null;\n if (part.name === \"show_ui\") return <GeneratedUi key={part.id} part={part} />;\n if (part.name === \"ask_user\")\n return (\n <AskUser\n key={part.id}\n part={part}\n disabled={!canAnswer || part.output !== undefined}\n onAnswer={(output) =>\n void addToolResult({ toolCallId: part.id, tool: part.name, output })\n }\n />\n );\n return <ToolActivity key={part.id} part={part} live={live} />;\n }","part","{ chat }: Readonly<{ chat: Chat }>","chat.interrupts.map((interrupt) =>\n interrupt.metadata?.kind === \"approval\" &&\n interrupt.status === \"pending\" &&\n \"resolveInterrupt\" in interrupt ? (\n <Alert\n key={interrupt.id}\n severity=\"warning\"\n action={\n <Stack direction=\"row\" spacing={1}>\n <Button\n color=\"inherit\"\n size=\"small\"\n disabled={chat.resuming}\n onClick={() => interrupt.resolveInterrupt(false)}\n >\n {t(\"Layout.Dialog.Cancel\")}\n </Button>\n <Button\n color=\"inherit\"\n size=\"small\"\n disabled={chat.resuming}\n onClick={() => interrupt.resolveInterrupt(true)}\n >\n {t(\"Layout.Dialog.Confirm\")}\n </Button>\n </Stack>\n }\n >\n {t(\"Layout.Chat.AreYouSure\")}\n </Alert>\n ) : null,\n )","interrupts","resuming","(interrupt) =>\n interrupt.metadata?.kind === \"approval\" &&\n interrupt.status === \"pending\" &&\n \"resolveInterrupt\" in interrupt ? (\n <Alert\n key={interrupt.id}\n severity=\"warning\"\n action={\n <Stack direction=\"row\" spacing={1}>\n <Button\n color=\"inherit\"\n size=\"small\"\n disabled={chat.resuming}\n onClick={() => interrupt.resolveInterrupt(false)}\n >\n {t(\"Layout.Dialog.Cancel\")}\n </Button>\n <Button\n color=\"inherit\"\n size=\"small\"\n disabled={chat.resuming}\n onClick={() => interrupt.resolveInterrupt(true)}\n >\n {t(\"Layout.Dialog.Confirm\")}\n </Button>\n </Stack>\n }\n >\n {t(\"Layout.Chat.AreYouSure\")}\n </Alert>\n ) : null","{ chat, onSend }: Readonly<{ chat: Chat; onSend: () => void }>","(event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (!draft.trim() || chat.isLoading) return;\n onSend();\n void chat.sendMessage(draft.trim());\n setDraft(\"\");\n }","chat.isLoading","(event: KeyboardEvent<HTMLFormElement>) => {\n if (event.key !== \"Enter\" || event.shiftKey || event.nativeEvent.isComposing) return;\n if (!(event.target instanceof HTMLTextAreaElement)) return;\n event.preventDefault();\n event.currentTarget.requestSubmit();\n }","async () => {\n if (await confirm(t(\"Layout.Chat.NewChatConfirm\"))) chat.clear();\n }","{ display: \"flex\", alignItems: \"flex-end\", gap: 1, p: 1, borderRadius: 7, boxShadow: 2 }","t(\"Layout.Chat.NewChat\")","() => void newChat()","<Add />","<span>\n <IconButton onClick={() => void newChat()} disabled={!chat.messages.length}>\n <Add />\n </IconButton>\n </span>","!chat.messages.length","<Tooltip title={t(\"Layout.Chat.NewChat\")}>\n <span>\n <IconButton onClick={() => void newChat()} disabled={!chat.messages.length}>\n <Add />\n </IconButton>\n </span>\n </Tooltip>","(event) => setDraft(event.target.value)","event","t(\"Layout.Chat.Message\")","{ input: { \"aria-label\": t(\"Layout.Chat.Message\") } }","{ flex: 1, py: 1 }","<InputBase\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n placeholder={t(\"Layout.Chat.Message\")}\n multiline\n maxRows={8}\n slotProps={{ input: { \"aria-label\": t(\"Layout.Chat.Message\") } }}\n sx={{ flex: 1, py: 1 }}\n />","chat.isLoading ? (\n <Tooltip title={t(\"Layout.Chat.Stop\")}>\n <IconButton onClick={chat.stop} sx={roundButtonSx}>\n <Stop />\n </IconButton>\n </Tooltip>\n ) : (\n <Tooltip title={t(\"Layout.Chat.Send\")}>\n <IconButton type=\"submit\" sx={roundButtonSx}>\n <ArrowUpward />\n </IconButton>\n </Tooltip>\n )","isLoading","stop","<Paper\n component=\"form\"\n variant=\"outlined\"\n onSubmit={send}\n onKeyDown={sendOnEnter}\n sx={{ display: \"flex\", alignItems: \"flex-end\", gap: 1, p: 1, borderRadius: 7, boxShadow: 2 }}\n >\n <Tooltip title={t(\"Layout.Chat.NewChat\")}>\n <span>\n <IconButton onClick={() => void newChat()} disabled={!chat.messages.length}>\n <Add />\n </IconButton>\n </span>\n </Tooltip>\n <InputBase\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n placeholder={t(\"Layout.Chat.Message\")}\n multiline\n maxRows={8}\n slotProps={{ input: { \"aria-label\": t(\"Layout.Chat.Message\") } }}\n sx={{ flex: 1, py: 1 }}\n />\n {chat.isLoading ? (\n <Tooltip title={t(\"Layout.Chat.Stop\")}>\n <IconButton onClick={chat.stop} sx={roundButtonSx}>\n <Stop />\n </IconButton>\n </Tooltip>\n ) : (\n <Tooltip title={t(\"Layout.Chat.Send\")}>\n <IconButton type=\"submit\" sx={roundButtonSx}>\n <ArrowUpward />\n </IconButton>\n </Tooltip>\n )}\n </Paper>","_c"],"sources":["../src/hooks/useDialogs.tsx","../src/components/router/RouterLink.tsx","../src/components/table/context.ts","../src/components/table/table/Pagination.tsx","../src/components/table/utils.ts","../src/components/table/formatValue.ts","../src/components/table/cells/formatters/AggregatedCell.tsx","../src/lib/ai/tools/ui.ts","../src/components/chat/generatedUi.tsx","../src/components/chat/ChatLayout.tsx"],"sourcesContent":["import {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n useEventCallback,\n} from \"@mui/material\";\nimport { useContext, useId } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { DialogsContext } from \"../contexts/DialogsContext\";\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\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","import { Link } from \"@mui/material\";\nimport { createLink } from \"@tanstack/react-router\";\nimport React from \"react\";\nimport type { LinkProps } from \"@mui/material\";\nimport type { LinkComponent } from \"@tanstack/react-router\";\n\nconst Component = React.forwardRef<HTMLAnchorElement, LinkProps>(\n function LinkComponent(props, reference) {\n return <Link ref={reference} {...props} />;\n },\n);\n\nconst CreatedComponent = createLink(Component);\n\nexport const RouterLink: LinkComponent<typeof Component> = (props) => {\n return <CreatedComponent {...props} />;\n};\n","import {\n aggregationFn_count,\n aggregationFn_extent,\n aggregationFn_first,\n aggregationFn_last,\n aggregationFn_max,\n aggregationFn_mean,\n aggregationFn_median,\n aggregationFn_min,\n aggregationFn_sum,\n aggregationFn_unique,\n aggregationFn_uniqueCount,\n createExpandedRowModel,\n createFacetedMinMaxValues,\n createFacetedRowModel,\n createFacetedUniqueValues,\n createFilteredRowModel,\n createGroupedRowModel,\n createPaginatedRowModel,\n createSortedRowModel,\n createTableHookContexts,\n filterFn_arrHas,\n filterFn_arrIncludes,\n filterFn_arrIncludesAll,\n filterFn_arrIncludesSome,\n filterFn_between,\n filterFn_betweenInclusive,\n filterFn_empty,\n filterFn_endsWith,\n filterFn_equals,\n filterFn_equalsString,\n filterFn_equalsStringSensitive,\n filterFn_greaterThan,\n filterFn_greaterThanOrEqualTo,\n filterFn_inDateRange,\n filterFn_inNumberRange,\n filterFn_includesString,\n filterFn_includesStringSensitive,\n filterFn_lessThan,\n filterFn_lessThanOrEqualTo,\n filterFn_notEmpty,\n filterFn_startsWith,\n filterFn_weakEquals,\n metaHelper,\n sortFn_alphanumeric,\n sortFn_alphanumericCaseSensitive,\n sortFn_basic,\n sortFn_datetime,\n sortFn_text,\n sortFn_textCaseSensitive,\n stockFeatures,\n tableFeatures,\n} from \"@tanstack/react-table\";\nimport type { AggregationFnDef } from \"@tanstack/react-table\";\nimport type { LayoutColumnMeta } from \"~/components/table/types\";\n\n// table-core types min/max/extent with its non-exported `RangeValue`, which breaks .d.ts emit.\ntype RangeValue = Date | number | undefined;\ntype WithResult<TFn, TResult> =\n TFn extends AggregationFnDef<infer TFeatures, infer TData, infer TValue, unknown>\n ? AggregationFnDef<TFeatures, TData, TValue, TResult>\n : never;\n\nexport const layoutTableFeatures = tableFeatures({\n ...stockFeatures,\n columnMeta: metaHelper<LayoutColumnMeta>(),\n filteredRowModel: createFilteredRowModel(),\n sortedRowModel: createSortedRowModel(),\n paginatedRowModel: createPaginatedRowModel(),\n expandedRowModel: createExpandedRowModel(),\n groupedRowModel: createGroupedRowModel(),\n facetedRowModel: createFacetedRowModel(),\n facetedUniqueValues: createFacetedUniqueValues(),\n facetedMinMaxValues: createFacetedMinMaxValues(),\n filterFns: {\n arrHas: filterFn_arrHas,\n arrIncludes: filterFn_arrIncludes,\n arrIncludesAll: filterFn_arrIncludesAll,\n arrIncludesSome: filterFn_arrIncludesSome,\n between: filterFn_between,\n betweenInclusive: filterFn_betweenInclusive,\n empty: filterFn_empty,\n endsWith: filterFn_endsWith,\n equals: filterFn_equals,\n equalsString: filterFn_equalsString,\n equalsStringSensitive: filterFn_equalsStringSensitive,\n greaterThan: filterFn_greaterThan,\n greaterThanOrEqualTo: filterFn_greaterThanOrEqualTo,\n inDateRange: filterFn_inDateRange,\n inNumberRange: filterFn_inNumberRange,\n includesString: filterFn_includesString,\n includesStringSensitive: filterFn_includesStringSensitive,\n lessThan: filterFn_lessThan,\n lessThanOrEqualTo: filterFn_lessThanOrEqualTo,\n notEmpty: filterFn_notEmpty,\n startsWith: filterFn_startsWith,\n weakEquals: filterFn_weakEquals,\n },\n sortFns: {\n alphanumeric: sortFn_alphanumeric,\n alphanumericCaseSensitive: sortFn_alphanumericCaseSensitive,\n basic: sortFn_basic,\n datetime: sortFn_datetime,\n text: sortFn_text,\n textCaseSensitive: sortFn_textCaseSensitive,\n },\n aggregationFns: {\n sum: aggregationFn_sum,\n min: aggregationFn_min as WithResult<typeof aggregationFn_min, RangeValue>,\n max: aggregationFn_max as WithResult<typeof aggregationFn_max, RangeValue>,\n extent: aggregationFn_extent as WithResult<\n typeof aggregationFn_extent,\n [RangeValue, RangeValue]\n >,\n mean: aggregationFn_mean,\n median: aggregationFn_median,\n unique: aggregationFn_unique,\n uniqueCount: aggregationFn_uniqueCount,\n count: aggregationFn_count,\n first: aggregationFn_first,\n last: aggregationFn_last,\n },\n});\n\nexport type LayoutTableFeatures = typeof layoutTableFeatures;\n\nexport const {\n tableContext,\n cellContext,\n headerContext,\n useTableContext,\n useCellContext,\n useHeaderContext,\n} = createTableHookContexts<LayoutTableFeatures>();\n","import { TablePagination, type TablePaginationProps } from \"@mui/material\";\nimport type { FC } from \"react\";\nimport { useTableContext } from \"~/components/table/context\";\n\nexport type PaginationProps = Omit<\n TablePaginationProps,\n \"count\" | \"page\" | \"rowsPerPage\" | \"onPageChange\" | \"onRowsPerPageChange\" | \"rowsPerPageOptions\"\n> & { pageSizeOptions?: Array<number> };\n\n/** A pager is for large data sets, so it offers no \"All\". LayoutTable starts at the lowest. */\nexport const DEFAULT_PAGE_SIZE_OPTIONS = [25, 50, 100];\n\nexport const Pagination: FC<PaginationProps> = ({\n pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS,\n ...props\n}) => {\n // The counts below are table methods; compiled, they would be cached on the table reference,\n // which does not change when only data or options (rowCount, pageCount) do.\n \"use no memo\";\n const table = useTableContext();\n const { pageIndex, pageSize } = table.state.pagination;\n\n return (\n <TablePagination\n component=\"div\"\n showFirstButton\n showLastButton\n {...props}\n sx={[\n { flexShrink: 0, minHeight: 52, borderTop: 1, borderColor: \"divider\" },\n ...(Array.isArray(props.sx) ? props.sx : [props.sx]),\n ]}\n rowsPerPageOptions={pageSizeOptions}\n // pageCount -1 means the total is unknown (cursor paging): MUI shows \"of more than N\" and\n // keeps Next enabled.\n count={table.getPageCount() === -1 ? -1 : table.getRowCount()}\n page={pageIndex}\n rowsPerPage={pageSize}\n onPageChange={(_, page) => table.setPageIndex(page)}\n // One update: a controlled onPaginationChange may resolve two calls against the same state.\n onRowsPerPageChange={(event) =>\n table.setPagination({ pageIndex: 0, pageSize: Number(event.target.value) })\n }\n />\n );\n};\n","import type { Theme } from \"@mui/material\";\nimport type { DisplayHotkey } from \"@tanstack/react-hotkeys\";\nimport { formatForDisplay } from \"@tanstack/react-hotkeys\";\nimport type { Cell, CellData, Column, RowData } from \"@tanstack/react-table\";\nimport type { Range } from \"@tanstack/react-virtual\";\nimport { defaultRangeExtractor } from \"@tanstack/react-virtual\";\nimport type { LayoutTableFeatures } from \"~/components/table/context\";\nimport type { LayoutColumnMeta } from \"./types\";\n\n/** Stable class names on every table part, for `sx` selectors like `.MuiDataGrid-*`. */\nexport const layoutTableClasses = {\n root: \"LayoutTable-root\",\n main: \"LayoutTable-main\",\n table: \"LayoutTable-table\",\n\n toolbar: \"LayoutTable-toolbar\",\n toolbarLabel: \"LayoutTable-toolbarLabel\",\n toolbarTitle: \"LayoutTable-toolbarTitle\",\n toolbarSelectedCount: \"LayoutTable-toolbarSelectedCount\",\n toolbarDivider: \"LayoutTable-toolbarDivider\",\n toolbarQuickFilter: \"LayoutTable-toolbarQuickFilter\",\n columnsButton: \"LayoutTable-columnsButton\",\n columnsPanel: \"LayoutTable-columnsPanel\",\n filtersButton: \"LayoutTable-filtersButton\",\n filterPanel: \"LayoutTable-filterPanel\",\n\n columnHeaders: \"LayoutTable-columnHeaders\",\n columnHeaderRow: \"LayoutTable-columnHeaderRow\",\n columnHeader: \"LayoutTable-columnHeader\",\n \"columnHeader--sortable\": \"LayoutTable-columnHeader--sortable\",\n \"columnHeader--sorted\": \"LayoutTable-columnHeader--sorted\",\n \"columnHeader--filtered\": \"LayoutTable-columnHeader--filtered\",\n \"columnHeader--pinnedStart\": \"LayoutTable-columnHeader--pinnedStart\",\n \"columnHeader--pinnedEnd\": \"LayoutTable-columnHeader--pinnedEnd\",\n columnHeaderContent: \"LayoutTable-columnHeaderContent\",\n columnHeaderTitleContainer: \"LayoutTable-columnHeaderTitleContainer\",\n sortLabel: \"LayoutTable-sortLabel\",\n sortIndex: \"LayoutTable-sortIndex\",\n menuIcon: \"LayoutTable-menuIcon\",\n columnSeparator: \"LayoutTable-columnSeparator\",\n \"columnSeparator--resizable\": \"LayoutTable-columnSeparator--resizable\",\n \"columnSeparator--resizing\": \"LayoutTable-columnSeparator--resizing\",\n\n body: \"LayoutTable-body\",\n row: \"LayoutTable-row\",\n \"row--grouped\": \"LayoutTable-row--grouped\",\n \"row--expanded\": \"LayoutTable-row--expanded\",\n \"row--pinned\": \"LayoutTable-row--pinned\",\n cell: \"LayoutTable-cell\",\n \"cell--selected\": \"LayoutTable-cell--selected\",\n \"cell--grouped\": \"LayoutTable-cell--grouped\",\n \"cell--aggregated\": \"LayoutTable-cell--aggregated\",\n \"cell--pinnedStart\": \"LayoutTable-cell--pinnedStart\",\n \"cell--pinnedEnd\": \"LayoutTable-cell--pinnedEnd\",\n groupCell: \"LayoutTable-groupCell\",\n expandButton: \"LayoutTable-expandButton\",\n actionsCell: \"LayoutTable-actionsCell\",\n cellOffset: \"LayoutTable-cellOffset\",\n rowOffset: \"LayoutTable-rowOffset\",\n filler: \"LayoutTable-filler\",\n skeletonRow: \"LayoutTable-skeletonRow\",\n skeletonCell: \"LayoutTable-skeletonCell\",\n overlay: \"LayoutTable-overlay\",\n\n footer: \"LayoutTable-footer\",\n footerRow: \"LayoutTable-footerRow\",\n footerCell: \"LayoutTable-footerCell\",\n aggregationValue: \"LayoutTable-aggregationValue\",\n pagination: \"LayoutTable-pagination\",\n} as const;\n\nexport const classNames = (...names: Array<string | false | null | undefined>): string =>\n names.filter(Boolean).join(\" \");\n\nexport const pinnedClass = <TData extends RowData, TValue extends CellData>(\n column: AnyColumn<TData, TValue>,\n part: \"columnHeader\" | \"cell\",\n): string | false => {\n const pinned = column.getIsPinned();\n return (\n !!pinned && layoutTableClasses[`${part}--${pinned === \"start\" ? \"pinnedStart\" : \"pinnedEnd\"}`]\n );\n};\n\nexport const shortcutLabel = (label: string, hotkey: DisplayHotkey): string =>\n `${label} (${formatForDisplay(hotkey)})`;\n\ntype AnyColumn<TData extends RowData, TValue extends CellData> = Column<\n LayoutTableFeatures,\n TData,\n TValue\n>;\n\nexport const columnLabel = <TData extends RowData, TValue extends CellData>(\n column: AnyColumn<TData, TValue>,\n): string => {\n const meta = column.columnDef.meta as LayoutColumnMeta | undefined;\n if (meta?.label) return meta.label;\n\n return typeof column.columnDef.header === \"string\" ? column.columnDef.header : column.id;\n};\n\nexport const hasColumnLabel = <TData extends RowData, TValue extends CellData>(\n column: AnyColumn<TData, TValue>,\n): boolean =>\n Boolean((column.columnDef.meta as LayoutColumnMeta | undefined)?.label) ||\n typeof column.columnDef.header === \"string\";\n\nexport const columnAlign = <TData extends RowData, TValue extends CellData>(\n column: AnyColumn<TData, TValue>,\n): \"left\" | \"center\" | \"right\" =>\n (column.columnDef.meta as LayoutColumnMeta | undefined)?.align ??\n (hasColumnLabel(column) ? \"left\" : \"center\");\n\n/** The column's `meta.flex`, or 0 once the user has resized it to a fixed width. */\nexport const columnFlex = <TData extends RowData, TValue extends CellData>(\n column: AnyColumn<TData, TValue>,\n): number =>\n Object.hasOwn(column.table.atoms.columnSizing.get(), column.id)\n ? 0\n : ((column.columnDef.meta as LayoutColumnMeta | undefined)?.flex ?? 0);\n\nexport const moveColumn = <TData extends RowData, TValue extends CellData>(\n column: AnyColumn<TData, TValue>,\n delta: number,\n): void => {\n const { table } = column;\n const current = table.atoms.columnOrder.get();\n const order = current.length ? [...current] : table.getAllLeafColumns().map(({ id }) => id);\n const from = order.indexOf(column.id);\n const to = from + delta;\n if (from < 0 || to < 0 || to >= order.length) return;\n\n order.splice(to, 0, ...order.splice(from, 1));\n table.setColumnOrder(order);\n};\n\nexport const pinnedSx = <TData extends RowData, TValue extends CellData>(\n column: AnyColumn<TData, TValue>,\n isHeader = false,\n) => {\n const pinned = column.getIsPinned();\n if (!pinned) return {};\n\n return {\n position: \"sticky\",\n zIndex: isHeader ? 4 : 2,\n insetInlineStart: pinned === \"start\" ? column.getStart(\"start\") : undefined,\n insetInlineEnd: pinned === \"end\" ? column.getAfter(\"end\") : undefined,\n bgcolor: \"background.paper\",\n ...(!isHeader && {\n \".MuiTableRow-root:hover > &\": {\n backgroundImage: (theme: Theme) =>\n `linear-gradient(${theme.palette.action.hover}, ${theme.palette.action.hover})`,\n },\n \".MuiTableRow-root.Mui-selected > &\": {\n backgroundImage: (theme: Theme) =>\n `linear-gradient(${theme.palette.action.selected}, ${theme.palette.action.selected})`,\n },\n }),\n ...(pinned === \"start\" &&\n column.getIsLastColumn(\"start\") && {\n borderInlineEnd: 1,\n borderInlineEndStyle: \"solid\",\n borderColor: \"divider\",\n }),\n ...(pinned === \"end\" &&\n column.getIsFirstColumn(\"end\") && {\n borderInlineStart: 1,\n borderInlineStartStyle: \"solid\",\n borderColor: \"divider\",\n }),\n };\n};\n\nexport const cellSelectionSx = <TData extends RowData, TValue extends CellData>(\n cell: Cell<LayoutTableFeatures, TData, TValue>,\n) => {\n if (!cell.getIsSelected()) return {};\n\n const edges = cell.getSelectionEdges();\n const outline = (theme: Theme) =>\n [\n edges.top && `inset 0 2px 0 0 ${theme.palette.primary.main}`,\n edges.bottom && `inset 0 -2px 0 0 ${theme.palette.primary.main}`,\n edges.left && `inset 2px 0 0 0 ${theme.palette.primary.main}`,\n edges.right && `inset -2px 0 0 0 ${theme.palette.primary.main}`,\n ]\n .filter(Boolean)\n .join(\", \") || \"none\";\n\n return {\n backgroundImage: (theme: Theme) =>\n `linear-gradient(${theme.palette.action.selected}, ${theme.palette.action.selected})`,\n boxShadow: outline,\n };\n};\n\n/** Spreadsheet TSV quoting, so a cell holding a tab or a newline stays one cell. */\nconst quoteTsv = (text: string): string =>\n /[\"\\t\\n\\r]/.test(text) ? `\"${text.replaceAll('\"', '\"\"')}\"` : text;\n\nconst toClipboardValue = (value: unknown): string => {\n if (value == null) return \"\";\n if (typeof value === \"string\") return quoteTsv(value);\n if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\")\n return quoteTsv(String(value));\n if (value instanceof Date) return quoteTsv(value.toISOString());\n\n // Everything else — objects, and the odd symbol or function — as JSON or blank.\n return quoteTsv(JSON.stringify(value) ?? \"\");\n};\n\n/**\n * Serializes `table.getSelectedCellRangesData()` as TSV, which is what Excel,\n * Google Sheets and LibreOffice all paste as a grid. Disjoint selection regions\n * are separated by a blank line.\n */\nexport const toClipboardText = (regions: Array<Array<Array<unknown>>>): string =>\n regions\n .map((rows) => rows.map((cells) => cells.map(toClipboardValue).join(\"\\t\")).join(\"\\n\"))\n .join(\"\\n\\n\");\n\nexport const lookaheadRange = (\n range: Range,\n direction: \"forward\" | \"backward\" | null,\n lookahead: number,\n): Array<number> => {\n const behind = direction ? 0 : range.overscan;\n const ahead = direction ? lookahead : range.overscan;\n\n return defaultRangeExtractor({\n ...range,\n startIndex: range.startIndex - (direction === \"backward\" ? ahead : behind),\n endIndex: range.endIndex + (direction === \"backward\" ? behind : ahead),\n overscan: 0,\n });\n};\n","import dayjs from \"dayjs\";\n\nexport const formatValue = (value: unknown, dateFormat = \"L LT\"): string => {\n if (value === null || value === undefined) return \"\";\n if (value instanceof Date) return dayjs(value).format(dateFormat);\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") {\n return value.toString();\n }\n\n return JSON.stringify(value) ?? \"\";\n};\n","import type { TypographyProps } from \"@mui/material\";\nimport { Typography } from \"@mui/material\";\nimport type { FC } from \"react\";\nimport { formatValue } from \"~/components/table/formatValue\";\nimport { useCellContext } from \"~/components/table/context\";\n\nexport const AggregatedCell: FC<\n TypographyProps & {\n prefix?: string;\n options?: Intl.NumberFormatOptions;\n dateFormat?: string;\n }\n> = ({ prefix = \"\", options, dateFormat, ...props }) => {\n const cell = useCellContext();\n const value = cell.getValue();\n if (value === null || value === undefined || value === \"\") return null;\n\n const format = (entry: unknown) =>\n typeof entry === \"number\"\n ? entry.toLocaleString(undefined, options)\n : formatValue(entry, dateFormat);\n\n return (\n <Typography variant=\"body2\" color=\"text.secondary\" noWrap {...props}>\n {prefix}\n {/* `extent` — the default aggregate for anything non-numeric — is a [min, max] pair. */}\n {Array.isArray(value) ? value.map(format).join(\" – \") : format(value)}\n </Typography>\n );\n};\n","import {\n Accordion,\n AccordionActions,\n AccordionDetails,\n AccordionSummary,\n Alert,\n AlertTitle,\n Avatar,\n AvatarGroup,\n Badge,\n Box,\n Breadcrumbs,\n Button,\n ButtonGroup,\n Card,\n CardActions,\n CardContent,\n CardHeader,\n CardMedia,\n Checkbox,\n Chip,\n CircularProgress,\n Divider,\n FormControl,\n FormControlLabel,\n FormGroup,\n FormHelperText,\n FormLabel,\n Grid,\n ImageList,\n ImageListItem,\n ImageListItemBar,\n InputLabel,\n LinearProgress,\n Link,\n List,\n ListItem,\n ListItemAvatar,\n ListItemText,\n ListSubheader,\n MenuItem,\n Paper,\n Radio,\n RadioGroup,\n Rating,\n Select,\n Skeleton,\n Slider,\n Stack,\n Step,\n StepContent,\n StepLabel,\n Stepper,\n Switch,\n Table,\n TableBody,\n TableCell,\n TableContainer,\n TableFooter,\n TableHead,\n TableRow,\n TextField,\n Tooltip,\n Typography,\n} from \"@mui/material\";\nimport { toolDefinition } from \"@tanstack/ai/client\";\nimport type { ElementType } from \"react\";\nimport { z } from \"zod\";\n\n/**\n * The MUI components the model may render, under their own names. Props pass through\n * untouched, so they are MUI's official props (`ComponentProps<typeof Card>`). Add a\n * component here and both tools offer it. Left out: anything that needs state, an icon,\n * an overlay or a callback to work.\n */\nexport const components = {\n Accordion,\n AccordionActions,\n AccordionDetails,\n AccordionSummary,\n Alert,\n AlertTitle,\n Avatar,\n AvatarGroup,\n Badge,\n Box,\n Breadcrumbs,\n Button,\n ButtonGroup,\n Card,\n CardActions,\n CardContent,\n CardHeader,\n CardMedia,\n Checkbox,\n Chip,\n CircularProgress,\n Divider,\n FormControl,\n FormControlLabel,\n FormGroup,\n FormHelperText,\n FormLabel,\n Grid,\n ImageList,\n ImageListItem,\n ImageListItemBar,\n InputLabel,\n LinearProgress,\n Link,\n List,\n ListItem,\n ListItemAvatar,\n ListItemText,\n ListSubheader,\n MenuItem,\n Paper,\n Radio,\n RadioGroup,\n Rating,\n Select,\n Skeleton,\n Slider,\n Stack,\n Step,\n StepContent,\n StepLabel,\n Stepper,\n Switch,\n Table,\n TableBody,\n TableCell,\n TableContainer,\n TableFooter,\n TableHead,\n TableRow,\n TextField,\n Tooltip,\n Typography,\n} satisfies Record<string, ElementType>;\n\nexport type ComponentName = keyof typeof components;\n\n/**\n * The TanStack Charts marks a `Chart` node takes as children, under their own names. Props pass\n * through untouched too: the rows as `data`, the rest the mark's official options. Only the\n * names live here; the marks load with the first chart, so a chart costs nothing until one shows.\n */\nexport const chartMarks = [\n \"areaX\",\n \"areaY\",\n \"arrow\",\n \"bandX\",\n \"bandY\",\n \"barX\",\n \"barY\",\n \"boxX\",\n \"boxY\",\n \"cell\",\n \"crosshair\",\n \"differenceX\",\n \"differenceY\",\n \"dot\",\n \"frame\",\n \"hexagon\",\n \"lineX\",\n \"lineY\",\n \"linearRegressionX\",\n \"linearRegressionY\",\n \"link\",\n \"rect\",\n \"ridgelineX\",\n \"ridgelineY\",\n \"ruleX\",\n \"ruleY\",\n \"text\",\n \"tickX\",\n \"tickY\",\n \"vector\",\n \"violinX\",\n \"violinY\",\n \"waffleX\",\n \"waffleY\",\n] as const;\n\nexport type ChartMarkName = (typeof chartMarks)[number];\n\ntype NodeType = ComponentName | \"Chart\" | ChartMarkName;\n\n/**\n * `show_ui` and `ask_user`. Built on call, not at import: `wcz-layout/hooks` is imported by\n * every app, and module-level calls survive tree-shaking, registry and all.\n */\nexport function createUiTools() {\n const types: Array<NodeType> = [\n ...(Object.keys(components) as Array<ComponentName>),\n \"Chart\",\n ...chartMarks,\n ];\n const UiNode = z.object({\n type: z.enum(types as [NodeType, ...Array<NodeType>]),\n props: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Official props of the MUI component (sx works), or of the TanStack Charts chart or mark. \" +\n \"A prop can hold a node.\",\n ),\n get children() {\n const child = z.union([z.string(), z.number(), UiNode]);\n return z\n .union([child, z.array(child)])\n .optional()\n .describe(\"Text, a node, or a list of them\");\n },\n });\n const uiInput = z.object({ ui: UiNode });\n\n return [\n toolDefinition({\n name: \"show_ui\",\n description:\n \"Show Material UI (MUI v9) components in the chat. Prefer it to markdown for structured \" +\n \"content: tables, cards, lists, key facts, statuses, steps and progress.\" +\n \"`ui` is one node { type, props, children }: `type` is the component, `props` its \" +\n \"official MUI props (sx works; a prop can hold a node, e.g. CardHeader avatar or Alert \" +\n \"action), `children` text, a node or a list of them. MUI v9 has no system props: \" +\n \"alignItems, gap, p, m and the like go in sx. Grid takes `container`, and `size` on \" +\n \"children (e.g. { xs: 12, sm: 6 }); never `item` or `xs`. The chat can be as narrow as \" +\n \"a phone. Callbacks do nothing; to let the user answer, use ask_user. \" +\n \"A Chart node draws numbers that compare or change with TanStack Charts. Its props are \" +\n \"the defineChart spec without marks: scales.x and scales.y, each { scale: 'band' for \" +\n \"categories, 'point' for ordered labels such as months, 'linear' for numbers (the \" +\n \"default), and the official options such as axis: { label }, grid, nice; padding and a \" +\n \"fixed domain work too }, color ({ legend: true for several series, domain }), focus \" +\n \"('group-x' for lines); and the Chart's ariaLabel and height. Its children are the \" +\n \"marks (barY, barX, lineY, areaY, dot, ruleY, text, cell, crosshair and the rest), each \" +\n \"with props { data: the rows, then the mark's official options, channels naming fields, \" +\n \"e.g. x: 'month', y: 'count', color: 'state' }. Bars at the same x stack; layout: \" +\n \"{ type: 'group' } puts them side by side. A line takes points: true for its dots: a \" +\n \"dot mark of its own adds a second tooltip row. Dates are labels: there is no time scale.\",\n inputSchema: uiInput,\n }).client(() => ({ shown: true })),\n toolDefinition({\n name: \"ask_user\",\n description:\n \"Ask the user with a Material UI form and wait for the answer. Same `ui` format as \" +\n \"show_ui. Give every input a `name`: TextField (type date/number work; select: true \" +\n \"with MenuItem children), FormControlLabel with a Checkbox, Switch or Radio `control`, \" +\n \"RadioGroup, Slider, Rating. Add Button(s) with type 'submit'; the clicked button's \" +\n \"name/value is included, so several buttons work as choices. Returns { [name]: value }: \" +\n \"repeated names give arrays, unchecked boxes are left out. Never use it to confirm a \" +\n \"tool call: tools that need approval ask the user themselves.\",\n inputSchema: uiInput,\n }).client(),\n ] as const;\n}\n","import { Alert, Box, Skeleton, Typography } from \"@mui/material\";\nimport { parsePartialJSON } from \"@tanstack/ai-react\";\nimport type { UIMessage } from \"@tanstack/ai-react\";\nimport { CatchBoundary } from \"@tanstack/react-router\";\nimport { createContext, lazy, Suspense, useContext } from \"react\";\nimport type { ElementType, FormEvent, Key, ReactNode } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { components } from \"~/lib/ai/tools/ui\";\nimport type { ComponentName } from \"~/lib/ai/tools/ui\";\n\ntype ToolCallPart = Extract<UIMessage[\"parts\"][number], { type: \"tool-call\" }>;\n\n/** Keys that run code or swap the rendered element. Checked at every depth: slotProps nest. */\nconst BLOCKED =\n /^([oO][nN]|form[A-Z]|component$|slots$|as$|key$|ref$|dangerouslySetInnerHTML$)|(Component|Ref)$/;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isNode = (\n value: unknown,\n): value is { type: ComponentName; props?: unknown; children?: unknown } =>\n isRecord(value) && typeof value.type === \"string\" && Object.hasOwn(components, value.type);\n\nconst isChart = (value: unknown): value is Record<string, unknown> =>\n isRecord(value) && value.type === \"Chart\";\n\nconst GeneratedChart = lazy(() =>\n import(\"./generatedChart\").then(({ GeneratedChart }) => ({ default: GeneratedChart })),\n);\n\nconst Streaming = createContext(false);\n\n/** Drawn once the arguments are complete; its data and options reach TanStack Charts as written. */\nfunction ChartNode({ node }: Readonly<{ node: Record<string, unknown> }>) {\n const streaming = useContext(Streaming);\n const { height } = isRecord(node.props) ? node.props : {};\n const placeholder = (\n <Skeleton variant=\"rounded\" height={typeof height === \"number\" ? height : 280} />\n );\n\n return streaming ? (\n placeholder\n ) : (\n <Suspense fallback={placeholder}>\n <GeneratedChart node={node} />\n </Suspense>\n );\n}\n\n/** Model-written props without blocked keys or password fields; nodes become elements. */\nconst toProps = (value: unknown): unknown => {\n if (isNode(value) || isChart(value)) return renderGeneratedUi(value);\n if (Array.isArray(value)) return value.map(toProps);\n if (!isRecord(value)) return value;\n return Object.fromEntries(\n Object.entries(value)\n .filter(([name, item]) => !BLOCKED.test(name) && !(name === \"type\" && item === \"password\"))\n .map(([name, item]) => [name, toProps(item)]),\n );\n};\n\n/** A node tree as the model wrote it. Anything that is not a known component renders nothing. */\nexport function renderGeneratedUi(value: unknown, key?: Key): ReactNode {\n if (typeof value === \"string\" || typeof value === \"number\") return value;\n // A lone child stays unwrapped: Tooltip and friends take exactly one element.\n if (Array.isArray(value))\n return value.length === 1 ? renderGeneratedUi(value[0], key) : value.map(renderGeneratedUi);\n if (isChart(value)) return <ChartNode key={key} node={value} />;\n if (!isNode(value)) return null;\n\n const Component: ElementType = components[value.type];\n const { children, ...props } = isRecord(value.props) ? value.props : {};\n return (\n <Component key={key} {...(toProps(props) as Record<string, unknown>)}>\n {renderGeneratedUi(value.children ?? children)}\n </Component>\n );\n}\n\n/** `show_ui`. Renders while the arguments still stream, so the UI builds up as the model writes it. */\nexport function GeneratedUi({ part }: Readonly<{ part: ToolCallPart }>) {\n const { t } = useTranslation();\n const input = (part.input ?? (parsePartialJSON(part.arguments) as unknown)) as\n | { ui?: unknown }\n | undefined;\n\n return (\n // Wide content (a table with many columns) scrolls inside the chat instead of widening the page.\n <Box sx={{ overflowX: \"auto\", m: -0.5, p: 0.5 }}>\n <CatchBoundary\n getResetKey={() => part.arguments}\n errorComponent={() => <Alert severity=\"warning\">{t(\"Layout.Chat.RenderFailed\")}</Alert>}\n >\n <Streaming value={part.input === undefined}>{renderGeneratedUi(input?.ui)}</Streaming>\n </CatchBoundary>\n </Box>\n );\n}\n\n/** `ask_user`. Submitting sends `{ [name]: value }` back to the model as the tool's result. */\nexport function AskUser({\n part,\n disabled,\n onAnswer,\n}: Readonly<{\n part: ToolCallPart;\n disabled: boolean;\n onAnswer: (values: Record<string, unknown>) => void;\n}>) {\n const answer: unknown = part.output;\n\n const submit = (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n const { submitter } = event.nativeEvent as SubmitEvent;\n const values: Record<string, unknown> = {};\n for (const [name, value] of new FormData(event.currentTarget, submitter)) {\n const previous = values[name];\n values[name] = previous === undefined ? value : [previous, value].flat();\n }\n onAnswer(values);\n };\n\n return (\n <Box component=\"form\" onSubmit={submit}>\n <Box\n component=\"fieldset\"\n disabled={disabled}\n sx={{\n border: 0,\n m: 0,\n p: 0,\n minWidth: 0,\n opacity: answer === undefined ? 1 : 0.6,\n pointerEvents: disabled ? \"none\" : undefined,\n }}\n >\n <GeneratedUi part={part} />\n </Box>\n {isRecord(answer) && (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {Object.entries(answer)\n .map(([name, value]) => `${name}: ${String(value)}`)\n .join(\", \")}\n </Typography>\n )}\n </Box>\n );\n}\n","import Add from \"@mui/icons-material/Add\";\nimport ArrowUpward from \"@mui/icons-material/ArrowUpward\";\nimport Refresh from \"@mui/icons-material/Refresh\";\nimport Stop from \"@mui/icons-material/Stop\";\nimport {\n Alert,\n Box,\n Button,\n IconButton,\n InputBase,\n Link,\n Paper,\n Stack,\n Tooltip,\n Typography,\n} from \"@mui/material\";\nimport type { SxProps, Theme } from \"@mui/material\";\nimport { keyframes } from \"@mui/material/styles\";\nimport type { UIMessage, UseChatReturn } from \"@tanstack/ai-react\";\nimport { streamingMarkdownExtension } from \"@tanstack/markdown/extensions/streaming\";\nimport { Markdown } from \"@tanstack/markdown/react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithoutRef, FormEvent, KeyboardEvent } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { AskUser, GeneratedUi } from \"~/components/chat/generatedUi\";\nimport { RouterLink } from \"~/components/router/RouterLink\";\nimport { useDialogs } from \"~/hooks/useDialogs\";\n\ntype Chat = UseChatReturn;\ntype ToolCallPart = Extract<UIMessage[\"parts\"][number], { type: \"tool-call\" }>;\n\n/** One centered reading column, like ChatGPT: full width on a phone, 48rem on a desktop. */\nconst columnSx = { width: \"100%\", maxWidth: \"48rem\", mx: \"auto\", px: 2 } as const;\n\nconst markdownSx = {\n typography: \"body1\",\n overflowWrap: \"anywhere\",\n \"& > *\": { my: 0 },\n \"& > * + *\": { mt: 2 },\n \"& pre\": { overflowX: \"auto\", p: 1.5, borderRadius: 2, bgcolor: \"action.hover\" },\n \"& :not(pre) > code\": { px: 0.5, borderRadius: 1, bgcolor: \"action.hover\" },\n \"& table\": { display: \"block\", overflowX: \"auto\", borderCollapse: \"collapse\" },\n \"& th, & td\": { border: 1, borderColor: \"divider\", px: 1, py: 0.5 },\n \"& img\": { maxWidth: \"100%\" },\n} as const;\n\n// Hides a half-written heading or list item while the reply streams.\nconst markdownExtensions = [streamingMarkdownExtension()];\n\n/** The app's own pages open in place, through the router; anything else in a new tab. */\nfunction MarkdownLink({ href = \"\", children }: ComponentPropsWithoutRef<\"a\">) {\n return href.startsWith(\"/\") && !href.startsWith(\"//\") ? (\n <RouterLink to={href}>{children}</RouterLink>\n ) : (\n <Link href={href} target=\"_blank\" rel=\"noreferrer\">\n {children}\n </Link>\n );\n}\n\nconst markdownComponents = { a: MarkdownLink };\n\nconst shimmer = keyframes`\n from { background-position: 100% 0; }\n to { background-position: -100% 0; }\n`;\n\n/** The model is working on a reply, but nothing of it is on screen yet. */\nexport function isReasoning({ isLoading, messages }: Pick<Chat, \"isLoading\" | \"messages\">) {\n const last = messages.at(-1);\n const part = last?.role === \"assistant\" ? last.parts.at(-1) : undefined;\n // A tool call shows its own line or UI until its result is in.\n const streaming =\n (part?.type === \"text\" && part.content !== \"\") ||\n (part?.type === \"tool-call\" && part.output === undefined);\n return isLoading && !streaming;\n}\n\n/** After a scroll event: at the bottom it follows new content, after a scroll up it stops. */\nexport function keepsFollowing(\n following: boolean,\n previousTop: number,\n {\n scrollTop,\n scrollHeight,\n clientHeight,\n }: Pick<HTMLElement, \"scrollTop\" | \"scrollHeight\" | \"clientHeight\">,\n) {\n if (scrollHeight - clientHeight - scrollTop <= 1) return true;\n return scrollTop < previousTop ? false : following;\n}\n\n/** Keeps the scroll container at the bottom while content grows, unless the user scrolled up. */\nfunction useFollowContent() {\n const ref = useRef<HTMLDivElement>(null);\n const following = useRef(true);\n\n useEffect(() => {\n const scroller = ref.current;\n if (!scroller) return;\n let previousTop = scroller.scrollTop;\n\n const onScroll = () => {\n following.current = keepsFollowing(following.current, previousTop, scroller);\n previousTop = scroller.scrollTop;\n };\n const observer = new ResizeObserver(() => {\n if (!following.current) return;\n scroller.scrollTop = scroller.scrollHeight;\n previousTop = scroller.scrollTop;\n });\n\n scroller.addEventListener(\"scroll\", onScroll, { passive: true });\n observer.observe(scroller);\n for (const child of scroller.children) observer.observe(child);\n return () => {\n scroller.removeEventListener(\"scroll\", onScroll);\n observer.disconnect();\n };\n }, []);\n\n return { ref, following };\n}\n\nconst shimmerSx: SxProps<Theme> = (theme) => {\n const { text } = (theme.vars ?? theme).palette;\n return {\n alignSelf: \"flex-start\",\n color: \"transparent\",\n backgroundImage: `linear-gradient(90deg, ${text.disabled} 40%, ${text.primary} 50%, ${text.disabled} 60%)`,\n backgroundSize: \"200% 100%\",\n backgroundClip: \"text\",\n WebkitBackgroundClip: \"text\",\n animation: `${shimmer} 2s linear infinite`,\n \"@media (prefers-reduced-motion: reduce)\": { animation: \"none\" },\n };\n};\n\n// Status lines in a row sit together.\nconst statusClass = \"LayoutChat-status\";\n\nfunction Reasoning() {\n const { t } = useTranslation();\n\n return (\n <Typography role=\"status\" className={statusClass} sx={shimmerSx}>\n {t(\"Layout.Chat.Reasoning\")}\n </Typography>\n );\n}\n\ntype ActivityKey =\n | \"WritingCode\"\n | \"RunningCode\"\n | \"RanCode\"\n | \"FindingTools\"\n | \"FoundTools\"\n | \"ReadingPage\"\n | \"ReadPage\"\n | \"Clicking\"\n | \"Clicked\"\n | \"Filling\"\n | \"Filled\"\n | \"PressingKey\"\n | \"PressedKey\"\n | \"UsingTool\"\n | \"UsedTool\";\n\n/** A tool's words while the model writes its input, while it runs, and once it is done. */\nconst activities: Record<string, [ActivityKey, ActivityKey, ActivityKey] | undefined> = {\n execute_typescript: [\"WritingCode\", \"RunningCode\", \"RanCode\"],\n discover_tools: [\"FindingTools\", \"FindingTools\", \"FoundTools\"],\n __lazy__tool__discovery__: [\"FindingTools\", \"FindingTools\", \"FoundTools\"],\n read_page: [\"ReadingPage\", \"ReadingPage\", \"ReadPage\"],\n click: [\"Clicking\", \"Clicking\", \"Clicked\"],\n fill: [\"Filling\", \"Filling\", \"Filled\"],\n press_key: [\"PressingKey\", \"PressingKey\", \"PressedKey\"],\n};\n\n/** What a page tool acted on, for its line: the element clicked, the values filled, the key. */\nfunction targetOf({ input }: ToolCallPart) {\n const { name, key, fields } = (input ?? {}) as {\n name?: string;\n key?: string;\n fields?: Array<{ value?: string }>;\n };\n const target = name ?? key ?? fields?.map(({ value }) => value).join(\", \") ?? \"\";\n return target.length > 60 ? `${target.slice(0, 59)}…` : target;\n}\n\nfunction activityOf({ name, state, output }: ToolCallPart, live: boolean) {\n const [writing, running, done] = activities[name] ?? [\"UsingTool\", \"UsingTool\", \"UsedTool\"];\n if (output !== undefined) return state === \"error\" ? \"ToolStopped\" : done;\n if (!live) return \"ToolStopped\";\n return state === \"awaiting-input\" || state === \"input-streaming\" ? writing : running;\n}\n\n/** A tool without UI of its own, as one line: what it does while it runs, then what it did. */\nfunction ToolActivity({ part, live }: Readonly<{ part: ToolCallPart; live: boolean }>) {\n const { t } = useTranslation();\n const running = live && part.output === undefined;\n\n return (\n <Typography\n variant=\"body2\"\n role={running ? \"status\" : undefined}\n className={statusClass}\n sx={running ? shimmerSx : { color: \"text.secondary\" }}\n >\n {t(`Layout.Chat.${activityOf(part, live)}`, { name: part.name, target: targetOf(part) })}\n </Typography>\n );\n}\n\nfunction ChatMessage({\n message,\n live,\n canAnswer,\n addToolResult,\n}: Readonly<{\n message: UIMessage;\n live: boolean;\n canAnswer: boolean;\n addToolResult: Chat[\"addToolResult\"];\n}>) {\n if (message.role === \"user\")\n return (\n <Typography\n sx={{\n alignSelf: \"flex-end\",\n maxWidth: \"80%\",\n px: 2,\n py: 1.25,\n borderRadius: 4.5,\n bgcolor: \"action.hover\",\n whiteSpace: \"pre-wrap\",\n overflowWrap: \"anywhere\",\n }}\n >\n {message.parts.map((part) => (part.type === \"text\" ? part.content : null))}\n </Typography>\n );\n\n return message.parts.map((part, index) => {\n if (part.type === \"text\")\n return part.content ? (\n <Box key={index} sx={markdownSx}>\n <Markdown extensions={markdownExtensions} components={markdownComponents}>\n {part.content}\n </Markdown>\n </Box>\n ) : null;\n if (part.type !== \"tool-call\") return null;\n const ui = part.name === \"show_ui\" || part.name === \"ask_user\";\n // The model draws a UI whose input failed again.\n if (ui && part.state === \"error\") return null;\n if (part.name === \"show_ui\") return <GeneratedUi key={part.id} part={part} />;\n if (part.name === \"ask_user\")\n return (\n <AskUser\n key={part.id}\n part={part}\n disabled={!canAnswer || part.output !== undefined}\n onAnswer={(output) =>\n void addToolResult({ toolCallId: part.id, tool: part.name, output })\n }\n />\n );\n return <ToolActivity key={part.id} part={part} live={live} />;\n });\n}\n\n/** Confirms a server tool marked `needsApproval`; the model has said what it is about to do. */\nfunction Approvals({ chat }: Readonly<{ chat: Chat }>) {\n const { t } = useTranslation();\n\n // Server tools are not registered on the client, so the typed `kind: \"tool-approval\"` never\n // matches here; the server's metadata marks the interrupt as an approval.\n return chat.interrupts.map((interrupt) =>\n interrupt.metadata?.kind === \"approval\" &&\n interrupt.status === \"pending\" &&\n \"resolveInterrupt\" in interrupt ? (\n <Alert\n key={interrupt.id}\n severity=\"warning\"\n action={\n <Stack direction=\"row\" spacing={1}>\n <Button\n color=\"inherit\"\n size=\"small\"\n disabled={chat.resuming}\n onClick={() => interrupt.resolveInterrupt(false)}\n >\n {t(\"Layout.Dialog.Cancel\")}\n </Button>\n <Button\n color=\"inherit\"\n size=\"small\"\n disabled={chat.resuming}\n onClick={() => interrupt.resolveInterrupt(true)}\n >\n {t(\"Layout.Dialog.Confirm\")}\n </Button>\n </Stack>\n }\n >\n {t(\"Layout.Chat.AreYouSure\")}\n </Alert>\n ) : null,\n );\n}\n\nconst roundButtonSx = {\n bgcolor: \"text.primary\",\n color: \"background.paper\",\n \"&:hover\": { bgcolor: \"text.secondary\" },\n} as const;\n\nfunction ChatInput({ chat, onSend }: Readonly<{ chat: Chat; onSend: () => void }>) {\n const { t } = useTranslation();\n const { confirm } = useDialogs();\n const [draft, setDraft] = useState(\"\");\n\n const send = (event: FormEvent<HTMLFormElement>) => {\n event.preventDefault();\n if (!draft.trim() || chat.isLoading) return;\n onSend();\n void chat.sendMessage(draft.trim());\n setDraft(\"\");\n };\n\n // Enter sends and Shift+Enter breaks the line; Enter that ends an IME composition (CJK) does neither.\n const sendOnEnter = (event: KeyboardEvent<HTMLFormElement>) => {\n if (event.key !== \"Enter\" || event.shiftKey || event.nativeEvent.isComposing) return;\n if (!(event.target instanceof HTMLTextAreaElement)) return;\n event.preventDefault();\n event.currentTarget.requestSubmit();\n };\n\n const newChat = async () => {\n if (await confirm(t(\"Layout.Chat.NewChatConfirm\"))) chat.clear();\n };\n\n return (\n <Paper\n component=\"form\"\n variant=\"outlined\"\n onSubmit={send}\n onKeyDown={sendOnEnter}\n sx={{ display: \"flex\", alignItems: \"flex-end\", gap: 1, p: 1, borderRadius: 7, boxShadow: 2 }}\n >\n <Tooltip title={t(\"Layout.Chat.NewChat\")}>\n <span>\n <IconButton onClick={() => void newChat()} disabled={!chat.messages.length}>\n <Add />\n </IconButton>\n </span>\n </Tooltip>\n <InputBase\n value={draft}\n onChange={(event) => setDraft(event.target.value)}\n placeholder={t(\"Layout.Chat.Message\")}\n multiline\n maxRows={8}\n slotProps={{ input: { \"aria-label\": t(\"Layout.Chat.Message\") } }}\n sx={{ flex: 1, py: 1 }}\n />\n {chat.isLoading ? (\n <Tooltip title={t(\"Layout.Chat.Stop\")}>\n <IconButton onClick={chat.stop} sx={roundButtonSx}>\n <Stop />\n </IconButton>\n </Tooltip>\n ) : (\n <Tooltip title={t(\"Layout.Chat.Send\")}>\n <IconButton type=\"submit\" sx={roundButtonSx}>\n <ArrowUpward />\n </IconButton>\n </Tooltip>\n )}\n </Paper>\n );\n}\n\ninterface ChatLayoutProps {\n chat: Chat;\n /** Styles the chat's root box, e.g. a background. */\n sx?: SxProps<Theme>;\n}\n\n/** The chat screen. Give it a parent with a height (e.g. `Fullscreen`). */\nexport function ChatLayout({ chat, sx }: Readonly<ChatLayoutProps>) {\n const { t } = useTranslation();\n const { ref, following } = useFollowContent();\n const last = chat.messages.at(-1);\n // A delete waiting for approval is still running.\n const live = chat.isLoading || chat.interrupts.some(({ status }) => status === \"pending\");\n\n return (\n <Box\n className=\"LayoutChat-root\"\n sx={[\n { display: \"flex\", flexDirection: \"column\", flex: 1, minHeight: 0, height: \"100%\" },\n ...(Array.isArray(sx) ? sx : [sx]),\n ]}\n >\n <Box ref={ref} sx={{ flex: 1, minHeight: 0, overflowY: \"auto\" }}>\n <Stack\n spacing={2.5}\n sx={{ ...columnSx, py: 3, [`& > .${statusClass} + .${statusClass}`]: { mt: 0.5 } }}\n >\n {chat.messages.map((message) => (\n <ChatMessage\n key={message.id}\n message={message}\n live={live && message === last}\n // A form answers only the newest question, once the reply has stopped streaming.\n canAnswer={!chat.isLoading && message === last}\n addToolResult={chat.addToolResult}\n />\n ))}\n <Approvals chat={chat} />\n {isReasoning(chat) && <Reasoning />}\n {chat.error && (\n <Alert\n severity=\"error\"\n action={\n <Tooltip title={t(\"Layout.Chat.Regenerate\")}>\n <IconButton color=\"inherit\" size=\"small\" onClick={() => void chat.reload()}>\n <Refresh fontSize=\"small\" />\n </IconButton>\n </Tooltip>\n }\n >\n {chat.error.message}\n </Alert>\n )}\n </Stack>\n </Box>\n <Box sx={{ ...columnSx, pb: 2 }}>\n <ChatInput chat={chat} onSend={() => (following.current = true)} />\n </Box>\n </Box>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,YAAA,IAAoE;;CAAxD,MAAA,EAAE,MAAM,SAAS,YAAjBA;CAC1B,MAAM,EAAE,MAAM,eAAe;CAC7B,MAAM,YAAY,MAAM;CAOXC,IAAAA;CAAM,IAAA,EAAA,OAAA,SAAA;EAAN,WAAM,QAAQ;EAAR,EAAA,KAAA;;;CAIDC,IAAAA;CAAQC,IAAAA,EAAAA,OAAAA,QAAAA,SAAAA,EAAAA,OAAS,GAAA;EAAjB,KAAA,QAAQ,SAAS,EAAE,qBAAqB;EAAhCA,EAAAA,KAAAA,QAAAA;EAAS,EAAA,KAAA;;;CAA/BC,IAAAA;CAAcF,IAAAA,EAAAA,OAAAA,IAAAA;EAAd,KAAA,oBAAC,aAAD,EAAA,UAAcA,GAA4C,CAAA;EAA5CA,EAAAA,KAAAA;;;CACdG,IAAAA;CAAmB,IAAA,EAAA,OAAA,aAAA,EAAA,OAAoBC,QAAAA,SAAAA;EAAvC,KAAA,oBAAC,eAAD;GAAe,I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;EAD2D,EAAA,KAAA;;;;;;;;;;;;;;;;;;;;CAA9DC,IAAAA;CAACR,IAAAA,EAAAA,QAAAA,MAAAA,EAAAA,QAAmBC,MAAAA,EAAAA,QAAcC,MAAAA,EAAAA,QAAiBC,MAAAA,EAAAA,QAAWC,MAAAA,EAAAA,QAC3DC,MAAAA,EAAAA,QAEAC,IAAAA;EAHH,KAAA,qBAACN,IAAD;GAAY,SAAQC;GAAQ,OAAMC;GAAiB,QAAA;GAAO,GAAIE;GAA9D,UAAA,CACGC,IAEAC,EACDN;;EAJDA,EAAAA,MAAAA;EAAmBC,EAAAA,MAAAA;EAAcC,EAAAA,MAAAA;EAAiBC,EAAAA,MAAAA;EAAWC,EAAAA,MAAAA;EAC3DC,EAAAA,MAAAA;EAEAC,EAAAA,MAAAA;;;CAJL,OACEE;AAMJ;;;;;;;;AC8CA,MAAa,aAAa;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;AASA,MAAa,aAAa;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;AAUA,SAAgB,gBAAgB;CAC9B,MAAM,QAAyB;EAC7B,GAAI,OAAO,KAAK,UAAU;EAC1B;EACA,GAAG;CACL;CACA,MAAM,SAASE,IAAE,OAAO;EACtB,MAAMA,IAAE,KAAK,KAAuC;EACpD,OAAOA,IACJ,OAA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1D,CAAA,CACF;;AAEN"}
@@ -1,15 +0,0 @@
1
- import z from "zod";
2
- declare const EmailSchema: z.ZodObject<{
3
- subject: z.ZodString;
4
- body: z.ZodString;
5
- to: z.ZodArray<z.ZodEmail>;
6
- bcc: z.ZodOptional<z.ZodArray<z.ZodEmail>>;
7
- cc: z.ZodOptional<z.ZodArray<z.ZodEmail>>;
8
- attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
9
- appName: z.ZodString;
10
- subId: z.ZodUUID;
11
- }, z.core.$strip>>>;
12
- }, z.core.$strip>;
13
- type Email = z.infer<typeof EmailSchema>;
14
- export { EmailSchema as n, Email as t };
15
- //# sourceMappingURL=Email-Dz5k0UWE.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"approval-B3ZQn9aH.mjs","names":["z"],"sources":["../src/data/server/approval.ts"],"sourcesContent":["import { createServerOnlyFn } from \"@tanstack/react-start\";\nimport { z } from \"zod\";\nimport { createApi } from \"~/lib/createApi\";\nimport {\n ApproveApprovalSchema,\n CancelApprovalSchema,\n CreateApprovalSchema,\n ResubmitApprovalSchema,\n WithdrawApprovalSchema,\n} from \"~/models/approval/Approval\";\nimport type { Approval } from \"~/models/approval/Approval\";\nimport { ApprovalStatus } from \"~/models/approval/ApprovalStatus\";\nimport { ApprovalStepResult } from \"~/models/approval/ApprovalStepResult\";\n\nexport const GetApprovalsSchema = z.object({\n appName: z.string().min(1).max(255),\n status: ApprovalStatus.optional(),\n approverEmployeeId: z.string().min(1).max(20).optional(),\n stepResult: ApprovalStepResult.optional(),\n});\n\nexport const GetApprovalSchema = z.object({\n id: z.uuid(),\n});\n\nconst approvalApi = () => createApi({ baseURL: \"APPROVAL_BASE_URL\", scopeKey: \"approval\" });\n\nexport const getApprovals = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof GetApprovalsSchema> }): Promise<Array<Approval>> => {\n const input = GetApprovalsSchema.parse(data);\n const queryParams = new URLSearchParams();\n queryParams.append(\"applicationName\", input.appName);\n if (input.status) queryParams.append(\"status\", input.status.toString());\n if (input.approverEmployeeId)\n queryParams.append(\"approverEmployeeId\", input.approverEmployeeId);\n if (input.stepResult) queryParams.append(\"stepResult\", input.stepResult.toString());\n\n const api = await approvalApi();\n const { data: approvals } = await api.request<Array<Approval>>({\n url: `/Requests?${queryParams.toString()}`,\n method: \"GET\",\n });\n return approvals;\n },\n);\n\nexport const getApproval = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof GetApprovalSchema> }): Promise<Approval> => {\n const input = GetApprovalSchema.parse(data);\n const api = await approvalApi();\n const { data: approval } = await api.request<Approval>({\n url: `/Requests/${input.id}`,\n method: \"GET\",\n });\n return approval;\n },\n);\n\nexport const createApproval = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof CreateApprovalSchema> }): Promise<Approval> => {\n const input = CreateApprovalSchema.parse(data);\n const api = await approvalApi();\n const { data: approval } = await api.request<Approval>({\n url: `/Requests`,\n method: \"POST\",\n data: input,\n });\n return approval;\n },\n);\n\nexport const approveApproval = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof ApproveApprovalSchema> }): Promise<Approval> => {\n const input = ApproveApprovalSchema.parse(data);\n const api = await approvalApi();\n const { data: approval } = await api.request<Approval>({\n url: `/Requests/${input.id}/single-approval`,\n method: \"POST\",\n data: input,\n });\n return approval;\n },\n);\n\nexport const resubmitApproval = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof ResubmitApprovalSchema> }): Promise<Approval> => {\n const input = ResubmitApprovalSchema.parse(data);\n const api = await approvalApi();\n const { data: approval } = await api.request<Approval>({\n url: `/Requests/${input.id}/resubmit`,\n method: \"POST\",\n data: input,\n });\n return approval;\n },\n);\n\nexport const withdrawApproval = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof WithdrawApprovalSchema> }): Promise<void> => {\n const input = WithdrawApprovalSchema.parse(data);\n const api = await approvalApi();\n await api.request<void>({\n url: `/Requests/${input.id}/withdraw`,\n method: \"POST\",\n data: input,\n });\n },\n);\n\nexport const cancelApproval = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof CancelApprovalSchema> }): Promise<void> => {\n const input = CancelApprovalSchema.parse(data);\n const api = await approvalApi();\n await api.request<void>({\n url: `/Requests/${input.id}/cancel`,\n method: \"POST\",\n data: input,\n });\n },\n);\n"],"mappings":";;;;;AAcA,MAAa,qBAAqBA,IAAE,OAAO;CACzC,SAASA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CAClC,QAAQ,eAAe,SAAS;CAChC,oBAAoBA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS;CACvD,YAAY,mBAAmB,SAAS;AAC1C,CAAC;AAED,MAAa,oBAAoBA,IAAE,OAAO,EACxC,IAAIA,IAAE,KAAK,EACb,CAAC;AAED,MAAM,oBAAoB,UAAU;CAAE,SAAS;CAAqB,UAAU;AAAW,CAAC;AAE1F,MAAa,eAAe,mBAC1B,OAAO,EAAE,WAAmF;CAC1F,MAAM,QAAQ,mBAAmB,MAAM,IAAI;CAC3C,MAAM,cAAc,IAAI,gBAAgB;CACxC,YAAY,OAAO,mBAAmB,MAAM,OAAO;CACnD,IAAI,MAAM,QAAQ,YAAY,OAAO,UAAU,MAAM,OAAO,SAAS,CAAC;CACtE,IAAI,MAAM,oBACR,YAAY,OAAO,sBAAsB,MAAM,kBAAkB;CACnE,IAAI,MAAM,YAAY,YAAY,OAAO,cAAc,MAAM,WAAW,SAAS,CAAC;CAGlF,MAAM,EAAE,MAAM,cAAc,OAAM,MADhB,YAAY,EAAA,CACQ,QAAyB;EAC7D,KAAK,aAAa,YAAY,SAAS;EACvC,QAAQ;CACV,CAAC;CACD,OAAO;AACT,CACF;AAEA,MAAa,cAAc,mBACzB,OAAO,EAAE,WAA2E;CAClF,MAAM,QAAQ,kBAAkB,MAAM,IAAI;CAE1C,MAAM,EAAE,MAAM,aAAa,OAAM,MADf,YAAY,EAAA,CACO,QAA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fM.mjs","names":[],"sources":["../src/lib/createApi.ts"],"sourcesContent":["import { createServerOnlyFn } from \"@tanstack/react-start\";\nimport axios, { AxiosError, type AxiosInstance } from \"axios\";\nimport https from \"node:https\";\nimport type { serverEnv } from \"virtual:wcz-layout\";\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\nimport { getAccessToken, getAppToken } from \"~/lib/auth/tokens\";\nimport { getSessionUser } from \"~/lib/auth/user\";\n\nexport interface ApiOptions {\n baseURL: keyof typeof serverEnv & `${string}BASE_URL${string}`;\n scopeKey: keyof typeof definedScopes;\n}\n\nconst httpsAgent = new https.Agent({\n rejectUnauthorized: false,\n});\n\nexport const createApi = createServerOnlyFn(\n async ({ baseURL, scopeKey }: ApiOptions): Promise<AxiosInstance> => {\n const resolvedBaseURL = process.env[baseURL];\n if (!resolvedBaseURL) throw new Error(`\"${baseURL}\" env variable is not set.`);\n\n const accessToken = (await getSessionUser())\n ? await getAccessToken(scopeKey)\n : await getAppToken(scopeKey);\n\n const api = axios.create({\n baseURL: resolvedBaseURL,\n httpsAgent,\n headers: { Authorization: `Bearer ${accessToken}` },\n });\n\n api.interceptors.response.use(undefined, (error: unknown) => {\n if (error instanceof AxiosError)\n throw new Error(error.response?.data?.message ?? error.message);\n throw error;\n });\n\n return api;\n },\n);\n"],"mappings":";;;;;;AAaA,MAAM,aAAa,IAAI,MAAM,MAAM,EACjC,oBAAoB,MACtB,CAAC;AAED,MAAa,YAAY,mBACvB,OAAO,EAAE,SAAS,eAAmD;CACnE,MAAM,kBAAkB,QAAQ,IAAI;CACpC,IAAI,CAAC,iBAAiB,MAAM,IAAI,MAAM,IAAI,QAAQ,2BAA2B;CAE7E,MAAM,cAAe,MAAM,eAAe,IACtC,MAAM,eAAe,QAAQ,IAC7B,MAAM,YAAY,QAAQ;CAE9B,MAAM,MAAM,MAAM,OAAO;EACvB,SAAS;EACT;EACA,SAAS,EAAE,eAAe,UAAU,cAAc;CACpD,CAAC;CAED,IAAI,aAAa,SAAS,IAAI,KAAA,IAAY,UAAmB;EAC3D,IAAI,iBAAiB,YACnB,MAAM,IAAI,MAAM,MAAM,UAAU,MAAM,WAAW,MAAM,OAAO;EAChE,MAAM;CACR,CAAC;CAED,OAAO;AACT,CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"env-BwFl7nWc.mjs","names":["z"],"sources":["../src/env.ts"],"sourcesContent":["import { createEnv } from \"@t3-oss/env-core\";\nimport { z } from \"zod\";\n\nexport const clientEnv = createEnv({\n clientPrefix: \"VITE_\",\n client: {},\n runtimeEnv: import.meta.env,\n emptyStringAsUndefined: true,\n});\n\nexport const serverEnv = createEnv({\n server: {\n ENTRA_CLIENT_ID: z.string(),\n ENTRA_TENANT_ID: z.string(),\n ENTRA_CLIENT_SECRET: z.string(),\n AWS_ISSUER: z.url().optional(),\n AWS_DOMAIN: z.url().optional(),\n AWS_CLIENT_ID: z.string().optional(),\n AWS_CLIENT_SECRET: z.string().optional(),\n SESSION_SECRET: z.string().min(32),\n FILE_BASE_URL: z.string().optional(),\n APPROVAL_BASE_URL: z.string().optional(),\n PEOPLESOFT_BASE_URL: z.string().optional(),\n EMAIL_BASE_URL: z.string().optional(),\n AI_BASE_URL: z.string().optional(),\n AI_SUBSCRIPTION_KEY: z.string().optional(),\n },\n runtimeEnv: process.env,\n emptyStringAsUndefined: true,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAGA,MAAa,YAAY,UAAU;CACjC,cAAc;CACd,QAAQ,CAAC;CACT,YAAY,YAAY;CACxB,wBAAwB;AAC1B,CAAC;AAED,MAAa,YAAY,UAAU;CACjC,QAAQ;EACN,iBAAiBA,IAAE,OAAO;EAC1B,iBAAiBA,IAAE,OAAO;EAC1B,qBAAqBA,IAAE,OAAO;EAC9B,YAAYA,IAAE,IAAI,CAAC,CAAC,SAAS;EAC7B,YAAYA,IAAE,IAAI,CAAC,CAAC,SAAS;EAC7B,eAAeA,IAAE,OAAO,CAAC,CAAC,SAAS;EACnC,mBAAmBA,IAAE,OAAO,CAAC,CAAC,SAAS;EACvC,gBAAgBA,IAAE,OAAO,CAAC,CAAC,IAAI,EAAE;EACjC,eAAeA,IAAE,OAAO,CAAC,CAAC,SAAS;EACnC,mBAAmBA,IAAE,OAAO,CAAC,CAAC,SAAS;EACvC,qBAAqBA,IAAE,OAAO,CAAC,CAAC,SAAS;EACzC,gBAAgBA,IAAE,OAAO,CAAC,CAAC,SAAS;EACpC,aAAaA,IAAE,OAAO,CAAC,CAAC,SAAS;EACjC,qBAAqBA,IAAE,OAAO,CAAC,CAAC,SAAS;CAC3C;CACA,YAAY,QAAQ;CACpB,wBAAwB;AAC1B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-BQ-Bu2g8.mjs","names":[],"sources":["../src/server/actions/file.ts","../src/data/client/file.ts"],"sourcesContent":["import { createServerFn } from \"@tanstack/react-start\";\nimport { serverEnv } from \"~/env\";\nimport { getAccessToken, getAppToken } from \"~/lib/auth/tokens\";\nimport { getSessionUser } from \"~/lib/auth/user\";\n\nexport const getFileUploadToken = createServerFn({ method: \"GET\" }).handler(async () => ({\n token: (await getSessionUser()) ? await getAccessToken(\"file\") : await getAppToken(\"file\"),\n endpoint: `${serverEnv.FILE_BASE_URL}/v1/upload`,\n}));\n","import { mutationOptions, queryOptions } from \"@tanstack/react-query\";\nimport { createServerFn } from \"@tanstack/react-start\";\nimport { Upload } from \"tus-js-client\";\nimport { uuidv7 } from \"uuidv7\";\nimport type { z } from \"zod\";\nimport type { UploadFileMetaSchema, UploadFileResult } from \"~/data/server/file\";\nimport {\n FileSchema,\n GetFileMetasSchema,\n UpdateFileMetaSchema,\n batchDeleteFiles,\n deleteFile,\n downloadFile,\n getFile,\n getFileMetas,\n getFileThumbnail,\n updateFileMeta,\n} from \"~/data/server/file\";\nimport type { QueryClientParam } from \"~/models/QueryClientParam\";\nimport { getFileUploadToken } from \"~/server/actions/file\";\n\nconst QUERY_KEY = \"file\";\nconst HOUR = 1000 * 60 * 60;\n\nconst getFileMetasRpc = createServerFn({ method: \"GET\" })\n .validator(GetFileMetasSchema)\n .handler(({ data }) => getFileMetas({ data }));\n\nconst getFileThumbnailRpc = createServerFn({ method: \"GET\" })\n .validator(FileSchema)\n .handler(({ data }) => getFileThumbnail({ data }));\n\nconst getFileRpc = createServerFn({ method: \"GET\" })\n .validator(FileSchema)\n .handler(({ data }) => getFile({ data }));\n\nconst downloadFileRpc = createServerFn({ method: \"GET\" })\n .validator(FileSchema)\n .handler(({ data }) => downloadFile({ data }));\n\nconst updateFileMetaRpc = createServerFn({ method: \"POST\" })\n .validator(UpdateFileMetaSchema)\n .handler(({ data }) => updateFileMeta({ data }));\n\nconst deleteFileRpc = createServerFn({ method: \"POST\" })\n .validator(FileSchema)\n .handler(({ data }) => deleteFile({ data }));\n\nconst batchDeleteFilesRpc = createServerFn({ method: \"POST\" })\n .validator(GetFileMetasSchema)\n .handler(({ data }) => batchDeleteFiles({ data }));\n\nconst baseOptions = {\n staleTime: HOUR,\n gcTime: HOUR,\n refetchOnWindowFocus: false,\n};\n\nasync function responseToObjectUrl(response: Response): Promise<string> {\n const blob = await response.blob();\n return URL.createObjectURL(blob);\n}\n\nfunction saveBlob(blob: Blob, fileName: string): void {\n const url = URL.createObjectURL(blob);\n const anchor = document.createElement(\"a\");\n anchor.href = url;\n anchor.download = fileName;\n anchor.click();\n URL.revokeObjectURL(url);\n}\n\nexport const fileMetasQueryOptions = (params: z.input<typeof GetFileMetasSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"meta\", params.appName, params.subId],\n queryFn: () => getFileMetasRpc({ data: params }),\n ...baseOptions,\n });\n\nexport const fileThumbnailQueryOptions = (params: z.input<typeof FileSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, \"thumbnail\", params.appName, params.id],\n queryFn: async () => responseToObjectUrl(await getFileThumbnailRpc({ data: params })),\n enabled: !!params.id,\n ...baseOptions,\n });\n\nexport const fileQueryOptions = (params: z.input<typeof FileSchema>) =>\n queryOptions({\n queryKey: [QUERY_KEY, params.appName, params.id],\n queryFn: async () => responseToObjectUrl(await downloadFileRpc({ data: params })),\n enabled: !!params.id,\n ...baseOptions,\n });\n\nexport const downloadFileMutationOptions = () =>\n mutationOptions({\n mutationFn: async (\n data: z.input<typeof FileSchema> & { fileName: string; fileExtension: string },\n ) => {\n const response = await downloadFileRpc({ data });\n saveBlob(await response.blob(), `${data.fileName}.${data.fileExtension}`);\n },\n });\n\nexport const openFileMutationOptions = ({ target }: { target: { current: Window | null } }) =>\n mutationOptions<string, Error, z.input<typeof FileSchema>>({\n mutationFn: async (data) => responseToObjectUrl(await getFileRpc({ data })),\n onSuccess: (source) => {\n const popup = target.current;\n target.current = null;\n\n if (popup) {\n popup.opener = null;\n popup.location.href = source;\n } else {\n window.open(source, \"_blank\");\n }\n },\n onError: () => {\n target.current?.close();\n target.current = null;\n },\n });\n\nexport const updateFileMetaMutationOptions = ({ queryClient }: QueryClientParam) =>\n mutationOptions({\n mutationFn: (data: z.input<typeof UpdateFileMetaSchema>) => updateFileMetaRpc({ data }),\n onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, \"meta\"], exact: false }),\n });\n\nexport const deleteFileMutationOptions = ({ queryClient }: QueryClientParam) =>\n mutationOptions({\n mutationFn: (data: z.input<typeof FileSchema>) => deleteFileRpc({ data }),\n onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, \"meta\"], exact: false }),\n });\n\nexport const batchDeleteFilesMutationOptions = ({ queryClient }: QueryClientParam) =>\n mutationOptions({\n mutationFn: (data: z.input<typeof GetFileMetasSchema>) => batchDeleteFilesRpc({ data }),\n onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, \"meta\"], exact: false }),\n });\n\nexport const uploadFileMutationOptions = ({ queryClient }: QueryClientParam) =>\n mutationOptions({\n mutationFn: async ({\n id = uuidv7(),\n appName,\n subId,\n file,\n setProgress,\n }: z.input<typeof UploadFileMetaSchema> & {\n setProgress?: (progress: number) => void;\n }): Promise<UploadFileResult> => {\n const { token, endpoint } = await getFileUploadToken();\n\n await new Promise<void>((resolve, reject) => {\n const upload = new Upload(file, {\n endpoint,\n chunkSize: 1_048_576,\n metadata: {\n id,\n appName: appName,\n subId: subId,\n filename: file.name,\n filetype: file.type,\n },\n headers: { Authorization: `Bearer ${token}` },\n onProgress: (bytesUploaded, bytesTotal) =>\n setProgress?.((bytesUploaded / bytesTotal) * 100),\n onError: reject,\n onSuccess: () => resolve(),\n });\n upload.start();\n });\n\n return { id, appName, subId, fileName: file.name };\n },\n onSuccess: (result) =>\n queryClient.invalidateQueries({\n queryKey: [QUERY_KEY, \"meta\", result.appName, result.subId],\n exact: false,\n }),\n });\n"],"mappings":";;;;;;;;;AAKA,MAAa,qBAAqB,eAAe,EAAE,QAAQ,MAAM,CAAC,CAAC,CAAC,QAAQ,aAAa;CACvF,OAAQ,MAAM,eAAe,IAAK,MAAM,eAAe,MAAM,IAAI,MAAM,YAAY,MAAM;CACzF,UAAU,GAAG,UAAU,cAAc;AACvC,EAAE;;ACaF,MAAM,YAAY;AAClB,MAAM,OAAO;AAEb,MAAM,kBAAkB,eAAe,EAAE,QAAQ,MAAM,CAAC,CAAC,CACtD,UAAU,kBAAkB,CAAC,CAC7B,SAAS,EAAE,WAAW,aAAa,EAAE,KAAK,CAAC,CAAC;AAE/C,MAAM,sBAAsB,eAAe,EAAE,QAAQ,MAAM,CAAC,CAAC,CAC1D,UAAU,UAAU,CAAC,CACrB,SAAS,EAAE,WAAW,iBAAiB,EAAE,KAAK,CAAC,CAAC;AAEnD,MAAM,aAAa,eAAe,EAAE,QAAQ,MAAM,CAAC,CAAC,CACjD,UAAU,UAAU,CAAC,CACrB,SAAS,EAAE,WAAW,QAAQ,EAAE,KAAK,CAAC,CAAC;AAE1C,MAAM,kBAAkB,eAAe,EAAE,QAAQ,MAAM,CAAC,CAAC,CACtD,UAAU,UAAU,CAAC,CACrB,SAAS,EAAE,WAAW,aAAa,EAAE,KAAK,CAAC,CAAC;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AAY,OAAO,EACjB,KAAK,OAAO,GACZ,SACA,OACA,MACA,kBAG+B;EAC/B,MAAM,EAAE,OAAO,aAAa,MAAM,mBAAmB;EAErD,MAAM,IAAI,SAAe,SAAS,WAAW;GAiB3C,IAhBmB,OAAO,MAAM;IAC9B;IACA,WAAW;IACX,UAAU;KACR;KACS;KACF;KACP,UAAU,KAAK;KACf,UAAU,KAAK;IACjB;IACA,SAAS,EAAE,eAAe,UAAU,QAAQ;IAC5C,aAAa,eAAe,eAC1B,cAAe,gBAAgB,aAAc,GAAG;IAClD,SAAS;IACT,iBAAiB,QAAQ;GAC3B,CACA,CAAA,CAAO,MAAM;EACf,CAAC;EAED,OAAO;GAAE;GAAI;GAAS;GAAO,UAAU,KAAK;EAAK;CACnD;CACA,YAAY,WACV,YAAY,kBAAkB;EAC5B,UAAU;GAAC;GAAW;GAAQ,OAAO;GAAS,OAAO;EAAK;EAC1D,OAAO;CACT,CAAC;AACL,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-DZ0KYhoB.mjs","names":["z"],"sources":["../src/data/server/file.ts"],"sourcesContent":["import { createServerOnlyFn } from \"@tanstack/react-start\";\nimport type { AxiosResponse } from \"axios\";\nimport https from \"node:https\";\nimport { Readable } from \"node:stream\";\nimport { DefaultHttpStack, Upload } from \"tus-js-client\";\nimport { z } from \"zod\";\nimport { serverEnv } from \"~/env\";\nimport { uuidv7 } from \"~/exports/utils\";\nimport { getAccessToken, getAppToken } from \"~/lib/auth/tokens\";\nimport { getSessionUser } from \"~/lib/auth/user\";\nimport { createApi } from \"~/lib/createApi\";\nimport type { FileMeta } from \"~/models/file/FileMeta\";\nimport { FileMetaSchema } from \"~/models/file/FileMeta\";\n\nexport const GetFileMetasSchema = z.object({\n appName: z.string().min(1).max(255),\n subId: z.uuid(),\n});\n\nexport const FileSchema = z.object({\n appName: z.string().min(1).max(255),\n id: z.uuid(),\n});\n\nexport const UpdateFileMetaSchema = FileMetaSchema.extend({\n fileName: z.string().min(1).max(255),\n});\n\nconst DeleteFileSchema = FileSchema;\n\nconst BatchDeleteFilesSchema = GetFileMetasSchema;\n\nexport interface UploadFileResult {\n id: string;\n appName: string;\n subId: string;\n fileName: string;\n}\n\nexport const UploadFileMetaSchema = z.object({\n id: z.uuid().default(uuidv7),\n appName: z.string().min(1).max(255),\n subId: z.uuid(),\n file: z.instanceof(File),\n});\n\nconst fileApi = () => createApi({ baseURL: \"FILE_BASE_URL\", scopeKey: \"file\" });\n\nfunction toFileResponse(response: AxiosResponse<Readable>, disposition?: string): Response {\n const headers = new Headers({\n \"Cache-Control\": \"private, max-age=3600, immutable\",\n \"Content-Type\": String(response.headers[\"content-type\"] ?? \"application/octet-stream\"),\n });\n const contentLength = response.headers[\"content-length\"];\n if (contentLength) headers.set(\"Content-Length\", String(contentLength));\n if (disposition) headers.set(\"Content-Disposition\", disposition);\n\n return new Response(Readable.toWeb(response.data) as ReadableStream, { headers });\n}\n\nexport const getFileMetas = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof GetFileMetasSchema> }): Promise<Array<FileMeta>> => {\n const input = GetFileMetasSchema.parse(data);\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", input.appName);\n queryParams.append(\"subId\", input.subId);\n\n const api = await fileApi();\n const { data: fileMetas } = await api.request<Array<FileMeta>>({\n url: `/v1/meta?${queryParams.toString()}`,\n method: \"GET\",\n });\n return fileMetas;\n },\n);\n\nexport const getFileThumbnail = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof FileSchema> }): Promise<Response> => {\n const input = FileSchema.parse(data);\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", input.appName);\n queryParams.append(\"id\", input.id);\n\n const api = await fileApi();\n const response = await api.request<Readable>({\n url: `/v1/thumbnail?${queryParams.toString()}`,\n method: \"GET\",\n responseType: \"stream\",\n });\n\n return toFileResponse(response);\n },\n);\n\nexport const getFile = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof FileSchema> }): Promise<Response> => {\n const input = FileSchema.parse(data);\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", input.appName);\n queryParams.append(\"id\", input.id);\n\n const api = await fileApi();\n const response = await api.request<Readable>({\n url: `/v1?${queryParams.toString()}`,\n method: \"GET\",\n responseType: \"stream\",\n });\n\n return toFileResponse(response, \"inline\");\n },\n);\n\nexport const downloadFile = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof FileSchema> }): Promise<Response> => {\n const input = FileSchema.parse(data);\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", input.appName);\n queryParams.append(\"id\", input.id);\n\n const api = await fileApi();\n const response = await api.request<Readable>({\n url: `/v1/download?${queryParams.toString()}`,\n method: \"GET\",\n responseType: \"stream\",\n });\n\n return toFileResponse(response);\n },\n);\n\nexport const updateFileMeta = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof UpdateFileMetaSchema> }): Promise<void> => {\n const input = UpdateFileMetaSchema.parse(data);\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", input.appName);\n queryParams.append(\"id\", input.id);\n\n const api = await fileApi();\n await api.request({ url: `/v1/meta?${queryParams.toString()}`, method: \"PUT\", data: input });\n },\n);\n\nexport const deleteFile = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof DeleteFileSchema> }): Promise<void> => {\n const input = DeleteFileSchema.parse(data);\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", input.appName);\n queryParams.append(\"id\", input.id);\n\n const api = await fileApi();\n await api.request({ url: `/v1?${queryParams.toString()}`, method: \"DELETE\" });\n },\n);\n\nexport const batchDeleteFiles = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof BatchDeleteFilesSchema> }): Promise<void> => {\n const input = BatchDeleteFilesSchema.parse(data);\n const queryParams = new URLSearchParams();\n queryParams.append(\"appName\", input.appName);\n queryParams.append(\"subId\", input.subId);\n\n const api = await fileApi();\n await api.request({ url: `/v1?${queryParams.toString()}`, method: \"DELETE\" });\n },\n);\n\nconst insecureHttpsAgent = new https.Agent({ rejectUnauthorized: false });\n\nexport const uploadFile = createServerOnlyFn(\n async ({ data }: { data: z.input<typeof UploadFileMetaSchema> }): Promise<UploadFileResult> => {\n const input = UploadFileMetaSchema.parse(data);\n const accessToken = (await getSessionUser())\n ? await getAccessToken(\"file\")\n : await getAppToken(\"file\");\n const stream = Readable.fromWeb(\n input.file.stream() as import(\"node:stream/web\").ReadableStream,\n );\n\n await new Promise<void>((resolve, reject) => {\n const upload = new Upload(stream, {\n endpoint: `${serverEnv.FILE_BASE_URL}/v1/upload`,\n httpStack: new DefaultHttpStack({ agent: insecureHttpsAgent }),\n uploadSize: input.file.size,\n chunkSize: 1_048_576,\n metadata: {\n id: input.id,\n appName: input.appName,\n subId: input.subId,\n filename: input.file.name,\n filetype: input.file.type,\n },\n headers: { Authorization: `Bearer ${accessToken}` },\n onError: reject,\n onSuccess: () => resolve(),\n });\n upload.start();\n });\n\n return {\n id: input.id,\n appName: input.appName,\n subId: input.subId,\n fileName: input.file.name,\n };\n },\n);\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,qBAAqBA,IAAE,OAAO;CACzC,SAASA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CAClC,OAAOA,IAAE,KAAK;AAChB,CAAC;AAED,MAAa,aAAaA,IAAE,OAAO;CACjC,SAASA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CAClC,IAAIA,IAAE,KAAK;AACb,CAAC;AAED,MAAa,uBAAuB,eAAe,OAAO,EACxD,UAAUA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,EACrC,CAAC;AAED,MAAM,mBAAmB;AAEzB,MAAM,yBAAyB;AAS/B,MAAa,uBAAuBA,IAAE,OAAO;CAC3C,IAAIA,IAAE,KAAK,CAAC,CAAC,QAAQ,MAAM;CAC3B,SAASA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,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,MAAa,mBAAmB,mBAC9B,OAAO,EAAE,WAA4E;CACnF,MAAM,QAAQ,uBAAuB,MAAM,IAAI;CAC/C,MAAM,cAAc,IAAI,gBAAgB;CACxC,YAAY,OAAO,WAAW,MAAM,OAAO;CAC3C,YAAY,OAAO,SAAS,MAAM,KAAK;CAGvC,OAAM,MADY,QAAQ,EAAA,CAChB,QAAQ;EAAE,KAAK,OAAO,YAAY,SAAS;EAAK,QAAQ;CAAS,CAAC;AAC9E,CACF;AAEA,MAAM,qBAAqB,IAAI,MAAM,MAAM,EAAE,oBAAoB,MAAM,CAAC;AAExE,MAAa,aAAa,mBACxB,OAAO,EAAE,WAAsF;CAC7F,MAAM,QAAQ,qBAAqB,MAAM,IAAI;CAC7C,MAAM,cAAe,MAAM,eAAe,IACtC,MAAM,eAAe,MAAM,IAC3B,MAAM,YAAY,MAAM;CAC5B,MAAM,SAAS,SAAS,QACtB,MAAM,KAAK,OAAO,CACpB;CAEA,MAAM,IAAI,SAAe,SAAS,WAAW;EAiB3C,IAhBmB,OAAO,QAAQ;GAChC,UAAU,GAAG,UAAU,cAAc;GACrC,WAAW,IAAI,iBAAiB,EAAE,OAAO,mBAAmB,CAAC;GAC7D,YAAY,MAAM,KAAK;GACvB,WAAW;GACX,UAAU;IACR,IAAI,MAAM;IACV,SAAS,MAAM;IACf,OAAO,MAAM;IACb,UAAU,MAAM,KAAK;IACrB,UAAU,MAAM,KAAK;GACvB;GACA,SAAS,EAAE,eAAe,UAAU,cAAc;GAClD,SAAS;GACT,iBAAiB,QAAQ;EAC3B,CACA,CAAA,CAAO,MAAM;CACf,CAAC;CAED,OAAO;EACL,IAAI,MAAM;EACV,SAAS,MAAM;EACf,OAAO,MAAM;EACb,UAAU,MAAM,KAAK;CACvB;AACF,CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"providers-BfFg_3eo.mjs","names":["definedScopes"],"sources":["../src/lib/auth/providers.ts"],"sourcesContent":["import * as jose from \"jose\";\nimport { scopes as definedScopes } from \"virtual:wcz-layout\";\nimport { serverEnv } from \"~/env\";\nimport type { Scope } from \"~/models/Scopes\";\nimport type { ProviderId } from \"~/models/User\";\n\n/**\n * Identity providers, server-side only. Entra is always present; AWS registers\n * itself when its env vars are set, so an Entra-only app is unchanged and the\n * login page renders a single button.\n */\nexport interface Provider {\n id: ProviderId;\n label: string;\n clientId: string;\n clientSecret: string;\n /** The `iss` claim, used to pick the right provider for an incoming Bearer. */\n issuer: string;\n authorizeEndpoint: string;\n tokenEndpoint: string;\n loginScopes: ReadonlyArray<string>;\n /**\n * Expected `aud` for incoming Bearer JWTs. Undefined for Cognito: its access\n * tokens carry `client_id`, not `aud`, so the user pool itself is the trust\n * boundary — any client in the pool is accepted.\n * ponytail: pool-wide trust; add a client_id allowlist if other pools' clients\n * could ever reach this app.\n */\n audience?: string;\n jwks: ReturnType<typeof jose.createRemoteJWKSet>;\n logoutUrl: (returnTo: string) => string;\n}\n\nconst entraAuthority = `https://login.microsoftonline.com/${serverEnv.ENTRA_TENANT_ID}`;\n\nconst entra: Provider = {\n id: \"entra\",\n label: \"Microsoft\",\n clientId: serverEnv.ENTRA_CLIENT_ID,\n clientSecret: serverEnv.ENTRA_CLIENT_SECRET,\n issuer: `${entraAuthority}/v2.0`,\n authorizeEndpoint: `${entraAuthority}/oauth2/v2.0/authorize`,\n tokenEndpoint: `${entraAuthority}/oauth2/v2.0/token`,\n // `offline_access` yields the multi-resource refresh token every delegated API\n // token is minted from; `User.Read` covers the Graph profile photo.\n loginScopes: [\"openid\", \"profile\", \"offline_access\", \"User.Read\"],\n audience: serverEnv.ENTRA_CLIENT_ID,\n jwks: jose.createRemoteJWKSet(new URL(`${entraAuthority}/discovery/v2.0/keys`)),\n logoutUrl: (returnTo) =>\n `${entraAuthority}/oauth2/v2.0/logout?post_logout_redirect_uri=${encodeURIComponent(returnTo)}`,\n};\n\n/**\n * Cognito cannot widen scopes after login, so every AWS scope the app will ever\n * ask for has to be requested up front. Derived from `scopes.ts` rather than\n * configured separately, so the two can't drift.\n */\n// @ts-expect-error TS6133: unused until the TODO in buildAws() requests these scopes.\nconst awsResourceScopes = [\n ...new Set(\n Object.values(definedScopes as Record<string, Scope>)\n .map((entry) => (typeof entry === \"string\" ? undefined : entry.aws))\n .filter((scope) => scope !== undefined),\n ),\n];\n\nconst buildAws = (): Provider | null => {\n const { AWS_ISSUER, AWS_DOMAIN, AWS_CLIENT_ID, AWS_CLIENT_SECRET } = serverEnv;\n if (!AWS_ISSUER || !AWS_DOMAIN || !AWS_CLIENT_ID || !AWS_CLIENT_SECRET) return null;\n\n return {\n id: \"aws\",\n label: \"AWS\",\n clientId: AWS_CLIENT_ID,\n clientSecret: AWS_CLIENT_SECRET,\n issuer: AWS_ISSUER,\n authorizeEndpoint: `${AWS_DOMAIN}/oauth2/authorize`,\n tokenEndpoint: `${AWS_DOMAIN}/oauth2/token`,\n loginScopes: [\"openid\", \"email\", \"phone\"], // TODO: [\"openid\", \"email\", \"phone\", ...awsResourceScopes]\n jwks: jose.createRemoteJWKSet(new URL(`${AWS_ISSUER}/.well-known/jwks.json`)),\n logoutUrl: (returnTo) =>\n `${AWS_DOMAIN}/logout?client_id=${AWS_CLIENT_ID}&logout_uri=${encodeURIComponent(returnTo)}`,\n };\n};\n\nconst aws = buildAws();\n\nexport const providers: ReadonlyArray<Provider> = aws ? [entra, aws] : [entra];\n\nexport const getProvider = (id: ProviderId): Provider => {\n const provider = providers.find((candidate) => candidate.id === id);\n if (!provider) throw new Error(`Identity provider \"${id}\" is not configured.`);\n return provider;\n};\n\nexport const getProviderByIssuer = (issuer: string | undefined): Provider | undefined =>\n providers.find((candidate) => candidate.issuer === issuer);\n"],"mappings":";;;;;AAiCA,MAAM,iBAAiB,qCAAqC,UAAU;AAEtE,MAAM,QAAkB;CACtB,IAAI;CACJ,OAAO;CACP,UAAU,UAAU;CACpB,cAAc,UAAU;CACxB,QAAQ,GAAG,eAAe;CAC1B,mBAAmB,GAAG,eAAe;CACrC,eAAe,GAAG,eAAe;CAGjC,aAAa;EAAC;EAAU;EAAW;EAAkB;CAAW;CAChE,UAAU,UAAU;CACpB,MAAM,KAAK,mBAAmB,IAAI,IAAI,GAAG,eAAe,qBAAqB,CAAC;CAC9E,YAAY,aACV,GAAG,eAAe,+CAA+C,mBAAmB,QAAQ;AAChG;AAQ0B,CACxB,GAAG,IAAI,IACL,OAAO,OAAOA,MAAsC,CAAC,CAClD,KAAK,UAAW,OAAO,UAAU,WAAW,KAAA,IAAY,MAAM,GAAI,CAAC,CACnE,QAAQ,UAAU,UAAU,KAAA,CAAS,CAC1C,CACF;AAEA,MAAM,iBAAkC;CACtC,MAAM,EAAE,YAAY,YAAY,eAAe,sBAAsB;CACrE,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,iBAAiB,CAAC,mBAAmB,OAAO;CAE/E,OAAO;EACL,IAAI;EACJ,OAAO;EACP,UAAU;EACV,cAAc;EACd,QAAQ;EACR,mBAAmB,GAAG,WAAW;EACjC,eAAe,GAAG,WAAW;EAC7B,aAAa;GAAC;GAAU;GAAS;EAAO;EACxC,MAAM,KAAK,mBAAmB,IAAI,IAAI,GAAG,WAAW,uBAAuB,CAAC;EAC5E,YAAY,aACV,GAAG,WAAW,oBAAoB,cAAc,cAAc,mBAAmB,QAAQ;CAC7F;AACF;AAEA,MAAM,MAAM,SAAS;AAErB,MAAa,YAAqC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK;AAE7E,MAAa,eAAe,OAA6B;CACvD,MAAM,WAAW,UAAU,MAAM,cAAc,UAAU,OAAO,EAAE;CAClE,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,sBAAsB,GAAG,qBAAqB;CAC7E,OAAO;AACT;AAEA,MAAa,uBAAuB,WAClC,UAAU,MAAM,cAAc,UAAU,WAAW,MAAM"}
@@ -1,23 +0,0 @@
1
- import { n as serverEnv } from "./env-BwFl7nWc.mjs";
2
- // src/lib/auth/session.ts
3
- const getAppSession = async () => {
4
- const [{ getIronSession }, { getCookie, setCookie }] = await Promise.all([import("iron-session"), import("@tanstack/react-start/server")]);
5
- return getIronSession({
6
- read: getCookie,
7
- write: setCookie
8
- }, {
9
- cookieName: "app-session",
10
- password: serverEnv.SESSION_SECRET,
11
- chunk: true,
12
- cookieOptions: {
13
- secure: process.env.NODE_ENV === "production",
14
- sameSite: "lax",
15
- httpOnly: true,
16
- path: "/",
17
- maxAge: void 0
18
- }
19
- });
20
- };
21
- export { getAppSession as t };
22
-
23
- //# sourceMappingURL=session-B_jK90RC.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"session-B_jK90RC.mjs","names":[],"sources":["../src/lib/auth/session.ts"],"sourcesContent":["import type { IronSession } from \"iron-session\";\nimport { serverEnv } from \"~/env\";\nimport type { ProviderId, User } from \"~/models/User\";\n\nexport interface AppSessionData {\n /** Which identity provider signed this user in. */\n provider?: ProviderId;\n /** The only token persisted; delegated access tokens are minted from it. */\n refreshToken?: string;\n user?: User;\n /** Transient, only between /auth/login and /auth/callback. */\n pkceVerifier?: string;\n state?: string;\n returnTo?: string;\n}\n\nexport type AppSession = IronSession<AppSessionData>;\n\nexport const getAppSession = async (): Promise<AppSession> => {\n // Dynamic import: `@tanstack/react-start/server` is the server entry and drags\n // in the SSR renderer (`react-dom/server`). Keep it out of the client graph —\n // this helper is only ever called server-side, and all callers already await it.\n const [{ getIronSession }, { getCookie, setCookie }] = await Promise.all([\n import(\"iron-session\"),\n import(\"@tanstack/react-start/server\"),\n ]);\n\n return getIronSession<AppSessionData>(\n { read: getCookie, write: setCookie },\n {\n // Not `session`: that name holds the pre-stable `useSession` seal, which\n // iron-session can't read. Users sign in once more after the upgrade.\n cookieName: \"app-session\",\n password: serverEnv.SESSION_SECRET,\n chunk: true,\n cookieOptions: {\n secure: process.env.NODE_ENV === \"production\",\n sameSite: \"lax\",\n httpOnly: true,\n path: \"/\",\n // Explicit `undefined`: browser-session cookie and a seal that never\n // expires — what `useSession` did. Omit it to fall back to iron's 14-day `ttl`.\n maxAge: undefined,\n },\n },\n );\n};\n"],"mappings":";;AAkBA,MAAa,gBAAgB,YAAiC;CAI5D,MAAM,CAAC,EAAE,kBAAkB,EAAE,WAAW,eAAe,MAAM,QAAQ,IAAI,CACvE,OAAO,iBACP,OAAO,+BACT,CAAC;CAED,OAAO,eACL;EAAE,MAAM;EAAW,OAAO;CAAU,GACpC;EAGE,YAAY;EACZ,UAAU,UAAU;EACpB,OAAO;EACP,eAAe;GACb,QAAQ,QAAQ,IAAI,aAAa;GACjC,UAAU;GACV,UAAU;GACV,MAAM;GAGN,QAAQ,KAAA;EACV;CACF,CACF;AACF"}