@open-mercato/cezar 0.21.0-pr2007.6497 → 0.21.0-pr2007.6500

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 (67) hide show
  1. package/package.json +3 -3
  2. package/web/dist/assets/{active-forge-DG0OKeXH.js → active-forge-CdVaRZw0.js} +1 -1
  3. package/web/dist/assets/{add-account-host-LKu3NE9D.js → add-account-host-CVZ1mofB.js} +1 -1
  4. package/web/dist/assets/{agent-setup-sheet-CBBNmyC9.js → agent-setup-sheet-DKO0a_nD.js} +2 -2
  5. package/web/dist/assets/{agent-task-pickers-DX05V8cV.js → agent-task-pickers-iRhZC1TH.js} +1 -1
  6. package/web/dist/assets/{ask-card-Bh2Gb99K.js → ask-card-Dzqeh0EB.js} +1 -1
  7. package/web/dist/assets/{assets-view-4oz2OenT.js → assets-view-BNRHjmP8.js} +1 -1
  8. package/web/dist/assets/{automation-format-rZap1O9e.js → automation-format-Cxf7Be95.js} +1 -1
  9. package/web/dist/assets/{automations-route-B46PaZQR.js → automations-route-BqxUPZin.js} +1 -1
  10. package/web/dist/assets/{cache-status-CNVLJTQg.js → cache-status-CyZK8orQ.js} +1 -1
  11. package/web/dist/assets/{commit-list-DSIate0M.js → commit-list-DPxJDUdu.js} +1 -1
  12. package/web/dist/assets/{compare-variants-CGKebm6S.js → compare-variants-BatFv1RF.js} +1 -1
  13. package/web/dist/assets/{composer-BdAI6c2J.js → composer-CPCdqFxK.js} +1 -1
  14. package/web/dist/assets/{composer-attachments-DqNLS65g.js → composer-attachments-BOl-Xzn5.js} +1 -1
  15. package/web/dist/assets/{dashboard-BCUzPZiq.js → dashboard-CJDgnGxo.js} +1 -1
  16. package/web/dist/assets/{decision-sources-Df3Tzgpf.js → decision-sources-CkrzaHlM.js} +1 -1
  17. package/web/dist/assets/{design-note-popup-DkfxOtct.js → design-note-popup-BhfY03SM.js} +1 -1
  18. package/web/dist/assets/{file-preview-CLIMmKHV.js → file-preview-BPrLPXoy.js} +1 -1
  19. package/web/dist/assets/{git-tab-loading-D7f4YwJO.js → git-tab-loading-BMqglMmI.js} +1 -1
  20. package/web/dist/assets/{github-CbMzT734.js → github-BXR0j7D8.js} +1 -1
  21. package/web/dist/assets/{global-tasks-CCALzyqd.js → global-tasks-CbA7HwQ7.js} +1 -1
  22. package/web/dist/assets/{host-usage-BikbUhw4.js → host-usage-VTid-8C1.js} +1 -1
  23. package/web/dist/assets/{impact-control-CReS3m2Y.js → impact-control-Bu_0zjzz.js} +1 -1
  24. package/web/dist/assets/{impact-model-BMHjhFuw.js → impact-model-D9LSXBsx.js} +1 -1
  25. package/web/dist/assets/{index-Dy4sBegL.js → index-CL6WgTsz.js} +4 -4
  26. package/web/dist/assets/{keyboard-inset-C4kdFNmX.js → keyboard-inset-E5M_hCk-.js} +1 -1
  27. package/web/dist/assets/{manager-approval-BiQVoTUG.js → manager-approval-vWgKS6cM.js} +1 -1
  28. package/web/dist/assets/{manager-approvals-u1-Poh-h.js → manager-approvals-CavHNA2L.js} +1 -1
  29. package/web/dist/assets/{manager-chat-D-jY5M8l.js → manager-chat-DgcV7H-B.js} +1 -1
  30. package/web/dist/assets/{manager-index-WcWyASfp.js → manager-index-B9OcUfy-.js} +1 -1
  31. package/web/dist/assets/{manager-new-B5CTZPz0.js → manager-new-UyBFCqZ3.js} +1 -1
  32. package/web/dist/assets/{manager-now--XQxm3Ec.js → manager-now-D8oDCNY2.js} +1 -1
  33. package/web/dist/assets/{manager-settings-B0I5n9BM.js → manager-settings-07zRz7Xx.js} +1 -1
  34. package/web/dist/assets/{managers-CES65Toz.js → managers-DP0esAfT.js} +1 -1
  35. package/web/dist/assets/{mascot-picker-Q6JfrQ-n.js → mascot-picker-BBexxvXp.js} +1 -1
  36. package/web/dist/assets/{phone-app-Csgi1QpC.js → phone-app-C2rT__Vf.js} +1 -1
  37. package/web/dist/assets/{plan-usage-CDUAXOMD.js → plan-usage-D1hnSOHC.js} +1 -1
  38. package/web/dist/assets/{project-router-CUgGEpgp.js → project-router-Bek4dR86.js} +1 -1
  39. package/web/dist/assets/{project-terminal-CJ3T6H0v.js → project-terminal-Brwfyn99.js} +2 -2
  40. package/web/dist/assets/{queries-hE7G6Kgl.js → queries-BeoT2lBk.js} +1 -1
  41. package/web/dist/assets/{questions-DunziRyk.js → questions-BVPh0WiE.js} +1 -1
  42. package/web/dist/assets/{questions-route-CtgEuVDZ.js → questions-route-GeRjlAy3.js} +1 -1
  43. package/web/dist/assets/{reasoning-effort-pill-B7JL5GDb.js → reasoning-effort-pill-Cc7H5UbY.js} +1 -1
  44. package/web/dist/assets/{reference-chip-CfXk1DW4.js → reference-chip-MmzMis9y.js} +1 -1
  45. package/web/dist/assets/{reference-conflict-action-BSPbRKbm.js → reference-conflict-action-TsKRSHEB.js} +1 -1
  46. package/web/dist/assets/{repo-git-BDRWWZpu.js → repo-git-NH30Gfq8.js} +1 -1
  47. package/web/dist/assets/{review-comments-block-vHl63wpg.js → review-comments-block--bXRMPRR.js} +1 -1
  48. package/web/dist/assets/{run-actions-D2QcJwa6.js → run-actions-CzNs18bI.js} +1 -1
  49. package/web/dist/assets/{run-confirm-dialog-B-lo1512.js → run-confirm-dialog-nm2zxz5H.js} +1 -1
  50. package/web/dist/assets/{run-diff-CVIc_8sB.js → run-diff-BcliH81b.js} +1 -1
  51. package/web/dist/assets/{skills-C6MwczY5.js → skills-DrfqAWB5.js} +1 -1
  52. package/web/dist/assets/{task-commits-DoazmBo5.js → task-commits-CX3o5ltO.js} +1 -1
  53. package/web/dist/assets/{task-graph-CfdhFDyL.js → task-graph-C_QRf5p_.js} +1 -1
  54. package/web/dist/assets/{task-notes-zrvbT78g.js → task-notes-D9BO4TZc.js} +1 -1
  55. package/web/dist/assets/{task-workspace-CSPBxduc.js → task-workspace-BuOG15nU.js} +3 -3
  56. package/web/dist/assets/{telemetry-DZWA8G8g.js → telemetry-BABVGObo.js} +1 -1
  57. package/web/dist/assets/{terminal-drawer-Ck93pIHP.js → terminal-drawer-BI8NHeym.js} +1 -1
  58. package/web/dist/assets/{terminal-pane-qj8Pq29k.js → terminal-pane-CcTMAhgu.js} +1 -1
  59. package/web/dist/assets/{terminal-scope-DFEubp18.js → terminal-scope-L8HZ5WaY.js} +1 -1
  60. package/web/dist/assets/{thread-items-O6QpMWl4.js → thread-items-Cm02k---.js} +1 -1
  61. package/web/dist/assets/{tracker-DyMEqEUb.js → tracker-DHDLVnP_.js} +1 -1
  62. package/web/dist/assets/{tree-pane-resize-BIc8V5hM.js → tree-pane-resize-mvhVN_v4.js} +1 -1
  63. package/web/dist/assets/{use-my-messages-nav-CjuQZjiQ.js → use-my-messages-nav-BllYc-ON.js} +1 -1
  64. package/web/dist/assets/{workflow-graph-B1gDxKeX.js → workflow-graph-BGLJR4CT.js} +1 -1
  65. package/web/dist/assets/{worktree-lifecycle-CoC8yBSW.js → worktree-lifecycle-Bt1ZWcV_.js} +1 -1
  66. package/web/dist/assets/{worktree-lifecycle-operation-DHBwiiIy.js → worktree-lifecycle-operation-D6XS-X8U.js} +1 -1
  67. package/web/dist/index.html +28 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/cezar",
3
- "version": "0.21.0-pr2007.6497",
3
+ "version": "0.21.0-pr2007.6500",
4
4
  "description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -56,8 +56,8 @@
56
56
  "zod": "^4.6.7"
57
57
  },
