@openagt/dashboard 0.55.0 → 0.56.0

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.
@@ -5,7 +5,7 @@ import{n as e,r as t,t as n}from"./rolldown-runtime-QTnfLwEv.js";import{t as r}f
5
5
  `).trim();t.push({headline:e||`error`,...i?{detail:i}:{}})}return t}function ta(e){let t=null;for(let n of e)n.kind===`session`?t={workspace:n.workspace,...n.sessionLink?{sessionLink:n.sessionLink}:{}}:n.kind===`session-update`&&(t={...t??{},sessionId:n.sessionId,...n.sessionLink?{sessionLink:n.sessionLink}:{}});return t}function na(e){let t=new Map;for(let n of e)if(n.kind===`choice-resolved`)t.delete(n.id);else if(n.kind===`driver`)t.clear();else if(n.kind===`end`)n.waiting!==!0&&t.clear();else if(n.kind===`choice`){let{kind:e,...r}=n;t.set(n.id,r)}return[...t.values()]}function ra(e){return e.kind===`awaiting`?`awaiting:${e.projectId}:${e.agentId??``}:${e.awaitId??``}`:e.kind===`uncommitted`||e.kind===`unpushed`?`${e.kind}:${e.projectId}:${e.agentId??``}`:e.url??``}function ia(e){return`${e.kind}:${e.projectId}:${e.agentId}`}var aa=class{keyOf;scopeOf;seen=new Set;warmedUp=new Set;constructor(e,t){this.keyOf=e,this.scopeOf=t}observe(e,t){let n=e.filter(e=>this.warmedUp.has(this.scopeOf(e))&&!this.seen.has(this.keyOf(e)));for(let t of e)this.seen.add(this.keyOf(t));for(let e of t)this.warmedUp.add(e);return n}};function oa(e){return{id:`bridge:${e.sessionId}`,title:e.title,options:e.options.map(e=>({id:e.label,label:e.label,...e.detail?{detail:e.detail}:{},...e.default?{default:!0}:{}})),...e.recommended?{recommended:e.recommended}:{},...e.multi?{multi:!0}:{}}}function sa(e,t){if(e.target!==`web`||e.status!==`done`)return;if(e.cloudWaiting)return`waiting`;if(e.mergeOutcome===`merged`)return`merged`;if(e.pr)return`done`;let n=Date.parse(e.startedAt);return Number.isFinite(n)&&t-n<=432e5?`in-cloud`:`done`}var ca=[`1/4`,`1/3`,`1/2`,`2/3`,`3/4`,`1`],la=e=>ca.indexOf(e);function ua(e){return ca.filter(t=>la(t)>=la(e.minWidth))}function da(e,t,n){let r=t?.[n]??t?.[`*`]??[],i=new Map(e.map(e=>[e.id,e]));return[...r.flatMap(e=>{let t=i.get(e.id);return t?(i.delete(e.id),[{card:t,width:e.width!==void 0&&la(e.width)>=la(t.minWidth)?e.width:t.width,hidden:e.hidden===!0}]):[]}),...[...i.values()].map(e=>({card:e,width:e.width,hidden:!1}))]}var J=t(r(),1),fa=U(`onPreferences`);U(`savePreferences`);var pa=U(`patchPreferences`),ma=U(`onProjectPresets`),ha=U(`saveProjectPresets`),ga=U(`onEditors`),_a={},va=null,ya=null,ba=new Map,xa=new Set,Sa=[],Ca=0,wa=0,Ta=new Set;function Ea(){for(let e of Ta)e()}function Da(e){return Ta.add(e),()=>Ta.delete(e)}var Oa=(0,J.createContext)(null);function ka(){!va&&!ya&&(ya=fa().then(e=>{va??=e}).catch(()=>{va??={}}).finally(()=>{ya=null,Ea()}))}typeof window<`u`&&(window.addEventListener(`focus`,Pa),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Pa()}));function Aa(e){!e||ba.has(e)||xa.has(e)||(xa.add(e),ma(e).then(t=>{ba.has(e)||ba.set(e,t)}).catch(()=>{ba.has(e)||ba.set(e,[])}).finally(()=>{xa.delete(e),Ea()}))}function ja(){let e=(0,J.useContext)(Oa),t=(0,J.useSyncExternalStore)(Da,()=>e?ba.get(e)??Sa:Sa,()=>Sa);return(0,J.useEffect)(()=>Aa(e),[e]),t}function Ma(e,t){e&&(ba.set(e,t),ha(e,t).catch(()=>{}),Ea())}function Na(e){va={...va??{},...e};let t=++Ca;wa++,pa(e).then(e=>{e.ok&&t===Ca&&(va=e.preferences,Ea())}).catch(()=>{}).finally(()=>wa--),Ea()}function Pa(){let e=Ca;fa().then(t=>{e!==Ca||wa>0||(va=t,Ea())}).catch(()=>{})}function Fa(){return(0,J.useContext)(Oa)}function Ia(){let e=(0,J.useSyncExternalStore)(Da,()=>va??_a,()=>_a);return(0,J.useEffect)(()=>ka(),[]),e}function La(){return(0,J.useSyncExternalStore)(Da,()=>va!==null,()=>!1)}function Ra(e){return e.theme??`system`}function za(e,t){return e===`dark`||e===`system`&&t}function Ba(e){return be(e)}function Va(e){return Ut(e,`newActivity`)}function Ha(e){return Ut(e,`humanIntervention`)}var Ua={app:`ui-sans-serif, system-ui, sans-serif`,code:`ui-monospace, SFMono-Regular, Menlo, monospace`,document:`ui-serif, Georgia, serif`},Wa=new Set([`IBM Plex Sans`,`JetBrains Mono`,`Source Serif 4`]),Ga=`picked-fonts`;function Ka(e){return`https://fonts.googleapis.com/css2?${e.map(e=>`family=${e.replace(/ /g,`+`)}:wght@400;500;600;700`).join(`&`)}&display=swap`}function qa(e,t){t.palette&&t.palette!==`openagent`?e.dataset.palette=t.palette:delete e.dataset.palette;let n=Wi(t.palette,t.accent);n?e.dataset.accent=n:delete e.dataset.accent;let r=t.font?Gi[t.font]:void 0,i=t.codeFont?Ki[t.codeFont]:void 0,a=t.documentFont&&t.documentFont!==`app`?qi[t.documentFont]:void 0;Ja(e,`--font-app`,r,Ua.app),Ja(e,`--font-code`,i,Ua.code),t.documentFont===`app`?e.style.setProperty(`--font-document`,`var(--font-app)`):Ja(e,`--font-document`,a,Ua.document);let o=[r,i,a].filter(e=>e!==void 0&&!Wa.has(e)),s=e.ownerDocument,c=s.getElementById(Ga);if(o.length===0){c?.remove();return}c||(c=s.createElement(`link`),c.id=Ga,c.rel=`stylesheet`,s.head.appendChild(c));let l=Ka(o);c.href!==l&&(c.href=l)}function Ja(e,t,n,r){n?e.style.setProperty(t,`'${n}', ${r}`):e.style.removeProperty(t)}var Y=t(Mi(),1),Ya=class extends J.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`Dashboard render error:`,e,t.componentStack)}reset=()=>this.setState({error:null});render(){let{error:e}=this.state;return e?(0,Y.jsxs)(`div`,{role:`alert`,className:`flex min-h-screen flex-col items-center justify-center gap-3 bg-background p-8 text-center text-foreground`,children:[(0,Y.jsx)(`p`,{className:`text-base font-medium`,children:`Something went wrong`}),(0,Y.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:`The dashboard hit an error and could not finish drawing this view. Your session is safe — the daemon keeps running. Try again, or reload the page.`}),e.message&&(0,Y.jsx)(`pre`,{className:`max-w-md overflow-x-auto rounded-md bg-muted px-3 py-2 text-left text-xs text-muted-foreground`,children:e.message}),(0,Y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Y.jsx)(V,{variant:`outline`,onClick:this.reset,children:`Try again`}),(0,Y.jsx)(V,{onClick:()=>window.location.reload(),children:`Reload`})]})]}):this.props.children}};function Xa({children:e}){let t=Ia(),n=Ra(t),{palette:r,accent:i,font:a,codeFont:o,documentFont:s}=t;return(0,J.useEffect)(()=>{qa(document.documentElement,{palette:r,accent:i,font:a,codeFont:o,documentFont:s})},[r,i,a,o,s]),(0,J.useEffect)(()=>{let e=document.documentElement,t=window.matchMedia(`(prefers-color-scheme: dark)`),r=()=>e.classList.toggle(`dark`,za(n,t.matches));if(r(),n===`system`)return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[n]),(0,Y.jsx)(`div`,{className:`min-h-screen bg-background text-foreground`,children:(0,Y.jsx)(T,{children:(0,Y.jsx)(Ya,{children:e})})})}var Za=U(`onAgents`),Qa=U(`onModuleAgents`),$a=U(`onRetainedWorktrees`),eo=U(`onAgentWorktree`),to=U(`onAgentMainBranch`),no=U(`onAgent`),ro=U(`onAgentsDoing`),io=U(`onDocs`);U(`onQueue`);var ao=U(`onOverview`),oo=U(`onRecentAgents`),so=U(`onInterventions`),co=U(`onActivity`),lo=U(`onDashboard`),uo=U(`onProjectFiles`),fo=U(`onGitHostHome`),po=U(`onRepositoryOffer`),mo=U(`onAgentHandoff`),ho=U(`onBridgeQuestion`),go=U(`onBridgeStatus`),_o=U(`onBridgeToken`),vo=U(`onBridgeAnswer`),yo=U(`onBridgeEvents`),bo=U(`onBridgeBrowser`),xo=U(`onStartedName`),So=U(`sendStop`),Co=U(`sendChoice`),wo=U(`sendBridgeAnswer`),To=U(`sendBridgeAnswerCancel`),Eo=U(`sendBridgeBrowser`),Do=U(`sendMessage`),Oo=U(`withdrawMessage`),ko=U(`sendNow`),Ao=U(`sendRemoveWorktree`),jo=U(`sendDeleteAgent`),Mo=U(`sendStart`),No=U(`sendOpenInApp`),Po=U(`sendOpenPullRequest`),Fo=U(`sendMerge`),Io=U(`sendPush`),Lo=U(`sendMergeBranch`),Ro=U(`sendCreateRepository`),zo=U(`onProjects`),Bo=U(`sendAddProject`),Vo=U(`onCloneTarget`),Ho=U(`sendAddProjectFromAddress`),Uo=U(`sendRemoveProject`),Wo=U(`sendShareRecords`),Go=U(`sendPickProjectDirectory`),Ko=U(`onOnboarding`),qo=U(`onCommands`),Jo=U(`onStartBranches`),Yo=U(`onStartCheck`),Xo=U(`onCloneCheck`),Zo=U(`onGitHostPeople`),Qo=U(`onServerLogins`),$o=U(`sendUseLoginsOn`),es=U(`sendAllowLogins`),ts=U(`sendSettleLogin`),ns=null,rs=new Set,is=!1,as=null,ss=`unread`,cs=null;function ls(){for(let e of rs)e()}function us(e){ns!==e&&(ns=e,ls())}function ds(e){is=!1,as=e,ss=`settled`,cs!==null&&(cs=null,ls()),us(e),Na({runOn:e??``})}function fs(){return ns}function ps(e){return rs.add(e),()=>rs.delete(e)}function ms(){return(0,J.useSyncExternalStore)(ps,fs,()=>null)}function hs(){return(0,J.useSyncExternalStore)(ps,()=>cs,()=>null)}function gs(e,t,n){if(ss===`unread`){if(t===null)return;if(e===void 0){ss=`settled`;return}if(!t.some(t=>t.id===e)){ss=`settled`,cs={why:`gone`},Na({runOn:``}),ls();return}ss=`checking`,as=e,is||us(e)}ss!==`checking`||e===void 0||n[e]===void 0||(ss=`settled`,n[e]!==`online`&&(as=null,cs={why:`offline`,id:e},is||us(null),ls()))}function _s(e){e===void 0?is&&(is=!1,us(as)):(us(e),is=!0)}function vs(e,t,n,r){if(t!==null&&!(n!==null&&n.address===void 0&&t!==r))return e.find(e=>e.id===t)}var ys=[],bs=null,xs=0,Ss=0,Cs=!1,ws=new Set;function Ts(e){return ws.add(e),()=>ws.delete(e)}function Es(){let e=++xs;return Ss++,zr().then(t=>{if(e===xs){bs=t;for(let e of ws)e()}},()=>{}).finally(()=>Ss--)}function Ds(){bs===null&&Ss===0&&Es(),!(Cs||typeof window>`u`)&&(Cs=!0,window.addEventListener(`focus`,()=>void Es()))}async function Os(e,t){let n=await _n(e,t);return n.ok&&await Es(),n}async function ks(e,t){let n=await fn(e,t);return n.ok&&await Es(),n}async function As(e){let t=await wi(e);return t.ok&&await Es(),t.ok?{ok:!0}:t}async function js(e,t){let n=await Gr(e,t);return n.ok&&await Es(),n}async function Ms(e){await mr(e).catch(()=>{}),await Es()}async function Ns(e){let t=await en(e).catch(()=>({ok:!1,error:`The machine could not be removed.`}));await Es();let n=fs();return t.ok&&n!==null&&!(bs??[]).some(e=>e.id===n)&&ds(null),t}function Ps(){let e=(0,J.useSyncExternalStore)(Ts,()=>bs!==null,()=>!1);return(0,J.useEffect)(Ds,[]),e}function Fs(){let e=(0,J.useSyncExternalStore)(Ts,()=>bs??ys,()=>ys);return(0,J.useEffect)(Ds,[]),e}var Is=30,Ls=24,Rs=810,zs=new Map;function Bs({text:e,start:t}){let[n]=(0,J.useState)(()=>{let n=Date.now();for(let[e,t]of zs)n-t>Rs&&zs.delete(e);let r=zs.get(e);return r===void 0?t?(zs.set(e,n),0):Rs:n-r});if(n>=Rs)return e;let r=[...e],i=e=>({animationDelay:`${Math.min(e,Ls)*Is-n}ms`});return(0,Y.jsxs)(Y.Fragment,{children:[r.slice(0,Ls).map((e,t)=>(0,Y.jsx)(`span`,{className:`letter-in`,style:i(t),children:e},t)),r.length>Ls&&(0,Y.jsx)(`span`,{className:`letter-in`,style:i(Ls),children:r.slice(Ls).join(``)})]})}var Vs=G(`ArrowDownUp`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`m21 8-4-4-4 4`,key:`1c9v7m`}],[`path`,{d:`M17 4v16`,key:`7dpous`}]]),Hs=G(`ArrowDown`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),Us=G(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),Ws=G(`ArrowUp`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),Gs=G(`BellOff`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),Ks=G(`Bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),qs=G(`Blocks`,[[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`path`,{d:`M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3`,key:`1fpvtg`}]]),Js=G(`Bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),Ys=G(`ChevronLeft`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Xs=G(`ChevronsUpDown`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Zs=G(`CircleAlert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Qs=G(`CircleArrowUp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16 12-4-4-4 4`,key:`177agl`}],[`path`,{d:`M12 16V8`,key:`1sbj14`}]]),$s=G(`CircleCheck`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),ec=G(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),tc=G(`CloudUpload`,[[`path`,{d:`M12 13v8`,key:`1l5pq0`}],[`path`,{d:`M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242`,key:`1pljnt`}],[`path`,{d:`m8 17 4-4 4 4`,key:`1quai1`}]]),nc=G(`Cloud`,[[`path`,{d:`M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z`,key:`p7xjir`}]]),rc=G(`Code`,[[`polyline`,{points:`16 18 22 12 16 6`,key:`z7tu5w`}],[`polyline`,{points:`8 6 2 12 8 18`,key:`1eg1df`}]]),ic=G(`Database`,[[`ellipse`,{cx:`12`,cy:`5`,rx:`9`,ry:`3`,key:`msslwz`}],[`path`,{d:`M3 5V19A9 3 0 0 0 21 19V5`,key:`1wlel7`}],[`path`,{d:`M3 12A9 3 0 0 0 21 12`,key:`mv7ke4`}]]),ac=G(`EllipsisVertical`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`12`,cy:`5`,r:`1`,key:`gxeob9`}],[`circle`,{cx:`12`,cy:`19`,r:`1`,key:`lyex9k`}]]),oc=G(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),sc=G(`ExternalLink`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),cc=G(`FilePen`,[[`path`,{d:`M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5`,key:`1couwa`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`1y4qbx`}]]),lc=G(`FileText`,[[`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`,key:`1rqfz7`}],[`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`,key:`tnqrlb`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),uc=G(`FolderGit2`,[[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`path`,{d:`M18 19c-2.8 0-5-2.2-5-5v8`,key:`pkpw2h`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),dc=G(`FolderOpen`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]),fc=G(`FolderPlus`,[[`path`,{d:`M12 10v6`,key:`1bos4e`}],[`path`,{d:`M9 13h6`,key:`1uhe8q`}],[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),pc=G(`FolderX`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}],[`path`,{d:`m9.5 10.5 5 5`,key:`ra9qjz`}],[`path`,{d:`m14.5 10.5-5 5`,key:`l2rkpq`}]]),mc=G(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),hc=G(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),gc=G(`GitMerge`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 21V9a9 9 0 0 0 9 9`,key:`7kw0sc`}]]),_c=G(`GitPullRequestClosed`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`m21 3-6 6`,key:`16nqsk`}],[`path`,{d:`m21 9-6-6`,key:`9j17rh`}],[`path`,{d:`M18 11.5V15`,key:`65xf6f`}],[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}]]),vc=G(`GitPullRequestDraft`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M18 6V5`,key:`1oao2s`}],[`path`,{d:`M18 11v-1`,key:`11c8tz`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),yc=G(`GitPullRequest`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),bc=G(`Github`,[[`path`,{d:`M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4`,key:`tonef`}],[`path`,{d:`M9 18c-4.51 2-5-2-7-2`,key:`9comsn`}]]),xc=G(`Globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),Sc=G(`GripVertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),Cc=G(`Inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),wc=G(`Info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),Tc=G(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Ec=G(`Layers`,[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]]),Dc=G(`LayoutDashboard`,[[`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`}]]),Oc=G(`Maximize2`,[[`polyline`,{points:`15 3 21 3 21 9`,key:`mznyad`}],[`polyline`,{points:`9 21 3 21 3 15`,key:`1avn1i`}],[`line`,{x1:`21`,x2:`14`,y1:`3`,y2:`10`,key:`ota7mn`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),kc=G(`Menu`,[[`line`,{x1:`4`,x2:`20`,y1:`12`,y2:`12`,key:`1e0a9i`}],[`line`,{x1:`4`,x2:`20`,y1:`6`,y2:`6`,key:`1owob3`}],[`line`,{x1:`4`,x2:`20`,y1:`18`,y2:`18`,key:`yk5zj1`}]]),Ac=G(`Minimize2`,[[`polyline`,{points:`4 14 10 14 10 20`,key:`11kfnr`}],[`polyline`,{points:`20 10 14 10 14 4`,key:`rlmsce`}],[`line`,{x1:`14`,x2:`21`,y1:`10`,y2:`3`,key:`o5lafz`}],[`line`,{x1:`3`,x2:`10`,y1:`21`,y2:`14`,key:`1atl0r`}]]),jc=G(`Monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),Mc=G(`Moon`,[[`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`,key:`a7tn18`}]]),Nc=G(`Palette`,[[`circle`,{cx:`13.5`,cy:`6.5`,r:`.5`,fill:`currentColor`,key:`1okk4w`}],[`circle`,{cx:`17.5`,cy:`10.5`,r:`.5`,fill:`currentColor`,key:`f64h9f`}],[`circle`,{cx:`8.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`fotxhn`}],[`circle`,{cx:`6.5`,cy:`12.5`,r:`.5`,fill:`currentColor`,key:`qy21gx`}],[`path`,{d:`M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z`,key:`12rzf8`}]]),Pc=G(`PencilLine`,[[`path`,{d:`M12 20h9`,key:`t2du7b`}],[`path`,{d:`M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z`,key:`1ykcvy`}],[`path`,{d:`m15 5 3 3`,key:`1w25hb`}]]),Fc=G(`Plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),Ic=G(`Puzzle`,[[`path`,{d:`M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z`,key:`w46dr5`}]]),Lc=G(`RefreshCw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Rc=G(`Search`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),zc=G(`Settings`,[[`path`,{d:`M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z`,key:`1qme2f`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),Bc=G(`SlidersHorizontal`,[[`line`,{x1:`21`,x2:`14`,y1:`4`,y2:`4`,key:`obuewd`}],[`line`,{x1:`10`,x2:`3`,y1:`4`,y2:`4`,key:`1q6298`}],[`line`,{x1:`21`,x2:`12`,y1:`12`,y2:`12`,key:`1iu8h1`}],[`line`,{x1:`8`,x2:`3`,y1:`12`,y2:`12`,key:`ntss68`}],[`line`,{x1:`21`,x2:`16`,y1:`20`,y2:`20`,key:`14d8ph`}],[`line`,{x1:`12`,x2:`3`,y1:`20`,y2:`20`,key:`m0wm8r`}],[`line`,{x1:`14`,x2:`14`,y1:`2`,y2:`6`,key:`14e1ph`}],[`line`,{x1:`8`,x2:`8`,y1:`10`,y2:`14`,key:`1i6ji0`}],[`line`,{x1:`16`,x2:`16`,y1:`18`,y2:`22`,key:`1lctlv`}]]),Vc=G(`SquareCheckBig`,[[`path`,{d:`M21 10.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.5`,key:`1uzm8b`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),Hc=G(`Square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),Uc=G(`Sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),Wc=G(`Trash2`,[[`path`,{d:`M3 6h18`,key:`d0wm0j`}],[`path`,{d:`M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6`,key:`4alrt4`}],[`path`,{d:`M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2`,key:`v07s0e`}],[`line`,{x1:`10`,x2:`10`,y1:`11`,y2:`17`,key:`1uufr5`}],[`line`,{x1:`14`,x2:`14`,y1:`11`,y2:`17`,key:`xtxkd`}]]),Gc=G(`TriangleAlert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Kc=G(`Upload`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`17 8 12 3 7 8`,key:`t8dd8p`}],[`line`,{x1:`12`,x2:`12`,y1:`3`,y2:`15`,key:`widbto`}]]),qc=G(`Workflow`,[[`rect`,{width:`8`,height:`8`,x:`3`,y:`3`,rx:`2`,key:`by2w9f`}],[`path`,{d:`M7 11v4a2 2 0 0 0 2 2h4`,key:`xkn7yn`}],[`rect`,{width:`8`,height:`8`,x:`13`,y:`13`,rx:`2`,key:`1cgmvn`}]]);function Jc(e){return Ji(e)??N(e.startedAt)}function Yc(e,t,n=Date.now()){if(!t||e.title!==void 0||e.parent!==void 0)return!1;let r=Date.parse(e.startedAt);return Number.isFinite(r)&&n-r<6e4}var Xc={created:`Date created`,updated:`Last updated`,name:`Name`};function Zc(e,t){let n=(e,t)=>e<t?1:e>t?-1:0,r=(e,t)=>n(e.agent.startedAt,t.agent.startedAt)||n(e.agent.id,t.agent.id);return t===`updated`?[...e].sort((e,t)=>n(e.agent.updatedAt,t.agent.updatedAt)||r(e,t)):t===`name`?[...e].sort((e,t)=>Jc(e.agent).localeCompare(Jc(t.agent),void 0,{sensitivity:`base`,numeric:!0})||r(e,t)):[...e].sort(r)}function Qc(e){let t=new Map;for(let n of e)t.set(n.name,[...t.get(n.name)??[],n]);let n=new Map;for(let r of e){let e=t.get(r.name).filter(e=>e!==r);n.set(r.id,e.length===0?r.name:$c(r,e))}return n}function $c(e,t){let n=el(e.path),r=t.map(e=>el(e.path));for(let e=2;e<=n.length;e++){let t=n.slice(-e).join(`/`);if(r.every(n=>n.slice(-e).join(`/`)!==t))return t}return e.path}function el(e){return e.split(/[\\/]/).filter(Boolean)}var tl=(0,J.createContext)(new Map);function nl(){let e=(0,J.useContext)(tl);return(t,n)=>e.get(t)??n}var rl={running:`text-primary`,done:`text-success`,stopped:`text-warning`,failed:`text-danger`},il={running:`bg-primary`,waiting:`bg-warning`,saving:`bg-success`,failed:`bg-danger`},al={stopped:`border-warning/70`,merged:`border-success/70`,done:`border-muted-foreground/60`,unknown:`border-dashed border-muted-foreground/60`},ol={open:{Icon:yc,tone:`text-success`,word:`open`},draft:{Icon:vc,tone:`text-muted-foreground`,word:`draft`},merged:{Icon:gc,tone:`text-merged`,word:`merged`},closed:{Icon:_c,tone:`text-danger`,word:`closed`}};function sl(e){let t=e.toLowerCase();return t===`open`||t===`draft`||t===`merged`||t===`closed`?t:void 0}function cl(e){let t=/^(\d{4}-\d{2}-\d{2}T\d{2})-(\d{2})-(\d{2})-(\d{3})Z$/.exec(e);return t?`${t[1]}:${t[2]}:${t[3]}.${t[4]}Z`:void 0}function ll(e,t){return e.filter(e=>e.parent===t).sort((e,t)=>e.id<t.id?-1:+(e.id>t.id))}function ul(e){return Jc(e).split(`
6
6
  `)[0].trim()}function dl(e){return e.status===`running`||e.status===`waiting`}var fl=1e4;function pl(e,t){return e.status===`running`||e.saving===!0||e.endedAt!==void 0&&t-Date.parse(e.endedAt)<fl}function ml(e){let t=new Map(e.map(e=>[e.key,e])),n=e=>e.agent.parent===void 0?void 0:t.get(e.key.slice(0,e.key.length-e.agent.id.length)+e.agent.parent),r=e=>{let t=n(e);return t&&!n(t)?t:void 0};return e.filter(e=>!r(e)).map(t=>({row:t,subagents:e.filter(e=>r(e)===t).sort((e,t)=>e.agent.id<t.agent.id?-1:+(e.agent.id>t.agent.id))}))}var hl=/^The run (\S+), started for this run, ended (\w+)(?:: (.*?))?\.?$/;function gl(e,t){let[n=``,...r]=e.split(`
7
7
  `),i=hl.exec(n.trim()),a=i&&t.find(e=>e.id===i[1]);if(!(!i||!a))return{agent:a,status:i[2],...i[3]?{detail:i[3]}:{},rest:r.join(`
