orc-ai 0.1.59 → 0.1.60

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 (88) hide show
  1. package/README.md +31 -7
  2. package/dist/index.js +911 -866
  3. package/dist/skills/orc-platform/references/packages.md +14 -2
  4. package/dist/skills/orc-platform/references/scratchpads.md +18 -0
  5. package/dist/skills/orc-platform/references/work.md +4 -2
  6. package/dist/web/assets/{Agents-BwzrreDL.js → Agents-DBN_IKhQ.js} +1 -1
  7. package/dist/web/assets/Attention-Col9bpvb.js +2 -0
  8. package/dist/web/assets/{Audit-MunmWePJ.js → Audit-DDhPMP5V.js} +1 -1
  9. package/dist/web/assets/{ChatUiRenderer-B8mQriTi.js → ChatUiRenderer-Bflvv2nP.js} +1 -1
  10. package/dist/web/assets/{ConfirmDialog-C2YawyrD.js → ConfirmDialog-DOSTWblx.js} +1 -1
  11. package/dist/web/assets/{Dashboard-BxIs9Tic.js → Dashboard-CXREcWFQ.js} +1 -1
  12. package/dist/web/assets/{DocumentWorkspace-CGBAaBzX.js → DocumentWorkspace-DVnU3uMP.js} +1 -1
  13. package/dist/web/assets/{FileEditor-BTbqUvIu.js → FileEditor-YLZReqhf.js} +1 -1
  14. package/dist/web/assets/{FormDialog-B4dHT0EU.js → FormDialog-CelnA8hT.js} +1 -1
  15. package/dist/web/assets/IntegrationCallback-elv3Aqfs.js +1 -0
  16. package/dist/web/assets/{JobWebhooks-CGwMk_nF.js → JobWebhooks-BvKIhaAK.js} +1 -1
  17. package/dist/web/assets/Jobs-TFiqlEzO.js +1 -0
  18. package/dist/web/assets/Knowledge-Dz9v7lfr.js +1 -0
  19. package/dist/web/assets/Markdown-CtVGTUZH.js +2 -0
  20. package/dist/web/assets/MarkdownEditor-CSloDLyL.js +2 -0
  21. package/dist/web/assets/{MarkdownRenderer-CSqZzC8Y.js → MarkdownRenderer-B6SKIKVL.js} +4 -4
  22. package/dist/web/assets/NativeFolderField-DwXF9tJW.js +1 -0
  23. package/dist/web/assets/{PackageCatalog-CNQ_Rha1.js → PackageCatalog-DSwcvJsN.js} +2 -2
  24. package/dist/web/assets/{PackageRunDialog-DUIQUood.js → PackageRunDialog-HoczGux2.js} +1 -1
  25. package/dist/web/assets/{Pager-CleJ2qHm.js → Pager-D-y150yZ.js} +1 -1
  26. package/dist/web/assets/Projects-D5da4x_q.js +3 -0
  27. package/dist/web/assets/{ResponsiveFilters-BIAzZYPs.js → ResponsiveFilters-CQ42T3S8.js} +1 -1
  28. package/dist/web/assets/{ResumeActions-Dbv5ctO7.js → ResumeActions-DYiHEYFy.js} +1 -1
  29. package/dist/web/assets/Rules-CYG1JoBH.js +18 -0
  30. package/dist/web/assets/{ScratchpadDiagramEditor-CY0VDkOm.js → ScratchpadDiagramEditor-Dcfngku2.js} +1 -1
  31. package/dist/web/assets/Scratchpads-uSMao0H4.js +10 -0
  32. package/dist/web/assets/Sessions-BWh81qh3.js +3 -0
  33. package/dist/web/assets/Settings-w_H15X7M.js +14 -0
  34. package/dist/web/assets/Skills-CmcTt8ye.js +8 -0
  35. package/dist/web/assets/{SourceEditor-Bm3YcLGC.js → SourceEditor-DNHVu9ux.js} +3 -3
  36. package/dist/web/assets/{TagInput-XEuKQyEW.js → TagInput-BmRYPN4B.js} +1 -1
  37. package/dist/web/assets/TaskDetailSheet-DfK_DtzG.js +1 -0
  38. package/dist/web/assets/{Tasks-C_0Et1rr.js → Tasks-CbOw64sI.js} +7 -7
  39. package/dist/web/assets/Terminals-DP3MyIBo.js +3 -0
  40. package/dist/web/assets/{ViewHeader-BajY1vkx.js → ViewHeader-BtTaSrXy.js} +1 -1
  41. package/dist/web/assets/{Webhooks-DgMaSyjO.js → Webhooks-CP-m_Dos.js} +1 -1
  42. package/dist/web/assets/{badge-CczwlQze.js → badge-CpU0J4qt.js} +1 -1
  43. package/dist/web/assets/check-N8fVGVDO.js +1 -0
  44. package/dist/web/assets/chevron-down-wgh-M0zj.js +1 -0
  45. package/dist/web/assets/circle-alert-OZ-kwnCD.js +1 -0
  46. package/dist/web/assets/{circle-check-B_-siEWc.js → circle-check-DQM5o2QS.js} +1 -1
  47. package/dist/web/assets/client-BnTXPI20.js +1 -0
  48. package/dist/web/assets/{dialog-C7wt3DcD.js → dialog-D86vkhdt.js} +1 -1
  49. package/dist/web/assets/{download-B0FkIRZc.js → download-6d5_Jyox.js} +1 -1
  50. package/dist/web/assets/{highlighted-body-JLMTFACH-CT50vDjv.js → highlighted-body-JLMTFACH-C0zXH1C-.js} +1 -1
  51. package/dist/web/assets/{index-C0yeM676.js → index-D5qFuDmc.js} +84 -30
  52. package/dist/web/assets/index-z4BVJQry.css +1 -0
  53. package/dist/web/assets/{link-2-CE3Sblf0.js → link-2-Ced5Jr2w.js} +1 -1
  54. package/dist/web/assets/{list-CSWWmpsk.js → list-OJI1AaZs.js} +1 -1
  55. package/dist/web/assets/{maximize-2-CN8Tztng.js → maximize-2-Daih3Vv7.js} +1 -1
  56. package/dist/web/assets/mermaid-WFAXDIZX-BTh2e4d1.js +1 -0
  57. package/dist/web/assets/{save-DWlDLKMf.js → save-CnCcteVb.js} +1 -1
  58. package/dist/web/assets/{scratchpad-kinds-BhSSEfi9.js → scratchpad-kinds-vQJshqz1.js} +1 -1
  59. package/dist/web/assets/{scratchpad-routes-BBSS02R-.js → scratchpad-routes-D8SCEha7.js} +1 -1
  60. package/dist/web/assets/{upload-Dj3lbGL_.js → upload-BLDr7Cwk.js} +1 -1
  61. package/dist/web/assets/useIntegrations-CkfXwYNs.js +1 -0
  62. package/dist/web/assets/{useJobs-lhzWAkUN.js → useJobs-BNj4dd9l.js} +1 -1
  63. package/dist/web/assets/{useMemories-76m7jnqk.js → useMemories-BpfvcV2g.js} +1 -1
  64. package/dist/web/assets/{useSessions-gfliXBHJ.js → useSessions-n-bp8ic5.js} +1 -1
  65. package/dist/web/assets/{x-vKt_RFSV.js → x-CIaAKXRo.js} +1 -1
  66. package/dist/web/index.html +11 -12
  67. package/package.json +1 -1
  68. package/dist/web/assets/Attention-By2dScSb.js +0 -2
  69. package/dist/web/assets/IntegrationCallback-DXHVQyoB.js +0 -1
  70. package/dist/web/assets/Jobs-B4eLen3k.js +0 -1
  71. package/dist/web/assets/Knowledge-CG71SuxG.js +0 -1
  72. package/dist/web/assets/Markdown-DRYI2VLT.js +0 -2
  73. package/dist/web/assets/MarkdownEditor-D8aBF3I9.js +0 -2
  74. package/dist/web/assets/Projects-BVhb3Dtm.js +0 -3
  75. package/dist/web/assets/Rules-CvQ24J5a.js +0 -18
  76. package/dist/web/assets/Scratchpads-D4htYgy_.js +0 -10
  77. package/dist/web/assets/Sessions-CG1mCfIY.js +0 -3
  78. package/dist/web/assets/Settings-BNCj7UWA.js +0 -14
  79. package/dist/web/assets/Skills-Ck_KrsPB.js +0 -8
  80. package/dist/web/assets/TaskDetailSheet-BzYkmkFK.js +0 -1
  81. package/dist/web/assets/Terminals-BbhfCTPR.js +0 -3
  82. package/dist/web/assets/check-DZNzZAdD.js +0 -1
  83. package/dist/web/assets/chevron-down-DjliQtS1.js +0 -1
  84. package/dist/web/assets/client-ByMuVs3d.js +0 -1
  85. package/dist/web/assets/index-Ci_YnsZ9.css +0 -1
  86. package/dist/web/assets/mermaid-WFAXDIZX-BLiIUJmd.js +0 -1
  87. package/dist/web/assets/schemas-BQZhekae.js +0 -55
  88. package/dist/web/assets/useIntegrations-Dmrd-_Pu.js +0 -1
@@ -72,8 +72,11 @@ lifecycle rules and exhaustive API/CLI manuals.
72
72
 
73
73
  For audited instruction edits, read raw `SKILL.md`, then `skill_update` with
74
74
  `expected_content`, scope, reason and session ID when available. Reconcile conflicts
75
- against the current version. This edits entry instructions, not supporting files;
76
- use the dashboard/file APIs for authored supporting text. Preserve original assets
75
+ against the current version. This edits entry instructions, not supporting files.
76
+ For a script, reference or other text file of a user skill, read it with `skill_read`
77
+ and `ref`, then `skill_file_write` with the full new text, that read text as
78
+ `expected_content` (null adds a new file) and a reason. File writes apply to every
79
+ scope; built-in and package skills are read-only. Preserve original assets
77
80
  and local edits. Verify save/reopen and effective reads in the intended scope.
78
81
 
79
82
  Folder import/export preserves supporting content:
@@ -91,6 +94,15 @@ with its imported baseline; local/upstream conflicts require review, not blind
91
94
  replacement. Review the pinned source and licenses before running imported scripts.
92
95
  Paths must remain inside the skill; symlinks/traversal and oversize bundles are rejected.
93
96
 
97
+ Local agents: `orc skill local [agent] [--path <dir>]` lists skills in agent folders
98
+ (`~/.claude/skills`, `~/.codex/skills`, ...) or any folder; `-s <names>` / `--all` imports.
99
+ `orc skill export-to <agent|dir> [names...] --dry-run` writes native skill folders back; add `--project <name>` to write into that project's checkout (`claude` -> `.claude/skills`, `agents` -> `.agents/skills`), listed by `orc skill project-folders`.
100
+ Near copies (a few characters different) and renamed copies count as the same skill and
101
+ are flagged, not imported or exported as new; existing folders change only with
102
+ `--overwrite <names>`. Memories: `orc mem sources|import|export` move project memories to and
103
+ from Claude Code memory folders (`<name>.md` + `MEMORY.md`) and Codex notes
104
+ (`~/.codex/memories/extensions/ad_hoc/notes`) with the same dedup.
105
+
94
106
  ## Agent profiles and portable packages
95
107
 
96
108
  A profile defines specialist instructions/model/tools; a backend selects how an