58
58
  "devDependencies": {
59
- "@open-mercato/cezar-api-client": "0.21.0-pr2007.6497",
60
- "@open-mercato/cezar-contract": "0.21.0-pr2007.6497",
59
+ "@open-mercato/cezar-api-client": "0.21.0-pr2007.6500",
60
+ "@open-mercato/cezar-contract": "0.21.0-pr2007.6500",
61
61
  "@types/node": "^20.14.0",
62
62
  "@types/proper-lockfile": "4.1.4",
63
63
  "@types/ws": "^8.18.1",
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{R as n,rt as r}from"./queries-hE7G6Kgl.js";import{c as i}from"./project-router-CUgGEpgp.js";import{t as a}from"./createLucideIcon-BHp8sXmF.js";var o=a(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),s=e(t(),1),c={github:`gh`};function l(e){return c[e]}function u(e){return`the ${e} CLI is not installed or not logged in — run \`${e} auth login\``}function d(e,t,n){let r=t?.bootProject??e?.bootProject??null;if(n===null||n==="default"||n===r)return e?.forge;let i=t?.projects?.find(e=>e.id===n);if(!i||!e)return;if(!i.forge)return null;let a=l(i.forge),o=a?e.checks?.find(e=>e.name===a):void 0;return!a||!o?{kind:i.forge}:o.available?{kind:i.forge,available:!0}:{kind:i.forge,available:!1,reason:u(a)}}function f(){let e=n().data,t=r().data,a=i();return(0,s.useMemo)(()=>d(e,t,a),[e,t,a])}export{o as n,f as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{R as n,rt as r}from"./queries-BeoT2lBk.js";import{c as i}from"./project-router-Bek4dR86.js";import{t as a}from"./createLucideIcon-BHp8sXmF.js";var o=a(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),s=e(t(),1),c={github:`gh`};function l(e){return c[e]}function u(e){return`the ${e} CLI is not installed or not logged in — run \`${e} auth login\``}function d(e,t,n){let r=t?.bootProject??e?.bootProject??null;if(n===null||n==="default"||n===r)return e?.forge;let i=t?.projects?.find(e=>e.id===n);if(!i||!e)return;if(!i.forge)return null;let a=l(i.forge),o=a?e.checks?.find(e=>e.name===a):void 0;return!a||!o?{kind:i.forge}:o.available?{kind:i.forge,available:!0}:{kind:i.forge,available:!1,reason:u(a)}}function f(){let e=n().data,t=r().data,a=i();return(0,s.useMemo)(()=>d(e,t,a),[e,t,a])}export{o as n,f as t};
@@ -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{Jo as r,Kt as i,O as a,Qo as o,R as s,Yo as c,bn as l,c as u,eo as d,ht as f,i as p,kr as m,nn as h,p as g,pi as _,r as v,st as y,v as b,w as x,yn as S}from"./queries-hE7G6Kgl.js";import{t as C,ut as w}from"./utils-D6vflkwY.js";import{f as T}from"./project-router-CUgGEpgp.js";import{r as E}from"./toaster-CnjJGypN.js";import{C as ee,D,O,b as te,c as k,d as A,i as j,k as ne,r as re,t as ie,u as ae,v as oe,x as se}from"./plan-usage-CDUAXOMD.js";import{t as ce}from"./createLucideIcon-BHp8sXmF.js";import{A as le,B as M,D as ue,L as de,c as fe,j as N,k as pe,t as P,z as me}from"./button-CSEYvv3h.js";import{r as he}from"./dist-CRisPV4Q.js";import{c as ge,i as _e,l as ve,n as ye,o as be,s as xe,t as Se}from"./select-DhHKFkXF.js";import{a as Ce,i as we,p as Te,r as Ee,t as De}from"./dropdown-menu-HzutX8-V.js";import{t as F}from"./external-link-BE6y205O.js";import{t as Oe}from"./folder-o-AvL3y3.js";import{i as ke,l as Ae}from"./loading-state-A_q6C0kQ.js";import{t as I}from"./spinner-5lGeVKBb.js";import{t as L}from"./input-DYkGEVpN.js";import{a as je,i as Me,n as Ne,o as Pe,r as Fe,t as Ie}from"./dialog-D68_yOhb.js";import{t as Le}from"./clipboard-DvCUPLwM.js";import{r as Re}from"./phone-app-Csgi1QpC.js";import{n as ze}from"./use-media-query-BF42EuKk.js";var Be=ce(`corner-left-up`,[[`path`,{d:`M14 9 9 4 4 9`,key:`1af5af`}],[`path`,{d:`M20 20h-7a4 4 0 0 1-4-4V4`,key:`1blwi3`}]]),Ve=/^(?:\\\\\?\\)?[A-Za-z]:$/,He=/^(?:[\\/]{2}(?!\?[\\/])|\\\\\?\\UNC\\)[^\\/]+[\\/][^\\/]+$/i;function Ue(e){let t=e.replace(/[\\/]+$/,``);if(Ve.test(t)||He.test(t))return null;let n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));if(n<0)return null;if(n===0)return t.slice(0,1);let r=t.slice(0,n);return Ve.test(r)?t.slice(0,n+1):r}var R=n(),We=`x-apple.systempreferences:com.apple.preference.security?Privacy_FilesAndFolders`,z=`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-foreground hover:bg-muted`;function Ge({path:e,selected:t,onSelect:n,onEnter:r,decorate:i,emptyHint:o,showHidden:s=!1}){let c=a(e,s),l=c.data?.parent??null,u=e===null?null:Ue(e);return(0,R.jsxs)(R.Fragment,{children:[c.data||c.isError?(0,R.jsx)(`p`,{"data-slot":`fs-breadcrumb`,className:`truncate font-mono text-meta text-soft-foreground`,title:c.data?.path??void 0,children:c.data?.path??``}):(0,R.jsx)(ke,{label:`Loading folder…`,"data-slot":`fs-breadcrumb`,children:(0,R.jsx)(Ae,{className:`my-[3px] h-3 w-48 max-w-full`})}),!c.isError&&c.data?.parent===null?(0,R.jsxs)(`p`,{"data-slot":`fs-root-hint`,className:`text-label text-soft-foreground`,children:[`This is the browse root. To browse elsewhere, change`,` `,(0,R.jsx)(`a`,{href:`/settings/global/projects`,className:`text-foreground underline underline-offset-4 hover:text-muted-foreground`,children:`Default browse folder in Settings → Projects`}),`.`]}):null,c.isError?(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,R.jsx)(`p`,{"data-slot":`fs-error`,className:`min-w-0 break-words text-ui text-danger`,children:c.error instanceof Error?c.error.message:`could not list that folder`}),c.error instanceof m&&c.error.status===403?(0,R.jsx)(`p`,{"data-slot":`fs-privacy-hint`,className:`text-label text-soft-foreground`,children:`Allow it under Privacy & Security ▸ Files & Folders, then try again.`}):null,(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-label`,children:[u===null?null:(0,R.jsxs)(`button`,{type:`button`,"data-slot":`fs-error-back`,onClick:()=>r(u),className:z,children:[(0,R.jsx)(Be,{className:`size-3.5`,"aria-hidden":!0}),`Back`]}),c.error instanceof m&&c.error.status===403?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`a`,{"data-slot":`fs-privacy-settings`,href:We,target:`_blank`,rel:`noreferrer`,className:z,children:`Open Privacy Settings`}),(0,R.jsx)(`button`,{type:`button`,"data-slot":`fs-retry`,onClick:()=>void c.refetch(),className:z,children:`Try again`})]}):null]})]}):(0,R.jsxs)(`ul`,{"data-slot":`fs-listing`,className:`max-h-64 divide-y divide-border/60 overflow-y-auto overscroll-contain rounded-md border border-border`,children:[l===null?null:(0,R.jsx)(`li`,{className:`flex`,children:(0,R.jsxs)(`button`,{type:`button`,"data-slot":`fs-up`,onClick:()=>r(l),className:`flex flex-1 items-center gap-2 px-3 py-2 text-left text-ui hover:bg-muted`,children:[(0,R.jsx)(Be,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),`Up one level`]})}),(c.data?.dirs??[]).map(e=>(0,R.jsxs)(`li`,{className:`flex items-stretch`,children:[(0,R.jsxs)(`button`,{type:`button`,"data-slot":`fs-dir`,"aria-pressed":t?.path===e.path,onClick:()=>n(e),onDoubleClick:()=>r(e.path),className:C(`flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left text-ui hover:bg-muted`,t?.path===e.path&&`bg-muted`),children:[(0,R.jsx)(Oe,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name}),i?.(e)]}),(0,R.jsx)(`button`,{type:`button`,"data-slot":`fs-enter`,"aria-label":`Open ${e.name}`,onClick:()=>r(e.path),className:`flex shrink-0 items-center px-2.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,R.jsx)(me,{className:`size-3.5`,"aria-hidden":`true`})})]},e.path)),c.data&&c.data.dirs.length===0?(0,R.jsx)(`li`,{className:`px-3 py-2 text-ui text-muted-foreground`,children:o}):null]}),c.data?.truncated?(0,R.jsx)(`p`,{"data-slot":`fs-truncated`,className:`text-meta text-muted-foreground`,children:`Too many folders to list — only the first ones are shown.`}):null]})}function Ke(e,t,n=!1){let r=a(e,n);return t?.path??r.data?.path??null}var B=e(t(),1),V=`Switch`,[qe,Je]=le(V),[Ye,H]=qe(V);function Xe(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=ue({prop:n,defaultProp:i??!1,onChange:c,caller:V}),[m,h]=B.useState(null),[g,_]=B.useState(null),v={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:B.useRef(!1),required:l,defaultChecked:i,isFormControl:!m||!!o||!!m.closest(`form`),bubbleInput:g,setBubbleInput:_};return(0,R.jsx)(Ye,{scope:t,...v,children:it(d)?d(v):r})}var Ze=`SwitchTrigger`,Qe=B.forwardRef(({__scopeSwitch:e,onClick:t,...n},r)=>{let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=H(Ze,e),h=de(r,u),g=B.useRef(c);return B.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=()=>d(g.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,R.jsx)(N.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":at(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:h,onClick:pe(t,e=>{d(e=>!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});Qe.displayName=Ze;var $e=B.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,R.jsx)(Xe,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Qe,{...d,ref:t,__scopeSwitch:n}),e&&(0,R.jsx)(rt,{__scopeSwitch:n})]})})});$e.displayName=V;var et=`SwitchThumb`,tt=B.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=H(et,n);return(0,R.jsx)(N.span,{"data-state":at(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});tt.displayName=et;var nt=`SwitchBubbleInput`,rt=B.forwardRef(({__scopeSwitch:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:a,defaultChecked:o,required:s,disabled:c,name:l,value:u,form:d,bubbleInput:f,setBubbleInput:p}=H(nt,e),m=de(n,p),h=ge(a),g=fe(r);B.useEffect(()=>{let e=f;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!i.current;if(h!==a&&n){let t=new Event(`click`,{bubbles:r});n.call(e,a),e.dispatchEvent(t)}},[f,h,a,i]);let _=B.useRef(a);return(0,R.jsx)(N.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:o??_.current,required:s,disabled:c,name:l,value:u,form:d,...t,tabIndex:-1,ref:m,style:{...t.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});rt.displayName=nt;function it(e){return typeof e==`function`}function at(e){return e?`checked`:`unchecked`}function ot({open:e,onOpenChange:t,providers:n,initialProvider:r}){let[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(r??n[0]??`claude`),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)(``),[m,h]=(0,B.useState)(!1),g=x(),_=f.trim();return(0,R.jsx)(Ie,{open:e,onOpenChange:t,children:(0,R.jsxs)(Ne,{"data-slot":`add-account-dialog`,className:`sm:max-w-lg`,children:[(0,R.jsxs)(je,{children:[(0,R.jsx)(Pe,{children:`Add agent account`}),(0,R.jsx)(Fe,{children:`The config folder this account uses. It does not have to exist yet — Connect signs in and the CLI creates it.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-ui`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Agent`}),(0,R.jsxs)(Se,{value:c,onValueChange:e=>l(e),children:[(0,R.jsx)(be,{size:`sm`,"aria-label":`Agent`,"data-slot":`add-account-provider`,"data-value":c,children:(0,R.jsx)(xe,{})}),(0,R.jsx)(ye,{position:`popper`,children:n.map(e=>(0,R.jsx)(_e,{value:e,children:e},e))})]})]}),(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 text-ui`,children:[(0,R.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Name`}),(0,R.jsx)(L,{type:`text`,"aria-label":`Account name`,"data-slot":`add-account-label`,value:u,placeholder:`Work`,onChange:e=>d(e.target.value),className:`h-8 flex-1 text-ui`})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-ui`,children:[(0,R.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Folder`}),(0,R.jsx)(L,{type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Config folder`,"data-slot":`add-account-dir`,value:f,placeholder:c===`codex`?`~/.codex-second`:c===`omp`?`~/.omp/agent-second`:`~/.claude-second`,onChange:e=>{p(e.target.value),s(null),g.reset()},className:`h-8 flex-1 font-mono text-label`}),(0,R.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`add-account-browse`,"aria-expanded":m,onClick:()=>h(e=>!e),children:m?`Hide folders`:`Browse…`})]}),(0,R.jsxs)(`p`,{className:`text-meta text-soft-foreground`,children:[`A `,(0,R.jsx)(`code`,{children:`~`}),` is kept as written and expanded when the agent runs.`]})]}),m?(0,R.jsx)(Ge,{path:i,selected:o,onSelect:e=>{s(e),p(e.path),g.reset()},onEnter:e=>{a(e),s(null),g.reset()},showHidden:!0,emptyHint:`No subfolders here — pick this folder by typing its path above.`}):null,g.isError?(0,R.jsx)(`p`,{"data-slot":`add-account-error`,className:`min-w-0 break-words text-ui text-danger`,children:g.error instanceof Error?g.error.message:`could not add that folder`}):null,(0,R.jsxs)(Me,{className:`min-w-0 sm:items-center sm:justify-end`,children:[(0,R.jsx)(P,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,R.jsx)(P,{"data-slot":`add-account-confirm`,disabled:_===``||g.isPending,onClick:()=>{_===``||g.isPending||g.mutate({provider:c,configDir:_,...u.trim()?{label:u.trim()}:{}},{onSuccess:()=>{t(!1),d(``),p(``),s(null),h(!1),E(`Account added — use Connect to sign in`)}})},children:g.isPending?`Adding…`:`Add account`})]})]})})}var U=e=>ne[e],W={claude:{mono:`C`},codex:{key:!0,mono:`X`,ring:!0},cursor:{mono:`Cu`},copilot:{mono:`Co`},opencode:{key:!0,mono:`O`},kimi:{mono:`K`,ring:!0},pi:{terminal:!0,mono:`π`},gemini:{terminal:!0,mono:`G`},antigravity:{terminal:!0,mono:`A`},junie:{terminal:!0,mono:`J`},omp:{terminal:!0,mono:`Ω`}},st=e=>new Set(Object.keys(W).filter(t=>W[t][e])),G=st(`terminal`),ct=st(`key`);function lt(e){let{mono:t,ring:n}=W[e];return{mono:t,color:`var(--runner-mark-${e})`,ring:n===!0}}function ut(e){if(e)try{return new URL(e).host}catch{return}}function dt(e,t,n,r){let i=U(n);switch(e){case`expired`:return t===`paste`?`That code expired. Codes are single-use and expire after a few minutes.`:`The code expired before it was approved.`;case`rejected`:return t===`key`?`The key was rejected by the provider.`:t===`paste`?`That code was not accepted. Codes are single-use and expire after a few minutes.`:`${i} did not accept the sign-in.`;case`account-mismatch`:return`Signed in as another account than ${r} used, so cezar kept the work paused rather than continue on someone else's plan.`;case`exited`:return t===`browser`?`The sign-in ended before you approved access.`:`${i} stopped the sign-in before it finished.`;case`not-installed`:return`${i} is not installed on the computer running cezar.`;case`timeout`:return t===`terminal`?`No sign-in was detected yet. Finish it in the terminal, then check again.`:`${i} did not confirm the sign-in within 15 minutes.`;case`unavailable`:return`${i} can't sign in from here. Run its sign-in on the computer running cezar.`;default:return`The sign-in did not finish.`}}function ft(e,t,n){let r={claude:`claude auth login`,codex:`codex login`,cursor:`agent login`,copilot:`copilot login`,opencode:`opencode auth login`,kimi:`kimi login`,pi:`pi /login`,gemini:`gemini`,antigravity:`agy`,junie:`junie`,omp:`omp`};if(n)return r[e];if(t){if(e===`claude`)return`CLAUDE_CONFIG_DIR=${t} claude auth login`;if(e===`codex`)return`CODEX_HOME=${t} codex login`}}function K({provider:e,small:t=!1,className:n}){let r=lt(e);return(0,R.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`runner-mark`,className:C(`inline-grid shrink-0 place-items-center font-sans font-bold`,t?`size-4 rounded-[4px] text-[9px]`:`size-[22px] rounded-md text-xs`,r.ring&&`shadow-[inset_0_0_0_1px_rgba(255,255,255,.25)]`,n),style:{background:r.color,color:`var(--runner-mark-ink)`},children:r.mono})}var pt=(0,B.createContext)(void 0),mt=()=>(0,B.useContext)(pt),ht=`(max-width: 767px)`,gt=(e,t)=>[...S.agentLogin(e,t),`start-error`],_t=()=>Promise.resolve(null);function q(e,t){let n=o(),i=O(e,t),a=D(e,t),c=r({queryKey:gt(e,t),queryFn:_t,enabled:!1,staleTime:1/0}).data??null,l=g().data?.profiles,u=l?.find(n=>n.provider===e&&n.id===t),d=u?.label??(t==="default"?`Default`:t),f=`${U(e)} · ${d}`,_=s().data?.capabilities?.localHandoff===!1||Re(),x=ze(ht),S=h(),C=b(),w=y(),T=r=>n.setQueryData(gt(e,t),r);return{session:i,news:a,startError:c,profiles:l,profile:u,account:d,who:f,remote:_,narrow:x,view:c?`failed`:p(i)?`signing`:i?.phase===`connected`?`success`:i?.phase===`failed`?`failed`:`expired`,start:S,recheck:w,reconnect:n=>{T(null),S.mutate({provider:e,...t==="default"?{}:{profileId:t},...n?{method:n}:{}},{onError:e=>T({message:e.message,...e instanceof m&&e.command?{command:e.command}:{}})})},checkAgain:()=>{w.mutate(t==="default"?`default:${e}`:t,{onSuccess:e=>{e.status.status===`connected`?E(`${f} is signed in. Resuming what waited on it…`):E(`${f} is still signed out. Finish the sign-in, then check again.`)},onError:e=>E(e.message,{tone:`danger`})})},stop:()=>{i?C.mutate(i):v(n,e,t),T(null)}}}function vt({provider:e,profileId:t,place:n,compact:r=!1,inSheet:i=!1,blocked:a,className:o}){let{session:s,news:c,profiles:l,profile:u,account:d,who:f,remote:p,narrow:m,view:h,startError:g,start:_,recheck:v,reconnect:y,checkAgain:b,stop:x}=q(e,t),S=mt(),[w,T]=(0,B.useState)(!1),[E,D]=(0,B.useState)(!1),O=e=>{T(!1),D(!0),y(e)},k=S?.switchTo?(0,R.jsx)(Mt,{provider:e,profileId:t,profiles:l??[],kind:S.kind,onSwitch:S.switchTo}):null,A=(0,R.jsxs)(P,{type:`button`,variant:`ghost`,size:`sm`,"aria-expanded":w,"data-action":`reconnect-more`,onClick:()=>T(e=>!e),children:[`More options`,w?(0,R.jsx)(ve,{"aria-hidden":`true`,className:`size-3.5`}):(0,R.jsx)(he,{"aria-hidden":`true`,className:`size-3.5`})]}),j=w?(0,R.jsx)(jt,{provider:e,command:s?.command??g?.command??ft(e,u?.configDir,u?.isDefault??t==="default"),checking:v.isPending,onCheck:b,onKey:ct.has(e)?()=>O(`key`):void 0}):null;if(h===`signing`&&s){let t=(0,R.jsx)(Ct,{session:s,who:f,remote:p,compact:r||m}),n=(0,R.jsx)(wt,{session:s,remote:p,stacked:m&&!i,onCheck:b,onRestart:()=>O(),onCancel:x,checking:v.isPending});return m&&!i?(0,R.jsxs)(`div`,{"data-slot":`reconnect-card`,"data-state":`signing`,"data-provider":e,className:C(J,yt,o),children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-ui font-semibold`,children:[(0,R.jsx)(I,{className:`size-3.5`}),(0,R.jsx)(K,{provider:e,small:!0}),`Signing in to `,f]}),(0,R.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap gap-1.5`,children:[(0,R.jsx)(P,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>D(!0),children:`Show sign-in`}),(0,R.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,onClick:x,children:`Cancel`})]}),(0,R.jsx)(oe,{open:E,onOpenChange:D,children:(0,R.jsxs)(te,{side:`bottom`,"data-slot":`reconnect-sheet`,className:`rounded-t-2xl px-4 pt-3 pb-[max(1.5rem,env(safe-area-inset-bottom))]`,children:[(0,R.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto mb-3 h-1 w-9 rounded-full bg-muted`}),(0,R.jsxs)(ee,{className:`flex items-center gap-2 text-base`,children:[(0,R.jsx)(K,{provider:e}),`Reconnect `,f]}),(0,R.jsxs)(se,{className:`sr-only`,children:[`Finish signing in to `,f,`.`]}),t,(0,R.jsx)(`div`,{className:`mt-3 flex flex-col items-stretch gap-1.5`,children:n})]})})]}):(0,R.jsxs)(`div`,{"data-slot":`reconnect-card`,"data-state":`signing`,"data-provider":e,role:`group`,"aria-live":`polite`,"aria-label":`Signing in to ${f}`,className:C(J,yt,o),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,R.jsx)(I,{className:`mt-1 size-3.5`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:Y,children:[(0,R.jsx)(K,{provider:e,small:!0}),` Signing in to `,f]}),t]})]}),(0,R.jsx)(`div`,{className:bt,children:n})]})}if(h===`success`){let t=s?.resumed??c?.resumed;return(0,R.jsxs)(`div`,{"data-slot":`reconnect-card`,"data-state":`success`,"data-provider":e,role:`status`,className:C(J,`border-success/30 bg-success/5`,o),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,R.jsx)(M,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-success-strong`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:Y,children:[f,` is signed in again`]}),n===`task`&&S?.parked===null?(0,R.jsx)(`div`,{className:X,children:`Continue the task to pick up where it stopped.`}):(0,R.jsxs)(`div`,{className:C(X,`flex items-center gap-1.5`),children:[(0,R.jsx)(I,{className:`size-3`}),n===`task`?`Continuing the run from the same session…`:n===`manager`?`Resuming this turn…`:`Resuming what waited on it…`]})]})]}),t?(0,R.jsx)(Nt,{account:d,resumed:t,compact:r}):null]})}if(h===`failed`){let t=g?.message??dt(s?.reason,s?.method,e,d);return(0,R.jsxs)(`div`,{"data-slot":`reconnect-card`,"data-state":`failed`,"data-provider":e,role:`alert`,className:C(J,o),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,R.jsx)(K,{provider:e}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:Y,children:[`Sign-in to `,f,` didn't finish`]}),(0,R.jsx)(`div`,{"data-slot":`reconnect-reason`,className:X,children:t})]})]}),(0,R.jsxs)(`div`,{className:C(bt,r&&`flex-col items-stretch`),children:[(0,R.jsx)(P,{type:`button`,variant:`contrast`,size:`sm`,"data-action":`reconnect-start`,disabled:_.isPending,onClick:()=>O(),children:`Try again`}),k,A]}),g?.command&&!w?(0,R.jsx)(Q,{command:g.command,label:`Run this on the computer running cezar:`}):null,j]})}let ne=G.has(e)&&!p;return(0,R.jsxs)(`div`,{"data-slot":`reconnect-card`,"data-state":`expired`,"data-provider":e,role:`group`,"aria-label":`${f} is signed out`,className:C(J,o),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,R.jsx)(K,{provider:e}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:Y,children:[f,` is signed out`,(0,R.jsx)(`span`,{"data-slot":`reconnect-pill`,className:C(Z,`border-danger/35 bg-danger/10 text-danger-strong`),children:`Login expired`})]}),(0,R.jsx)(`div`,{className:X,children:n===`task`&&S?.parked===null?`The run stopped when the login expired. Reconnect, then Continue the task.`:n===`task`?`The run paused at its first request after the login expired. Reconnect and it continues from the same session.`:n===`manager`?`This turn stopped before answering. Reconnect and it picks up where it stopped.`:`Reconnect and everything waiting on it resumes.`})]})]}),(0,R.jsxs)(`div`,{className:C(bt,r&&`flex-col items-stretch`),children:[(0,R.jsxs)(P,{type:`button`,variant:`contrast`,size:`sm`,"data-action":`reconnect-start`,disabled:_.isPending,onClick:()=>O(),children:[_.isPending?(0,R.jsx)(I,{className:`size-3`}):null,ne?(0,R.jsxs)(R.Fragment,{children:[`Sign in to `,d,` `,(0,R.jsx)(F,{"aria-hidden":`true`,className:`size-3`})]}):(0,R.jsxs)(R.Fragment,{children:[`Reconnect `,d]})]}),k,A]}),j,a&&!r?(0,R.jsxs)(`div`,{"data-slot":`reconnect-blocked`,className:`mt-2.5 flex flex-wrap items-center gap-1.5 text-micro text-soft-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full bg-pending`}),a]}):null]})}var J=`mt-2 max-w-[640px] rounded-[10px] border border-danger/30 bg-danger/5 px-3.5 py-3 transition-colors`,yt=`border-border bg-card`,Y=`flex flex-wrap items-center gap-1.5 text-ui font-semibold text-foreground`,X=`mt-0.5 text-xs text-muted-foreground`,bt=`mt-2.5 flex flex-wrap items-center gap-1.5`,Z=`inline-flex h-[18px] items-center rounded-full border px-1.5 text-micro font-semibold tracking-[.02em] whitespace-nowrap`;function xt({provider:e,profileId:t,at:n,signedOutHere:r=!1}){let i=St(e,t??`default`),a=e?` ${U(e)} · ${i}`:``,o=n?new Date(n):void 0,s=o&&Number.isFinite(o.getTime())?o.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}):void 0;return(0,R.jsx)(`p`,{"data-slot":`reconnected-line`,"data-state":r?`older`:`reconnected`,className:`mt-1.5 flex items-center gap-1.5 text-label text-muted-foreground`,children:r?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),a.trim(),` was signed out here`]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(M,{"aria-hidden":`true`,className:`size-3.5 text-success-strong`}),`Reconnected`,a,` · resumed`,s?(0,R.jsxs)(R.Fragment,{children:[` at `,(0,R.jsx)(`time`,{dateTime:n,children:s})]}):null]})})}function St(e,t){return(g().data?.profiles)?.find(n=>n.provider===e&&n.id===t)?.label??(t==="default"?`Default`:t)}function Ct({session:e,who:t,remote:n,compact:r,stepsLabel:i=`resume`}){let a=U(e.provider),s=ut(e.url),c=o();if(e.phase===`starting`)return(0,R.jsxs)(`p`,{className:X,children:[`Starting `,a,`'s sign-in…`]});if(e.phase===`verifying`)return(0,R.jsx)(Tt,{steps:[[`done`,`Sign-in finished`],[`now`,`Verifying the account`],[`todo`,i===`resume`?`Resume`:`Ready`]]});switch(e.method){case`browser`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:X,children:[`Open this link in the browser and profile you sign in to `,a,` with, then approve access. `,i===`resume`?`This card`:`This dialog`,` updates by itself.`]}),e.url?(0,R.jsx)(Q,{command:e.url,copyLabel:`Copy link`}):null,(0,R.jsx)(Tt,{steps:[[`done`,`Sign-in started`],[`now`,`Approve in your browser`],[`todo`,i===`resume`?`Verify & resume`:`Verify`]]})]});case`link`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:X,children:[`Open the `,a,` sign-in `,n?`on this or any device`:`in your browser`,` and approve. `,a,` confirms it to cezar directly, with no callback to this computer.`]}),e.url?(0,R.jsx)(Q,{command:e.url,copyLabel:`Copy link`}):null]});case`device`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:X,children:[`Enter this code at `,(0,R.jsx)(`b`,{className:`font-semibold text-foreground`,children:s??`the sign-in page`}),n?`, on this or any device`:``,`.`]}),e.userCode?(0,R.jsx)(Et,{code:e.userCode,expiresAt:e.expiresAt}):(0,R.jsx)(`p`,{className:X,children:`Waiting for the code…`})]});case`paste`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Tt,{steps:[[`done`,`Sign-in started`],[`now`,`Approve & copy the code`],[`todo`,`Paste it here`]]}),(0,R.jsxs)(`p`,{className:C(X,`mt-2`),children:[`1. Open the sign-in link on `,r?`this phone`:`any device`,` and approve. `,a,` then shows a one-time code.`,(0,R.jsx)(`br`,{}),`2. Paste that code here. It goes straight to `,a,` on your computer.`]}),(0,R.jsx)(Ot,{session:e,kind:`code`,placeholder:`Paste the code from ${a}`,submitLabel:`Sign in`,onAnswer:e=>l(c,e)})]});case`key`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:X,children:e.provider===`opencode`?`Paste an API key for the provider this account used. It goes straight into OpenCode's own credential store; cezar doesn't keep it.`:`Paste an OpenAI API key. Codex stores it in this account's folder; cezar doesn't keep it.`}),ct.has(e.provider)?(0,R.jsx)(Ot,{session:e,kind:`key`,placeholder:`sk-…`,submitLabel:`Save & sign in`,keyProviders:e.provider===`opencode`?e.keyProviders:void 0,onAnswer:e=>l(c,e)}):null]});case`terminal`:return n?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:X,children:[a,` can only sign in on the computer running cezar. Run this there, then come back:`]}),e.command?(0,R.jsx)(Q,{command:e.command}):null]}):(0,R.jsxs)(`p`,{className:X,children:[a,` signs in only in its own window. We opened it in a terminal; finish there and this card notices by itself.`]})}return(0,R.jsxs)(`p`,{className:X,children:[`Signing in to `,t,`…`]})}function wt({session:e,remote:t,stacked:n,checking:r,onCheck:i,onRestart:a,onCancel:o}){let s=ut(e.url),c=e.url?()=>kt(e.url):void 0,l=n?`default`:`sm`,u=null;if(e.method===`browser`&&c)u=(0,R.jsxs)(P,{type:`button`,variant:`outline`,size:l,onClick:c,children:[`Open in default browser `,(0,R.jsx)(F,{"aria-hidden":`true`,className:`size-3`})]});else if(e.method===`link`&&c)u=(0,R.jsxs)(P,{type:`button`,variant:n?`contrast`:`outline`,size:l,onClick:c,children:[`Open `,U(e.provider),` sign-in `,(0,R.jsx)(F,{"aria-hidden":`true`,className:`size-3`})]});else if(e.method===`device`&&c){let t=e.userCode;u=n&&t?(0,R.jsxs)(P,{type:`button`,variant:`contrast`,size:l,onClick:()=>{Le(t).catch(()=>{}),c()},children:[`Copy code & open `,s,` `,(0,R.jsx)(F,{"aria-hidden":`true`,className:`size-3`})]}):(0,R.jsxs)(P,{type:`button`,variant:`outline`,size:l,onClick:c,children:[`Open `,s,` `,(0,R.jsx)(F,{"aria-hidden":`true`,className:`size-3`})]})}else e.method===`paste`&&c?u=(0,R.jsxs)(P,{type:`button`,variant:`outline`,size:l,onClick:c,children:[`Open sign-in link `,(0,R.jsx)(F,{"aria-hidden":`true`,className:`size-3`})]}):e.method===`terminal`&&(u=t?(0,R.jsx)(P,{type:`button`,variant:`outline`,size:l,disabled:r,onClick:i,children:`I've signed in · Check`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P,{type:`button`,variant:`outline`,size:l,onClick:a,children:`Open again`}),(0,R.jsx)(P,{type:`button`,variant:`outline`,size:l,disabled:r,onClick:i,children:`I've signed in`})]}));return(0,R.jsxs)(R.Fragment,{children:[u,(0,R.jsx)(P,{type:`button`,variant:`ghost`,size:l,"data-action":`reconnect-cancel`,onClick:o,children:`Cancel`})]})}function Tt({steps:e}){return(0,R.jsx)(`ol`,{"data-slot":`reconnect-steps`,className:`mt-2.5 flex flex-wrap gap-3.5 text-micro text-soft-foreground`,children:e.map(([e,t])=>(0,R.jsxs)(`li`,{"data-state":e,className:C(`flex items-center gap-1`,e===`done`&&`text-success-strong`,e===`now`&&`text-foreground`),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:e===`done`?`✓`:e===`now`?`●`:`○`}),t]},t))})}function Et({code:e,expiresAt:t}){let n=Dt(t);return(0,R.jsxs)(`div`,{"data-slot":`reconnect-device`,className:`mt-2.5 flex flex-wrap items-center gap-2.5`,children:[(0,R.jsx)(`span`,{"aria-label":`One-time code`,className:`rounded-lg border border-border bg-background px-3 py-1.5 font-mono text-xl font-semibold tracking-[.18em]`,children:e}),(0,R.jsx)(At,{text:e,label:`Copy code`,variant:`outline`}),n===void 0?null:(0,R.jsxs)(`span`,{className:`text-label text-muted-foreground`,children:[`Expires in `,(0,R.jsx)(`span`,{"data-slot":`reconnect-countdown`,className:`font-mono`,children:n})]})]})}function Dt(e){let[t,n]=(0,B.useState)(()=>Date.now());if((0,B.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return;let r=Date.parse(e);if(!Number.isFinite(r))return;let i=Math.max(0,r-t);return`${Math.floor(i/6e4)}:${String(Math.floor(i/1e3)%60).padStart(2,`0`)}`}function Ot({session:e,kind:t,placeholder:n,submitLabel:r,keyProviders:i,onAnswer:a}){let o=(0,B.useRef)(null),[s,c]=(0,B.useState)(),l=s!==void 0&&i?.includes(s)?s:i?.[0],[u,f]=(0,B.useState)(!1);return(0,R.jsxs)(`form`,{"data-slot":`reconnect-secret`,onSubmit:n=>{n.preventDefault();let r=o.current,i=r?.value.trim()??``;r&&(r.value=``),i&&(f(!0),d(e.sessionId,t===`code`?{code:i}:{apiKey:i,...l?{keyProvider:l}:{}}).then(a).catch(e=>E(e instanceof Error?e.message:String(e),{tone:`danger`})).finally(()=>f(!1)))},className:`mt-2 flex flex-wrap gap-1.5`,children:[i&&i.length>0?(0,R.jsxs)(Se,{value:l,onValueChange:c,children:[(0,R.jsx)(be,{size:`sm`,"aria-label":`Provider`,"data-slot":`reconnect-key-provider`,className:`h-[30px] text-xs`,children:(0,R.jsx)(xe,{})}),(0,R.jsx)(ye,{children:i.map(e=>(0,R.jsx)(_e,{value:e,children:e},e))})]}):null,(0,R.jsx)(`input`,{ref:o,type:`password`,autoComplete:`off`,spellCheck:!1,"aria-label":t===`code`?`One-time code`:`API key`,placeholder:n,className:`h-[30px] min-w-[140px] flex-1 rounded-sm border border-border bg-background px-2.5 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30`}),(0,R.jsx)(P,{type:`submit`,variant:`contrast`,size:`sm`,disabled:u,children:r})]})}function kt(e){window.open(e,`_blank`,`noopener,noreferrer`)}function At({text:e,label:t,variant:n=`ghost`}){let[r,i]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i(!1),1200);return()=>clearTimeout(e)},[r]),(0,R.jsx)(P,{type:`button`,variant:n,size:`sm`,onClick:()=>Le(e).then(()=>i(!0),()=>E(`Could not copy`,{tone:`danger`})),children:r?`Copied`:t})}function Q({command:e,label:t,copyLabel:n=`Copy`}){return(0,R.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:[t?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}):null,(0,R.jsxs)(`div`,{"data-slot":`reconnect-command`,className:`flex max-w-full items-center gap-1.5 rounded-lg border border-border bg-background py-1 pr-1 pl-2`,children:[(0,R.jsx)(`code`,{className:`min-w-0 flex-1 overflow-auto font-mono text-xs whitespace-nowrap`,children:e}),(0,R.jsx)(At,{text:e,label:n})]})]})}function jt({provider:e,command:t,checking:n,onCheck:r,onKey:i}){let a=`h-auto p-0 font-medium text-foreground underline underline-offset-2 hover:no-underline`;return(0,R.jsxs)(`div`,{"data-slot":`reconnect-more`,className:`mt-2.5 flex flex-col gap-2 border-t border-dashed border-border pt-2.5 text-xs`,children:[(0,R.jsx)(`button`,{type:`button`,"data-action":`reconnect-check`,disabled:n,onClick:r,className:C(a,`self-start disabled:opacity-50`),children:`Already signed in? Check again`}),i?(0,R.jsx)(`button`,{type:`button`,"data-action":`reconnect-key`,onClick:i,className:C(a,`self-start`),children:`Sign in with an API key instead`}):null,(0,R.jsx)(T,{to:`/settings/global/accounts`,className:C(a,`self-start`),children:`Open Settings → Agent accounts`}),t?(0,R.jsx)(Q,{command:t,label:`Last resort, on the machine running cezar (${U(e)}):`}):null]})}function Mt({provider:e,profileId:t,profiles:n,kind:r,onSwitch:i}){let[a,o]=(0,B.useState)(!1),s=en(),c=n.filter(t=>t.provider===e&&!t.pending),l=c.filter(e=>e.id!==t),u=s?.capable.includes(e)??!1;if(l.length===0&&!u)return null;let d=e=>e.status?.status!==`disconnected`&&e.status?.status!==`not-installed`,f=l.find(e=>e.status?.status===`connected`)??l.find(d),p=e=>{o(!0),i(e).catch(e=>E(e instanceof Error?e.message:String(e),{tone:`danger`})).finally(()=>o(!1))};return(0,R.jsxs)(`span`,{"data-slot":`reconnect-switch`,className:`inline-flex`,children:[f?(0,R.jsxs)(P,{type:`button`,variant:`outline`,size:`sm`,"data-action":`reconnect-switch`,disabled:a,className:`rounded-r-none border-r-0`,onClick:()=>p(f.id),children:[`Use `,f.label,` instead`]}):null,(0,R.jsxs)(De,{children:[(0,R.jsx)(Te,{asChild:!0,children:(0,R.jsxs)(P,{type:`button`,variant:`outline`,size:`sm`,"aria-label":f?`Accounts to switch to`:void 0,disabled:a,className:C(f&&`rounded-l-none px-1.5`),children:[f?null:`Use another account`,(0,R.jsx)(he,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,R.jsxs)(Ee,{align:`start`,className:`min-w-60`,children:[(0,R.jsxs)(Ce,{className:`text-micro tracking-[.06em] text-soft-foreground uppercase`,children:[`Accounts this `,r,` may use`]}),c.map(n=>{let r=n.id===t?`disconnected`:n.status?.status;return(0,R.jsxs)(we,{"data-account":n.id,disabled:n.id===t||!d(n),onSelect:()=>p(n.id),children:[(0,R.jsx)(K,{provider:e,small:!0}),U(e),` · `,n.label,r===`connected`?(0,R.jsx)(`span`,{className:C(Z,`ml-auto border-success/35 bg-success/10 text-success-strong`),children:`Signed in`}):r===`disconnected`?(0,R.jsx)(`span`,{className:C(Z,`ml-auto border-danger/35 bg-danger/10 text-danger-strong`),children:`Signed out`}):r===`not-installed`?(0,R.jsx)(`span`,{className:C(Z,`ml-auto`),children:`Not installed`}):null]},n.id)}),u&&s?(0,R.jsx)(we,{"data-action":`reconnect-add-account`,onSelect:()=>s.open({provider:e,onAdded:e=>p(e.id)}),children:`Add an account…`}):null,(0,R.jsx)(`p`,{className:`px-2 py-1.5 text-micro text-soft-foreground`,children:r===`task`?`Switching account starts a fresh session; the task keeps its worktree and changes.`:`The manager keeps its memory; the next turn starts a fresh transcript.`})]})]})]})}function Nt({account:e,resumed:t,compact:n}){let r=mt()?.ownId,i={runs:t.runs.filter(e=>e.runId!==r),managers:t.managers.filter(e=>e.managerId!==r)};return i.runs.length+i.managers.length===0?null:n?(0,R.jsxs)(`p`,{"data-slot":`reconnect-resumed`,className:`mt-2.5 flex items-center gap-1.5 text-micro text-soft-foreground`,children:[(0,R.jsx)(I,{className:`size-2.5`}),`Also resuming on `,e,`: `,Pt(i.runs.length,`task`),i.runs.length&&i.managers.length?` · `:``,Pt(i.managers.length,`manager`)]}):(0,R.jsxs)(`div`,{"data-slot":`reconnect-resumed`,className:`mt-2.5 flex flex-col gap-2 border-t border-dashed border-border pt-2.5 text-xs`,children:[(0,R.jsxs)(`p`,{children:[`Also resuming on `,e,`:`]}),(0,R.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[i.runs.map(e=>(0,R.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(I,{className:`size-2.5`}),(0,R.jsxs)(T,{to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.runId)}`,className:`underline underline-offset-2`,children:[`Task “`,e.title,`”`]})]},`${e.projectId}/${e.runId}`)),i.managers.map(e=>(0,R.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(I,{className:`size-2.5`}),(0,R.jsxs)(T,{to:`/manager/${encodeURIComponent(e.managerId)}`,className:`underline underline-offset-2`,children:[`Manager “`,e.title,`”`]}),(0,R.jsx)(`span`,{className:`text-soft-foreground`,children:`· chat turn`})]},e.managerId))]}),(0,R.jsx)(`p`,{className:`text-micro text-soft-foreground`,children:`Watch checks run on their next tick.`})]})}var Pt=(e,t)=>e===0?``:`${e} ${t}${e===1?``:`s`}`;function Ft({className:e,size:t=`default`,...n}){return(0,R.jsx)($e,{"data-slot":`switch`,"data-size":t,className:C(`peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...n,children:(0,R.jsx)(tt,{"data-slot":`switch-thumb`,className:C(`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}var It=e=>e.consumers.reduce((e,t)=>e+t.estimatePp,0);function Lt(e,t){return e?.windows.find(e=>e.current&&e.account.key===t)}function Rt(e){return`${new Date(e).toLocaleDateString(void 0,{weekday:`short`,day:`numeric`,month:`short`})} ${ae(e)}`}function zt(e){return!e||!e.usedPercent?`no reading yet`:`${A(e.usedPercent.last)} used · resets ${ae(e.resetsAt)} · cezar tasks and managers ${k(It(e))} of it, outside cezar ${A(e.outsideCezarPp)}${Vt(e)}`}function Bt(e){return!e||!e.usedPercent?`no reading yet`:`${A(e.usedPercent.last)} used · resets ${Rt(e.resetsAt)} · this week: cezar ${k(It(e))}, outside cezar ${A(e.outsideCezarPp)}${Vt(e)}`}function Vt(e){let t=[e.beforeTrackingPp>0?`before tracking ${A(e.beforeTrackingPp)}`:``,e.untrackedPp>0?`not tracked ${A(e.untrackedPp)}`:``,e.unsplitPp>0?`couldn't split ${A(e.unsplitPp)}`:``,e.correctionPp>0?`provider correction −${A(e.correctionPp)}`:``].filter(Boolean);return t.length?`, ${t.join(`, `)}`:``}function Ht({provider:e,accountId:t}){let n=`${e}:${t}`,r=(0,B.useId)(),i=ie({kind:`five-hour`,account:n}),a=ie({kind:`weekly`,account:n}),o=re(),s=j(),c=o.data?.enabled===!1,l=!c&&o.data?.accounts[n]!==!1,u=o.data?.retentionDays??90;return(0,R.jsxs)(`div`,{"data-slot":`account-plan-usage`,className:`mt-3 flex flex-col gap-2 border-t border-border/60 pt-2.5 text-label`,children:[(0,R.jsxs)(`dl`,{className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-x-3 gap-y-1`,children:[(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`5-hour limit`}),(0,R.jsx)(`dd`,{"data-slot":`account-plan-five-hour`,className:`min-w-0 text-foreground tabular-nums`,children:i.isPending?`Reading…`:i.isError?`unavailable`:zt(Lt(i.data,n))}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`Weekly limit`}),(0,R.jsx)(`dd`,{"data-slot":`account-plan-weekly`,className:`min-w-0 text-foreground tabular-nums`,children:a.isPending?`Reading…`:a.isError?`unavailable`:Bt(Lt(a.data,n))})]}),(0,R.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,R.jsx)(Ft,{id:r,"data-slot":`account-plan-tracking`,checked:l,disabled:c||o.isPending||s.isPending,onCheckedChange:e=>s.mutate({account:n,enabled:e},{onError:e=>E(e.message,{tone:`danger`})})}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`label`,{htmlFor:r,className:`font-medium text-foreground`,children:`Track plan limit usage`}),(0,R.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Saves the limit readings on this computer (no prompts or code) so cezar can show which tasks used them. Kept `,u,` days.`]}),c?(0,R.jsx)(`p`,{"data-slot":`account-plan-tracking-off`,className:`mt-0.5 text-muted-foreground`,children:o.data?.reason??`Turned off on this computer (CEZ_USAGE_LOG=0).`}):null]})]})]})}function Ut({open:e,onOpenChange:t,providers:n,initialProvider:r,onAdvanced:i,resume:a,onAdded:o}){let s=ze(ht),[c,l]=(0,B.useState)(a?.provider??(r&&n.includes(r)?r:n[0]??`claude`)),[u,d]=(0,B.useState)(``),[p,m]=(0,B.useState)(a??null),[h,g]=(0,B.useState)(a?`signing`:`pick`),[_,v]=(0,B.useState)(!1),y=x(),b=f(),S=()=>t(!1),C=()=>{h===`signing`&&p?v(!0):S()},w=()=>{if(!p)return S();b.mutate(p.id,{onSettled:()=>{v(!1),S()},onError:e=>E(e.message,{tone:`danger`})})},T=()=>{y.isPending||y.mutate({provider:c,managed:!0,...u.trim()?{label:u.trim()}:{}},{onSuccess:({profile:e})=>{m(e),g(`signing`)}})},D=h===`pick`?0:h===`signing`?1:2,O=(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(K,{provider:p?.provider??c}),`Add agent account`]})}),k;h===`pick`?k=(0,R.jsx)(Kt,{providers:n,provider:c,onProvider:e=>{l(e),y.reset()},label:u,onLabel:e=>{d(e),y.reset()},error:y.error?Wt(y.error):null,pending:y.isPending,narrow:s,onCancel:S,onContinue:T,onAdvanced:i}):p&&h===`signing`?k=_?(0,R.jsx)(Jt,{account:p,busy:b.isPending,onKeep:()=>v(!1),onDiscard:w,narrow:s}):(0,R.jsx)(qt,{account:p,narrow:s,onSignedIn:()=>g(`ready`),onCancel:()=>v(!0)}):p&&(k=(0,R.jsx)(Xt,{account:p,narrow:s,onDone:e=>{e&&o?.(p),S()},onRemove:w,removing:b.isPending}));let A=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Gt,{index:D}),k]});return s?(0,R.jsx)(oe,{open:e,onOpenChange:e=>e?t(!0):C(),children:(0,R.jsxs)(te,{side:`bottom`,"data-slot":`add-account-wizard`,className:`max-h-[92dvh] overflow-y-auto rounded-t-2xl px-4 pt-3 pb-[max(1.5rem,env(safe-area-inset-bottom))]`,children:[(0,R.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto mb-3 h-1 w-9 rounded-full bg-muted`}),(0,R.jsx)(ee,{className:`text-base`,children:O}),(0,R.jsx)(se,{className:`sr-only`,children:`Sign in to a new agent account.`}),A]})}):(0,R.jsx)(Ie,{open:e,onOpenChange:e=>e?t(!0):C(),children:(0,R.jsxs)(Ne,{"data-slot":`add-account-wizard`,className:`sm:max-w-lg`,children:[(0,R.jsx)(Pe,{children:O}),(0,R.jsx)(Fe,{className:`sr-only`,children:`Sign in to a new agent account.`}),A]})})}function Wt(e){return e instanceof m?e.message:e.message||`Could not add the account.`}function Gt({index:e}){return(0,R.jsx)(`ol`,{"data-slot":`add-account-steps`,className:`flex gap-1.5 text-micro text-soft-foreground`,children:[`Agent`,`Sign in`,`Ready`].map((t,n)=>(0,R.jsxs)(`li`,{"data-state":n<e?`done`:n===e?`now`:`todo`,className:C(`flex flex-1 items-center gap-1 border-t-2 border-muted pt-1.5`,n<e&&`border-success text-success-strong`,n===e&&`border-foreground text-foreground`),children:[n<e?(0,R.jsx)(M,{"aria-hidden":`true`,className:`size-3`}):(0,R.jsx)(`span`,{"aria-hidden":`true`,children:n+1}),t]},t))})}function $({narrow:e,children:t}){return(0,R.jsx)(`div`,{className:C(`mt-2 flex gap-2`,e?`flex-col-reverse items-stretch`:`items-center justify-end`),children:t})}function Kt({providers:e,provider:t,onProvider:n,label:r,onLabel:i,error:a,pending:o,narrow:s,onCancel:c,onContinue:l,onAdvanced:u}){return(0,R.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Agent`,className:C(`grid gap-2`,s?`grid-cols-1`:`grid-cols-2`),children:e.map(e=>(0,R.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e===t,"data-provider":e,onClick:()=>n(e),className:C(`flex items-start gap-2.5 rounded-lg border border-border bg-card px-3 py-2 text-left text-ui`,e===t&&`border-ring ring-[3px] ring-ring/25`),children:[(0,R.jsx)(K,{provider:e}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:`block font-medium`,children:U(e)}),(0,R.jsx)(`span`,{className:`block text-micro text-soft-foreground`,children:G.has(e)?`Signs in in a terminal`:`Signs in through its web page`})]})]},e))}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-muted-foreground`,children:[`Account name`,(0,R.jsx)(L,{type:`text`,"data-slot":`add-account-name`,value:r,placeholder:`Work`,maxLength:200,onChange:e=>i(e.target.value),className:`h-9 text-base md:text-sm`})]}),a?(0,R.jsx)(`p`,{"data-slot":`add-account-error`,role:`alert`,className:`text-ui text-danger`,children:a}):null,u?(0,R.jsx)(`button`,{type:`button`,"data-action":`add-account-advanced`,onClick:u,className:`self-start text-xs text-muted-foreground underline underline-offset-2 hover:no-underline`,children:`Advanced: use a folder that is already signed in`}):null,(0,R.jsxs)($,{narrow:s,children:[(0,R.jsx)(P,{type:`button`,variant:`ghost`,onClick:c,children:`Cancel`}),(0,R.jsxs)(P,{type:`submit`,variant:`contrast`,"data-action":`add-account-continue`,disabled:o,children:[o?(0,R.jsx)(I,{className:`size-3`}):null,`Continue · sign in`]})]})]})}function qt({account:e,narrow:t,onSignedIn:n,onCancel:r}){let{session:i,view:a,startError:s,remote:c,who:l,start:u,recheck:d,reconnect:f,checkAgain:p,stop:m}=q(e.provider,e.id),h=o(),g=(0,B.useRef)(!1);(0,B.useEffect)(()=>{g.current||(g.current=!0,f())},[]),(0,B.useEffect)(()=>{a===`success`&&(h.invalidateQueries({queryKey:S.agentProfiles}),n())},[a]);let _=()=>{m(),r()};if(a===`failed`){let n=s?.message??dt(i?.reason,i?.method,e.provider,e.label);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`div`,{"data-slot":`add-account-failed`,role:`alert`,className:`rounded-lg border border-danger/30 bg-danger/5 px-3 py-2 text-ui`,children:[(0,R.jsxs)(`b`,{className:`font-semibold`,children:[`Sign-in to `,l,` didn't finish.`]}),` `,(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:n})]}),(0,R.jsxs)($,{narrow:t,children:[(0,R.jsx)(P,{type:`button`,variant:`ghost`,onClick:_,children:`Cancel`}),(0,R.jsx)(P,{type:`button`,variant:`contrast`,"data-action":`add-account-retry`,disabled:u.isPending,onClick:()=>f(),children:i?.reason===`expired`?`Get a new code`:`Try again`})]})]})}return(0,R.jsxs)(`div`,{"data-slot":`add-account-signing`,className:`flex flex-col gap-3`,children:[i?(0,R.jsx)(Ct,{session:i,who:l,remote:c,compact:t,stepsLabel:`verify`}):(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(I,{className:`size-3`}),`Creating a private folder and starting `,U(e.provider),`'s sign-in…`]}),(0,R.jsx)($,{narrow:t,children:i?(0,R.jsx)(wt,{session:i,remote:c,stacked:t,checking:d.isPending,onCheck:p,onRestart:()=>f(),onCancel:_}):(0,R.jsx)(P,{type:`button`,variant:`ghost`,onClick:_,children:`Cancel`})})]})}function Jt({account:e,busy:t,narrow:n,onKeep:r,onDiscard:i}){return(0,R.jsxs)(`div`,{"data-slot":`add-account-cancel`,className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`p`,{className:`text-ui`,children:[(0,R.jsxs)(`b`,{className:`font-semibold`,children:[`Stop adding `,U(e.provider),` · `,e.label,`?`]}),(0,R.jsx)(`br`,{}),(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[`The sign-in stops and the folder cezar made for it is deleted. Your other `,U(e.provider),` logins are not touched.`]})]}),(0,R.jsxs)($,{narrow:n,children:[(0,R.jsx)(P,{type:`button`,variant:`ghost`,onClick:r,children:`Keep signing in`}),(0,R.jsx)(P,{type:`button`,variant:`destructive`,"data-action":`add-account-discard`,disabled:t,onClick:i,children:`Stop & delete`})]})]})}var Yt=e=>e?.find(e=>e.label===`Email`)?.value.trim().toLowerCase()||void 0;function Xt({account:e,narrow:t,removing:n,onDone:r,onRemove:a}){let o=g().data,s=u(w(e),!0),l=i(),[d,f]=(0,B.useState)(!1),p=o?.hostPaths!==!1,m=(o?.profiles??[]).filter(t=>t.provider===e.provider&&t.id!==e.id&&!t.pending),h=c({queries:m.map(e=>({queryKey:S.agentAccountDetails(w(e)),queryFn:({signal:t})=>_(w(e),{signal:t}),staleTime:0,retry:!1}))}),v=s.data?.available?Yt(s.data.fields):void 0,y=v===void 0?-1:h.findIndex(e=>e.data?.available&&Yt(e.data.fields)===v),b=y>=0?m[y]:void 0,x=`${U(e.provider)} · ${e.label}`;return(0,R.jsxs)(`div`,{"data-slot":`add-account-ready`,className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 rounded-lg border border-success/30 bg-success/5 px-3 py-2 text-ui`,children:[(0,R.jsx)(M,{"aria-hidden":`true`,className:`size-4 shrink-0 text-success-strong`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`b`,{className:`font-semibold`,children:x}),` is signed in and ready.`]})]}),b?(0,R.jsxs)(`div`,{"data-slot":`add-account-duplicate`,className:`rounded-lg border border-pending/35 bg-pending/5 px-3 py-2 text-ui`,children:[(0,R.jsxs)(`b`,{className:`font-semibold`,children:[`This is the same login as “`,b.label,`”`]}),` `,(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,v,`). Two accounts on one login share one subscription and its limits.`]})]}):null,s.isPending?(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`Reading account details…`}):s.data?.available?(0,R.jsx)(`dl`,{"data-slot":`add-account-identity`,className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-x-3 gap-y-1 text-label`,children:s.data.fields.map(e=>(0,R.jsxs)(B.Fragment,{children:[(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all`,children:e.value})]},e.label))}):s.data?.reason?(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:s.data.reason}):null,e.provider===`claude`||e.provider===`codex`?(0,R.jsx)(Ht,{provider:e.provider,accountId:e.id}):null,p?(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-ui`,children:[(0,R.jsx)(`input`,{type:`checkbox`,"data-slot":`add-account-default`,checked:d,onChange:e=>f(e.target.checked)}),`Use it for projects that have not picked a `,U(e.provider),` account`]}):null,(0,R.jsxs)($,{narrow:t,children:[b?(0,R.jsx)(P,{type:`button`,variant:`ghost`,"data-action":`add-account-remove-duplicate`,disabled:n,onClick:a,children:`Remove this one`}):null,(0,R.jsx)(P,{type:`button`,variant:`contrast`,"data-action":`add-account-done`,disabled:l.isPending,onClick:()=>{if(!d)return r(!0);l.mutate({projectId:null,provider:e.provider,profileId:e.id},{onSuccess:()=>r(!0),onError:e=>E(e.message,{tone:`danger`})})},children:b?`Keep both`:`Done`})]})]})}var Zt=(0,B.createContext)(null),Qt=[];function $t(){let e=g().data;return e?.editable?e.profileCapableProviders??Qt:Qt}function en(){let e=(0,B.useContext)(Zt),t=$t();return(0,B.useMemo)(()=>e&&t.length>0?{capable:t,open:e}:null,[e,t])}function tn({children:e}){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),a=(0,B.useCallback)((e={})=>n({...e,key:Date.now()}),[]);return(0,R.jsxs)(Zt.Provider,{value:a,children:[e,t?(0,R.jsx)(nn,{request:t,onClose:()=>n(null),onAdvanced:e=>{i(e),n(null)}}):null,r===null?null:(0,R.jsx)(rn,{provider:r,onClose:()=>i(null)})]})}function nn({request:e,onClose:t,onAdvanced:n}){let r=g().data,i=$t();if(!r)return null;let a=r.hostPaths!==!1,o=e.provider&&i.includes(e.provider)?e.provider:i[0];return(0,R.jsx)(Ut,{open:!0,onOpenChange:e=>!e&&t(),providers:i,initialProvider:e.provider,resume:e.resume,onAdded:e.onAdded,onAdvanced:a&&o?()=>n(o):void 0},e.key)}function rn({provider:e,onClose:t}){return(0,R.jsx)(ot,{open:!0,onOpenChange:e=>!e&&t(),providers:[...$t()],initialProvider:e},e)}export{vt as a,pt as c,U as d,Ge as f,Ft as i,K as l,en as n,xt as o,Ke as p,Ht as r,q as s,tn as t,G as u};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Jo as r,Kt as i,O as a,Qo as o,R as s,Yo as c,bn as l,c as u,eo as d,ht as f,i as p,kr as m,nn as h,p as g,pi as _,r as v,st as y,v as b,w as x,yn as S}from"./queries-BeoT2lBk.js";import{t as C,ut as w}from"./utils-D6vflkwY.js";import{f as T}from"./project-router-Bek4dR86.js";import{r as E}from"./toaster-CnjJGypN.js";import{C as ee,D,O,b as te,c as k,d as A,i as j,k as ne,r as re,t as ie,u as ae,v as oe,x as se}from"./plan-usage-D1hnSOHC.js";import{t as ce}from"./createLucideIcon-BHp8sXmF.js";import{A as le,B as M,D as ue,L as de,c as fe,j as N,k as pe,t as P,z as me}from"./button-CSEYvv3h.js";import{r as he}from"./dist-CRisPV4Q.js";import{c as ge,i as _e,l as ve,n as ye,o as be,s as xe,t as Se}from"./select-DhHKFkXF.js";import{a as Ce,i as we,p as Te,r as Ee,t as De}from"./dropdown-menu-HzutX8-V.js";import{t as F}from"./external-link-BE6y205O.js";import{t as Oe}from"./folder-o-AvL3y3.js";import{i as ke,l as Ae}from"./loading-state-A_q6C0kQ.js";import{t as I}from"./spinner-5lGeVKBb.js";import{t as L}from"./input-DYkGEVpN.js";import{a as je,i as Me,n as Ne,o as Pe,r as Fe,t as Ie}from"./dialog-D68_yOhb.js";import{t as Le}from"./clipboard-DvCUPLwM.js";import{r as Re}from"./phone-app-C2rT__Vf.js";import{n as ze}from"./use-media-query-BF42EuKk.js";var Be=ce(`corner-left-up`,[[`path`,{d:`M14 9 9 4 4 9`,key:`1af5af`}],[`path`,{d:`M20 20h-7a4 4 0 0 1-4-4V4`,key:`1blwi3`}]]),Ve=/^(?:\\\\\?\\)?[A-Za-z]:$/,He=/^(?:[\\/]{2}(?!\?[\\/])|\\\\\?\\UNC\\)[^\\/]+[\\/][^\\/]+$/i;function Ue(e){let t=e.replace(/[\\/]+$/,``);if(Ve.test(t)||He.test(t))return null;let n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));if(n<0)return null;if(n===0)return t.slice(0,1);let r=t.slice(0,n);return Ve.test(r)?t.slice(0,n+1):r}var R=n(),We=`x-apple.systempreferences:com.apple.preference.security?Privacy_FilesAndFolders`,z=`inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-foreground hover:bg-muted`;function Ge({path:e,selected:t,onSelect:n,onEnter:r,decorate:i,emptyHint:o,showHidden:s=!1}){let c=a(e,s),l=c.data?.parent??null,u=e===null?null:Ue(e);return(0,R.jsxs)(R.Fragment,{children:[c.data||c.isError?(0,R.jsx)(`p`,{"data-slot":`fs-breadcrumb`,className:`truncate font-mono text-meta text-soft-foreground`,title:c.data?.path??void 0,children:c.data?.path??``}):(0,R.jsx)(ke,{label:`Loading folder…`,"data-slot":`fs-breadcrumb`,children:(0,R.jsx)(Ae,{className:`my-[3px] h-3 w-48 max-w-full`})}),!c.isError&&c.data?.parent===null?(0,R.jsxs)(`p`,{"data-slot":`fs-root-hint`,className:`text-label text-soft-foreground`,children:[`This is the browse root. To browse elsewhere, change`,` `,(0,R.jsx)(`a`,{href:`/settings/global/projects`,className:`text-foreground underline underline-offset-4 hover:text-muted-foreground`,children:`Default browse folder in Settings → Projects`}),`.`]}):null,c.isError?(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-2`,children:[(0,R.jsx)(`p`,{"data-slot":`fs-error`,className:`min-w-0 break-words text-ui text-danger`,children:c.error instanceof Error?c.error.message:`could not list that folder`}),c.error instanceof m&&c.error.status===403?(0,R.jsx)(`p`,{"data-slot":`fs-privacy-hint`,className:`text-label text-soft-foreground`,children:`Allow it under Privacy & Security ▸ Files & Folders, then try again.`}):null,(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-label`,children:[u===null?null:(0,R.jsxs)(`button`,{type:`button`,"data-slot":`fs-error-back`,onClick:()=>r(u),className:z,children:[(0,R.jsx)(Be,{className:`size-3.5`,"aria-hidden":!0}),`Back`]}),c.error instanceof m&&c.error.status===403?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`a`,{"data-slot":`fs-privacy-settings`,href:We,target:`_blank`,rel:`noreferrer`,className:z,children:`Open Privacy Settings`}),(0,R.jsx)(`button`,{type:`button`,"data-slot":`fs-retry`,onClick:()=>void c.refetch(),className:z,children:`Try again`})]}):null]})]}):(0,R.jsxs)(`ul`,{"data-slot":`fs-listing`,className:`max-h-64 divide-y divide-border/60 overflow-y-auto overscroll-contain rounded-md border border-border`,children:[l===null?null:(0,R.jsx)(`li`,{className:`flex`,children:(0,R.jsxs)(`button`,{type:`button`,"data-slot":`fs-up`,onClick:()=>r(l),className:`flex flex-1 items-center gap-2 px-3 py-2 text-left text-ui hover:bg-muted`,children:[(0,R.jsx)(Be,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),`Up one level`]})}),(c.data?.dirs??[]).map(e=>(0,R.jsxs)(`li`,{className:`flex items-stretch`,children:[(0,R.jsxs)(`button`,{type:`button`,"data-slot":`fs-dir`,"aria-pressed":t?.path===e.path,onClick:()=>n(e),onDoubleClick:()=>r(e.path),className:C(`flex min-w-0 flex-1 items-center gap-2 px-3 py-2 text-left text-ui hover:bg-muted`,t?.path===e.path&&`bg-muted`),children:[(0,R.jsx)(Oe,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.name}),i?.(e)]}),(0,R.jsx)(`button`,{type:`button`,"data-slot":`fs-enter`,"aria-label":`Open ${e.name}`,onClick:()=>r(e.path),className:`flex shrink-0 items-center px-2.5 text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,R.jsx)(me,{className:`size-3.5`,"aria-hidden":`true`})})]},e.path)),c.data&&c.data.dirs.length===0?(0,R.jsx)(`li`,{className:`px-3 py-2 text-ui text-muted-foreground`,children:o}):null]}),c.data?.truncated?(0,R.jsx)(`p`,{"data-slot":`fs-truncated`,className:`text-meta text-muted-foreground`,children:`Too many folders to list — only the first ones are shown.`}):null]})}function Ke(e,t,n=!1){let r=a(e,n);return t?.path??r.data?.path??null}var B=e(t(),1),V=`Switch`,[qe,Je]=le(V),[Ye,H]=qe(V);function Xe(e){let{__scopeSwitch:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=ue({prop:n,defaultProp:i??!1,onChange:c,caller:V}),[m,h]=B.useState(null),[g,_]=B.useState(null),v={checked:f,setChecked:p,disabled:a,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:B.useRef(!1),required:l,defaultChecked:i,isFormControl:!m||!!o||!!m.closest(`form`),bubbleInput:g,setBubbleInput:_};return(0,R.jsx)(Ye,{scope:t,...v,children:it(d)?d(v):r})}var Ze=`SwitchTrigger`,Qe=B.forwardRef(({__scopeSwitch:e,onClick:t,...n},r)=>{let{control:i,form:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:p,bubbleInput:m}=H(Ze,e),h=de(r,u),g=B.useRef(c);return B.useEffect(()=>{let e=a?i?.ownerDocument.getElementById(a):i?.form;if(e instanceof HTMLFormElement){let t=()=>d(g.current);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[i,a,d]),(0,R.jsx)(N.button,{type:`button`,role:`switch`,"aria-checked":c,"aria-required":l,"data-state":at(c),"data-disabled":s?``:void 0,disabled:s,value:o,...n,ref:h,onClick:pe(t,e=>{d(e=>!e),m&&p&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})});Qe.displayName=Ze;var $e=B.forwardRef((e,t)=>{let{__scopeSwitch:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,R.jsx)(Xe,{__scopeSwitch:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Qe,{...d,ref:t,__scopeSwitch:n}),e&&(0,R.jsx)(rt,{__scopeSwitch:n})]})})});$e.displayName=V;var et=`SwitchThumb`,tt=B.forwardRef((e,t)=>{let{__scopeSwitch:n,...r}=e,i=H(et,n);return(0,R.jsx)(N.span,{"data-state":at(i.checked),"data-disabled":i.disabled?``:void 0,...r,ref:t})});tt.displayName=et;var nt=`SwitchBubbleInput`,rt=B.forwardRef(({__scopeSwitch:e,...t},n)=>{let{control:r,hasConsumerStoppedPropagationRef:i,checked:a,defaultChecked:o,required:s,disabled:c,name:l,value:u,form:d,bubbleInput:f,setBubbleInput:p}=H(nt,e),m=de(n,p),h=ge(a),g=fe(r);B.useEffect(()=>{let e=f;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=!i.current;if(h!==a&&n){let t=new Event(`click`,{bubbles:r});n.call(e,a),e.dispatchEvent(t)}},[f,h,a,i]);let _=B.useRef(a);return(0,R.jsx)(N.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:o??_.current,required:s,disabled:c,name:l,value:u,form:d,...t,tabIndex:-1,ref:m,style:{...t.style,...g,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})});rt.displayName=nt;function it(e){return typeof e==`function`}function at(e){return e?`checked`:`unchecked`}function ot({open:e,onOpenChange:t,providers:n,initialProvider:r}){let[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(r??n[0]??`claude`),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)(``),[m,h]=(0,B.useState)(!1),g=x(),_=f.trim();return(0,R.jsx)(Ie,{open:e,onOpenChange:t,children:(0,R.jsxs)(Ne,{"data-slot":`add-account-dialog`,className:`sm:max-w-lg`,children:[(0,R.jsxs)(je,{children:[(0,R.jsx)(Pe,{children:`Add agent account`}),(0,R.jsx)(Fe,{children:`The config folder this account uses. It does not have to exist yet — Connect signs in and the CLI creates it.`})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-ui`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Agent`}),(0,R.jsxs)(Se,{value:c,onValueChange:e=>l(e),children:[(0,R.jsx)(be,{size:`sm`,"aria-label":`Agent`,"data-slot":`add-account-provider`,"data-value":c,children:(0,R.jsx)(xe,{})}),(0,R.jsx)(ye,{position:`popper`,children:n.map(e=>(0,R.jsx)(_e,{value:e,children:e},e))})]})]}),(0,R.jsxs)(`label`,{className:`flex min-w-0 flex-1 items-center gap-2 text-ui`,children:[(0,R.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Name`}),(0,R.jsx)(L,{type:`text`,"aria-label":`Account name`,"data-slot":`add-account-label`,value:u,placeholder:`Work`,onChange:e=>d(e.target.value),className:`h-8 flex-1 text-ui`})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 text-ui`,children:[(0,R.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`Folder`}),(0,R.jsx)(L,{type:`text`,spellCheck:!1,autoComplete:`off`,"aria-label":`Config folder`,"data-slot":`add-account-dir`,value:f,placeholder:c===`codex`?`~/.codex-second`:c===`omp`?`~/.omp/agent-second`:`~/.claude-second`,onChange:e=>{p(e.target.value),s(null),g.reset()},className:`h-8 flex-1 font-mono text-label`}),(0,R.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`add-account-browse`,"aria-expanded":m,onClick:()=>h(e=>!e),children:m?`Hide folders`:`Browse…`})]}),(0,R.jsxs)(`p`,{className:`text-meta text-soft-foreground`,children:[`A `,(0,R.jsx)(`code`,{children:`~`}),` is kept as written and expanded when the agent runs.`]})]}),m?(0,R.jsx)(Ge,{path:i,selected:o,onSelect:e=>{s(e),p(e.path),g.reset()},onEnter:e=>{a(e),s(null),g.reset()},showHidden:!0,emptyHint:`No subfolders here — pick this folder by typing its path above.`}):null,g.isError?(0,R.jsx)(`p`,{"data-slot":`add-account-error`,className:`min-w-0 break-words text-ui text-danger`,children:g.error instanceof Error?g.error.message:`could not add that folder`}):null,(0,R.jsxs)(Me,{className:`min-w-0 sm:items-center sm:justify-end`,children:[(0,R.jsx)(P,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,R.jsx)(P,{"data-slot":`add-account-confirm`,disabled:_===``||g.isPending,onClick:()=>{_===``||g.isPending||g.mutate({provider:c,configDir:_,...u.trim()?{label:u.trim()}:{}},{onSuccess:()=>{t(!1),d(``),p(``),s(null),h(!1),E(`Account added — use Connect to sign in`)}})},children:g.isPending?`Adding…`:`Add account`})]})]})})}var U=e=>ne[e],W={claude:{mono:`C`},codex:{key:!0,mono:`X`,ring:!0},cursor:{mono:`Cu`},copilot:{mono:`Co`},opencode:{key:!0,mono:`O`},kimi:{mono:`K`,ring:!0},pi:{terminal:!0,mono:`π`},gemini:{terminal:!0,mono:`G`},antigravity:{terminal:!0,mono:`A`},junie:{terminal:!0,mono:`J`},omp:{terminal:!0,mono:`Ω`}},st=e=>new Set(Object.keys(W).filter(t=>W[t][e])),G=st(`terminal`),ct=st(`key`);function lt(e){let{mono:t,ring:n}=W[e];return{mono:t,color:`var(--runner-mark-${e})`,ring:n===!0}}function ut(e){if(e)try{return new URL(e).host}catch{return}}function dt(e,t,n,r){let i=U(n);switch(e){case`expired`:return t===`paste`?`That code expired. Codes are single-use and expire after a few minutes.`:`The code expired before it was approved.`;case`rejected`:return t===`key`?`The key was rejected by the provider.`:t===`paste`?`That code was not accepted. Codes are single-use and expire after a few minutes.`:`${i} did not accept the sign-in.`;case`account-mismatch`:return`Signed in as another account than ${r} used, so cezar kept the work paused rather than continue on someone else's plan.`;case`exited`:return t===`browser`?`The sign-in ended before you approved access.`:`${i} stopped the sign-in before it finished.`;case`not-installed`:return`${i} is not installed on the computer running cezar.`;case`timeout`:return t===`terminal`?`No sign-in was detected yet. Finish it in the terminal, then check again.`:`${i} did not confirm the sign-in within 15 minutes.`;case`unavailable`:return`${i} can't sign in from here. Run its sign-in on the computer running cezar.`;default:return`The sign-in did not finish.`}}function ft(e,t,n){let r={claude:`claude auth login`,codex:`codex login`,cursor:`agent login`,copilot:`copilot login`,opencode:`opencode auth login`,kimi:`kimi login`,pi:`pi /login`,gemini:`gemini`,antigravity:`agy`,junie:`junie`,omp:`omp`};if(n)return r[e];if(t){if(e===`claude`)return`CLAUDE_CONFIG_DIR=${t} claude auth login`;if(e===`codex`)return`CODEX_HOME=${t} codex login`}}function K({provider:e,small:t=!1,className:n}){let r=lt(e);return(0,R.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`runner-mark`,className:C(`inline-grid shrink-0 place-items-center font-sans font-bold`,t?`size-4 rounded-[4px] text-[9px]`:`size-[22px] rounded-md text-xs`,r.ring&&`shadow-[inset_0_0_0_1px_rgba(255,255,255,.25)]`,n),style:{background:r.color,color:`var(--runner-mark-ink)`},children:r.mono})}var pt=(0,B.createContext)(void 0),mt=()=>(0,B.useContext)(pt),ht=`(max-width: 767px)`,gt=(e,t)=>[...S.agentLogin(e,t),`start-error`],_t=()=>Promise.resolve(null);function q(e,t){let n=o(),i=O(e,t),a=D(e,t),c=r({queryKey:gt(e,t),queryFn:_t,enabled:!1,staleTime:1/0}).data??null,l=g().data?.profiles,u=l?.find(n=>n.provider===e&&n.id===t),d=u?.label??(t==="default"?`Default`:t),f=`${U(e)} · ${d}`,_=s().data?.capabilities?.localHandoff===!1||Re(),x=ze(ht),S=h(),C=b(),w=y(),T=r=>n.setQueryData(gt(e,t),r);return{session:i,news:a,startError:c,profiles:l,profile:u,account:d,who:f,remote:_,narrow:x,view:c?`failed`:p(i)?`signing`:i?.phase===`connected`?`success`:i?.phase===`failed`?`failed`:`expired`,start:S,recheck:w,reconnect:n=>{T(null),S.mutate({provider:e,...t==="default"?{}:{profileId:t},...n?{method:n}:{}},{onError:e=>T({message:e.message,...e instanceof m&&e.command?{command:e.command}:{}})})},checkAgain:()=>{w.mutate(t==="default"?`default:${e}`:t,{onSuccess:e=>{e.status.status===`connected`?E(`${f} is signed in. Resuming what waited on it…`):E(`${f} is still signed out. Finish the sign-in, then check again.`)},onError:e=>E(e.message,{tone:`danger`})})},stop:()=>{i?C.mutate(i):v(n,e,t),T(null)}}}function vt({provider:e,profileId:t,place:n,compact:r=!1,inSheet:i=!1,blocked:a,className:o}){let{session:s,news:c,profiles:l,profile:u,account:d,who:f,remote:p,narrow:m,view:h,startError:g,start:_,recheck:v,reconnect:y,checkAgain:b,stop:x}=q(e,t),S=mt(),[w,T]=(0,B.useState)(!1),[E,D]=(0,B.useState)(!1),O=e=>{T(!1),D(!0),y(e)},k=S?.switchTo?(0,R.jsx)(Mt,{provider:e,profileId:t,profiles:l??[],kind:S.kind,onSwitch:S.switchTo}):null,A=(0,R.jsxs)(P,{type:`button`,variant:`ghost`,size:`sm`,"aria-expanded":w,"data-action":`reconnect-more`,onClick:()=>T(e=>!e),children:[`More options`,w?(0,R.jsx)(ve,{"aria-hidden":`true`,className:`size-3.5`}):(0,R.jsx)(he,{"aria-hidden":`true`,className:`size-3.5`})]}),j=w?(0,R.jsx)(jt,{provider:e,command:s?.command??g?.command??ft(e,u?.configDir,u?.isDefault??t==="default"),checking:v.isPending,onCheck:b,onKey:ct.has(e)?()=>O(`key`):void 0}):null;if(h===`signing`&&s){let t=(0,R.jsx)(Ct,{session:s,who:f,remote:p,compact:r||m}),n=(0,R.jsx)(wt,{session:s,remote:p,stacked:m&&!i,onCheck:b,onRestart:()=>O(),onCancel:x,checking:v.isPending});return m&&!i?(0,R.jsxs)(`div`,{"data-slot":`reconnect-card`,"data-state":`signing`,"data-provider":e,className:C(J,yt,o),children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-ui font-semibold`,children:[(0,R.jsx)(I,{className:`size-3.5`}),(0,R.jsx)(K,{provider:e,small:!0}),`Signing in to `,f]}),(0,R.jsxs)(`div`,{className:`mt-2.5 flex flex-wrap gap-1.5`,children:[(0,R.jsx)(P,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>D(!0),children:`Show sign-in`}),(0,R.jsx)(P,{type:`button`,variant:`ghost`,size:`sm`,onClick:x,children:`Cancel`})]}),(0,R.jsx)(oe,{open:E,onOpenChange:D,children:(0,R.jsxs)(te,{side:`bottom`,"data-slot":`reconnect-sheet`,className:`rounded-t-2xl px-4 pt-3 pb-[max(1.5rem,env(safe-area-inset-bottom))]`,children:[(0,R.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto mb-3 h-1 w-9 rounded-full bg-muted`}),(0,R.jsxs)(ee,{className:`flex items-center gap-2 text-base`,children:[(0,R.jsx)(K,{provider:e}),`Reconnect `,f]}),(0,R.jsxs)(se,{className:`sr-only`,children:[`Finish signing in to `,f,`.`]}),t,(0,R.jsx)(`div`,{className:`mt-3 flex flex-col items-stretch gap-1.5`,children:n})]})})]}):(0,R.jsxs)(`div`,{"data-slot":`reconnect-card`,"data-state":`signing`,"data-provider":e,role:`group`,"aria-live":`polite`,"aria-label":`Signing in to ${f}`,className:C(J,yt,o),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,R.jsx)(I,{className:`mt-1 size-3.5`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:Y,children:[(0,R.jsx)(K,{provider:e,small:!0}),` Signing in to `,f]}),t]})]}),(0,R.jsx)(`div`,{className:bt,children:n})]})}if(h===`success`){let t=s?.resumed??c?.resumed;return(0,R.jsxs)(`div`,{"data-slot":`reconnect-card`,"data-state":`success`,"data-provider":e,role:`status`,className:C(J,`border-success/30 bg-success/5`,o),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,R.jsx)(M,{"aria-hidden":`true`,className:`mt-0.5 size-4 shrink-0 text-success-strong`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{className:Y,children:[f,` is signed in again`]}),n===`task`&&S?.parked===null?(0,R.jsx)(`div`,{className:X,children:`Continue the task to pick up where it stopped.`}):(0,R.jsxs)(`div`,{className:C(X,`flex items-center gap-1.5`),children:[(0,R.jsx)(I,{className:`size-3`}),n===`task`?`Continuing the run from the same session…`:n===`manager`?`Resuming this turn…`:`Resuming what waited on it…`]})]})]}),t?(0,R.jsx)(Nt,{account:d,resumed:t,compact:r}):null]})}if(h===`failed`){let t=g?.message??dt(s?.reason,s?.method,e,d);return(0,R.jsxs)(`div`,{"data-slot":`reconnect-card`,"data-state":`failed`,"data-provider":e,role:`alert`,className:C(J,o),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,R.jsx)(K,{provider:e}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:Y,children:[`Sign-in to `,f,` didn't finish`]}),(0,R.jsx)(`div`,{"data-slot":`reconnect-reason`,className:X,children:t})]})]}),(0,R.jsxs)(`div`,{className:C(bt,r&&`flex-col items-stretch`),children:[(0,R.jsx)(P,{type:`button`,variant:`contrast`,size:`sm`,"data-action":`reconnect-start`,disabled:_.isPending,onClick:()=>O(),children:`Try again`}),k,A]}),g?.command&&!w?(0,R.jsx)(Q,{command:g.command,label:`Run this on the computer running cezar:`}):null,j]})}let ne=G.has(e)&&!p;return(0,R.jsxs)(`div`,{"data-slot":`reconnect-card`,"data-state":`expired`,"data-provider":e,role:`group`,"aria-label":`${f} is signed out`,className:C(J,o),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,R.jsx)(K,{provider:e}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:Y,children:[f,` is signed out`,(0,R.jsx)(`span`,{"data-slot":`reconnect-pill`,className:C(Z,`border-danger/35 bg-danger/10 text-danger-strong`),children:`Login expired`})]}),(0,R.jsx)(`div`,{className:X,children:n===`task`&&S?.parked===null?`The run stopped when the login expired. Reconnect, then Continue the task.`:n===`task`?`The run paused at its first request after the login expired. Reconnect and it continues from the same session.`:n===`manager`?`This turn stopped before answering. Reconnect and it picks up where it stopped.`:`Reconnect and everything waiting on it resumes.`})]})]}),(0,R.jsxs)(`div`,{className:C(bt,r&&`flex-col items-stretch`),children:[(0,R.jsxs)(P,{type:`button`,variant:`contrast`,size:`sm`,"data-action":`reconnect-start`,disabled:_.isPending,onClick:()=>O(),children:[_.isPending?(0,R.jsx)(I,{className:`size-3`}):null,ne?(0,R.jsxs)(R.Fragment,{children:[`Sign in to `,d,` `,(0,R.jsx)(F,{"aria-hidden":`true`,className:`size-3`})]}):(0,R.jsxs)(R.Fragment,{children:[`Reconnect `,d]})]}),k,A]}),j,a&&!r?(0,R.jsxs)(`div`,{"data-slot":`reconnect-blocked`,className:`mt-2.5 flex flex-wrap items-center gap-1.5 text-micro text-soft-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`size-1.5 rounded-full bg-pending`}),a]}):null]})}var J=`mt-2 max-w-[640px] rounded-[10px] border border-danger/30 bg-danger/5 px-3.5 py-3 transition-colors`,yt=`border-border bg-card`,Y=`flex flex-wrap items-center gap-1.5 text-ui font-semibold text-foreground`,X=`mt-0.5 text-xs text-muted-foreground`,bt=`mt-2.5 flex flex-wrap items-center gap-1.5`,Z=`inline-flex h-[18px] items-center rounded-full border px-1.5 text-micro font-semibold tracking-[.02em] whitespace-nowrap`;function xt({provider:e,profileId:t,at:n,signedOutHere:r=!1}){let i=St(e,t??`default`),a=e?` ${U(e)} · ${i}`:``,o=n?new Date(n):void 0,s=o&&Number.isFinite(o.getTime())?o.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}):void 0;return(0,R.jsx)(`p`,{"data-slot":`reconnected-line`,"data-state":r?`older`:`reconnected`,className:`mt-1.5 flex items-center gap-1.5 text-label text-muted-foreground`,children:r?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),a.trim(),` was signed out here`]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(M,{"aria-hidden":`true`,className:`size-3.5 text-success-strong`}),`Reconnected`,a,` · resumed`,s?(0,R.jsxs)(R.Fragment,{children:[` at `,(0,R.jsx)(`time`,{dateTime:n,children:s})]}):null]})})}function St(e,t){return(g().data?.profiles)?.find(n=>n.provider===e&&n.id===t)?.label??(t==="default"?`Default`:t)}function Ct({session:e,who:t,remote:n,compact:r,stepsLabel:i=`resume`}){let a=U(e.provider),s=ut(e.url),c=o();if(e.phase===`starting`)return(0,R.jsxs)(`p`,{className:X,children:[`Starting `,a,`'s sign-in…`]});if(e.phase===`verifying`)return(0,R.jsx)(Tt,{steps:[[`done`,`Sign-in finished`],[`now`,`Verifying the account`],[`todo`,i===`resume`?`Resume`:`Ready`]]});switch(e.method){case`browser`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:X,children:[`Open this link in the browser and profile you sign in to `,a,` with, then approve access. `,i===`resume`?`This card`:`This dialog`,` updates by itself.`]}),e.url?(0,R.jsx)(Q,{command:e.url,copyLabel:`Copy link`}):null,(0,R.jsx)(Tt,{steps:[[`done`,`Sign-in started`],[`now`,`Approve in your browser`],[`todo`,i===`resume`?`Verify & resume`:`Verify`]]})]});case`link`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:X,children:[`Open the `,a,` sign-in `,n?`on this or any device`:`in your browser`,` and approve. `,a,` confirms it to cezar directly, with no callback to this computer.`]}),e.url?(0,R.jsx)(Q,{command:e.url,copyLabel:`Copy link`}):null]});case`device`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:X,children:[`Enter this code at `,(0,R.jsx)(`b`,{className:`font-semibold text-foreground`,children:s??`the sign-in page`}),n?`, on this or any device`:``,`.`]}),e.userCode?(0,R.jsx)(Et,{code:e.userCode,expiresAt:e.expiresAt}):(0,R.jsx)(`p`,{className:X,children:`Waiting for the code…`})]});case`paste`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Tt,{steps:[[`done`,`Sign-in started`],[`now`,`Approve & copy the code`],[`todo`,`Paste it here`]]}),(0,R.jsxs)(`p`,{className:C(X,`mt-2`),children:[`1. Open the sign-in link on `,r?`this phone`:`any device`,` and approve. `,a,` then shows a one-time code.`,(0,R.jsx)(`br`,{}),`2. Paste that code here. It goes straight to `,a,` on your computer.`]}),(0,R.jsx)(Ot,{session:e,kind:`code`,placeholder:`Paste the code from ${a}`,submitLabel:`Sign in`,onAnswer:e=>l(c,e)})]});case`key`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:X,children:e.provider===`opencode`?`Paste an API key for the provider this account used. It goes straight into OpenCode's own credential store; cezar doesn't keep it.`:`Paste an OpenAI API key. Codex stores it in this account's folder; cezar doesn't keep it.`}),ct.has(e.provider)?(0,R.jsx)(Ot,{session:e,kind:`key`,placeholder:`sk-…`,submitLabel:`Save & sign in`,keyProviders:e.provider===`opencode`?e.keyProviders:void 0,onAnswer:e=>l(c,e)}):null]});case`terminal`:return n?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:X,children:[a,` can only sign in on the computer running cezar. Run this there, then come back:`]}),e.command?(0,R.jsx)(Q,{command:e.command}):null]}):(0,R.jsxs)(`p`,{className:X,children:[a,` signs in only in its own window. We opened it in a terminal; finish there and this card notices by itself.`]})}return(0,R.jsxs)(`p`,{className:X,children:[`Signing in to `,t,`…`]})}function wt({session:e,remote:t,stacked:n,checking:r,onCheck:i,onRestart:a,onCancel:o}){let s=ut(e.url),c=e.url?()=>kt(e.url):void 0,l=n?`default`:`sm`,u=null;if(e.method===`browser`&&c)u=(0,R.jsxs)(P,{type:`button`,variant:`outline`,size:l,onClick:c,children:[`Open in default browser `,(0,R.jsx)(F,{"aria-hidden":`true`,className:`size-3`})]});else if(e.method===`link`&&c)u=(0,R.jsxs)(P,{type:`button`,variant:n?`contrast`:`outline`,size:l,onClick:c,children:[`Open `,U(e.provider),` sign-in `,(0,R.jsx)(F,{"aria-hidden":`true`,className:`size-3`})]});else if(e.method===`device`&&c){let t=e.userCode;u=n&&t?(0,R.jsxs)(P,{type:`button`,variant:`contrast`,size:l,onClick:()=>{Le(t).catch(()=>{}),c()},children:[`Copy code & open `,s,` `,(0,R.jsx)(F,{"aria-hidden":`true`,className:`size-3`})]}):(0,R.jsxs)(P,{type:`button`,variant:`outline`,size:l,onClick:c,children:[`Open `,s,` `,(0,R.jsx)(F,{"aria-hidden":`true`,className:`size-3`})]})}else e.method===`paste`&&c?u=(0,R.jsxs)(P,{type:`button`,variant:`outline`,size:l,onClick:c,children:[`Open sign-in link `,(0,R.jsx)(F,{"aria-hidden":`true`,className:`size-3`})]}):e.method===`terminal`&&(u=t?(0,R.jsx)(P,{type:`button`,variant:`outline`,size:l,disabled:r,onClick:i,children:`I've signed in · Check`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P,{type:`button`,variant:`outline`,size:l,onClick:a,children:`Open again`}),(0,R.jsx)(P,{type:`button`,variant:`outline`,size:l,disabled:r,onClick:i,children:`I've signed in`})]}));return(0,R.jsxs)(R.Fragment,{children:[u,(0,R.jsx)(P,{type:`button`,variant:`ghost`,size:l,"data-action":`reconnect-cancel`,onClick:o,children:`Cancel`})]})}function Tt({steps:e}){return(0,R.jsx)(`ol`,{"data-slot":`reconnect-steps`,className:`mt-2.5 flex flex-wrap gap-3.5 text-micro text-soft-foreground`,children:e.map(([e,t])=>(0,R.jsxs)(`li`,{"data-state":e,className:C(`flex items-center gap-1`,e===`done`&&`text-success-strong`,e===`now`&&`text-foreground`),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:e===`done`?`✓`:e===`now`?`●`:`○`}),t]},t))})}function Et({code:e,expiresAt:t}){let n=Dt(t);return(0,R.jsxs)(`div`,{"data-slot":`reconnect-device`,className:`mt-2.5 flex flex-wrap items-center gap-2.5`,children:[(0,R.jsx)(`span`,{"aria-label":`One-time code`,className:`rounded-lg border border-border bg-background px-3 py-1.5 font-mono text-xl font-semibold tracking-[.18em]`,children:e}),(0,R.jsx)(At,{text:e,label:`Copy code`,variant:`outline`}),n===void 0?null:(0,R.jsxs)(`span`,{className:`text-label text-muted-foreground`,children:[`Expires in `,(0,R.jsx)(`span`,{"data-slot":`reconnect-countdown`,className:`font-mono`,children:n})]})]})}function Dt(e){let[t,n]=(0,B.useState)(()=>Date.now());if((0,B.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),!e)return;let r=Date.parse(e);if(!Number.isFinite(r))return;let i=Math.max(0,r-t);return`${Math.floor(i/6e4)}:${String(Math.floor(i/1e3)%60).padStart(2,`0`)}`}function Ot({session:e,kind:t,placeholder:n,submitLabel:r,keyProviders:i,onAnswer:a}){let o=(0,B.useRef)(null),[s,c]=(0,B.useState)(),l=s!==void 0&&i?.includes(s)?s:i?.[0],[u,f]=(0,B.useState)(!1);return(0,R.jsxs)(`form`,{"data-slot":`reconnect-secret`,onSubmit:n=>{n.preventDefault();let r=o.current,i=r?.value.trim()??``;r&&(r.value=``),i&&(f(!0),d(e.sessionId,t===`code`?{code:i}:{apiKey:i,...l?{keyProvider:l}:{}}).then(a).catch(e=>E(e instanceof Error?e.message:String(e),{tone:`danger`})).finally(()=>f(!1)))},className:`mt-2 flex flex-wrap gap-1.5`,children:[i&&i.length>0?(0,R.jsxs)(Se,{value:l,onValueChange:c,children:[(0,R.jsx)(be,{size:`sm`,"aria-label":`Provider`,"data-slot":`reconnect-key-provider`,className:`h-[30px] text-xs`,children:(0,R.jsx)(xe,{})}),(0,R.jsx)(ye,{children:i.map(e=>(0,R.jsx)(_e,{value:e,children:e},e))})]}):null,(0,R.jsx)(`input`,{ref:o,type:`password`,autoComplete:`off`,spellCheck:!1,"aria-label":t===`code`?`One-time code`:`API key`,placeholder:n,className:`h-[30px] min-w-[140px] flex-1 rounded-sm border border-border bg-background px-2.5 text-sm text-foreground outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/30`}),(0,R.jsx)(P,{type:`submit`,variant:`contrast`,size:`sm`,disabled:u,children:r})]})}function kt(e){window.open(e,`_blank`,`noopener,noreferrer`)}function At({text:e,label:t,variant:n=`ghost`}){let[r,i]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{if(!r)return;let e=setTimeout(()=>i(!1),1200);return()=>clearTimeout(e)},[r]),(0,R.jsx)(P,{type:`button`,variant:n,size:`sm`,onClick:()=>Le(e).then(()=>i(!0),()=>E(`Could not copy`,{tone:`danger`})),children:r?`Copied`:t})}function Q({command:e,label:t,copyLabel:n=`Copy`}){return(0,R.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5`,children:[t?(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t}):null,(0,R.jsxs)(`div`,{"data-slot":`reconnect-command`,className:`flex max-w-full items-center gap-1.5 rounded-lg border border-border bg-background py-1 pr-1 pl-2`,children:[(0,R.jsx)(`code`,{className:`min-w-0 flex-1 overflow-auto font-mono text-xs whitespace-nowrap`,children:e}),(0,R.jsx)(At,{text:e,label:n})]})]})}function jt({provider:e,command:t,checking:n,onCheck:r,onKey:i}){let a=`h-auto p-0 font-medium text-foreground underline underline-offset-2 hover:no-underline`;return(0,R.jsxs)(`div`,{"data-slot":`reconnect-more`,className:`mt-2.5 flex flex-col gap-2 border-t border-dashed border-border pt-2.5 text-xs`,children:[(0,R.jsx)(`button`,{type:`button`,"data-action":`reconnect-check`,disabled:n,onClick:r,className:C(a,`self-start disabled:opacity-50`),children:`Already signed in? Check again`}),i?(0,R.jsx)(`button`,{type:`button`,"data-action":`reconnect-key`,onClick:i,className:C(a,`self-start`),children:`Sign in with an API key instead`}):null,(0,R.jsx)(T,{to:`/settings/global/accounts`,className:C(a,`self-start`),children:`Open Settings → Agent accounts`}),t?(0,R.jsx)(Q,{command:t,label:`Last resort, on the machine running cezar (${U(e)}):`}):null]})}function Mt({provider:e,profileId:t,profiles:n,kind:r,onSwitch:i}){let[a,o]=(0,B.useState)(!1),s=en(),c=n.filter(t=>t.provider===e&&!t.pending),l=c.filter(e=>e.id!==t),u=s?.capable.includes(e)??!1;if(l.length===0&&!u)return null;let d=e=>e.status?.status!==`disconnected`&&e.status?.status!==`not-installed`,f=l.find(e=>e.status?.status===`connected`)??l.find(d),p=e=>{o(!0),i(e).catch(e=>E(e instanceof Error?e.message:String(e),{tone:`danger`})).finally(()=>o(!1))};return(0,R.jsxs)(`span`,{"data-slot":`reconnect-switch`,className:`inline-flex`,children:[f?(0,R.jsxs)(P,{type:`button`,variant:`outline`,size:`sm`,"data-action":`reconnect-switch`,disabled:a,className:`rounded-r-none border-r-0`,onClick:()=>p(f.id),children:[`Use `,f.label,` instead`]}):null,(0,R.jsxs)(De,{children:[(0,R.jsx)(Te,{asChild:!0,children:(0,R.jsxs)(P,{type:`button`,variant:`outline`,size:`sm`,"aria-label":f?`Accounts to switch to`:void 0,disabled:a,className:C(f&&`rounded-l-none px-1.5`),children:[f?null:`Use another account`,(0,R.jsx)(he,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,R.jsxs)(Ee,{align:`start`,className:`min-w-60`,children:[(0,R.jsxs)(Ce,{className:`text-micro tracking-[.06em] text-soft-foreground uppercase`,children:[`Accounts this `,r,` may use`]}),c.map(n=>{let r=n.id===t?`disconnected`:n.status?.status;return(0,R.jsxs)(we,{"data-account":n.id,disabled:n.id===t||!d(n),onSelect:()=>p(n.id),children:[(0,R.jsx)(K,{provider:e,small:!0}),U(e),` · `,n.label,r===`connected`?(0,R.jsx)(`span`,{className:C(Z,`ml-auto border-success/35 bg-success/10 text-success-strong`),children:`Signed in`}):r===`disconnected`?(0,R.jsx)(`span`,{className:C(Z,`ml-auto border-danger/35 bg-danger/10 text-danger-strong`),children:`Signed out`}):r===`not-installed`?(0,R.jsx)(`span`,{className:C(Z,`ml-auto`),children:`Not installed`}):null]},n.id)}),u&&s?(0,R.jsx)(we,{"data-action":`reconnect-add-account`,onSelect:()=>s.open({provider:e,onAdded:e=>p(e.id)}),children:`Add an account…`}):null,(0,R.jsx)(`p`,{className:`px-2 py-1.5 text-micro text-soft-foreground`,children:r===`task`?`Switching account starts a fresh session; the task keeps its worktree and changes.`:`The manager keeps its memory; the next turn starts a fresh transcript.`})]})]})]})}function Nt({account:e,resumed:t,compact:n}){let r=mt()?.ownId,i={runs:t.runs.filter(e=>e.runId!==r),managers:t.managers.filter(e=>e.managerId!==r)};return i.runs.length+i.managers.length===0?null:n?(0,R.jsxs)(`p`,{"data-slot":`reconnect-resumed`,className:`mt-2.5 flex items-center gap-1.5 text-micro text-soft-foreground`,children:[(0,R.jsx)(I,{className:`size-2.5`}),`Also resuming on `,e,`: `,Pt(i.runs.length,`task`),i.runs.length&&i.managers.length?` · `:``,Pt(i.managers.length,`manager`)]}):(0,R.jsxs)(`div`,{"data-slot":`reconnect-resumed`,className:`mt-2.5 flex flex-col gap-2 border-t border-dashed border-border pt-2.5 text-xs`,children:[(0,R.jsxs)(`p`,{children:[`Also resuming on `,e,`:`]}),(0,R.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[i.runs.map(e=>(0,R.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(I,{className:`size-2.5`}),(0,R.jsxs)(T,{to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.runId)}`,className:`underline underline-offset-2`,children:[`Task “`,e.title,`”`]})]},`${e.projectId}/${e.runId}`)),i.managers.map(e=>(0,R.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(I,{className:`size-2.5`}),(0,R.jsxs)(T,{to:`/manager/${encodeURIComponent(e.managerId)}`,className:`underline underline-offset-2`,children:[`Manager “`,e.title,`”`]}),(0,R.jsx)(`span`,{className:`text-soft-foreground`,children:`· chat turn`})]},e.managerId))]}),(0,R.jsx)(`p`,{className:`text-micro text-soft-foreground`,children:`Watch checks run on their next tick.`})]})}var Pt=(e,t)=>e===0?``:`${e} ${t}${e===1?``:`s`}`;function Ft({className:e,size:t=`default`,...n}){return(0,R.jsx)($e,{"data-slot":`switch`,"data-size":t,className:C(`peer group/switch inline-flex shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 data-[size=default]:h-[1.15rem] data-[size=default]:w-8 data-[size=sm]:h-3.5 data-[size=sm]:w-6 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input`,e),...n,children:(0,R.jsx)(tt,{"data-slot":`switch-thumb`,className:C(`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0`)})})}var It=e=>e.consumers.reduce((e,t)=>e+t.estimatePp,0);function Lt(e,t){return e?.windows.find(e=>e.current&&e.account.key===t)}function Rt(e){return`${new Date(e).toLocaleDateString(void 0,{weekday:`short`,day:`numeric`,month:`short`})} ${ae(e)}`}function zt(e){return!e||!e.usedPercent?`no reading yet`:`${A(e.usedPercent.last)} used · resets ${ae(e.resetsAt)} · cezar tasks and managers ${k(It(e))} of it, outside cezar ${A(e.outsideCezarPp)}${Vt(e)}`}function Bt(e){return!e||!e.usedPercent?`no reading yet`:`${A(e.usedPercent.last)} used · resets ${Rt(e.resetsAt)} · this week: cezar ${k(It(e))}, outside cezar ${A(e.outsideCezarPp)}${Vt(e)}`}function Vt(e){let t=[e.beforeTrackingPp>0?`before tracking ${A(e.beforeTrackingPp)}`:``,e.untrackedPp>0?`not tracked ${A(e.untrackedPp)}`:``,e.unsplitPp>0?`couldn't split ${A(e.unsplitPp)}`:``,e.correctionPp>0?`provider correction −${A(e.correctionPp)}`:``].filter(Boolean);return t.length?`, ${t.join(`, `)}`:``}function Ht({provider:e,accountId:t}){let n=`${e}:${t}`,r=(0,B.useId)(),i=ie({kind:`five-hour`,account:n}),a=ie({kind:`weekly`,account:n}),o=re(),s=j(),c=o.data?.enabled===!1,l=!c&&o.data?.accounts[n]!==!1,u=o.data?.retentionDays??90;return(0,R.jsxs)(`div`,{"data-slot":`account-plan-usage`,className:`mt-3 flex flex-col gap-2 border-t border-border/60 pt-2.5 text-label`,children:[(0,R.jsxs)(`dl`,{className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-x-3 gap-y-1`,children:[(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`5-hour limit`}),(0,R.jsx)(`dd`,{"data-slot":`account-plan-five-hour`,className:`min-w-0 text-foreground tabular-nums`,children:i.isPending?`Reading…`:i.isError?`unavailable`:zt(Lt(i.data,n))}),(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:`Weekly limit`}),(0,R.jsx)(`dd`,{"data-slot":`account-plan-weekly`,className:`min-w-0 text-foreground tabular-nums`,children:a.isPending?`Reading…`:a.isError?`unavailable`:Bt(Lt(a.data,n))})]}),(0,R.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,R.jsx)(Ft,{id:r,"data-slot":`account-plan-tracking`,checked:l,disabled:c||o.isPending||s.isPending,onCheckedChange:e=>s.mutate({account:n,enabled:e},{onError:e=>E(e.message,{tone:`danger`})})}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`label`,{htmlFor:r,className:`font-medium text-foreground`,children:`Track plan limit usage`}),(0,R.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Saves the limit readings on this computer (no prompts or code) so cezar can show which tasks used them. Kept `,u,` days.`]}),c?(0,R.jsx)(`p`,{"data-slot":`account-plan-tracking-off`,className:`mt-0.5 text-muted-foreground`,children:o.data?.reason??`Turned off on this computer (CEZ_USAGE_LOG=0).`}):null]})]})]})}function Ut({open:e,onOpenChange:t,providers:n,initialProvider:r,onAdvanced:i,resume:a,onAdded:o}){let s=ze(ht),[c,l]=(0,B.useState)(a?.provider??(r&&n.includes(r)?r:n[0]??`claude`)),[u,d]=(0,B.useState)(``),[p,m]=(0,B.useState)(a??null),[h,g]=(0,B.useState)(a?`signing`:`pick`),[_,v]=(0,B.useState)(!1),y=x(),b=f(),S=()=>t(!1),C=()=>{h===`signing`&&p?v(!0):S()},w=()=>{if(!p)return S();b.mutate(p.id,{onSettled:()=>{v(!1),S()},onError:e=>E(e.message,{tone:`danger`})})},T=()=>{y.isPending||y.mutate({provider:c,managed:!0,...u.trim()?{label:u.trim()}:{}},{onSuccess:({profile:e})=>{m(e),g(`signing`)}})},D=h===`pick`?0:h===`signing`?1:2,O=(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(K,{provider:p?.provider??c}),`Add agent account`]})}),k;h===`pick`?k=(0,R.jsx)(Kt,{providers:n,provider:c,onProvider:e=>{l(e),y.reset()},label:u,onLabel:e=>{d(e),y.reset()},error:y.error?Wt(y.error):null,pending:y.isPending,narrow:s,onCancel:S,onContinue:T,onAdvanced:i}):p&&h===`signing`?k=_?(0,R.jsx)(Jt,{account:p,busy:b.isPending,onKeep:()=>v(!1),onDiscard:w,narrow:s}):(0,R.jsx)(qt,{account:p,narrow:s,onSignedIn:()=>g(`ready`),onCancel:()=>v(!0)}):p&&(k=(0,R.jsx)(Xt,{account:p,narrow:s,onDone:e=>{e&&o?.(p),S()},onRemove:w,removing:b.isPending}));let A=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Gt,{index:D}),k]});return s?(0,R.jsx)(oe,{open:e,onOpenChange:e=>e?t(!0):C(),children:(0,R.jsxs)(te,{side:`bottom`,"data-slot":`add-account-wizard`,className:`max-h-[92dvh] overflow-y-auto rounded-t-2xl px-4 pt-3 pb-[max(1.5rem,env(safe-area-inset-bottom))]`,children:[(0,R.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto mb-3 h-1 w-9 rounded-full bg-muted`}),(0,R.jsx)(ee,{className:`text-base`,children:O}),(0,R.jsx)(se,{className:`sr-only`,children:`Sign in to a new agent account.`}),A]})}):(0,R.jsx)(Ie,{open:e,onOpenChange:e=>e?t(!0):C(),children:(0,R.jsxs)(Ne,{"data-slot":`add-account-wizard`,className:`sm:max-w-lg`,children:[(0,R.jsx)(Pe,{children:O}),(0,R.jsx)(Fe,{className:`sr-only`,children:`Sign in to a new agent account.`}),A]})})}function Wt(e){return e instanceof m?e.message:e.message||`Could not add the account.`}function Gt({index:e}){return(0,R.jsx)(`ol`,{"data-slot":`add-account-steps`,className:`flex gap-1.5 text-micro text-soft-foreground`,children:[`Agent`,`Sign in`,`Ready`].map((t,n)=>(0,R.jsxs)(`li`,{"data-state":n<e?`done`:n===e?`now`:`todo`,className:C(`flex flex-1 items-center gap-1 border-t-2 border-muted pt-1.5`,n<e&&`border-success text-success-strong`,n===e&&`border-foreground text-foreground`),children:[n<e?(0,R.jsx)(M,{"aria-hidden":`true`,className:`size-3`}):(0,R.jsx)(`span`,{"aria-hidden":`true`,children:n+1}),t]},t))})}function $({narrow:e,children:t}){return(0,R.jsx)(`div`,{className:C(`mt-2 flex gap-2`,e?`flex-col-reverse items-stretch`:`items-center justify-end`),children:t})}function Kt({providers:e,provider:t,onProvider:n,label:r,onLabel:i,error:a,pending:o,narrow:s,onCancel:c,onContinue:l,onAdvanced:u}){return(0,R.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Agent`,className:C(`grid gap-2`,s?`grid-cols-1`:`grid-cols-2`),children:e.map(e=>(0,R.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":e===t,"data-provider":e,onClick:()=>n(e),className:C(`flex items-start gap-2.5 rounded-lg border border-border bg-card px-3 py-2 text-left text-ui`,e===t&&`border-ring ring-[3px] ring-ring/25`),children:[(0,R.jsx)(K,{provider:e}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[(0,R.jsx)(`span`,{className:`block font-medium`,children:U(e)}),(0,R.jsx)(`span`,{className:`block text-micro text-soft-foreground`,children:G.has(e)?`Signs in in a terminal`:`Signs in through its web page`})]})]},e))}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-muted-foreground`,children:[`Account name`,(0,R.jsx)(L,{type:`text`,"data-slot":`add-account-name`,value:r,placeholder:`Work`,maxLength:200,onChange:e=>i(e.target.value),className:`h-9 text-base md:text-sm`})]}),a?(0,R.jsx)(`p`,{"data-slot":`add-account-error`,role:`alert`,className:`text-ui text-danger`,children:a}):null,u?(0,R.jsx)(`button`,{type:`button`,"data-action":`add-account-advanced`,onClick:u,className:`self-start text-xs text-muted-foreground underline underline-offset-2 hover:no-underline`,children:`Advanced: use a folder that is already signed in`}):null,(0,R.jsxs)($,{narrow:s,children:[(0,R.jsx)(P,{type:`button`,variant:`ghost`,onClick:c,children:`Cancel`}),(0,R.jsxs)(P,{type:`submit`,variant:`contrast`,"data-action":`add-account-continue`,disabled:o,children:[o?(0,R.jsx)(I,{className:`size-3`}):null,`Continue · sign in`]})]})]})}function qt({account:e,narrow:t,onSignedIn:n,onCancel:r}){let{session:i,view:a,startError:s,remote:c,who:l,start:u,recheck:d,reconnect:f,checkAgain:p,stop:m}=q(e.provider,e.id),h=o(),g=(0,B.useRef)(!1);(0,B.useEffect)(()=>{g.current||(g.current=!0,f())},[]),(0,B.useEffect)(()=>{a===`success`&&(h.invalidateQueries({queryKey:S.agentProfiles}),n())},[a]);let _=()=>{m(),r()};if(a===`failed`){let n=s?.message??dt(i?.reason,i?.method,e.provider,e.label);return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`div`,{"data-slot":`add-account-failed`,role:`alert`,className:`rounded-lg border border-danger/30 bg-danger/5 px-3 py-2 text-ui`,children:[(0,R.jsxs)(`b`,{className:`font-semibold`,children:[`Sign-in to `,l,` didn't finish.`]}),` `,(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:n})]}),(0,R.jsxs)($,{narrow:t,children:[(0,R.jsx)(P,{type:`button`,variant:`ghost`,onClick:_,children:`Cancel`}),(0,R.jsx)(P,{type:`button`,variant:`contrast`,"data-action":`add-account-retry`,disabled:u.isPending,onClick:()=>f(),children:i?.reason===`expired`?`Get a new code`:`Try again`})]})]})}return(0,R.jsxs)(`div`,{"data-slot":`add-account-signing`,className:`flex flex-col gap-3`,children:[i?(0,R.jsx)(Ct,{session:i,who:l,remote:c,compact:t,stepsLabel:`verify`}):(0,R.jsxs)(`p`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,R.jsx)(I,{className:`size-3`}),`Creating a private folder and starting `,U(e.provider),`'s sign-in…`]}),(0,R.jsx)($,{narrow:t,children:i?(0,R.jsx)(wt,{session:i,remote:c,stacked:t,checking:d.isPending,onCheck:p,onRestart:()=>f(),onCancel:_}):(0,R.jsx)(P,{type:`button`,variant:`ghost`,onClick:_,children:`Cancel`})})]})}function Jt({account:e,busy:t,narrow:n,onKeep:r,onDiscard:i}){return(0,R.jsxs)(`div`,{"data-slot":`add-account-cancel`,className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`p`,{className:`text-ui`,children:[(0,R.jsxs)(`b`,{className:`font-semibold`,children:[`Stop adding `,U(e.provider),` · `,e.label,`?`]}),(0,R.jsx)(`br`,{}),(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[`The sign-in stops and the folder cezar made for it is deleted. Your other `,U(e.provider),` logins are not touched.`]})]}),(0,R.jsxs)($,{narrow:n,children:[(0,R.jsx)(P,{type:`button`,variant:`ghost`,onClick:r,children:`Keep signing in`}),(0,R.jsx)(P,{type:`button`,variant:`destructive`,"data-action":`add-account-discard`,disabled:t,onClick:i,children:`Stop & delete`})]})]})}var Yt=e=>e?.find(e=>e.label===`Email`)?.value.trim().toLowerCase()||void 0;function Xt({account:e,narrow:t,removing:n,onDone:r,onRemove:a}){let o=g().data,s=u(w(e),!0),l=i(),[d,f]=(0,B.useState)(!1),p=o?.hostPaths!==!1,m=(o?.profiles??[]).filter(t=>t.provider===e.provider&&t.id!==e.id&&!t.pending),h=c({queries:m.map(e=>({queryKey:S.agentAccountDetails(w(e)),queryFn:({signal:t})=>_(w(e),{signal:t}),staleTime:0,retry:!1}))}),v=s.data?.available?Yt(s.data.fields):void 0,y=v===void 0?-1:h.findIndex(e=>e.data?.available&&Yt(e.data.fields)===v),b=y>=0?m[y]:void 0,x=`${U(e.provider)} · ${e.label}`;return(0,R.jsxs)(`div`,{"data-slot":`add-account-ready`,className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 rounded-lg border border-success/30 bg-success/5 px-3 py-2 text-ui`,children:[(0,R.jsx)(M,{"aria-hidden":`true`,className:`size-4 shrink-0 text-success-strong`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`b`,{className:`font-semibold`,children:x}),` is signed in and ready.`]})]}),b?(0,R.jsxs)(`div`,{"data-slot":`add-account-duplicate`,className:`rounded-lg border border-pending/35 bg-pending/5 px-3 py-2 text-ui`,children:[(0,R.jsxs)(`b`,{className:`font-semibold`,children:[`This is the same login as “`,b.label,`”`]}),` `,(0,R.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,v,`). Two accounts on one login share one subscription and its limits.`]})]}):null,s.isPending?(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`Reading account details…`}):s.data?.available?(0,R.jsx)(`dl`,{"data-slot":`add-account-identity`,className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-x-3 gap-y-1 text-label`,children:s.data.fields.map(e=>(0,R.jsxs)(B.Fragment,{children:[(0,R.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all`,children:e.value})]},e.label))}):s.data?.reason?(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:s.data.reason}):null,e.provider===`claude`||e.provider===`codex`?(0,R.jsx)(Ht,{provider:e.provider,accountId:e.id}):null,p?(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-ui`,children:[(0,R.jsx)(`input`,{type:`checkbox`,"data-slot":`add-account-default`,checked:d,onChange:e=>f(e.target.checked)}),`Use it for projects that have not picked a `,U(e.provider),` account`]}):null,(0,R.jsxs)($,{narrow:t,children:[b?(0,R.jsx)(P,{type:`button`,variant:`ghost`,"data-action":`add-account-remove-duplicate`,disabled:n,onClick:a,children:`Remove this one`}):null,(0,R.jsx)(P,{type:`button`,variant:`contrast`,"data-action":`add-account-done`,disabled:l.isPending,onClick:()=>{if(!d)return r(!0);l.mutate({projectId:null,provider:e.provider,profileId:e.id},{onSuccess:()=>r(!0),onError:e=>E(e.message,{tone:`danger`})})},children:b?`Keep both`:`Done`})]})]})}var Zt=(0,B.createContext)(null),Qt=[];function $t(){let e=g().data;return e?.editable?e.profileCapableProviders??Qt:Qt}function en(){let e=(0,B.useContext)(Zt),t=$t();return(0,B.useMemo)(()=>e&&t.length>0?{capable:t,open:e}:null,[e,t])}function tn({children:e}){let[t,n]=(0,B.useState)(null),[r,i]=(0,B.useState)(null),a=(0,B.useCallback)((e={})=>n({...e,key:Date.now()}),[]);return(0,R.jsxs)(Zt.Provider,{value:a,children:[e,t?(0,R.jsx)(nn,{request:t,onClose:()=>n(null),onAdvanced:e=>{i(e),n(null)}}):null,r===null?null:(0,R.jsx)(rn,{provider:r,onClose:()=>i(null)})]})}function nn({request:e,onClose:t,onAdvanced:n}){let r=g().data,i=$t();if(!r)return null;let a=r.hostPaths!==!1,o=e.provider&&i.includes(e.provider)?e.provider:i[0];return(0,R.jsx)(Ut,{open:!0,onOpenChange:e=>!e&&t(),providers:i,initialProvider:e.provider,resume:e.resume,onAdded:e.onAdded,onAdvanced:a&&o?()=>n(o):void 0},e.key)}function rn({provider:e,onClose:t}){return(0,R.jsx)(ot,{open:!0,onOpenChange:e=>!e&&t(),providers:[...$t()],initialProvider:e},e)}export{vt as a,pt as c,U as d,Ge as f,Ft as i,K as l,en as n,xt as o,Ke as p,Ht as r,q as s,tn as t,G as u};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-pane-qj8Pq29k.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/queries-hE7G6Kgl.js","assets/utils-D6vflkwY.js","assets/bundle-mjs-rHxsej31.js","assets/preload-helper-Czpn1I53.js","assets/clipboard-DvCUPLwM.js","assets/host-usage-BikbUhw4.js","assets/use-desktop-BNN3U2y9.js","assets/terminal-pane-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Aa as r,Ha as i,Lr as a,Qo as o,U as s,Vo as c,_ as l,en as u,it as d,m as f,ut as p,yn as m,yo as h}from"./queries-hE7G6Kgl.js";import{t as g}from"./preload-helper-Czpn1I53.js";import{r as _}from"./toaster-CnjJGypN.js";import{C as v,b as y,k as b,v as x,x as S}from"./plan-usage-CDUAXOMD.js";import{t as C}from"./createLucideIcon-BHp8sXmF.js";import{B as w,t as T}from"./button-CSEYvv3h.js";import{a as E,u as D}from"./add-account-host-LKu3NE9D.js";import{t as O}from"./external-link-BE6y205O.js";import{t as k}from"./loader-circle-CPBhhDbB.js";import{t as A}from"./spinner-5lGeVKBb.js";import{n as j,o as M,r as N,t as ee}from"./dialog-D68_yOhb.js";import{t as te}from"./clipboard-DvCUPLwM.js";import{r as P}from"./phone-app-Csgi1QpC.js";var F=C(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),I=e(t(),1),L={claude:`Anthropic’s coding agent. Uses your Claude account.`,codex:`OpenAI’s coding agent. Uses your ChatGPT account.`,opencode:`Open-source agent. Works with many model providers.`,cursor:`Cursor’s agent, without the editor. Uses your Cursor account.`,copilot:`GitHub’s coding agent. Uses your Copilot plan.`};function R(e,t){let n=new Map((t?.providers??[]).map(e=>[e.provider,e])),r=e.agents.flatMap(e=>{let t=n.get(e.provider),r=L[e.provider];if(r===void 0||t?.status===`connected`||t?.enabled===!1)return[];let i=t===void 0||t.status===`not-installed`?`missing`:`signed-out`;return[{...e,installCommand:e.install.runnable?e.install.command:null,label:b[e.provider],description:r,state:i}]});return[...r.filter(e=>e.state===`signed-out`),...r.filter(e=>e.state===`missing`)]}var ne=/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)|\u001B\[[0-?]*[ -/]*[@-~]/g,re=/https?:\/\/[^\s"'<>\u0007\u001B]+/g;function z(e){let t=e.replace(ne,` `).match(re)??[];for(let e of t.reverse()){let t=ie(e.replace(/[.,;:)\]]+$/,``));if(t&&![`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname))return t.href}return null}function ie(e){try{return new URL(e)}catch{return null}}function ae(e,t){if(t?.enabled===!1)return null;if(t?t.status===`not-installed`:e?.installed===!1)return e?.install.runnable?`install`:`how-to-install`;let n=e?W(e):`unknown`;return e&&(n===`update-required`||n===`update-available`)&&e.update?`update`:t?.status===`disconnected`||t?.status===`unknown`?`sign-in`:null}var oe={install:`Install`,"how-to-install":`How to install`,"sign-in":`Sign in`,update:`Update`};function B(e){if(!e?.installed)return null;let t=W(e);return t===`update-required`?{label:`${e.minVersion} required`,tone:`danger`}:t===`update-available`?{label:`${e.latestVersion} available`,tone:`warn`}:t===`current`&&e.latestVersion?{label:`up to date`,tone:`ok`}:null}var se={native:`the native installer`,npm:`npm`,brew:`Homebrew`,script:`the vendor install script`},V=e=>e?se[e]:null,H=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;function U(e,t){let n=H.exec(e.trim()),r=H.exec(t.trim());if(!n||!r)return null;for(let e=1;e<=3;e++){let t=Number(n[e])-Number(r[e]);if(t!==0)return t>0?1:-1}return!n[4]&&!r[4]?0:n[4]?r[4]?n[4]===r[4]?0:n[4]>r[4]?1:-1:-1:1}function W(e){let{version:t,minVersion:n,latestVersion:r}=e;if(!e.installed||!t||U(t,t)===null)return`unknown`;let i=n?U(t,n):null;if(i!==null&&i<0)return`update-required`;let a=r?U(r,t):null;return a===null?n?`current`:`unknown`:a>0?`update-available`:`current`}var G=n(),ce=I.lazy(()=>g(()=>import(`./terminal-pane-qj8Pq29k.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),le=3e3,ue=60,K=4,q=1e4;function de(e,t){return R(e,t).some(e=>e.state===`signed-out`)?`Sign in to an agent`:`Pick your agent`}function J({setup:e,status:t}){let n=s(),r=u(),i=l(),o=p(),c=o.mutateAsync,d=o.mutate,f=R(e,t),[m,h]=I.useState(e.session),[g,_]=I.useState(null),v=e.session;I.useEffect(()=>{v&&(h(v),v.exitCode===null&&_(null))},[v]);let y=r.mutate,x=I.useCallback((e,t)=>{_(null),y({provider:e,action:t},{onSuccess:e=>h(e),onError:n=>{_({provider:e,action:t,message:n.message}),d()}})},[d,y]),S=I.useRef(null),C=I.useCallback((e,t)=>{if(S.current===e.id)return;S.current=e.id;let{provider:r,action:i}=e,a=b[r];i===`install`&&n(),c().then(e=>{let n=e.providers.find(e=>e.provider===r);if(n?.status===`connected`)return;let o=n!==void 0&&n.status!==`not-installed`;i===`install`&&o?x(r,`login`):_(i===`login`||t?{provider:r,action:i,message:t||`The sign-in to ${a} did not finish.`}:{provider:r,action:i,message:`${a} installed, but cezar cannot find it. Restart cezar from a new terminal, or check that npm’s global folder is on your PATH.`})},()=>_({provider:r,action:i,message:`cezar could not check the agent. Try again.`}))},[x,n,c]),w=v?.exitCode??null;I.useEffect(()=>{if(!(!v||w===null)){if(v.action===`install`&&w!==0){if(S.current===v.id)return;S.current=v.id,n(),_({provider:v.provider,action:v.action,message:`${b[v.provider]} did not install. The terminal says why.`});return}C(v,``)}},[w,n,v,C]);let E=I.useRef(null);v&&(E.current=v.id),I.useEffect(()=>{v||!m||m.exitCode!==null||E.current!==m.id||(h(null),C(m,`The terminal closed before it finished.`))},[v,C,m]);let D=m!==null&&m.exitCode===null,O=D&&m?.action===`install`,k=D&&m?.action===`login`;I.useEffect(()=>{if(!k)return;let e=0,t=window.setInterval(()=>{e+=1,(e<=ue||e%K===0)&&d()},le);return()=>window.clearInterval(t)},[d,k]),I.useEffect(()=>{if(D)return;let e=window.setInterval(()=>d(),q);return()=>window.clearInterval(e)},[d,D]);let A=I.useRef(null);A.current=k&&m?m.id:null;let j=I.useRef(!1);I.useEffect(()=>(j.current=!0,()=>{j.current=!1;let e=A.current;window.setTimeout(()=>{!j.current&&e&&a(e).catch(()=>{})},0)}),[]);let M=()=>{m&&i.mutate(m.id),h(null)},N=()=>{_(null),D||h(null)};return(0,G.jsx)(`div`,{className:`mt-7 flex w-full flex-col gap-3 text-left`,children:f.map(e=>{let t=m?.provider===e.provider,n=g?.provider===e.provider?g:null,i=D||r.isPending;return(0,G.jsxs)(`div`,{"data-slot":`agent-row`,"data-state":e.state,"data-provider":e.provider,className:`rounded-xl border border-border bg-card p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-lead text-foreground`,children:e.label}),(0,G.jsx)(`div`,{className:`text-ui text-muted-foreground`,children:e.state===`missing`?e.description:`Installed, not signed in`})]}),(0,G.jsx)(Y,{row:e,open:t,busy:i,onStart:x})]}),!t&&!n&&e.state===`missing`&&e.installCommand===null?(0,G.jsxs)(`p`,{className:`mt-3 text-ui text-soft-foreground`,children:[e.install.command?(0,G.jsxs)(G.Fragment,{children:[`Run `,(0,G.jsx)(`code`,{className:`font-mono text-meta`,children:e.install.command}),` on this computer, or see `]}):`See `,(0,G.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2`,children:`the install docs`}),`.`]}):null,!t&&!n&&e.state===`missing`&&e.installCommand?(0,G.jsx)(X,{command:e.installCommand}):null,t&&m?(0,G.jsx)(fe,{session:m,running:D,installing:O},m.id):null,n&&!t?(0,G.jsx)(X,{command:(n.action===`install`?e.installCommand:e.loginCommand)??``}):null,n?(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsx)(`p`,{role:`alert`,className:`min-w-0 flex-1 text-ui text-danger`,children:n.message}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:N,children:`Close`}),(0,G.jsx)(T,{size:`sm`,className:`font-normal`,disabled:r.isPending,onClick:()=>x(n.provider,n.action),children:`Try again`})]})]}):null,t&&D?(0,G.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,G.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:O?`Sign-in comes next.`:`This page continues by itself.`}),(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:M,children:`Cancel`})]}):null]},e.provider)})})}function Y({row:e,open:t,busy:n,onStart:r}){return t?null:e.state===`signed-out`?(0,G.jsx)(T,{className:`font-normal`,disabled:n||e.loginCommand===null,onClick:()=>r(e.provider,`login`),children:`Sign in`}):e.installCommand===null?null:(0,G.jsx)(T,{className:`font-normal`,disabled:n,onClick:()=>r(e.provider,`install`),children:`Install`})}function X({command:e}){return(0,G.jsxs)(`code`,{className:`mt-3 block truncate font-mono text-meta text-soft-foreground`,title:e,children:[(0,G.jsx)(`span`,{className:`select-none`,children:`$ `}),e]})}function fe({session:e,running:t,installing:n}){let[a,o]=I.useState(null),s=e.id,c=I.useRef(``),l=e.action===`login`,u=I.useMemo(()=>({read:async e=>{let t=await r(s,e);return l&&t.data&&(c.current=(c.current+t.data).slice(-16384),o(z(c.current))),t},write:e=>h(s,e),resize:(e,t)=>i(s,e,t)}),[s,l]),d=I.useMemo(()=>({id:s,exitCode:t?null:e.exitCode,topic:t?e.topic:null}),[s,t,e.exitCode,e.topic]),f=b[e.provider];return(0,G.jsxs)(`div`,{"data-slot":`agent-setup-terminal`,className:`mt-3 flex flex-col gap-2`,children:[t?(0,G.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[(0,G.jsx)(k,{className:`size-3.5 shrink-0 motion-safe:animate-spin`,"aria-hidden":`true`}),e.action===`update`?e.command.startsWith(`sudo `)?`Updating ${f}. Click the terminal and type your computer password if it asks.`:`Updating ${f}…`:n?e.command.startsWith(`sudo `)?`Installing ${f}. Click the terminal and type your computer password if it asks.`:`Installing ${f}…`:`Sign in to ${f}. Click the terminal to answer its questions.`]}):null,(0,G.jsx)(X,{command:e.command}),(0,G.jsx)(`div`,{className:`relative h-72 overflow-hidden rounded-lg border border-border bg-card-2`,children:(0,G.jsx)(I.Suspense,{fallback:null,children:(0,G.jsx)(ce,{runId:e.runId,session:d,active:!0,io:u})})}),l&&a&&t?(0,G.jsx)(T,{asChild:!0,size:`sm`,variant:`outline`,className:`self-start font-normal`,children:(0,G.jsxs)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,children:[`Open sign-in page`,(0,G.jsx)(O,{"aria-hidden":`true`})]})}):null]})}var pe={install:[`install`,`login`],update:[`update`],"sign-in":[`login`]},me=3e3,he=2e3,Z=new Set,ge=5e3;function Q({provider:e,action:t,open:n,onOpenChange:r}){let i=I.useMemo(()=>P(),[]),a=`${t===`install`?`Install`:t===`update`?`Update`:`Sign in to`} ${b[e]}`,o=n?(0,G.jsx)(_e,{provider:e,action:t,onClose:()=>r(!1)}):null;return i?(0,G.jsx)(x,{open:n,onOpenChange:r,children:(0,G.jsxs)(y,{side:`bottom`,"data-slot":`agent-setup-sheet`,className:`max-h-[92dvh] overflow-y-auto rounded-t-2xl px-4 pt-3 pb-[max(1.5rem,env(safe-area-inset-bottom))]`,children:[(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto mb-3 h-1 w-9 rounded-full bg-muted`}),(0,G.jsx)(v,{className:`text-base`,children:a}),(0,G.jsxs)(S,{className:`sr-only`,children:[a,` on your computer.`]}),o]})}):(0,G.jsx)(ee,{open:n,onOpenChange:r,children:(0,G.jsxs)(j,{"data-slot":`agent-setup-sheet`,className:`max-h-[90dvh] overflow-y-auto sm:max-w-xl`,children:[(0,G.jsx)(M,{children:a}),(0,G.jsxs)(N,{className:`sr-only`,children:[a,` on this computer.`]}),o]})})}function _e({provider:e,action:t,onClose:n}){let r=o(),i=f(),h=d(),g=p(),v=u(),y=s(),x=b[e],S=f({latest:!0,enabled:!1}).data?.agents.find(t=>t.provider===e),C=i.data?.agents.find(t=>t.provider===e),E=C&&S?.latestVersion&&S.version===C.version?{...C,latestVersion:S.latestVersion}:C,D=i.data?.available===!0,O=i.data?.available===!0&&i.data.interactive,k=i.data?.session??null,j=c(h.data,e),[M,N]=I.useState(t===`sign-in`?`sign-in`:`confirm`),ee=I.useRef(M);ee.current=M,I.useEffect(()=>()=>{ee.current===`waiting`&&_(`${b[e]} was not updated: the sheet closed while it waited for tasks.`)},[e]);let[te,P]=I.useState(null),[F,L]=I.useState(null),[R,ne]=I.useState(null),re=g.mutate,z=g.mutateAsync,ie=I.useRef(E?.version??null);ie.current=E?.version??null;let ae=I.useRef(null),oe=I.useRef(new Set),B=I.useCallback(e=>{e.action===`update`&&(ae.current=ie.current),L(e),N(e.action===`login`?`sign-in`:`running`)},[]),se=M===`confirm`||M===`sign-in`&&F===null;I.useEffect(()=>{!k||k.provider!==e||k.exitCode!==null||!se||Z.has(k.id)||pe[t].includes(k.action)&&B(k)},[t,se,e,k,B]);let V=i.refetch,H=I.useRef(F);H.current=F;let U=I.useRef(null),[W,ce]=I.useState(null),[le,ue]=I.useState(0),K=I.useRef(null),q=I.useRef(!0);I.useEffect(()=>(q.current=!0,()=>{q.current=!1,K.current!==null&&window.clearTimeout(K.current)}),[]);let de=M===`running`||M===`sign-in`;I.useEffect(()=>{if(!F||!i.data)return;if(k?.id===F.id){k!==F&&L(k);return}if(F.exitCode!==null||!de||U.current===F.id)return;let e=F;U.current=e.id,V().then(t=>{if(U.current=null,H.current?.id!==e.id)return;if(t.isError){if(!q.current)return;K.current=window.setTimeout(()=>ue(e=>e+1),he);return}let n=t.data?.session;if(n?.id===e.id)return L(n);L(null),ce(e)})},[le,V,k,i.data,F,de]);let J=I.useCallback(e=>{Z.add(e),r.setQueryData(m.agentSetup,t=>t?.available&&t.session?.id===e?{...t,session:null}:t)},[r]),Y=I.useCallback(()=>r.invalidateQueries({queryKey:m.agentSetup}),[r]),X=I.useCallback((e,t=!1)=>{if(t)return void Z.delete(e);Y().finally(()=>Z.delete(e))},[Y]),Q=I.useCallback((e,t=!1)=>{Z.delete(e),t||Y()},[Y]),_e=l(),$=F?.action===`login`&&F.exitCode===null?F.id:null,xe=$&&oe.current.has($)?$:null,Se=I.useRef(xe);Se.current=xe,I.useEffect(()=>()=>{let e=Se.current;e&&(J(e),a(e).then(()=>X(e),()=>Q(e)))},[J,Q,X]);let Ce=_e.mutateAsync,we=I.useCallback((e,t)=>{J(e),Ce(e).then(()=>X(e,!0),()=>{Q(e,!0),q.current&&t()})},[Ce,J,Q,X]),[Te,Ee]=I.useState(null),De=I.useCallback(e=>{Ee(null),we(e,()=>Ee(e))},[we]);I.useEffect(()=>{M!==`done`||!$||(L(null),De($))},[De,$,M]);let Oe=()=>{if(!F||!$)return L(null);let e=$,t=F;P(null),L(null),we(e,()=>{L(e=>e??t),P(`cezar could not stop the sign-in terminal. Try again.`)})},ke=v.mutate,Ae=I.useCallback((t,n)=>{P(null),ke({provider:e,action:t,...n?{force:n}:{}},{onSuccess:e=>{if(e.joined&&Z.has(e.id)){P(`The last sign-in terminal is still stopping. Try again in a moment.`);return}e.action===`login`&&!e.joined&&oe.current.add(e.id),B(e)},onError:e=>{P(e.message),N(t===`login`?`sign-in`:`failed`)}})},[e,ke,B]),je=I.useRef(!1);I.useEffect(()=>{if(M!==`waiting`){je.current=!1;return}if(E?.activeRuns===0){if(je.current)return;je.current=!0,Ae(`update`);return}let e=window.setInterval(()=>void V(),ge);return()=>window.clearInterval(e)},[E?.activeRuns,M,V,Ae]);let Me=I.useRef(null);I.useEffect(()=>{if(!(!F||F.action===`login`||F.exitCode===null||Me.current===F.id)){if(Me.current=F.id,y(),F.exitCode!==0){V(),P(`${x} did not ${F.action===`install`?`install`:`update`}. The terminal says why.`),N(`failed`);return}if(F.action===`update`){V().then(t=>{ne(t.data?.agents.find(t=>t.provider===e)?.version??null),N(`done`)});return}z().then(t=>{r.invalidateQueries({queryKey:m.agentSetup});let n=t.providers.find(t=>t.provider===e);if(n?.status===`connected`)return N(`done`);if(n&&n.status!==`not-installed`)return N(`sign-in`);P(`${x} installed, but cezar cannot find it. Restart cezar from a new terminal, or check that the install folder is on your PATH.`),N(`failed`)},()=>{r.invalidateQueries({queryKey:m.agentSetup}),P(`cezar could not check the agent. Try again.`),N(`failed`)})}},[y,x,e,r,V,z,F]),I.useEffect(()=>{if(!W)return;ce(null);let t=`The terminal closed before cezar saw it finish.`;if(W.action===`login`){P(`${t} Open it again, or check again if you signed in.`);return}if(y(),W.action===`update`){let n=ae.current;V().then(r=>{let i=r.data?.agents.find(t=>t.provider===e)?.version??null;if(i&&i!==n)return ne(i),N(`done`);P(`${t} ${x} still reports ${i??`no version`}. Try again.`),N(`failed`)});return}z().then(n=>{r.invalidateQueries({queryKey:m.agentSetup});let i=n.providers.find(t=>t.provider===e);if(i?.status===`connected`)return N(`done`);if(i&&i.status!==`not-installed`)return N(`sign-in`);P(`${t} ${x} is not installed. Try again.`),N(`failed`)},()=>{P(`cezar could not check the agent. Try again.`),N(`failed`)})},[y,x,e,r,V,z,W]);let Ne=I.useRef(null);return I.useEffect(()=>{if(!F||F.action!==`login`||F.exitCode===null||Ne.current===F.id)return;Ne.current=F.id;let t=F.id;z().then(n=>{n.providers.find(t=>t.provider===e)?.status!==`connected`&&(L(e=>e?.id===t?null:e),P(`The sign-in terminal closed before ${x} signed in. Open it again, or check again.`))},()=>{})},[x,e,z,F]),I.useEffect(()=>{if(M!==`sign-in`)return;let e=window.setInterval(()=>re(),me);return()=>window.clearInterval(e)},[M,re]),I.useEffect(()=>{M===`sign-in`&&j?.status===`connected`&&N(`done`)},[M,j?.status]),i.isPending?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 py-6 text-ui text-muted-foreground`,children:[(0,G.jsx)(A,{}),` Checking this computer…`]}):E?(0,G.jsxs)(`div`,{"data-slot":`agent-setup-flow`,"data-phase":M,"data-provider":e,className:`mt-2 flex flex-col gap-3`,children:[(0,G.jsx)(ve,{action:t,phase:M,entry:E}),M===`confirm`||M===`waiting`?(0,G.jsx)(ye,{entry:E,action:t===`update`?`update`:`install`,available:D,interactive:O,reason:i.data?.reason??null,waiting:M===`waiting`,busy:v.isPending,onRun:e=>Ae(t===`update`?`update`:`install`,e),onWait:()=>N(`waiting`),onCancel:n}):null,(M===`running`||M===`failed`&&F)&&F&&F.action!==`login`?(0,G.jsx)(fe,{session:F,running:F.exitCode===null,installing:F.action===`install`},F.id):null,M===`running`?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:O?`Closing this keeps it running; open it again to rejoin.`:`The log is read-only on your phone.`}),(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:n,children:`Run in background`})]}):null,M===`sign-in`?(0,G.jsx)(be,{provider:e,entry:E,interactive:O&&D,session:F?.action===`login`?F:null,failure:te,busy:v.isPending||_e.isPending,onTerminal:()=>Ae(`login`),onCheck:()=>re(),onCancel:Oe}):null,M===`failed`?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsx)(`p`,{role:`alert`,className:`min-w-0 flex-1 text-ui text-danger`,children:te}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:n,children:`Close`}),(0,G.jsx)(T,{size:`sm`,className:`font-normal`,disabled:v.isPending,onClick:()=>{L(null),N(`confirm`)},children:`Try again`})]})]}):null,M===`done`?(0,G.jsxs)(`div`,{role:`status`,className:`flex items-center justify-between gap-3 rounded-md border border-success/30 bg-success/5 px-3 py-2.5`,children:[(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-ui text-foreground`,children:[(0,G.jsx)(w,{"aria-hidden":`true`,className:`size-4 text-success-strong`}),t===`update`?R?`${x} is updated. It reports ${R} now.`:`${x} is updated.`:`${x} is ready.`]}),(0,G.jsx)(T,{size:`sm`,className:`font-normal`,onClick:n,children:`Done`})]}):null,M===`done`&&Te?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsx)(`p`,{role:`alert`,className:`min-w-0 flex-1 text-ui text-danger`,children:`cezar could not close the sign-in terminal, and it blocks setting up other agents.`}),(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,disabled:_e.isPending,onClick:()=>De(Te),children:`Close it`})]}):null]}):(0,G.jsx)(`p`,{className:`py-4 text-ui text-danger`,children:`The agent could not be checked. Try again.`})}function ve({action:e,phase:t,entry:n}){let r=[`confirm`,`running`,`sign-in`,`done`],i=Math.max(0,r.indexOf(t===`waiting`?`confirm`:t===`failed`?`running`:t));return(0,G.jsx)(`ol`,{"aria-label":`Steps`,className:`flex flex-wrap gap-x-4 gap-y-1 text-meta text-muted-foreground`,children:(e===`update`?[[`confirm`,`Confirm`],[`running`,`Update`],[`done`,`Done`]]:e===`sign-in`?[[`sign-in`,`Sign in`],[`done`,`Done`]]:[[`confirm`,`Confirm`],[`running`,n.install.runnable?`Install`:`Install yourself`],[`sign-in`,`Sign in`],[`done`,`Done`]]).map(([e,n])=>{let a=r.indexOf(e),o=a<i||t===`done`?`done`:a===i?`current`:`todo`;return(0,G.jsxs)(`li`,{"data-state":o,"aria-current":o===`current`?`step`:void 0,className:o===`current`?`font-medium text-foreground`:o===`done`?`text-success-strong`:``,children:[o===`done`?`✓ `:``,n]},e)})})}function ye({entry:e,action:t,available:n,interactive:r,reason:i,waiting:a,busy:o,onRun:s,onWait:c,onCancel:l}){let u=t===`install`?e.install:e.update,d=u?.command??null,f=!r&&u?.sudo===!0,p=n&&u?.runnable===!0&&d!==null&&!f,m=t===`update`?V(e.method):null,h=b[e.provider],g=n?u?.runnable?f?`This needs your computer password, so it has to finish on your computer.`:null:d?`cezar does not run this command itself (it is not verified yet, or it is a third-party installer), so it shows it for you to run.`:t===`update`?`cezar cannot tell how this copy of ${h} was installed, so it has no update to run. Update it the way you installed it; the vendor’s page shows how.`:`cezar does not know this installer yet. The vendor’s page shows how to install it.`:i;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:p?r?`cezar runs this on this computer, in your home folder, with your user account.`:`This runs on your computer, with your user account.`:d?`Run this in a terminal on the computer running cezar.`:t===`update`?`Update ${h} on the computer running cezar, the way it was installed.`:`Install it on the computer running cezar, following the vendor’s steps.`}),d?(0,G.jsx)($,{command:d}):null,(0,G.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-meta`,children:[m?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:t===`update`?`Installed via`:`Method`}),(0,G.jsx)(`dd`,{children:m})]}):null,e.version?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:`Installed`}),(0,G.jsx)(`dd`,{className:`font-mono`,children:e.version})]}):null,e.latestVersion?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:`Latest`}),(0,G.jsx)(`dd`,{className:`font-mono`,children:e.latestVersion})]}):null,e.minVersion?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:`cezar needs`}),(0,G.jsxs)(`dd`,{className:`font-mono`,children:[e.minVersion,` or newer`]})]}):null]}),g?(0,G.jsx)(`p`,{"data-slot":`agent-setup-why`,className:`rounded-md border border-pending/40 bg-pending/5 px-3 py-2 text-ui text-foreground`,children:g}):null,p&&u?.sudo?(0,G.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`It asks for your computer password in the terminal below.`}):null,t===`update`&&e.activeRuns>0&&p?(0,G.jsxs)(`p`,{"data-slot":`agent-setup-active-runs`,className:`rounded-md border border-pending/40 bg-pending/5 px-3 py-2 text-ui text-foreground`,children:[e.activeRuns,` task`,e.activeRuns===1?` is`:`s are`,` running on `,h,`. Updating now can interrupt`,e.method===`npm`?` them, because npm replaces the files in place.`:` a task that starts the CLI again.`]}):null,a?(0,G.jsx)(`p`,{"data-slot":`agent-setup-waiting`,role:`status`,className:`text-ui text-soft-foreground`,children:`Keep this open: the update starts here once the tasks finish. Closing it cancels the wait.`}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsxs)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-meta text-foreground underline underline-offset-2`,children:[`Official docs `,(0,G.jsx)(O,{"aria-hidden":`true`,className:`size-3`})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(T,{size:`sm`,variant:`ghost`,className:`font-normal`,onClick:l,children:p?`Cancel`:`Close`}),p&&t===`update`&&e.activeRuns>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,disabled:o,onClick:()=>s(!0),children:`Update now`}),(0,G.jsx)(T,{size:`sm`,className:`font-normal`,disabled:o||a,onClick:c,children:a?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(A,{}),` Waiting for tasks…`]}):`Update when they finish`})]}):p?(0,G.jsxs)(T,{size:`sm`,className:`font-normal`,disabled:o,onClick:()=>s(),children:[o?(0,G.jsx)(A,{}):null,t===`update`?`Update`:`Install`]}):null]})]})]})}function be({provider:e,entry:t,interactive:n,session:r,failure:i,busy:a,onTerminal:o,onCheck:s,onCancel:c}){return D.has(e)?r?(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(fe,{session:r,running:r.exitCode===null,installing:!1},r.id),i?(0,G.jsx)(`p`,{role:`alert`,className:`text-ui text-danger`,children:i}):null,r.exitCode===null?(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:c,children:`Cancel`})}):null]}):(0,G.jsxs)(`div`,{"data-slot":`agent-setup-terminal-sign-in`,className:`flex flex-col gap-2`,children:[(0,G.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:n?`${b[e]} signs in from its own terminal. Open one here and follow it.`:`${b[e]} signs in from a terminal on your computer. Finish on your computer; this updates by itself.`}),t.loginCommand?(0,G.jsx)($,{command:t.loginCommand}):null,i?(0,G.jsx)(`p`,{role:`alert`,className:`text-ui text-danger`,children:i}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n?(0,G.jsx)(T,{size:`sm`,className:`font-normal`,disabled:a||t.loginCommand===null,onClick:o,children:`Open terminal here`}):(0,G.jsx)(`span`,{"data-slot":`agent-setup-finish-on-computer`,className:`text-ui font-medium text-foreground`,children:`Finish on my computer`}),(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:s,children:`Check again`})]})]}):(0,G.jsx)(E,{provider:e,profileId:`default`,place:`attention`,inSheet:!0,compact:!n})}function $({command:e}){let t=async()=>{try{await te(e),_(`Command copied`)}catch{_(`Could not copy the command`,{tone:`danger`})}};return(0,G.jsxs)(`div`,{"data-slot":`agent-setup-command`,className:`flex items-center gap-2 rounded-md border border-border bg-card-2 px-3 py-2`,children:[(0,G.jsx)(`code`,{className:`min-w-0 flex-1 break-all font-mono text-meta text-foreground`,children:e}),(0,G.jsx)(T,{size:`sm`,variant:`ghost`,className:`shrink-0 font-normal`,onClick:()=>void t(),children:`Copy`})]})}function xe(){let[e,t]=I.useState(null);return{open:I.useCallback((e,n)=>{t({provider:e,action:n===`sign-in`?`sign-in`:n===`update`?`update`:`install`})},[]),element:e?(0,G.jsx)(Q,{provider:e.provider,action:e.action,open:!0,onOpenChange:e=>{e||t(null)}}):null}}export{oe as a,B as c,de as i,F as l,xe as n,ae as o,J as r,R as s,Q as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/terminal-pane-CcTMAhgu.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/queries-BeoT2lBk.js","assets/utils-D6vflkwY.js","assets/bundle-mjs-rHxsej31.js","assets/preload-helper-Czpn1I53.js","assets/clipboard-DvCUPLwM.js","assets/host-usage-VTid-8C1.js","assets/use-desktop-BNN3U2y9.js","assets/terminal-pane-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Aa as r,Ha as i,Lr as a,Qo as o,U as s,Vo as c,_ as l,en as u,it as d,m as f,ut as p,yn as m,yo as h}from"./queries-BeoT2lBk.js";import{t as g}from"./preload-helper-Czpn1I53.js";import{r as _}from"./toaster-CnjJGypN.js";import{C as v,b as y,k as b,v as x,x as S}from"./plan-usage-D1hnSOHC.js";import{t as C}from"./createLucideIcon-BHp8sXmF.js";import{B as w,t as T}from"./button-CSEYvv3h.js";import{a as E,u as D}from"./add-account-host-CVZ1mofB.js";import{t as O}from"./external-link-BE6y205O.js";import{t as k}from"./loader-circle-CPBhhDbB.js";import{t as A}from"./spinner-5lGeVKBb.js";import{n as j,o as M,r as N,t as ee}from"./dialog-D68_yOhb.js";import{t as te}from"./clipboard-DvCUPLwM.js";import{r as P}from"./phone-app-C2rT__Vf.js";var F=C(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),I=e(t(),1),L={claude:`Anthropic’s coding agent. Uses your Claude account.`,codex:`OpenAI’s coding agent. Uses your ChatGPT account.`,opencode:`Open-source agent. Works with many model providers.`,cursor:`Cursor’s agent, without the editor. Uses your Cursor account.`,copilot:`GitHub’s coding agent. Uses your Copilot plan.`};function R(e,t){let n=new Map((t?.providers??[]).map(e=>[e.provider,e])),r=e.agents.flatMap(e=>{let t=n.get(e.provider),r=L[e.provider];if(r===void 0||t?.status===`connected`||t?.enabled===!1)return[];let i=t===void 0||t.status===`not-installed`?`missing`:`signed-out`;return[{...e,installCommand:e.install.runnable?e.install.command:null,label:b[e.provider],description:r,state:i}]});return[...r.filter(e=>e.state===`signed-out`),...r.filter(e=>e.state===`missing`)]}var ne=/\u001B\][^\u0007\u001B]*(?:\u0007|\u001B\\)|\u001B\[[0-?]*[ -/]*[@-~]/g,re=/https?:\/\/[^\s"'<>\u0007\u001B]+/g;function z(e){let t=e.replace(ne,` `).match(re)??[];for(let e of t.reverse()){let t=ie(e.replace(/[.,;:)\]]+$/,``));if(t&&![`localhost`,`127.0.0.1`,`[::1]`].includes(t.hostname))return t.href}return null}function ie(e){try{return new URL(e)}catch{return null}}function ae(e,t){if(t?.enabled===!1)return null;if(t?t.status===`not-installed`:e?.installed===!1)return e?.install.runnable?`install`:`how-to-install`;let n=e?W(e):`unknown`;return e&&(n===`update-required`||n===`update-available`)&&e.update?`update`:t?.status===`disconnected`||t?.status===`unknown`?`sign-in`:null}var oe={install:`Install`,"how-to-install":`How to install`,"sign-in":`Sign in`,update:`Update`};function B(e){if(!e?.installed)return null;let t=W(e);return t===`update-required`?{label:`${e.minVersion} required`,tone:`danger`}:t===`update-available`?{label:`${e.latestVersion} available`,tone:`warn`}:t===`current`&&e.latestVersion?{label:`up to date`,tone:`ok`}:null}var se={native:`the native installer`,npm:`npm`,brew:`Homebrew`,script:`the vendor install script`},V=e=>e?se[e]:null,H=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?$/;function U(e,t){let n=H.exec(e.trim()),r=H.exec(t.trim());if(!n||!r)return null;for(let e=1;e<=3;e++){let t=Number(n[e])-Number(r[e]);if(t!==0)return t>0?1:-1}return!n[4]&&!r[4]?0:n[4]?r[4]?n[4]===r[4]?0:n[4]>r[4]?1:-1:-1:1}function W(e){let{version:t,minVersion:n,latestVersion:r}=e;if(!e.installed||!t||U(t,t)===null)return`unknown`;let i=n?U(t,n):null;if(i!==null&&i<0)return`update-required`;let a=r?U(r,t):null;return a===null?n?`current`:`unknown`:a>0?`update-available`:`current`}var G=n(),ce=I.lazy(()=>g(()=>import(`./terminal-pane-CcTMAhgu.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),le=3e3,ue=60,K=4,q=1e4;function de(e,t){return R(e,t).some(e=>e.state===`signed-out`)?`Sign in to an agent`:`Pick your agent`}function J({setup:e,status:t}){let n=s(),r=u(),i=l(),o=p(),c=o.mutateAsync,d=o.mutate,f=R(e,t),[m,h]=I.useState(e.session),[g,_]=I.useState(null),v=e.session;I.useEffect(()=>{v&&(h(v),v.exitCode===null&&_(null))},[v]);let y=r.mutate,x=I.useCallback((e,t)=>{_(null),y({provider:e,action:t},{onSuccess:e=>h(e),onError:n=>{_({provider:e,action:t,message:n.message}),d()}})},[d,y]),S=I.useRef(null),C=I.useCallback((e,t)=>{if(S.current===e.id)return;S.current=e.id;let{provider:r,action:i}=e,a=b[r];i===`install`&&n(),c().then(e=>{let n=e.providers.find(e=>e.provider===r);if(n?.status===`connected`)return;let o=n!==void 0&&n.status!==`not-installed`;i===`install`&&o?x(r,`login`):_(i===`login`||t?{provider:r,action:i,message:t||`The sign-in to ${a} did not finish.`}:{provider:r,action:i,message:`${a} installed, but cezar cannot find it. Restart cezar from a new terminal, or check that npm’s global folder is on your PATH.`})},()=>_({provider:r,action:i,message:`cezar could not check the agent. Try again.`}))},[x,n,c]),w=v?.exitCode??null;I.useEffect(()=>{if(!(!v||w===null)){if(v.action===`install`&&w!==0){if(S.current===v.id)return;S.current=v.id,n(),_({provider:v.provider,action:v.action,message:`${b[v.provider]} did not install. The terminal says why.`});return}C(v,``)}},[w,n,v,C]);let E=I.useRef(null);v&&(E.current=v.id),I.useEffect(()=>{v||!m||m.exitCode!==null||E.current!==m.id||(h(null),C(m,`The terminal closed before it finished.`))},[v,C,m]);let D=m!==null&&m.exitCode===null,O=D&&m?.action===`install`,k=D&&m?.action===`login`;I.useEffect(()=>{if(!k)return;let e=0,t=window.setInterval(()=>{e+=1,(e<=ue||e%K===0)&&d()},le);return()=>window.clearInterval(t)},[d,k]),I.useEffect(()=>{if(D)return;let e=window.setInterval(()=>d(),q);return()=>window.clearInterval(e)},[d,D]);let A=I.useRef(null);A.current=k&&m?m.id:null;let j=I.useRef(!1);I.useEffect(()=>(j.current=!0,()=>{j.current=!1;let e=A.current;window.setTimeout(()=>{!j.current&&e&&a(e).catch(()=>{})},0)}),[]);let M=()=>{m&&i.mutate(m.id),h(null)},N=()=>{_(null),D||h(null)};return(0,G.jsx)(`div`,{className:`mt-7 flex w-full flex-col gap-3 text-left`,children:f.map(e=>{let t=m?.provider===e.provider,n=g?.provider===e.provider?g:null,i=D||r.isPending;return(0,G.jsxs)(`div`,{"data-slot":`agent-row`,"data-state":e.state,"data-provider":e.provider,className:`rounded-xl border border-border bg-card p-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-lead text-foreground`,children:e.label}),(0,G.jsx)(`div`,{className:`text-ui text-muted-foreground`,children:e.state===`missing`?e.description:`Installed, not signed in`})]}),(0,G.jsx)(Y,{row:e,open:t,busy:i,onStart:x})]}),!t&&!n&&e.state===`missing`&&e.installCommand===null?(0,G.jsxs)(`p`,{className:`mt-3 text-ui text-soft-foreground`,children:[e.install.command?(0,G.jsxs)(G.Fragment,{children:[`Run `,(0,G.jsx)(`code`,{className:`font-mono text-meta`,children:e.install.command}),` on this computer, or see `]}):`See `,(0,G.jsx)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`underline underline-offset-2`,children:`the install docs`}),`.`]}):null,!t&&!n&&e.state===`missing`&&e.installCommand?(0,G.jsx)(X,{command:e.installCommand}):null,t&&m?(0,G.jsx)(fe,{session:m,running:D,installing:O},m.id):null,n&&!t?(0,G.jsx)(X,{command:(n.action===`install`?e.installCommand:e.loginCommand)??``}):null,n?(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsx)(`p`,{role:`alert`,className:`min-w-0 flex-1 text-ui text-danger`,children:n.message}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:N,children:`Close`}),(0,G.jsx)(T,{size:`sm`,className:`font-normal`,disabled:r.isPending,onClick:()=>x(n.provider,n.action),children:`Try again`})]})]}):null,t&&D?(0,G.jsxs)(`div`,{className:`mt-3 flex items-center justify-between gap-3`,children:[(0,G.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:O?`Sign-in comes next.`:`This page continues by itself.`}),(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:M,children:`Cancel`})]}):null]},e.provider)})})}function Y({row:e,open:t,busy:n,onStart:r}){return t?null:e.state===`signed-out`?(0,G.jsx)(T,{className:`font-normal`,disabled:n||e.loginCommand===null,onClick:()=>r(e.provider,`login`),children:`Sign in`}):e.installCommand===null?null:(0,G.jsx)(T,{className:`font-normal`,disabled:n,onClick:()=>r(e.provider,`install`),children:`Install`})}function X({command:e}){return(0,G.jsxs)(`code`,{className:`mt-3 block truncate font-mono text-meta text-soft-foreground`,title:e,children:[(0,G.jsx)(`span`,{className:`select-none`,children:`$ `}),e]})}function fe({session:e,running:t,installing:n}){let[a,o]=I.useState(null),s=e.id,c=I.useRef(``),l=e.action===`login`,u=I.useMemo(()=>({read:async e=>{let t=await r(s,e);return l&&t.data&&(c.current=(c.current+t.data).slice(-16384),o(z(c.current))),t},write:e=>h(s,e),resize:(e,t)=>i(s,e,t)}),[s,l]),d=I.useMemo(()=>({id:s,exitCode:t?null:e.exitCode,topic:t?e.topic:null}),[s,t,e.exitCode,e.topic]),f=b[e.provider];return(0,G.jsxs)(`div`,{"data-slot":`agent-setup-terminal`,className:`mt-3 flex flex-col gap-2`,children:[t?(0,G.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-ui text-muted-foreground`,children:[(0,G.jsx)(k,{className:`size-3.5 shrink-0 motion-safe:animate-spin`,"aria-hidden":`true`}),e.action===`update`?e.command.startsWith(`sudo `)?`Updating ${f}. Click the terminal and type your computer password if it asks.`:`Updating ${f}…`:n?e.command.startsWith(`sudo `)?`Installing ${f}. Click the terminal and type your computer password if it asks.`:`Installing ${f}…`:`Sign in to ${f}. Click the terminal to answer its questions.`]}):null,(0,G.jsx)(X,{command:e.command}),(0,G.jsx)(`div`,{className:`relative h-72 overflow-hidden rounded-lg border border-border bg-card-2`,children:(0,G.jsx)(I.Suspense,{fallback:null,children:(0,G.jsx)(ce,{runId:e.runId,session:d,active:!0,io:u})})}),l&&a&&t?(0,G.jsx)(T,{asChild:!0,size:`sm`,variant:`outline`,className:`self-start font-normal`,children:(0,G.jsxs)(`a`,{href:a,target:`_blank`,rel:`noopener noreferrer`,children:[`Open sign-in page`,(0,G.jsx)(O,{"aria-hidden":`true`})]})}):null]})}var pe={install:[`install`,`login`],update:[`update`],"sign-in":[`login`]},me=3e3,he=2e3,Z=new Set,ge=5e3;function Q({provider:e,action:t,open:n,onOpenChange:r}){let i=I.useMemo(()=>P(),[]),a=`${t===`install`?`Install`:t===`update`?`Update`:`Sign in to`} ${b[e]}`,o=n?(0,G.jsx)(_e,{provider:e,action:t,onClose:()=>r(!1)}):null;return i?(0,G.jsx)(x,{open:n,onOpenChange:r,children:(0,G.jsxs)(y,{side:`bottom`,"data-slot":`agent-setup-sheet`,className:`max-h-[92dvh] overflow-y-auto rounded-t-2xl px-4 pt-3 pb-[max(1.5rem,env(safe-area-inset-bottom))]`,children:[(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto mb-3 h-1 w-9 rounded-full bg-muted`}),(0,G.jsx)(v,{className:`text-base`,children:a}),(0,G.jsxs)(S,{className:`sr-only`,children:[a,` on your computer.`]}),o]})}):(0,G.jsx)(ee,{open:n,onOpenChange:r,children:(0,G.jsxs)(j,{"data-slot":`agent-setup-sheet`,className:`max-h-[90dvh] overflow-y-auto sm:max-w-xl`,children:[(0,G.jsx)(M,{children:a}),(0,G.jsxs)(N,{className:`sr-only`,children:[a,` on this computer.`]}),o]})})}function _e({provider:e,action:t,onClose:n}){let r=o(),i=f(),h=d(),g=p(),v=u(),y=s(),x=b[e],S=f({latest:!0,enabled:!1}).data?.agents.find(t=>t.provider===e),C=i.data?.agents.find(t=>t.provider===e),E=C&&S?.latestVersion&&S.version===C.version?{...C,latestVersion:S.latestVersion}:C,D=i.data?.available===!0,O=i.data?.available===!0&&i.data.interactive,k=i.data?.session??null,j=c(h.data,e),[M,N]=I.useState(t===`sign-in`?`sign-in`:`confirm`),ee=I.useRef(M);ee.current=M,I.useEffect(()=>()=>{ee.current===`waiting`&&_(`${b[e]} was not updated: the sheet closed while it waited for tasks.`)},[e]);let[te,P]=I.useState(null),[F,L]=I.useState(null),[R,ne]=I.useState(null),re=g.mutate,z=g.mutateAsync,ie=I.useRef(E?.version??null);ie.current=E?.version??null;let ae=I.useRef(null),oe=I.useRef(new Set),B=I.useCallback(e=>{e.action===`update`&&(ae.current=ie.current),L(e),N(e.action===`login`?`sign-in`:`running`)},[]),se=M===`confirm`||M===`sign-in`&&F===null;I.useEffect(()=>{!k||k.provider!==e||k.exitCode!==null||!se||Z.has(k.id)||pe[t].includes(k.action)&&B(k)},[t,se,e,k,B]);let V=i.refetch,H=I.useRef(F);H.current=F;let U=I.useRef(null),[W,ce]=I.useState(null),[le,ue]=I.useState(0),K=I.useRef(null),q=I.useRef(!0);I.useEffect(()=>(q.current=!0,()=>{q.current=!1,K.current!==null&&window.clearTimeout(K.current)}),[]);let de=M===`running`||M===`sign-in`;I.useEffect(()=>{if(!F||!i.data)return;if(k?.id===F.id){k!==F&&L(k);return}if(F.exitCode!==null||!de||U.current===F.id)return;let e=F;U.current=e.id,V().then(t=>{if(U.current=null,H.current?.id!==e.id)return;if(t.isError){if(!q.current)return;K.current=window.setTimeout(()=>ue(e=>e+1),he);return}let n=t.data?.session;if(n?.id===e.id)return L(n);L(null),ce(e)})},[le,V,k,i.data,F,de]);let J=I.useCallback(e=>{Z.add(e),r.setQueryData(m.agentSetup,t=>t?.available&&t.session?.id===e?{...t,session:null}:t)},[r]),Y=I.useCallback(()=>r.invalidateQueries({queryKey:m.agentSetup}),[r]),X=I.useCallback((e,t=!1)=>{if(t)return void Z.delete(e);Y().finally(()=>Z.delete(e))},[Y]),Q=I.useCallback((e,t=!1)=>{Z.delete(e),t||Y()},[Y]),_e=l(),$=F?.action===`login`&&F.exitCode===null?F.id:null,xe=$&&oe.current.has($)?$:null,Se=I.useRef(xe);Se.current=xe,I.useEffect(()=>()=>{let e=Se.current;e&&(J(e),a(e).then(()=>X(e),()=>Q(e)))},[J,Q,X]);let Ce=_e.mutateAsync,we=I.useCallback((e,t)=>{J(e),Ce(e).then(()=>X(e,!0),()=>{Q(e,!0),q.current&&t()})},[Ce,J,Q,X]),[Te,Ee]=I.useState(null),De=I.useCallback(e=>{Ee(null),we(e,()=>Ee(e))},[we]);I.useEffect(()=>{M!==`done`||!$||(L(null),De($))},[De,$,M]);let Oe=()=>{if(!F||!$)return L(null);let e=$,t=F;P(null),L(null),we(e,()=>{L(e=>e??t),P(`cezar could not stop the sign-in terminal. Try again.`)})},ke=v.mutate,Ae=I.useCallback((t,n)=>{P(null),ke({provider:e,action:t,...n?{force:n}:{}},{onSuccess:e=>{if(e.joined&&Z.has(e.id)){P(`The last sign-in terminal is still stopping. Try again in a moment.`);return}e.action===`login`&&!e.joined&&oe.current.add(e.id),B(e)},onError:e=>{P(e.message),N(t===`login`?`sign-in`:`failed`)}})},[e,ke,B]),je=I.useRef(!1);I.useEffect(()=>{if(M!==`waiting`){je.current=!1;return}if(E?.activeRuns===0){if(je.current)return;je.current=!0,Ae(`update`);return}let e=window.setInterval(()=>void V(),ge);return()=>window.clearInterval(e)},[E?.activeRuns,M,V,Ae]);let Me=I.useRef(null);I.useEffect(()=>{if(!(!F||F.action===`login`||F.exitCode===null||Me.current===F.id)){if(Me.current=F.id,y(),F.exitCode!==0){V(),P(`${x} did not ${F.action===`install`?`install`:`update`}. The terminal says why.`),N(`failed`);return}if(F.action===`update`){V().then(t=>{ne(t.data?.agents.find(t=>t.provider===e)?.version??null),N(`done`)});return}z().then(t=>{r.invalidateQueries({queryKey:m.agentSetup});let n=t.providers.find(t=>t.provider===e);if(n?.status===`connected`)return N(`done`);if(n&&n.status!==`not-installed`)return N(`sign-in`);P(`${x} installed, but cezar cannot find it. Restart cezar from a new terminal, or check that the install folder is on your PATH.`),N(`failed`)},()=>{r.invalidateQueries({queryKey:m.agentSetup}),P(`cezar could not check the agent. Try again.`),N(`failed`)})}},[y,x,e,r,V,z,F]),I.useEffect(()=>{if(!W)return;ce(null);let t=`The terminal closed before cezar saw it finish.`;if(W.action===`login`){P(`${t} Open it again, or check again if you signed in.`);return}if(y(),W.action===`update`){let n=ae.current;V().then(r=>{let i=r.data?.agents.find(t=>t.provider===e)?.version??null;if(i&&i!==n)return ne(i),N(`done`);P(`${t} ${x} still reports ${i??`no version`}. Try again.`),N(`failed`)});return}z().then(n=>{r.invalidateQueries({queryKey:m.agentSetup});let i=n.providers.find(t=>t.provider===e);if(i?.status===`connected`)return N(`done`);if(i&&i.status!==`not-installed`)return N(`sign-in`);P(`${t} ${x} is not installed. Try again.`),N(`failed`)},()=>{P(`cezar could not check the agent. Try again.`),N(`failed`)})},[y,x,e,r,V,z,W]);let Ne=I.useRef(null);return I.useEffect(()=>{if(!F||F.action!==`login`||F.exitCode===null||Ne.current===F.id)return;Ne.current=F.id;let t=F.id;z().then(n=>{n.providers.find(t=>t.provider===e)?.status!==`connected`&&(L(e=>e?.id===t?null:e),P(`The sign-in terminal closed before ${x} signed in. Open it again, or check again.`))},()=>{})},[x,e,z,F]),I.useEffect(()=>{if(M!==`sign-in`)return;let e=window.setInterval(()=>re(),me);return()=>window.clearInterval(e)},[M,re]),I.useEffect(()=>{M===`sign-in`&&j?.status===`connected`&&N(`done`)},[M,j?.status]),i.isPending?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 py-6 text-ui text-muted-foreground`,children:[(0,G.jsx)(A,{}),` Checking this computer…`]}):E?(0,G.jsxs)(`div`,{"data-slot":`agent-setup-flow`,"data-phase":M,"data-provider":e,className:`mt-2 flex flex-col gap-3`,children:[(0,G.jsx)(ve,{action:t,phase:M,entry:E}),M===`confirm`||M===`waiting`?(0,G.jsx)(ye,{entry:E,action:t===`update`?`update`:`install`,available:D,interactive:O,reason:i.data?.reason??null,waiting:M===`waiting`,busy:v.isPending,onRun:e=>Ae(t===`update`?`update`:`install`,e),onWait:()=>N(`waiting`),onCancel:n}):null,(M===`running`||M===`failed`&&F)&&F&&F.action!==`login`?(0,G.jsx)(fe,{session:F,running:F.exitCode===null,installing:F.action===`install`},F.id):null,M===`running`?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:O?`Closing this keeps it running; open it again to rejoin.`:`The log is read-only on your phone.`}),(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:n,children:`Run in background`})]}):null,M===`sign-in`?(0,G.jsx)(be,{provider:e,entry:E,interactive:O&&D,session:F?.action===`login`?F:null,failure:te,busy:v.isPending||_e.isPending,onTerminal:()=>Ae(`login`),onCheck:()=>re(),onCancel:Oe}):null,M===`failed`?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsx)(`p`,{role:`alert`,className:`min-w-0 flex-1 text-ui text-danger`,children:te}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:n,children:`Close`}),(0,G.jsx)(T,{size:`sm`,className:`font-normal`,disabled:v.isPending,onClick:()=>{L(null),N(`confirm`)},children:`Try again`})]})]}):null,M===`done`?(0,G.jsxs)(`div`,{role:`status`,className:`flex items-center justify-between gap-3 rounded-md border border-success/30 bg-success/5 px-3 py-2.5`,children:[(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-ui text-foreground`,children:[(0,G.jsx)(w,{"aria-hidden":`true`,className:`size-4 text-success-strong`}),t===`update`?R?`${x} is updated. It reports ${R} now.`:`${x} is updated.`:`${x} is ready.`]}),(0,G.jsx)(T,{size:`sm`,className:`font-normal`,onClick:n,children:`Done`})]}):null,M===`done`&&Te?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsx)(`p`,{role:`alert`,className:`min-w-0 flex-1 text-ui text-danger`,children:`cezar could not close the sign-in terminal, and it blocks setting up other agents.`}),(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,disabled:_e.isPending,onClick:()=>De(Te),children:`Close it`})]}):null]}):(0,G.jsx)(`p`,{className:`py-4 text-ui text-danger`,children:`The agent could not be checked. Try again.`})}function ve({action:e,phase:t,entry:n}){let r=[`confirm`,`running`,`sign-in`,`done`],i=Math.max(0,r.indexOf(t===`waiting`?`confirm`:t===`failed`?`running`:t));return(0,G.jsx)(`ol`,{"aria-label":`Steps`,className:`flex flex-wrap gap-x-4 gap-y-1 text-meta text-muted-foreground`,children:(e===`update`?[[`confirm`,`Confirm`],[`running`,`Update`],[`done`,`Done`]]:e===`sign-in`?[[`sign-in`,`Sign in`],[`done`,`Done`]]:[[`confirm`,`Confirm`],[`running`,n.install.runnable?`Install`:`Install yourself`],[`sign-in`,`Sign in`],[`done`,`Done`]]).map(([e,n])=>{let a=r.indexOf(e),o=a<i||t===`done`?`done`:a===i?`current`:`todo`;return(0,G.jsxs)(`li`,{"data-state":o,"aria-current":o===`current`?`step`:void 0,className:o===`current`?`font-medium text-foreground`:o===`done`?`text-success-strong`:``,children:[o===`done`?`✓ `:``,n]},e)})})}function ye({entry:e,action:t,available:n,interactive:r,reason:i,waiting:a,busy:o,onRun:s,onWait:c,onCancel:l}){let u=t===`install`?e.install:e.update,d=u?.command??null,f=!r&&u?.sudo===!0,p=n&&u?.runnable===!0&&d!==null&&!f,m=t===`update`?V(e.method):null,h=b[e.provider],g=n?u?.runnable?f?`This needs your computer password, so it has to finish on your computer.`:null:d?`cezar does not run this command itself (it is not verified yet, or it is a third-party installer), so it shows it for you to run.`:t===`update`?`cezar cannot tell how this copy of ${h} was installed, so it has no update to run. Update it the way you installed it; the vendor’s page shows how.`:`cezar does not know this installer yet. The vendor’s page shows how to install it.`:i;return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:p?r?`cezar runs this on this computer, in your home folder, with your user account.`:`This runs on your computer, with your user account.`:d?`Run this in a terminal on the computer running cezar.`:t===`update`?`Update ${h} on the computer running cezar, the way it was installed.`:`Install it on the computer running cezar, following the vendor’s steps.`}),d?(0,G.jsx)($,{command:d}):null,(0,G.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-meta`,children:[m?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:t===`update`?`Installed via`:`Method`}),(0,G.jsx)(`dd`,{children:m})]}):null,e.version?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:`Installed`}),(0,G.jsx)(`dd`,{className:`font-mono`,children:e.version})]}):null,e.latestVersion?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:`Latest`}),(0,G.jsx)(`dd`,{className:`font-mono`,children:e.latestVersion})]}):null,e.minVersion?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground`,children:`cezar needs`}),(0,G.jsxs)(`dd`,{className:`font-mono`,children:[e.minVersion,` or newer`]})]}):null]}),g?(0,G.jsx)(`p`,{"data-slot":`agent-setup-why`,className:`rounded-md border border-pending/40 bg-pending/5 px-3 py-2 text-ui text-foreground`,children:g}):null,p&&u?.sudo?(0,G.jsx)(`p`,{className:`text-ui text-soft-foreground`,children:`It asks for your computer password in the terminal below.`}):null,t===`update`&&e.activeRuns>0&&p?(0,G.jsxs)(`p`,{"data-slot":`agent-setup-active-runs`,className:`rounded-md border border-pending/40 bg-pending/5 px-3 py-2 text-ui text-foreground`,children:[e.activeRuns,` task`,e.activeRuns===1?` is`:`s are`,` running on `,h,`. Updating now can interrupt`,e.method===`npm`?` them, because npm replaces the files in place.`:` a task that starts the CLI again.`]}):null,a?(0,G.jsx)(`p`,{"data-slot":`agent-setup-waiting`,role:`status`,className:`text-ui text-soft-foreground`,children:`Keep this open: the update starts here once the tasks finish. Closing it cancels the wait.`}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsxs)(`a`,{href:e.docsUrl,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-meta text-foreground underline underline-offset-2`,children:[`Official docs `,(0,G.jsx)(O,{"aria-hidden":`true`,className:`size-3`})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(T,{size:`sm`,variant:`ghost`,className:`font-normal`,onClick:l,children:p?`Cancel`:`Close`}),p&&t===`update`&&e.activeRuns>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,disabled:o,onClick:()=>s(!0),children:`Update now`}),(0,G.jsx)(T,{size:`sm`,className:`font-normal`,disabled:o||a,onClick:c,children:a?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(A,{}),` Waiting for tasks…`]}):`Update when they finish`})]}):p?(0,G.jsxs)(T,{size:`sm`,className:`font-normal`,disabled:o,onClick:()=>s(),children:[o?(0,G.jsx)(A,{}):null,t===`update`?`Update`:`Install`]}):null]})]})]})}function be({provider:e,entry:t,interactive:n,session:r,failure:i,busy:a,onTerminal:o,onCheck:s,onCancel:c}){return D.has(e)?r?(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(fe,{session:r,running:r.exitCode===null,installing:!1},r.id),i?(0,G.jsx)(`p`,{role:`alert`,className:`text-ui text-danger`,children:i}):null,r.exitCode===null?(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:c,children:`Cancel`})}):null]}):(0,G.jsxs)(`div`,{"data-slot":`agent-setup-terminal-sign-in`,className:`flex flex-col gap-2`,children:[(0,G.jsx)(`p`,{className:`text-ui text-muted-foreground`,children:n?`${b[e]} signs in from its own terminal. Open one here and follow it.`:`${b[e]} signs in from a terminal on your computer. Finish on your computer; this updates by itself.`}),t.loginCommand?(0,G.jsx)($,{command:t.loginCommand}):null,i?(0,G.jsx)(`p`,{role:`alert`,className:`text-ui text-danger`,children:i}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[n?(0,G.jsx)(T,{size:`sm`,className:`font-normal`,disabled:a||t.loginCommand===null,onClick:o,children:`Open terminal here`}):(0,G.jsx)(`span`,{"data-slot":`agent-setup-finish-on-computer`,className:`text-ui font-medium text-foreground`,children:`Finish on my computer`}),(0,G.jsx)(T,{size:`sm`,variant:`outline`,className:`font-normal`,onClick:s,children:`Check again`})]})]}):(0,G.jsx)(E,{provider:e,profileId:`default`,place:`attention`,inSheet:!0,compact:!n})}function $({command:e}){let t=async()=>{try{await te(e),_(`Command copied`)}catch{_(`Could not copy the command`,{tone:`danger`})}};return(0,G.jsxs)(`div`,{"data-slot":`agent-setup-command`,className:`flex items-center gap-2 rounded-md border border-border bg-card-2 px-3 py-2`,children:[(0,G.jsx)(`code`,{className:`min-w-0 flex-1 break-all font-mono text-meta text-foreground`,children:e}),(0,G.jsx)(T,{size:`sm`,variant:`ghost`,className:`shrink-0 font-normal`,onClick:()=>void t(),children:`Copy`})]})}function xe(){let[e,t]=I.useState(null);return{open:I.useCallback((e,n)=>{t({provider:e,action:n===`sign-in`?`sign-in`:n===`update`?`update`:`install`})},[]),element:e?(0,G.jsx)(Q,{provider:e.provider,action:e.action,open:!0,onOpenChange:e=>{e||t(null)}}):null}}export{oe as a,B as c,de as i,F as l,xe as n,ae as o,J as r,R as s,Q as t};
@@ -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{t as r}from"./utils-D6vflkwY.js";import{t as i}from"./project-router-CUgGEpgp.js";import{N as a}from"./run-actions-D2QcJwa6.js";import{B as o}from"./button-CSEYvv3h.js";import{r as s}from"./dist-CRisPV4Q.js";import{_ as c}from"./impact-model-BMHjhFuw.js";import{S as l,b as u,m as d,v as f,x as p}from"./composer-BdAI6c2J.js";import{t as m}from"./workflow-C6Wv2H83.js";import{i as h,r as g,t as _}from"./popover-DjHn4iDB.js";import{t as v}from"./icon-tooltip-kHRxVj4G.js";import{a as y,i as b,o as x,r as S,s as C,t as w}from"./command-C_kjiDlG.js";import{i as T}from"./chip-C-HRz7Zl.js";import"./reasoning-effort-pill-B7JL5GDb.js";import{T as E}from"./index-Dy4sBegL.js";var D=n();function O({name:e,route:t,selected:n,list:i,detail:a}){return(0,D.jsxs)(`div`,{"data-route":t,className:`flex h-full min-h-0 items-stretch`,children:[(0,D.jsx)(`section`,{"data-slot":`${e}-list`,className:r(`w-full min-h-0 flex-col overflow-y-auto overscroll-contain border-border md:flex md:w-[360px] md:shrink-0 md:border-r`,n?`hidden`:`flex`),children:i}),(0,D.jsx)(`section`,{"data-slot":`${e}-detail`,className:r(`min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,n?`flex`:`hidden md:flex`),children:a})]})}function k({resolved:e,dataSlot:t}){return e.providerPending||e.canRun?null:(0,D.jsxs)(`span`,{"data-slot":t,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[e.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,D.jsx)(i,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]})}var A=e(t(),1);function j({workflows:e,value:t,onChange:n,slotPrefix:i=`gh`}){let[a,c]=(0,A.useState)(!1),[u,d]=(0,A.useState)(``),f=(0,A.useRef)(null),v=p(e,u);return(0,D.jsxs)(_,{open:a,onOpenChange:e=>{c(e),e||d(``)},children:[(0,D.jsx)(h,{asChild:!0,children:(0,D.jsxs)(`button`,{type:`button`,"data-slot":`${i}-workflow-trigger`,"aria-label":`Choose a workflow`,className:r(T,t&&`border-foreground/60 font-mono text-meta font-semibold text-foreground`),children:[(0,D.jsx)(m,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),(0,D.jsx)(`span`,{className:`max-w-44 truncate`,children:t??`workflow`}),(0,D.jsx)(s,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,D.jsx)(g,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,D.jsxs)(w,{label:`Choose a workflow`,shouldFilter:!1,children:[(0,D.jsx)(y,{placeholder:`search workflows…`,value:u,onValueChange:d,onInput:()=>f.current?.scrollTo(0,0)}),(0,D.jsxs)(C,{ref:f,"data-slot":`${i}-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[v.length===0?(0,D.jsx)(S,{children:`Nothing matches.`}):null,(0,D.jsx)(b,{children:v.map(e=>{let r=t===e.name;return(0,D.jsxs)(x,{value:`workflow ${e.name}`,keywords:l(e.name,e.description),"data-slot":`${i}-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),c(!1)},children:[(0,D.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label text-muted-foreground`,children:e.description}):null,r?(0,D.jsx)(o,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]},e.name)})})]})]})})]})}function M({skills:e,skillUsage:t,selected:n,onToggle:i,maxSelections:p,slotPrefix:m=`gh`}){let[O,k]=(0,A.useState)(!1),[j,M]=(0,A.useState)(``),[N,P]=(0,A.useState)(null),F=(0,A.useRef)(null),{mostUsed:I,project:L,global:R}=f(u(e,j,t),t),z=(e,t)=>{let a=n.includes(e.name);return(0,D.jsxs)(x,{value:`skill ${e.name} ${e.path}`,keywords:l(e.name,e.description),"data-slot":`${m}-skill-option`,"data-skill":e.name,"data-selected":a?`true`:void 0,disabled:!a&&p!==void 0&&n.length>=p,onSelect:()=>i(e.name),children:[(0,D.jsx)(`span`,{className:r(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label text-muted-foreground`,children:e.description}):null,(0,D.jsx)(v,{label:`View skill`,children:(0,D.jsx)(`button`,{type:`button`,"data-slot":`${m}-skill-view`,"aria-label":`View skill ${e.name}`,onClick:t=>{t.preventDefault(),t.stopPropagation(),P(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,D.jsx)(c,{"aria-hidden":`true`,className:`size-3.5`})})}),a?(0,D.jsx)(o,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e.path)};return e.length===0?null:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(E,{skill:N,onClose:()=>P(null)}),(0,D.jsxs)(_,{open:O,onOpenChange:e=>{k(e),e||M(``)},children:[(0,D.jsx)(h,{asChild:!0,children:(0,D.jsxs)(`button`,{type:`button`,"data-slot":`${m}-skills-trigger`,"aria-label":`Choose skills`,className:r(T,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,D.jsx)(a,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),`skills`,n.length>0?` · ${n.length}`:``,(0,D.jsx)(s,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,D.jsx)(g,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,D.jsxs)(w,{label:`Choose skills`,shouldFilter:!1,children:[(0,D.jsx)(y,{placeholder:`search skills…`,value:j,onValueChange:M,onInput:()=>F.current?.scrollTo(0,0)}),(0,D.jsxs)(C,{ref:F,"data-slot":`${m}-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[I.length===0&&L.length===0&&R.length===0?(0,D.jsx)(S,{children:`Nothing matches.`}):null,I.length>0?(0,D.jsx)(b,{heading:`Most used`,children:I.map(e=>z(e,d(e)))}):null,L.length>0?(0,D.jsx)(b,{heading:`Project skills`,children:L.map(e=>z(e,!0))}):null,R.length>0?(0,D.jsx)(b,{heading:`Global`,children:R.map(e=>z(e,!1))}):null]})]})})]})]})}export{O as i,j as n,k as r,M 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{t as r}from"./utils-D6vflkwY.js";import{t as i}from"./project-router-Bek4dR86.js";import{N as a}from"./run-actions-CzNs18bI.js";import{B as o}from"./button-CSEYvv3h.js";import{r as s}from"./dist-CRisPV4Q.js";import{_ as c}from"./impact-model-D9LSXBsx.js";import{S as l,b as u,m as d,v as f,x as p}from"./composer-CPCdqFxK.js";import{t as m}from"./workflow-C6Wv2H83.js";import{i as h,r as g,t as _}from"./popover-DjHn4iDB.js";import{t as v}from"./icon-tooltip-kHRxVj4G.js";import{a as y,i as b,o as x,r as S,s as C,t as w}from"./command-C_kjiDlG.js";import{i as T}from"./chip-C-HRz7Zl.js";import"./reasoning-effort-pill-Cc7H5UbY.js";import{T as E}from"./index-CL6WgTsz.js";var D=n();function O({name:e,route:t,selected:n,list:i,detail:a}){return(0,D.jsxs)(`div`,{"data-route":t,className:`flex h-full min-h-0 items-stretch`,children:[(0,D.jsx)(`section`,{"data-slot":`${e}-list`,className:r(`w-full min-h-0 flex-col overflow-y-auto overscroll-contain border-border md:flex md:w-[360px] md:shrink-0 md:border-r`,n?`hidden`:`flex`),children:i}),(0,D.jsx)(`section`,{"data-slot":`${e}-detail`,className:r(`min-w-0 min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,n?`flex`:`hidden md:flex`),children:a})]})}function k({resolved:e,dataSlot:t}){return e.providerPending||e.canRun?null:(0,D.jsxs)(`span`,{"data-slot":t,className:`inline-flex flex-wrap items-center gap-1 text-xs text-muted-foreground`,children:[e.providerError?`Provider authentication could not be verified.`:`Connect an agent provider to run this item.`,(0,D.jsx)(i,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]})}var A=e(t(),1);function j({workflows:e,value:t,onChange:n,slotPrefix:i=`gh`}){let[a,c]=(0,A.useState)(!1),[u,d]=(0,A.useState)(``),f=(0,A.useRef)(null),v=p(e,u);return(0,D.jsxs)(_,{open:a,onOpenChange:e=>{c(e),e||d(``)},children:[(0,D.jsx)(h,{asChild:!0,children:(0,D.jsxs)(`button`,{type:`button`,"data-slot":`${i}-workflow-trigger`,"aria-label":`Choose a workflow`,className:r(T,t&&`border-foreground/60 font-mono text-meta font-semibold text-foreground`),children:[(0,D.jsx)(m,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),(0,D.jsx)(`span`,{className:`max-w-44 truncate`,children:t??`workflow`}),(0,D.jsx)(s,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,D.jsx)(g,{align:`start`,sideOffset:8,className:`w-[320px] max-w-[calc(100vw-2rem)] p-0`,children:(0,D.jsxs)(w,{label:`Choose a workflow`,shouldFilter:!1,children:[(0,D.jsx)(y,{placeholder:`search workflows…`,value:u,onValueChange:d,onInput:()=>f.current?.scrollTo(0,0)}),(0,D.jsxs)(C,{ref:f,"data-slot":`${i}-workflow-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[v.length===0?(0,D.jsx)(S,{children:`Nothing matches.`}):null,(0,D.jsx)(b,{children:v.map(e=>{let r=t===e.name;return(0,D.jsxs)(x,{value:`workflow ${e.name}`,keywords:l(e.name,e.description),"data-slot":`${i}-workflow-option`,"data-workflow":e.name,onSelect:()=>{n(r?null:e.name),c(!1)},children:[(0,D.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),e.description?(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label text-muted-foreground`,children:e.description}):null,r?(0,D.jsx)(o,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-primary`}):null]},e.name)})})]})]})})]})}function M({skills:e,skillUsage:t,selected:n,onToggle:i,maxSelections:p,slotPrefix:m=`gh`}){let[O,k]=(0,A.useState)(!1),[j,M]=(0,A.useState)(``),[N,P]=(0,A.useState)(null),F=(0,A.useRef)(null),{mostUsed:I,project:L,global:R}=f(u(e,j,t),t),z=(e,t)=>{let a=n.includes(e.name);return(0,D.jsxs)(x,{value:`skill ${e.name} ${e.path}`,keywords:l(e.name,e.description),"data-slot":`${m}-skill-option`,"data-skill":e.name,"data-selected":a?`true`:void 0,disabled:!a&&p!==void 0&&n.length>=p,onSelect:()=>i(e.name),children:[(0,D.jsx)(`span`,{className:r(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,D.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label text-muted-foreground`,children:e.description}):null,(0,D.jsx)(v,{label:`View skill`,children:(0,D.jsx)(`button`,{type:`button`,"data-slot":`${m}-skill-view`,"aria-label":`View skill ${e.name}`,onClick:t=>{t.preventDefault(),t.stopPropagation(),P(e)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,D.jsx)(c,{"aria-hidden":`true`,className:`size-3.5`})})}),a?(0,D.jsx)(o,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-primary`}):null]},e.path)};return e.length===0?null:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(E,{skill:N,onClose:()=>P(null)}),(0,D.jsxs)(_,{open:O,onOpenChange:e=>{k(e),e||M(``)},children:[(0,D.jsx)(h,{asChild:!0,children:(0,D.jsxs)(`button`,{type:`button`,"data-slot":`${m}-skills-trigger`,"aria-label":`Choose skills`,className:r(T,n.length>0&&`border-foreground/60 font-semibold text-foreground`),children:[(0,D.jsx)(a,{"aria-hidden":`true`,className:`size-3 shrink-0 text-violet`}),`skills`,n.length>0?` · ${n.length}`:``,(0,D.jsx)(s,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,D.jsx)(g,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,D.jsxs)(w,{label:`Choose skills`,shouldFilter:!1,children:[(0,D.jsx)(y,{placeholder:`search skills…`,value:j,onValueChange:M,onInput:()=>F.current?.scrollTo(0,0)}),(0,D.jsxs)(C,{ref:F,"data-slot":`${m}-skill-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[I.length===0&&L.length===0&&R.length===0?(0,D.jsx)(S,{children:`Nothing matches.`}):null,I.length>0?(0,D.jsx)(b,{heading:`Most used`,children:I.map(e=>z(e,d(e)))}):null,L.length>0?(0,D.jsx)(b,{heading:`Project skills`,children:L.map(e=>z(e,!0))}):null,R.length>0?(0,D.jsx)(b,{heading:`Global`,children:R.map(e=>z(e,!1))}):null]})]})})]})]})}export{O as i,j as n,k as r,M as t};
@@ -1,3 +1,3 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Qo as r,pr as i}from"./queries-hE7G6Kgl.js";import{Wt as a,t as o}from"./utils-D6vflkwY.js";import{c as s,t as c,y as l}from"./project-router-CUgGEpgp.js";import{c as u,g as d,h as f,u as p}from"./questions-DunziRyk.js";import{t as m}from"./createLucideIcon-BHp8sXmF.js";import{l as h}from"./reference-chip-CfXk1DW4.js";import{B as g,t as _}from"./button-CSEYvv3h.js";import{t as v}from"./circle-alert-ClwRNTQt.js";import{t as y}from"./status-dot-BXauQwic.js";import{r as b}from"./format-BUbPQpzw.js";import{s as x}from"./reference-conflict-action-BSPbRKbm.js";import{t as S}from"./textarea-B1PDsZ3z.js";import{n as C}from"./chip-C-HRz7Zl.js";import{r as w,t as T}from"./enter-key-Bsscx4Nx.js";import{t as E}from"./ask-text-BCgKRzhp.js";var D=m(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),O=e(t(),1),k=n();function A(e,t){switch(e.reason){case`answered`:return e.answeredIn?.startsWith(`task:`)?`Answered in the task`:e.answeredIn?.startsWith(`manager:`)?`Answered in the manager’s chat`:`Answered`;case`dismissed`:return`Closed: dismissed by you`;case`replaced`:return`Closed: replaced`;case`retracted`:return`Closed: withdrawn by the ${t}`;case`expired`:return`Closed: expired`;case`ended`:return`Closed: task ended`}}function j({closed:e,questions:t,asker:n,id:r,link:i,className:a}){let o=e.at?b(e.at):``,s=e.detail??(e.reason===`replaced`?`A newer “${t[0]?.header??`question`}” question replaced this one.`:e.reason===`dismissed`&&n===`manager`?`The manager was told you skipped it.`:void 0);return(0,k.jsxs)(`div`,{id:r,tabIndex:r?-1:void 0,"data-slot":`ask-closed`,"data-reason":e.reason,className:[`flex max-w-full flex-col gap-1 rounded-lg border border-dashed border-border px-3 py-2 text-label text-muted-foreground outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,a].filter(Boolean).join(` `),children:[(0,k.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[(0,k.jsx)(h,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,k.jsx)(`span`,{"data-slot":`ask-closed-reason`,className:`font-medium text-soft-foreground`,children:A(e,n)}),o?(0,k.jsxs)(`span`,{"aria-hidden":`true`,children:[`· `,o,` ago`]}):null,t.map((e,t)=>(0,k.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px text-micro font-semibold`,children:e.header},t))]}),t.map((e,t)=>(0,k.jsx)(`s`,{className:`break-words`,children:e.question},t)),e.reason===`answered`&&e.answer?(0,k.jsx)(`span`,{"data-slot":`ask-closed-answer`,className:`break-words text-foreground`,children:e.answer}):null,s||i?(0,k.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[s?(0,k.jsx)(`span`,{className:`break-words`,children:s}):null,i]}):null]})}function M({detail:e,onDismiss:t,disabled:n}){return(0,k.jsxs)(`div`,{"data-slot":`question-stale`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 rounded-md border border-pending/40 bg-pending/10 px-2.5 py-1.5 text-label text-foreground`,children:[(0,k.jsx)(v,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-pending-strong`}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`May be out of date: `,e]}),(0,k.jsx)(_,{variant:`ghost`,size:`sm`,"data-slot":`question-stale-dismiss`,className:`pointer-coarse:min-h-11`,disabled:n,onClick:t,children:`Dismiss as out of date`})]})}function N({label:e,onUndo:t}){return(0,k.jsxs)(`div`,{"data-slot":`question-dismissing`,className:`flex flex-wrap items-center gap-2 rounded-lg border border-dashed border-border px-3 py-2 text-label text-muted-foreground`,children:[(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Dismissed «`,e,`»`]}),(0,k.jsx)(_,{variant:`outline`,size:`sm`,"data-slot":`question-undo`,className:`pointer-coarse:min-h-11`,onClick:t,children:`Undo`})]})}var P=`I need more information to answer this — please explain the context and ask again.`;function F(e,t){let n=t.split(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Qo as r,pr as i}from"./queries-BeoT2lBk.js";import{Wt as a,t as o}from"./utils-D6vflkwY.js";import{c as s,t as c,y as l}from"./project-router-Bek4dR86.js";import{c as u,g as d,h as f,u as p}from"./questions-BVPh0WiE.js";import{t as m}from"./createLucideIcon-BHp8sXmF.js";import{l as h}from"./reference-chip-MmzMis9y.js";import{B as g,t as _}from"./button-CSEYvv3h.js";import{t as v}from"./circle-alert-ClwRNTQt.js";import{t as y}from"./status-dot-BXauQwic.js";import{r as b}from"./format-BUbPQpzw.js";import{s as x}from"./reference-conflict-action-TsKRSHEB.js";import{t as S}from"./textarea-B1PDsZ3z.js";import{n as C}from"./chip-C-HRz7Zl.js";import{r as w,t as T}from"./enter-key-Bsscx4Nx.js";import{t as E}from"./ask-text-BCgKRzhp.js";var D=m(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),O=e(t(),1),k=n();function A(e,t){switch(e.reason){case`answered`:return e.answeredIn?.startsWith(`task:`)?`Answered in the task`:e.answeredIn?.startsWith(`manager:`)?`Answered in the manager’s chat`:`Answered`;case`dismissed`:return`Closed: dismissed by you`;case`replaced`:return`Closed: replaced`;case`retracted`:return`Closed: withdrawn by the ${t}`;case`expired`:return`Closed: expired`;case`ended`:return`Closed: task ended`}}function j({closed:e,questions:t,asker:n,id:r,link:i,className:a}){let o=e.at?b(e.at):``,s=e.detail??(e.reason===`replaced`?`A newer “${t[0]?.header??`question`}” question replaced this one.`:e.reason===`dismissed`&&n===`manager`?`The manager was told you skipped it.`:void 0);return(0,k.jsxs)(`div`,{id:r,tabIndex:r?-1:void 0,"data-slot":`ask-closed`,"data-reason":e.reason,className:[`flex max-w-full flex-col gap-1 rounded-lg border border-dashed border-border px-3 py-2 text-label text-muted-foreground outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,a].filter(Boolean).join(` `),children:[(0,k.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1`,children:[(0,k.jsx)(h,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,k.jsx)(`span`,{"data-slot":`ask-closed-reason`,className:`font-medium text-soft-foreground`,children:A(e,n)}),o?(0,k.jsxs)(`span`,{"aria-hidden":`true`,children:[`· `,o,` ago`]}):null,t.map((e,t)=>(0,k.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-px text-micro font-semibold`,children:e.header},t))]}),t.map((e,t)=>(0,k.jsx)(`s`,{className:`break-words`,children:e.question},t)),e.reason===`answered`&&e.answer?(0,k.jsx)(`span`,{"data-slot":`ask-closed-answer`,className:`break-words text-foreground`,children:e.answer}):null,s||i?(0,k.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[s?(0,k.jsx)(`span`,{className:`break-words`,children:s}):null,i]}):null]})}function M({detail:e,onDismiss:t,disabled:n}){return(0,k.jsxs)(`div`,{"data-slot":`question-stale`,className:`flex flex-wrap items-center gap-x-2 gap-y-1 rounded-md border border-pending/40 bg-pending/10 px-2.5 py-1.5 text-label text-foreground`,children:[(0,k.jsx)(v,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-pending-strong`}),(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`May be out of date: `,e]}),(0,k.jsx)(_,{variant:`ghost`,size:`sm`,"data-slot":`question-stale-dismiss`,className:`pointer-coarse:min-h-11`,disabled:n,onClick:t,children:`Dismiss as out of date`})]})}function N({label:e,onUndo:t}){return(0,k.jsxs)(`div`,{"data-slot":`question-dismissing`,className:`flex flex-wrap items-center gap-2 rounded-lg border border-dashed border-border px-3 py-2 text-label text-muted-foreground`,children:[(0,k.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[`Dismissed «`,e,`»`]}),(0,k.jsx)(_,{variant:`outline`,size:`sm`,"data-slot":`question-undo`,className:`pointer-coarse:min-h-11`,onClick:t,children:`Undo`})]})}var P=`I need more information to answer this — please explain the context and ask again.`;function F(e,t){let n=t.split(`
2
2
  `);if(n.length!==e.questions.length)return null;let r=n.map((t,n)=>{let r=`${e.questions[n]?.header??``}: `;return t.startsWith(r)?{header:e.questions[n].header,value:t.slice(r.length)}:null});return r.every(e=>e!==null&&e.value.trim()!==``)?r:null}function I(e,t){if(t===`I need more information to answer this — please explain the context and ask again.`)return{picks:[],moreInfo:!0};let n=e.options.map(e=>e.label).sort((e,t)=>t.length-e.length),r=[],i=t;for(;i!==``;){let e=n.find(e=>!r.includes(e)&&(i===e||i.startsWith(`${e}, `)));if(!e)break;r.push(e),i=i.slice(Math.min(i.length,e.length+2))}return i===``?{picks:r}:{picks:r,own:i}}function L({questions:e,lines:t,slot:n}){let r=(0,O.useContext)(E);return(0,k.jsx)(`dl`,{"data-slot":n,className:`flex flex-col gap-2`,children:t.map(({header:t,value:n},i)=>{let a=e[i],o=a?I(a,n):{picks:[],own:n},s=a?.options.filter(e=>o.picks.includes(e.label)&&e.description)??[];return(0,k.jsxs)(`div`,{"data-slot":`ask-answer`,className:`flex min-w-0 flex-col gap-1`,children:[(0,k.jsxs)(`dt`,{className:`eyebrow text-muted-foreground`,children:[t,(0,k.jsx)(`span`,{className:`sr-only`,children:`:`})]}),(0,k.jsxs)(`dd`,{className:`min-w-0`,children:[(0,k.jsxs)(`ul`,{className:`flex flex-wrap gap-1.5`,children:[a?.options.map(e=>{let t=o.picks.includes(e.label);return(0,k.jsx)(`li`,{className:`flex min-w-0 max-w-full`,children:(0,k.jsxs)(C,{active:t,title:e.description===void 0?void 0:r.plain(e.description),icon:t?(0,k.jsx)(g,{"aria-hidden":`true`,className:`size-3 shrink-0 text-success`}):void 0,children:[r.plain(e.label),t?(0,k.jsx)(`span`,{className:`sr-only`,children:` (chosen)`}):null]})},e.label)}),o.own?(0,k.jsx)(`li`,{className:`flex min-w-0 max-w-full`,children:(0,k.jsxs)(C,{active:!0,dashed:!0,"data-answer":`other`,icon:(0,k.jsx)(D,{"aria-hidden":`true`,className:`size-3 shrink-0`}),children:[(0,k.jsx)(`span`,{className:`sr-only`,children:`Own answer: `}),o.own]})}):null,o.moreInfo?(0,k.jsx)(`li`,{className:`flex min-w-0 max-w-full`,children:(0,k.jsxs)(C,{active:!0,dashed:!0,"data-answer":`more-info`,children:[`Need more info`,(0,k.jsx)(`span`,{className:`sr-only`,children:` (chosen)`})]})}):null]}),s.map(e=>(0,k.jsx)(`p`,{"data-slot":`ask-answer-description`,className:`mt-1 break-words text-meta text-muted-foreground`,children:r.render(e.description)},e.label))]})]},i)})})}var R=new Map,z=(e,t)=>JSON.stringify([e,t.id,t.questions.map(e=>[e.header,e.question,e.options.map(e=>e.label)])]);function B(e,t){return R.get(z(e,t))??{}}function V(e,t,n){R.set(z(e,t),n)}function H(e,t){R.delete(z(e,t))}var U={labels:[]},W=i({status:`waiting`}),G=e=>e.other?.trim().replace(/\s+/g,` `)??``,K=e=>e.moreInfo===!0||e.labels.length>0||G(e)!==``;function q(e,t){if(t.moreInfo)return`${e.header}: ${P}`;let n=G(t);return`${e.header}: ${[...t.labels,...n?[n]:[]].join(`, `)}`}function J({ask:e,run:t}){if((0,O.useEffect)(()=>{e.resolved&&H(t.id,e)},[e,t.id]),e.closed&&(e.closed.reason!==`answered`||e.closed.answeredIn))return(0,k.jsx)(j,{closed:e.closed,questions:e.questions,asker:`agent`,link:e.closed.reason===`replaced`?(0,k.jsx)(c,{to:{hash:`#ask`},"data-slot":`ask-closed-newer`,className:`font-medium text-foreground underline underline-offset-4`,children:`Go to the newer question ↓`}):void 0});let n=e.resolved&&e.answer?F(e,e.answer):null;return n?(0,k.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,className:`flex flex-col gap-2 rounded-lg border border-border bg-card px-3.5 py-2.5 text-label text-muted-foreground`,children:[(0,k.jsxs)(`span`,{className:`flex items-center gap-1 text-soft-foreground`,children:[(0,k.jsx)(g,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`Answered`]}),(0,k.jsx)(L,{questions:e.questions,lines:n,slot:`ask-answers`})]}):e.resolved?(0,k.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`true`,className:`rounded-lg border border-border bg-card px-3.5 py-2.5 text-label text-muted-foreground`,children:[(0,k.jsx)(g,{"aria-hidden":`true`,className:`mr-1 inline size-3.5 align-[-2px] text-soft-foreground`}),(0,k.jsx)(`span`,{className:`text-soft-foreground`,children:`Answered`}),e.answer?(0,k.jsx)(`span`,{className:`ml-1.5 break-words whitespace-pre-line text-foreground`,children:e.answer}):null]}):(0,k.jsx)(X,{ask:e,run:t})}function Y(e,t){let n=d(!1).data?.open.find(n=>n.source.kind===`task`&&n.source.runId===e.id&&n.key.endsWith(`:${t}`)),r=s();return n?n.key:r?a({kind:`task`,projectId:r,runId:e.id,requestId:t}):void 0}function X({ask:e,run:t}){let n=x(t,void 0,`ask_answer`,e.id),i=r(),a=Y(t,e.id),o=f().find(e=>e.key===a&&!e.error),s=t.asks?.find(t=>t.requestId===e.id&&!t.closed)?.stale;return a&&o?(0,k.jsx)(N,{label:o.label,onUndo:()=>p(a)}):(0,k.jsxs)(k.Fragment,{children:[s&&a?(0,k.jsx)(M,{detail:s.detail,disabled:n.isPending,onDismiss:()=>u(i,a,e.questions[0]?.header??`Question`)}):null,(0,k.jsx)(Z,{ask:e,ownerId:t.id,delivery:n,asker:e.fromWorkflow?`The workflow is asking`:`The agent is asking`})]})}function Z({ask:e,ownerId:t,delivery:n,asker:r,composerBelow:i=!0,framed:a=!0}){let o=n.blockedBy!==void 0,s=e.questions,u=s.length===1&&s[0]?.multiSelect!==!0,[d,f]=(0,O.useState)(()=>B(t,e)),p=(n,r)=>f(i=>{let a={...i,[n]:r};return V(t,e,a),a}),m=e=>d[e]??U,h=e=>K(m(e)),g=s.every((e,t)=>h(t)),v=s.some((e,t)=>h(t))?s.filter((e,t)=>!h(t)).map(e=>e.header):[],b=()=>void n.send(s.map((e,t)=>q(e,m(t))).join(`
3
3
  `)),x=n.mode===`resume`,S=(0,O.useRef)(null),{hash:C}=l();return(0,O.useEffect)(()=>{C!==`#ask`||!S.current||$(S.current)},[C]),(0,k.jsxs)(`div`,{ref:S,"data-slot":`ask-card`,"data-resolved":`false`,"data-delivery":n.mode,"aria-busy":n.isPending||void 0,"data-tone":W.tone,className:a?`rounded-lg border border-info/30 bg-info/5 px-4 pt-3.5 pb-3.5`:void 0,children:[a||n.isPending?(0,k.jsxs)(`div`,{className:`mb-2.5 flex items-center gap-2`,children:[a?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(y,{tone:W.tone,pulse:W.pulse}),(0,k.jsx)(`span`,{"data-slot":`ask-asker`,className:`text-label font-semibold text-foreground`,children:r})]}):null,n.isPending?(0,k.jsx)(`span`,{"data-slot":`ask-sending`,role:`status`,className:`ml-auto text-meta text-muted-foreground`,children:`Sending…`}):null]}):null,(0,k.jsx)(`div`,{className:`flex flex-col gap-4`,children:s.map((e,t)=>(0,k.jsx)(ee,{question:e,disabled:n.isPending||o,oneTap:u,answer:m(t),onChange:e=>{o||p(t,e)},onSubmit:t=>{!o&&K(t)&&n.send(q(e,t))}},e.id??t))}),u?x?(0,k.jsx)(`p`,{"data-slot":`ask-resume-hint`,className:`mt-3 text-meta text-muted-foreground`,children:`The session has ended — your answer reopens it and goes to the agent.`}):null:(0,k.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-2.5 gap-y-1.5`,children:[(0,k.jsx)(_,{size:`sm`,disabled:n.isPending||o||!g,className:`pointer-coarse:min-h-11 disabled:bg-muted disabled:text-muted-foreground disabled:opacity-100 disabled:shadow-[inset_0_0_0_1px_var(--border)]`,onClick:b,children:x?`Send answer & reopen`:`Send answer`}),(0,k.jsx)(`span`,{"data-slot":x?`ask-resume-hint`:`ask-hint`,className:`min-w-0 text-meta text-muted-foreground`,children:x?`the session has ended — sending reopens it`:`${s.length>1?`answer each question`:`pick one or more`}${i?` — or type a reply below`:``}`})]}),!u&&v.length>0?(0,k.jsxs)(`p`,{"data-slot":`ask-unanswered`,className:`mt-2 text-meta text-muted-foreground`,children:[`unanswered: `,v.join(`, `)]}):null,n.blockedBy===`provider`?(0,k.jsxs)(`div`,{"data-slot":`ask-provider-gate`,className:`mt-3 flex flex-wrap items-center gap-1.5 text-label text-muted-foreground`,children:[(0,k.jsx)(`span`,{children:n.reason}),(0,k.jsx)(c,{to:`/settings/agents#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}):null,n.blockedBy===`no-session`?(0,k.jsx)(`p`,{"data-slot":`ask-no-session`,className:`mt-3 text-label text-muted-foreground`,children:n.reason}):null,n.error?(0,k.jsx)(`p`,{"data-slot":`ask-error`,role:`alert`,className:`mt-3 text-label text-danger`,children:n.error}):null]})}function ee({question:e,disabled:t,oneTap:n,answer:r,onChange:i,onSubmit:a}){let o=e.multiSelect===!0,s=(0,O.useContext)(E),c=w(),l=(0,O.useId)(),u=r.other!==void 0,d=(0,O.useRef)(null),[f,p]=(0,O.useState)(!1);(0,O.useEffect)(()=>{f&&(d.current?.focus(),p(!1))},[f]);let m=e=>n?a(e):i(e),h=e=>{if(!o){m({labels:[e]});return}i({labels:r.labels.includes(e)?r.labels.filter(t=>t!==e):[...r.labels,e],...u?{other:r.other}:{}})};return(0,k.jsxs)(`div`,{role:`group`,"aria-labelledby":l,children:[(0,k.jsxs)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`rounded-md bg-primary px-1.5 py-0.5 eyebrow text-primary-foreground`,children:e.header}),o?(0,k.jsx)(`span`,{"aria-hidden":`true`,className:`ml-auto text-micro text-soft-foreground`,children:`select all that apply`}):null]}),(0,k.jsxs)(`p`,{id:l,className:`mb-2.5 break-words text-body font-semibold text-foreground`,children:[s.render(e.question),o?(0,k.jsx)(`span`,{className:`sr-only`,children:` (select all that apply)`}):null]}),(0,k.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.options.map(e=>(0,k.jsx)(te,{label:e.label,description:e.description,checkbox:o,selected:r.labels.includes(e.label),disabled:t,onClick:()=>h(e.label)},e.label)),(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,k.jsx)(Q,{slot:`ask-other`,selected:u,disabled:t,onClick:()=>{if(u){i({labels:r.labels});return}i({labels:o?r.labels:[],other:``}),p(!0)},children:`Other…`}),(0,k.jsx)(Q,{slot:`ask-more-info`,selected:r.moreInfo===!0,disabled:t,onClick:()=>r.moreInfo?i(U):m({labels:[],moreInfo:!0}),children:`Need more info`})]}),u?(0,k.jsxs)(`div`,{"data-slot":`ask-other-input`,className:`flex flex-col gap-2`,children:[(0,k.jsx)(S,{ref:d,rows:2,"aria-label":`Your own answer: ${s.plain(e.question)}`,placeholder:`Type your own answer`,value:r.other,disabled:t,enterKeyHint:n&&!c?`send`:`enter`,onChange:e=>i({...r,other:e.target.value}),onKeyDown:e=>{let t=T({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing,keyCode:e.keyCode},c);n&&t&&(e.preventDefault(),a(r))}}),n?(0,k.jsx)(`div`,{children:(0,k.jsx)(_,{size:`sm`,disabled:t||!K(r),onClick:()=>a(r),children:`Send answer`})}):null]}):null]})]})}function te({label:e,description:t,checkbox:n,selected:r,disabled:i,onClick:a}){let s=(0,O.useContext)(E),c=(0,O.useId)(),l=o(`flex w-full flex-col gap-0.5 rounded-md border px-3.5 py-2.5 text-left outline-none transition-colors motion-reduce:transition-none pointer-coarse:min-h-11`,r?`border-primary/60 bg-primary/[0.06]`:`border-border bg-card`),u=(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-ui font-semibold text-foreground`,children:[n?(0,k.jsx)(`span`,{"aria-hidden":!0,className:o(`flex size-4 shrink-0 items-center justify-center rounded border text-micro`,r?`border-primary bg-primary text-primary-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,k.jsx)(`span`,{className:`min-w-0 break-words`,children:s.render(e,`option`)})]}),t?(0,k.jsx)(`span`,{id:c,className:`min-w-0 break-words text-label text-muted-foreground`,children:s.render(t,`option`)}):null]});return s.interactive(e)||t!==void 0&&s.interactive(t)?(0,k.jsxs)(`div`,{"data-slot":`ask-choice`,className:o(l,`relative has-[>button:hover]:border-primary/50 has-[>button:hover]:bg-primary/[0.06]`,`has-[>button:focus-visible]:ring-[3px] has-[>button:focus-visible]:ring-ring/50`,i&&`opacity-50`),children:[(0,k.jsx)(`button`,{type:`button`,disabled:i,"aria-pressed":r,"aria-label":s.plain(e),...t?{"aria-describedby":c}:{},onClick:a,className:`absolute inset-0 rounded-md outline-none`}),u]}):(0,k.jsx)(`button`,{type:`button`,"data-slot":`ask-choice`,disabled:i,"aria-pressed":r,onClick:a,className:o(l,`focus-visible:ring-[3px] focus-visible:ring-ring/50`,`hover:border-primary/50 hover:bg-primary/[0.06] disabled:pointer-events-none disabled:opacity-50`),children:u})}function Q({slot:e,selected:t,disabled:n,onClick:r,children:i}){return(0,k.jsx)(`button`,{type:`button`,"data-slot":e,disabled:n,"aria-pressed":t,onClick:r,className:o(`rounded-md border border-dashed px-3 py-1.5 text-label font-medium text-muted-foreground outline-none transition-colors motion-reduce:transition-none`,`focus-visible:ring-[3px] focus-visible:ring-ring/50 pointer-coarse:min-h-11 pointer-coarse:px-3.5`,`hover:border-primary/50 hover:bg-primary/[0.06] hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,t?`border-primary/60 bg-primary/[0.06] text-foreground`:`border-border bg-card`),children:i})}function $(e){e.scrollIntoView?.({block:`center`}),e.querySelector(`button, input, textarea`)?.focus()}function ne(e){let t=e.querySelectorAll(`[data-slot="ask-card"][data-resolved="false"]`);return t.length>0?t[t.length-1]:null}export{H as a,N as c,$ as i,j as l,Z as n,L as o,ne as r,F as s,J as t,M as u};