8
- `).trim()}}function _l(e){return cl(e.id)??e.startedAt}function vl(e){let t=new Map;for(let n of e){if(n.kind!==`driver`)continue;let e=n.event;if(e.type===`subagent`){let r=t.get(e.id),{type:i,...a}=e;t.set(e.id,{...a,calls:r?.calls??0,...r?.tool===void 0?{}:{tool:r.tool},...(r?.startedAt??n.at)===void 0?{}:{startedAt:r?.startedAt??n.at},...e.status!==`working`&&n.at!==void 0?{endedAt:n.at}:{}})}else if(e.type===`action`&&e.subagent!==void 0){let n=t.get(e.subagent);n&&t.set(e.subagent,{...n,calls:n.calls+1,tool:e.label})}}return[...t.values()]}function yl(e){let t=new Set,n=new Set(e.flatMap(e=>e.kind===`driver`&&e.event.type===`output`&&e.event.failed===!0&&e.event.id!==void 0?[e.event.id]:[])),r=new Set(e.flatMap(e=>e.kind===`driver`&&e.event.type===`action`&&e.event.subagent===void 0&&e.event.id!==void 0&&!n.has(e.event.id)&&Tl(e.event.whole??e.event.detail)?[e.event.id]:[]));for(let n of e)n.kind===`driver`&&n.event.type===`subagent`&&t.add(n.event.id);let i=new Set([...t].flatMap(e=>[e,e.split(`:`)[0]])),a=new Set;for(let t of e){if(t.kind!==`driver`)continue;let e=t.event;(e.type===`subagent`||(e.type===`action`||e.type===`output`||e.type===`text`||e.type===`thought`)&&e.subagent!==void 0||(e.type===`action`||e.type===`output`)&&e.id!==void 0&&(i.has(e.id)||r.has(e.id)))&&a.add(t)}return a}function bl(e,t){return e.filter(e=>e.kind===`driver`&&(e.event.type===`action`||e.event.type===`output`||e.event.type===`text`||e.event.type===`thought`)&&e.event.subagent===t)}function xl(e,t){let n=e.status===`running`;return{key:`run:${e.id}`,name:ul(e),...e.model===void 0?{}:{model:e.model},status:e.status,working:n,startedAt:_l(e),...e.endedAt===void 0?{}:{endedAt:e.endedAt},...n&&t?.tool!==void 0?{tool:t.tool}:{},...n&&t!==void 0?{calls:t.calls}:{},...n&&t?.doing!==void 0?{doing:t.doing}:{},...e.cost===void 0?{}:{cost:e.cost},...e.intent===void 0?{}:{prompt:e.intent},agent:e}}function Sl(e,t,n){let r=e.status===`working`&&t,i=e.status===`failed`?`failed`:e.status===`ended`?`done`:r?`running`:`stopped`;return{key:`call:${e.id}`,name:e.name??e.role??`Subagent`,...e.model===void 0?{}:{model:e.model},status:i,working:r,startedAt:e.startedAt??n,...e.endedAt===void 0?{}:{endedAt:e.endedAt},...r&&e.tool!==void 0?{tool:e.tool}:{},...r?{calls:e.calls}:{},...e.prompt===void 0?{}:{prompt:e.prompt},...e.tokens===void 0?{}:{tokens:e.tokens},...e.toolUses===void 0?{}:{toolUses:e.toolUses},call:e}}function Cl(e,t,n,r){let i=[];for(let t of e)i.push((i.at(-1)??0)+ +!!r(t));let a=(t,n)=>{let r=Date.parse(n),a=e.findIndex(e=>e.at!==void 0&&Date.parse(e.at)>r),o=a===-1?e.length:a;return{step:t,time:n,index:o,stretch:o>0?i[o-1]:0}},o=t.flatMap(e=>{let t=n.get(e.key);return[a({kind:`agent`,row:e},e.startedAt),...t!==void 0&&e.endedAt!==void 0?[a({kind:`message`,row:e,text:t},e.endedAt)]:[]]}).sort((e,t)=>e.index-t.index||(e.time<t.time?-1:1)),s=new Map,c=new Map;for(let{step:e,index:t,stretch:n}of o){let r=c.get(n)??t;c.set(n,r),s.set(r,[...s.get(r)??[],e])}return s}function wl(e){let t=e.filter(e=>e.kind===`agent`),n=e.length-t.length,r=t.filter(e=>e.row.status===`failed`).length,i=t.length===1?`ran an agent`:`ran ${t.length} agents`,a=n===1?`received a message`:`received ${n} messages`,o=[...t.length>0?[i]:[],...n>0?[a]:[]];e[0]?.kind===`message`&&o.reverse();let s=[...o,...r>0?[`${r} failed`]:[]].join(`, `);return s.charAt(0).toUpperCase()+s.slice(1)}function Tl(e){if(e===void 0)return!1;let t=e.split(/;|&&|\n/).map(e=>e.trim()).filter(Boolean),n=/^npx (?:-y )?@openagt\/skill-orchestration(?:@\S+)? (?:start|land|next|list|read)\b/;return t.some(e=>n.test(e))&&t.every(e=>n.test(e)||/^git (?:status|log|diff)\b/.test(e))}function El(e,t){return bl(e,t).flatMap(e=>e.kind===`driver`&&e.event.type===`text`?[e.event.text]:[]).at(-1)}function Dl(e){return e.replace(/^Its last words:\n/m,``).trim()}function Ol(e){let t=new Set,n=new Set(e.flatMap(e=>e.kind===`driver`&&e.event.type===`subagent`?[e.event.id,e.event.id.split(`:`)[0]]:[])),r=!1,i=!1,a;for(let o of e){if(o.kind!==`driver`)continue;let e=o.event;if(e.type===`start`){t.clear(),r=!1,i=!1,a=void 0;continue}if(e.type===`subagent`&&e.id!==void 0){e.status===`working`?t.has(e.id)||(t.size===0&&(i=!1),t.add(e.id),r=!0):(t.delete(e.id),r&&t.size===0?(a=o.at,r=!1,i=!1):r&&(i=!0));continue}e.subagent===void 0&&((e.type===`action`||e.type===`output`)&&e.id!==void 0&&n.has(e.id)||[`action`,`output`,`text`,`thought`,`thinking`,`partial`].includes(e.type)&&(r&&i&&(a=o.at),r=!1,i=!1,e.type===`text`&&t.size>0&&(r=!0)))}return{waiting:r&&t.size>0,...a===void 0?{}:{wokeAt:a}}}function kl(){let e=`rounded bg-muted px-1`;return(0,Y.jsxs)(`div`,{className:`space-y-1 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`p`,{children:`Adding a project lets agents work in its folder. Adding it:`}),(0,Y.jsxs)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:[(0,Y.jsx)(`li`,{children:`makes no commit on your branch and pushes nothing`}),(0,Y.jsxs)(`li`,{children:[`lets OpenAgent keep its own files there, in hidden folders (`,(0,Y.jsx)(`code`,{className:e,children:`.openagent`}),`,`,` `,(0,Y.jsx)(`code`,{className:e,children:`.branches`}),`, `,(0,Y.jsx)(`code`,{className:e,children:`.agent-runner`}),`)`]}),(0,Y.jsxs)(`li`,{children:[`keeps the agents’ records in your own folder `,(0,Y.jsx)(`code`,{className:e,children:`~/.openagent`}),`, outside the project, unless you choose to share them`]}),(0,Y.jsxs)(`li`,{children:[`gives each agent four basic skills in its own copy, hidden from git: `,(0,Y.jsx)(`code`,{className:e,children:`branches`}),`,`,` `,(0,Y.jsx)(`code`,{className:e,children:`logs`}),`, `,(0,Y.jsx)(`code`,{className:e,children:`question`}),`, and `,(0,Y.jsx)(`code`,{className:e,children:`github`}),` when the project is on GitHub`]})]}),(0,Y.jsx)(`p`,{children:`Agents work in their own copies, on their own branches. Your files and your branch stay as they are.`}),(0,Y.jsx)(`p`,{className:`italic`,children:`A folder with no git, or a repository with no commit yet, gets one empty first commit.`})]})}function Al({folder:e,fromAddress:t=!1,onAdded:n,onClose:r}){let[i,a]=(0,J.useState)(e??null),[o,s]=(0,J.useState)(t),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(!1),m=(0,J.useId)(),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null),{busy:y,error:b,reset:x,run:S}=Yn(),C=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=document.activeElement instanceof HTMLElement?document.activeElement:null;return()=>e?.focus()},[]);let w=async()=>{v(null);let e=await Go().catch(()=>({ok:!1,error:`Could not reach the daemon.`}));if(!e.ok){v(e.error);return}if(!e.path){r();return}x(),a(e.path)};(0,J.useEffect)(()=>{!e&&!t&&w()},[]),(0,J.useEffect)(()=>{if(!h)return;let e=setTimeout(r,h.noRemote||h.path?6e3:2500);return()=>clearTimeout(e)},[h]);let T=async e=>{e.preventDefault();let t=c.trim();if(y||!t)return;let n=await S(()=>Vo(t),`Could not reach the daemon.`);n.ok&&d({typed:t,address:n.value.address,path:n.value.path})},E=async()=>{if(y||!i&&!u)return;let e=await S(()=>u?Ho(u.typed,f):Bo(i,f),`Failed to add the project.`);e.ok&&(g({alreadyActivated:e.value.alreadyActivated,noRemote:e.value.noRemote===!0,...e.value.path?{path:e.value.path}:{}}),n())};return(0,Y.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-black/40 pt-24`,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),r();return}if(e.key!==`Tab`||!C.current)return;let t=[...C.current.querySelectorAll(`button, input, [tabindex]:not([tabindex="-1"])`)].filter(e=>!e.hasAttribute(`disabled`)),n=t[0],i=t[t.length-1];!n||!i||(e.shiftKey&&document.activeElement===n?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),n.focus()))},children:[(0,Y.jsx)(`div`,{className:`absolute inset-0`,onClick:r}),(0,Y.jsx)(`div`,{ref:C,role:`dialog`,"aria-modal":`true`,"aria-label":`Add project`,className:`relative w-96 max-w-[90vw] rounded-lg border border-border bg-background p-4 shadow-lg`,children:h?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{role:`status`,className:`mb-3 text-sm font-medium`,children:h.alreadyActivated?`Already added`:`Project added`}),h.noRemote&&(0,Y.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:`This repository has no remote, so the agents’ records stay on this machine.`}),h.path&&(0,Y.jsxs)(`p`,{className:`mb-3 break-all text-xs text-muted-foreground`,children:[`It is in `,(0,Y.jsx)(`code`,{className:`rounded bg-muted px-1`,children:h.path}),`.`]}),(0,Y.jsx)(`div`,{className:`flex justify-end`,children:(0,Y.jsx)(V,{type:`button`,size:`sm`,autoFocus:!0,onClick:r,children:`Done`})})]}):o&&!u?(0,Y.jsxs)(`form`,{onSubmit:e=>void T(e),children:[(0,Y.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:`Add project from a GitHub address`}),_&&(0,Y.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:_}),(0,Y.jsx)(`label`,{className:`mb-1 block text-xs text-muted-foreground`,htmlFor:`add-project-address`,children:`The repository’s address. Any git host works.`}),(0,Y.jsx)(Hr,{id:`add-project-address`,autoFocus:!0,value:c,disabled:y,onChange:e=>l(e.target.value),placeholder:`github.com/you/project`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,className:`mb-2 h-8 bg-background px-2 font-mono text-xs`}),(0,Y.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:`It is cloned into the projects folder of this computer, with the logins this computer has.`}),b&&(0,Y.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:b}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:`Cancel`}),(0,Y.jsx)(V,{type:`submit`,size:`sm`,disabled:y||!c.trim(),children:`Next`})]})]}):_?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:`Add project`}),(0,Y.jsx)(`p`,{className:`mb-3 text-xs text-danger`,children:_}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Y.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:`Cancel`}),(0,Y.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>s(!0),children:`Add from a GitHub address`}),(0,Y.jsx)(V,{type:`button`,size:`sm`,onClick:()=>void w(),children:`Try again`})]})]}):i||u?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:`Do you trust this repository?`}),(0,Y.jsx)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:(0,Y.jsx)(`code`,{className:`rounded bg-muted px-1`,children:u?u.address:i})}),u&&(0,Y.jsxs)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:[`It will be cloned to `,(0,Y.jsx)(`code`,{className:`rounded bg-muted px-1`,children:u.path}),`.`]}),(0,Y.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:`Adding it lets the agent read its files. Hidden instructions in an untrusted repo can hijack the agent (prompt injection), so only add repos you trust.`}),(0,Y.jsx)(`div`,{className:`mb-3`,children:(0,Y.jsx)(kl,{})}),(0,Y.jsxs)(`div`,{className:`mb-3 text-xs`,children:[(0,Y.jsx)(`p`,{id:m,className:`mb-1 font-medium text-foreground`,children:`The agents’ records (what you ask, what each agent answers)`}),(0,Y.jsxs)(ki,{"aria-labelledby":m,value:f?`share`:`keep`,disabled:y,onValueChange:e=>p(e===`share`),className:`gap-1.5`,children:[(0,Y.jsx)(kt,{value:`keep`,className:`flex-nowrap items-start text-xs [&>[data-slot=radio-group-item]]:mt-0.5`,children:(0,Y.jsxs)(`span`,{children:[`Keep them on this machine`,(0,Y.jsx)(`span`,{className:`block text-muted-foreground`,children:`Nothing is pushed.`})]})}),(0,Y.jsx)(kt,{value:`share`,className:`flex-nowrap items-start text-xs [&>[data-slot=radio-group-item]]:mt-0.5`,children:(0,Y.jsxs)(`span`,{children:[`Share them to the repository’s remote`,(0,Y.jsxs)(`span`,{className:`block text-muted-foreground`,children:[`Pushes a branch `,(0,Y.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`agent-data`}),` to origin, and keeps pushing as agents work.`]})]})})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`You can change this later in the project’s menu.`})]}),b&&(0,Y.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:b}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,disabled:y,onClick:()=>{x(),u?d(null):e?r():w()},children:u?`Change the address`:e?`Cancel`:`Choose again`}),(0,Y.jsx)(V,{type:`button`,size:`sm`,autoFocus:!0,disabled:y,onClick:()=>void E(),children:y?u?`Cloning…`:`Adding…`:u?`I trust it, clone and add it`:`I trust it, add it`})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:`Add project`}),(0,Y.jsx)(`p`,{role:`status`,className:`mb-3 text-xs text-muted-foreground`,children:`Choose the repository's folder in the system dialog…`}),(0,Y.jsx)(`div`,{className:`flex justify-end`,children:(0,Y.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:`Cancel`})})]})})]})}var jl=new Map;function Ml(e={}){let{locale:t,...n}=e,r={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...n},i=`${He(t)}|${JSON.stringify(r)}`,a=jl.get(i);if(a)return a;let o=new Intl.Collator(t,r),s={contains(e,t,n){if(!t)return!0;let r=$n(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(o.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=$n(e,n);return o.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=$n(e,n),i=t.length;return r.length>=i&&o.compare(r.slice(r.length-i),t)===0}};return jl.set(i,s),s}var Nl=`⁠`;function Pl(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function Fl(e=!0){let t=p(),n=J.useRef(null);return J.useEffect(()=>{if(!e||nr)return;let r=n.current;if(r==null)return;let i=Pl(r);if(i==null)return;let a=i.data,o=`${a}${Nl}`;return i.nodeValue=o,t.start(200,()=>{i.nodeValue===o&&(i.nodeValue=a)}),()=>{t.clear(),i.nodeValue===o&&(i.nodeValue=a)}},[e,n,t]),n}function Il(e){switch(e){case`data-sync`:return`Not syncing with the remote`;case`provider`:return`Unsettled: which package provides the data`}}function Ll({errors:e}){return!e||e.length===0?null:(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 border-b border-danger/30 bg-danger/10 px-4 py-3`,children:e.map(e=>(0,Y.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 text-sm`,children:[(0,Y.jsx)(Gc,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`p`,{className:`font-medium text-danger`,children:[Il(e.code),(0,Y.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · since `,xt(e.since)]})]}),(0,Y.jsx)(`p`,{className:`break-words text-muted-foreground`,children:e.message})]})]},e.code))})}function Rl({project:e}){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:q(`h-2 w-2 shrink-0 rounded-full`,e.errors?.length?`bg-danger`:e.activated?`bg-primary`:`bg-muted-foreground`)})}function zl({name:e,label:t}){let n=t.endsWith(e)?t.slice(0,-e.length):``;return(0,Y.jsxs)(`span`,{className:`block truncate`,children:[n&&(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:n}),n?e:t]})}function Bl({machineId:e}){let t=Fs().find(t=>t.id===e);if(!t)return null;let n=_e[le(t).kind];return(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,Y.jsx)(n,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[`on `,Ct(t)]})]})}function Vl({projects:e,scope:t,pending:n=!1,onScope:r,onProjectAdded:i}){let[a,o]=(0,J.useState)(null),s=nl(),c=t===null?void 0:e.find(e=>e.id===t),l=c?s(c.id,c.name):`All projects`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Mn,{children:[(0,Y.jsxs)(mt,{"aria-label":`Project: ${n?`loading`:l}`,className:`flex w-full items-center gap-2 rounded-md border border-sidebar-border bg-background px-2 py-1.5 text-sm font-medium transition-colors hover:bg-sidebar-accent/60`,children:[n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 shrink-0 rounded-full bg-muted`}),(0,Y.jsx)(`span`,{className:`flex-1`,children:(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`block h-3.5 w-24 animate-pulse rounded bg-muted`})})]}):(0,Y.jsxs)(Y.Fragment,{children:[c?(0,Y.jsx)(Rl,{project:c}):(0,Y.jsx)(Ec,{className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1 truncate text-left`,children:l})]}),(0,Y.jsx)(Xs,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0})]}),(0,Y.jsxs)(hr,{align:`start`,className:`w-[var(--anchor-width)]`,children:[(0,Y.jsxs)(K,{onClick:()=>r(null),children:[(0,Y.jsx)(Ec,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1`,children:`All projects`}),t===null&&(0,Y.jsx)(Ir,{className:`h-3.5 w-3.5 shrink-0`,"aria-label":`selected`})]}),e.length>0&&(0,Y.jsx)(ci,{}),e.map(e=>(0,Y.jsxs)(K,{onClick:()=>r(e.id),children:[(0,Y.jsx)(Rl,{project:e}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(zl,{name:e.name,label:s(e.id,e.name)}),e.machine!==void 0&&(0,Y.jsx)(Bl,{machineId:e.machine}),e.errors?.map(e=>(0,Y.jsx)(`span`,{title:e.message,className:`block truncate text-xs text-danger`,children:Il(e.code)},e.code)),!e.errors?.length&&!e.activated&&(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Not activated`}),!e.errors?.length&&e.activated&&e.local&&(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.local===`no-remote`?`Local only, no remote`:`Records kept on this machine`})]}),e.id===t&&(0,Y.jsx)(Ir,{className:`h-3.5 w-3.5 shrink-0`,"aria-label":`selected`})]},e.id)),(0,Y.jsx)(ci,{}),(0,Y.jsxs)(K,{onClick:()=>o(`folder`),className:`text-muted-foreground`,children:[(0,Y.jsx)(Fc,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Add project`})]}),(0,Y.jsxs)(K,{onClick:()=>o(`address`),className:`text-muted-foreground`,children:[(0,Y.jsx)(Fc,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Add from a GitHub address`})]})]})]}),a&&(0,Y.jsx)(Al,{fromAddress:a===`address`,onAdded:()=>i?.(),onClose:()=>o(null)})]})}function Hl(e,t=!0){return e===`awaiting`?`Needs answer`:e===`uncommitted`?`Needs commit`:e===`unpushed`?t?`Needs PR`:`Needs push`:`Needs merge`}var Ul={awaiting:{Icon:ec,tone:`text-warning`},uncommitted:{Icon:cc,tone:`text-info`},unpushed:{Icon:hc,tone:`text-info`},pr:{Icon:yc,tone:`text-success`}};function Wl(e){return e.kind===`awaiting`?e.question:e.kind===`uncommitted`?e.files?e.files===1?`1 file`:`${e.files} files`:void 0:e.kind===`unpushed`?e.commits?e.commits===1?`1 commit`:`${e.commits} commits`:void 0:`#${e.number}`}function Gl(e){return e.kind===`awaiting`?`Open the agent to answer`:e.kind===`uncommitted`?`Open the session: it left files uncommitted`:e.kind===`unpushed`?`Open the session: work on ${e.branch??``} is not published`:e.agentId?`Open the session of PR #${e.number}`:`Open PR #${e.number}`}function Kl({items:e,onOpenAgent:t,onOpenProject:n,grouped:r=!1}){let[i,a]=(0,J.useState)(!1),o=i?e:e.slice(0,5),s=e.length-5,c=new Set(e.map(e=>e.projectId)).size>1;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`ul`,{children:o.map(e=>{let{Icon:i,tone:a}=Ul[e.kind],o=Wl(e),s=er(e.createdAt,``),l=(0,Y.jsxs)(Y.Fragment,{children:[r?(0,Y.jsx)(`span`,{title:Hl(e.kind,e.gitHost),className:q(`flex size-4 shrink-0 items-center justify-center`,a),children:(0,Y.jsx)(i,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}):(0,Y.jsxs)(`span`,{className:q(`flex w-28 shrink-0 items-center gap-1.5 text-xs max-md:w-auto max-md:flex-1`,a),children:[(0,Y.jsx)(i,{className:`h-3.5 w-3.5 shrink-0`}),Hl(e.kind,e.gitHost)]}),(0,Y.jsx)(`span`,{className:q(`min-w-0 shrink truncate text-foreground md:max-w-[50%]`,r?`max-md:flex-1`:`max-md:order-1 max-md:basis-full`),children:e.title}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground md:flex-auto max-md:order-2 max-md:basis-full`,children:o}),e.computer&&(0,Y.jsx)(ut,{computer:e.computer,named:!1}),c&&(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.projectName}),(0,Y.jsx)(`span`,{className:`min-w-14 shrink-0 text-right text-xs tabular-nums text-muted-foreground`,children:s}),(0,Y.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}),u=`flex w-full items-center overflow-hidden whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm hover:bg-accent/40 md:gap-3 max-md:flex-wrap max-md:gap-x-3 max-md:gap-y-0.5`;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:e.kind===`pr`&&!e.agentId?(0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:u}):(0,Y.jsx)(`button`,{type:`button`,onClick:()=>e.agentId?t(e.projectId,e.agentId):n?.(e.projectId),className:u}),children:l}),(0,Y.jsx)(H,{children:e.computer?`${Gl(e)} · runs on ${e.computer.name}`:Gl(e)})]})},ra(e))})}),s>0&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(!i),className:`mt-1 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:i?`Show fewer`:`Show ${s} more`})]})}var ql=[`#e69875`,`#dbbc7f`,`#a7c080`,`#7fbbb3`,`#d699b6`,`#e67e80`],Jl=[{d:`M-160 -166.3 A10 10 0 0 0 -175 -174.9 L-234 -140.9 A10 10 0 0 0 -239 -132.2 L-239 34.1 A10 10 0 0 0 -234 42.7 L-72 136.3 A10 10 0 0 0 -62 136.3 L-21 112.6 A10 10 0 0 0 -21 95.3 L-173 7.5 A10 10 0 0 1 -178 -1.2 L-178 -97 A10 10 0 0 1 -173 -105.7 L-165 -110.3 A10 10 0 0 0 -160 -118.9 Z`,axis:[-160,-148.4,-36.5,121.5]},{d:`M64 -221.7 A10 10 0 0 0 64 -239 L5 -273.1 A10 10 0 0 0 -5 -273.1 L-149 -189.9 A10 10 0 0 0 -154 -181.3 L-154 5.8 A10 10 0 0 0 -149 14.4 L-108 38.1 A10 10 0 0 0 -93 29.4 L-93 -146.1 A10 10 0 0 1 -88 -154.7 L-5 -202.6 A10 10 0 0 1 5 -202.6 L13 -198 A10 10 0 0 0 23 -198 Z`,axis:[48.5,-212.8,-123.5,29.2]},{d:`M224 -55.4 A10 10 0 0 0 239 -64.1 L239 -132.2 A10 10 0 0 0 234 -140.9 L90 -224 A10 10 0 0 0 80 -224 L-82 -130.5 A10 10 0 0 0 -87 -121.8 L-87 -74.5 A10 10 0 0 0 -72 -65.8 L80 -153.6 A10 10 0 0 1 90 -153.6 L173 -105.7 A10 10 0 0 1 178 -97 L178 -87.8 A10 10 0 0 0 183 -79.1 Z`,axis:[208.5,-64.4,-87,-92.4]},{d:`M160 166.3 A10 10 0 0 0 175 174.9 L234 140.9 A10 10 0 0 0 239 132.2 L239 -34.1 A10 10 0 0 0 234 -42.7 L72 -136.3 A10 10 0 0 0 62 -136.3 L21 -112.6 A10 10 0 0 0 21 -95.3 L173 -7.5 A10 10 0 0 1 178 1.2 L178 97 A10 10 0 0 1 173 105.7 L165 110.3 A10 10 0 0 0 160 118.9 Z`,axis:[160,148.4,36.5,-121.5]},{d:`M-64 221.7 A10 10 0 0 0 -64 239 L-5 273.1 A10 10 0 0 0 5 273.1 L149 189.9 A10 10 0 0 0 154 181.3 L154 -5.8 A10 10 0 0 0 149 -14.4 L108 -38.1 A10 10 0 0 0 93 -29.4 L93 146.1 A10 10 0 0 1 88 154.7 L5 202.6 A10 10 0 0 1 -5 202.6 L-13 198 A10 10 0 0 0 -23 198 Z`,axis:[-48.5,212.8,123.5,-29.2]},{d:`M-224 55.4 A10 10 0 0 0 -239 64.1 L-239 132.2 A10 10 0 0 0 -234 140.9 L-90 224 A10 10 0 0 0 -80 224 L82 130.5 A10 10 0 0 0 87 121.8 L87 74.5 A10 10 0 0 0 72 65.8 L-80 153.6 A10 10 0 0 1 -90 153.6 L-173 105.7 A10 10 0 0 1 -178 97 L-178 87.8 A10 10 0 0 0 -183 79.1 Z`,axis:[-208.5,64.4,87,92.4]}];function Yl(e){return e?`AI is working for you 🚀`:`AI isn't working for you 💤`}function Xl(e){return e?`AI is working for you`:`AI isn't working for you`}function Zl(e){return ql[(e%ql.length+ql.length)%ql.length]}function Ql(e){return ql.map((t,n)=>Zl(e+n)).concat(Zl(e)).join(`;`)}function $l({className:e,working:t=!1}){let n=Yl(t);return(0,Y.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`-289 -326 578 651.9`,className:e,role:`img`,"aria-label":Xl(t),children:[(0,Y.jsx)(`title`,{children:n}),t&&(0,Y.jsx)(`defs`,{children:Jl.map(({axis:[e,t,n,r]},i)=>(0,Y.jsxs)(`linearGradient`,{id:`hexknot-${i}`,gradientUnits:`userSpaceOnUse`,x1:e,y1:t,x2:n,y2:r,children:[(0,Y.jsx)(`stop`,{offset:`0`,stopColor:Zl(i),children:(0,Y.jsx)(`animate`,{attributeName:`stop-color`,dur:`6s`,repeatCount:`indefinite`,values:Ql(i)})}),(0,Y.jsx)(`stop`,{offset:`1`,stopColor:Zl(i-1),children:(0,Y.jsx)(`animate`,{attributeName:`stop-color`,dur:`6s`,repeatCount:`indefinite`,values:Ql(i-1)})})]},i))}),Jl.map(({d:e},n)=>(0,Y.jsx)(`path`,{fill:t?`url(#hexknot-${n})`:`var(--logo-${n+1})`,d:e},n))]})}function eu({working:e,href:t=`/`,onNavigate:n}){return(0,Y.jsxs)(`a`,{href:t,onClick:e=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0||(e.preventDefault(),n())},className:`flex shrink-0 items-center gap-3 rounded-md [view-transition-name:oa-brand] transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-primary)]`,children:[(0,Y.jsx)($l,{className:`h-6 w-auto shrink-0`,working:e}),(0,Y.jsx)(`span`,{className:`shrink-0 font-['IBM_Plex_Sans',ui-sans-serif,sans-serif] text-[17px] leading-6 font-medium max-sm:hidden`,children:`OpenAgent`})]})}function tu(){return document.cookie.split(`;`).some(e=>e.trim().startsWith(`openagent-view=`))}function nu(){if(!tu())return null;let e=`relative flex h-6 items-center justify-center rounded-md font-['IBM_Plex_Sans',ui-sans-serif,sans-serif] text-xs font-medium whitespace-nowrap`;return(0,Y.jsxs)(`div`,{className:`relative inline-flex gap-0.5 self-start rounded-lg border border-sidebar-border p-0.5 [view-transition-name:oa-toggle]`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`absolute top-0.5 left-[calc(0.125rem+96px+0.125rem)] h-6 w-[84px] rounded-md bg-primary [view-transition-name:oa-toggle-thumb]`}),(0,Y.jsxs)(`span`,{className:`relative inline-flex gap-0.5 [view-transition-name:oa-toggle-labels]`,children:[(0,Y.jsx)(`a`,{href:`/_view/landing`,className:q(e,`w-[96px] text-muted-foreground transition-colors hover:text-foreground`),children:`Landing page`}),(0,Y.jsx)(`span`,{"aria-current":`page`,className:q(e,`w-[84px] text-primary-foreground`),children:`Dashboard`})]})]})}var ru=U(`onPerson`),iu=[{value:`system`,label:`System`,icon:jc},{value:`light`,label:`Light`,icon:Uc},{value:`dark`,label:`Dark`,icon:Mc}];function au(){let e=Ra(Ia()),t=iu.find(t=>t.value===e)??iu[0],n=t.icon;return(0,Y.jsxs)(Ti,{children:[(0,Y.jsxs)(bi,{children:[(0,Y.jsx)(n,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1`,children:`Theme`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t.label})]}),(0,Y.jsx)(pn,{children:iu.map(t=>{let n=t.icon;return(0,Y.jsxs)(K,{closeOnClick:!1,onClick:()=>Na({theme:t.value}),children:[(0,Y.jsx)(Ir,{className:q(`h-3.5 w-3.5 shrink-0`,t.value===e?`opacity-100`:`opacity-0`)}),(0,Y.jsx)(n,{className:`h-3.5 w-3.5 shrink-0 opacity-70`}),t.label]},t.value)})})]})}function ou(){return(0,J.useSyncExternalStore)(su,()=>typeof Notification>`u`?`unsupported`:Notification.permission,()=>`unsupported`)}function su(e){let t=setInterval(e,3e3);return()=>clearInterval(t)}function cu(){let e=Ia(),t=Ba(e),n=Va(e),r=Ha(e),i=ou(),a=i!==`unsupported`,o=i===`denied`,s=t&&i===`granted`;return(0,Y.jsxs)(Ti,{children:[(0,Y.jsxs)(bi,{children:[s?(0,Y.jsx)(Ks,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0}):(0,Y.jsx)(Gs,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1`,children:`Notifications`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:s?`On`:`Off`})]}),(0,Y.jsxs)(pn,{className:`min-w-[16rem]`,children:[a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Hn,{children:[(0,Y.jsx)(tn,{children:`Deliver to`}),(0,Y.jsx)(Ar,{checked:t,disabled:o,onCheckedChange:e=>{Na({notifyBrowser:e}),e&&i==="default"&&Notification.requestPermission()},className:`items-start`,children:(0,Y.jsx)(Dt,{label:`Browser`,description:o?`Blocked in your browser settings`:t&&i==="default"?`Click to allow browser notifications`:`Desktop notifications while the dashboard is open`})})]}),(0,Y.jsx)(ci,{})]}),(0,Y.jsxs)(Hn,{children:[(0,Y.jsx)(tn,{children:`Notify me about`}),(0,Y.jsx)(Ar,{checked:r,onCheckedChange:e=>Na({notifyHumanIntervention:e}),className:`items-start`,children:(0,Y.jsx)(Dt,{label:`Human Queue`,description:`An agent awaiting you, or a PR to review`})}),(0,Y.jsx)(Ar,{checked:n,onCheckedChange:e=>Na({notifyNewActivity:e}),className:`items-start`,children:(0,Y.jsx)(Dt,{label:`New activity`,description:`An agent started or finished`})})]})]})]})}var lu=U(`onGitHosts`),uu=U(`sendUseGitHostAccount`),du=U(`sendForgetGitHostAccount`),fu=U(`sendGitHostLogin`),pu=U(`sendGitHostInstall`),mu=U(`onAgentState`),hu=U(`sendAgentFix`),gu=U(`onProjectAccounts`),_u=U(`sendProjectAccounts`),vu=`accounts`,yu=2e3,bu=8e3,xu=3e4;function Su(e,t,n,r){let[i,a]=(0,J.useState)(xu),{value:o,reload:s}=xi(t,void 0,i,[...r,i],{remember:e}),c=n(o);return(0,J.useEffect)(()=>{c!==i&&a(c)},[c,i]),{value:o,reload:s}}function Cu(e,t=!0){let{value:n,reload:r}=Su(`agent-state:${e??``}`,t?()=>mu(e):null,e=>e?.fixing?yu:e&&!e.ready?bu:xu,[e,t]);return{state:n,reload:r}}function wu(){let{value:e,reload:t}=Su(`git-hosts`,lu,e=>e?.hosts.some(e=>e.provider?.installing||e.provider?.loggingIn)?yu:e?.hosts.some(e=>Eu(e)===`step`||Eu(e)===`not-installed`)?bu:xu,[]);return{view:e,reload:t}}function Tu(e){if(e)return e.ready?`connected`:e.fix?.kind===`install`||/ not found/.test(e.problem??``)?`not-installed`:`step`}function Eu(e){let t=e.provider;if(t)return t.installed?t.accounts.length>0&&t.accounts.every(e=>e.ok)?`connected`:`step`:`not-installed`}var Du={step:{words:`Log in`,tone:`bg-warning/10 text-warning`,dot:`bg-warning`},"not-installed":{words:`Not installed`,tone:`bg-muted text-muted-foreground`,dot:`bg-muted-foreground`}};function Ou({words:e,tone:t,dot:n}){return(0,Y.jsxs)(`span`,{className:q(`inline-flex shrink-0 items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,t),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:q(`size-1.5 rounded-full`,n)}),e]})}function ku({state:e}){return e===`connected`?null:(0,Y.jsx)(Ou,{...Du[e]})}function Au({svg:e,className:t}){if(!e)return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:q(`size-4 shrink-0 rounded-sm bg-muted-foreground/30`,t)});let n=`url("data:image/svg+xml;utf8,${encodeURIComponent(e)}")`;return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:q(`size-4 shrink-0 bg-current`,t),style:{maskImage:n,WebkitMaskImage:n,maskSize:`contain`,WebkitMaskSize:`contain`,maskRepeat:`no-repeat`,WebkitMaskRepeat:`no-repeat`}})}var ju=72;function Mu({command:e}){let[t,n]=(0,J.useState)(!1),r=e.length>ju;return(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[(0,Y.jsx)(`code`,{className:q(`min-w-0 flex-1 font-mono text-[11px] text-muted-foreground`,r&&!t?`truncate`:`break-all`),children:e}),r&&(0,Y.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline`,onClick:()=>n(!t),children:t?`Less`:`Show all`}),(0,Y.jsx)(pe,{text:e,label:`Copy the command`})]})}function Nu(e){let t=$r[e.driver];return Tu(e)===`not-installed`?`${t} is not installed.`:/ logged in/.test(e.problem??``)?`${t} is not logged in.`:e.problem??`${t} cannot start.`}function Pu(e){let t=e.provider;return t.installed?t.accounts.length===0?`No ${t.name} account is logged in.`:`${t.name} no longer takes a login: add it again.`:`${t.tool}, the tool for ${t.name}, is not installed.`}function Fu({label:e,busy:t,busyWords:n,command:r,failed:i,onPress:a,size:o=`sm`}){return(0,Y.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[t?(0,Y.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:n}):(0,Y.jsx)(V,{size:o,onClick:a,children:e}),r&&(0,Y.jsx)(Mu,{command:r}),i&&(0,Y.jsx)(`p`,{role:`alert`,className:`whitespace-pre-line text-xs text-danger`,children:i})]})}function Iu(e){let t=$r[e.driver];return e.fixing===`install`?`Installing ${t}…`:`Say yes in the page this computer's browser opened to log ${t} in.`}function Lu({state:e,onChanged:t,size:n}){let[r,i]=(0,J.useState)();if(e.ready||!e.fix)return null;let a=$r[e.driver],o=async()=>{i(void 0);let n=await hu(e.driver);n.ok||i(n.error),t()};return(0,Y.jsx)(Fu,{size:n,label:e.fix.kind===`install`?`Install ${a}`:`Log in to ${a}`,busy:e.fixing!==void 0,busyWords:Iu(e),command:e.fix.command,...(r??e.failed)===void 0?{}:{failed:r??e.failed},onPress:()=>void o()})}function Ru({code:e,url:t}){return(0,Y.jsxs)(`div`,{role:`status`,className:`space-y-1.5 text-xs`,children:[(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`Type this code at the page below, signed in to the account to add:`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`code`,{className:`rounded bg-muted px-2 py-1 font-mono text-sm font-medium tracking-wider`,children:e}),(0,Y.jsx)(pe,{text:e,label:`Copy the code`}),(0,Y.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`text-[var(--color-primary)] underline-offset-2 hover:underline`,children:t.replace(/^https:\/\//,``)})]})]})}function zu(e){let[t,n]=(0,J.useState)(),[r,i]=(0,J.useState)(!1);return{start:async t=>{i(!0),n(void 0);try{let r=await fu(t);r.ok||n(r.error),await e()}finally{i(!1)}},error:t,busy:r}}function Bu({row:e,onChanged:t,size:n}){let[r,i]=(0,J.useState)(),a=zu(t),o=e.provider;if(!o)return null;if(!o.installed){if(!o.install)return(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Install ${o.tool} by hand: ${o.name} makes none for this computer.`});let a=async()=>{i(void 0);let n=await pu(e.host);n.ok||i(n.error),await t()};return(0,Y.jsx)(Fu,{size:n,label:`Install ${o.tool}`,busy:o.installing===!0,busyWords:`Installing ${o.tool}…`,command:o.install,...(r??o.installFailed)===void 0?{}:{failed:r??o.installFailed},onPress:()=>void a()})}return o.loggingIn?(0,Y.jsx)(Ru,{code:o.loggingIn.code,url:o.loggingIn.url}):o.accounts.length>0?null:(0,Y.jsx)(Fu,{size:n,label:`Log in to ${o.name}`,busy:a.busy,busyWords:`Asking for a code…`,...a.error===void 0?{}:{failed:a.error},onPress:()=>void a.start(e.host)})}function Vu(){let{state:e,reload:t}=Cu(),{view:n,reload:r}=wu(),i=async()=>{await Promise.all([t(),r()])},a=[];if(e&&!e.ready){let n=$r[e.driver];a.push({key:`agent`,name:n,words:Nu(e),entry:vu,fix:(0,Y.jsx)(Lu,{state:e,onChanged:()=>void t()})})}for(let e of n?.hosts??[]){let t=e.provider;!t||Eu(e)===`connected`||a.push({key:`host:${e.host}`,name:t.name,words:Pu(e),entry:vu,fix:(0,Y.jsx)(Bu,{row:e,onChanged:r})})}return{missing:a,reload:i,hosts:n}}function Hu(e){return e.trim().split(/\s+/)[0]??e}function Uu(e){let t=e.trim().split(/\s+/).filter(Boolean);return(t.length>1?`${t[0][0]}${t.at(-1)[0]}`:t[0]?.[0]??`?`).toUpperCase()}function Wu({person:e,dot:t}){let[n,r]=(0,J.useState)(!1),i=e?.avatar&&!n?e.avatar:void 0;return(0,Y.jsxs)(`span`,{"aria-hidden":!0,className:`relative shrink-0`,children:[(0,Y.jsx)(`span`,{className:`flex h-6 w-6 items-center justify-center overflow-hidden rounded-full bg-muted text-[10px] font-medium text-muted-foreground`,children:i?(0,Y.jsx)(`img`,{src:i,alt:``,referrerPolicy:`no-referrer`,className:`h-full w-full object-cover`,onError:()=>r(!0)}):e?Uu(e.name):null}),t&&(0,Y.jsx)(`span`,{"data-testid":`missing-dot`,className:`absolute -top-0.5 -right-0.5 size-2 rounded-full bg-warning ring-2 ring-sidebar`})]})}function Gu({onSettings:e}){let t=mn(()=>ru().catch(()=>null),null,[],{remember:`person`}),{missing:n}=Vu();return(0,Y.jsxs)(Mn,{children:[(0,Y.jsxs)(mt,{"aria-label":`${t?`${t.name}: settings`:`Settings`}${n.length>0?`, something is missing`:``}`,className:`flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm outline-none hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-sidebar-ring data-[popup-open]:bg-sidebar-accent`,children:[(0,Y.jsx)(Wu,{person:t,dot:n.length>0}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t?Hu(t.name):``}),(0,Y.jsx)(zc,{className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}),(0,Y.jsxs)(hr,{align:`start`,className:`min-w-[14rem]`,children:[t&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Hn,{children:(0,Y.jsxs)(tn,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-foreground`,children:t.name}),t.login&&(0,Y.jsxs)(`span`,{className:`truncate font-normal`,children:[`@`,t.login]})]})}),(0,Y.jsx)(ci,{})]}),n.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[n.map(t=>(0,Y.jsxs)(K,{onClick:()=>e(t.entry),className:`text-warning`,children:[(0,Y.jsx)(Zs,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:t.words})]},t.key)),(0,Y.jsx)(ci,{})]}),(0,Y.jsx)(au,{}),(0,Y.jsx)(cu,{}),(0,Y.jsx)(ci,{}),(0,Y.jsxs)(K,{onClick:()=>e(),children:[(0,Y.jsx)(zc,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0}),`Settings`]})]})]})}var Ku=`oa.sidebar-width`,qu=new Set,Ju=e=>Math.round(Math.min(448,Math.max(224,e)));function Yu(){try{let e=Number(localStorage.getItem(Ku));return Number.isFinite(e)&&e>0?Ju(e):256}catch{return 256}}var Xu=Yu();function Zu(e){Xu=e===void 0?256:Ju(e);try{e===void 0?localStorage.removeItem(Ku):localStorage.setItem(Ku,String(Xu))}catch{}for(let e of qu)e()}function Qu(){return(0,J.useSyncExternalStore)(e=>(qu.add(e),()=>qu.delete(e)),()=>Xu)}var $u=`oa.sidebar-hidden`;function ed(){try{return localStorage.getItem($u)===`true`}catch{return!1}}var td=ed();function nd(e){td=e;try{e?localStorage.setItem($u,`true`):localStorage.removeItem($u)}catch{}for(let e of qu)e()}function rd(){return(0,J.useSyncExternalStore)(e=>(qu.add(e),()=>qu.delete(e)),()=>td)}var id=16;function ad(){let e=Qu(),t=(0,J.useRef)(null);return(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`The width of the sidebar`,"aria-valuenow":e,"aria-valuemin":224,"aria-valuemax":448,tabIndex:0,onPointerDown:n=>{n.preventDefault(),n.currentTarget.setPointerCapture(n.pointerId),t.current={x:n.clientX,width:e}},onPointerMove:e=>{t.current&&Zu(t.current.width+e.clientX-t.current.x)},onPointerUp:()=>t.current=null,onPointerCancel:()=>t.current=null,onDoubleClick:()=>Zu(void 0),onKeyDown:t=>{t.key===`ArrowLeft`||t.key===`ArrowRight`?(t.preventDefault(),Zu(e+(t.key===`ArrowRight`?id:-16))):t.key===`Enter`&&e!==256&&Zu(void 0)},className:`group/edge absolute inset-y-0 -right-1 z-20 flex w-2 cursor-col-resize touch-none justify-center outline-none`,children:(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-[3px] bg-transparent transition-colors group-hover/edge:bg-primary group-focus-visible/edge:bg-primary group-active/edge:bg-primary`})})}function od(e,t){return`agent-log:${e}:${t}`}function sd(e,t){Ei(od(e,t),()=>no(e,t))}function cd(e,t){return e===null||t.status===`running`?{}:{onNear:()=>sd(e,t.id)}}function ld({pageScrolls:e=!1,projectId:t,scope:n=null,scopePending:r=!1,listLoaded:i=!0,onScope:a=()=>{},homeHref:o=`/`,agents:s,selectedAgentId:c,onSelect:l,recentAgents:u,onSelectRecent:d,projects:f=[],onNewAgentInProject:p,onProjectAdded:m,startTick:h=0,startIntent:g=``,startTitle:_,startId:v=null,startProjectName:y,working:b=!1,onDashboard:x=()=>{},onSettings:C=()=>{},pages:w=[],activePage:T=null,onPage:E=()=>{},interventionCount:D=0}){let{isMobile:O,open:k,setOpenMobile:A}=En(),j=e=>(...t)=>{A(!1),e(...t)},N=Ia(),P=nl(),[F,ee]=(0,J.useState)(null);(0,J.useEffect)(()=>{h>0&&ee({intent:g,id:v})},[h]);let te=n===null&&u!==void 0,I=te?u.map(e=>e.agent):s,L=I.some(e=>e.status===`running`),R=F!==null&&I.some(e=>e.id===F.id);(0,J.useEffect)(()=>{R&&ee(null)},[R]),(0,J.useEffect)(()=>{ee(null)},[n]),(0,J.useEffect)(()=>{if(F===null||L)return;let e=setTimeout(()=>ee(null),2e4);return()=>clearTimeout(e)},[F,L]);let ne=F!==null&&!L&&!R,re=c!==null&&!I.some(e=>e.id===c),ie=N.recentsSort??`created`,ae=Zc(te?u.map(e=>({key:`${e.projectId}:${e.agent.id}`,agent:e.agent,project:P(e.projectId,e.projectName),projectId:e.projectId,active:e.projectId===t&&e.agent.id===c,onClick:()=>d?.(e.projectId,e.agent.id),...cd(e.projectId,e.agent)})):s.map(e=>({key:e.id,agent:e,projectId:t,active:e.id===c,onClick:()=>l(e.id),...cd(t,e)})),ie),z=t!==null&&c===null,oe=ml(ae),[B,ce]=(0,J.useState)({}),le=ae.length>0||ne,ue=e=>e.projectId??n,de=ji(ae.map(e=>({projectId:ue(e),person:e.agent.person})),Zo,`sidebar:people`),fe=Nn(),pe=(e,t,n=e.agent.status,r)=>(0,Y.jsx)(hd,{status:n,fold:r,saving:e.agent.saving===!0&&n===e.agent.status,intent:t?ul(e.agent):Jc(e.agent),naming:!t&&Yc(e.agent,N.nameRuns!==!1),driver:e.agent.driver,...e.agent.person&&!t?{person:e.agent.person,account:de(ue(e),e.agent.person)}:{},...e.agent.model?{model:ur(fe?.[xr(e.agent.driver)??`claude-code`],e.agent.model)}:{},...e.project&&!t?{project:e.project}:{},subtitle:er(e.agent.startedAt),active:e.active,remote:e.agent.target===`remote`,cloud:e.agent.target===`web`,...e.agent.otherHost&&e.agent.host?{startedOn:e.agent.host}:{},cloudState:sa(e.agent,Date.now()),...e.agent.remoteLabel?{remoteLabel:e.agent.remoteLabel}:{},...e.agent.remoteKind?{remoteKind:e.agent.remoteKind}:{},seenAt:e.agent.seenAt,...e.agent.pr?{pr:{number:e.agent.pr.number,...e.agent.prState?{state:e.agent.prState}:{}}}:{},...e.agent.unpublished?{unpublished:e.agent.unpublished}:{},...e.agent.uncommitted?{uncommitted:e.agent.uncommitted}:{},gitHost:f.find(t=>t.id===e.projectId)?.gitHost!==!1,onClick:j(e.onClick),onNear:e.onNear});if(!O&&!k)return null;let me=e&&!O;return(0,Y.jsxs)(Y.Fragment,{children:[me&&(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`w-(--sidebar-width) shrink-0`}),(0,Y.jsxs)(Ft,{collapsible:O?`offcanvas`:`none`,className:q(`relative w-(--sidebar-width) border-r border-sidebar-border`,me&&`fixed inset-y-0 left-0 z-20 h-dvh`),children:[(0,Y.jsxs)(Vt,{className:`gap-4 pb-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1 pt-1`,children:[(0,Y.jsx)(eu,{working:b,href:o,onNavigate:j(x)}),(0,Y.jsx)(S,{})]}),(0,Y.jsx)(nu,{}),(0,Y.jsx)(Vl,{projects:f,scope:n,pending:r,onScope:a,onProjectAdded:m})]}),(0,Y.jsxs)(Vt,{className:`gap-0.5 pt-0! pb-2`,children:[(0,Y.jsx)(fd,{scope:n,projects:f,active:z,onNewAgentInProject:p&&j(p),onSelect:j(l),onProjectAdded:m}),(0,Y.jsx)(dd,{active:t===null&&T===null,count:D,onClick:j(x)}),w.map(e=>(0,Y.jsx)(ud,{icon:e.icon??qs,label:e.label,active:T===e.segment,onClick:j(()=>E(e.segment))},e.segment))]}),(0,Y.jsx)(se,{className:`overflow-hidden`,children:(0,Y.jsx)(M,{className:`min-h-0 flex-1`,children:(0,Y.jsxs)(Lr,{className:`pt-3 pr-3`,children:[(0,Y.jsxs)(`div`,{className:`sticky top-0 z-10`,children:[(0,Y.jsxs)(Kt,{className:`rounded-none bg-sidebar font-normal tracking-wide text-muted-foreground`,children:[`Recent agents`,(0,Y.jsx)(pd,{order:ie})]}),(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`rail-fade pointer-events-none absolute inset-x-0 top-full h-4 bg-gradient-to-b from-sidebar to-transparent`})]}),(0,Y.jsxs)(we,{children:[(0,Y.jsxs)(Qt,{className:`gap-0.5`,children:[ne&&(0,Y.jsx)(ot,{children:(0,Y.jsx)(hd,{status:`running`,...N.nameRuns===!1?{intent:F?.intent??void 0}:_===void 0?{intent:void 0,naming:!0}:{intent:_},...te&&y?{project:y}:{},subtitle:`just now`,driver:N.driver,active:re,standIn:!0,onClick:j(()=>l(null))})}),oe.map(({row:e,subagents:t})=>{let n=B[e.key]??t.some(e=>dl(e.agent)||e.active),r=t.filter(e=>e.agent.status===`running`).length,i=Date.now(),a=e.agent.status===`done`&&t.some(e=>pl(e.agent,i));return(0,Y.jsxs)(ot,{children:[pe(e,!1,a?`running`:e.agent.status,t.length>0?{count:t.length,working:r,open:n,onToggle:()=>ce(t=>({...t,[e.key]:!n}))}:void 0),t.length>0&&n&&(0,Y.jsx)(`div`,{className:`mt-0.5 ml-4 flex flex-col gap-0.5 border-l border-sidebar-border pl-2`,children:t.map(e=>(0,Y.jsx)(`div`,{children:pe(e,!0)},e.key))})]},e.key)})]}),!le&&i&&(0,Y.jsx)(`p`,{className:`whitespace-nowrap px-2 py-1 text-sm text-muted-foreground`,children:`No agents yet.`})]})]})})}),(0,Y.jsx)(Ae,{className:`border-t border-sidebar-border`,children:(0,Y.jsx)(Gu,{onSettings:j(C)})}),!O&&(0,Y.jsx)(ad,{})]})]})}function ud({icon:e,label:t,active:n,onClick:r,children:i}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:r,"aria-current":n?`page`:void 0,className:q(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors`,n?`bg-sidebar-accent text-sidebar-accent-foreground`:`text-foreground hover:bg-sidebar-accent/60`),children:[(0,Y.jsx)(e,{className:`h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1 text-left`,children:t}),i]})}function dd({active:e,count:t,onClick:n}){return(0,Y.jsx)(ud,{icon:Dc,label:`Overview`,active:e,onClick:n,children:t>0&&(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(`span`,{className:`min-w-5 rounded-full bg-primary px-1.5 text-center text-xs font-semibold text-primary-foreground tabular-nums`}),children:t}),(0,Y.jsxs)(H,{children:[t,` item`,t===1?``:`s`,` in your Human Queue`]})]})})}function fd({scope:e,projects:t,active:n=!1,onNewAgentInProject:r,onSelect:i,onProjectAdded:a}){let[o,s]=(0,J.useState)(!1),c=nl(),l=q(`h-auto w-full justify-start gap-2 px-2 py-1.5 font-normal`,n&&`bg-sidebar-accent text-sidebar-accent-foreground`),u=e=>r?r(e):i(null);if(e!==null||t.length===1){let n=e??t[0].id;return(0,Y.jsxs)(V,{variant:`ghost`,className:l,onClick:()=>u(n),children:[(0,Y.jsx)(Fc,{className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:`New agent`})]})}return t.length===0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(yi,{children:[(0,Y.jsxs)(pi,{render:(0,Y.jsx)(V,{variant:`ghost`,className:l,onClick:()=>s(!0)}),children:[(0,Y.jsx)(Fc,{className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:`New agent`})]}),(0,Y.jsx)(H,{children:`Add a project to start an agent`})]}),o&&(0,Y.jsx)(Al,{onAdded:()=>a?.(),onClose:()=>s(!1)})]}):(0,Y.jsxs)(Mn,{children:[(0,Y.jsxs)(mt,{"aria-label":`New agent`,className:q(st({variant:`ghost`}),l),children:[(0,Y.jsx)(Fc,{className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:`New agent`}),(0,Y.jsx)(ke,{className:`ml-auto h-3.5 w-3.5 shrink-0 opacity-70`})]}),(0,Y.jsx)(hr,{align:`start`,className:`w-[13.5rem]`,children:t.map(e=>(0,Y.jsxs)(K,{onClick:()=>u(e.id),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:q(`h-2 w-2 shrink-0 rounded-full`,e.activated?`bg-primary`:`bg-muted-foreground`)}),(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:c(e.id,e.name)})]},e.id))})]})}function pd({order:e}){return(0,Y.jsxs)(Mn,{children:[(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(mt,{type:`button`,"aria-label":`Sort agents`,className:`ml-auto flex h-5 w-5 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`}),children:(0,Y.jsx)(Vs,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,Y.jsxs)(H,{children:[`Sort by: `,Xc[e]]})]}),(0,Y.jsx)(hr,{align:`end`,className:`min-w-40`,children:(0,Y.jsxs)(Hn,{children:[(0,Y.jsx)(tn,{className:`font-normal`,children:`Sort by`}),Object.keys(Xc).map(t=>(0,Y.jsxs)(K,{"aria-current":t===e,onClick:()=>Na({recentsSort:t}),children:[(0,Y.jsx)(Ir,{className:q(`h-3.5 w-3.5 shrink-0`,t===e?`opacity-100`:`opacity-0`),"aria-hidden":!0}),Xc[t]]},t))]})})]})}var md=`size-3.5 text-[7px]`;function hd({status:e,intent:t,naming:n=!1,project:r,subtitle:i,active:a,onClick:o,onNear:s,driver:c,model:l,standIn:u=!1,saving:d=!1,remote:f=!1,cloud:p=!1,cloudState:m,remoteLabel:h,remoteKind:g=`server`,seenAt:_,startedOn:v,fold:y,pr:b,unpublished:x,uncommitted:S,gitHost:C=!0,person:w,account:T}){let E=e===`waiting`||m===`waiting`,D=xr(c),O=_e[g],k=m===`in-cloud`,A=m===`merged`?`merged`:void 0,j=d&&!p,M=(0,J.useRef)(null),[N,P]=(0,J.useState)(!1);(0,J.useEffect)(()=>{let e=M.current;if(!e)return;let t=!1,n=()=>{t||P(e.scrollWidth>e.clientWidth+1)};n(),document.fonts?.ready.then(n);let r=typeof ResizeObserver>`u`?void 0:new ResizeObserver(n);return r?.observe(e),()=>{t=!0,r?.disconnect()}},[t,n]);let F=n?``:t||`New agent`,ee=(0,J.useRef)(!1);n&&(ee.current=!0);let te=q(`rail-title min-w-0 flex-1 text-sm font-normal`,N&&`is-overflowing`),I=E?`waiting`:k?`in cloud`:A||(j?`saving…`:e===`unknown`?`status unknown`:e),L=e===`unknown`?`${h??`Its computer`} offline${_?` · last seen ${er(_)}`:``}`:void 0,R=e===`running`||k||j,ne=j?il.saving:E?il.waiting:R?il.running:il[e],re=(A?al[A]:al[e])??al.done,ie=b?.state?ol[b.state]:void 0,ae=b?`PR #${b.number}${ie?` ${ie.word}`:``}`:void 0,z=S?{Icon:cc,said:`${Hl(`uncommitted`)} · ${S} file${S===1?``:`s`}`}:x?{Icon:hc,said:`${Hl(`unpushed`,C)} · ${x} commit${x===1?``:`s`}`}:void 0,oe=w?dt(w,T):void 0,B=[I,...r?[r]:[],i,...oe?[oe]:[],...D?[$r[D]]:[],...v?[`started on ${v}`]:[],...L?[L]:f?[h?`runs on ${h}`:`runs on another machine`]:[],...p?[`a Claude Code cloud session`]:[],...ae?[ae]:[],...z?[z.said]:[]].join(` · `),se=D?[$r[D],...l?[l]:[]].join(` · `):void 0;return(0,Y.jsxs)(V,{variant:`ghost`,"aria-label":`${n?`Naming this session`:F} · ${B}`,className:q(`rail-row h-8 w-full items-center gap-2 px-2 text-left`,a&&`bg-accent text-accent-foreground`),...u?{"data-stand-in":``}:{},onClick:o,onPointerEnter:s,onFocus:s,children:[(0,Y.jsx)(`span`,{role:`img`,"aria-label":I,className:q(`inline-block h-2 w-2 shrink-0 rounded-full`,ne??q(`border`,re),R&&`animate-pulse`)}),(0,Y.jsxs)(yi,{disabled:!N,children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(`span`,{ref:M,className:te}),children:n?(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`block h-3.5 w-2/3 animate-pulse rounded bg-muted-foreground/20`}):(0,Y.jsx)(Bs,{text:F,start:u||ee.current})}),(0,Y.jsx)(H,{side:`right`,className:`max-w-96 whitespace-pre-wrap break-words text-sm`,children:F})]}),v&&(0,Y.jsx)(gd,{said:`Started on ${v}`,children:(0,Y.jsx)(Et,{className:`h-3 w-3 text-muted-foreground`})}),f&&(0,Y.jsx)(gd,{said:L??(h?`Runs on ${h}`:`Runs on another machine`),children:(0,Y.jsx)(O,{className:`h-3 w-3 text-muted-foreground`})}),p&&(0,Y.jsx)(gd,{said:`Runs as a Claude Code cloud session`,children:(0,Y.jsx)(nc,{className:`h-3 w-3 text-muted-foreground`})}),r&&(0,Y.jsx)(`span`,{className:`max-w-[35%] min-w-0 shrink truncate text-xs text-muted-foreground`,children:r}),y&&(0,Y.jsxs)(`span`,{role:`button`,tabIndex:0,"aria-expanded":y.open,"aria-label":`${y.count} agent${y.count===1?``:`s`}${y.working>0?` · ${y.working} running`:``}`,title:`${y.count} subagent${y.count===1?``:`s`}${y.working>0?`, ${y.working} running`:``}`,onClick:e=>{e.stopPropagation(),y.onToggle()},onKeyDown:e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),e.stopPropagation(),y.onToggle())},className:`flex shrink-0 items-center gap-0.5 rounded-sm px-1 text-[11px] font-normal tabular-nums text-muted-foreground transition-colors hover:bg-background hover:text-foreground`,children:[(0,Y.jsx)(ke,{className:q(`h-3 w-3 shrink-0 transition-transform`,y.open||`-rotate-90`),"aria-hidden":!0}),(0,Y.jsx)(Js,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),y.count]}),ie&&ae&&(0,Y.jsx)(gd,{said:ae,children:(0,Y.jsx)(ie.Icon,{className:q(`h-3 w-3`,ie.tone)})}),z&&(0,Y.jsx)(gd,{said:z.said,children:(0,Y.jsx)(z.Icon,{className:`h-3 w-3 text-muted-foreground`})}),oe?(0,Y.jsx)(gd,{said:oe,children:(0,Y.jsx)($e,{email:w,picture:T?.avatar,className:md})}):u&&(0,Y.jsx)($e,{className:md}),D&&se&&(0,Y.jsx)(gd,{said:se,children:(0,Y.jsx)(hi,{driver:D,className:`h-3 w-3 text-muted-foreground`})})]})}function gd({said:e,children:t}){return(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(`span`,{role:`img`,"aria-label":e,className:`flex shrink-0 items-center`}),children:t}),(0,Y.jsx)(H,{children:e})]})}function _d(e=typeof window>`u`?``:window.location.hostname){return e===``||Ee(e)?`This machine`:e}function vd(e,t){let n=_d(t);return n===`This machine`?e:n}function yd(e){return{...e.driver?{driver:e.driver}:{},...e.model?{model:e.model}:{},...e.effort?{effort:e.effort}:{},...e.publish?{publish:e.publish}:{}}}function bd(e){let{busy:t,error:n,reset:r,run:i}=Yn(),[a,o]=(0,J.useState)(null),s=(0,J.useRef)(!0),c=(0,J.useRef)(e);return c.current=e,(0,J.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]),{busy:t,cloning:a!==null&&a.scope===e,error:n,reset:r,start:async(t,n,r={},a=`Failed to start the agent.`)=>{let l=e,u=()=>s.current&&c.current===l,d=await i(async()=>{let e=await Mo(t,n,r);if(e.ok||!e.notThere)return e;let i=r.machine;o({scope:l});try{let e=i===void 0?await wd(()=>Vn(t),()=>on(t),u):await wd(()=>In(t,i),()=>wr(t,i),u);if(e===xd||!u())return xd;if(!e.ok)return e}finally{o(null)}return Mo(t,n,r)},a);return d.ok?d.value??void 0:void 0}}}var xd=null,Sd=2e3,Cd=16*6e4;async function wd(e,t,n){let r=Date.now()+Cd,i=await e();for(;i.ok&&!i.there;){if(Date.now()>r)return{ok:!1,error:`The project is still being cloned. Send again in a few minutes.`};if(await new Promise(e=>setTimeout(e,Sd)),!n())return xd;i=await t()}return i.ok?{ok:!0}:i}function Td(e){let t=Ia().startFrom?.[e??``],n=xi(e?()=>t?qo(e,t):qo(e):null,null,15e3,[e,t?.kind,t?.kind===`published`?t.branch:void 0]),r=(0,J.useRef)({projectId:e,launcher:null});return n.loaded&&(r.current={projectId:e,launcher:n.value}),n.loaded||r.current.projectId!==e?n.value:r.current.launcher}function Ed(e){return e.filter(e=>e.waiting===void 0)}var Dd=`all`,Od=`settings`,kd=`item`;function Ad(e,t){let[n=``,r=``]=e.split(`?`),i=new URLSearchParams(r),a=i.get(Od),o=i.get(kd),s=a===null?{}:{settings:a,...o?{settingsItem:o}:{}},[c,...l]=n.split(`/`).filter(Boolean).map(Pd);if(c===`settings`)return{projectId:null,agentId:null,settings:a??l[0]??``};if(!c||c===`overview`)return{projectId:null,agentId:null,...s};let u=t.projectOf(c);if(u===void 0&&ve(c))return{projectId:null,agentId:null,page:c,pagePath:l,...s};let d=u??c,[f,...p]=l;return f===`overview`?{projectId:null,agentId:null,scope:d,...s}:f!==void 0&&ve(f)?{projectId:null,agentId:null,page:f,pagePath:p,scope:d,...s}:{projectId:d,agentId:f??null,...i.has(Dd)?{}:{scope:d},...s}}function jd(e,t){let n=!e.page&&e.projectId&&!e.scope?[Dd]:[],r=e.settings===void 0?[]:[`${Od}=${encodeURIComponent(e.settings)}`,...e.settingsItem?[`${kd}=${encodeURIComponent(e.settingsItem)}`]:[]],i=[...n,...r].join(`&`);return Nd(e,t)+(i?`?${i}`:``)}function Md(e,t){let[n=``,r=``]=e.split(`?`),i=new URLSearchParams(t);for(let e of[Dd,Od,kd,...new URLSearchParams(r).keys()])i.delete(e);let a=[i.toString(),r].filter(Boolean).join(`&`);return a?`${n}?${a}`:n}function Nd({projectId:e,agentId:t,page:n,pagePath:r,scope:i},a){let o=!n&&e?e:i,s=o?[a.addressOf(o)]:[],c=n?[n,...r??[]]:e?t?[t]:[]:o?[et]:[];return`/`+[...s,...c].map(encodeURIComponent).join(`/`)}function Pd(e){try{return decodeURIComponent(e)}catch{return e}}var Fd=new Set;function Id(){for(let e of Fd)e()}function Ld(e){return Fd.size===0&&window.addEventListener(`popstate`,Id),Fd.add(e),()=>{Fd.delete(e),Fd.size===0&&window.removeEventListener(`popstate`,Id)}}var Rd=()=>window.location.pathname+window.location.search;function zd(e){let t=(0,J.useSyncExternalStore)(Ld,Rd,()=>`/`);return{route:Ad(t,e),go:(n,r)=>{let i=r?.keepQuery?Md(jd(n,e),window.location.search):jd(n,e);i!==t&&(r?.replace?window.history.replaceState(null,``,i):window.history.pushState(null,``,i),Id())}}}function Bd(e,t){let n=new URL(window.location.href);n.searchParams.set(Od,e),t?n.searchParams.set(kd,t):n.searchParams.delete(kd),window.history.pushState(null,``,n.pathname+n.search),Id()}function Vd(){let[e,t]=(0,J.useState)(new Set);return{context:e,add:e=>t(t=>t.has(e)?t:new Set(t).add(e)),remove:e=>t(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),toggle:e=>t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),reset:()=>t(new Set)}}function Hd(e,t){let n=[...t];return n.length?`${e.trimEnd()}\n\nContext: ${n.join(`, `)}`:e}var Ud=`inline-flex h-7 min-w-0 max-w-full shrink items-center gap-1.5 overflow-hidden rounded-md px-2 text-[13px] font-normal text-muted-foreground max-sm:max-w-none max-sm:shrink-0`,Wd=q(Ud,`transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50`),Gd=`flex h-8 items-center gap-2`,Kd=`flex min-w-0 flex-1 items-center gap-0.5 max-sm:overflow-x-auto max-sm:[scrollbar-width:none] max-sm:[mask-image:linear-gradient(to_right,#000_85%,transparent)]`;function qd({children:e,end:t}){return(0,Y.jsxs)(`div`,{className:q(`mb-1`,Gd),children:[(0,Y.jsx)(`div`,{className:Kd,children:e}),t&&(0,Y.jsx)(`div`,{className:`shrink-0`,children:t})]})}function Jd({tip:e,children:t}){return(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(`span`,{className:`inline-flex min-w-0 max-w-full shrink max-sm:max-w-none max-sm:shrink-0`}),children:t}),(0,Y.jsx)(H,{children:e})]})}function Yd({icon:e,children:t}){return(0,Y.jsxs)(`span`,{className:Ud,children:[e,(0,Y.jsx)(`span`,{className:`truncate`,children:t})]})}var Xd={nothing:`Adds nothing to your message. The agent decides, and usually commits.`,commit:`It commits its work on its branch.`,branch:`It commits and pushes its branch.`,pr:`It commits, pushes its branch and opens a pull request.`,merge:`It commits, pushes its branch and opens a pull request set to merge once its checks pass.`};function Zd({publish:e,picks:t,onPublish:n,target:r,busy:i}){let a=e===`pr`||e===`merge`?r:void 0;return(0,Y.jsxs)(Mn,{children:[(0,Y.jsxs)(yi,{children:[(0,Y.jsxs)(pi,{render:(0,Y.jsx)(mt,{type:`button`,disabled:i,"aria-label":`Auto`,className:q(Wd,`max-w-[20rem]!`)}),children:[(0,Y.jsx)(`span`,{className:`truncate`,children:`Auto: ${Lt[e]}${a?` → ${a.into}`:``}`}),(0,Y.jsx)(ke,{className:`h-3 w-3 shrink-0 opacity-70`,"aria-hidden":!0})]}),(0,Y.jsx)(H,{children:`What the agent does by itself when it finishes.${a?` The pull request goes into ${a.into}.`:``}`})]}),(0,Y.jsxs)(hr,{className:`min-w-[19rem] max-w-[22rem]`,children:[(0,Y.jsxs)(Hn,{children:[(0,Y.jsx)(tn,{className:`font-normal`,children:`When the agent finishes`}),t.map(t=>(0,Y.jsxs)(K,{className:`items-start`,"aria-current":t===e,onClick:()=>n(t),children:[(0,Y.jsx)(Ir,{className:q(`mt-0.5 h-3.5 w-3.5 shrink-0`,t===e?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,Y.jsx)(Dt,{label:Lt[t],description:Xd[t]})]},t))]}),a?.picks&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ci,{}),(0,Y.jsxs)(Hn,{children:[(0,Y.jsx)(tn,{className:`font-normal`,children:`The pull request goes into`}),a.picks.map(e=>(0,Y.jsxs)(K,{"aria-current":e===a.into,onClick:()=>a.onPick?.(e),children:[(0,Y.jsx)(Ir,{className:q(`h-3.5 w-3.5 shrink-0`,e===a.into?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`truncate`,children:e})]},e))]})]})]})]})}function Qd({files:e,onRemove:t,busy:n}){return e.length===0?null:(0,Y.jsx)(`div`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>t(e),"aria-label":`Remove ${e} from context`,className:`flex h-3.5 w-3.5 items-center justify-center rounded text-muted-foreground hover:text-danger disabled:opacity-50`}),children:(0,Y.jsx)(Ai,{className:`h-3.5 w-3.5`})}),(0,Y.jsxs)(H,{children:[`Remove `,e]})]}),(0,Y.jsx)(`span`,{className:`truncate`,title:e,children:e})]},e))})}function $d({projectId:e,context:t,busy:n,onToggle:r}){let i=mn(zo,[],[]).filter(e=>e.machine===void 0),a=new Set(i.map(e=>e.path)),o=[...t].filter(e=>!a.has(e)),s=i.filter(t=>t.id!==e),c=s.filter(e=>t.has(e.path)).length;return(0,Y.jsx)(ef,{otherProjects:s,context:t,contextFiles:o,summary:[c>0?`${c} project${c>1?`s`:``}`:null,o.length>0?`${o.length} file${o.length>1?`s`:``}`:null].filter(Boolean).join(` · `),busy:n,onToggle:r})}function ef({otherProjects:e,context:t,contextFiles:n,summary:r,busy:i,onToggle:a}){return(0,Y.jsxs)(Mn,{children:[(0,Y.jsxs)(yi,{children:[(0,Y.jsxs)(pi,{render:(0,Y.jsx)(mt,{type:`button`,disabled:i,className:Wd}),children:[(0,Y.jsx)(Ec,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),`Context`,r&&(0,Y.jsxs)(`span`,{className:`text-primary`,children:[` · `,r]})]}),(0,Y.jsx)(H,{children:`Narrow the run to specific repos and files`})]}),(0,Y.jsxs)(hr,{align:`start`,className:`min-w-[18rem] max-w-[24rem]`,children:[(0,Y.jsxs)(Hn,{children:[(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(tn,{}),children:`Projects`}),(0,Y.jsx)(H,{className:`max-w-[22rem]`,children:`The agent can still reach every repo; ticking some just narrows its focus.`})]}),e.length>0?e.map(e=>(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(Ar,{checked:t.has(e.path),onCheckedChange:()=>a(e.path),disabled:i}),children:(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})}),(0,Y.jsx)(H,{children:e.path})]},e.id)):(0,Y.jsx)(`p`,{className:`px-2 py-1 text-xs text-muted-foreground/60`,children:`No other repos to add.`})]}),(0,Y.jsx)(ci,{}),(0,Y.jsxs)(Hn,{children:[(0,Y.jsx)(tn,{children:`Files`}),n.length>0?(0,Y.jsx)(`div`,{className:`px-2 py-1`,children:(0,Y.jsx)(Qd,{files:n,onRemove:a,busy:i})}):(0,Y.jsx)(`p`,{className:`px-2 py-1 text-xs text-muted-foreground/60`,children:`None yet — add with # or the Files pane.`})]})]})]})}function tf(e){this.content=e}tf.prototype={constructor:tf,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new tf(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new tf(n)},addToStart:function(e,t){return new tf([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new tf(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new tf(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=tf.from(e),e.size?new tf(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=tf.from(e),e.size?new tf(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=tf.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},tf.from=function(e){if(e instanceof tf)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new tf(t)};function nf(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&of(e.charCodeAt(r-1))&&af(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=nf(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function rf(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&of(e.charCodeAt(i-1))&&af(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=rf(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function af(e){return e>=56320&&e<57344}function of(e){return e>=55296&&e<56320}var X=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return nf(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return rf(this,e,t,n)}findIndex(e){if(e==0)return cf(0,e);if(e==this.size)return cf(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?cf(t+1,i):cf(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};X.empty=new X([],0);var sf={index:0,offset:0};function cf(e,t){return sf.index=e,sf.offset=t,sf}function lf(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!lf(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!lf(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var uf=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&lf(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};uf.none=[];var df=class extends Error{},Z=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=pf(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(ff(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(X.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};Z.empty=new Z(X.empty,0,0);function ff(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(ff(a.content,t-i-1,n-i-1)))}function pf(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=pf(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function mf(e,t,n){if(n.openStart>e.depth)throw new df(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new df(`Inconsistent open depths`);return hf(e,t,n,0)}function hf(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=hf(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return bf(a,Sf(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return bf(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Cf(n,e);return bf(a,xf(e,i,o,t,r))}}function gf(e,t){if(!t.type.compatibleContent(e.type))throw new df(`Cannot join `+t.type.name+` onto `+e.type.name)}function _f(e,t,n){let r=e.node(n);return gf(r,t.node(n)),r}function vf(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function yf(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(vf(e.nodeAfter,r),a++));for(let e=a;e<o;e++)vf(i.child(e),r);t&&t.depth==n&&t.textOffset&&vf(t.nodeBefore,r)}function bf(e,t){if(!e.type.validContent(t))throw new df(`Invalid content for node `+e.type.name);return e.copy(t)}function xf(e,t,n,r,i){let a=e.depth>i&&_f(e,t,i+1),o=r.depth>i&&_f(n,r,i+1),s=[];return yf(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(gf(a,o),vf(bf(a,xf(e,t,n,r,i+1)),s)):(a&&vf(bf(a,Sf(e,t,i+1)),s),yf(t,n,i,s),o&&vf(bf(o,Sf(n,r,i+1)),s)),yf(r,null,i,s),new X(s)}function Sf(e,t,n){let r=[];return yf(null,e,n,r),e.depth>n&&vf(bf(_f(e,t,n+1),Sf(e,t,n+1)),r),yf(t,null,n,r),new X(r)}function Cf(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(X.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var wf=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return uf.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Of(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Df.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Df.set(t,r=new Tf);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Ef,i}},Tf=class{constructor(){this.elts=[],this.i=0}},Ef=12,Df=new WeakMap,Of=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},kf=Object.create(null),Af=class e{constructor(e,t,n,r=uf.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||X.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&lf(this.attrs,t||e.defaultAttrs||kf)&&uf.sameSet(this.marks,n||uf.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Z.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new Z(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return mf(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return wf.resolveCached(this,e)}resolveNoCache(e){return wf.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Mf(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=X.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=uf.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!uf.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=X.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};Af.prototype.text=void 0;var jf=class e extends Af{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Mf(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Mf(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Nf=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Pf(t,n);if(r.next==null)return e.empty;let i=Ff(r);r.next&&r.err(`Unexpected trailing text`);let a=Gf(Hf(i));return Kf(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return X.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
8
+ `).trim()}}function _l(e){return cl(e.id)??e.startedAt}function vl(e){let t=new Map;for(let n of e){if(n.kind!==`driver`)continue;let e=n.event;if(e.type===`subagent`){let r=t.get(e.id),{type:i,...a}=e;t.set(e.id,{...a,calls:r?.calls??0,...r?.tool===void 0?{}:{tool:r.tool},...(r?.startedAt??n.at)===void 0?{}:{startedAt:r?.startedAt??n.at},...e.status!==`working`&&n.at!==void 0?{endedAt:n.at}:{}})}else if(e.type===`action`&&e.subagent!==void 0){let n=t.get(e.subagent);n&&t.set(e.subagent,{...n,calls:n.calls+1,tool:e.label})}}return[...t.values()]}function yl(e){let t=new Set,n=new Set(e.flatMap(e=>e.kind===`driver`&&e.event.type===`output`&&e.event.failed===!0&&e.event.id!==void 0?[e.event.id]:[])),r=new Set(e.flatMap(e=>e.kind===`driver`&&e.event.type===`action`&&e.event.subagent===void 0&&e.event.id!==void 0&&!n.has(e.event.id)&&Tl(e.event.whole??e.event.detail)?[e.event.id]:[]));for(let n of e)n.kind===`driver`&&n.event.type===`subagent`&&t.add(n.event.id);let i=new Set([...t].flatMap(e=>[e,e.split(`:`)[0]])),a=new Set;for(let t of e){if(t.kind!==`driver`)continue;let e=t.event;(e.type===`subagent`||(e.type===`action`||e.type===`output`||e.type===`text`||e.type===`thought`)&&e.subagent!==void 0||(e.type===`action`||e.type===`output`)&&e.id!==void 0&&(i.has(e.id)||r.has(e.id)))&&a.add(t)}return a}function bl(e,t){return e.filter(e=>e.kind===`driver`&&(e.event.type===`action`||e.event.type===`output`||e.event.type===`text`||e.event.type===`thought`)&&e.event.subagent===t)}function xl(e,t){let n=e.status===`running`;return{key:`run:${e.id}`,name:ul(e),...e.model===void 0?{}:{model:e.model},status:e.status,working:n,startedAt:_l(e),...e.endedAt===void 0?{}:{endedAt:e.endedAt},...n&&t?.tool!==void 0?{tool:t.tool}:{},...n&&t!==void 0?{calls:t.calls}:{},...n&&t?.doing!==void 0?{doing:t.doing}:{},...e.cost===void 0?{}:{cost:e.cost},...e.intent===void 0?{}:{prompt:e.intent},agent:e}}function Sl(e,t,n){let r=e.status===`working`&&t,i=e.status===`failed`?`failed`:e.status===`ended`?`done`:r?`running`:`stopped`;return{key:`call:${e.id}`,name:e.name??e.role??`Subagent`,...e.model===void 0?{}:{model:e.model},status:i,working:r,startedAt:e.startedAt??n,...e.endedAt===void 0?{}:{endedAt:e.endedAt},...r&&e.tool!==void 0?{tool:e.tool}:{},...r?{calls:e.calls}:{},...e.prompt===void 0?{}:{prompt:e.prompt},...e.tokens===void 0?{}:{tokens:e.tokens},...e.toolUses===void 0?{}:{toolUses:e.toolUses},call:e}}function Cl(e,t,n,r){let i=[];for(let t of e)i.push((i.at(-1)??0)+ +!!r(t));let a=(t,n)=>{let r=Date.parse(n),a=e.findIndex(e=>e.at!==void 0&&Date.parse(e.at)>r),o=a===-1?e.length:a;return{step:t,time:n,index:o,stretch:o>0?i[o-1]:0}},o=t.flatMap(e=>{let t=n.get(e.key);return[a({kind:`agent`,row:e},e.startedAt),...t!==void 0&&e.endedAt!==void 0?[a({kind:`message`,row:e,text:t},e.endedAt)]:[]]}).sort((e,t)=>e.index-t.index||(e.time<t.time?-1:1)),s=new Map,c=new Map;for(let{step:e,index:t,stretch:n}of o){let r=c.get(n)??t;c.set(n,r),s.set(r,[...s.get(r)??[],e])}return s}function wl(e){let t=e.filter(e=>e.kind===`agent`),n=e.length-t.length,r=t.filter(e=>e.row.status===`failed`).length,i=t.length===1?`ran an agent`:`ran ${t.length} agents`,a=n===1?`received a message`:`received ${n} messages`,o=[...t.length>0?[i]:[],...n>0?[a]:[]];e[0]?.kind===`message`&&o.reverse();let s=[...o,...r>0?[`${r} failed`]:[]].join(`, `);return s.charAt(0).toUpperCase()+s.slice(1)}function Tl(e){if(e===void 0)return!1;let t=e.split(/;|&&|\n/).map(e=>e.trim()).filter(Boolean),n=/^npx (?:-y )?@openagt\/skill-orchestration(?:@\S+)? (?:start|land|next|list|read)\b/;return t.some(e=>n.test(e))&&t.every(e=>n.test(e)||/^git (?:status|log|diff)\b/.test(e))}function El(e,t){return bl(e,t).flatMap(e=>e.kind===`driver`&&e.event.type===`text`?[e.event.text]:[]).at(-1)}function Dl(e){return e.replace(/^Its last words:\n/m,``).trim()}function Ol(e){let t=new Set,n=new Set(e.flatMap(e=>e.kind===`driver`&&e.event.type===`subagent`?[e.event.id,e.event.id.split(`:`)[0]]:[])),r=!1,i=!1,a;for(let o of e){if(o.kind!==`driver`)continue;let e=o.event;if(e.type===`start`){t.clear(),r=!1,i=!1,a=void 0;continue}if(e.type===`subagent`&&e.id!==void 0){e.status===`working`?t.has(e.id)||(t.size===0&&(i=!1),t.add(e.id),r=!0):(t.delete(e.id),r&&t.size===0?(a=o.at,r=!1,i=!1):r&&(i=!0));continue}e.subagent===void 0&&((e.type===`action`||e.type===`output`)&&e.id!==void 0&&n.has(e.id)||[`action`,`output`,`text`,`thought`,`thinking`,`partial`].includes(e.type)&&(r&&i&&(a=o.at),r=!1,i=!1,e.type===`text`&&t.size>0&&(r=!0)))}return{waiting:r&&t.size>0,...a===void 0?{}:{wokeAt:a}}}function kl(){let e=`rounded bg-muted px-1`;return(0,Y.jsxs)(`div`,{className:`space-y-1 text-xs text-muted-foreground`,children:[(0,Y.jsx)(`p`,{children:`Adding a project lets agents work in its folder. Adding it:`}),(0,Y.jsxs)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:[(0,Y.jsx)(`li`,{children:`makes no commit on your branch and pushes nothing`}),(0,Y.jsxs)(`li`,{children:[`lets OpenAgent keep its own files there, in hidden folders (`,(0,Y.jsx)(`code`,{className:e,children:`.openagent`}),`,`,` `,(0,Y.jsx)(`code`,{className:e,children:`.branches`}),`, `,(0,Y.jsx)(`code`,{className:e,children:`.agent-runner`}),`)`]}),(0,Y.jsxs)(`li`,{children:[`keeps the agents’ records in your own folder `,(0,Y.jsx)(`code`,{className:e,children:`~/.openagent`}),`, outside the project, unless you choose to share them`]}),(0,Y.jsxs)(`li`,{children:[`gives each agent four basic skills in its own copy, hidden from git: `,(0,Y.jsx)(`code`,{className:e,children:`branches`}),`,`,` `,(0,Y.jsx)(`code`,{className:e,children:`logs`}),`, `,(0,Y.jsx)(`code`,{className:e,children:`question`}),`, and `,(0,Y.jsx)(`code`,{className:e,children:`github`}),` when the project is on GitHub`]})]}),(0,Y.jsx)(`p`,{children:`Agents work in their own copies, on their own branches. Your files and your branch stay as they are.`}),(0,Y.jsx)(`p`,{className:`italic`,children:`A folder with no git, or a repository with no commit yet, gets one empty first commit.`})]})}function Al({folder:e,fromAddress:t=!1,onAdded:n,onClose:r}){let[i,a]=(0,J.useState)(e??null),[o,s]=(0,J.useState)(t),[c,l]=(0,J.useState)(``),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(!1),m=(0,J.useId)(),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null),{busy:y,error:b,reset:x,run:S}=Yn(),C=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=document.activeElement instanceof HTMLElement?document.activeElement:null;return()=>e?.focus()},[]);let w=async()=>{v(null);let e=await Go().catch(()=>({ok:!1,error:`Could not reach the daemon.`}));if(!e.ok){v(e.error);return}if(!e.path){r();return}x(),a(e.path)};(0,J.useEffect)(()=>{!e&&!t&&w()},[]),(0,J.useEffect)(()=>{if(!h)return;let e=setTimeout(r,h.noRemote||h.path?6e3:2500);return()=>clearTimeout(e)},[h]);let T=async e=>{e.preventDefault();let t=c.trim();if(y||!t)return;let n=await S(()=>Vo(t),`Could not reach the daemon.`);n.ok&&d({typed:t,address:n.value.address,path:n.value.path})},E=async()=>{if(y||!i&&!u)return;let e=await S(()=>u?Ho(u.typed,f):Bo(i,f),`Failed to add the project.`);e.ok&&(g({alreadyActivated:e.value.alreadyActivated,noRemote:e.value.noRemote===!0,...e.value.path?{path:e.value.path}:{}}),n())};return(0,Y.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-start justify-center bg-black/40 pt-24`,onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),r();return}if(e.key!==`Tab`||!C.current)return;let t=[...C.current.querySelectorAll(`button, input, [tabindex]:not([tabindex="-1"])`)].filter(e=>!e.hasAttribute(`disabled`)),n=t[0],i=t[t.length-1];!n||!i||(e.shiftKey&&document.activeElement===n?(e.preventDefault(),i.focus()):!e.shiftKey&&document.activeElement===i&&(e.preventDefault(),n.focus()))},children:[(0,Y.jsx)(`div`,{className:`absolute inset-0`,onClick:r}),(0,Y.jsx)(`div`,{ref:C,role:`dialog`,"aria-modal":`true`,"aria-label":`Add project`,className:`relative w-96 max-w-[90vw] rounded-lg border border-border bg-background p-4 shadow-lg`,children:h?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{role:`status`,className:`mb-3 text-sm font-medium`,children:h.alreadyActivated?`Already added`:`Project added`}),h.noRemote&&(0,Y.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:`This repository has no remote, so the agents’ records stay on this machine.`}),h.path&&(0,Y.jsxs)(`p`,{className:`mb-3 break-all text-xs text-muted-foreground`,children:[`It is in `,(0,Y.jsx)(`code`,{className:`rounded bg-muted px-1`,children:h.path}),`.`]}),(0,Y.jsx)(`div`,{className:`flex justify-end`,children:(0,Y.jsx)(V,{type:`button`,size:`sm`,autoFocus:!0,onClick:r,children:`Done`})})]}):o&&!u?(0,Y.jsxs)(`form`,{onSubmit:e=>void T(e),children:[(0,Y.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:`Add project from a GitHub address`}),_&&(0,Y.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:_}),(0,Y.jsx)(`label`,{className:`mb-1 block text-xs text-muted-foreground`,htmlFor:`add-project-address`,children:`The repository’s address. Any git host works.`}),(0,Y.jsx)(Hr,{id:`add-project-address`,autoFocus:!0,value:c,disabled:y,onChange:e=>l(e.target.value),placeholder:`github.com/you/project`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,className:`mb-2 h-8 bg-background px-2 font-mono text-xs`}),(0,Y.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:`It is cloned into the projects folder of this computer, with the logins this computer has.`}),b&&(0,Y.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:b}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:`Cancel`}),(0,Y.jsx)(V,{type:`submit`,size:`sm`,disabled:y||!c.trim(),children:`Next`})]})]}):_?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:`Add project`}),(0,Y.jsx)(`p`,{className:`mb-3 text-xs text-danger`,children:_}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[(0,Y.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:`Cancel`}),(0,Y.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>s(!0),children:`Add from a GitHub address`}),(0,Y.jsx)(V,{type:`button`,size:`sm`,onClick:()=>void w(),children:`Try again`})]})]}):i||u?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:`Do you trust this repository?`}),(0,Y.jsx)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:(0,Y.jsx)(`code`,{className:`rounded bg-muted px-1`,children:u?u.address:i})}),u&&(0,Y.jsxs)(`p`,{className:`mb-2 break-all text-xs text-muted-foreground`,children:[`It will be cloned to `,(0,Y.jsx)(`code`,{className:`rounded bg-muted px-1`,children:u.path}),`.`]}),(0,Y.jsx)(`p`,{className:`mb-3 text-xs text-muted-foreground`,children:`Adding it lets the agent read its files. Hidden instructions in an untrusted repo can hijack the agent (prompt injection), so only add repos you trust.`}),(0,Y.jsx)(`div`,{className:`mb-3`,children:(0,Y.jsx)(kl,{})}),(0,Y.jsxs)(`div`,{className:`mb-3 text-xs`,children:[(0,Y.jsx)(`p`,{id:m,className:`mb-1 font-medium text-foreground`,children:`The agents’ records (what you ask, what each agent answers)`}),(0,Y.jsxs)(ki,{"aria-labelledby":m,value:f?`share`:`keep`,disabled:y,onValueChange:e=>p(e===`share`),className:`gap-1.5`,children:[(0,Y.jsx)(kt,{value:`keep`,className:`flex-nowrap items-start text-xs [&>[data-slot=radio-group-item]]:mt-0.5`,children:(0,Y.jsxs)(`span`,{children:[`Keep them on this machine`,(0,Y.jsx)(`span`,{className:`block text-muted-foreground`,children:`Nothing is pushed.`})]})}),(0,Y.jsx)(kt,{value:`share`,className:`flex-nowrap items-start text-xs [&>[data-slot=radio-group-item]]:mt-0.5`,children:(0,Y.jsxs)(`span`,{children:[`Share them to the repository’s remote`,(0,Y.jsxs)(`span`,{className:`block text-muted-foreground`,children:[`Pushes a branch `,(0,Y.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`agent-data`}),` to origin, and keeps pushing as agents work.`]})]})})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:`You can change this later in the project’s menu.`})]}),b&&(0,Y.jsx)(`p`,{className:`mb-2 text-xs text-danger`,children:b}),(0,Y.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Y.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,disabled:y,onClick:()=>{x(),u?d(null):e?r():w()},children:u?`Change the address`:e?`Cancel`:`Choose again`}),(0,Y.jsx)(V,{type:`button`,size:`sm`,autoFocus:!0,disabled:y,onClick:()=>void E(),children:y?u?`Cloning…`:`Adding…`:u?`I trust it, clone and add it`:`I trust it, add it`})]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:`Add project`}),(0,Y.jsx)(`p`,{role:`status`,className:`mb-3 text-xs text-muted-foreground`,children:`Choose the repository's folder in the system dialog…`}),(0,Y.jsx)(`div`,{className:`flex justify-end`,children:(0,Y.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:r,children:`Cancel`})})]})})]})}var jl=new Map;function Ml(e={}){let{locale:t,...n}=e,r={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...n},i=`${He(t)}|${JSON.stringify(r)}`,a=jl.get(i);if(a)return a;let o=new Intl.Collator(t,r),s={contains(e,t,n){if(!t)return!0;let r=$n(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(o.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=$n(e,n);return o.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=$n(e,n),i=t.length;return r.length>=i&&o.compare(r.slice(r.length-i),t)===0}};return jl.set(i,s),s}var Nl=`⁠`;function Pl(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function Fl(e=!0){let t=p(),n=J.useRef(null);return J.useEffect(()=>{if(!e||nr)return;let r=n.current;if(r==null)return;let i=Pl(r);if(i==null)return;let a=i.data,o=`${a}${Nl}`;return i.nodeValue=o,t.start(200,()=>{i.nodeValue===o&&(i.nodeValue=a)}),()=>{t.clear(),i.nodeValue===o&&(i.nodeValue=a)}},[e,n,t]),n}function Il(e){switch(e){case`data-sync`:return`Not syncing with the remote`;case`provider`:return`Unsettled: which package provides the data`}}function Ll({errors:e}){return!e||e.length===0?null:(0,Y.jsx)(`div`,{className:`flex flex-col gap-2 border-b border-danger/30 bg-danger/10 px-4 py-3`,children:e.map(e=>(0,Y.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 text-sm`,children:[(0,Y.jsx)(Gc,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsxs)(`p`,{className:`font-medium text-danger`,children:[Il(e.code),(0,Y.jsxs)(`span`,{className:`font-normal text-muted-foreground`,children:[` · since `,xt(e.since)]})]}),(0,Y.jsx)(`p`,{className:`break-words text-muted-foreground`,children:e.message})]})]},e.code))})}function Rl({project:e}){return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:q(`h-2 w-2 shrink-0 rounded-full`,e.errors?.length?`bg-danger`:e.activated?`bg-primary`:`bg-muted-foreground`)})}function zl({name:e,label:t}){let n=t.endsWith(e)?t.slice(0,-e.length):``;return(0,Y.jsxs)(`span`,{className:`block truncate`,children:[n&&(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:n}),n?e:t]})}function Bl({machineId:e}){let t=Fs().find(t=>t.id===e);if(!t)return null;let n=_e[le(t).kind];return(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,Y.jsx)(n,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`truncate`,children:[`on `,Ct(t)]})]})}function Vl({projects:e,scope:t,pending:n=!1,onScope:r,onProjectAdded:i}){let[a,o]=(0,J.useState)(null),s=nl(),c=t===null?void 0:e.find(e=>e.id===t),l=c?s(c.id,c.name):`All projects`;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Mn,{children:[(0,Y.jsxs)(mt,{"aria-label":`Project: ${n?`loading`:l}`,className:`flex w-full items-center gap-2 rounded-md border border-sidebar-border bg-background px-2 py-1.5 text-sm font-medium transition-colors hover:bg-sidebar-accent/60`,children:[n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`h-2 w-2 shrink-0 rounded-full bg-muted`}),(0,Y.jsx)(`span`,{className:`flex-1`,children:(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`block h-3.5 w-24 animate-pulse rounded bg-muted`})})]}):(0,Y.jsxs)(Y.Fragment,{children:[c?(0,Y.jsx)(Rl,{project:c}):(0,Y.jsx)(Ec,{className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1 truncate text-left`,children:l})]}),(0,Y.jsx)(Xs,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0})]}),(0,Y.jsxs)(hr,{align:`start`,className:`w-[var(--anchor-width)]`,children:[(0,Y.jsxs)(K,{onClick:()=>r(null),children:[(0,Y.jsx)(Ec,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1`,children:`All projects`}),t===null&&(0,Y.jsx)(Ir,{className:`h-3.5 w-3.5 shrink-0`,"aria-label":`selected`})]}),e.length>0&&(0,Y.jsx)(ci,{}),e.map(e=>(0,Y.jsxs)(K,{onClick:()=>r(e.id),children:[(0,Y.jsx)(Rl,{project:e}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(zl,{name:e.name,label:s(e.id,e.name)}),e.machine!==void 0&&(0,Y.jsx)(Bl,{machineId:e.machine}),e.errors?.map(e=>(0,Y.jsx)(`span`,{title:e.message,className:`block truncate text-xs text-danger`,children:Il(e.code)},e.code)),!e.errors?.length&&!e.activated&&(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Not activated`}),!e.errors?.length&&e.activated&&e.local&&(0,Y.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.local===`no-remote`?`Local only, no remote`:`Records kept on this machine`})]}),e.id===t&&(0,Y.jsx)(Ir,{className:`h-3.5 w-3.5 shrink-0`,"aria-label":`selected`})]},e.id)),(0,Y.jsx)(ci,{}),(0,Y.jsxs)(K,{onClick:()=>o(`folder`),className:`text-muted-foreground`,children:[(0,Y.jsx)(Fc,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Add project`})]}),(0,Y.jsxs)(K,{onClick:()=>o(`address`),className:`text-muted-foreground`,children:[(0,Y.jsx)(Fc,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{children:`Add from a GitHub address`})]})]})]}),a&&(0,Y.jsx)(Al,{fromAddress:a===`address`,onAdded:()=>i?.(),onClose:()=>o(null)})]})}function Hl(e,t=!0){return e===`awaiting`?`Needs answer`:e===`uncommitted`?`Needs commit`:e===`unpushed`?t?`Needs PR`:`Needs push`:`Needs merge`}var Ul={awaiting:{Icon:ec,tone:`text-warning`},uncommitted:{Icon:cc,tone:`text-info`},unpushed:{Icon:hc,tone:`text-info`},pr:{Icon:yc,tone:`text-success`}};function Wl(e){return e.kind===`awaiting`?e.question:e.kind===`uncommitted`?e.files?e.files===1?`1 file`:`${e.files} files`:void 0:e.kind===`unpushed`?e.commits?e.commits===1?`1 commit`:`${e.commits} commits`:void 0:`#${e.number}`}function Gl(e){return e.kind===`awaiting`?`Open the agent to answer`:e.kind===`uncommitted`?`Open the session: it left files uncommitted`:e.kind===`unpushed`?`Open the session: work on ${e.branch??``} is not published`:e.agentId?`Open the session of PR #${e.number}`:`Open PR #${e.number}`}function Kl({items:e,onOpenAgent:t,onOpenProject:n,grouped:r=!1}){let[i,a]=(0,J.useState)(!1),o=i?e:e.slice(0,5),s=e.length-5,c=new Set(e.map(e=>e.projectId)).size>1;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`ul`,{children:o.map(e=>{let{Icon:i,tone:a}=Ul[e.kind],o=Wl(e),s=er(e.createdAt,``),l=(0,Y.jsxs)(Y.Fragment,{children:[r?(0,Y.jsx)(`span`,{title:Hl(e.kind,e.gitHost),className:q(`flex size-4 shrink-0 items-center justify-center`,a),children:(0,Y.jsx)(i,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}):(0,Y.jsxs)(`span`,{className:q(`flex w-28 shrink-0 items-center gap-1.5 text-xs max-md:w-auto max-md:flex-1`,a),children:[(0,Y.jsx)(i,{className:`h-3.5 w-3.5 shrink-0`}),Hl(e.kind,e.gitHost)]}),(0,Y.jsx)(`span`,{className:q(`min-w-0 shrink truncate text-foreground md:max-w-[50%]`,r?`max-md:flex-1`:`max-md:order-1 max-md:basis-full`),children:e.title}),(0,Y.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground md:flex-auto max-md:order-2 max-md:basis-full`,children:o}),e.computer&&(0,Y.jsx)(ut,{computer:e.computer,named:!1}),c&&(0,Y.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:e.projectName}),(0,Y.jsx)(`span`,{className:`min-w-14 shrink-0 text-right text-xs tabular-nums text-muted-foreground`,children:s}),(0,Y.jsx)(Ce,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}),u=`flex w-full items-center overflow-hidden whitespace-nowrap rounded-md px-2 py-1.5 text-left text-sm hover:bg-accent/40 md:gap-3 max-md:flex-wrap max-md:gap-x-3 max-md:gap-y-0.5`;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:e.kind===`pr`&&!e.agentId?(0,Y.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,className:u}):(0,Y.jsx)(`button`,{type:`button`,onClick:()=>e.agentId?t(e.projectId,e.agentId):n?.(e.projectId),className:u}),children:l}),(0,Y.jsx)(H,{children:e.computer?`${Gl(e)} · runs on ${e.computer.name}`:Gl(e)})]})},ra(e))})}),s>0&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>a(!i),className:`mt-1 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:i?`Show fewer`:`Show ${s} more`})]})}var ql=[`#e69875`,`#dbbc7f`,`#a7c080`,`#7fbbb3`,`#d699b6`,`#e67e80`],Jl=[{d:`M-160 -166.3 A10 10 0 0 0 -175 -174.9 L-234 -140.9 A10 10 0 0 0 -239 -132.2 L-239 34.1 A10 10 0 0 0 -234 42.7 L-72 136.3 A10 10 0 0 0 -62 136.3 L-21 112.6 A10 10 0 0 0 -21 95.3 L-173 7.5 A10 10 0 0 1 -178 -1.2 L-178 -97 A10 10 0 0 1 -173 -105.7 L-165 -110.3 A10 10 0 0 0 -160 -118.9 Z`,axis:[-160,-148.4,-36.5,121.5]},{d:`M64 -221.7 A10 10 0 0 0 64 -239 L5 -273.1 A10 10 0 0 0 -5 -273.1 L-149 -189.9 A10 10 0 0 0 -154 -181.3 L-154 5.8 A10 10 0 0 0 -149 14.4 L-108 38.1 A10 10 0 0 0 -93 29.4 L-93 -146.1 A10 10 0 0 1 -88 -154.7 L-5 -202.6 A10 10 0 0 1 5 -202.6 L13 -198 A10 10 0 0 0 23 -198 Z`,axis:[48.5,-212.8,-123.5,29.2]},{d:`M224 -55.4 A10 10 0 0 0 239 -64.1 L239 -132.2 A10 10 0 0 0 234 -140.9 L90 -224 A10 10 0 0 0 80 -224 L-82 -130.5 A10 10 0 0 0 -87 -121.8 L-87 -74.5 A10 10 0 0 0 -72 -65.8 L80 -153.6 A10 10 0 0 1 90 -153.6 L173 -105.7 A10 10 0 0 1 178 -97 L178 -87.8 A10 10 0 0 0 183 -79.1 Z`,axis:[208.5,-64.4,-87,-92.4]},{d:`M160 166.3 A10 10 0 0 0 175 174.9 L234 140.9 A10 10 0 0 0 239 132.2 L239 -34.1 A10 10 0 0 0 234 -42.7 L72 -136.3 A10 10 0 0 0 62 -136.3 L21 -112.6 A10 10 0 0 0 21 -95.3 L173 -7.5 A10 10 0 0 1 178 1.2 L178 97 A10 10 0 0 1 173 105.7 L165 110.3 A10 10 0 0 0 160 118.9 Z`,axis:[160,148.4,36.5,-121.5]},{d:`M-64 221.7 A10 10 0 0 0 -64 239 L-5 273.1 A10 10 0 0 0 5 273.1 L149 189.9 A10 10 0 0 0 154 181.3 L154 -5.8 A10 10 0 0 0 149 -14.4 L108 -38.1 A10 10 0 0 0 93 -29.4 L93 146.1 A10 10 0 0 1 88 154.7 L5 202.6 A10 10 0 0 1 -5 202.6 L-13 198 A10 10 0 0 0 -23 198 Z`,axis:[-48.5,212.8,123.5,-29.2]},{d:`M-224 55.4 A10 10 0 0 0 -239 64.1 L-239 132.2 A10 10 0 0 0 -234 140.9 L-90 224 A10 10 0 0 0 -80 224 L82 130.5 A10 10 0 0 0 87 121.8 L87 74.5 A10 10 0 0 0 72 65.8 L-80 153.6 A10 10 0 0 1 -90 153.6 L-173 105.7 A10 10 0 0 1 -178 97 L-178 87.8 A10 10 0 0 0 -183 79.1 Z`,axis:[-208.5,64.4,87,92.4]}];function Yl(e){return e?`AI is working for you 🚀`:`AI isn't working for you 💤`}function Xl(e){return e?`AI is working for you`:`AI isn't working for you`}function Zl(e){return ql[(e%ql.length+ql.length)%ql.length]}function Ql(e){return ql.map((t,n)=>Zl(e+n)).concat(Zl(e)).join(`;`)}function $l({className:e,working:t=!1}){let n=Yl(t);return(0,Y.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`-289 -326 578 651.9`,className:e,role:`img`,"aria-label":Xl(t),children:[(0,Y.jsx)(`title`,{children:n}),t&&(0,Y.jsx)(`defs`,{children:Jl.map(({axis:[e,t,n,r]},i)=>(0,Y.jsxs)(`linearGradient`,{id:`hexknot-${i}`,gradientUnits:`userSpaceOnUse`,x1:e,y1:t,x2:n,y2:r,children:[(0,Y.jsx)(`stop`,{offset:`0`,stopColor:Zl(i),children:(0,Y.jsx)(`animate`,{attributeName:`stop-color`,dur:`6s`,repeatCount:`indefinite`,values:Ql(i)})}),(0,Y.jsx)(`stop`,{offset:`1`,stopColor:Zl(i-1),children:(0,Y.jsx)(`animate`,{attributeName:`stop-color`,dur:`6s`,repeatCount:`indefinite`,values:Ql(i-1)})})]},i))}),Jl.map(({d:e},n)=>(0,Y.jsx)(`path`,{fill:t?`url(#hexknot-${n})`:`var(--logo-${n+1})`,d:e},n))]})}function eu({working:e,href:t=`/`,onNavigate:n}){return(0,Y.jsxs)(`a`,{href:t,onClick:e=>{e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0||(e.preventDefault(),n())},className:`flex shrink-0 items-center gap-3 rounded-md [view-transition-name:oa-brand] transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-primary)]`,children:[(0,Y.jsx)($l,{className:`h-6 w-auto shrink-0`,working:e}),(0,Y.jsx)(`span`,{className:`shrink-0 font-['IBM_Plex_Sans',ui-sans-serif,sans-serif] text-[17px] leading-6 font-medium max-sm:hidden`,children:`OpenAgent`})]})}function tu(){return document.cookie.split(`;`).some(e=>e.trim().startsWith(`openagent-view=`))}function nu(){if(!tu())return null;let e=`relative flex h-6 items-center justify-center rounded-md font-['IBM_Plex_Sans',ui-sans-serif,sans-serif] text-xs font-medium whitespace-nowrap`;return(0,Y.jsxs)(`div`,{className:`relative inline-flex gap-0.5 self-start rounded-lg border border-sidebar-border p-0.5 [view-transition-name:oa-toggle]`,children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`absolute top-0.5 left-[calc(0.125rem+96px+0.125rem)] h-6 w-[84px] rounded-md bg-primary [view-transition-name:oa-toggle-thumb]`}),(0,Y.jsxs)(`span`,{className:`relative inline-flex gap-0.5 [view-transition-name:oa-toggle-labels]`,children:[(0,Y.jsx)(`a`,{href:`/_view/landing`,className:q(e,`w-[96px] text-muted-foreground transition-colors hover:text-foreground`),children:`Landing page`}),(0,Y.jsx)(`span`,{"aria-current":`page`,className:q(e,`w-[84px] text-primary-foreground`),children:`Dashboard`})]})]})}var ru=U(`onPerson`),iu=[{value:`system`,label:`System`,icon:jc},{value:`light`,label:`Light`,icon:Uc},{value:`dark`,label:`Dark`,icon:Mc}];function au(){let e=Ra(Ia()),t=iu.find(t=>t.value===e)??iu[0],n=t.icon;return(0,Y.jsxs)(Ti,{children:[(0,Y.jsxs)(bi,{children:[(0,Y.jsx)(n,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1`,children:`Theme`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:t.label})]}),(0,Y.jsx)(pn,{children:iu.map(t=>{let n=t.icon;return(0,Y.jsxs)(K,{closeOnClick:!1,onClick:()=>Na({theme:t.value}),children:[(0,Y.jsx)(Ir,{className:q(`h-3.5 w-3.5 shrink-0`,t.value===e?`opacity-100`:`opacity-0`)}),(0,Y.jsx)(n,{className:`h-3.5 w-3.5 shrink-0 opacity-70`}),t.label]},t.value)})})]})}function ou(){return(0,J.useSyncExternalStore)(su,()=>typeof Notification>`u`?`unsupported`:Notification.permission,()=>`unsupported`)}function su(e){let t=setInterval(e,3e3);return()=>clearInterval(t)}function cu(){let e=Ia(),t=Ba(e),n=Va(e),r=Ha(e),i=ou(),a=i!==`unsupported`,o=i===`denied`,s=t&&i===`granted`;return(0,Y.jsxs)(Ti,{children:[(0,Y.jsxs)(bi,{children:[s?(0,Y.jsx)(Ks,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0}):(0,Y.jsx)(Gs,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1`,children:`Notifications`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:s?`On`:`Off`})]}),(0,Y.jsxs)(pn,{className:`min-w-[16rem]`,children:[a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(Hn,{children:[(0,Y.jsx)(tn,{children:`Deliver to`}),(0,Y.jsx)(Ar,{checked:t,disabled:o,onCheckedChange:e=>{Na({notifyBrowser:e}),e&&i==="default"&&Notification.requestPermission()},className:`items-start`,children:(0,Y.jsx)(Dt,{label:`Browser`,description:o?`Blocked in your browser settings`:t&&i==="default"?`Click to allow browser notifications`:`Desktop notifications while the dashboard is open`})})]}),(0,Y.jsx)(ci,{})]}),(0,Y.jsxs)(Hn,{children:[(0,Y.jsx)(tn,{children:`Notify me about`}),(0,Y.jsx)(Ar,{checked:r,onCheckedChange:e=>Na({notifyHumanIntervention:e}),className:`items-start`,children:(0,Y.jsx)(Dt,{label:`Human Queue`,description:`An agent awaiting you, or a PR to review`})}),(0,Y.jsx)(Ar,{checked:n,onCheckedChange:e=>Na({notifyNewActivity:e}),className:`items-start`,children:(0,Y.jsx)(Dt,{label:`New activity`,description:`An agent started or finished`})})]})]})]})}var lu=U(`onGitHosts`),uu=U(`sendUseGitHostAccount`),du=U(`sendForgetGitHostAccount`),fu=U(`sendGitHostLogin`),pu=U(`sendGitHostInstall`),mu=U(`onAgentState`),hu=U(`sendAgentFix`),gu=U(`onProjectAccounts`),_u=U(`sendProjectAccounts`),vu=`accounts`,yu=2e3,bu=8e3,xu=3e4;function Su(e,t,n,r){let[i,a]=(0,J.useState)(xu),{value:o,reload:s}=xi(t,void 0,i,[...r,i],{remember:e}),c=n(o);return(0,J.useEffect)(()=>{c!==i&&a(c)},[c,i]),{value:o,reload:s}}function Cu(e,t=!0){let{value:n,reload:r}=Su(`agent-state:${e??``}`,t?()=>mu(e):null,e=>e?.fixing?yu:e&&!e.ready?bu:xu,[e,t]);return{state:n,reload:r}}function wu(){let{value:e,reload:t}=Su(`git-hosts`,lu,e=>e?.hosts.some(e=>e.provider?.installing||e.provider?.loggingIn)?yu:e?.hosts.some(e=>Eu(e)===`step`||Eu(e)===`not-installed`)?bu:xu,[]);return{view:e,reload:t}}function Tu(e){if(e)return e.ready?`connected`:e.fix?.kind===`install`||/ not found/.test(e.problem??``)?`not-installed`:`step`}function Eu(e){let t=e.provider;if(t)return t.installed?t.accounts.length>0&&t.accounts.every(e=>e.ok)?`connected`:`step`:`not-installed`}var Du={step:{words:`Log in`,tone:`bg-warning/10 text-warning`,dot:`bg-warning`},"not-installed":{words:`Not installed`,tone:`bg-muted text-muted-foreground`,dot:`bg-muted-foreground`}};function Ou({words:e,tone:t,dot:n}){return(0,Y.jsxs)(`span`,{className:q(`inline-flex shrink-0 items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium`,t),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:q(`size-1.5 rounded-full`,n)}),e]})}function ku({state:e}){return e===`connected`?null:(0,Y.jsx)(Ou,{...Du[e]})}function Au({svg:e,className:t}){if(!e)return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:q(`size-4 shrink-0 rounded-sm bg-muted-foreground/30`,t)});let n=`url("data:image/svg+xml;utf8,${encodeURIComponent(e)}")`;return(0,Y.jsx)(`span`,{"aria-hidden":!0,className:q(`size-4 shrink-0 bg-current`,t),style:{maskImage:n,WebkitMaskImage:n,maskSize:`contain`,WebkitMaskSize:`contain`,maskRepeat:`no-repeat`,WebkitMaskRepeat:`no-repeat`}})}var ju=72;function Mu({command:e}){let[t,n]=(0,J.useState)(!1),r=e.length>ju;return(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-start gap-1`,children:[(0,Y.jsx)(`code`,{className:q(`min-w-0 flex-1 font-mono text-[11px] text-muted-foreground`,r&&!t?`truncate`:`break-all`),children:e}),r&&(0,Y.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline`,onClick:()=>n(!t),children:t?`Less`:`Show all`}),(0,Y.jsx)(pe,{text:e,label:`Copy the command`})]})}function Nu(e){let t=$r[e.driver];return Tu(e)===`not-installed`?`${t} is not installed.`:/ logged in/.test(e.problem??``)?`${t} is not logged in.`:e.problem??`${t} cannot start.`}function Pu(e){let t=e.provider;return t.installed?t.accounts.length===0?`No ${t.name} account is logged in.`:`${t.name} no longer takes a login: add it again.`:`${t.tool}, the tool for ${t.name}, is not installed.`}function Fu({label:e,busy:t,busyWords:n,command:r,failed:i,onPress:a,size:o=`sm`}){return(0,Y.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[t?(0,Y.jsx)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:n}):(0,Y.jsx)(V,{size:o,onClick:a,children:e}),r&&(0,Y.jsx)(Mu,{command:r}),i&&(0,Y.jsx)(`p`,{role:`alert`,className:`whitespace-pre-line text-xs text-danger`,children:i})]})}function Iu(e){let t=$r[e.driver];return e.fixing===`install`?`Installing ${t}…`:`Say yes in the page this computer's browser opened to log ${t} in.`}function Lu({state:e,onChanged:t,size:n}){let[r,i]=(0,J.useState)();if(e.ready||!e.fix)return null;let a=$r[e.driver],o=async()=>{i(void 0);let n=await hu(e.driver);n.ok||i(n.error),t()};return(0,Y.jsx)(Fu,{size:n,label:e.fix.kind===`install`?`Install ${a}`:`Log in to ${a}`,busy:e.fixing!==void 0,busyWords:Iu(e),command:e.fix.command,...(r??e.failed)===void 0?{}:{failed:r??e.failed},onPress:()=>void o()})}function Ru({code:e,url:t}){return(0,Y.jsxs)(`div`,{role:`status`,className:`space-y-1.5 text-xs`,children:[(0,Y.jsx)(`p`,{className:`text-muted-foreground`,children:`Type this code at the page below, signed in to the account to add:`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`code`,{className:`rounded bg-muted px-2 py-1 font-mono text-sm font-medium tracking-wider`,children:e}),(0,Y.jsx)(pe,{text:e,label:`Copy the code`}),(0,Y.jsx)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`text-[var(--color-primary)] underline-offset-2 hover:underline`,children:t.replace(/^https:\/\//,``)})]})]})}function zu(e){let[t,n]=(0,J.useState)(),[r,i]=(0,J.useState)(!1);return{start:async t=>{i(!0),n(void 0);try{let r=await fu(t);r.ok||n(r.error),await e()}finally{i(!1)}},error:t,busy:r}}function Bu({row:e,onChanged:t,size:n}){let[r,i]=(0,J.useState)(),a=zu(t),o=e.provider;if(!o)return null;if(!o.installed){if(!o.install)return(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Install ${o.tool} by hand: ${o.name} makes none for this computer.`});let a=async()=>{i(void 0);let n=await pu(e.host);n.ok||i(n.error),await t()};return(0,Y.jsx)(Fu,{size:n,label:`Install ${o.tool}`,busy:o.installing===!0,busyWords:`Installing ${o.tool}…`,command:o.install,...(r??o.installFailed)===void 0?{}:{failed:r??o.installFailed},onPress:()=>void a()})}return o.loggingIn?(0,Y.jsx)(Ru,{code:o.loggingIn.code,url:o.loggingIn.url}):o.accounts.length>0?null:(0,Y.jsx)(Fu,{size:n,label:`Log in to ${o.name}`,busy:a.busy,busyWords:`Asking for a code…`,...a.error===void 0?{}:{failed:a.error},onPress:()=>void a.start(e.host)})}function Vu(){let{state:e,reload:t}=Cu(),{view:n,reload:r}=wu(),i=async()=>{await Promise.all([t(),r()])},a=[];if(e&&!e.ready){let n=$r[e.driver];a.push({key:`agent`,name:n,words:Nu(e),entry:vu,fix:(0,Y.jsx)(Lu,{state:e,onChanged:()=>void t()})})}for(let e of n?.hosts??[]){let t=e.provider;!t||Eu(e)===`connected`||a.push({key:`host:${e.host}`,name:t.name,words:Pu(e),entry:vu,fix:(0,Y.jsx)(Bu,{row:e,onChanged:r})})}return{missing:a,reload:i,hosts:n}}function Hu(e){return e.trim().split(/\s+/)[0]??e}function Uu(e){let t=e.trim().split(/\s+/).filter(Boolean);return(t.length>1?`${t[0][0]}${t.at(-1)[0]}`:t[0]?.[0]??`?`).toUpperCase()}function Wu({person:e,dot:t}){let[n,r]=(0,J.useState)(!1),i=e?.avatar&&!n?e.avatar:void 0;return(0,Y.jsxs)(`span`,{"aria-hidden":!0,className:`relative shrink-0`,children:[(0,Y.jsx)(`span`,{className:`flex h-6 w-6 items-center justify-center overflow-hidden rounded-full bg-muted text-[10px] font-medium text-muted-foreground`,children:i?(0,Y.jsx)(`img`,{src:i,alt:``,referrerPolicy:`no-referrer`,className:`h-full w-full object-cover`,onError:()=>r(!0)}):e?Uu(e.name):null}),t&&(0,Y.jsx)(`span`,{"data-testid":`missing-dot`,className:`absolute -top-0.5 -right-0.5 size-2 rounded-full bg-warning ring-2 ring-sidebar`})]})}function Gu({onSettings:e}){let t=mn(()=>ru().catch(()=>null),null,[],{remember:`person`}),{missing:n}=Vu();return(0,Y.jsxs)(Mn,{children:[(0,Y.jsxs)(mt,{"aria-label":`${t?`${t.name}: settings`:`Settings`}${n.length>0?`, something is missing`:``}`,className:`flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left text-sm outline-none hover:bg-sidebar-accent focus-visible:ring-2 focus-visible:ring-sidebar-ring data-[popup-open]:bg-sidebar-accent`,children:[(0,Y.jsx)(Wu,{person:t,dot:n.length>0}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t?Hu(t.name):``}),(0,Y.jsx)(zc,{className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}),(0,Y.jsxs)(hr,{align:`start`,className:`min-w-[14rem]`,children:[t&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Hn,{children:(0,Y.jsxs)(tn,{className:`flex flex-col`,children:[(0,Y.jsx)(`span`,{className:`truncate text-foreground`,children:t.name}),t.login&&(0,Y.jsxs)(`span`,{className:`truncate font-normal`,children:[`@`,t.login]})]})}),(0,Y.jsx)(ci,{})]}),n.length>0&&(0,Y.jsxs)(Y.Fragment,{children:[n.map(t=>(0,Y.jsxs)(K,{onClick:()=>e(t.entry),className:`text-warning`,children:[(0,Y.jsx)(Zs,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:t.words})]},t.key)),(0,Y.jsx)(ci,{})]}),(0,Y.jsx)(au,{}),(0,Y.jsx)(cu,{}),(0,Y.jsx)(ci,{}),(0,Y.jsxs)(K,{onClick:()=>e(),children:[(0,Y.jsx)(zc,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0}),`Settings`]})]})]})}var Ku=`oa.sidebar-width`,qu=new Set,Ju=e=>Math.round(Math.min(448,Math.max(224,e)));function Yu(){try{let e=Number(localStorage.getItem(Ku));return Number.isFinite(e)&&e>0?Ju(e):256}catch{return 256}}var Xu=Yu();function Zu(e){Xu=e===void 0?256:Ju(e);try{e===void 0?localStorage.removeItem(Ku):localStorage.setItem(Ku,String(Xu))}catch{}for(let e of qu)e()}function Qu(){return(0,J.useSyncExternalStore)(e=>(qu.add(e),()=>qu.delete(e)),()=>Xu)}var $u=`oa.sidebar-hidden`;function ed(){try{return localStorage.getItem($u)===`true`}catch{return!1}}var td=ed();function nd(e){td=e;try{e?localStorage.setItem($u,`true`):localStorage.removeItem($u)}catch{}for(let e of qu)e()}function rd(){return(0,J.useSyncExternalStore)(e=>(qu.add(e),()=>qu.delete(e)),()=>td)}var id=16;function ad(){let e=Qu(),t=(0,J.useRef)(null);return(0,Y.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`The width of the sidebar`,"aria-valuenow":e,"aria-valuemin":224,"aria-valuemax":448,tabIndex:0,onPointerDown:n=>{n.preventDefault(),n.currentTarget.setPointerCapture(n.pointerId),t.current={x:n.clientX,width:e}},onPointerMove:e=>{t.current&&Zu(t.current.width+e.clientX-t.current.x)},onPointerUp:()=>t.current=null,onPointerCancel:()=>t.current=null,onDoubleClick:()=>Zu(void 0),onKeyDown:t=>{t.key===`ArrowLeft`||t.key===`ArrowRight`?(t.preventDefault(),Zu(e+(t.key===`ArrowRight`?id:-16))):t.key===`Enter`&&e!==256&&Zu(void 0)},className:`group/edge absolute inset-y-0 -right-1 z-20 flex w-2 cursor-col-resize touch-none justify-center outline-none`,children:(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-[3px] bg-transparent transition-colors group-hover/edge:bg-primary group-focus-visible/edge:bg-primary group-active/edge:bg-primary`})})}function od(e,t){return`agent-log:${e}:${t}`}function sd(e,t){Ei(od(e,t),()=>no(e,t))}function cd(e,t){return e===null||t.status===`running`?{}:{onNear:()=>sd(e,t.id)}}function ld({pageScrolls:e=!1,projectId:t,scope:n=null,scopePending:r=!1,listLoaded:i=!0,onScope:a=()=>{},homeHref:o=`/`,agents:s,selectedAgentId:c,onSelect:l,recentAgents:u,onSelectRecent:d,projects:f=[],onNewAgentInProject:p,onProjectAdded:m,startTick:h=0,startIntent:g=``,startTitle:_,startId:v=null,startProjectName:y,working:b=!1,onDashboard:x=()=>{},onSettings:C=()=>{},pages:w=[],activePage:T=null,onPage:E=()=>{},interventionCount:D=0}){let{isMobile:O,open:k,setOpenMobile:A}=En(),j=e=>(...t)=>{A(!1),e(...t)},N=Ia(),P=nl(),[F,ee]=(0,J.useState)(null);(0,J.useEffect)(()=>{h>0&&ee({intent:g,id:v})},[h]);let te=n===null&&u!==void 0,I=te?u.map(e=>e.agent):s,L=I.some(e=>e.status===`running`),R=F!==null&&I.some(e=>e.id===F.id);(0,J.useEffect)(()=>{R&&ee(null)},[R]),(0,J.useEffect)(()=>{ee(null)},[n]),(0,J.useEffect)(()=>{if(F===null||L)return;let e=setTimeout(()=>ee(null),2e4);return()=>clearTimeout(e)},[F,L]);let ne=F!==null&&!L&&!R,re=c!==null&&!I.some(e=>e.id===c),ie=N.recentsSort??`created`,ae=Zc(te?u.map(e=>({key:`${e.projectId}:${e.agent.id}`,agent:e.agent,project:P(e.projectId,e.projectName),projectId:e.projectId,active:e.projectId===t&&e.agent.id===c,onClick:()=>d?.(e.projectId,e.agent.id),...cd(e.projectId,e.agent)})):s.map(e=>({key:e.id,agent:e,projectId:t,active:e.id===c,onClick:()=>l(e.id),...cd(t,e)})),ie),z=t!==null&&c===null,oe=ml(ae),[B,ce]=(0,J.useState)({}),le=ae.length>0||ne,ue=e=>e.projectId??n,de=ji(ae.map(e=>({projectId:ue(e),person:e.agent.person})),Zo,`sidebar:people`),fe=Nn(),pe=(e,t,n=e.agent.status,r)=>(0,Y.jsx)(hd,{status:n,fold:r,saving:e.agent.saving===!0&&n===e.agent.status,intent:t?ul(e.agent):Jc(e.agent),naming:!t&&Yc(e.agent,N.nameRuns!==!1),driver:e.agent.driver,...e.agent.person&&!t?{person:e.agent.person,account:de(ue(e),e.agent.person)}:{},...e.agent.model?{model:ur(fe?.[xr(e.agent.driver)??`claude-code`],e.agent.model)}:{},...e.project&&!t?{project:e.project}:{},subtitle:er(e.agent.startedAt),active:e.active,remote:e.agent.target===`remote`,cloud:e.agent.target===`web`,...e.agent.otherHost&&e.agent.host?{startedOn:e.agent.host}:{},cloudState:sa(e.agent,Date.now()),...e.agent.remoteLabel?{remoteLabel:e.agent.remoteLabel}:{},...e.agent.remoteKind?{remoteKind:e.agent.remoteKind}:{},seenAt:e.agent.seenAt,...e.agent.pr?{pr:{number:e.agent.pr.number,...e.agent.prState?{state:e.agent.prState}:{}}}:{},...e.agent.unpublished?{unpublished:e.agent.unpublished}:{},...e.agent.uncommitted?{uncommitted:e.agent.uncommitted}:{},gitHost:f.find(t=>t.id===e.projectId)?.gitHost!==!1,onClick:j(e.onClick),onNear:e.onNear});if(!O&&!k)return null;let me=e&&!O;return(0,Y.jsxs)(Y.Fragment,{children:[me&&(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`w-(--sidebar-width) shrink-0`}),(0,Y.jsxs)(Ft,{collapsible:O?`offcanvas`:`none`,className:q(`relative w-(--sidebar-width) border-r border-sidebar-border`,me&&`fixed top-(--top-banner,0px) left-0 z-20 h-[calc(100dvh-var(--top-banner,0px))]`),children:[(0,Y.jsxs)(Vt,{className:`gap-4 pb-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-1 pt-1`,children:[(0,Y.jsx)(eu,{working:b,href:o,onNavigate:j(x)}),(0,Y.jsx)(S,{})]}),(0,Y.jsx)(nu,{}),(0,Y.jsx)(Vl,{projects:f,scope:n,pending:r,onScope:a,onProjectAdded:m})]}),(0,Y.jsxs)(Vt,{className:`gap-0.5 pt-0! pb-2`,children:[(0,Y.jsx)(fd,{scope:n,projects:f,active:z,onNewAgentInProject:p&&j(p),onSelect:j(l),onProjectAdded:m}),(0,Y.jsx)(dd,{active:t===null&&T===null,count:D,onClick:j(x)}),w.map(e=>(0,Y.jsx)(ud,{icon:e.icon??qs,label:e.label,active:T===e.segment,onClick:j(()=>E(e.segment))},e.segment))]}),(0,Y.jsx)(se,{className:`overflow-hidden`,children:(0,Y.jsx)(M,{className:`min-h-0 flex-1`,children:(0,Y.jsxs)(Lr,{className:`pt-3 pr-3`,children:[(0,Y.jsxs)(`div`,{className:`sticky top-0 z-10`,children:[(0,Y.jsxs)(Kt,{className:`rounded-none bg-sidebar font-normal tracking-wide text-muted-foreground`,children:[`Recent agents`,(0,Y.jsx)(pd,{order:ie})]}),(0,Y.jsx)(`div`,{"aria-hidden":!0,className:`rail-fade pointer-events-none absolute inset-x-0 top-full h-4 bg-gradient-to-b from-sidebar to-transparent`})]}),(0,Y.jsxs)(we,{children:[(0,Y.jsxs)(Qt,{className:`gap-0.5`,children:[ne&&(0,Y.jsx)(ot,{children:(0,Y.jsx)(hd,{status:`running`,...N.nameRuns===!1?{intent:F?.intent??void 0}:_===void 0?{intent:void 0,naming:!0}:{intent:_},...te&&y?{project:y}:{},subtitle:`just now`,driver:N.driver,active:re,standIn:!0,onClick:j(()=>l(null))})}),oe.map(({row:e,subagents:t})=>{let n=B[e.key]??t.some(e=>dl(e.agent)||e.active),r=t.filter(e=>e.agent.status===`running`).length,i=Date.now(),a=e.agent.status===`done`&&t.some(e=>pl(e.agent,i));return(0,Y.jsxs)(ot,{children:[pe(e,!1,a?`running`:e.agent.status,t.length>0?{count:t.length,working:r,open:n,onToggle:()=>ce(t=>({...t,[e.key]:!n}))}:void 0),t.length>0&&n&&(0,Y.jsx)(`div`,{className:`mt-0.5 ml-4 flex flex-col gap-0.5 border-l border-sidebar-border pl-2`,children:t.map(e=>(0,Y.jsx)(`div`,{children:pe(e,!0)},e.key))})]},e.key)})]}),!le&&i&&(0,Y.jsx)(`p`,{className:`whitespace-nowrap px-2 py-1 text-sm text-muted-foreground`,children:`No agents yet.`})]})]})})}),(0,Y.jsx)(Ae,{className:`border-t border-sidebar-border`,children:(0,Y.jsx)(Gu,{onSettings:j(C)})}),!O&&(0,Y.jsx)(ad,{})]})]})}function ud({icon:e,label:t,active:n,onClick:r,children:i}){return(0,Y.jsxs)(`button`,{type:`button`,onClick:r,"aria-current":n?`page`:void 0,className:q(`flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-sm transition-colors`,n?`bg-sidebar-accent text-sidebar-accent-foreground`:`text-foreground hover:bg-sidebar-accent/60`),children:[(0,Y.jsx)(e,{className:`h-4 w-4 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1 text-left`,children:t}),i]})}function dd({active:e,count:t,onClick:n}){return(0,Y.jsx)(ud,{icon:Dc,label:`Overview`,active:e,onClick:n,children:t>0&&(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(`span`,{className:`min-w-5 rounded-full bg-primary px-1.5 text-center text-xs font-semibold text-primary-foreground tabular-nums`}),children:t}),(0,Y.jsxs)(H,{children:[t,` item`,t===1?``:`s`,` in your Human Queue`]})]})})}function fd({scope:e,projects:t,active:n=!1,onNewAgentInProject:r,onSelect:i,onProjectAdded:a}){let[o,s]=(0,J.useState)(!1),c=nl(),l=q(`h-auto w-full justify-start gap-2 px-2 py-1.5 font-normal`,n&&`bg-sidebar-accent text-sidebar-accent-foreground`),u=e=>r?r(e):i(null);if(e!==null||t.length===1){let n=e??t[0].id;return(0,Y.jsxs)(V,{variant:`ghost`,className:l,onClick:()=>u(n),children:[(0,Y.jsx)(Fc,{className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:`New agent`})]})}return t.length===0?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(yi,{children:[(0,Y.jsxs)(pi,{render:(0,Y.jsx)(V,{variant:`ghost`,className:l,onClick:()=>s(!0)}),children:[(0,Y.jsx)(Fc,{className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:`New agent`})]}),(0,Y.jsx)(H,{children:`Add a project to start an agent`})]}),o&&(0,Y.jsx)(Al,{onAdded:()=>a?.(),onClose:()=>s(!1)})]}):(0,Y.jsxs)(Mn,{children:[(0,Y.jsxs)(mt,{"aria-label":`New agent`,className:q(st({variant:`ghost`}),l),children:[(0,Y.jsx)(Fc,{className:`h-4 w-4 shrink-0`}),(0,Y.jsx)(`span`,{className:`whitespace-nowrap`,children:`New agent`}),(0,Y.jsx)(ke,{className:`ml-auto h-3.5 w-3.5 shrink-0 opacity-70`})]}),(0,Y.jsx)(hr,{align:`start`,className:`w-[13.5rem]`,children:t.map(e=>(0,Y.jsxs)(K,{onClick:()=>u(e.id),children:[(0,Y.jsx)(`span`,{"aria-hidden":!0,className:q(`h-2 w-2 shrink-0 rounded-full`,e.activated?`bg-primary`:`bg-muted-foreground`)}),(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:c(e.id,e.name)})]},e.id))})]})}function pd({order:e}){return(0,Y.jsxs)(Mn,{children:[(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(mt,{type:`button`,"aria-label":`Sort agents`,className:`ml-auto flex h-5 w-5 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground`}),children:(0,Y.jsx)(Vs,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,Y.jsxs)(H,{children:[`Sort by: `,Xc[e]]})]}),(0,Y.jsx)(hr,{align:`end`,className:`min-w-40`,children:(0,Y.jsxs)(Hn,{children:[(0,Y.jsx)(tn,{className:`font-normal`,children:`Sort by`}),Object.keys(Xc).map(t=>(0,Y.jsxs)(K,{"aria-current":t===e,onClick:()=>Na({recentsSort:t}),children:[(0,Y.jsx)(Ir,{className:q(`h-3.5 w-3.5 shrink-0`,t===e?`opacity-100`:`opacity-0`),"aria-hidden":!0}),Xc[t]]},t))]})})]})}var md=`size-3.5 text-[7px]`;function hd({status:e,intent:t,naming:n=!1,project:r,subtitle:i,active:a,onClick:o,onNear:s,driver:c,model:l,standIn:u=!1,saving:d=!1,remote:f=!1,cloud:p=!1,cloudState:m,remoteLabel:h,remoteKind:g=`server`,seenAt:_,startedOn:v,fold:y,pr:b,unpublished:x,uncommitted:S,gitHost:C=!0,person:w,account:T}){let E=e===`waiting`||m===`waiting`,D=xr(c),O=_e[g],k=m===`in-cloud`,A=m===`merged`?`merged`:void 0,j=d&&!p,M=(0,J.useRef)(null),[N,P]=(0,J.useState)(!1);(0,J.useEffect)(()=>{let e=M.current;if(!e)return;let t=!1,n=()=>{t||P(e.scrollWidth>e.clientWidth+1)};n(),document.fonts?.ready.then(n);let r=typeof ResizeObserver>`u`?void 0:new ResizeObserver(n);return r?.observe(e),()=>{t=!0,r?.disconnect()}},[t,n]);let F=n?``:t||`New agent`,ee=(0,J.useRef)(!1);n&&(ee.current=!0);let te=q(`rail-title min-w-0 flex-1 text-sm font-normal`,N&&`is-overflowing`),I=E?`waiting`:k?`in cloud`:A||(j?`saving…`:e===`unknown`?`status unknown`:e),L=e===`unknown`?`${h??`Its computer`} offline${_?` · last seen ${er(_)}`:``}`:void 0,R=e===`running`||k||j,ne=j?il.saving:E?il.waiting:R?il.running:il[e],re=(A?al[A]:al[e])??al.done,ie=b?.state?ol[b.state]:void 0,ae=b?`PR #${b.number}${ie?` ${ie.word}`:``}`:void 0,z=S?{Icon:cc,said:`${Hl(`uncommitted`)} · ${S} file${S===1?``:`s`}`}:x?{Icon:hc,said:`${Hl(`unpushed`,C)} · ${x} commit${x===1?``:`s`}`}:void 0,oe=w?dt(w,T):void 0,B=[I,...r?[r]:[],i,...oe?[oe]:[],...D?[$r[D]]:[],...v?[`started on ${v}`]:[],...L?[L]:f?[h?`runs on ${h}`:`runs on another machine`]:[],...p?[`a Claude Code cloud session`]:[],...ae?[ae]:[],...z?[z.said]:[]].join(` · `),se=D?[$r[D],...l?[l]:[]].join(` · `):void 0;return(0,Y.jsxs)(V,{variant:`ghost`,"aria-label":`${n?`Naming this session`:F} · ${B}`,className:q(`rail-row h-8 w-full items-center gap-2 px-2 text-left`,a&&`bg-accent text-accent-foreground`),...u?{"data-stand-in":``}:{},onClick:o,onPointerEnter:s,onFocus:s,children:[(0,Y.jsx)(`span`,{role:`img`,"aria-label":I,className:q(`inline-block h-2 w-2 shrink-0 rounded-full`,ne??q(`border`,re),R&&`animate-pulse`)}),(0,Y.jsxs)(yi,{disabled:!N,children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(`span`,{ref:M,className:te}),children:n?(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`block h-3.5 w-2/3 animate-pulse rounded bg-muted-foreground/20`}):(0,Y.jsx)(Bs,{text:F,start:u||ee.current})}),(0,Y.jsx)(H,{side:`right`,className:`max-w-96 whitespace-pre-wrap break-words text-sm`,children:F})]}),v&&(0,Y.jsx)(gd,{said:`Started on ${v}`,children:(0,Y.jsx)(Et,{className:`h-3 w-3 text-muted-foreground`})}),f&&(0,Y.jsx)(gd,{said:L??(h?`Runs on ${h}`:`Runs on another machine`),children:(0,Y.jsx)(O,{className:`h-3 w-3 text-muted-foreground`})}),p&&(0,Y.jsx)(gd,{said:`Runs as a Claude Code cloud session`,children:(0,Y.jsx)(nc,{className:`h-3 w-3 text-muted-foreground`})}),r&&(0,Y.jsx)(`span`,{className:`max-w-[35%] min-w-0 shrink truncate text-xs text-muted-foreground`,children:r}),y&&(0,Y.jsxs)(`span`,{role:`button`,tabIndex:0,"aria-expanded":y.open,"aria-label":`${y.count} agent${y.count===1?``:`s`}${y.working>0?` · ${y.working} running`:``}`,title:`${y.count} subagent${y.count===1?``:`s`}${y.working>0?`, ${y.working} running`:``}`,onClick:e=>{e.stopPropagation(),y.onToggle()},onKeyDown:e=>{e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),e.stopPropagation(),y.onToggle())},className:`flex shrink-0 items-center gap-0.5 rounded-sm px-1 text-[11px] font-normal tabular-nums text-muted-foreground transition-colors hover:bg-background hover:text-foreground`,children:[(0,Y.jsx)(ke,{className:q(`h-3 w-3 shrink-0 transition-transform`,y.open||`-rotate-90`),"aria-hidden":!0}),(0,Y.jsx)(Js,{className:`h-3 w-3 shrink-0`,"aria-hidden":!0}),y.count]}),ie&&ae&&(0,Y.jsx)(gd,{said:ae,children:(0,Y.jsx)(ie.Icon,{className:q(`h-3 w-3`,ie.tone)})}),z&&(0,Y.jsx)(gd,{said:z.said,children:(0,Y.jsx)(z.Icon,{className:`h-3 w-3 text-muted-foreground`})}),oe?(0,Y.jsx)(gd,{said:oe,children:(0,Y.jsx)($e,{email:w,picture:T?.avatar,className:md})}):u&&(0,Y.jsx)($e,{className:md}),D&&se&&(0,Y.jsx)(gd,{said:se,children:(0,Y.jsx)(hi,{driver:D,className:`h-3 w-3 text-muted-foreground`})})]})}function gd({said:e,children:t}){return(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(`span`,{role:`img`,"aria-label":e,className:`flex shrink-0 items-center`}),children:t}),(0,Y.jsx)(H,{children:e})]})}function _d(e=typeof window>`u`?``:window.location.hostname){return e===``||Ee(e)?`This machine`:e}function vd(e,t){let n=_d(t);return n===`This machine`?e:n}function yd(e){return{...e.driver?{driver:e.driver}:{},...e.model?{model:e.model}:{},...e.effort?{effort:e.effort}:{},...e.publish?{publish:e.publish}:{}}}function bd(e){let{busy:t,error:n,reset:r,run:i}=Yn(),[a,o]=(0,J.useState)(null),s=(0,J.useRef)(!0),c=(0,J.useRef)(e);return c.current=e,(0,J.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]),{busy:t,cloning:a!==null&&a.scope===e,error:n,reset:r,start:async(t,n,r={},a=`Failed to start the agent.`)=>{let l=e,u=()=>s.current&&c.current===l,d=await i(async()=>{let e=await Mo(t,n,r);if(e.ok||!e.notThere)return e;let i=r.machine;o({scope:l});try{let e=i===void 0?await wd(()=>Vn(t),()=>on(t),u):await wd(()=>In(t,i),()=>wr(t,i),u);if(e===xd||!u())return xd;if(!e.ok)return e}finally{o(null)}return Mo(t,n,r)},a);return d.ok?d.value??void 0:void 0}}}var xd=null,Sd=2e3,Cd=16*6e4;async function wd(e,t,n){let r=Date.now()+Cd,i=await e();for(;i.ok&&!i.there;){if(Date.now()>r)return{ok:!1,error:`The project is still being cloned. Send again in a few minutes.`};if(await new Promise(e=>setTimeout(e,Sd)),!n())return xd;i=await t()}return i.ok?{ok:!0}:i}function Td(e){let t=Ia().startFrom?.[e??``],n=xi(e?()=>t?qo(e,t):qo(e):null,null,15e3,[e,t?.kind,t?.kind===`published`?t.branch:void 0]),r=(0,J.useRef)({projectId:e,launcher:null});return n.loaded&&(r.current={projectId:e,launcher:n.value}),n.loaded||r.current.projectId!==e?n.value:r.current.launcher}function Ed(e){return e.filter(e=>e.waiting===void 0)}var Dd=`all`,Od=`settings`,kd=`item`;function Ad(e,t){let[n=``,r=``]=e.split(`?`),i=new URLSearchParams(r),a=i.get(Od),o=i.get(kd),s=a===null?{}:{settings:a,...o?{settingsItem:o}:{}},[c,...l]=n.split(`/`).filter(Boolean).map(Pd);if(c===`settings`)return{projectId:null,agentId:null,settings:a??l[0]??``};if(!c||c===`overview`)return{projectId:null,agentId:null,...s};let u=t.projectOf(c);if(u===void 0&&ve(c))return{projectId:null,agentId:null,page:c,pagePath:l,...s};let d=u??c,[f,...p]=l;return f===`overview`?{projectId:null,agentId:null,scope:d,...s}:f!==void 0&&ve(f)?{projectId:null,agentId:null,page:f,pagePath:p,scope:d,...s}:{projectId:d,agentId:f??null,...i.has(Dd)?{}:{scope:d},...s}}function jd(e,t){let n=!e.page&&e.projectId&&!e.scope?[Dd]:[],r=e.settings===void 0?[]:[`${Od}=${encodeURIComponent(e.settings)}`,...e.settingsItem?[`${kd}=${encodeURIComponent(e.settingsItem)}`]:[]],i=[...n,...r].join(`&`);return Nd(e,t)+(i?`?${i}`:``)}function Md(e,t){let[n=``,r=``]=e.split(`?`),i=new URLSearchParams(t);for(let e of[Dd,Od,kd,...new URLSearchParams(r).keys()])i.delete(e);let a=[i.toString(),r].filter(Boolean).join(`&`);return a?`${n}?${a}`:n}function Nd({projectId:e,agentId:t,page:n,pagePath:r,scope:i},a){let o=!n&&e?e:i,s=o?[a.addressOf(o)]:[],c=n?[n,...r??[]]:e?t?[t]:[]:o?[et]:[];return`/`+[...s,...c].map(encodeURIComponent).join(`/`)}function Pd(e){try{return decodeURIComponent(e)}catch{return e}}var Fd=new Set;function Id(){for(let e of Fd)e()}function Ld(e){return Fd.size===0&&window.addEventListener(`popstate`,Id),Fd.add(e),()=>{Fd.delete(e),Fd.size===0&&window.removeEventListener(`popstate`,Id)}}var Rd=()=>window.location.pathname+window.location.search;function zd(e){let t=(0,J.useSyncExternalStore)(Ld,Rd,()=>`/`);return{route:Ad(t,e),go:(n,r)=>{let i=r?.keepQuery?Md(jd(n,e),window.location.search):jd(n,e);i!==t&&(r?.replace?window.history.replaceState(null,``,i):window.history.pushState(null,``,i),Id())}}}function Bd(e,t){let n=new URL(window.location.href);n.searchParams.set(Od,e),t?n.searchParams.set(kd,t):n.searchParams.delete(kd),window.history.pushState(null,``,n.pathname+n.search),Id()}function Vd(){let[e,t]=(0,J.useState)(new Set);return{context:e,add:e=>t(t=>t.has(e)?t:new Set(t).add(e)),remove:e=>t(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),toggle:e=>t(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),reset:()=>t(new Set)}}function Hd(e,t){let n=[...t];return n.length?`${e.trimEnd()}\n\nContext: ${n.join(`, `)}`:e}var Ud=`inline-flex h-7 min-w-0 max-w-full shrink items-center gap-1.5 overflow-hidden rounded-md px-2 text-[13px] font-normal text-muted-foreground max-sm:max-w-none max-sm:shrink-0`,Wd=q(Ud,`transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:pointer-events-none disabled:opacity-50`),Gd=`flex h-8 items-center gap-2`,Kd=`flex min-w-0 flex-1 items-center gap-0.5 max-sm:overflow-x-auto max-sm:[scrollbar-width:none] max-sm:[mask-image:linear-gradient(to_right,#000_85%,transparent)]`;function qd({children:e,end:t}){return(0,Y.jsxs)(`div`,{className:q(`mb-1`,Gd),children:[(0,Y.jsx)(`div`,{className:Kd,children:e}),t&&(0,Y.jsx)(`div`,{className:`shrink-0`,children:t})]})}function Jd({tip:e,children:t}){return(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(`span`,{className:`inline-flex min-w-0 max-w-full shrink max-sm:max-w-none max-sm:shrink-0`}),children:t}),(0,Y.jsx)(H,{children:e})]})}function Yd({icon:e,children:t}){return(0,Y.jsxs)(`span`,{className:Ud,children:[e,(0,Y.jsx)(`span`,{className:`truncate`,children:t})]})}var Xd={nothing:`Adds nothing to your message. The agent decides, and usually commits.`,commit:`It commits its work on its branch.`,branch:`It commits and pushes its branch.`,pr:`It commits, pushes its branch and opens a pull request.`,merge:`It commits, pushes its branch and opens a pull request set to merge once its checks pass.`};function Zd({publish:e,picks:t,onPublish:n,target:r,busy:i}){let a=e===`pr`||e===`merge`?r:void 0;return(0,Y.jsxs)(Mn,{children:[(0,Y.jsxs)(yi,{children:[(0,Y.jsxs)(pi,{render:(0,Y.jsx)(mt,{type:`button`,disabled:i,"aria-label":`Auto`,className:q(Wd,`max-w-[20rem]!`)}),children:[(0,Y.jsx)(`span`,{className:`truncate`,children:`Auto: ${Lt[e]}${a?` → ${a.into}`:``}`}),(0,Y.jsx)(ke,{className:`h-3 w-3 shrink-0 opacity-70`,"aria-hidden":!0})]}),(0,Y.jsx)(H,{children:`What the agent does by itself when it finishes.${a?` The pull request goes into ${a.into}.`:``}`})]}),(0,Y.jsxs)(hr,{className:`min-w-[19rem] max-w-[22rem]`,children:[(0,Y.jsxs)(Hn,{children:[(0,Y.jsx)(tn,{className:`font-normal`,children:`When the agent finishes`}),t.map(t=>(0,Y.jsxs)(K,{className:`items-start`,"aria-current":t===e,onClick:()=>n(t),children:[(0,Y.jsx)(Ir,{className:q(`mt-0.5 h-3.5 w-3.5 shrink-0`,t===e?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,Y.jsx)(Dt,{label:Lt[t],description:Xd[t]})]},t))]}),a?.picks&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ci,{}),(0,Y.jsxs)(Hn,{children:[(0,Y.jsx)(tn,{className:`font-normal`,children:`The pull request goes into`}),a.picks.map(e=>(0,Y.jsxs)(K,{"aria-current":e===a.into,onClick:()=>a.onPick?.(e),children:[(0,Y.jsx)(Ir,{className:q(`h-3.5 w-3.5 shrink-0`,e===a.into?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`truncate`,children:e})]},e))]})]})]})]})}function Qd({files:e,onRemove:t,busy:n}){return e.length===0?null:(0,Y.jsx)(`div`,{className:`flex flex-col gap-1`,children:e.map(e=>(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>t(e),"aria-label":`Remove ${e} from context`,className:`flex h-3.5 w-3.5 items-center justify-center rounded text-muted-foreground hover:text-danger disabled:opacity-50`}),children:(0,Y.jsx)(Ai,{className:`h-3.5 w-3.5`})}),(0,Y.jsxs)(H,{children:[`Remove `,e]})]}),(0,Y.jsx)(`span`,{className:`truncate`,title:e,children:e})]},e))})}function $d({projectId:e,context:t,busy:n,onToggle:r}){let i=mn(zo,[],[]).filter(e=>e.machine===void 0),a=new Set(i.map(e=>e.path)),o=[...t].filter(e=>!a.has(e)),s=i.filter(t=>t.id!==e),c=s.filter(e=>t.has(e.path)).length;return(0,Y.jsx)(ef,{otherProjects:s,context:t,contextFiles:o,summary:[c>0?`${c} project${c>1?`s`:``}`:null,o.length>0?`${o.length} file${o.length>1?`s`:``}`:null].filter(Boolean).join(` · `),busy:n,onToggle:r})}function ef({otherProjects:e,context:t,contextFiles:n,summary:r,busy:i,onToggle:a}){return(0,Y.jsxs)(Mn,{children:[(0,Y.jsxs)(yi,{children:[(0,Y.jsxs)(pi,{render:(0,Y.jsx)(mt,{type:`button`,disabled:i,className:Wd}),children:[(0,Y.jsx)(Ec,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),`Context`,r&&(0,Y.jsxs)(`span`,{className:`text-primary`,children:[` · `,r]})]}),(0,Y.jsx)(H,{children:`Narrow the run to specific repos and files`})]}),(0,Y.jsxs)(hr,{align:`start`,className:`min-w-[18rem] max-w-[24rem]`,children:[(0,Y.jsxs)(Hn,{children:[(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(tn,{}),children:`Projects`}),(0,Y.jsx)(H,{className:`max-w-[22rem]`,children:`The agent can still reach every repo; ticking some just narrows its focus.`})]}),e.length>0?e.map(e=>(0,Y.jsxs)(yi,{children:[(0,Y.jsx)(pi,{render:(0,Y.jsx)(Ar,{checked:t.has(e.path),onCheckedChange:()=>a(e.path),disabled:i}),children:(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})}),(0,Y.jsx)(H,{children:e.path})]},e.id)):(0,Y.jsx)(`p`,{className:`px-2 py-1 text-xs text-muted-foreground/60`,children:`No other repos to add.`})]}),(0,Y.jsx)(ci,{}),(0,Y.jsxs)(Hn,{children:[(0,Y.jsx)(tn,{children:`Files`}),n.length>0?(0,Y.jsx)(`div`,{className:`px-2 py-1`,children:(0,Y.jsx)(Qd,{files:n,onRemove:a,busy:i})}):(0,Y.jsx)(`p`,{className:`px-2 py-1 text-xs text-muted-foreground/60`,children:`None yet — add with # or the Files pane.`})]})]})]})}function tf(e){this.content=e}tf.prototype={constructor:tf,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return t==-1?void 0:this.content[t+1]},update:function(e,t,n){var r=n&&n!=e?this.remove(n):this,i=r.find(e),a=r.content.slice();return i==-1?a.push(n||e,t):(a[i+1]=t,n&&(a[i]=n)),new tf(a)},remove:function(e){var t=this.find(e);if(t==-1)return this;var n=this.content.slice();return n.splice(t,2),new tf(n)},addToStart:function(e,t){return new tf([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new tf(n)},addBefore:function(e,t,n){var r=this.remove(t),i=r.content.slice(),a=r.find(e);return i.splice(a==-1?i.length:a,0,t,n),new tf(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return e=tf.from(e),e.size?new tf(e.content.concat(this.subtract(e).content)):this},append:function(e){return e=tf.from(e),e.size?new tf(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=tf.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},tf.from=function(e){if(e instanceof tf)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new tf(t)};function nf(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(r),a=t.child(r);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){let e=i.text,t=a.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&of(e.charCodeAt(r-1))&&af(e.charCodeAt(r))&&n--,n}if(i.content.size||a.content.size){let e=nf(i.content,a.content,n+1);if(e!=null)return e}n+=i.nodeSize}}function rf(e,t,n,r){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let o=e.child(--i),s=t.child(--a),c=o.nodeSize;if(o==s){n-=c,r-=c;continue}if(!o.sameMarkup(s))return{a:n,b:r};if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,i=e.length,a=t.length;for(;i>0&&a>0&&e[i-1]==t[a-1];)i--,a--,n--,r--;return i&&a&&i<e.length&&of(e.charCodeAt(i-1))&&af(e.charCodeAt(i))&&(n++,r++),{a:n,b:r}}if(o.content.size||s.content.size){let e=rf(o.content,s.content,n-1,r-1);if(e)return e}n-=c,r-=c}}function af(e){return e>=56320&&e<57344}function of(e){return e>=55296&&e<56320}var X=class e{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,i){for(let a=0,o=0;o<t;a++){let s=this.content[a],c=o+s.nodeSize;if(c>e&&n(s,r+o,i||null,a)!==!1&&s.content.size){let i=o+1;s.nodesBetween(Math.max(0,e-i),Math.min(s.content.size,t-i),n,r+i)}o=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let i=``,a=!0;return this.nodesBetween(e,t,(o,s)=>{let c=o.isText?o.text.slice(Math.max(e,s)-s,t-s):o.isLeaf?r?typeof r==`function`?r(o):r:o.type.spec.leafText?o.type.spec.leafText(o):``:``;o.isBlock&&(o.isLeaf&&c||o.isTextblock)&&n&&(a?a=!1:i+=n),i+=c},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new e(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],i=0;if(n>t)for(let e=0,a=0;a<n;e++){let o=this.content[e],s=a+o.nodeSize;s>t&&((a<t||s>n)&&(o=o.isText?o.cut(Math.max(0,t-a),Math.min(o.text.length,n-a)):o.cut(Math.max(0,t-a-1),Math.min(o.content.size,n-a-1))),r.push(o),i+=o.nodeSize),a=s}return new e(r,i)}cutByIndex(t,n){return t==n?e.empty:t==0&&n==this.content.length?this:new e(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-r.nodeSize;return i[t]=n,new e(i,a)}addToStart(t){return new e([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new e(this.content.concat(t),this.size+t.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw RangeError(`Index `+e+` out of range for `+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return nf(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return rf(this,e,t,n)}findIndex(e){if(e==0)return cf(0,e);if(e==this.size)return cf(this.content.length,e);if(e>this.size||e<0)throw RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=this.child(t),i=n+r.nodeSize;if(i>=e)return i==e?cf(t+1,i):cf(t,n);n=i}}toString(){return`<`+this.toStringInner()+`>`}toStringInner(){return this.content.join(`, `)}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(t,n){if(!n)return e.empty;if(!Array.isArray(n))throw RangeError(`Invalid input for Fragment.fromJSON`);return e.fromArray(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return e.empty;let n,r=0;for(let e=0;e<t.length;e++){let i=t[e];r+=i.nodeSize,e&&i.isText&&t[e-1].sameMarkup(i)?(n||=t.slice(0,e),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new e(n||t,r)}static from(t){if(!t)return e.empty;if(t instanceof e)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new e([t],t.nodeSize);throw RangeError(`Can not convert `+t+` to a Fragment`+(t.nodesBetween?` (looks like multiple versions of prosemirror-model were loaded)`:``))}};X.empty=new X([],0);var sf={index:0,offset:0};function cf(e,t){return sf.index=e,sf.offset=t,sf}function lf(e,t){if(e===t)return!0;if(!(e&&typeof e==`object`)||!(t&&typeof t==`object`))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!lf(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!lf(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}var uf=class e{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||=e.slice(0,r);else if(i.type.excludes(this.type))return e;else!n&&i.type.rank>this.type.rank&&(t||=e.slice(0,r),t.push(this),n=!0),t&&t.push(i)}return t||=e.slice(),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&lf(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Mark.fromJSON`);let n=e.marks[t.type];if(!n)throw RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return e.none;if(t instanceof e)return[t];let n=t.slice();return n.sort((e,t)=>e.type.rank-t.type.rank),n}};uf.none=[];var df=class extends Error{},Z=class e{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=pf(this.content,t+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new e(r,this.openStart,this.openEnd)}removeBetween(t,n){return new e(ff(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+`(`+this.openStart+`,`+this.openEnd+`)`}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(t,n){if(!n)return e.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!=`number`||typeof i!=`number`)throw RangeError(`Invalid input for Slice.fromJSON`);return new e(X.fromJSON(t,n.content),r,i)}static maxOpen(t,n=!0){let r=0,i=0;for(let e=t.firstChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.firstChild)r++;for(let e=t.lastChild;e&&!e.isLeaf&&(n||!e.type.spec.isolating);e=e.lastChild)i++;return new e(t,r,i)}};Z.empty=new Z(X.empty,0,0);function ff(e,t,n){let{index:r,offset:i}=e.findIndex(t),a=e.maybeChild(r),{index:o,offset:s}=e.findIndex(n);if(i==t||a.isText){if(s!=n&&!e.child(o).isText)throw RangeError(`Removing non-flat range`);return e.cut(0,t).append(e.cut(n))}if(r!=o)throw RangeError(`Removing non-flat range`);return e.replaceChild(r,a.copy(ff(a.content,t-i-1,n-i-1)))}function pf(e,t,n,r,i,a){let{index:o,offset:s}=e.findIndex(t),c=e.maybeChild(o);if(s==t||c.isText)return a&&r<=0&&i<=0&&!a.canReplace(o,o,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=pf(c.content,t-s-1,n,o==0?r-1:0,o==e.childCount-1?i-1:0,c);return l&&e.replaceChild(o,c.copy(l))}function mf(e,t,n){if(n.openStart>e.depth)throw new df(`Inserted content deeper than insertion position`);if(e.depth-n.openStart!=t.depth-n.openEnd)throw new df(`Inconsistent open depths`);return hf(e,t,n,0)}function hf(e,t,n,r){let i=e.index(r),a=e.node(r);if(i==t.index(r)&&r<e.depth-n.openStart){let o=hf(e,t,n,r+1);return a.copy(a.content.replaceChild(i,o))}else if(!n.content.size)return bf(a,Sf(e,t,r));else if(!n.openStart&&!n.openEnd&&e.depth==r&&t.depth==r){let r=e.parent,i=r.content;return bf(r,i.cut(0,e.parentOffset).append(n.content).append(i.cut(t.parentOffset)))}else{let{start:i,end:o}=Cf(n,e);return bf(a,xf(e,i,o,t,r))}}function gf(e,t){if(!t.type.compatibleContent(e.type))throw new df(`Cannot join `+t.type.name+` onto `+e.type.name)}function _f(e,t,n){let r=e.node(n);return gf(r,t.node(n)),r}function vf(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function yf(e,t,n,r){let i=(t||e).node(n),a=0,o=t?t.index(n):i.childCount;e&&(a=e.index(n),e.depth>n?a++:e.textOffset&&(vf(e.nodeAfter,r),a++));for(let e=a;e<o;e++)vf(i.child(e),r);t&&t.depth==n&&t.textOffset&&vf(t.nodeBefore,r)}function bf(e,t){if(!e.type.validContent(t))throw new df(`Invalid content for node `+e.type.name);return e.copy(t)}function xf(e,t,n,r,i){let a=e.depth>i&&_f(e,t,i+1),o=r.depth>i&&_f(n,r,i+1),s=[];return yf(null,e,i,s),a&&o&&t.index(i)==n.index(i)?(gf(a,o),vf(bf(a,xf(e,t,n,r,i+1)),s)):(a&&vf(bf(a,Sf(e,t,i+1)),s),yf(t,n,i,s),o&&vf(bf(o,Sf(n,r,i+1)),s)),yf(r,null,i,s),new X(s)}function Sf(e,t,n){let r=[];return yf(null,e,n,r),e.depth>n&&vf(bf(_f(e,t,n+1),Sf(e,t,n+1)),r),yf(t,null,n,r),new X(r)}function Cf(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(X.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}var wf=class e{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position before the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw RangeError(`There is no position after the top-level node`);return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return uf.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let i=n.marks;for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<n.length;i++)n[i].type.spec.inclusive===!1&&(!r||!n[i].isInSet(r.marks))&&(n=n[i--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Of(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e=``;for(let t=1;t<=this.depth;t++)e+=(e?`/`:``)+this.node(t).type.name+`_`+this.index(t-1);return e+`:`+this.parentOffset}static resolve(t,n){if(!(n>=0&&n<=t.content.size))throw RangeError(`Position `+n+` out of range`);let r=[],i=0,a=n;for(let e=t;;){let{index:t,offset:n}=e.content.findIndex(a),o=a-n;if(r.push(e,t,i+n),!o||(e=e.child(t),e.isText))break;a=o-1,i+=n+1}return new e(n,r,a)}static resolveCached(t,n){let r=Df.get(t);if(r)for(let e=0;e<r.elts.length;e++){let t=r.elts[e];if(t.pos==n)return t}else Df.set(t,r=new Tf);let i=r.elts[r.i]=e.resolve(t,n);return r.i=(r.i+1)%Ef,i}},Tf=class{constructor(){this.elts=[],this.i=0}},Ef=12,Df=new WeakMap,Of=class{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},kf=Object.create(null),Af=class e{constructor(e,t,n,r=uf.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||X.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,``)}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&lf(this.attrs,t||e.defaultAttrs||kf)&&uf.sameSet(this.marks,n||uf.none)}copy(t=null){return t==this.content?this:new e(this.type,this.attrs,t,this.marks)}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.content,t)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return Z.empty;let r=this.resolve(e),i=this.resolve(t),a=n?0:r.sharedDepth(t),o=r.start(a);return new Z(r.node(a).content.cut(r.pos-o,i.pos-o),r.depth-a,i.depth-a)}replace(e,t,n){return mf(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return wf.resolveCached(this,e)}resolveNoCache(e){return wf.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+=`(`+this.content.toStringInner()+`)`),Mf(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw Error(`Called contentMatchAt on a node with invalid content`);return t}canReplace(e,t,n=X.empty,r=0,i=n.childCount){let a=this.contentMatchAt(e).matchFragment(n,r,i),o=a&&a.matchFragment(this.content,t);if(!o||!o.validEnd)return!1;for(let e=r;e<i;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(n),a=i&&i.matchFragment(this.content,t);return a?a.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=uf.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!uf.sameSet(e,this.marks))throw RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw RangeError(`Invalid input for Node.fromJSON`);let n;if(t.marks){if(!Array.isArray(t.marks))throw RangeError(`Invalid mark data for Node.fromJSON`);n=t.marks.map(e.markFromJSON)}if(t.type==`text`){if(typeof t.text!=`string`)throw RangeError(`Invalid text node in JSON`);return e.text(t.text,n)}let r=X.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,r,n);return i.type.checkAttrs(i.attrs),i}};Af.prototype.text=void 0;var jf=class e extends Af{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw RangeError(`Empty text nodes are not allowed`);this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Mf(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new e(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new e(this.type,this.attrs,t,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}};function Mf(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+`(`+t+`)`;return t}var Nf=class e{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(t,n){let r=new Pf(t,n);if(r.next==null)return e.empty;let i=Ff(r);r.next&&r.err(`Unexpected trailing text`);let a=Gf(Hf(i));return Kf(a,r),a}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let i=t;r&&i<n;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];function i(a,o){let s=a.matchFragment(e,n);if(s&&(!t||s.validEnd))return X.from(o.map(e=>e.createAndFill()));for(let e=0;e<a.next.length;e++){let{type:t,next:n}=a.next[e];if(!(t.isText||t.hasRequiredAttrs())&&r.indexOf(n)==-1){r.push(n);let e=i(n,o.concat(t));if(e)return e}}return null}return i(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),i=r.match;if(i.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<i.next.length;e++){let{type:a,next:o}=i.next[e];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in t)&&(!r.type||o.validEnd)&&(n.push({match:a.contentMatch,type:a,via:r}),t[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let r=0;r<n.next.length;r++)e.indexOf(n.next[r].next)==-1&&t(n.next[r].next)}return t(this),e.map((t,n)=>{let r=n+(t.validEnd?`*`:` `)+` `;for(let n=0;n<t.next.length;n++)r+=(n?`, `:``)+t.next[n].type.name+`->`+e.indexOf(t.next[n].next);return r}).join(`
9
9
  `)}};Nf.empty=new Nf(!0);var Pf=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==``&&this.tokens.pop(),this.tokens[0]==``&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw SyntaxError(e+` (in content expression '`+this.string+`')`)}};function Ff(e){let t=[];do t.push(If(e));while(e.eat(`|`));return t.length==1?t[0]:{type:`choice`,exprs:t}}function If(e){let t=[];do t.push(Lf(e));while(e.next&&e.next!=`)`&&e.next!=`|`);return t.length==1?t[0]:{type:`seq`,exprs:t}}function Lf(e){let t=Vf(e);for(;;)if(e.eat(`+`))t={type:`plus`,expr:t};else if(e.eat(`*`))t={type:`star`,expr:t};else if(e.eat(`?`))t={type:`opt`,expr:t};else if(e.eat(`{`))t=zf(e,t);else break;return t}function Rf(e){/\D/.test(e.next)&&e.err(`Expected number, got '`+e.next+`'`);let t=Number(e.next);return e.pos++,t}function zf(e,t){let n=Rf(e),r=n;return e.eat(`,`)&&(r=e.next==`}`?-1:Rf(e)),e.eat(`}`)||e.err(`Unclosed braced range`),{type:`range`,min:n,max:r,expr:t}}function Bf(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let i=[];for(let e in n){let r=n[e];r.isInGroup(t)&&i.push(r)}return i.length==0&&e.err(`No node type or group '`+t+`' found`),i}function Vf(e){if(e.eat(`(`)){let t=Ff(e);return e.eat(`)`)||e.err(`Missing closing paren`),t}else if(/\W/.test(e.next))e.err(`Unexpected token '`+e.next+`'`);else{let t=Bf(e,e.next).map(t=>(e.inline==null?e.inline=t.isInline:e.inline!=t.isInline&&e.err(`Mixing inline and block content`),{type:`name`,value:t}));return e.pos++,t.length==1?t[0]:{type:`choice`,exprs:t}}}function Hf(e){let t=[[]];return i(a(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let i={term:r,to:n};return t[e].push(i),i}function i(e,t){e.forEach(e=>e.to=t)}function a(e,t){if(e.type==`choice`)return e.exprs.reduce((e,n)=>e.concat(a(n,t)),[]);if(e.type==`seq`)for(let r=0;;r++){let o=a(e.exprs[r],t);if(r==e.exprs.length-1)return o;i(o,t=n())}else if(e.type==`star`){let o=n();return r(t,o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`plus`){let o=n();return i(a(e.expr,t),o),i(a(e.expr,o),o),[r(o)]}else if(e.type==`opt`)return[r(t)].concat(a(e.expr,t));else if(e.type==`range`){let o=t;for(let t=0;t<e.min;t++){let t=n();i(a(e.expr,o),t),o=t}if(e.max==-1)i(a(e.expr,o),o);else for(let t=e.min;t<e.max;t++){let t=n();r(o,t),i(a(e.expr,o),t),o=t}return[r(o)]}else if(e.type==`name`)return[r(t,void 0,e.value)];else throw Error(`Unknown expr type`)}}function Uf(e,t){return t-e}function Wf(e,t){let n=[];return r(t),n.sort(Uf);function r(t){let i=e[t];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(t);for(let e=0;e<i.length;e++){let{term:t,to:a}=i[e];!t&&n.indexOf(a)==-1&&r(a)}}}function Gf(e){let t=Object.create(null);return n(Wf(e,0));function n(r){let i=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<i.length;e++)i[e][0]==t&&(r=i[e][1]);Wf(e,n).forEach(e=>{r||i.push([t,r=[]]),r.indexOf(e)==-1&&r.push(e)})})});let a=t[r.join(`,`)]=new Nf(r.indexOf(e.length-1)>-1);for(let e=0;e<i.length;e++){let r=i[e][1].sort(Uf);a.next.push({type:i[e][0],next:t[r.join(`,`)]||n(r)})}return a}}function Kf(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],i=!e.validEnd,a=[];for(let t=0;t<e.next.length;t++){let{type:n,next:o}=e.next[t];a.push(n.name),i&&!(n.isText||n.hasRequiredAttrs())&&(i=!1),r.indexOf(o)==-1&&r.push(o)}i&&t.err(`Only non-generatable nodes (`+a.join(`, `)+`) in a required position (see https://prosemirror.net/docs/guide/#generatable)`)}}function qf(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function Jf(e,t){let n=Object.create(null);for(let r in e){let i=t&&t[r];if(i===void 0){let t=e[r];if(t.hasDefault)i=t.default;else throw RangeError(`No value supplied for attribute `+r)}n[r]=i}return n}function Yf(e,t,n,r){for(let i in t)if(!(i in e))throw RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function Xf(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new $f(e,r,t[r]);return n}var Zf=class e{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(` `):[],this.attrs=Xf(e,n.attrs),this.defaultAttrs=qf(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e==`text`),this.isText=e==`text`}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Nf.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?`pre`:`normal`)}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Jf(this.attrs,e)}create(e=null,t,n){if(this.isText)throw Error(`NodeType.create can't construct text nodes`);return new Af(this,this.computeAttrs(e),X.from(t),uf.setFrom(n))}createChecked(e=null,t,n){return t=X.from(t),this.checkContent(t),new Af(this,this.computeAttrs(e),t,uf.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=X.from(t),t.size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(X.empty,!0);return i?new Af(this,e,t.append(i),uf.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Yf(this.attrs,e,`node`,this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||=e.slice(0,n);return t?t.length?t:uf.none:e}static compile(t,n){let r=Object.create(null);t.forEach((t,i)=>r[t]=new e(t,n,i));let i=n.spec.topNode||`doc`;if(!r[i])throw RangeError(`Schema is missing its top node type ('`+i+`')`);if(!r.text)throw RangeError(`Every schema needs a 'text' type`);for(let e in r.text.attrs)throw RangeError(`The text node type should not have attributes`);return r}};function Qf(e,t,n){let r=n.split(`|`);return n=>{let i=n===null?`null`:typeof n;if(r.indexOf(i)<0)throw RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${i}`)}}var $f=class{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,`default`),this.default=n.default,this.validate=typeof n.validate==`string`?Qf(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}},ep=class e{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=Xf(e,r.attrs),this.excluded=null;let i=qf(this.attrs);this.instance=i?new uf(this,i):null}create(e=null){return!e&&this.instance?this.instance:new uf(this,Jf(this.attrs,e))}static compile(t,n){let r=Object.create(null),i=0;return t.forEach((t,a)=>r[t]=new e(t,i++,n,a)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Yf(this.attrs,e,`mark`,this.name)}excludes(e){return this.excluded.indexOf(e)>-1}},tp=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=tf.from(e.nodes),t.marks=tf.from(e.marks||{}),this.nodes=Zf.compile(this.spec.nodes,this),this.marks=ep.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw RangeError(e+` can not be both a node and a mark`);let t=this.nodes[e],r=t.spec.content||``,i=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=Nf.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw RangeError(`Multiple linebreak nodes defined`);if(!t.isInline||!t.isLeaf)throw RangeError(`Linebreak replacement nodes must be inline leaf nodes`);this.linebreakReplacement=t}t.markSet=i==`_`?null:i?np(this,i.split(` `)):i==``||!t.inlineContent?[]:null}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=n==null?[t]:n==``?[]:np(this,n.split(` `))}this.nodeFromJSON=e=>Af.fromJSON(this,e),this.markFromJSON=e=>uf.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||`doc`],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if(typeof e==`string`)e=this.nodeType(e);else if(!(e instanceof Zf))throw RangeError(`Invalid node type: `+e);else if(e.schema!=this)throw RangeError(`Node type from different schema used (`+e.name+`)`);return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new jf(n,n.defaultAttrs,e,uf.setFrom(t))}mark(e,t){return typeof e==`string`&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw RangeError(`Unknown node type: `+e);return t}};function np(e,t){let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e.marks[i],o=a;if(a)n.push(a);else for(let t in e.marks){let r=e.marks[t];(i==`_`||r.spec.group&&r.spec.group.split(` `).indexOf(i)>-1)&&n.push(o=r)}if(!o)throw SyntaxError(`Unknown mark type: '`+t[r]+`'`)}return n}function rp(e){return e.tag!=null}function ip(e){return e.style!=null}var ap=class e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(rp(e))this.tags.push(e);else if(ip(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new mp(this,t,!1);return n.addAll(e,uf.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new mp(this,t,!0);return n.addAll(e,uf.none,t.from,t.to),Z.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(gp(e,n.tag)&&(n.namespace===void 0||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(t===!1)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let r=this.styles[i],a=r.style;if(!(a.indexOf(e)!=0||r.context&&!n.matchesContext(r.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(e===!1)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=e.priority==null?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((e.priority==null?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=_p(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=_p(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new e(t,e.schemaRules(t)))}},op={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},sp={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},cp={ol:!0,ul:!0},lp=1,up=2,dp=4;function fp(e,t,n){return t==null?e&&e.whitespace==`pre`?3:n&-5:(t?lp:0)|(t===`full`?up:0)}var pp=class{constructor(e,t,n,r,i,a){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=a,this.content=[],this.activeMarks=uf.none,this.match=i||(a&dp?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(X.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let t=this.type.contentMatch,n;return(n=t.findWrapping(e.type))?(this.match=t,n):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&lp)){let e=this.content[this.content.length-1],t;if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let t=X.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(X.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!op.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},mp=class{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,a=fp(null,t.preserveWhitespace,0)|(n?dp:0);i=r?new pp(r.type,r.attrs,uf.none,!0,t.topMatch||r.type.contentMatch,a):n?new pp(null,null,uf.none,!0,null,a):new pp(e.schema.topNodeType,null,uf.none,!0,null,a),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,i=r.options&up?`full`:this.localPreserveWS||(r.options&lp)>0,{schema:a}=this.parser;if(i===`full`||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(!i){if(n=n.replace(/[ \t\r\n\u000c]+/g,` `),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],i=e.previousSibling;(!t||i&&i.nodeName==`BR`||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}}else if(i===`full`)n=n.replace(/\r\n?/g,`
10
10
  `);else if(a.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(a.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(a.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(a.text(e[n]),t,!/\S/.test(e[n]));n=``}else n=n.replace(/\r?\n|\r/g,` `);n&&this.insertNode(a.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,i=this.top;(e.tagName==`PRE`||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let a=e.nodeName.toLowerCase(),o;cp.hasOwnProperty(a)&&this.parser.normalizeLists&&hp(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,n));out:if(s?s.ignore:sp.hasOwnProperty(a))this.findInside(e),this.ignoreFallback(e,t);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let n,r=this.needsBlock;if(op.hasOwnProperty(a))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),n=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break out}let o=s&&s.skip?t:this.readStyles(e,t);o&&this.addAll(e,o),n&&this.sync(i),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,s,n,s.consuming===!1?o:void 0)}this.localPreserveWS=r}leafFallback(e,t){e.nodeName==`BR`&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
11
11
  `),t)}ignoreFallback(e,t){e.nodeName==`BR`&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text(`-`),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],i=n.getPropertyValue(r);if(i)for(let e;;){let n=this.parser.matchStyle(r,i,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),n.consuming===!1)e=n;else break}}return t}addElementByRule(e,t,n,r){let i,a;if(t.node)if(a=this.parser.schema.nodes[t.node],a.isLeaf)this.insertNode(a.create(t.attrs),n,e.nodeName==`BR`)||this.leafFallback(e,n);else{let e=this.enter(a,t.attrs||null,n,t.preserveWhitespace);e&&(i=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let o=this.top;if(a&&a.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;typeof t.contentElement==`string`?r=e.querySelector(t.contentElement):typeof t.contentElement==`function`?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}i&&this.sync(o)&&this.open--}addAll(e,t,n,r){let i=n||0;for(let a=n?e.childNodes[n]:e.firstChild,o=r==null?null:e.childNodes[r];a!=o;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a,t);this.findAtPoint(e,i)}findPlace(e,t,n){let r,i;for(let t=this.open,a=0;t>=0;t--){let o=this.nodes[t],s=o.findWrapping(e);if(s&&(!r||r.length>s.length+a)&&(r=s,i=o,!s.length))break;if(o.solid){if(n)break;a+=2}}if(!r)return null;this.sync(i);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&=t.match.matchType(e.type);let n=uf.none;for(let i of r.concat(e.marks))(t.type?t.type.allowsMarkType(i.type):vp(i.type,e.type))&&(n=i.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let i=this.findPlace(e.create(t),n,!1);return i&&=this.enterInner(e,t,n,!0,r),i}enterInner(e,t,n,r=!1,i){this.closeExtra();let a=this.top;a.match=a.match&&a.match.matchType(e);let o=fp(e,i,a.options);a.options&dp&&a.content.length==0&&(o|=dp);let s=uf.none;return n=n.filter(t=>(a.type?a.type.allowsMarkType(t.type):vp(t.type,e))?(s=t.addToSet(s),!1):!0),this.nodes.push(new pp(e,t,s,r,null,o)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;else this.localPreserveWS&&(this.nodes[t].options|=lp);return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf(`|`)>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split(`/`),n=this.options.context,r=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+ +!r,a=(e,o)=>{for(;e>=0;e--){let s=t[e];if(s==``){if(e==t.length-1||e==0)continue;for(;o>=i;o--)if(a(e-1,o))return!0;return!1}else{let e=o>0||o==0&&r?this.nodes[o].type:n&&o>=i?n.node(o-i).type:null;if(!e||e.name!=s&&!e.isInGroup(s))return!1;o--}}return!0};return a(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}};function hp(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=t.nodeType==1?t.nodeName.toLowerCase():null;e&&cp.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):e==`li`?n=t:e&&(n=null)}}function gp(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function _p(e){let t={};for(let n in e)t[n]=e[n];return t}function vp(e,t){let n=t.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(e))continue;let a=[],o=e=>{a.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:i}=e.edge(n);if(r==t||a.indexOf(i)<0&&o(i))return!0}};if(o(i.contentMatch))return!0}}var yp=class e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||=xp(t).createDocumentFragment();let r=n,i=[];return e.forEach(e=>{if(i.length||e.marks.length){let n=0,a=0;for(;n<i.length&&a<e.marks.length;){let t=e.marks[a];if(!this.marks[t.type.name]){a++;continue}if(!t.eq(i[n][0])||t.type.spec.spanning===!1)break;n++,a++}for(;n<i.length;)r=i.pop()[1];for(;a<e.marks.length;){let n=e.marks[a++],o=this.serializeMark(n,e.isInline,t);o&&(i.push([n,r]),r.appendChild(o.dom),r=o.contentDOM||o.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return xp(t).createTextNode(e.text);let{dom:n,contentDOM:r}=Tp(xp(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw RangeError(`Content hole not allowed in a leaf node spec`);this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&Tp(xp(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return typeof t==`string`?{dom:e.createTextNode(t)}:Tp(e,t,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new e(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(e){let t=bp(e.nodes);return t.text||=e=>e.text,t}static marksFromSchema(e){return bp(e.marks)}};function bp(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function xp(e){return e.document||window.document}var Sp=new WeakMap;function Cp(e){let t=Sp.get(e);return t===void 0&&Sp.set(e,t=wp(e)),t}function wp(e){let t=null;function n(e){if(e&&typeof e==`object`)if(Array.isArray(e))if(typeof e[0]==`string`)t||=[],t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}function Tp(e,t,n,r){if(t.nodeType==1)return{dom:t};if(t.dom&&t.dom.nodeType==1)return t;let i=t[0],a;if(typeof i!=`string`)throw RangeError(`Invalid array passed to renderSpec`);if(r&&(a=Cp(r))&&a.indexOf(t)>-1)throw RangeError(`Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.`);let o=i.indexOf(` `);o>0&&(n=i.slice(0,o),i=i.slice(o+1));let s,c=n?e.createElementNS(n,i):e.createElement(i),l=t[1],u=1;if(l&&typeof l==`object`&&l.nodeType==null&&!Array.isArray(l)){u=2;for(let e in l)if(l[e]!=null){let t=e.indexOf(` `);t>0?c.setAttributeNS(e.slice(0,t),e.slice(t+1),l[e]):e==`style`&&c.style?c.style.cssText=l[e]:c.setAttribute(e,l[e])}}for(let i=u;i<t.length;i++){let a=t[i];if(a===0){if(i<t.length-1||i>u)throw RangeError(`Content hole must be the only child of its parent node`);return{dom:c,contentDOM:c}}else if(typeof a==`string`)c.appendChild(e.createTextNode(a));else{let{dom:t,contentDOM:i}=Tp(e,a,n,r);if(c.appendChild(t),i){if(s)throw RangeError(`Multiple content holes`);s=i}}}return{dom:c,contentDOM:s}}var Ep=65535,Dp=2**16;function Op(e,t){return e+t*Dp}function kp(e){return e&Ep}function Ap(e){return(e-(e&Ep))/Dp}var jp=1,Mp=2,Np=4,Pp=8,Fp=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Pp)>0}get deletedBefore(){return(this.delInfo&5)>0}get deletedAfter(){return(this.delInfo&6)>0}get deletedAcross(){return(this.delInfo&Np)>0}},Ip=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=kp(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+Ap(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:Op(o/3,e-s),f=e==s?Mp:e==u?jp:Np;return(t<0?e!=s:e!=u)&&(f|=Pp),new Fp(a,f,d)}r+=l-c}return n?e+r:new Fp(e+r,0,null)}touches(e,t){let n=0,r=kp(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};Ip.empty=new Ip([]);var Lp=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new Fp(e,r,null)}},Rp=Object.create(null),zp=class{getMap(){return Ip.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=Rp[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Rp)throw RangeError(`Duplicate use of step JSON ID `+e);return Rp[e]=t,t.prototype.jsonID=e,t}},Bp=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof df)return e.fail(t.message);throw t}}};function Vp(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Vp(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return X.fromArray(r)}var Hp=class e extends zp{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new Z(Vp(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return Bp.fromReplace(e,this.from,this.to,i)}invert(){return new Up(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};zp.jsonID(`addMark`,Hp);var Up=class e extends zp{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new Z(Vp(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return Bp.fromReplace(e,this.from,this.to,n)}invert(){return new Hp(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};zp.jsonID(`removeMark`,Up);var Wp=class e extends zp{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Bp.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return Bp.fromReplace(e,this.pos,this.pos+1,new Z(X.from(n),0,+!t.isLeaf))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new Gp(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};zp.jsonID(`addNodeMark`,Wp);var Gp=class e extends zp{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return Bp.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return Bp.fromReplace(e,this.pos,this.pos+1,new Z(X.from(n),0,+!t.isLeaf))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Wp(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};zp.jsonID(`removeNodeMark`,Gp);var Kp=class e extends zp{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Jp(e,this.from,this.to)?Bp.fail(`Structure replace would overwrite content`):Bp.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ip([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.to,-1),r=this.from==this.to&&e.MAP_BIAS<0?n:t.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new e(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?Z.empty:new Z(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?Z.empty:new Z(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,Z.fromJSON(t,n.slice),!!n.structure)}};Kp.MAP_BIAS=1,zp.jsonID(`replace`,Kp);var qp=class e extends zp{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(Jp(e,this.from,this.gapFrom)||Jp(e,this.gapTo,this.to)))return Bp.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return Bp.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?Bp.fromReplace(e,this.from,this.to,n):Bp.fail(`Content does not fit in gap`)}getMap(){return new Ip([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,Z.fromJSON(t,n.slice),n.insert,!!n.structure)}};zp.jsonID(`replaceAround`,qp);function Jp(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function Yp(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new Up(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new Hp(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function Xp(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof ep){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new Up(t.from,t.to,t.style)))}function Zp(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new Kp(s,l,Z.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Up(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new Z(X.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new Kp(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(X.empty,!0);e.replace(s,s,new Z(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Qp(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function $p(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Qp(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function em(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=X.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=X.from(r.node(e).copy(u)),d++):c--;let f=X.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=X.from(i.node(e).copy(f)),p++):l++;e.step(new qp(c,l,o,s,new Z(u.append(f),d,p),u.size-d,!0))}function tm(e,t,n=null,r=e){let i=rm(e,t),a=i&&im(r,t);return a?i.map(nm).concat({type:t,attrs:n}).concat(a.map(nm)):null}function nm(e){return{type:e,attrs:null}}function rm(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.contentMatchAt(r).findWrapping(t);if(!a)return null;let o=a.length?a[0]:t;return n.canReplaceWith(r,i,o)?a:null}function im(e,t){let{parent:n,startIndex:r,endIndex:i}=e,a=n.child(r),o=t.contentMatch.findWrapping(a.type);if(!o)return null;let s=(o.length?o[o.length-1]:t).contentMatch;for(let e=r;s&&e<i;e++)s=s.matchType(n.child(e).type);return!s||!s.validEnd?null:o}function am(e,t,n){let r=X.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=X.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new qp(i,a,i,a,new Z(r,0,0),n.length,!0))}function om(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&lm(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&cm(e,t,n,a),Zp(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new qp(c,l,c+1,l-1,new Z(X.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&sm(e,t,n,a),!1}})}function sm(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function cm(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
@@ -149,4 +149,4 @@ ${t.innerHTML}
149
149
  `),c=a.map(e=>e.segment).join(`
150
150
  `),l=(0,J.useMemo)(()=>Pe(s?s.split(`
151
151
  `):[],c?c.split(`
152
- `):[]),[s,c]),u=r&&o,f=(0,J.useMemo)(()=>Qc(n),[n]),{route:p,go:m}=zd(l),{projectId:h,agentId:g}=p,v=p.page??null;(0,J.useEffect)(()=>{u&&m(p,{replace:!0,keepQuery:!0})},[u,l]);let y=p.scope&&n.some(e=>e.id===p.scope)?p.scope:null;(0,J.useEffect)(()=>{y&&wB(y)},[y]);let b=y===null&&(p.scope!==void 0||v!==null)&&!u,x=(0,J.useMemo)(()=>y?n.filter(e=>e.id===y):n,[n,y]),S=(0,J.useMemo)(()=>y?a.filter(e=>e.projects.includes(y)):a,[a,y]),C=v?S.find(e=>e.segment===v):void 0,w=(e,t)=>m({...e,...y?{scope:e.scope??e.projectId??y}:{}},t),T=e=>{let{scope:t,...n}=p;if(n.projectId!==null){if(e===null)return m(n,{keepQuery:!0});if(n.projectId!==e)return m(n.agentId===null?{projectId:e,agentId:null,scope:e}:{projectId:null,agentId:null,scope:e})}let r=a.find(e=>e.segment===n.page);if(e!==null&&r&&!r.projects.includes(e))return m({projectId:null,agentId:null,scope:e});let{pagePath:i,...o}=n;m({...o,...e===null?{}:{scope:e}},{keepQuery:!i?.length})},[E,D]=(0,J.useState)({tick:0,intent:``,id:null,projectId:null,at:0}),O=u?h??y:null,{agents:k,reload:A,loaded:j}=BW(O,E.id!==null&&E.projectId===O?E.id:null,h===null?1e4:2e3),M=Vd(),{context:N,add:F,remove:ee,toggle:te,reset:I}=M;(0,J.useEffect)(()=>{I()},[h,g]);let{value:L}=xi(h?()=>uo(h,g??void 0):null,oG,1e4,[h,g]),{value:R,stale:ne}=xi(so,cG,5e3,[],{remember:`interventions`,stored:!0}),re=h?n.find(e=>e.id===h):void 0,ie=re?f.get(re.id)??re.name:null,ae=y?R.items.filter(e=>e.projectId===y):R.items;ZW(ae.length,ie??(y?f.get(y)??null:null));let z=h!==null&&n.length>0&&!n.some(e=>e.id===h),oe=Ia();JW(ne?cG:R,Ha(oe)&&Ba(oe));let B=Va(oe)&&Ba(oe),{value:se}=xi(B?co:null,lG,15e3,[B],void 0,LW(void 0));YW(se,B);let ce=y===null&&!b,le=RW(1e4),{value:ue,reload:de,loaded:fe}=xi(ce?oo:null,uG,le,[ce],void 0,LW(void 0)),pe=E.id===null?void 0:ue.find(e=>e.agent.id===E.id&&e.projectId===E.projectId),me=ce&&E.id!==null&&Date.now()-E.at<3e4&&(pe===void 0||Yc(pe.agent,oe.nameRuns!==!1));(0,J.useEffect)(()=>{if(!me)return;let e=setInterval(()=>void de(),1e3),t=setTimeout(()=>clearInterval(e),zW);return()=>{clearInterval(e),clearTimeout(t)}},[me,de]);let he=(e,t,n,r,i)=>{let a=n===g&&e===h;D(o=>({tick:a?o.tick:o.tick+1,intent:t,id:n,projectId:e,at:Date.now(),...r?{runsOn:r}:{},...i?{picks:i}:{}})),I(),w({projectId:e,agentId:n}),A(),de(),!a&&oe.nameRuns!==!1&&e!==null&&xo(e,n).then(e=>{e!==void 0&&D(t=>t.id===n?{...t,title:e}:t)},()=>{})},ge=(e,n,r,i,a)=>{i!==void 0&&i!==h&&t(e=>e+1),he(i??h,e,n,r,a)},_e=e=>{w({projectId:h,agentId:e})},ve=e=>{w({projectId:e,agentId:null})},ye=(e,t)=>{w({projectId:e,agentId:t})},be=e=>{w({projectId:e,agentId:null}),I()},xe=()=>{w({projectId:null,agentId:null})},Se=(e=``)=>{m({...p,settings:e},{keepQuery:!0})},Ce=e=>{let{settingsItem:t,...n}=p;m({...n,settings:e},{keepQuery:!0,replace:!0})},we=()=>{let{settings:e,settingsItem:t,...n}=p;m(n,{keepQuery:!0})},Te=e=>{w({projectId:null,agentId:null,page:e})},Ee=or({openAgent:ye,openPage:(e,t,n)=>w({projectId:null,agentId:null,page:e,...t&&t.length?{pagePath:t}:{},...n?{scope:n}:{}}),pageHref:e=>jd({projectId:null,agentId:null,page:e,...y?{scope:y}:{}},l),openSettings:e=>Se(e),gitHostPeople:Zo,startRun:async(e,t,n)=>{let r=await Mo(e,t,yd(oe));return r.ok&&(n?.land??!0?he(e,t,r.agentId):A()),r},configureRun:(e,t)=>{_(t),ve(e)},agents:(e,t)=>UW(e,t),machines:async()=>{let e=await yr(),t=vd(e.name);return{...e,...t===void 0?{}:{name:t}}},addMachine:async(e,t)=>{let n=await Os(e,t);return n.ok?{ok:!0}:n},removeMachine:Ns,renameMachine:async(e,t)=>{let n=await ks(e,t);return n.ok?{ok:!0}:n},renameComputer:async e=>{let t=await As(e);return t.ok?{ok:!0}:t},letMachineIn:cr,machineCode:xn,computersThrough:Bt,machinePerson:Tn,removeMachineDevice:si,machineAccounts:async(e,t)=>{let n=await Zt(e,t);return n&&n.accounts.map((e,t)=>({id:e.id,name:e.name,own:e.own,...e.from===void 0?{}:{from:e.from},first:e.state===`in-use`||t===0&&n.accounts.length===1}))},removeMachineAccount:kr,useLoginsOn:$o,addComputerThrough:async(e,t)=>{let n=await js(e,t);return n.ok?{ok:!0}:n},watchScreen:_W,sendToScreen:vW}),{events:De,lost:Oe,writing:ke}=SW(h,g,E.tick),Ae=De.filter(e=>e.kind===`end`).length;(0,J.useEffect)(()=>{Ae>0&&A()},[Ae]);let V=$W(),je=V.active.length>0;rG(je);let Me=aG(),Ne=g?k.find(e=>e.id===g)??(j?void 0:ue.find(e=>e.projectId===h&&e.agent.id===g)?.agent):void 0,Fe=(0,J.useMemo)(()=>g?ll(k,g):[],[k,g]),Ie=()=>{t(e=>e+1),m({projectId:null,agentId:null})},Le=re?.machine===void 0?Ie:void 0,Re=()=>{if(v)return C?(0,Y.jsx)(dF,{page:C,projects:x,projectId:y,path:p.pagePath??[]}):u?(0,Y.jsx)(hW,{title:`No such page`,detail:y!==null&&a.some(e=>e.segment===v)?`The project "${n.find(e=>e.id===y)?.name??y}" has no package that adds a page at "${v}".`:p.scope===void 0?`No project has the address "/${v}", and no installed package adds a page there.`:`No installed package adds a page at "${v}".`,actionLabel:`Go to the Overview`,onAction:xe}):null;if(!h)return b?null:(0,Y.jsx)(pB,{onSelectProject:ve,onSelectAgent:ye,onAgentStarted:he,interventions:ae,interventionsStale:ne,active:V,projects:n,scope:y});if(z)return(0,Y.jsx)(hW,{title:`No such project`,detail:`No project is registered as "${h}". It may have been removed, or the link may be from another machine.`,actionLabel:`Go to the Overview`,onAction:xe});if(g===null)return(0,Y.jsx)(sz,{projectId:h,projectName:ie,home:re?.machine,waiting:ae,events:De,onAgentStarted:ge,files:L,context:N,addContext:F,removeContext:ee,toggleContext:te,onOpenAgent:ye,errors:re?.errors,onProjectRemoved:Ie,onSkillsChanged:()=>t(e=>e+1)});let e=g===E.id?E.title:void 0;return Ne?(0,Y.jsx)(rW,{projectId:h,agentId:g,events:De,live:Ne.status===`running`,card:Ne,label:Ne.parent===void 0?Yc(Ne,oe.nameRuns!==!1)?e:Jc(Ne):ul(Ne),naming:Ne.parent===void 0&&Yc(Ne,oe.nameRuns!==!1)&&e===void 0,projectName:ie,files:L,lost:Oe,writing:ke,startedWith:g===E.id?E.intent:void 0,picks:g===E.id?E.picks:void 0,target:Ne.target,remoteLabel:Ne.remoteLabel,subagents:Fe,onAgentStarted:ge,contextSet:M,onDeleted:()=>{_e(null),A()},onProjectRemoved:Le}):g===E.id||!j?(0,Y.jsx)(rW,{projectId:h,agentId:g,events:De,live:g===E.id||null,picks:g===E.id?E.picks:void 0,label:oe.nameRuns===!1?E.intent||void 0:e,naming:g===E.id&&oe.nameRuns!==!1&&e===void 0,projectName:ie,remoteLabel:g===E.id?E.runsOn:void 0,files:L,lost:Oe,writing:ke,startedWith:g===E.id?E.intent:void 0,onAgentStarted:ge,contextSet:M,onProjectRemoved:Le}):(0,Y.jsx)(hW,{title:`This agent is gone`,detail:`There is no record of this agent. Once its checkout is removed, a finished agent is kept only when the project has a logs skill installed.`,actionLabel:`Back to the project`,onAction:()=>_e(null)})},ze=br(),Be=Qu(),Ve=rd(),He=v?C?.label??``:h===null?`Overview`:null,Ue=He!==null;return(0,J.useEffect)(()=>{if(Ue)return;document.documentElement.dataset.pinned=`true`;let e=window.visualViewport,t=document.documentElement,n=()=>{if(e){if(!fG()){t.style.removeProperty(`--shown-height`),t.style.removeProperty(`--shown-top`),(window.scrollY!==0||e.offsetTop!==0)&&window.scrollTo(0,0);return}t.style.setProperty(`--shown-height`,`${e.height}px`),t.style.setProperty(`--shown-top`,`${e.offsetTop}px`)}},r=0,i=0,a=()=>{n(),r=performance.now()<i?requestAnimationFrame(a):0},o=()=>{i=performance.now()+dG,n(),r===0&&(r=requestAnimationFrame(a))};return n(),e?.addEventListener(`resize`,o),e?.addEventListener(`scroll`,o),document.addEventListener(`focusin`,o),document.addEventListener(`focusout`,o),()=>{delete t.dataset.pinned,t.style.removeProperty(`--shown-height`),t.style.removeProperty(`--shown-top`),cancelAnimationFrame(r),e?.removeEventListener(`resize`,o),e?.removeEventListener(`scroll`,o),document.removeEventListener(`focusin`,o),document.removeEventListener(`focusout`,o)}},[Ue]),(0,Y.jsx)(fr.Provider,{value:i,children:(0,Y.jsx)(P.Provider,{value:Ee,children:(0,Y.jsx)(Oa.Provider,{value:h,children:(0,Y.jsx)(tl.Provider,{value:f,children:(0,Y.jsxs)(d,{open:!Ve,onOpenChange:e=>nd(!e),className:Ue?`min-h-dvh flex-col`:`fixed inset-x-0 top-(--shown-top,0px) h-(--shown-height,100dvh) min-h-0 flex-col overflow-hidden`,style:{"--sidebar-width":`${Be}px`},children:[!Me&&(0,Y.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 border-b border-border bg-warning/10 px-4 py-2 text-xs text-warning`,children:[(0,Y.jsx)(Gc,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),`The daemon is not answering — retrying. Everything on this page is frozen until it returns.`]}),(0,Y.jsxs)(`div`,{className:q(`relative flex min-h-0 flex-1`,Ue?`overflow-x-clip`:`overflow-hidden`),children:[(0,Y.jsx)(ld,{pageScrolls:Ue,projectId:h,scope:y,scopePending:b,listLoaded:y===null?fe:j,onScope:T,homeHref:jd({projectId:null,agentId:null,...y?{scope:y}:{}},l),agents:k,selectedAgentId:g,onSelect:e=>w({projectId:y??h,agentId:e}),recentAgents:ue,onSelectRecent:ye,projects:n,onNewAgentInProject:be,onProjectAdded:()=>{t(e=>e+1),A()},startTick:E.tick,startIntent:E.intent,startTitle:E.title,startId:E.id,startProjectName:E.projectId===null?void 0:f.get(E.projectId),working:je,onDashboard:xe,onSettings:Se,pages:S,activePage:v,onPage:Te,interventionCount:ae.length}),ze&&!Ue&&(0,Y.jsx)(pW,{}),(0,Y.jsx)(KR,{projectId:h,agentId:g,enabled:!v,files:L,context:N,toggleContext:te,activity:De.length,subagent:h&&g?(0,Y.jsx)(sW,{projectId:h,agentId:g,events:De,subagents:Fe,live:Ne?.status===`running`,onOpenAgent:_e}):void 0,children:(0,Y.jsx)($R,{children:(0,Y.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[ze&&He!==null&&(0,Y.jsx)(mW,{title:He}),Re()]})})})]}),i.everyPage.map(({EveryPage:e,package:t})=>(0,Y.jsx)(lF,{package:t,label:`${t} popup`,children:(0,Y.jsx)(e,{})},t)),p.settings!==void 0&&(0,Y.jsx)(NB,{entry:p.settings,openItem:p.settingsItem,onEntry:Ce,onClose:we,scope:y,projects:n})]})})})})})}var mG=document.getElementById(`root`);if(!mG)throw Error(`no #root in index.html`);var hG=(0,Pi.createRoot)(mG);(0,Ni.flushSync)(()=>hG.render((0,Y.jsx)(Xa,{children:(0,Y.jsx)(pG,{})})));
152
+ `):[]),[s,c]),u=r&&o,f=(0,J.useMemo)(()=>Qc(n),[n]),{route:p,go:m}=zd(l),{projectId:h,agentId:g}=p,v=p.page??null;(0,J.useEffect)(()=>{u&&m(p,{replace:!0,keepQuery:!0})},[u,l]);let y=p.scope&&n.some(e=>e.id===p.scope)?p.scope:null;(0,J.useEffect)(()=>{y&&wB(y)},[y]);let b=y===null&&(p.scope!==void 0||v!==null)&&!u,x=(0,J.useMemo)(()=>y?n.filter(e=>e.id===y):n,[n,y]),S=(0,J.useMemo)(()=>y?a.filter(e=>e.projects.includes(y)):a,[a,y]),C=v?S.find(e=>e.segment===v):void 0,w=(e,t)=>m({...e,...y?{scope:e.scope??e.projectId??y}:{}},t),T=e=>{let{scope:t,...n}=p;if(n.projectId!==null){if(e===null)return m(n,{keepQuery:!0});if(n.projectId!==e)return m(n.agentId===null?{projectId:e,agentId:null,scope:e}:{projectId:null,agentId:null,scope:e})}let r=a.find(e=>e.segment===n.page);if(e!==null&&r&&!r.projects.includes(e))return m({projectId:null,agentId:null,scope:e});let{pagePath:i,...o}=n;m({...o,...e===null?{}:{scope:e}},{keepQuery:!i?.length})},[E,D]=(0,J.useState)({tick:0,intent:``,id:null,projectId:null,at:0}),O=u?h??y:null,{agents:k,reload:A,loaded:j}=BW(O,E.id!==null&&E.projectId===O?E.id:null,h===null?1e4:2e3),M=Vd(),{context:N,add:F,remove:ee,toggle:te,reset:I}=M;(0,J.useEffect)(()=>{I()},[h,g]);let{value:L}=xi(h?()=>uo(h,g??void 0):null,oG,1e4,[h,g]),{value:R,stale:ne}=xi(so,cG,5e3,[],{remember:`interventions`,stored:!0}),re=h?n.find(e=>e.id===h):void 0,ie=re?f.get(re.id)??re.name:null,ae=y?R.items.filter(e=>e.projectId===y):R.items;ZW(ae.length,ie??(y?f.get(y)??null:null));let z=h!==null&&n.length>0&&!n.some(e=>e.id===h),oe=Ia();JW(ne?cG:R,Ha(oe)&&Ba(oe));let B=Va(oe)&&Ba(oe),{value:se}=xi(B?co:null,lG,15e3,[B],void 0,LW(void 0));YW(se,B);let ce=y===null&&!b,le=RW(1e4),{value:ue,reload:de,loaded:fe}=xi(ce?oo:null,uG,le,[ce],void 0,LW(void 0)),pe=E.id===null?void 0:ue.find(e=>e.agent.id===E.id&&e.projectId===E.projectId),me=ce&&E.id!==null&&Date.now()-E.at<3e4&&(pe===void 0||Yc(pe.agent,oe.nameRuns!==!1));(0,J.useEffect)(()=>{if(!me)return;let e=setInterval(()=>void de(),1e3),t=setTimeout(()=>clearInterval(e),zW);return()=>{clearInterval(e),clearTimeout(t)}},[me,de]);let he=(e,t,n,r,i)=>{let a=n===g&&e===h;D(o=>({tick:a?o.tick:o.tick+1,intent:t,id:n,projectId:e,at:Date.now(),...r?{runsOn:r}:{},...i?{picks:i}:{}})),I(),w({projectId:e,agentId:n}),A(),de(),!a&&oe.nameRuns!==!1&&e!==null&&xo(e,n).then(e=>{e!==void 0&&D(t=>t.id===n?{...t,title:e}:t)},()=>{})},ge=(e,n,r,i,a)=>{i!==void 0&&i!==h&&t(e=>e+1),he(i??h,e,n,r,a)},_e=e=>{w({projectId:h,agentId:e})},ve=e=>{w({projectId:e,agentId:null})},ye=(e,t)=>{w({projectId:e,agentId:t})},be=e=>{w({projectId:e,agentId:null}),I()},xe=()=>{w({projectId:null,agentId:null})},Se=(e=``)=>{m({...p,settings:e},{keepQuery:!0})},Ce=e=>{let{settingsItem:t,...n}=p;m({...n,settings:e},{keepQuery:!0,replace:!0})},we=()=>{let{settings:e,settingsItem:t,...n}=p;m(n,{keepQuery:!0})},Te=e=>{w({projectId:null,agentId:null,page:e})},Ee=or({openAgent:ye,openPage:(e,t,n)=>w({projectId:null,agentId:null,page:e,...t&&t.length?{pagePath:t}:{},...n?{scope:n}:{}}),pageHref:e=>jd({projectId:null,agentId:null,page:e,...y?{scope:y}:{}},l),openSettings:e=>Se(e),gitHostPeople:Zo,startRun:async(e,t,n)=>{let r=await Mo(e,t,yd(oe));return r.ok&&(n?.land??!0?he(e,t,r.agentId):A()),r},configureRun:(e,t)=>{_(t),ve(e)},agents:(e,t)=>UW(e,t),machines:async()=>{let e=await yr(),t=vd(e.name);return{...e,...t===void 0?{}:{name:t}}},addMachine:async(e,t)=>{let n=await Os(e,t);return n.ok?{ok:!0}:n},removeMachine:Ns,renameMachine:async(e,t)=>{let n=await ks(e,t);return n.ok?{ok:!0}:n},renameComputer:async e=>{let t=await As(e);return t.ok?{ok:!0}:t},letMachineIn:cr,machineCode:xn,computersThrough:Bt,machinePerson:Tn,removeMachineDevice:si,machineAccounts:async(e,t)=>{let n=await Zt(e,t);return n&&n.accounts.map((e,t)=>({id:e.id,name:e.name,own:e.own,...e.from===void 0?{}:{from:e.from},first:e.state===`in-use`||t===0&&n.accounts.length===1}))},removeMachineAccount:kr,useLoginsOn:$o,addComputerThrough:async(e,t)=>{let n=await js(e,t);return n.ok?{ok:!0}:n},watchScreen:_W,sendToScreen:vW}),{events:De,lost:Oe,writing:ke}=SW(h,g,E.tick),Ae=De.filter(e=>e.kind===`end`).length;(0,J.useEffect)(()=>{Ae>0&&A()},[Ae]);let V=$W(),je=V.active.length>0;rG(je);let Me=aG(),Ne=g?k.find(e=>e.id===g)??(j?void 0:ue.find(e=>e.projectId===h&&e.agent.id===g)?.agent):void 0,Fe=(0,J.useMemo)(()=>g?ll(k,g):[],[k,g]),Ie=()=>{t(e=>e+1),m({projectId:null,agentId:null})},Le=re?.machine===void 0?Ie:void 0,Re=()=>{if(v)return C?(0,Y.jsx)(dF,{page:C,projects:x,projectId:y,path:p.pagePath??[]}):u?(0,Y.jsx)(hW,{title:`No such page`,detail:y!==null&&a.some(e=>e.segment===v)?`The project "${n.find(e=>e.id===y)?.name??y}" has no package that adds a page at "${v}".`:p.scope===void 0?`No project has the address "/${v}", and no installed package adds a page there.`:`No installed package adds a page at "${v}".`,actionLabel:`Go to the Overview`,onAction:xe}):null;if(!h)return b?null:(0,Y.jsx)(pB,{onSelectProject:ve,onSelectAgent:ye,onAgentStarted:he,interventions:ae,interventionsStale:ne,active:V,projects:n,scope:y});if(z)return(0,Y.jsx)(hW,{title:`No such project`,detail:`No project is registered as "${h}". It may have been removed, or the link may be from another machine.`,actionLabel:`Go to the Overview`,onAction:xe});if(g===null)return(0,Y.jsx)(sz,{projectId:h,projectName:ie,home:re?.machine,waiting:ae,events:De,onAgentStarted:ge,files:L,context:N,addContext:F,removeContext:ee,toggleContext:te,onOpenAgent:ye,errors:re?.errors,onProjectRemoved:Ie,onSkillsChanged:()=>t(e=>e+1)});let e=g===E.id?E.title:void 0;return Ne?(0,Y.jsx)(rW,{projectId:h,agentId:g,events:De,live:Ne.status===`running`,card:Ne,label:Ne.parent===void 0?Yc(Ne,oe.nameRuns!==!1)?e:Jc(Ne):ul(Ne),naming:Ne.parent===void 0&&Yc(Ne,oe.nameRuns!==!1)&&e===void 0,projectName:ie,files:L,lost:Oe&&Me,writing:ke,startedWith:g===E.id?E.intent:void 0,picks:g===E.id?E.picks:void 0,target:Ne.target,remoteLabel:Ne.remoteLabel,subagents:Fe,onAgentStarted:ge,contextSet:M,onDeleted:()=>{_e(null),A()},onProjectRemoved:Le}):g===E.id||!j?(0,Y.jsx)(rW,{projectId:h,agentId:g,events:De,live:g===E.id||null,picks:g===E.id?E.picks:void 0,label:oe.nameRuns===!1?E.intent||void 0:e,naming:g===E.id&&oe.nameRuns!==!1&&e===void 0,projectName:ie,remoteLabel:g===E.id?E.runsOn:void 0,files:L,lost:Oe&&Me,writing:ke,startedWith:g===E.id?E.intent:void 0,onAgentStarted:ge,contextSet:M,onProjectRemoved:Le}):(0,Y.jsx)(hW,{title:`This agent is gone`,detail:`There is no record of this agent. Once its checkout is removed, a finished agent is kept only when the project has a logs skill installed.`,actionLabel:`Back to the project`,onAction:()=>_e(null)})},ze=br(),Be=Qu(),Ve=rd(),He=v?C?.label??``:h===null?`Overview`:null,Ue=He!==null;return(0,J.useEffect)(()=>{if(Ue)return;document.documentElement.dataset.pinned=`true`;let e=window.visualViewport,t=document.documentElement,n=()=>{if(e){if(!fG()){t.style.removeProperty(`--shown-height`),t.style.removeProperty(`--shown-top`),(window.scrollY!==0||e.offsetTop!==0)&&window.scrollTo(0,0);return}t.style.setProperty(`--shown-height`,`${e.height}px`),t.style.setProperty(`--shown-top`,`${e.offsetTop}px`)}},r=0,i=0,a=()=>{n(),r=performance.now()<i?requestAnimationFrame(a):0},o=()=>{i=performance.now()+dG,n(),r===0&&(r=requestAnimationFrame(a))};return n(),e?.addEventListener(`resize`,o),e?.addEventListener(`scroll`,o),document.addEventListener(`focusin`,o),document.addEventListener(`focusout`,o),()=>{delete t.dataset.pinned,t.style.removeProperty(`--shown-height`),t.style.removeProperty(`--shown-top`),cancelAnimationFrame(r),e?.removeEventListener(`resize`,o),e?.removeEventListener(`scroll`,o),document.removeEventListener(`focusin`,o),document.removeEventListener(`focusout`,o)}},[Ue]),(0,Y.jsx)(fr.Provider,{value:i,children:(0,Y.jsx)(P.Provider,{value:Ee,children:(0,Y.jsx)(Oa.Provider,{value:h,children:(0,Y.jsx)(tl.Provider,{value:f,children:(0,Y.jsxs)(d,{open:!Ve,onOpenChange:e=>nd(!e),className:Ue?`min-h-dvh flex-col`:`fixed inset-x-0 top-(--shown-top,0px) h-(--shown-height,100dvh) min-h-0 flex-col overflow-hidden`,style:{"--sidebar-width":`${Be}px`,...Me?{}:{"--top-banner":`2.25rem`}},children:[!Me&&(0,Y.jsx)(`div`,{role:`alert`,className:q(`h-(--top-banner) shrink-0 bg-background`,Ue&&`sticky top-0 z-30`),children:(0,Y.jsxs)(`div`,{className:`flex h-full items-center gap-2 border-b border-border bg-warning/10 px-4 text-xs text-warning`,children:[(0,Y.jsx)(Gc,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),`The daemon is not answering — retrying. Everything on this page is frozen until it returns.`]})}),(0,Y.jsxs)(`div`,{className:q(`relative flex min-h-0 flex-1`,Ue?`overflow-x-clip`:`overflow-hidden`),children:[(0,Y.jsx)(ld,{pageScrolls:Ue,projectId:h,scope:y,scopePending:b,listLoaded:y===null?fe:j,onScope:T,homeHref:jd({projectId:null,agentId:null,...y?{scope:y}:{}},l),agents:k,selectedAgentId:g,onSelect:e=>w({projectId:y??h,agentId:e}),recentAgents:ue,onSelectRecent:ye,projects:n,onNewAgentInProject:be,onProjectAdded:()=>{t(e=>e+1),A()},startTick:E.tick,startIntent:E.intent,startTitle:E.title,startId:E.id,startProjectName:E.projectId===null?void 0:f.get(E.projectId),working:je,onDashboard:xe,onSettings:Se,pages:S,activePage:v,onPage:Te,interventionCount:ae.length}),ze&&!Ue&&(0,Y.jsx)(pW,{}),(0,Y.jsx)(KR,{projectId:h,agentId:g,enabled:!v,files:L,context:N,toggleContext:te,activity:De.length,subagent:h&&g?(0,Y.jsx)(sW,{projectId:h,agentId:g,events:De,subagents:Fe,live:Ne?.status===`running`,onOpenAgent:_e}):void 0,children:(0,Y.jsx)($R,{children:(0,Y.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[ze&&He!==null&&(0,Y.jsx)(mW,{title:He}),Re()]})})})]}),i.everyPage.map(({EveryPage:e,package:t})=>(0,Y.jsx)(lF,{package:t,label:`${t} popup`,children:(0,Y.jsx)(e,{})},t)),p.settings!==void 0&&(0,Y.jsx)(NB,{entry:p.settings,openItem:p.settingsItem,onEntry:Ce,onClose:we,scope:y,projects:n})]})})})})})}var mG=document.getElementById(`root`);if(!mG)throw Error(`no #root in index.html`);var hG=(0,Pi.createRoot)(mG);(0,Ni.flushSync)(()=>hG.render((0,Y.jsx)(Xa,{children:(0,Y.jsx)(pG,{})})));