@hearsay-tools/squawk 0.19.0-dev.9291 → 0.19.0-dev.9292

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 (123) hide show
  1. package/dist/contract/hosts.d.ts +76 -1
  2. package/dist/contract/index.d.ts +1 -0
  3. package/dist/contract/index.js +1354 -1288
  4. package/dist/contract/project-signal.d.ts +31 -0
  5. package/dist/delegation/routes.d.ts +4 -4
  6. package/dist/delegation/transport.d.ts +10 -10
  7. package/dist/features/automations/tools.d.ts +8 -8
  8. package/dist/features/hosts/index.js +2 -0
  9. package/dist/features/hosts/index.js.map +1 -1
  10. package/dist/features/hosts/routes.d.ts +45 -1
  11. package/dist/features/hosts/routes.js +109 -1
  12. package/dist/features/hosts/routes.js.map +1 -1
  13. package/dist/features/hosts/runs-index-patch.d.ts +5 -0
  14. package/dist/features/hosts/runs-index-patch.js +36 -0
  15. package/dist/features/hosts/runs-index-patch.js.map +1 -1
  16. package/dist/features/hosts/runs-index.d.ts +9 -1
  17. package/dist/features/hosts/runs-index.js +27 -0
  18. package/dist/features/hosts/runs-index.js.map +1 -1
  19. package/dist/runs/run-exits.d.ts +352 -352
  20. package/dist/runs/run-index.d.ts +2 -0
  21. package/dist/runs/run-index.js +9 -1
  22. package/dist/runs/run-index.js.map +1 -1
  23. package/dist/server/repo-routes.d.ts +13 -13
  24. package/dist/server/server.d.ts +1379 -1379
  25. package/dist/workflows/continuation-admission.d.ts +72 -72
  26. package/dist/workflows/input-acknowledgement.d.ts +24 -24
  27. package/package.json +4 -4
  28. package/web/dist/assets/accounts-section-BHP8K_nY.js +1 -0
  29. package/web/dist/assets/activity-motion-DEEIuaki.js +1 -0
  30. package/web/dist/assets/{activity-route-CruXBXE5.js → activity-route-vtZmQsDB.js} +1 -1
  31. package/web/dist/assets/agent-accounts-BC78GKYv.js +1 -0
  32. package/web/dist/assets/{agent-config-section-BUxTgHrB.js → agent-config-section-CbnVaIx7.js} +1 -1
  33. package/web/dist/assets/{agent-defaults-section-BXUzcpEv.js → agent-defaults-section-Blxd9IpY.js} +1 -1
  34. package/web/dist/assets/{appearance-DnPsNI40.js → appearance-B_y9StVj.js} +1 -1
  35. package/web/dist/assets/{archive-on-merge-field-DR-KA2nj.js → archive-on-merge-field-DlChylWt.js} +1 -1
  36. package/web/dist/assets/{ask-card-DqWVy7zb.js → ask-card-DzWKRJ1x.js} +3 -3
  37. package/web/dist/assets/attention-C33sN0aA.js +1 -0
  38. package/web/dist/assets/automations-route-DxE9u9p0.js +2 -0
  39. package/web/dist/assets/{commit-list-zMKEapLK.js → commit-list-SxBDO_q5.js} +1 -1
  40. package/web/dist/assets/diff-B6Ye5Xg9.js +3 -0
  41. package/web/dist/assets/{diff-controls-DbkfJxfp.js → diff-controls-BFQOIJ97.js} +1 -1
  42. package/web/dist/assets/{diff-view-Cl7rXVa_.js → diff-view-BkF3xtYW.js} +1 -1
  43. package/web/dist/assets/{discard-changes-dialog-BYLEBMpG.js → discard-changes-dialog-CaS0koto.js} +1 -1
  44. package/web/dist/assets/{file-preview-CBjQS3sX.js → file-preview-ByWn2eDz.js} +1 -1
  45. package/web/dist/assets/{folder-browser-_2PCbZWK.js → folder-browser-CHTNDBIU.js} +1 -1
  46. package/web/dist/assets/{git-toolbar-CAAZ5T8F.js → git-toolbar-COI-N232.js} +1 -1
  47. package/web/dist/assets/github-CAQJIg-J.js +1 -0
  48. package/web/dist/assets/{global-activity-route-BQz9m_XA.js → global-activity-route-99-UqSlC.js} +1 -1
  49. package/web/dist/assets/hosts-BDfuQnus.js +1 -0
  50. package/web/dist/assets/index-BAXboPqe.js +21 -0
  51. package/web/dist/assets/label-Qj4HjGeN.js +1 -0
  52. package/web/dist/assets/{markdown-CcQNTOHx.js → markdown-D7p7x8Pe.js} +1 -1
  53. package/web/dist/assets/{open-in-menu-WJ8dhdTo.js → open-in-menu-D07DgRwh.js} +1 -1
  54. package/web/dist/assets/{option-select-DGRezng8.js → option-select-BvsSDWBz.js} +1 -1
  55. package/web/dist/assets/{preferences-section-DfiqoVZx.js → preferences-section-DkdcKxmS.js} +1 -1
  56. package/web/dist/assets/{preview-DXX3jdRy.js → preview-7NPVVq1D.js} +1 -1
  57. package/web/dist/assets/{preview-pane-connected-Bf6SWOsM.js → preview-pane-connected-B3f0fR6q.js} +2 -2
  58. package/web/dist/assets/{project-location-8EYHMbCE.js → project-location-CvZY7aOx.js} +1 -1
  59. package/web/dist/assets/{project-router-TP6DSj1S.js → project-router-l_pJCK5X.js} +1 -1
  60. package/web/dist/assets/project-scope-context-_6sNMsAf.js +4 -0
  61. package/web/dist/assets/{projects-section-CaKm84OL.js → projects-section-DGzDfKN_.js} +1 -1
  62. package/web/dist/assets/{prompt-templates-section-Bh6YEqh0.js → prompt-templates-section-DbHe-j9Z.js} +1 -1
  63. package/web/dist/assets/queries-CPNrCEon.js +1 -0
  64. package/web/dist/assets/read-state-BXLUf0Xi.js +1 -0
  65. package/web/dist/assets/reference-chip-B32qTHb5.js +1 -0
  66. package/web/dist/assets/{remote-settings-notice-cNffux8C.js → remote-settings-notice-ByPYNQyB.js} +1 -1
  67. package/web/dist/assets/{repo-git-nFi9DHBQ.js → repo-git-4rKalM-L.js} +1 -1
  68. package/web/dist/assets/{report-reader-BbA7ERJe.js → report-reader-IAYhP0KQ.js} +1 -1
  69. package/web/dist/assets/{report-selection-DOq2dcjz.js → report-selection-DCC-F7i6.js} +1 -1
  70. package/web/dist/assets/{reports-iMUK2IiW.js → reports-BP_hajNp.js} +1 -1
  71. package/web/dist/assets/{resources-section-BsPU-yD9.js → resources-section-QNbLbu3j.js} +1 -1
  72. package/web/dist/assets/{review-notes-drafts-BncrXliY.js → review-notes-drafts-CB8u-M0E.js} +1 -1
  73. package/web/dist/assets/{review-panel-CTc1ypIJ.js → review-panel-Bw8yG2xg.js} +1 -1
  74. package/web/dist/assets/{review-strip-D1gmgNIH.js → review-strip-BojRnCkg.js} +1 -1
  75. package/web/dist/assets/{run-detail-refresh-B4t_zvMa.js → run-detail-refresh-CZ7VyCgP.js} +1 -1
  76. package/web/dist/assets/{run-diff-CbyXSgBK.js → run-diff-CMZgQG9B.js} +1 -1
  77. package/web/dist/assets/run-header-D7LZBbaL.js +2 -0
  78. package/web/dist/assets/{select--NKdUD0C.js → select-D9BIA_Kn.js} +1 -1
  79. package/web/dist/assets/{session-context-section-D02yRmGY.js → session-context-section-CxFRidmv.js} +1 -1
  80. package/web/dist/assets/{settings-agent-picker-GPhOc6Lz.js → settings-agent-picker-Cy_ZpuNd.js} +1 -1
  81. package/web/dist/assets/{settings-save-bar-CroXxZIi.js → settings-save-bar-DzbndGGQ.js} +1 -1
  82. package/web/dist/assets/settings-shell-DS8k_xP6.js +1 -0
  83. package/web/dist/assets/{sidebar-section-BOtjR98E.js → sidebar-section-CY978tNF.js} +1 -1
  84. package/web/dist/assets/{skills-C7MuiePR.js → skills-WZ5YRCbF.js} +1 -1
  85. package/web/dist/assets/{status-dot-Bn3O77El.js → status-dot-Dvy-rnDJ.js} +1 -1
  86. package/web/dist/assets/{tab-link-BeONvGY1.js → tab-link-BPkGPOYd.js} +1 -1
  87. package/web/dist/assets/task-changes-Dd2KHRQ6.js +5 -0
  88. package/web/dist/assets/task-commits-De0FVgKP.js +1 -0
  89. package/web/dist/assets/{task-file-scope-BfJ7TDbf.js → task-file-scope-C_cr_ix-.js} +1 -1
  90. package/web/dist/assets/{task-files-CNz4PSKs.js → task-files-resMdu9u.js} +1 -1
  91. package/web/dist/assets/{task-github-item-B0mRxbLm.js → task-github-item-Hz1RbO88.js} +1 -1
  92. package/web/dist/assets/task-groups-Bc_WNTMe.js +1 -0
  93. package/web/dist/assets/task-thread-D7vUf0g7.js +2 -0
  94. package/web/dist/assets/{thread-state-B_uTIWzc.js → thread-state-Bjh3rImx.js} +1 -1
  95. package/web/dist/assets/{unified-diff-JD9Q6oCe.js → unified-diff-weWjKedZ.js} +1 -1
  96. package/web/dist/assets/use-finish-run-BuyJkeEN.js +1 -0
  97. package/web/dist/assets/{use-hand-to-agent-state-zwUimLza.js → use-hand-to-agent-state-CSDPzpM7.js} +1 -1
  98. package/web/dist/assets/use-path-bases-DgEkRWYi.js +1 -0
  99. package/web/dist/assets/use-workspace-config-save-M2ethek2.js +1 -0
  100. package/web/dist/assets/{workflows-BXDmsEl-.js → workflows-DtnnAq4w.js} +1 -1
  101. package/web/dist/assets/{workspace-tools-Ehk2KrtT.js → workspace-tools-CSLTEwLa.js} +1 -1
  102. package/web/dist/assets/{worktrees-section-DWZwtc3-.js → worktrees-section-Crp31i8F.js} +1 -1
  103. package/web/dist/index.html +17 -14
  104. package/web/dist/assets/accounts-section-uuhrLHok.js +0 -1
  105. package/web/dist/assets/activity-motion-CHyZRjxl.js +0 -1
  106. package/web/dist/assets/agent-accounts-CSU96w_T.js +0 -1
  107. package/web/dist/assets/automations-route-BmCWqncy.js +0 -2
  108. package/web/dist/assets/diff-BPw0S-BU.js +0 -3
  109. package/web/dist/assets/github-DehUrgzW.js +0 -1
  110. package/web/dist/assets/hosts-BEeMKHcf.js +0 -1
  111. package/web/dist/assets/index-D0RESQCN.js +0 -21
  112. package/web/dist/assets/label-VKt-7Z5C.js +0 -1
  113. package/web/dist/assets/project-scope-context-BWHk0niI.js +0 -4
  114. package/web/dist/assets/queries-Byfl3YoC.js +0 -1
  115. package/web/dist/assets/reference-chip-rDOAte2y.js +0 -1
  116. package/web/dist/assets/run-header-BREol2Ej.js +0 -2
  117. package/web/dist/assets/settings-shell-CEDsPkJW.js +0 -1
  118. package/web/dist/assets/task-changes-CPDdG-BK.js +0 -5
  119. package/web/dist/assets/task-commits-BFWXi7xF.js +0 -1
  120. package/web/dist/assets/task-thread-DH9xiw7O.js +0 -2
  121. package/web/dist/assets/use-finish-run-D7Ll1bwP.js +0 -1
  122. package/web/dist/assets/use-path-bases-BmFE7O79.js +0 -1
  123. package/web/dist/assets/use-workspace-config-save-71tIi9IP.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{K as r,M as i,Q as a,S as o,St as s,U as c,W as l,Z as u,bt as d,g as f,gt as p,mt as m,on as h,pt as g,sn as _,xt as v,yr as y}from"./queries-Byfl3YoC.js";import{I as b,Qt as x,a as S,ea as C,r as w,wn as T,yn as ee,zn as E}from"./project-scope-context-BWHk0niI.js";import{c as D}from"./design-icons-QbNMZniQ.js";import{t as O}from"./button-BV_AiLj2.js";import{t as k}from"./switch-B9OfOEzC.js";import{t as A}from"./status-dot-Bn3O77El.js";import{n as j}from"./agent-accounts-CSU96w_T.js";import{t as M}from"./centered-state-N8vWM_Hw.js";import{I as N,Mn as P,P as F,R as I}from"./index-D0RESQCN.js";import{t as te}from"./textarea-BGp28xFr.js";import{t as L}from"./option-select-DGRezng8.js";import{a as ne,i as R,n as z,r as B,t as V}from"./settings-agent-picker-GPhOc6Lz.js";import{n as H,t as U}from"./save-cue-CpHgT93o.js";import{n as W}from"./settings-field-AyinSFR_.js";import{r as G}from"./settings-save-bar-CroXxZIi.js";import{n as K}from"./saved-draft-BwzBc-_Y.js";var q=e(t(),1),J=n(),Y={connected:P(`connected`),disconnected:P(`disconnected`),"not-installed":P(`not-installed`),unknown:P(`unknown`)};function X(e,t,n){return{providers:e.providers.map(e=>e.provider===t?{...e,enabled:n}:e)}}function re(e,t){return e?Y[e]:t?{label:`Checking…`,tone:`neutral`}:Y.unknown}function ie(e,t){return e===`unknown`||t&&!e}function ae({provider:e,state:t,current:n,statusIsError:r}){return t===`not-installed`?(0,J.jsxs)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:[`Install `,e.displayName,`, then run `,(0,J.jsx)(`code`,{children:e.loginCommand}),`.`]}):ie(t,r)?(0,J.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:`Verification failed. Check again when the provider is available.`}):n?.hint?(0,J.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:n.hint}):null}function oe({provider:e,state:t,current:n,isConnecting:r,incidentId:i,refresh:a,connect:o,retry:s,queueToggle:c}){let l=t===`disconnected`||t===`unknown`,u=H();return(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t===`not-installed`?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(U,{saved:u.saved}),(0,J.jsx)(k,{checked:n?.enabled??!0,"aria-label":`Use ${e.displayName}`,onCheckedChange:t=>c(e.id,t,u.flash)})]}),l?(0,J.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate(void 0,{onError:e=>S(e.message,{tone:`danger`})}),children:`Check again`}):null,t===`disconnected`&&e.browserLogin?(0,J.jsx)(z,{provider:e.id,label:e.displayName}):null,t===`disconnected`&&e.terminalLogin!==!1?(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:r?`Opening…`:`Connect`}):null,i===void 0?null:(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:s.isPending,onClick:()=>s.mutate({provider:e.id,authFailureId:i},{onSuccess:()=>S(`${e.displayName} can be tried again.`),onError:e=>S(e.message,{tone:`danger`})}),children:`Try again`})]})}function se({manual:e,provider:t,connected:n,onCopy:r}){return e===null||e.provider!==t||n?null:(0,J.jsxs)(`div`,{role:`region`,"aria-label":`${e.label} manual sign-in`,className:`rounded-md border border-pending/40 bg-pending/5 px-3.5 py-3`,children:[(0,J.jsx)(`p`,{className:`text-[13px] text-foreground`,children:e.message}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`code`,{className:`min-w-0 flex-1 overflow-x-auto rounded-sm bg-muted px-2 py-1.5 text-xs`,children:e.command}),(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r(e.command),children:`Copy command`})]})]})}function ce(){let e=d(),t=l(),n=r(),i=u(),a=C(),[o,s]=(0,q.useState)(null),c=(0,q.useRef)(Promise.resolve()),f=(0,q.useRef)({}),p=(0,q.useRef)({}),h=(0,q.useRef)(t.data);(0,q.useEffect)(()=>{o&&E(t.data,o.provider)?.status===`connected`&&s(null)},[o,t.data]),(0,q.useEffect)(()=>{if(t.data){if(Object.values(p.current).every(e=>e===0)||!h.current){h.current=t.data;return}h.current={providers:t.data.providers.map(e=>({...e,enabled:(p.current[e.provider]??0)>0?E(h.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[t.data]);let b=(0,q.useCallback)((e,t,n)=>{let r=_.providerStatus,i=a.getQueryData(r);if(!i)return;h.current||=i;let o=X(i,e,t);p.current[e]=(p.current[e]??0)+1,a.setQueryData(r,o);let s=(f.current[e]??0)+1;f.current[e]=s,c.current=c.current.then(async()=>{try{let i=await ee(e,t),o=E(i,e)?.enabled;if(o===void 0)return;if(h.current=X(h.current??i,e,o),s===f.current[e]){let t=a.getQueryData(r);a.setQueryData(r,t?X(t,e,o):i),n()}}catch(t){if(s===f.current[e]){let n=E(h.current,e)?.enabled,i=a.getQueryData(r);i&&n!==void 0?a.setQueryData(r,X(i,e,n)):h.current?a.setQueryData(r,h.current):a.removeQueries({queryKey:r,exact:!0}),S(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{p.current[e]=(p.current[e]??0)-1}})},[a]),w=y({mutationFn:e=>x(e),onSuccess:async(e,t)=>{s(null),S(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await a.invalidateQueries({queryKey:_.providerStatus}),await v(a,t,`none`)},onError:(t,n)=>{if(t instanceof T&&t.command){let r=g(e.data,n);s({provider:n,label:r,message:t.message,command:t.command});return}S(t.message,{tone:`danger`})}}),D=async e=>{try{await navigator.clipboard.writeText(e),S(`Command copied`)}catch{S(`Could not copy the command`,{tone:`danger`})}};return(0,J.jsxs)(`section`,{id:`providers`,"data-slot":`provider-settings`,className:`scroll-mt-20`,children:[(0,J.jsxs)(`div`,{className:`mb-2`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Providers`}),(0,J.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Connect the coding agents available on this computer.`})]}),t.isError?(0,J.jsxs)(`div`,{role:`alert`,className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border border-danger/30 bg-danger/5 px-3 py-2.5`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:`Provider status could not be loaded`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.error.message})]}),(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:t.isFetching,onClick:()=>void t.refetch(),children:`Retry`})]}):null,(0,J.jsx)(`div`,{className:`flex flex-col gap-2`,children:m(e.data).map(e=>{let r=E(t.data,e.id),a=r?.status,s=re(a,t.isPending),c=w.isPending&&w.variables===e.id,l=r?.authFailureId;return(0,J.jsxs)(q.Fragment,{children:[(0,J.jsxs)(`div`,{"data-slot":`provider-card`,"data-provider":e.id,className:`rounded-md border border-border bg-card px-3.5 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:e.displayName}),(0,J.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(A,{tone:s.tone,pulse:t.isPending}),(0,J.jsx)(`span`,{children:s.label}),r?.enabled===!1?(0,J.jsx)(`span`,{children:`Disabled`}):null]}),(0,J.jsx)(ae,{provider:e,state:a,current:r,statusIsError:t.isError})]}),(0,J.jsx)(oe,{provider:e,state:a,current:r,isConnecting:c,incidentId:l,refresh:n,connect:w,retry:i,queueToggle:b})]}),l===void 0?null:(0,J.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Use this after completing the provider sign-in flow. Squawk cannot validate the credential without a task/model request; it will verify it on the next task.`})]}),(0,J.jsx)(se,{manual:o,provider:e.id,connected:a===`connected`,onCopy:D})]},e.id)})})]})}var Z=2e4;function le(){let e=f(),t=d(),n=s(p(t.data)),r=l();return e.isPending?(0,J.jsx)(`p`,{"data-slot":`agents-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent settings…`}):e.isError?(0,J.jsx)(M,{icon:(0,J.jsx)(D,{}),tone:`danger`,title:`Agent settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,J.jsx)(ue,{config:e.data,catalogs:n,providerStatus:r,runners:t.data})}function ue({config:e,catalogs:t,providerStatus:n,runners:r}){let i=o(),a=C(),s=y({mutationFn:e=>b(e),onSuccess:e=>{a.setQueryData(h.config,e),a.invalidateQueries({queryKey:h.health}),a.invalidateQueries({queryKey:h.repo})},onError:e=>S(e.message,{tone:`danger`})}),[c,l]=K(e.systemPrompt??``),u=c.trim(),d=u===(e.systemPrompt??``),f=u.length>Z;G({dirty:!d,invalid:f,busy:s.isPending,save:()=>s.mutateAsync({systemPrompt:u===``?null:u}),discard:()=>l(e.systemPrompt??``)});let p=H(),g=H(),_=H(),v=H(),x=H(),w=(e,t)=>s.mutate(e,{onSuccess:t});return(0,J.jsxs)(`div`,{"data-slot":`agent-defaults-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,J.jsx)(Q,{defaultRunner:e.defaultRunner,providerStatus:n,saving:s.isPending,saved:p.saved,onSaved:p.flash,onPick:e=>w({defaultRunner:e},p.flash)}),(0,J.jsx)(W,{wide:!0,title:`Default model`,hint:e.modelsLocked?`Models are locked to the defaults configured in the native coding-agent settings.`:`The model preselected in the composer for each runner. Runner default lets the runner decide per task.`,saved:e.modelsLocked?void 0:g.saved,children:(0,J.jsx)(`div`,{"data-slot":`agents-model-rows`,className:`flex flex-col gap-2.5`,children:m(r).map(i=>{let{providerConnected:a,providerReason:o}=ne(n,i.id),c=t[i.id],l=N(i.id,r,c),u=I(i.id,r,c?.data,[e.defaultModels[i.id]]),d=e.defaultModels[i.id]??``,f=u.find(e=>e.id===d)?.label??d??`Runner default`;return(0,J.jsxs)(`label`,{className:`settings-option-row`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h3`,{children:i.displayName})}),e.modelsLocked?(0,J.jsx)(`output`,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,title:`Model selection is locked to native coding-agent settings.`,className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs`,children:f}):(0,J.jsx)(L,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,value:d,title:o??i.pickerDescription,disabled:s.isPending||!a,onValueChange:e=>w({defaultModels:{[i.id]:e||null}},g.flash),className:`settings-select max-w-full bg-card`,options:[...u.map(e=>({value:e.id,label:e.label})),...l?[{value:F,label:l,disabled:!0}]:[]]})]},i.id)})})}),(0,J.jsxs)(W,{wide:!0,title:`System prompt`,hint:`Extra instructions for every run in this project.`,reportsDirty:!0,children:[(0,J.jsx)(te,{"aria-label":`System prompt`,"data-slot":`agents-system-prompt`,value:c,onChange:e=>l(e.target.value),placeholder:`Extra rules for every agent run — conventions, tone, review requirements…`,className:`min-h-48 w-full`}),(0,J.jsx)(de,{length:u.length,overLimit:f})]}),(0,J.jsxs)(`section`,{"data-slot":`agents-task-runs`,className:`settings-field flex flex-col gap-5`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Task runs`}),(0,J.jsx)($,{title:`Live title updates`,hint:`Refresh a task's short title through the namer model as the run progresses. A manual rename always wins and stops updates for that task.`,saved:_.saved,children:(0,J.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,J.jsx)(k,{"aria-label":`Live title updates`,"data-slot":`agents-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:s.isPending,onCheckedChange:e=>w({liveTitleUpdates:e},_.flash)}),(0,J.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})}),(0,J.jsx)($,{title:`Review changes before finishing`,hint:`When on, a task with changes pauses so you can Accept, Send back, or open a Draft PR. Autonomous tasks always skip this and finish on their own. Default: off — tasks finish without asking.`,saved:v.saved,children:(0,J.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,J.jsx)(k,{"aria-label":`Review changes before finishing`,"data-slot":`agents-review-gate`,checked:e.reviewGate??!1,disabled:s.isPending,onCheckedChange:e=>w({reviewGate:e},v.flash)}),(0,J.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,J.jsx)($,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,saved:x.saved,children:i.data?.info?(0,J.jsx)(L,{"aria-label":`Base branch`,"data-slot":`agents-base-branch`,value:e.baseBranch??``,disabled:s.isPending,onValueChange:e=>w({baseBranch:e||null},x.flash),className:`settings-select max-w-full bg-card`,options:[{value:``,label:`follow checked-out branch (default)`},...i.data.branches.map(e=>({value:e,label:e}))]}):(0,J.jsx)(`p`,{"data-slot":`agents-base-branch-unavailable`,className:`text-[13px] text-soft-foreground`,children:i.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})})]}),(0,J.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,J.jsx)(`summary`,{children:`Provider connections`}),(0,J.jsx)(ce,{})]})]})}function Q({defaultRunner:e,providerStatus:t,saving:n,saved:r,onSaved:s,onPick:l}){let u=i(),f=c(),p=w(),m=o(),h=a(),g=p.projectId??`default`,_=m.data?.info?.root,v=j(u.data,p.projectId,_),y=d().data,b=B(u.data?.profiles??[],y),x=R(b,y);return(0,J.jsxs)(W,{title:`Default runner`,hint:`Project defaults. A task can override these choices.`,saved:r,children:[(0,J.jsx)(V,{rows:b,runner:e,accountFor:e=>v?.[e]??null,providerStatus:t,disabled:n,accountDisabled:h.isPending||f.data===void 0,onPick:(t,n,r)=>{t!==e&&l(t),r&&h.mutate({projectId:g,provider:t,profileId:n},{onSuccess:s,onError:e=>S(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&E(t.data,e)?.enabled===!1?(0,J.jsx)(`p`,{"data-slot":`agents-runner-disabled`,className:`text-[13px] text-muted-foreground`,children:`This provider is disabled. Enable it above or choose another provider.`}):null,x?(0,J.jsx)(`p`,{className:`max-w-md text-[13px] text-muted-foreground`,children:`The account is personal and never committed. Tasks already started under another account can’t be resumed here — their sessions live in that account’s folder.`}):null]})}function $({title:e,hint:t,saved:n,children:r}){return(0,J.jsxs)(`section`,{className:`settings-option-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{children:e}),(0,J.jsxs)(`p`,{children:[t,` `,(0,J.jsx)(U,{saved:n})]})]}),r]})}function de({length:e,overLimit:t}){return(0,J.jsx)(J.Fragment,{children:t?(0,J.jsxs)(`p`,{"data-slot":`agents-prompt-limit`,className:`text-xs text-danger`,children:[e.toLocaleString(),` characters — the limit is `,Z.toLocaleString(),`.`]}):(0,J.jsx)(`p`,{"data-slot":`agents-prompt-help`,className:`text-xs text-muted-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`})})}export{le as AgentDefaultsSection};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{K as r,M as i,Q as a,S as o,St as s,U as c,W as l,Z as u,bt as d,g as f,gt as p,mt as m,on as h,pt as g,sn as _,xt as v,zn as y}from"./queries-CPNrCEon.js";import{I as b,Qt as x,a as S,ha as C,r as w,wn as T,yn as ee,zn as E}from"./project-scope-context-_6sNMsAf.js";import{c as D}from"./design-icons-QbNMZniQ.js";import{t as O}from"./button-BV_AiLj2.js";import{t as k}from"./switch-B9OfOEzC.js";import{t as A}from"./status-dot-Dvy-rnDJ.js";import{n as j}from"./agent-accounts-BC78GKYv.js";import{t as M}from"./centered-state-N8vWM_Hw.js";import{I as N,Mn as P,P as F,R as I}from"./index-BAXboPqe.js";import{t as te}from"./textarea-BGp28xFr.js";import{t as L}from"./option-select-BvsSDWBz.js";import{a as ne,i as R,n as z,r as B,t as V}from"./settings-agent-picker-Cy_ZpuNd.js";import{n as H,t as U}from"./save-cue-CpHgT93o.js";import{n as W}from"./settings-field-AyinSFR_.js";import{r as G}from"./settings-save-bar-DzbndGGQ.js";import{n as K}from"./saved-draft-BwzBc-_Y.js";var q=e(t(),1),J=n(),Y={connected:P(`connected`),disconnected:P(`disconnected`),"not-installed":P(`not-installed`),unknown:P(`unknown`)};function X(e,t,n){return{providers:e.providers.map(e=>e.provider===t?{...e,enabled:n}:e)}}function re(e,t){return e?Y[e]:t?{label:`Checking…`,tone:`neutral`}:Y.unknown}function ie(e,t){return e===`unknown`||t&&!e}function ae({provider:e,state:t,current:n,statusIsError:r}){return t===`not-installed`?(0,J.jsxs)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:[`Install `,e.displayName,`, then run `,(0,J.jsx)(`code`,{children:e.loginCommand}),`.`]}):ie(t,r)?(0,J.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:`Verification failed. Check again when the provider is available.`}):n?.hint?(0,J.jsx)(`p`,{className:`mt-1.5 text-xs text-soft-foreground`,children:n.hint}):null}function oe({provider:e,state:t,current:n,isConnecting:r,incidentId:i,refresh:a,connect:o,retry:s,queueToggle:c}){let l=t===`disconnected`||t===`unknown`,u=H();return(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t===`not-installed`?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(U,{saved:u.saved}),(0,J.jsx)(k,{checked:n?.enabled??!0,"aria-label":`Use ${e.displayName}`,onCheckedChange:t=>c(e.id,t,u.flash)})]}),l?(0,J.jsx)(O,{type:`button`,variant:`ghost`,size:`sm`,disabled:a.isPending,onClick:()=>a.mutate(void 0,{onError:e=>S(e.message,{tone:`danger`})}),children:`Check again`}):null,t===`disconnected`&&e.browserLogin?(0,J.jsx)(z,{provider:e.id,label:e.displayName}):null,t===`disconnected`&&e.terminalLogin!==!1?(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:o.isPending,onClick:()=>o.mutate(e.id),children:r?`Opening…`:`Connect`}):null,i===void 0?null:(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:s.isPending,onClick:()=>s.mutate({provider:e.id,authFailureId:i},{onSuccess:()=>S(`${e.displayName} can be tried again.`),onError:e=>S(e.message,{tone:`danger`})}),children:`Try again`})]})}function se({manual:e,provider:t,connected:n,onCopy:r}){return e===null||e.provider!==t||n?null:(0,J.jsxs)(`div`,{role:`region`,"aria-label":`${e.label} manual sign-in`,className:`rounded-md border border-pending/40 bg-pending/5 px-3.5 py-3`,children:[(0,J.jsx)(`p`,{className:`text-[13px] text-foreground`,children:e.message}),(0,J.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2`,children:[(0,J.jsx)(`code`,{className:`min-w-0 flex-1 overflow-x-auto rounded-sm bg-muted px-2 py-1.5 text-xs`,children:e.command}),(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void r(e.command),children:`Copy command`})]})]})}function ce(){let e=d(),t=l(),n=r(),i=u(),a=C(),[o,s]=(0,q.useState)(null),c=(0,q.useRef)(Promise.resolve()),f=(0,q.useRef)({}),p=(0,q.useRef)({}),h=(0,q.useRef)(t.data);(0,q.useEffect)(()=>{o&&E(t.data,o.provider)?.status===`connected`&&s(null)},[o,t.data]),(0,q.useEffect)(()=>{if(t.data){if(Object.values(p.current).every(e=>e===0)||!h.current){h.current=t.data;return}h.current={providers:t.data.providers.map(e=>({...e,enabled:(p.current[e.provider]??0)>0?E(h.current,e.provider)?.enabled??e.enabled:e.enabled}))}}},[t.data]);let b=(0,q.useCallback)((e,t,n)=>{let r=_.providerStatus,i=a.getQueryData(r);if(!i)return;h.current||=i;let o=X(i,e,t);p.current[e]=(p.current[e]??0)+1,a.setQueryData(r,o);let s=(f.current[e]??0)+1;f.current[e]=s,c.current=c.current.then(async()=>{try{let i=await ee(e,t),o=E(i,e)?.enabled;if(o===void 0)return;if(h.current=X(h.current??i,e,o),s===f.current[e]){let t=a.getQueryData(r);a.setQueryData(r,t?X(t,e,o):i),n()}}catch(t){if(s===f.current[e]){let n=E(h.current,e)?.enabled,i=a.getQueryData(r);i&&n!==void 0?a.setQueryData(r,X(i,e,n)):h.current?a.setQueryData(r,h.current):a.removeQueries({queryKey:r,exact:!0}),S(t instanceof Error?t.message:String(t),{tone:`danger`})}}finally{p.current[e]=(p.current[e]??0)-1}})},[a]),w=y({mutationFn:e=>x(e),onSuccess:async(e,t)=>{s(null),S(e.opened?`Finish signing in in the terminal, then check again.`:`Provider is already connected.`),await a.invalidateQueries({queryKey:_.providerStatus}),await v(a,t,`none`)},onError:(t,n)=>{if(t instanceof T&&t.command){let r=g(e.data,n);s({provider:n,label:r,message:t.message,command:t.command});return}S(t.message,{tone:`danger`})}}),D=async e=>{try{await navigator.clipboard.writeText(e),S(`Command copied`)}catch{S(`Could not copy the command`,{tone:`danger`})}};return(0,J.jsxs)(`section`,{id:`providers`,"data-slot":`provider-settings`,className:`scroll-mt-20`,children:[(0,J.jsxs)(`div`,{className:`mb-2`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Providers`}),(0,J.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Connect the coding agents available on this computer.`})]}),t.isError?(0,J.jsxs)(`div`,{role:`alert`,className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border border-danger/30 bg-danger/5 px-3 py-2.5`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`text-[13px] font-medium text-foreground`,children:`Provider status could not be loaded`}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.error.message})]}),(0,J.jsx)(O,{type:`button`,variant:`outline`,size:`sm`,disabled:t.isFetching,onClick:()=>void t.refetch(),children:`Retry`})]}):null,(0,J.jsx)(`div`,{className:`flex flex-col gap-2`,children:m(e.data).map(e=>{let r=E(t.data,e.id),a=r?.status,s=re(a,t.isPending),c=w.isPending&&w.variables===e.id,l=r?.authFailureId;return(0,J.jsxs)(q.Fragment,{children:[(0,J.jsxs)(`div`,{"data-slot":`provider-card`,"data-provider":e.id,className:`rounded-md border border-border bg-card px-3.5 py-3`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsx)(`h3`,{className:`text-[13px] font-semibold text-foreground`,children:e.displayName}),(0,J.jsxs)(`div`,{className:`mt-1 flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,J.jsx)(A,{tone:s.tone,pulse:t.isPending}),(0,J.jsx)(`span`,{children:s.label}),r?.enabled===!1?(0,J.jsx)(`span`,{children:`Disabled`}):null]}),(0,J.jsx)(ae,{provider:e,state:a,current:r,statusIsError:t.isError})]}),(0,J.jsx)(oe,{provider:e,state:a,current:r,isConnecting:c,incidentId:l,refresh:n,connect:w,retry:i,queueToggle:b})]}),l===void 0?null:(0,J.jsx)(`p`,{className:`mt-2 text-xs text-soft-foreground`,children:`Use this after completing the provider sign-in flow. Squawk cannot validate the credential without a task/model request; it will verify it on the next task.`})]}),(0,J.jsx)(se,{manual:o,provider:e.id,connected:a===`connected`,onCopy:D})]},e.id)})})]})}var Z=2e4;function le(){let e=f(),t=d(),n=s(p(t.data)),r=l();return e.isPending?(0,J.jsx)(`p`,{"data-slot":`agents-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading agent settings…`}):e.isError?(0,J.jsx)(M,{icon:(0,J.jsx)(D,{}),tone:`danger`,title:`Agent settings did not load`,subtitle:e.error.message,heading:`h2`}):(0,J.jsx)(ue,{config:e.data,catalogs:n,providerStatus:r,runners:t.data})}function ue({config:e,catalogs:t,providerStatus:n,runners:r}){let i=o(),a=C(),s=y({mutationFn:e=>b(e),onSuccess:e=>{a.setQueryData(h.config,e),a.invalidateQueries({queryKey:h.health}),a.invalidateQueries({queryKey:h.repo})},onError:e=>S(e.message,{tone:`danger`})}),[c,l]=K(e.systemPrompt??``),u=c.trim(),d=u===(e.systemPrompt??``),f=u.length>Z;G({dirty:!d,invalid:f,busy:s.isPending,save:()=>s.mutateAsync({systemPrompt:u===``?null:u}),discard:()=>l(e.systemPrompt??``)});let p=H(),g=H(),_=H(),v=H(),x=H(),w=(e,t)=>s.mutate(e,{onSuccess:t});return(0,J.jsxs)(`div`,{"data-slot":`agent-defaults-section`,className:`mx-auto flex w-full max-w-2xl flex-col gap-7 p-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:p-6 md:pb-6`,children:[(0,J.jsx)(Q,{defaultRunner:e.defaultRunner,providerStatus:n,saving:s.isPending,saved:p.saved,onSaved:p.flash,onPick:e=>w({defaultRunner:e},p.flash)}),(0,J.jsx)(W,{wide:!0,title:`Default model`,hint:e.modelsLocked?`Models are locked to the defaults configured in the native coding-agent settings.`:`The model preselected in the composer for each runner. Runner default lets the runner decide per task.`,saved:e.modelsLocked?void 0:g.saved,children:(0,J.jsx)(`div`,{"data-slot":`agents-model-rows`,className:`flex flex-col gap-2.5`,children:m(r).map(i=>{let{providerConnected:a,providerReason:o}=ne(n,i.id),c=t[i.id],l=N(i.id,r,c),u=I(i.id,r,c?.data,[e.defaultModels[i.id]]),d=e.defaultModels[i.id]??``,f=u.find(e=>e.id===d)?.label??d??`Runner default`;return(0,J.jsxs)(`label`,{className:`settings-option-row`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`h3`,{children:i.displayName})}),e.modelsLocked?(0,J.jsx)(`output`,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,title:`Model selection is locked to native coding-agent settings.`,className:`block rounded-md border border-input bg-card px-3 py-1.5 text-sm shadow-xs`,children:f}):(0,J.jsx)(L,{"aria-label":`Default model for ${i.pickerLabel}`,"data-slot":`agents-model`,"data-runner":i.id,value:d,title:o??i.pickerDescription,disabled:s.isPending||!a,onValueChange:e=>w({defaultModels:{[i.id]:e||null}},g.flash),className:`settings-select max-w-full bg-card`,options:[...u.map(e=>({value:e.id,label:e.label})),...l?[{value:F,label:l,disabled:!0}]:[]]})]},i.id)})})}),(0,J.jsxs)(W,{wide:!0,title:`System prompt`,hint:`Extra instructions for every run in this project.`,reportsDirty:!0,children:[(0,J.jsx)(te,{"aria-label":`System prompt`,"data-slot":`agents-system-prompt`,value:c,onChange:e=>l(e.target.value),placeholder:`Extra rules for every agent run — conventions, tone, review requirements…`,className:`min-h-48 w-full`}),(0,J.jsx)(de,{length:u.length,overLimit:f})]}),(0,J.jsxs)(`section`,{"data-slot":`agents-task-runs`,className:`settings-field flex flex-col gap-5`,children:[(0,J.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Task runs`}),(0,J.jsx)($,{title:`Live title updates`,hint:`Refresh a task's short title through the namer model as the run progresses. A manual rename always wins and stops updates for that task.`,saved:_.saved,children:(0,J.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,J.jsx)(k,{"aria-label":`Live title updates`,"data-slot":`agents-live-title-updates`,checked:e.liveTitleUpdates??!0,disabled:s.isPending,onCheckedChange:e=>w({liveTitleUpdates:e},_.flash)}),(0,J.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.liveTitleUpdates??!0?`On`:`Off`,e.liveTitleUpdates===null&&` (default)`]})]})}),(0,J.jsx)($,{title:`Review changes before finishing`,hint:`When on, a task with changes pauses so you can Accept, Send back, or open a Draft PR. Autonomous tasks always skip this and finish on their own. Default: off — tasks finish without asking.`,saved:v.saved,children:(0,J.jsxs)(`label`,{className:`flex w-fit items-center gap-3`,children:[(0,J.jsx)(k,{"aria-label":`Review changes before finishing`,"data-slot":`agents-review-gate`,checked:e.reviewGate??!1,disabled:s.isPending,onCheckedChange:e=>w({reviewGate:e},v.flash)}),(0,J.jsxs)(`span`,{className:`text-[13px] text-muted-foreground`,children:[e.reviewGate??!1?`On`:`Off`,e.reviewGate===null&&` (default)`]})]})}),(0,J.jsx)($,{title:`Base branch`,hint:`New task worktrees branch from this and draft PRs target it. Also settable from the Git view.`,saved:x.saved,children:i.data?.info?(0,J.jsx)(L,{"aria-label":`Base branch`,"data-slot":`agents-base-branch`,value:e.baseBranch??``,disabled:s.isPending,onValueChange:e=>w({baseBranch:e||null},x.flash),className:`settings-select max-w-full bg-card`,options:[{value:``,label:`follow checked-out branch (default)`},...i.data.branches.map(e=>({value:e,label:e}))]}):(0,J.jsx)(`p`,{"data-slot":`agents-base-branch-unavailable`,className:`text-[13px] text-soft-foreground`,children:i.isPending?`Loading branches…`:`Not a git repository — tasks run in place, no branching.`})})]}),(0,J.jsxs)(`details`,{className:`settings-disclosure`,children:[(0,J.jsx)(`summary`,{children:`Provider connections`}),(0,J.jsx)(ce,{})]})]})}function Q({defaultRunner:e,providerStatus:t,saving:n,saved:r,onSaved:s,onPick:l}){let u=i(),f=c(),p=w(),m=o(),h=a(),g=p.projectId??`default`,_=m.data?.info?.root,v=j(u.data,p.projectId,_),y=d().data,b=B(u.data?.profiles??[],y),x=R(b,y);return(0,J.jsxs)(W,{title:`Default runner`,hint:`Project defaults. A task can override these choices.`,saved:r,children:[(0,J.jsx)(V,{rows:b,runner:e,accountFor:e=>v?.[e]??null,providerStatus:t,disabled:n,accountDisabled:h.isPending||f.data===void 0,onPick:(t,n,r)=>{t!==e&&l(t),r&&h.mutate({projectId:g,provider:t,profileId:n},{onSuccess:s,onError:e=>S(e.message,{tone:`danger`})})}}),!t.isPending&&!t.isError&&E(t.data,e)?.enabled===!1?(0,J.jsx)(`p`,{"data-slot":`agents-runner-disabled`,className:`text-[13px] text-muted-foreground`,children:`This provider is disabled. Enable it above or choose another provider.`}):null,x?(0,J.jsx)(`p`,{className:`max-w-md text-[13px] text-muted-foreground`,children:`The account is personal and never committed. Tasks already started under another account can’t be resumed here — their sessions live in that account’s folder.`}):null]})}function $({title:e,hint:t,saved:n,children:r}){return(0,J.jsxs)(`section`,{className:`settings-option-row`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h3`,{children:e}),(0,J.jsxs)(`p`,{children:[t,` `,(0,J.jsx)(U,{saved:n})]})]}),r]})}function de({length:e,overLimit:t}){return(0,J.jsx)(J.Fragment,{children:t?(0,J.jsxs)(`p`,{"data-slot":`agents-prompt-limit`,className:`text-xs text-danger`,children:[e.toLocaleString(),` characters — the limit is `,Z.toLocaleString(),`.`]}):(0,J.jsx)(`p`,{"data-slot":`agents-prompt-help`,className:`text-xs text-muted-foreground`,children:`Leave empty and save to clear. Applied to new runs only.`})})}export{le as AgentDefaultsSection};
@@ -1 +1 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{U as t}from"./queries-Byfl3YoC.js";import{o as n}from"./dist-CCX8mhHc.js";import{t as r}from"./createLucideIcon-BHp8sXmF.js";import{n as i,t as a}from"./moon-CRE9nU5R.js";import{t as o}from"./button-BV_AiLj2.js";import{En as s,_t as c,rr as l}from"./index-D0RESQCN.js";import{n as u}from"./save-cue-CpHgT93o.js";import{n as d}from"./settings-field-AyinSFR_.js";var f=r(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),p=e(),m=[{value:`system`,label:`System`,icon:i},{value:`light`,label:`Light`,icon:f},{value:`dark`,label:`Dark`,icon:a}],h=[{value:`cezarion`,label:`Squawk`,swatch:`var(--accent-strong)`}],g=[{value:`comfortable`,label:`Comfortable`},{value:`compact`,label:`Compact`},{value:`ultra`,label:`Ultra-compact`}],_=[{value:`narrow`,label:`Narrow`},{value:`wide`,label:`Wide`}];function v({slot:e,label:t,value:r,options:i,onChange:a}){return(0,p.jsx)(`div`,{role:`radiogroup`,"aria-label":t,"data-slot":e,className:`inline-flex w-fit gap-0.5 rounded-lg border border-border bg-muted/60 p-1 max-md:max-w-full max-md:flex-wrap`,children:i.map(e=>{let t=e.value===r;return(0,p.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-value":e.value,onClick:()=>a(e.value),className:n(`flex min-h-11 items-center gap-2 whitespace-nowrap rounded-md border border-transparent px-3 py-1.5 text-[13px] font-medium transition-colors`,t?`border border-border bg-card text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`),children:[e.icon?(0,p.jsx)(e.icon,{"aria-hidden":`true`,className:`size-3.5`}):null,e.swatch?(0,p.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-border`,style:{background:e.swatch}}):null,e.label]},e.value)})})}function y(){let e=t(),{order:n,canReorder:r,reset:i}=s();return!((e.data?.projects.length??0)>1)||n.length===0?null:(0,p.jsx)(d,{title:`Project order`,hint:`The project rail is in the order you dragged it into. Reset puts it back in the order the projects were added. Saved with your workspace, so every browser sees it.`,children:(0,p.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`appearance-project-order-reset`,disabled:!r,onClick:i,className:`w-fit`,children:`Reset order`})})}function b(){let{theme:e,setTheme:t}=l(),{accent:n,density:r,width:i,setAccent:a,setDensity:o,setWidth:s}=c(),f=u(),b=u(),x=u(),S=u(),C=e=>t=>{t&&e()};return(0,p.jsxs)(`div`,{"data-slot":`appearance-section`,className:`flex w-full flex-col gap-7 rounded-lg border border-border bg-card p-5`,children:[(0,p.jsx)(d,{title:`Theme`,hint:`System follows your OS preference. Applies to this browser.`,saved:f.saved,children:(0,p.jsx)(v,{slot:`appearance-theme`,label:`Theme`,value:e,options:m,onChange:e=>{t(e)&&f.flash()}})}),h.length>1?(0,p.jsx)(d,{title:`Accent`,hint:`The cockpit brand accent. Saved with your workspace appearance.`,saved:b.saved,children:(0,p.jsx)(v,{slot:`appearance-accent`,label:`Accent`,value:n,options:h,onChange:e=>void a(e).then(C(b.flash))})}):null,(0,p.jsx)(d,{title:`Density`,hint:`Compact tightens spacing across the cockpit — text stays the same size.`,saved:x.saved,children:(0,p.jsx)(v,{slot:`appearance-density`,label:`Density`,value:r,options:g,onChange:e=>void o(e).then(C(x.flash))})}),(0,p.jsx)(d,{title:`Reading width`,hint:`Wide lets a task's session and commits use more of the screen. Narrow keeps a comfortable reading column. The Changes tab is always full-width.`,saved:S.saved,children:(0,p.jsx)(v,{slot:`appearance-width`,label:`Reading width`,value:i,options:_,onChange:e=>void s(e).then(C(S.flash))})}),(0,p.jsx)(y,{}),(0,p.jsxs)(`div`,{className:`settings-appearance-preview settings-readout`,children:[(0,p.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:`PREVIEW`}),(0,p.jsx)(`p`,{className:`mt-3 text-base`,children:`Review finalization retries`}),(0,p.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Needs you · Squawk · Task `,`#`,`227`]}),(0,p.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-border bg-card px-4 py-3 text-xs text-foreground shadow-xs`,children:`Open task`})]}),(0,p.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Changes apply immediately. Theme is browser-local; density and reading width are saved with your workspace.`})]})}export{b as AppearanceSection};
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{U as t}from"./queries-CPNrCEon.js";import{o as n}from"./dist-CCX8mhHc.js";import{t as r}from"./createLucideIcon-BHp8sXmF.js";import{n as i,t as a}from"./moon-CRE9nU5R.js";import{t as o}from"./button-BV_AiLj2.js";import{En as s,_t as c,rr as l}from"./index-BAXboPqe.js";import{n as u}from"./save-cue-CpHgT93o.js";import{n as d}from"./settings-field-AyinSFR_.js";var f=r(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),p=e(),m=[{value:`system`,label:`System`,icon:i},{value:`light`,label:`Light`,icon:f},{value:`dark`,label:`Dark`,icon:a}],h=[{value:`cezarion`,label:`Squawk`,swatch:`var(--accent-strong)`}],g=[{value:`comfortable`,label:`Comfortable`},{value:`compact`,label:`Compact`},{value:`ultra`,label:`Ultra-compact`}],_=[{value:`narrow`,label:`Narrow`},{value:`wide`,label:`Wide`}];function v({slot:e,label:t,value:r,options:i,onChange:a}){return(0,p.jsx)(`div`,{role:`radiogroup`,"aria-label":t,"data-slot":e,className:`inline-flex w-fit gap-0.5 rounded-lg border border-border bg-muted/60 p-1 max-md:max-w-full max-md:flex-wrap`,children:i.map(e=>{let t=e.value===r;return(0,p.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-value":e.value,onClick:()=>a(e.value),className:n(`flex min-h-11 items-center gap-2 whitespace-nowrap rounded-md border border-transparent px-3 py-1.5 text-[13px] font-medium transition-colors`,t?`border border-border bg-card text-foreground shadow-xs`:`text-muted-foreground hover:text-foreground`),children:[e.icon?(0,p.jsx)(e.icon,{"aria-hidden":`true`,className:`size-3.5`}):null,e.swatch?(0,p.jsx)(`span`,{"aria-hidden":`true`,className:`size-3 rounded-full border border-border`,style:{background:e.swatch}}):null,e.label]},e.value)})})}function y(){let e=t(),{order:n,canReorder:r,reset:i}=s();return!((e.data?.projects.length??0)>1)||n.length===0?null:(0,p.jsx)(d,{title:`Project order`,hint:`The project rail is in the order you dragged it into. Reset puts it back in the order the projects were added. Saved with your workspace, so every browser sees it.`,children:(0,p.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`appearance-project-order-reset`,disabled:!r,onClick:i,className:`w-fit`,children:`Reset order`})})}function b(){let{theme:e,setTheme:t}=l(),{accent:n,density:r,width:i,setAccent:a,setDensity:o,setWidth:s}=c(),f=u(),b=u(),x=u(),S=u(),C=e=>t=>{t&&e()};return(0,p.jsxs)(`div`,{"data-slot":`appearance-section`,className:`flex w-full flex-col gap-7 rounded-lg border border-border bg-card p-5`,children:[(0,p.jsx)(d,{title:`Theme`,hint:`System follows your OS preference. Applies to this browser.`,saved:f.saved,children:(0,p.jsx)(v,{slot:`appearance-theme`,label:`Theme`,value:e,options:m,onChange:e=>{t(e)&&f.flash()}})}),h.length>1?(0,p.jsx)(d,{title:`Accent`,hint:`The cockpit brand accent. Saved with your workspace appearance.`,saved:b.saved,children:(0,p.jsx)(v,{slot:`appearance-accent`,label:`Accent`,value:n,options:h,onChange:e=>void a(e).then(C(b.flash))})}):null,(0,p.jsx)(d,{title:`Density`,hint:`Compact tightens spacing across the cockpit — text stays the same size.`,saved:x.saved,children:(0,p.jsx)(v,{slot:`appearance-density`,label:`Density`,value:r,options:g,onChange:e=>void o(e).then(C(x.flash))})}),(0,p.jsx)(d,{title:`Reading width`,hint:`Wide lets a task's session and commits use more of the screen. Narrow keeps a comfortable reading column. The Changes tab is always full-width.`,saved:S.saved,children:(0,p.jsx)(v,{slot:`appearance-width`,label:`Reading width`,value:i,options:_,onChange:e=>void s(e).then(C(S.flash))})}),(0,p.jsx)(y,{}),(0,p.jsxs)(`div`,{className:`settings-appearance-preview settings-readout`,children:[(0,p.jsx)(`span`,{className:`text-[12px] text-soft-foreground`,children:`PREVIEW`}),(0,p.jsx)(`p`,{className:`mt-3 text-base`,children:`Review finalization retries`}),(0,p.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Needs you · Squawk · Task `,`#`,`227`]}),(0,p.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-border bg-card px-4 py-3 text-xs text-foreground shadow-xs`,children:`Open task`})]}),(0,p.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`Changes apply immediately. Theme is browser-local; density and reading width are saved with your workspace.`})]})}export{b as AppearanceSection};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{g as r,on as i,rt as a,sn as o,yr as s}from"./queries-Byfl3YoC.js";import{I as c,dn as l,ea as u}from"./project-scope-context-BWHk0niI.js";import{t as d}from"./option-select-DGRezng8.js";import{n as f,t as p}from"./save-cue-CpHgT93o.js";var m=e(t(),1),h=n();function g(){let e=r();return e.isPending?(0,h.jsx)(`p`,{role:`status`,children:`Loading task settings…`}):e.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Task settings did not load: `,e.error.message]}):(0,h.jsx)(v,{config:e.data,scope:`project`})}function _(){let e=a();return e.isPending?(0,h.jsx)(`p`,{role:`status`,className:`text-sm`,children:`Loading task settings…`}):e.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Task settings did not load: `,e.error.message]}):(0,h.jsx)(v,{config:e.data,scope:`global`})}function v({config:e,scope:t}){let n=(0,m.useId)(),r=u(),a=f(),g=s({mutationFn:async({archiveOnMerge:e,projectKey:n})=>t===`project`?c({archiveOnMerge:e},n[0]):l({archiveOnMerge:e}),onSuccess:(e,{projectKey:n})=>{t===`project`?r.setQueryData(n,e):(r.setQueryData(o.config,e),r.invalidateQueries({predicate:e=>e.queryKey.at(-1)===`config`&&e.queryKey!==o.config})),a.flash()}});return(0,h.jsxs)(`section`,{"data-slot":`archive-on-merge-field`,className:`settings-field flex min-w-0 flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:n,className:`text-sm font-semibold text-foreground`,children:`Archive tasks after PRs merge`}),(0,h.jsxs)(`p`,{id:`${n}-hint`,className:`text-[13px] text-muted-foreground`,children:[`Automatically archive a settled task and its workers once all their associated pull requests merge. History stays available in Archived. `,(0,h.jsx)(p,{saved:a.saved})]})]}),(0,h.jsx)(d,{id:n,"aria-describedby":`${n}-hint ${n}-effective`,className:`settings-select w-64 max-w-full bg-background`,value:e.archiveOnMerge===null?`inherit`:e.archiveOnMerge?`enabled`:`disabled`,disabled:g.isPending,onValueChange:e=>g.mutate({archiveOnMerge:e===`inherit`?null:e===`enabled`,projectKey:i.config}),options:[{value:`inherit`,label:t===`project`?`Inherit global setting`:`Use default`},{value:`enabled`,label:`Enabled`},{value:`disabled`,label:`Disabled`}]}),(0,h.jsxs)(`p`,{id:`${n}-effective`,className:`text-[13px] text-muted-foreground`,children:[`Currently `,e.effectiveArchiveOnMerge?`enabled`:`disabled`,` · `,e.archiveOnMergeSource,` setting.`]}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Unarchive restores the task. It stays visible until a later associated PR merges.`}),g.isPending?(0,h.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Saving…`}):null,g.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not save: `,g.error.message]}):null]})}export{_ as n,g as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{g as r,on as i,rt as a,sn as o,zn as s}from"./queries-CPNrCEon.js";import{I as c,dn as l,ha as u}from"./project-scope-context-_6sNMsAf.js";import{t as d}from"./option-select-BvsSDWBz.js";import{n as f,t as p}from"./save-cue-CpHgT93o.js";var m=e(t(),1),h=n();function g(){let e=r();return e.isPending?(0,h.jsx)(`p`,{role:`status`,children:`Loading task settings…`}):e.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Task settings did not load: `,e.error.message]}):(0,h.jsx)(v,{config:e.data,scope:`project`})}function _(){let e=a();return e.isPending?(0,h.jsx)(`p`,{role:`status`,className:`text-sm`,children:`Loading task settings…`}):e.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Task settings did not load: `,e.error.message]}):(0,h.jsx)(v,{config:e.data,scope:`global`})}function v({config:e,scope:t}){let n=(0,m.useId)(),r=u(),a=f(),g=s({mutationFn:async({archiveOnMerge:e,projectKey:n})=>t===`project`?c({archiveOnMerge:e},n[0]):l({archiveOnMerge:e}),onSuccess:(e,{projectKey:n})=>{t===`project`?r.setQueryData(n,e):(r.setQueryData(o.config,e),r.invalidateQueries({predicate:e=>e.queryKey.at(-1)===`config`&&e.queryKey!==o.config})),a.flash()}});return(0,h.jsxs)(`section`,{"data-slot":`archive-on-merge-field`,className:`settings-field flex min-w-0 flex-col gap-3`,children:[(0,h.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,h.jsx)(`label`,{htmlFor:n,className:`text-sm font-semibold text-foreground`,children:`Archive tasks after PRs merge`}),(0,h.jsxs)(`p`,{id:`${n}-hint`,className:`text-[13px] text-muted-foreground`,children:[`Automatically archive a settled task and its workers once all their associated pull requests merge. History stays available in Archived. `,(0,h.jsx)(p,{saved:a.saved})]})]}),(0,h.jsx)(d,{id:n,"aria-describedby":`${n}-hint ${n}-effective`,className:`settings-select w-64 max-w-full bg-background`,value:e.archiveOnMerge===null?`inherit`:e.archiveOnMerge?`enabled`:`disabled`,disabled:g.isPending,onValueChange:e=>g.mutate({archiveOnMerge:e===`inherit`?null:e===`enabled`,projectKey:i.config}),options:[{value:`inherit`,label:t===`project`?`Inherit global setting`:`Use default`},{value:`enabled`,label:`Enabled`},{value:`disabled`,label:`Disabled`}]}),(0,h.jsxs)(`p`,{id:`${n}-effective`,className:`text-[13px] text-muted-foreground`,children:[`Currently `,e.effectiveArchiveOnMerge?`enabled`:`disabled`,` · `,e.archiveOnMergeSource,` setting.`]}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Unarchive restores the task. It stays visible until a later associated PR merges.`}),g.isPending?(0,h.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Saving…`}):null,g.isError?(0,h.jsxs)(`p`,{role:`alert`,className:`text-sm text-danger`,children:[`Could not save: `,g.error.message]}):null]})}export{_ as n,g as t};
@@ -1,9 +1,9 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ot as r,bt as i,pt as a}from"./queries-Byfl3YoC.js";import{_ as o}from"./host-context-KsSKxKbI.js";import{Sr as s,ci as c,hr as l}from"./project-scope-context-BWHk0niI.js";import{m as u,n as d,p as f}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as p}from"./dist-CCX8mhHc.js";import{J as m,Q as h,V as g,c as _,d as v,f as y,mt as b,pt as x,st as S,u as C,y as w}from"./design-icons-QbNMZniQ.js";import{t as T}from"./createLucideIcon-BHp8sXmF.js";import{t as E}from"./check-OP-CVgZG.js";import{t as D}from"./chevron-right-BENZ-1ZN.js";import{n as ee}from"./smartphone-Lr8Ug2z_.js";import{t as O}from"./loader-circle-CPBhhDbB.js";import{t as te}from"./message-square-B-MD-8rD.js";import{n as ne,t as re}from"./tool-display-CTbToGmi.js";import{t as k}from"./square-terminal-B6RYYieR.js";import{t as A}from"./button-BV_AiLj2.js";import{n as j,r as M,t as N}from"./collapsible-D5i3hm2L.js";import{t as P}from"./project-router-TP6DSj1S.js";import{a as ie,c as ae,i as oe,l as se,o as ce,s as le,t as ue}from"./report-selection-DOq2dcjz.js";import{r as de}from"./html-report-BX3msvci.js";import{S as fe,pr as pe,un as me,vr as F,wn as he,wr as ge,x as _e}from"./index-D0RESQCN.js";import{t as ve}from"./zoomable-image-Dv85Vr4A.js";import{t as I}from"./textarea-BGp28xFr.js";import{t as L}from"./markdown-CcQNTOHx.js";import{t as ye}from"./task-file-scope-BfJ7TDbf.js";import{t as be}from"./report-title-D4Mbu2Er.js";var xe=T(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),Se=T(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Ce=T(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),we=T(`locate-fixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),R=T(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Te=T(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),z=e(t(),1),B=n();function Ee(e,t){if(e.length===1)return[t.replace(RegExp(`^${De(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function De(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Oe(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}var ke=`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ot as r,bt as i,pt as a}from"./queries-CPNrCEon.js";import{_ as o}from"./host-context-KsSKxKbI.js";import{Oi as s,Sr as c,hr as l}from"./project-scope-context-_6sNMsAf.js";import{m as u,n as d,p as f}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as p}from"./dist-CCX8mhHc.js";import{J as m,Q as h,V as g,c as _,d as v,f as y,mt as b,pt as x,st as S,u as C,y as w}from"./design-icons-QbNMZniQ.js";import{t as T}from"./createLucideIcon-BHp8sXmF.js";import{t as E}from"./check-OP-CVgZG.js";import{t as D}from"./chevron-right-BENZ-1ZN.js";import{n as ee}from"./smartphone-Lr8Ug2z_.js";import{t as O}from"./loader-circle-CPBhhDbB.js";import{t as te}from"./message-square-B-MD-8rD.js";import{n as ne,t as re}from"./tool-display-CTbToGmi.js";import{t as k}from"./square-terminal-B6RYYieR.js";import{t as A}from"./button-BV_AiLj2.js";import{n as j,r as M,t as N}from"./collapsible-D5i3hm2L.js";import{t as P}from"./project-router-l_pJCK5X.js";import{a as ie,c as ae,i as oe,l as se,o as ce,s as le,t as ue}from"./report-selection-DCC-F7i6.js";import{r as de}from"./html-report-BX3msvci.js";import{S as fe,pr as pe,un as me,vr as F,wn as he,wr as ge,x as _e}from"./index-BAXboPqe.js";import{t as ve}from"./zoomable-image-Dv85Vr4A.js";import{t as I}from"./textarea-BGp28xFr.js";import{t as L}from"./markdown-D7p7x8Pe.js";import{t as ye}from"./task-file-scope-C_cr_ix-.js";import{t as be}from"./report-title-D4Mbu2Er.js";var xe=T(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),Se=T(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),Ce=T(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),we=T(`locate-fixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),R=T(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Te=T(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),z=e(t(),1),B=n();function Ee(e,t){if(e.length===1)return[t.replace(RegExp(`^${De(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function De(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Oe(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}var ke=`
2
2
 
3
3
  Additional comments:
4
- `;function Ae(e){let t=e.indexOf(ke);if(t<0)return{body:e,comment:void 0};let n=e.slice(t+23).trim();return{body:e.slice(0,t),comment:n||void 0}}function je({ask:e}){let t=e.answer===void 0?void 0:Ae(e.answer),n=t===void 0?void 0:Ee(e.questions,t.body);return(0,B.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((t,r)=>{let i=n?.[r],a=Oe(t,i),o=i!==void 0&&a.length===0;return(0,B.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":t.question,children:[(0,B.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[t.header,` · Question `,r+1,` of `,e.questions.length]}),(0,B.jsx)(`p`,{className:`break-words font-semibold`,children:t.question}),t.options?(0,B.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[t.options.map(e=>(0,B.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,B.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,B.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,B.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,B.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,B.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,B.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,B.jsx)(V,{text:i}):null]})]}):i===void 0?null:(0,B.jsx)(V,{text:i})]},t.id??r)}),n&&t?.comment?(0,B.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`Additional comments`,children:[(0,B.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Additional comments`}),(0,B.jsx)(V,{text:t.comment})]}):null,!n&&e.answer!==void 0?(0,B.jsx)(V,{text:e.answer}):null]})}function V({text:e}){return(0,B.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}function H(e,t,n){let r=n[e];return r===void 0?(t[e]?.length??0)>0:r.trim().length>0}function Me(e,t,n){let r=n[e]?.trim();if(r)return r;let i=t[e]??[];return i.length>0?i.join(`, `):`Not answered yet`}function Ne({stepped:e,mode:t,onModeChange:n,showModeSwitch:r,stepLabel:i,hasSheetContext:a,showContextButtonRef:o,onOpenContext:s,onShowOrigin:c,onFold:l}){let u=l!==void 0,d=a?(0,B.jsxs)(A,{ref:o,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,"aria-label":u?`Show context`:void 0,className:p(`px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,u&&`ms-auto`),onClick:s,children:[(0,B.jsx)(F,{"aria-hidden":`true`,className:`size-3.5`}),u?`Context`:`Show context`]}):c&&u?(0,B.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`ask-show-origin`,"aria-label":`Show where it was asked`,title:`Show where it was asked`,className:`ms-auto shrink-0 text-link-foreground`,onClick:c,children:(0,B.jsx)(we,{"aria-hidden":`true`,className:`size-4`})}):c?(0,B.jsx)(He,{onShowOrigin:c}):null,f=r?(0,B.jsx)(Pe,{mode:t,onModeChange:n}):null;return u?(0,B.jsxs)(`div`,{"data-slot":`ask-header`,"data-compact":`true`,className:`flex shrink-0 items-center gap-1.5 border-b border-border/70 py-1 ps-1.5 pe-1`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:`Needs your answer`}),e&&t===`options`?(0,B.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`sr-only`,children:i}):null,f,d,(0,B.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`ask-fold`,"aria-label":`Fold the question`,"aria-expanded":`true`,className:p(`shrink-0 text-muted-foreground`,!d&&`ms-auto`),onClick:l,children:(0,B.jsx)(C,{"aria-hidden":`true`,className:`size-4`})})]}):(0,B.jsxs)(`div`,{"data-slot":`ask-header`,className:`flex shrink-0 flex-wrap items-center gap-x-2 gap-y-1 border-b border-border/70 px-2.5 py-1.5 md:px-3 md:py-2`,children:[(0,B.jsx)(`span`,{className:`text-xs font-semibold text-link-foreground`,children:`Needs your answer`}),e&&t===`options`?(0,B.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`rounded-full bg-accent-strong/15 px-2 py-0.5 text-xs font-semibold text-foreground tabular-nums`,children:i}):null,(0,B.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-1.5`,children:[d,f]})]})}function Pe({mode:e,onModeChange:t}){return(0,B.jsxs)(`div`,{"data-slot":`ask-mode-switch`,role:`group`,"aria-label":`Reply mode`,className:`inline-flex shrink-0 items-center rounded-lg border border-border bg-card p-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-options`,"aria-pressed":e===`options`,onClick:()=>t(`options`),className:p(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,e===`options`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Options`}),(0,B.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-reply`,"aria-pressed":e===`reply`,onClick:()=>t(`reply`),className:p(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,e===`reply`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Write a reply`})]})}function Fe({tag:e,text:t,position:n,onOpen:r}){return(0,B.jsxs)(`button`,{type:`button`,"data-slot":`ask-folded-row`,"aria-expanded":`false`,onClick:r,className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl px-2.5 py-1.5 text-start focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,B.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:t}),n===void 0?null:(0,B.jsx)(`span`,{"data-slot":`ask-folded-position`,className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:n}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Open the question`}),(0,B.jsx)(y,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]})}function Ie({questions:e,stepIndex:t,selections:n,otherAnswers:r,hasComment:i,onSelectStep:a}){let o=e.length;return(0,B.jsxs)(`div`,{"data-slot":`ask-step-pills`,role:`group`,"aria-label":`Question steps`,className:`hidden shrink-0 flex-wrap items-center gap-1.5 border-b border-border/60 px-3 py-1.5 md:flex`,children:[e.map((e,i)=>{let o=t===i,s=H(i,n,r);return(0,B.jsxs)(`button`,{type:`button`,"aria-current":o?`step`:void 0,onClick:()=>a(i),className:p(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,o?`border-accent-strong bg-accent-strong/15 text-foreground`:s?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,B.jsx)(`span`,{className:`tabular-nums text-xs font-semibold`,children:s?(0,B.jsx)(E,{"aria-hidden":`true`,className:`size-3 text-semantic-green`}):`${i+1}.`}),(0,B.jsx)(`span`,{className:`max-w-[140px] truncate`,children:e.header})]},e.id??i)}),(0,B.jsxs)(`button`,{type:`button`,"aria-current":t===o?`step`:void 0,onClick:()=>a(o),className:p(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,t===o?`border-accent-strong bg-accent-strong/15 text-foreground`:i?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-dashed border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,B.jsx)(R,{"aria-hidden":`true`,className:`size-3`}),(0,B.jsx)(`span`,{children:`Comment`})]})]})}function Le({questions:e,selections:t,otherAnswers:n,comment:r,disabled:i,onCommentChange:a,onJumpToQuestion:o}){let s=(0,z.useId)();return(0,B.jsxs)(`div`,{"data-slot":`ask-comment-step`,className:`flex flex-col gap-2.5`,children:[(0,B.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-2.5`,children:[(0,B.jsx)(`p`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Selected answers`}),(0,B.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map((e,r)=>{let i=H(r,t,n);return(0,B.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>o(r),className:`min-h-11 text-start font-medium text-link-foreground underline-offset-4 hover:underline md:min-h-6`,children:e.header}),(0,B.jsx)(`span`,{className:p(`min-w-0 truncate text-end`,i?`text-foreground`:`text-semantic-red`),children:Me(r,t,n)})]},e.id??r)})})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`label`,{htmlFor:s,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,B.jsx)(I,{id:s,"data-slot":`ask-additional-comment`,rows:2,value:r,disabled:i,placeholder:`Optional extra notes to send with your selections…`,onChange:e=>a(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}function Re({value:e,onValueChange:t,disabled:n,renderFreeTextReply:r}){let i=(0,z.useId)();return r?(0,B.jsx)(`div`,{"data-slot":`ask-free-text`,children:r({value:e,onValueChange:t,disabled:n})}):(0,B.jsxs)(`div`,{"data-slot":`ask-free-text`,className:`flex flex-col gap-2`,children:[(0,B.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium text-foreground`,children:`Reply to the agent`}),(0,B.jsx)(I,{id:i,rows:2,value:e,disabled:n,placeholder:`Write a free-text reply…`,onChange:e=>t(e.target.value),className:`bg-card text-base md:text-[13px]`})]})}function ze({stepIndex:e,questionCount:t,answeredCount:n,allAnswered:r,hasComment:i,resuming:a,disabled:o,onBack:s,onNext:c,onOpenComment:l,onSend:u,questions:d,selections:f,otherAnswers:m,stopControl:h,compact:g=!1}){let _=e===t-1,v=e===t,y=a?`Send answer & reopen`:`Send answer`,b=a?(0,B.jsx)(`span`,{"data-slot":`ask-resume-hint`,className:`text-xs text-soft-foreground`,children:`Reopens the closed session.`}):null,x=!_&&!v?(0,B.jsxs)(A,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:c,children:[`Next`,(0,B.jsx)(D,{"aria-hidden":`true`,className:`size-4`})]}):null,S=_?(0,B.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:l,children:i?`Edit comment`:`+ Comment`}):null,C=_||v||r?(0,B.jsx)(A,{type:`button`,size:`sm`,className:`px-3.5`,disabled:o||!r,onClick:u,children:y}):null;return(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e>0?(0,B.jsxs)(A,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:s,children:[(0,B.jsx)(ge,{"aria-hidden":`true`,className:`size-4`}),`Back`]}):null,(0,B.jsxs)(`span`,{"data-slot":`ask-progress-dots`,"aria-hidden":`true`,className:`flex items-center gap-1.5 px-1 md:hidden`,children:[d.map((t,n)=>{let r=n===e,i=H(n,f,m);return(0,B.jsx)(`span`,{className:p(`size-2 rounded-full motion-safe:transition-colors`,r?`bg-accent-strong`:i?`bg-success`:`bg-border`)},t.id??n)}),(0,B.jsx)(`span`,{className:p(`size-2 rounded-full motion-safe:transition-colors`,v?`bg-accent-strong`:i?`bg-success`:`bg-border/60`)})]}),(0,B.jsxs)(`span`,{"data-slot":`ask-progress-summary`,className:`hidden text-xs text-soft-foreground tabular-nums sm:inline`,children:[n,` of `,t,` answered`]}),g?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{"data-slot":`ask-step-actions`,className:`ms-auto flex items-center gap-2`,children:[x,C]}),S||h?(0,B.jsxs)(`div`,{"data-slot":`ask-secondary-actions`,className:`ms-auto flex items-center gap-2`,children:[S,h]}):null,b]}):(0,B.jsxs)(B.Fragment,{children:[b,(0,B.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:[h,x,S,C]})]})]})}function Be({oneTap:e,hasOtherAnswer:t,allowComment:n,commentOpen:r,hasComment:i,resuming:a,disabled:o,onToggleComment:s,onSend:c,stopControl:l,compact:u=!1}){return(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n?(0,B.jsxs)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-add-comment`,className:`px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:s,children:[(0,B.jsx)(R,{"aria-hidden":`true`,className:`size-3.5`}),r?`Hide comment`:i?`Edit comment`:`+ Add comment`]}):null,u&&!a?null:(0,B.jsx)(`span`,{"data-slot":a?`ask-resume-hint`:`ask-hint`,className:`text-xs text-soft-foreground`,children:a?`Reopens the closed session.`:e?`Tap an option to send.`:`Choose an answer, then send.`}),(0,B.jsxs)(`div`,{className:`ms-auto flex items-center gap-2`,children:[l,!e||t||r||i?(0,B.jsx)(A,{type:`button`,size:`sm`,className:`px-3.5`,disabled:o,onClick:c,children:a?`Send answer & reopen`:`Send answer`}):null]})]})}function Ve({blockedBy:e,reason:t,error:n}){return(0,B.jsxs)(B.Fragment,{children:[t?(0,B.jsxs)(`p`,{"data-slot":`ask-blocked-reason`,className:`text-xs text-muted-foreground`,children:[t,` `,e===`provider`?(0,B.jsx)(P,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null]}):null,n?(0,B.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:n}):null]})}function He({onShowOrigin:e,className:t}){return(0,B.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,onClick:e,className:p(`px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,t),children:`Show where it was asked`})}function Ue({open:e,onOpenChange:t,runId:n,context:r,onShowOrigin:i,returnFocusRef:a}){let o=(0,z.useRef)(!1);return(0,B.jsx)(oe,{open:e,onOpenChange:t,children:(0,B.jsxs)(ce,{side:`right`,showCloseButton:!1,"data-slot":`ask-context-sheet`,className:`flex w-full max-w-[540px] flex-col gap-0 p-0 sm:max-w-[540px]`,onCloseAutoFocus:e=>{if(e.preventDefault(),o.current){o.current=!1,i?.();return}a?.current?.focus()},children:[(0,B.jsxs)(ae,{className:`relative shrink-0 border-b border-border px-5 py-4 pr-14`,children:[(0,B.jsx)(se,{children:`Question context`}),(0,B.jsx)(le,{children:`Your selections and drafts stay intact while you read.`}),(0,B.jsx)(ie,{asChild:!0,children:(0,B.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,className:`absolute inset-bs-2 end-2`,children:(0,B.jsx)(b,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,B.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain break-words px-5 py-4 text-sm text-foreground`,children:(0,B.jsx)(ye,{runId:n,children:(0,B.jsx)(L,{breaks:!0,children:r})})}),i?(0,B.jsx)(`div`,{className:`flex shrink-0 items-center justify-end border-t border-border px-5 py-3`,children:(0,B.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-show-origin`,onClick:()=>{o.current=!0,t(!1),i()},children:`Show where it was asked`})}):null]})})}function We(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ge=/^[A-Za-z0-9_./:=+,@%-]+$/;function Ke(e){return e.replaceAll(`'`,`'\\''`)}function qe(e){return e===``?`''`:Ge.test(e)?e:`\u0027${Ke(e)}\u0027`}function Je(e){if(!We(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(qe).join(` `)}}function Ye(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function Xe(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Ze(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function U(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Qe(e){let t=Ye(Xe(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))U(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){U(e[2])&&i.push({label:Ze(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Ze(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&U(t)&&i.push({label:t,href:t})}return i}var $e=(0,z.createContext)(void 0),et=(0,z.createContext)(void 0);function tt(e,t){let n=new Map;for(let r of Qe(e)){let e=fe(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function W(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function nt({text:e,messageKey:t}){let n=(0,z.useContext)(_e),r=(0,z.useContext)(et),i=t??r;if(!n||i===void 0)return null;let a=tt(e,n);return a.length===0?null:(0,B.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,B.jsx)(rt,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function rt({reference:e,messageKey:t}){let{artifactId:n,runId:i,label:a,href:o}=e,s=(0,z.useContext)($e),c=(0,z.useContext)(ue);(0,z.useLayoutEffect)(()=>c?.register(n,i),[c,n,i]);let l=r(i,n),p=f(),m=u();if(l.isError)return(0,B.jsx)(d,{id:W(t,n),"data-slot":`report-card-fallback`,to:o,state:{readerFrom:p.pathname+p.search},children:a});let h=l.data?.artifact;if(h&&!de(h.name))return null;let g=new URLSearchParams(p.search);g.set(`report`,n),g.set(`card`,t);let _=new URLSearchParams(p.search).has(`report`)?p.state:null,v=new URLSearchParams(p.search);v.delete(`report`),v.delete(`card`);let y=`${p.pathname}${v.size?`?${v}`:``}`,b=window.navigation,x={reportCardEntry:!0,reportReturnTo:_?.reportReturnTo??y,reportReturnKey:_?.reportReturnKey??b?.currentEntry?.key,reportScrollTop:_?.reportScrollTop},S={pathname:p.pathname,search:`?${g}`,hash:new URL(o,`https://cockpit.invalid`).hash};return(0,B.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":i,"aria-busy":l.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,B.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:h?be(h):a}),(0,B.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,B.jsx)(d,{id:W(t,n),to:S,state:x,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),s?.(t);let n=x.reportScrollTop??(document.querySelector(`[data-slot="thread-transcript"]`)??document.querySelector(`[data-slot="main"]`))?.scrollTop;m(S,{state:{...x,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${l.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var it={message:!0,reasoning:!0,tool:!0,hook:!0};function at(e){return Object.hasOwn(it,e)&&it[e]}var G=e=>e.kind===`tool`,ot=e=>e.kind===`conversation`,st=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,ct=(e,t,n)=>`${e} ${e===1?t:n}`;function lt(e,t){let n=[];return e>0&&n.push(ct(e,`file`,`files`)),t>0&&n.push(ct(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function ut(e){return`${e} earlier tool call${e===1?``:`s`}`}var dt=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function ft(e){for(let t of dt)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var pt=new WeakMap;function mt(e){let t=pt.get(e);if(t)return t;let n=ht(e);return pt.set(e,n),n}function ht(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(G).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=at(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:lt(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of gt(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(ot(e)){s(),c.push(e);continue}l(),G(e)&&st(e)&&!r.has(e.id)?o.push(e):(s(),G(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function gt(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var K=new Map,_t=(0,z.createContext)(null);function q(){return(0,z.useContext)(_t)}function vt({runId:e,children:t}){let n=(0,z.useMemo)(()=>({get:t=>K.get(e)?.get(t),set:(t,n)=>{let r=K.get(e)??new Map;r.set(t,n),K.set(e,r)}}),[e]);return(0,B.jsx)(_t.Provider,{value:n,children:t})}function yt(e){return e.scrollTop<Math.max(600,e.clientHeight)}function bt(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function xt(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function St(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function Ct(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var wt=new Map;function Tt(e,t){wt.set(e,t)}function Et(e){return wt.get(e)}var J=new Map;function Dt(e,t){J.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function Ot(e){return J.get(e)}function kt(e,t,n){let r=J.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var At=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),jt=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Mt=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Nt=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Pt=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Y(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function X(e){let t=Y(e);return t===void 0?void 0:At.format(t)}function Ft(e){let t=Y(e);return t===void 0?void 0:jt.format(t)}var Z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function It(e){let t=Y(e);return t===void 0?void 0:Z(t)}function Lt(e,t=new Date){let n=Y(e);if(n===void 0)return;let r=Z(n);return r===Z(t)?`Today`:r===Z(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Mt:Nt).format(n)}function Rt(e,t){let n=Y(e),r=Y(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function zt({ts:e}){let t=X(e);return t===void 0?null:(0,B.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Ft(e),className:`text-xs leading-none text-soft-foreground`,children:t})}function Bt({startedAt:e,completedAt:t}){let n=X(t);if(n===void 0)return null;let r=Rt(e,t);return(0,B.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-xs leading-none text-soft-foreground`,children:[(0,B.jsx)(`time`,{dateTime:t,title:Ft(t),children:n}),r===void 0?null:(0,B.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Vt({ts:e}){let t=Lt(e),n=Y(e);if(t===void 0||n===void 0)return null;let r=Pt.format(n);return(0,B.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-xs font-medium text-soft-foreground`,children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,B.jsx)(`time`,{dateTime:It(e),title:r,children:t}),(0,B.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Ht={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function Ut({note:e}){return e.icon===`handoff`?(0,B.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,B.jsx)(pe,{className:`size-3`})}),(0,B.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,B.jsxs)(N,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,B.jsxs)(`div`,{className:p(`flex items-start gap-2`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,B.jsxs)(M,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,B.jsx)(v,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,B.jsx)(j,{children:(0,B.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-xs text-muted-foreground`,children:e.details.map((e,t)=>(0,B.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,B.jsxs)(`span`,{className:`font-sans font-medium text-foreground`,children:[Ht[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,B.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:p(`px-0.5 text-xs`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var Wt={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function Q({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let o=Wt[e],s=r===void 0?void 0:X(r);return(0,B.jsxs)(`article`,{...a,"data-role":e,"aria-label":o.speaker,className:p(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes,n),children:[(0,B.jsxs)(`p`,{className:p(`m-0 flex w-full min-w-0 items-start gap-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,B.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,B.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,B.jsx)(te,{"aria-hidden":`true`,className:`size-4 shrink-0`}),o.label]}),i]}),s===void 0?null:(0,B.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,B.jsx)(zt,{ts:r})})]}),(0,B.jsx)(`div`,{className:p(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,o.body,`leading-[1.6]`),children:t})]})}var Gt=[],Kt=(0,z.memo)(function({text:e,imageCount:t=0,images:n=Gt,ts:r,onEdit:i,onRemove:a,editLabel:s=`Edit message`,removeLabel:l=`Remove message`,children:u}){let d=t-n.length,[f,p]=(0,z.useState)(!1),[h,g]=(0,z.useState)(e),[_,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)(),x=()=>{g(e),b(void 0),p(!0)},C=async()=>{let t=h.trim();if(!t||t===e){p(!1);return}v(!0),b(void 0);try{await i?.(t),p(!1)}catch(e){b(e instanceof Error?e.message:`Could not save the message`)}finally{v(!1)}},w=async()=>{v(!0),b(void 0);try{await a?.()}catch(e){b(e instanceof Error?e.message:`Could not remove the message`)}finally{v(!1)}};return f?(0,B.jsxs)(Q,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,B.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),p(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),C())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,B.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>p(!1),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:_?(0,B.jsx)(O,{className:`size-3.5 animate-spin`}):`Save`})]}),y?(0,B.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:y}):null]}):(0,B.jsxs)(Q,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[i||a?(0,B.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[i?(0,B.jsx)(`button`,{type:`button`,"aria-label":s,onClick:x,disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,B.jsx)(Te,{className:`size-3.5`})}):null,a?(0,B.jsx)(`button`,{type:`button`,"aria-label":l,onClick:()=>void w(),disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,B.jsx)(S,{className:`size-3.5`})}):null]}):null,y?(0,B.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:y}):null,u??(0,B.jsx)(L,{breaks:!0,children:e}),n.length>0?(0,B.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>c(e.split(`/`).pop()??``)?(0,B.jsx)(ve,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,B.jsxs)(`a`,{href:o(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(m,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,d>0?(0,B.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[d,` image`,d>1?`s`:``,` attached`]}):null]})}),qt=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,Jt=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Yt(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Jt).forEach(e=>e.remove());let r=Qe(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!U(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Xt(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=Yt(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var Zt=(0,z.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,z.useRef)(null),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),c=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Xt(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,B.jsxs)(Q,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,B.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:qt,children:[(0,B.jsx)(w,{className:`size-3.5`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,B.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:qt,children:[(0,B.jsx)(F,{className:`size-3.5`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,B.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,B.jsx)(`div`,{ref:r,children:(0,B.jsx)(L,{breaks:!0,children:e})}),(0,B.jsx)(nt,{text:e,messageKey:n})]})});function Qt({incident:e}){let t=i().data;if(!t)return null;let n=a(t,e.provider);return(0,B.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,B.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,B.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,B.jsx)(P,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var $t=(0,z.memo)(function({text:e}){let t=(0,z.useId)();if(e.trim()===``)return null;let n=e.split(`
4
+ `;function Ae(e){let t=e.indexOf(ke);if(t<0)return{body:e,comment:void 0};let n=e.slice(t+23).trim();return{body:e.slice(0,t),comment:n||void 0}}function je({ask:e}){let t=e.answer===void 0?void 0:Ae(e.answer),n=t===void 0?void 0:Ee(e.questions,t.body);return(0,B.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((t,r)=>{let i=n?.[r],a=Oe(t,i),o=i!==void 0&&a.length===0;return(0,B.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":t.question,children:[(0,B.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[t.header,` · Question `,r+1,` of `,e.questions.length]}),(0,B.jsx)(`p`,{className:`break-words font-semibold`,children:t.question}),t.options?(0,B.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[t.options.map(e=>(0,B.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,B.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,B.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,B.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,B.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,B.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,B.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,B.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,B.jsx)(V,{text:i}):null]})]}):i===void 0?null:(0,B.jsx)(V,{text:i})]},t.id??r)}),n&&t?.comment?(0,B.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`Additional comments`,children:[(0,B.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Additional comments`}),(0,B.jsx)(V,{text:t.comment})]}):null,!n&&e.answer!==void 0?(0,B.jsx)(V,{text:e.answer}):null]})}function V({text:e}){return(0,B.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}function H(e,t,n){let r=n[e];return r===void 0?(t[e]?.length??0)>0:r.trim().length>0}function Me(e,t,n){let r=n[e]?.trim();if(r)return r;let i=t[e]??[];return i.length>0?i.join(`, `):`Not answered yet`}function Ne({stepped:e,mode:t,onModeChange:n,showModeSwitch:r,stepLabel:i,hasSheetContext:a,showContextButtonRef:o,onOpenContext:s,onShowOrigin:c,onFold:l}){let u=l!==void 0,d=a?(0,B.jsxs)(A,{ref:o,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,"aria-label":u?`Show context`:void 0,className:p(`px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,u&&`ms-auto`),onClick:s,children:[(0,B.jsx)(F,{"aria-hidden":`true`,className:`size-3.5`}),u?`Context`:`Show context`]}):c&&u?(0,B.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`ask-show-origin`,"aria-label":`Show where it was asked`,title:`Show where it was asked`,className:`ms-auto shrink-0 text-link-foreground`,onClick:c,children:(0,B.jsx)(we,{"aria-hidden":`true`,className:`size-4`})}):c?(0,B.jsx)(He,{onShowOrigin:c}):null,f=r?(0,B.jsx)(Pe,{mode:t,onModeChange:n}):null;return u?(0,B.jsxs)(`div`,{"data-slot":`ask-header`,"data-compact":`true`,className:`flex shrink-0 items-center gap-1.5 border-b border-border/70 py-1 ps-1.5 pe-1`,children:[(0,B.jsx)(`span`,{className:`sr-only`,children:`Needs your answer`}),e&&t===`options`?(0,B.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`sr-only`,children:i}):null,f,d,(0,B.jsx)(A,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`ask-fold`,"aria-label":`Fold the question`,"aria-expanded":`true`,className:p(`shrink-0 text-muted-foreground`,!d&&`ms-auto`),onClick:l,children:(0,B.jsx)(C,{"aria-hidden":`true`,className:`size-4`})})]}):(0,B.jsxs)(`div`,{"data-slot":`ask-header`,className:`flex shrink-0 flex-wrap items-center gap-x-2 gap-y-1 border-b border-border/70 px-2.5 py-1.5 md:px-3 md:py-2`,children:[(0,B.jsx)(`span`,{className:`text-xs font-semibold text-link-foreground`,children:`Needs your answer`}),e&&t===`options`?(0,B.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`rounded-full bg-accent-strong/15 px-2 py-0.5 text-xs font-semibold text-foreground tabular-nums`,children:i}):null,(0,B.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-1.5`,children:[d,f]})]})}function Pe({mode:e,onModeChange:t}){return(0,B.jsxs)(`div`,{"data-slot":`ask-mode-switch`,role:`group`,"aria-label":`Reply mode`,className:`inline-flex shrink-0 items-center rounded-lg border border-border bg-card p-0.5`,children:[(0,B.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-options`,"aria-pressed":e===`options`,onClick:()=>t(`options`),className:p(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,e===`options`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Options`}),(0,B.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-reply`,"aria-pressed":e===`reply`,onClick:()=>t(`reply`),className:p(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,e===`reply`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Write a reply`})]})}function Fe({tag:e,text:t,position:n,onOpen:r}){return(0,B.jsxs)(`button`,{type:`button`,"data-slot":`ask-folded-row`,"aria-expanded":`false`,onClick:r,className:`flex min-h-11 w-full min-w-0 items-center gap-2 rounded-xl px-2.5 py-1.5 text-start focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,B.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-semibold text-foreground`,children:t}),n===void 0?null:(0,B.jsx)(`span`,{"data-slot":`ask-folded-position`,className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:n}),(0,B.jsx)(`span`,{className:`sr-only`,children:`Open the question`}),(0,B.jsx)(y,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`})]})}function Ie({questions:e,stepIndex:t,selections:n,otherAnswers:r,hasComment:i,onSelectStep:a}){let o=e.length;return(0,B.jsxs)(`div`,{"data-slot":`ask-step-pills`,role:`group`,"aria-label":`Question steps`,className:`hidden shrink-0 flex-wrap items-center gap-1.5 border-b border-border/60 px-3 py-1.5 md:flex`,children:[e.map((e,i)=>{let o=t===i,s=H(i,n,r);return(0,B.jsxs)(`button`,{type:`button`,"aria-current":o?`step`:void 0,onClick:()=>a(i),className:p(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,o?`border-accent-strong bg-accent-strong/15 text-foreground`:s?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,B.jsx)(`span`,{className:`tabular-nums text-xs font-semibold`,children:s?(0,B.jsx)(E,{"aria-hidden":`true`,className:`size-3 text-semantic-green`}):`${i+1}.`}),(0,B.jsx)(`span`,{className:`max-w-[140px] truncate`,children:e.header})]},e.id??i)}),(0,B.jsxs)(`button`,{type:`button`,"aria-current":t===o?`step`:void 0,onClick:()=>a(o),className:p(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,t===o?`border-accent-strong bg-accent-strong/15 text-foreground`:i?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-dashed border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,B.jsx)(R,{"aria-hidden":`true`,className:`size-3`}),(0,B.jsx)(`span`,{children:`Comment`})]})]})}function Le({questions:e,selections:t,otherAnswers:n,comment:r,disabled:i,onCommentChange:a,onJumpToQuestion:o}){let s=(0,z.useId)();return(0,B.jsxs)(`div`,{"data-slot":`ask-comment-step`,className:`flex flex-col gap-2.5`,children:[(0,B.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-2.5`,children:[(0,B.jsx)(`p`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Selected answers`}),(0,B.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map((e,r)=>{let i=H(r,t,n);return(0,B.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>o(r),className:`min-h-11 text-start font-medium text-link-foreground underline-offset-4 hover:underline md:min-h-6`,children:e.header}),(0,B.jsx)(`span`,{className:p(`min-w-0 truncate text-end`,i?`text-foreground`:`text-semantic-red`),children:Me(r,t,n)})]},e.id??r)})})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`label`,{htmlFor:s,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,B.jsx)(I,{id:s,"data-slot":`ask-additional-comment`,rows:2,value:r,disabled:i,placeholder:`Optional extra notes to send with your selections…`,onChange:e=>a(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}function Re({value:e,onValueChange:t,disabled:n,renderFreeTextReply:r}){let i=(0,z.useId)();return r?(0,B.jsx)(`div`,{"data-slot":`ask-free-text`,children:r({value:e,onValueChange:t,disabled:n})}):(0,B.jsxs)(`div`,{"data-slot":`ask-free-text`,className:`flex flex-col gap-2`,children:[(0,B.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium text-foreground`,children:`Reply to the agent`}),(0,B.jsx)(I,{id:i,rows:2,value:e,disabled:n,placeholder:`Write a free-text reply…`,onChange:e=>t(e.target.value),className:`bg-card text-base md:text-[13px]`})]})}function ze({stepIndex:e,questionCount:t,answeredCount:n,allAnswered:r,hasComment:i,resuming:a,disabled:o,onBack:s,onNext:c,onOpenComment:l,onSend:u,questions:d,selections:f,otherAnswers:m,stopControl:h,compact:g=!1}){let _=e===t-1,v=e===t,y=a?`Send answer & reopen`:`Send answer`,b=a?(0,B.jsx)(`span`,{"data-slot":`ask-resume-hint`,className:`text-xs text-soft-foreground`,children:`Reopens the closed session.`}):null,x=!_&&!v?(0,B.jsxs)(A,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:c,children:[`Next`,(0,B.jsx)(D,{"aria-hidden":`true`,className:`size-4`})]}):null,S=_?(0,B.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:l,children:i?`Edit comment`:`+ Comment`}):null,C=_||v||r?(0,B.jsx)(A,{type:`button`,size:`sm`,className:`px-3.5`,disabled:o||!r,onClick:u,children:y}):null;return(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e>0?(0,B.jsxs)(A,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:s,children:[(0,B.jsx)(ge,{"aria-hidden":`true`,className:`size-4`}),`Back`]}):null,(0,B.jsxs)(`span`,{"data-slot":`ask-progress-dots`,"aria-hidden":`true`,className:`flex items-center gap-1.5 px-1 md:hidden`,children:[d.map((t,n)=>{let r=n===e,i=H(n,f,m);return(0,B.jsx)(`span`,{className:p(`size-2 rounded-full motion-safe:transition-colors`,r?`bg-accent-strong`:i?`bg-success`:`bg-border`)},t.id??n)}),(0,B.jsx)(`span`,{className:p(`size-2 rounded-full motion-safe:transition-colors`,v?`bg-accent-strong`:i?`bg-success`:`bg-border/60`)})]}),(0,B.jsxs)(`span`,{"data-slot":`ask-progress-summary`,className:`hidden text-xs text-soft-foreground tabular-nums sm:inline`,children:[n,` of `,t,` answered`]}),g?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{"data-slot":`ask-step-actions`,className:`ms-auto flex items-center gap-2`,children:[x,C]}),S||h?(0,B.jsxs)(`div`,{"data-slot":`ask-secondary-actions`,className:`ms-auto flex items-center gap-2`,children:[S,h]}):null,b]}):(0,B.jsxs)(B.Fragment,{children:[b,(0,B.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:[h,x,S,C]})]})]})}function Be({oneTap:e,hasOtherAnswer:t,allowComment:n,commentOpen:r,hasComment:i,resuming:a,disabled:o,onToggleComment:s,onSend:c,stopControl:l,compact:u=!1}){return(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n?(0,B.jsxs)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-add-comment`,className:`px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:s,children:[(0,B.jsx)(R,{"aria-hidden":`true`,className:`size-3.5`}),r?`Hide comment`:i?`Edit comment`:`+ Add comment`]}):null,u&&!a?null:(0,B.jsx)(`span`,{"data-slot":a?`ask-resume-hint`:`ask-hint`,className:`text-xs text-soft-foreground`,children:a?`Reopens the closed session.`:e?`Tap an option to send.`:`Choose an answer, then send.`}),(0,B.jsxs)(`div`,{className:`ms-auto flex items-center gap-2`,children:[l,!e||t||r||i?(0,B.jsx)(A,{type:`button`,size:`sm`,className:`px-3.5`,disabled:o,onClick:c,children:a?`Send answer & reopen`:`Send answer`}):null]})]})}function Ve({blockedBy:e,reason:t,error:n}){return(0,B.jsxs)(B.Fragment,{children:[t?(0,B.jsxs)(`p`,{"data-slot":`ask-blocked-reason`,className:`text-xs text-muted-foreground`,children:[t,` `,e===`provider`?(0,B.jsx)(P,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null]}):null,n?(0,B.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:n}):null]})}function He({onShowOrigin:e,className:t}){return(0,B.jsx)(A,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,onClick:e,className:p(`px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,t),children:`Show where it was asked`})}function Ue({open:e,onOpenChange:t,runId:n,context:r,onShowOrigin:i,returnFocusRef:a}){let o=(0,z.useRef)(!1);return(0,B.jsx)(oe,{open:e,onOpenChange:t,children:(0,B.jsxs)(ce,{side:`right`,showCloseButton:!1,"data-slot":`ask-context-sheet`,className:`flex w-full max-w-[540px] flex-col gap-0 p-0 sm:max-w-[540px]`,onCloseAutoFocus:e=>{if(e.preventDefault(),o.current){o.current=!1,i?.();return}a?.current?.focus()},children:[(0,B.jsxs)(ae,{className:`relative shrink-0 border-b border-border px-5 py-4 pr-14`,children:[(0,B.jsx)(se,{children:`Question context`}),(0,B.jsx)(le,{children:`Your selections and drafts stay intact while you read.`}),(0,B.jsx)(ie,{asChild:!0,children:(0,B.jsx)(A,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,className:`absolute inset-bs-2 end-2`,children:(0,B.jsx)(b,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,B.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain break-words px-5 py-4 text-sm text-foreground`,children:(0,B.jsx)(ye,{runId:n,children:(0,B.jsx)(L,{breaks:!0,children:r})})}),i?(0,B.jsx)(`div`,{className:`flex shrink-0 items-center justify-end border-t border-border px-5 py-3`,children:(0,B.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-show-origin`,onClick:()=>{o.current=!0,t(!1),i()},children:`Show where it was asked`})}):null]})})}function We(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ge=/^[A-Za-z0-9_./:=+,@%-]+$/;function Ke(e){return e.replaceAll(`'`,`'\\''`)}function qe(e){return e===``?`''`:Ge.test(e)?e:`\u0027${Ke(e)}\u0027`}function Je(e){if(!We(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(qe).join(` `)}}function Ye(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function Xe(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Ze(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function U(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function Qe(e){let t=Ye(Xe(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))U(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){U(e[2])&&i.push({label:Ze(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Ze(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&U(t)&&i.push({label:t,href:t})}return i}var $e=(0,z.createContext)(void 0),et=(0,z.createContext)(void 0);function tt(e,t){let n=new Map;for(let r of Qe(e)){let e=fe(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function W(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function nt({text:e,messageKey:t}){let n=(0,z.useContext)(_e),r=(0,z.useContext)(et),i=t??r;if(!n||i===void 0)return null;let a=tt(e,n);return a.length===0?null:(0,B.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,B.jsx)(rt,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function rt({reference:e,messageKey:t}){let{artifactId:n,runId:i,label:a,href:o}=e,s=(0,z.useContext)($e),c=(0,z.useContext)(ue);(0,z.useLayoutEffect)(()=>c?.register(n,i),[c,n,i]);let l=r(i,n),p=f(),m=u();if(l.isError)return(0,B.jsx)(d,{id:W(t,n),"data-slot":`report-card-fallback`,to:o,state:{readerFrom:p.pathname+p.search},children:a});let h=l.data?.artifact;if(h&&!de(h.name))return null;let g=new URLSearchParams(p.search);g.set(`report`,n),g.set(`card`,t);let _=new URLSearchParams(p.search).has(`report`)?p.state:null,v=new URLSearchParams(p.search);v.delete(`report`),v.delete(`card`);let y=`${p.pathname}${v.size?`?${v}`:``}`,b=window.navigation,x={reportCardEntry:!0,reportReturnTo:_?.reportReturnTo??y,reportReturnKey:_?.reportReturnKey??b?.currentEntry?.key,reportScrollTop:_?.reportScrollTop},S={pathname:p.pathname,search:`?${g}`,hash:new URL(o,`https://cockpit.invalid`).hash};return(0,B.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":i,"aria-busy":l.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,B.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:h?be(h):a}),(0,B.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,B.jsx)(d,{id:W(t,n),to:S,state:x,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),s?.(t);let n=x.reportScrollTop??(document.querySelector(`[data-slot="thread-transcript"]`)??document.querySelector(`[data-slot="main"]`))?.scrollTop;m(S,{state:{...x,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${l.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var it={message:!0,reasoning:!0,tool:!0,hook:!0};function at(e){return Object.hasOwn(it,e)&&it[e]}var G=e=>e.kind===`tool`,ot=e=>e.kind===`conversation`,st=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,ct=(e,t,n)=>`${e} ${e===1?t:n}`;function lt(e,t){let n=[];return e>0&&n.push(ct(e,`file`,`files`)),t>0&&n.push(ct(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function ut(e){return`${e} earlier tool call${e===1?``:`s`}`}var dt=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function ft(e){for(let t of dt)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var pt=new WeakMap;function mt(e){let t=pt.get(e);if(t)return t;let n=ht(e);return pt.set(e,n),n}function ht(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(G).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=at(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:lt(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of gt(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(ot(e)){s(),c.push(e);continue}l(),G(e)&&st(e)&&!r.has(e.id)?o.push(e):(s(),G(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function gt(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var K=new Map,_t=(0,z.createContext)(null);function q(){return(0,z.useContext)(_t)}function vt({runId:e,children:t}){let n=(0,z.useMemo)(()=>({get:t=>K.get(e)?.get(t),set:(t,n)=>{let r=K.get(e)??new Map;r.set(t,n),K.set(e,r)}}),[e]);return(0,B.jsx)(_t.Provider,{value:n,children:t})}function yt(e){return e.scrollTop<Math.max(600,e.clientHeight)}function bt(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function xt(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function St(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function Ct(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var wt=new Map;function Tt(e,t){wt.set(e,t)}function Et(e){return wt.get(e)}var J=new Map;function Dt(e,t){J.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function Ot(e){return J.get(e)}function kt(e,t,n){let r=J.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var At=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),jt=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Mt=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Nt=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Pt=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function Y(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function X(e){let t=Y(e);return t===void 0?void 0:At.format(t)}function Ft(e){let t=Y(e);return t===void 0?void 0:jt.format(t)}var Z=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function It(e){let t=Y(e);return t===void 0?void 0:Z(t)}function Lt(e,t=new Date){let n=Y(e);if(n===void 0)return;let r=Z(n);return r===Z(t)?`Today`:r===Z(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Mt:Nt).format(n)}function Rt(e,t){let n=Y(e),r=Y(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function zt({ts:e}){let t=X(e);return t===void 0?null:(0,B.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:Ft(e),className:`text-xs leading-none text-soft-foreground`,children:t})}function Bt({startedAt:e,completedAt:t}){let n=X(t);if(n===void 0)return null;let r=Rt(e,t);return(0,B.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-xs leading-none text-soft-foreground`,children:[(0,B.jsx)(`time`,{dateTime:t,title:Ft(t),children:n}),r===void 0?null:(0,B.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Vt({ts:e}){let t=Lt(e),n=Y(e);if(t===void 0||n===void 0)return null;let r=Pt.format(n);return(0,B.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-xs font-medium text-soft-foreground`,children:[(0,B.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,B.jsx)(`time`,{dateTime:It(e),title:r,children:t}),(0,B.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var Ht={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function Ut({note:e}){return e.icon===`handoff`?(0,B.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,B.jsx)(pe,{className:`size-3`})}),(0,B.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,B.jsxs)(N,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,B.jsxs)(`div`,{className:p(`flex items-start gap-2`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[(0,B.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,B.jsxs)(M,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,B.jsx)(v,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,B.jsx)(j,{children:(0,B.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-xs text-muted-foreground`,children:e.details.map((e,t)=>(0,B.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,B.jsxs)(`span`,{className:`font-sans font-medium text-foreground`,children:[Ht[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,B.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:p(`px-0.5 text-xs`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var Wt={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function Q({role:e,children:t,className:n,ts:r,headerActions:i,...a}){let o=Wt[e],s=r===void 0?void 0:X(r);return(0,B.jsxs)(`article`,{...a,"data-role":e,"aria-label":o.speaker,className:p(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,o.classes,n),children:[(0,B.jsxs)(`p`,{className:p(`m-0 flex w-full min-w-0 items-start gap-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,o.accent),children:[(0,B.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,B.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,B.jsx)(te,{"aria-hidden":`true`,className:`size-4 shrink-0`}),o.label]}),i]}),s===void 0?null:(0,B.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,B.jsx)(zt,{ts:r})})]}),(0,B.jsx)(`div`,{className:p(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,o.body,`leading-[1.6]`),children:t})]})}var Gt=[],Kt=(0,z.memo)(function({text:e,imageCount:t=0,images:n=Gt,ts:r,onEdit:i,onRemove:a,editLabel:c=`Edit message`,removeLabel:l=`Remove message`,children:u}){let d=t-n.length,[f,p]=(0,z.useState)(!1),[h,g]=(0,z.useState)(e),[_,v]=(0,z.useState)(!1),[y,b]=(0,z.useState)(),x=()=>{g(e),b(void 0),p(!0)},C=async()=>{let t=h.trim();if(!t||t===e){p(!1);return}v(!0),b(void 0);try{await i?.(t),p(!1)}catch(e){b(e instanceof Error?e.message:`Could not save the message`)}finally{v(!1)}},w=async()=>{v(!0),b(void 0);try{await a?.()}catch(e){b(e instanceof Error?e.message:`Could not remove the message`)}finally{v(!1)}};return f?(0,B.jsxs)(Q,{role:`user`,ts:r,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,B.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),p(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),C())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,B.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>p(!1),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:_?(0,B.jsx)(O,{className:`size-3.5 animate-spin`}):`Save`})]}),y?(0,B.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:y}):null]}):(0,B.jsxs)(Q,{role:`user`,ts:r,"data-slot":`user-bubble`,className:`group`,children:[i||a?(0,B.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[i?(0,B.jsx)(`button`,{type:`button`,"aria-label":c,onClick:x,disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,B.jsx)(Te,{className:`size-3.5`})}):null,a?(0,B.jsx)(`button`,{type:`button`,"aria-label":l,onClick:()=>void w(),disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,B.jsx)(S,{className:`size-3.5`})}):null]}):null,y?(0,B.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:y}):null,u??(0,B.jsx)(L,{breaks:!0,children:e}),n.length>0?(0,B.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>s(e.split(`/`).pop()??``)?(0,B.jsx)(ve,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,B.jsxs)(`a`,{href:o(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(m,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,B.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,d>0?(0,B.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[d,` image`,d>1?`s`:``,` attached`]}):null]})}),qt=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,Jt=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Yt(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Jt).forEach(e=>e.remove());let r=Qe(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!U(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Xt(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=Yt(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var Zt=(0,z.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,z.useRef)(null),[i,a]=(0,z.useState)(null),[o,s]=(0,z.useState)(null),c=(0,z.useRef)(null);(0,z.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Xt(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,B.jsxs)(Q,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,B.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,B.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:qt,children:[(0,B.jsx)(w,{className:`size-3.5`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,B.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:qt,children:[(0,B.jsx)(F,{className:`size-3.5`,"aria-hidden":`true`}),(0,B.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,B.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,B.jsx)(`div`,{ref:r,children:(0,B.jsx)(L,{breaks:!0,children:e})}),(0,B.jsx)(nt,{text:e,messageKey:n})]})});function Qt({incident:e}){let t=i().data;if(!t)return null;let n=a(t,e.provider);return(0,B.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,B.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,B.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,B.jsx)(P,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var $t=(0,z.memo)(function({text:e}){let t=(0,z.useId)();if(e.trim()===``)return null;let n=e.split(`
5
5
  `,1)[0]??``,r=n.length<e.length;return(0,B.jsxs)(N,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,B.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,B.jsx)(v,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,B.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,B.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground max-md:[&_*]:inline max-md:[&_*]:whitespace-nowrap`,children:(0,B.jsx)(L,{inline:!0,children:n})}),r?(0,B.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,B.jsx)(M,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,B.jsx)(j,{children:(0,B.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,B.jsx)(L,{children:e})})})]})});function en(){return(0,B.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,B.jsx)(O,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,B.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var tn={read:F,edit:Te,delete:S,move:Ce,search:h,execute:k,think:Se,fetch:ee,task:_,plan:g,other:x},nn=e=>e.split(`
6
6
  `).length;function rn({text:e,streaming:t}){let[n,r]=(0,z.useState)(!1),i=(0,z.useRef)(null),a=(0,z.useRef)(!0);(0,z.useEffect)(()=>{let e=i.current;t&&e&&a.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let o=nn(e),s=!t&&!n&&o>12;return(0,B.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":s?`true`:void 0,children:[(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(`div`,{ref:i,onScroll:t?e=>{a.current=St(e.currentTarget)}:void 0,className:p(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,s&&`max-h-[216px] overflow-y-hidden`),children:(0,B.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),s?(0,B.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&o>12?(0,B.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-xs font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${o} lines`}):null]})}function an({diffs:e}){return(0,B.jsx)(B.Fragment,{children:e.map((e,t)=>(0,B.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-xs wrap-anywhere text-muted-foreground`,children:e.path}),(0,B.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...on(e.oldText).map((e,t)=>(0,B.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...on(e.newText).map((e,t)=>(0,B.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
7
7
  `).map((e,t)=>(0,B.jsx)(sn,{text:e},t))})]},`${e.path}:${t}`))})}function on(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
8
8
  `)}function sn({text:e}){return(0,B.jsx)(`span`,{className:p(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function cn(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function ln(e){let t=e.status===`running`||e.status===`pending`,n=ft(e.title),{verb:r,detail:i}=e.toolKind===`execute`&&n.detail===void 0?{verb:`Ran`,detail:e.title}:n;return{busy:t,verb:r,detail:i,expandedCommand:(e.toolKind===`execute`?Je(e.input):ne(e.name).toolKind===e.toolKind?re(e.name,e.input):void 0)??i,Icon:tn[e.toolKind]??x}}function un(e,t){return e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t>0}function dn({item:e,busy:t}){return(0,B.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[t?(0,B.jsx)(O,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,B.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,B.jsx)(`span`,{"data-slot":`tool-exit`,className:p(`rounded-full px-2 py-px font-mono text-xs font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})}function fn({item:e,command:t,busy:n,nested:r,cacheKey:i,renderNested:a}){return(0,B.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[t===void 0?null:(0,B.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t}),e.error!==void 0&&e.error!==``?(0,B.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap wrap-anywhere text-signal-word-red`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,B.jsx)(an,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,B.jsx)(rn,{text:e.output,streaming:n}):null,r.length>0?(0,B.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:a?.(r,i??e.id)}):null]})}function pn({item:e,nested:t=[],cacheKey:n,renderNested:r}){let i=q(),[a,o]=(0,z.useState)(()=>n===void 0?null:i?.get(n)??null),s=e=>{n!==void 0&&i?.set(n,e),o(e)},{busy:c,verb:l,detail:u,expandedCommand:d,Icon:f}=ln(e),m=un(e,t.length),h=d!==void 0||m,g=h&&(a??(m&&cn(e)));return(0,B.jsxs)(N,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:g,onOpenChange:s,className:p(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,B.jsxs)(M,{disabled:!h,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,B.jsx)(v,{"aria-hidden":!0,className:p(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!h&&`invisible`)}),(0,B.jsx)(f,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,B.jsx)(`span`,{className:p(`shrink-0 font-semibold`,c&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:l}),u===void 0?null:(0,B.jsx)(`code`,{title:u,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:u}),(0,B.jsx)(dn,{item:e,busy:c})]}),(0,B.jsx)(j,{children:(0,B.jsx)(fn,{item:e,command:d,busy:c,nested:t,cacheKey:n,renderNested:r})})]})}function mn(e){let t=e.name??e.event,n=t.indexOf(`:`);return n>0?`${t.slice(0,n)} · ${t.slice(n+1)}`:t}function hn({item:e,cacheKey:t}){let n=q(),[r,i]=(0,z.useState)(()=>t===void 0?!1:n?.get(t)??!1),a=e=>{t!==void 0&&n?.set(t,e),i(e)},o=e.status!==`completed`,s=e.entries.some(e=>e.kind===`context`),c=(e.stdout??``)!==``||(e.stderr??``)!==``,l=mn(e);return(0,B.jsxs)(N,{"data-slot":`hook-card`,"data-status":e.status,open:r,onOpenChange:a,className:p(`min-w-0 overflow-hidden rounded-md border bg-card`,o?`border-danger/25`:`border-border`),children:[(0,B.jsxs)(M,{className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] hover:bg-muted`,children:[(0,B.jsx)(v,{"aria-hidden":!0,className:`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),(0,B.jsx)(xe,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,B.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Hook`}),(0,B.jsx)(`code`,{title:l,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:l}),(0,B.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[o?(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status}):s?(0,B.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`context`}):null,o&&typeof e.exitCode==`number`&&e.exitCode!==0?(0,B.jsx)(`span`,{"data-slot":`hook-exit`,className:`rounded-full bg-danger/10 px-2 py-px font-mono text-xs font-semibold text-danger`,children:e.exitCode}):null]})]}),(0,B.jsx)(j,{children:(0,B.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.entries.map((e,t)=>(0,B.jsx)(`pre`,{"data-slot":`hook-entry`,"data-kind":e.kind,className:p(`px-3 py-2 font-mono text-xs leading-[1.7] whitespace-pre-wrap [overflow-wrap:anywhere]`,(e.kind===`error`||e.kind===`stop`)&&`text-signal-word-red`),children:e.text},t)),e.source===void 0?null:(0,B.jsx)(`p`,{"data-slot":`hook-source`,className:`px-3 pb-2 font-mono text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:e.source}),c?(0,B.jsxs)(N,{className:`border-t border-border`,children:[(0,B.jsxs)(M,{"data-slot":`hook-raw-toggle`,className:`group flex w-full items-center gap-1 px-3 py-1 text-left text-xs text-muted-foreground hover:text-foreground`,children:[(0,B.jsx)(v,{"aria-hidden":!0,className:`size-3 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),`Raw output${typeof e.exitCode==`number`?` · exit ${e.exitCode}`:``}`]}),(0,B.jsxs)(j,{children:[e.stdout?(0,B.jsx)(`pre`,{"data-slot":`hook-stdout`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.stdout}):null,e.stderr?(0,B.jsx)(`pre`,{"data-slot":`hook-stderr`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap text-signal-word-red [overflow-wrap:anywhere]`,children:e.stderr}):null]})]}):null]})})]})}function gn({group:e,scope:t}){return(0,B.jsxs)(N,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,B.jsxs)(M,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,B.jsx)(v,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,B.jsx)(j,{children:(0,B.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,B.jsx)(pn,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function _n({count:e,children:t}){return(0,B.jsxs)(N,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,B.jsxs)(M,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,B.jsx)(v,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),ut(e)]}),(0,B.jsx)(j,{children:(0,B.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function vn({image:e}){return(0,B.jsx)(ve,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}var yn={finish:`Closed when the task finished`,superseded:`Closed when the worker went on`,"parent-stopped":`Closed when the parent stopped`,"worker-stopped":`Closed when the worker stopped`,undeliverable:`Closed: not delivered`};function bn(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function xn(e,t,n,r=``){let i=e.map((e,r)=>bn(e,t[r]??[],n[r])).join(`
9
- `),a=r.trim();return a?`${i}\n\nAdditional comments:\n${a}`:i}function Sn({ask:e,run:t,projectId:n,onShowOrigin:r,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s=!1,onFinish:c,finishing:l=!1,mode:u,onModeChange:d,hideReplyBody:f=!1,delivery:p,surface:m=`transcript`,fold:h}){let g=m===`transcript`&&e.context?(0,B.jsx)($,{text:e.context}):null;if(e.resolved)return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e.context?(0,B.jsx)($,{text:e.context}):null,(0,B.jsxs)(Q,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,B.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?yn[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,B.jsx)(je,{ask:e})]})]});let _=e.placement===`pinned`&&r?r:void 0;return e.routedToParent?(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[g,(0,B.jsx)(Cn,{ask:e,runId:t.id,surface:m,onShowOrigin:_})]}):(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[g,(0,B.jsx)(Dn,{ask:e,run:t,projectId:n,surface:m,onShowOrigin:_,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s,onFinish:c,finishing:l,controlledMode:u,onModeChange:d,hideReplyBody:f,delivery:p,fold:h})]})}function $({text:e}){return(0,B.jsx)(Q,{role:`agent`,children:(0,B.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,B.jsx)(L,{breaks:!0,children:e})})})}function Cn({ask:e,runId:t,surface:n,onShowOrigin:r}){let[i,a]=(0,z.useState)(!1),o=(0,z.useRef)(null),s=n===`decision-zone`&&!!e.context;return(0,B.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-xl border border-card-edge bg-card shadow-card px-3 py-2.5`,children:[(0,B.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`}),s?(0,B.jsx)(A,{ref:o,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,className:`ms-auto px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,onClick:()=>a(!0),children:`Show context`}):null]}),(0,B.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,B.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,B.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,B.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,B.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,B.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,B.jsxs)(`li`,{className:`break-words`,children:[(0,B.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,B.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,B.jsx)(`p`,{"data-slot":`ask-open-routed`,className:`text-[13px] text-muted-foreground`,children:`Open question: answered in words, with no options.`})]},e.id??t))}),(0,B.jsxs)(`div`,{"data-slot":`ask-footer`,className:`mt-2.5 flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,B.jsx)(P,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),!s&&r?(0,B.jsx)(He,{onShowOrigin:r,className:`ms-auto`}):null]}),s&&e.context?(0,B.jsx)(Ue,{open:i,onOpenChange:a,runId:t,context:e.context,onShowOrigin:r,returnFocusRef:o}):null]})}function wn(e,t,n,r,i){let a=t.blockedBy!==void 0,o=e.questions,s=o.length>1,c=o.length,[l,u]=(0,z.useState)(`options`),d=n??l,f=e=>{u(e),r?.(e)},[p,m]=(0,z.useState)(0),[h,g]=(0,z.useState)({}),[_,v]=(0,z.useState)({}),[y,b]=(0,z.useState)(``),[x,S]=(0,z.useState)(!1),[C,w]=(0,z.useState)(``),[T,E]=(0,z.useState)(!1),D=s&&p===c,ee=o.length===1&&o[0]?.options!==void 0&&o[0]?.multiSelect!==!0&&!x&&y.trim()===``;he(Object.values(h).some(e=>e.length>0)||Object.values(_).some(e=>e.trim()!==``)||y.trim()!==``||C.trim()!==``);let O=(e,t)=>g(n=>({...n,[e]:t})),te=e=>v(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),ne=e=>{O(e,[]),v(t=>({...t,[e]:t[e]??``}))},re=o.some((e,t)=>!e.options||_[t]!==void 0),k=o.filter((e,t)=>H(t,h,_)).length,A=k===o.length,j=async e=>{let n=await t.send(e);return n===void 0&&i?.(),n};return{delivery:t,blocked:a,questions:o,stepped:s,commentStepIndex:c,mode:d,setMode:f,stepIndex:p,setStepIndex:m,selections:h,otherAnswers:_,setOtherAnswers:v,additionalComment:y,setAdditionalComment:b,singleCommentOpen:x,setSingleCommentOpen:S,freeTextDraft:C,setFreeTextDraft:w,contextOpen:T,setContextOpen:E,onCommentStep:D,oneTap:ee,setQuestion:O,clearOtherAnswer:te,selectOther:ne,hasOtherAnswer:re,answeredCount:k,allAnswered:A,deliver:j,sendAll:()=>void j(xn(o,h,_,y)),sendFreeText:()=>{let e=C.trim();e&&j(e).then(e=>{e===void 0&&w(``)})}}}function Tn({state:e,renderFreeTextReply:t}){let n=(0,z.useId)(),r=e.delivery.isPending||e.blocked;if(e.mode===`reply`)return(0,B.jsx)(Re,{value:e.freeTextDraft,onValueChange:e.setFreeTextDraft,disabled:r,renderFreeTextReply:t});if(e.onCommentStep)return(0,B.jsx)(Le,{questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,comment:e.additionalComment,disabled:r,onCommentChange:e.setAdditionalComment,onJumpToQuestion:e.setStepIndex});let i=e.stepped?Math.min(e.stepIndex,e.questions.length-1):0,a=e.questions[i];return a?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Nn,{question:a,disabled:r,selected:e.selections[i]??[],isOther:e.otherAnswers[i]!==void 0,otherAnswer:e.otherAnswers[i]??``,onSelect:t=>{e.blocked||(e.clearOtherAnswer(i),e.oneTap?e.deliver(bn(a,t)):e.setQuestion(i,t))},onOtherToggle:()=>{e.blocked||(e.otherAnswers[i]===void 0?e.selectOther(i):e.clearOtherAnswer(i))},onOtherChange:t=>e.setOtherAnswers(e=>({...e,[i]:t}))},a.id??i),!e.stepped&&e.singleCommentOpen?(0,B.jsxs)(`div`,{className:`pt-1`,children:[(0,B.jsx)(`label`,{htmlFor:n,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,B.jsx)(I,{id:n,"data-slot":`ask-additional-comment`,rows:2,value:e.additionalComment,disabled:r,placeholder:`Optional extra notes for the agent…`,onChange:t=>e.setAdditionalComment(t.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):null}function En({onFinish:e,finishing:t,onStop:n,stopping:r,onActionError:i}){if(!e&&!n)return null;let a=e=>{i(void 0),Promise.resolve(e()).catch(e=>{i(e instanceof Error?e.message:String(e),l(e))})};return(0,B.jsxs)(B.Fragment,{children:[e?(0,B.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-finish`,disabled:t||r,title:`Close the session and mark this task done`,className:`px-3`,onClick:()=>a(e),children:t?`Finishing…`:`Finish`}):null,n?(0,B.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,disabled:r||t,className:`px-3`,onClick:()=>a(n),children:r?`Stopping…`:`Stop`}):null]})}function Dn(e){return e.delivery===void 0?(0,B.jsx)(On,{...e}):(0,B.jsx)(kn,{...e,delivery:e.delivery})}function On(e){let t=me(e.run,e.projectId);return(0,B.jsx)(kn,{...e,delivery:t})}function kn({ask:e,run:t,surface:n,onShowOrigin:r,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:c,onFinish:l,finishing:u,controlledMode:d,onModeChange:f,hideReplyBody:m,delivery:h,fold:g}){let _=wn(e,h,d,f,i),[v,y]=(0,z.useState)(void 0),b=v?.message;s(()=>{y(e=>e?.clearOnHostRecovery?void 0:e)});let x=(0,z.useRef)(null),S=n===`decision-zone`||a!==void 0,C=n===`decision-zone`&&!!e.context,w=_.mode===`reply`&&m,T=_.onCommentStep?`Comment (optional)`:`${_.stepIndex+1} of ${_.questions.length}`,E=g?.folded===!0,D=(0,B.jsx)(En,{onFinish:l,finishing:u,onStop:o,stopping:c,onActionError:(e,t=!1)=>{y(e===void 0?void 0:{message:e,clearOnHostRecovery:t})}});return(0,B.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-ask-mode":_.mode,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":_.delivery.mode,"data-folded":g?String(E):void 0,className:p(`rounded-xl border border-accent-strong/30 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card`,w&&!E&&`rounded-b-none border-b-0`),children:[E?(0,B.jsx)(jn,{state:_,stepLabel:T,onOpen:()=>g.onFoldChange(!1)}):(0,B.jsx)(An,{state:_,stepLabel:T,showModeSwitch:S,hasSheetContext:C,contextButtonRef:x,onShowOrigin:r,onFold:g?()=>g.onFoldChange(!0):void 0,replyDockedOutside:w,renderFreeTextReply:a,stopControl:D,actionError:b}),C&&e.context?(0,B.jsx)(Ue,{open:_.contextOpen,onOpenChange:_.setContextOpen,runId:t.id,context:e.context,onShowOrigin:r,returnFocusRef:x}):null]})}function An({state:e,stepLabel:t,showModeSwitch:n,hasSheetContext:r,contextButtonRef:i,onShowOrigin:a,onFold:o,replyDockedOutside:s,renderFreeTextReply:c,stopControl:l,actionError:u}){let d=e.additionalComment.trim()!==``;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Ne,{stepped:e.stepped,mode:e.mode,onModeChange:e.setMode,showModeSwitch:n,stepLabel:t,hasSheetContext:r,showContextButtonRef:i,onOpenContext:()=>e.setContextOpen(!0),onShowOrigin:r?void 0:a,onFold:o}),e.stepped&&e.mode===`options`?(0,B.jsx)(Ie,{questions:e.questions,stepIndex:e.stepIndex,selections:e.selections,otherAnswers:e.otherAnswers,hasComment:d,onSelectStep:e.setStepIndex}):null,s?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-2.5 px-3 py-2.5`,children:(0,B.jsx)(Tn,{state:e,renderFreeTextReply:c})}),(0,B.jsxs)(`div`,{"data-slot":`ask-footer`,className:`flex shrink-0 flex-col gap-2 border-t border-border/70 px-3 py-2`,children:[(0,B.jsx)(Mn,{state:e,hasComment:d,resuming:e.delivery.mode===`resume`,hasCustomReply:c!==void 0,stopControl:l,compact:o!==void 0}),(0,B.jsx)(Ve,{blockedBy:e.delivery.blockedBy,reason:e.delivery.reason,error:e.delivery.error??u})]})]})]})}function jn({state:e,stepLabel:t,onOpen:n}){let r=e.questions[Math.min(e.stepIndex,e.questions.length-1)];return e.onCommentStep?(0,B.jsx)(Fe,{tag:`Comment`,text:`Add a comment, then send.`,position:void 0,onOpen:n}):(0,B.jsx)(Fe,{tag:r?.header??``,text:r?.question??``,position:e.stepped?t:void 0,onOpen:n})}function Mn({state:e,hasComment:t,resuming:n,hasCustomReply:r,stopControl:i,compact:a}){return e.mode===`reply`?r?null:(0,B.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[i,(0,B.jsx)(A,{type:`button`,size:`sm`,className:`px-3.5`,disabled:e.delivery.isPending||e.blocked||e.freeTextDraft.trim()===``,onClick:e.sendFreeText,children:`Send reply`})]}):e.stepped?(0,B.jsx)(ze,{stepIndex:e.stepIndex,questionCount:e.questions.length,answeredCount:e.answeredCount,allAnswered:e.allAnswered,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked,onBack:()=>e.setStepIndex(e=>Math.max(0,e-1)),onNext:()=>e.setStepIndex(t=>Math.min(e.commentStepIndex,t+1)),onOpenComment:()=>e.setStepIndex(e.commentStepIndex),onSend:e.sendAll,questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,stopControl:i,compact:a}):(0,B.jsx)(Be,{oneTap:e.oneTap,hasOtherAnswer:e.hasOtherAnswer,allowComment:e.questions[0]?.allowFreeText!==!1,commentOpen:e.singleCommentOpen,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked||!e.allAnswered,onToggleComment:()=>e.setSingleCommentOpen(e=>!e),onSend:e.sendAll,stopControl:i,compact:a})}function Nn({question:e,disabled:t,selected:n,isOther:r,otherAnswer:i,onSelect:a,onOtherToggle:o,onOtherChange:s}){let c=(0,z.useId)(),l=(0,z.useRef)(null),u=(0,z.useRef)(r),d=e.options,f=d!==void 0,m=f&&e.multiSelect===!0;(0,z.useEffect)(()=>{let e=r&&!u.current;u.current=r,e&&f&&l.current?.focus()},[r,f]);let h=e=>{if(!m){a([e]);return}a(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,B.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,children:[(0,B.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,B.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),(0,B.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-sm font-semibold text-foreground`,children:e.question}),m?(0,B.jsx)(`span`,{className:`ms-auto text-xs text-soft-foreground`,children:`select all that apply`}):null]}),d?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{"data-slot":`ask-options`,className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2 sm:gap-2`,children:[d.map(e=>{let r=n.includes(e.label);return(0,B.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>h(e.label),className:p(`flex min-h-11 w-full flex-col items-start justify-start content-start gap-0.5 rounded-md border px-2.5 py-1.5 text-left transition-colors focus-visible:outline-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong bg-accent-strong/15 ring-1 ring-accent-strong/30 pointer-hover:border-accent-strong pointer-hover:bg-accent-strong/15`:`border-border bg-card pointer-hover:border-accent-strong/50 pointer-hover:bg-accent-strong/[0.08]`),children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[13px] font-semibold text-foreground`,children:[m?(0,B.jsx)(`span`,{"aria-hidden":`true`,className:p(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,B.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,B.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)}),e.allowFreeText===!1?null:(0,B.jsx)(A,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?c:void 0,disabled:t,onClick:o,size:`block`,className:p(`px-2.5`,d.length%2==0&&`sm:col-span-2`,r&&`border-accent-strong bg-accent-strong/15 ring-1 ring-accent-strong/30 pointer-hover:border-accent-strong pointer-hover:bg-accent-strong/15`),children:`Other`})]}),e.allowFreeText!==!1&&r?(0,B.jsxs)(`div`,{className:`mt-2`,children:[(0,B.jsx)(`label`,{htmlFor:c,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,B.jsx)(I,{ref:l,id:c,rows:2,value:i,disabled:t,placeholder:`Type your custom answer…`,onChange:e=>s(e.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`label`,{htmlFor:c,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,B.jsx)(I,{id:c,rows:2,value:i,disabled:t,placeholder:`Type your answer…`,onChange:e=>s(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}export{q as A,kt as C,xt as D,Tt as E,$e as F,W as I,tt as L,ft as M,at as N,Ct as O,et as P,je as R,Ot as S,Dt as T,X as _,hn as a,St as b,$t as c,Kt as d,en as f,Bt as g,zt as h,gn as i,mt as j,vt as k,pn as l,Vt as m,$ as n,vn as o,Ut as p,Zt as r,Qt as s,Sn as t,_n as u,It as v,Et as w,yt as x,bt as y,R as z};
9
+ `),a=r.trim();return a?`${i}\n\nAdditional comments:\n${a}`:i}function Sn({ask:e,run:t,projectId:n,onShowOrigin:r,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s=!1,onFinish:c,finishing:l=!1,mode:u,onModeChange:d,hideReplyBody:f=!1,delivery:p,surface:m=`transcript`,fold:h}){let g=m===`transcript`&&e.context?(0,B.jsx)($,{text:e.context}):null;if(e.resolved)return(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e.context?(0,B.jsx)($,{text:e.context}):null,(0,B.jsxs)(Q,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,B.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?yn[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,B.jsx)(je,{ask:e})]})]});let _=e.placement===`pinned`&&r?r:void 0;return e.routedToParent?(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[g,(0,B.jsx)(Cn,{ask:e,runId:t.id,surface:m,onShowOrigin:_})]}):(0,B.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[g,(0,B.jsx)(Dn,{ask:e,run:t,projectId:n,surface:m,onShowOrigin:_,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s,onFinish:c,finishing:l,controlledMode:u,onModeChange:d,hideReplyBody:f,delivery:p,fold:h})]})}function $({text:e}){return(0,B.jsx)(Q,{role:`agent`,children:(0,B.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,B.jsx)(L,{breaks:!0,children:e})})})}function Cn({ask:e,runId:t,surface:n,onShowOrigin:r}){let[i,a]=(0,z.useState)(!1),o=(0,z.useRef)(null),s=n===`decision-zone`&&!!e.context;return(0,B.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-xl border border-card-edge bg-card shadow-card px-3 py-2.5`,children:[(0,B.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`}),s?(0,B.jsx)(A,{ref:o,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,className:`ms-auto px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,onClick:()=>a(!0),children:`Show context`}):null]}),(0,B.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,B.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,B.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,B.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,B.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,B.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,B.jsxs)(`li`,{className:`break-words`,children:[(0,B.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,B.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,B.jsx)(`p`,{"data-slot":`ask-open-routed`,className:`text-[13px] text-muted-foreground`,children:`Open question: answered in words, with no options.`})]},e.id??t))}),(0,B.jsxs)(`div`,{"data-slot":`ask-footer`,className:`mt-2.5 flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,B.jsx)(P,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),!s&&r?(0,B.jsx)(He,{onShowOrigin:r,className:`ms-auto`}):null]}),s&&e.context?(0,B.jsx)(Ue,{open:i,onOpenChange:a,runId:t,context:e.context,onShowOrigin:r,returnFocusRef:o}):null]})}function wn(e,t,n,r,i){let a=t.blockedBy!==void 0,o=e.questions,s=o.length>1,c=o.length,[l,u]=(0,z.useState)(`options`),d=n??l,f=e=>{u(e),r?.(e)},[p,m]=(0,z.useState)(0),[h,g]=(0,z.useState)({}),[_,v]=(0,z.useState)({}),[y,b]=(0,z.useState)(``),[x,S]=(0,z.useState)(!1),[C,w]=(0,z.useState)(``),[T,E]=(0,z.useState)(!1),D=s&&p===c,ee=o.length===1&&o[0]?.options!==void 0&&o[0]?.multiSelect!==!0&&!x&&y.trim()===``;he(Object.values(h).some(e=>e.length>0)||Object.values(_).some(e=>e.trim()!==``)||y.trim()!==``||C.trim()!==``);let O=(e,t)=>g(n=>({...n,[e]:t})),te=e=>v(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),ne=e=>{O(e,[]),v(t=>({...t,[e]:t[e]??``}))},re=o.some((e,t)=>!e.options||_[t]!==void 0),k=o.filter((e,t)=>H(t,h,_)).length,A=k===o.length,j=async e=>{let n=await t.send(e);return n===void 0&&i?.(),n};return{delivery:t,blocked:a,questions:o,stepped:s,commentStepIndex:c,mode:d,setMode:f,stepIndex:p,setStepIndex:m,selections:h,otherAnswers:_,setOtherAnswers:v,additionalComment:y,setAdditionalComment:b,singleCommentOpen:x,setSingleCommentOpen:S,freeTextDraft:C,setFreeTextDraft:w,contextOpen:T,setContextOpen:E,onCommentStep:D,oneTap:ee,setQuestion:O,clearOtherAnswer:te,selectOther:ne,hasOtherAnswer:re,answeredCount:k,allAnswered:A,deliver:j,sendAll:()=>void j(xn(o,h,_,y)),sendFreeText:()=>{let e=C.trim();e&&j(e).then(e=>{e===void 0&&w(``)})}}}function Tn({state:e,renderFreeTextReply:t}){let n=(0,z.useId)(),r=e.delivery.isPending||e.blocked;if(e.mode===`reply`)return(0,B.jsx)(Re,{value:e.freeTextDraft,onValueChange:e.setFreeTextDraft,disabled:r,renderFreeTextReply:t});if(e.onCommentStep)return(0,B.jsx)(Le,{questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,comment:e.additionalComment,disabled:r,onCommentChange:e.setAdditionalComment,onJumpToQuestion:e.setStepIndex});let i=e.stepped?Math.min(e.stepIndex,e.questions.length-1):0,a=e.questions[i];return a?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Nn,{question:a,disabled:r,selected:e.selections[i]??[],isOther:e.otherAnswers[i]!==void 0,otherAnswer:e.otherAnswers[i]??``,onSelect:t=>{e.blocked||(e.clearOtherAnswer(i),e.oneTap?e.deliver(bn(a,t)):e.setQuestion(i,t))},onOtherToggle:()=>{e.blocked||(e.otherAnswers[i]===void 0?e.selectOther(i):e.clearOtherAnswer(i))},onOtherChange:t=>e.setOtherAnswers(e=>({...e,[i]:t}))},a.id??i),!e.stepped&&e.singleCommentOpen?(0,B.jsxs)(`div`,{className:`pt-1`,children:[(0,B.jsx)(`label`,{htmlFor:n,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,B.jsx)(I,{id:n,"data-slot":`ask-additional-comment`,rows:2,value:e.additionalComment,disabled:r,placeholder:`Optional extra notes for the agent…`,onChange:t=>e.setAdditionalComment(t.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):null}function En({onFinish:e,finishing:t,onStop:n,stopping:r,onActionError:i}){if(!e&&!n)return null;let a=e=>{i(void 0),Promise.resolve(e()).catch(e=>{i(e instanceof Error?e.message:String(e),l(e))})};return(0,B.jsxs)(B.Fragment,{children:[e?(0,B.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-finish`,disabled:t||r,title:`Close the session and mark this task done`,className:`px-3`,onClick:()=>a(e),children:t?`Finishing…`:`Finish`}):null,n?(0,B.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,disabled:r||t,className:`px-3`,onClick:()=>a(n),children:r?`Stopping…`:`Stop`}):null]})}function Dn(e){return e.delivery===void 0?(0,B.jsx)(On,{...e}):(0,B.jsx)(kn,{...e,delivery:e.delivery})}function On(e){let t=me(e.run,e.projectId);return(0,B.jsx)(kn,{...e,delivery:t})}function kn({ask:e,run:t,surface:n,onShowOrigin:r,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s,onFinish:l,finishing:u,controlledMode:d,onModeChange:f,hideReplyBody:m,delivery:h,fold:g}){let _=wn(e,h,d,f,i),[v,y]=(0,z.useState)(void 0),b=v?.message;c(()=>{y(e=>e?.clearOnHostRecovery?void 0:e)});let x=(0,z.useRef)(null),S=n===`decision-zone`||a!==void 0,C=n===`decision-zone`&&!!e.context,w=_.mode===`reply`&&m,T=_.onCommentStep?`Comment (optional)`:`${_.stepIndex+1} of ${_.questions.length}`,E=g?.folded===!0,D=(0,B.jsx)(En,{onFinish:l,finishing:u,onStop:o,stopping:s,onActionError:(e,t=!1)=>{y(e===void 0?void 0:{message:e,clearOnHostRecovery:t})}});return(0,B.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-ask-mode":_.mode,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":_.delivery.mode,"data-folded":g?String(E):void 0,className:p(`rounded-xl border border-accent-strong/30 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card`,w&&!E&&`rounded-b-none border-b-0`),children:[E?(0,B.jsx)(jn,{state:_,stepLabel:T,onOpen:()=>g.onFoldChange(!1)}):(0,B.jsx)(An,{state:_,stepLabel:T,showModeSwitch:S,hasSheetContext:C,contextButtonRef:x,onShowOrigin:r,onFold:g?()=>g.onFoldChange(!0):void 0,replyDockedOutside:w,renderFreeTextReply:a,stopControl:D,actionError:b}),C&&e.context?(0,B.jsx)(Ue,{open:_.contextOpen,onOpenChange:_.setContextOpen,runId:t.id,context:e.context,onShowOrigin:r,returnFocusRef:x}):null]})}function An({state:e,stepLabel:t,showModeSwitch:n,hasSheetContext:r,contextButtonRef:i,onShowOrigin:a,onFold:o,replyDockedOutside:s,renderFreeTextReply:c,stopControl:l,actionError:u}){let d=e.additionalComment.trim()!==``;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(Ne,{stepped:e.stepped,mode:e.mode,onModeChange:e.setMode,showModeSwitch:n,stepLabel:t,hasSheetContext:r,showContextButtonRef:i,onOpenContext:()=>e.setContextOpen(!0),onShowOrigin:r?void 0:a,onFold:o}),e.stepped&&e.mode===`options`?(0,B.jsx)(Ie,{questions:e.questions,stepIndex:e.stepIndex,selections:e.selections,otherAnswers:e.otherAnswers,hasComment:d,onSelectStep:e.setStepIndex}):null,s?null:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-2.5 px-3 py-2.5`,children:(0,B.jsx)(Tn,{state:e,renderFreeTextReply:c})}),(0,B.jsxs)(`div`,{"data-slot":`ask-footer`,className:`flex shrink-0 flex-col gap-2 border-t border-border/70 px-3 py-2`,children:[(0,B.jsx)(Mn,{state:e,hasComment:d,resuming:e.delivery.mode===`resume`,hasCustomReply:c!==void 0,stopControl:l,compact:o!==void 0}),(0,B.jsx)(Ve,{blockedBy:e.delivery.blockedBy,reason:e.delivery.reason,error:e.delivery.error??u})]})]})]})}function jn({state:e,stepLabel:t,onOpen:n}){let r=e.questions[Math.min(e.stepIndex,e.questions.length-1)];return e.onCommentStep?(0,B.jsx)(Fe,{tag:`Comment`,text:`Add a comment, then send.`,position:void 0,onOpen:n}):(0,B.jsx)(Fe,{tag:r?.header??``,text:r?.question??``,position:e.stepped?t:void 0,onOpen:n})}function Mn({state:e,hasComment:t,resuming:n,hasCustomReply:r,stopControl:i,compact:a}){return e.mode===`reply`?r?null:(0,B.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[i,(0,B.jsx)(A,{type:`button`,size:`sm`,className:`px-3.5`,disabled:e.delivery.isPending||e.blocked||e.freeTextDraft.trim()===``,onClick:e.sendFreeText,children:`Send reply`})]}):e.stepped?(0,B.jsx)(ze,{stepIndex:e.stepIndex,questionCount:e.questions.length,answeredCount:e.answeredCount,allAnswered:e.allAnswered,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked,onBack:()=>e.setStepIndex(e=>Math.max(0,e-1)),onNext:()=>e.setStepIndex(t=>Math.min(e.commentStepIndex,t+1)),onOpenComment:()=>e.setStepIndex(e.commentStepIndex),onSend:e.sendAll,questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,stopControl:i,compact:a}):(0,B.jsx)(Be,{oneTap:e.oneTap,hasOtherAnswer:e.hasOtherAnswer,allowComment:e.questions[0]?.allowFreeText!==!1,commentOpen:e.singleCommentOpen,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked||!e.allAnswered,onToggleComment:()=>e.setSingleCommentOpen(e=>!e),onSend:e.sendAll,stopControl:i,compact:a})}function Nn({question:e,disabled:t,selected:n,isOther:r,otherAnswer:i,onSelect:a,onOtherToggle:o,onOtherChange:s}){let c=(0,z.useId)(),l=(0,z.useRef)(null),u=(0,z.useRef)(r),d=e.options,f=d!==void 0,m=f&&e.multiSelect===!0;(0,z.useEffect)(()=>{let e=r&&!u.current;u.current=r,e&&f&&l.current?.focus()},[r,f]);let h=e=>{if(!m){a([e]);return}a(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,B.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,children:[(0,B.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,B.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),(0,B.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-sm font-semibold text-foreground`,children:e.question}),m?(0,B.jsx)(`span`,{className:`ms-auto text-xs text-soft-foreground`,children:`select all that apply`}):null]}),d?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{"data-slot":`ask-options`,className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2 sm:gap-2`,children:[d.map(e=>{let r=n.includes(e.label);return(0,B.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>h(e.label),className:p(`flex min-h-11 w-full flex-col items-start justify-start content-start gap-0.5 rounded-md border px-2.5 py-1.5 text-left transition-colors focus-visible:outline-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong bg-accent-strong/15 ring-1 ring-accent-strong/30 pointer-hover:border-accent-strong pointer-hover:bg-accent-strong/15`:`border-border bg-card pointer-hover:border-accent-strong/50 pointer-hover:bg-accent-strong/[0.08]`),children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[13px] font-semibold text-foreground`,children:[m?(0,B.jsx)(`span`,{"aria-hidden":`true`,className:p(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,B.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,B.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)}),e.allowFreeText===!1?null:(0,B.jsx)(A,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?c:void 0,disabled:t,onClick:o,size:`block`,className:p(`px-2.5`,d.length%2==0&&`sm:col-span-2`,r&&`border-accent-strong bg-accent-strong/15 ring-1 ring-accent-strong/30 pointer-hover:border-accent-strong pointer-hover:bg-accent-strong/15`),children:`Other`})]}),e.allowFreeText!==!1&&r?(0,B.jsxs)(`div`,{className:`mt-2`,children:[(0,B.jsx)(`label`,{htmlFor:c,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,B.jsx)(I,{ref:l,id:c,rows:2,value:i,disabled:t,placeholder:`Type your custom answer…`,onChange:e=>s(e.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`label`,{htmlFor:c,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,B.jsx)(I,{id:c,rows:2,value:i,disabled:t,placeholder:`Type your answer…`,onChange:e=>s(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}export{q as A,kt as C,xt as D,Tt as E,$e as F,W as I,tt as L,ft as M,at as N,Ct as O,et as P,je as R,Ot as S,Dt as T,X as _,hn as a,St as b,$t as c,Kt as d,en as f,Bt as g,zt as h,gn as i,mt as j,vt as k,pn as l,Vt as m,$ as n,vn as o,Ut as p,Zt as r,Qt as s,Sn as t,_n as u,It as v,Et as w,yt as x,bt as y,R as z};
@@ -0,0 +1 @@
1
+ import{Bi as e,Fi as t}from"./project-scope-context-_6sNMsAf.js";function n(n){return t[e(n).bucket]<=t.waiting}export{n as t};