@@ -133,6 +133,24 @@ async function loadTasks() {
133
133
  </script>
134
134
  ```
135
135
 
136
+ To run a job from a button and show what it returns, trigger it with `sync=true`: the
137
+ call waits for the run (up to `wait_secs`, default and max 240) and answers 200 with
138
+ `status`, `exit_code`, `stdout`, `stderr` and `result`, the job's stdout parsed as JSON
139
+ (null when it is not JSON). Have the job print one JSON document as its last and only
140
+ stdout. A 202 means it is still running: poll `/jobs/{id}/runs` for that `run_id`.
141
+
142
+ ```js
143
+ button.onclick = async () => {
144
+ status.textContent = "running…";
145
+ const res = await orc.fetch(`/jobs/${JOB_ID}/trigger?sync=true`, { method: "POST" });
146
+ const run = await res.json();
147
+ if (res.status === 202) return void (status.textContent = `still running (${run.run_id})`);
148
+ if (!res.ok) return void (status.textContent = `ORC API ${res.status}`);
149
+ status.textContent = run.status;
150
+ render(run.result ?? run.stdout); // build nodes with textContent, not innerHTML
151
+ };
152
+ ```
153
+
136
154
  Show which mode the page is in and tell the human that live data needs "Render with
137
155
  ORC access". Check routes and limits in the OpenAPI spec (`/openapi.json`) rather than
138
156
  guessing. Writes (`POST`/`PATCH`) act as the human: make each one an explicit user
@@ -68,13 +68,15 @@ blocker causes and the next decision/action. Avoid an arbitrary universal stall
68
68
  ## Jobs and gateway
69
69
 
70
70
  Jobs execute configured commands: inspect command, cwd, environment, trigger and
71
- timeout before running. `job_list`, `job_run`, `job_status` cover agent operations;
71
+ timeout before running. `job_list`, `job_run`, `job_status` (pass `logs: true` for output) cover agent operations;
72
72
  use CLI/API help for creation and schedules. `cron` replaces the old `repeat` trigger.
73
73
  Verify a run's exit code and bounded log output; scheduler presence is not success.
74
74
 
75
75
  Example for an intended test job: `orc job add verify --command "bun test"
76
76
  --trigger manual --timeout 300 --project my-app`, inspect `orc job show verify`,
77
- run with `orc job run verify`, then `orc job runs verify --logs`. Verify the actual
77
+ run with `orc job run verify`, then `orc job runs verify --logs`, or wait for the
78
+ output with `orc job run verify --wait` (exits non-zero unless the run succeeds; JSON
79
+ stdout comes back as `result` with `--json`; API: `POST /jobs/{id}/trigger?sync=true`). Verify the actual
78
80
  cwd/project and command before executing; add cron/watch only when recurring work
79
81
  is wanted. Pausing a schedule uses job update/disabled; inspect whether an already
80
82
  running job still needs an explicit stop. Check retries, timeout and scheduler logs
@@ -1,4 +1,4 @@
1
- import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i,t as a}from"./useMutation-HX90wI4L.js";import{t as o,u as s}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as c}from"./button-C91mbQEU.js";import{t as l}from"./label-BdnRgBbz.js";import{n as u}from"./client-ByMuVs3d.js";import{a as d,n as f,o as p,t as m}from"./dialog-C7wt3DcD.js";import{Ft as h,G as g,K as _,Mt as v,Nt as y,Pt as b,Rn as x,W as S,X as C,Y as w,ct as T,p as E}from"./index-C0yeM676.js";import{t as D}from"./ConfirmDialog-C2YawyrD.js";import{i as O,n as k,t as A}from"./PackageRunDialog-DUIQUood.js";import{t as j}from"./ErrorState-DprXzfow.js";import{t as M}from"./ViewHeader-BajY1vkx.js";import{t as N}from"./useDetailRoute-DOhAbdV7.js";import{t as P}from"./view-params-DD7i9s5g.js";var F=e(t(),1),I={specialist:`---
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i,t as a}from"./useMutation-HX90wI4L.js";import{t as o,u as s}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as c}from"./button-C91mbQEU.js";import{t as l}from"./label-BdnRgBbz.js";import{n as u}from"./client-BnTXPI20.js";import{a as d,n as f,o as p,t as m}from"./dialog-D86vkhdt.js";import{Ft as h,G as g,K as _,Mt as v,Nt as y,Pt as b,Qn as x,W as S,X as C,Y as w,ct as T,p as E}from"./index-D5qFuDmc.js";import{t as D}from"./ConfirmDialog-DOSTWblx.js";import{i as O,n as k,t as A}from"./PackageRunDialog-HoczGux2.js";import{t as j}from"./ErrorState-DprXzfow.js";import{t as M}from"./ViewHeader-BtTaSrXy.js";import{t as N}from"./useDetailRoute-DOhAbdV7.js";import{t as P}from"./view-params-DD7i9s5g.js";var F=e(t(),1),I={specialist:`---
2
2
  name: Specialist
3
3
  description: Describe when to use this specialist
4
4
  ---
@@ -0,0 +1,2 @@
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{t as i}from"./useMutation-HX90wI4L.js";import{f as a,m as o}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as s}from"./button-C91mbQEU.js";import{h as c,n as l,t as u}from"./client-BnTXPI20.js";import{t as d}from"./circle-alert-OZ-kwnCD.js";import{t as f}from"./textarea-BRdsUa6B.js";import{F as p,Ft as m,Hn as h,Kn as g,Lt as _,Wn as v,d as y,er as b,f as x,u as S}from"./index-D5qFuDmc.js";import{c as C}from"./live-sessions-D07BClP7.js";import{t as w}from"./ViewHeader-BtTaSrXy.js";import{i as T,n as E}from"./terminal-links-B3ce99i1.js";var D={name:`check-check`,size:24,node:[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]};D.node;var O=c(D),k={name:`clock`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]};k.node;var A=c(k),j={name:`inbox`,size:24,node:[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]};j.node;var M=c(j),N=e(t(),1),P=n();function F({request:e,actions:t}){let n=e.input.command,[a,o]=(0,N.useState)(e.response?.kind===`command`?e.response.script??n?.script??``:n?.script??``),[c,d]=(0,N.useState)({}),[h,g]=(0,N.useState)(!1),_=r(),v=i({mutationFn:async()=>{let t=c;return d({}),l.humanRequests.run(e.id,e.version,a,t)},onSettled:()=>_.invalidateQueries({queryKey:[`human-requests`]})});if(!n)return null;let y=e.status===`pending`&&!v.isPending;return(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsxs)(`dl`,{className:`flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 gap-1`,children:[(0,P.jsx)(`dt`,{children:`Host:`}),(0,P.jsx)(`dd`,{className:`wrap-anywhere`,children:n.host??`Local`})]}),(0,P.jsxs)(`div`,{className:`flex min-w-0 gap-1`,children:[(0,P.jsx)(`dt`,{children:`Folder:`}),(0,P.jsx)(`dd`,{className:`wrap-anywhere`,children:n.cwd})]})]}),(0,P.jsxs)(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),y&&v.mutate()},children:[(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,P.jsx)(`span`,{className:`text-xs font-medium`,children:`Command to run`}),y&&(0,P.jsx)(s,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`attention-edit-command`,"aria-expanded":h,"aria-controls":`command-${e.id}`,onClick:()=>g(!h),children:h?`Done editing`:`Edit command`})]}),h&&y?(0,P.jsxs)(`label`,{htmlFor:`command-${e.id}`,className:`block`,children:[(0,P.jsx)(`span`,{className:`sr-only`,children:`Command to run`}),(0,P.jsx)(f,{id:`command-${e.id}`,"data-testid":`attention-command`,value:e.response?.kind===`command`?e.response.script??a:a,onChange:e=>o(e.target.value),disabled:!y,maxLength:16e3,className:`min-h-20 font-mono text-xs`})]}):(0,P.jsx)(`section`,{"aria-label":`Command to run`,tabIndex:0,"data-testid":`attention-command-preview`,className:`max-h-40 overflow-auto rounded-sm bg-surface px-2 py-1.5 focus-visible:outline-2 focus-visible:outline-focus`,children:(0,P.jsx)(`pre`,{className:`whitespace-pre-wrap wrap-anywhere font-mono text-xs`,children:e.response?.kind===`command`?e.response.script??a:a})})]}),(0,P.jsx)(`div`,{className:`grid gap-x-3 gap-y-2 sm:grid-cols-2`,children:y&&n.arguments.map(t=>(0,P.jsxs)(`label`,{htmlFor:`argument-${e.id}-${t.name}`,className:`block min-w-0 space-y-1 text-xs`,children:[(0,P.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,P.jsxs)(`span`,{children:[t.label,t.required?``:` (optional)`]}),(0,P.jsx)(`code`,{"data-testid":`attention-argument-name-${t.name}`,className:`break-all font-mono text-xs text-muted-foreground`,children:`ORC_INPUT_${t.name}`})]}),(0,P.jsx)(m,{id:`argument-${e.id}-${t.name}`,type:`password`,autoComplete:`off`,"data-testid":`attention-argument-${t.name}`,value:c[t.name]??``,required:t.required,maxLength:16e3,"aria-describedby":t.description?`argument-help-${e.id}-${t.name}`:void 0,onChange:e=>d(n=>({...n,[t.name]:e.target.value}))}),t.description&&(0,P.jsx)(`span`,{id:`argument-help-${e.id}-${t.name}`,className:`block text-muted-foreground`,children:t.description})]},t.name))}),(y||v.isPending||e.status===`running`)&&(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,P.jsx)(s,{"data-testid":`attention-run`,type:`submit`,size:`sm`,disabled:!y||!a.trim()||n.arguments.some(e=>e.required&&!c[e.name]),children:v.isPending||e.status===`running`?`Running…`:`Run command`}),y&&t,(0,P.jsx)(p,{label:`Secure input handling`,testId:`attention-input-help`,children:`All entered values are used only for this run and redacted from its output. The agent receives the result without the raw inputs.`})]}),v.error&&(0,P.jsx)(`p`,{role:`alert`,children:v.error instanceof u&&v.error.status<500?v.error.message:`${v.error.message}. Could not confirm completion. Refresh the request before trying again.`})]}),e.response?.kind===`command`&&(0,P.jsxs)(`div`,{"data-testid":`attention-command-result`,className:`space-y-2`,children:[(0,P.jsxs)(`p`,{children:[`Exit code: `,e.response.exit_code]}),(0,P.jsxs)(`pre`,{className:`whitespace-pre-wrap break-all text-xs`,children:[e.response.stdout,e.response.stderr]}),e.response.truncated&&(0,P.jsx)(`p`,{children:`Output was truncated.`})]})]})}var I={pending:{label:`Waiting for you`,tone:`text-warning`,Icon:A},running:{label:`Running`,tone:`text-muted-foreground`,Icon:g,spin:!0},unavailable:{label:`Agent unavailable`,tone:`text-error`,Icon:d},answered:{label:`Answered · agent hasn't picked it up`,tone:`text-muted-foreground`,Icon:M},delivered:{label:`Delivered`,tone:`text-secondary`,Icon:O},cancelled:{label:`Cancelled`,tone:`text-muted-foreground`,Icon:d},expired:{label:`Expired`,tone:`text-muted-foreground`,Icon:A}};function L(e){return e.status===`answered`?e.push_state===`pushing`?{label:`Pushing to session…`,tone:`text-primary`,Icon:g,spin:!0}:e.seen_at?{label:`Delivered · agent read it`,tone:`text-secondary`,Icon:O}:e.push_state===`interrupted`?{label:`Push interrupted · agent may have it`,tone:`text-warning`,Icon:d}:e.push_state===`failed`?{label:`Couldn't push · agent can still read it`,tone:`text-error`,Icon:d}:I.answered:I[e.status]}function R(e){return e.input.kind===`command`?e.input.command?.host??`Local`:e.input.action?e.input.action.host:e.input.origin.execution_host===void 0?null:e.input.origin.execution_host??`Local`}function z({session:e}){let t=a(),[n]=o(),{terminals:r}=_(),i=E(r,e.id);return(0,P.jsxs)(`article`,{"data-testid":`attention-session-${e.id}`,className:`grid min-w-0 gap-2 border-b border-border py-3 @xl/attention:grid-cols-[minmax(0,1fr)_auto] @xl/attention:items-center`,children:[(0,P.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-medium wrap-break-word`,children:e.name??`Coding session`}),(0,P.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[(0,P.jsx)(`span`,{className:`text-warning`,children:`Question`}),(0,P.jsx)(`span`,{children:e.agent}),(0,P.jsx)(`span`,{children:e.host??`Local`}),(0,P.jsx)(`span`,{children:`Reply in the original session`})]})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[i&&(0,P.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>t(C(T(i.id),n.get(`project`))),children:`Open terminal`}),(0,P.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>{let r=new URLSearchParams(n);r.set(`session`,e.id),t({pathname:`/sessions`,search:r.toString()})},children:`View session`})]})]})}function B({request:e,expanded:t,onToggle:n}){let[c,u]=(0,N.useState)(``),[d,m]=(0,N.useState)([]),[g,_]=(0,N.useState)(e.input.choices.length===0),y=r(),x=a(),[S]=o(),C=i({mutationFn:t=>l.humanRequests.respond(e.id,e.version,t),onSettled:()=>y.invalidateQueries({queryKey:[`human-requests`]})}),w=i({mutationFn:()=>l.humanRequests.cancel(e.id,e.version),onSettled:()=>y.invalidateQueries({queryKey:[`human-requests`]})}),T=e.status===`pending`,E=L(e),D=R(e),O=C.isPending||w.isPending,k=(0,P.jsxs)(P.Fragment,{children:[e.input.origin.chat_thread_id&&(0,P.jsxs)(s,{"data-testid":`attention-open-chat`,size:`sm`,variant:`ghost`,type:`button`,onClick:()=>{let t=new URLSearchParams(S);t.set(`chat`,`open`),t.set(`chatThread`,e.input.origin.chat_thread_id??``),x({search:t.toString()})},children:[(0,P.jsx)(v,{size:14}),` Open chat`]}),(T||e.status===`unavailable`||e.status===`answered`&&!e.seen_at&&(!e.push_state||e.push_state===`failed`))&&(0,P.jsx)(s,{"data-testid":`attention-cancel`,size:`sm`,variant:`ghost`,type:`button`,disabled:O,onClick:()=>w.mutate(),children:w.isPending?T?`Cancelling…`:`Dismissing…`:T?`Cancel request`:`Dismiss`})]}),A=e.input.action?.input,j=A?.item&&typeof A.item==`object`?A.item:void 0,M=typeof A?.threadId==`string`,I=M?{...Object.fromEntries(Object.entries(A??{}).filter(([e])=>![`threadId`,`turnId`,`itemId`,`startedAtMs`,`item`,`availableDecisions`,`proposedExecpolicyAmendment`,`commandActions`,`kind`].includes(e))),...j?.changes?{changes:j.changes}:{}}:A;return(0,P.jsxs)(`article`,{"data-testid":`attention-request-${e.id}`,className:`min-w-0 border-b border-border`,children:[(0,P.jsxs)(`div`,{className:`flex min-h-11 items-center gap-3 py-1`,children:[(0,P.jsx)(`h2`,{className:`min-w-0 flex-1`,children:(0,P.jsxs)(`button`,{type:`button`,"data-testid":`attention-review`,"aria-expanded":t,"aria-controls":`request-details-${e.id}`,onClick:n,className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-sm py-1 text-left focus-visible:outline-2 focus-visible:outline-focus sm:min-h-9 [@media(pointer:coarse)]:min-h-11`,children:[(0,P.jsx)(b,{"aria-hidden":`true`,size:14,className:`shrink-0 text-muted-foreground ${t?`rotate-90`:``}`}),(0,P.jsxs)(`span`,{className:`min-w-0`,children:[(0,P.jsx)(`span`,{className:`block text-sm font-medium wrap-anywhere ${t?`whitespace-pre-wrap`:`line-clamp-1`}`,children:e.input.title??e.input.prompt}),(0,P.jsxs)(`span`,{className:`block truncate text-xs font-normal text-muted-foreground`,children:[e.input.origin.session_title??e.input.origin.backend,D&&` · ${D}`]})]})]})}),(0,P.jsxs)(`span`,{"data-testid":`attention-state`,className:`flex shrink-0 items-center gap-1 text-xs ${E.tone}`,children:[(0,P.jsx)(E.Icon,{"aria-hidden":`true`,size:13,className:E.spin?`animate-spin`:``}),E.label]})]}),(0,P.jsxs)(`div`,{id:`request-details-${e.id}`,hidden:!t,className:t?`max-w-3xl space-y-3 pb-3 pl-6`:`hidden`,children:[(0,P.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[e.input.title&&(0,P.jsx)(`p`,{className:`text-sm whitespace-pre-wrap wrap-anywhere`,children:e.input.prompt}),(0,P.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,P.jsx)(`summary`,{"data-testid":`attention-details-toggle`,className:`min-h-8 cursor-pointer py-1 [@media(pointer:coarse)]:min-h-11`,children:`Request details`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,P.jsxs)(`span`,{className:T?`text-warning`:void 0,children:[e.input.kind===`command`?`Command`:e.input.kind===`question`?`Question`:`Approval`,` `,`· `,e.input.origin.backend]}),(e.input.rule_binding||e.input.rule_bindings?.length)&&(0,P.jsx)(`span`,{children:`ORC rule`})]}),(0,P.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,P.jsxs)(`span`,{className:`min-w-0 max-w-full truncate`,title:e.input.origin.session_title??e.input.origin.session_id,children:[e.input.origin.session_title??`Session ${e.input.origin.session_id}`,e.input.origin.execution_host!==void 0&&` · ${e.input.origin.execution_host??`Local`}`]}),(0,P.jsxs)(`span`,{className:`flex flex-wrap gap-x-2`,"data-testid":`attention-date`,children:[(0,P.jsxs)(`span`,{children:[`Created`,` `,(0,P.jsx)(`time`,{dateTime:new Date(e.created_at).toISOString(),title:new Date(e.created_at).toLocaleString(),children:new Date(e.created_at).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})})]}),e.responded_at!==null&&(0,P.jsxs)(`span`,{children:[`Answered`,` `,(0,P.jsx)(`time`,{dateTime:new Date(e.responded_at).toISOString(),title:new Date(e.responded_at).toLocaleString(),children:new Date(e.responded_at).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})})]})]})]})]}),e.input.kind===`command`&&(0,P.jsx)(F,{request:e,actions:k}),e.input.action&&(0,P.jsxs)(`div`,{className:`min-w-0 space-y-2 text-sm`,children:[(0,P.jsxs)(`dl`,{className:`flex min-w-0 flex-wrap gap-x-4 gap-y-1 text-xs`,children:[(0,P.jsxs)(`div`,{className:`flex min-w-0 gap-1`,children:[(0,P.jsx)(`dt`,{className:`text-muted-foreground`,children:`Host:`}),(0,P.jsx)(`dd`,{className:`wrap-anywhere`,children:e.input.action.host})]}),(0,P.jsxs)(`div`,{className:`flex min-w-0 gap-1`,children:[(0,P.jsx)(`dt`,{className:`text-muted-foreground`,children:`Folder:`}),(0,P.jsx)(`dd`,{className:`wrap-anywhere`,children:e.input.action.cwd})]})]}),(0,P.jsx)(`section`,{"aria-label":`Requested action`,tabIndex:0,className:`max-h-64 overflow-auto whitespace-pre-wrap wrap-anywhere rounded-md border border-border p-2 font-mono text-xs focus-visible:outline-2 focus-visible:outline-focus`,children:(0,P.jsxs)(`pre`,{"data-testid":`attention-action`,className:`whitespace-pre-wrap wrap-anywhere`,children:[e.input.action.tool,`
2
+ `,JSON.stringify(I&&Object.keys(I).length?I:A,null,2)]})}),M&&(0,P.jsxs)(`details`,{className:`text-xs text-outline`,children:[(0,P.jsx)(`summary`,{"data-testid":`attention-native-details-toggle`,className:`min-h-11 cursor-pointer py-1 sm:min-h-8 [@media(pointer:coarse)]:min-h-11`,children:`Full request details`}),(0,P.jsx)(`pre`,{className:`whitespace-pre-wrap break-all mt-2`,children:JSON.stringify(A,null,2)})]})]})]}),(0,P.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[T&&e.input.kind===`question`&&(0,P.jsxs)(`form`,{className:`space-y-2`,onSubmit:e=>{e.preventDefault(),C.mutate({kind:`question`,answer:c,...d.length?{selected_choices:d}:{}})},children:[(0,P.jsx)(`div`,{className:`grid gap-1 @xl/attention:grid-cols-2 @4xl/attention:grid-cols-1`,children:e.input.choices.map(t=>(0,P.jsxs)(`label`,{className:`flex min-h-11 min-w-0 cursor-pointer items-start gap-2 rounded-md px-2 py-1.5 text-sm sm:min-h-8 [@media(pointer:coarse)]:min-h-11 hover:bg-surface ${(e.input.multi_select?d.includes(t):c===t)?`bg-surface-highest`:``}`,"data-testid":`attention-choice-${t}`,children:[(0,P.jsx)(`input`,{type:e.input.multi_select?`checkbox`:`radio`,name:`choice-${e.id}`,checked:e.input.multi_select?d.includes(t):c===t,disabled:O,className:`mt-1 size-3.5 shrink-0 accent-primary`,onChange:()=>{if(e.input.multi_select){let e=d.includes(t)?d.filter(e=>e!==t):[...d,t];m(e),u(e.join(`, `))}else u(t)}}),(0,P.jsxs)(`span`,{className:`min-w-0 wrap-anywhere`,children:[(0,P.jsx)(`span`,{children:t}),Object.keys(e.input.choice_descriptions).includes(t)&&e.input.choice_descriptions[t]&&(0,P.jsx)(`span`,{className:`block text-xs font-normal text-muted-foreground`,children:e.input.choice_descriptions[t]})]})]},t))}),e.input.choices.length>0&&(0,P.jsxs)(s,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`attention-edit-answer`,"aria-expanded":g,"aria-controls":`answer-editor-${e.id}`,disabled:O,onClick:()=>_(!g),children:[(0,P.jsx)(h,{size:14}),` `,g?`Hide editor`:`Write an answer`]}),(0,P.jsxs)(`label`,{id:`answer-editor-${e.id}`,htmlFor:`answer-${e.id}`,hidden:!g,className:g?`block text-sm space-y-1`:`hidden`,children:[(0,P.jsx)(`span`,{children:`Your answer`}),(0,P.jsx)(f,{id:`answer-${e.id}`,"data-testid":`attention-answer`,value:c,onChange:e=>{u(e.target.value),m([])},maxLength:16e3,disabled:O,rows:2,className:`min-h-20 max-h-48 resize-y`})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,P.jsx)(s,{size:`sm`,"data-testid":`attention-send`,type:`submit`,disabled:!c.trim()||O,children:C.isPending?`Sending…`:`Send answer`}),k]})]}),T&&e.input.kind===`approval`&&(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,P.jsx)(s,{size:`sm`,"data-testid":`attention-approve`,disabled:O,onClick:()=>C.mutate({kind:`approval`,approved:!0}),children:`Approve`}),(0,P.jsx)(s,{size:`sm`,"data-testid":`attention-deny`,variant:`outline`,disabled:O,onClick:()=>C.mutate({kind:`approval`,approved:!1}),children:`Deny`}),(0,P.jsx)(p,{label:`Approval permissions`,testId:`attention-approval-help`,children:`Your approval lets this agent continue with its existing permissions.`}),k]}),e.response&&e.response.kind!==`command`&&(0,P.jsx)(`p`,{"data-testid":`attention-response`,className:`text-sm whitespace-pre-wrap wrap-anywhere`,children:e.response.kind===`question`?e.response.answer:e.response.approved?`Approved`:`Denied`}),!T&&(0,P.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:k})]})]}),(e.delivery_error||e.push_state&&e.push_error)&&(0,P.jsx)(`p`,{"data-testid":`attention-push-error`,role:`status`,className:`pb-2 pl-6 text-sm text-error`,children:e.delivery_error??e.push_error}),w.error&&(0,P.jsx)(`p`,{role:`alert`,children:w.error.message}),C.error&&(0,P.jsx)(`p`,{role:`alert`,"data-testid":`attention-error`,className:`text-sm text-destructive`,children:C.error.message})]})}function V(){let[e,t]=(0,N.useState)(null),n=x(),r=S(),i=y(),c=a(),[l]=o();return(0,P.jsxs)(`div`,{"data-testid":`attention-view`,className:`@container/attention min-w-0`,children:[(0,P.jsx)(w,{title:`Attention needed`,meta:n.data?n.data.length+r.data.length+i.data.length:void 0,help:`Questions and approvals from your agents. Live Codex questions can also appear as session notices. Direct responses require an ORC connection or a supported hook; ACPX CLI does not expose pending approvals to ORC.`}),n.isLoading&&(0,P.jsx)(`p`,{role:`status`,children:`Loading requests…`}),n.error&&(0,P.jsx)(`p`,{role:`alert`,children:n.error.message}),r.error&&(0,P.jsxs)(`p`,{role:`alert`,children:[`Could not check waiting sessions: `,r.error.message]}),i.error&&(0,P.jsxs)(`p`,{role:`alert`,children:[`Could not check waiting chats: `,i.error.message]}),n.data?.length===0&&!n.error&&!r.isLoading&&!r.error&&!i.isLoading&&!i.error&&r.data.length===0&&i.data.length===0&&(0,P.jsx)(`p`,{"data-testid":`attention-empty`,className:`grid min-h-[min(40dvh,20rem)] place-items-center text-sm text-muted-foreground`,children:`Nothing needs your attention.`}),n.data?.length===100&&(0,P.jsx)(`p`,{className:`text-sm text-outline mb-4`,children:`Showing the first 100 requests, with pending requests first. Resolving or dismissing entries reveals more.`}),(0,P.jsxs)(`div`,{children:[i.data.map(e=>(0,P.jsxs)(`article`,{"data-testid":`attention-chat-${e.thread_id}`,className:`grid min-w-0 gap-2 border-b border-border py-3 @xl/attention:grid-cols-[minmax(0,1fr)_auto] @xl/attention:items-center`,children:[(0,P.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-medium wrap-break-word`,children:e.title}),(0,P.jsxs)(`p`,{className:`flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[(0,P.jsx)(`span`,{className:`text-warning`,children:e.kind===`question`?`Question`:`Approval`}),(0,P.jsx)(`span`,{children:e.agent}),(0,P.jsx)(`span`,{children:e.host??`Local`}),(0,P.jsx)(`span`,{children:`Chat`})]})]}),(0,P.jsx)(s,{size:`sm`,variant:`ghost`,className:`justify-self-start @xl/attention:justify-self-end`,onClick:()=>{let t=new URLSearchParams(l);t.set(`chat`,`open`),t.set(`chatThread`,e.thread_id),c({search:t.toString()})},children:`Open chat`})]},`${e.thread_id}:${e.request_key}`)),r.data.map(e=>(0,P.jsx)(z,{session:e},e.id)),n.data?.map(n=>(0,P.jsx)(B,{request:n,expanded:e===n.id,onToggle:()=>t(e=>e===n.id?null:n.id)},n.id))]})]})}export{V as default};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./scroll-area-Cmb_s_kX.js";import{t as i}from"./chevron-down-DjliQtS1.js";import{t as a}from"./Markdown-DRYI2VLT.js";import{Bn as o,G as s,K as c,Tt as l,U as u,W as d,X as f,Y as p,st as m}from"./index-C0yeM676.js";import{t as h}from"./ErrorState-DprXzfow.js";import{t as g}from"./ViewHeader-BajY1vkx.js";import{t as _}from"./useDetailRoute-DOhAbdV7.js";import{t as v}from"./view-params-DD7i9s5g.js";import{t as y}from"./EmptyState-YM4VSLR9.js";import{t as b}from"./Pager-CleJ2qHm.js";import{i as x,r as S}from"./useSessions-gfliXBHJ.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-Q26Vm3R3.js";import{t as k}from"./useProjectScope-DtEj9j-P.js";var A=e(t(),1),j=n(),M={file:`text-outline`,task:`text-outline`,decision:`text-outline`,error:`text-error`,git:`text-outline`,rule:`text-outline`,plan:`text-outline`},N=`text-outline`;function P(e){return M[e]??N}function F({sessionId:e,open:t,onClose:n}){let{data:i,isLoading:o,error:l,refetch:g}=x(e??``);return(0,j.jsx)(d,{open:t,onOpenChange:e=>!e&&n(),children:(0,j.jsxs)(c,{side:`right`,defaultWidth:540,resizeKey:`sessions`,children:[(0,j.jsx)(p,{children:(0,j.jsx)(f,{children:o?`Loading...`:i?`${i.agent??`Session`} ${i.agent_version?`v${i.agent_version}`:``}`:`Session Detail`})}),(0,j.jsxs)(s,{children:[(0,j.jsx)(`p`,{className:`mb-4 text-sm text-outline`,children:`This audit record contains summaries and events. Open Sessions to read native agent conversations or resume them.`}),l?(0,j.jsx)(h,{message:l.message,onRetry:()=>g()}):o?(0,j.jsx)(`div`,{className:`space-y-4`,children:[...[,,,,]].map((e,t)=>(0,j.jsx)(u,{className:`h-8 w-full bg-surface-highest`},t))}):i?(0,j.jsxs)(`div`,{className:`space-y-6`,children:[i.summary&&(0,j.jsx)(`div`,{className:`font-body text-xs text-on-surface leading-relaxed`,children:(0,j.jsx)(a,{children:i.summary})}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,j.jsx)(m,{label:`ID`,children:(0,j.jsx)(`span`,{className:`font-mono text-xs break-all`,children:i.id})}),(0,j.jsx)(m,{label:`Project ID`,children:i.project_id??`—`}),(0,j.jsx)(m,{label:`Job Run ID`,children:i.job_run_id??`—`}),(0,j.jsx)(m,{label:`Tokens Used`,children:i.tokens_used==null?`—`:i.tokens_used.toLocaleString()}),(0,j.jsx)(m,{label:`Created`,children:new Date(i.created_at).toLocaleString()})]}),i.events.length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:[`Events (`,i.events.length,`)`]}),(0,j.jsx)(r,{className:`h-[300px]`,children:(0,j.jsx)(`div`,{className:`space-y-1`,children:[...i.events].sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()).map(e=>(0,j.jsx)(I,{event:e},e.id))})})]}),i.snapshot&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:`Snapshot`}),(0,j.jsx)(r,{className:`h-[200px]`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word bg-background border-l border-border p-3`,children:i.snapshot})})]})]}):(0,j.jsx)(`div`,{className:`font-body text-xs text-outline py-8 text-center`,children:`Session not found`})]})]})})}function I({event:e}){let[t,n]=(0,A.useState)(!1),r=e.data!=null;return(0,j.jsxs)(`div`,{className:`border-b border-border/65`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-surface-high transition-colors`,onClick:()=>r&&n(!t),"aria-expanded":r?t:void 0,children:[r?t?(0,j.jsx)(i,{size:10,className:`text-outline shrink-0`}):(0,j.jsx)(o,{size:10,className:`text-outline shrink-0`}):(0,j.jsx)(`span`,{className:`w-[10px] shrink-0`}),(0,j.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 text-[10px] font-label font-medium ${P(e.type)}`,children:e.type}),(0,j.jsx)(`span`,{className:`flex-1 font-body text-xs text-outline truncate`,children:L(e.data)}),(0,j.jsx)(`span`,{className:`font-label text-[10px] text-outline shrink-0`,children:new Date(e.created_at).toLocaleTimeString()})]}),t&&r&&(0,j.jsx)(`div`,{className:`px-3 pb-2`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word bg-background border-l border-border/65 p-2 max-h-48 overflow-auto`,children:JSON.stringify(e.data,null,2)})})]})}function L(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;if(typeof t.path==`string`)return t.path;if(typeof t.content==`string`)return t.content.length>80?`${t.content.slice(0,80)}...`:t.content;if(typeof t.message==`string`)return t.message;if(typeof t.summary==`string`)return t.summary;let n=Object.keys(t);return n.length<=3?n.join(`, `):`${n.length} fields`}return String(e)}var R=25,z=`font-label text-xs font-medium text-outline`;function B({projectId:e}){let t=l(`xl`),[n,r]=v(`order`,`desc`,[`asc`,`desc`]),[i,a]=(0,A.useState)({order:n,page:0}),o=i.order===n?i.page:0,s=e=>a({order:n,page:e}),{selectedId:c,openDetail:d,closeDetail:f}=_(`/audit`,`sessionId`),{data:p,isLoading:m,error:g,refetch:x}=S({...e===`all`?{}:{project_id:e},limit:R,offset:o*R,order:n});if(g)return(0,j.jsx)(h,{message:g.message,onRetry:()=>x()});let k=p?.sessions??[],M=p?.total??0;return(0,j.jsxs)(`section`,{"data-testid":`logged-sessions`,children:[(0,j.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-2`,children:[(0,j.jsxs)(`span`,{className:`text-xs text-outline`,children:[M,` records`]}),(0,j.jsxs)(`select`,{"aria-label":`Sort audit by date`,"data-testid":`audit-date-sort`,value:n,onChange:e=>{s(0),r(e.target.value)},className:`form-control form-control-single w-auto max-w-full`,children:[(0,j.jsx)(`option`,{value:`desc`,children:`Created: newest first`}),(0,j.jsx)(`option`,{value:`asc`,children:`Created: oldest first`})]})]}),m?(0,j.jsx)(`div`,{className:`space-y-2`,children:[...[,,,,,]].map((e,t)=>(0,j.jsx)(u,{className:`h-10 w-full bg-surface-highest`},t))}):k.length===0?(0,j.jsx)(y,{message:`No audit records`}):(0,j.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[t?(0,j.jsxs)(O,{children:[(0,j.jsx)(C,{children:(0,j.jsxs)(E,{className:`border-b border-border hover:bg-transparent`,children:[(0,j.jsx)(w,{className:z,children:`Agent`}),(0,j.jsx)(w,{className:`${z} w-24`,children:`Version`}),(0,j.jsx)(w,{className:z,children:`Summary`}),(0,j.jsx)(w,{className:`${z} w-24`,children:`Project`}),(0,j.jsx)(w,{className:`${z} w-28`,children:`Tokens used`}),(0,j.jsx)(w,{className:`${z} w-36`,children:`Created`})]})}),(0,j.jsx)(T,{children:k.map(e=>(0,j.jsxs)(E,{"data-testid":`session-row`,"data-session-id":e.id,className:`border-b border-border/65 hover:bg-surface-high cursor-pointer`,onClick:()=>d(e.id),children:[(0,j.jsx)(D,{className:`font-label text-xs text-primary`,children:(0,j.jsx)(`button`,{type:`button`,className:`text-left font-medium hover:underline`,onClick:t=>{t.stopPropagation(),d(e.id)},children:e.agent??`Session`})}),(0,j.jsx)(D,{className:`font-label text-xs text-outline`,children:e.agent_version??`—`}),(0,j.jsx)(D,{className:`font-body text-xs text-on-surface-variant max-w-sm truncate`,children:e.summary??`—`}),(0,j.jsx)(D,{className:`font-label text-xs text-outline`,children:e.project_id?e.project_id.slice(-6):`—`}),(0,j.jsx)(D,{className:`font-label text-xs text-outline text-right`,children:e.tokens_used==null?`—`:e.tokens_used.toLocaleString()}),(0,j.jsx)(D,{className:`font-label text-xs text-outline`,children:new Date(e.created_at).toLocaleString()})]},e.id))})]}):(0,j.jsx)(`div`,{className:`divide-y divide-border`,children:k.map(e=>(0,j.jsxs)(`article`,{"data-testid":`session-row`,"data-session-id":e.id,className:`py-3 space-y-2`,children:[(0,j.jsx)(`button`,{type:`button`,className:`min-h-8 text-sm text-left font-medium text-primary wrap-break-word`,onClick:()=>d(e.id),children:e.agent??`Session`}),(0,j.jsx)(`p`,{className:`text-sm leading-relaxed text-on-surface wrap-break-word`,children:e.summary??`No summary recorded`}),(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2 text-xs text-outline`,children:[(0,j.jsxs)(`span`,{children:[`Version `,e.agent_version??`—`]}),(0,j.jsxs)(`span`,{children:[e.tokens_used?.toLocaleString()??`—`,` tokens`]}),(0,j.jsx)(`span`,{children:e.project_id?`Project ${e.project_id.slice(-6)}`:`Unassigned`}),(0,j.jsx)(`span`,{children:new Date(e.created_at).toLocaleString()})]})]},e.id))}),(0,j.jsx)(b,{page:o,pageSize:R,total:M,onPage:s})]}),(0,j.jsx)(F,{sessionId:c,open:!!c,onClose:f})]})}function V({projectId:e}){let t=k(e);return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(g,{title:`Audit`,help:`Recorded summaries and events. Open Sessions to read conversations or resume a coding agent.`}),(0,j.jsx)(B,{projectId:t},t)]})}export{V as default};
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./scroll-area-Cmb_s_kX.js";import{t as i}from"./chevron-down-wgh-M0zj.js";import{t as a}from"./Markdown-CtVGTUZH.js";import{G as o,K as s,Tt as c,U as l,W as u,X as d,Y as f,er as p,st as m}from"./index-D5qFuDmc.js";import{t as h}from"./ErrorState-DprXzfow.js";import{t as g}from"./ViewHeader-BtTaSrXy.js";import{t as _}from"./useDetailRoute-DOhAbdV7.js";import{t as v}from"./view-params-DD7i9s5g.js";import{t as y}from"./EmptyState-YM4VSLR9.js";import{t as b}from"./Pager-D-y150yZ.js";import{i as x,r as S}from"./useSessions-n-bp8ic5.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./table-Q26Vm3R3.js";import{t as k}from"./useProjectScope-DtEj9j-P.js";var A=e(t(),1),j=n(),M={file:`text-outline`,task:`text-outline`,decision:`text-outline`,error:`text-error`,git:`text-outline`,rule:`text-outline`,plan:`text-outline`},N=`text-outline`;function P(e){return M[e]??N}function F({sessionId:e,open:t,onClose:n}){let{data:i,isLoading:c,error:p,refetch:g}=x(e??``);return(0,j.jsx)(u,{open:t,onOpenChange:e=>!e&&n(),children:(0,j.jsxs)(s,{side:`right`,defaultWidth:540,resizeKey:`sessions`,children:[(0,j.jsx)(f,{children:(0,j.jsx)(d,{children:c?`Loading...`:i?`${i.agent??`Session`} ${i.agent_version?`v${i.agent_version}`:``}`:`Session Detail`})}),(0,j.jsxs)(o,{children:[(0,j.jsx)(`p`,{className:`mb-4 text-sm text-outline`,children:`This audit record contains summaries and events. Open Sessions to read native agent conversations or resume them.`}),p?(0,j.jsx)(h,{message:p.message,onRetry:()=>g()}):c?(0,j.jsx)(`div`,{className:`space-y-4`,children:[...[,,,,]].map((e,t)=>(0,j.jsx)(l,{className:`h-8 w-full bg-surface-highest`},t))}):i?(0,j.jsxs)(`div`,{className:`space-y-6`,children:[i.summary&&(0,j.jsx)(`div`,{className:`font-body text-xs text-on-surface leading-relaxed`,children:(0,j.jsx)(a,{children:i.summary})}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-4`,children:[(0,j.jsx)(m,{label:`ID`,children:(0,j.jsx)(`span`,{className:`font-mono text-xs break-all`,children:i.id})}),(0,j.jsx)(m,{label:`Project ID`,children:i.project_id??`—`}),(0,j.jsx)(m,{label:`Job Run ID`,children:i.job_run_id??`—`}),(0,j.jsx)(m,{label:`Tokens Used`,children:i.tokens_used==null?`—`:i.tokens_used.toLocaleString()}),(0,j.jsx)(m,{label:`Created`,children:new Date(i.created_at).toLocaleString()})]}),i.events.length>0&&(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:[`Events (`,i.events.length,`)`]}),(0,j.jsx)(r,{className:`h-[300px]`,children:(0,j.jsx)(`div`,{className:`space-y-1`,children:[...i.events].sort((e,t)=>new Date(e.created_at).getTime()-new Date(t.created_at).getTime()).map(e=>(0,j.jsx)(I,{event:e},e.id))})})]}),i.snapshot&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`div`,{className:`font-label text-xs font-medium text-outline mb-3`,children:`Snapshot`}),(0,j.jsx)(r,{className:`h-[200px]`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word bg-background border-l border-border p-3`,children:i.snapshot})})]})]}):(0,j.jsx)(`div`,{className:`font-body text-xs text-outline py-8 text-center`,children:`Session not found`})]})]})})}function I({event:e}){let[t,n]=(0,A.useState)(!1),r=e.data!=null;return(0,j.jsxs)(`div`,{className:`border-b border-border/65`,children:[(0,j.jsxs)(`button`,{type:`button`,className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-surface-high transition-colors`,onClick:()=>r&&n(!t),"aria-expanded":r?t:void 0,children:[r?t?(0,j.jsx)(i,{size:10,className:`text-outline shrink-0`}):(0,j.jsx)(p,{size:10,className:`text-outline shrink-0`}):(0,j.jsx)(`span`,{className:`w-[10px] shrink-0`}),(0,j.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 text-[10px] font-label font-medium ${P(e.type)}`,children:e.type}),(0,j.jsx)(`span`,{className:`flex-1 font-body text-xs text-outline truncate`,children:L(e.data)}),(0,j.jsx)(`span`,{className:`font-label text-[10px] text-outline shrink-0`,children:new Date(e.created_at).toLocaleTimeString()})]}),t&&r&&(0,j.jsx)(`div`,{className:`px-3 pb-2`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-on-surface-variant whitespace-pre-wrap wrap-break-word bg-background border-l border-border/65 p-2 max-h-48 overflow-auto`,children:JSON.stringify(e.data,null,2)})})]})}function L(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;if(typeof t.path==`string`)return t.path;if(typeof t.content==`string`)return t.content.length>80?`${t.content.slice(0,80)}...`:t.content;if(typeof t.message==`string`)return t.message;if(typeof t.summary==`string`)return t.summary;let n=Object.keys(t);return n.length<=3?n.join(`, `):`${n.length} fields`}return String(e)}var R=25,z=`font-label text-xs font-medium text-outline`;function B({projectId:e}){let t=c(`xl`),[n,r]=v(`order`,`desc`,[`asc`,`desc`]),[i,a]=(0,A.useState)({order:n,page:0}),o=i.order===n?i.page:0,s=e=>a({order:n,page:e}),{selectedId:u,openDetail:d,closeDetail:f}=_(`/audit`,`sessionId`),{data:p,isLoading:m,error:g,refetch:x}=S({...e===`all`?{}:{project_id:e},limit:R,offset:o*R,order:n});if(g)return(0,j.jsx)(h,{message:g.message,onRetry:()=>x()});let k=p?.sessions??[],M=p?.total??0;return(0,j.jsxs)(`section`,{"data-testid":`logged-sessions`,children:[(0,j.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-2`,children:[(0,j.jsxs)(`span`,{className:`text-xs text-outline`,children:[M,` records`]}),(0,j.jsxs)(`select`,{"aria-label":`Sort audit by date`,"data-testid":`audit-date-sort`,value:n,onChange:e=>{s(0),r(e.target.value)},className:`form-control form-control-single w-auto max-w-full`,children:[(0,j.jsx)(`option`,{value:`desc`,children:`Created: newest first`}),(0,j.jsx)(`option`,{value:`asc`,children:`Created: oldest first`})]})]}),m?(0,j.jsx)(`div`,{className:`space-y-2`,children:[...[,,,,,]].map((e,t)=>(0,j.jsx)(l,{className:`h-10 w-full bg-surface-highest`},t))}):k.length===0?(0,j.jsx)(y,{message:`No audit records`}):(0,j.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[t?(0,j.jsxs)(O,{children:[(0,j.jsx)(C,{children:(0,j.jsxs)(E,{className:`border-b border-border hover:bg-transparent`,children:[(0,j.jsx)(w,{className:z,children:`Agent`}),(0,j.jsx)(w,{className:`${z} w-24`,children:`Version`}),(0,j.jsx)(w,{className:z,children:`Summary`}),(0,j.jsx)(w,{className:`${z} w-24`,children:`Project`}),(0,j.jsx)(w,{className:`${z} w-28`,children:`Tokens used`}),(0,j.jsx)(w,{className:`${z} w-36`,children:`Created`})]})}),(0,j.jsx)(T,{children:k.map(e=>(0,j.jsxs)(E,{"data-testid":`session-row`,"data-session-id":e.id,className:`border-b border-border/65 hover:bg-surface-high cursor-pointer`,onClick:()=>d(e.id),children:[(0,j.jsx)(D,{className:`font-label text-xs text-primary`,children:(0,j.jsx)(`button`,{type:`button`,className:`text-left font-medium hover:underline`,onClick:t=>{t.stopPropagation(),d(e.id)},children:e.agent??`Session`})}),(0,j.jsx)(D,{className:`font-label text-xs text-outline`,children:e.agent_version??`—`}),(0,j.jsx)(D,{className:`font-body text-xs text-on-surface-variant max-w-sm truncate`,children:e.summary??`—`}),(0,j.jsx)(D,{className:`font-label text-xs text-outline`,children:e.project_id?e.project_id.slice(-6):`—`}),(0,j.jsx)(D,{className:`font-label text-xs text-outline text-right`,children:e.tokens_used==null?`—`:e.tokens_used.toLocaleString()}),(0,j.jsx)(D,{className:`font-label text-xs text-outline`,children:new Date(e.created_at).toLocaleString()})]},e.id))})]}):(0,j.jsx)(`div`,{className:`divide-y divide-border`,children:k.map(e=>(0,j.jsxs)(`article`,{"data-testid":`session-row`,"data-session-id":e.id,className:`py-3 space-y-2`,children:[(0,j.jsx)(`button`,{type:`button`,className:`min-h-8 text-sm text-left font-medium text-primary wrap-break-word`,onClick:()=>d(e.id),children:e.agent??`Session`}),(0,j.jsx)(`p`,{className:`text-sm leading-relaxed text-on-surface wrap-break-word`,children:e.summary??`No summary recorded`}),(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2 text-xs text-outline`,children:[(0,j.jsxs)(`span`,{children:[`Version `,e.agent_version??`—`]}),(0,j.jsxs)(`span`,{children:[e.tokens_used?.toLocaleString()??`—`,` tokens`]}),(0,j.jsx)(`span`,{children:e.project_id?`Project ${e.project_id.slice(-6)}`:`Unassigned`}),(0,j.jsx)(`span`,{children:new Date(e.created_at).toLocaleString()})]})]},e.id))}),(0,j.jsx)(b,{page:o,pageSize:R,total:M,onPage:s})]}),(0,j.jsx)(F,{sessionId:u,open:!!u,onClose:f})]})}function V({projectId:e}){let t=k(e);return(0,j.jsxs)(`div`,{children:[(0,j.jsx)(g,{title:`Audit`,help:`Recorded summaries and events. Open Sessions to read conversations or resume a coding agent.`}),(0,j.jsx)(B,{projectId:t},t)]})}export{V as default};
@@ -1,4 +1,4 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ScratchpadDiagramPreview-C76RVMjL.js","assets/rolldown-runtime-DSDNlrLa.js","assets/jsx-runtime-CVMpzJz9.js","assets/prod-BxHPuooG.js","assets/react-dom-DTbwZiiP.js","assets/es2015-w69PgVrA.js","assets/floating-ui.react-dom-BDMgcqWu.js","assets/preload-helper-BLdHbfdN.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i}from"./useMutation-HX90wI4L.js";import{f as a,t as o,u as s}from"./chunk-OB3PAWPO-1IihCzFx.js";import{l as c,t as l}from"./button-C91mbQEU.js";import{n as u}from"./client-ByMuVs3d.js";import{t as d}from"./maximize-2-CN8Tztng.js";import{t as f}from"./preload-helper-BLdHbfdN.js";import{t as p}from"./Markdown-DRYI2VLT.js";import{n as m,o as h,r as g,s as _,t as v}from"./dialog-C7wt3DcD.js";import{$t as y,D as b,N as x,Qt as S,T as C,Xt as w,Yt as T,Zt as ee,an as E,cn as te,dn as D,en as O,fn as ne,gn as k,gt as A,hn as j,in as M,k as N,ln as re,mn as P,nn as ie,on as ae,pn as F,rn as oe,sn as se,tn as ce,un as le,vn as ue}from"./index-C0yeM676.js";import{t as de}from"./ConfirmDialog-C2YawyrD.js";import{c as fe,l as pe,r as me}from"./useJobs-lhzWAkUN.js";import{t as he}from"./PriorityBadge-D263N3pH.js";import{t as ge}from"./StatusBadge-BUGpPpcH.js";import{n as _e,s as ve}from"./scratchpad-routes-BBSS02R-.js";import{a as ye,t as be}from"./live-sessions-D07BClP7.js";var I=e(t(),1),L=n(),xe=(0,I.createContext)(null);function Se(e,t){return e?null:Object.keys(t).length===0?{}:F(t)}function Ce({store:e,initialState:t={},onStateChange:n,children:r}){let i=(0,I.useRef)(void 0);!e&&!i.current&&(i.current=ne(t));let a=e??i.current,o=(0,I.useRef)(a);o.current=a;let s=(0,I.useRef)(!!e);s.current=!!e,(0,I.useRef)(e?`controlled`:`uncontrolled`),(0,I.useRef)(!1);let c=(0,I.useRef)(t),l=(0,I.useRef)(Se(!!e,t));(0,I.useEffect)(()=>{if(e||t===c.current)return;c.current=t;let n=t&&Object.keys(t).length>0?F(t):{},r=l.current??{},i=new Set([...Object.keys(r),...Object.keys(n)]),o={};for(let e of i)r[e]!==n[e]&&(o[e]=e in n?n[e]:void 0);l.current=n,Object.keys(o).length>0&&a.update(o)},[e,t,a]);let u=(0,I.useSyncExternalStore)(a.subscribe,a.getSnapshot,a.getServerSnapshot??a.getSnapshot),d=(0,I.useRef)(n);d.current=n;let f=(0,I.useCallback)((e,t)=>{let n=o.current,r=n.getSnapshot();n.set(e,t),!s.current&&n.getSnapshot()!==r&&d.current?.([{path:e,value:t}])},[]),p=(0,I.useCallback)(e=>{let t=o.current,n=t.getSnapshot();if(t.update(e),!s.current&&t.getSnapshot()!==n){let t=[];for(let[r,i]of Object.entries(e))P(n,r)!==i&&t.push({path:r,value:i});t.length>0&&d.current?.(t)}},[]),m=(0,I.useCallback)(e=>o.current.get(e),[]),h=(0,I.useCallback)(()=>o.current.getSnapshot(),[]),g=(0,I.useMemo)(()=>({state:u,get:m,set:f,update:p,getSnapshot:h}),[u,m,f,p,h]);return(0,L.jsx)(xe.Provider,{value:g,children:r})}function R(){let e=(0,I.useContext)(xe);if(!e)throw Error(`useStateStore must be used within a StateProvider`);return e}var we=(0,I.createContext)(null);function Te({children:e}){let{state:t}=R(),n=(0,I.useMemo)(()=>({stateModel:t}),[t]),r=(0,I.useMemo)(()=>e=>y(e,n),[n]),i=(0,I.useMemo)(()=>({isVisible:r,ctx:n}),[r,n]);return(0,L.jsx)(we.Provider,{value:i,children:e})}function Ee(){let e=(0,I.useContext)(we);if(!e)throw Error(`useVisibility must be used within a VisibilityProvider`);return e}var De=(0,I.createContext)(null),Oe={};function ke(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(n!==i){if(typeof n==`object`&&n&&typeof i==`object`&&i){let e=n.$state,t=i.$state;if(typeof e==`string`&&e===t)continue}return!1}}return!0}function Ae(e,t){if(e===t)return!0;if(e.validateOn!==t.validateOn)return!1;let n=e.checks??[],r=t.checks??[];if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t.type!==i.type||t.message!==i.message||!ke(t.args,i.args))return!1}return!0}function je({customFunctions:e=Oe,children:t}){let{state:n,getSnapshot:r}=R(),[i,a]=(0,I.useState)({}),o=(0,I.useRef)({}),[s,c]=(0,I.useState)({}),l=(0,I.useCallback)((e,t)=>{c(n=>{let r=n[e];return r&&Ae(r,t)?n:{...n,[e]:t}})},[]),u=(0,I.useCallback)((t,n)=>{let i=r(),s=t.split(`/`).filter(Boolean),c=i;for(let e of s)if(typeof c==`object`&&c)c=c[e];else{c=void 0;break}let l=re(n,{value:c,stateModel:i,customFunctions:e}),u={touched:o.current[t]?.touched??!0,validated:!0,result:l};return o.current={...o.current,[t]:u},a(o.current),l},[e,r]),d=(0,I.useCallback)(e=>{o.current={...o.current,[e]:{...o.current[e],touched:!0,validated:o.current[e]?.validated??!1,result:o.current[e]?.result??null}},a(o.current)},[]),f=(0,I.useCallback)(e=>{let{[e]:t,...n}=o.current;o.current=n,a(n)},[]),p=(0,I.useCallback)(()=>{let e=!0;for(let[t,n]of Object.entries(s))u(t,n).valid||(e=!1);return e},[s,u]),m=(0,I.useMemo)(()=>({customFunctions:e,get fieldStates(){return o.current},validate:u,touch:d,clear:f,validateAll:p,registerField:l}),[e,i,u,d,f,p,l]);return(0,L.jsx)(De.Provider,{value:m,children:t})}function Me(){return(0,I.useContext)(De)}var z=0;function Ne(){return z+=1,`${Date.now()}-${z}`}function B(e,t){if(e==null)return e;if(e===`$id`)return Ne();if(typeof e==`object`&&!Array.isArray(e)){let n=e,r=Object.keys(n);if(r.length===1&&typeof n.$state==`string`)return t(n.$state);if(r.length===1&&`$id`in n)return Ne()}if(Array.isArray(e))return e.map(e=>B(e,t));if(typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=B(i,t);return n}return e}var Pe=(0,I.createContext)(null);function Fe({handlers:e={},navigate:t,children:n}){let{get:r,set:i,getSnapshot:a}=R(),o=Me(),[s,c]=(0,I.useState)(e),[l,u]=(0,I.useState)(new Set),[d,f]=(0,I.useState)(null),p=(0,I.useCallback)((e,t)=>{c(n=>({...n,[e]:t}))},[]),m=(0,I.useCallback)(async e=>{let n=E(e,a()),c=ie(),l=Date.now();oe({id:c,name:n.action,params:n.params,at:l});let d=!0,p;try{if(n.action===`setState`&&n.params){let e=n.params.statePath,t=n.params.value;e&&i(e,t);return}if(n.action===`pushState`&&n.params){let e=n.params.statePath,t=n.params.value;if(e){let a=B(t,r),o=r(e)??[];i(e,[...o,a]);let s=n.params.clearStatePath;s&&i(s,``)}return}if(n.action===`removeState`&&n.params){let e=n.params.statePath,t=n.params.index;if(e!==void 0&&t!==void 0){let n=r(e)??[];i(e,n.filter((e,n)=>n!==t))}return}if(n.action===`push`&&n.params){let e=n.params.screen;if(e){let t=r(`/currentScreen`),n=r(`/navStack`)??[];t?i(`/navStack`,[...n,t]):i(`/navStack`,[...n,``]),i(`/currentScreen`,e)}return}if(n.action===`pop`){let e=r(`/navStack`)??[];if(e.length>0){let t=e[e.length-1];i(`/navStack`,e.slice(0,-1)),t?i(`/currentScreen`,t):i(`/currentScreen`,void 0)}return}if(n.action===`validateForm`){let e=o?.validateAll;if(!e){console.warn(`validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.`);return}let t=e(),r={};for(let[e,t]of Object.entries(o.fieldStates))t.result&&!t.result.valid&&(r[e]=t.result.errors);let a=n.params?.statePath||`/formValidation`;i(a,{valid:t,errors:r});return}let e=s[n.action];if(!e){console.warn(`No handler registered for action: ${n.action}`);return}if(n.confirm)return new Promise((t,r)=>{f({action:n,handler:e,resolve:()=>{f(null),t()},reject:()=>{f(null),r(Error(`Action cancelled`))}})}).then(async()=>{u(e=>new Set(e).add(n.action));try{await O({action:n,handler:e,setState:i,navigate:t,executeAction:async e=>{await m(e)}})}finally{u(e=>{let t=new Set(e);return t.delete(n.action),t})}});u(e=>new Set(e).add(n.action));try{await O({action:n,handler:e,setState:i,navigate:t,executeAction:async e=>{await m(e)}})}finally{u(e=>{let t=new Set(e);return t.delete(n.action),t})}}catch(e){throw d=!1,p=e,e}finally{let e=Date.now();M({id:c,name:n.action,ok:d,at:e,durationMs:e-l,error:p})}},[s,r,i,a,t,o]),h=(0,I.useCallback)(()=>{d?.resolve()},[d]),g=(0,I.useCallback)(()=>{d?.reject()},[d]),_=(0,I.useMemo)(()=>({handlers:s,loadingActions:l,pendingConfirmation:d,execute:m,confirm:h,cancel:g,registerHandler:p}),[s,l,d,m,h,g,p]);return(0,L.jsx)(Pe.Provider,{value:_,children:n})}function Ie(){let e=(0,I.useContext)(Pe);if(!e)throw Error(`useActions must be used within an ActionProvider`);return e}function Le({confirm:e,onConfirm:t,onCancel:n}){let r=e.variant===`danger`;return(0,L.jsx)(`div`,{style:{position:`fixed`,inset:0,backgroundColor:`rgba(0, 0, 0, 0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:50},onClick:n,children:(0,L.jsxs)(`div`,{style:{backgroundColor:`white`,borderRadius:`8px`,padding:`24px`,maxWidth:`400px`,width:`100%`,boxShadow:`0 20px 25px -5px rgba(0, 0, 0, 0.1)`},onClick:e=>e.stopPropagation(),children:[(0,L.jsx)(`h3`,{style:{margin:`0 0 8px 0`,fontSize:`18px`,fontWeight:600},children:e.title}),(0,L.jsx)(`p`,{style:{margin:`0 0 24px 0`,color:`#6b7280`},children:e.message}),(0,L.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,justifyContent:`flex-end`},children:[(0,L.jsx)(`button`,{onClick:n,style:{padding:`8px 16px`,borderRadius:`6px`,border:`1px solid #d1d5db`,backgroundColor:`white`,cursor:`pointer`},children:e.cancelLabel??`Cancel`}),(0,L.jsx)(`button`,{onClick:t,style:{padding:`8px 16px`,borderRadius:`6px`,border:`none`,backgroundColor:r?`#dc2626`:`#3b82f6`,color:`white`,cursor:`pointer`},children:e.confirmLabel??`Confirm`})]})]})})}var Re=(0,I.createContext)(null);function ze({item:e,index:t,basePath:n,children:r}){return(0,L.jsx)(Re.Provider,{value:{item:e,index:t,basePath:n},children:r})}function Be(){return(0,I.useContext)(Re)}var Ve=new WeakMap,He={},Ue=class extends I.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error(`[json-render] Rendering error in <${this.props.elementType}>:`,e,t.componentStack)}componentDidUpdate(e){this.state.hasError&&e.resetKey!==this.props.resetKey&&this.setState({hasError:!1})}render(){return this.state.hasError?null:this.props.children}},We={},Ge=I.createContext(We);function Ke(){return I.useContext(Ge)}var qe=I.createContext(void 0);function Je(){return I.useContext(qe)}function Ye(e,t){let n=t.current;if(n===e)return n;if(n&&e){let t=Object.keys(e);if(t.length===Object.keys(n).length&&t.every(t=>Object.prototype.hasOwnProperty.call(n,t)&&n[t]===e[t]))return n}return t.current=e,e}function Xe(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function V(e,t){if(Object.is(e,t))return!0;let n=Array.isArray(e);if(n!==Array.isArray(t)||!n&&(e===null||t===null||typeof e!=`object`||typeof t!=`object`))return!1;let r=e,i=t,a=Object.keys(i);return n&&e.length!==t.length||a.length!==Object.keys(r).length?!1:a.every(e=>Object.prototype.hasOwnProperty.call(r,e)&&V(r[e],i[e]))}function Ze(e){if(typeof e!=`object`||!e)return e;let t=Array.isArray(e)?Array(e.length):{};for(let n of Object.keys(e))t[n]=Ze(e[n]);return t}function Qe(e,t){if(Object.is(e,t))return e;let n=Array.isArray(e);if(n!==Array.isArray(t)||!n&&(!Xe(e)||!Xe(t)))return t;let r=e,i=t,a=Object.keys(i),o=n?Array(t.length):{},s=(!n||e.length===t.length)&&a.length===Object.keys(r).length;for(let e of a){let t=i[e];Object.prototype.hasOwnProperty.call(r,e)?(t=Qe(r[e],t),Object.is(r[e],t)||(s=!1)):s=!1,o[e]=t}return s?e:o}function $e(e){let t=(0,I.useRef)({}),n=(0,I.useRef)(0);if(!e)return{};let r=t.current,i={},a={},o=new Set;for(let t of Object.keys(e.elements)){if(a[t]!==void 0)continue;let s=e.elements[t];if(!s)continue;o.add(t);let c=[{key:t,element:s,children:[...s.children??[],...Object.values(s.slots??{}).flat()],childIndex:0,childVersions:[]}];for(;c.length>0;){let t=c[c.length-1],s=t.children[t.childIndex];if(s!==void 0){let n=a[s];if(n!==void 0){t.childVersions.push([s,n]),t.childIndex+=1;continue}let r=e.elements[s];if(!r||o.has(s)){t.childVersions.push([s,-1]),t.childIndex+=1;continue}o.add(s),c.push({key:s,element:r,children:[...r.children??[],...Object.values(r.slots??{}).flat()],childIndex:0,childVersions:[]});continue}let l=r[t.key],u=l&&V(l.own,t.element)&&V(l.children,t.childVersions)?l.version:++n.current;o.delete(t.key),i[t.key]={own:Ze(t.element),children:t.childVersions,version:u},a[t.key]=u,c.pop()}}return t.current=i,a}var et=I.memo(function({Component:e,element:t,slots:n,emit:r,on:i,bindings:a,loading:o,children:s}){return(0,L.jsx)(e,{element:t,slots:n,emit:r,on:i,bindings:a,loading:o,children:s})},(e,t)=>e.Component===t.Component&&e.signature===t.signature&&e.execute===t.execute&&e.actionContext?.item===t.actionContext?.item&&e.actionContext?.index===t.actionContext?.index&&e.actionContext?.basePath===t.actionContext?.basePath&&e.functions===t.functions&&e.directives===t.directives&&e.element.props===t.element.props&&e.bindings===t.bindings&&e.loading===t.loading);function tt(){return I.useSyncExternalStore(D,ce,()=>!1)}function nt({element:e,elementKey:t,spec:n,registry:r,loading:i,fallback:a,signatures:o}){let s=tt(),c=Be(),{ctx:l}=Ee(),{execute:u}=Ie(),{getSnapshot:d,state:f}=R(),p=Ke(),m=Je(),h=(0,I.useMemo)(()=>{let e=c?{...l,repeatItem:c.item,repeatIndex:c.index,repeatBasePath:c.basePath}:{...l};return e.functions=p,e.directives=m,e},[l,c,p,m]),g=e.repeat!==void 0&&c==null?le(e.visible):{container:e.visible,itemFilter:void 0},_=g.itemFilter,v=g.container===void 0||y(g.container,h),b=e.on,x=(0,I.useCallback)(async e=>{let t=b?.[e];if(!t)return;let n=Array.isArray(t)?t:[t];for(let e of n){if(!e.params){await u(e);continue}let t={...h,stateModel:d()},n={};for(let[r,i]of Object.entries(e.params))n[r]=ae(i,t);await u({...e,params:n})}},[b,u,h,d]),S=(0,I.useCallback)(e=>{let t=b?.[e];return t?{emit:()=>x(e),shouldPreventDefault:(Array.isArray(t)?t:[t]).some(e=>e.preventDefault),bound:!0}:{emit:()=>{},shouldPreventDefault:!1,bound:!1}},[b,x]),C=e.watch,w=(0,I.useRef)(null),T=(0,I.useRef)(void 0),ee=(0,I.useRef)(void 0),E=(0,I.useRef)({}),D=(0,I.useMemo)(()=>{if(!C)return;let e={};for(let t of Object.keys(C))e[t]=P(f,t);let t=T.current;if(t){let n=Object.keys(e);if(n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n]))return t}return T.current=e,e},[C,f]);if((0,I.useEffect)(()=>{if(!C||!D)return;let e=Object.keys(C);if(e.length===0)return;let t=w.current;if(w.current=D,t===null)return;let n=!1;return(async()=>{for(let r of e){if(n)break;if(D[r]!==t[r]){let e=C[r];if(!e)continue;let t=Array.isArray(e)?e:[e];for(let e of t){if(n)break;if(!e.params){if(await u(e),n)break;continue}let t={...h,stateModel:d()},r={};for(let[n,i]of Object.entries(e.params))r[n]=ae(i,t);if(await u({...e,params:r}),n)break}}}})().catch(console.error),()=>{n=!0}},[C,D,u,h,d]),!v)return null;let O=e.props??He,ne=Ye(se(O,h),ee),k=Qe(E.current,te(O,h));E.current=k;let A=k===e.props?e:{...e,props:k},j=r[A.type]??a;if(!j)return console.warn(`No renderer for component type: ${A.type}`),null;let M=Ve.get(r)?.[A.type];if(A.slots&&M?.slots){let e=new Set(M.slots);for(let t of Object.keys(A.slots))t==="default"?console.warn(`[json-render] Component "${A.type}" uses slots.default. Use "children" for default slot content.`):e.has(t)||console.warn(`[json-render] Unknown slot "${t}" on component "${A.type}". Available slots: ${M.slots.join(`, `)}`)}let N=(e,t)=>e.map(e=>{let s=n.elements[e];if(!s){if(!i){let n=t?`in slot "${t}" of "${A.type}"`:`as child of "${A.type}"`;console.warn(`[json-render] Missing element "${e}" referenced ${n}. This element will not render.`)}return null}return(0,L.jsx)(H,{element:s,elementKey:e,spec:n,registry:r,loading:i,fallback:a,signatures:o},e)}),re=A.repeat?(0,L.jsx)(rt,{element:A,spec:n,registry:r,loading:i,fallback:a,itemFilter:_,signatures:o}):A.children?N(A.children):void 0,ie=A.slots?Object.fromEntries(Object.entries(A.slots).map(([e,t])=>[e,N(t,e)])):void 0,F=(0,L.jsx)(et,{Component:j,signature:o[t??``],execute:u,actionContext:c,functions:p,directives:m,element:A,slots:ie,emit:x,on:S,bindings:ne,loading:i,children:re}),oe=s&&t?(0,L.jsx)(`span`,{"data-jr-key":t,style:{display:`contents`},children:F}):F;return(0,L.jsx)(Ue,{elementType:A.type,resetKey:o[t??``],children:oe})}var H=I.memo(function(e){return(0,L.jsx)(nt,{...e})},(e,t)=>e.elementKey===t.elementKey&&e.signatures[e.elementKey??``]===t.signatures[t.elementKey??``]&&e.registry===t.registry&&e.loading===t.loading&&e.fallback===t.fallback);function rt({element:e,spec:t,registry:n,loading:r,fallback:i,signatures:a,itemFilter:o}){let{state:s}=R(),{ctx:c}=Ee(),l=Be(),u=e.repeat,d=k(u.statePath,l?.basePath);if(d===void 0)return console.warn(`[json-render] $item in repeat.statePath used outside of a repeat scope`),null;let f=(P(s,d)??[]).map((e,t)=>({itemValue:e,index:t})).filter(({itemValue:e,index:t})=>o===void 0||y(o,{...c,repeatItem:e,repeatIndex:t}));return(0,L.jsx)(L.Fragment,{children:f.map(({itemValue:o,index:s})=>{let c=u.key&&typeof o==`object`&&o?String(o[u.key]??s):String(s);return(0,L.jsx)(ze,{item:o,index:s,basePath:j(d,s),children:e.children?.map(o=>{let s=t.elements[o];return s?(0,L.jsx)(H,{element:s,elementKey:o,spec:t,registry:n,loading:r,fallback:i,signatures:a},o):(r||console.warn(`[json-render] Missing element "${o}" referenced as child of "${e.type}" (repeat). This element will not render.`),null)})},c)})})}function it({spec:e,registry:t,loading:n,fallback:r}){let i=$e(e);if(!e||!e.root)return null;let a=e.elements[e.root];return a?(0,L.jsx)(H,{element:a,elementKey:e.root,spec:e,registry:t,loading:n,fallback:r,signatures:i}):null}function at({registry:e,store:t,initialState:n,handlers:r,navigate:i,validationFunctions:a,functions:o,directives:s,onStateChange:c,children:l}){let u=(0,I.useMemo)(()=>s?S(s):void 0,[s]);return(0,L.jsx)(Ce,{store:t,initialState:n,onStateChange:c,children:(0,L.jsx)(Te,{children:(0,L.jsx)(je,{customFunctions:a,children:(0,L.jsx)(Fe,{handlers:r,navigate:i,children:(0,L.jsx)(Ge.Provider,{value:o??We,children:(0,L.jsxs)(qe.Provider,{value:u,children:[l,(0,L.jsx)(ot,{})]})})})})})})}function ot(){let{pendingConfirmation:e,confirm:t,cancel:n}=Ie();return e?.action.confirm?(0,L.jsx)(Le,{confirm:e.action.confirm,onConfirm:t,onCancel:n}):null}function st(e,t){let n={};if(t.components)for(let[e,r]of Object.entries(t.components))n[e]=({element:e,children:t,slots:n,emit:i,on:a,bindings:o,loading:s})=>r({props:e.props,children:t,slots:n,emit:i,on:a,bindings:o,loading:s});let r=e.data.components;r&&Ve.set(n,r);let i=t.actions?Object.entries(t.actions):[];return{registry:n,handlers:(e,t)=>{let n={};for(let[r,a]of i)n[r]=async n=>{let r=e()??(()=>void 0),i=t();await a(n,r,i)};return n},executeAction:async(e,t,n,r={})=>{let a=i.find(([t])=>t===e);a?await a[1](t,n,r):console.warn(`Unknown action: ${e}`)}}}var ct={"task.delete":{title:`Delete this task?`,description:`This permanently deletes the task. It cannot be undone.`,label:`Delete`,destructive:!0},"job.run":{title:`Run this job now?`,description:`The job starts immediately with its saved command and settings.`,label:`Run now`,destructive:!1}},lt=(0,I.createContext)(null);function U(){let e=(0,I.useContext)(lt);if(!e)throw Error(`useChatUiAction must be used inside ChatUiActionProvider`);return e}function ut(){let{outcome:e}=U();return e?(0,L.jsx)(`p`,{role:e.tone===`error`?`alert`:`status`,"data-testid":`chat-ui-action-result`,className:`mt-1.5 text-xs ${e.tone===`error`?`text-error`:`text-on-surface-variant`}`,children:e.text}):null}function dt({children:e}){let t=r(),n=x(),i=b(),a=C(),o=fe(),s=pe(),[c,l]=(0,I.useState)(new Set),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(null),m=(0,I.useRef)(null),h=(0,I.useCallback)((e,t)=>new Promise(n=>{m.current?.(!1),m.current=n,p({name:e,id:t})}),[]),g=e=>{m.current?.(e),m.current=null,p(null)},_=(0,I.useCallback)(async(e,r)=>{let c=r.id;switch(e){case`task.update`:{let{id:e,...t}=r;return await n.mutateAsync({id:c,...t}),`Task updated`}case`task.comment`:return await a.mutateAsync({id:c,content:r.content}),`Comment added`;case`task.delete`:return await i.mutateAsync(c),await t.invalidateQueries({queryKey:[`task`,c]}),`Task deleted`;case`job.run`:return await o.mutateAsync(c),await t.invalidateQueries({queryKey:[`job`,c]}),`Job run started`;case`job.setEnabled`:return await s.mutateAsync({id:c,enabled:r.enabled}),r.enabled?`Job enabled`:`Job disabled`}},[t,n,a,i,o,s]),v=(0,I.useCallback)(async(e,t)=>{let n=w.data.actions[e];if(!n){d({tone:`error`,text:`Unknown action: ${e}`});return}let r=e,i=n.params.safeParse(t??{});if(!i.success){d({tone:`error`,text:`Invalid ${r} parameters`});return}let a=i.data;if(T.has(r)&&!await h(r,a.id))return;let o=`${r}:${a.id}`;l(e=>new Set(e).add(o)),d(null);try{d({tone:`success`,text:await _(r,a)})}catch(e){d({tone:`error`,text:e instanceof Error?e.message:String(e)})}finally{l(e=>{let t=new Set(e);return t.delete(o),t})}},[h,_]),y=(0,I.useMemo)(()=>({run:v,pending:c,outcome:u}),[v,c,u]),S=f?ct[f.name]:void 0;return(0,L.jsxs)(lt.Provider,{value:y,children:[e,(0,L.jsx)(ut,{}),(0,L.jsx)(de,{open:!!f,title:S?.title??`Confirm action`,description:f&&S?`${S.description} Target ${f.name===`task.delete`?`task`:`job`}: ${f.id}.`:`This runs as you through the ORC API.`,confirmLabel:S?.label??`Confirm`,variant:S?.destructive===!1?`warning`:`destructive`,onConfirm:()=>g(!0),onCancel:()=>g(!1)})]})}function ft(){let{run:e}=U();return(0,I.useMemo)(()=>Object.fromEntries(Object.keys(w.data.actions).map(t=>[t,n=>e(t,n)])),[e])}var pt={neutral:`bg-muted-foreground`,progress:`bg-progress`,success:`bg-secondary`,warning:`bg-tertiary`,error:`bg-error`};function mt(e,t){if(!e.startsWith(`/`))return e;let n=new URLSearchParams(t);if(n.get(`chat`)!==`open`)return e;let r=new URL(e,`http://orc.local`),i=r.searchParams;i.set(`chat`,`open`);let a=n.get(`chatThread`);return a&&i.set(`chatThread`,a),`${r.pathname}?${i}${r.hash}`}function W({href:e,children:t,className:n,testId:r}){let i=s(),a=c(`inline-flex min-w-0 items-center text-on-surface underline decoration-outline-variant underline-offset-4 hover:decoration-current focus-visible:outline-2 focus-visible:outline-focus`,n);return e.startsWith(`/`)?(0,L.jsx)(o,{"data-testid":r,to:mt(e,i.search),className:a,children:t}):(0,L.jsx)(`a`,{"data-testid":r,href:e,target:`_blank`,rel:`noopener noreferrer`,className:a,children:t})}function ht({tone:e,className:t}){return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:c(`size-1.5 shrink-0 rounded-full`,pt[e],t)})}function G({children:e,className:t,testId:n}){return(0,L.jsx)(`section`,{"data-testid":n,className:c(`min-w-0 rounded-lg border border-outline-variant px-3 py-2.5`,t),children:e})}function K({children:e}){return(0,L.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-on-surface-variant`,children:e})}function q({label:e}){return(0,L.jsx)(`div`,{role:`status`,"aria-label":e,className:`h-14 animate-pulse rounded-lg border border-outline-variant bg-surface`})}function J({label:e,error:t}){let n=t instanceof Error?t.message:String(t);return(0,L.jsxs)(`div`,{role:`alert`,"data-testid":`chat-ui-entity-error`,className:`rounded-lg border border-outline-variant px-3 py-2 text-xs text-on-surface-variant`,children:[(0,L.jsx)(`span`,{className:`text-error`,children:e}),` `,n]})}function gt({children:e,testId:t}){return(0,L.jsx)(`ul`,{"data-testid":t,className:`min-w-0 divide-y divide-outline-variant`,children:e})}function _t({children:e}){return(0,L.jsx)(`p`,{className:`py-2 text-xs text-on-surface-variant`,children:e})}function vt({value:e,label:t}){let n=Math.max(0,Math.min(100,e));return(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,"aria-label":t??`Progress`,className:`h-1 flex-1 overflow-hidden rounded-full bg-selected`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full bg-progress`,style:{width:`${n}%`}})}),(0,L.jsxs)(`span`,{className:`shrink-0 text-xs tabular-nums text-on-surface-variant`,children:[t?`${t} · `:``,n,`%`]})]})}function Y(e){if(e==null)return`—`;let t=new Date(typeof e==`number`?e*1e3:e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function X({title:e,heading:t,testId:n,canExpand:r,children:i}){let[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(!1),l=(0,I.useRef)(null);return(0,L.jsxs)(v,{open:s,onOpenChange:c,children:[(0,L.jsxs)(G,{testId:n,className:`space-y-2`,children:[(0,L.jsxs)(`header`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1 text-sm font-medium`,children:t??e}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,"data-testid":`chat-ui-expand`,"aria-label":`${a?`Collapse`:`Expand`} ${e}`,"aria-expanded":a,className:`min-h-11 shrink-0 rounded px-2 text-xs text-muted-foreground hover:bg-surface focus-visible:outline-2 focus-visible:outline-focus sm:min-h-8`,onClick:()=>o(e=>!e),children:a?`Collapse`:`Expand`}),(0,L.jsx)(_,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,"data-testid":`chat-ui-fullscreen`,"aria-label":`View ${e} fullscreen`,className:`flex size-11 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-surface focus-visible:outline-2 focus-visible:outline-focus sm:size-8`,children:(0,L.jsx)(d,{size:15,"aria-hidden":`true`})})})]})]}),!s&&i(a)]}),(0,L.jsxs)(m,{ref:l,"data-testid":`chat-ui-fullscreen-dialog`,className:`left-0 flex w-screen max-w-none max-h-none translate-x-0 translate-y-0 flex-col gap-3 overflow-hidden rounded-none p-4 sm:rounded-none sm:p-6 [&>button]:size-11`,style:{top:`var(--app-top, 0px)`,height:`var(--app-height, 100dvh)`},onOpenAutoFocus:e=>{e.preventDefault(),l.current?.focus()},onClick:e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`a`)?.getAttribute(`href`);t?.startsWith(`/`)&&!t.startsWith(`//`)&&c(!1)},children:[(0,L.jsx)(h,{className:`min-w-0 pr-12 break-words`,children:t??e}),(0,L.jsx)(g,{className:`sr-only`,children:`Full current content. Press Escape or Close to return to chat.`}),(0,L.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain`,"data-testid":`chat-ui-fullscreen-content`,children:s&&i(!0)}),s&&(0,L.jsx)(ut,{})]})]})}var yt=(0,I.lazy)(()=>f(()=>import(`./ScratchpadDiagramPreview-C76RVMjL.js`),__vite__mapDeps([0,1,2,3,4,5,6,7]))),bt=`default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'none'; form-action 'none'; base-uri 'none'`;function xt(e){let t=`<meta http-equiv="Content-Security-Policy" content="${bt}">`,n=/^\s*<!doctype[^>]*>/i.exec(e);return n?`${n[0]}${t}${e.slice(n[0].length)}`:`${t}${e}`}function St({pad:e,expanded:t}){return e.kind===`html`?(0,L.jsx)(`iframe`,{"data-testid":`chat-ui-scratchpad-html`,title:`${e.title} preview`,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,srcDoc:xt(e.content),className:`w-full border border-outline-variant bg-white ${t?`h-[70vh] min-h-80`:`h-72`}`}):e.kind===`diagram`?(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(`p`,{role:`status`,children:`Loading diagram…`}),children:(0,L.jsx)(yt,{content:e.content,title:e.title,expanded:t},e.content)}):t?(0,L.jsx)(p,{readable:!0,children:e.content}):(0,L.jsx)(`p`,{className:`line-clamp-4 whitespace-pre-wrap break-words text-xs`,children:e.content})}var Ct=[`todo`,`queued`,`doing`,`review`,`changes_requested`,`blocked`,`done`,`paused`,`cancelled`],wt=10,Z=`text-sm font-medium no-underline hover:underline`,Q=e=>e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `);function Tt({id:e}){let{data:t}=A(e);return e?(0,L.jsx)(W,{href:`/projects/${e}`,children:t?.name??`Project`}):null}function Et({id:e}){let{data:t,isLoading:n,error:r}=N(e),{run:i,pending:a}=U();if(n)return(0,L.jsx)(q,{label:`Loading task`});if(r||!t)return(0,L.jsx)(J,{label:`Task unavailable.`,error:r??`Not found`});let o=a.has(`task.update:${e}`)||a.has(`task.delete:${e}`);return(0,L.jsx)(X,{testId:`chat-ui-task`,title:t.title,heading:(0,L.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,L.jsx)(W,{href:`/tasks/${t.id}`,className:c(Z,`break-words`),children:t.title}),(0,L.jsx)(he,{priority:t.priority,className:`shrink-0`})]}),canExpand:!!(t.body&&(t.body.length>120||t.body.split(`
2
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{n as i}from"./useMutation-HX90wI4L.js";import{f as a,t as o,u as s}from"./chunk-OB3PAWPO-1IihCzFx.js";import{l as c,t as l}from"./button-C91mbQEU.js";import{n as u}from"./client-BnTXPI20.js";import{t as d}from"./maximize-2-Daih3Vv7.js";import{t as f}from"./preload-helper-BLdHbfdN.js";import{t as p}from"./Markdown-CtVGTUZH.js";import{n as m,o as h,r as g,s as _,t as v}from"./dialog-D86vkhdt.js";import{$t as y,D as b,N as x,Qt as S,T as C,Xt as w,Yt as T,Zt as ee,an as E,cn as te,dn as D,en as O,fn as ne,gn as k,gt as A,hn as j,in as M,k as N,ln as re,mn as P,nn as ie,on as ae,pn as F,rn as oe,sn as se,tn as ce,un as le,vn as ue}from"./index-D5qFuDmc.js";import{t as de}from"./ConfirmDialog-DOSTWblx.js";import{c as fe,l as pe,r as me}from"./useJobs-BNj4dd9l.js";import{t as he}from"./PriorityBadge-D263N3pH.js";import{t as ge}from"./StatusBadge-BUGpPpcH.js";import{n as _e,s as ve}from"./scratchpad-routes-D8SCEha7.js";import{a as ye,t as be}from"./live-sessions-D07BClP7.js";var I=e(t(),1),L=n(),xe=(0,I.createContext)(null);function Se(e,t){return e?null:Object.keys(t).length===0?{}:F(t)}function Ce({store:e,initialState:t={},onStateChange:n,children:r}){let i=(0,I.useRef)(void 0);!e&&!i.current&&(i.current=ne(t));let a=e??i.current,o=(0,I.useRef)(a);o.current=a;let s=(0,I.useRef)(!!e);s.current=!!e,(0,I.useRef)(e?`controlled`:`uncontrolled`),(0,I.useRef)(!1);let c=(0,I.useRef)(t),l=(0,I.useRef)(Se(!!e,t));(0,I.useEffect)(()=>{if(e||t===c.current)return;c.current=t;let n=t&&Object.keys(t).length>0?F(t):{},r=l.current??{},i=new Set([...Object.keys(r),...Object.keys(n)]),o={};for(let e of i)r[e]!==n[e]&&(o[e]=e in n?n[e]:void 0);l.current=n,Object.keys(o).length>0&&a.update(o)},[e,t,a]);let u=(0,I.useSyncExternalStore)(a.subscribe,a.getSnapshot,a.getServerSnapshot??a.getSnapshot),d=(0,I.useRef)(n);d.current=n;let f=(0,I.useCallback)((e,t)=>{let n=o.current,r=n.getSnapshot();n.set(e,t),!s.current&&n.getSnapshot()!==r&&d.current?.([{path:e,value:t}])},[]),p=(0,I.useCallback)(e=>{let t=o.current,n=t.getSnapshot();if(t.update(e),!s.current&&t.getSnapshot()!==n){let t=[];for(let[r,i]of Object.entries(e))P(n,r)!==i&&t.push({path:r,value:i});t.length>0&&d.current?.(t)}},[]),m=(0,I.useCallback)(e=>o.current.get(e),[]),h=(0,I.useCallback)(()=>o.current.getSnapshot(),[]),g=(0,I.useMemo)(()=>({state:u,get:m,set:f,update:p,getSnapshot:h}),[u,m,f,p,h]);return(0,L.jsx)(xe.Provider,{value:g,children:r})}function R(){let e=(0,I.useContext)(xe);if(!e)throw Error(`useStateStore must be used within a StateProvider`);return e}var we=(0,I.createContext)(null);function Te({children:e}){let{state:t}=R(),n=(0,I.useMemo)(()=>({stateModel:t}),[t]),r=(0,I.useMemo)(()=>e=>y(e,n),[n]),i=(0,I.useMemo)(()=>({isVisible:r,ctx:n}),[r,n]);return(0,L.jsx)(we.Provider,{value:i,children:e})}function Ee(){let e=(0,I.useContext)(we);if(!e)throw Error(`useVisibility must be used within a VisibilityProvider`);return e}var De=(0,I.createContext)(null),Oe={};function ke(e,t){if(e===t)return!0;if(!e||!t)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n){let n=e[r],i=t[r];if(n!==i){if(typeof n==`object`&&n&&typeof i==`object`&&i){let e=n.$state,t=i.$state;if(typeof e==`string`&&e===t)continue}return!1}}return!0}function Ae(e,t){if(e===t)return!0;if(e.validateOn!==t.validateOn)return!1;let n=e.checks??[],r=t.checks??[];if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t.type!==i.type||t.message!==i.message||!ke(t.args,i.args))return!1}return!0}function je({customFunctions:e=Oe,children:t}){let{state:n,getSnapshot:r}=R(),[i,a]=(0,I.useState)({}),o=(0,I.useRef)({}),[s,c]=(0,I.useState)({}),l=(0,I.useCallback)((e,t)=>{c(n=>{let r=n[e];return r&&Ae(r,t)?n:{...n,[e]:t}})},[]),u=(0,I.useCallback)((t,n)=>{let i=r(),s=t.split(`/`).filter(Boolean),c=i;for(let e of s)if(typeof c==`object`&&c)c=c[e];else{c=void 0;break}let l=re(n,{value:c,stateModel:i,customFunctions:e}),u={touched:o.current[t]?.touched??!0,validated:!0,result:l};return o.current={...o.current,[t]:u},a(o.current),l},[e,r]),d=(0,I.useCallback)(e=>{o.current={...o.current,[e]:{...o.current[e],touched:!0,validated:o.current[e]?.validated??!1,result:o.current[e]?.result??null}},a(o.current)},[]),f=(0,I.useCallback)(e=>{let{[e]:t,...n}=o.current;o.current=n,a(n)},[]),p=(0,I.useCallback)(()=>{let e=!0;for(let[t,n]of Object.entries(s))u(t,n).valid||(e=!1);return e},[s,u]),m=(0,I.useMemo)(()=>({customFunctions:e,get fieldStates(){return o.current},validate:u,touch:d,clear:f,validateAll:p,registerField:l}),[e,i,u,d,f,p,l]);return(0,L.jsx)(De.Provider,{value:m,children:t})}function Me(){return(0,I.useContext)(De)}var z=0;function Ne(){return z+=1,`${Date.now()}-${z}`}function B(e,t){if(e==null)return e;if(e===`$id`)return Ne();if(typeof e==`object`&&!Array.isArray(e)){let n=e,r=Object.keys(n);if(r.length===1&&typeof n.$state==`string`)return t(n.$state);if(r.length===1&&`$id`in n)return Ne()}if(Array.isArray(e))return e.map(e=>B(e,t));if(typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=B(i,t);return n}return e}var Pe=(0,I.createContext)(null);function Fe({handlers:e={},navigate:t,children:n}){let{get:r,set:i,getSnapshot:a}=R(),o=Me(),[s,c]=(0,I.useState)(e),[l,u]=(0,I.useState)(new Set),[d,f]=(0,I.useState)(null),p=(0,I.useCallback)((e,t)=>{c(n=>({...n,[e]:t}))},[]),m=(0,I.useCallback)(async e=>{let n=E(e,a()),c=ie(),l=Date.now();oe({id:c,name:n.action,params:n.params,at:l});let d=!0,p;try{if(n.action===`setState`&&n.params){let e=n.params.statePath,t=n.params.value;e&&i(e,t);return}if(n.action===`pushState`&&n.params){let e=n.params.statePath,t=n.params.value;if(e){let a=B(t,r),o=r(e)??[];i(e,[...o,a]);let s=n.params.clearStatePath;s&&i(s,``)}return}if(n.action===`removeState`&&n.params){let e=n.params.statePath,t=n.params.index;if(e!==void 0&&t!==void 0){let n=r(e)??[];i(e,n.filter((e,n)=>n!==t))}return}if(n.action===`push`&&n.params){let e=n.params.screen;if(e){let t=r(`/currentScreen`),n=r(`/navStack`)??[];t?i(`/navStack`,[...n,t]):i(`/navStack`,[...n,``]),i(`/currentScreen`,e)}return}if(n.action===`pop`){let e=r(`/navStack`)??[];if(e.length>0){let t=e[e.length-1];i(`/navStack`,e.slice(0,-1)),t?i(`/currentScreen`,t):i(`/currentScreen`,void 0)}return}if(n.action===`validateForm`){let e=o?.validateAll;if(!e){console.warn(`validateForm action was dispatched but no ValidationProvider is connected. Ensure ValidationProvider is rendered inside the provider tree.`);return}let t=e(),r={};for(let[e,t]of Object.entries(o.fieldStates))t.result&&!t.result.valid&&(r[e]=t.result.errors);let a=n.params?.statePath||`/formValidation`;i(a,{valid:t,errors:r});return}let e=s[n.action];if(!e){console.warn(`No handler registered for action: ${n.action}`);return}if(n.confirm)return new Promise((t,r)=>{f({action:n,handler:e,resolve:()=>{f(null),t()},reject:()=>{f(null),r(Error(`Action cancelled`))}})}).then(async()=>{u(e=>new Set(e).add(n.action));try{await O({action:n,handler:e,setState:i,navigate:t,executeAction:async e=>{await m(e)}})}finally{u(e=>{let t=new Set(e);return t.delete(n.action),t})}});u(e=>new Set(e).add(n.action));try{await O({action:n,handler:e,setState:i,navigate:t,executeAction:async e=>{await m(e)}})}finally{u(e=>{let t=new Set(e);return t.delete(n.action),t})}}catch(e){throw d=!1,p=e,e}finally{let e=Date.now();M({id:c,name:n.action,ok:d,at:e,durationMs:e-l,error:p})}},[s,r,i,a,t,o]),h=(0,I.useCallback)(()=>{d?.resolve()},[d]),g=(0,I.useCallback)(()=>{d?.reject()},[d]),_=(0,I.useMemo)(()=>({handlers:s,loadingActions:l,pendingConfirmation:d,execute:m,confirm:h,cancel:g,registerHandler:p}),[s,l,d,m,h,g,p]);return(0,L.jsx)(Pe.Provider,{value:_,children:n})}function Ie(){let e=(0,I.useContext)(Pe);if(!e)throw Error(`useActions must be used within an ActionProvider`);return e}function Le({confirm:e,onConfirm:t,onCancel:n}){let r=e.variant===`danger`;return(0,L.jsx)(`div`,{style:{position:`fixed`,inset:0,backgroundColor:`rgba(0, 0, 0, 0.5)`,display:`flex`,alignItems:`center`,justifyContent:`center`,zIndex:50},onClick:n,children:(0,L.jsxs)(`div`,{style:{backgroundColor:`white`,borderRadius:`8px`,padding:`24px`,maxWidth:`400px`,width:`100%`,boxShadow:`0 20px 25px -5px rgba(0, 0, 0, 0.1)`},onClick:e=>e.stopPropagation(),children:[(0,L.jsx)(`h3`,{style:{margin:`0 0 8px 0`,fontSize:`18px`,fontWeight:600},children:e.title}),(0,L.jsx)(`p`,{style:{margin:`0 0 24px 0`,color:`#6b7280`},children:e.message}),(0,L.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,justifyContent:`flex-end`},children:[(0,L.jsx)(`button`,{onClick:n,style:{padding:`8px 16px`,borderRadius:`6px`,border:`1px solid #d1d5db`,backgroundColor:`white`,cursor:`pointer`},children:e.cancelLabel??`Cancel`}),(0,L.jsx)(`button`,{onClick:t,style:{padding:`8px 16px`,borderRadius:`6px`,border:`none`,backgroundColor:r?`#dc2626`:`#3b82f6`,color:`white`,cursor:`pointer`},children:e.confirmLabel??`Confirm`})]})]})})}var Re=(0,I.createContext)(null);function ze({item:e,index:t,basePath:n,children:r}){return(0,L.jsx)(Re.Provider,{value:{item:e,index:t,basePath:n},children:r})}function Be(){return(0,I.useContext)(Re)}var Ve=new WeakMap,He={},Ue=class extends I.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error(`[json-render] Rendering error in <${this.props.elementType}>:`,e,t.componentStack)}componentDidUpdate(e){this.state.hasError&&e.resetKey!==this.props.resetKey&&this.setState({hasError:!1})}render(){return this.state.hasError?null:this.props.children}},We={},Ge=I.createContext(We);function Ke(){return I.useContext(Ge)}var qe=I.createContext(void 0);function Je(){return I.useContext(qe)}function Ye(e,t){let n=t.current;if(n===e)return n;if(n&&e){let t=Object.keys(e);if(t.length===Object.keys(n).length&&t.every(t=>Object.prototype.hasOwnProperty.call(n,t)&&n[t]===e[t]))return n}return t.current=e,e}function Xe(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function V(e,t){if(Object.is(e,t))return!0;let n=Array.isArray(e);if(n!==Array.isArray(t)||!n&&(e===null||t===null||typeof e!=`object`||typeof t!=`object`))return!1;let r=e,i=t,a=Object.keys(i);return n&&e.length!==t.length||a.length!==Object.keys(r).length?!1:a.every(e=>Object.prototype.hasOwnProperty.call(r,e)&&V(r[e],i[e]))}function Ze(e){if(typeof e!=`object`||!e)return e;let t=Array.isArray(e)?Array(e.length):{};for(let n of Object.keys(e))t[n]=Ze(e[n]);return t}function Qe(e,t){if(Object.is(e,t))return e;let n=Array.isArray(e);if(n!==Array.isArray(t)||!n&&(!Xe(e)||!Xe(t)))return t;let r=e,i=t,a=Object.keys(i),o=n?Array(t.length):{},s=(!n||e.length===t.length)&&a.length===Object.keys(r).length;for(let e of a){let t=i[e];Object.prototype.hasOwnProperty.call(r,e)?(t=Qe(r[e],t),Object.is(r[e],t)||(s=!1)):s=!1,o[e]=t}return s?e:o}function $e(e){let t=(0,I.useRef)({}),n=(0,I.useRef)(0);if(!e)return{};let r=t.current,i={},a={},o=new Set;for(let t of Object.keys(e.elements)){if(a[t]!==void 0)continue;let s=e.elements[t];if(!s)continue;o.add(t);let c=[{key:t,element:s,children:[...s.children??[],...Object.values(s.slots??{}).flat()],childIndex:0,childVersions:[]}];for(;c.length>0;){let t=c[c.length-1],s=t.children[t.childIndex];if(s!==void 0){let n=a[s];if(n!==void 0){t.childVersions.push([s,n]),t.childIndex+=1;continue}let r=e.elements[s];if(!r||o.has(s)){t.childVersions.push([s,-1]),t.childIndex+=1;continue}o.add(s),c.push({key:s,element:r,children:[...r.children??[],...Object.values(r.slots??{}).flat()],childIndex:0,childVersions:[]});continue}let l=r[t.key],u=l&&V(l.own,t.element)&&V(l.children,t.childVersions)?l.version:++n.current;o.delete(t.key),i[t.key]={own:Ze(t.element),children:t.childVersions,version:u},a[t.key]=u,c.pop()}}return t.current=i,a}var et=I.memo(function({Component:e,element:t,slots:n,emit:r,on:i,bindings:a,loading:o,children:s}){return(0,L.jsx)(e,{element:t,slots:n,emit:r,on:i,bindings:a,loading:o,children:s})},(e,t)=>e.Component===t.Component&&e.signature===t.signature&&e.execute===t.execute&&e.actionContext?.item===t.actionContext?.item&&e.actionContext?.index===t.actionContext?.index&&e.actionContext?.basePath===t.actionContext?.basePath&&e.functions===t.functions&&e.directives===t.directives&&e.element.props===t.element.props&&e.bindings===t.bindings&&e.loading===t.loading);function tt(){return I.useSyncExternalStore(D,ce,()=>!1)}function nt({element:e,elementKey:t,spec:n,registry:r,loading:i,fallback:a,signatures:o}){let s=tt(),c=Be(),{ctx:l}=Ee(),{execute:u}=Ie(),{getSnapshot:d,state:f}=R(),p=Ke(),m=Je(),h=(0,I.useMemo)(()=>{let e=c?{...l,repeatItem:c.item,repeatIndex:c.index,repeatBasePath:c.basePath}:{...l};return e.functions=p,e.directives=m,e},[l,c,p,m]),g=e.repeat!==void 0&&c==null?le(e.visible):{container:e.visible,itemFilter:void 0},_=g.itemFilter,v=g.container===void 0||y(g.container,h),b=e.on,x=(0,I.useCallback)(async e=>{let t=b?.[e];if(!t)return;let n=Array.isArray(t)?t:[t];for(let e of n){if(!e.params){await u(e);continue}let t={...h,stateModel:d()},n={};for(let[r,i]of Object.entries(e.params))n[r]=ae(i,t);await u({...e,params:n})}},[b,u,h,d]),S=(0,I.useCallback)(e=>{let t=b?.[e];return t?{emit:()=>x(e),shouldPreventDefault:(Array.isArray(t)?t:[t]).some(e=>e.preventDefault),bound:!0}:{emit:()=>{},shouldPreventDefault:!1,bound:!1}},[b,x]),C=e.watch,w=(0,I.useRef)(null),T=(0,I.useRef)(void 0),ee=(0,I.useRef)(void 0),E=(0,I.useRef)({}),D=(0,I.useMemo)(()=>{if(!C)return;let e={};for(let t of Object.keys(C))e[t]=P(f,t);let t=T.current;if(t){let n=Object.keys(e);if(n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n]))return t}return T.current=e,e},[C,f]);if((0,I.useEffect)(()=>{if(!C||!D)return;let e=Object.keys(C);if(e.length===0)return;let t=w.current;if(w.current=D,t===null)return;let n=!1;return(async()=>{for(let r of e){if(n)break;if(D[r]!==t[r]){let e=C[r];if(!e)continue;let t=Array.isArray(e)?e:[e];for(let e of t){if(n)break;if(!e.params){if(await u(e),n)break;continue}let t={...h,stateModel:d()},r={};for(let[n,i]of Object.entries(e.params))r[n]=ae(i,t);if(await u({...e,params:r}),n)break}}}})().catch(console.error),()=>{n=!0}},[C,D,u,h,d]),!v)return null;let O=e.props??He,ne=Ye(se(O,h),ee),k=Qe(E.current,te(O,h));E.current=k;let A=k===e.props?e:{...e,props:k},j=r[A.type]??a;if(!j)return console.warn(`No renderer for component type: ${A.type}`),null;let M=Ve.get(r)?.[A.type];if(A.slots&&M?.slots){let e=new Set(M.slots);for(let t of Object.keys(A.slots))t==="default"?console.warn(`[json-render] Component "${A.type}" uses slots.default. Use "children" for default slot content.`):e.has(t)||console.warn(`[json-render] Unknown slot "${t}" on component "${A.type}". Available slots: ${M.slots.join(`, `)}`)}let N=(e,t)=>e.map(e=>{let s=n.elements[e];if(!s){if(!i){let n=t?`in slot "${t}" of "${A.type}"`:`as child of "${A.type}"`;console.warn(`[json-render] Missing element "${e}" referenced ${n}. This element will not render.`)}return null}return(0,L.jsx)(H,{element:s,elementKey:e,spec:n,registry:r,loading:i,fallback:a,signatures:o},e)}),re=A.repeat?(0,L.jsx)(rt,{element:A,spec:n,registry:r,loading:i,fallback:a,itemFilter:_,signatures:o}):A.children?N(A.children):void 0,ie=A.slots?Object.fromEntries(Object.entries(A.slots).map(([e,t])=>[e,N(t,e)])):void 0,F=(0,L.jsx)(et,{Component:j,signature:o[t??``],execute:u,actionContext:c,functions:p,directives:m,element:A,slots:ie,emit:x,on:S,bindings:ne,loading:i,children:re}),oe=s&&t?(0,L.jsx)(`span`,{"data-jr-key":t,style:{display:`contents`},children:F}):F;return(0,L.jsx)(Ue,{elementType:A.type,resetKey:o[t??``],children:oe})}var H=I.memo(function(e){return(0,L.jsx)(nt,{...e})},(e,t)=>e.elementKey===t.elementKey&&e.signatures[e.elementKey??``]===t.signatures[t.elementKey??``]&&e.registry===t.registry&&e.loading===t.loading&&e.fallback===t.fallback);function rt({element:e,spec:t,registry:n,loading:r,fallback:i,signatures:a,itemFilter:o}){let{state:s}=R(),{ctx:c}=Ee(),l=Be(),u=e.repeat,d=k(u.statePath,l?.basePath);if(d===void 0)return console.warn(`[json-render] $item in repeat.statePath used outside of a repeat scope`),null;let f=(P(s,d)??[]).map((e,t)=>({itemValue:e,index:t})).filter(({itemValue:e,index:t})=>o===void 0||y(o,{...c,repeatItem:e,repeatIndex:t}));return(0,L.jsx)(L.Fragment,{children:f.map(({itemValue:o,index:s})=>{let c=u.key&&typeof o==`object`&&o?String(o[u.key]??s):String(s);return(0,L.jsx)(ze,{item:o,index:s,basePath:j(d,s),children:e.children?.map(o=>{let s=t.elements[o];return s?(0,L.jsx)(H,{element:s,elementKey:o,spec:t,registry:n,loading:r,fallback:i,signatures:a},o):(r||console.warn(`[json-render] Missing element "${o}" referenced as child of "${e.type}" (repeat). This element will not render.`),null)})},c)})})}function it({spec:e,registry:t,loading:n,fallback:r}){let i=$e(e);if(!e||!e.root)return null;let a=e.elements[e.root];return a?(0,L.jsx)(H,{element:a,elementKey:e.root,spec:e,registry:t,loading:n,fallback:r,signatures:i}):null}function at({registry:e,store:t,initialState:n,handlers:r,navigate:i,validationFunctions:a,functions:o,directives:s,onStateChange:c,children:l}){let u=(0,I.useMemo)(()=>s?S(s):void 0,[s]);return(0,L.jsx)(Ce,{store:t,initialState:n,onStateChange:c,children:(0,L.jsx)(Te,{children:(0,L.jsx)(je,{customFunctions:a,children:(0,L.jsx)(Fe,{handlers:r,navigate:i,children:(0,L.jsx)(Ge.Provider,{value:o??We,children:(0,L.jsxs)(qe.Provider,{value:u,children:[l,(0,L.jsx)(ot,{})]})})})})})})}function ot(){let{pendingConfirmation:e,confirm:t,cancel:n}=Ie();return e?.action.confirm?(0,L.jsx)(Le,{confirm:e.action.confirm,onConfirm:t,onCancel:n}):null}function st(e,t){let n={};if(t.components)for(let[e,r]of Object.entries(t.components))n[e]=({element:e,children:t,slots:n,emit:i,on:a,bindings:o,loading:s})=>r({props:e.props,children:t,slots:n,emit:i,on:a,bindings:o,loading:s});let r=e.data.components;r&&Ve.set(n,r);let i=t.actions?Object.entries(t.actions):[];return{registry:n,handlers:(e,t)=>{let n={};for(let[r,a]of i)n[r]=async n=>{let r=e()??(()=>void 0),i=t();await a(n,r,i)};return n},executeAction:async(e,t,n,r={})=>{let a=i.find(([t])=>t===e);a?await a[1](t,n,r):console.warn(`Unknown action: ${e}`)}}}var ct={"task.delete":{title:`Delete this task?`,description:`This permanently deletes the task. It cannot be undone.`,label:`Delete`,destructive:!0},"job.run":{title:`Run this job now?`,description:`The job starts immediately with its saved command and settings.`,label:`Run now`,destructive:!1}},lt=(0,I.createContext)(null);function U(){let e=(0,I.useContext)(lt);if(!e)throw Error(`useChatUiAction must be used inside ChatUiActionProvider`);return e}function ut(){let{outcome:e}=U();return e?(0,L.jsx)(`p`,{role:e.tone===`error`?`alert`:`status`,"data-testid":`chat-ui-action-result`,className:`mt-1.5 text-xs ${e.tone===`error`?`text-error`:`text-on-surface-variant`}`,children:e.text}):null}function dt({children:e}){let t=r(),n=x(),i=b(),a=C(),o=fe(),s=pe(),[c,l]=(0,I.useState)(new Set),[u,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(null),m=(0,I.useRef)(null),h=(0,I.useCallback)((e,t)=>new Promise(n=>{m.current?.(!1),m.current=n,p({name:e,id:t})}),[]),g=e=>{m.current?.(e),m.current=null,p(null)},_=(0,I.useCallback)(async(e,r)=>{let c=r.id;switch(e){case`task.update`:{let{id:e,...t}=r;return await n.mutateAsync({id:c,...t}),`Task updated`}case`task.comment`:return await a.mutateAsync({id:c,content:r.content}),`Comment added`;case`task.delete`:return await i.mutateAsync(c),await t.invalidateQueries({queryKey:[`task`,c]}),`Task deleted`;case`job.run`:return await o.mutateAsync(c),await t.invalidateQueries({queryKey:[`job`,c]}),`Job run started`;case`job.setEnabled`:return await s.mutateAsync({id:c,enabled:r.enabled}),r.enabled?`Job enabled`:`Job disabled`}},[t,n,a,i,o,s]),v=(0,I.useCallback)(async(e,t)=>{let n=w.data.actions[e];if(!n){d({tone:`error`,text:`Unknown action: ${e}`});return}let r=e,i=n.params.safeParse(t??{});if(!i.success){d({tone:`error`,text:`Invalid ${r} parameters`});return}let a=i.data;if(T.has(r)&&!await h(r,a.id))return;let o=`${r}:${a.id}`;l(e=>new Set(e).add(o)),d(null);try{d({tone:`success`,text:await _(r,a)})}catch(e){d({tone:`error`,text:e instanceof Error?e.message:String(e)})}finally{l(e=>{let t=new Set(e);return t.delete(o),t})}},[h,_]),y=(0,I.useMemo)(()=>({run:v,pending:c,outcome:u}),[v,c,u]),S=f?ct[f.name]:void 0;return(0,L.jsxs)(lt.Provider,{value:y,children:[e,(0,L.jsx)(ut,{}),(0,L.jsx)(de,{open:!!f,title:S?.title??`Confirm action`,description:f&&S?`${S.description} Target ${f.name===`task.delete`?`task`:`job`}: ${f.id}.`:`This runs as you through the ORC API.`,confirmLabel:S?.label??`Confirm`,variant:S?.destructive===!1?`warning`:`destructive`,onConfirm:()=>g(!0),onCancel:()=>g(!1)})]})}function ft(){let{run:e}=U();return(0,I.useMemo)(()=>Object.fromEntries(Object.keys(w.data.actions).map(t=>[t,n=>e(t,n)])),[e])}var pt={neutral:`bg-muted-foreground`,progress:`bg-progress`,success:`bg-secondary`,warning:`bg-tertiary`,error:`bg-error`};function mt(e,t){if(!e.startsWith(`/`))return e;let n=new URLSearchParams(t);if(n.get(`chat`)!==`open`)return e;let r=new URL(e,`http://orc.local`),i=r.searchParams;i.set(`chat`,`open`);let a=n.get(`chatThread`);return a&&i.set(`chatThread`,a),`${r.pathname}?${i}${r.hash}`}function W({href:e,children:t,className:n,testId:r}){let i=s(),a=c(`inline-flex min-w-0 items-center text-on-surface underline decoration-outline-variant underline-offset-4 hover:decoration-current focus-visible:outline-2 focus-visible:outline-focus`,n);return e.startsWith(`/`)?(0,L.jsx)(o,{"data-testid":r,to:mt(e,i.search),className:a,children:t}):(0,L.jsx)(`a`,{"data-testid":r,href:e,target:`_blank`,rel:`noopener noreferrer`,className:a,children:t})}function ht({tone:e,className:t}){return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:c(`size-1.5 shrink-0 rounded-full`,pt[e],t)})}function G({children:e,className:t,testId:n}){return(0,L.jsx)(`section`,{"data-testid":n,className:c(`min-w-0 rounded-lg border border-outline-variant px-3 py-2.5`,t),children:e})}function K({children:e}){return(0,L.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-on-surface-variant`,children:e})}function q({label:e}){return(0,L.jsx)(`div`,{role:`status`,"aria-label":e,className:`h-14 animate-pulse rounded-lg border border-outline-variant bg-surface`})}function J({label:e,error:t}){let n=t instanceof Error?t.message:String(t);return(0,L.jsxs)(`div`,{role:`alert`,"data-testid":`chat-ui-entity-error`,className:`rounded-lg border border-outline-variant px-3 py-2 text-xs text-on-surface-variant`,children:[(0,L.jsx)(`span`,{className:`text-error`,children:e}),` `,n]})}function gt({children:e,testId:t}){return(0,L.jsx)(`ul`,{"data-testid":t,className:`min-w-0 divide-y divide-outline-variant`,children:e})}function _t({children:e}){return(0,L.jsx)(`p`,{className:`py-2 text-xs text-on-surface-variant`,children:e})}function vt({value:e,label:t}){let n=Math.max(0,Math.min(100,e));return(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":n,"aria-label":t??`Progress`,className:`h-1 flex-1 overflow-hidden rounded-full bg-selected`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full bg-progress`,style:{width:`${n}%`}})}),(0,L.jsxs)(`span`,{className:`shrink-0 text-xs tabular-nums text-on-surface-variant`,children:[t?`${t} · `:``,n,`%`]})]})}function Y(e){if(e==null)return`—`;let t=new Date(typeof e==`number`?e*1e3:e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function X({title:e,heading:t,testId:n,canExpand:r,children:i}){let[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(!1),l=(0,I.useRef)(null);return(0,L.jsxs)(v,{open:s,onOpenChange:c,children:[(0,L.jsxs)(G,{testId:n,className:`space-y-2`,children:[(0,L.jsxs)(`header`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`min-w-0 flex-1 text-sm font-medium`,children:t??e}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,"data-testid":`chat-ui-expand`,"aria-label":`${a?`Collapse`:`Expand`} ${e}`,"aria-expanded":a,className:`min-h-11 shrink-0 rounded px-2 text-xs text-muted-foreground hover:bg-surface focus-visible:outline-2 focus-visible:outline-focus sm:min-h-8`,onClick:()=>o(e=>!e),children:a?`Collapse`:`Expand`}),(0,L.jsx)(_,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,"data-testid":`chat-ui-fullscreen`,"aria-label":`View ${e} fullscreen`,className:`flex size-11 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-surface focus-visible:outline-2 focus-visible:outline-focus sm:size-8`,children:(0,L.jsx)(d,{size:15,"aria-hidden":`true`})})})]})]}),!s&&i(a)]}),(0,L.jsxs)(m,{ref:l,"data-testid":`chat-ui-fullscreen-dialog`,className:`left-0 flex w-screen max-w-none max-h-none translate-x-0 translate-y-0 flex-col gap-3 overflow-hidden rounded-none p-4 sm:rounded-none sm:p-6 [&>button]:size-11`,style:{top:`var(--app-top, 0px)`,height:`var(--app-height, 100dvh)`},onOpenAutoFocus:e=>{e.preventDefault(),l.current?.focus()},onClick:e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`a`)?.getAttribute(`href`);t?.startsWith(`/`)&&!t.startsWith(`//`)&&c(!1)},children:[(0,L.jsx)(h,{className:`min-w-0 pr-12 break-words`,children:t??e}),(0,L.jsx)(g,{className:`sr-only`,children:`Full current content. Press Escape or Close to return to chat.`}),(0,L.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1 overflow-auto overscroll-contain`,"data-testid":`chat-ui-fullscreen-content`,children:s&&i(!0)}),s&&(0,L.jsx)(ut,{})]})]})}var yt=(0,I.lazy)(()=>f(()=>import(`./ScratchpadDiagramPreview-C76RVMjL.js`),__vite__mapDeps([0,1,2,3,4,5,6,7]))),bt=`default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: blob:; font-src data:; connect-src 'none'; form-action 'none'; base-uri 'none'`;function xt(e){let t=`<meta http-equiv="Content-Security-Policy" content="${bt}">`,n=/^\s*<!doctype[^>]*>/i.exec(e);return n?`${n[0]}${t}${e.slice(n[0].length)}`:`${t}${e}`}function St({pad:e,expanded:t}){return e.kind===`html`?(0,L.jsx)(`iframe`,{"data-testid":`chat-ui-scratchpad-html`,title:`${e.title} preview`,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`,srcDoc:xt(e.content),className:`w-full border border-outline-variant bg-white ${t?`h-[70vh] min-h-80`:`h-72`}`}):e.kind===`diagram`?(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(`p`,{role:`status`,children:`Loading diagram…`}),children:(0,L.jsx)(yt,{content:e.content,title:e.title,expanded:t},e.content)}):t?(0,L.jsx)(p,{readable:!0,children:e.content}):(0,L.jsx)(`p`,{className:`line-clamp-4 whitespace-pre-wrap break-words text-xs`,children:e.content})}var Ct=[`todo`,`queued`,`doing`,`review`,`changes_requested`,`blocked`,`done`,`paused`,`cancelled`],wt=10,Z=`text-sm font-medium no-underline hover:underline`,Q=e=>e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g,` `);function Tt({id:e}){let{data:t}=A(e);return e?(0,L.jsx)(W,{href:`/projects/${e}`,children:t?.name??`Project`}):null}function Et({id:e}){let{data:t,isLoading:n,error:r}=N(e),{run:i,pending:a}=U();if(n)return(0,L.jsx)(q,{label:`Loading task`});if(r||!t)return(0,L.jsx)(J,{label:`Task unavailable.`,error:r??`Not found`});let o=a.has(`task.update:${e}`)||a.has(`task.delete:${e}`);return(0,L.jsx)(X,{testId:`chat-ui-task`,title:t.title,heading:(0,L.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,L.jsx)(W,{href:`/tasks/${t.id}`,className:c(Z,`break-words`),children:t.title}),(0,L.jsx)(he,{priority:t.priority,className:`shrink-0`})]}),canExpand:!!(t.body&&(t.body.length>120||t.body.split(`
3
3
  `).length>2)),children:n=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(K,{children:[(0,L.jsx)(ge,{status:t.status,className:`px-0`}),(0,L.jsx)(Tt,{id:t.project_id}),(0,L.jsxs)(`span`,{children:[`Updated `,ye(t.updated_at)]})]}),t.progress>0&&(0,L.jsx)(vt,{value:t.progress}),t.body&&(0,L.jsx)(`p`,{className:c(`whitespace-pre-wrap break-words text-on-surface-variant`,n?`text-base leading-relaxed`:`line-clamp-2 text-xs`),children:t.body}),(0,L.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-on-surface-variant`,children:[`Status`,(0,L.jsx)(`select`,{"data-testid":`chat-ui-task-status`,"aria-label":`Task status`,className:`form-control form-control-single w-auto min-w-36`,value:t.status,disabled:o,onChange:t=>i(`task.update`,{id:e,status:t.target.value}),children:Ct.map(e=>(0,L.jsx)(`option`,{value:e,children:Q(e)},e))})]})]})})}function Dt({task:e}){return(0,L.jsxs)(`li`,{className:`flex min-w-0 items-center justify-between gap-3 py-2`,children:[(0,L.jsx)(W,{href:`/tasks/${e.id}`,className:`min-w-0 truncate text-sm no-underline hover:underline`,children:(0,L.jsx)(`span`,{className:`truncate`,children:e.title})}),(0,L.jsx)(ge,{status:e.status,className:`shrink-0 px-0`})]})}function Ot({projectId:e,status:t,limit:n=wt}){let r={project_id:e,status:t,limit:n},{data:a,isLoading:o,error:s}=i({queryKey:[`tasks`,`chat-ui`,r],queryFn:()=>u.tasks.list(r)});return o?(0,L.jsx)(q,{label:`Loading tasks`}):s||!a?(0,L.jsx)(J,{label:`Tasks unavailable.`,error:s}):(0,L.jsxs)(G,{testId:`chat-ui-task-list`,children:[a.tasks.length?(0,L.jsx)(gt,{children:a.tasks.map(e=>(0,L.jsx)(Dt,{task:e},e.id))}):(0,L.jsx)(_t,{children:`No matching tasks.`}),a.total>a.tasks.length&&(0,L.jsxs)(`p`,{className:`pt-1 text-xs text-on-surface-variant`,children:[a.tasks.length,` of `,a.total,` ·`,` `,(0,L.jsx)(W,{href:e?`/projects/${e}`:`/tasks`,children:`View all`})]})]})}function kt(e){return e.trigger_type===`cron`&&e.cron_expr?e.cron_expr:Q(e.trigger_type)}function At({id:e}){let{data:t,isLoading:n,error:r}=me(e),{run:i,pending:a}=U();return n?(0,L.jsx)(q,{label:`Loading job`}):r||!t?(0,L.jsx)(J,{label:`Job unavailable.`,error:r??`Not found`}):(0,L.jsxs)(G,{testId:`chat-ui-job`,className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[(0,L.jsx)(W,{href:`/jobs/${t.id}`,className:c(Z,`break-words`),children:t.name}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-on-surface-variant`,children:[(0,L.jsx)(ht,{tone:t.enabled?`success`:`neutral`}),t.enabled?`Enabled`:`Disabled`]})]}),t.description&&(0,L.jsx)(`p`,{className:`text-xs text-on-surface-variant`,children:t.description}),(0,L.jsxs)(K,{children:[(0,L.jsx)(`span`,{className:`font-mono`,children:kt(t)}),(0,L.jsxs)(`span`,{children:[`Last `,Y(t.last_run_at)]}),t.enabled&&t.next_run_at&&(0,L.jsxs)(`span`,{children:[`Next `,Y(t.next_run_at)]}),(0,L.jsxs)(`span`,{children:[t.run_count,` runs`]}),(0,L.jsx)(Tt,{id:t.project_id})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(l,{"data-testid":`chat-ui-job-run`,size:`sm`,variant:`outline`,disabled:a.has(`job.run:${e}`),onClick:()=>i(`job.run`,{id:e}),children:`Run now`}),(0,L.jsx)(l,{"data-testid":`chat-ui-job-toggle`,size:`sm`,variant:`ghost`,disabled:a.has(`job.setEnabled:${e}`),onClick:()=>i(`job.setEnabled`,{id:e,enabled:!t.enabled}),children:t.enabled?`Disable`:`Enable`})]})]})}function jt({projectId:e,limit:t=wt}){let n={project_id:e,limit:t},{data:r,isLoading:a,error:o}=i({queryKey:[`sessions`,`live`,`chat-ui`,n],queryFn:()=>u.sessions.live(n)});if(a)return(0,L.jsx)(q,{label:`Loading sessions`});if(o||!r)return(0,L.jsx)(J,{label:`Sessions unavailable.`,error:o});let s=r.sessions.length>3||r.sessions.some(e=>(e.summary?.length??0)>100);return(0,L.jsx)(X,{testId:`chat-ui-session-list`,title:`Sessions`,canExpand:s,children:e=>(0,L.jsxs)(L.Fragment,{children:[r.sessions.length?(0,L.jsx)(gt,{children:(e?r.sessions:r.sessions.slice(0,3)).map(t=>{let n=be[t.status];return(0,L.jsxs)(`li`,{className:`flex min-w-0 flex-col gap-1 py-2`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,L.jsx)(W,{href:`/sessions?session=${encodeURIComponent(t.id)}`,className:`min-w-0 text-sm no-underline hover:underline`,children:(0,L.jsx)(`span`,{className:e?`break-words`:`truncate`,children:t.name??t.agent})}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-on-surface-variant`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:c(`size-1.5 rounded-full`,n.dot)}),n.label]})]}),t.summary&&(0,L.jsx)(`p`,{className:c(`whitespace-pre-wrap break-words text-on-surface-variant`,e?`text-sm leading-relaxed`:`line-clamp-2 text-xs`),children:t.summary}),(0,L.jsxs)(K,{children:[(0,L.jsx)(`span`,{children:t.agent}),(0,L.jsx)(`span`,{children:ye(t.last_activity_at)}),t.task&&(0,L.jsx)(W,{href:`/tasks/${t.task.id}`,children:t.task.title})]})]},t.id)})}):(0,L.jsx)(_t,{children:`No sessions yet.`}),!e&&r.sessions.length>3&&(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`3 of `,r.sessions.length,` loaded sessions`]})]})})}function Mt(e){return e.length>240||e.split(`
4
4
  `).length>4}function Nt({id:e}){let{data:t,isLoading:n,error:r}=ve(e);return n?(0,L.jsx)(q,{label:`Loading scratchpad`}):r||!t?(0,L.jsx)(J,{label:`Scratchpad unavailable.`,error:r??`Not found`}):(0,L.jsx)(X,{testId:`chat-ui-scratchpad`,title:t.title,heading:(0,L.jsx)(W,{href:_e(t.id),className:c(Z,`break-words`),children:t.title}),canExpand:t.kind!==`doc`||Mt(t.content),children:e=>(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,L.jsx)(`div`,{"data-testid":`chat-ui-scratchpad-content`,children:(0,L.jsx)(St,{pad:t,expanded:e})}),(0,L.jsxs)(K,{children:[(0,L.jsx)(`span`,{children:Q(t.kind)}),t.tags.map(e=>(0,L.jsxs)(`span`,{children:[`#`,e]},e)),(0,L.jsxs)(`span`,{children:[`Updated `,Y(t.updated_at)]})]})]})})}var Pt={sm:`gap-1.5`,md:`gap-3`,lg:`gap-5`},Ft={primary:`default`,secondary:`outline`,destructive:`destructive`},{registry:$}=st(w,{components:{Stack:({props:e,children:t})=>(0,L.jsx)(`div`,{className:c(`flex min-w-0`,e.direction===`horizontal`?`flex-row flex-wrap items-center`:`flex-col`,Pt[e.gap??`md`]),children:t}),Button:({props:e,emit:t,loading:n})=>(0,L.jsx)(l,{type:`button`,size:`sm`,className:`w-fit`,"data-testid":`chat-ui-button`,variant:Ft[e.variant??`secondary`],disabled:n,onClick:()=>t(`press`),children:e.label}),Task:({props:e})=>(0,L.jsx)(Et,{id:e.id}),TaskList:({props:e})=>(0,L.jsx)(Ot,{projectId:e.projectId,status:e.status,limit:e.limit}),Job:({props:e})=>(0,L.jsx)(At,{id:e.id}),SessionList:({props:e})=>(0,L.jsx)(jt,{projectId:e.projectId,limit:e.limit}),Scratchpad:({props:e})=>(0,L.jsx)(Nt,{id:e.id})}});function It({spec:e}){let t=ft(),n=a();return(0,L.jsx)(at,{registry:$,handlers:t,navigate:n,initialState:e.state,children:(0,L.jsx)(it,{spec:e,registry:$})})}function Lt({source:e}){let t=(0,I.useMemo)(()=>ee(e),[e]);return t.ok?(0,L.jsx)(`div`,{"data-testid":`chat-ui-block`,className:`my-2 min-w-0`,children:(0,L.jsx)(dt,{children:(0,L.jsx)(It,{spec:t.spec})})}):(0,L.jsx)(ue,{source:e,error:t.error})}export{Lt as default};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{t}from"./button-C91mbQEU.js";import{a as n,i as r,n as i,o as a,r as o,t as s}from"./dialog-C7wt3DcD.js";var c=e();function l({open:e,onConfirm:l,onCancel:u,title:d,description:f,confirmLabel:p=`Delete`,variant:m=`destructive`,isPending:h}){return(0,c.jsx)(s,{open:e,onOpenChange:e=>!e&&u(),children:(0,c.jsxs)(i,{className:`bg-surface border-surface-highest max-w-sm`,children:[(0,c.jsxs)(n,{children:[(0,c.jsx)(a,{className:`font-headline text-sm text-on-surface`,children:d}),(0,c.jsx)(o,{className:`font-body text-xs text-outline mt-2`,children:f})]}),(0,c.jsxs)(r,{className:`mt-4`,children:[(0,c.jsx)(t,{"data-testid":`confirm-dialog-cancel`,type:`button`,variant:`ghost`,size:`sm`,onClick:u,className:`font-label text-xs text-outline`,children:`Cancel`}),(0,c.jsx)(t,{"data-testid":`confirm-dialog-confirm`,variant:`ghost`,type:`button`,size:`sm`,onClick:l,disabled:h,className:m===`destructive`?`font-label text-xs bg-error/15 text-error border border-error/30 hover:bg-error/25`:`font-label text-xs bg-tertiary/15 text-tertiary border border-tertiary/30 hover:bg-tertiary/25`,children:h?`...`:p})]})]})})}export{l as t};
1
+ import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{t}from"./button-C91mbQEU.js";import{a as n,i as r,n as i,o as a,r as o,t as s}from"./dialog-D86vkhdt.js";var c=e();function l({open:e,onConfirm:l,onCancel:u,title:d,description:f,confirmLabel:p=`Delete`,variant:m=`destructive`,isPending:h}){return(0,c.jsx)(s,{open:e,onOpenChange:e=>!e&&u(),children:(0,c.jsxs)(i,{className:`bg-surface border-surface-highest max-w-sm`,children:[(0,c.jsxs)(n,{children:[(0,c.jsx)(a,{className:`font-headline text-sm text-on-surface`,children:d}),(0,c.jsx)(o,{className:`font-body text-xs text-outline mt-2`,children:f})]}),(0,c.jsxs)(r,{className:`mt-4`,children:[(0,c.jsx)(t,{"data-testid":`confirm-dialog-cancel`,type:`button`,variant:`ghost`,size:`sm`,onClick:u,className:`font-label text-xs text-outline`,children:`Cancel`}),(0,c.jsx)(t,{"data-testid":`confirm-dialog-confirm`,variant:`ghost`,type:`button`,size:`sm`,onClick:l,disabled:h,className:m===`destructive`?`font-label text-xs bg-error/15 text-error border border-error/30 hover:bg-error/25`:`font-label text-xs bg-tertiary/15 text-tertiary border border-tertiary/30 hover:bg-tertiary/25`,children:h?`...`:p})]})]})})}export{l as t};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{f as t}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as n}from"./button-C91mbQEU.js";import{M as r,S as i,Tt as a,U as o,vt as s}from"./index-C0yeM676.js";import{o as c}from"./useJobs-lhzWAkUN.js";import{t as l}from"./PriorityBadge-D263N3pH.js";import{t as u}from"./StatusBadge-BUGpPpcH.js";import{a as d,t as f}from"./live-sessions-D07BClP7.js";import{t as p}from"./ErrorState-DprXzfow.js";import{t as m}from"./ViewHeader-BajY1vkx.js";import{n as h}from"./useSessions-gfliXBHJ.js";import{a as g,i as _,n as v,o as y,r as b,t as x}from"./table-Q26Vm3R3.js";import{t as S}from"./useProjectScope-DtEj9j-P.js";import{t as C}from"./ResumeActions-Dbv5ctO7.js";import{r as w}from"./useMemories-76m7jnqk.js";var T=e();function E(e,t){return e.isLoading?`…`:e.error?`—`:t}function D({projectId:e}){let D=t(),O=S(e),k=a(`sm`),A=e=>{let t=new URL(e,window.location.origin);t.searchParams.set(`project`,O),D({pathname:t.pathname,search:t.search,hash:t.hash})},j=O===`all`?void 0:{project_id:O},M=r(j),{data:N,isLoading:P}=M,F=c(j),{data:I}=F,L=w({project_id:j?.project_id,limit:1},{enabled:O!==`unassigned`}),R=O===`unassigned`?0:L.data?.total??0,{data:z}=s(),B=h(!0,j?.project_id),V=(B.data??[]).filter(e=>O===`all`||(O===`unassigned`?e.project_id===null:e.project_id===O)),H=O===`unassigned`?(I??[]).filter(e=>e.project_id===null):I??[],U=O===`unassigned`?(N??[]).filter(e=>e.project_id===null):N??[],W=U.reduce((e,t)=>(e[t.status]=(e[t.status]??0)+1,e),{}),G=[...U].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).slice(0,8),K=H.filter(e=>e.enabled),q=O===`all`?`All Projects`:O===`unassigned`?`Unassigned`:z?.find(e=>e.id===O)?.name??``,J=[{label:`Doing`,value:E(M,W.doing??0),sub:`in progress`,path:`/tasks?view=table&status=doing`},{label:`Review`,value:E(M,W.review??0),sub:`awaiting review`,path:`/tasks?view=table&status=review`},{label:`Blocked`,value:E(M,W.blocked??0),sub:`needs attention`,path:`/tasks?view=table&status=blocked`},{label:`Todo`,value:E(M,(W.todo??0)+(W.queued??0)),sub:`pending`,path:`/tasks?view=board`},{label:`Done`,value:E(M,W.done??0),sub:`completed`,path:`/tasks?view=table&status=done`}],Y=[{label:`Active jobs`,value:E(F,K.length),sub:`of ${H.length} total`,path:`/jobs`},{label:`Memories`,value:E(L,R),sub:`in this scope`,path:i},{label:`Projects`,value:(z??[]).filter(e=>e.status===`active`).length,sub:`active across workspace`,path:`/projects`}];return(0,T.jsxs)(`div`,{"data-activity-preview":!0,"data-testid":`activity-preview`,className:`activity-preview`,children:[(0,T.jsx)(m,{title:`Activity`,meta:q||`All projects`,action:(0,T.jsx)(n,{onClick:()=>A(`/tasks`),children:`View tasks`})}),[M,F,L,B].some(e=>e.isLoading)&&(0,T.jsx)(`p`,{role:`status`,className:`activity-muted mb-4`,children:`Loading activity…`}),[{name:`Tasks`,query:M},{name:`Jobs`,query:F},{name:`Memories`,query:L},{name:`Sessions`,query:B}].filter(({query:e})=>e.error).map(({name:e,query:t})=>(0,T.jsx)(p,{message:`${e}: ${t.error?.message??`Could not load activity`}`,onRetry:()=>t.refetch()},e)),(0,T.jsx)(`section`,{className:`activity-metrics`,"aria-label":`Task summary`,children:J.map(e=>(0,T.jsxs)(`button`,{type:`button`,"data-testid":`stat-card`,"data-stat-label":e.label,className:`activity-metric`,onClick:()=>A(e.path),children:[(0,T.jsx)(`span`,{className:`activity-metric-label`,children:e.label}),(0,T.jsx)(`span`,{"data-testid":`stat-card-value`,className:`activity-metric-value`,children:e.value}),(0,T.jsx)(`span`,{className:`activity-metric-sub`,children:e.sub})]},e.label))}),(0,T.jsx)(`section`,{className:`activity-resources`,"aria-label":`Workspace summary`,children:Y.map(e=>(0,T.jsxs)(`button`,{type:`button`,"data-testid":`stat-card`,"data-stat-label":e.label,onClick:()=>A(e.path),children:[(0,T.jsx)(`span`,{children:e.label}),(0,T.jsx)(`span`,{"data-testid":`stat-card-value`,className:`activity-resource-value`,children:e.value}),(0,T.jsx)(`span`,{className:`activity-resource-sub`,children:e.sub})]},e.label))}),(0,T.jsxs)(`section`,{className:`activity-section`,children:[(0,T.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,T.jsx)(`h2`,{children:`Recent tasks`}),(0,T.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>A(`/tasks`),children:`View all`})]}),P?(0,T.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,T.jsx)(o,{className:`h-10 w-full`},e))}):G.length===0?(0,T.jsx)(`p`,{className:`activity-empty`,children:`No tasks`}):k?(0,T.jsxs)(x,{className:`activity-task-table`,children:[(0,T.jsx)(g,{children:(0,T.jsxs)(y,{children:[(0,T.jsx)(_,{children:`Task`}),(0,T.jsx)(_,{className:`w-36`,children:`Status`}),(0,T.jsx)(_,{className:`w-28`,children:`Priority`}),(0,T.jsx)(_,{className:`w-28`,children:`Updated`})]})}),(0,T.jsx)(v,{children:G.map(e=>(0,T.jsxs)(y,{onClick:()=>A(`/tasks/${e.id}`),children:[(0,T.jsx)(b,{children:(0,T.jsx)(`button`,{type:`button`,className:`activity-task-title`,onClick:t=>{t.stopPropagation(),A(`/tasks/${e.id}`)},children:e.title})}),(0,T.jsx)(b,{children:(0,T.jsx)(`span`,{className:`activity-status`,"data-status":e.status,children:(0,T.jsx)(u,{status:e.status})})}),(0,T.jsx)(b,{children:(0,T.jsx)(`span`,{className:`activity-priority`,children:(0,T.jsx)(l,{priority:e.priority})})}),(0,T.jsx)(b,{className:`activity-muted`,children:new Date(e.updated_at).toLocaleDateString()})]},e.id))})]}):(0,T.jsx)(`div`,{className:`activity-task-list`,children:G.map(e=>(0,T.jsxs)(`article`,{className:`activity-task-mobile`,children:[(0,T.jsx)(`button`,{type:`button`,className:`activity-task-title`,onClick:()=>A(`/tasks/${e.id}`),children:e.title}),(0,T.jsxs)(`div`,{className:`activity-task-meta`,children:[(0,T.jsx)(`span`,{className:`activity-status`,"data-status":e.status,children:(0,T.jsx)(u,{status:e.status})}),(0,T.jsx)(`span`,{className:`activity-priority`,children:(0,T.jsx)(l,{priority:e.priority})}),(0,T.jsx)(`span`,{children:new Date(e.updated_at).toLocaleDateString()})]})]},e.id))})]}),(0,T.jsxs)(`div`,{className:`activity-secondary`,children:[K.length>0&&(0,T.jsxs)(`section`,{className:`activity-section`,children:[(0,T.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,T.jsx)(`h2`,{children:`Active jobs`}),(0,T.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>A(`/jobs`),children:`View all`})]}),(0,T.jsx)(`div`,{className:`activity-row-list`,children:K.slice(0,5).map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`activity-row`,onClick:()=>A(`/jobs/${e.id}`),children:[(0,T.jsxs)(`span`,{className:`activity-row-heading`,children:[(0,T.jsx)(`span`,{children:e.name}),(0,T.jsx)(`span`,{className:`activity-muted`,children:e.trigger_type})]}),e.last_run_at&&(0,T.jsxs)(`span`,{className:`activity-row-description`,children:[`Last run `,new Date(e.last_run_at).toLocaleString()]})]},e.id))})]}),V.length>0&&(0,T.jsxs)(`section`,{className:`activity-section`,children:[(0,T.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,T.jsx)(`h2`,{children:`Agent sessions`}),(0,T.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>A(`/sessions`),children:`View all`})]}),(0,T.jsx)(`div`,{className:`activity-row-list`,children:V.slice(0,5).map(e=>(0,T.jsxs)(`div`,{className:`activity-row`,children:[(0,T.jsxs)(`button`,{type:`button`,className:`w-full text-left`,"data-testid":`activity-session-link`,"data-session-id":e.id,onClick:()=>A(`/sessions?session=${encodeURIComponent(e.id)}`),children:[(0,T.jsxs)(`span`,{className:`activity-row-heading`,children:[(0,T.jsx)(`span`,{children:e.name??e.agent}),(0,T.jsx)(`span`,{className:`activity-muted`,children:d(e.last_activity_at)})]}),(0,T.jsxs)(`span`,{className:`activity-row-description inline-flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`size-1.5 rounded-full ${f[e.status].dot}`}),e.agent,` · `,f[e.status].label,e.task?` · ${e.task.title}`:``]})]}),(0,T.jsx)(C,{session:e})]},e.id))})]})]}),O===`all`&&(z??[]).length>0&&(0,T.jsxs)(`section`,{className:`activity-section`,children:[(0,T.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,T.jsx)(`h2`,{children:`Projects`}),(0,T.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>A(`/projects`),children:`View all`})]}),(0,T.jsx)(`div`,{className:`activity-projects`,children:(z??[]).filter(e=>e.status===`active`).slice(0,6).map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`activity-row`,onClick:()=>A(`/projects/${e.id}`),children:[(0,T.jsx)(`span`,{className:`activity-row-heading`,children:e.name}),e.description&&(0,T.jsx)(`span`,{className:`activity-row-description`,children:e.description})]},e.id))})]})]})}export{D as default};
1
+ import{t as e}from"./jsx-runtime-CVMpzJz9.js";import{f as t}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as n}from"./button-C91mbQEU.js";import{M as r,S as i,Tt as a,U as o,vt as s}from"./index-D5qFuDmc.js";import{o as c}from"./useJobs-BNj4dd9l.js";import{t as l}from"./PriorityBadge-D263N3pH.js";import{t as u}from"./StatusBadge-BUGpPpcH.js";import{a as d,t as f}from"./live-sessions-D07BClP7.js";import{t as p}from"./ErrorState-DprXzfow.js";import{t as m}from"./ViewHeader-BtTaSrXy.js";import{n as h}from"./useSessions-n-bp8ic5.js";import{a as g,i as _,n as v,o as y,r as b,t as x}from"./table-Q26Vm3R3.js";import{t as S}from"./useProjectScope-DtEj9j-P.js";import{t as C}from"./ResumeActions-DYiHEYFy.js";import{r as w}from"./useMemories-BpfvcV2g.js";var T=e();function E(e,t){return e.isLoading?`…`:e.error?`—`:t}function D({projectId:e}){let D=t(),O=S(e),k=a(`sm`),A=e=>{let t=new URL(e,window.location.origin);t.searchParams.set(`project`,O),D({pathname:t.pathname,search:t.search,hash:t.hash})},j=O===`all`?void 0:{project_id:O},M=r(j),{data:N,isLoading:P}=M,F=c(j),{data:I}=F,L=w({project_id:j?.project_id,limit:1},{enabled:O!==`unassigned`}),R=O===`unassigned`?0:L.data?.total??0,{data:z}=s(),B=h(!0,j?.project_id),V=(B.data??[]).filter(e=>O===`all`||(O===`unassigned`?e.project_id===null:e.project_id===O)),H=O===`unassigned`?(I??[]).filter(e=>e.project_id===null):I??[],U=O===`unassigned`?(N??[]).filter(e=>e.project_id===null):N??[],W=U.reduce((e,t)=>(e[t.status]=(e[t.status]??0)+1,e),{}),G=[...U].sort((e,t)=>new Date(t.updated_at).getTime()-new Date(e.updated_at).getTime()).slice(0,8),K=H.filter(e=>e.enabled),q=O===`all`?`All Projects`:O===`unassigned`?`Unassigned`:z?.find(e=>e.id===O)?.name??``,J=[{label:`Doing`,value:E(M,W.doing??0),sub:`in progress`,path:`/tasks?view=table&status=doing`},{label:`Review`,value:E(M,W.review??0),sub:`awaiting review`,path:`/tasks?view=table&status=review`},{label:`Blocked`,value:E(M,W.blocked??0),sub:`needs attention`,path:`/tasks?view=table&status=blocked`},{label:`Todo`,value:E(M,(W.todo??0)+(W.queued??0)),sub:`pending`,path:`/tasks?view=board`},{label:`Done`,value:E(M,W.done??0),sub:`completed`,path:`/tasks?view=table&status=done`}],Y=[{label:`Active jobs`,value:E(F,K.length),sub:`of ${H.length} total`,path:`/jobs`},{label:`Memories`,value:E(L,R),sub:`in this scope`,path:i},{label:`Projects`,value:(z??[]).filter(e=>e.status===`active`).length,sub:`active across workspace`,path:`/projects`}];return(0,T.jsxs)(`div`,{"data-activity-preview":!0,"data-testid":`activity-preview`,className:`activity-preview`,children:[(0,T.jsx)(m,{title:`Activity`,meta:q||`All projects`,action:(0,T.jsx)(n,{onClick:()=>A(`/tasks`),children:`View tasks`})}),[M,F,L,B].some(e=>e.isLoading)&&(0,T.jsx)(`p`,{role:`status`,className:`activity-muted mb-4`,children:`Loading activity…`}),[{name:`Tasks`,query:M},{name:`Jobs`,query:F},{name:`Memories`,query:L},{name:`Sessions`,query:B}].filter(({query:e})=>e.error).map(({name:e,query:t})=>(0,T.jsx)(p,{message:`${e}: ${t.error?.message??`Could not load activity`}`,onRetry:()=>t.refetch()},e)),(0,T.jsx)(`section`,{className:`activity-metrics`,"aria-label":`Task summary`,children:J.map(e=>(0,T.jsxs)(`button`,{type:`button`,"data-testid":`stat-card`,"data-stat-label":e.label,className:`activity-metric`,onClick:()=>A(e.path),children:[(0,T.jsx)(`span`,{className:`activity-metric-label`,children:e.label}),(0,T.jsx)(`span`,{"data-testid":`stat-card-value`,className:`activity-metric-value`,children:e.value}),(0,T.jsx)(`span`,{className:`activity-metric-sub`,children:e.sub})]},e.label))}),(0,T.jsx)(`section`,{className:`activity-resources`,"aria-label":`Workspace summary`,children:Y.map(e=>(0,T.jsxs)(`button`,{type:`button`,"data-testid":`stat-card`,"data-stat-label":e.label,onClick:()=>A(e.path),children:[(0,T.jsx)(`span`,{children:e.label}),(0,T.jsx)(`span`,{"data-testid":`stat-card-value`,className:`activity-resource-value`,children:e.value}),(0,T.jsx)(`span`,{className:`activity-resource-sub`,children:e.sub})]},e.label))}),(0,T.jsxs)(`section`,{className:`activity-section`,children:[(0,T.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,T.jsx)(`h2`,{children:`Recent tasks`}),(0,T.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>A(`/tasks`),children:`View all`})]}),P?(0,T.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,T.jsx)(o,{className:`h-10 w-full`},e))}):G.length===0?(0,T.jsx)(`p`,{className:`activity-empty`,children:`No tasks`}):k?(0,T.jsxs)(x,{className:`activity-task-table`,children:[(0,T.jsx)(g,{children:(0,T.jsxs)(y,{children:[(0,T.jsx)(_,{children:`Task`}),(0,T.jsx)(_,{className:`w-36`,children:`Status`}),(0,T.jsx)(_,{className:`w-28`,children:`Priority`}),(0,T.jsx)(_,{className:`w-28`,children:`Updated`})]})}),(0,T.jsx)(v,{children:G.map(e=>(0,T.jsxs)(y,{onClick:()=>A(`/tasks/${e.id}`),children:[(0,T.jsx)(b,{children:(0,T.jsx)(`button`,{type:`button`,className:`activity-task-title`,onClick:t=>{t.stopPropagation(),A(`/tasks/${e.id}`)},children:e.title})}),(0,T.jsx)(b,{children:(0,T.jsx)(`span`,{className:`activity-status`,"data-status":e.status,children:(0,T.jsx)(u,{status:e.status})})}),(0,T.jsx)(b,{children:(0,T.jsx)(`span`,{className:`activity-priority`,children:(0,T.jsx)(l,{priority:e.priority})})}),(0,T.jsx)(b,{className:`activity-muted`,children:new Date(e.updated_at).toLocaleDateString()})]},e.id))})]}):(0,T.jsx)(`div`,{className:`activity-task-list`,children:G.map(e=>(0,T.jsxs)(`article`,{className:`activity-task-mobile`,children:[(0,T.jsx)(`button`,{type:`button`,className:`activity-task-title`,onClick:()=>A(`/tasks/${e.id}`),children:e.title}),(0,T.jsxs)(`div`,{className:`activity-task-meta`,children:[(0,T.jsx)(`span`,{className:`activity-status`,"data-status":e.status,children:(0,T.jsx)(u,{status:e.status})}),(0,T.jsx)(`span`,{className:`activity-priority`,children:(0,T.jsx)(l,{priority:e.priority})}),(0,T.jsx)(`span`,{children:new Date(e.updated_at).toLocaleDateString()})]})]},e.id))})]}),(0,T.jsxs)(`div`,{className:`activity-secondary`,children:[K.length>0&&(0,T.jsxs)(`section`,{className:`activity-section`,children:[(0,T.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,T.jsx)(`h2`,{children:`Active jobs`}),(0,T.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>A(`/jobs`),children:`View all`})]}),(0,T.jsx)(`div`,{className:`activity-row-list`,children:K.slice(0,5).map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`activity-row`,onClick:()=>A(`/jobs/${e.id}`),children:[(0,T.jsxs)(`span`,{className:`activity-row-heading`,children:[(0,T.jsx)(`span`,{children:e.name}),(0,T.jsx)(`span`,{className:`activity-muted`,children:e.trigger_type})]}),e.last_run_at&&(0,T.jsxs)(`span`,{className:`activity-row-description`,children:[`Last run `,new Date(e.last_run_at).toLocaleString()]})]},e.id))})]}),V.length>0&&(0,T.jsxs)(`section`,{className:`activity-section`,children:[(0,T.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,T.jsx)(`h2`,{children:`Agent sessions`}),(0,T.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>A(`/sessions`),children:`View all`})]}),(0,T.jsx)(`div`,{className:`activity-row-list`,children:V.slice(0,5).map(e=>(0,T.jsxs)(`div`,{className:`activity-row`,children:[(0,T.jsxs)(`button`,{type:`button`,className:`w-full text-left`,"data-testid":`activity-session-link`,"data-session-id":e.id,onClick:()=>A(`/sessions?session=${encodeURIComponent(e.id)}`),children:[(0,T.jsxs)(`span`,{className:`activity-row-heading`,children:[(0,T.jsx)(`span`,{children:e.name??e.agent}),(0,T.jsx)(`span`,{className:`activity-muted`,children:d(e.last_activity_at)})]}),(0,T.jsxs)(`span`,{className:`activity-row-description inline-flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`size-1.5 rounded-full ${f[e.status].dot}`}),e.agent,` · `,f[e.status].label,e.task?` · ${e.task.title}`:``]})]}),(0,T.jsx)(C,{session:e})]},e.id))})]})]}),O===`all`&&(z??[]).length>0&&(0,T.jsxs)(`section`,{className:`activity-section`,children:[(0,T.jsxs)(`div`,{className:`activity-section-heading`,children:[(0,T.jsx)(`h2`,{children:`Projects`}),(0,T.jsx)(`button`,{type:`button`,className:`activity-text-action`,onClick:()=>A(`/projects`),children:`View all`})]}),(0,T.jsx)(`div`,{className:`activity-projects`,children:(z??[]).filter(e=>e.status===`active`).slice(0,6).map(e=>(0,T.jsxs)(`button`,{type:`button`,className:`activity-row`,onClick:()=>A(`/projects/${e.id}`),children:[(0,T.jsx)(`span`,{className:`activity-row-heading`,children:e.name}),e.description&&(0,T.jsx)(`span`,{className:`activity-row-description`,children:e.description})]},e.id))})]})]})}export{D as default};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{f as r,m as i}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as a}from"./button-C91mbQEU.js";import{t as o}from"./MarkdownEditor-D8aBF3I9.js";var s=e(t(),1),c=n(),l=new Map,u=new Set;typeof window<`u`&&window.addEventListener(`beforeunload`,e=>{l.size&&(e.preventDefault(),e.returnValue=``)});function d(e){return u.has(e)?!1:l.has(e)?window.confirm(`Discard unsaved changes to this document?`)?(l.delete(e),!0):!1:!0}function f({documentId:e,content:t,path:n,onSave:f,testId:p,wikiLinks:m,navigation:h,expanded:g,onExpandedChange:_,layout:v,pageTitle:y,hideFrontmatter:b,compact:x}){let[S]=i(),C=r(),w=S.get(`editorMode`),T=w===`edit`||w===`split`?w:`read`,E=(0,s.useRef)(l.get(e)??{original:t,content:t}),[D,O]=(0,s.useState)(E.current.content),[k,A]=(0,s.useState)(E.current.original),[j,M]=(0,s.useState)(!1),[N,P]=(0,s.useState)(null),F=(0,s.useRef)(!1),I=(0,s.useRef)(E.current.content),L=D!==k;(0,s.useEffect)(()=>{l.has(e)||(O(t),I.current=t,A(t))},[t,e]);function R(t){I.current=t,O(t),t===k?l.delete(e):l.set(e,{original:k,content:t})}async function z(){if(!f||!L||F.current)return;F.current=!0,u.add(e),M(!0),P(null);let t=I.current;try{let n=await f(t,k),r=typeof n==`string`?n:t;A(r),I.current===t?(l.delete(e),I.current=r,O(r)):l.set(e,{original:r,content:I.current})}catch(e){P(e instanceof Error?e.message:`Could not save document`)}finally{F.current=!1,u.delete(e),M(!1)}}function B(e){let t=new URLSearchParams(window.location.search);t.set(`editorMode`,e),t.toString()!==new URLSearchParams(window.location.search).toString()&&C({search:t.toString(),hash:window.location.hash})}function V(){d(e)&&(O(t),A(t),I.current=t,P(null))}let H=f?j?`Saving…`:L?`Unsaved changes`:`Saved`:`Read-only`,U=(0,c.jsxs)(c.Fragment,{children:[N&&(0,c.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[N,` Your draft has been kept.`]}),L&&t!==k&&(0,c.jsx)(`p`,{role:`status`,className:`text-sm text-outline`,children:`The document changed elsewhere. Your draft is preserved; saving will check for conflicts.`})]});return v===`page`?(0,c.jsx)(`div`,{className:`min-w-0`,"data-testid":`document-workspace`,children:(0,c.jsx)(o,{path:n,value:D,onChange:R,onSave:()=>void z(),readOnly:!f||j,testId:p,wikiLinks:m,initialMode:`read`,mode:T,onModeChange:B,expanded:g,onExpandedChange:_,layout:`page`,pageTitle:y,hideFrontmatter:b,compact:x,notice:N||L&&t!==k?U:void 0,actions:(T!==`read`||L||j)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`span`,{"data-testid":`document-save-status`,role:`status`,className:`text-xs text-outline`,children:H}),f&&(L||j)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`document-discard`,disabled:j,onClick:V,children:`Discard`}),(0,c.jsx)(a,{type:`button`,size:`sm`,"data-testid":`document-save`,disabled:j,onClick:()=>void z(),children:`Save`})]})]})})}):(0,c.jsx)(`div`,{className:`min-w-0 space-y-3`,"data-testid":`document-workspace`,children:(0,c.jsx)(o,{path:n,value:D,onChange:R,onSave:()=>void z(),readOnly:!f||j,testId:p,wikiLinks:m,initialMode:`read`,mode:T,onModeChange:B,expanded:g,onExpandedChange:_,layout:v,compact:x,header:(0,c.jsxs)(`div`,{className:`space-y-2`,children:[h&&(0,c.jsx)(`div`,{className:`mb-3 min-w-0`,children:h}),(0,c.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,c.jsx)(`span`,{"data-testid":`document-save-status`,role:`status`,className:`min-w-0 flex-1 text-sm text-outline`,children:H}),f&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a,{type:`button`,variant:`ghost`,"data-testid":`document-discard`,disabled:!L||j,onClick:V,children:`Discard changes`}),(0,c.jsx)(a,{type:`button`,"data-testid":`document-save`,disabled:!L||j,onClick:()=>void z(),children:`Save changes`})]})]}),U]})})})}export{d as n,f as t};
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{f as r,m as i}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as a}from"./button-C91mbQEU.js";import{t as o}from"./MarkdownEditor-CSloDLyL.js";var s=e(t(),1),c=n(),l=new Map,u=new Set;typeof window<`u`&&window.addEventListener(`beforeunload`,e=>{l.size&&(e.preventDefault(),e.returnValue=``)});function d(e){return u.has(e)?!1:l.has(e)?window.confirm(`Discard unsaved changes to this document?`)?(l.delete(e),!0):!1:!0}function f({documentId:e,content:t,path:n,onSave:f,testId:p,wikiLinks:m,navigation:h,expanded:g,onExpandedChange:_,layout:v,pageTitle:y,hideFrontmatter:b,compact:x}){let[S]=i(),C=r(),w=S.get(`editorMode`),T=w===`edit`||w===`split`?w:`read`,E=(0,s.useRef)(l.get(e)??{original:t,content:t}),[D,O]=(0,s.useState)(E.current.content),[k,A]=(0,s.useState)(E.current.original),[j,M]=(0,s.useState)(!1),[N,P]=(0,s.useState)(null),F=(0,s.useRef)(!1),I=(0,s.useRef)(E.current.content),L=D!==k;(0,s.useEffect)(()=>{l.has(e)||(O(t),I.current=t,A(t))},[t,e]);function R(t){I.current=t,O(t),t===k?l.delete(e):l.set(e,{original:k,content:t})}async function z(){if(!f||!L||F.current)return;F.current=!0,u.add(e),M(!0),P(null);let t=I.current;try{let n=await f(t,k),r=typeof n==`string`?n:t;A(r),I.current===t?(l.delete(e),I.current=r,O(r)):l.set(e,{original:r,content:I.current})}catch(e){P(e instanceof Error?e.message:`Could not save document`)}finally{F.current=!1,u.delete(e),M(!1)}}function B(e){let t=new URLSearchParams(window.location.search);t.set(`editorMode`,e),t.toString()!==new URLSearchParams(window.location.search).toString()&&C({search:t.toString(),hash:window.location.hash})}function V(){d(e)&&(O(t),A(t),I.current=t,P(null))}let H=f?j?`Saving…`:L?`Unsaved changes`:`Saved`:`Read-only`,U=(0,c.jsxs)(c.Fragment,{children:[N&&(0,c.jsxs)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:[N,` Your draft has been kept.`]}),L&&t!==k&&(0,c.jsx)(`p`,{role:`status`,className:`text-sm text-outline`,children:`The document changed elsewhere. Your draft is preserved; saving will check for conflicts.`})]});return v===`page`?(0,c.jsx)(`div`,{className:`min-w-0`,"data-testid":`document-workspace`,children:(0,c.jsx)(o,{path:n,value:D,onChange:R,onSave:()=>void z(),readOnly:!f||j,testId:p,wikiLinks:m,initialMode:`read`,mode:T,onModeChange:B,expanded:g,onExpandedChange:_,layout:`page`,pageTitle:y,hideFrontmatter:b,compact:x,notice:N||L&&t!==k?U:void 0,actions:(T!==`read`||L||j)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`span`,{"data-testid":`document-save-status`,role:`status`,className:`text-xs text-outline`,children:H}),f&&(L||j)&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a,{type:`button`,size:`sm`,variant:`ghost`,"data-testid":`document-discard`,disabled:j,onClick:V,children:`Discard`}),(0,c.jsx)(a,{type:`button`,size:`sm`,"data-testid":`document-save`,disabled:j,onClick:()=>void z(),children:`Save`})]})]})})}):(0,c.jsx)(`div`,{className:`min-w-0 space-y-3`,"data-testid":`document-workspace`,children:(0,c.jsx)(o,{path:n,value:D,onChange:R,onSave:()=>void z(),readOnly:!f||j,testId:p,wikiLinks:m,initialMode:`read`,mode:T,onModeChange:B,expanded:g,onExpandedChange:_,layout:v,compact:x,header:(0,c.jsxs)(`div`,{className:`space-y-2`,children:[h&&(0,c.jsx)(`div`,{className:`mb-3 min-w-0`,children:h}),(0,c.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,c.jsx)(`span`,{"data-testid":`document-save-status`,role:`status`,className:`min-w-0 flex-1 text-sm text-outline`,children:H}),f&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(a,{type:`button`,variant:`ghost`,"data-testid":`document-discard`,disabled:!L||j,onClick:V,children:`Discard changes`}),(0,c.jsx)(a,{type:`button`,"data-testid":`document-save`,disabled:!L||j,onClick:()=>void z(),children:`Save changes`})]})]}),U]})})})}export{d as n,f as t};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{m as i}from"./chunk-OB3PAWPO-1IihCzFx.js";import{n as a}from"./client-ByMuVs3d.js";import{t as o}from"./MarkdownEditor-D8aBF3I9.js";import{t as s}from"./save-DWlDLKMf.js";import{t as c}from"./file-kind-BYU1kv95.js";import{ct as l}from"./index-C0yeM676.js";var u=e(t(),1),d=n(),f=new Map;typeof window<`u`&&window.addEventListener(`beforeunload`,e=>{f.size!==0&&(e.preventDefault(),e.returnValue=``)});function p({terminalId:e,path:t,content:n,readOnly:p,onDirty:m}){let[h,g]=i(),_=h.get(`editorMode`),v=_===`read`||_===`split`?_:`edit`,y=`${e}:${t}`,b=(0,u.useRef)(f.get(y)??{original:n,content:n}),x=(0,u.useRef)(b.current.original),S=(0,u.useRef)(b.current.content),[C,w]=(0,u.useState)(b.current.content!==b.current.original),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(null),[k,A]=(0,u.useState)(b.current.content),j=r(),M=(0,u.useRef)(()=>{}),N=(0,u.useRef)(!1),P=(0,u.useRef)(!1),F=(0,u.useRef)(m);F.current=m;async function I(){if(N.current||p||S.current===x.current)return;N.current=!0,E(!0),O(null);let n=S.current;try{await a.git.saveFile(e,t,n,x.current),x.current=n;let r=S.current!==n;w(r),P.current&&F.current(r),r?f.set(y,{original:n,content:S.current}):f.delete(y),j.invalidateQueries({queryKey:[`checkout-files`,e,t]}),j.invalidateQueries({queryKey:[`git`,e]})}catch(e){O(e instanceof Error?e.message:`Could not save file`)}finally{N.current=!1,E(!1)}}M.current=()=>void I(),(0,u.useEffect)(()=>(P.current=!0,F.current(b.current.content!==b.current.original),()=>{P.current=!1}),[]),(0,u.useEffect)(()=>{N.current||f.has(y)||n===x.current||(x.current=n,S.current=n,A(n),w(!1),P.current&&F.current(!1))},[n,y]);function L(e){S.current=e,A(e);let t=e!==x.current;w(t),F.current(t),t?f.set(y,{original:x.current,content:e}):f.delete(y)}function R(){window.confirm(`Discard your edits and reload the file from disk?`)&&a.git.files(e,t).then(e=>{if(e.content===null||e.binary||e.truncated)throw Error(`File is no longer editable`);x.current=e.content,S.current=e.content,f.delete(y),A(e.content),w(!1),F.current(!1),O(null)}).catch(e=>O(e instanceof Error?e.message:`Could not reload file`))}let z=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-surface-highest px-2 py-1`,children:[(0,d.jsxs)(`button`,{type:`button`,"data-testid":`file-save`,disabled:!C||T||p,onClick:()=>void I(),className:`flex min-h-11 items-center gap-1 rounded px-2 py-1 text-sm text-primary hover:bg-surface-highest disabled:opacity-40`,title:`Save (Ctrl/Cmd+S)`,children:[(0,d.jsx)(s,{size:14}),T?`Saving…`:`Save`]}),(0,d.jsx)(`span`,{"data-testid":`file-save-status`,className:`min-w-0 flex-1 truncate text-sm text-on-surface-variant`,children:p?`Read-only preview`:C?`Unsaved changes`:`Saved`})]}),D&&(0,d.jsxs)(`div`,{role:`alert`,className:`shrink-0 border-b border-error/30 p-2 text-xs text-error`,children:[D,(0,d.jsx)(`button`,{type:`button`,"data-testid":`file-reload`,onClick:R,className:`ml-2 underline`,children:`Reload from disk`})]})]});return(0,d.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`file-editor`,children:[!c(t)&&z,(0,d.jsx)(`div`,{"data-testid":`file-preview`,className:`min-h-0 flex-1 overflow-hidden`,children:c(t)?(0,d.jsx)(o,{path:t,value:k,onChange:L,onSave:()=>M.current(),readOnly:p,height:`100%`,testId:`file-editor-input`,header:z,mode:v,onModeChange:e=>g(t=>{let n=new URLSearchParams(t);return n.set(`editorMode`,e),n})}):(0,d.jsx)(l,{path:t,value:k,onChange:L,onSave:()=>M.current(),readOnly:p,height:`100%`,testId:`file-editor-input`})})]})}export{p as FileEditor};
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{n as r}from"./QueryClientProvider-DlPztvhd.js";import{m as i}from"./chunk-OB3PAWPO-1IihCzFx.js";import{n as a}from"./client-BnTXPI20.js";import{t as o}from"./MarkdownEditor-CSloDLyL.js";import{t as s}from"./save-CnCcteVb.js";import{t as c}from"./file-kind-BYU1kv95.js";import{ct as l}from"./index-D5qFuDmc.js";var u=e(t(),1),d=n(),f=new Map;typeof window<`u`&&window.addEventListener(`beforeunload`,e=>{f.size!==0&&(e.preventDefault(),e.returnValue=``)});function p({terminalId:e,path:t,content:n,readOnly:p,onDirty:m}){let[h,g]=i(),_=h.get(`editorMode`),v=_===`read`||_===`split`?_:`edit`,y=`${e}:${t}`,b=(0,u.useRef)(f.get(y)??{original:n,content:n}),x=(0,u.useRef)(b.current.original),S=(0,u.useRef)(b.current.content),[C,w]=(0,u.useState)(b.current.content!==b.current.original),[T,E]=(0,u.useState)(!1),[D,O]=(0,u.useState)(null),[k,A]=(0,u.useState)(b.current.content),j=r(),M=(0,u.useRef)(()=>{}),N=(0,u.useRef)(!1),P=(0,u.useRef)(!1),F=(0,u.useRef)(m);F.current=m;async function I(){if(N.current||p||S.current===x.current)return;N.current=!0,E(!0),O(null);let n=S.current;try{await a.git.saveFile(e,t,n,x.current),x.current=n;let r=S.current!==n;w(r),P.current&&F.current(r),r?f.set(y,{original:n,content:S.current}):f.delete(y),j.invalidateQueries({queryKey:[`checkout-files`,e,t]}),j.invalidateQueries({queryKey:[`git`,e]})}catch(e){O(e instanceof Error?e.message:`Could not save file`)}finally{N.current=!1,E(!1)}}M.current=()=>void I(),(0,u.useEffect)(()=>(P.current=!0,F.current(b.current.content!==b.current.original),()=>{P.current=!1}),[]),(0,u.useEffect)(()=>{N.current||f.has(y)||n===x.current||(x.current=n,S.current=n,A(n),w(!1),P.current&&F.current(!1))},[n,y]);function L(e){S.current=e,A(e);let t=e!==x.current;w(t),F.current(t),t?f.set(y,{original:x.current,content:e}):f.delete(y)}function R(){window.confirm(`Discard your edits and reload the file from disk?`)&&a.git.files(e,t).then(e=>{if(e.content===null||e.binary||e.truncated)throw Error(`File is no longer editable`);x.current=e.content,S.current=e.content,f.delete(y),A(e.content),w(!1),F.current(!1),O(null)}).catch(e=>O(e instanceof Error?e.message:`Could not reload file`))}let z=(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 border-b border-surface-highest px-2 py-1`,children:[(0,d.jsxs)(`button`,{type:`button`,"data-testid":`file-save`,disabled:!C||T||p,onClick:()=>void I(),className:`flex min-h-11 items-center gap-1 rounded px-2 py-1 text-sm text-primary hover:bg-surface-highest disabled:opacity-40`,title:`Save (Ctrl/Cmd+S)`,children:[(0,d.jsx)(s,{size:14}),T?`Saving…`:`Save`]}),(0,d.jsx)(`span`,{"data-testid":`file-save-status`,className:`min-w-0 flex-1 truncate text-sm text-on-surface-variant`,children:p?`Read-only preview`:C?`Unsaved changes`:`Saved`})]}),D&&(0,d.jsxs)(`div`,{role:`alert`,className:`shrink-0 border-b border-error/30 p-2 text-xs text-error`,children:[D,(0,d.jsx)(`button`,{type:`button`,"data-testid":`file-reload`,onClick:R,className:`ml-2 underline`,children:`Reload from disk`})]})]});return(0,d.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-testid":`file-editor`,children:[!c(t)&&z,(0,d.jsx)(`div`,{"data-testid":`file-preview`,className:`min-h-0 flex-1 overflow-hidden`,children:c(t)?(0,d.jsx)(o,{path:t,value:k,onChange:L,onSave:()=>M.current(),readOnly:p,height:`100%`,testId:`file-editor-input`,header:z,mode:v,onModeChange:e=>g(t=>{let n=new URLSearchParams(t);return n.set(`editorMode`,e),n})}):(0,d.jsx)(l,{path:t,value:k,onChange:L,onSave:()=>M.current(),readOnly:p,height:`100%`,testId:`file-editor-input`})})]})}export{p as FileEditor};
@@ -1 +1 @@
1
- import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./react-dom-DTbwZiiP.js";import{l as i}from"./chunk-OB3PAWPO-1IihCzFx.js";import{C as a,E as o,F as s,I as c,M as l,N as u,P as d,T as f,_ as p,f as m,g as h,h as g,j as _,k as v,l as y,m as b,p as x,t as S,v as C,y as w}from"./button-C91mbQEU.js";import{t as T}from"./dist-bytwC6rk.js";import{n as E,t as ee}from"./es2015-w69PgVrA.js";import{t as D}from"./dist-BKxzy3T8.js";import{t as te}from"./dist-Ct6061MC.js";import{t as O}from"./dist-D8Wfxh48.js";import{h as k}from"./client-ByMuVs3d.js";import{t as A}from"./check-DZNzZAdD.js";import{t as j}from"./chevron-down-DjliQtS1.js";import{a as ne,i as M,n as N,o as re,r as P,t as F}from"./dialog-C7wt3DcD.js";var I=e(t(),1),L=e(r(),1),R=n(),z=Object.defineProperty,B=(e,t)=>z(e,`name`,{value:t,configurable:!0}),ie={ItemAligned:`item-aligned`,Popper:`popper`},V={LTR:`ltr`,RTL:`rtl`},H=[` `,`Enter`,`ArrowUp`,`ArrowDown`],U=[` `,`Enter`],W=`Select`,[G,K,ae]=D(W),[q,oe]=d(W,[ae,h]),J=h(),[se,Y]=q(W),[ce,le]=q(W);function ue(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:p,required:m,form:h,internal_do_not_use_render:g}=e,v=J(t),[y,b]=I.useState(null),[S,C]=I.useState(null),[w,T]=I.useState(!1),E=te(u),[ee,D]=_({prop:r,defaultProp:i??!1,onChange:a,caller:W}),[O,k]=_({prop:o,defaultProp:s,onChange:c,caller:W}),A=I.useRef(null),j=I.useRef(!1),[ne,M]=I.useState(null),N=B(e=>{M({value:e,hasConsumerStoppedPropagation:j.current}),k(e)},`handleUserSelect`),re=I.useRef(O);I.useEffect(()=>{let e=h?y?.ownerDocument.getElementById(h):y?.form;if(e instanceof HTMLFormElement){let t=B(()=>k(re.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,y,k]);let P=!y||!!h||!!y.closest(`form`),[F,L]=I.useState(new Set),z=l(),ie=Array.from(F).map(e=>e.props.value).join(`;`),V=I.useCallback(e=>{L(t=>new Set(t).add(e))},[]),H=I.useCallback(e=>{L(t=>{let n=new Set(t);return n.delete(e),n})},[]),U={required:m,trigger:y,onTriggerChange:b,valueNode:S,onValueNodeChange:C,valueNodeHasChildren:w,onValueNodeHasChildrenChange:T,contentId:z,value:O,onValueChange:k,hasConsumerStoppedPropagationRef:j,userSelection:ne,onUserSelect:N,open:ee,onOpenChange:D,dir:E,triggerPointerDownPosRef:A,disabled:p,name:d,autoComplete:f,form:h,nativeOptions:F,nativeSelectKey:ie,isFormControl:P};return(0,R.jsx)(x,{...v,children:(0,R.jsx)(se,{scope:t,...U,children:(0,R.jsx)(G.Provider,{scope:t,children:(0,R.jsx)(ce,{scope:t,onNativeOptionAdd:V,onNativeOptionRemove:H,children:Ze(g)?g(U):n})})})})}B(ue,`SelectProvider`);var de=B(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,R.jsx)(ue,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,R.jsxs)(R.Fragment,{children:[n,e?(0,R.jsx)(Xe,{__scopeSelect:t}):null]})})},`Select`),fe=`SelectTrigger`,pe=I.forwardRef(B(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=J(n),l=Y(fe,n),u=l.disabled||r,d=s(t,l.onTriggerChange),f=K(n),p=I.useRef(`touch`),[m,h,g]=Qe(e=>{let t=f().filter(e=>!e.disabled),n=$e(t,e,t.find(e=>e.value===l.value));n!==void 0&&l.onUserSelect(n.value)}),_=B(e=>{u||(l.onOpenChange(!0),g()),e&&(l.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,R.jsx)(b,{asChild:!0,...a,children:(0,R.jsx)(o.button,{type:`button`,role:`combobox`,"aria-controls":l.open?l.contentId:void 0,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":`none`,dir:l.dir,"data-state":l.open?`open`:`closed`,disabled:u,"data-disabled":u?``:void 0,"data-placeholder":$(l.value)?``:void 0,...i,ref:d,onClick:c(i.onClick,e=>{e.currentTarget.focus(),p.current!==`mouse`&&_(e)}),onPointerDown:c(i.onPointerDown,e=>{p.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(_(e),e.preventDefault())}),onKeyDown:c(i.onKeyDown,e=>{let t=m.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(l.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),h(e.key)),!(t&&e.key===` `)&&H.includes(e.key)&&(_(),e.preventDefault())})})})},`SelectTrigger`)),me=`SelectValue`,he=I.forwardRef(B(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:c=``,...l}=e,d=Y(me,n),{onValueNodeHasChildrenChange:f}=d,p=a!==void 0,m=s(t,d.onValueNodeChange);u(()=>{f(p)},[f,p]);let h=$(d.value);return(0,R.jsx)(o.span,{...l,asChild:!h&&l.asChild,ref:m,style:{pointerEvents:`none`},children:(0,R.jsx)(I.Fragment,{children:h?c:a},h?`placeholder`:`value`)})},`SelectValue`)),ge=I.forwardRef(B(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,R.jsx)(o.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[_e,ve]=q(`SelectPortal`,{forceMount:void 0}),ye=B(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,R.jsx)(_e,{scope:e.__scopeSelect,forceMount:n,children:(0,R.jsx)(C,{asChild:!0,...r})})},`SelectPortal`),X=`SelectContent`,be=I.forwardRef(B(function(e,t){let n=ve(X,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=Y(X,e.__scopeSelect),[o,s]=I.useState();return u(()=>{s(new DocumentFragment)},[]),(0,R.jsx)(p,{present:r||a.open,children:({present:e})=>e?(0,R.jsx)(we,{...i,ref:t}):(0,R.jsx)(xe,{...i,fragment:o})})},`SelectContent`)),xe=I.forwardRef(B(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?L.createPortal((0,R.jsx)(Se,{scope:n,children:(0,R.jsx)(G.Slot,{scope:n,children:(0,R.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Z=10,[Se,Q]=q(X),Ce=v(`SelectContent.RemoveScroll`),we=I.forwardRef(B(function(e,t){let{__scopeSelect:n}=e,{position:r=ie.ItemAligned,onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:l,side:u,sideOffset:d,align:f,alignOffset:p,arrowPadding:m,collisionBoundary:h,collisionPadding:g,sticky:_,hideWhenDetached:v,avoidCollisions:y,...b}=e,x=Y(X,n),[S,C]=I.useState(null),[D,te]=I.useState(null),O=s(t,C),[k,A]=I.useState(null),[j,ne]=I.useState(null),M=K(n),[N,re]=I.useState(!1),P=I.useRef(!1),F=I.useRef(!1),L=I.useRef(!1);I.useEffect(()=>{if(S)return ee(S)},[S]),T();let z=I.useCallback(e=>{let[t,...n]=M().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&D&&(D.scrollTop=0),n===r&&D&&(D.scrollTop=D.scrollHeight),n?.focus(),document.activeElement!==i))return},[M,D]),V=I.useCallback(()=>z([k,S]),[z,k,S]);I.useEffect(()=>{N&&V()},[N,V]);let{onOpenChange:H,triggerPointerDownPosRef:U}=x;I.useEffect(()=>{if(S){let e={x:0,y:0},t=B(t=>{e={x:Math.abs(Math.round(t.pageX)-(U.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(U.current?.y??0))}},`handlePointerMove`),n=B(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(S)||H(!1),document.removeEventListener(`pointermove`,t),U.current=null},`handlePointerUp`);return U.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[S,H,U]),I.useEffect(()=>{let e=B(()=>H(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[H]);let[W,G]=Qe(e=>{let t=M().filter(e=>!e.disabled),n=$e(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ae=I.useCallback((e,t,n)=>{let r=!F.current;r&&(F.current=!0);let i=!P.current&&!n;x.value!==void 0&&x.value===t||i?(A(e),i&&(P.current=!0)):r&&A(e)},[x.value]),q=I.useCallback(()=>S?.focus(),[S]),oe=I.useCallback((e,t,n)=>{if(!e)return;let r=!L.current;r&&(L.current=!0);let i=!P.current&&!n;(x.value!==void 0&&x.value===t||i||r)&&ne(e)},[x.value]),J=r===ie.Popper?Ee:Te,se=J===Ee?{side:u,sideOffset:d,align:f,alignOffset:p,arrowPadding:m,collisionBoundary:h,collisionPadding:g,sticky:_,hideWhenDetached:v,avoidCollisions:y}:{};return(0,R.jsx)(Se,{scope:n,content:S,viewport:D,onViewportChange:te,itemRefCallback:ae,selectedItem:k,onItemLeave:q,itemTextRefCallback:oe,focusSelectedItem:V,selectedItemText:j,position:r,isPositioned:N,searchRef:W,children:(0,R.jsx)(E,{as:Ce,allowPinchZoom:!0,children:(0,R.jsx)(w,{asChild:!0,trapped:x.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:c(i,e=>{x.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,R.jsx)(a,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:(0,R.jsx)(J,{role:`listbox`,id:x.contentId,"data-state":x.open?`open`:`closed`,dir:x.dir,onContextMenu:e=>e.preventDefault(),...b,...se,onPlaced:()=>re(!0),ref:O,style:{display:`flex`,flexDirection:`column`,outline:`none`,...b.style},onKeyDown:c(b.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&G(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=M().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>z(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),Te=I.forwardRef(B(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=Y(X,n),c=Q(X,n),[l,d]=I.useState(null),[f,p]=I.useState(null),m=s(t,p),h=K(n),g=I.useRef(!1),_=I.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=c,S=I.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&f&&v&&y&&b){let e=a.trigger.getBoundingClientRect(),t=f.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(a.dir!==V.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,c=Math.max(s,t.width),u=window.innerWidth-Z,d=O(a,[Z,Math.max(Z,u-c)]);l.style.minWidth=s+`px`,l.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,c=Math.max(s,t.width),u=window.innerWidth-Z,d=O(a,[Z,Math.max(Z,u-c)]);l.style.minWidth=s+`px`,l.style.right=d+`px`}let o=h(),s=window.innerHeight-Z*2,c=v.scrollHeight,u=window.getComputedStyle(f),d=parseInt(u.borderTopWidth,10),p=parseInt(u.paddingTop,10),m=parseInt(u.borderBottomWidth,10),_=parseInt(u.paddingBottom,10),x=d+p+c+_+m,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Z,ee=s-E,D=y.offsetHeight/2,te=y.offsetTop+D,k=d+p+te,A=x-k;if(k<=E){let e=o.length>0&&y===o[o.length-1].ref.current;l.style.bottom=`0px`;let t=f.clientHeight-v.offsetTop-v.offsetHeight,n=k+Math.max(ee,D+(e?T:0)+t+m);l.style.height=n+`px`}else{let e=o.length>0&&y===o[0].ref.current;l.style.top=`0px`;let t=Math.max(E,d+v.offsetTop+(e?w:0)+D)+A;l.style.height=t+`px`,v.scrollTop=k-E+v.offsetTop}l.style.margin=`${Z}px 0`,l.style.minHeight=S+`px`,l.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[h,a.trigger,a.valueNode,l,f,v,y,b,a.dir,r]);u(()=>S(),[S]);let[C,w]=I.useState();u(()=>{f&&w(window.getComputedStyle(f).zIndex)},[f]);let T=I.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,R.jsx)(De,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:(0,R.jsx)(`div`,{ref:d,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,R.jsx)(o.div,{...i,ref:m,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Ee=I.forwardRef(B(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Z,...a}=e,o=J(n);return(0,R.jsx)(g,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[De,Oe]=q(X,{}),ke=`SelectViewport`,Ae=I.forwardRef(B(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Q(ke,n),l=Oe(ke,n),u=s(t,a.onViewportChange),d=I.useRef(0);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,R.jsx)(G.Slot,{scope:n,children:(0,R.jsx)(o.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:u,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:c(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=l;if(r?.current&&n){let e=Math.abs(d.current-t.scrollTop);if(e>0){let r=window.innerHeight-Z*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}d.current=t.scrollTop})})})]})},`SelectViewport`)),[je,Me]=q(`SelectGroup`),Ne=`SelectLabel`,Pe=I.forwardRef(B(function(e,t){let{__scopeSelect:n,...r}=e,i=Me(Ne,n);return(0,R.jsx)(o.div,{id:i.id,...r,ref:t})},`SelectLabel`)),Fe=`SelectItem`,[Ie,Le]=q(Fe),Re=I.forwardRef(B(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...u}=e,d=Y(Fe,n),p=Q(Fe,n),m=d.value===r,[h,g]=I.useState(a??``),[_,v]=I.useState(!1),y=f(e=>p.itemRefCallback?.(e,r,i)),b=s(t,y),x=l(),S=I.useRef(`touch`);function C(e){d.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),d.onUserSelect(r),d.onOpenChange(!1)}return B(C,`handleSelect`),(0,R.jsx)(Ie,{scope:n,value:r,disabled:i,textId:x,isSelected:m,onItemTextChange:I.useCallback(e=>{g(t=>t||(e?.textContent??``).trim())},[]),children:(0,R.jsx)(G.ItemSlot,{scope:n,value:r,disabled:i,textValue:h,children:(0,R.jsx)(o.div,{role:`option`,"aria-labelledby":x,"data-highlighted":_?``:void 0,"aria-selected":m&&_,"data-state":m?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...u,ref:b,onFocus:c(u.onFocus,()=>v(!0)),onBlur:c(u.onBlur,()=>v(!1)),onClick:c(u.onClick,e=>{i||S.current!==`mouse`&&C(e)}),onPointerUp:c(u.onPointerUp,e=>{i||S.current===`mouse`&&C(e)}),onPointerDown:c(u.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:c(u.onPointerMove,e=>{S.current=e.pointerType,i?p.onItemLeave?.():S.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:c(u.onPointerLeave,e=>{e.currentTarget===document.activeElement&&p.onItemLeave?.()}),onKeyDown:c(u.onKeyDown,e=>{i||e.target!==e.currentTarget||(p.searchRef?.current===``||e.key!==` `)&&(U.includes(e.key)&&C(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),ze=`SelectItemText`,Be=I.forwardRef(B(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,c=Y(ze,n),l=Q(ze,n),d=Le(ze,n),p=le(ze,n),[m,h]=I.useState(null),g=f(e=>l.itemTextRefCallback?.(e,d.value,d.disabled)),_=s(t,h,d.onItemTextChange,g),v=m?.textContent,y=I.useMemo(()=>(0,R.jsx)(`option`,{value:d.value,disabled:d.disabled,children:v},d.value),[d.disabled,d.value,v]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=p;return u(()=>(b(y),()=>x(y)),[b,x,y]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(o.span,{id:d.textId,...a,ref:_}),d.isSelected&&c.valueNode&&!c.valueNodeHasChildren&&!$(c.value)?L.createPortal(a.children,c.valueNode):null]})},`SelectItemText`)),Ve=`SelectItemIndicator`,He=I.forwardRef(B(function(e,t){let{__scopeSelect:n,...r}=e;return Le(Ve,n).isSelected?(0,R.jsx)(o.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Ue=`SelectScrollUpButton`,We=I.forwardRef(B(function(e,t){let n=Q(Ue,e.__scopeSelect),r=Oe(Ue,e.__scopeSelect),[i,a]=I.useState(!1),o=s(t,r.onScrollButtonChange);return u(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};B(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,R.jsx)(qe,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Ge=`SelectScrollDownButton`,Ke=I.forwardRef(B(function(e,t){let n=Q(Ge,e.__scopeSelect),r=Oe(Ge,e.__scopeSelect),[i,a]=I.useState(!1),o=s(t,r.onScrollButtonChange);return u(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};B(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,R.jsx)(qe,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),qe=I.forwardRef(B(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Q(`SelectScrollButton`,n),s=I.useRef(null),l=K(n),d=I.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return I.useEffect(()=>()=>d(),[d]),u(()=>{l().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[l]),(0,R.jsx)(o.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:c(i.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:c(i.onPointerMove,()=>{a.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:c(i.onPointerLeave,()=>{d()})})},`SelectScrollButtonImpl`)),Je=I.forwardRef(B(function(e,t){let{__scopeSelect:n,...r}=e;return(0,R.jsx)(o.div,{"aria-hidden":!0,...r,ref:t})},`SelectSeparator`)),Ye=`SelectBubbleInput`,Xe=I.forwardRef(B(function({__scopeSelect:e,...t},n){let r=Y(Ye,e),{value:i,onValueChange:a,required:c,disabled:l,name:u,autoComplete:d,form:f,userSelection:p}=r,{nativeOptions:h,nativeSelectKey:g}=r,_=I.useRef(null),v=s(n,_),y=i??``,b=I.useRef(y),x=I.useRef(p),S=I.useRef(!1),C=Array.from(h).some(e=>(e.props.value??``)===``);return I.useEffect(()=>{let e=_.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=p!==null&&p!==x.current;x.current=p;let i=b.current!==y;b.current=y;let a=r&&i;if(r&&!i&&p.value!==y&&!p.hasConsumerStoppedPropagation&&n){S.current=!0;try{n.call(e,p.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{S.current=!1,n.call(e,y)}return}let o=a&&!p.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,y),e.dispatchEvent(t)}},[y,p]),(0,R.jsxs)(o.select,{"aria-hidden":!0,required:c,tabIndex:-1,name:u,autoComplete:d,disabled:l,form:f,onChange:e=>{S.current||a(e.target.value)},...t,style:{...m,...t.style},ref:v,defaultValue:y,children:[$(i)&&!C?(0,R.jsx)(`option`,{value:``}):null,Array.from(h)]},g)},`SelectBubbleInput`));function Ze(e){return typeof e==`function`}B(Ze,`isFunction`);function $(e){return e===``||e===void 0}B($,`shouldShowPlaceholder`);function Qe(e){let t=f(e),n=I.useRef(``),r=I.useRef(0),i=I.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}B(a,`updateSearch`),a(i)},[t]),a=I.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return I.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}B(Qe,`useTypeaheadSearch`);function $e(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=et(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}B($e,`findNextItem`);function et(e,t){return e.map((n,r)=>e[(t+r)%e.length])}B(et,`wrapArray`);var tt={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};tt.node;var nt=k(tt),rt=de,it=he,at=I.forwardRef(({className:e,children:t,...n},r)=>(0,R.jsxs)(pe,{ref:r,className:y(`form-control form-control-single select-trigger flex items-center justify-between gap-2 text-start data-placeholder:text-muted-foreground [&>span]:min-w-0 [&>span]:truncate`,e),...n,children:[t,(0,R.jsx)(ge,{asChild:!0,children:(0,R.jsx)(j,{className:`select-chevron shrink-0 text-muted-foreground`,strokeWidth:1.5,"aria-hidden":`true`})})]}));at.displayName=pe.displayName;var ot=I.forwardRef(({className:e,...t},n)=>(0,R.jsx)(We,{ref:n,className:y(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,R.jsx)(nt,{className:`h-4 w-4`})}));ot.displayName=We.displayName;var st=I.forwardRef(({className:e,...t},n)=>(0,R.jsx)(Ke,{ref:n,className:y(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,R.jsx)(j,{className:`h-4 w-4`})}));st.displayName=Ke.displayName;var ct=I.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,R.jsx)(ye,{children:(0,R.jsxs)(be,{ref:i,className:y(`relative z-50 max-h-(--radix-select-content-available-height) min-w-32 overflow-y-auto overflow-x-hidden rounded-md border border-control-border bg-surface-high text-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-select-content-transform-origin) `,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,R.jsx)(ot,{}),(0,R.jsx)(Ae,{className:y(`p-1`,n===`popper`&&`h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width)`),children:t}),(0,R.jsx)(st,{})]})}));ct.displayName=be.displayName;var lt=I.forwardRef(({className:e,...t},n)=>(0,R.jsx)(Pe,{ref:n,className:y(`py-1.5 pl-8 pr-2 text-sm font-semibold`,e),...t}));lt.displayName=Pe.displayName;var ut=I.forwardRef(({className:e,children:t,...n},r)=>(0,R.jsxs)(Re,{ref:r,className:y(`relative flex min-h-8 w-full cursor-default select-none items-center rounded-xs py-1.5 pl-8 pr-2 text-sm outline-hidden focus:bg-muted focus:text-foreground data-disabled:pointer-events-none data-disabled:opacity-50 max-md:min-h-11 pointer-coarse:min-h-11`,e),...n,children:[(0,R.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,R.jsx)(He,{children:(0,R.jsx)(A,{className:`h-4 w-4`})})}),(0,R.jsx)(Be,{children:t})]}));ut.displayName=Re.displayName;var dt=I.forwardRef(({className:e,...t},n)=>(0,R.jsx)(Je,{ref:n,className:y(`-mx-1 my-1 h-px bg-muted `,e),...t}));dt.displayName=Je.displayName;function ft(e){return e.open?(0,R.jsx)(pt,{...e}):null}function pt({open:e,dirty:t,busy:n=!1,onClose:r,onDiscard:a,testId:o=`form-dialog`,className:s,children:c}){let[l,u]=(0,I.useState)(!1),d=(0,I.useId)(),f=(0,I.useRef)(null),p=(0,I.useRef)(!1),m=(0,I.useRef)(!1),h=(0,I.useRef)(null),g=(0,I.useRef)(null),_=(0,I.useRef)(!1),v=i(()=>e&&(t||n)&&!_.current);(0,I.useEffect)(()=>{if(n)return;let e=g.current?.querySelector(`[role="alert"]`);e instanceof HTMLElement&&e.scrollIntoView({block:`nearest`})},[n]),(0,I.useEffect)(()=>{v.state===`blocked`&&(p.current=!1,u(!0))},[v.state]),(0,I.useEffect)(()=>{if(!e||!t&&!n)return;let r=e=>{_.current||(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,r),()=>window.removeEventListener(`beforeunload`,r)},[e,t,n]);let b=()=>{v.state===`blocked`&&v.reset(),u(!1)},x=()=>{_.current=!0,v.state===`blocked`&&v.reset(),r()};e&&!m.current&&(h.current=document.activeElement instanceof HTMLElement?document.activeElement:null),m.current=e;let C=()=>{n||(t?(p.current=!1,u(!0)):r())};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(F,{open:e,onOpenChange:e=>!e&&C(),children:(0,R.jsx)(N,{ref:g,"data-testid":o,closeDisabled:n,"aria-busy":n,className:y(`work-form-dialog flex w-[min(960px,calc(100vw-3rem))] max-w-none flex-col gap-0 overflow-hidden p-0 max-sm:h-[var(--app-height,100dvh)] max-sm:max-h-[var(--app-height,100dvh)] max-sm:w-full max-sm:rounded-none max-sm:border-0`,s),onCloseAutoFocus:e=>{h.current?.isConnected&&(e.preventDefault(),h.current.focus())},children:c(C,x)})}),(0,R.jsx)(F,{open:l,onOpenChange:e=>e?u(!0):b(),children:(0,R.jsxs)(N,{className:`max-w-sm`,"aria-describedby":d,onOpenAutoFocus:e=>{e.preventDefault(),f.current?.focus()},onCloseAutoFocus:e=>{p.current&&h.current?.isConnected&&(e.preventDefault(),h.current.focus())},children:[(0,R.jsxs)(ne,{children:[(0,R.jsx)(re,{children:`Discard changes?`}),(0,R.jsx)(P,{id:d,children:n?`Saving changes. Wait for this operation to finish.`:`Your form has unsaved changes.`})]}),(0,R.jsxs)(M,{children:[(0,R.jsx)(S,{variant:`ghost`,"data-testid":`discard-form-changes`,disabled:n,onClick:()=>{p.current=!0,_.current=!0,u(!1),a?.(),r(),v.state===`blocked`&&v.proceed()},children:`Discard changes`}),(0,R.jsx)(S,{ref:f,"data-testid":`keep-editing`,onClick:b,children:`Keep editing`})]})]})})]})}export{at as a,ut as i,rt as n,it as o,ct as r,ft as t};
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{t as r}from"./react-dom-DTbwZiiP.js";import{l as i}from"./chunk-OB3PAWPO-1IihCzFx.js";import{C as a,E as o,F as s,I as c,M as l,N as u,P as d,T as f,_ as p,f as m,g as h,h as g,j as _,k as v,l as y,m as b,p as x,t as S,v as C,y as w}from"./button-C91mbQEU.js";import{t as T}from"./dist-bytwC6rk.js";import{n as E,t as ee}from"./es2015-w69PgVrA.js";import{t as D}from"./dist-BKxzy3T8.js";import{t as te}from"./dist-Ct6061MC.js";import{t as O}from"./dist-D8Wfxh48.js";import{h as k}from"./client-BnTXPI20.js";import{t as A}from"./check-N8fVGVDO.js";import{t as j}from"./chevron-down-wgh-M0zj.js";import{a as ne,i as M,n as N,o as re,r as P,t as F}from"./dialog-D86vkhdt.js";var I=e(t(),1),L=e(r(),1),R=n(),z=Object.defineProperty,B=(e,t)=>z(e,`name`,{value:t,configurable:!0}),ie={ItemAligned:`item-aligned`,Popper:`popper`},V={LTR:`ltr`,RTL:`rtl`},H=[` `,`Enter`,`ArrowUp`,`ArrowDown`],U=[` `,`Enter`],W=`Select`,[G,K,ae]=D(W),[q,oe]=d(W,[ae,h]),J=h(),[se,Y]=q(W),[ce,le]=q(W);function ue(e){let{__scopeSelect:t,children:n,open:r,defaultOpen:i,onOpenChange:a,value:o,defaultValue:s,onValueChange:c,dir:u,name:d,autoComplete:f,disabled:p,required:m,form:h,internal_do_not_use_render:g}=e,v=J(t),[y,b]=I.useState(null),[S,C]=I.useState(null),[w,T]=I.useState(!1),E=te(u),[ee,D]=_({prop:r,defaultProp:i??!1,onChange:a,caller:W}),[O,k]=_({prop:o,defaultProp:s,onChange:c,caller:W}),A=I.useRef(null),j=I.useRef(!1),[ne,M]=I.useState(null),N=B(e=>{M({value:e,hasConsumerStoppedPropagation:j.current}),k(e)},`handleUserSelect`),re=I.useRef(O);I.useEffect(()=>{let e=h?y?.ownerDocument.getElementById(h):y?.form;if(e instanceof HTMLFormElement){let t=B(()=>k(re.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[h,y,k]);let P=!y||!!h||!!y.closest(`form`),[F,L]=I.useState(new Set),z=l(),ie=Array.from(F).map(e=>e.props.value).join(`;`),V=I.useCallback(e=>{L(t=>new Set(t).add(e))},[]),H=I.useCallback(e=>{L(t=>{let n=new Set(t);return n.delete(e),n})},[]),U={required:m,trigger:y,onTriggerChange:b,valueNode:S,onValueNodeChange:C,valueNodeHasChildren:w,onValueNodeHasChildrenChange:T,contentId:z,value:O,onValueChange:k,hasConsumerStoppedPropagationRef:j,userSelection:ne,onUserSelect:N,open:ee,onOpenChange:D,dir:E,triggerPointerDownPosRef:A,disabled:p,name:d,autoComplete:f,form:h,nativeOptions:F,nativeSelectKey:ie,isFormControl:P};return(0,R.jsx)(x,{...v,children:(0,R.jsx)(se,{scope:t,...U,children:(0,R.jsx)(G.Provider,{scope:t,children:(0,R.jsx)(ce,{scope:t,onNativeOptionAdd:V,onNativeOptionRemove:H,children:Ze(g)?g(U):n})})})})}B(ue,`SelectProvider`);var de=B(e=>{let{__scopeSelect:t,children:n,...r}=e;return(0,R.jsx)(ue,{__scopeSelect:t,...r,internal_do_not_use_render:({isFormControl:e})=>(0,R.jsxs)(R.Fragment,{children:[n,e?(0,R.jsx)(Xe,{__scopeSelect:t}):null]})})},`Select`),fe=`SelectTrigger`,pe=I.forwardRef(B(function(e,t){let{__scopeSelect:n,disabled:r=!1,...i}=e,a=J(n),l=Y(fe,n),u=l.disabled||r,d=s(t,l.onTriggerChange),f=K(n),p=I.useRef(`touch`),[m,h,g]=Qe(e=>{let t=f().filter(e=>!e.disabled),n=$e(t,e,t.find(e=>e.value===l.value));n!==void 0&&l.onUserSelect(n.value)}),_=B(e=>{u||(l.onOpenChange(!0),g()),e&&(l.triggerPointerDownPosRef.current={x:Math.round(e.pageX),y:Math.round(e.pageY)})},`handleOpen`);return(0,R.jsx)(b,{asChild:!0,...a,children:(0,R.jsx)(o.button,{type:`button`,role:`combobox`,"aria-controls":l.open?l.contentId:void 0,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":`none`,dir:l.dir,"data-state":l.open?`open`:`closed`,disabled:u,"data-disabled":u?``:void 0,"data-placeholder":$(l.value)?``:void 0,...i,ref:d,onClick:c(i.onClick,e=>{e.currentTarget.focus(),p.current!==`mouse`&&_(e)}),onPointerDown:c(i.onPointerDown,e=>{p.current=e.pointerType;let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),e.button===0&&e.ctrlKey===!1&&e.pointerType===`mouse`&&(_(e),e.preventDefault())}),onKeyDown:c(i.onKeyDown,e=>{let t=m.current!==``;!(e.ctrlKey||e.altKey||e.metaKey)&&e.key.length===1&&(l.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),h(e.key)),!(t&&e.key===` `)&&H.includes(e.key)&&(_(),e.preventDefault())})})})},`SelectTrigger`)),me=`SelectValue`,he=I.forwardRef(B(function(e,t){let{__scopeSelect:n,className:r,style:i,children:a,placeholder:c=``,...l}=e,d=Y(me,n),{onValueNodeHasChildrenChange:f}=d,p=a!==void 0,m=s(t,d.onValueNodeChange);u(()=>{f(p)},[f,p]);let h=$(d.value);return(0,R.jsx)(o.span,{...l,asChild:!h&&l.asChild,ref:m,style:{pointerEvents:`none`},children:(0,R.jsx)(I.Fragment,{children:h?c:a},h?`placeholder`:`value`)})},`SelectValue`)),ge=I.forwardRef(B(function(e,t){let{__scopeSelect:n,children:r,...i}=e;return(0,R.jsx)(o.span,{"aria-hidden":!0,...i,ref:t,children:r||`▼`})},`SelectIcon`)),[_e,ve]=q(`SelectPortal`,{forceMount:void 0}),ye=B(e=>{let{__scopeSelect:t,forceMount:n,...r}=e;return(0,R.jsx)(_e,{scope:e.__scopeSelect,forceMount:n,children:(0,R.jsx)(C,{asChild:!0,...r})})},`SelectPortal`),X=`SelectContent`,be=I.forwardRef(B(function(e,t){let n=ve(X,e.__scopeSelect),{forceMount:r=n.forceMount,...i}=e,a=Y(X,e.__scopeSelect),[o,s]=I.useState();return u(()=>{s(new DocumentFragment)},[]),(0,R.jsx)(p,{present:r||a.open,children:({present:e})=>e?(0,R.jsx)(we,{...i,ref:t}):(0,R.jsx)(xe,{...i,fragment:o})})},`SelectContent`)),xe=I.forwardRef(B(function(e,t){let{__scopeSelect:n,children:r,fragment:i}=e;return i?L.createPortal((0,R.jsx)(Se,{scope:n,children:(0,R.jsx)(G.Slot,{scope:n,children:(0,R.jsx)(`div`,{ref:t,children:r})})}),i):null},`SelectContentFragment`)),Z=10,[Se,Q]=q(X),Ce=v(`SelectContent.RemoveScroll`),we=I.forwardRef(B(function(e,t){let{__scopeSelect:n}=e,{position:r=ie.ItemAligned,onCloseAutoFocus:i,onEscapeKeyDown:o,onPointerDownOutside:l,side:u,sideOffset:d,align:f,alignOffset:p,arrowPadding:m,collisionBoundary:h,collisionPadding:g,sticky:_,hideWhenDetached:v,avoidCollisions:y,...b}=e,x=Y(X,n),[S,C]=I.useState(null),[D,te]=I.useState(null),O=s(t,C),[k,A]=I.useState(null),[j,ne]=I.useState(null),M=K(n),[N,re]=I.useState(!1),P=I.useRef(!1),F=I.useRef(!1),L=I.useRef(!1);I.useEffect(()=>{if(S)return ee(S)},[S]),T();let z=I.useCallback(e=>{let[t,...n]=M().map(e=>e.ref.current),[r]=n.slice(-1),i=document.activeElement;for(let n of e)if(n===i||(n?.scrollIntoView({block:`nearest`}),n===t&&D&&(D.scrollTop=0),n===r&&D&&(D.scrollTop=D.scrollHeight),n?.focus(),document.activeElement!==i))return},[M,D]),V=I.useCallback(()=>z([k,S]),[z,k,S]);I.useEffect(()=>{N&&V()},[N,V]);let{onOpenChange:H,triggerPointerDownPosRef:U}=x;I.useEffect(()=>{if(S){let e={x:0,y:0},t=B(t=>{e={x:Math.abs(Math.round(t.pageX)-(U.current?.x??0)),y:Math.abs(Math.round(t.pageY)-(U.current?.y??0))}},`handlePointerMove`),n=B(n=>{e.x<=10&&e.y<=10?n.preventDefault():n.composedPath().includes(S)||H(!1),document.removeEventListener(`pointermove`,t),U.current=null},`handlePointerUp`);return U.current!==null&&(document.addEventListener(`pointermove`,t),document.addEventListener(`pointerup`,n,{capture:!0,once:!0})),()=>{document.removeEventListener(`pointermove`,t),document.removeEventListener(`pointerup`,n,{capture:!0})}}},[S,H,U]),I.useEffect(()=>{let e=B(()=>H(!1),`close`);return window.addEventListener(`blur`,e),window.addEventListener(`resize`,e),()=>{window.removeEventListener(`blur`,e),window.removeEventListener(`resize`,e)}},[H]);let[W,G]=Qe(e=>{let t=M().filter(e=>!e.disabled),n=$e(t,e,t.find(e=>e.ref.current===document.activeElement));n&&setTimeout(()=>n.ref.current?.focus())}),ae=I.useCallback((e,t,n)=>{let r=!F.current;r&&(F.current=!0);let i=!P.current&&!n;x.value!==void 0&&x.value===t||i?(A(e),i&&(P.current=!0)):r&&A(e)},[x.value]),q=I.useCallback(()=>S?.focus(),[S]),oe=I.useCallback((e,t,n)=>{if(!e)return;let r=!L.current;r&&(L.current=!0);let i=!P.current&&!n;(x.value!==void 0&&x.value===t||i||r)&&ne(e)},[x.value]),J=r===ie.Popper?Ee:Te,se=J===Ee?{side:u,sideOffset:d,align:f,alignOffset:p,arrowPadding:m,collisionBoundary:h,collisionPadding:g,sticky:_,hideWhenDetached:v,avoidCollisions:y}:{};return(0,R.jsx)(Se,{scope:n,content:S,viewport:D,onViewportChange:te,itemRefCallback:ae,selectedItem:k,onItemLeave:q,itemTextRefCallback:oe,focusSelectedItem:V,selectedItemText:j,position:r,isPositioned:N,searchRef:W,children:(0,R.jsx)(E,{as:Ce,allowPinchZoom:!0,children:(0,R.jsx)(w,{asChild:!0,trapped:x.open,onMountAutoFocus:e=>{e.preventDefault()},onUnmountAutoFocus:c(i,e=>{x.trigger?.focus({preventScroll:!0}),e.preventDefault()}),children:(0,R.jsx)(a,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:e=>e.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:(0,R.jsx)(J,{role:`listbox`,id:x.contentId,"data-state":x.open?`open`:`closed`,dir:x.dir,onContextMenu:e=>e.preventDefault(),...b,...se,onPlaced:()=>re(!0),ref:O,style:{display:`flex`,flexDirection:`column`,outline:`none`,...b.style},onKeyDown:c(b.onKeyDown,e=>{let t=e.ctrlKey||e.altKey||e.metaKey;if(e.key===`Tab`&&e.preventDefault(),!t&&e.key.length===1&&G(e.key),[`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(e.key)){let t=M().filter(e=>!e.disabled).map(e=>e.ref.current);if([`ArrowUp`,`End`].includes(e.key)&&(t=t.slice().reverse()),[`ArrowUp`,`ArrowDown`].includes(e.key)){let n=e.target,r=t.indexOf(n);t=t.slice(r+1)}setTimeout(()=>z(t)),e.preventDefault()}})})})})})})},`SelectContentImpl`)),Te=I.forwardRef(B(function(e,t){let{__scopeSelect:n,onPlaced:r,...i}=e,a=Y(X,n),c=Q(X,n),[l,d]=I.useState(null),[f,p]=I.useState(null),m=s(t,p),h=K(n),g=I.useRef(!1),_=I.useRef(!0),{viewport:v,selectedItem:y,selectedItemText:b,focusSelectedItem:x}=c,S=I.useCallback(()=>{if(a.trigger&&a.valueNode&&l&&f&&v&&y&&b){let e=a.trigger.getBoundingClientRect(),t=f.getBoundingClientRect(),n=a.valueNode.getBoundingClientRect(),i=b.getBoundingClientRect();if(a.dir!==V.RTL){let r=i.left-t.left,a=n.left-r,o=e.left-a,s=e.width+o,c=Math.max(s,t.width),u=window.innerWidth-Z,d=O(a,[Z,Math.max(Z,u-c)]);l.style.minWidth=s+`px`,l.style.left=d+`px`}else{let r=t.right-i.right,a=window.innerWidth-n.right-r,o=window.innerWidth-e.right-a,s=e.width+o,c=Math.max(s,t.width),u=window.innerWidth-Z,d=O(a,[Z,Math.max(Z,u-c)]);l.style.minWidth=s+`px`,l.style.right=d+`px`}let o=h(),s=window.innerHeight-Z*2,c=v.scrollHeight,u=window.getComputedStyle(f),d=parseInt(u.borderTopWidth,10),p=parseInt(u.paddingTop,10),m=parseInt(u.borderBottomWidth,10),_=parseInt(u.paddingBottom,10),x=d+p+c+_+m,S=Math.min(y.offsetHeight*5,x),C=window.getComputedStyle(v),w=parseInt(C.paddingTop,10),T=parseInt(C.paddingBottom,10),E=e.top+e.height/2-Z,ee=s-E,D=y.offsetHeight/2,te=y.offsetTop+D,k=d+p+te,A=x-k;if(k<=E){let e=o.length>0&&y===o[o.length-1].ref.current;l.style.bottom=`0px`;let t=f.clientHeight-v.offsetTop-v.offsetHeight,n=k+Math.max(ee,D+(e?T:0)+t+m);l.style.height=n+`px`}else{let e=o.length>0&&y===o[0].ref.current;l.style.top=`0px`;let t=Math.max(E,d+v.offsetTop+(e?w:0)+D)+A;l.style.height=t+`px`,v.scrollTop=k-E+v.offsetTop}l.style.margin=`${Z}px 0`,l.style.minHeight=S+`px`,l.style.maxHeight=s+`px`,r?.(),requestAnimationFrame(()=>g.current=!0)}},[h,a.trigger,a.valueNode,l,f,v,y,b,a.dir,r]);u(()=>S(),[S]);let[C,w]=I.useState();u(()=>{f&&w(window.getComputedStyle(f).zIndex)},[f]);let T=I.useCallback(e=>{e&&_.current===!0&&(S(),x?.(),_.current=!1)},[S,x]);return(0,R.jsx)(De,{scope:n,contentWrapper:l,shouldExpandOnScrollRef:g,onScrollButtonChange:T,children:(0,R.jsx)(`div`,{ref:d,style:{display:`flex`,flexDirection:`column`,position:`fixed`,zIndex:C},children:(0,R.jsx)(o.div,{...i,ref:m,style:{boxSizing:`border-box`,maxHeight:`100%`,...i.style}})})})},`SelectItemAlignedPosition`)),Ee=I.forwardRef(B(function(e,t){let{__scopeSelect:n,align:r=`start`,collisionPadding:i=Z,...a}=e,o=J(n);return(0,R.jsx)(g,{...o,...a,ref:t,align:r,collisionPadding:i,style:{boxSizing:`border-box`,...a.style,"--radix-select-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-select-content-available-width":`var(--radix-popper-available-width)`,"--radix-select-content-available-height":`var(--radix-popper-available-height)`,"--radix-select-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-select-trigger-height":`var(--radix-popper-anchor-height)`}})},`SelectPopperPosition`)),[De,Oe]=q(X,{}),ke=`SelectViewport`,Ae=I.forwardRef(B(function(e,t){let{__scopeSelect:n,nonce:r,...i}=e,a=Q(ke,n),l=Oe(ke,n),u=s(t,a.onViewportChange),d=I.useRef(0);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}`},nonce:r}),(0,R.jsx)(G.Slot,{scope:n,children:(0,R.jsx)(o.div,{"data-radix-select-viewport":``,role:`presentation`,...i,ref:u,style:{position:`relative`,flex:1,overflow:`hidden auto`,...i.style},onScroll:c(i.onScroll,e=>{let t=e.currentTarget,{contentWrapper:n,shouldExpandOnScrollRef:r}=l;if(r?.current&&n){let e=Math.abs(d.current-t.scrollTop);if(e>0){let r=window.innerHeight-Z*2,i=parseFloat(n.style.minHeight),a=parseFloat(n.style.height),o=Math.max(i,a);if(o<r){let i=o+e,a=Math.min(r,i),s=i-a;n.style.height=a+`px`,n.style.bottom===`0px`&&(t.scrollTop=s>0?s:0,n.style.justifyContent=`flex-end`)}}}d.current=t.scrollTop})})})]})},`SelectViewport`)),[je,Me]=q(`SelectGroup`),Ne=`SelectLabel`,Pe=I.forwardRef(B(function(e,t){let{__scopeSelect:n,...r}=e,i=Me(Ne,n);return(0,R.jsx)(o.div,{id:i.id,...r,ref:t})},`SelectLabel`)),Fe=`SelectItem`,[Ie,Le]=q(Fe),Re=I.forwardRef(B(function(e,t){let{__scopeSelect:n,value:r,disabled:i=!1,textValue:a,...u}=e,d=Y(Fe,n),p=Q(Fe,n),m=d.value===r,[h,g]=I.useState(a??``),[_,v]=I.useState(!1),y=f(e=>p.itemRefCallback?.(e,r,i)),b=s(t,y),x=l(),S=I.useRef(`touch`);function C(e){d.hasConsumerStoppedPropagationRef.current=e.isPropagationStopped(),d.onUserSelect(r),d.onOpenChange(!1)}return B(C,`handleSelect`),(0,R.jsx)(Ie,{scope:n,value:r,disabled:i,textId:x,isSelected:m,onItemTextChange:I.useCallback(e=>{g(t=>t||(e?.textContent??``).trim())},[]),children:(0,R.jsx)(G.ItemSlot,{scope:n,value:r,disabled:i,textValue:h,children:(0,R.jsx)(o.div,{role:`option`,"aria-labelledby":x,"data-highlighted":_?``:void 0,"aria-selected":m&&_,"data-state":m?`checked`:`unchecked`,"aria-disabled":i||void 0,"data-disabled":i?``:void 0,tabIndex:i?void 0:-1,...u,ref:b,onFocus:c(u.onFocus,()=>v(!0)),onBlur:c(u.onBlur,()=>v(!1)),onClick:c(u.onClick,e=>{i||S.current!==`mouse`&&C(e)}),onPointerUp:c(u.onPointerUp,e=>{i||S.current===`mouse`&&C(e)}),onPointerDown:c(u.onPointerDown,e=>{S.current=e.pointerType}),onPointerMove:c(u.onPointerMove,e=>{S.current=e.pointerType,i?p.onItemLeave?.():S.current===`mouse`&&e.currentTarget.focus({preventScroll:!0})}),onPointerLeave:c(u.onPointerLeave,e=>{e.currentTarget===document.activeElement&&p.onItemLeave?.()}),onKeyDown:c(u.onKeyDown,e=>{i||e.target!==e.currentTarget||(p.searchRef?.current===``||e.key!==` `)&&(U.includes(e.key)&&C(e),e.key===` `&&e.preventDefault())})})})})},`SelectItem`)),ze=`SelectItemText`,Be=I.forwardRef(B(function(e,t){let{__scopeSelect:n,className:r,style:i,...a}=e,c=Y(ze,n),l=Q(ze,n),d=Le(ze,n),p=le(ze,n),[m,h]=I.useState(null),g=f(e=>l.itemTextRefCallback?.(e,d.value,d.disabled)),_=s(t,h,d.onItemTextChange,g),v=m?.textContent,y=I.useMemo(()=>(0,R.jsx)(`option`,{value:d.value,disabled:d.disabled,children:v},d.value),[d.disabled,d.value,v]),{onNativeOptionAdd:b,onNativeOptionRemove:x}=p;return u(()=>(b(y),()=>x(y)),[b,x,y]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(o.span,{id:d.textId,...a,ref:_}),d.isSelected&&c.valueNode&&!c.valueNodeHasChildren&&!$(c.value)?L.createPortal(a.children,c.valueNode):null]})},`SelectItemText`)),Ve=`SelectItemIndicator`,He=I.forwardRef(B(function(e,t){let{__scopeSelect:n,...r}=e;return Le(Ve,n).isSelected?(0,R.jsx)(o.span,{"aria-hidden":!0,...r,ref:t}):null},`SelectItemIndicator`)),Ue=`SelectScrollUpButton`,We=I.forwardRef(B(function(e,t){let n=Q(Ue,e.__scopeSelect),r=Oe(Ue,e.__scopeSelect),[i,a]=I.useState(!1),o=s(t,r.onScrollButtonChange);return u(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollTop>0;a(e)};B(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,R.jsx)(qe,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop-=t.offsetHeight)}}):null},`SelectScrollUpButton`)),Ge=`SelectScrollDownButton`,Ke=I.forwardRef(B(function(e,t){let n=Q(Ge,e.__scopeSelect),r=Oe(Ge,e.__scopeSelect),[i,a]=I.useState(!1),o=s(t,r.onScrollButtonChange);return u(()=>{if(n.viewport&&n.isPositioned){let e=function(){let e=t.scrollHeight-t.clientHeight,n=Math.ceil(t.scrollTop)<e;a(n)};B(e,`handleScroll`);let t=n.viewport;return e(),t.addEventListener(`scroll`,e),()=>t.removeEventListener(`scroll`,e)}},[n.viewport,n.isPositioned]),i?(0,R.jsx)(qe,{...e,ref:o,onAutoScroll:()=>{let{viewport:e,selectedItem:t}=n;e&&t&&(e.scrollTop+=t.offsetHeight)}}):null},`SelectScrollDownButton`)),qe=I.forwardRef(B(function(e,t){let{__scopeSelect:n,onAutoScroll:r,...i}=e,a=Q(`SelectScrollButton`,n),s=I.useRef(null),l=K(n),d=I.useCallback(()=>{s.current!==null&&(window.clearInterval(s.current),s.current=null)},[]);return I.useEffect(()=>()=>d(),[d]),u(()=>{l().find(e=>e.ref.current===document.activeElement)?.ref.current?.scrollIntoView({block:`nearest`})},[l]),(0,R.jsx)(o.div,{"aria-hidden":!0,...i,ref:t,style:{flexShrink:0,...i.style},onPointerDown:c(i.onPointerDown,()=>{s.current===null&&(s.current=window.setInterval(r,50))}),onPointerMove:c(i.onPointerMove,()=>{a.onItemLeave?.(),s.current===null&&(s.current=window.setInterval(r,50))}),onPointerLeave:c(i.onPointerLeave,()=>{d()})})},`SelectScrollButtonImpl`)),Je=I.forwardRef(B(function(e,t){let{__scopeSelect:n,...r}=e;return(0,R.jsx)(o.div,{"aria-hidden":!0,...r,ref:t})},`SelectSeparator`)),Ye=`SelectBubbleInput`,Xe=I.forwardRef(B(function({__scopeSelect:e,...t},n){let r=Y(Ye,e),{value:i,onValueChange:a,required:c,disabled:l,name:u,autoComplete:d,form:f,userSelection:p}=r,{nativeOptions:h,nativeSelectKey:g}=r,_=I.useRef(null),v=s(n,_),y=i??``,b=I.useRef(y),x=I.useRef(p),S=I.useRef(!1),C=Array.from(h).some(e=>(e.props.value??``)===``);return I.useEffect(()=>{let e=_.current;if(!e)return;let t=window.HTMLSelectElement.prototype,n=Object.getOwnPropertyDescriptor(t,`value`).set,r=p!==null&&p!==x.current;x.current=p;let i=b.current!==y;b.current=y;let a=r&&i;if(r&&!i&&p.value!==y&&!p.hasConsumerStoppedPropagation&&n){S.current=!0;try{n.call(e,p.value),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}finally{S.current=!1,n.call(e,y)}return}let o=a&&!p.hasConsumerStoppedPropagation;if(i&&n){let t=new Event(`change`,{bubbles:o});n.call(e,y),e.dispatchEvent(t)}},[y,p]),(0,R.jsxs)(o.select,{"aria-hidden":!0,required:c,tabIndex:-1,name:u,autoComplete:d,disabled:l,form:f,onChange:e=>{S.current||a(e.target.value)},...t,style:{...m,...t.style},ref:v,defaultValue:y,children:[$(i)&&!C?(0,R.jsx)(`option`,{value:``}):null,Array.from(h)]},g)},`SelectBubbleInput`));function Ze(e){return typeof e==`function`}B(Ze,`isFunction`);function $(e){return e===``||e===void 0}B($,`shouldShowPlaceholder`);function Qe(e){let t=f(e),n=I.useRef(``),r=I.useRef(0),i=I.useCallback(e=>{let i=n.current+e;t(i);function a(e){n.current=e,window.clearTimeout(r.current),e!==``&&(r.current=window.setTimeout(()=>a(``),1e3))}B(a,`updateSearch`),a(i)},[t]),a=I.useCallback(()=>{n.current=``,window.clearTimeout(r.current)},[]);return I.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,a]}B(Qe,`useTypeaheadSearch`);function $e(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=et(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.textValue.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}B($e,`findNextItem`);function et(e,t){return e.map((n,r)=>e[(t+r)%e.length])}B(et,`wrapArray`);var tt={name:`chevron-up`,size:24,node:[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]};tt.node;var nt=k(tt),rt=de,it=he,at=I.forwardRef(({className:e,children:t,...n},r)=>(0,R.jsxs)(pe,{ref:r,className:y(`form-control form-control-single select-trigger flex items-center justify-between gap-2 text-start data-placeholder:text-muted-foreground [&>span]:min-w-0 [&>span]:truncate`,e),...n,children:[t,(0,R.jsx)(ge,{asChild:!0,children:(0,R.jsx)(j,{className:`select-chevron shrink-0 text-muted-foreground`,strokeWidth:1.5,"aria-hidden":`true`})})]}));at.displayName=pe.displayName;var ot=I.forwardRef(({className:e,...t},n)=>(0,R.jsx)(We,{ref:n,className:y(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,R.jsx)(nt,{className:`h-4 w-4`})}));ot.displayName=We.displayName;var st=I.forwardRef(({className:e,...t},n)=>(0,R.jsx)(Ke,{ref:n,className:y(`flex cursor-default items-center justify-center py-1`,e),...t,children:(0,R.jsx)(j,{className:`h-4 w-4`})}));st.displayName=Ke.displayName;var ct=I.forwardRef(({className:e,children:t,position:n=`popper`,...r},i)=>(0,R.jsx)(ye,{children:(0,R.jsxs)(be,{ref:i,className:y(`relative z-50 max-h-(--radix-select-content-available-height) min-w-32 overflow-y-auto overflow-x-hidden rounded-md border border-control-border bg-surface-high text-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-select-content-transform-origin) `,n===`popper`&&`data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1`,e),position:n,...r,children:[(0,R.jsx)(ot,{}),(0,R.jsx)(Ae,{className:y(`p-1`,n===`popper`&&`h-(--radix-select-trigger-height) w-full min-w-(--radix-select-trigger-width)`),children:t}),(0,R.jsx)(st,{})]})}));ct.displayName=be.displayName;var lt=I.forwardRef(({className:e,...t},n)=>(0,R.jsx)(Pe,{ref:n,className:y(`py-1.5 pl-8 pr-2 text-sm font-semibold`,e),...t}));lt.displayName=Pe.displayName;var ut=I.forwardRef(({className:e,children:t,...n},r)=>(0,R.jsxs)(Re,{ref:r,className:y(`relative flex min-h-8 w-full cursor-default select-none items-center rounded-xs py-1.5 pl-8 pr-2 text-sm outline-hidden focus:bg-muted focus:text-foreground data-disabled:pointer-events-none data-disabled:opacity-50 max-md:min-h-11 pointer-coarse:min-h-11`,e),...n,children:[(0,R.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,R.jsx)(He,{children:(0,R.jsx)(A,{className:`h-4 w-4`})})}),(0,R.jsx)(Be,{children:t})]}));ut.displayName=Re.displayName;var dt=I.forwardRef(({className:e,...t},n)=>(0,R.jsx)(Je,{ref:n,className:y(`-mx-1 my-1 h-px bg-muted `,e),...t}));dt.displayName=Je.displayName;function ft(e){return e.open?(0,R.jsx)(pt,{...e}):null}function pt({open:e,dirty:t,busy:n=!1,onClose:r,onDiscard:a,testId:o=`form-dialog`,className:s,children:c}){let[l,u]=(0,I.useState)(!1),d=(0,I.useId)(),f=(0,I.useRef)(null),p=(0,I.useRef)(!1),m=(0,I.useRef)(!1),h=(0,I.useRef)(null),g=(0,I.useRef)(null),_=(0,I.useRef)(!1),v=i(()=>e&&(t||n)&&!_.current);(0,I.useEffect)(()=>{if(n)return;let e=g.current?.querySelector(`[role="alert"]`);e instanceof HTMLElement&&e.scrollIntoView({block:`nearest`})},[n]),(0,I.useEffect)(()=>{v.state===`blocked`&&(p.current=!1,u(!0))},[v.state]),(0,I.useEffect)(()=>{if(!e||!t&&!n)return;let r=e=>{_.current||(e.preventDefault(),e.returnValue=``)};return window.addEventListener(`beforeunload`,r),()=>window.removeEventListener(`beforeunload`,r)},[e,t,n]);let b=()=>{v.state===`blocked`&&v.reset(),u(!1)},x=()=>{_.current=!0,v.state===`blocked`&&v.reset(),r()};e&&!m.current&&(h.current=document.activeElement instanceof HTMLElement?document.activeElement:null),m.current=e;let C=()=>{n||(t?(p.current=!1,u(!0)):r())};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(F,{open:e,onOpenChange:e=>!e&&C(),children:(0,R.jsx)(N,{ref:g,"data-testid":o,closeDisabled:n,"aria-busy":n,className:y(`work-form-dialog flex w-[min(960px,calc(100vw-3rem))] max-w-none flex-col gap-0 overflow-hidden p-0 max-sm:h-[var(--app-height,100dvh)] max-sm:max-h-[var(--app-height,100dvh)] max-sm:w-full max-sm:rounded-none max-sm:border-0`,s),onCloseAutoFocus:e=>{h.current?.isConnected&&(e.preventDefault(),h.current.focus())},children:c(C,x)})}),(0,R.jsx)(F,{open:l,onOpenChange:e=>e?u(!0):b(),children:(0,R.jsxs)(N,{className:`max-w-sm`,"aria-describedby":d,onOpenAutoFocus:e=>{e.preventDefault(),f.current?.focus()},onCloseAutoFocus:e=>{p.current&&h.current?.isConnected&&(e.preventDefault(),h.current.focus())},children:[(0,R.jsxs)(ne,{children:[(0,R.jsx)(re,{children:`Discard changes?`}),(0,R.jsx)(P,{id:d,children:n?`Saving changes. Wait for this operation to finish.`:`Your form has unsaved changes.`})]}),(0,R.jsxs)(M,{children:[(0,R.jsx)(S,{variant:`ghost`,"data-testid":`discard-form-changes`,disabled:n,onClick:()=>{p.current=!0,_.current=!0,u(!1),a?.(),r(),v.state===`blocked`&&v.proceed()},children:`Discard changes`}),(0,R.jsx)(S,{ref:f,"data-testid":`keep-editing`,onClick:b,children:`Keep editing`})]})]})})]})}export{at as a,ut as i,rt as n,it as o,ct as r,ft as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-DSDNlrLa.js";import{n as t,t as n}from"./jsx-runtime-CVMpzJz9.js";import{m as r,p as i,t as a}from"./chunk-OB3PAWPO-1IihCzFx.js";import{t as o}from"./circle-alert-OZ-kwnCD.js";import{t as s}from"./circle-check-DQM5o2QS.js";import{c}from"./useIntegrations-CkfXwYNs.js";var l=e(t(),1),u=n(),d=`/settings?settingsSection=integrations&integrationsTab=connections`;function f(){let{name:e=``}=i(),[t]=r(),n=c(),f=t.get(`code`),p=t.get(`state`),m=t.get(`error_description`)??t.get(`error`),h=(0,l.useRef)(!1);(0,l.useEffect)(()=>{!h.current&&f&&p&&(h.current=!0,n.mutate({name:e,code:f,state:p}))},[n,e,f,p]);let g=m??(!f||!p?`The sign-in response is missing its code.`:n.error?.message);return(0,u.jsxs)(`main`,{className:`mx-auto max-w-md p-6`,"data-testid":`integration-callback`,children:[(0,u.jsxs)(`h1`,{className:`mb-3 font-headline text-base`,children:[`Sign in to `,e]}),g?(0,u.jsxs)(`p`,{role:`alert`,className:`flex gap-2 text-sm text-error`,children:[(0,u.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),(0,u.jsx)(`span`,{className:`min-w-0 wrap-break-word`,children:g})]}):n.isSuccess?(0,u.jsxs)(`p`,{role:`status`,className:`flex gap-2 text-sm`,children:[(0,u.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-success`,"aria-hidden":!0}),`Signed in. ORC and the `,(0,u.jsx)(`code`,{children:`spec`}),` CLI now use this connection's tokens.`]}):(0,u.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Finishing sign-in…`}),(0,u.jsx)(a,{to:d,className:`mt-4 inline-block text-sm text-primary underline`,children:`Back to connections`})]})}export{f as default};