@open-mercato/cezar 0.21.0-pr2498.6331 → 0.21.0-pr2498.6331.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/web/dist/assets/{active-forge-Dwq789DN.js → active-forge-BtA41yqu.js} +1 -1
- package/web/dist/assets/{add-account-host-B9PMxJNV.js → add-account-host-D-oZ2ZEP.js} +1 -1
- package/web/dist/assets/{agent-task-pickers-CdQljEWX.js → agent-task-pickers-B2Eaiu-s.js} +1 -1
- package/web/dist/assets/{ask-card-DKYu2N_y.js → ask-card-CVqluuwp.js} +1 -1
- package/web/dist/assets/{assets-view-D-1dKZOy.js → assets-view-B4jQ3vQF.js} +1 -1
- package/web/dist/assets/{automation-format-DWkTB0R1.js → automation-format-DToN5xfT.js} +1 -1
- package/web/dist/assets/{automations-route-CKIsZ5Lj.js → automations-route-BC1GWcEy.js} +1 -1
- package/web/dist/assets/{cache-status-CQlDe8Eb.js → cache-status-4_ZlVmbv.js} +1 -1
- package/web/dist/assets/{command-BgBpLKYX.js → command-DLEgTYTp.js} +1 -1
- package/web/dist/assets/{commit-list-BoH_fwlG.js → commit-list-DVmgHzBY.js} +1 -1
- package/web/dist/assets/{compare-variants-D59SY6Z2.js → compare-variants-BoagGCmr.js} +1 -1
- package/web/dist/assets/{composer-Dv0y059k.js → composer-CMFOAl1V.js} +1 -1
- package/web/dist/assets/{composer-attachments-CHWr0yhc.js → composer-attachments-pfbcBnl_.js} +1 -1
- package/web/dist/assets/{dashboard-KjhF5MN6.js → dashboard-fVnpPqKL.js} +1 -1
- package/web/dist/assets/{decision-sources-Dnlg3yd8.js → decision-sources-CTqc76SO.js} +1 -1
- package/web/dist/assets/{design-note-popup-D5m53gtY.js → design-note-popup-CYbWcKiE.js} +1 -1
- package/web/dist/assets/{file-preview-YElcu1xa.js → file-preview-CMpGrEqT.js} +1 -1
- package/web/dist/assets/{git-tab-loading-Cd-J2t1N.js → git-tab-loading-B4Gym6lK.js} +1 -1
- package/web/dist/assets/{github-BZAKqzBY.js → github-6MrT4jz8.js} +1 -1
- package/web/dist/assets/{global-tasks-DKszpmPe.js → global-tasks-DAjM1opJ.js} +1 -1
- package/web/dist/assets/{host-usage-BKJFV0VW.js → host-usage-DZHi5UG_.js} +1 -1
- package/web/dist/assets/{impact-control-DKBfGyR4.js → impact-control-Dsdm9QKF.js} +1 -1
- package/web/dist/assets/{impact-model-Dq_ZglsM.js → impact-model-Dn_guR3S.js} +1 -1
- package/web/dist/assets/{index-Ch3mvQqM.js → index-CmuEcgSz.js} +4 -4
- package/web/dist/assets/{keyboard-inset-CLcx0471.js → keyboard-inset-BZ_CPEYj.js} +1 -1
- package/web/dist/assets/{manager-approval-Bo9ESfly.js → manager-approval-2kcDTd_y.js} +1 -1
- package/web/dist/assets/{manager-approvals-lK1vf3Hl.js → manager-approvals-ninQZos6.js} +1 -1
- package/web/dist/assets/{manager-chat-DXAfjz5X.js → manager-chat-4B9GnkIL.js} +1 -1
- package/web/dist/assets/{manager-index-CPEnxAR1.js → manager-index-BKOGt0Xl.js} +1 -1
- package/web/dist/assets/{manager-new-vuyD4DfT.js → manager-new-D_EWGJDQ.js} +1 -1
- package/web/dist/assets/{manager-now-fLLYRY5N.js → manager-now-Cad5G7Pm.js} +1 -1
- package/web/dist/assets/{manager-settings-DNmUBl0c.js → manager-settings-DmRWL-vS.js} +1 -1
- package/web/dist/assets/{managers-XxR9VkFB.js → managers-BPDUfsAp.js} +1 -1
- package/web/dist/assets/{mascot-picker-DJ2V7E48.js → mascot-picker-C_fD-oHu.js} +1 -1
- package/web/dist/assets/{phone-app-PuqSAX5l.js → phone-app-p_yS8Txg.js} +1 -1
- package/web/dist/assets/{plan-usage-DHvUCR47.js → plan-usage-k846Eayo.js} +1 -1
- package/web/dist/assets/{project-router-DzrdQl7o.js → project-router-jwkbmkUy.js} +1 -1
- package/web/dist/assets/{project-terminal-D8LY-AGS.js → project-terminal-tsZHXET9.js} +2 -2
- package/web/dist/assets/{queries-xqgnsU4z.js → queries-Cwkv3B0F.js} +1 -1
- package/web/dist/assets/{questions-DcWmawf9.js → questions-DPXsqwIB.js} +1 -1
- package/web/dist/assets/{questions-route-DWuvbBBR.js → questions-route-BCswpu9Z.js} +1 -1
- package/web/dist/assets/{reasoning-effort-pill-Ba1wN7x5.js → reasoning-effort-pill-7_ZzbUCI.js} +1 -1
- package/web/dist/assets/{reference-chip-DaLdfQZ2.js → reference-chip-BmyQH_ub.js} +1 -1
- package/web/dist/assets/{reference-conflict-action-Dqb3RYE3.js → reference-conflict-action-BhHcpIRH.js} +1 -1
- package/web/dist/assets/{repo-git-jRKA0jo_.js → repo-git-DbZHkk1W.js} +1 -1
- package/web/dist/assets/{review-comments-block-_NbQfjgh.js → review-comments-block-DfI0strR.js} +1 -1
- package/web/dist/assets/{run-actions-D8pJsnJR.js → run-actions-jZ19SNcg.js} +1 -1
- package/web/dist/assets/{run-confirm-dialog-CGXYpN1v.js → run-confirm-dialog-CnY3owNz.js} +1 -1
- package/web/dist/assets/{run-diff-BVZWAhUl.js → run-diff-Bh-q3uGA.js} +1 -1
- package/web/dist/assets/{skills-DYpwMKcS.js → skills-Gygkh75l.js} +1 -1
- package/web/dist/assets/{task-commits-Bj5a351H.js → task-commits-Cp9tKgvD.js} +1 -1
- package/web/dist/assets/{task-graph-B2K5SM8a.js → task-graph-B1NnKXMn.js} +1 -1
- package/web/dist/assets/{task-notes-Czcfgo_F.js → task-notes-ANUlwUKt.js} +1 -1
- package/web/dist/assets/{task-workspace-DNwNbuA6.js → task-workspace-Bx9Yh1d6.js} +3 -3
- package/web/dist/assets/{telemetry-0nx_MWzu.js → telemetry-Dsu-7yZb.js} +1 -1
- package/web/dist/assets/{terminal-drawer-DEdrfC7Z.js → terminal-drawer-C5TeIg-_.js} +1 -1
- package/web/dist/assets/{terminal-pane-oQKuA09l.js → terminal-pane-D5yV-wBX.js} +1 -1
- package/web/dist/assets/{terminal-scope-BfEhD4M8.js → terminal-scope-BVqJNood.js} +1 -1
- package/web/dist/assets/{thread-items-BmUWyMgL.js → thread-items-BLBLFMk2.js} +1 -1
- package/web/dist/assets/{tracker-B3M_llNT.js → tracker-COWFF_pW.js} +1 -1
- package/web/dist/assets/{tree-pane-resize-BIwaTBC8.js → tree-pane-resize-DKHPlBnI.js} +1 -1
- package/web/dist/assets/{use-my-messages-nav-P_CTHG5r.js → use-my-messages-nav-NAWRdOEQ.js} +1 -1
- package/web/dist/assets/{workflow-graph-DfjcL5P9.js → workflow-graph-BW-TY0vH.js} +1 -1
- package/web/dist/assets/{worktree-lifecycle-DXJ2n58y.js → worktree-lifecycle-HhWLaJEw.js} +1 -1
- package/web/dist/assets/{worktree-lifecycle-operation-crrE73au.js → worktree-lifecycle-operation-CAq9_lx3.js} +1 -1
- 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-pr2498.6331",
|
|
3
|
+
"version": "0.21.0-pr2498.6331.2",
|
|
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-pr2498.6331",
|
|
60
|
-
"@open-mercato/cezar-contract": "0.21.0-pr2498.6331",
|
|
59
|
+
"@open-mercato/cezar-api-client": "0.21.0-pr2498.6331.2",
|
|
60
|
+
"@open-mercato/cezar-contract": "0.21.0-pr2498.6331.2",
|
|
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-
|
|
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-Cwkv3B0F.js";import{c as i}from"./project-router-jwkbmkUy.js";import{t as a}from"./createLucideIcon-BHp8sXmF.js";var o=a(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),s=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`}]]),c=e(t(),1),l={github:`gh`};function u(e){return l[e]}function d(e){return`the ${e} CLI is not installed or not logged in — run \`${e} auth login\``}function f(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=u(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:d(a)}}function p(){let e=n().data,t=r().data,a=i();return(0,c.useMemo)(()=>f(e,t,a),[e,t,a])}export{s as n,o as r,p 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{Go as r,Kt as i,O as a,R as o,Wo as s,Xa as c,bn as l,c as u,ht as d,i as f,kr as p,nn as m,p as h,qo as g,r as _,st as v,ui as y,v as b,w as x,yn as S}from"./queries-xqgnsU4z.js";import{st as C,t as w}from"./utils-BqOIVEJr.js";import{f as T}from"./project-router-DzrdQl7o.js";import{r as E}from"./toaster-BMipmHDN.js";import{A as D,C as ee,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-DHvUCR47.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-gNzgdKDO.js";import{r as he}from"./dist-C6DsSlbr.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-BE41nYi1.js";import{a as Ce,i as we,p as Te,r as Ee,t as De}from"./dropdown-menu-l1zNfazK.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-DswGcrs0.js";import{t as I}from"./spinner-Dp0xaGds.js";import{t as L}from"./input-DiWD6Sks.js";import{a as je,i as Me,n as Ne,o as Pe,r as Fe,t as Ie}from"./dialog-BbiTsOGC.js";import{t as Le}from"./clipboard-DvCUPLwM.js";import{r as Re}from"./phone-app-PuqSAX5l.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 p&&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 p&&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:w(`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=>D[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])),ct=st(`terminal`),lt=st(`key`);function ut(e){let{mono:t,ring:n}=W[e];return{mono:t,color:`var(--runner-mark-${e})`,ring:n===!0}}function dt(e){if(e)try{return new URL(e).host}catch{return}}function ft(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 pt(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 G({provider:e,small:t=!1,className:n}){let r=ut(e);return(0,R.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`runner-mark`,className:w(`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 mt=(0,B.createContext)(void 0),ht=()=>(0,B.useContext)(mt),gt=`(max-width: 767px)`,_t=(e,t)=>[...S.agentLogin(e,t),`start-error`],vt=()=>Promise.resolve(null);function K(e,t){let n=g(),r=ne(e,t),i=O(e,t),a=s({queryKey:_t(e,t),queryFn:vt,enabled:!1,staleTime:1/0}).data??null,c=h().data?.profiles,l=c?.find(n=>n.provider===e&&n.id===t),u=l?.label??(t==="default"?`Default`:t),d=`${U(e)} · ${u}`,y=o().data?.capabilities?.localHandoff===!1||Re(),x=ze(gt),S=m(),C=b(),w=v(),T=r=>n.setQueryData(_t(e,t),r);return{session:r,news:i,startError:a,profiles:c,profile:l,account:u,who:d,remote:y,narrow:x,view:a?`failed`:f(r)?`signing`:r?.phase===`connected`?`success`:r?.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 p&&e.command?{command:e.command}:{}})})},checkAgain:()=>{w.mutate(t==="default"?`default:${e}`:t,{onSuccess:e=>{e.status.status===`connected`?E(`${d} is signed in. Resuming what waited on it…`):E(`${d} is still signed out. Finish the sign-in, then check again.`)},onError:e=>E(e.message,{tone:`danger`})})},stop:()=>{r?C.mutate(r):_(n,e,t),T(null)}}}function yt({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}=K(e,t),S=ht(),[C,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":C,"data-action":`reconnect-more`,onClick:()=>T(e=>!e),children:[`More options`,C?(0,R.jsx)(ve,{"aria-hidden":`true`,className:`size-3.5`}):(0,R.jsx)(he,{"aria-hidden":`true`,className:`size-3.5`})]}),j=C?(0,R.jsx)(jt,{provider:e,command:s?.command??g?.command??pt(e,u?.configDir,u?.isDefault??t==="default"),checking:v.isPending,onCheck:b,onKey:lt.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:w(q,bt,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)(G,{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)(G,{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:w(q,bt,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:J,children:[(0,R.jsx)(G,{provider:e,small:!0}),` Signing in to `,f]}),t]})]}),(0,R.jsx)(`div`,{className:X,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:w(q,`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:J,children:[f,` is signed in again`]}),n===`task`&&S?.parked===null?(0,R.jsx)(`div`,{className:Y,children:`Continue the task to pick up where it stopped.`}):(0,R.jsxs)(`div`,{className:w(Y,`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??ft(s?.reason,s?.method,e,d);return(0,R.jsxs)(`div`,{"data-slot":`reconnect-card`,"data-state":`failed`,"data-provider":e,role:`alert`,className:w(q,o),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,R.jsx)(G,{provider:e}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:J,children:[`Sign-in to `,f,` didn't finish`]}),(0,R.jsx)(`div`,{"data-slot":`reconnect-reason`,className:Y,children:t})]})]}),(0,R.jsxs)(`div`,{className:w(X,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&&!C?(0,R.jsx)(Q,{command:g.command,label:`Run this on the computer running cezar:`}):null,j]})}let ne=ct.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:w(q,o),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,R.jsx)(G,{provider:e}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:J,children:[f,` is signed out`,(0,R.jsx)(`span`,{"data-slot":`reconnect-pill`,className:w(Z,`border-danger/35 bg-danger/10 text-danger-strong`),children:`Login expired`})]}),(0,R.jsx)(`div`,{className:Y,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:w(X,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 q=`mt-2 max-w-[640px] rounded-[10px] border border-danger/30 bg-danger/5 px-3.5 py-3 transition-colors`,bt=`border-border bg-card`,J=`flex flex-wrap items-center gap-1.5 text-ui font-semibold text-foreground`,Y=`mt-0.5 text-xs text-muted-foreground`,X=`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(h().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),o=dt(e.url),s=g();if(e.phase===`starting`)return(0,R.jsxs)(`p`,{className:Y,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:Y,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:Y,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:Y,children:[`Enter this code at `,(0,R.jsx)(`b`,{className:`font-semibold text-foreground`,children:o??`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:Y,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:w(Y,`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(s,e)})]});case`key`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:Y,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.`}),lt.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(s,e)}):null]});case`terminal`:return n?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:Y,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:Y,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:Y,children:[`Signing in to `,t,`…`]})}function wt({session:e,remote:t,stacked:n,checking:r,onCheck:i,onRestart:a,onCancel:o}){let s=dt(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:w(`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,l]=(0,B.useState)(),u=s!==void 0&&i?.includes(s)?s:i?.[0],[d,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),c(e.sessionId,t===`code`?{code:i}:{apiKey:i,...u?{keyProvider:u}:{}}).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:u,onValueChange:l,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:d,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:w(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:w(a,`self-start`),children:`Sign in with an API key instead`}):null,(0,R.jsx)(T,{to:`/settings/global/accounts`,className:w(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:w(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)(G,{provider:e,small:!0}),U(e),` · `,n.label,r===`connected`?(0,R.jsx)(`span`,{className:w(Z,`ml-auto border-success/35 bg-success/10 text-success-strong`),children:`Signed in`}):r===`disconnected`?(0,R.jsx)(`span`,{className:w(Z,`ml-auto border-danger/35 bg-danger/10 text-danger-strong`),children:`Signed out`}):r===`not-installed`?(0,R.jsx)(`span`,{className:w(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=ht()?.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:w(`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:w(`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(gt),[c,l]=(0,B.useState)(a?.provider??(r&&n.includes(r)?r:n[0]??`claude`)),[u,f]=(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=d(),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)(G,{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=>{f(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 p?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:w(`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:w(`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:w(`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:w(`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)(G,{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:ct.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:o,remote:s,who:c,start:l,recheck:u,reconnect:d,checkAgain:f,stop:p}=K(e.provider,e.id),m=g(),h=(0,B.useRef)(!1);(0,B.useEffect)(()=>{h.current||(h.current=!0,d())},[]),(0,B.useEffect)(()=>{a===`success`&&(m.invalidateQueries({queryKey:S.agentProfiles}),n())},[a]);let _=()=>{p(),r()};if(a===`failed`){let n=o?.message??ft(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 `,c,` 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:l.isPending,onClick:()=>d(),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:c,remote:s,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:s,stacked:t,checking:u.isPending,onCheck:f,onRestart:()=>d(),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:a,onRemove:o}){let s=h().data,c=u(C(e),!0),l=i(),[d,f]=(0,B.useState)(!1),p=s?.hostPaths!==!1,m=(s?.profiles??[]).filter(t=>t.provider===e.provider&&t.id!==e.id&&!t.pending),g=r({queries:m.map(e=>({queryKey:S.agentAccountDetails(C(e)),queryFn:({signal:t})=>y(C(e),{signal:t}),staleTime:0,retry:!1}))}),_=c.data?.available?Yt(c.data.fields):void 0,v=_===void 0?-1:g.findIndex(e=>e.data?.available&&Yt(e.data.fields)===_),b=v>=0?m[v]: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:[`(`,_,`). Two accounts on one login share one subscription and its limits.`]})]}):null,c.isPending?(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`Reading account details…`}):c.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:c.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))}):c.data?.reason?(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:c.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:o,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 a(!0);l.mutate({projectId:null,provider:e.provider,profileId:e.id},{onSuccess:()=>a(!0),onError:e=>E(e.message,{tone:`danger`})})},children:b?`Keep both`:`Done`})]})]})}var Zt=(0,B.createContext)(null),Qt=[];function $t(){let e=h().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=h().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{yt as a,mt as c,Ge as d,Ke as f,Ft as i,G as l,en as n,xt as o,Ht as r,K as s,tn as t,U 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{Go as r,Kt as i,O as a,R as o,Wo as s,Xa as c,bn as l,c as u,ht as d,i as f,kr as p,nn as m,p as h,qo as g,r as _,st as v,ui as y,v as b,w as x,yn as S}from"./queries-Cwkv3B0F.js";import{st as C,t as w}from"./utils-BqOIVEJr.js";import{f as T}from"./project-router-jwkbmkUy.js";import{r as E}from"./toaster-BMipmHDN.js";import{A as D,C as ee,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-k846Eayo.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-gNzgdKDO.js";import{r as he}from"./dist-C6DsSlbr.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-BE41nYi1.js";import{a as Ce,i as we,p as Te,r as Ee,t as De}from"./dropdown-menu-l1zNfazK.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-DswGcrs0.js";import{t as I}from"./spinner-Dp0xaGds.js";import{t as L}from"./input-DiWD6Sks.js";import{a as je,i as Me,n as Ne,o as Pe,r as Fe,t as Ie}from"./dialog-BbiTsOGC.js";import{t as Le}from"./clipboard-DvCUPLwM.js";import{r as Re}from"./phone-app-p_yS8Txg.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 p&&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 p&&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:w(`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=>D[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])),ct=st(`terminal`),lt=st(`key`);function ut(e){let{mono:t,ring:n}=W[e];return{mono:t,color:`var(--runner-mark-${e})`,ring:n===!0}}function dt(e){if(e)try{return new URL(e).host}catch{return}}function ft(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 pt(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 G({provider:e,small:t=!1,className:n}){let r=ut(e);return(0,R.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`runner-mark`,className:w(`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 mt=(0,B.createContext)(void 0),ht=()=>(0,B.useContext)(mt),gt=`(max-width: 767px)`,_t=(e,t)=>[...S.agentLogin(e,t),`start-error`],vt=()=>Promise.resolve(null);function K(e,t){let n=g(),r=ne(e,t),i=O(e,t),a=s({queryKey:_t(e,t),queryFn:vt,enabled:!1,staleTime:1/0}).data??null,c=h().data?.profiles,l=c?.find(n=>n.provider===e&&n.id===t),u=l?.label??(t==="default"?`Default`:t),d=`${U(e)} · ${u}`,y=o().data?.capabilities?.localHandoff===!1||Re(),x=ze(gt),S=m(),C=b(),w=v(),T=r=>n.setQueryData(_t(e,t),r);return{session:r,news:i,startError:a,profiles:c,profile:l,account:u,who:d,remote:y,narrow:x,view:a?`failed`:f(r)?`signing`:r?.phase===`connected`?`success`:r?.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 p&&e.command?{command:e.command}:{}})})},checkAgain:()=>{w.mutate(t==="default"?`default:${e}`:t,{onSuccess:e=>{e.status.status===`connected`?E(`${d} is signed in. Resuming what waited on it…`):E(`${d} is still signed out. Finish the sign-in, then check again.`)},onError:e=>E(e.message,{tone:`danger`})})},stop:()=>{r?C.mutate(r):_(n,e,t),T(null)}}}function yt({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}=K(e,t),S=ht(),[C,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":C,"data-action":`reconnect-more`,onClick:()=>T(e=>!e),children:[`More options`,C?(0,R.jsx)(ve,{"aria-hidden":`true`,className:`size-3.5`}):(0,R.jsx)(he,{"aria-hidden":`true`,className:`size-3.5`})]}),j=C?(0,R.jsx)(jt,{provider:e,command:s?.command??g?.command??pt(e,u?.configDir,u?.isDefault??t==="default"),checking:v.isPending,onCheck:b,onKey:lt.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:w(q,bt,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)(G,{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)(G,{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:w(q,bt,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:J,children:[(0,R.jsx)(G,{provider:e,small:!0}),` Signing in to `,f]}),t]})]}),(0,R.jsx)(`div`,{className:X,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:w(q,`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:J,children:[f,` is signed in again`]}),n===`task`&&S?.parked===null?(0,R.jsx)(`div`,{className:Y,children:`Continue the task to pick up where it stopped.`}):(0,R.jsxs)(`div`,{className:w(Y,`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??ft(s?.reason,s?.method,e,d);return(0,R.jsxs)(`div`,{"data-slot":`reconnect-card`,"data-state":`failed`,"data-provider":e,role:`alert`,className:w(q,o),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,R.jsx)(G,{provider:e}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:J,children:[`Sign-in to `,f,` didn't finish`]}),(0,R.jsx)(`div`,{"data-slot":`reconnect-reason`,className:Y,children:t})]})]}),(0,R.jsxs)(`div`,{className:w(X,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&&!C?(0,R.jsx)(Q,{command:g.command,label:`Run this on the computer running cezar:`}):null,j]})}let ne=ct.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:w(q,o),children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2.5`,children:[(0,R.jsx)(G,{provider:e}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:J,children:[f,` is signed out`,(0,R.jsx)(`span`,{"data-slot":`reconnect-pill`,className:w(Z,`border-danger/35 bg-danger/10 text-danger-strong`),children:`Login expired`})]}),(0,R.jsx)(`div`,{className:Y,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:w(X,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 q=`mt-2 max-w-[640px] rounded-[10px] border border-danger/30 bg-danger/5 px-3.5 py-3 transition-colors`,bt=`border-border bg-card`,J=`flex flex-wrap items-center gap-1.5 text-ui font-semibold text-foreground`,Y=`mt-0.5 text-xs text-muted-foreground`,X=`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(h().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),o=dt(e.url),s=g();if(e.phase===`starting`)return(0,R.jsxs)(`p`,{className:Y,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:Y,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:Y,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:Y,children:[`Enter this code at `,(0,R.jsx)(`b`,{className:`font-semibold text-foreground`,children:o??`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:Y,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:w(Y,`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(s,e)})]});case`key`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:Y,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.`}),lt.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(s,e)}):null]});case`terminal`:return n?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:Y,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:Y,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:Y,children:[`Signing in to `,t,`…`]})}function wt({session:e,remote:t,stacked:n,checking:r,onCheck:i,onRestart:a,onCancel:o}){let s=dt(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:w(`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,l]=(0,B.useState)(),u=s!==void 0&&i?.includes(s)?s:i?.[0],[d,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),c(e.sessionId,t===`code`?{code:i}:{apiKey:i,...u?{keyProvider:u}:{}}).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:u,onValueChange:l,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:d,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:w(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:w(a,`self-start`),children:`Sign in with an API key instead`}):null,(0,R.jsx)(T,{to:`/settings/global/accounts`,className:w(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:w(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)(G,{provider:e,small:!0}),U(e),` · `,n.label,r===`connected`?(0,R.jsx)(`span`,{className:w(Z,`ml-auto border-success/35 bg-success/10 text-success-strong`),children:`Signed in`}):r===`disconnected`?(0,R.jsx)(`span`,{className:w(Z,`ml-auto border-danger/35 bg-danger/10 text-danger-strong`),children:`Signed out`}):r===`not-installed`?(0,R.jsx)(`span`,{className:w(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=ht()?.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:w(`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:w(`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(gt),[c,l]=(0,B.useState)(a?.provider??(r&&n.includes(r)?r:n[0]??`claude`)),[u,f]=(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=d(),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)(G,{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=>{f(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 p?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:w(`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:w(`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:w(`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:w(`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)(G,{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:ct.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:o,remote:s,who:c,start:l,recheck:u,reconnect:d,checkAgain:f,stop:p}=K(e.provider,e.id),m=g(),h=(0,B.useRef)(!1);(0,B.useEffect)(()=>{h.current||(h.current=!0,d())},[]),(0,B.useEffect)(()=>{a===`success`&&(m.invalidateQueries({queryKey:S.agentProfiles}),n())},[a]);let _=()=>{p(),r()};if(a===`failed`){let n=o?.message??ft(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 `,c,` 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:l.isPending,onClick:()=>d(),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:c,remote:s,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:s,stacked:t,checking:u.isPending,onCheck:f,onRestart:()=>d(),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:a,onRemove:o}){let s=h().data,c=u(C(e),!0),l=i(),[d,f]=(0,B.useState)(!1),p=s?.hostPaths!==!1,m=(s?.profiles??[]).filter(t=>t.provider===e.provider&&t.id!==e.id&&!t.pending),g=r({queries:m.map(e=>({queryKey:S.agentAccountDetails(C(e)),queryFn:({signal:t})=>y(C(e),{signal:t}),staleTime:0,retry:!1}))}),_=c.data?.available?Yt(c.data.fields):void 0,v=_===void 0?-1:g.findIndex(e=>e.data?.available&&Yt(e.data.fields)===_),b=v>=0?m[v]: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:[`(`,_,`). Two accounts on one login share one subscription and its limits.`]})]}):null,c.isPending?(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`Reading account details…`}):c.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:c.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))}):c.data?.reason?(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:c.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:o,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 a(!0);l.mutate({projectId:null,provider:e.provider,profileId:e.id},{onSuccess:()=>a(!0),onError:e=>E(e.message,{tone:`danger`})})},children:b?`Keep both`:`Done`})]})]})}var Zt=(0,B.createContext)(null),Qt=[];function $t(){let e=h().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=h().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{yt as a,mt as c,Ge as d,Ke as f,Ft as i,G as l,en as n,xt as o,Ht as r,K as s,tn as t,U as u};
|
|
@@ -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-BqOIVEJr.js";import{t as i}from"./project-router-
|
|
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-BqOIVEJr.js";import{t as i}from"./project-router-jwkbmkUy.js";import{N as a}from"./run-actions-jZ19SNcg.js";import{B as o}from"./button-gNzgdKDO.js";import{r as s}from"./dist-C6DsSlbr.js";import{_ as c}from"./impact-model-Dn_guR3S.js";import{S as l,b as u,m as d,v as f,x as p}from"./composer-CMFOAl1V.js";import{t as m}from"./workflow-C6Wv2H83.js";import{i as h,r as g,t as _}from"./popover-YpIwsUHW.js";import{t as v}from"./icon-tooltip-BoIAtNoM.js";import{a as y,i as b,o as x,r as S,s as C,t as w}from"./command-DLEgTYTp.js";import{i as T}from"./chip-mJ7iViV-.js";import"./reasoning-effort-pill-7_ZzbUCI.js";import{T as E}from"./index-CmuEcgSz.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{pr as r,qo as i}from"./queries-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{pr as r,qo as i}from"./queries-Cwkv3B0F.js";import{t as a,zt as o}from"./utils-BqOIVEJr.js";import{c as s,t as c,y as l}from"./project-router-jwkbmkUy.js";import{c as u,g as d,h as f,u as p}from"./questions-DPXsqwIB.js";import{t as m}from"./createLucideIcon-BHp8sXmF.js";import{l as h}from"./reference-chip-BmyQH_ub.js";import{B as g,t as _}from"./button-gNzgdKDO.js";import{t as v}from"./circle-alert-ClwRNTQt.js";import{t as y}from"./status-dot-B2uh7fMk.js";import{r as b}from"./format-BUbPQpzw.js";import{s as x}from"./reference-conflict-action-BhHcpIRH.js";import{t as S}from"./textarea-BUfbdq_L.js";import{r as C,t as w}from"./enter-key-Bsscx4Nx.js";import{n as T}from"./chip-mJ7iViV-.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)(T,{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)(T,{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)(T,{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=r({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?o({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),r=i(),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(r,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=C(),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=w({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:o}){let s=(0,O.useContext)(E),c=(0,O.useId)(),l=a(`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:a(`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:a(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:o,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:o,className:a(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:a(`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};
|
|
@@ -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{Ha as r,Ot as i,kt as a}from"./queries-xqgnsU4z.js";import{Jt as o,t as s}from"./utils-BqOIVEJr.js";import{S as c,l}from"./project-router-DzrdQl7o.js";import{t as u}from"./createLucideIcon-BHp8sXmF.js";import{k as d}from"./run-actions-D8pJsnJR.js";import{t as f}from"./button-gNzgdKDO.js";import{r as p}from"./dist-C6DsSlbr.js";import{a as m,o as h,p as g,r as _,s as v,t as y}from"./dropdown-menu-l1zNfazK.js";import{t as b}from"./download-CfgyYHf7.js";import{t as x}from"./external-link-BE6y205O.js";import{t as S}from"./file-preview-YElcu1xa.js";import{t as C}from"./file--aqoYe_k.js";import{t as w}from"./layers-CS8s30-0.js";import{t as T}from"./loader-circle-CPBhhDbB.js";import{S as E,_ as D,a as O,b as k,d as A,f as j,g as M,h as N,i as P,l as F,m as I,t as L,v as R,x as z,y as B}from"./design-note-popup-D5m53gtY.js";import{t as V}from"./send-C4FmsrnF.js";import{t as H}from"./triangle-alert-CIzim6ZN.js";import{t as U}from"./x-BqECUykl.js";import{t as W}from"./icon-tooltip-BoIAtNoM.js";import{r as G}from"./format-BUbPQpzw.js";import{t as K}from"./centered-state-Do6b5T_L.js";import{t as ee}from"./markdown-DyDHD9Cf.js";import{Ot as te,Wt as ne,Xt as re,Yt as q,kt as J}from"./index-Ch3mvQqM.js";import{t as Y}from"./comment-count-Dj9nmTRF.js";import{l as ie,o as ae,p as oe}from"./review-comments-block-_NbQfjgh.js";var se=u(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),ce=u(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),le=u(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),X=e(t(),1);function ue(e){let t=o.safeParse(e);return t.success?{ref:t.data.ref,label:t.data.label.slice(0,200)}:null}function de(e,t){return e?`About ${e.ref} ("${e.label}"): ${t}`:t}function fe(e,t){let n=(0,X.useRef)(t);n.current=t,(0,X.useEffect)(()=>{let t=t=>{let r=e.current?.contentWindow;if(!r||t.source!==r)return;let i=ue(t.data);i&&n.current(i)};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e])}var Z=n();function pe({run:e,reference:t,onClearReference:n,comments:r}){let i=j(e),a=I(e,i.continueWith),o=d(e),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),h=(0,X.useId)(),g=e.status===`running`||e.status===`waiting`,_=e.status===`queued`,v=!g&&!_&&i.available;if(!g&&!_&&!v||e.worktreeLifecycle?.activeOperationId)return null;let y=g&&!o.usable?o.reason:v&&!i.canContinue?i.reason??`No provider can continue this task.`:void 0,b=r?.all.length??0,x=!y&&!l&&(s.trim()!==``||b>0),S=async e=>{if(e?.preventDefault(),x){u(!0),m(null);try{let e=s.trim()===``?``:de(t,s.trim());r&&b>0&&ae(e,void 0)?await r.submit(t=>a(ie(e,t),[])):await a(e,[]),c(``),n()}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}}};return(0,Z.jsxs)(`form`,{"data-slot":`assets-ask`,"aria-label":`Ask about this asset`,onSubmit:e=>void S(e),className:`shrink-0 border-t border-border bg-background px-2 py-2 sm:px-3`,children:[t?(0,Z.jsxs)(`span`,{"data-slot":`assets-ask-ref`,className:`mb-1.5 inline-flex max-w-full items-center gap-1 rounded-full border border-border bg-muted py-0.5 pr-0.5 pl-2 text-meta`,children:[(0,Z.jsx)(se,{"aria-hidden":`true`,className:`size-3 shrink-0 text-muted-foreground`}),(0,Z.jsx)(W,{label:`${t.ref} — ${t.label}`,children:(0,Z.jsxs)(`span`,{className:`truncate`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:t.ref}),` `,t.label]})}),(0,Z.jsx)(`button`,{type:`button`,"data-action":`assets-ask-ref-remove`,"aria-label":`Remove reference`,onClick:n,className:`rounded-full p-0.5 text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Z.jsx)(U,{"aria-hidden":`true`,className:`size-3`})})]}):null,r&&b>0?(0,Z.jsx)(`div`,{"data-slot":`assets-ask-comments`,className:`mb-1.5 flex flex-wrap gap-1.5`,children:(0,Z.jsx)(A,{runId:e.id,comments:r.all,onRemove:r.remove})}):null,(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsx)(`textarea`,{"data-slot":`assets-ask-input`,"aria-label":t?`Ask about ${t.label||t.ref}`:`Ask the agent about this asset`,"aria-describedby":y||p?h:void 0,rows:1,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&S()},disabled:!!y,placeholder:t?`Ask or correct — ⌘↵ to send`:b>0?`Add a message, or send the ${b===1?`comment`:`${b} comments`} as they are — ⌘↵`:`Ask the agent about this report — click an element to reference it`,className:`max-h-32 min-h-9 flex-1 resize-y rounded-md border border-border bg-card px-2.5 py-2 text-ui focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:opacity-60`}),(0,Z.jsxs)(f,{type:`submit`,size:`sm`,"data-action":`assets-ask-send`,disabled:!x,"aria-busy":l||void 0,children:[l?(0,Z.jsx)(T,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Z.jsx)(V,{"aria-hidden":`true`}),v?`Continue`:`Send`]})]}),y||p?(0,Z.jsx)(`p`,{id:h,"data-slot":`assets-ask-reason`,className:`mt-1 text-label text-muted-foreground`,children:p??y}):null]})}function me(e){return`${e}${e.includes(`?`)?`&`:`?`}picker=1`}function he(e,t){let n=e.selector.split(` > `).at(-1)??e.selector;return{url:``,selector:e.selector,tag:/^[a-z][a-z0-9-]*/i.exec(n)?.[0]??n,text:e.label,html:e.excerpt,styles:{},rect:{x:0,y:0,width:0,height:0},viewport:{width:0,height:0},components:[],source:``,mark:t}}function ge({frameRef:e,frameKey:t,asset:n,store:r,active:i,onActiveChange:a}){let o=(0,X.useMemo)(()=>r.assetComments.filter(e=>e.asset===n),[n,r.assetComments]),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)({}),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(``),h=(0,X.useRef)(new Map),g=(0,X.useRef)(!1);(0,X.useEffect)(()=>{c(!1),u({}),f(null),h.current.clear()},[t]);let _=(0,X.useCallback)(e=>h.current.get(e.id)??e.id,[]),v=(0,X.useCallback)(t=>{e.current?.contentWindow?.postMessage({source:`cezar-design-host`,...t},`*`)},[e]),y=(0,X.useMemo)(()=>{let e=o.map((e,t)=>({key:_(e),n:t+1,selector:e.selector}));return d&&d.commentId===void 0?[...e,{key:d.key}]:e},[o,d,_]),b=JSON.stringify(y),x=(0,X.useCallback)(()=>v({type:`set-marks`,marks:JSON.parse(b)}),[b,v]);(0,X.useEffect)(()=>{s&&v({type:`set-active`,active:i})},[i,v,s]),(0,X.useEffect)(()=>{s&&x()},[s,x]);let S=(0,X.useRef)({comments:o,editing:d,active:i});S.current={comments:o,editing:d,active:i},(0,X.useEffect)(()=>{let t=t=>{if(t.source===null||t.source!==e.current?.contentWindow)return;let n=t.data;if(typeof n!=`object`||!n||n.source!==`cezar-design`)return;let r=S.current;if(n.type===`ready`)h.current.clear(),c(!0);else if(n.type===`rects`)u(P(n.rects));else if(n.type===`toggle`)a(!1);else if(n.type===`cancel`)r.editing?f(null):a(!1);else if(n.type===`picked`){let e=F(n.element);if(!e?.mark||!r.active){x();return}let t=e.mark;u(n=>({...n,[t]:e.rect})),f({key:t,pick:{...e,mark:t}}),m(``)}else if(n.type===`mark-clicked`&&typeof n.key==`string`){let e=n.key,t=r.comments.find(t=>_(t)===e);if(!t)return;g.current=!1,f({key:e,pick:he(t,e),commentId:t.id}),m(t.body)}};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e,_,a,x]);let C=(0,X.useCallback)(()=>{let e=d?.commentId?o.find(e=>e.id===d.commentId):void 0;e&&!g.current&&p.trim()!==``&&p.trim()!==e.body&&r.update(e.id,p.trim()),f(null)},[o,d,r,p]),w=(0,X.useRef)(C);w.current=C,(0,X.useEffect)(()=>{if(!i)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||e.isComposing||(e.preventDefault(),S.current.editing?w.current():a(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,a]),(0,X.useEffect)(()=>{d?.commentId!==void 0&&!o.some(e=>e.id===d.commentId)&&f(null)},[o,d]);let T=(0,X.useRef)(null),E=(0,X.useRef)(null),[D,k]=(0,X.useState)(null),A=d?l[d.key]:void 0;(0,X.useLayoutEffect)(()=>{if(!d)return k(null);let e=T.current?.parentElement,t=E.current;!e||!t||k(O(A,{width:e.clientWidth,height:e.clientHeight},{width:t.offsetWidth,height:t.offsetHeight}))},[A,d]);let j=D!==null,M=d?.key;if((0,X.useEffect)(()=>{j&&M&&E.current?.querySelector(`textarea`)?.focus()},[M,j]),!d)return(0,Z.jsx)(`div`,{ref:T,hidden:!0});let N=d.commentId?o.findIndex(e=>e.id===d.commentId)+1:0,I=C;return(0,Z.jsx)(`div`,{ref:T,children:(0,Z.jsx)(`div`,{ref:E,"data-slot":`asset-comment-popup`,role:`dialog`,"aria-label":`Comment on this element`,className:`absolute z-20 w-[min(360px,calc(100%-16px))] rounded-xl border border-border bg-background shadow-lg`,style:D?{left:D.left,top:D.top}:{visibility:`hidden`,left:0,top:0},children:(0,Z.jsx)(L,{noun:`comment`,note:{key:d.key,pick:d.pick,text:p,phase:`draft`,added:d.commentId!==void 0,...N>0?{number:N}:{}},notes:{setText:(e,t)=>m(t),markAdded:()=>{let e=p.trim();if(e===``)return;let t=r.addAsset({asset:n,selector:d.pick.selector,label:d.pick.text,excerpt:d.pick.html,body:e});t&&h.current.set(t,d.key)},discard:()=>{d.commentId&&(g.current=!0,r.remove(d.commentId))}},onClose:I})})})}var _e=`No assets yet`,ve=`Agents publish pages here when they write to the run's artifacts folder.`;function ye({runId:e,routed:t,run:n}){let i=a(e),o=c(),u=l(),[d,p]=(0,X.useState)(void 0),m=t?o.name:d,h=i.data?.artifacts??[],g=B(h,m),_=(0,X.useCallback)(n=>{t?u(`/tasks/${e}/assets/${encodeURIComponent(n)}`,{replace:!0}):p(n)},[u,t,e]),[v,y]=xe(),[S,C]=(0,X.useState)(0),[D,O]=(0,X.useState)(void 0),k=g?.kind===`html`?Q(i.data?.versions,g.name):[],A=k.at(-1)?.version,j=D&&g&&D.name===g.name&&D.version!==A&&k.some(e=>e.version===D.version)?D.version:void 0,M=(0,X.useRef)(null),[N,P]=(0,X.useState)(null);fe(M,P);let F=oe(n?e:``),I=n!==void 0&&g?.kind===`html`&&j===void 0,[L,R]=(0,X.useState)(null),z=I&&L?.name===g?.name,V=(0,X.useCallback)(e=>R(e&&g?{name:g.name}:null),[g]),U=new Map;for(let e of F.assetComments)U.set(e.asset,(U.get(e.asset)??0)+1);let G=g?`${g.name}@${g.updatedAt}#${S}v${j??``}`:``;return i.isPending?(0,Z.jsx)(K,{icon:(0,Z.jsx)(T,{className:`motion-safe:animate-spin`}),tone:`neutral`,heading:`h2`,title:`Loading assets…`}):i.isError?(0,Z.jsx)(K,{icon:(0,Z.jsx)(H,{}),tone:`danger`,heading:`h2`,title:`Could not load this task's assets`,subtitle:i.error.message}):(0,Z.jsxs)(`section`,{"data-slot":`assets-view`,className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,Z.jsxs)(`div`,{"data-slot":`assets-toolbar`,role:`toolbar`,"aria-label":`Assets`,className:`flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-2 sm:px-3`,children:[g?(0,Z.jsx)(Se,{artifacts:h,current:g,onSelect:_,counts:U}):(0,Z.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`Assets`}),g?.kind===`html`?(0,Z.jsx)(W,{label:`Runs in a sandbox: no access to cezar, your cookies or the network beyond pinned CDN scripts`,children:(0,Z.jsxs)(`span`,{"data-slot":`assets-sandboxed`,tabIndex:0,className:`hidden items-center gap-1 rounded-sm border border-border px-1.5 py-px text-meta text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none sm:inline-flex`,children:[(0,Z.jsx)(ne,{"aria-hidden":`true`,className:`size-3`}),`sandboxed`]})}):null,g&&k.length>1?(0,Z.jsx)(be,{versions:k,viewing:j,onSelect:e=>O(e===A?void 0:{name:g.name,version:e})}):null,j===void 0?null:(0,Z.jsxs)(`span`,{"data-slot":`assets-viewing-version`,className:`inline-flex items-center gap-1.5 text-meta text-muted-foreground`,children:[`Viewing v`,j,(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`—`}),(0,Z.jsx)(`button`,{type:`button`,"data-action":`assets-version-current`,onClick:()=>O(void 0),className:`font-medium text-foreground underline underline-offset-2`,children:`back to current`})]}),i.data.truncated?(0,Z.jsxs)(`span`,{className:`hidden text-meta text-muted-foreground md:inline`,children:[`Showing the newest `,i.data.artifacts.length,` files; the folder has more`]}):null,(0,Z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[I&&g?(0,Z.jsx)(W,{label:z?`Stop commenting (Esc)`:`Comment — click an element of the page to leave a comment for the agent`,children:(0,Z.jsxs)(f,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-comment`,"aria-pressed":z,disabled:!F.ready,className:s(`text-muted-foreground max-sm:px-1.5`,z&&`bg-muted text-foreground`),onClick:()=>V(!z),children:[(0,Z.jsx)(le,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`max-sm:sr-only`,children:`Comment`}),(0,Z.jsx)(Y,{count:U.get(g.name)??0})]})}):null,(0,Z.jsx)(W,{label:v?`Leave focus — bring the sidebar back`:`Focus — fold the sidebar to icons while Assets is open`,children:(0,Z.jsx)(f,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-action":`assets-focus`,"aria-pressed":v,"aria-label":v?`Leave focus`:`Focus`,className:s(`text-muted-foreground`,v&&`bg-muted text-foreground`),onClick:()=>y(!v),children:v?(0,Z.jsx)(q,{"aria-hidden":`true`}):(0,Z.jsx)(re,{"aria-hidden":`true`})})}),g?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{asChild:!0,variant:`ghost`,size:`sm`,className:`text-muted-foreground max-sm:size-[30px] max-sm:px-0`,children:(0,Z.jsxs)(`a`,{"data-action":`assets-open`,href:r(e,g.name,j),target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Open in new tab`,title:`Open in new tab (still sandboxed)`,children:[(0,Z.jsx)(x,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`max-sm:sr-only`,children:`Open in new tab`})]})}),(0,Z.jsx)(f,{asChild:!0,variant:`ghost`,size:`sm`,className:`text-muted-foreground max-sm:size-[30px] max-sm:px-0`,children:(0,Z.jsxs)(`a`,{"data-action":`assets-download`,href:r(e,g.name,j),download:g.name,"aria-label":`Download`,children:[(0,Z.jsx)(b,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`max-sm:sr-only`,children:`Download`})]})}),(0,Z.jsxs)(f,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-reload`,"aria-label":`Reload`,className:`text-muted-foreground max-sm:size-[30px] max-sm:px-0`,onClick:()=>C(e=>e+1),children:[(0,Z.jsx)(E,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`max-sm:sr-only`,children:`Reload`})]})]}):null]})]}),g&&I?(0,Z.jsxs)(`div`,{"data-slot":`assets-comment-area`,className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsx)($,{runId:e,artifact:g,version:j,frameRef:M,picker:!0},G),(0,Z.jsx)(ge,{frameRef:M,frameKey:G,asset:g.name,store:F,active:z,onActiveChange:V}),z?(0,Z.jsx)(`p`,{"data-slot":`assets-comment-hint`,className:`pointer-events-none absolute bottom-3 left-1/2 z-10 -translate-x-1/2 rounded-full border border-border bg-background/95 px-3 py-1 text-label whitespace-nowrap text-muted-foreground shadow-sm`,children:`Click an element to comment · Esc to stop`}):null]}):g?(0,Z.jsx)($,{runId:e,artifact:g,version:j,frameRef:M},G):(0,Z.jsx)(K,{icon:(0,Z.jsx)(w,{}),tone:`neutral`,heading:`h2`,title:_e,subtitle:ve}),n&&g?(0,Z.jsx)(pe,{run:n,reference:N,onClearReference:()=>P(null),comments:F}):null]})}function Q(e,t){return(e??[]).filter(e=>e.files.includes(t))}function be({versions:e,viewing:t,onSelect:n}){let r=e.at(-1),i=t??r?.version;return(0,Z.jsxs)(y,{children:[(0,Z.jsx)(g,{asChild:!0,children:(0,Z.jsxs)(f,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-versions`,"aria-label":`Version v${i} — pick another version`,className:`h-7 gap-1 px-2 text-label text-muted-foreground`,children:[(0,Z.jsx)(ce,{"aria-hidden":`true`,className:`size-3.5`}),`v`,i,r&&t===void 0?(0,Z.jsxs)(`span`,{className:`hidden sm:inline`,children:[`· `,G(r.updatedAt),` ago`]}):null,(0,Z.jsx)(p,{"aria-hidden":`true`,className:`size-3.5 opacity-60`})]})}),(0,Z.jsxs)(_,{align:`start`,className:`w-56`,children:[(0,Z.jsx)(m,{children:`Versions`}),(0,Z.jsx)(h,{value:String(i),onValueChange:e=>n(Number(e)),children:[...e].reverse().map(e=>(0,Z.jsxs)(v,{value:String(e.version),"data-version":e.version,children:[`v`,e.version,` · `,G(e.updatedAt),` ago`,e.version===r?.version?(0,Z.jsx)(`span`,{className:`ml-auto text-meta text-muted-foreground`,children:`current`}):null]},e.version))})]})]})}function xe(){let[e,t]=(0,X.useState)(()=>k(`assets`)),n=(0,X.useCallback)(e=>{z(`assets`,e),t(e)},[]);return(0,X.useEffect)(()=>{if(e)return te(()=>n(!1))},[e,n]),[e,n]}function Se({artifacts:e,current:t,onSelect:n,counts:r}){let i=R(e);return(0,Z.jsxs)(y,{children:[(0,Z.jsx)(g,{asChild:!0,children:(0,Z.jsxs)(f,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-switcher`,"aria-label":`Asset: ${D(t)} — switch asset`,className:`h-7 min-w-0 max-w-[min(28rem,60vw)] gap-1.5 px-2 text-ui font-medium`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:D(t)}),(0,Z.jsx)(`span`,{className:`shrink-0 text-meta font-normal text-muted-foreground`,children:M[t.kind]}),(0,Z.jsx)(p,{"aria-hidden":`true`,className:`size-3.5 shrink-0 opacity-60`})]})}),(0,Z.jsxs)(_,{align:`start`,className:`max-h-80 w-80 overflow-y-auto`,children:[(0,Z.jsxs)(m,{children:[e.length,` `,e.length===1?`asset`:`assets`]}),(0,Z.jsx)(h,{value:t.name,onValueChange:n,children:i.map(e=>(0,Z.jsx)(v,{value:e.name,"data-asset":e.name,children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:D(e)}),(0,Z.jsx)(Y,{count:r?.get(e.name)??0})]}),(0,Z.jsxs)(`span`,{className:`truncate font-mono text-meta text-muted-foreground`,children:[e.name,` · `,M[e.kind],` · `,G(e.updatedAt)]})]})},e.name))})]})]})}function $({runId:e,artifact:t,version:n,frameRef:i,picker:a=!1}){let o=J(),s=r(e,t.name,n);switch(t.kind){case`html`:return(0,Z.jsx)(`iframe`,{ref:i,"data-slot":`assets-frame`,title:D(t),src:`${a?me(s):s}#theme=${o}`,sandbox:N,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-background`});case`image`:return(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,Z.jsx)(`img`,{"data-slot":`assets-image`,src:s,alt:D(t),className:`max-w-full rounded-sm`})});case`markdown`:case`json`:return(0,Z.jsx)(Ce,{runId:e,artifact:t});case`other`:return(0,Z.jsx)(K,{icon:(0,Z.jsx)(C,{}),tone:`neutral`,heading:`h2`,title:`No preview for this file`,subtitle:`${t.name} — download it to open it locally.`,actions:(0,Z.jsx)(f,{asChild:!0,variant:`outline`,children:(0,Z.jsxs)(`a`,{"data-action":`assets-download-file`,href:s,download:t.name,children:[(0,Z.jsx)(b,{"aria-hidden":`true`}),`Download`]})})})}}function Ce({runId:e,artifact:t}){let n=i(e,t.name,t.updatedAt);return n.isPending?(0,Z.jsxs)(`p`,{className:`px-4 py-6 text-center text-label text-soft-foreground`,children:[`Loading `,t.name,`…`]}):n.isError?(0,Z.jsx)(K,{icon:(0,Z.jsx)(H,{}),tone:`danger`,heading:`h2`,title:`Could not load this asset`,subtitle:n.error.message}):(0,Z.jsx)(`div`,{"data-slot":`assets-${t.kind}`,className:`min-h-0 flex-1 overflow-auto`,children:t.kind===`markdown`?(0,Z.jsx)(`div`,{className:`mx-auto max-w-3xl px-4 py-4`,children:(0,Z.jsx)(ee,{children:n.data})}):(0,Z.jsx)(S,{path:t.name,text:n.data})})}export{ye as AssetsView};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ha as r,Ot as i,kt as a}from"./queries-Cwkv3B0F.js";import{Jt as o,t as s}from"./utils-BqOIVEJr.js";import{S as c,l}from"./project-router-jwkbmkUy.js";import{t as u}from"./createLucideIcon-BHp8sXmF.js";import{k as d}from"./run-actions-jZ19SNcg.js";import{t as f}from"./button-gNzgdKDO.js";import{r as p}from"./dist-C6DsSlbr.js";import{a as m,o as h,p as g,r as _,s as v,t as y}from"./dropdown-menu-l1zNfazK.js";import{t as b}from"./download-CfgyYHf7.js";import{t as x}from"./external-link-BE6y205O.js";import{t as S}from"./file-preview-CMpGrEqT.js";import{t as C}from"./file--aqoYe_k.js";import{t as w}from"./layers-CS8s30-0.js";import{t as T}from"./loader-circle-CPBhhDbB.js";import{S as E,_ as D,a as O,b as k,d as A,f as j,g as M,h as N,i as P,l as F,m as I,t as L,v as R,x as z,y as B}from"./design-note-popup-CYbWcKiE.js";import{t as V}from"./send-C4FmsrnF.js";import{t as H}from"./triangle-alert-CIzim6ZN.js";import{t as U}from"./x-BqECUykl.js";import{t as W}from"./icon-tooltip-BoIAtNoM.js";import{r as G}from"./format-BUbPQpzw.js";import{t as K}from"./centered-state-Do6b5T_L.js";import{t as ee}from"./markdown-DyDHD9Cf.js";import{Ot as te,Wt as ne,Xt as re,Yt as q,kt as J}from"./index-CmuEcgSz.js";import{t as Y}from"./comment-count-Dj9nmTRF.js";import{l as ie,o as ae,p as oe}from"./review-comments-block-DfI0strR.js";var se=u(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),ce=u(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),le=u(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]),X=e(t(),1);function ue(e){let t=o.safeParse(e);return t.success?{ref:t.data.ref,label:t.data.label.slice(0,200)}:null}function de(e,t){return e?`About ${e.ref} ("${e.label}"): ${t}`:t}function fe(e,t){let n=(0,X.useRef)(t);n.current=t,(0,X.useEffect)(()=>{let t=t=>{let r=e.current?.contentWindow;if(!r||t.source!==r)return;let i=ue(t.data);i&&n.current(i)};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e])}var Z=n();function pe({run:e,reference:t,onClearReference:n,comments:r}){let i=j(e),a=I(e,i.continueWith),o=d(e),[s,c]=(0,X.useState)(``),[l,u]=(0,X.useState)(!1),[p,m]=(0,X.useState)(null),h=(0,X.useId)(),g=e.status===`running`||e.status===`waiting`,_=e.status===`queued`,v=!g&&!_&&i.available;if(!g&&!_&&!v||e.worktreeLifecycle?.activeOperationId)return null;let y=g&&!o.usable?o.reason:v&&!i.canContinue?i.reason??`No provider can continue this task.`:void 0,b=r?.all.length??0,x=!y&&!l&&(s.trim()!==``||b>0),S=async e=>{if(e?.preventDefault(),x){u(!0),m(null);try{let e=s.trim()===``?``:de(t,s.trim());r&&b>0&&ae(e,void 0)?await r.submit(t=>a(ie(e,t),[])):await a(e,[]),c(``),n()}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}}};return(0,Z.jsxs)(`form`,{"data-slot":`assets-ask`,"aria-label":`Ask about this asset`,onSubmit:e=>void S(e),className:`shrink-0 border-t border-border bg-background px-2 py-2 sm:px-3`,children:[t?(0,Z.jsxs)(`span`,{"data-slot":`assets-ask-ref`,className:`mb-1.5 inline-flex max-w-full items-center gap-1 rounded-full border border-border bg-muted py-0.5 pr-0.5 pl-2 text-meta`,children:[(0,Z.jsx)(se,{"aria-hidden":`true`,className:`size-3 shrink-0 text-muted-foreground`}),(0,Z.jsx)(W,{label:`${t.ref} — ${t.label}`,children:(0,Z.jsxs)(`span`,{className:`truncate`,children:[(0,Z.jsx)(`span`,{className:`font-mono text-muted-foreground`,children:t.ref}),` `,t.label]})}),(0,Z.jsx)(`button`,{type:`button`,"data-action":`assets-ask-ref-remove`,"aria-label":`Remove reference`,onClick:n,className:`rounded-full p-0.5 text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Z.jsx)(U,{"aria-hidden":`true`,className:`size-3`})})]}):null,r&&b>0?(0,Z.jsx)(`div`,{"data-slot":`assets-ask-comments`,className:`mb-1.5 flex flex-wrap gap-1.5`,children:(0,Z.jsx)(A,{runId:e.id,comments:r.all,onRemove:r.remove})}):null,(0,Z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,Z.jsx)(`textarea`,{"data-slot":`assets-ask-input`,"aria-label":t?`Ask about ${t.label||t.ref}`:`Ask the agent about this asset`,"aria-describedby":y||p?h:void 0,rows:1,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&S()},disabled:!!y,placeholder:t?`Ask or correct — ⌘↵ to send`:b>0?`Add a message, or send the ${b===1?`comment`:`${b} comments`} as they are — ⌘↵`:`Ask the agent about this report — click an element to reference it`,className:`max-h-32 min-h-9 flex-1 resize-y rounded-md border border-border bg-card px-2.5 py-2 text-ui focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none disabled:opacity-60`}),(0,Z.jsxs)(f,{type:`submit`,size:`sm`,"data-action":`assets-ask-send`,disabled:!x,"aria-busy":l||void 0,children:[l?(0,Z.jsx)(T,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Z.jsx)(V,{"aria-hidden":`true`}),v?`Continue`:`Send`]})]}),y||p?(0,Z.jsx)(`p`,{id:h,"data-slot":`assets-ask-reason`,className:`mt-1 text-label text-muted-foreground`,children:p??y}):null]})}function me(e){return`${e}${e.includes(`?`)?`&`:`?`}picker=1`}function he(e,t){let n=e.selector.split(` > `).at(-1)??e.selector;return{url:``,selector:e.selector,tag:/^[a-z][a-z0-9-]*/i.exec(n)?.[0]??n,text:e.label,html:e.excerpt,styles:{},rect:{x:0,y:0,width:0,height:0},viewport:{width:0,height:0},components:[],source:``,mark:t}}function ge({frameRef:e,frameKey:t,asset:n,store:r,active:i,onActiveChange:a}){let o=(0,X.useMemo)(()=>r.assetComments.filter(e=>e.asset===n),[n,r.assetComments]),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)({}),[d,f]=(0,X.useState)(null),[p,m]=(0,X.useState)(``),h=(0,X.useRef)(new Map),g=(0,X.useRef)(!1);(0,X.useEffect)(()=>{c(!1),u({}),f(null),h.current.clear()},[t]);let _=(0,X.useCallback)(e=>h.current.get(e.id)??e.id,[]),v=(0,X.useCallback)(t=>{e.current?.contentWindow?.postMessage({source:`cezar-design-host`,...t},`*`)},[e]),y=(0,X.useMemo)(()=>{let e=o.map((e,t)=>({key:_(e),n:t+1,selector:e.selector}));return d&&d.commentId===void 0?[...e,{key:d.key}]:e},[o,d,_]),b=JSON.stringify(y),x=(0,X.useCallback)(()=>v({type:`set-marks`,marks:JSON.parse(b)}),[b,v]);(0,X.useEffect)(()=>{s&&v({type:`set-active`,active:i})},[i,v,s]),(0,X.useEffect)(()=>{s&&x()},[s,x]);let S=(0,X.useRef)({comments:o,editing:d,active:i});S.current={comments:o,editing:d,active:i},(0,X.useEffect)(()=>{let t=t=>{if(t.source===null||t.source!==e.current?.contentWindow)return;let n=t.data;if(typeof n!=`object`||!n||n.source!==`cezar-design`)return;let r=S.current;if(n.type===`ready`)h.current.clear(),c(!0);else if(n.type===`rects`)u(P(n.rects));else if(n.type===`toggle`)a(!1);else if(n.type===`cancel`)r.editing?f(null):a(!1);else if(n.type===`picked`){let e=F(n.element);if(!e?.mark||!r.active){x();return}let t=e.mark;u(n=>({...n,[t]:e.rect})),f({key:t,pick:{...e,mark:t}}),m(``)}else if(n.type===`mark-clicked`&&typeof n.key==`string`){let e=n.key,t=r.comments.find(t=>_(t)===e);if(!t)return;g.current=!1,f({key:e,pick:he(t,e),commentId:t.id}),m(t.body)}};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e,_,a,x]);let C=(0,X.useCallback)(()=>{let e=d?.commentId?o.find(e=>e.id===d.commentId):void 0;e&&!g.current&&p.trim()!==``&&p.trim()!==e.body&&r.update(e.id,p.trim()),f(null)},[o,d,r,p]),w=(0,X.useRef)(C);w.current=C,(0,X.useEffect)(()=>{if(!i)return;let e=e=>{e.key!==`Escape`||e.defaultPrevented||e.isComposing||(e.preventDefault(),S.current.editing?w.current():a(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i,a]),(0,X.useEffect)(()=>{d?.commentId!==void 0&&!o.some(e=>e.id===d.commentId)&&f(null)},[o,d]);let T=(0,X.useRef)(null),E=(0,X.useRef)(null),[D,k]=(0,X.useState)(null),A=d?l[d.key]:void 0;(0,X.useLayoutEffect)(()=>{if(!d)return k(null);let e=T.current?.parentElement,t=E.current;!e||!t||k(O(A,{width:e.clientWidth,height:e.clientHeight},{width:t.offsetWidth,height:t.offsetHeight}))},[A,d]);let j=D!==null,M=d?.key;if((0,X.useEffect)(()=>{j&&M&&E.current?.querySelector(`textarea`)?.focus()},[M,j]),!d)return(0,Z.jsx)(`div`,{ref:T,hidden:!0});let N=d.commentId?o.findIndex(e=>e.id===d.commentId)+1:0,I=C;return(0,Z.jsx)(`div`,{ref:T,children:(0,Z.jsx)(`div`,{ref:E,"data-slot":`asset-comment-popup`,role:`dialog`,"aria-label":`Comment on this element`,className:`absolute z-20 w-[min(360px,calc(100%-16px))] rounded-xl border border-border bg-background shadow-lg`,style:D?{left:D.left,top:D.top}:{visibility:`hidden`,left:0,top:0},children:(0,Z.jsx)(L,{noun:`comment`,note:{key:d.key,pick:d.pick,text:p,phase:`draft`,added:d.commentId!==void 0,...N>0?{number:N}:{}},notes:{setText:(e,t)=>m(t),markAdded:()=>{let e=p.trim();if(e===``)return;let t=r.addAsset({asset:n,selector:d.pick.selector,label:d.pick.text,excerpt:d.pick.html,body:e});t&&h.current.set(t,d.key)},discard:()=>{d.commentId&&(g.current=!0,r.remove(d.commentId))}},onClose:I})})})}var _e=`No assets yet`,ve=`Agents publish pages here when they write to the run's artifacts folder.`;function ye({runId:e,routed:t,run:n}){let i=a(e),o=c(),u=l(),[d,p]=(0,X.useState)(void 0),m=t?o.name:d,h=i.data?.artifacts??[],g=B(h,m),_=(0,X.useCallback)(n=>{t?u(`/tasks/${e}/assets/${encodeURIComponent(n)}`,{replace:!0}):p(n)},[u,t,e]),[v,y]=xe(),[S,C]=(0,X.useState)(0),[D,O]=(0,X.useState)(void 0),k=g?.kind===`html`?Q(i.data?.versions,g.name):[],A=k.at(-1)?.version,j=D&&g&&D.name===g.name&&D.version!==A&&k.some(e=>e.version===D.version)?D.version:void 0,M=(0,X.useRef)(null),[N,P]=(0,X.useState)(null);fe(M,P);let F=oe(n?e:``),I=n!==void 0&&g?.kind===`html`&&j===void 0,[L,R]=(0,X.useState)(null),z=I&&L?.name===g?.name,V=(0,X.useCallback)(e=>R(e&&g?{name:g.name}:null),[g]),U=new Map;for(let e of F.assetComments)U.set(e.asset,(U.get(e.asset)??0)+1);let G=g?`${g.name}@${g.updatedAt}#${S}v${j??``}`:``;return i.isPending?(0,Z.jsx)(K,{icon:(0,Z.jsx)(T,{className:`motion-safe:animate-spin`}),tone:`neutral`,heading:`h2`,title:`Loading assets…`}):i.isError?(0,Z.jsx)(K,{icon:(0,Z.jsx)(H,{}),tone:`danger`,heading:`h2`,title:`Could not load this task's assets`,subtitle:i.error.message}):(0,Z.jsxs)(`section`,{"data-slot":`assets-view`,className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,Z.jsxs)(`div`,{"data-slot":`assets-toolbar`,role:`toolbar`,"aria-label":`Assets`,className:`flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-2 sm:px-3`,children:[g?(0,Z.jsx)(Se,{artifacts:h,current:g,onSelect:_,counts:U}):(0,Z.jsx)(`span`,{className:`px-1 text-xs text-muted-foreground`,children:`Assets`}),g?.kind===`html`?(0,Z.jsx)(W,{label:`Runs in a sandbox: no access to cezar, your cookies or the network beyond pinned CDN scripts`,children:(0,Z.jsxs)(`span`,{"data-slot":`assets-sandboxed`,tabIndex:0,className:`hidden items-center gap-1 rounded-sm border border-border px-1.5 py-px text-meta text-muted-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none sm:inline-flex`,children:[(0,Z.jsx)(ne,{"aria-hidden":`true`,className:`size-3`}),`sandboxed`]})}):null,g&&k.length>1?(0,Z.jsx)(be,{versions:k,viewing:j,onSelect:e=>O(e===A?void 0:{name:g.name,version:e})}):null,j===void 0?null:(0,Z.jsxs)(`span`,{"data-slot":`assets-viewing-version`,className:`inline-flex items-center gap-1.5 text-meta text-muted-foreground`,children:[`Viewing v`,j,(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`—`}),(0,Z.jsx)(`button`,{type:`button`,"data-action":`assets-version-current`,onClick:()=>O(void 0),className:`font-medium text-foreground underline underline-offset-2`,children:`back to current`})]}),i.data.truncated?(0,Z.jsxs)(`span`,{className:`hidden text-meta text-muted-foreground md:inline`,children:[`Showing the newest `,i.data.artifacts.length,` files; the folder has more`]}):null,(0,Z.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-0.5`,children:[I&&g?(0,Z.jsx)(W,{label:z?`Stop commenting (Esc)`:`Comment — click an element of the page to leave a comment for the agent`,children:(0,Z.jsxs)(f,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-comment`,"aria-pressed":z,disabled:!F.ready,className:s(`text-muted-foreground max-sm:px-1.5`,z&&`bg-muted text-foreground`),onClick:()=>V(!z),children:[(0,Z.jsx)(le,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`max-sm:sr-only`,children:`Comment`}),(0,Z.jsx)(Y,{count:U.get(g.name)??0})]})}):null,(0,Z.jsx)(W,{label:v?`Leave focus — bring the sidebar back`:`Focus — fold the sidebar to icons while Assets is open`,children:(0,Z.jsx)(f,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-action":`assets-focus`,"aria-pressed":v,"aria-label":v?`Leave focus`:`Focus`,className:s(`text-muted-foreground`,v&&`bg-muted text-foreground`),onClick:()=>y(!v),children:v?(0,Z.jsx)(q,{"aria-hidden":`true`}):(0,Z.jsx)(re,{"aria-hidden":`true`})})}),g?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f,{asChild:!0,variant:`ghost`,size:`sm`,className:`text-muted-foreground max-sm:size-[30px] max-sm:px-0`,children:(0,Z.jsxs)(`a`,{"data-action":`assets-open`,href:r(e,g.name,j),target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Open in new tab`,title:`Open in new tab (still sandboxed)`,children:[(0,Z.jsx)(x,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`max-sm:sr-only`,children:`Open in new tab`})]})}),(0,Z.jsx)(f,{asChild:!0,variant:`ghost`,size:`sm`,className:`text-muted-foreground max-sm:size-[30px] max-sm:px-0`,children:(0,Z.jsxs)(`a`,{"data-action":`assets-download`,href:r(e,g.name,j),download:g.name,"aria-label":`Download`,children:[(0,Z.jsx)(b,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`max-sm:sr-only`,children:`Download`})]})}),(0,Z.jsxs)(f,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-reload`,"aria-label":`Reload`,className:`text-muted-foreground max-sm:size-[30px] max-sm:px-0`,onClick:()=>C(e=>e+1),children:[(0,Z.jsx)(E,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`max-sm:sr-only`,children:`Reload`})]})]}):null]})]}),g&&I?(0,Z.jsxs)(`div`,{"data-slot":`assets-comment-area`,className:`relative flex min-h-0 flex-1 flex-col`,children:[(0,Z.jsx)($,{runId:e,artifact:g,version:j,frameRef:M,picker:!0},G),(0,Z.jsx)(ge,{frameRef:M,frameKey:G,asset:g.name,store:F,active:z,onActiveChange:V}),z?(0,Z.jsx)(`p`,{"data-slot":`assets-comment-hint`,className:`pointer-events-none absolute bottom-3 left-1/2 z-10 -translate-x-1/2 rounded-full border border-border bg-background/95 px-3 py-1 text-label whitespace-nowrap text-muted-foreground shadow-sm`,children:`Click an element to comment · Esc to stop`}):null]}):g?(0,Z.jsx)($,{runId:e,artifact:g,version:j,frameRef:M},G):(0,Z.jsx)(K,{icon:(0,Z.jsx)(w,{}),tone:`neutral`,heading:`h2`,title:_e,subtitle:ve}),n&&g?(0,Z.jsx)(pe,{run:n,reference:N,onClearReference:()=>P(null),comments:F}):null]})}function Q(e,t){return(e??[]).filter(e=>e.files.includes(t))}function be({versions:e,viewing:t,onSelect:n}){let r=e.at(-1),i=t??r?.version;return(0,Z.jsxs)(y,{children:[(0,Z.jsx)(g,{asChild:!0,children:(0,Z.jsxs)(f,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-versions`,"aria-label":`Version v${i} — pick another version`,className:`h-7 gap-1 px-2 text-label text-muted-foreground`,children:[(0,Z.jsx)(ce,{"aria-hidden":`true`,className:`size-3.5`}),`v`,i,r&&t===void 0?(0,Z.jsxs)(`span`,{className:`hidden sm:inline`,children:[`· `,G(r.updatedAt),` ago`]}):null,(0,Z.jsx)(p,{"aria-hidden":`true`,className:`size-3.5 opacity-60`})]})}),(0,Z.jsxs)(_,{align:`start`,className:`w-56`,children:[(0,Z.jsx)(m,{children:`Versions`}),(0,Z.jsx)(h,{value:String(i),onValueChange:e=>n(Number(e)),children:[...e].reverse().map(e=>(0,Z.jsxs)(v,{value:String(e.version),"data-version":e.version,children:[`v`,e.version,` · `,G(e.updatedAt),` ago`,e.version===r?.version?(0,Z.jsx)(`span`,{className:`ml-auto text-meta text-muted-foreground`,children:`current`}):null]},e.version))})]})]})}function xe(){let[e,t]=(0,X.useState)(()=>k(`assets`)),n=(0,X.useCallback)(e=>{z(`assets`,e),t(e)},[]);return(0,X.useEffect)(()=>{if(e)return te(()=>n(!1))},[e,n]),[e,n]}function Se({artifacts:e,current:t,onSelect:n,counts:r}){let i=R(e);return(0,Z.jsxs)(y,{children:[(0,Z.jsx)(g,{asChild:!0,children:(0,Z.jsxs)(f,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`assets-switcher`,"aria-label":`Asset: ${D(t)} — switch asset`,className:`h-7 min-w-0 max-w-[min(28rem,60vw)] gap-1.5 px-2 text-ui font-medium`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:D(t)}),(0,Z.jsx)(`span`,{className:`shrink-0 text-meta font-normal text-muted-foreground`,children:M[t.kind]}),(0,Z.jsx)(p,{"aria-hidden":`true`,className:`size-3.5 shrink-0 opacity-60`})]})}),(0,Z.jsxs)(_,{align:`start`,className:`max-h-80 w-80 overflow-y-auto`,children:[(0,Z.jsxs)(m,{children:[e.length,` `,e.length===1?`asset`:`assets`]}),(0,Z.jsx)(h,{value:t.name,onValueChange:n,children:i.map(e=>(0,Z.jsx)(v,{value:e.name,"data-asset":e.name,children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`truncate`,children:D(e)}),(0,Z.jsx)(Y,{count:r?.get(e.name)??0})]}),(0,Z.jsxs)(`span`,{className:`truncate font-mono text-meta text-muted-foreground`,children:[e.name,` · `,M[e.kind],` · `,G(e.updatedAt)]})]})},e.name))})]})]})}function $({runId:e,artifact:t,version:n,frameRef:i,picker:a=!1}){let o=J(),s=r(e,t.name,n);switch(t.kind){case`html`:return(0,Z.jsx)(`iframe`,{ref:i,"data-slot":`assets-frame`,title:D(t),src:`${a?me(s):s}#theme=${o}`,sandbox:N,referrerPolicy:`no-referrer`,className:`min-h-0 w-full flex-1 border-0 bg-background`});case`image`:return(0,Z.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center overflow-auto p-4`,children:(0,Z.jsx)(`img`,{"data-slot":`assets-image`,src:s,alt:D(t),className:`max-w-full rounded-sm`})});case`markdown`:case`json`:return(0,Z.jsx)(Ce,{runId:e,artifact:t});case`other`:return(0,Z.jsx)(K,{icon:(0,Z.jsx)(C,{}),tone:`neutral`,heading:`h2`,title:`No preview for this file`,subtitle:`${t.name} — download it to open it locally.`,actions:(0,Z.jsx)(f,{asChild:!0,variant:`outline`,children:(0,Z.jsxs)(`a`,{"data-action":`assets-download-file`,href:s,download:t.name,children:[(0,Z.jsx)(b,{"aria-hidden":`true`}),`Download`]})})})}}function Ce({runId:e,artifact:t}){let n=i(e,t.name,t.updatedAt);return n.isPending?(0,Z.jsxs)(`p`,{className:`px-4 py-6 text-center text-label text-soft-foreground`,children:[`Loading `,t.name,`…`]}):n.isError?(0,Z.jsx)(K,{icon:(0,Z.jsx)(H,{}),tone:`danger`,heading:`h2`,title:`Could not load this asset`,subtitle:n.error.message}):(0,Z.jsx)(`div`,{"data-slot":`assets-${t.kind}`,className:`min-h-0 flex-1 overflow-auto`,children:t.kind===`markdown`?(0,Z.jsx)(`div`,{className:`mx-auto max-w-3xl px-4 py-4`,children:(0,Z.jsx)(ee,{children:n.data})}):(0,Z.jsx)(S,{path:t.name,text:n.data})})}export{ye as AssetsView};
|
|
@@ -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{Ci as r,Cr as i,Di as a,Dr as o,Er as s,No as c,Or as l,Po as u,Sn as d,Sr as f,Tr as p,a as m,kr as h,pr as g,qo as _,vo as v,wr as y,yn as b,yo as ee,yr as x,z as S}from"./queries-xqgnsU4z.js";import{G as te,J as C,Yt as ne,Z as w,Zt as re,a as T,c as E,en as ie,it as D,rt as O,s as k,tt as A}from"./utils-BqOIVEJr.js";import{t as ae}from"./worktree-lifecycle-DXJ2n58y.js";import{D as oe,E as se}from"./plan-usage-DHvUCR47.js";import{d as j,g as M,m as N,r as ce,t as le}from"./managers-XxR9VkFB.js";import{n as P}from"./segmented-Dh3fdAcq.js";import{C as F,_ as I,a as L,b as R,r as ue}from"./questions-DcWmawf9.js";import{t as de}from"./run-events-BubjG0MJ.js";import{t as z}from"./createLucideIcon-BHp8sXmF.js";var B=e(t(),1),V=new Map,H=e=>({status:e.status,archived:e.archived,awaitingAnswerSince:e.awaitingAnswerSince,idleClosedAt:e.idleClosedAt}),U=new Map,W=new Set,G=0;function fe(e,t){t?U.set(e,G+1):U.delete(e),G++,W.forEach(e=>e())}function pe(e,t){let n=`${e}:${typeof t==`string`?t:t.id}`;V.delete(n),V.set(n,{value:typeof t==`string`?null:H(t),revision:G+1}),V.size>2e3&&V.delete(V.keys().next().value),G++,W.forEach(e=>e())}function K(e){return(0,B.useSyncExternalStore)(e=>(W.add(e),()=>{W.delete(e)}),()=>G),he(e.projectId,e.id)}var me=()=>G,he=(e,t)=>U.has(e)?null:V.get(`${e}:${t}`)?.value;function q(e,t=[]){let n=new Map(t.map(e=>[`${e.projectId}:${e.id}`,e])),r=!1;for(let n of t){let t=U.get(n.projectId);t!==void 0&&t<=e&&(U.delete(n.projectId),r=!0)}for(let[t,i]of V){let a=n.get(t);i.revision>e||!a||(a.status!==void 0&&a.archived!==void 0?(V.set(t,{value:H({status:a.status,archived:a.archived,awaitingAnswerSince:a.awaitingAnswerSince,idleClosedAt:a.idleClosedAt}),revision:G+1}),r=!0):i.value===null&&(V.delete(t),r=!0))}r&&(G++,W.forEach(e=>e()))}function J(e){return{enabled:(e&&typeof e==`object`?e:{}).enabled===!0}}function Y(){let e=globalThis.Notification;if(typeof e!=`function`)return`unsupported`;let t=e.permission;return t===`granted`||t===`denied`?t:`default`}function ge(e,t){let n=new Map,r=[];for(let i of t??[]){n.set(i.id,i.status);let t=e.get(i.id);t===void 0||t===i.status||x(i)&&r.push(i)}return{entering:r,statuses:n}}function X(e){return e.enabled&&e.hidden&&e.permission===`granted`}function Z(e){let t=g(e).label;return{title:e.titleSummary??e.title,body:`Task ${t}`,tag:`cezar-run-${e.id}`,path:`/p/default/tasks/${encodeURIComponent(e.id)}`}}var Q=e=>e.pendingActions+e.pendingQuestions+e.important;function _e(e,t){let n=new Map(t.map(e=>[e.id,Q(e)]));return{entering:e===null?[]:t.filter(t=>t.notify!==!1&&Q(t)>(e.get(t.id)??0)),counts:n}}function ve(e){return{title:e.name,body:e.pendingActions>0?`Needs your approval`:e.pendingQuestions>0?`Has a question for you`:e.headline??e.preview??`New message`,tag:`cezar-manager-${e.id}`,path:`/manager/${encodeURIComponent(e.id)}`}}function ye(e,t){let n=t.disk?.guardWarning??null;return e===null&&n!==null?n:null}function be(e){return{title:`Disk almost full`,body:e,tag:`cezar-disk-guard`,path:`/settings/global/behaviour#resources`}}function xe(e){return Y()===`granted`&&Se(e)?!0:J(e.getQueryData(b.uiState)?.notifications).enabled&&Y()===`granted`}function Se(e){return Y()===`granted`&&e.getQueryData(b.uiState)===void 0}var Ce=n(),we=`${T(`/workspace/events`)}?slim=1`,Te=1,Ee=2,De=3e3,Oe=2e3,ke=[`run`,`run-deleted`,`todos`,`usage`,`ping`],Ae=[`project-added`,`project-removed`,`checkout-progress`,`automation-change`,`tracker-changed`,`phone-pairing`],je=new Set;function Me(e){return je.add(e),()=>{je.delete(e)}}var Ne=400,Pe=15e3;function Fe(e){let t;return{onEvent(n){n.type!==`run`&&n.type!==`run-deleted`||t===void 0&&(t=setTimeout(()=>{t=void 0,e.invalidateQueries({queryKey:b.runsIndex})},Ne))},cancel(){clearTimeout(t),t=void 0}}}var Ie=[500,1500];function Le(e){let t=new Set,n=new Map,r=new Set,o=!1,s=e=>{t.delete(e),n.delete(e)},c=(t,r,a)=>{let o=n.get(t);if(s(t),o?.kind===`deleted`){e.setQueryData(r,e=>i(e,a.id));return}e.setQueryData(r,e=>{let t=e!==void 0&&e.some(e=>e.id===a.id)?e:y(e,a);return o?.kind===`run`?y(t,o.frame):t})},l=(t,n,i,u,d)=>{a(i,u).then(e=>{o||c(t,n,e)}).catch(a=>{if(o)return;let c=Ie[d],f=a instanceof h&&a.status>=400&&a.status<500;if(c===void 0||f){s(t),c===void 0&&e.invalidateQueries({queryKey:n,refetchType:`active`});return}let p=setTimeout(()=>{r.delete(p),o||l(t,n,i,u,d+1)},c);r.add(p)})};return{run(e,r){if(o)return;let i=E(),a=`${i}\0${e}`;if(t.has(a)){n.set(a,{kind:`run`,frame:r});return}t.add(a),l(a,[i,`runs`,`list`],i,e,0)},deleted(e){if(o)return;let r=`${E()}\0${e}`;t.has(r)&&n.set(r,{kind:`deleted`})},cancel(){o=!0;for(let e of r)clearTimeout(e);r.clear(),t.clear(),n.clear()}}}function Re(e,t){let n;for(let t of e.getQueryCache().getAll()){if(t.queryKey[1]!==`health`)continue;let e=t.state.data?.bootProject;if(typeof e==`string`){n=e;break}}let r=new Set([t]);return n===t&&r.add(`default`),[...r]}function ze(e){return[[`run-history`,e],[`run-history-context`,e],[`run-history-tail`,e]]}function Be(e){return[[e,`runs`],[e,`todos`],[e,`worktrees`],...ze(e)]}function Ve(e){if(e[0]!==`workspace`)return e[0]===`run-history`||e[0]===`run-history-context`||e[0]===`run-history-tail`?typeof e[1]==`string`?e[1]:void 0:typeof e[0]==`string`?e[0]:void 0}function He(e){return[...new Set(e.getQueryCache().getAll().map(({queryKey:e})=>Ve(e)).filter(e=>e!==void 0))]}function Ue(e){let t,n=new Set;return{onEvent(r){if(!(t!==void 0&&n.has(r))){for(let t of Re(e,r))n.add(t);t===void 0&&(t=setTimeout(()=>{t=void 0;let r=n;n=new Set;let i=E();for(let t of r)for(let n of Be(t))e.invalidateQueries({queryKey:n,refetchType:t===i?`active`:`none`})},Ne))}},cancel(){clearTimeout(t),t=void 0,n.clear()}}}function We(e,t,n,r){let i=new Map,a,o=0,s=()=>{if(clearTimeout(a),a=void 0,o>0)return;let s=$(e),c=i;i=new Map;for(let i of c.values())i.project===s?Ke(e,t,i.event,r):n(i.project)},c=()=>{a===void 0&&(a=setTimeout(s,50))};return{onEvent(e,t){let n=e.type===`run`?e.run.id:e.id;i.set(`${t}:${n}`,{event:e,project:t}),c()},beginReconcile(){s(),o+=1},endReconcile(){o!==0&&(--o,o===0&&s())},cancel(){clearTimeout(a),a=void 0,i.clear(),o=0}}}async function Ge(e){let t=E(),n=[m.runs.all,b.runsIndex,b.dashboard,m.todos,m.health,m.worktrees,ae.all(),b.providerStatus,b.hostUsage,b.skillsUpdateAll,j.list,L.all,R.all,[`run-history`,t],[`run-history-context`,t]],r=Promise.allSettled([Promise.all([e.cancelQueries({queryKey:[`tracker`],predicate:e=>e.queryKey[2]!==`items`||e.getObserversCount()===0}),e.cancelQueries({queryKey:b.projects})]).then(()=>Promise.all([e.invalidateQueries({queryKey:[`tracker`],predicate:e=>e.queryKey[2]!==`items`||e.getObserversCount()===0}),e.invalidateQueries({queryKey:b.projects})])),e.invalidateQueries({queryKey:[`worktree-lifecycle`],refetchType:`none`}),M(e),N(e),...He(e).filter(e=>e!==t).flatMap(t=>Be(t).map(t=>e.invalidateQueries({queryKey:t,refetchType:`none`}))),...n.map(t=>e.invalidateQueries({queryKey:t}))]),i=!1,a;try{await Promise.race([r.then(()=>{i=!0}),new Promise(e=>{a=setTimeout(e,Pe)})])}finally{clearTimeout(a)}i||await Promise.allSettled(n.map(t=>e.cancelQueries({queryKey:t})))}function $(e){return k()??e.getQueryData(m.health)?.bootProject}function Ke(e,t,n,r){switch(n.type){case`run`:{let t=m.runs.list(),i=e.getQueryData(t);i&&!s(n.run)&&!i.some(e=>e.id===n.run.id)?r.run(n.run.id,n.run):e.setQueryData(t,e=>y(e,n.run));let a=m.runs.detail(n.run.id);e.getQueryData(a)!==void 0&&e.setQueryData(a,e=>e===void 0?e:o(e,n.run));let c=m.runs.changes(n.run.id);e.getQueryData(c)!==void 0&&e.invalidateQueries({queryKey:c}),e.invalidateQueries({queryKey:m.worktrees});return}case`run-deleted`:r.deleted(n.id),e.setQueryData(m.runs.list(),e=>i(e,n.id)),e.removeQueries({queryKey:m.runs.detail(n.id)}),e.removeQueries({queryKey:m.runs.diff(n.id)}),e.invalidateQueries({queryKey:m.worktrees});return;case`todos`:e.setQueryData(m.todos,n.items);return;case`usage`:t.set(n.usage);return;case`ping`:return}}function qe(e,t=we){let n=_();(0,B.useEffect)(()=>{let i=globalThis.EventSource;if(typeof i!=`function`)return;let a=null,o,s,f=new Set,p=()=>{clearTimeout(o),clearTimeout(s),o=void 0,s=void 0;let e=$(n);for(let t of f){let r=t===e?E():t;n.invalidateQueries({queryKey:ae.all(r),refetchType:t===e?`active`:`none`}),t===e&&n.invalidateQueries({queryKey:m.worktrees})}f.clear()},h,g,_=()=>{clearTimeout(h),clearTimeout(g),h=void 0,g=void 0,n.invalidateQueries({queryKey:b.dashboard,refetchType:document.visibilityState===`hidden`?`none`:`active`,predicate:e=>e.queryKey[2]!==`telemetry`&&e.queryKey[2]!==`automations`&&!(e.queryKey[2]===`feed`&&e.queryKey[3]===`github`)})},y=()=>{clearTimeout(h),h=setTimeout(_,250),g??=setTimeout(_,1e3)},x=Fe(n),S=Le(n),C=Ue(n),w=We(n,e,C.onEvent,S),T,D=!1,O=!1,k,A=!1,j=Date.now(),M,N=!1,I=!1,L=0,R=new Set,z=[],B=()=>{N=!0,I=!1;let e=b.providerStatus;n.cancelQueries({queryKey:e,exact:!0}).then(()=>n.invalidateQueries({queryKey:e,exact:!0,refetchType:`active`})).finally(()=>{if(A||!I){N=!1;return}B()})},V=e=>{let t=b.providerStatus,r=c(n.getQueryData(t),e);if(r!==void 0){n.setQueryData(t,r);return}if(N){I=!0;return}B()},H=Date.now(),U=0,W,G=()=>{W!==void 0||Date.now()-U<1e4||(W=setTimeout(()=>{W=void 0,!(A||P.isConnected())&&(U=Date.now(),r().catch(()=>{}))},Oe))},K=()=>{H=Date.now(),L+=1,w.beginReconcile(),Ge(n).finally(()=>{--L,L===0&&(A?(R.clear(),z=[]):me()),w.endReconcile()})},me=()=>{let e=R,t=z;R=new Set,z=[];let r=$(n);for(let t of e)t===r?n.invalidateQueries({queryKey:m.todos}):C.onEvent(t);for(let e of t)V(e)},he=()=>{A||T!==void 0||(T=setTimeout(()=>{T=void 0,A||q()},De))},q=()=>{P.connected(!1),a?.close(),j=Date.now();let r=new i(t,{withCredentials:!0});a=r,r.addEventListener(`open`,()=>{A||a!==r||(j=Date.now(),clearTimeout(k),k=void 0,(D||O)&&K(),v.opened(),ee.clear(),P.connected(!0),D=!0,O=!1)});for(let t of ke)r.addEventListener(t,i=>{if(A||a!==r)return;j=Date.now();let o=l(t,i.data);if(o){if(x.onEvent(o.event),(o.event.type===`run`||o.event.type===`run-deleted`)&&(ue(n),F(n),y(),o.project&&pe(o.project,o.event.type===`run-deleted`?o.event.id:o.event.run),o.project&&(o.event.type===`run-deleted`||o.event.run.status!==`running`)&&P.remove(o.project,o.event.type===`run-deleted`?o.event.id:o.event.run.id)),t===`usage`)try{let e=te.safeParse(JSON.parse(i.data));e.success&&P.replace(e.data.project,e.data.samples??[],e.data.sentAt)}catch{}if(o.project!==null&&o.project!==$(n)){C.onEvent(o.project);return}o.event.type===`run`||o.event.type===`run-deleted`?o.project!==null&&w.onEvent(o.event,o.project):o.event.type===`todos`&&L>0?o.project!==null&&R.add(o.project):Ke(n,e,o.event,S)}});r.addEventListener(`worktree-lifecycle`,e=>{if(A||a!==r)return;j=Date.now();let t;try{t=JSON.parse(e.data)}catch{return}let n=re.safeParse(t);n.success&&(f.add(n.data.projectId),clearTimeout(o),o=setTimeout(p,100),s??=setTimeout(p,1e3))}),r.addEventListener(`artifacts`,e=>{if(A||a!==r)return;j=Date.now();let t;try{t=JSON.parse(e.data)}catch{return}let i=ne.safeParse(t);if(!i.success)return;let{project:o,runId:s,artifacts:c,truncated:l,versions:u}=i.data;if(o!==void 0&&o!==$(n)){C.onEvent(o);return}let d={artifacts:c,truncated:l,...u?{versions:u}:{}},f=m.runs.artifacts(s);n.getQueryData(f)!==void 0&&n.setQueryData(f,d),n.setQueriesData({queryKey:m.runs.impactSubjects},e=>e?.run?.id===s?$e(e,d):e),n.invalidateQueries({queryKey:m.runs.projectAssets})});for(let e of Ae)r.addEventListener(e,t=>{if(A||a!==r)return;j=Date.now();let i;try{i=JSON.parse(t.data)}catch{return}if(e===`tracker-changed`){if(!ie.safeParse(i).success)return;Promise.all([n.cancelQueries({queryKey:[`tracker`]}),n.cancelQueries({queryKey:b.projects})]).then(()=>Promise.all([n.invalidateQueries({queryKey:[`tracker`]}),n.invalidateQueries({queryKey:b.projects})]))}e!==`checkout-progress`&&e!==`automation-change`&&e!==`tracker-changed`&&(i&&typeof i==`object`&&(e===`project-removed`&&`id`in i&&typeof i.id==`string`?(fe(i.id,!0),P.remove(i.id)):e===`project-added`&&`project`in i&&i.project&&typeof i.project==`object`&&`id`in i.project&&typeof i.project.id==`string`&&fe(i.project.id,!1)),n.invalidateQueries({queryKey:b.projects}),n.invalidateQueries({queryKey:b.dashboard,refetchType:document.visibilityState===`hidden`?`none`:`active`}));for(let t of[...je])t(e,i)});for(let e of le)r.addEventListener(e,t=>{A||a!==r||(j=Date.now(),ce(n,e,t.data),e!==`manager-delta`&&(ue(n),F(n)))});r.addEventListener(`attention-change`,()=>{A||a!==r||(j=Date.now(),F(n))}),r.addEventListener(`provider-status`,e=>{if(A||a!==r)return;j=Date.now();let t;try{t=JSON.parse(e.data)}catch{return}let n=u(t);if(n){if(L>0){z.push(n);return}V(n)}}),r.addEventListener(`agent-login`,e=>{if(A||a!==r)return;j=Date.now();let t;try{t=JSON.parse(e.data)}catch{return}oe(n,t)}),r.addEventListener(`account-reconnected`,e=>{if(A||a!==r)return;j=Date.now();let t;try{t=JSON.parse(e.data)}catch{return}se(n,t)}),r.addEventListener(`error`,()=>{A||a!==r||(P.connected(!1),v.failedAttempt(),G(),r.readyState===Ee&&he())})},J=()=>{O=!0,clearTimeout(k),k=setTimeout(()=>{k=void 0,!(A||!O)&&(O=!1,K())},Pe)},Y,ge=()=>{if(Y=void 0,A||document.visibilityState!==`hidden`)return;if(xe(n)){Se(n)&&(Y=setTimeout(ge,de));return}clearTimeout(T),T=void 0;let e=a;a=null,P.connected(!1),e?.close()},X=()=>{document.visibilityState===`hidden`&&(Y??=setTimeout(ge,de))},Z=()=>{A||(clearTimeout(T),T=void 0,J(),q())},Q=()=>{if(document.visibilityState===`hidden`){X();return}if(clearTimeout(Y),Y=void 0,!a||a.readyState===Ee||Date.now()-j>2e4){Z();return}K()},_e=()=>{a?.readyState===Te&&P.isConnected()||Z()},ve=v.setReconnect(()=>{Z(),d(),n.invalidateQueries({queryKey:m.health})}),ye=()=>{clearTimeout(T),T=void 0;let e=a;a=null,P.connected(!1),e?.close()},be=e=>{e.persisted&&(J(),q(),X())};return M=setInterval(()=>{A||document.visibilityState!==`visible`||(!P.isConnected()&&L===0&&Date.now()-H>=3e4&&K(),!(Date.now()-j<=4e4)&&(v.failedAttempt(),clearTimeout(T),T=void 0,q()))},1e4),document.addEventListener(`visibilitychange`,Q),window.addEventListener(`online`,_e),window.addEventListener(`pagehide`,ye),window.addEventListener(`pageshow`,be),q(),X(),()=>{A=!0,clearTimeout(T),clearTimeout(k),clearInterval(M),clearTimeout(W),clearTimeout(Y),P.connected(!1),clearTimeout(h),clearTimeout(g),clearTimeout(o),clearTimeout(s),f.clear(),x.cancel(),S.cancel(),C.cancel(),w.cancel(),R.clear(),z=[],document.removeEventListener(`visibilitychange`,Q),window.removeEventListener(`online`,_e),ve(),window.removeEventListener(`pagehide`,ye),window.removeEventListener(`pageshow`,be);let e=a;a=null,P.connected(!1),e?.close()}},[n,e,t])}var Je=(0,B.createContext)(null);function Ye({children:e}){let[t]=(0,B.useState)(p);return qe(t),S(),I(),(0,Ce.jsx)(Je.Provider,{value:t,children:e})}function Xe(e){let t=(0,B.useContext)(Je),n=t?t.get:Qe;return(0,B.useSyncExternalStore)(t?t.subscribe:Ze,()=>e?n()[e]:void 0,()=>void 0)}var Ze=()=>()=>void 0,Qe=()=>f;function $e(e,t){if(e.run===null)return e;let{versions:n,...r}=e;return{...r,artifacts:t.artifacts,truncated:t.truncated,...t.versions?{versions:t.versions}:{}}}var et=z(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]);function tt(e){return C[((e-1)%7+7)%7]??``}function nt(e,t){let n=D(typeof e==`number`?e:Date.parse(e),t);return n?`${tt(n.weekday)} ${w(n.hour,n.minute)}`:``}function rt(e,t){let n=D(typeof e==`number`?e:Date.parse(e),t);return n?w(n.hour,n.minute):``}function it(e,t,n=Date.now()){let r=Date.parse(e),i=D(r,t);if(!i)return``;if(n-r<6*864e5)return`${tt(i.weekday)} ${w(i.hour,i.minute)}`;let a=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][i.month-1];return`${i.day} ${a} ${w(i.hour,i.minute)}`}function at(e,t=Date.now()){let n=Math.max(0,Math.round((e-t)/6e4));return n<60?`in ${n}m`:n<1440?`in ${Math.round(n/60)}h`:`in ${Math.round(n/1440)}d`}function ot(e){let t=Math.round(e/60),n=Math.floor(t/60);return n>0?`${n}h ${String(t%60).padStart(2,`0`)}m`:`${t}m`}function st(e){return e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function ct(e){switch(e){case`done`:return`success`;case`running`:case`queued`:case`waiting`:return`pending`;case`failed`:case`cancelled`:return`danger`;case`review`:return`info`}}function lt(e){if(e.kind===`schedule`)return O(e).map(A).join(`; `);if(e.kind===`tracker`){let t=e.trackerTrigger,n=t?.association.kind===`jira`?`Jira`:t?.association.kind===`linear`?`Linear`:`Tracker`;return t?`${n} · ${t.events.join(`, `)}${t.targetStatusIds?.length?` → ${t.targetStatusIds.join(`, `)}`:``}${t.changedLabelIds?.length?` · labels ${t.changedLabelIds.join(`, `)}`:``} · every ${Math.round((e.intervalSeconds??1800)/60)} min`:`${n} · select an event to complete setup`}let t=(e.events??[]).join(`, `),n=Math.round((e.intervalSeconds??300)/60);return`on ${t||`github`} · every ${n} min`}function ut(e){switch(e){case`launched`:case`manual`:case`catch-up`:return`success`;case`failed`:case`error`:case`rate-limited`:return`danger`;default:return`neutral`}}export{X as C,K as E,Y as S,q as T,Z as _,at as a,ye as b,rt as c,et as d,Ye as f,ve as g,be as h,it as i,lt as l,Xe as m,tt as n,ut as o,Me as p,nt as r,ct as s,ot as t,st as u,_e as v,me as w,J as x,ge as y};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ci as r,Cr as i,Di as a,Dr as o,Er as s,No as c,Or as l,Po as u,Sn as d,Sr as f,Tr as p,a as m,kr as h,pr as g,qo as _,vo as v,wr as y,yn as b,yo as ee,yr as x,z as S}from"./queries-Cwkv3B0F.js";import{G as te,J as C,Yt as ne,Z as w,Zt as re,a as T,c as E,en as ie,it as D,rt as O,s as k,tt as A}from"./utils-BqOIVEJr.js";import{t as ae}from"./worktree-lifecycle-HhWLaJEw.js";import{D as oe,E as se}from"./plan-usage-k846Eayo.js";import{d as j,g as M,m as N,r as ce,t as le}from"./managers-BPDUfsAp.js";import{n as P}from"./segmented-Dh3fdAcq.js";import{C as F,_ as I,a as L,b as R,r as ue}from"./questions-DPXsqwIB.js";import{t as de}from"./run-events-BubjG0MJ.js";import{t as z}from"./createLucideIcon-BHp8sXmF.js";var B=e(t(),1),V=new Map,H=e=>({status:e.status,archived:e.archived,awaitingAnswerSince:e.awaitingAnswerSince,idleClosedAt:e.idleClosedAt}),U=new Map,W=new Set,G=0;function fe(e,t){t?U.set(e,G+1):U.delete(e),G++,W.forEach(e=>e())}function pe(e,t){let n=`${e}:${typeof t==`string`?t:t.id}`;V.delete(n),V.set(n,{value:typeof t==`string`?null:H(t),revision:G+1}),V.size>2e3&&V.delete(V.keys().next().value),G++,W.forEach(e=>e())}function K(e){return(0,B.useSyncExternalStore)(e=>(W.add(e),()=>{W.delete(e)}),()=>G),he(e.projectId,e.id)}var me=()=>G,he=(e,t)=>U.has(e)?null:V.get(`${e}:${t}`)?.value;function q(e,t=[]){let n=new Map(t.map(e=>[`${e.projectId}:${e.id}`,e])),r=!1;for(let n of t){let t=U.get(n.projectId);t!==void 0&&t<=e&&(U.delete(n.projectId),r=!0)}for(let[t,i]of V){let a=n.get(t);i.revision>e||!a||(a.status!==void 0&&a.archived!==void 0?(V.set(t,{value:H({status:a.status,archived:a.archived,awaitingAnswerSince:a.awaitingAnswerSince,idleClosedAt:a.idleClosedAt}),revision:G+1}),r=!0):i.value===null&&(V.delete(t),r=!0))}r&&(G++,W.forEach(e=>e()))}function J(e){return{enabled:(e&&typeof e==`object`?e:{}).enabled===!0}}function Y(){let e=globalThis.Notification;if(typeof e!=`function`)return`unsupported`;let t=e.permission;return t===`granted`||t===`denied`?t:`default`}function ge(e,t){let n=new Map,r=[];for(let i of t??[]){n.set(i.id,i.status);let t=e.get(i.id);t===void 0||t===i.status||x(i)&&r.push(i)}return{entering:r,statuses:n}}function X(e){return e.enabled&&e.hidden&&e.permission===`granted`}function Z(e){let t=g(e).label;return{title:e.titleSummary??e.title,body:`Task ${t}`,tag:`cezar-run-${e.id}`,path:`/p/default/tasks/${encodeURIComponent(e.id)}`}}var Q=e=>e.pendingActions+e.pendingQuestions+e.important;function _e(e,t){let n=new Map(t.map(e=>[e.id,Q(e)]));return{entering:e===null?[]:t.filter(t=>t.notify!==!1&&Q(t)>(e.get(t.id)??0)),counts:n}}function ve(e){return{title:e.name,body:e.pendingActions>0?`Needs your approval`:e.pendingQuestions>0?`Has a question for you`:e.headline??e.preview??`New message`,tag:`cezar-manager-${e.id}`,path:`/manager/${encodeURIComponent(e.id)}`}}function ye(e,t){let n=t.disk?.guardWarning??null;return e===null&&n!==null?n:null}function be(e){return{title:`Disk almost full`,body:e,tag:`cezar-disk-guard`,path:`/settings/global/behaviour#resources`}}function xe(e){return Y()===`granted`&&Se(e)?!0:J(e.getQueryData(b.uiState)?.notifications).enabled&&Y()===`granted`}function Se(e){return Y()===`granted`&&e.getQueryData(b.uiState)===void 0}var Ce=n(),we=`${T(`/workspace/events`)}?slim=1`,Te=1,Ee=2,De=3e3,Oe=2e3,ke=[`run`,`run-deleted`,`todos`,`usage`,`ping`],Ae=[`project-added`,`project-removed`,`checkout-progress`,`automation-change`,`tracker-changed`,`phone-pairing`],je=new Set;function Me(e){return je.add(e),()=>{je.delete(e)}}var Ne=400,Pe=15e3;function Fe(e){let t;return{onEvent(n){n.type!==`run`&&n.type!==`run-deleted`||t===void 0&&(t=setTimeout(()=>{t=void 0,e.invalidateQueries({queryKey:b.runsIndex})},Ne))},cancel(){clearTimeout(t),t=void 0}}}var Ie=[500,1500];function Le(e){let t=new Set,n=new Map,r=new Set,o=!1,s=e=>{t.delete(e),n.delete(e)},c=(t,r,a)=>{let o=n.get(t);if(s(t),o?.kind===`deleted`){e.setQueryData(r,e=>i(e,a.id));return}e.setQueryData(r,e=>{let t=e!==void 0&&e.some(e=>e.id===a.id)?e:y(e,a);return o?.kind===`run`?y(t,o.frame):t})},l=(t,n,i,u,d)=>{a(i,u).then(e=>{o||c(t,n,e)}).catch(a=>{if(o)return;let c=Ie[d],f=a instanceof h&&a.status>=400&&a.status<500;if(c===void 0||f){s(t),c===void 0&&e.invalidateQueries({queryKey:n,refetchType:`active`});return}let p=setTimeout(()=>{r.delete(p),o||l(t,n,i,u,d+1)},c);r.add(p)})};return{run(e,r){if(o)return;let i=E(),a=`${i}\0${e}`;if(t.has(a)){n.set(a,{kind:`run`,frame:r});return}t.add(a),l(a,[i,`runs`,`list`],i,e,0)},deleted(e){if(o)return;let r=`${E()}\0${e}`;t.has(r)&&n.set(r,{kind:`deleted`})},cancel(){o=!0;for(let e of r)clearTimeout(e);r.clear(),t.clear(),n.clear()}}}function Re(e,t){let n;for(let t of e.getQueryCache().getAll()){if(t.queryKey[1]!==`health`)continue;let e=t.state.data?.bootProject;if(typeof e==`string`){n=e;break}}let r=new Set([t]);return n===t&&r.add(`default`),[...r]}function ze(e){return[[`run-history`,e],[`run-history-context`,e],[`run-history-tail`,e]]}function Be(e){return[[e,`runs`],[e,`todos`],[e,`worktrees`],...ze(e)]}function Ve(e){if(e[0]!==`workspace`)return e[0]===`run-history`||e[0]===`run-history-context`||e[0]===`run-history-tail`?typeof e[1]==`string`?e[1]:void 0:typeof e[0]==`string`?e[0]:void 0}function He(e){return[...new Set(e.getQueryCache().getAll().map(({queryKey:e})=>Ve(e)).filter(e=>e!==void 0))]}function Ue(e){let t,n=new Set;return{onEvent(r){if(!(t!==void 0&&n.has(r))){for(let t of Re(e,r))n.add(t);t===void 0&&(t=setTimeout(()=>{t=void 0;let r=n;n=new Set;let i=E();for(let t of r)for(let n of Be(t))e.invalidateQueries({queryKey:n,refetchType:t===i?`active`:`none`})},Ne))}},cancel(){clearTimeout(t),t=void 0,n.clear()}}}function We(e,t,n,r){let i=new Map,a,o=0,s=()=>{if(clearTimeout(a),a=void 0,o>0)return;let s=$(e),c=i;i=new Map;for(let i of c.values())i.project===s?Ke(e,t,i.event,r):n(i.project)},c=()=>{a===void 0&&(a=setTimeout(s,50))};return{onEvent(e,t){let n=e.type===`run`?e.run.id:e.id;i.set(`${t}:${n}`,{event:e,project:t}),c()},beginReconcile(){s(),o+=1},endReconcile(){o!==0&&(--o,o===0&&s())},cancel(){clearTimeout(a),a=void 0,i.clear(),o=0}}}async function Ge(e){let t=E(),n=[m.runs.all,b.runsIndex,b.dashboard,m.todos,m.health,m.worktrees,ae.all(),b.providerStatus,b.hostUsage,b.skillsUpdateAll,j.list,L.all,R.all,[`run-history`,t],[`run-history-context`,t]],r=Promise.allSettled([Promise.all([e.cancelQueries({queryKey:[`tracker`],predicate:e=>e.queryKey[2]!==`items`||e.getObserversCount()===0}),e.cancelQueries({queryKey:b.projects})]).then(()=>Promise.all([e.invalidateQueries({queryKey:[`tracker`],predicate:e=>e.queryKey[2]!==`items`||e.getObserversCount()===0}),e.invalidateQueries({queryKey:b.projects})])),e.invalidateQueries({queryKey:[`worktree-lifecycle`],refetchType:`none`}),M(e),N(e),...He(e).filter(e=>e!==t).flatMap(t=>Be(t).map(t=>e.invalidateQueries({queryKey:t,refetchType:`none`}))),...n.map(t=>e.invalidateQueries({queryKey:t}))]),i=!1,a;try{await Promise.race([r.then(()=>{i=!0}),new Promise(e=>{a=setTimeout(e,Pe)})])}finally{clearTimeout(a)}i||await Promise.allSettled(n.map(t=>e.cancelQueries({queryKey:t})))}function $(e){return k()??e.getQueryData(m.health)?.bootProject}function Ke(e,t,n,r){switch(n.type){case`run`:{let t=m.runs.list(),i=e.getQueryData(t);i&&!s(n.run)&&!i.some(e=>e.id===n.run.id)?r.run(n.run.id,n.run):e.setQueryData(t,e=>y(e,n.run));let a=m.runs.detail(n.run.id);e.getQueryData(a)!==void 0&&e.setQueryData(a,e=>e===void 0?e:o(e,n.run));let c=m.runs.changes(n.run.id);e.getQueryData(c)!==void 0&&e.invalidateQueries({queryKey:c}),e.invalidateQueries({queryKey:m.worktrees});return}case`run-deleted`:r.deleted(n.id),e.setQueryData(m.runs.list(),e=>i(e,n.id)),e.removeQueries({queryKey:m.runs.detail(n.id)}),e.removeQueries({queryKey:m.runs.diff(n.id)}),e.invalidateQueries({queryKey:m.worktrees});return;case`todos`:e.setQueryData(m.todos,n.items);return;case`usage`:t.set(n.usage);return;case`ping`:return}}function qe(e,t=we){let n=_();(0,B.useEffect)(()=>{let i=globalThis.EventSource;if(typeof i!=`function`)return;let a=null,o,s,f=new Set,p=()=>{clearTimeout(o),clearTimeout(s),o=void 0,s=void 0;let e=$(n);for(let t of f){let r=t===e?E():t;n.invalidateQueries({queryKey:ae.all(r),refetchType:t===e?`active`:`none`}),t===e&&n.invalidateQueries({queryKey:m.worktrees})}f.clear()},h,g,_=()=>{clearTimeout(h),clearTimeout(g),h=void 0,g=void 0,n.invalidateQueries({queryKey:b.dashboard,refetchType:document.visibilityState===`hidden`?`none`:`active`,predicate:e=>e.queryKey[2]!==`telemetry`&&e.queryKey[2]!==`automations`&&!(e.queryKey[2]===`feed`&&e.queryKey[3]===`github`)})},y=()=>{clearTimeout(h),h=setTimeout(_,250),g??=setTimeout(_,1e3)},x=Fe(n),S=Le(n),C=Ue(n),w=We(n,e,C.onEvent,S),T,D=!1,O=!1,k,A=!1,j=Date.now(),M,N=!1,I=!1,L=0,R=new Set,z=[],B=()=>{N=!0,I=!1;let e=b.providerStatus;n.cancelQueries({queryKey:e,exact:!0}).then(()=>n.invalidateQueries({queryKey:e,exact:!0,refetchType:`active`})).finally(()=>{if(A||!I){N=!1;return}B()})},V=e=>{let t=b.providerStatus,r=c(n.getQueryData(t),e);if(r!==void 0){n.setQueryData(t,r);return}if(N){I=!0;return}B()},H=Date.now(),U=0,W,G=()=>{W!==void 0||Date.now()-U<1e4||(W=setTimeout(()=>{W=void 0,!(A||P.isConnected())&&(U=Date.now(),r().catch(()=>{}))},Oe))},K=()=>{H=Date.now(),L+=1,w.beginReconcile(),Ge(n).finally(()=>{--L,L===0&&(A?(R.clear(),z=[]):me()),w.endReconcile()})},me=()=>{let e=R,t=z;R=new Set,z=[];let r=$(n);for(let t of e)t===r?n.invalidateQueries({queryKey:m.todos}):C.onEvent(t);for(let e of t)V(e)},he=()=>{A||T!==void 0||(T=setTimeout(()=>{T=void 0,A||q()},De))},q=()=>{P.connected(!1),a?.close(),j=Date.now();let r=new i(t,{withCredentials:!0});a=r,r.addEventListener(`open`,()=>{A||a!==r||(j=Date.now(),clearTimeout(k),k=void 0,(D||O)&&K(),v.opened(),ee.clear(),P.connected(!0),D=!0,O=!1)});for(let t of ke)r.addEventListener(t,i=>{if(A||a!==r)return;j=Date.now();let o=l(t,i.data);if(o){if(x.onEvent(o.event),(o.event.type===`run`||o.event.type===`run-deleted`)&&(ue(n),F(n),y(),o.project&&pe(o.project,o.event.type===`run-deleted`?o.event.id:o.event.run),o.project&&(o.event.type===`run-deleted`||o.event.run.status!==`running`)&&P.remove(o.project,o.event.type===`run-deleted`?o.event.id:o.event.run.id)),t===`usage`)try{let e=te.safeParse(JSON.parse(i.data));e.success&&P.replace(e.data.project,e.data.samples??[],e.data.sentAt)}catch{}if(o.project!==null&&o.project!==$(n)){C.onEvent(o.project);return}o.event.type===`run`||o.event.type===`run-deleted`?o.project!==null&&w.onEvent(o.event,o.project):o.event.type===`todos`&&L>0?o.project!==null&&R.add(o.project):Ke(n,e,o.event,S)}});r.addEventListener(`worktree-lifecycle`,e=>{if(A||a!==r)return;j=Date.now();let t;try{t=JSON.parse(e.data)}catch{return}let n=re.safeParse(t);n.success&&(f.add(n.data.projectId),clearTimeout(o),o=setTimeout(p,100),s??=setTimeout(p,1e3))}),r.addEventListener(`artifacts`,e=>{if(A||a!==r)return;j=Date.now();let t;try{t=JSON.parse(e.data)}catch{return}let i=ne.safeParse(t);if(!i.success)return;let{project:o,runId:s,artifacts:c,truncated:l,versions:u}=i.data;if(o!==void 0&&o!==$(n)){C.onEvent(o);return}let d={artifacts:c,truncated:l,...u?{versions:u}:{}},f=m.runs.artifacts(s);n.getQueryData(f)!==void 0&&n.setQueryData(f,d),n.setQueriesData({queryKey:m.runs.impactSubjects},e=>e?.run?.id===s?$e(e,d):e),n.invalidateQueries({queryKey:m.runs.projectAssets})});for(let e of Ae)r.addEventListener(e,t=>{if(A||a!==r)return;j=Date.now();let i;try{i=JSON.parse(t.data)}catch{return}if(e===`tracker-changed`){if(!ie.safeParse(i).success)return;Promise.all([n.cancelQueries({queryKey:[`tracker`]}),n.cancelQueries({queryKey:b.projects})]).then(()=>Promise.all([n.invalidateQueries({queryKey:[`tracker`]}),n.invalidateQueries({queryKey:b.projects})]))}e!==`checkout-progress`&&e!==`automation-change`&&e!==`tracker-changed`&&(i&&typeof i==`object`&&(e===`project-removed`&&`id`in i&&typeof i.id==`string`?(fe(i.id,!0),P.remove(i.id)):e===`project-added`&&`project`in i&&i.project&&typeof i.project==`object`&&`id`in i.project&&typeof i.project.id==`string`&&fe(i.project.id,!1)),n.invalidateQueries({queryKey:b.projects}),n.invalidateQueries({queryKey:b.dashboard,refetchType:document.visibilityState===`hidden`?`none`:`active`}));for(let t of[...je])t(e,i)});for(let e of le)r.addEventListener(e,t=>{A||a!==r||(j=Date.now(),ce(n,e,t.data),e!==`manager-delta`&&(ue(n),F(n)))});r.addEventListener(`attention-change`,()=>{A||a!==r||(j=Date.now(),F(n))}),r.addEventListener(`provider-status`,e=>{if(A||a!==r)return;j=Date.now();let t;try{t=JSON.parse(e.data)}catch{return}let n=u(t);if(n){if(L>0){z.push(n);return}V(n)}}),r.addEventListener(`agent-login`,e=>{if(A||a!==r)return;j=Date.now();let t;try{t=JSON.parse(e.data)}catch{return}oe(n,t)}),r.addEventListener(`account-reconnected`,e=>{if(A||a!==r)return;j=Date.now();let t;try{t=JSON.parse(e.data)}catch{return}se(n,t)}),r.addEventListener(`error`,()=>{A||a!==r||(P.connected(!1),v.failedAttempt(),G(),r.readyState===Ee&&he())})},J=()=>{O=!0,clearTimeout(k),k=setTimeout(()=>{k=void 0,!(A||!O)&&(O=!1,K())},Pe)},Y,ge=()=>{if(Y=void 0,A||document.visibilityState!==`hidden`)return;if(xe(n)){Se(n)&&(Y=setTimeout(ge,de));return}clearTimeout(T),T=void 0;let e=a;a=null,P.connected(!1),e?.close()},X=()=>{document.visibilityState===`hidden`&&(Y??=setTimeout(ge,de))},Z=()=>{A||(clearTimeout(T),T=void 0,J(),q())},Q=()=>{if(document.visibilityState===`hidden`){X();return}if(clearTimeout(Y),Y=void 0,!a||a.readyState===Ee||Date.now()-j>2e4){Z();return}K()},_e=()=>{a?.readyState===Te&&P.isConnected()||Z()},ve=v.setReconnect(()=>{Z(),d(),n.invalidateQueries({queryKey:m.health})}),ye=()=>{clearTimeout(T),T=void 0;let e=a;a=null,P.connected(!1),e?.close()},be=e=>{e.persisted&&(J(),q(),X())};return M=setInterval(()=>{A||document.visibilityState!==`visible`||(!P.isConnected()&&L===0&&Date.now()-H>=3e4&&K(),!(Date.now()-j<=4e4)&&(v.failedAttempt(),clearTimeout(T),T=void 0,q()))},1e4),document.addEventListener(`visibilitychange`,Q),window.addEventListener(`online`,_e),window.addEventListener(`pagehide`,ye),window.addEventListener(`pageshow`,be),q(),X(),()=>{A=!0,clearTimeout(T),clearTimeout(k),clearInterval(M),clearTimeout(W),clearTimeout(Y),P.connected(!1),clearTimeout(h),clearTimeout(g),clearTimeout(o),clearTimeout(s),f.clear(),x.cancel(),S.cancel(),C.cancel(),w.cancel(),R.clear(),z=[],document.removeEventListener(`visibilitychange`,Q),window.removeEventListener(`online`,_e),ve(),window.removeEventListener(`pagehide`,ye),window.removeEventListener(`pageshow`,be);let e=a;a=null,P.connected(!1),e?.close()}},[n,e,t])}var Je=(0,B.createContext)(null);function Ye({children:e}){let[t]=(0,B.useState)(p);return qe(t),S(),I(),(0,Ce.jsx)(Je.Provider,{value:t,children:e})}function Xe(e){let t=(0,B.useContext)(Je),n=t?t.get:Qe;return(0,B.useSyncExternalStore)(t?t.subscribe:Ze,()=>e?n()[e]:void 0,()=>void 0)}var Ze=()=>()=>void 0,Qe=()=>f;function $e(e,t){if(e.run===null)return e;let{versions:n,...r}=e;return{...r,artifacts:t.artifacts,truncated:t.truncated,...t.versions?{versions:t.versions}:{}}}var et=z(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]);function tt(e){return C[((e-1)%7+7)%7]??``}function nt(e,t){let n=D(typeof e==`number`?e:Date.parse(e),t);return n?`${tt(n.weekday)} ${w(n.hour,n.minute)}`:``}function rt(e,t){let n=D(typeof e==`number`?e:Date.parse(e),t);return n?w(n.hour,n.minute):``}function it(e,t,n=Date.now()){let r=Date.parse(e),i=D(r,t);if(!i)return``;if(n-r<6*864e5)return`${tt(i.weekday)} ${w(i.hour,i.minute)}`;let a=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][i.month-1];return`${i.day} ${a} ${w(i.hour,i.minute)}`}function at(e,t=Date.now()){let n=Math.max(0,Math.round((e-t)/6e4));return n<60?`in ${n}m`:n<1440?`in ${Math.round(n/60)}h`:`in ${Math.round(n/1440)}d`}function ot(e){let t=Math.round(e/60),n=Math.floor(t/60);return n>0?`${n}h ${String(t%60).padStart(2,`0`)}m`:`${t}m`}function st(e){return e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function ct(e){switch(e){case`done`:return`success`;case`running`:case`queued`:case`waiting`:return`pending`;case`failed`:case`cancelled`:return`danger`;case`review`:return`info`}}function lt(e){if(e.kind===`schedule`)return O(e).map(A).join(`; `);if(e.kind===`tracker`){let t=e.trackerTrigger,n=t?.association.kind===`jira`?`Jira`:t?.association.kind===`linear`?`Linear`:`Tracker`;return t?`${n} · ${t.events.join(`, `)}${t.targetStatusIds?.length?` → ${t.targetStatusIds.join(`, `)}`:``}${t.changedLabelIds?.length?` · labels ${t.changedLabelIds.join(`, `)}`:``} · every ${Math.round((e.intervalSeconds??1800)/60)} min`:`${n} · select an event to complete setup`}let t=(e.events??[]).join(`, `),n=Math.round((e.intervalSeconds??300)/60);return`on ${t||`github`} · every ${n} min`}function ut(e){switch(e){case`launched`:case`manual`:case`catch-up`:return`success`;case`failed`:case`error`:case`rate-limited`:return`danger`;default:return`neutral`}}export{X as C,K as E,Y as S,q as T,Z as _,at as a,ye as b,rt as c,et as d,Ye as f,ve as g,be as h,it as i,lt as l,Xe as m,tt as n,ut as o,Me as p,nt as r,ct as s,ot as t,st as u,_e as v,me as w,J as x,ge as y};
|