@openagt/dashboard 0.41.0 → 0.42.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.
Files changed (37) hide show
  1. package/dist/daemon.d.ts.map +1 -1
  2. package/dist/daemon.js +4 -0
  3. package/dist/daemon.js.map +1 -1
  4. package/dist/dashboard/computers-sync.d.ts +104 -0
  5. package/dist/dashboard/computers-sync.d.ts.map +1 -0
  6. package/dist/dashboard/computers-sync.js +179 -0
  7. package/dist/dashboard/computers-sync.js.map +1 -0
  8. package/dist/dashboard/models.d.ts +2 -1
  9. package/dist/dashboard/models.d.ts.map +1 -1
  10. package/dist/dashboard/models.js +1 -1
  11. package/dist/dashboard/models.js.map +1 -1
  12. package/dist/dashboard-bundle/assets/host/{module-BcFzlJhp.js → module-BWXIkXv5.js} +1 -1
  13. package/dist/dashboard-bundle/assets/{main-rpNhGecV.js → main-CA55XzlS.js} +3 -3
  14. package/dist/dashboard-bundle/assets/{module-Bhd9t16k.js → module-CXKv8UKd.js} +1 -1
  15. package/dist/dashboard-bundle/index.html +3 -3
  16. package/dist/dashboard-rpc/computers.d.ts +27 -0
  17. package/dist/dashboard-rpc/computers.d.ts.map +1 -0
  18. package/dist/dashboard-rpc/computers.js +90 -0
  19. package/dist/dashboard-rpc/computers.js.map +1 -0
  20. package/dist/dashboard-rpc/machines.d.ts +4 -0
  21. package/dist/dashboard-rpc/machines.d.ts.map +1 -1
  22. package/dist/dashboard-rpc/machines.js +24 -1
  23. package/dist/dashboard-rpc/machines.js.map +1 -1
  24. package/dist/dashboard-rpc/relay-dispatch.d.ts.map +1 -1
  25. package/dist/dashboard-rpc/relay-dispatch.js +3 -2
  26. package/dist/dashboard-rpc/relay-dispatch.js.map +1 -1
  27. package/dist/module-types/dashboard/lib/models.d.ts +7 -3
  28. package/dist/module-types/src/dashboard/computers-sync.d.ts +103 -0
  29. package/dist/module-types/src/dashboard/models.d.ts +2 -1
  30. package/dist/module-types/src/dashboard-rpc/computers.d.ts +26 -0
  31. package/dist/module-types/src/dashboard-rpc/machines.d.ts +4 -0
  32. package/dist/module-types/src/registry.d.ts +20 -0
  33. package/dist/registry.d.ts +20 -0
  34. package/dist/registry.d.ts.map +1 -1
  35. package/dist/registry.js +49 -4
  36. package/dist/registry.js.map +1 -1
  37. package/package.json +17 -17
@@ -1,4 +1,4 @@
1
- import{n as e,r as t,t as n}from"./rolldown-runtime-QTnfLwEv.js";import{t as r}from"./client-CbBRB9m4.js";import{t as i}from"./react-CZI7_Jkm.js";import{t as a}from"./react-dom-cJyBB_A4.js";import{$ as o,$n as s,$t as c,A as l,An as u,Ar as d,At as f,B as p,Bn as m,Bt as h,Cn as g,Cr as _,Ct as v,D as y,Dn as b,Dr as x,Dt as S,E as C,En as w,Er as T,Et as E,F as D,Fn as O,Ft as k,Gn as A,Gt as j,H as M,Hn as N,Ht as P,In as ee,It as te,Jn as ne,Jt as re,Kn as ie,Ln as ae,Lt as F,M as I,Mn as oe,Mr as se,Mt as ce,Nn as le,Nr as ue,Nt as de,O as fe,On as pe,Or as me,Ot as he,Pn as ge,Pr as _e,Pt as ve,Q as ye,Qn as be,Qt as L,Rn as xe,Rt as Se,S as Ce,Sn as we,Sr as Te,St as Ee,T as De,Tn as Oe,Tr as ke,Tt as Ae,U as je,Un as Me,Ut as Ne,V as Pe,Vn as Fe,Vt as Ie,W as Le,Wn as R,Wt as Re,Xn as ze,Xt as Be,Yn as Ve,Yt as He,Zn as Ue,Zt as We,_ as Ge,_n as Ke,_r as qe,_t as Je,an as Ye,ar as Xe,at as Ze,b as Qe,bn as $e,br as et,bt as tt,cn as nt,cr as rt,ct as it,dn as at,dr as z,dt as ot,en as st,er as ct,et as lt,fn as ut,fr as dt,ft,g as pt,gr as B,gt as mt,h as ht,hn as gt,hr as _t,ht as vt,i as yt,in as bt,ir as xt,it as St,j as Ct,jn as wt,jr as Tt,jt as Et,k as Dt,kn as Ot,kr as kt,kt as At,ln as jt,lr as Mt,lt as Nt,mn as Pt,mr as V,mt as Ft,nn as It,nr as Lt,nt as Rt,on as zt,or as Bt,ot as Vt,p as Ht,pn as Ut,pr as H,pt as Wt,qn as Gt,rn as Kt,rr as qt,sn as Jt,sr as Yt,t as Xt,tn as Zt,tr as Qt,tt as $t,un as en,ur as U,ut as tn,vn as nn,vr as W,vt as rn,wn as an,wt as on,x as sn,xn as cn,xr as ln,xt as un,y as dn,yn as fn,yr as pn,zn as mn,zt as hn}from"./module-Bhd9t16k.js";import{t as gn}from"./jsx-runtime-By8HlURe.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var _n=t(r(),1);function vn(e){return Array.isArray(e)?[...e]:e?[e]:[]}function yn(e){switch(e.kind){case`session`:return`◆ ${e.fake?`fake`:e.driver}${e.model?` (${e.model})`:``} in ${e.workspace}${e.sessionLink?` — ${e.sessionLink}`:``}`;case`session-update`:return` session ${e.sessionId}${e.sessionLink?` — ${e.sessionLink}`:``}`;case`screen`:return`◆ ${e.label}`;case`log`:return` ${e.message}`;case`error`:return`✗ ${e.headline}${e.detail?`\n ${e.detail.replace(/\n/g,`
1
+ import{n as e,r as t,t as n}from"./rolldown-runtime-QTnfLwEv.js";import{t as r}from"./client-CbBRB9m4.js";import{t as i}from"./react-CZI7_Jkm.js";import{t as a}from"./react-dom-cJyBB_A4.js";import{$ as o,$n as s,$t as c,A as l,An as u,Ar as d,At as f,B as p,Bn as m,Bt as h,Cn as g,Cr as _,Ct as v,D as y,Dn as b,Dr as x,Dt as S,E as C,En as w,Er as T,Et as E,F as D,Fn as O,Ft as k,Gn as A,Gt as j,H as M,Hn as N,Ht as P,In as ee,It as te,Jn as ne,Jt as re,Kn as ie,Ln as ae,Lt as F,M as I,Mn as oe,Mr as se,Mt as ce,Nn as le,Nr as ue,Nt as de,O as fe,On as pe,Or as me,Ot as he,Pn as ge,Pr as _e,Pt as ve,Q as ye,Qn as be,Qt as L,Rn as xe,Rt as Se,S as Ce,Sn as we,Sr as Te,St as Ee,T as De,Tn as Oe,Tr as ke,Tt as Ae,U as je,Un as Me,Ut as Ne,V as Pe,Vn as Fe,Vt as Ie,W as Le,Wn as R,Wt as Re,Xn as ze,Xt as Be,Yn as Ve,Yt as He,Zn as Ue,Zt as We,_ as Ge,_n as Ke,_r as qe,_t as Je,an as Ye,ar as Xe,at as Ze,b as Qe,bn as $e,br as et,bt as tt,cn as nt,cr as rt,ct as it,dn as at,dr as z,dt as ot,en as st,er as ct,et as lt,fn as ut,fr as dt,ft,g as pt,gr as B,gt as mt,h as ht,hn as gt,hr as _t,ht as vt,i as yt,in as bt,ir as xt,it as St,j as Ct,jn as wt,jr as Tt,jt as Et,k as Dt,kn as Ot,kr as kt,kt as At,ln as jt,lr as Mt,lt as Nt,mn as Pt,mr as V,mt as Ft,nn as It,nr as Lt,nt as Rt,on as zt,or as Bt,ot as Vt,p as Ht,pn as Ut,pr as H,pt as Wt,qn as Gt,rn as Kt,rr as qt,sn as Jt,sr as Yt,t as Xt,tn as Zt,tr as Qt,tt as $t,un as en,ur as U,ut as tn,vn as nn,vr as W,vt as rn,wn as an,wt as on,x as sn,xn as cn,xr as ln,xt as un,y as dn,yn as fn,yr as pn,zn as mn,zt as hn}from"./module-CXKv8UKd.js";import{t as gn}from"./jsx-runtime-By8HlURe.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var _n=t(r(),1);function vn(e){return Array.isArray(e)?[...e]:e?[e]:[]}function yn(e){switch(e.kind){case`session`:return`◆ ${e.fake?`fake`:e.driver}${e.model?` (${e.model})`:``} in ${e.workspace}${e.sessionLink?` — ${e.sessionLink}`:``}`;case`session-update`:return` session ${e.sessionId}${e.sessionLink?` — ${e.sessionLink}`:``}`;case`screen`:return`◆ ${e.label}`;case`log`:return` ${e.message}`;case`error`:return`✗ ${e.headline}${e.detail?`\n ${e.detail.replace(/\n/g,`
2
2
  `)}`:``}`;case`settled`:return`◆ done for now — waiting for your next message`;case`branch`:return` branch: ${e.branch}`;case`cloud-anchor`:return` hand-off anchor: ${e.sha.slice(0,7)}`;case`pull-request`:return` pull request: #${e.number}`;case`usage`:return` spend: $${e.costUsd.toFixed(4)}`;case`choice`:{let t=t=>e.multi?t.default?`[x]`:`[ ]`:t.id===e.recommended?`●`:`○`,n=e.options.map(e=>` ${t(e)} ${e.label}`).join(`
3
3
  `);return`? ${e.title}\n${n}`}case`choice-resolved`:return` ✓ chose ${vn(e.picked).join(`, `)||`(none)`} (${e.by})`;case`driver`:return bn(e.event);case`intent`:return`▶ "${Sn(e.text)}"`;case`title`:return`Named the session: ${Sn(e.text)}`;case`end`:return e.ok?`✓ finished`:e.stopped?`■ stopped`:e.waiting?`? waiting for an answer`:`✗ failed: ${e.detail??`unknown error`}`}}function bn(e){switch(e.type){case`start`:return` › prompt: ${Sn(e.prompt,140)}`;case`session`:return` session ${e.sessionId}`;case`model`:return` model ${e.model}`;case`partial`:case`text`:return` ${Sn(e.text)}`;case`action`:return e.detail===void 0?` · ${e.label}`:` · ${e.label} ${Sn(e.detail,140)}`;case`output`:return` ${e.failed?`✗`:`→`} ${Sn(e.text,140)}`;case`subagent`:return` ${e.status===`ended`?`✓`:e.status===`failed`?`✗`:`·`} subagent ${Sn(e.name??e.role??e.id,60)}`;case`thought`:return` 💭 ${Sn(e.text,140)}`;case`result`:return` ‹ turn complete`;case`rate-limit`:return` ${xn(e.limit)}`;case`error`:return` ! agent error: ${e.message}`;case`notice`:return` ~ ${e.message}`;case`question`:return` ? ${Sn(e.question.title,140)}`}}function xn(e){let t=new Date(e.resetsAt).toISOString();return e.status===`rejected`?`✗ quota exhausted (${e.window}), resets ${t}`:e.status===`allowed_warning`?`! quota running low (${e.window}), resets ${t}`:`· quota ${e.status} (${e.window}), resets ${t}`}function Sn(e,t=100){let n=e.replace(/\s+/g,` `).trim();return n.length>t?n.slice(0,t-1)+`…`:n}function Cn(e){return e.title?.trim()||e.intent?.trim()||e.branch?.trim()||void 0}function wn(e,t=Date.now()){let n=new Set,r=new Map,i=new Map,a=-1;e.forEach((e,t)=>{e.kind===`end`&&!e.waiting&&(a=t),e.kind===`screen`&&(e.ended?(n.add(e),r.delete(e.url),i.delete(e.url)):e.until===void 0?r.set(e.url,t):(n.add(e),i.set(e.url,{at:t,until:Date.parse(e.until)})))});let o=new Set;for(let[n,s]of r){let r=i.get(n);(s>a||r!==void 0&&r.at>a&&r.until>t)&&o.add(e[s])}return{live:o,hidden:n}}var Tn=[`B`,`KB`,`MB`,`GB`,`TB`];function En(e,t=`–`){if(typeof e!=`number`||!Number.isFinite(e)||e<0)return t;let n=e,r=0;for(;n>=1024&&r<Tn.length-1;)n/=1024,r++;return`${n<10&&r>0?Math.round(n*10)/10:Math.round(n)} ${Tn[r]}`}function Dn(e){let t=[];for(let n of e)if(n.kind===`error`)t.push({headline:n.headline,...n.detail?{detail:n.detail}:{}});else if(n.kind===`driver`&&n.event.type===`error`&&typeof n.event.message==`string`){let[e=``,...r]=n.event.message.trim().split(`
4
4
  `),i=r.join(`
@@ -126,8 +126,8 @@ ${t.innerHTML}
126
126
  `),e.text(t.textContent,!1),e.ensureNewLine(),e.write("```"),e.closeBlock(t)},parse:{setup(e){e.set({langPrefix:this.options.languageClassPrefix??`language-`})},updateDOM(e){e.innerHTML=e.innerHTML.replace(/\n<\/code><\/pre>/g,`</code></pre>`)}}}}}}),rO=lx.create({name:`hardBreak`}).extend({addStorage(){return{markdown:{serialize(e,t,n,r){for(let i=r+1;i<n.childCount;i++)if(n.child(i).type!=t.type){e.write(e.inTable?ZD.storage.markdown.serialize.call(this,e,t,n):`\\
127
127
  `);return}},parse:{}}}}}),iO=lx.create({name:`heading`}).extend({addStorage(){return{markdown:{serialize:kD.nodes.heading,parse:{}}}}}),aO=lx.create({name:`horizontalRule`}).extend({addStorage(){return{markdown:{serialize:kD.nodes.horizontal_rule,parse:{}}}}}),oO=lx.create({name:`image`}).extend({addStorage(){return{markdown:{serialize:kD.nodes.image,parse:{}}}}}),sO=lx.create({name:`listItem`}).extend({addStorage(){return{markdown:{serialize:kD.nodes.list_item,parse:{}}}}}),cO=lx.create({name:`orderedList`});function lO(e,t,n){let r=0;for(;n-r>0&&t.child(n-r-1).type.name===e.type.name;r++);return r}var uO=cO.extend({addStorage(){return{markdown:{serialize(e,t,n,r){let i=t.attrs.start||1,a=String(i+t.childCount-1).length,o=e.repeat(` `,a+2),s=lO(t,n,r)%2?`) `:`. `;e.renderList(t,o,t=>{let n=String(i+t);return e.repeat(` `,a-n.length)+n+s})},parse:{}}}}}),dO=lx.create({name:`paragraph`}).extend({addStorage(){return{markdown:{serialize:kD.nodes.paragraph,parse:{}}}}});function fO(e){var t;return(e==null||(t=e.content)==null?void 0:t.content)??[]}var pO=lx.create({name:`table`}).extend({addStorage(){return{markdown:{serialize(e,t,n){if(!hO(t)){ZD.storage.markdown.serialize.call(this,e,t,n);return}e.inTable=!0,t.forEach((t,n,r)=>{if(e.write(`| `),t.forEach((t,n,r)=>{r&&e.write(` | `);let i=t.firstChild;i.textContent.trim()&&e.renderInline(i)}),e.write(` |`),e.ensureNewLine(),!r){let n=Array.from({length:t.childCount}).map(()=>`---`).join(` | `);e.write(`| ${n} |`),e.ensureNewLine()}}),e.closeBlock(t),e.inTable=!1},parse:{}}}}});function mO(e){return e.attrs.colspan>1||e.attrs.rowspan>1}function hO(e){let t=fO(e),n=t[0],r=t.slice(1);return!(fO(n).some(e=>e.type.name!==`tableHeader`||mO(e)||e.childCount>1)||r.some(e=>fO(e).some(e=>e.type.name===`tableHeader`||mO(e)||e.childCount>1)))}var gO=[eO,tO,nO,rO,iO,aO,ZD,oO,sO,uO,dO,pO,lx.create({name:`taskItem`}).extend({addStorage(){return{markdown:{serialize(e,t){let n=t.attrs.checked?`[x]`:`[ ]`;e.write(`${n} `),e.renderContent(t)},parse:{updateDOM(e){[...e.querySelectorAll(`.task-list-item`)].forEach(e=>{let t=e.querySelector(`input`);e.setAttribute(`data-type`,`taskItem`),t&&(e.setAttribute(`data-checked`,t.checked),t.remove())})}}}}}}),lx.create({name:`taskList`}).extend({addStorage(){return{markdown:{serialize:tO.storage.markdown.serialize,parse:{setup(e){e.use(ND.default)},updateDOM(e){[...e.querySelectorAll(`.contains-task-list`)].forEach(e=>{e.setAttribute(`data-type`,`taskList`)})}}}}}}),lx.create({name:`text`}).extend({addStorage(){return{markdown:{serialize(e,t){e.text(JD(t.text))},parse:{}}}}}),Zv.create({name:`bold`}).extend({addStorage(){return{markdown:{serialize:kD.marks.strong,parse:{}}}}}),Zv.create({name:`code`}).extend({addStorage(){return{markdown:{serialize:kD.marks.code,parse:{}}}}}),GD,Zv.create({name:`italic`}).extend({addStorage(){return{markdown:{serialize:kD.marks.em,parse:{}}}}}),Zv.create({name:`link`}).extend({addStorage(){return{markdown:{serialize:kD.marks.link,parse:{}}}}}),Zv.create({name:`strike`}).extend({addStorage(){return{markdown:{serialize:{open:`~~`,close:`~~`,expelEnclosingWhitespace:!0},parse:{}}}}})];function _O(e){let t=e.storage?.markdown,n=gO.find(t=>t.name===e.name)?.storage.markdown;return t||n?{...n,...t}:null}var vO=class{constructor(e){ID(this,`editor`,null),this.editor=e}serialize(e){let t=new WD(this.nodes,this.marks,{hardBreakNodeName:rO.name});return t.renderContent(e),t.out}get nodes(){return{...Object.fromEntries(Object.keys(this.editor.schema.nodes).map(e=>[e,this.serializeNode(ZD)])),...Object.fromEntries(this.editor.extensionManager.extensions.filter(e=>e.type===`node`&&this.serializeNode(e)).map(e=>[e.name,this.serializeNode(e)])??[])}}get marks(){return{...Object.fromEntries(Object.keys(this.editor.schema.marks).map(e=>[e,this.serializeMark(GD)])),...Object.fromEntries(this.editor.extensionManager.extensions.filter(e=>e.type===`mark`&&this.serializeMark(e)).map(e=>[e.name,this.serializeMark(e)])??[])}}serializeNode(e){var t;return(t=_O(e))==null||(t=t.serialize)==null?void 0:t.bind({editor:this.editor,options:e.options})}serializeMark(e){let t=_O(e)?.serialize;return t?{...t,open:typeof t.open==`function`?t.open.bind({editor:this.editor,options:e.options}):t.open,close:typeof t.close==`function`?t.close.bind({editor:this.editor,options:e.options}):t.close}:null}},yO=class{constructor(e,t){ID(this,`editor`,null),ID(this,`md`,null);let{html:n,linkify:r,breaks:i}=t;this.editor=e,this.md=this.withPatchedRenderer(_D({html:n,linkify:r,breaks:i}))}parse(e){let{inline:t}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(typeof e==`string`){this.editor.extensionManager.extensions.forEach(e=>{var t;return(t=_O(e))==null||(t=t.parse)==null||(t=t.setup)==null?void 0:t.call({editor:this.editor,options:e.options},this.md)});let n=qD(this.md.render(e));return this.editor.extensionManager.extensions.forEach(e=>{var t;return(t=_O(e))==null||(t=t.parse)==null||(t=t.updateDOM)==null?void 0:t.call({editor:this.editor,options:e.options},n)}),this.normalizeDOM(n,{inline:t,content:e}),n.innerHTML}return e}normalizeDOM(e,t){let{inline:n,content:r}=t;return this.normalizeBlocks(e),e.querySelectorAll(`*`).forEach(e=>{e.nextSibling?.nodeType===Node.TEXT_NODE&&!e.closest(`pre`)&&(e.nextSibling.textContent=e.nextSibling.textContent.replace(/^\n/,``))}),n&&this.normalizeInline(e,r),e}normalizeBlocks(e){let t=Object.values(this.editor.schema.nodes).filter(e=>e.isBlock).map(e=>e.spec.parseDOM?.map(e=>e.tag)).flat().filter(Boolean).join(`,`);t&&[...e.querySelectorAll(t)].forEach(e=>{e.parentElement.matches(`p`)&&YD(e)})}normalizeInline(e,t){var n;if((n=e.firstElementChild)!=null&&n.matches(`p`)){let n=e.firstElementChild,{nextElementSibling:r}=n,i=t.match(/^\s+/)?.[0]??``,a=r?``:t.match(/\s+$/)?.[0]??``;if(t.match(/^\n\n/)){n.innerHTML=`${n.innerHTML}${a}`;return}XD(n),e.innerHTML=`${i}${e.innerHTML}${a}`}}withPatchedRenderer(e){let t=e=>function(){let t=e(...arguments);return t===`
128
128
  `?t:t[t.length-1]===`
129
- `?t.slice(0,-1):t};return e.renderer.rules.hardbreak=t(e.renderer.rules.hardbreak),e.renderer.rules.softbreak=t(e.renderer.rules.softbreak),e.renderer.rules.fence=t(e.renderer.rules.fence),e.renderer.rules.code_block=t(e.renderer.rules.code_block),e.renderer.renderToken=t(e.renderer.renderToken.bind(e.renderer)),e}},bO=sy.create({name:`markdownClipboard`,addOptions(){return{transformPastedText:!1,transformCopiedText:!1}},addProseMirrorPlugins(){return[new Jf({key:new Zf(`markdownClipboard`),props:{clipboardTextParser:(e,t,n)=>{if(n||!this.options.transformPastedText)return null;let r=this.editor.storage.markdown.parser.parse(e,{inline:!0});return qu.fromSchema(this.editor.schema).parseSlice(qD(r),{preserveWhitespace:!0,context:t})},clipboardTextSerializer:e=>this.options.transformCopiedText?this.editor.storage.markdown.serializer.serialize(e.content):null}})]}}),xO=sy.create({name:`markdown`,priority:50,addOptions(){return{html:!0,tightLists:!0,tightListClass:`tight`,bulletListMarker:`-`,linkify:!1,breaks:!1,transformPastedText:!1,transformCopiedText:!1}},addCommands(){let e=ex.Commands.config.addCommands();return{setContent:(t,n,r)=>i=>e.setContent(i.editor.storage.markdown.parser.parse(t),n,r)(i),insertContentAt:(t,n,r)=>i=>e.insertContentAt(t,i.editor.storage.markdown.parser.parse(n,{inline:!0}),r)(i)}},onBeforeCreate(){this.editor.storage.markdown={options:{...this.options},parser:new yO(this.editor,this.options),serializer:new vO(this.editor),getMarkdown:()=>this.editor.storage.markdown.serializer.serialize(this.editor.state.doc)},this.editor.options.initialContent=this.editor.options.content,this.editor.options.content=this.editor.storage.markdown.parser.parse(this.editor.options.content)},onCreate(){this.editor.options.content=this.editor.options.initialContent,delete this.editor.options.initialContent},addStorage(){return{}},addExtensions(){return[LD.configure({tight:this.options.tightLists,tightClass:this.options.tightListClass}),bO.configure({transformPastedText:this.options.transformPastedText,transformCopiedText:this.options.transformCopiedText})]}}),SO=lx.create({name:`token`,group:`inline`,inline:!0,atom:!0,selectable:!0,addAttributes(){return{kind:{default:`file`},label:{default:``},text:{default:``}}},parseHTML(){return[{tag:`span[data-token]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`span`,jv(t,{"data-token":e.attrs.kind,class:`pe-token`}),e.attrs.label||e.attrs.text]},renderText({node:e}){return e.attrs.text},addStorage(){return{markdown:{serialize(e,t){e.write(t.attrs.text)},parse:{}}}}});function CO(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=fx(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}var wO=new Zf(`suggestion`);function TO({pluginKey:e=wO,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:h=CO}){let g,_=p?.(),v=new Jf({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,p=!c.active&&l.active,m=c.active&&!l.active,h=!p&&!m&&c.query!==l.query,v=p||u&&h,y=h||u,b=m||u&&h;if(!v&&!y&&!b)return;let x=b&&!v?c:l,S=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);g={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>d({editor:t,range:x.range,props:e}),decorationNode:S,clientRect:S?()=>{let{decorationId:n}=this.key?.getState(t.state);return e.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:null},v&&((r=_?.onBeforeStart)==null||r.call(_,g)),y&&((i=_?.onBeforeUpdate)==null||i.call(_,g)),(y||v)&&(g.items=await f({editor:t,query:x.query})),b&&((a=_?.onExit)==null||a.call(_,g)),y&&((o=_?.onUpdate)==null||o.call(_,g)),v&&((s=_?.onStart)==null||s.call(_,g))},destroy:()=>{var e;g&&((e=_?.onExit)==null||e.call(_,g))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(e,s,c,l){let{isEditable:u}=t,{composing:d}=t.view,{selection:f}=e,{empty:p,from:g}=f,_={...s};if(_.composing=d,u&&(p||t.view.composing)){(g<s.range.from||g>s.range.to)&&!d&&!s.composing&&(_.active=!1);let e=h({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:f.$from}),c=`id_${Math.floor(Math.random()*4294967295)}`;e&&m({editor:t,state:l,range:e.range,isActive:s.active})?(_.active=!0,_.decorationId=s.decorationId?s.decorationId:c,_.range=e.range,_.query=e.query,_.text=e.text):_.active=!1}else _.active=!1;return _.active||(_.decorationId=null,_.range={from:0,to:0},_.query=null,_.text=null),_}},props:{handleKeyDown(e,t){let{active:n,range:r}=v.getState(e.state);return n&&(_?.onKeyDown)?.call(_,{view:e,event:t,range:r})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=v.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),Pg.create(e.doc,[jg.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return v}function EO(e){return`prompt-suggestion-option-${e}`}var DO=(0,G.forwardRef)(function({items:e,command:t,emptyNote:n,onActiveChange:r},i){let[a,o]=(0,G.useState)(0);return(0,G.useEffect)(()=>o(0),[e]),(0,G.useEffect)(()=>{r?.(e.length>0?EO(a):null)},[e,a,r]),(0,G.useImperativeHandle)(i,()=>({onKeyDown:n=>{if(e.length===0)return!1;if(n.key===`ArrowDown`)return o(t=>(t+1)%e.length),!0;if(n.key===`ArrowUp`)return o(t=>(t-1+e.length)%e.length),!0;if(n.key===`Enter`||n.key===`Tab`){let n=e[a];return n&&t(n),!0}return!1}})),e.length===0?(0,K.jsx)(`div`,{role:`status`,className:`w-64 rounded-md border border-border bg-card p-2 text-sm text-muted-foreground shadow-md`,children:n??`No matches`}):(0,K.jsx)(`div`,{role:`listbox`,"aria-label":`Suggestions`,className:`max-h-72 w-64 overflow-y-auto rounded-md border border-border bg-card p-1 text-sm shadow-md`,children:e.map((n,r)=>(0,K.jsxs)(`div`,{children:[n.group&&(r===0||e[r-1]?.group!==n.group)&&(0,K.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70`,children:n.group}),(0,K.jsxs)(`button`,{type:`button`,id:EO(r),role:`option`,"aria-selected":r===a,...n.title?{title:n.title}:{},onMouseDown:e=>{e.preventDefault(),t(n)},onMouseEnter:()=>o(r),className:B(`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left`,r===a?`bg-accent text-accent-foreground`:`hover:bg-accent/60`),children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:n.label}),n.hint&&(0,K.jsx)(`span`,{className:`ml-auto truncate text-xs text-muted-foreground`,children:n.hint})]})]},n.id))})});function OO(e,t){if(!t)return;let n=window.innerHeight-t.bottom;e.style.left=`${t.left}px`,n<320?(e.style.top=``,e.style.bottom=`${window.innerHeight-t.top+4}px`):(e.style.bottom=``,e.style.top=`${t.bottom+4}px`)}function kO(e){let t=null,n=null,r=null,i=null,a=null,o=!1,s=e=>{a&&(e?a.setAttribute(`aria-activedescendant`,e):a.removeAttribute(`aria-activedescendant`))},c=i=>{let{items:c,command:l}=i,u=c.length===0&&!i.query?e.emptyNote:void 0,d=!o&&(c.length>0||!!u);t&&(t.style.display=d?``:`none`),a?.setAttribute(`aria-expanded`,d?`true`:`false`),d||s(null),n?.render((0,G.createElement)(DO,{items:c,command:l,emptyNote:u,onActiveChange:s,ref:e=>{r=e}}))},l=()=>{t&&OO(t,i?.()??null)};return{onStart(e){o=!1,t=document.createElement(`div`),t.style.position=`fixed`,t.style.zIndex=`50`,document.body.appendChild(t),n=(0,_n.createRoot)(t),i=e.clientRect??null,a=e.editor?.view.dom??null,l(),c(e),window.addEventListener(`scroll`,l,!0),window.addEventListener(`resize`,l)},onUpdate(e){i=e.clientRect??null,l(),c(e)},onKeyDown(e){return e.event.key===`Escape`?!t||t.style.display===`none`?!1:(o=!0,t.style.display=`none`,a?.setAttribute(`aria-expanded`,`false`),s(null),!0):r?.onKeyDown(e.event)??!1},onExit(){o=!1,window.removeEventListener(`scroll`,l,!0),window.removeEventListener(`resize`,l),a?.setAttribute(`aria-expanded`,`false`),s(null),a=null,n?.unmount(),t?.remove(),n=null,t=null,r=null,i=null}}}function AO(e){return sy.create({name:`suggestion-${e.key}`,addProseMirrorPlugins(){return[TO({editor:this.editor,char:e.char,pluginKey:new Zf(e.key),items:({query:t})=>e.items(t.toLowerCase()),command:({editor:t,range:n,props:r})=>e.onSelect(r,{editor:t,range:n}),render:()=>kO(e)})]}})}function jO(e,t,n){e.chain().focus().deleteRange(t).insertContent([{type:`token`,attrs:{kind:n.kind,label:n.label,text:n.text}},{type:`text`,text:` `}]).run()}function MO(e,t){e.commands.setContent(t),e.commands.focus(`end`),/\s$/.test(t)&&e.commands.insertContent({type:`text`,text:` `})}var NO=(0,G.forwardRef)(function({onChange:e,onSubmit:t,onPreset:n,onMentionProject:r,onMentionFile:i,onMentionRemoved:a,projects:o,files:s=[],commands:c,customPresets:l=[],projectPresets:u=[],onNewPreset:d,disabled:f=!1,placeholder:p=`Describe what to do…`,initialText:m,compact:h=!1},g){let[_,v]=(0,G.useState)(!0),y=(0,G.useRef)(o),b=(0,G.useRef)(s),x=(0,G.useRef)(c),S=(0,G.useRef)(l),C=(0,G.useRef)(u),w=(0,G.useRef)(d),T=(0,G.useRef)(n),E=(0,G.useRef)(r),D=(0,G.useRef)(i),O=(0,G.useRef)(a),k=(0,G.useRef)(e),A=(0,G.useRef)(t);(0,G.useEffect)(()=>{y.current=o,b.current=s,x.current=c,S.current=l,C.current=u,w.current=d,T.current=n,E.current=r,D.current=i,O.current=a,k.current=e,A.current=t});let j=(0,G.useRef)(new Set),M=e=>{let t=new Set;e.state.doc.descendants(e=>(e.type.name===`token`&&(e.attrs.kind===`project`||e.attrs.kind===`file`)&&t.add(String(e.attrs.text)),!0));for(let e of j.current)if(!t.has(e)){if(e.startsWith(`#`))O.current?.(e.slice(1));else if(e.startsWith(`@`)){let t=y.current.find(t=>t.name===e.slice(1));t&&O.current?.(t.path)}}j.current=t},N=(e,t)=>{let n=!e.isEmpty;return MO(e,t),M(e),v(e.isEmpty),k.current(e.storage.markdown.getMarkdown()),n},P=Lx({immediatelyRender:!1,extensions:[cC,xO.configure({html:!1,linkify:!1,breaks:!0,transformPastedText:!0}),SO,AO({char:`/`,key:`slash`,items:e=>{let t=e.toLowerCase();if(x.current.some(e=>e.name===t))return[];let n=x.current.filter(e=>e.name.includes(t)).map(e=>({id:`command:${e.name}`,label:`/${e.name}`,group:`Commands`,...e.description?{title:e.description}:{}})),r=S.current.filter(e=>e.label.toLowerCase().includes(t)).map(e=>({id:`custom-preset:${e.id}`,label:e.label,hint:`saved prompt`,group:`Saved prompts`})),i=C.current.filter(e=>e.label.toLowerCase().includes(t)).map(e=>({id:`project-preset:${e.id}`,label:e.label,hint:`project saved prompt`,group:`Saved prompts`})),a=w.current&&`save prompt`.includes(t)?[{id:`new-preset`,label:`Save prompt…`,hint:`save the current prompt`,group:`Saved prompts`}]:[];return[...n,...r,...i,...a]},onSelect:(e,{editor:t,range:n})=>{if(e.id.startsWith(`command:`)){let r=x.current.find(t=>`command:${t.name}`===e.id);if(r){t.chain().focus().deleteRange(n).run();let e=N(t,`/${r.name} `);T.current?.(`/${r.name}`,e)}return}if(e.id.startsWith(`custom-preset:`)){let r=S.current.find(t=>`custom-preset:${t.id}`===e.id);if(r){t.chain().focus().deleteRange(n).run();let e=N(t,r.prompt);T.current?.(r.label,e)}return}if(e.id.startsWith(`project-preset:`)){let r=C.current.find(t=>`project-preset:${t.id}`===e.id);if(r){t.chain().focus().deleteRange(n).run();let e=N(t,r.prompt);T.current?.(r.label,e)}return}e.id===`new-preset`&&(t.chain().focus().deleteRange(n).run(),w.current?.())}}),AO({char:`@`,key:`at`,emptyNote:`No projects to reference yet.`,items:e=>y.current.filter(t=>t.name.toLowerCase().includes(e)).slice(0,8).map(e=>({id:`project:${e.id}`,label:`@${e.name}`,hint:`project`,group:`Projects`})),onSelect:(e,{editor:t,range:n})=>{let r=y.current.find(t=>`project:${t.id}`===e.id);r&&(jO(t,n,{kind:`project`,label:`@${r.name}`,text:`@${r.name}`}),E.current?.(r.path))}}),AO({char:`#`,key:`hash`,emptyNote:`No files indexed here yet.`,items:e=>b.current.filter(t=>t.toLowerCase().includes(e.toLowerCase())).slice(0,8).map(e=>({id:`file:${e}`,label:`#${e}`,hint:`file`,group:`Files`})),onSelect:(e,{editor:t,range:n})=>{let r=e.id.slice(5);jO(t,n,{kind:`file`,label:`#${r}`,text:`#${r}`}),D.current?.(r)}})],editorProps:{attributes:{class:`pe-prose focus:outline-none`,role:`textbox`,"aria-multiline":`true`,"aria-label":`Prompt`,"aria-placeholder":p},handleKeyDown:(e,t)=>(t.metaKey||t.ctrlKey)&&t.key===`Enter`?(t.preventDefault(),A.current(),!0):t.key===`Enter`&&!t.shiftKey&&!t.altKey&&!t.isComposing?e.dom.getAttribute(`aria-expanded`)===`true`||e.state.selection.$from.parent.type.name===`codeBlock`?!1:(t.preventDefault(),A.current(),!0):!1},onUpdate:({editor:e})=>{M(e),v(e.isEmpty),k.current(e.storage.markdown.getMarkdown())}});(0,G.useImperativeHandle)(g,()=>({clear:()=>{P?.commands.clearContent(),P&&M(P),v(!0),k.current(``)},focus:()=>P?.commands.focus(`end`),loadTemplate:e=>P?N(P,e):!1})),(0,G.useEffect)(()=>{P?.setEditable(!f,!1)},[P,f]);let ee=(0,G.useRef)(!1);(0,G.useEffect)(()=>{!P||ee.current||!m||(ee.current=!0,N(P,m))},[P,m]);let te=h?`px-2 py-1.5`:`px-3 py-2.5`,ne=h?`inset-x-2 top-1.5`:`inset-x-3 top-2.5`;return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Ye,{className:h?`rounded-md border border-border focus-within:ring-2 focus-within:ring-[var(--color-primary)]`:``,viewportClassName:h?`max-h-32 min-h-8`:`max-h-64 min-h-10`,children:(0,K.jsx)(wx,{editor:P,className:`w-full bg-transparent text-sm pointer-coarse:text-base ${te}`})}),_&&(0,K.jsx)(`span`,{className:`pointer-events-none absolute truncate text-sm text-muted-foreground pointer-coarse:text-base ${ne}`,children:p})]})}),PO=80;function FO(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`p-${Date.now()}`}function IO({currentPrompt:e,busy:t,canSaveToProject:n,onSave:r,onCancel:i}){let[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(e),[l,u]=(0,G.useState)(`user`),d=()=>{let e=a.trim(),t=s.trim();!e||!t||r({id:FO(),label:e,prompt:t},n?l:`user`)};return(0,K.jsx)(mt,{open:!0,onOpenChange:e=>{e||i()},title:`Save prompt`,children:(0,K.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),d())},children:[(0,K.jsx)(jt,{type:`text`,value:a,maxLength:PO,placeholder:`Name`,disabled:t,autoFocus:!0,onChange:e=>o(e.target.value),className:`h-8 bg-background px-2`}),(0,K.jsx)(Je,{value:s,placeholder:`The prompt to save…`,disabled:t,rows:5,onChange:e=>c(e.target.value),className:`resize-y px-2 py-1 font-mono text-xs`}),n&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-[var(--color-muted-foreground)]`,children:[(0,K.jsx)(`span`,{children:`Save to`}),(0,K.jsx)(`div`,{className:`inline-flex overflow-hidden rounded-md border border-border`,children:[`user`,`project`].map(e=>(0,K.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>u(e),"aria-pressed":l===e,className:l===e?`bg-foreground px-2 py-0.5 text-background`:`px-2 py-0.5 text-foreground hover:bg-[var(--color-muted)]`,children:e===`user`?`Just me`:`This project`},e))}),(0,K.jsx)(`span`,{className:`truncate`,children:l===`project`?`Committed to the repo, shared with your team`:`Private to you, on every project`})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex items-center justify-end gap-2`,children:[(0,K.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,children:`Cancel`}),(0,K.jsx)(V,{type:`button`,size:`sm`,disabled:t||!a.trim()||!s.trim(),onClick:d,children:`Save prompt`})]})]})})}function LO({preset:e,busy:t,onLoad:n,onDelete:r}){return(0,K.jsxs)(L,{disabled:t,onClick:()=>n(e.prompt,e.label),className:`items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(`button`,{type:`button`,disabled:t,onClick:t=>{t.stopPropagation(),r(e.id)},"aria-label":`Delete saved prompt ${e.label}`,className:`rounded p-0.5 text-[var(--color-muted-foreground)] hover:text-danger`}),children:(0,K.jsx)(ee,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,K.jsxs)(z,{children:[`Delete "`,e.label,`"`]})]})]})}function RO({commands:e,customPresets:t,projectPresets:n,busy:r,onLoad:i,onNew:a,onDelete:o,onDeleteProject:s}){return(0,K.jsxs)(re,{children:[(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(bt,{type:`button`,disabled:r,"aria-label":`Commands`,className:B(_t({variant:`ghost`,size:`icon-sm`}),`h-8 w-8`)}),children:(0,K.jsx)(Fa,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsx)(z,{children:`Run a command or load a saved prompt. In the box: / commands · @ projects · # files`})]}),(0,K.jsxs)(Be,{align:`start`,className:`min-w-[16rem] max-w-[20rem]`,children:[(0,K.jsxs)(We,{children:[(0,K.jsx)(c,{children:`Commands`}),e.length===0&&(0,K.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`This project has no commands.`}),e.map(e=>{let t={disabled:r||e.waiting!==void 0,onClick:()=>i(`/${e.name} `,`/${e.name}`),className:`items-start`},n=(0,K.jsx)(Ae,{label:`/${e.name}`,...e.waiting===void 0?{}:{description:`waiting to reach ${e.waiting}`}});return e.description?(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(L,{...t}),children:n}),(0,K.jsx)(z,{className:`max-w-[22rem]`,children:e.description})]},e.name):(0,K.jsx)(L,{...t,children:n},e.name)})]}),t.length>0&&(0,K.jsxs)(We,{children:[(0,K.jsx)(st,{}),(0,K.jsx)(c,{children:`Your saved prompts`}),t.map(e=>(0,K.jsx)(LO,{preset:e,busy:r,onLoad:i,onDelete:o},e.id))]}),n.length>0&&(0,K.jsxs)(We,{children:[(0,K.jsx)(st,{}),(0,K.jsx)(c,{children:`Project saved prompts`}),n.map(e=>(0,K.jsx)(LO,{preset:e,busy:r,onLoad:i,onDelete:s},e.id))]}),a&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(st,{}),(0,K.jsxs)(L,{disabled:r,onClick:a,children:[(0,K.jsx)(Fa,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Save prompt…`]})]})]})]})}var zO=`the CLI's own default`,BO={xhigh:`Extra high`};function VO(e){return BO[e]??e.charAt(0).toUpperCase()+e.slice(1)}function HO(e,t){return e.find(e=>e.value===t)??e[0]}function UO(e,t){if(t)return e?.models.find(e=>e.value===t)?.label??t}function WO({drivers:e,driver:t,model:n,onChange:r,effort:i,busy:a}){let o=HO(e,t),s=UO(o,n),l=i?.levels??[],u=i?.level===void 0?void 0:VO(i.level),d=`Driver: ${o?.label??``} · Model: ${s??`the CLI's own default`}${l.length>0?` · Effort: ${u??`the agent’s default`}`:``}`;return(0,K.jsxs)(re,{children:[(0,K.jsxs)(U,{children:[(0,K.jsxs)(H,{render:(0,K.jsx)(bt,{type:`button`,disabled:a,"aria-label":d,className:B(Il,`text-foreground`)}),children:[o?.icon?(0,K.jsx)(`span`,{className:`flex h-3.5 w-3.5 items-center justify-center [&>svg]:size-3.5`,children:o.icon}):o?.label,s,u&&(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:u}),(0,K.jsx)(Fe,{className:`h-3 w-3 shrink-0 opacity-70`})]}),(0,K.jsx)(z,{children:d})]}),(0,K.jsxs)(Be,{align:`end`,children:[e.map(e=>(0,K.jsxs)(Zt,{children:[(0,K.jsxs)(Kt,{children:[(0,K.jsx)(N,{className:B(`h-3.5 w-3.5 shrink-0`,e.value===t?`opacity-100`:`opacity-0`)}),e.icon&&(0,K.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center`,children:e.icon}),(0,K.jsx)(`span`,{className:`flex-1`,children:e.label})]}),(0,K.jsxs)(It,{children:[e.models.length===0&&e.modelsNote&&(0,K.jsx)(L,{disabled:!0,children:e.modelsNote}),e.models.map(i=>(0,K.jsxs)(L,{onClick:()=>r(e.value,i.value),children:[(0,K.jsx)(N,{className:B(`h-3.5 w-3.5 shrink-0`,e.value===t&&i.value===n?`opacity-100`:`opacity-0`)}),i.label]},i.value))]})]},e.value)),l.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(st,{}),(0,K.jsxs)(We,{children:[(0,K.jsx)(c,{children:`Effort`}),(0,K.jsxs)(L,{onClick:()=>i.onChange(void 0),children:[(0,K.jsx)(N,{className:B(`h-3.5 w-3.5 shrink-0`,i?.level===void 0?`opacity-100`:`opacity-0`)}),`The agent’s default`]}),l.map(e=>(0,K.jsxs)(L,{onClick:()=>i.onChange(e),children:[(0,K.jsx)(N,{className:B(`h-3.5 w-3.5 shrink-0`,i?.level===e?`opacity-100`:`opacity-0`)}),VO(e)]},e))]})]})]})]})}function GO(e){let{kind:t,place:n}=pn(e);return t===`shared`?`${n}. Runs use your own logins.`:n}function KO({connection:e,busy:t,inRow:n=!1}){let r=e.selectedMachineId&&!e.onlyHere&&(!e.onlyThere||e.selectedMachineId===e.home)?e.machines.find(t=>t.id===e.selectedMachineId):void 0,i=ol(),a=r?et(r):i,o=!r,s=o?xe:le[pn(r).kind];return(0,K.jsxs)(re,{children:[(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(bt,{type:`button`,disabled:t,"aria-label":`Run on`,className:n?Il:B(_t({variant:`ghost`,size:`icon-sm`}),`relative h-8 w-8`)}),children:n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`relative flex shrink-0`,children:[(0,K.jsx)(s,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),!o&&(0,K.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 h-1.5 w-1.5 rounded-full bg-[var(--color-primary)]`})]}),(0,K.jsx)(`span`,{className:`truncate`,children:a}),(0,K.jsx)(Fe,{className:`h-3 w-3 shrink-0 opacity-70`,"aria-hidden":!0})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(s,{className:`h-4 w-4`}),!o&&(0,K.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-[var(--color-primary)]`})]})}),(0,K.jsx)(z,{children:`Run on — ${r?.label??i}`})]}),(0,K.jsxs)(Be,{align:n?`start`:`end`,className:`min-w-[19rem] max-w-[22rem]`,children:[(0,K.jsxs)(L,{className:B(`items-start gap-2`,e.onlyThere&&`opacity-60`),disabled:e.onlyThere,onClick:()=>e.onSelectLocal(),children:[(0,K.jsx)(N,{className:B(`mt-0.5 h-3.5 w-3.5 shrink-0`,o?`opacity-100`:`opacity-0`)}),(0,K.jsx)(xe,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,K.jsx)(Ae,{label:i,description:e.home===void 0?`Runs here, through this project's start hook.`:e.onlyThere?`It has no repository address to clone it here from.`:`Cloned here first, then runs here.`})]}),e.machines.map(t=>{let n=e.status[t.id],i=n===`offline`,a=GO(t),o=e.home===void 0?a:t.id===e.home?`${a}. Has this project.`:`${a}. Cloned there first, then runs there.`,s=i?ln(t.url)?`Not connected. It must be on, with OpenAgent running.`:`Offline · ${o}`:o,c=e.onlyHere||e.onlyThere===!0&&t.id!==e.home;return(0,K.jsxs)(L,{className:B(`items-start gap-2`,(i||c)&&`opacity-60`),disabled:c,onClick:()=>e.onSelect(t),children:[(0,K.jsx)(N,{className:B(`mt-0.5 h-3.5 w-3.5 shrink-0`,r?.id===t.id?`opacity-100`:`opacity-0`)}),(0,K.jsx)(ge,{kind:pn(t).kind,online:n===`online`,className:`mt-0.5`}),(0,K.jsx)(Ae,{label:et(t),description:s})]},t.id)}),e.onlyHere&&e.machines.length>0&&(0,K.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`This project has no repository address, so it cannot be sent to another machine.`}),(0,K.jsxs)(L,{className:`items-start`,disabled:t,onClick:()=>e.onAddMachine(),children:[(0,K.jsx)(Fa,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsx)(Ae,{label:`Add a machine…`,description:`Connect a computer, or join with a code.`})]})]})]})}var qO=1e4;function JO(e){let t=e.map(e=>e.id).join(`|`),n=g((0,G.useMemo)(()=>t?()=>Ue():null,[t]),{},qO,[t]).value;return(0,G.useMemo)(()=>{let e={};for(let[t,r]of Object.entries(n))e[t]=r?`online`:`offline`;return e},[n])}var YO={"claude-code":{icon:(0,K.jsx)(ao,{className:`h-4 w-4`})},codex:{icon:(0,K.jsx)(oo,{className:`h-4 w-4`})}},XO=`flex h-8 items-center gap-2`,ZO=`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)]`,QO=(0,G.forwardRef)(function({files:e,addContext:t,removeContext:n,startsAt:r,controls:i,sessionModel:a,sessionContext:o,onSubmit:s,onPromptChange:c,onPreset:l,busy:u,submitLabel:d,submitBusyLabel:f,placeholder:p,compact:m=!1,showDriverModel:h=!0,inAgent:g=!1,canSubmit:_=!0,idleControl:v,home:y},b){let[x,S]=(0,G.useState)(``),[C,w]=(0,G.useState)(!1),T=(0,G.useRef)(null),E=Vi(),D=JO(E),O=we(ti,[],[]),k=(0,G.useMemo)(()=>O.filter(e=>e.machine===void 0),[O]),A=lr(),j=A.model??``,M=A.driver??`claude-code`,N=A.customPresets??[],P=ir(),ee=cr(),te=_l(ee),ne=te?.commands??[],re=y===void 0&&te!==null&&te.address===void 0,ie=y!==void 0&&te!==null&&te.address===void 0,F=wi(),I=Ei(E,F,te,y),oe=nn(g?void 0:I?.id),se=!!I&&D[I.id]===`offline`,[ce,le]=(0,G.useState)(null),ue=I?.owner,de=!g&&!!I&&ue!==void 0&&!I.told&&ce!==I.id;(0,G.useImperativeHandle)(b,()=>({clear:()=>{T.current?.clear(),S(``)},focus:()=>T.current?.focus()}));let[fe,pe]=(0,G.useState)(void 0);(0,G.useEffect)(()=>{if(m||g)return;let e=vt();e&&pe(e)},[m,g]);let me=(0,G.useRef)(!1),he=e=>{e?.preventDefault();let t=x.trim();!t||u||me.current||se||de||!_||(me.current=!0,Promise.resolve(s(t)).finally(()=>{me.current=!1}))},ge=(e,t)=>{let n=T.current?.loadTemplate(e)??!1;l?.(t,n)},_e=(0,K.jsx)(NO,{ref:T,compact:m,onChange:e=>{S(e),c?.(e)},onSubmit:he,...l?{onPreset:l}:{},...t?{onMentionProject:t,onMentionFile:t}:{},...n?{onMentionRemoved:n}:{},projects:k,files:e,commands:vl(ne),customPresets:N,projectPresets:P,...m?{}:{onNewPreset:()=>w(!0)},disabled:u,...p?{placeholder:p}:{},...fe?{initialText:fe}:{}}),ve=h&&(0,K.jsx)(WO,{drivers:ut(oe).map(e=>({...e,...YO[e.value]})),driver:M,model:j,onChange:(e,t)=>or({driver:e,model:t}),effort:{levels:Pt(oe,M,j),level:A.effort||void 0,onChange:e=>or({effort:e??``})},busy:u}),ye=!m&&(0,K.jsx)(RO,{commands:ne,customPresets:N,projectPresets:P,busy:u,onLoad:ge,onNew:()=>w(!0),onDelete:e=>or({customPresets:N.filter(t=>t.id!==e)}),onDeleteProject:e=>ar(ee,P.filter(t=>t.id!==e))}),be=g?null:(0,K.jsx)(KO,{busy:u,inRow:!m,connection:{machines:E,selectedMachineId:F,onlyHere:re,home:y,onlyThere:ie,onSelect:e=>xi(e.id),onSelectLocal:()=>xi(null),onAddMachine:()=>Ml(`devices`),status:D}}),L=!!x.trim(),xe=(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(V,{type:`submit`,size:`icon-sm`,onClick:he,disabled:u||!L||se||de||!_,"aria-hidden":!L,tabIndex:L?void 0:-1,"aria-label":d,className:B(`h-8 w-8 shrink-0 transition-[margin,opacity,transform] duration-150 ease-out`,L?B(`ml-0 translate-x-0 opacity-100`,u?`disabled:opacity-100`:`disabled:opacity-40`):B(`pointer-events-none translate-x-2 opacity-0 disabled:opacity-0`,m?`-ml-[2.375rem]`:`-ml-8`))}),children:u?(0,K.jsx)(ae,{className:`h-4 w-4 animate-spin`}):(0,K.jsx)(Gi,{className:`h-4 w-4`})}),(0,K.jsx)(z,{children:u?f:`${d} (Enter · Shift+Enter for a new line)`})]}),Se=!L&&v?v:xe,Ce=se&&(0,K.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:`${I?et(I):`The selected machine`} is offline. Pick another place to run, then start.`}),Te=de&&(0,K.jsxs)(`div`,{role:`note`,className:`mb-1.5 flex items-center gap-3 rounded-md border border-border bg-background px-3 py-2 text-xs`,children:[(0,K.jsxs)(`p`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:`Your GitHub and Claude logins are copied to @${ue}'s server.`}),` `,(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`@${ue} can see what is on it. Runs there start once you say OK.`})]}),(0,K.jsx)(V,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>{le(I.id),zi(I.id)},children:`OK`})]});return m?(0,K.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:_e}),ve,be,Se]}):(0,K.jsxs)(K.Fragment,{children:[!g&&(0,K.jsx)(`div`,{className:B(`mb-1`,XO),children:(0,K.jsxs)(`div`,{className:ZO,children:[be,r]})}),Te,(0,K.jsxs)(`div`,{className:`flex items-end rounded-xl border border-border bg-card focus-within:border-muted-foreground/40`,children:[ye&&(0,K.jsx)(`div`,{className:`-mr-2 flex shrink-0 items-center p-1`,children:ye}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:_e}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center p-1`,children:Se})]}),(0,K.jsxs)(`div`,{className:B(`mt-1`,XO),children:[(0,K.jsx)(`div`,{className:ZO,children:i}),(0,K.jsx)(`div`,{className:`shrink-0`,children:ve||(0,K.jsxs)(`span`,{className:`flex items-center`,children:[a!==void 0&&(0,K.jsx)(`span`,{className:`px-2 text-[13px] text-muted-foreground`,children:a}),o]})})]}),Ce,C&&(0,K.jsx)(IO,{currentPrompt:x,busy:u,canSaveToProject:ee!==null,onCancel:()=>{w(!1),T.current?.focus()},onSave:(e,t)=>{t===`project`?ar(ee,[...P,e]):or({customPresets:[...N,e]}),w(!1),T.current?.focus()}})]})});function $O(e,t,n){return e===`local`?`${n} (local)`:t}function ek({main:e,local:t,pick:n,onPick:r,busy:i}){let a=$O(n,e,t),o=[{pick:`main`,label:e,description:`The project's main branch, fetched fresh.`},{pick:`local`,label:`My local branch ${t}`,description:`Your branch as committed on this machine; uncommitted edits are not carried. If the agent publishes, your commits that are not pushed go up with its branch.`}];return(0,K.jsxs)(re,{children:[(0,K.jsxs)(U,{children:[(0,K.jsxs)(H,{render:(0,K.jsx)(bt,{type:`button`,disabled:i,"aria-label":`The agent starts from`,className:Il}),children:[(0,K.jsx)(ha,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`truncate`,children:a}),(0,K.jsx)(Fe,{className:`h-3 w-3 shrink-0 opacity-70`,"aria-hidden":!0})]}),(0,K.jsx)(z,{children:`The agent starts from ${a}`})]}),(0,K.jsx)(Be,{align:`start`,className:`min-w-[19rem] max-w-[22rem]`,children:(0,K.jsxs)(We,{children:[(0,K.jsx)(c,{className:`font-normal`,children:`The agent starts from`}),o.map(e=>(0,K.jsxs)(L,{className:`items-start`,"aria-current":e.pick===n,onClick:()=>r(e.pick),children:[(0,K.jsx)(N,{className:B(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.pick===n?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,K.jsx)(Ae,{label:e.label,description:e.description})]},e.pick))]})})]})}function tk(e,t){let n=t?.replace(/\/+$/,``);return n&&e.startsWith(`${n}/`)?e.slice(n.length+1):e}function nk(e,t){let n=t?.replace(/\/+$/,``);return n===void 0||!e.startsWith(`/`)||e.startsWith(`${n}/`)}function rk(e){return e.kind===`driver`&&e.event.type===`output`?e.event.changed??[]:[]}function ik(e){return e.kind===`driver`&&e.event.type===`start`}function ak(e,t){let n=new Map;for(let r of e){if(!nk(r.path,t))continue;let e=tk(r.path,t),i=n.get(e)??{path:e,name:e.replace(/\/+$/,``).split(`/`).pop()||e,added:0,removed:0,created:!1};n.set(e,{...i,added:i.added+r.added,removed:i.removed+r.removed,created:i.created||r.created===!0})}return[...n.values()].map(e=>e.created?{...e,added:Math.max(0,e.added-e.removed),removed:0}:e)}function ok(e,t){let n=new Map,r=[];for(let i of e){if(ik(i)){r.length>0&&n.set(i,ak(r,t)),r=[];continue}r.push(...rk(i))}return{ended:n,last:ak(r,t)}}function sk(e){return{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)}}var ck={Bash:{verb:`Ran`,doing:`Running`,kind:`command`},Read:{verb:`Read`,doing:`Reading`,kind:`read`,file:!0},Edit:{verb:`Edited`,doing:`Editing`,kind:`edit`,file:!0},MultiEdit:{verb:`Edited`,doing:`Editing`,kind:`edit`,file:!0},NotebookEdit:{verb:`Edited`,doing:`Editing`,kind:`edit`,file:!0},Write:{verb:`Wrote`,doing:`Writing`,kind:`edit`,file:!0},Grep:{verb:`Searched`,doing:`Searching`,kind:`search`,plain:!0},Glob:{verb:`Searched`,doing:`Searching`,kind:`find`,plain:!0},WebSearch:{verb:`Searched the web`,doing:`Searching the web`,kind:`web`,plain:!0},WebFetch:{verb:`Fetched`,doing:`Fetching`,kind:`other`},Skill:{verb:`Ran skill`,doing:`Running skill`,kind:`skill`,slash:!0},Task:{verb:`Started agent`,doing:`Starting agent`,kind:`other`},Agent:{verb:`Started agent`,doing:`Starting agent`,kind:`other`},TodoWrite:{verb:`Updated todos`,doing:`Updating todos`,kind:`other`},ToolSearch:{verb:`Loaded tools`,doing:`Loading tools`,kind:`other`},commandExecution:{verb:`Ran`,doing:`Running`,kind:`command`},fileChange:{verb:`Edited`,doing:`Editing`,kind:`edit`,file:!0},mcpToolCall:{verb:`Called`,doing:`Calling`,kind:`other`},webSearch:{verb:`Searched the web`,doing:`Searching the web`,kind:`web`,plain:!0}};function lk(e){if(!/^[a-z]+([A-Z][a-z]*)+$/.test(e))return e;let t=e.replace(/[A-Z]/g,e=>` ${e.toLowerCase()}`);return t.charAt(0).toUpperCase()+t.slice(1)}function uk(e){return e.split(`, `).map(e=>e.replace(/\/+$/,``).split(`/`).pop()||e).join(`, `)}function dk(e){let t=/^mcp__(.+?)__(.+)$/.exec(e);if(!t)return;let n=t[2].replace(/_/g,` `);return{verb:`Used ${t[1]}:`,doing:`Using ${t[1]}:`,tool:n.charAt(0).toUpperCase()+n.slice(1)}}function fk(e,t,n){let r=ck[e],i=dk(e),a={verb:r?.verb??i?.verb??lk(e),doing:r?.doing??i?.doing??lk(e),kind:r?.kind??`other`};if(i&&(a.target=i.tool),r?.plain&&(a.plain=!0),t!==void 0&&(a.detail=t,a.target=r?.file?uk(t):r?.slash?`/${t.replace(/^\//,``)}`:t),n!==void 0&&n.length>0){let e=ak(n);a.kind=`edit`,a.verb=e.every(e=>e.created)?`Created`:`Updated`,a.target=e.map(e=>e.name).join(`, `),a.files=e,a.size=sk(e)}return a}var pk=(e,t,n)=>e===1?t:`${e} ${n}`;function mk(e){let t=t=>e.filter(e=>e.kind===t),n=t(`edit`),r=new Set(t(`read`).map((e,t)=>e.detail??t)).size,i=[],a={parts:i},o=t(`command`).length;if(o>0&&i.push({words:`ran ${pk(o,`a command`,`commands`)}`}),r>0&&i.push({words:`read ${pk(r,`a file`,`files`)}`}),t(`search`).length>0&&i.push({words:`searched code`}),t(`find`).length>0&&i.push({words:`found files`}),t(`web`).length>0&&i.push({words:`searched the web`}),n.length>0){let e=ak(n.flatMap(e=>(e.files??[]).map(e=>({path:e.path,added:e.added,removed:e.removed,...e.created?{created:!0}:{}})))),t=e.filter(e=>e.created).length;e.length===1?i.push({words:t===1?`created`:`edited`,target:e[0].name}):e.length===0?i.push({words:`edited ${pk(n.length,`a file`,`files`)}`}):(t>0&&i.push({words:`created ${pk(t,`a file`,`files`)}`}),e.length>t&&i.push({words:`edited ${pk(e.length-t,`a file`,`files`)}`})),e.length>0&&(a.size=sk(e))}let s=t(`skill`).length+t(`other`).length;return s>0&&i.push({words:`used ${pk(s,`a tool`,`tools`)}`}),i[0]&&(i[0].words=i[0].words.charAt(0).toUpperCase()+i[0].words.slice(1)),a}function hk(e){return e.parts.map(e=>e.target===void 0?e.words:`${e.words} ${e.target}`).join(`, `)}function gk({added:e,removed:t}){return(0,K.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,t]})]})}function _k({added:e,removed:t}){return(0,K.jsxs)(`span`,{className:`flex h-4 shrink-0 overflow-hidden rounded text-[10px] font-medium tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`bg-success/20 px-1 text-success`,"aria-hidden":!0,children:[`+`,e]}),(0,K.jsxs)(`span`,{className:`bg-danger/20 px-1 text-danger`,"aria-hidden":!0,children:[`−`,t]}),(0,K.jsxs)(`span`,{className:`sr-only`,children:[e,` added, `,t,` removed`]})]})}function vk({files:e,onOpen:t}){let n=e.length>1,r=`flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2`;return(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col rounded-[10px] p-1 font-sans ring-1 ring-border`,children:[n&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex h-7 items-center px-2 text-[13px] text-foreground`,children:[`Edited `,e.length,` files`]}),(0,K.jsx)(`div`,{"aria-hidden":!0,className:`-mx-1 my-1 h-px bg-border`})]}),(0,K.jsx)(`ul`,{"aria-label":`Files changed`,className:`flex min-w-0 flex-col`,children:e.map(e=>{let n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ua,{className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left text-[13px] text-foreground`,title:e.path,children:e.name}),(0,K.jsx)(`span`,{className:`text-xs`,children:(0,K.jsx)(gk,{added:e.added,removed:e.removed})})]});return(0,K.jsx)(`li`,{className:`min-w-0`,children:t?(0,K.jsx)(`button`,{type:`button`,onClick:()=>t(e.path),"aria-label":`Show the change to ${e.name}`,className:`${r} hover:bg-foreground/5`,children:n}):(0,K.jsx)(`div`,{className:r,children:n})},e.path)})}),n&&t&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(),className:`${r} hover:bg-foreground/5`,children:[(0,K.jsx)(`span`,{className:`flex-1 text-left text-[13px] text-foreground`,children:`See all`}),(0,K.jsx)(`span`,{className:`text-xs`,children:(0,K.jsx)(gk,{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)})})]})]})}function yk({since:e}){let[t,n]=(0,G.useState)(()=>Date.now());return(0,G.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]),(0,K.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:Ot(t-Date.parse(e))})}function bk(){return(0,K.jsxs)(`span`,{className:`dot-wave shrink-0`,"aria-hidden":!0,children:[(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{})]})}function xk(e){let t=e.trim().split(`
130
- `).find(e=>e.trim()!==``)?.trim()??`Thought`;return t.length>90?`${t.slice(0,90).trimEnd()}…`:t}var Sk=`max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md px-2.5 py-1.5 font-mono text-xs text-foreground`;function Ck({label:e,detail:t,whole:n,summary:r,output:i,live:a}){let[o,s]=(0,G.useState)(!1),c=fk(e,t,i?.changed),l=n??c.detail,u=c.kind===`command`?r:void 0,d=(0,K.jsxs)(K.Fragment,{children:[u===void 0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:B(`shrink-0`,a&&`text-shimmer`),children:a?c.doing:c.verb}),c.target!==void 0&&(0,K.jsx)(`span`,{className:B(`truncate`,a?`text-shimmer`:!c.plain&&`text-foreground`),children:c.target})]}):(0,K.jsx)(`span`,{className:B(`truncate`,a&&`text-shimmer`),children:u}),c.size!==void 0&&(0,K.jsx)(_k,{...c.size}),a?.since!==void 0&&(0,K.jsx)(yk,{since:a.since})]});return l===void 0&&i===void 0?(0,K.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:d}):(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,"aria-label":u??[a?c.doing:c.verb,c.target].filter(Boolean).join(` `),className:`flex max-w-full min-w-0 items-center gap-1.5 text-left hover:text-foreground`,children:[d,(0,K.jsx)(m,{className:B(`h-3.5 w-3.5 shrink-0 transition-transform`,o&&`rotate-90`),"aria-hidden":!0})]}),o&&(0,K.jsxs)(`div`,{className:`mt-1 flex flex-col gap-1`,children:[l!==void 0&&(0,K.jsxs)(`pre`,{"aria-label":c.kind===`command`?`Command`:`Detail`,className:B(Sk,`bg-muted`),children:[c.kind===`command`&&(0,K.jsx)(`span`,{className:`select-none text-muted-foreground`,children:`$ `}),l]}),i!==void 0&&i.text!==``&&(0,K.jsx)(`pre`,{"aria-label":`Output`,className:B(Sk,`border border-border`),children:i.text}),i?.failed&&(0,K.jsx)(`div`,{className:`text-xs text-danger`,children:i.exitCode===void 0?`Failed`:`Failed: exit code ${i.exitCode}`})]})]})}function wk({text:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),"aria-expanded":t,"aria-label":`Thought`,className:`flex min-w-0 max-w-full items-center gap-1.5 hover:text-foreground`,children:[(0,K.jsx)(`span`,{className:`truncate italic`,children:xk(e)}),(0,K.jsx)(m,{className:B(`h-3.5 w-3.5 shrink-0 transition-transform`,t&&`rotate-90`),"aria-hidden":!0})]}),t&&(0,K.jsx)(`div`,{className:`mt-1 italic`,children:(0,K.jsx)(Wt,{text:e,compact:!0})})]})}function Tk({call:e,word:t,since:n}){return(0,K.jsxs)(`div`,{role:`status`,className:`flex min-w-0 flex-1 items-center gap-2 font-sans text-sm text-muted-foreground`,children:[(0,K.jsx)(bk,{}),(0,K.jsx)(`span`,{className:`morph-in flex min-w-0 items-center gap-2`,children:e?(0,K.jsx)(Ck,{...e,live:{since:n}}):(0,K.jsxs)(K.Fragment,{children:[t!==void 0&&(0,K.jsx)(`span`,{className:`text-shimmer`,children:t}),n!==void 0&&(0,K.jsx)(yk,{since:n})]})},e?e.id??`${e.label} ${e.detail??``}`:t)]})}function Ek({steps:e,lead:t}){let[n,r]=(0,G.useState)(!1),i=lr().showThinking===!0?e:e.filter(e=>e.type===`action`),a=e.filter(e=>e.type===`action`);if(a.length===0)return null;let o=mk(a.map(e=>fk(e.label,e.detail,e.output?.changed))),s=hk(o),c=i.length===1?i[0]:void 0;return c?.type===`action`&&!t?(0,K.jsx)(`div`,{className:`min-w-0 flex-1 font-sans text-sm text-muted-foreground`,children:(0,K.jsx)(Ck,{...c})}):(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 font-sans text-sm text-muted-foreground`,children:[(0,K.jsx)(`div`,{className:`group/status flex`,children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,"aria-label":s,className:`flex min-w-0 items-center gap-1.5 py-0.5`,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate text-left`,children:o.parts.map((e,t)=>(0,K.jsxs)(G.Fragment,{children:[(0,K.jsxs)(`span`,{className:`group-hover/status:text-foreground/80 group-has-focus-visible/status:text-foreground/80`,children:[t>0&&`, `,e.words]}),e.target!==void 0&&(0,K.jsxs)(`span`,{className:`text-foreground/80 group-hover/status:text-foreground group-has-focus-visible/status:text-foreground`,children:[` `,e.target]})]},t))}),o.size!==void 0&&(0,K.jsx)(_k,{...o.size}),(0,K.jsx)(m,{className:B(`h-3.5 w-3.5 shrink-0 transition-transform`,n&&`rotate-90`),"aria-hidden":!0})]})}),n&&(0,K.jsxs)(`div`,{className:`mt-1.5 flex flex-col divide-y divide-border rounded-lg border border-border`,children:[t&&(0,K.jsx)(`div`,{className:`px-2 py-1.5`,children:t}),i.map((e,t)=>(0,K.jsx)(`div`,{className:`px-2 py-1.5`,children:e.type===`action`?(0,K.jsx)(Ck,{...e}):(0,K.jsx)(wk,{text:e.text})},t))]})]})}var Dk=`Starting session`,Ok=8e3,kk=6e4,Ak=8e3;function jk({projectId:e,projectName:t,onAgentStarted:n,files:r,context:i,addContext:a,removeContext:o,toggleContext:s,onOpenSkills:c,home:l}){let[u,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(null),{busy:h,cloning:_,error:v,reset:y,start:b}=fl(e),x=(0,G.useRef)(null),S=lr(),C=_l(e),w=Vi(),T=wi();(0,G.useEffect)(()=>Ti(l),[e,l]);let E=Ei(w,T,C,l),D=l!==void 0&&E?.id===l,O=E!==void 0&&!D,k=l!==void 0&&E===void 0,A=C!==null&&!C.startHook&&!O&&!k,j=O?[]:vl(C?.commands??[]),M=ul(j),N=O?!0:C?.gitHost??!0,P=O?!0:C?.remote??!0,ee=d(S.publish,N,P),te=O||k?void 0:C?.startFrom,re=S.startFrom?.[e]??`main`,ae=ur(),F=t=>{let{[e]:n,...r}=S.startFrom??{};or({startFrom:t===`local`?{...r,[e]:`local`}:r})},I=S.driver,[oe,ce]=(0,G.useState)(0),le=C?.address,ue=we(E?null:k?le===void 0?null:()=>fi(le,I):()=>di(e,I),null,[e,I,E===void 0,k,le,oe]),[de,fe]=(0,G.useState)(kk),pe=g(E?()=>ne(e,E.id,I):null,null,de,[e,I,E?.id]).value,me=E?pe:ue;(0,G.useEffect)(()=>{let e=pe&&pe.problems.length>0?Ok:kk;e!==de&&fe(e)},[pe,de]);let he=!E&&me?.fix!==void 0,{state:ge,reload:ve}=Ss(_e(I)?I:void 0,he),ye=se[_e(I)?I:`claude-code`],be=g(E?.owner===void 0?null:()=>ie(E.id),null,Ak,[E?.id]).value,L=E?.owner!==void 0&&be?.ok?[`GitHub`,`Claude`].filter(e=>be.logins[e===`GitHub`?`github`:`claude`]===void 0):[],xe=E?et(E):void 0,Se=(0,G.useRef)(void 0);return(0,G.useEffect)(()=>{let e=he?ge?.ready:void 0;Se.current===!1&&e===!0&&ce(e=>e+1),Se.current=e},[he,ge?.ready]),(0,K.jsxs)(`form`,{onSubmit:e=>e.preventDefault(),className:`relative mx-auto w-full max-w-3xl p-2`,children:[(0,K.jsx)(QO,{ref:x,home:l,files:r,addContext:a,removeContext:o,startsAt:t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ll,{icon:(0,K.jsx)(ma,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),children:t}),te&&ae&&(0,K.jsx)(ek,{main:te.main,local:te.local,pick:re,onPick:F,busy:h})]}):null,controls:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Vl,{projectId:e,context:i,busy:h,onToggle:s}),(0,K.jsx)(zl,{publish:ee,picks:kt(N,P),onPublish:e=>or({publish:e}),cleanup:M?S.postMergeCleanup??!1:void 0,onCleanup:e=>or({postMergeCleanup:e}),busy:h}),c&&(0,K.jsxs)(`button`,{type:`button`,onClick:c,className:Il,children:[(0,K.jsx)(Ia,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`truncate`,children:`Skills`})]})]}),onSubmit:async t=>{if(h)return;f(Dk),m(E?et(E):k?Mk():null);let r=await b(e,Pl(t,i),{...cl(S),...dl(S,j),...te&&re===`local`?{base:te.local}:{},...E?{machine:E.id}:{}});f(null),r&&(n?.(t,r.agentId,E?.label,r.projectId),x.current?.clear())},onPromptChange:e=>{!e.trim()&&u&&f(null),v&&y()},onPreset:(e,t)=>{y(),f(t?`${e} loaded over your draft — undo (⌘Z) brings the draft back`:`${e} loaded — review or edit, then Start`)},busy:h,canSubmit:!A,submitLabel:`Start agent`,submitBusyLabel:`Starting…`}),(0,K.jsxs)(`div`,{className:`absolute inset-x-2 bottom-full flex flex-col gap-1.5 pb-1`,children:[v&&L.length===0&&!me?.problems.length&&(0,K.jsx)(Nk,{...Pk(v)}),E&&L.length>0&&(0,K.jsx)(Nk,{title:`Your ${L.join(` and `)} ${L.length===1?`login is`:`logins are`} not on ${xe} yet.`,detail:`Runs there use your own logins. Log ${L.length===1?`it`:`them`} in on its page, or start your first run there from your page on ${Te(E.url)??`its server`}, which copies yours.`,actions:(0,K.jsx)(V,{type:`button`,size:`xs`,onClick:()=>Ml(`devices`,E.id),children:`Log in on ${xe}`})}),me?.problems.map(e=>e===me.fix?.problem?E?(0,K.jsx)(Nk,{title:me.fix.kind===`log-in`?`${ye} is not logged in on ${xe}.`:`${ye} is not installed on ${xe}.`,...me.fix.kind===`log-in`?{actions:(0,K.jsx)(Ys,{machineId:E.id,onAccounts:()=>Ml(_s)})}:{}},e):(0,K.jsx)(Nk,{...ge&&!ge.ready?{title:js(ge),actions:(0,K.jsx)(Fs,{state:ge,onChanged:()=>void ve(),size:`xs`})}:Pk(e)},e):(0,K.jsx)(Nk,{...Pk(e)},e)),me?.warnings.map(e=>(0,K.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-warning/30 bg-[color-mix(in_oklab,var(--color-warning)_8%,var(--color-background))] px-3 py-1.5 text-xs text-warning`,children:e},e)),A&&(0,K.jsx)(Nk,{title:`This project has no start hook.`,detail:(0,K.jsxs)(K.Fragment,{children:[`Add a `,(0,K.jsx)(`code`,{className:`font-mono`,children:`start:`}),` line to `,(0,K.jsx)(`code`,{className:`font-mono`,children:`.openagent/hooks.yml`}),`.`]})}),u===Dk&&!v&&(0,K.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 px-1.5 text-sm text-muted-foreground`,children:[(0,K.jsx)(bk,{}),(0,K.jsx)(`span`,{className:`text-shimmer`,children:_&&p?`Cloning ${t??`this project`} on ${p}, the first time only`:u})]})]}),u!==Dk&&u&&!v&&(0,K.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-muted-foreground`,children:u})]})}function Mk(){let e=ol();return e===`This machine`?`this computer`:e}function Nk({title:e,detail:t,actions:n}){return(0,K.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2.5 rounded-lg border border-danger/30 bg-[color-mix(in_oklab,var(--color-danger)_8%,var(--color-background))] px-3 py-2.5 shadow-sm`,children:[(0,K.jsx)(Qi,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere]`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-danger`,children:e}),t!==void 0&&(0,K.jsxs)(K.Fragment,{children:[` `,(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]}),n!==void 0&&(0,K.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-foreground`,children:n})]})]})}function Pk(e){let t=e.search(/\.\s+(?=[A-Z`@])/);return t<=0||t>140?{title:e}:{title:e.slice(0,t+1),detail:e.slice(t+1).trim()}}function Fk(e){let t=Bk(e);return t.length>0&&!t.some(e=>e.kind===`end`)}function Ik(e){let t=Bk(e).find(e=>e.kind===`end`);if(!(!t||t.kind!==`end`))return{ok:t.ok,stopped:t.stopped===!0,...t.waiting===!0?{waiting:!0}:{},...t.detail===void 0?{}:{detail:t.detail}}}function Lk(e){if(e!==`running`)return{ok:e===`done`,stopped:e===`stopped`,...e===`waiting`?{waiting:!0}:{}}}function Rk(e){let t;for(let n of e){if(n.kind!==`driver`||n.event.type!==`action`)continue;let e=/^run (https?:\/\/\S+)$/.exec(n.event.label);e&&(t=e[1])}return t}function zk(e){let t;for(let n of e){if(n.kind!==`driver`||n.event.type!==`action`)continue;let e=/^cloud (https:\/\/claude\.ai\/code\/(session_[A-Za-z0-9]+)\S*)$/.exec(n.event.label);e&&(t={url:e[1],id:e[2]})}return t}function Bk(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let i=e[r]?.kind;if(i===`session`){t=r;break}if(i===`end`&&n){t=r+1;break}i===`driver`&&(n=!0)}return e.slice(t)}function Vk(e){let t=e?.sessionLink,n=e?.sessionId;return!t||!n||!t.includes(n)?null:{href:t,label:`Open session (${n}) ↗`}}function Hk(e){let t=e?.sessionId;if(!t)return null;let n=e.workspace;if(!n)return t;let r=`'${n.replaceAll(`'`,`'\\''`)}'`;return`mkdir -p ${r} && cd ${r} && claude --resume ${t}`}function Uk(){return we(()=>Un(),[],[])}function Wk(e){let t=Uk();return e&&!t.some(t=>t.bin===e)?[...t,{bin:e,label:e}]:t}function Gk({busy:e}){let t=lr().editor,n=Wk(t);return(0,K.jsxs)(We,{children:[(0,K.jsx)(c,{children:`Preferred editor`}),(0,K.jsxs)(L,{disabled:e,closeOnClick:!1,onClick:()=>or({editor:``}),className:`items-start`,children:[(0,K.jsx)(N,{className:B(`mt-0.5 h-3.5 w-3.5 shrink-0`,t?`opacity-0`:`opacity-100`)}),(0,K.jsx)(Ae,{label:`Default`,description:`$OPENAGENT_EDITOR, or code`})]}),n.map(n=>(0,K.jsxs)(L,{disabled:e,closeOnClick:!1,onClick:()=>or({editor:n.bin}),className:`items-start`,children:[(0,K.jsx)(N,{className:B(`mt-0.5 h-3.5 w-3.5 shrink-0`,t===n.bin?`opacity-100`:`opacity-0`)}),(0,K.jsx)(Ae,{label:n.label,description:n.bin})]},n.bin))]})}var Kk=`font-medium text-foreground`;function qk({projectId:e,open:t,onOpenChange:n,onRemoved:r}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),{busy:c,error:l,run:u,reset:d}=en();(0,G.useEffect)(()=>{t&&(a(!1),d())},[t,d]);let f=()=>{n(!1),queueMicrotask(r)};return(0,K.jsx)(ot,{open:t,onOpenChange:e=>{c||o||n(e)},children:(0,K.jsxs)(Ie,{children:[(0,K.jsx)(j,{className:`fixed inset-0 z-50 bg-black/40 backdrop-blur-[1px]`}),(0,K.jsx)(P,{className:`fixed left-1/2 top-1/2 z-50 max-h-[calc(100vh-2rem)] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-lg border border-border bg-card p-5 text-card-foreground shadow-lg`,children:o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(hn,{className:`text-sm font-semibold`,children:`Project removed`}),(0,K.jsx)(Ne,{className:`mt-2 text-xs leading-relaxed text-muted-foreground`,children:`It left the dashboard’s list. This is what happened to OpenAgent’s files in the folder.`}),(0,K.jsx)(Jk,{title:`Deleted`,empty:`Nothing: there was nothing of OpenAgent’s to delete.`,lines:o.removed}),o.kept.length>0&&(0,K.jsx)(Jk,{title:`Kept`,lines:o.kept.map(e=>`${e.path}: ${e.reason}`)}),o.failed.length>0&&(0,K.jsx)(Jk,{title:`Could not be cleaned`,lines:o.failed,danger:!0}),(0,K.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,K.jsx)(V,{size:`sm`,onClick:f,children:`Done`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(hn,{className:`text-sm font-semibold`,children:`Remove this project?`}),(0,K.jsxs)(Ne,{className:`mt-2 text-xs leading-relaxed text-muted-foreground`,children:[`It leaves the dashboard’s list, and its scheduler stops unless you set it to keep running.`,` `,i?(0,K.jsx)(K.Fragment,{children:`Your files and your commits stay.`}):(0,K.jsxs)(K.Fragment,{children:[`Nothing in the folder is deleted: your files and your commits stay, and so do OpenAgent’s own files there (`,(0,K.jsx)(`span`,{className:Kk,children:`.openagent`}),`, `,(0,K.jsx)(`span`,{className:Kk,children:`.branches`}),`,`,` `,(0,K.jsx)(`span`,{className:Kk,children:`.agent-runner`}),` and the branch `,(0,K.jsx)(`span`,{className:Kk,children:`agent-data`}),` with the agents’ records).`]}),` `,`Add the folder again to bring the project back.`]}),(0,K.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-start gap-2 text-xs text-foreground`,children:[(0,K.jsx)(Nt,{checked:i,onCheckedChange:e=>a(e===!0),disabled:c,className:`mt-0.5`}),(0,K.jsx)(`span`,{children:`Also delete OpenAgent’s files in this folder`})]}),i&&(0,K.jsxs)(`div`,{className:`mt-2 rounded-md border border-border p-3 text-xs leading-relaxed text-muted-foreground`,children:[(0,K.jsxs)(`p`,{children:[`This deletes, on this machine: the agents’ checkouts in `,(0,K.jsx)(`span`,{className:Kk,children:`.branches`}),`, the folders`,` `,(0,K.jsx)(`span`,{className:Kk,children:`.openagent`}),` (with `,(0,K.jsx)(`span`,{className:Kk,children:`hooks.yml`}),`, the project’s start lines) and`,` `,(0,K.jsx)(`span`,{className:Kk,children:`.agent-runner`}),`, and the local branch `,(0,K.jsx)(`span`,{className:Kk,children:`agent-data`}),`. A tool that worked in the project removes its own files too: the scheduler’s state, the subagent settings.`]}),(0,K.jsxs)(`p`,{className:`mt-2`,children:[(0,K.jsx)(`span`,{className:Kk,children:`The agents’ conversations go with that branch.`}),` If you never shared the records, this is their only copy. If you did, what has not reached the remote yet is lost. An agent that waits for your answer cannot be continued after this.`]}),(0,K.jsxs)(`p`,{className:`mt-2`,children:[`It never touches the remote, your files, your commits, a branch with work on it, or a file git tracks. A checkout with uncommitted work stays, and so does `,(0,K.jsx)(`span`,{className:Kk,children:`.agent-runner/config.yml`}),` if you wrote one. A scheduler you set to keep running is not stopped: its files, the records and `,(0,K.jsx)(`span`,{className:Kk,children:`.openagent`}),` then stay. Stop it, add the folder again and remove it once more to delete them. You see the list of what went and what stayed right after.`]})]}),l&&(0,K.jsx)(`p`,{className:`mt-2 text-xs text-danger`,children:l}),(0,K.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,K.jsx)(Re,{render:(0,K.jsx)(V,{variant:`outline`,size:`sm`,disabled:c,children:`Cancel`})}),(0,K.jsx)(V,{variant:`destructive`,size:`sm`,disabled:c,onClick:()=>{u(()=>ai(e,i),`Could not remove the project.`).then(e=>{if(!e.ok)return;let t=e.value.cleanup;t?s(t):f()})},className:B(c&&`cursor-progress`),children:c?`Removing…`:i?`Remove and delete`:`Remove`})]})]})})]})})}function Jk({title:e,lines:t,empty:n,danger:r=!1}){return(0,K.jsxs)(`div`,{className:`mt-3 text-xs`,children:[(0,K.jsx)(`p`,{className:B(`font-medium`,r?`text-danger`:`text-foreground`),children:e}),t.length===0?(0,K.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n}):(0,K.jsx)(`ul`,{className:`mt-1 space-y-0.5 text-muted-foreground`,children:t.map(e=>(0,K.jsx)(`li`,{className:`break-words`,children:e},e))})]})}function Yk({projectId:e,agentId:t,events:n,label:r,retainedWorktree:i=!1,onWorktreeRemoved:a,onDeleted:o,onProjectRemoved:s,details:c,size:l}){let u=!!t,d=Fk(n),f=On(n),p=Vk(f),m=d||i,h=Hk(f),[g,_]=(0,G.useState)(!1),v=(0,G.useRef)(void 0);(0,G.useEffect)(()=>()=>clearTimeout(v.current),[]);let y=()=>{h&&navigator.clipboard?.writeText(h).then(()=>{_(!0),clearTimeout(v.current),v.current=setTimeout(()=>_(!1),1500)})},[b,x]=(0,G.useState)(0),S=we(()=>jr(e),null,[e,b],`previous`),C=we(u?null:()=>Mr(e),null,[e,u,b]),[w,T]=(0,G.useState)(!1),[E,D]=(0,G.useState)(0),O=we(u?null:()=>oi(e),null,[e,u,b,E],`previous`),[k,A]=(0,G.useState)(!1),[j,M]=(0,G.useState)(!1),P=()=>void ne(()=>si(e,!1),`Could not stop sharing.`).then(e=>{e.ok&&D(e=>e+1)}),{busy:ee,error:te,run:ne}=en(),[ie,ae]=(0,G.useState)(!1);(0,G.useEffect)(()=>ae(!1),[t]);let F=ee||ie&&d,[I,oe]=(0,G.useState)(!1),se=n=>ne(()=>Yr(e,n,t??void 0),`Failed to open.`),ce=()=>void ne(()=>Br(e,t??void 0),`Could not stop the session.`).then(e=>{e.ok&&ae(!0)}),le=()=>{t&&ne(()=>Kr(e,t),`Could not remove the worktree.`).then(e=>{e.ok&&a?.()})},ue=r?.trim()||t,de=u?`Session actions`:`Project actions`,fe=i&&!d&&!!t,pe=!!o&&!d&&!!t,me=S&&(0,K.jsxs)(L,{render:(0,K.jsx)(`a`,{href:S.url,target:`_blank`,rel:`noreferrer`}),children:[(0,K.jsx)(ca,{className:`h-3.5 w-3.5 shrink-0`}),` Open on `,S.name]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(re,{children:[u?(0,K.jsxs)(bt,{type:`button`,"aria-label":de,title:r,className:`flex min-w-0 items-center gap-1 rounded px-1 py-0.5 text-left text-xs hover:bg-muted data-[popup-open]:bg-muted`,children:[r?(0,K.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:r}):(0,K.jsx)(`span`,{"data-testid":`title-placeholder`,className:`h-3 w-40 max-w-full rounded bg-muted`}),(0,K.jsx)(Fe,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}):(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(bt,{type:`button`,"aria-label":de,className:_t({variant:`outline`,size:`icon-sm`})}),children:(0,K.jsx)(sa,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(z,{children:de})]}),(0,K.jsxs)(Be,{align:u?`start`:`end`,className:`min-w-[14rem]`,children:[c&&(0,K.jsxs)(L,{onClick:c.onToggle,children:[(0,K.jsx)(wa,{className:`h-3.5 w-3.5 shrink-0`}),` `,c.open?`Hide details`:`Show details`]}),!u&&me,C&&(0,K.jsxs)(L,{onClick:()=>T(!0),children:[(0,K.jsx)(ia,{className:`h-3.5 w-3.5 shrink-0`}),` Create a repository on `,C.name,`…`]}),O===`kept`&&(0,K.jsxs)(L,{onClick:()=>A(!0),children:[(0,K.jsx)(ia,{className:`h-3.5 w-3.5 shrink-0`}),` Share the agents’ records to the remote…`]}),O===`origin`&&(0,K.jsxs)(L,{disabled:ee,onClick:P,children:[(0,K.jsx)(ra,{className:`h-3.5 w-3.5 shrink-0`}),` Stop sharing the agents’ records`]}),(0,K.jsxs)(L,{disabled:ee,onClick:()=>void se(`files`),title:t&&!m?`This session no longer has its own checkout`:void 0,children:[(0,K.jsx)(da,{className:`h-3.5 w-3.5 shrink-0`}),` `,t?m?`Open session's folder`:`Open project folder`:`Open folder`]}),(0,K.jsxs)(Zt,{children:[(0,K.jsxs)(Kt,{disabled:ee,children:[(0,K.jsx)(oa,{className:`h-3.5 w-3.5 shrink-0`}),` Open in editor`]}),(0,K.jsxs)(It,{className:`min-w-[15rem]`,children:[(0,K.jsxs)(L,{disabled:ee,onClick:()=>void se(`editor`),children:[(0,K.jsx)(oa,{className:`h-3.5 w-3.5 shrink-0`}),` `,t?`Open this session's checkout`:`Open in your editor`]}),(0,K.jsx)(st,{}),(0,K.jsx)(Gk,{busy:ee})]})]}),u&&me,p&&(0,K.jsxs)(L,{render:(0,K.jsx)(`a`,{href:p.href,target:`_blank`,rel:`noreferrer`}),children:[(0,K.jsx)(ca,{className:`h-3.5 w-3.5 shrink-0`}),` `,p.label.replace(` ↗`,``)]}),h&&f?.sessionId&&(0,K.jsxs)(L,{closeOnClick:!1,onClick:y,title:h,children:[g?(0,K.jsx)(N,{className:`h-3.5 w-3.5 shrink-0 text-success`}):(0,K.jsx)(mn,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`flex-1`,children:g?`Copied`:f.workspace?`Copy resume command`:`Copy session id`}),(0,K.jsx)(`span`,{className:`ml-auto pl-3 font-mono text-[10px] text-muted-foreground`,children:f.sessionId.slice(0,8)})]}),(d||fe||pe)&&(0,K.jsx)(st,{}),d&&(0,K.jsxs)(L,{disabled:F,onClick:()=>void ce(),children:[(0,K.jsx)(Va,{className:`h-3 w-3 shrink-0 fill-current`}),` `,F?`Stopping…`:`Stop agent`]}),fe&&(0,K.jsxs)(L,{disabled:ee,onClick:()=>le(),children:[(0,K.jsx)(pa,{className:`h-3.5 w-3.5 shrink-0`}),` `,(0,K.jsx)(`span`,{className:`flex-1`,children:`Remove worktree`}),l&&(0,K.jsx)(`span`,{className:`ml-auto pl-3 text-[10px] text-muted-foreground`,children:l})]}),pe&&(0,K.jsxs)(L,{onClick:()=>oe(!0),className:`text-danger`,children:[(0,K.jsx)(Ua,{className:`h-3.5 w-3.5 shrink-0`}),` Delete session`]}),s&&!u&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(st,{}),(0,K.jsxs)(L,{onClick:()=>M(!0),className:`text-danger`,children:[(0,K.jsx)(Ua,{className:`h-3.5 w-3.5 shrink-0`}),` Remove project…`]})]}),te&&(0,K.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-danger`,children:te})]})]}),C&&(0,K.jsx)(tn,{open:w,onOpenChange:T,title:`Create a private repository on ${C.name}?`,body:(0,K.jsxs)(K.Fragment,{children:[`This creates the private repository `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:C.repository}),` on your`,` `,C.name,` account and pushes this project to it. The project’s code leaves this machine.`]}),confirmLabel:`Create and push`,confirmBusyLabel:`Creating…`,fallbackError:`Could not create the repository.`,destructive:!1,onConfirm:()=>ei(e),onSuccess:()=>x(e=>e+1)}),O===`kept`&&(0,K.jsx)(tn,{open:k,onOpenChange:A,title:`Share the agents’ records to the remote?`,body:(0,K.jsxs)(K.Fragment,{children:[`This pushes a branch `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`agent-data`}),` to this project’s remote, and keeps pushing as agents work. It holds what you asked each agent and what it answered, under your git email. Everyone who can read the remote can read it.`]}),confirmLabel:`Share`,confirmBusyLabel:`Sharing…`,fallbackError:`Could not share the records.`,destructive:!1,onConfirm:()=>si(e,!0),onSuccess:()=>D(e=>e+1)}),s&&!u&&(0,K.jsx)(qk,{projectId:e,open:j,onOpenChange:M,onRemoved:s}),o&&t&&(0,K.jsx)(tn,{open:I,onOpenChange:oe,title:`Delete this agent?`,body:(0,K.jsxs)(K.Fragment,{children:[`Deleting `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:ue}),` removes it from the dashboard for good — its history can’t be recovered. Its branch and any pull request stay in git.`]}),confirmLabel:`Delete`,confirmBusyLabel:`Deleting…`,fallbackError:`Could not delete the agent.`,onConfirm:()=>qr(e,t),onSuccess:o})]})}function Xk({docs:e,loaded:t}){let[n,r]=(0,G.useState)(0);if(!t)return(0,K.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading…`});if(e.length===0)return(0,K.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`No PLAN/TODO docs yet.`});let i=e[Math.min(n,e.length-1)];return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-auto flex-col`,children:[(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1 border-b border-border p-2`,children:e.map((e,t)=>(0,K.jsx)(V,{variant:`ghost`,size:`sm`,className:B(`h-7 text-xs`,t===n&&`bg-accent text-accent-foreground`),onClick:()=>r(t),children:e.name},e.name))}),(0,K.jsx)(Ye,{className:`min-h-0 flex-auto`,children:(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsx)(Wt,{text:i.content})})})]})}var Zk=class extends G.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e.message:String(e)}}render(){return this.state.error===null?this.props.children:(0,K.jsxs)(`div`,{role:`alert`,className:`p-6 text-sm text-danger`,children:[`The `,this.props.label,` failed: `,this.state.error]})}};function Qk({package:e,label:t,children:n}){let r=Ze(e);return(0,K.jsx)(Xt.Provider,{value:r,children:(0,K.jsx)(Zk,{label:t,children:n})})}function $k(e,t){return e.flatMap(e=>{let n=t.find(t=>t.id===e);return n?[{id:n.id,name:n.name,gitHost:n.gitHost}]:[]})}function eA({page:e,projects:t,projectId:n,path:r}){let i=e.Page;return(0,K.jsx)(Qk,{package:e.package,label:`${e.label} page`,children:(0,K.jsx)(i,{projects:$k(e.projects,t),projectId:n,path:r})},e.segment)}function tA(e){let t=(0,G.useId)();return`${e??t}`}var nA=typeof window<`u`?G.useLayoutEffect:G.useEffect;function rA(e){let t=(0,G.useRef)(e);return nA(()=>{t.current=e},[e]),(0,G.useCallback)((...e)=>t.current?.(...e),[t])}function iA(...e){return rA(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function aA(e,t){return t?e*2+1:e+1}function oA(e,t){return t?e*2-1:e}function sA(e,t,n){let r=aA(e,n);return t===void 0?`${r} / -1`:`${r} / span ${oA(t,n)}`}function cA(e){return`${e*2} / span 1`}function lA({crossCount:e,crossSpan:t,crossStart:n,hasGutters:r}){let i=t===void 0?e:n+t;if(n===0&&i===e)return`1 / -1`;let a=aA(n,r),o=aA(i-1,r)+1;return r&&(n>0&&a--,i<e&&o++),`${a} / ${o}`}function uA(e,t){return Number.isInteger(e)&&e>=1&&e<t}function dA(e,t=`Assertion error`){if(!e)throw Error(t)}var fA=(0,G.createContext)(null);function pA(){let e=(0,G.useContext)(fA);return dA(e,`Grid Context not found; did you render a Cell or Gridline outside of a Grid?`),e}function mA({children:e,className:t,column:n,columnSpan:r=1,elementRef:i,id:a,row:o,rowSpan:s=1,style:c,...l}){let u=tA(a),{gutters:d,registerCell:f}=pA(),p=(0,G.useRef)(null),m=iA(p,i);return nA(()=>{let e=p.current;if(e!==null)return f({column:n,columnSpan:r,element:e,id:u,row:o,rowSpan:s})},[n,r,u,f,o,s]),(0,K.jsx)(`div`,{...l,className:t,"data-cell":!0,"data-testid":u,id:u,ref:m,style:{overflow:`auto`,...c,minHeight:0,minWidth:0,gridColumn:sA(n,r,d.column),gridRow:sA(o,s,d.row)},children:e})}mA.displayName=`Cell`;var hA;function gA(){return hA===void 0&&(hA=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),hA}function _A({expandHitTargets:e,axis:t,rect:n}){let r=e?gA()?t.resizeTargetMinimumSize.coarse:t.resizeTargetMinimumSize.fine:0;if(n.width<r){let e=r-n.width;n=new DOMRect(n.x-e/2,n.y,n.width+e,n.height)}if(n.height<r){let e=r-n.height;n=new DOMRect(n.x,n.y-e/2,n.width,n.height+e)}return n}function vA({axis:e,cells:t,index:n,rect:r}){let i=[r];for(let r of t){let t=e===`column`?r.column:r.row,a=e===`column`?r.columnSpan:r.rowSpan;if(t>=n||t+a<=n)continue;let o=r.element.getBoundingClientRect(),s=e===`column`?o.top:o.left,c=e===`column`?o.bottom:o.right;c<=s||(i=i.flatMap(t=>{let n=e===`column`?t.top:t.left,r=e===`column`?t.bottom:t.right;if(s>=r||c<=n)return[t];let i=[],a=(n,r)=>{i.push(e===`column`?new DOMRect(t.x,n,t.width,r-n):new DOMRect(n,t.y,r-n,t.height))};return n<s&&a(n,s),r>c&&a(c,r),i}))}return i}function yA({axis:e,cells:t,crossTrackCount:n,expandHitTargets:r,resizeAxis:i,axisSize:a,includeDisabled:o,separatorPlacements:s}){let{items:c,separators:l}=i,u=c.length,d=-1,f=-1,p=0;if(c.forEach((e,t)=>{e.constraintProps.disabled||(p++,d===-1&&(d=t),f=t)}),!o&&p<2)return[];let m=e=>o||e>d&&e<=f,h=[],g=(e,t,n)=>({axis:i,axisSize:a,items:[c[e-1],c[e]],rect:t,separator:n}),_=(n,r)=>{let i;for(let a of t){let t=e===`column`?a.row:a.column,o=e===`column`?a.rowSpan:a.columnSpan;if(r===`start`?t===n:t+o-1===n){let t=a.element.getBoundingClientRect();if(r===`start`){let n=e===`column`?t.top:t.left;i=i===void 0?n:Math.min(i,n)}else{let n=e===`column`?t.bottom:t.right;i=i===void 0?n:Math.max(i,n)}}}return i},v=new Set;for(let a of l){let c=s.get(a);if(!c||c.index<1||c.index>=u||(v.add(c.index),!o&&(a.disabled||a.element.hasAttribute(`aria-disabled`)))||!m(c.index))continue;let l=a.element.getBoundingClientRect(),{crossSpan:d,crossStart:f}=c,p=d===void 0?n:f+d,y=e===`column`?l.top:l.left,b=e===`column`?l.bottom:l.right;if(f>0){let e=_(f-1,`end`);e!==void 0&&e<y&&(y=e)}if(p<n){let e=_(p,`start`);e!==void 0&&e>b&&(b=e)}l=e===`column`?new DOMRect(l.x,y,l.width,b-y):new DOMRect(y,l.y,b-y,l.height),l=_A({expandHitTargets:r,axis:i,rect:l}),o?h.push(g(c.index,l,a)):vA({axis:e,cells:t,index:c.index,rect:l}).forEach(e=>{h.push(g(c.index,e,a))})}let y=(n,a)=>{vA({axis:e,cells:t,index:n,rect:_A({expandHitTargets:r,axis:i,rect:a})}).forEach(e=>{h.push(g(n,e))})},b=Array.from({length:n},()=>Array(u));for(let r of t){let[t,i,a,o]=e===`column`?[r.column,r.columnSpan,r.row,r.rowSpan]:[r.row,r.rowSpan,r.column,r.columnSpan];for(let e=Math.max(0,a);e<Math.min(n,a+o);e++)for(let n=Math.max(0,t);n<Math.min(u,t+i);n++)b[e][n]??=r}let x=new Map,S=t=>{let n=x.get(t);if(!n){let r=t.element.getBoundingClientRect();n=e===`column`?{crossEnd:r.bottom,crossStart:r.top,end:r.right,start:r.left}:{crossEnd:r.right,crossStart:r.left,end:r.bottom,start:r.top},x.set(t,n)}return n},C=({crossEnd:t,crossStart:n,end:r,start:i})=>e===`column`?new DOMRect(i,n,r-i,t-n):new DOMRect(n,i,t-n,r-i);for(let e=1;e<u;e++){if(v.has(e)||!m(e))continue;let t;for(let r=0;r<n;r++){let n=b[r][e-1],i=b[r][e],a;if((n||i)&&n!==i){let e=n?S(n):void 0,t=i?S(i):void 0,r=e?.end??t.start,o=t?.start??e.end,s=Math.max(e?.crossStart??-1/0,t?.crossStart??-1/0),c=Math.min(e?.crossEnd??1/0,t?.crossEnd??1/0);a={crossEnd:Math.max(s,c),crossStart:s,end:Math.max(r,o),start:Math.min(r,o)}}a?t=t?{crossEnd:Math.max(t.crossEnd,a.crossEnd),crossStart:Math.min(t.crossStart,a.crossStart),end:Math.max(t.end,a.end),start:Math.min(t.start,a.start)}:a:t&&=(y(e,C(t)),void 0)}t&&y(e,C(t))}return h}function bA(e){let t=parseFloat(e??``);return Number.isFinite(t)?t:0}function xA({axis:e,element:t,gutterSizes:n,hasGutters:r,layout:i,trackIds:a}){let o=a.length,s=r?o*2-1:o,c=t.ownerDocument.defaultView?.getComputedStyle(t),l=e===`column`?c?.gridTemplateColumns:c?.gridTemplateRows;if(l){let e=l.trim().split(/\s+/);if(e.length===s&&e.every(e=>/^-?[\d.]+px$/.test(e))){let t=a.map((t,n)=>bA(e[r?n*2:n]));return{availableSize:t.reduce((e,t)=>e+t,0),trackSizes:t}}}let u=e===`column`?t.offsetWidth:t.offsetHeight,d=e===`column`?bA(c?.paddingLeft)+bA(c?.paddingRight)+bA(c?.borderLeftWidth)+bA(c?.borderRightWidth):bA(c?.paddingTop)+bA(c?.paddingBottom)+bA(c?.borderTopWidth)+bA(c?.borderBottomWidth),f=bA(e===`column`?c?.columnGap:c?.rowGap),p=n.reduce((e,t)=>e+t,0),m=Math.max(0,u-d-f*Math.max(0,s-1)-p);return{availableSize:m,trackSizes:a.map(e=>i&&i[e]!==void 0?i[e]/100*m:m/o)}}function SA(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}var CA=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},wA={cursorFlags:0,state:`inactive`},TA=new CA;function EA(){return wA}function DA(e){return TA.addListener(`change`,e)}function OA(e,t=[],n,r=!1){let i=wA,a={...wA};a.cursorFlags=e,a.state===`active`&&(a.didPointerMove||=r,a.previews=t,n&&(a.previewLayoutMap=n)),wA=a,TA.emit(`change`,{prev:i,next:a})}function kA(e){let t=wA;wA=e,t.state===`active`&&e.state!==`active`&&t.didPointerMove&&t.hitRegions.forEach(({separator:e})=>{e&&e.element.ownerDocument.activeElement===e.element&&e.element.blur()}),TA.emit(`change`,{prev:t,next:e})}function AA(e){wA.state!==`active`||!wA.previews.some(t=>t.separator===e)||kA({...wA,previews:wA.previews.map(t=>t.separator===e?{...t}:t)})}function jA(e){if(wA.state===`inactive`)return!1;let t=wA.hitRegions.filter(t=>t.axis!==e),n=wA.state===`active`&&wA.previews.some(t=>t.axis===e);if(t.length===wA.hitRegions.length&&!n)return!1;if(t.length===0)kA({cursorFlags:0,state:`inactive`});else if(wA.state===`active`){let n=new Map(wA.initialLayoutMap),r=new Map(wA.previewLayoutMap);n.delete(e),r.delete(e),kA({...wA,cursorFlags:0,hitRegions:t,initialLayoutMap:n,previewLayoutMap:r,previews:wA.previews.filter(t=>t.axis!==e)})}else kA({...wA,hitRegions:t});return!0}var MA=e=>e,NA=()=>{},PA=1,FA=2,IA=4,LA=8,RA=3,zA=12,BA;function VA(){return BA===void 0&&(BA=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(BA=!0)),BA}function HA({cursorFlags:e,axes:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&VA()){let t=(e&PA)!==0,n=(e&FA)!==0,r=(e&IA)!==0,i=(e&LA)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return VA()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var UA=new WeakMap;function WA(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=UA.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=EA();switch(r.state){case`active`:case`hover`:{let e=HA({cursorFlags:r.cursorFlags,axes:r.hitRegions.map(e=>e.axis),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}UA.set(e,{prevStyle:t,styleSheet:n})}function GA({axis:e}){let{layoutStrategy:t,orientation:n,items:r}=e;return t?t.calculateAvailableSize():r.reduce((e,t)=>(e+=n===`horizontal`?t.element.offsetWidth:t.element.offsetHeight,e),0)}function KA(e,t){let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_DISCONNECTED?0:n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}function qA(e,t){return Array.from(t).sort((t,n)=>{let r=e===`horizontal`?JA(t,n):YA(t,n);return r===0?KA(t.element,n.element):r})}function JA(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function YA(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function XA(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function ZA(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function QA({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=ZA(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return dA(i,`No rect found`),i}function $A({expandHitTargets:e=!0,axis:t,includeDisabled:n=!1}){if(t.layoutStrategy)return t.layoutStrategy.calculateHitRegions({expandHitTargets:e,axis:t,includeDisabled:n});let{element:r,orientation:i,items:a,separators:o}=t,s=qA(i,Array.from(r.children).filter(XA).filter(e=>!e.hasAttribute(`data-resize-preview`)).map(e=>({element:e}))).map(({element:e})=>e),c=[],l=!1,u=!1,d=-1,f,p=-1,m=0,h,g=[];{let e=-1;for(let t of s)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(m++,d===-1&&(d=e),p=e))}if(n||m>1){let r=-1;for(let m of s)if(m.hasAttribute(`data-panel`)){r++;let o=a.find(e=>e.element===m);if(o){if(h){let a=h.element.getBoundingClientRect(),s=m.getBoundingClientRect(),_;if(u){let e=i===`horizontal`?new DOMRect(a.right,a.top,0,a.height):new DOMRect(a.left,a.bottom,a.width,0),t=i===`horizontal`?new DOMRect(s.left,s.top,0,s.height):new DOMRect(s.left,s.top,s.width,0);switch(g.length){case 0:_=[e,t];break;case 1:{let n=g[0];_=[n,QA({orientation:i,rects:[a,s],targetRect:n.element.getBoundingClientRect()})===a?t:e];break}default:_=g;break}}else _=g.length?g:[i===`horizontal`?new DOMRect(a.right,s.top,s.left-a.right,s.height):new DOMRect(s.left,a.bottom,s.width,s.top-a.bottom)];for(let i of _){let a=_A({expandHitTargets:e,axis:t,rect:`width`in i?i:i.element.getBoundingClientRect()});(n||!l&&!(r<=d||r>p))&&(f??=GA({axis:t}),c.push({axis:t,axisSize:f,items:[h,o],separator:`width`in i?void 0:i,rect:a})),l=!1}}u=!1,h=o,g=[]}}else if(m.hasAttribute(`data-separator`)){m.ariaDisabled!==null&&(l=!0);let e=o.find(e=>e.element===m);e?g.push(e):(h=void 0,g=[])}else u=!0}return c}function ej(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function tj(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function nj(e){return e/100*window.innerHeight}function rj(e){return e/100*window.innerWidth}function ij({axisSize:e,itemElement:t,styleProp:n}){let r,[i,a]=SA(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=tj(t,i);break;case`em`:r=ej(t,i);break;case`vh`:r=nj(i);break;case`vw`:r=rj(i);break}return r}function aj(e){return parseFloat(e.toFixed(3))}function oj(e){let{items:t}=e,n=GA({axis:e});return n===0?t.map(e=>({groupResizeBehavior:e.constraintProps.groupResizeBehavior,collapsedSize:0,collapsible:e.constraintProps.collapsible===!0,defaultSize:void 0,disabled:e.constraintProps.disabled,minSize:0,maxSize:100,itemId:e.id})):t.map(e=>{let{element:t,constraintProps:r}=e,i=0;r.collapsedSize!==void 0&&(i=aj(ij({axisSize:n,itemElement:t,styleProp:r.collapsedSize})/n*100));let a;r.collapsedThreshold!==void 0&&(a=aj(ij({axisSize:n,itemElement:t,styleProp:r.collapsedThreshold})/n*100));let o;r.defaultSize!==void 0&&(o=aj(ij({axisSize:n,itemElement:t,styleProp:r.defaultSize})/n*100));let s=0;r.minSize!==void 0&&(s=aj(ij({axisSize:n,itemElement:t,styleProp:r.minSize})/n*100));let c=100;return r.maxSize!==void 0&&(c=aj(ij({axisSize:n,itemElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsedThreshold:a,collapsible:r.collapsible===!0,defaultSize:o,disabled:r.disabled,minSize:s,maxSize:c,itemId:e.id}})}var sj=new Map,cj=new CA;function lj(e){sj=new Map(sj),sj.delete(e)}function uj(e,t){for(let[t]of sj)if(t.id===e)return t}function dj(e,t){for(let[t,n]of sj)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function fj(){return sj}function pj(e,t){return cj.addListener(`axisChange`,n=>{n.axis.id===e&&t(n)})}function mj(e,t,n){let r=sj.get(e);sj=new Map(sj),sj.set(e,t),cj.emit(`axisChange`,{axis:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function hj(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function gj(e,t,n=0){return Math.abs(aj(e)-aj(t))<=n}function _j(e,t){return gj(e,t)?0:e>t?1:-1}function vj({overrideDisabledItems:e,itemConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsedThreshold:a,collapsible:o,disabled:s,maxSize:c=100,minSize:l=0}=t;if(s&&!e)return n;if(_j(r,l)<0)if(o){let e=a??(l-i)/2,t=_j(n,i)<=0,o=t?i+e:l-e,s=_j(r,o);r=_j(r,i)<=0||s<0||a!==void 0&&t&&s===0?i:l}else r=l;return r=Math.min(c,r),r=aj(r),r}function yj({delta:e,initialLayout:t,itemConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(gj(e,0))return t;let o=a===`imperative-api`,s=n.map(({itemId:e})=>t[e]),c=n.map(({itemId:e})=>i[e]),l=[...s],[u,d]=r;dA(u!=null,`Invalid first pivot index`),dA(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];dA(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(dA(n!=null,`Previous layout not found for panel index ${t}`),gj(n,i)){let t=o-n;_j(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];dA(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(dA(n!=null,`Previous layout not found for panel index ${t}`),gj(n,o)){let t=n-i;_j(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];dA(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsedSize:a,collapsedThreshold:o,collapsible:c,minSize:l}=r;if(c&&_j(i,l)<0){let t=l-a,n=o??t/2;if(_j(i+Math.abs(e),l)<0){let r=_j(Math.abs(e),n);e=r>0||r===0&&o===void 0&&e<0?e<0?-t:t:0}}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];dA(e!=null,`Previous layout not found for panel index ${r}`);let a=vj({overrideDisabledItems:o,itemConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];dA(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=vj({overrideDisabledItems:o,itemConstraints:n[t],prevSize:i,size:a});if(!gj(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(hj(c,l))return i;{let t=e<0?d:u,r=s[t];dA(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=vj({overrideDisabledItems:o,itemConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!gj(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];dA(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=vj({overrideDisabledItems:o,itemConstraints:n[r],prevSize:i,size:a});if(gj(i,s)||(t-=s-i,l[r]=s),gj(t,0))break;e>0?r--:r++}}}return gj(Object.values(l).reduce((e,t)=>t+e,0),100,.1)?l.reduce((e,t,r)=>(e[n[r].itemId]=t,e),{}):i}function bj(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||_j(e[n],t[n])!==0)return!1;return!0}function xj({commit:e,document:t,event:n,hitRegions:r,initialLayoutMap:i,mountedAxes:a,pointerDownAtPoint:o,prevCursorFlags:s}){let c=0,l=EA(),u=l.state===`active`?l.previews:[],d=new Map(l.state===`active`?l.previewLayoutMap:void 0);r.forEach(t=>{let{axis:r,axisSize:s}=t,{orientation:l,items:f}=r;if(e&&r.resizePreviewMode!==`separator`)return;let{disableCursor:p}=r.mutableState,m=0;m=o?l===`horizontal`?(n.clientX-o.x)/s*100:(n.clientY-o.y)/s*100:l===`horizontal`?n.clientX<0?-100:100:n.clientY<0?-100:100;let h=i.get(r),g=a.get(r);if(!h||!g)return;let{defaultLayoutDeferred:_,derivedItemConstraints:v,axisSize:y,layout:b,separatorToItems:x}=g;if(v&&b&&x){let n=r.resizePreviewMode===`separator`?d.get(r)??b:b,i=yj({delta:m,initialLayout:h,itemConstraints:v,pivotIndices:t.items.map(e=>f.indexOf(e)),prevLayout:n,trigger:`mouse-or-touch`});if(r.resizePreviewMode===`separator`&&!e&&!bj(i,n)){d.set(r,i);let e=0,t=f.map(t=>(e+=i[t.id]-h[t.id],s/100*e));u=u.map(e=>{if(e.axis!==r)return e;let n=t[e.itemIndex];return n===e.offset?e:{...e,offset:n}})}if(bj(i,n)&&m!==0&&!p)switch(l){case`horizontal`:c|=m<0?PA:FA;break;case`vertical`:c|=m<0?IA:LA;break}(r.resizePreviewMode!==`separator`||e)&&!bj(i,b)&&mj(t.axis,{defaultLayoutDeferred:_,derivedItemConstraints:v,axisSize:y,layout:i,requestedAxisSize:y,requestedLayout:i,separatorToItems:x})}});let f=0;n.movementX===0?f|=s&RA:f|=c&RA,n.movementY===0?f|=s&zA:f|=c&zA;let p=l.state===`active`&&(n.clientX!==l.pointerDownAtPoint.x||n.clientY!==l.pointerDownAtPoint.y);OA(f,u,d,p),WA(t)}function Sj(e,t){let n=EA(),r=fj(),i=!1;switch(n.state){case`active`:xj({commit:!0,document:e,event:t,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags}),kA({cursorFlags:0,state:`inactive`}),n.hitRegions.length>0&&(WA(e),i=!0,n.hitRegions.forEach(e=>{if(!r.has(e.axis))return;let t=dj(e.axis.id,!0);mj(e.axis,t,{isUserInteraction:!0})}))}return i}function Cj(e){e.defaultPrevented||Sj(e.currentTarget,e)}function wj(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=ZA(n,a.rect);switch(e){case`horizontal`:(t.x<i.x||t.x===i.x&&t.y<=i.y)&&(r=a,i=t);break;case`vertical`:(t.y<i.y||t.y===i.y&&t.x<=i.x)&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function Tj(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Ej(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:Mj(e),b:Mj(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();dA(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:jj(Aj(n.a)),b:jj(Aj(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var Dj=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Oj(e){let t=getComputedStyle(Nj(e)??e).display;return t===`flex`||t===`inline-flex`}function kj(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Oj(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||Dj.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Aj(e){let t=e.length;for(;t--;){let n=e[t];if(dA(n,`Missing node`),kj(n))return n}return null}function jj(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Mj(e){let t=[];for(;e;)t.push(e),e=Nj(e);return t}function Nj(e){let{parentNode:t}=e;return Tj(t)?t.host:t}function Pj(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Fj(e){try{return e.matches(`:modal`)}catch{return!1}}function Ij({axisElement:e,hitRegion:t,pointerEventTarget:n}){if(XA(n)){let t=n.closest(`dialog`);if(t&&!t.contains(e)&&Fj(t))return!1}if(!XA(n)||n.contains(e)||e.contains(n))return!0;if(Ej(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Pj(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Lj(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=$A({axis:r}),a=wj(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Ij({axisElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Rj({layout:e,itemConstraints:t}){let n=t.map(({itemId:t})=>e[t]),r=[...n],i=r.reduce((e,t)=>e+t,0);if(Object.keys(e).length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${Object.values(e).map(e=>`${e}%`).join(`, `)}`);if(!gj(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];dA(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];dA(i!=null,`No layout data found for index ${e}`);let o=r[e];dA(o!=null,`No layout data found for index ${e}`);let s=vj({overrideDisabledItems:!0,itemConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!gj(a,0))for(let e=0;e<t.length;e++){let n=r[e];dA(n!=null,`No layout data found for index ${e}`);let i=n+a,o=vj({overrideDisabledItems:!0,itemConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,gj(a,0)))break}return r.reduce((e,n,r)=>(e[t[r].itemId]=n,e),{})}function zj({axisId:e,itemId:t}){let n=()=>{let t=fj();for(let[n,{defaultLayoutDeferred:r,derivedItemConstraints:i,layout:a,axisSize:o,separatorToItems:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedItemConstraints:i,axis:n,axisSize:o,layout:a,separatorToItems:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedItemConstraints.find(e=>e.itemId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().axis.items.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:e,items:n,prevLayout:r,derivedItemConstraints:i})=>{let o=a(),s=n.findIndex(e=>e.id===t),c=s===0,l=s===n.length-1;if(l&&e<o&&(c||n.slice(0,s).every((e,t)=>{let n=i[t];return n?.collapsible&&gj(n.collapsedSize,r[n.itemId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:aj(100-e)}}return yj({delta:l?o-e:e-o,initialLayout:r,itemConstraints:i,pivotIndices:l?[s-1,s]:[s,s+1],prevLayout:r,trigger:`imperative-api`})},s=e=>{if(e===a())return;let{defaultLayoutDeferred:t,derivedItemConstraints:r,axis:i,axisSize:s,layout:c,separatorToItems:l}=n(),u=Rj({layout:o({nextSize:e,items:i.items,prevLayout:c,derivedItemConstraints:r}),itemConstraints:r});bj(c,u)||mj(i,{defaultLayoutDeferred:t,derivedItemConstraints:r,axisSize:s,layout:u,requestedAxisSize:s,requestedLayout:u,separatorToItems:l})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),o=a();e&&o!==t&&(n.expandToSize=o,s(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:o}=i(),c=a();if(e&&c===t){let e=o.expandToSize??n;e===0&&(e=1),s(e)}},getSize:()=>{let{axis:e}=n(),r=a(),{element:o}=i();return{asPercentage:r,inPixels:e.layoutStrategy?e.layoutStrategy.getItemSizeInPixels(t):e.orientation===`horizontal`?o.offsetWidth:o.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&gj(t,n)},resize:e=>{let{axis:t}=n(),{element:r}=i(),a=GA({axis:t}),o=aj(ij({axisSize:a,itemElement:r,styleProp:e})/a*100);s(o)}}}function Bj(e){e.defaultPrevented||Lj(e,fj()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.items.find(e=>e.constraintProps.defaultSize!==void 0);if(n){let r=n.constraintProps.defaultSize,i=zj({axisId:t.axis.id,itemId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Vj(e){let t=fj();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Hj({axisId:e}){let t=()=>{let t=fj();for(let[n,r]of t)if(n.id===e)return{axis:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedItemConstraints:r,axis:i,axisSize:a,layout:o,separatorToItems:s}=t(),c=Rj({layout:e,itemConstraints:r});return n?o:(bj(o,c)||mj(i,{defaultLayoutDeferred:n,derivedItemConstraints:r,axisSize:a,layout:c,requestedAxisSize:a,requestedLayout:c,separatorToItems:s}),c)}}}function Uj(e,t){let n=Vj(e),r=dj(n.id,!0),i=n.separators.find(t=>t.element===e);dA(i,`Matching separator not found`);let a=r.separatorToItems.get(i);dA(a,`Matching panels not found`);let o=a.map(e=>n.items.indexOf(e)),s=Hj({axisId:n.id}).getLayout(),c=Rj({layout:yj({delta:t,initialLayout:s,itemConstraints:r.derivedItemConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),itemConstraints:r.derivedItemConstraints});bj(s,c)||mj(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedItemConstraints:r.derivedItemConstraints,axisSize:r.axisSize,layout:c,requestedAxisSize:r.axisSize,requestedLayout:c,separatorToItems:r.separatorToItems},{isUserInteraction:!0})}function Wj(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Vj(t);if(!(n.disabled||n.separators.find(e=>e.element===t)?.disabled))switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&Uj(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&Uj(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&Uj(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&Uj(t,-5);break;case`End`:e.preventDefault(),Uj(t,100);break;case`Enter`:{e.preventDefault();let{derivedItemConstraints:r,layout:i,separatorToItems:a}=dj(n.id,!0),o=n.separators.find(e=>e.element===t);dA(o,`Matching separator not found`);let s=a.get(o);dA(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.itemId===c.id);if(dA(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];Uj(t,(l.collapsedSize===e?n.mutableState.expandedItemSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let t=n.separators.map(e=>e.element),r=Array.from(t).findIndex(t=>t===e.currentTarget);dA(r!==null,`Index not found`),t[e.shiftKey?r>0?r-1:t.length-1:r+1<t.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),Uj(t,-100);break}}function Gj(e,t){let{element:n,orientation:r,items:i}=e,a=n.getBoundingClientRect(),o=r===`horizontal`;return $A({expandHitTargets:!1,axis:e,includeDisabled:!0}).map(({items:r,rect:s,separator:c},l)=>{let u=i.indexOf(r[0]),d=o?s.left+s.width/2:s.top+s.height/2;return{active:t.some(t=>{if(t.axis!==e||t.items[0]!==r[0])return!1;if(c||t.separator)return t.separator===c;let n=o?t.rect.left+t.rect.width/2:t.rect.top+t.rect.height/2;return gj(d,n)}),axis:e,key:c?`separator-${c.id}`:`panel-${r[0].id}-${l}`,offset:0,itemIndex:u,rect:new DOMRect((o&&!c?d:s.left)-a.left-n.clientLeft+n.scrollLeft,(!o&&!c?d:s.top)-a.top-n.clientTop+n.scrollTop,o&&!c?0:s.width,!o&&!c?0:s.height),separator:c}})}function Kj(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=fj(),n=Lj(e,t);if(n.length===0)return;let r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.axis);n&&r.set(e.axis,n.layout)});let a=Array.from(r.keys()).flatMap(e=>e.resizePreviewMode===`separator`?Gj(e,n):[]);kA({cursorFlags:0,didPointerMove:!1,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},previewLayoutMap:new Map(r),previews:a,state:`active`}),e.preventDefault()}function qj(e){let t=fj(),n=EA();switch(n.state){case`active`:xj({commit:!1,document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:t,prevCursorFlags:n.cursorFlags})}}function Jj(e){if(e.defaultPrevented)return;let t=EA(),n=fj();switch(t.state){case`active`:if(e.buttons===0){t.previewLayoutMap.forEach((e,t)=>{let r=n.get(t);t.resizePreviewMode===`separator`&&r&&!bj(e,r.layout)&&mj(t,{...r,layout:e,requestedAxisSize:r.axisSize,requestedLayout:e})}),kA({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{if(!n.has(e.axis))return;let t=dj(e.axis.id,!0);mj(e.axis,t,{isUserInteraction:!0})}),WA(e.currentTarget);return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.isConnected&&!t.hasPointerCapture?.(e.pointerId)&&t.setPointerCapture?.(e.pointerId)}xj({commit:!1,document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedAxes:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=Lj(e,n);r.length===0?t.state!==`inactive`&&kA({cursorFlags:0,state:`inactive`}):kA({cursorFlags:0,hitRegions:r,state:`hover`}),WA(e.currentTarget);break}}}function Yj(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(EA().state){case`hover`:kA({cursorFlags:0,state:`inactive`})}}function Xj(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||Sj(e.currentTarget,e)&&e.preventDefault()}function Zj(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=aj(i.defaultSize);n+=e,r[i.itemId]=e}else r[i.itemId]=void 0;let i=e.length-t;if(i!==0){let t=aj((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.itemId]=t)}return r}function Qj(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}function $j({axis:e,itemConstraints:t}){let n=e.items.map(({id:e})=>e).join(`,`),r=e.mutableState.defaultLayout;return e.mutableState.layouts[n]??(r&&Qj(e.items,r)?r:Zj(t))}function eM({itemIds:e,layout:t}){return Rj({layout:t,itemConstraints:e.map(e=>({collapsedSize:0,collapsible:!1,defaultSize:void 0,disabled:void 0,itemId:e,maxSize:100,minSize:0}))})}function tM(e,t,n){if(!n[0])return;let r=e.items.find(e=>e.element===t);if(!r||!r.onResize)return;let i=GA({axis:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:aj(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function nM(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function rM(e,t){return e.length===t.length&&e.every((e,n)=>nM(e,t[n]))}function iM({axis:e,nextAxisSize:t,prevAxisSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.items){let e=r[l.id]??0;switch(l.constraintProps.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=aj(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=aj((r[e]??0)/a*l);else{let e=aj(l/c.length);for(let t of c)u[t]=e}return u}var aM=new Map;function oM(e){let t=!0;dA(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=GA({axis:e});if(t===0)return;let n=dj(e.id);if(!n)return;let r=oj(e),i=n.requestedAxisSize,a=n.requestedLayout;n.defaultLayoutDeferred&&(i=t,a=eM({itemIds:e.items.map(({id:e})=>e),layout:$j({axis:e,itemConstraints:r})}));let o=Rj({layout:iM({axis:e,nextAxisSize:t,prevAxisSize:i,prevLayout:a}),itemConstraints:r});if(!n.defaultLayoutDeferred&&bj(n.layout,o)&&rM(n.derivedItemConstraints,r)&&n.axisSize===t)continue;mj(e,{defaultLayoutDeferred:!1,derivedItemConstraints:r,axisSize:t,layout:o,requestedAxisSize:i,requestedLayout:a,separatorToItems:n.separatorToItems})}}else tM(e,i,n)}});a.observe(e.element),e.items.forEach(e=>{dA(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=GA({axis:e}),s=oj(e),c=$j({axis:e,itemConstraints:s}),l=Rj({layout:c,itemConstraints:s}),u=e.element.ownerDocument;aM.set(u,(aM.get(u)??0)+1);let d=new Map;return $A({axis:e,includeDisabled:!0}).forEach(e=>{e.separator&&d.set(e.separator,e.items)}),mj(e,{defaultLayoutDeferred:o===0,derivedItemConstraints:s,axisSize:o,layout:l,requestedAxisSize:o,requestedLayout:eM({itemIds:e.items.map(({id:e})=>e),layout:c}),separatorToItems:d}),e.separators.forEach(e=>{dA(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Wj)}),aM.get(u)===1&&(u.addEventListener(`contextmenu`,Cj,!0),u.addEventListener(`dblclick`,Bj,!0),u.addEventListener(`pointerdown`,Kj,!0),u.addEventListener(`pointerleave`,qj),u.addEventListener(`pointermove`,Jj),u.addEventListener(`pointerout`,Yj),u.addEventListener(`pointerup`,Xj,!0)),function(){t=!1,aM.set(u,Math.max(0,(aM.get(u)??0)-1)),lj(e),jA(e)&&WA(u),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Wj)}),aM.get(u)||(u.removeEventListener(`contextmenu`,Cj,!0),u.removeEventListener(`dblclick`,Bj,!0),u.removeEventListener(`pointerdown`,Kj,!0),u.removeEventListener(`pointerleave`,qj),u.removeEventListener(`pointermove`,Jj),u.removeEventListener(`pointerout`,Yj),u.removeEventListener(`pointerup`,Xj,!0)),a.disconnect()}}function sM({derivedItemConstraints:e,axis:t,layout:n,prevLayout:r,requestedLayout:i}){let a=t.items.map(({id:e})=>e).join(`,`);t.mutableState.layouts[a]=i,r&&e.forEach(e=>{if(e.collapsible){let i=gj(e.collapsedSize,n[e.itemId]),a=gj(e.collapsedSize,r[e.itemId]);i&&!a&&(t.mutableState.expandedItemSizes[e.itemId]=r[e.itemId])}})}function cM(){let[e,t]=(0,G.useState)({});return[e,(0,G.useCallback)(()=>t({}),[])]}function lM(e){let t=(0,G.useRef)({...e});return nA(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var uM=(0,G.createContext)(null);function dM({layout:e,itemConstraints:t,itemId:n,itemIndex:r}){let i,a,o=e[n],s=t.find(e=>e.itemId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=Rj({layout:yj({delta:l-o,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n],i=Rj({layout:yj({delta:c-o,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function fM({attributes:e,axisId:t,axisOrientation:n,children:r,className:i,disableCursor:a,disabled:o,disableDoubleClick:s,elementRef:c,id:l,isSharedHitRegion:u,preview:d,registerSeparator:f,requiredStyle:p,style:m,styleDefaults:h,tabIndex:g=0,updateSeparatorProps:_}){let v=lM({disabled:o,disableDoubleClick:s,children:r,className:i,preview:d,style:m}),[y,b]=(0,G.useState)({}),[x,S]=(0,G.useState)(`inactive`),[C,w]=(0,G.useState)(!1),T=(0,G.useRef)(null),E=(0,G.useRef)(null),D=iA(T,c),O=n===`horizontal`?`vertical`:`horizontal`;nA(()=>{let e=T.current;if(e!==null){let n={disabled:v.disabled,disableDoubleClick:v.disableDoubleClick,element:e,id:l,get children(){return v.children},get className(){return v.className},get preview(){return v.preview},get style(){return v.style}};E.current=n;let r=f(n),i=DA(e=>{S(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===n||(u?.(e)??!1))?e.next.state:`inactive`)}),a=pj(t,e=>{let{derivedItemConstraints:t,layout:r,separatorToItems:i}=e.next,a=i.get(n);if(a){let n=a[0],i=t.findIndex(e=>e.itemId===n.id),{layoutStrategy:o}=e.axis;b({...dM({layout:r,itemConstraints:t,itemId:n.id,itemIndex:i}),...o?.getItemAriaControls&&{valueControls:o.getItemAriaControls(n.id)}})}});return()=>{E.current=null,i(),a(),r()}}},[t,l,u,f,v]),nA(()=>{let e=E.current;e&&AA(e)},[d]),(0,G.useEffect)(()=>{_(l,{disabled:o,disableDoubleClick:s})},[o,s,l,_]);let k;o&&!a&&(k=`not-allowed`);let A;if(o)A=`disabled`;else switch(x){case`active`:A=`active`;break;default:A=C?`focus`:x}return(0,K.jsx)(`div`,{...e,"aria-controls":y.valueControls,"aria-disabled":o||void 0,"aria-orientation":O,"aria-valuemax":y.valueMax,"aria-valuemin":y.valueMin,"aria-valuenow":y.valueNow,children:r,className:i,"data-separator":A,"data-testid":l,id:l,onBlur:()=>w(!1),onFocus:()=>w(!0),ref:D,role:`separator`,style:{...h,cursor:k,...m,...p,touchAction:`none`},tabIndex:o?void 0:g})}function pM({axis:e,children:t,className:n,crossSpan:r,crossStart:i,disabled:a,elementRef:o,index:s,style:c}){let l=tA(void 0),{getDisableCursor:u,getResizeAxisId:d,gutters:f,registerSeparator:p,separatorPlacements:m,trackCounts:h,updateSeparatorProps:g}=pA(),_=d(e),v=e===`column`?`row`:`column`,y=h[v],b=!!a||!uA(s,h[e]),x=!0;for(let t of m.values())if(t.axis===e&&t.index===s&&!t.disabled&&t.crossStart<i){x=!1;break}let S=(0,G.useCallback)(e=>e.axis.id===_&&e.axis.items.indexOf(e.items[1])===s,[_,s]),C=(0,G.useCallback)(t=>p({axis:e,crossSpan:r,crossStart:i,disabled:!!a,index:s},t),[e,r,i,a,s,p]),w=cA(s),T=lA({crossCount:y,crossSpan:r,crossStart:i,hasGutters:f[v]});return(0,K.jsx)(fM,{axisId:_,axisOrientation:e===`column`?`horizontal`:`vertical`,className:n,disableCursor:u(),disabled:b,disableDoubleClick:void 0,elementRef:o,id:l,isSharedHitRegion:S,registerSeparator:C,requiredStyle:{gridColumn:e===`column`?w:T,gridRow:e===`row`?w:T},style:c,tabIndex:x?0:-1,updateSeparatorProps:g,children:t})}function mM(e){let{children:t,className:n,disabled:r,elementRef:i,style:a}=e;return e.type===`column`?(0,K.jsx)(pM,{axis:`column`,className:n,crossSpan:e.rowSpan,crossStart:e.row??0,disabled:r,elementRef:i,index:e.column,style:a,children:t}):(0,K.jsx)(pM,{axis:`row`,className:n,crossSpan:e.columnSpan,crossStart:e.column??0,disabled:r,elementRef:i,index:e.row,style:a,children:t})}mM.displayName=`Gridline`;var hM=[`column`,`row`],gM={columns:{},rows:{}};function _M({children:e,className:t,columns:n,defaultLayout:r,disableCursor:i,disabled:a,elementRef:o,gridRef:s,id:c,onLayoutChange:l,onLayoutChanged:u,resizeTargetMinimumSize:d={coarse:20,fine:10},rows:f,style:p,...m}){let h=tA(c),g=(0,G.useCallback)(e=>e===`column`?`${h}:columns`:`${h}:rows`,[h]),_=vM(n,`columns`),v=vM(f,`rows`),y=e=>e===`column`?_:v,b=(0,G.useRef)({onLayoutChange:gM,onLayoutChanged:gM}),x=rA(e=>{SM(b.current.onLayoutChange,e)||(b.current.onLayoutChange=e,l?.(e))}),S=rA((e,t,n)=>{SM(b.current.onLayoutChanged,e)||(b.current.onLayoutChanged=e,u?.(e,{isUserInteraction:t,requestedLayout:n}))}),C=(0,G.useRef)(null),w=iA(C,o),[T,E]=cM(),D=(0,G.useRef)({cells:[],column:{expandedItemSizes:{},layouts:{}},loggedErrors:new Set,row:{expandedItemSizes:{},layouts:{}},separators:new Map}),O={column:!1,row:!1};for(let e of D.current.separators.values())O[e.axis]=!0;yM(e,O);let k=lM({defaultLayout:r,disableCursor:i,resizeTargetMinimumSize:d}),A=rA(()=>!!k.disableCursor),j=(0,G.useCallback)(e=>{let t=D.current;return t.cells=[...t.cells,e],E(),()=>{t.cells=t.cells.filter(t=>t!==e),E()}},[E]),M=(0,G.useCallback)((e,t)=>{let n=D.current;return n.separators=new Map(n.separators),n.separators.set(t,e),E(),()=>{n.separators=new Map(n.separators),n.separators.delete(t),E()}},[E]),N=(0,G.useCallback)((e,{disabled:t,disableDoubleClick:n})=>{for(let r of D.current.separators.keys())r.id===e&&(r.disabled=t,r.disableDoubleClick=n)},[]),P=D.current.separators,ee=(0,G.useMemo)(()=>({getDisableCursor:A,getResizeAxisId:g,gutters:{column:O.column,row:O.row},id:h,registerCell:j,registerSeparator:M,separatorPlacements:P,trackCounts:{column:_.length,row:v.length},updateSeparatorProps:N}),[_.length,A,g,O.column,O.row,h,j,M,v.length,P,N]),te=(0,G.useRef)([]);nA(()=>{let e=C.current;if(e===null)return;let t=D.current,n=xM({cells:t.cells,separatorPlacements:t.separators,trackCounts:{column:_.length,row:v.length}});n.forEach(e=>{t.loggedErrors.has(e)||console.error(e)}),t.loggedErrors=new Set(n);let r=e=>Array.from(t.separators.entries()).filter(([,t])=>t.axis===e).sort(([,e],[,t])=>e.index-t.index).map(([e])=>e),i=hM.map(n=>{let i=n===`column`?_:v,o=n===`column`?v:_,s=i.map(e=>e.id),c=g(n),l=r(n),u=l.length>0,d=i.map(({id:t,...n},r)=>({element:e,id:s[r],idIsStable:!0,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:void 0,constraintProps:n})),f=()=>{let r=[];if(u){for(let[e,a]of t.separators)if(a.axis===n&&uA(a.index,i.length)){let t=e.element.getBoundingClientRect();r[a.index]=Math.max(r[a.index]??0,n===`column`?t.width:t.height)}}return xA({axis:n,element:e,gutterSizes:r.filter(e=>e!==void 0),hasGutters:u,layout:dj(c)?.layout,trackIds:s})},p,m=k.defaultLayout?.[n===`column`?`columns`:`rows`];if(m!==void 0&&Object.keys(m).length===s.length){p={};for(let e of s){let t=m[e];t!==void 0&&(p[e]=t)}}return{disabled:!!a,element:e,id:c,layoutStrategy:{getItemAriaControls:e=>{let r=s.indexOf(e);return t.cells.filter(e=>{let t=n===`column`?e.column:e.row,i=n===`column`?e.columnSpan:e.rowSpan;return t<=r&&r<t+i}).map(e=>e.element.id).filter(Boolean).join(` `)||void 0},calculateAvailableSize:()=>f().availableSize,calculateHitRegions:({expandHitTargets:e,axis:r,includeDisabled:i})=>yA({axis:n,cells:t.cells,crossTrackCount:o.length,expandHitTargets:e,resizeAxis:r,axisSize:f().availableSize,includeDisabled:i,separatorPlacements:t.separators}),getItemSizeInPixels:e=>f().trackSizes[s.indexOf(e)]??0},mutableState:{defaultLayout:p,disableCursor:!!k.disableCursor,expandedItemSizes:t[n].expandedItemSizes,layouts:t[n].layouts},orientation:n===`column`?`horizontal`:`vertical`,items:d,resizePreviewMode:`panel`,get resizeTargetMinimumSize(){return k.resizeTargetMinimumSize},separators:l}});te.current=i;let o=i.map(e=>oM(e)),s=()=>{let[e,t]=i.map(e=>dj(e.id));if(!(!e||!t||e.defaultLayoutDeferred||t.defaultLayoutDeferred))return{layout:{columns:e.layout,rows:t.layout},requestedLayout:{columns:e.requestedLayout,rows:t.requestedLayout}}};{let e=s();e&&(x(e.layout),S(e.layout,!1,e.requestedLayout))}let c=i.map(e=>pj(e.id,t=>{let{defaultLayoutDeferred:n,derivedItemConstraints:r,layout:a,requestedLayout:o}=t.next;if(n||r.length===0)return;sM({derivedItemConstraints:r,axis:e,layout:a,prevLayout:t.prev?.layout,requestedLayout:o});let c=s();if(c){let e=EA(),n=e.state!==`active`||!e.hitRegions.some(e=>i.includes(e.axis));x(c.layout),n&&S(c.layout,t.isUserInteraction,c.requestedLayout)}}));return()=>{te.current=[],o.forEach(e=>e()),c.forEach(e=>e())}},[_,a,g,h,S,x,v,T,k]),(0,G.useEffect)(()=>{te.current.forEach(e=>{e.mutableState.defaultLayout=r?.[e.orientation===`horizontal`?`columns`:`rows`],e.mutableState.disableCursor=!!i})}),(0,G.useImperativeHandle)(s,()=>{let e=()=>{let[e,t]=hM.map(g);return!uj(e)||!uj(t)?{columns:{},rows:{}}:{columns:Hj({axisId:e}).getLayout(),rows:Hj({axisId:t}).getLayout()}},t=e=>e.map(e=>`"${e}"`).join(`, `),n=(e,n)=>{let r=g(e),i=()=>{let i=uj(r);return dA(i,`Grid "${h}" has not been mounted`),dA(i.items.some(e=>e.id===n),`Grid "${h}" no longer contains a ${e} with id "${n}"; ${e} ids are ${t(i.items.map(e=>e.id))}`),zj({axisId:r,itemId:n})};return{collapse:()=>i().collapse(),expand:()=>i().expand(),getSize:()=>i().getSize(),isCollapsed:()=>i().isCollapsed(),resize:e=>i().resize(e)}};return{getLayout:e,getTrackById:(e,r)=>{let i=e===`column`?_:v,a=`${r}`;return dA(i.some(e=>e.id===a),`Grid "${h}" does not contain a ${e} with id "${a}"; ${e} ids are ${t(i.map(e=>e.id))}`),n(e,a)},getTrackByIndex:(e,t)=>{let r=e===`column`?_:v,i=Number.isInteger(t)?r[t]:void 0;return dA(i,`Grid "${h}" does not contain a ${e} at index ${t}; it has ${r.length} ${e}s`),n(e,i.id)},setLayout:t=>(hM.forEach(e=>{let n=t[e===`column`?`columns`:`rows`],r=g(e);n&&uj(r)&&Hj({axisId:r}).setLayout(n)}),e())}},[_,g,h,v]);let ne=()=>hM.map(e=>{let t=dj(g(e)),n=y(e);return(t&&!t.defaultLayoutDeferred?n.map(e=>`minmax(0, ${t.layout[e.id]??1}fr)`):bM(n,r?.[e===`column`?`columns`:`rows`])).join(O[e]?` auto `:` `)}).join(`|`),[re,ie]=(0,G.useSyncExternalStore)((0,G.useCallback)(e=>{let t=hM.map(t=>pj(g(t),e));return()=>t.forEach(e=>e())},[g]),ne,ne).split(`|`);return(0,K.jsx)(fA.Provider,{value:ee,children:(0,K.jsx)(`div`,{...m,className:t,"data-grid":!0,"data-testid":h,id:h,ref:w,style:{height:`100%`,width:`100%`,overflow:`hidden`,...p,display:`grid`,gridTemplateColumns:re,gridTemplateRows:ie,touchAction:`none`},children:(0,K.jsx)(uM.Provider,{value:null,children:e})})})}_M.displayName=`Grid`;function vM(e,t){let n=JSON.stringify(e);return(0,G.useMemo)(()=>{let r=typeof e==`number`?Array.from({length:e},(e,t)=>({id:`${t}`})):e.map((e,t)=>({...e,id:`${e.id??t}`}));return dA(r.length>0,`Grid must have at least one track; "${t}" is ${n}`),r},[n])}function yM(e,t){G.Children.forEach(e,e=>{if((0,G.isValidElement)(e))if(e.type===mM){let{type:n}=e.props;n===`column`?t.column=!0:n===`row`&&(t.row=!0)}else typeof e.type==`symbol`&&e.props!==null&&typeof e.props==`object`&&`children`in e.props&&yM(e.props.children,t)})}function bM(e,t){if(t)return e.map(e=>`minmax(0, ${t[e.id]??1}fr)`);let n=e.map(e=>e.defaultSize===void 0?void 0:SA(e.defaultSize)),r=100,i=0;return n.forEach(e=>{e===void 0?i++:e[1]===`%`&&(r-=e[0])}),n.map(e=>{if(e===void 0)return`minmax(0, ${Math.max(0,r)/Math.max(1,i)}fr)`;let[t,n]=e;return n===`%`?`minmax(0, ${t}fr)`:`${t}${n}`})}function xM({cells:e,separatorPlacements:t,trackCounts:n}){let r=[];for(let t of e)hM.forEach(e=>{let[i,a]=e===`column`?[t.column,t.columnSpan]:[t.row,t.rowSpan],o=n[e];(!Number.isInteger(i)||!Number.isInteger(a)||i<0||a<1||i+a>o)&&r.push(`Invalid Cell ${e} placement (${e}: ${i}, ${e}Span: ${a}); Grid has ${o} ${e}s`)});let i=({axis:e,crossSpan:t,crossStart:n,disabled:r,index:i})=>{let a=e===`column`?`row`:`column`,o=`type="${e}" ${e}={${i}}`;return(n!==0||t!==void 0)&&(o+=` ${a}={${n}}`),t!==void 0&&(o+=` ${a}Span={${t}}`),r&&(o+=` disabled`),`<Gridline ${o} />`},a=Array.from(t.values()).filter(e=>{let{axis:t,crossSpan:i,crossStart:a,index:o}=e,s=t===`column`?`row`:`column`,c=n[t],l=n[s],u=!0;return uA(o,c)||(r.push(`Invalid ${t} Gridline ${t} (${o}); must be between 1 and ${c-1}`),u=!1),!Number.isInteger(a)||a<0||a>=l?(r.push(`Invalid ${t} Gridline ${s} (${a}); must be between 0 and ${l-1}`),u=!1):i!==void 0&&(!Number.isInteger(i)||i<1||a+i>l)&&(r.push(`Invalid ${t} Gridline ${s}Span (${i}); Grid has ${l} ${s}s`),u=!1),u}),o=e=>{let t=n[e.axis===`column`?`row`:`column`];return[e.crossStart,e.crossSpan===void 0?t:e.crossStart+e.crossSpan]};return a.forEach((t,n)=>{let{axis:s,index:c}=t,[l,u]=o(t);for(let n of e){let[e,a,o,d]=s===`column`?[n.column,n.columnSpan,n.row,n.rowSpan]:[n.row,n.rowSpan,n.column,n.columnSpan];if(e<c&&c<e+a&&o<u&&l<o+d){let n=s===`column`?`row`:`column`;r.push(`${i(t)} overlaps a Cell that spans across it (${s}: ${e}, ${s}Span: ${a}, ${n}: ${o}, ${n}Span: ${d}); use the ${n} and ${n}Span props to render gridlines beside the Cell instead`)}}for(let e of a.slice(n+1))if(e.axis===s&&e.index===c){let[n,a]=o(e);n<u&&l<a&&r.push(`${i(t)} overlaps ${i(e)}`)}}),r}function SM(e,t){return bj(e.columns,t.columns)&&bj(e.rows,t.rows)}function CM(e){for(let t=1;t<e.length;t++)if(KA(e[t-1],e[t])>0)return!1;return!0}function wM({separator:e}){let{element:t}=e,n=(0,G.useRef)(null);return nA(()=>{let e=t.cloneNode(!0),r=[t,...t.querySelectorAll(`*`)],i=[e,...e.querySelectorAll(`*`)],a=t.ownerDocument.defaultView;return r.forEach((e,t)=>{let n=i[t];if(n instanceof a.HTMLElement||n instanceof a.SVGElement){let t=a.getComputedStyle(e);for(let e=0;e<t.length;e++){let r=t.item(e);n.style.setProperty(r,t.getPropertyValue(r))}}n.removeAttribute(`data-testid`),n.removeAttribute(`id`)}),Object.assign(e.style,{boxSizing:`border-box`,height:`100%`,margin:`0`,position:`static`,transform:`none`,width:`100%`}),n.current.appendChild(e),()=>e.remove()},[t]),(0,K.jsx)(`div`,{ref:n,style:{height:`100%`,opacity:.65,pointerEvents:`none`,width:`100%`}})}function TM(){let e=(0,G.useContext)(uM);return dA(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function EM(e){let{registerOverlay:t}=TM(),n=(0,G.useRef)(e);nM(n.current,e)||(n.current=e);let r=n.current;return nA(()=>t(r),[t,r]),null}EM.displayName=`SeparatorOverlay`;function DM({active:e,orientation:t,style:n,...r}){let i;switch(t){case`horizontal`:i={height:`100%`,minWidth:`1px`};break;case`vertical`:i={minHeight:`1px`,width:`100%`};break}return(0,K.jsx)(`div`,{...r,"data-separator-overlay":e?`active`:`inactive`,style:{...i,...n,flexShrink:0,pointerEvents:`none`}})}function OM({overlay:e,preview:t}){let{axis:n,offset:r,rect:i,separator:a}=t,o=n.orientation===`horizontal`,s=a?.preview,c=e;return(0,G.isValidElement)(s)&&s.type===EM&&(c=s.props,s=void 0),s??(c?s=(0,K.jsx)(DM,{...c,active:t.active,orientation:n.orientation}):a&&(s=(0,K.jsx)(wM,{separator:a}))),(0,K.jsx)(`div`,{"aria-hidden":`true`,"data-resize-preview":!0,inert:!0,style:{height:i.height,left:i.left,pointerEvents:`none`,position:`absolute`,top:i.top,transform:o?`translateX(${r}px)`:`translateY(${r}px)`,width:i.width},children:s})}function kM(e){return Array.from(e).sort(KA)}function AM(e,t){let n=(0,G.useRef)({getLayout:()=>({}),setLayout:MA});(0,G.useImperativeHandle)(t,()=>n.current,[]),nA(()=>{Object.assign(n.current,Hj({axisId:e}))})}function jM({groupId:e,resizePreviewMode:t}){let[n,r]=(0,G.useState)([]),i=(0,G.useRef)(n);return nA(()=>{let n=n=>{let a=uj(e),o=t===`separator`&&n.state===`active`?n.previews.filter(e=>e.axis===a&&(e.active||!gj(e.offset,0))):[],s=i.current;s.length===o.length&&o.every((e,t)=>e===s[t])||(i.current=o,r(o))};if(t!==`separator`){n(EA());return}let a=DA(({next:e})=>n(e));return n(EA()),a},[e,t]),n}function MM({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizePreviewMode:d=`panel`,resizeTargetMinimumSize:f={coarse:20,fine:10},style:p,...m}){let h=(0,G.useRef)({onLayoutChange:{},onLayoutChanged:{}}),g=rA(e=>{bj(h.current.onLayoutChange,e)||(h.current.onLayoutChange=e,c?.(e))}),_=rA((e,t,n)=>{bj(h.current.onLayoutChanged,e)||(h.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t,requestedLayout:n}))}),v=tA(s),[y,b]=(0,G.useState)(),x=jM({groupId:v,resizePreviewMode:d}),S=(0,G.useRef)(null),[C,w]=cM(),T=(0,G.useRef)([]),E=(0,G.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],separators:[]}),D=iA(S,a);AM(v,o);let O=rA((e,t)=>{let r=dj(e);if(r)return{flexGrow:r.layout[t]??1};if(n?.[t])return{flexGrow:n?.[t]}}),k=lM({defaultLayout:n,disableCursor:r,resizeTargetMinimumSize:f}),A=(0,G.useMemo)(()=>({get disableCursor(){return!!k.disableCursor},getPanelStyles:O,id:v,orientation:u,registerPanel:e=>{let t=E.current;return t.panels=qA(u,[...t.panels,e]),w(),()=>{t.panels=t.panels.filter(t=>t!==e),w()}},registerOverlay:e=>(b(e),()=>{b(void 0)}),registerSeparator:e=>{let t=E.current;return t.separators=qA(u,[...t.separators,e]),w(),()=>{t.separators=t.separators.filter(t=>t!==e),w()}},updatePanelProps:(e,{disabled:t})=>{let n=E.current.panels.find(t=>t.id===e);n&&(n.constraintProps.disabled=t);let r=uj(v),i=dj(v);r&&i&&mj(r,{...i,derivedItemConstraints:oj(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=E.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[O,v,w,u,k]),j=(0,G.useRef)(null);return nA(()=>{let e=S.current;if(e===null)return;let t=E.current;t.panels=qA(u,t.panels),t.separators=qA(u,t.separators),T.current=kM([...t.panels.map(({element:e})=>e),...t.separators.map(({element:e})=>e)]);let n;if(k.defaultLayout!==void 0&&Object.keys(k.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=k.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:v,mutableState:{defaultLayout:n,disableCursor:!!k.disableCursor,expandedItemSizes:E.current.lastExpandedPanelSizes,layouts:E.current.layouts},orientation:u,items:t.panels,resizePreviewMode:d,get resizeTargetMinimumSize(){return k.resizeTargetMinimumSize},separators:t.separators};j.current=r;let a=oM(r),{defaultLayoutDeferred:o,derivedItemConstraints:s,layout:c,requestedLayout:l}=dj(r.id,!0);!o&&s.length>0&&(g(c),_(c,!1,l));let f=pj(v,e=>{let{defaultLayoutDeferred:t,derivedItemConstraints:n,layout:i,requestedLayout:a}=e.next;if(t||n.length===0)return;sM({derivedItemConstraints:n,axis:r,layout:i,prevLayout:e.prev?.layout,requestedLayout:a});let o=EA(),s=o.state!==`active`||!o.hitRegions.some(e=>e.axis===r);g(i),s&&_(i,e.isUserInteraction,a)});return()=>{j.current=null,a(),f()}},[i,v,_,g,u,C,d,k]),nA(()=>{CM(T.current)||w()}),(0,G.useEffect)(()=>{let e=j.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,K.jsx)(uM.Provider,{value:A,children:(0,K.jsxs)(`div`,{...m,className:t,"data-group":!0,"data-testid":v,id:v,ref:D,style:{height:`100%`,width:`100%`,overflow:`hidden`,position:d===`separator`?`relative`:void 0,...p,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:[e,x.map(e=>(0,K.jsx)(OM,{overlay:y,preview:e},e.key))]})})}MM.displayName=`Group`;function NM(e,t){let{id:n}=TM(),r=(0,G.useRef)({collapse:NA,expand:NA,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:NA});(0,G.useImperativeHandle)(t,()=>r.current,[]),nA(()=>{Object.assign(r.current,zj({axisId:n,itemId:e}))})}function PM({children:e,className:t,collapsedSize:n=`0%`,collapsedThreshold:r,collapsible:i=!1,defaultSize:a,disabled:o,elementRef:s,groupResizeBehavior:c=`preserve-relative-size`,id:l,maxSize:u=`100%`,minSize:d=`0%`,onResize:f,panelRef:p,style:m,...h}){let g=!!l,_=tA(l),v=lM({disabled:o}),y=(0,G.useRef)(null),b=iA(y,s),{getPanelStyles:x,id:S,orientation:C,registerPanel:w,updatePanelProps:T}=TM(),E=f!==null,D=rA((e,t,n)=>{f?.(e,l,n)});nA(()=>{let e=y.current;if(e!==null){let t={element:e,id:_,idIsStable:g,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:E?D:void 0,constraintProps:{groupResizeBehavior:c,collapsedSize:n,collapsedThreshold:r,collapsible:i,defaultSize:a,disabled:v.disabled,maxSize:u,minSize:d}};return w(t)}},[c,n,r,i,a,E,_,g,u,d,D,w,v]),(0,G.useEffect)(()=>{T(_,{disabled:o})},[o,_,T]),NM(_,p);let O=()=>{let e=x(S,_);if(e)return JSON.stringify(e)},k=(0,G.useSyncExternalStore)(e=>pj(S,e),O,O),A;return A=k?JSON.parse(k):a===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:a},(0,K.jsx)(`div`,{...h,"data-disabled":o||void 0,"data-panel":!0,"data-testid":_,id:_,ref:b,style:{...FM,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...A},children:(0,K.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...m,touchAction:C===`horizontal`?`pan-y`:`pan-x`},children:e})})}PM.displayName=`Panel`;var FM={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0},IM={flexBasis:`auto`},LM={flexGrow:0,flexShrink:0};function RM({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,preview:o,style:s,...c}){let l=tA(a),{disableCursor:u,id:d,orientation:f,registerSeparator:p,updateSeparatorProps:m}=TM();return(0,K.jsx)(fM,{attributes:c,axisId:d,axisOrientation:f,className:t,disableCursor:u,disabled:n,disableDoubleClick:r,elementRef:i,id:l,preview:o,registerSeparator:p,requiredStyle:LM,style:s,styleDefaults:IM,updateSeparatorProps:m,children:e})}RM.displayName=`Separator`;function zM({className:e,...t}){return(0,K.jsx)(MM,{"data-slot":`resizable-panel-group`,className:B(`flex h-full w-full`,e),...t})}function BM(e){return(0,K.jsx)(PM,{"data-slot":`resizable-panel`,...e})}function VM({className:e,...t}){return(0,K.jsx)(RM,{"data-slot":`resizable-handle`,className:B(`group/handle relative shrink-0 bg-border outline-none`,`aria-[orientation=vertical]:w-px aria-[orientation=horizontal]:h-px`,e),...t,children:(0,K.jsx)(`div`,{className:B(`pointer-events-none absolute z-10 bg-transparent transition-colors`,`group-aria-[orientation=vertical]/handle:inset-y-0 group-aria-[orientation=vertical]/handle:-left-px group-aria-[orientation=vertical]/handle:w-[3px]`,`group-aria-[orientation=horizontal]/handle:inset-x-0 group-aria-[orientation=horizontal]/handle:-top-px group-aria-[orientation=horizontal]/handle:h-[3px]`,`group-data-[separator=hover]/handle:bg-primary group-data-[separator=focus]/handle:bg-primary group-data-[separator=active]/handle:bg-primary`)})})}var HM=`oa.panes`,UM=200,WM=new Set,GM=[];function KM(e,t){return t?`${e}/${t}`:`new`}var qM=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function JM(e){if(!qM(e))return{};let t={};for(let[n,r]of Object.entries(e))qM(r)&&Object.values(r).every(e=>typeof e==`number`)&&(t[n]=r);return t}function YM(e){let t;try{t=JSON.parse(e??`null`)}catch{t=null}let n={};if(qM(t)&&qM(t.pages))for(let[e,r]of Object.entries(t.pages))qM(r)&&(n[e]={open:Array.isArray(r.open)?r.open.filter(e=>typeof e==`string`):[],sizes:JM(r.sizes)});return{pages:n,last:qM(t)?JM(t.last):{}}}var XM,ZM;function QM(){let e=ZM??null;if(ZM===void 0)try{e=globalThis.localStorage?.getItem(HM)??null}catch{e=null}return XM?.raw!==e&&(XM={raw:e,kept:YM(e)}),XM.kept}function $M(e,t,n){let r=QM(),{[e]:i,...a}=r.pages,o=t(i??{open:[],sizes:{}}),s=o.open.length>0||Object.keys(o.sizes).length>0?{...a,[e]:o}:a,c=Object.keys(s);for(let e of c.slice(0,Math.max(0,c.length-UM)))delete s[e];let l=JSON.stringify({pages:s,last:n??r.last});try{globalThis.localStorage?.setItem(HM,l),ZM=void 0}catch{ZM=l}for(let e of WM)e()}function eN(e){return WM.add(e),()=>WM.delete(e)}function tN(e,t,n){!n&&cN.get(e)===t&&cN.delete(e),$M(e,e=>e.open.includes(t)===n?e:{...e,open:n?[...e.open,t]:e.open.filter(e=>e!==t)})}function nN(e){cN.delete(e),$M(e,e=>({...e,open:[]}))}function rN(e){return(0,G.useSyncExternalStore)(eN,()=>QM().pages[e]?.open??GM,()=>GM)}function iN(e,t){let n=QM();return n.pages[e]?.sizes[t]??n.last[t]}var aN=0;function oN(e,t){return QM().pages[e]?.sizes[t]?e:`~${aN}`}function sN(e,t,n){aN++,$M(e,e=>({...e,sizes:{...e.sizes,[t]:n}}),{...QM().last,[t]:n})}var cN=new Map;function lN(e,t){t===void 0?cN.delete(e):cN.set(e,t);for(let e of WM)e()}function uN(e){return(0,G.useSyncExternalStore)(eN,()=>cN.get(e),()=>void 0)}var dN=new Map,fN=new Map,pN=new Map,mN=new Set,hN=0;function gN(e){return mN.add(e),()=>mN.delete(e)}function _N(e,t){dN.set(e,t===void 0?{at:++hN}:{path:t,at:++hN});for(let e of mN)e()}function vN(e){return(0,G.useSyncExternalStore)(gN,()=>dN.get(e),()=>void 0)}function yN(e){fN.set(e,++hN);for(let e of mN)e()}function bN(e){return(0,G.useSyncExternalStore)(gN,()=>fN.get(e),()=>void 0)}function xN(e,t){pN.set(e,{key:t,at:++hN});for(let e of mN)e()}function SN(e){return(0,G.useSyncExternalStore)(gN,()=>pN.get(e),()=>void 0)}var CN=e=>`${e.package}/${e.id}`,wN=`docs`,TN=`subagent`,EN=`workspace`,DN=`chat`,ON=`panes`,kN=50,AN=(0,G.createContext)({page:``,enabled:!1,panes:[],open:[],expanded:void 0,panelProps:void 0,reveal:void 0,docs:[],docsLoaded:!1,subagent:null}),jN=0;function MN({projectId:e,agentId:t,enabled:n,files:r,context:i,toggleContext:a,activity:o,subagent:s,children:c}){let l=n?e:null,{value:u,loaded:d}=g(l?()=>wr(l):null,[],4e3,[l],l?{remember:`docs:${l}`}:void 0),{panels:f}=sn(),p=KM(l??``,t),m=SN(p),h=s!==void 0&&m!==void 0,_=(0,G.useMemo)(()=>{if(!l)return[];let e=f.filter(e=>e.projects.includes(l)).map(e=>({id:CN(e),label:e.label,icon:e.icon,panel:e})),t=[...u.length>0?[{id:wN,label:`Docs`,icon:ua}]:[],...h?[{id:TN,label:`Subagent`,icon:Yi,hidden:!0}]:[]];return[...e,...t]},[f,l,u.length,h]),v=rN(p),y=(0,G.useMemo)(()=>v.flatMap(e=>_.find(t=>t.id===e)??[]),[v,_]),b=uN(p);(0,G.useEffect)(()=>()=>{F()&&nN(p)},[p]);let x=vN(p),S=_.find(e=>e.panel?.changes)?.id,C=x?.at;(0,G.useEffect)(()=>{C===void 0||S===void 0||C<=jN||(jN=C,tN(p,S,!0))},[C,S,p]);let w=bN(p),T=_.find(e=>e.panel?.screen)?.id;(0,G.useEffect)(()=>{w===void 0||T===void 0||w<=jN||(jN=w,tN(p,T,!0))},[w,T,p]);let E=m?.at;(0,G.useEffect)(()=>{E===void 0||!h||E<=jN||(jN=E,tN(p,TN,!0))},[E,h,p]);let D=(0,G.useMemo)(()=>new Set(r.filter(e=>i.has(e))),[r,i]),O=(0,G.useMemo)(()=>({files:D,toggle:a}),[D,a]),k=(0,G.useMemo)(()=>l?{projectId:l,...t?{agentId:t,...o===void 0?{}:{activity:o}}:{},context:O}:void 0,[l,t,o,O]),A=(0,G.useMemo)(()=>({page:p,enabled:l!==null,panes:_,open:y,expanded:y.some(e=>e.id===b)?b:void 0,panelProps:k,reveal:x,docs:u,docsLoaded:d,subagent:s??null}),[p,l,_,y,b,k,x,u,d,s]);return(0,K.jsx)(AN.Provider,{value:A,children:c})}function NN(){let{open:e}=(0,G.useContext)(AN);return Se()&&e.length>0}function PN(){let{page:e,panes:t,open:n}=(0,G.useContext)(AN),r=t.filter(e=>!e.hidden);return NN()||r.length===0?null:(0,K.jsx)(`div`,{role:`group`,"aria-label":`Panes`,className:`flex shrink-0 items-center gap-0.5`,children:r.map(t=>{let r=n.includes(t);return(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(V,{variant:`ghost`,size:`icon-sm`,className:B(`shrink-0 text-muted-foreground`,r&&`bg-accent text-accent-foreground`),"aria-label":t.label,"aria-pressed":r,onClick:()=>tN(e,t.id,!r)}),children:(0,K.jsx)(t.icon,{className:`h-4 w-4`})}),(0,K.jsx)(z,{children:t.label})]},t.id)})})}function FN(){let{page:e,panes:t,open:n}=(0,G.useContext)(AN);return NN()?(0,K.jsxs)(re,{children:[(0,K.jsx)(bt,{"aria-label":`Panes`,className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,K.jsx)(sa,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsx)(Be,{align:`start`,className:`min-w-[12rem]`,children:t.filter(e=>!e.hidden||n.includes(e)).map(t=>(0,K.jsxs)(He,{closeOnClick:!0,checked:n.includes(t),onCheckedChange:n=>tN(e,t.id,n),children:[(0,K.jsx)(t.icon,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),` `,t.label]},t.id))})]}):null}function IN({pane:e}){let{page:t,expanded:n,panelProps:r,reveal:i,docs:a,docsLoaded:o,subagent:s}=(0,G.useContext)(AN),c=n===e.id,[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(null),p=(0,G.useMemo)(()=>({title:l,actions:d}),[l,d]);return(0,K.jsx)(`div`,{className:c?`absolute inset-0 z-30 flex bg-background`:`flex h-full min-h-0 min-w-0`,children:(0,K.jsxs)(`section`,{"aria-label":e.label,className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background`,children:[(0,K.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-0.5 border-b border-border pr-2 pl-2`,children:[(0,K.jsx)(`div`,{ref:u,className:`peer flex min-w-0 flex-1 items-center gap-0.5 empty:hidden`}),(0,K.jsx)(`h2`,{className:`min-w-0 flex-1 truncate pl-2 text-[13px] text-muted-foreground peer-[:not(:empty)]:hidden`,children:e.label}),(0,K.jsx)(`div`,{ref:f,className:`flex shrink-0 items-center gap-0.5 empty:hidden`}),(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(V,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground`,"aria-label":c?`Bring ${e.label} back to its place`:`Let ${e.label} fill the page`,"aria-pressed":c,onClick:()=>lN(t,c?void 0:e.id)}),children:c?(0,K.jsx)(Aa,{className:`h-3.5 w-3.5`}):(0,K.jsx)(Oa,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(z,{children:c?`Back to its place`:`Fill the page`})]}),(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(V,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground`,"aria-label":`Close ${e.label}`,onClick:()=>tN(t,e.id,!1)}),children:(0,K.jsx)(ee,{className:`h-4 w-4`})}),(0,K.jsx)(z,{children:`Close`})]})]}),(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:e.id===TN?(0,K.jsx)(Ct.Provider,{value:p,children:s}):e.panel&&r?(0,K.jsx)(Qk,{package:e.panel.package,label:`${e.label} pane`,children:(0,K.jsx)(Ct.Provider,{value:p,children:(0,K.jsx)(e.panel.Panel,{...e.panel.changes&&i?{...r,reveal:i}:r})})}):(0,K.jsx)(Xk,{docs:a,loaded:o})})]})})}var LN=e=>e.map(e=>e.id).join(`+`);function RN(){let{page:e,open:t,expanded:n}=(0,G.useContext)(AN),r=LN(t),i=iN(e,r),a=oN(e,r),o=e=>`${e.id}@${a}`;return(0,K.jsx)(zM,{orientation:`vertical`,disabled:n!==void 0,onLayoutChanged:(n,{isUserInteraction:i})=>{let a=t.map(e=>[e.id,n[o(e)]]);i&&a.every(([,e])=>e!==void 0)&&sN(e,r,Object.fromEntries(a))},children:t.flatMap((e,n)=>[...n>0?[(0,K.jsx)(VM,{"aria-label":`The height of ${t[n-1].label} and ${e.label}`},`above-${e.id}`)]:[],(0,K.jsx)(BM,{id:o(e),defaultSize:`${i?.[e.id]??100/t.length}%`,minSize:96,style:{overflow:`hidden`},children:(0,K.jsx)(IN,{pane:e})},e.id)])})}function zN({children:e}){let{page:t,enabled:n,open:r,expanded:i}=(0,G.useContext)(AN),a=Se(),o=r.length>0&&!a;if(!n)return e;let s=iN(t,EN)?.[ON]??kN,c=`${ON}@${oN(t,EN)}`;return(0,K.jsxs)(`div`,{className:`relative flex min-w-0 flex-1`,children:[(0,K.jsxs)(zM,{orientation:`horizontal`,disabled:i!==void 0,onLayoutChanged:(e,{isUserInteraction:n})=>{let[r,i]=[e[DN],e[c]];n&&r!==void 0&&i!==void 0&&sN(t,EN,{[DN]:r,[ON]:i})},children:[(0,K.jsx)(BM,{id:DN,minSize:320,className:`flex min-w-0 flex-col`,style:{overflow:`hidden`},children:e}),o&&(0,K.jsx)(VM,{"aria-label":`The width of the chat and the panes`}),o&&(0,K.jsx)(BM,{id:c,defaultSize:`${s}%`,minSize:288,style:{overflow:`hidden`},children:(0,K.jsx)(RN,{})})]}),a&&r.length>0&&(0,K.jsx)(`div`,{className:B(`absolute inset-y-0 right-0 z-20 flex flex-col divide-y divide-border border-l border-border bg-background`,i?`left-0`:`w-2/3 min-w-64 max-w-full`),children:r.map(e=>(0,K.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,K.jsx)(IN,{pane:e})},e.id))})]})}var BN=[];function VN({projectId:e,onProjectRemoved:t}){return(0,K.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 overflow-hidden pr-2 md:pl-4 max-md:pl-11`,children:[(0,K.jsx)(v,{}),(0,K.jsx)(FN,{}),(0,K.jsx)(`div`,{className:`grow shrink-0`}),(0,K.jsx)(Yk,{projectId:e,events:BN,onProjectRemoved:t}),(0,K.jsx)(PN,{})]})}var HN=W(`onProjectSkills`),UN=W(`sendChangeSkills`),WN=W(`sendProjectSkills`),GN=e=>e.standing!==`absent`,KN=e=>e.groups.flatMap(e=>e.skills),qN=(e,t,n)=>`${e} ${e===1?t:n}`;function JN({names:e}){return e.length>3?(0,K.jsxs)(`span`,{className:`text-foreground`,children:[e.length,` skills`]}):(0,K.jsxs)(K.Fragment,{children:[`The`,` `,e.map((t,n)=>(0,K.jsxs)(`span`,{children:[n>0&&(n===e.length-1?` and `:`, `),(0,K.jsx)(`span`,{className:`text-foreground`,children:t})]},t)),` `,e.length===1?`skill`:`skills`]})}var YN=e=>e.length===1?`is`:`are`,XN=e=>e.length===1?`it`:`them`,ZN={newer:`a newer version is there`,changed:`changed by hand`,own:`your own text`},QN=e=>e.remote?`Send to ${e.remote}`:`Commit`;function $N({projectId:e,onChanged:t,door:n}){let{value:r,reload:i,loaded:a}=g(()=>HN(e).catch(()=>null),null,15e3,[e],`previous`),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),{error:u,run:d}=en(),f=n?.open??!1;if((0,G.useEffect)(()=>{f&&r&&s(e=>e??r)},[f,r]),!r)return f&&a?(0,K.jsx)(`p`,{role:`alert`,className:`m-3 rounded-lg border border-border px-3 py-2 text-sm text-danger`,children:`This project’s skills could not be read.`}):null;let p=async()=>{await i(),t?.()},m=async(e,t)=>{l(e);try{(await t()).ok&&await p()}finally{l(null)}},{newer:h,waiting:_,here:v,sending:y,inRequest:b,onBranch:x}=eP(r),S=()=>m(`update`,()=>tP(e,r,d)),C=()=>m(`send`,()=>d(()=>WN(e),`Could not send the skills.`)),w=o&&(0,K.jsx)(rP,{projectId:e,skills:o,onClose:()=>{s(null),n?.onClose()},onSaved:()=>void p()});return h.length===0&&!y&&!b&&!x&&!u?w||null:(0,K.jsxs)(`div`,{role:`status`,"aria-label":`This project's skills`,className:`m-3 flex flex-col gap-1.5 rounded-lg border border-border px-3 py-2 text-sm text-muted-foreground`,children:[h.length>0&&(0,K.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(JN,{names:h}),` `,h.length===1?`has a newer version`:`have newer versions`,`.`]}),(0,K.jsx)(V,{type:`button`,variant:`outline`,size:`xs`,className:`shrink-0`,disabled:c!==null,onClick:()=>void S(),children:c===`update`?`Updating…`:`Update`})]}),y&&(0,K.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(JN,{names:v}),` `,YN(v),` `,r.remote?`on this computer only`:`not committed`,`, so your agents do not have `,XN(v),` yet.`,r.local&&r.remote&&` Or pick My local branch when you start an agent.`]}),(0,K.jsx)(V,{type:`button`,variant:`outline`,size:`xs`,className:`shrink-0`,disabled:c!==null,onClick:()=>void C(),children:c===`send`?`Sending…`:QN(r)})]}),b&&(0,K.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(JN,{names:_}),` `,YN(_),` in pull request #`,r.request.number,`. Your agents get `,XN(_),` once it is merged.`]}),(0,K.jsxs)(`a`,{href:r.request.url,target:`_blank`,rel:`noreferrer`,className:_t({variant:`outline`,size:`xs`,className:`shrink-0`}),children:[`Open #`,r.request.number]})]}),x&&(0,K.jsxs)(`span`,{children:[(0,K.jsx)(JN,{names:_}),` `,YN(_),` on the branch `,r.branch,` on `,r.remote,`. Merge it into `,r.startBranch??`the default branch`,`, and your agents get `,XN(_),`.`]}),u&&(0,K.jsx)(`span`,{className:`text-danger`,children:u}),w]})}function eP(e){let t=KN(e).filter(e=>e.standing===`newer`).map(e=>e.name),n=KN(e).filter(e=>e.waiting).map(e=>e.name),r=e.request||e.branch?e.uncommitted:[...new Set([...e.uncommitted,...n])],i=e.git&&r.length>0,a=e.request!==void 0&&n.length>0,o=!a&&e.branch!==void 0&&n.length>0,s=KN(e).filter(GN).map(e=>e.name);return{newer:t,waiting:n,here:r,sending:i,inRequest:a,onBranch:o,held:s.length,heldNames:s}}async function tP(e,t,n){let{newer:r}=eP(t),i=await n(()=>UN(e,{write:r}),`Could not update the skills.`);return!i.ok||!t.git?i:n(()=>WN(e,r),`Could not send the skills.`)}function nP(e){let t=KN(e).filter(GN);return t.length>0?new Set(t.map(e=>e.name)):new Set(e.groups.filter(e=>e.ticked).flatMap(e=>e.skills.map(e=>e.name)))}function rP({projectId:e,skills:t,onClose:n,onSaved:r}){let[i,a]=(0,G.useState)(()=>nP(t)),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),{busy:u,error:d,run:f}=en(),p=(e,t)=>a(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),m=KN(t).filter(e=>i.has(e.name)&&!GN(e)).map(e=>e.name),h=KN(t).filter(e=>!i.has(e.name)&&GN(e)).map(e=>e.name),g=m.length===0&&h.length===0,_=async t=>{l(null);let n=await f(()=>WN(e,t),`Could not send the skills.`);n.ok&&l(n.value),r()},v=async()=>{let n=await f(()=>UN(e,{write:m,remove:h}),`Could not change the skills.`);if(!n.ok)return;s(n.value),r();let i=[...n.value.written,...n.value.removed];i.length>0&&t.git&&await _(i)},y=g||!t.git?`Save`:t.remote?`Save and send to ${t.remote}`:`Save and commit`,b=t.startBranch??`the default branch`;return(0,K.jsx)(mt,{open:!0,onOpenChange:e=>{!e&&!u&&n()},title:`Skills`,children:o?(0,K.jsxs)(`div`,{className:`space-y-2 text-xs leading-relaxed text-muted-foreground`,children:[o.written.length>0&&(0,K.jsxs)(`p`,{children:[`Wrote `,qN(o.written.length,`skill`,`skills`),` in `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`.agents/skills`}),`, linked in`,` `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`.claude/skills`}),`: `,(0,K.jsx)(`span`,{className:`text-foreground`,children:o.written.join(`, `)}),`.`]}),o.removed.length>0&&(0,K.jsxs)(`p`,{children:[`Deleted `,qN(o.removed.length,`skill`,`skills`),`: `,(0,K.jsx)(`span`,{className:`text-foreground`,children:o.removed.join(`, `)}),`.`]}),o.scheduler===`on`&&(0,K.jsx)(`p`,{children:`The scheduler is on for this project, on this machine. Every automation starts switched off.`}),o.scheduler===`off`&&(0,K.jsx)(`p`,{children:`The scheduler is off for this project on this machine, and stopped.`}),o.left.map(({path:e,reason:t})=>(0,K.jsxs)(`p`,{children:[`Left as it is: `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1`,children:e}),` (`,t,`).`]},e)),o.schedulerError&&(0,K.jsxs)(`p`,{className:`text-danger`,children:[`The scheduler was not switched: `,o.schedulerError]}),o.written.length+o.removed.length>0&&!t.git&&(0,K.jsx)(`p`,{children:`This folder is not a git repository, so there is nothing to commit.`}),c?.ok&&c.sent===`committed`&&(0,K.jsx)(`p`,{children:`Committed. Your agents get this change from their next start.`}),c?.ok&&c.sent===`pushed`&&(0,K.jsxs)(`p`,{children:[`Sent to `,t.remote,`, on `,c.branch,`. Your agents get this change from their next start.`]}),c?.ok&&c.sent===`request`&&(0,K.jsxs)(`p`,{children:[t.remote,` took no push to `,b,`, so the change is in`,` `,(0,K.jsxs)(`a`,{href:c.request.url,target:`_blank`,rel:`noreferrer`,className:`text-foreground underline underline-offset-2`,children:[`pull request #`,c.request.number]}),`. Your agents get it once it is merged.`]}),c?.ok&&c.sent===`branch`&&(0,K.jsxs)(`p`,{children:[b,` took no push, so the change is on the branch `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1`,children:c.branch}),`. Merge it into `,b,`, and your agents get it.`]}),d&&(0,K.jsx)(`p`,{className:`text-danger`,children:o.written.length+o.removed.length>0?`Saved in the project's folder, not sent: ${d}`:d}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[d&&o.written.length+o.removed.length>0&&t.git&&(0,K.jsx)(V,{type:`button`,size:`sm`,disabled:u,onClick:()=>void _([...o.written,...o.removed]),children:u?`Sending…`:`Send again`}),(0,K.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,disabled:u,onClick:n,children:`Done`})]})]}):(0,K.jsxs)(`div`,{className:`text-xs`,children:[(0,K.jsxs)(`p`,{className:`mb-2 leading-relaxed text-muted-foreground`,children:[`A ticked skill is written into the project’s folder and an unticked one is deleted`,t.remote?`; Save sends the change to ${t.remote}, where your agents start from`:t.git?`; Save commits the change`:``,`. The skills every agent gets by default come with every run and are not here.`]}),(0,K.jsx)(`div`,{className:`max-h-[55vh] space-y-3 overflow-y-auto pr-1`,children:t.groups.map(e=>(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{className:`mb-1 font-medium text-foreground`,children:e.title}),e.skills.map(e=>(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 py-0.5`,children:[(0,K.jsx)(Nt,{checked:i.has(e.name),onCheckedChange:t=>p(e.name,t===!0),disabled:u,className:`mt-0.5`,"aria-label":e.name}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:e.name}),ZN[e.standing]&&(0,K.jsxs)(`span`,{className:`text-warning`,children:[` (`,ZN[e.standing],`)`]}),e.waiting&&t.startBranch!==void 0&&(0,K.jsxs)(`span`,{className:`text-warning`,children:[` (waiting to reach `,t.startBranch,`)`]}),(0,K.jsx)(`span`,{className:`block text-muted-foreground`,children:e.description})]})]},e.name))]},e.title))}),d&&(0,K.jsx)(`p`,{className:`mt-2 text-danger`,children:d}),(0,K.jsxs)(`div`,{className:`mt-3 flex items-center justify-end gap-2`,children:[(0,K.jsx)(`span`,{className:`mr-auto text-muted-foreground`,children:g?`Nothing to change.`:[m.length>0?`${qN(m.length,`skill`,`skills`)} to write`:``,h.length>0?`${qN(h.length,`skill`,`skills`)} to delete`:``].filter(Boolean).join(`, `)+`.`}),(0,K.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,disabled:u,onClick:n,children:`Cancel`}),(0,K.jsx)(V,{type:`button`,size:`sm`,disabled:u||g,onClick:()=>void v(),children:u?`Saving…`:y})]})]})})}function iP({events:e,headline:t=!1}){let n=aP(e);if(n.length===0)return null;let r=n[n.length-1];return(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsxs)(`span`,{role:`alert`,className:`flex shrink-0 items-center gap-1.5 text-danger`,children:[(0,K.jsx)(Wa,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsxs)(`span`,{className:`font-medium`,children:[n.length,` `,n.length===1?`error`:`errors`]}),t&&(0,K.jsxs)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:[`· `,r.headline]})]})}),(0,K.jsx)(z,{className:`whitespace-pre-line`,children:n.map(e=>e.headline).join(`
129
+ `?t.slice(0,-1):t};return e.renderer.rules.hardbreak=t(e.renderer.rules.hardbreak),e.renderer.rules.softbreak=t(e.renderer.rules.softbreak),e.renderer.rules.fence=t(e.renderer.rules.fence),e.renderer.rules.code_block=t(e.renderer.rules.code_block),e.renderer.renderToken=t(e.renderer.renderToken.bind(e.renderer)),e}},bO=sy.create({name:`markdownClipboard`,addOptions(){return{transformPastedText:!1,transformCopiedText:!1}},addProseMirrorPlugins(){return[new Jf({key:new Zf(`markdownClipboard`),props:{clipboardTextParser:(e,t,n)=>{if(n||!this.options.transformPastedText)return null;let r=this.editor.storage.markdown.parser.parse(e,{inline:!0});return qu.fromSchema(this.editor.schema).parseSlice(qD(r),{preserveWhitespace:!0,context:t})},clipboardTextSerializer:e=>this.options.transformCopiedText?this.editor.storage.markdown.serializer.serialize(e.content):null}})]}}),xO=sy.create({name:`markdown`,priority:50,addOptions(){return{html:!0,tightLists:!0,tightListClass:`tight`,bulletListMarker:`-`,linkify:!1,breaks:!1,transformPastedText:!1,transformCopiedText:!1}},addCommands(){let e=ex.Commands.config.addCommands();return{setContent:(t,n,r)=>i=>e.setContent(i.editor.storage.markdown.parser.parse(t),n,r)(i),insertContentAt:(t,n,r)=>i=>e.insertContentAt(t,i.editor.storage.markdown.parser.parse(n,{inline:!0}),r)(i)}},onBeforeCreate(){this.editor.storage.markdown={options:{...this.options},parser:new yO(this.editor,this.options),serializer:new vO(this.editor),getMarkdown:()=>this.editor.storage.markdown.serializer.serialize(this.editor.state.doc)},this.editor.options.initialContent=this.editor.options.content,this.editor.options.content=this.editor.storage.markdown.parser.parse(this.editor.options.content)},onCreate(){this.editor.options.content=this.editor.options.initialContent,delete this.editor.options.initialContent},addStorage(){return{}},addExtensions(){return[LD.configure({tight:this.options.tightLists,tightClass:this.options.tightListClass}),bO.configure({transformPastedText:this.options.transformPastedText,transformCopiedText:this.options.transformCopiedText})]}}),SO=lx.create({name:`token`,group:`inline`,inline:!0,atom:!0,selectable:!0,addAttributes(){return{kind:{default:`file`},label:{default:``},text:{default:``}}},parseHTML(){return[{tag:`span[data-token]`}]},renderHTML({node:e,HTMLAttributes:t}){return[`span`,jv(t,{"data-token":e.attrs.kind,class:`pe-token`}),e.attrs.label||e.attrs.text]},renderText({node:e}){return e.attrs.text},addStorage(){return{markdown:{serialize(e,t){e.write(t.attrs.text)},parse:{}}}}});function CO(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=fx(t),l=RegExp(`\\s${c}$`),u=a?`^`:``,d=r?``:c,f=RegExp(s?`${u}${c}.*?(?=\\s${d}|$)`:`${u}(?:^)?${c}[^\\s${d}]*`,`gm`),p=o.nodeBefore?.isText&&o.nodeBefore.text;if(!p)return null;let m=o.pos-p.length,h=Array.from(p.matchAll(f)).pop();if(!h||h.input===void 0||h.index===void 0)return null;let g=h.input.slice(Math.max(0,h.index-1),h.index),_=RegExp(`^[${i?.join(``)}\0]?$`).test(g);if(i!==null&&!_)return null;let v=m+h.index,y=v+h[0].length;return s&&l.test(p.slice(y-1,y+1))&&(h[0]+=` `,y+=1),v<o.pos&&y>=o.pos?{range:{from:v,to:y},query:h[0].slice(t.length),text:h[0]}:null}var wO=new Zf(`suggestion`);function TO({pluginKey:e=wO,editor:t,char:n=`@`,allowSpaces:r=!1,allowToIncludeChar:i=!1,allowedPrefixes:a=[` `],startOfLine:o=!1,decorationTag:s=`span`,decorationClass:c=`suggestion`,decorationContent:l=``,decorationEmptyClass:u=`is-empty`,command:d=()=>null,items:f=()=>[],render:p=()=>({}),allow:m=()=>!0,findSuggestionMatch:h=CO}){let g,_=p?.(),v=new Jf({key:e,view(){return{update:async(e,n)=>{var r,i,a,o,s;let c=this.key?.getState(n),l=this.key?.getState(e.state),u=c.active&&l.active&&c.range.from!==l.range.from,p=!c.active&&l.active,m=c.active&&!l.active,h=!p&&!m&&c.query!==l.query,v=p||u&&h,y=h||u,b=m||u&&h;if(!v&&!y&&!b)return;let x=b&&!v?c:l,S=e.dom.querySelector(`[data-decoration-id="${x.decorationId}"]`);g={editor:t,range:x.range,query:x.query,text:x.text,items:[],command:e=>d({editor:t,range:x.range,props:e}),decorationNode:S,clientRect:S?()=>{let{decorationId:n}=this.key?.getState(t.state);return e.dom.querySelector(`[data-decoration-id="${n}"]`)?.getBoundingClientRect()||null}:null},v&&((r=_?.onBeforeStart)==null||r.call(_,g)),y&&((i=_?.onBeforeUpdate)==null||i.call(_,g)),(y||v)&&(g.items=await f({editor:t,query:x.query})),b&&((a=_?.onExit)==null||a.call(_,g)),y&&((o=_?.onUpdate)==null||o.call(_,g)),v&&((s=_?.onStart)==null||s.call(_,g))},destroy:()=>{var e;g&&((e=_?.onExit)==null||e.call(_,g))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(e,s,c,l){let{isEditable:u}=t,{composing:d}=t.view,{selection:f}=e,{empty:p,from:g}=f,_={...s};if(_.composing=d,u&&(p||t.view.composing)){(g<s.range.from||g>s.range.to)&&!d&&!s.composing&&(_.active=!1);let e=h({char:n,allowSpaces:r,allowToIncludeChar:i,allowedPrefixes:a,startOfLine:o,$position:f.$from}),c=`id_${Math.floor(Math.random()*4294967295)}`;e&&m({editor:t,state:l,range:e.range,isActive:s.active})?(_.active=!0,_.decorationId=s.decorationId?s.decorationId:c,_.range=e.range,_.query=e.query,_.text=e.text):_.active=!1}else _.active=!1;return _.active||(_.decorationId=null,_.range={from:0,to:0},_.query=null,_.text=null),_}},props:{handleKeyDown(e,t){let{active:n,range:r}=v.getState(e.state);return n&&(_?.onKeyDown)?.call(_,{view:e,event:t,range:r})||!1},decorations(e){let{active:t,range:n,decorationId:r,query:i}=v.getState(e);if(!t)return null;let a=!i?.length,o=[c];return a&&o.push(u),Pg.create(e.doc,[jg.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return v}function EO(e){return`prompt-suggestion-option-${e}`}var DO=(0,G.forwardRef)(function({items:e,command:t,emptyNote:n,onActiveChange:r},i){let[a,o]=(0,G.useState)(0);return(0,G.useEffect)(()=>o(0),[e]),(0,G.useEffect)(()=>{r?.(e.length>0?EO(a):null)},[e,a,r]),(0,G.useImperativeHandle)(i,()=>({onKeyDown:n=>{if(e.length===0)return!1;if(n.key===`ArrowDown`)return o(t=>(t+1)%e.length),!0;if(n.key===`ArrowUp`)return o(t=>(t-1+e.length)%e.length),!0;if(n.key===`Enter`||n.key===`Tab`){let n=e[a];return n&&t(n),!0}return!1}})),e.length===0?(0,K.jsx)(`div`,{role:`status`,className:`w-64 rounded-md border border-border bg-card p-2 text-sm text-muted-foreground shadow-md`,children:n??`No matches`}):(0,K.jsx)(`div`,{role:`listbox`,"aria-label":`Suggestions`,className:`max-h-72 w-64 overflow-y-auto rounded-md border border-border bg-card p-1 text-sm shadow-md`,children:e.map((n,r)=>(0,K.jsxs)(`div`,{children:[n.group&&(r===0||e[r-1]?.group!==n.group)&&(0,K.jsx)(`div`,{className:`px-2 pb-1 pt-2 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground/70`,children:n.group}),(0,K.jsxs)(`button`,{type:`button`,id:EO(r),role:`option`,"aria-selected":r===a,...n.title?{title:n.title}:{},onMouseDown:e=>{e.preventDefault(),t(n)},onMouseEnter:()=>o(r),className:B(`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left`,r===a?`bg-accent text-accent-foreground`:`hover:bg-accent/60`),children:[(0,K.jsx)(`span`,{className:`truncate font-medium`,children:n.label}),n.hint&&(0,K.jsx)(`span`,{className:`ml-auto truncate text-xs text-muted-foreground`,children:n.hint})]})]},n.id))})});function OO(e,t){if(!t)return;let n=window.innerHeight-t.bottom;e.style.left=`${t.left}px`,n<320?(e.style.top=``,e.style.bottom=`${window.innerHeight-t.top+4}px`):(e.style.bottom=``,e.style.top=`${t.bottom+4}px`)}function kO(e){let t=null,n=null,r=null,i=null,a=null,o=!1,s=e=>{a&&(e?a.setAttribute(`aria-activedescendant`,e):a.removeAttribute(`aria-activedescendant`))},c=i=>{let{items:c,command:l}=i,u=c.length===0&&!i.query?e.emptyNote:void 0,d=!o&&(c.length>0||!!u);t&&(t.style.display=d?``:`none`),a?.setAttribute(`aria-expanded`,d?`true`:`false`),d||s(null),n?.render((0,G.createElement)(DO,{items:c,command:l,emptyNote:u,onActiveChange:s,ref:e=>{r=e}}))},l=()=>{t&&OO(t,i?.()??null)};return{onStart(e){o=!1,t=document.createElement(`div`),t.style.position=`fixed`,t.style.zIndex=`50`,document.body.appendChild(t),n=(0,_n.createRoot)(t),i=e.clientRect??null,a=e.editor?.view.dom??null,l(),c(e),window.addEventListener(`scroll`,l,!0),window.addEventListener(`resize`,l)},onUpdate(e){i=e.clientRect??null,l(),c(e)},onKeyDown(e){return e.event.key===`Escape`?!t||t.style.display===`none`?!1:(o=!0,t.style.display=`none`,a?.setAttribute(`aria-expanded`,`false`),s(null),!0):r?.onKeyDown(e.event)??!1},onExit(){o=!1,window.removeEventListener(`scroll`,l,!0),window.removeEventListener(`resize`,l),a?.setAttribute(`aria-expanded`,`false`),s(null),a=null,n?.unmount(),t?.remove(),n=null,t=null,r=null,i=null}}}function AO(e){return sy.create({name:`suggestion-${e.key}`,addProseMirrorPlugins(){return[TO({editor:this.editor,char:e.char,pluginKey:new Zf(e.key),items:({query:t})=>e.items(t.toLowerCase()),command:({editor:t,range:n,props:r})=>e.onSelect(r,{editor:t,range:n}),render:()=>kO(e)})]}})}function jO(e,t,n){e.chain().focus().deleteRange(t).insertContent([{type:`token`,attrs:{kind:n.kind,label:n.label,text:n.text}},{type:`text`,text:` `}]).run()}function MO(e,t){e.commands.setContent(t),e.commands.focus(`end`),/\s$/.test(t)&&e.commands.insertContent({type:`text`,text:` `})}var NO=(0,G.forwardRef)(function({onChange:e,onSubmit:t,onPreset:n,onMentionProject:r,onMentionFile:i,onMentionRemoved:a,projects:o,files:s=[],commands:c,customPresets:l=[],projectPresets:u=[],onNewPreset:d,disabled:f=!1,placeholder:p=`Describe what to do…`,initialText:m,compact:h=!1},g){let[_,v]=(0,G.useState)(!0),y=(0,G.useRef)(o),b=(0,G.useRef)(s),x=(0,G.useRef)(c),S=(0,G.useRef)(l),C=(0,G.useRef)(u),w=(0,G.useRef)(d),T=(0,G.useRef)(n),E=(0,G.useRef)(r),D=(0,G.useRef)(i),O=(0,G.useRef)(a),k=(0,G.useRef)(e),A=(0,G.useRef)(t);(0,G.useEffect)(()=>{y.current=o,b.current=s,x.current=c,S.current=l,C.current=u,w.current=d,T.current=n,E.current=r,D.current=i,O.current=a,k.current=e,A.current=t});let j=(0,G.useRef)(new Set),M=e=>{let t=new Set;e.state.doc.descendants(e=>(e.type.name===`token`&&(e.attrs.kind===`project`||e.attrs.kind===`file`)&&t.add(String(e.attrs.text)),!0));for(let e of j.current)if(!t.has(e)){if(e.startsWith(`#`))O.current?.(e.slice(1));else if(e.startsWith(`@`)){let t=y.current.find(t=>t.name===e.slice(1));t&&O.current?.(t.path)}}j.current=t},N=(e,t)=>{let n=!e.isEmpty;return MO(e,t),M(e),v(e.isEmpty),k.current(e.storage.markdown.getMarkdown()),n},P=Lx({immediatelyRender:!1,extensions:[cC,xO.configure({html:!1,linkify:!1,breaks:!0,transformPastedText:!0}),SO,AO({char:`/`,key:`slash`,items:e=>{let t=e.toLowerCase();if(x.current.some(e=>e.name===t))return[];let n=x.current.filter(e=>e.name.includes(t)).map(e=>({id:`command:${e.name}`,label:`/${e.name}`,group:`Commands`,...e.description?{title:e.description}:{}})),r=S.current.filter(e=>e.label.toLowerCase().includes(t)).map(e=>({id:`custom-preset:${e.id}`,label:e.label,hint:`saved prompt`,group:`Saved prompts`})),i=C.current.filter(e=>e.label.toLowerCase().includes(t)).map(e=>({id:`project-preset:${e.id}`,label:e.label,hint:`project saved prompt`,group:`Saved prompts`})),a=w.current&&`save prompt`.includes(t)?[{id:`new-preset`,label:`Save prompt…`,hint:`save the current prompt`,group:`Saved prompts`}]:[];return[...n,...r,...i,...a]},onSelect:(e,{editor:t,range:n})=>{if(e.id.startsWith(`command:`)){let r=x.current.find(t=>`command:${t.name}`===e.id);if(r){t.chain().focus().deleteRange(n).run();let e=N(t,`/${r.name} `);T.current?.(`/${r.name}`,e)}return}if(e.id.startsWith(`custom-preset:`)){let r=S.current.find(t=>`custom-preset:${t.id}`===e.id);if(r){t.chain().focus().deleteRange(n).run();let e=N(t,r.prompt);T.current?.(r.label,e)}return}if(e.id.startsWith(`project-preset:`)){let r=C.current.find(t=>`project-preset:${t.id}`===e.id);if(r){t.chain().focus().deleteRange(n).run();let e=N(t,r.prompt);T.current?.(r.label,e)}return}e.id===`new-preset`&&(t.chain().focus().deleteRange(n).run(),w.current?.())}}),AO({char:`@`,key:`at`,emptyNote:`No projects to reference yet.`,items:e=>y.current.filter(t=>t.name.toLowerCase().includes(e)).slice(0,8).map(e=>({id:`project:${e.id}`,label:`@${e.name}`,hint:`project`,group:`Projects`})),onSelect:(e,{editor:t,range:n})=>{let r=y.current.find(t=>`project:${t.id}`===e.id);r&&(jO(t,n,{kind:`project`,label:`@${r.name}`,text:`@${r.name}`}),E.current?.(r.path))}}),AO({char:`#`,key:`hash`,emptyNote:`No files indexed here yet.`,items:e=>b.current.filter(t=>t.toLowerCase().includes(e.toLowerCase())).slice(0,8).map(e=>({id:`file:${e}`,label:`#${e}`,hint:`file`,group:`Files`})),onSelect:(e,{editor:t,range:n})=>{let r=e.id.slice(5);jO(t,n,{kind:`file`,label:`#${r}`,text:`#${r}`}),D.current?.(r)}})],editorProps:{attributes:{class:`pe-prose focus:outline-none`,role:`textbox`,"aria-multiline":`true`,"aria-label":`Prompt`,"aria-placeholder":p},handleKeyDown:(e,t)=>(t.metaKey||t.ctrlKey)&&t.key===`Enter`?(t.preventDefault(),A.current(),!0):t.key===`Enter`&&!t.shiftKey&&!t.altKey&&!t.isComposing?e.dom.getAttribute(`aria-expanded`)===`true`||e.state.selection.$from.parent.type.name===`codeBlock`?!1:(t.preventDefault(),A.current(),!0):!1},onUpdate:({editor:e})=>{M(e),v(e.isEmpty),k.current(e.storage.markdown.getMarkdown())}});(0,G.useImperativeHandle)(g,()=>({clear:()=>{P?.commands.clearContent(),P&&M(P),v(!0),k.current(``)},focus:()=>P?.commands.focus(`end`),loadTemplate:e=>P?N(P,e):!1})),(0,G.useEffect)(()=>{P?.setEditable(!f,!1)},[P,f]);let ee=(0,G.useRef)(!1);(0,G.useEffect)(()=>{!P||ee.current||!m||(ee.current=!0,N(P,m))},[P,m]);let te=h?`px-2 py-1.5`:`px-3 py-2.5`,ne=h?`inset-x-2 top-1.5`:`inset-x-3 top-2.5`;return(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(Ye,{className:h?`rounded-md border border-border focus-within:ring-2 focus-within:ring-[var(--color-primary)]`:``,viewportClassName:h?`max-h-32 min-h-8`:`max-h-64 min-h-10`,children:(0,K.jsx)(wx,{editor:P,className:`w-full bg-transparent text-sm pointer-coarse:text-base ${te}`})}),_&&(0,K.jsx)(`span`,{className:`pointer-events-none absolute truncate text-sm text-muted-foreground pointer-coarse:text-base ${ne}`,children:p})]})}),PO=80;function FO(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`p-${Date.now()}`}function IO({currentPrompt:e,busy:t,canSaveToProject:n,onSave:r,onCancel:i}){let[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(e),[l,u]=(0,G.useState)(`user`),d=()=>{let e=a.trim(),t=s.trim();!e||!t||r({id:FO(),label:e,prompt:t},n?l:`user`)};return(0,K.jsx)(mt,{open:!0,onOpenChange:e=>{e||i()},title:`Save prompt`,children:(0,K.jsxs)(`div`,{className:`flex w-full flex-col gap-2`,onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),d())},children:[(0,K.jsx)(jt,{type:`text`,value:a,maxLength:PO,placeholder:`Name`,disabled:t,autoFocus:!0,onChange:e=>o(e.target.value),className:`h-8 bg-background px-2`}),(0,K.jsx)(Je,{value:s,placeholder:`The prompt to save…`,disabled:t,rows:5,onChange:e=>c(e.target.value),className:`resize-y px-2 py-1 font-mono text-xs`}),n&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-[var(--color-muted-foreground)]`,children:[(0,K.jsx)(`span`,{children:`Save to`}),(0,K.jsx)(`div`,{className:`inline-flex overflow-hidden rounded-md border border-border`,children:[`user`,`project`].map(e=>(0,K.jsx)(`button`,{type:`button`,disabled:t,onClick:()=>u(e),"aria-pressed":l===e,className:l===e?`bg-foreground px-2 py-0.5 text-background`:`px-2 py-0.5 text-foreground hover:bg-[var(--color-muted)]`,children:e===`user`?`Just me`:`This project`},e))}),(0,K.jsx)(`span`,{className:`truncate`,children:l===`project`?`Committed to the repo, shared with your team`:`Private to you, on every project`})]}),(0,K.jsxs)(`div`,{className:`mt-1 flex items-center justify-end gap-2`,children:[(0,K.jsx)(V,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,children:`Cancel`}),(0,K.jsx)(V,{type:`button`,size:`sm`,disabled:t||!a.trim()||!s.trim(),onClick:d,children:`Save prompt`})]})]})})}function LO({preset:e,busy:t,onLoad:n,onDelete:r}){return(0,K.jsxs)(L,{disabled:t,onClick:()=>n(e.prompt,e.label),className:`items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(`button`,{type:`button`,disabled:t,onClick:t=>{t.stopPropagation(),r(e.id)},"aria-label":`Delete saved prompt ${e.label}`,className:`rounded p-0.5 text-[var(--color-muted-foreground)] hover:text-danger`}),children:(0,K.jsx)(ee,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,K.jsxs)(z,{children:[`Delete "`,e.label,`"`]})]})]})}function RO({commands:e,customPresets:t,projectPresets:n,busy:r,onLoad:i,onNew:a,onDelete:o,onDeleteProject:s}){return(0,K.jsxs)(re,{children:[(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(bt,{type:`button`,disabled:r,"aria-label":`Commands`,className:B(_t({variant:`ghost`,size:`icon-sm`}),`h-8 w-8`)}),children:(0,K.jsx)(Fa,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsx)(z,{children:`Run a command or load a saved prompt. In the box: / commands · @ projects · # files`})]}),(0,K.jsxs)(Be,{align:`start`,className:`min-w-[16rem] max-w-[20rem]`,children:[(0,K.jsxs)(We,{children:[(0,K.jsx)(c,{children:`Commands`}),e.length===0&&(0,K.jsx)(`div`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`This project has no commands.`}),e.map(e=>{let t={disabled:r||e.waiting!==void 0,onClick:()=>i(`/${e.name} `,`/${e.name}`),className:`items-start`},n=(0,K.jsx)(Ae,{label:`/${e.name}`,...e.waiting===void 0?{}:{description:`waiting to reach ${e.waiting}`}});return e.description?(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(L,{...t}),children:n}),(0,K.jsx)(z,{className:`max-w-[22rem]`,children:e.description})]},e.name):(0,K.jsx)(L,{...t,children:n},e.name)})]}),t.length>0&&(0,K.jsxs)(We,{children:[(0,K.jsx)(st,{}),(0,K.jsx)(c,{children:`Your saved prompts`}),t.map(e=>(0,K.jsx)(LO,{preset:e,busy:r,onLoad:i,onDelete:o},e.id))]}),n.length>0&&(0,K.jsxs)(We,{children:[(0,K.jsx)(st,{}),(0,K.jsx)(c,{children:`Project saved prompts`}),n.map(e=>(0,K.jsx)(LO,{preset:e,busy:r,onLoad:i,onDelete:s},e.id))]}),a&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(st,{}),(0,K.jsxs)(L,{disabled:r,onClick:a,children:[(0,K.jsx)(Fa,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Save prompt…`]})]})]})]})}var zO=`the CLI's own default`,BO={xhigh:`Extra high`};function VO(e){return BO[e]??e.charAt(0).toUpperCase()+e.slice(1)}function HO(e,t){return e.find(e=>e.value===t)??e[0]}function UO(e,t){if(t)return e?.models.find(e=>e.value===t)?.label??t}function WO({drivers:e,driver:t,model:n,onChange:r,effort:i,busy:a}){let o=HO(e,t),s=UO(o,n),l=i?.levels??[],u=i?.level===void 0?void 0:VO(i.level),d=`Driver: ${o?.label??``} · Model: ${s??`the CLI's own default`}${l.length>0?` · Effort: ${u??`the agent’s default`}`:``}`;return(0,K.jsxs)(re,{children:[(0,K.jsxs)(U,{children:[(0,K.jsxs)(H,{render:(0,K.jsx)(bt,{type:`button`,disabled:a,"aria-label":d,className:B(Il,`text-foreground`)}),children:[o?.icon?(0,K.jsx)(`span`,{className:`flex h-3.5 w-3.5 items-center justify-center [&>svg]:size-3.5`,children:o.icon}):o?.label,s,u&&(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:u}),(0,K.jsx)(Fe,{className:`h-3 w-3 shrink-0 opacity-70`})]}),(0,K.jsx)(z,{children:d})]}),(0,K.jsxs)(Be,{align:`end`,children:[e.map(e=>(0,K.jsxs)(Zt,{children:[(0,K.jsxs)(Kt,{children:[(0,K.jsx)(N,{className:B(`h-3.5 w-3.5 shrink-0`,e.value===t?`opacity-100`:`opacity-0`)}),e.icon&&(0,K.jsx)(`span`,{className:`flex h-4 w-4 items-center justify-center`,children:e.icon}),(0,K.jsx)(`span`,{className:`flex-1`,children:e.label})]}),(0,K.jsxs)(It,{children:[e.models.length===0&&e.modelsNote&&(0,K.jsx)(L,{disabled:!0,children:e.modelsNote}),e.models.map(i=>(0,K.jsxs)(L,{onClick:()=>r(e.value,i.value),children:[(0,K.jsx)(N,{className:B(`h-3.5 w-3.5 shrink-0`,e.value===t&&i.value===n?`opacity-100`:`opacity-0`)}),i.label]},i.value))]})]},e.value)),l.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(st,{}),(0,K.jsxs)(We,{children:[(0,K.jsx)(c,{children:`Effort`}),(0,K.jsxs)(L,{onClick:()=>i.onChange(void 0),children:[(0,K.jsx)(N,{className:B(`h-3.5 w-3.5 shrink-0`,i?.level===void 0?`opacity-100`:`opacity-0`)}),`The agent’s default`]}),l.map(e=>(0,K.jsxs)(L,{onClick:()=>i.onChange(e),children:[(0,K.jsx)(N,{className:B(`h-3.5 w-3.5 shrink-0`,i?.level===e?`opacity-100`:`opacity-0`)}),VO(e)]},e))]})]})]})]})}function GO(e){let{kind:t,place:n}=pn(e);return t===`shared`?`${n}. Runs use your own logins.`:n}function KO({connection:e,busy:t,inRow:n=!1}){let r=e.selectedMachineId&&!e.onlyHere&&(!e.onlyThere||e.selectedMachineId===e.home)?e.machines.find(t=>t.id===e.selectedMachineId):void 0,i=ol(),a=r?et(r):i,o=!r,s=o?xe:le[pn(r).kind];return(0,K.jsxs)(re,{children:[(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(bt,{type:`button`,disabled:t,"aria-label":`Run on`,className:n?Il:B(_t({variant:`ghost`,size:`icon-sm`}),`relative h-8 w-8`)}),children:n?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`span`,{className:`relative flex shrink-0`,children:[(0,K.jsx)(s,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),!o&&(0,K.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 h-1.5 w-1.5 rounded-full bg-[var(--color-primary)]`})]}),(0,K.jsx)(`span`,{className:`truncate`,children:a}),(0,K.jsx)(Fe,{className:`h-3 w-3 shrink-0 opacity-70`,"aria-hidden":!0})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(s,{className:`h-4 w-4`}),!o&&(0,K.jsx)(`span`,{className:`absolute -right-0.5 -top-0.5 h-2 w-2 rounded-full bg-[var(--color-primary)]`})]})}),(0,K.jsx)(z,{children:`Run on — ${r?.label??i}`})]}),(0,K.jsxs)(Be,{align:n?`start`:`end`,className:`min-w-[19rem] max-w-[22rem]`,children:[(0,K.jsxs)(L,{className:B(`items-start gap-2`,e.onlyThere&&`opacity-60`),disabled:e.onlyThere,onClick:()=>e.onSelectLocal(),children:[(0,K.jsx)(N,{className:B(`mt-0.5 h-3.5 w-3.5 shrink-0`,o?`opacity-100`:`opacity-0`)}),(0,K.jsx)(xe,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,K.jsx)(Ae,{label:i,description:e.home===void 0?`Runs here, through this project's start hook.`:e.onlyThere?`It has no repository address to clone it here from.`:`Cloned here first, then runs here.`})]}),e.machines.map(t=>{let n=e.status[t.id],i=n===`offline`,a=GO(t),o=e.home===void 0?a:t.id===e.home?`${a}. Has this project.`:`${a}. Cloned there first, then runs there.`,s=i?ln(t.url)?`Not connected. It must be on, with OpenAgent running.`:`Offline · ${o}`:o,c=e.onlyHere||e.onlyThere===!0&&t.id!==e.home;return(0,K.jsxs)(L,{className:B(`items-start gap-2`,(i||c)&&`opacity-60`),disabled:c,onClick:()=>e.onSelect(t),children:[(0,K.jsx)(N,{className:B(`mt-0.5 h-3.5 w-3.5 shrink-0`,r?.id===t.id?`opacity-100`:`opacity-0`)}),(0,K.jsx)(ge,{kind:pn(t).kind,online:n===`online`,className:`mt-0.5`}),(0,K.jsx)(Ae,{label:et(t),description:s})]},t.id)}),e.onlyHere&&e.machines.length>0&&(0,K.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`This project has no repository address, so it cannot be sent to another machine.`}),(0,K.jsxs)(L,{className:`items-start`,disabled:t,onClick:()=>e.onAddMachine(),children:[(0,K.jsx)(Fa,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsx)(Ae,{label:`Add a machine…`,description:`Connect a computer, or join with a code.`})]})]})]})}var qO=1e4;function JO(e){let t=e.map(e=>e.id).join(`|`),n=g((0,G.useMemo)(()=>t?()=>Ue():null,[t]),{},qO,[t]).value;return(0,G.useMemo)(()=>{let e={};for(let[t,r]of Object.entries(n))e[t]=r?`online`:`offline`;return e},[n])}var YO={"claude-code":{icon:(0,K.jsx)(ao,{className:`h-4 w-4`})},codex:{icon:(0,K.jsx)(oo,{className:`h-4 w-4`})}},XO=`flex h-8 items-center gap-2`,ZO=`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)]`,QO=(0,G.forwardRef)(function({files:e,addContext:t,removeContext:n,startsAt:r,controls:i,sessionModel:a,sessionContext:o,onSubmit:s,onPromptChange:c,onPreset:l,busy:u,submitLabel:d,submitBusyLabel:f,placeholder:p,compact:m=!1,showDriverModel:h=!0,inAgent:g=!1,canSubmit:_=!0,idleControl:v,home:y},b){let[x,S]=(0,G.useState)(``),[C,w]=(0,G.useState)(!1),T=(0,G.useRef)(null),E=Vi(),D=JO(E),O=we(ti,[],[]),k=(0,G.useMemo)(()=>O.filter(e=>e.machine===void 0),[O]),A=lr(),j=A.model??``,M=A.driver??`claude-code`,N=A.customPresets??[],P=ir(),ee=cr(),te=_l(ee),ne=te?.commands??[],re=y===void 0&&te!==null&&te.address===void 0,ie=y!==void 0&&te!==null&&te.address===void 0,F=wi(),I=Ei(E,F,te,y),{models:oe,theirs:se}=nn(g?void 0:I?.id),ce=!!I&&D[I.id]===`offline`,[le,ue]=(0,G.useState)(null),de=I?.owner,fe=!g&&!!I&&de!==void 0&&!I.told&&le!==I.id;(0,G.useImperativeHandle)(b,()=>({clear:()=>{T.current?.clear(),S(``)},focus:()=>T.current?.focus()}));let[pe,me]=(0,G.useState)(void 0);(0,G.useEffect)(()=>{if(m||g)return;let e=vt();e&&me(e)},[m,g]);let he=(0,G.useRef)(!1),ge=e=>{e?.preventDefault();let t=x.trim();!t||u||he.current||ce||fe||!_||(he.current=!0,Promise.resolve(s(t)).finally(()=>{he.current=!1}))},_e=(e,t)=>{let n=T.current?.loadTemplate(e)??!1;l?.(t,n)},ve=(0,K.jsx)(NO,{ref:T,compact:m,onChange:e=>{S(e),c?.(e)},onSubmit:ge,...l?{onPreset:l}:{},...t?{onMentionProject:t,onMentionFile:t}:{},...n?{onMentionRemoved:n}:{},projects:k,files:e,commands:vl(ne),customPresets:N,projectPresets:P,...m?{}:{onNewPreset:()=>w(!0)},disabled:u,...p?{placeholder:p}:{},...pe?{initialText:pe}:{}}),ye=h&&(0,K.jsx)(WO,{drivers:ut(oe,se&&I?et(I):void 0).map(e=>({...e,...YO[e.value]})),driver:M,model:j,onChange:(e,t)=>or({driver:e,model:t}),effort:{levels:Pt(oe,M,j),level:A.effort||void 0,onChange:e=>or({effort:e??``})},busy:u}),be=!m&&(0,K.jsx)(RO,{commands:ne,customPresets:N,projectPresets:P,busy:u,onLoad:_e,onNew:()=>w(!0),onDelete:e=>or({customPresets:N.filter(t=>t.id!==e)}),onDeleteProject:e=>ar(ee,P.filter(t=>t.id!==e))}),L=g?null:(0,K.jsx)(KO,{busy:u,inRow:!m,connection:{machines:E,selectedMachineId:F,onlyHere:re,home:y,onlyThere:ie,onSelect:e=>xi(e.id),onSelectLocal:()=>xi(null),onAddMachine:()=>Ml(`devices`),status:D}}),xe=!!x.trim(),Se=(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(V,{type:`submit`,size:`icon-sm`,onClick:ge,disabled:u||!xe||ce||fe||!_,"aria-hidden":!xe,tabIndex:xe?void 0:-1,"aria-label":d,className:B(`h-8 w-8 shrink-0 transition-[margin,opacity,transform] duration-150 ease-out`,xe?B(`ml-0 translate-x-0 opacity-100`,u?`disabled:opacity-100`:`disabled:opacity-40`):B(`pointer-events-none translate-x-2 opacity-0 disabled:opacity-0`,m?`-ml-[2.375rem]`:`-ml-8`))}),children:u?(0,K.jsx)(ae,{className:`h-4 w-4 animate-spin`}):(0,K.jsx)(Gi,{className:`h-4 w-4`})}),(0,K.jsx)(z,{children:u?f:`${d} (Enter · Shift+Enter for a new line)`})]}),Ce=!xe&&v?v:Se,Te=ce&&(0,K.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:`${I?et(I):`The selected machine`} is offline. Pick another place to run, then start.`}),Ee=fe&&(0,K.jsxs)(`div`,{role:`note`,className:`mb-1.5 flex items-center gap-3 rounded-md border border-border bg-background px-3 py-2 text-xs`,children:[(0,K.jsxs)(`p`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:`Your GitHub and Claude logins are copied to @${de}'s server.`}),` `,(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`@${de} can see what is on it. Runs there start once you say OK.`})]}),(0,K.jsx)(V,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>{ue(I.id),zi(I.id)},children:`OK`})]});return m?(0,K.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:ve}),ye,L,Ce]}):(0,K.jsxs)(K.Fragment,{children:[!g&&(0,K.jsx)(`div`,{className:B(`mb-1`,XO),children:(0,K.jsxs)(`div`,{className:ZO,children:[L,r]})}),Ee,(0,K.jsxs)(`div`,{className:`flex items-end rounded-xl border border-border bg-card focus-within:border-muted-foreground/40`,children:[be&&(0,K.jsx)(`div`,{className:`-mr-2 flex shrink-0 items-center p-1`,children:be}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:ve}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center p-1`,children:Ce})]}),(0,K.jsxs)(`div`,{className:B(`mt-1`,XO),children:[(0,K.jsx)(`div`,{className:ZO,children:i}),(0,K.jsx)(`div`,{className:`shrink-0`,children:ye||(0,K.jsxs)(`span`,{className:`flex items-center`,children:[a!==void 0&&(0,K.jsx)(`span`,{className:`px-2 text-[13px] text-muted-foreground`,children:a}),o]})})]}),Te,C&&(0,K.jsx)(IO,{currentPrompt:x,busy:u,canSaveToProject:ee!==null,onCancel:()=>{w(!1),T.current?.focus()},onSave:(e,t)=>{t===`project`?ar(ee,[...P,e]):or({customPresets:[...N,e]}),w(!1),T.current?.focus()}})]})});function $O(e,t,n){return e===`local`?`${n} (local)`:t}function ek({main:e,local:t,pick:n,onPick:r,busy:i}){let a=$O(n,e,t),o=[{pick:`main`,label:e,description:`The project's main branch, fetched fresh.`},{pick:`local`,label:`My local branch ${t}`,description:`Your branch as committed on this machine; uncommitted edits are not carried. If the agent publishes, your commits that are not pushed go up with its branch.`}];return(0,K.jsxs)(re,{children:[(0,K.jsxs)(U,{children:[(0,K.jsxs)(H,{render:(0,K.jsx)(bt,{type:`button`,disabled:i,"aria-label":`The agent starts from`,className:Il}),children:[(0,K.jsx)(ha,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`truncate`,children:a}),(0,K.jsx)(Fe,{className:`h-3 w-3 shrink-0 opacity-70`,"aria-hidden":!0})]}),(0,K.jsx)(z,{children:`The agent starts from ${a}`})]}),(0,K.jsx)(Be,{align:`start`,className:`min-w-[19rem] max-w-[22rem]`,children:(0,K.jsxs)(We,{children:[(0,K.jsx)(c,{className:`font-normal`,children:`The agent starts from`}),o.map(e=>(0,K.jsxs)(L,{className:`items-start`,"aria-current":e.pick===n,onClick:()=>r(e.pick),children:[(0,K.jsx)(N,{className:B(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.pick===n?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,K.jsx)(Ae,{label:e.label,description:e.description})]},e.pick))]})})]})}function tk(e,t){let n=t?.replace(/\/+$/,``);return n&&e.startsWith(`${n}/`)?e.slice(n.length+1):e}function nk(e,t){let n=t?.replace(/\/+$/,``);return n===void 0||!e.startsWith(`/`)||e.startsWith(`${n}/`)}function rk(e){return e.kind===`driver`&&e.event.type===`output`?e.event.changed??[]:[]}function ik(e){return e.kind===`driver`&&e.event.type===`start`}function ak(e,t){let n=new Map;for(let r of e){if(!nk(r.path,t))continue;let e=tk(r.path,t),i=n.get(e)??{path:e,name:e.replace(/\/+$/,``).split(`/`).pop()||e,added:0,removed:0,created:!1};n.set(e,{...i,added:i.added+r.added,removed:i.removed+r.removed,created:i.created||r.created===!0})}return[...n.values()].map(e=>e.created?{...e,added:Math.max(0,e.added-e.removed),removed:0}:e)}function ok(e,t){let n=new Map,r=[];for(let i of e){if(ik(i)){r.length>0&&n.set(i,ak(r,t)),r=[];continue}r.push(...rk(i))}return{ended:n,last:ak(r,t)}}function sk(e){return{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)}}var ck={Bash:{verb:`Ran`,doing:`Running`,kind:`command`},Read:{verb:`Read`,doing:`Reading`,kind:`read`,file:!0},Edit:{verb:`Edited`,doing:`Editing`,kind:`edit`,file:!0},MultiEdit:{verb:`Edited`,doing:`Editing`,kind:`edit`,file:!0},NotebookEdit:{verb:`Edited`,doing:`Editing`,kind:`edit`,file:!0},Write:{verb:`Wrote`,doing:`Writing`,kind:`edit`,file:!0},Grep:{verb:`Searched`,doing:`Searching`,kind:`search`,plain:!0},Glob:{verb:`Searched`,doing:`Searching`,kind:`find`,plain:!0},WebSearch:{verb:`Searched the web`,doing:`Searching the web`,kind:`web`,plain:!0},WebFetch:{verb:`Fetched`,doing:`Fetching`,kind:`other`},Skill:{verb:`Ran skill`,doing:`Running skill`,kind:`skill`,slash:!0},Task:{verb:`Started agent`,doing:`Starting agent`,kind:`other`},Agent:{verb:`Started agent`,doing:`Starting agent`,kind:`other`},TodoWrite:{verb:`Updated todos`,doing:`Updating todos`,kind:`other`},ToolSearch:{verb:`Loaded tools`,doing:`Loading tools`,kind:`other`},commandExecution:{verb:`Ran`,doing:`Running`,kind:`command`},fileChange:{verb:`Edited`,doing:`Editing`,kind:`edit`,file:!0},mcpToolCall:{verb:`Called`,doing:`Calling`,kind:`other`},webSearch:{verb:`Searched the web`,doing:`Searching the web`,kind:`web`,plain:!0}};function lk(e){if(!/^[a-z]+([A-Z][a-z]*)+$/.test(e))return e;let t=e.replace(/[A-Z]/g,e=>` ${e.toLowerCase()}`);return t.charAt(0).toUpperCase()+t.slice(1)}function uk(e){return e.split(`, `).map(e=>e.replace(/\/+$/,``).split(`/`).pop()||e).join(`, `)}function dk(e){let t=/^mcp__(.+?)__(.+)$/.exec(e);if(!t)return;let n=t[2].replace(/_/g,` `);return{verb:`Used ${t[1]}:`,doing:`Using ${t[1]}:`,tool:n.charAt(0).toUpperCase()+n.slice(1)}}function fk(e,t,n){let r=ck[e],i=dk(e),a={verb:r?.verb??i?.verb??lk(e),doing:r?.doing??i?.doing??lk(e),kind:r?.kind??`other`};if(i&&(a.target=i.tool),r?.plain&&(a.plain=!0),t!==void 0&&(a.detail=t,a.target=r?.file?uk(t):r?.slash?`/${t.replace(/^\//,``)}`:t),n!==void 0&&n.length>0){let e=ak(n);a.kind=`edit`,a.verb=e.every(e=>e.created)?`Created`:`Updated`,a.target=e.map(e=>e.name).join(`, `),a.files=e,a.size=sk(e)}return a}var pk=(e,t,n)=>e===1?t:`${e} ${n}`;function mk(e){let t=t=>e.filter(e=>e.kind===t),n=t(`edit`),r=new Set(t(`read`).map((e,t)=>e.detail??t)).size,i=[],a={parts:i},o=t(`command`).length;if(o>0&&i.push({words:`ran ${pk(o,`a command`,`commands`)}`}),r>0&&i.push({words:`read ${pk(r,`a file`,`files`)}`}),t(`search`).length>0&&i.push({words:`searched code`}),t(`find`).length>0&&i.push({words:`found files`}),t(`web`).length>0&&i.push({words:`searched the web`}),n.length>0){let e=ak(n.flatMap(e=>(e.files??[]).map(e=>({path:e.path,added:e.added,removed:e.removed,...e.created?{created:!0}:{}})))),t=e.filter(e=>e.created).length;e.length===1?i.push({words:t===1?`created`:`edited`,target:e[0].name}):e.length===0?i.push({words:`edited ${pk(n.length,`a file`,`files`)}`}):(t>0&&i.push({words:`created ${pk(t,`a file`,`files`)}`}),e.length>t&&i.push({words:`edited ${pk(e.length-t,`a file`,`files`)}`})),e.length>0&&(a.size=sk(e))}let s=t(`skill`).length+t(`other`).length;return s>0&&i.push({words:`used ${pk(s,`a tool`,`tools`)}`}),i[0]&&(i[0].words=i[0].words.charAt(0).toUpperCase()+i[0].words.slice(1)),a}function hk(e){return e.parts.map(e=>e.target===void 0?e.words:`${e.words} ${e.target}`).join(`, `)}function gk({added:e,removed:t}){return(0,K.jsxs)(`span`,{className:`shrink-0 tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}),` `,(0,K.jsxs)(`span`,{className:`text-danger`,children:[`−`,t]})]})}function _k({added:e,removed:t}){return(0,K.jsxs)(`span`,{className:`flex h-4 shrink-0 overflow-hidden rounded text-[10px] font-medium tabular-nums`,children:[(0,K.jsxs)(`span`,{className:`bg-success/20 px-1 text-success`,"aria-hidden":!0,children:[`+`,e]}),(0,K.jsxs)(`span`,{className:`bg-danger/20 px-1 text-danger`,"aria-hidden":!0,children:[`−`,t]}),(0,K.jsxs)(`span`,{className:`sr-only`,children:[e,` added, `,t,` removed`]})]})}function vk({files:e,onOpen:t}){let n=e.length>1,r=`flex h-7 w-full min-w-0 items-center gap-1.5 rounded-md px-2`;return(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col rounded-[10px] p-1 font-sans ring-1 ring-border`,children:[n&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`flex h-7 items-center px-2 text-[13px] text-foreground`,children:[`Edited `,e.length,` files`]}),(0,K.jsx)(`div`,{"aria-hidden":!0,className:`-mx-1 my-1 h-px bg-border`})]}),(0,K.jsx)(`ul`,{"aria-label":`Files changed`,className:`flex min-w-0 flex-col`,children:e.map(e=>{let n=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ua,{className:`h-4 w-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left text-[13px] text-foreground`,title:e.path,children:e.name}),(0,K.jsx)(`span`,{className:`text-xs`,children:(0,K.jsx)(gk,{added:e.added,removed:e.removed})})]});return(0,K.jsx)(`li`,{className:`min-w-0`,children:t?(0,K.jsx)(`button`,{type:`button`,onClick:()=>t(e.path),"aria-label":`Show the change to ${e.name}`,className:`${r} hover:bg-foreground/5`,children:n}):(0,K.jsx)(`div`,{className:r,children:n})},e.path)})}),n&&t&&(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t(),className:`${r} hover:bg-foreground/5`,children:[(0,K.jsx)(`span`,{className:`flex-1 text-left text-[13px] text-foreground`,children:`See all`}),(0,K.jsx)(`span`,{className:`text-xs`,children:(0,K.jsx)(gk,{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)})})]})]})}function yk({since:e}){let[t,n]=(0,G.useState)(()=>Date.now());return(0,G.useEffect)(()=>{let e=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(e)},[]),(0,K.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:Ot(t-Date.parse(e))})}function bk(){return(0,K.jsxs)(`span`,{className:`dot-wave shrink-0`,"aria-hidden":!0,children:[(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{}),(0,K.jsx)(`span`,{})]})}function xk(e){let t=e.trim().split(`
130
+ `).find(e=>e.trim()!==``)?.trim()??`Thought`;return t.length>90?`${t.slice(0,90).trimEnd()}…`:t}var Sk=`max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md px-2.5 py-1.5 font-mono text-xs text-foreground`;function Ck({label:e,detail:t,whole:n,summary:r,output:i,live:a}){let[o,s]=(0,G.useState)(!1),c=fk(e,t,i?.changed),l=n??c.detail,u=c.kind===`command`?r:void 0,d=(0,K.jsxs)(K.Fragment,{children:[u===void 0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:B(`shrink-0`,a&&`text-shimmer`),children:a?c.doing:c.verb}),c.target!==void 0&&(0,K.jsx)(`span`,{className:B(`truncate`,a?`text-shimmer`:!c.plain&&`text-foreground`),children:c.target})]}):(0,K.jsx)(`span`,{className:B(`truncate`,a&&`text-shimmer`),children:u}),c.size!==void 0&&(0,K.jsx)(_k,{...c.size}),a?.since!==void 0&&(0,K.jsx)(yk,{since:a.since})]});return l===void 0&&i===void 0?(0,K.jsx)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:d}):(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,"aria-label":u??[a?c.doing:c.verb,c.target].filter(Boolean).join(` `),className:`flex max-w-full min-w-0 items-center gap-1.5 text-left hover:text-foreground`,children:[d,(0,K.jsx)(m,{className:B(`h-3.5 w-3.5 shrink-0 transition-transform`,o&&`rotate-90`),"aria-hidden":!0})]}),o&&(0,K.jsxs)(`div`,{className:`mt-1 flex flex-col gap-1`,children:[l!==void 0&&(0,K.jsxs)(`pre`,{"aria-label":c.kind===`command`?`Command`:`Detail`,className:B(Sk,`bg-muted`),children:[c.kind===`command`&&(0,K.jsx)(`span`,{className:`select-none text-muted-foreground`,children:`$ `}),l]}),i!==void 0&&i.text!==``&&(0,K.jsx)(`pre`,{"aria-label":`Output`,className:B(Sk,`border border-border`),children:i.text}),i?.failed&&(0,K.jsx)(`div`,{className:`text-xs text-danger`,children:i.exitCode===void 0?`Failed`:`Failed: exit code ${i.exitCode}`})]})]})}function wk({text:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),"aria-expanded":t,"aria-label":`Thought`,className:`flex min-w-0 max-w-full items-center gap-1.5 hover:text-foreground`,children:[(0,K.jsx)(`span`,{className:`truncate italic`,children:xk(e)}),(0,K.jsx)(m,{className:B(`h-3.5 w-3.5 shrink-0 transition-transform`,t&&`rotate-90`),"aria-hidden":!0})]}),t&&(0,K.jsx)(`div`,{className:`mt-1 italic`,children:(0,K.jsx)(Wt,{text:e,compact:!0})})]})}function Tk({call:e,word:t,since:n}){return(0,K.jsxs)(`div`,{role:`status`,className:`flex min-w-0 flex-1 items-center gap-2 font-sans text-sm text-muted-foreground`,children:[(0,K.jsx)(bk,{}),(0,K.jsx)(`span`,{className:`morph-in flex min-w-0 items-center gap-2`,children:e?(0,K.jsx)(Ck,{...e,live:{since:n}}):(0,K.jsxs)(K.Fragment,{children:[t!==void 0&&(0,K.jsx)(`span`,{className:`text-shimmer`,children:t}),n!==void 0&&(0,K.jsx)(yk,{since:n})]})},e?e.id??`${e.label} ${e.detail??``}`:t)]})}function Ek({steps:e,lead:t}){let[n,r]=(0,G.useState)(!1),i=lr().showThinking===!0?e:e.filter(e=>e.type===`action`),a=e.filter(e=>e.type===`action`);if(a.length===0)return null;let o=mk(a.map(e=>fk(e.label,e.detail,e.output?.changed))),s=hk(o),c=i.length===1?i[0]:void 0;return c?.type===`action`&&!t?(0,K.jsx)(`div`,{className:`min-w-0 flex-1 font-sans text-sm text-muted-foreground`,children:(0,K.jsx)(Ck,{...c})}):(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 font-sans text-sm text-muted-foreground`,children:[(0,K.jsx)(`div`,{className:`group/status flex`,children:(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-expanded":n,"aria-label":s,className:`flex min-w-0 items-center gap-1.5 py-0.5`,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate text-left`,children:o.parts.map((e,t)=>(0,K.jsxs)(G.Fragment,{children:[(0,K.jsxs)(`span`,{className:`group-hover/status:text-foreground/80 group-has-focus-visible/status:text-foreground/80`,children:[t>0&&`, `,e.words]}),e.target!==void 0&&(0,K.jsxs)(`span`,{className:`text-foreground/80 group-hover/status:text-foreground group-has-focus-visible/status:text-foreground`,children:[` `,e.target]})]},t))}),o.size!==void 0&&(0,K.jsx)(_k,{...o.size}),(0,K.jsx)(m,{className:B(`h-3.5 w-3.5 shrink-0 transition-transform`,n&&`rotate-90`),"aria-hidden":!0})]})}),n&&(0,K.jsxs)(`div`,{className:`mt-1.5 flex flex-col divide-y divide-border rounded-lg border border-border`,children:[t&&(0,K.jsx)(`div`,{className:`px-2 py-1.5`,children:t}),i.map((e,t)=>(0,K.jsx)(`div`,{className:`px-2 py-1.5`,children:e.type===`action`?(0,K.jsx)(Ck,{...e}):(0,K.jsx)(wk,{text:e.text})},t))]})]})}var Dk=`Starting session`,Ok=8e3,kk=6e4,Ak=8e3;function jk({projectId:e,projectName:t,onAgentStarted:n,files:r,context:i,addContext:a,removeContext:o,toggleContext:s,onOpenSkills:c,home:l}){let[u,f]=(0,G.useState)(null),[p,m]=(0,G.useState)(null),{busy:h,cloning:_,error:v,reset:y,start:b}=fl(e),x=(0,G.useRef)(null),S=lr(),C=_l(e),w=Vi(),T=wi();(0,G.useEffect)(()=>Ti(l),[e,l]);let E=Ei(w,T,C,l),D=l!==void 0&&E?.id===l,O=E!==void 0&&!D,k=l!==void 0&&E===void 0,A=C!==null&&!C.startHook&&!O&&!k,j=O?[]:vl(C?.commands??[]),M=ul(j),N=O?!0:C?.gitHost??!0,P=O?!0:C?.remote??!0,ee=d(S.publish,N,P),te=O||k?void 0:C?.startFrom,re=S.startFrom?.[e]??`main`,ae=ur(),F=t=>{let{[e]:n,...r}=S.startFrom??{};or({startFrom:t===`local`?{...r,[e]:`local`}:r})},I=S.driver,[oe,ce]=(0,G.useState)(0),le=C?.address,ue=we(E?null:k?le===void 0?null:()=>fi(le,I):()=>di(e,I),null,[e,I,E===void 0,k,le,oe]),[de,fe]=(0,G.useState)(kk),pe=g(E?()=>ne(e,E.id,I):null,null,de,[e,I,E?.id]).value,me=E?pe:ue;(0,G.useEffect)(()=>{let e=pe&&pe.problems.length>0?Ok:kk;e!==de&&fe(e)},[pe,de]);let he=!E&&me?.fix!==void 0,{state:ge,reload:ve}=Ss(_e(I)?I:void 0,he),ye=se[_e(I)?I:`claude-code`],be=g(E?.owner===void 0?null:()=>ie(E.id),null,Ak,[E?.id]).value,L=E?.owner!==void 0&&be?.ok?[`GitHub`,`Claude`].filter(e=>be.logins[e===`GitHub`?`github`:`claude`]===void 0):[],xe=E?et(E):void 0,Se=(0,G.useRef)(void 0);return(0,G.useEffect)(()=>{let e=he?ge?.ready:void 0;Se.current===!1&&e===!0&&ce(e=>e+1),Se.current=e},[he,ge?.ready]),(0,K.jsxs)(`form`,{onSubmit:e=>e.preventDefault(),className:`relative mx-auto w-full max-w-3xl p-2`,children:[(0,K.jsx)(QO,{ref:x,home:l,files:r,addContext:a,removeContext:o,startsAt:t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Ll,{icon:(0,K.jsx)(ma,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),children:t}),te&&ae&&(0,K.jsx)(ek,{main:te.main,local:te.local,pick:re,onPick:F,busy:h})]}):null,controls:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Vl,{projectId:e,context:i,busy:h,onToggle:s}),(0,K.jsx)(zl,{publish:ee,picks:kt(N,P),onPublish:e=>or({publish:e}),cleanup:M?S.postMergeCleanup??!1:void 0,onCleanup:e=>or({postMergeCleanup:e}),busy:h}),c&&(0,K.jsxs)(`button`,{type:`button`,onClick:c,className:Il,children:[(0,K.jsx)(Ia,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`truncate`,children:`Skills`})]})]}),onSubmit:async t=>{if(h)return;f(Dk),m(E?et(E):k?Mk():null);let r=await b(e,Pl(t,i),{...cl(S),...dl(S,j),...te&&re===`local`?{base:te.local}:{},...E?{machine:E.id}:{}});f(null),r&&(n?.(t,r.agentId,E?.label,r.projectId),x.current?.clear())},onPromptChange:e=>{!e.trim()&&u&&f(null),v&&y()},onPreset:(e,t)=>{y(),f(t?`${e} loaded over your draft — undo (⌘Z) brings the draft back`:`${e} loaded — review or edit, then Start`)},busy:h,canSubmit:!A,submitLabel:`Start agent`,submitBusyLabel:`Starting…`}),(0,K.jsxs)(`div`,{className:`absolute inset-x-2 bottom-full flex flex-col gap-1.5 pb-1`,children:[v&&L.length===0&&!me?.problems.length&&(0,K.jsx)(Nk,{...Pk(v)}),E&&L.length>0&&(0,K.jsx)(Nk,{title:`Your ${L.join(` and `)} ${L.length===1?`login is`:`logins are`} not on ${xe} yet.`,detail:`Runs there use your own logins. Log ${L.length===1?`it`:`them`} in on its page, or start your first run there from your page on ${Te(E.url)??`its server`}, which copies yours.`,actions:(0,K.jsx)(V,{type:`button`,size:`xs`,onClick:()=>Ml(`devices`,E.id),children:`Log in on ${xe}`})}),me?.problems.map(e=>e===me.fix?.problem?E?me.fix.kind===`log-in`?(0,K.jsx)(Nk,{title:`${ye} is not logged in on ${xe}.`,actions:(0,K.jsx)(Ys,{machineId:E.id,onAccounts:()=>Ml(_s)})},e):(0,K.jsx)(Nk,{title:`${ye} is not installed on ${xe}.`,detail:`Update ${xe} to get it.`,actions:(0,K.jsx)(V,{type:`button`,size:`xs`,onClick:()=>Ml(`devices`,E.id),children:`Update ${xe}`})},e):(0,K.jsx)(Nk,{...ge&&!ge.ready?{title:js(ge),actions:(0,K.jsx)(Fs,{state:ge,onChanged:()=>void ve(),size:`xs`})}:Pk(e)},e):(0,K.jsx)(Nk,{...Pk(e)},e)),me?.warnings.map(e=>(0,K.jsx)(`p`,{role:`alert`,className:`rounded-lg border border-warning/30 bg-[color-mix(in_oklab,var(--color-warning)_8%,var(--color-background))] px-3 py-1.5 text-xs text-warning`,children:e},e)),A&&(0,K.jsx)(Nk,{title:`This project has no start hook.`,detail:(0,K.jsxs)(K.Fragment,{children:[`Add a `,(0,K.jsx)(`code`,{className:`font-mono`,children:`start:`}),` line to `,(0,K.jsx)(`code`,{className:`font-mono`,children:`.openagent/hooks.yml`}),`.`]})}),u===Dk&&!v&&(0,K.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 px-1.5 text-sm text-muted-foreground`,children:[(0,K.jsx)(bk,{}),(0,K.jsx)(`span`,{className:`text-shimmer`,children:_&&p?`Cloning ${t??`this project`} on ${p}, the first time only`:u})]})]}),u!==Dk&&u&&!v&&(0,K.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-muted-foreground`,children:u})]})}function Mk(){let e=ol();return e===`This machine`?`this computer`:e}function Nk({title:e,detail:t,actions:n}){return(0,K.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2.5 rounded-lg border border-danger/30 bg-[color-mix(in_oklab,var(--color-danger)_8%,var(--color-background))] px-3 py-2.5 shadow-sm`,children:[(0,K.jsx)(Qi,{className:`mt-0.5 h-4 w-4 shrink-0 text-danger`,"aria-hidden":!0}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 [overflow-wrap:anywhere]`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-danger`,children:e}),t!==void 0&&(0,K.jsxs)(K.Fragment,{children:[` `,(0,K.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t})]}),n!==void 0&&(0,K.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-foreground`,children:n})]})]})}function Pk(e){let t=e.search(/\.\s+(?=[A-Z`@])/);return t<=0||t>140?{title:e}:{title:e.slice(0,t+1),detail:e.slice(t+1).trim()}}function Fk(e){let t=Bk(e);return t.length>0&&!t.some(e=>e.kind===`end`)}function Ik(e){let t=Bk(e).find(e=>e.kind===`end`);if(!(!t||t.kind!==`end`))return{ok:t.ok,stopped:t.stopped===!0,...t.waiting===!0?{waiting:!0}:{},...t.detail===void 0?{}:{detail:t.detail}}}function Lk(e){if(e!==`running`)return{ok:e===`done`,stopped:e===`stopped`,...e===`waiting`?{waiting:!0}:{}}}function Rk(e){let t;for(let n of e){if(n.kind!==`driver`||n.event.type!==`action`)continue;let e=/^run (https?:\/\/\S+)$/.exec(n.event.label);e&&(t=e[1])}return t}function zk(e){let t;for(let n of e){if(n.kind!==`driver`||n.event.type!==`action`)continue;let e=/^cloud (https:\/\/claude\.ai\/code\/(session_[A-Za-z0-9]+)\S*)$/.exec(n.event.label);e&&(t={url:e[1],id:e[2]})}return t}function Bk(e){let t=0,n=!1;for(let r=e.length-1;r>=0;r--){let i=e[r]?.kind;if(i===`session`){t=r;break}if(i===`end`&&n){t=r+1;break}i===`driver`&&(n=!0)}return e.slice(t)}function Vk(e){let t=e?.sessionLink,n=e?.sessionId;return!t||!n||!t.includes(n)?null:{href:t,label:`Open session (${n}) ↗`}}function Hk(e){let t=e?.sessionId;if(!t)return null;let n=e.workspace;if(!n)return t;let r=`'${n.replaceAll(`'`,`'\\''`)}'`;return`mkdir -p ${r} && cd ${r} && claude --resume ${t}`}function Uk(){return we(()=>Un(),[],[])}function Wk(e){let t=Uk();return e&&!t.some(t=>t.bin===e)?[...t,{bin:e,label:e}]:t}function Gk({busy:e}){let t=lr().editor,n=Wk(t);return(0,K.jsxs)(We,{children:[(0,K.jsx)(c,{children:`Preferred editor`}),(0,K.jsxs)(L,{disabled:e,closeOnClick:!1,onClick:()=>or({editor:``}),className:`items-start`,children:[(0,K.jsx)(N,{className:B(`mt-0.5 h-3.5 w-3.5 shrink-0`,t?`opacity-0`:`opacity-100`)}),(0,K.jsx)(Ae,{label:`Default`,description:`$OPENAGENT_EDITOR, or code`})]}),n.map(n=>(0,K.jsxs)(L,{disabled:e,closeOnClick:!1,onClick:()=>or({editor:n.bin}),className:`items-start`,children:[(0,K.jsx)(N,{className:B(`mt-0.5 h-3.5 w-3.5 shrink-0`,t===n.bin?`opacity-100`:`opacity-0`)}),(0,K.jsx)(Ae,{label:n.label,description:n.bin})]},n.bin))]})}var Kk=`font-medium text-foreground`;function qk({projectId:e,open:t,onOpenChange:n,onRemoved:r}){let[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),{busy:c,error:l,run:u,reset:d}=en();(0,G.useEffect)(()=>{t&&(a(!1),d())},[t,d]);let f=()=>{n(!1),queueMicrotask(r)};return(0,K.jsx)(ot,{open:t,onOpenChange:e=>{c||o||n(e)},children:(0,K.jsxs)(Ie,{children:[(0,K.jsx)(j,{className:`fixed inset-0 z-50 bg-black/40 backdrop-blur-[1px]`}),(0,K.jsx)(P,{className:`fixed left-1/2 top-1/2 z-50 max-h-[calc(100vh-2rem)] w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-lg border border-border bg-card p-5 text-card-foreground shadow-lg`,children:o?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(hn,{className:`text-sm font-semibold`,children:`Project removed`}),(0,K.jsx)(Ne,{className:`mt-2 text-xs leading-relaxed text-muted-foreground`,children:`It left the dashboard’s list. This is what happened to OpenAgent’s files in the folder.`}),(0,K.jsx)(Jk,{title:`Deleted`,empty:`Nothing: there was nothing of OpenAgent’s to delete.`,lines:o.removed}),o.kept.length>0&&(0,K.jsx)(Jk,{title:`Kept`,lines:o.kept.map(e=>`${e.path}: ${e.reason}`)}),o.failed.length>0&&(0,K.jsx)(Jk,{title:`Could not be cleaned`,lines:o.failed,danger:!0}),(0,K.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,K.jsx)(V,{size:`sm`,onClick:f,children:`Done`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(hn,{className:`text-sm font-semibold`,children:`Remove this project?`}),(0,K.jsxs)(Ne,{className:`mt-2 text-xs leading-relaxed text-muted-foreground`,children:[`It leaves the dashboard’s list, and its scheduler stops unless you set it to keep running.`,` `,i?(0,K.jsx)(K.Fragment,{children:`Your files and your commits stay.`}):(0,K.jsxs)(K.Fragment,{children:[`Nothing in the folder is deleted: your files and your commits stay, and so do OpenAgent’s own files there (`,(0,K.jsx)(`span`,{className:Kk,children:`.openagent`}),`, `,(0,K.jsx)(`span`,{className:Kk,children:`.branches`}),`,`,` `,(0,K.jsx)(`span`,{className:Kk,children:`.agent-runner`}),` and the branch `,(0,K.jsx)(`span`,{className:Kk,children:`agent-data`}),` with the agents’ records).`]}),` `,`Add the folder again to bring the project back.`]}),(0,K.jsxs)(`label`,{className:`mt-3 flex cursor-pointer items-start gap-2 text-xs text-foreground`,children:[(0,K.jsx)(Nt,{checked:i,onCheckedChange:e=>a(e===!0),disabled:c,className:`mt-0.5`}),(0,K.jsx)(`span`,{children:`Also delete OpenAgent’s files in this folder`})]}),i&&(0,K.jsxs)(`div`,{className:`mt-2 rounded-md border border-border p-3 text-xs leading-relaxed text-muted-foreground`,children:[(0,K.jsxs)(`p`,{children:[`This deletes, on this machine: the agents’ checkouts in `,(0,K.jsx)(`span`,{className:Kk,children:`.branches`}),`, the folders`,` `,(0,K.jsx)(`span`,{className:Kk,children:`.openagent`}),` (with `,(0,K.jsx)(`span`,{className:Kk,children:`hooks.yml`}),`, the project’s start lines) and`,` `,(0,K.jsx)(`span`,{className:Kk,children:`.agent-runner`}),`, and the local branch `,(0,K.jsx)(`span`,{className:Kk,children:`agent-data`}),`. A tool that worked in the project removes its own files too: the scheduler’s state, the subagent settings.`]}),(0,K.jsxs)(`p`,{className:`mt-2`,children:[(0,K.jsx)(`span`,{className:Kk,children:`The agents’ conversations go with that branch.`}),` If you never shared the records, this is their only copy. If you did, what has not reached the remote yet is lost. An agent that waits for your answer cannot be continued after this.`]}),(0,K.jsxs)(`p`,{className:`mt-2`,children:[`It never touches the remote, your files, your commits, a branch with work on it, or a file git tracks. A checkout with uncommitted work stays, and so does `,(0,K.jsx)(`span`,{className:Kk,children:`.agent-runner/config.yml`}),` if you wrote one. A scheduler you set to keep running is not stopped: its files, the records and `,(0,K.jsx)(`span`,{className:Kk,children:`.openagent`}),` then stay. Stop it, add the folder again and remove it once more to delete them. You see the list of what went and what stayed right after.`]})]}),l&&(0,K.jsx)(`p`,{className:`mt-2 text-xs text-danger`,children:l}),(0,K.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,K.jsx)(Re,{render:(0,K.jsx)(V,{variant:`outline`,size:`sm`,disabled:c,children:`Cancel`})}),(0,K.jsx)(V,{variant:`destructive`,size:`sm`,disabled:c,onClick:()=>{u(()=>ai(e,i),`Could not remove the project.`).then(e=>{if(!e.ok)return;let t=e.value.cleanup;t?s(t):f()})},className:B(c&&`cursor-progress`),children:c?`Removing…`:i?`Remove and delete`:`Remove`})]})]})})]})})}function Jk({title:e,lines:t,empty:n,danger:r=!1}){return(0,K.jsxs)(`div`,{className:`mt-3 text-xs`,children:[(0,K.jsx)(`p`,{className:B(`font-medium`,r?`text-danger`:`text-foreground`),children:e}),t.length===0?(0,K.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:n}):(0,K.jsx)(`ul`,{className:`mt-1 space-y-0.5 text-muted-foreground`,children:t.map(e=>(0,K.jsx)(`li`,{className:`break-words`,children:e},e))})]})}function Yk({projectId:e,agentId:t,events:n,label:r,retainedWorktree:i=!1,onWorktreeRemoved:a,onDeleted:o,onProjectRemoved:s,details:c,size:l}){let u=!!t,d=Fk(n),f=On(n),p=Vk(f),m=d||i,h=Hk(f),[g,_]=(0,G.useState)(!1),v=(0,G.useRef)(void 0);(0,G.useEffect)(()=>()=>clearTimeout(v.current),[]);let y=()=>{h&&navigator.clipboard?.writeText(h).then(()=>{_(!0),clearTimeout(v.current),v.current=setTimeout(()=>_(!1),1500)})},[b,x]=(0,G.useState)(0),S=we(()=>jr(e),null,[e,b],`previous`),C=we(u?null:()=>Mr(e),null,[e,u,b]),[w,T]=(0,G.useState)(!1),[E,D]=(0,G.useState)(0),O=we(u?null:()=>oi(e),null,[e,u,b,E],`previous`),[k,A]=(0,G.useState)(!1),[j,M]=(0,G.useState)(!1),P=()=>void ne(()=>si(e,!1),`Could not stop sharing.`).then(e=>{e.ok&&D(e=>e+1)}),{busy:ee,error:te,run:ne}=en(),[ie,ae]=(0,G.useState)(!1);(0,G.useEffect)(()=>ae(!1),[t]);let F=ee||ie&&d,[I,oe]=(0,G.useState)(!1),se=n=>ne(()=>Yr(e,n,t??void 0),`Failed to open.`),ce=()=>void ne(()=>Br(e,t??void 0),`Could not stop the session.`).then(e=>{e.ok&&ae(!0)}),le=()=>{t&&ne(()=>Kr(e,t),`Could not remove the worktree.`).then(e=>{e.ok&&a?.()})},ue=r?.trim()||t,de=u?`Session actions`:`Project actions`,fe=i&&!d&&!!t,pe=!!o&&!d&&!!t,me=S&&(0,K.jsxs)(L,{render:(0,K.jsx)(`a`,{href:S.url,target:`_blank`,rel:`noreferrer`}),children:[(0,K.jsx)(ca,{className:`h-3.5 w-3.5 shrink-0`}),` Open on `,S.name]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(re,{children:[u?(0,K.jsxs)(bt,{type:`button`,"aria-label":de,title:r,className:`flex min-w-0 items-center gap-1 rounded px-1 py-0.5 text-left text-xs hover:bg-muted data-[popup-open]:bg-muted`,children:[r?(0,K.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:r}):(0,K.jsx)(`span`,{"data-testid":`title-placeholder`,className:`h-3 w-40 max-w-full rounded bg-muted`}),(0,K.jsx)(Fe,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}):(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(bt,{type:`button`,"aria-label":de,className:_t({variant:`outline`,size:`icon-sm`})}),children:(0,K.jsx)(sa,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(z,{children:de})]}),(0,K.jsxs)(Be,{align:u?`start`:`end`,className:`min-w-[14rem]`,children:[c&&(0,K.jsxs)(L,{onClick:c.onToggle,children:[(0,K.jsx)(wa,{className:`h-3.5 w-3.5 shrink-0`}),` `,c.open?`Hide details`:`Show details`]}),!u&&me,C&&(0,K.jsxs)(L,{onClick:()=>T(!0),children:[(0,K.jsx)(ia,{className:`h-3.5 w-3.5 shrink-0`}),` Create a repository on `,C.name,`…`]}),O===`kept`&&(0,K.jsxs)(L,{onClick:()=>A(!0),children:[(0,K.jsx)(ia,{className:`h-3.5 w-3.5 shrink-0`}),` Share the agents’ records to the remote…`]}),O===`origin`&&(0,K.jsxs)(L,{disabled:ee,onClick:P,children:[(0,K.jsx)(ra,{className:`h-3.5 w-3.5 shrink-0`}),` Stop sharing the agents’ records`]}),(0,K.jsxs)(L,{disabled:ee,onClick:()=>void se(`files`),title:t&&!m?`This session no longer has its own checkout`:void 0,children:[(0,K.jsx)(da,{className:`h-3.5 w-3.5 shrink-0`}),` `,t?m?`Open session's folder`:`Open project folder`:`Open folder`]}),(0,K.jsxs)(Zt,{children:[(0,K.jsxs)(Kt,{disabled:ee,children:[(0,K.jsx)(oa,{className:`h-3.5 w-3.5 shrink-0`}),` Open in editor`]}),(0,K.jsxs)(It,{className:`min-w-[15rem]`,children:[(0,K.jsxs)(L,{disabled:ee,onClick:()=>void se(`editor`),children:[(0,K.jsx)(oa,{className:`h-3.5 w-3.5 shrink-0`}),` `,t?`Open this session's checkout`:`Open in your editor`]}),(0,K.jsx)(st,{}),(0,K.jsx)(Gk,{busy:ee})]})]}),u&&me,p&&(0,K.jsxs)(L,{render:(0,K.jsx)(`a`,{href:p.href,target:`_blank`,rel:`noreferrer`}),children:[(0,K.jsx)(ca,{className:`h-3.5 w-3.5 shrink-0`}),` `,p.label.replace(` ↗`,``)]}),h&&f?.sessionId&&(0,K.jsxs)(L,{closeOnClick:!1,onClick:y,title:h,children:[g?(0,K.jsx)(N,{className:`h-3.5 w-3.5 shrink-0 text-success`}):(0,K.jsx)(mn,{className:`h-3.5 w-3.5 shrink-0`}),(0,K.jsx)(`span`,{className:`flex-1`,children:g?`Copied`:f.workspace?`Copy resume command`:`Copy session id`}),(0,K.jsx)(`span`,{className:`ml-auto pl-3 font-mono text-[10px] text-muted-foreground`,children:f.sessionId.slice(0,8)})]}),(d||fe||pe)&&(0,K.jsx)(st,{}),d&&(0,K.jsxs)(L,{disabled:F,onClick:()=>void ce(),children:[(0,K.jsx)(Va,{className:`h-3 w-3 shrink-0 fill-current`}),` `,F?`Stopping…`:`Stop agent`]}),fe&&(0,K.jsxs)(L,{disabled:ee,onClick:()=>le(),children:[(0,K.jsx)(pa,{className:`h-3.5 w-3.5 shrink-0`}),` `,(0,K.jsx)(`span`,{className:`flex-1`,children:`Remove worktree`}),l&&(0,K.jsx)(`span`,{className:`ml-auto pl-3 text-[10px] text-muted-foreground`,children:l})]}),pe&&(0,K.jsxs)(L,{onClick:()=>oe(!0),className:`text-danger`,children:[(0,K.jsx)(Ua,{className:`h-3.5 w-3.5 shrink-0`}),` Delete session`]}),s&&!u&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(st,{}),(0,K.jsxs)(L,{onClick:()=>M(!0),className:`text-danger`,children:[(0,K.jsx)(Ua,{className:`h-3.5 w-3.5 shrink-0`}),` Remove project…`]})]}),te&&(0,K.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-danger`,children:te})]})]}),C&&(0,K.jsx)(tn,{open:w,onOpenChange:T,title:`Create a private repository on ${C.name}?`,body:(0,K.jsxs)(K.Fragment,{children:[`This creates the private repository `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:C.repository}),` on your`,` `,C.name,` account and pushes this project to it. The project’s code leaves this machine.`]}),confirmLabel:`Create and push`,confirmBusyLabel:`Creating…`,fallbackError:`Could not create the repository.`,destructive:!1,onConfirm:()=>ei(e),onSuccess:()=>x(e=>e+1)}),O===`kept`&&(0,K.jsx)(tn,{open:k,onOpenChange:A,title:`Share the agents’ records to the remote?`,body:(0,K.jsxs)(K.Fragment,{children:[`This pushes a branch `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:`agent-data`}),` to this project’s remote, and keeps pushing as agents work. It holds what you asked each agent and what it answered, under your git email. Everyone who can read the remote can read it.`]}),confirmLabel:`Share`,confirmBusyLabel:`Sharing…`,fallbackError:`Could not share the records.`,destructive:!1,onConfirm:()=>si(e,!0),onSuccess:()=>D(e=>e+1)}),s&&!u&&(0,K.jsx)(qk,{projectId:e,open:j,onOpenChange:M,onRemoved:s}),o&&t&&(0,K.jsx)(tn,{open:I,onOpenChange:oe,title:`Delete this agent?`,body:(0,K.jsxs)(K.Fragment,{children:[`Deleting `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:ue}),` removes it from the dashboard for good — its history can’t be recovered. Its branch and any pull request stay in git.`]}),confirmLabel:`Delete`,confirmBusyLabel:`Deleting…`,fallbackError:`Could not delete the agent.`,onConfirm:()=>qr(e,t),onSuccess:o})]})}function Xk({docs:e,loaded:t}){let[n,r]=(0,G.useState)(0);if(!t)return(0,K.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading…`});if(e.length===0)return(0,K.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`No PLAN/TODO docs yet.`});let i=e[Math.min(n,e.length-1)];return(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-auto flex-col`,children:[(0,K.jsx)(`div`,{className:`flex flex-wrap gap-1 border-b border-border p-2`,children:e.map((e,t)=>(0,K.jsx)(V,{variant:`ghost`,size:`sm`,className:B(`h-7 text-xs`,t===n&&`bg-accent text-accent-foreground`),onClick:()=>r(t),children:e.name},e.name))}),(0,K.jsx)(Ye,{className:`min-h-0 flex-auto`,children:(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsx)(Wt,{text:i.content})})})]})}var Zk=class extends G.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e.message:String(e)}}render(){return this.state.error===null?this.props.children:(0,K.jsxs)(`div`,{role:`alert`,className:`p-6 text-sm text-danger`,children:[`The `,this.props.label,` failed: `,this.state.error]})}};function Qk({package:e,label:t,children:n}){let r=Ze(e);return(0,K.jsx)(Xt.Provider,{value:r,children:(0,K.jsx)(Zk,{label:t,children:n})})}function $k(e,t){return e.flatMap(e=>{let n=t.find(t=>t.id===e);return n?[{id:n.id,name:n.name,gitHost:n.gitHost}]:[]})}function eA({page:e,projects:t,projectId:n,path:r}){let i=e.Page;return(0,K.jsx)(Qk,{package:e.package,label:`${e.label} page`,children:(0,K.jsx)(i,{projects:$k(e.projects,t),projectId:n,path:r})},e.segment)}function tA(e){let t=(0,G.useId)();return`${e??t}`}var nA=typeof window<`u`?G.useLayoutEffect:G.useEffect;function rA(e){let t=(0,G.useRef)(e);return nA(()=>{t.current=e},[e]),(0,G.useCallback)((...e)=>t.current?.(...e),[t])}function iA(...e){return rA(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function aA(e,t){return t?e*2+1:e+1}function oA(e,t){return t?e*2-1:e}function sA(e,t,n){let r=aA(e,n);return t===void 0?`${r} / -1`:`${r} / span ${oA(t,n)}`}function cA(e){return`${e*2} / span 1`}function lA({crossCount:e,crossSpan:t,crossStart:n,hasGutters:r}){let i=t===void 0?e:n+t;if(n===0&&i===e)return`1 / -1`;let a=aA(n,r),o=aA(i-1,r)+1;return r&&(n>0&&a--,i<e&&o++),`${a} / ${o}`}function uA(e,t){return Number.isInteger(e)&&e>=1&&e<t}function dA(e,t=`Assertion error`){if(!e)throw Error(t)}var fA=(0,G.createContext)(null);function pA(){let e=(0,G.useContext)(fA);return dA(e,`Grid Context not found; did you render a Cell or Gridline outside of a Grid?`),e}function mA({children:e,className:t,column:n,columnSpan:r=1,elementRef:i,id:a,row:o,rowSpan:s=1,style:c,...l}){let u=tA(a),{gutters:d,registerCell:f}=pA(),p=(0,G.useRef)(null),m=iA(p,i);return nA(()=>{let e=p.current;if(e!==null)return f({column:n,columnSpan:r,element:e,id:u,row:o,rowSpan:s})},[n,r,u,f,o,s]),(0,K.jsx)(`div`,{...l,className:t,"data-cell":!0,"data-testid":u,id:u,ref:m,style:{overflow:`auto`,...c,minHeight:0,minWidth:0,gridColumn:sA(n,r,d.column),gridRow:sA(o,s,d.row)},children:e})}mA.displayName=`Cell`;var hA;function gA(){return hA===void 0&&(hA=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),hA}function _A({expandHitTargets:e,axis:t,rect:n}){let r=e?gA()?t.resizeTargetMinimumSize.coarse:t.resizeTargetMinimumSize.fine:0;if(n.width<r){let e=r-n.width;n=new DOMRect(n.x-e/2,n.y,n.width+e,n.height)}if(n.height<r){let e=r-n.height;n=new DOMRect(n.x,n.y-e/2,n.width,n.height+e)}return n}function vA({axis:e,cells:t,index:n,rect:r}){let i=[r];for(let r of t){let t=e===`column`?r.column:r.row,a=e===`column`?r.columnSpan:r.rowSpan;if(t>=n||t+a<=n)continue;let o=r.element.getBoundingClientRect(),s=e===`column`?o.top:o.left,c=e===`column`?o.bottom:o.right;c<=s||(i=i.flatMap(t=>{let n=e===`column`?t.top:t.left,r=e===`column`?t.bottom:t.right;if(s>=r||c<=n)return[t];let i=[],a=(n,r)=>{i.push(e===`column`?new DOMRect(t.x,n,t.width,r-n):new DOMRect(n,t.y,r-n,t.height))};return n<s&&a(n,s),r>c&&a(c,r),i}))}return i}function yA({axis:e,cells:t,crossTrackCount:n,expandHitTargets:r,resizeAxis:i,axisSize:a,includeDisabled:o,separatorPlacements:s}){let{items:c,separators:l}=i,u=c.length,d=-1,f=-1,p=0;if(c.forEach((e,t)=>{e.constraintProps.disabled||(p++,d===-1&&(d=t),f=t)}),!o&&p<2)return[];let m=e=>o||e>d&&e<=f,h=[],g=(e,t,n)=>({axis:i,axisSize:a,items:[c[e-1],c[e]],rect:t,separator:n}),_=(n,r)=>{let i;for(let a of t){let t=e===`column`?a.row:a.column,o=e===`column`?a.rowSpan:a.columnSpan;if(r===`start`?t===n:t+o-1===n){let t=a.element.getBoundingClientRect();if(r===`start`){let n=e===`column`?t.top:t.left;i=i===void 0?n:Math.min(i,n)}else{let n=e===`column`?t.bottom:t.right;i=i===void 0?n:Math.max(i,n)}}}return i},v=new Set;for(let a of l){let c=s.get(a);if(!c||c.index<1||c.index>=u||(v.add(c.index),!o&&(a.disabled||a.element.hasAttribute(`aria-disabled`)))||!m(c.index))continue;let l=a.element.getBoundingClientRect(),{crossSpan:d,crossStart:f}=c,p=d===void 0?n:f+d,y=e===`column`?l.top:l.left,b=e===`column`?l.bottom:l.right;if(f>0){let e=_(f-1,`end`);e!==void 0&&e<y&&(y=e)}if(p<n){let e=_(p,`start`);e!==void 0&&e>b&&(b=e)}l=e===`column`?new DOMRect(l.x,y,l.width,b-y):new DOMRect(y,l.y,b-y,l.height),l=_A({expandHitTargets:r,axis:i,rect:l}),o?h.push(g(c.index,l,a)):vA({axis:e,cells:t,index:c.index,rect:l}).forEach(e=>{h.push(g(c.index,e,a))})}let y=(n,a)=>{vA({axis:e,cells:t,index:n,rect:_A({expandHitTargets:r,axis:i,rect:a})}).forEach(e=>{h.push(g(n,e))})},b=Array.from({length:n},()=>Array(u));for(let r of t){let[t,i,a,o]=e===`column`?[r.column,r.columnSpan,r.row,r.rowSpan]:[r.row,r.rowSpan,r.column,r.columnSpan];for(let e=Math.max(0,a);e<Math.min(n,a+o);e++)for(let n=Math.max(0,t);n<Math.min(u,t+i);n++)b[e][n]??=r}let x=new Map,S=t=>{let n=x.get(t);if(!n){let r=t.element.getBoundingClientRect();n=e===`column`?{crossEnd:r.bottom,crossStart:r.top,end:r.right,start:r.left}:{crossEnd:r.right,crossStart:r.left,end:r.bottom,start:r.top},x.set(t,n)}return n},C=({crossEnd:t,crossStart:n,end:r,start:i})=>e===`column`?new DOMRect(i,n,r-i,t-n):new DOMRect(n,i,t-n,r-i);for(let e=1;e<u;e++){if(v.has(e)||!m(e))continue;let t;for(let r=0;r<n;r++){let n=b[r][e-1],i=b[r][e],a;if((n||i)&&n!==i){let e=n?S(n):void 0,t=i?S(i):void 0,r=e?.end??t.start,o=t?.start??e.end,s=Math.max(e?.crossStart??-1/0,t?.crossStart??-1/0),c=Math.min(e?.crossEnd??1/0,t?.crossEnd??1/0);a={crossEnd:Math.max(s,c),crossStart:s,end:Math.max(r,o),start:Math.min(r,o)}}a?t=t?{crossEnd:Math.max(t.crossEnd,a.crossEnd),crossStart:Math.min(t.crossStart,a.crossStart),end:Math.max(t.end,a.end),start:Math.min(t.start,a.start)}:a:t&&=(y(e,C(t)),void 0)}t&&y(e,C(t))}return h}function bA(e){let t=parseFloat(e??``);return Number.isFinite(t)?t:0}function xA({axis:e,element:t,gutterSizes:n,hasGutters:r,layout:i,trackIds:a}){let o=a.length,s=r?o*2-1:o,c=t.ownerDocument.defaultView?.getComputedStyle(t),l=e===`column`?c?.gridTemplateColumns:c?.gridTemplateRows;if(l){let e=l.trim().split(/\s+/);if(e.length===s&&e.every(e=>/^-?[\d.]+px$/.test(e))){let t=a.map((t,n)=>bA(e[r?n*2:n]));return{availableSize:t.reduce((e,t)=>e+t,0),trackSizes:t}}}let u=e===`column`?t.offsetWidth:t.offsetHeight,d=e===`column`?bA(c?.paddingLeft)+bA(c?.paddingRight)+bA(c?.borderLeftWidth)+bA(c?.borderRightWidth):bA(c?.paddingTop)+bA(c?.paddingBottom)+bA(c?.borderTopWidth)+bA(c?.borderBottomWidth),f=bA(e===`column`?c?.columnGap:c?.rowGap),p=n.reduce((e,t)=>e+t,0),m=Math.max(0,u-d-f*Math.max(0,s-1)-p);return{availableSize:m,trackSizes:a.map(e=>i&&i[e]!==void 0?i[e]/100*m:m/o)}}function SA(e){switch(typeof e){case`number`:return[e,`px`];case`string`:{let t=parseFloat(e);return e.endsWith(`%`)?[t,`%`]:e.endsWith(`px`)?[t,`px`]:e.endsWith(`rem`)?[t,`rem`]:e.endsWith(`em`)?[t,`em`]:e.endsWith(`vh`)?[t,`vh`]:e.endsWith(`vw`)?[t,`vw`]:[t,`%`]}}}var CA=class{#e={};addListener(e,t){let n=this.#e[e];return n===void 0?this.#e[e]=[t]:n.includes(t)||n.push(t),()=>{this.removeListener(e,t)}}emit(e,t){let n=this.#e[e];if(n!==void 0)if(n.length===1)n[0].call(null,t);else{let e=!1,r=null,i=Array.from(n);for(let n=0;n<i.length;n++){let a=i[n];try{a.call(null,t)}catch(t){r===null&&(e=!0,r=t)}}if(e)throw r}}removeAllListeners(){this.#e={}}removeListener(e,t){let n=this.#e[e];if(n!==void 0){let e=n.indexOf(t);e>=0&&n.splice(e,1)}}},wA={cursorFlags:0,state:`inactive`},TA=new CA;function EA(){return wA}function DA(e){return TA.addListener(`change`,e)}function OA(e,t=[],n,r=!1){let i=wA,a={...wA};a.cursorFlags=e,a.state===`active`&&(a.didPointerMove||=r,a.previews=t,n&&(a.previewLayoutMap=n)),wA=a,TA.emit(`change`,{prev:i,next:a})}function kA(e){let t=wA;wA=e,t.state===`active`&&e.state!==`active`&&t.didPointerMove&&t.hitRegions.forEach(({separator:e})=>{e&&e.element.ownerDocument.activeElement===e.element&&e.element.blur()}),TA.emit(`change`,{prev:t,next:e})}function AA(e){wA.state!==`active`||!wA.previews.some(t=>t.separator===e)||kA({...wA,previews:wA.previews.map(t=>t.separator===e?{...t}:t)})}function jA(e){if(wA.state===`inactive`)return!1;let t=wA.hitRegions.filter(t=>t.axis!==e),n=wA.state===`active`&&wA.previews.some(t=>t.axis===e);if(t.length===wA.hitRegions.length&&!n)return!1;if(t.length===0)kA({cursorFlags:0,state:`inactive`});else if(wA.state===`active`){let n=new Map(wA.initialLayoutMap),r=new Map(wA.previewLayoutMap);n.delete(e),r.delete(e),kA({...wA,cursorFlags:0,hitRegions:t,initialLayoutMap:n,previewLayoutMap:r,previews:wA.previews.filter(t=>t.axis!==e)})}else kA({...wA,hitRegions:t});return!0}var MA=e=>e,NA=()=>{},PA=1,FA=2,IA=4,LA=8,RA=3,zA=12,BA;function VA(){return BA===void 0&&(BA=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(BA=!0)),BA}function HA({cursorFlags:e,axes:t,state:n}){let r=0,i=0;switch(n){case`active`:case`hover`:t.forEach(e=>{if(!e.mutableState.disableCursor)switch(e.orientation){case`horizontal`:r++;break;case`vertical`:i++;break}})}if(!(r===0&&i===0)){switch(n){case`active`:if(e&&VA()){let t=(e&PA)!==0,n=(e&FA)!==0,r=(e&IA)!==0,i=(e&LA)!==0;if(t)return r?`se-resize`:i?`ne-resize`:`e-resize`;if(n)return r?`sw-resize`:i?`nw-resize`:`w-resize`;if(r)return`s-resize`;if(i)return`n-resize`}break}return VA()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var UA=new WeakMap;function WA(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=UA.get(e)??{};n===void 0&&(n=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&(Object.isExtensible(e.adoptedStyleSheets)?e.adoptedStyleSheets.push(n):e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));let r=EA();switch(r.state){case`active`:case`hover`:{let e=HA({cursorFlags:r.cursorFlags,axes:r.hitRegions.map(e=>e.axis),state:r.state}),i=`*, *:hover {cursor: ${e} !important; }`;if(t===i)return;t=i,e?n.cssRules.length===0?n.insertRule(i):n.replaceSync(i):n.cssRules.length===1&&n.deleteRule(0);break}case`inactive`:t=void 0,n.cssRules.length===1&&n.deleteRule(0);break}UA.set(e,{prevStyle:t,styleSheet:n})}function GA({axis:e}){let{layoutStrategy:t,orientation:n,items:r}=e;return t?t.calculateAvailableSize():r.reduce((e,t)=>(e+=n===`horizontal`?t.element.offsetWidth:t.element.offsetHeight,e),0)}function KA(e,t){let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_DISCONNECTED?0:n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}function qA(e,t){return Array.from(t).sort((t,n)=>{let r=e===`horizontal`?JA(t,n):YA(t,n);return r===0?KA(t.element,n.element):r})}function JA(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function YA(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function XA(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function ZA(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function QA({orientation:e,rects:t,targetRect:n}){let r={x:n.x+n.width/2,y:n.y+n.height/2},i,a=Number.MAX_VALUE;for(let n of t){let{x:t,y:o}=ZA(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return dA(i,`No rect found`),i}function $A({expandHitTargets:e=!0,axis:t,includeDisabled:n=!1}){if(t.layoutStrategy)return t.layoutStrategy.calculateHitRegions({expandHitTargets:e,axis:t,includeDisabled:n});let{element:r,orientation:i,items:a,separators:o}=t,s=qA(i,Array.from(r.children).filter(XA).filter(e=>!e.hasAttribute(`data-resize-preview`)).map(e=>({element:e}))).map(({element:e})=>e),c=[],l=!1,u=!1,d=-1,f,p=-1,m=0,h,g=[];{let e=-1;for(let t of s)t.hasAttribute(`data-panel`)&&(e++,t.hasAttribute(`data-disabled`)||(m++,d===-1&&(d=e),p=e))}if(n||m>1){let r=-1;for(let m of s)if(m.hasAttribute(`data-panel`)){r++;let o=a.find(e=>e.element===m);if(o){if(h){let a=h.element.getBoundingClientRect(),s=m.getBoundingClientRect(),_;if(u){let e=i===`horizontal`?new DOMRect(a.right,a.top,0,a.height):new DOMRect(a.left,a.bottom,a.width,0),t=i===`horizontal`?new DOMRect(s.left,s.top,0,s.height):new DOMRect(s.left,s.top,s.width,0);switch(g.length){case 0:_=[e,t];break;case 1:{let n=g[0];_=[n,QA({orientation:i,rects:[a,s],targetRect:n.element.getBoundingClientRect()})===a?t:e];break}default:_=g;break}}else _=g.length?g:[i===`horizontal`?new DOMRect(a.right,s.top,s.left-a.right,s.height):new DOMRect(s.left,a.bottom,s.width,s.top-a.bottom)];for(let i of _){let a=_A({expandHitTargets:e,axis:t,rect:`width`in i?i:i.element.getBoundingClientRect()});(n||!l&&!(r<=d||r>p))&&(f??=GA({axis:t}),c.push({axis:t,axisSize:f,items:[h,o],separator:`width`in i?void 0:i,rect:a})),l=!1}}u=!1,h=o,g=[]}}else if(m.hasAttribute(`data-separator`)){m.ariaDisabled!==null&&(l=!0);let e=o.find(e=>e.element===m);e?g.push(e):(h=void 0,g=[])}else u=!0}return c}function ej(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function tj(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function nj(e){return e/100*window.innerHeight}function rj(e){return e/100*window.innerWidth}function ij({axisSize:e,itemElement:t,styleProp:n}){let r,[i,a]=SA(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=tj(t,i);break;case`em`:r=ej(t,i);break;case`vh`:r=nj(i);break;case`vw`:r=rj(i);break}return r}function aj(e){return parseFloat(e.toFixed(3))}function oj(e){let{items:t}=e,n=GA({axis:e});return n===0?t.map(e=>({groupResizeBehavior:e.constraintProps.groupResizeBehavior,collapsedSize:0,collapsible:e.constraintProps.collapsible===!0,defaultSize:void 0,disabled:e.constraintProps.disabled,minSize:0,maxSize:100,itemId:e.id})):t.map(e=>{let{element:t,constraintProps:r}=e,i=0;r.collapsedSize!==void 0&&(i=aj(ij({axisSize:n,itemElement:t,styleProp:r.collapsedSize})/n*100));let a;r.collapsedThreshold!==void 0&&(a=aj(ij({axisSize:n,itemElement:t,styleProp:r.collapsedThreshold})/n*100));let o;r.defaultSize!==void 0&&(o=aj(ij({axisSize:n,itemElement:t,styleProp:r.defaultSize})/n*100));let s=0;r.minSize!==void 0&&(s=aj(ij({axisSize:n,itemElement:t,styleProp:r.minSize})/n*100));let c=100;return r.maxSize!==void 0&&(c=aj(ij({axisSize:n,itemElement:t,styleProp:r.maxSize})/n*100)),{groupResizeBehavior:r.groupResizeBehavior,collapsedSize:i,collapsedThreshold:a,collapsible:r.collapsible===!0,defaultSize:o,disabled:r.disabled,minSize:s,maxSize:c,itemId:e.id}})}var sj=new Map,cj=new CA;function lj(e){sj=new Map(sj),sj.delete(e)}function uj(e,t){for(let[t]of sj)if(t.id===e)return t}function dj(e,t){for(let[t,n]of sj)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function fj(){return sj}function pj(e,t){return cj.addListener(`axisChange`,n=>{n.axis.id===e&&t(n)})}function mj(e,t,n){let r=sj.get(e);sj=new Map(sj),sj.set(e,t),cj.emit(`axisChange`,{axis:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function hj(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function gj(e,t,n=0){return Math.abs(aj(e)-aj(t))<=n}function _j(e,t){return gj(e,t)?0:e>t?1:-1}function vj({overrideDisabledItems:e,itemConstraints:t,prevSize:n,size:r}){let{collapsedSize:i=0,collapsedThreshold:a,collapsible:o,disabled:s,maxSize:c=100,minSize:l=0}=t;if(s&&!e)return n;if(_j(r,l)<0)if(o){let e=a??(l-i)/2,t=_j(n,i)<=0,o=t?i+e:l-e,s=_j(r,o);r=_j(r,i)<=0||s<0||a!==void 0&&t&&s===0?i:l}else r=l;return r=Math.min(c,r),r=aj(r),r}function yj({delta:e,initialLayout:t,itemConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(gj(e,0))return t;let o=a===`imperative-api`,s=n.map(({itemId:e})=>t[e]),c=n.map(({itemId:e})=>i[e]),l=[...s],[u,d]=r;dA(u!=null,`Invalid first pivot index`),dA(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];dA(r,`Panel constraints not found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(dA(n!=null,`Previous layout not found for panel index ${t}`),gj(n,i)){let t=o-n;_j(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];dA(r,`No panel constraints found for index ${t}`);let{collapsedSize:i=0,collapsible:a,minSize:o=0}=r;if(a){let n=s[t];if(dA(n!=null,`Previous layout not found for panel index ${t}`),gj(n,o)){let t=n-i;_j(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];dA(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsedSize:a,collapsedThreshold:o,collapsible:c,minSize:l}=r;if(c&&_j(i,l)<0){let t=l-a,n=o??t/2;if(_j(i+Math.abs(e),l)<0){let r=_j(Math.abs(e),n);e=r>0||r===0&&o===void 0&&e<0?e<0?-t:t:0}}break}}{let t=e<0?1:-1,r=e<0?d:u,i=0;for(;;){let e=s[r];dA(e!=null,`Previous layout not found for panel index ${r}`);let a=vj({overrideDisabledItems:o,itemConstraints:n[r],prevSize:e,size:100})-e;if(i+=a,r+=t,r<0||r>=n.length)break}let a=Math.min(Math.abs(e),Math.abs(i));e=e<0?0-a:a}{let t=e<0?u:d;for(;t>=0&&t<n.length;){let r=Math.abs(e)-Math.abs(f),i=s[t];dA(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=vj({overrideDisabledItems:o,itemConstraints:n[t],prevSize:i,size:a});if(!gj(i,c)&&(f+=i-c,l[t]=c,f.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?t--:t++}}if(hj(c,l))return i;{let t=e<0?d:u,r=s[t];dA(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=vj({overrideDisabledItems:o,itemConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!gj(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];dA(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=vj({overrideDisabledItems:o,itemConstraints:n[r],prevSize:i,size:a});if(gj(i,s)||(t-=s-i,l[r]=s),gj(t,0))break;e>0?r--:r++}}}return gj(Object.values(l).reduce((e,t)=>t+e,0),100,.1)?l.reduce((e,t,r)=>(e[n[r].itemId]=t,e),{}):i}function bj(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||_j(e[n],t[n])!==0)return!1;return!0}function xj({commit:e,document:t,event:n,hitRegions:r,initialLayoutMap:i,mountedAxes:a,pointerDownAtPoint:o,prevCursorFlags:s}){let c=0,l=EA(),u=l.state===`active`?l.previews:[],d=new Map(l.state===`active`?l.previewLayoutMap:void 0);r.forEach(t=>{let{axis:r,axisSize:s}=t,{orientation:l,items:f}=r;if(e&&r.resizePreviewMode!==`separator`)return;let{disableCursor:p}=r.mutableState,m=0;m=o?l===`horizontal`?(n.clientX-o.x)/s*100:(n.clientY-o.y)/s*100:l===`horizontal`?n.clientX<0?-100:100:n.clientY<0?-100:100;let h=i.get(r),g=a.get(r);if(!h||!g)return;let{defaultLayoutDeferred:_,derivedItemConstraints:v,axisSize:y,layout:b,separatorToItems:x}=g;if(v&&b&&x){let n=r.resizePreviewMode===`separator`?d.get(r)??b:b,i=yj({delta:m,initialLayout:h,itemConstraints:v,pivotIndices:t.items.map(e=>f.indexOf(e)),prevLayout:n,trigger:`mouse-or-touch`});if(r.resizePreviewMode===`separator`&&!e&&!bj(i,n)){d.set(r,i);let e=0,t=f.map(t=>(e+=i[t.id]-h[t.id],s/100*e));u=u.map(e=>{if(e.axis!==r)return e;let n=t[e.itemIndex];return n===e.offset?e:{...e,offset:n}})}if(bj(i,n)&&m!==0&&!p)switch(l){case`horizontal`:c|=m<0?PA:FA;break;case`vertical`:c|=m<0?IA:LA;break}(r.resizePreviewMode!==`separator`||e)&&!bj(i,b)&&mj(t.axis,{defaultLayoutDeferred:_,derivedItemConstraints:v,axisSize:y,layout:i,requestedAxisSize:y,requestedLayout:i,separatorToItems:x})}});let f=0;n.movementX===0?f|=s&RA:f|=c&RA,n.movementY===0?f|=s&zA:f|=c&zA;let p=l.state===`active`&&(n.clientX!==l.pointerDownAtPoint.x||n.clientY!==l.pointerDownAtPoint.y);OA(f,u,d,p),WA(t)}function Sj(e,t){let n=EA(),r=fj(),i=!1;switch(n.state){case`active`:xj({commit:!0,document:e,event:t,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags}),kA({cursorFlags:0,state:`inactive`}),n.hitRegions.length>0&&(WA(e),i=!0,n.hitRegions.forEach(e=>{if(!r.has(e.axis))return;let t=dj(e.axis.id,!0);mj(e.axis,t,{isUserInteraction:!0})}))}return i}function Cj(e){e.defaultPrevented||Sj(e.currentTarget,e)}function wj(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=ZA(n,a.rect);switch(e){case`horizontal`:(t.x<i.x||t.x===i.x&&t.y<=i.y)&&(r=a,i=t);break;case`vertical`:(t.y<i.y||t.y===i.y&&t.x<=i.x)&&(r=a,i=t);break}}return r?{distance:i,hitRegion:r}:void 0}function Tj(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Ej(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:Mj(e),b:Mj(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();dA(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:jj(Aj(n.a)),b:jj(Aj(n.b))};if(i.a===i.b){let e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)},i=e.length;for(;i--;){let n=e[i];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(i.a-i.b)}var Dj=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Oj(e){let t=getComputedStyle(Nj(e)??e).display;return t===`flex`||t===`inline-flex`}function kj(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Oj(e))||+t.opacity<1||`transform`in t&&t.transform!==`none`||`webkitTransform`in t&&t.webkitTransform!==`none`||`mixBlendMode`in t&&t.mixBlendMode!==`normal`||`filter`in t&&t.filter!==`none`||`webkitFilter`in t&&t.webkitFilter!==`none`||`isolation`in t&&t.isolation===`isolate`||Dj.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Aj(e){let t=e.length;for(;t--;){let n=e[t];if(dA(n,`Missing node`),kj(n))return n}return null}function jj(e){return e&&Number(getComputedStyle(e).zIndex)||0}function Mj(e){let t=[];for(;e;)t.push(e),e=Nj(e);return t}function Nj(e){let{parentNode:t}=e;return Tj(t)?t.host:t}function Pj(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Fj(e){try{return e.matches(`:modal`)}catch{return!1}}function Ij({axisElement:e,hitRegion:t,pointerEventTarget:n}){if(XA(n)){let t=n.closest(`dialog`);if(t&&!t.contains(e)&&Fj(t))return!1}if(!XA(n)||n.contains(e)||e.contains(n))return!0;if(Ej(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(Pj(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function Lj(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=$A({axis:r}),a=wj(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Ij({axisElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function Rj({layout:e,itemConstraints:t}){let n=t.map(({itemId:t})=>e[t]),r=[...n],i=r.reduce((e,t)=>e+t,0);if(Object.keys(e).length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${Object.values(e).map(e=>`${e}%`).join(`, `)}`);if(!gj(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];dA(t!=null,`No layout data found for index ${e}`),r[e]=100/i*t}let a=0;for(let e=0;e<t.length;e++){let i=n[e];dA(i!=null,`No layout data found for index ${e}`);let o=r[e];dA(o!=null,`No layout data found for index ${e}`);let s=vj({overrideDisabledItems:!0,itemConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!gj(a,0))for(let e=0;e<t.length;e++){let n=r[e];dA(n!=null,`No layout data found for index ${e}`);let i=n+a,o=vj({overrideDisabledItems:!0,itemConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,gj(a,0)))break}return r.reduce((e,n,r)=>(e[t[r].itemId]=n,e),{})}function zj({axisId:e,itemId:t}){let n=()=>{let t=fj();for(let[n,{defaultLayoutDeferred:r,derivedItemConstraints:i,layout:a,axisSize:o,separatorToItems:s}]of t)if(n.id===e)return{defaultLayoutDeferred:r,derivedItemConstraints:i,axis:n,axisSize:o,layout:a,separatorToItems:s};throw Error(`Group ${e} not found`)},r=()=>{let e=n().derivedItemConstraints.find(e=>e.itemId===t);if(e!==void 0)return e;throw Error(`Panel constraints not found for Panel ${t}`)},i=()=>{let e=n().axis.items.find(e=>e.id===t);if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},a=()=>{let e=n().layout[t];if(e!==void 0)return e;throw Error(`Layout not found for Panel ${t}`)},o=({nextSize:e,items:n,prevLayout:r,derivedItemConstraints:i})=>{let o=a(),s=n.findIndex(e=>e.id===t),c=s===0,l=s===n.length-1;if(l&&e<o&&(c||n.slice(0,s).every((e,t)=>{let n=i[t];return n?.collapsible&&gj(n.collapsedSize,r[n.itemId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:aj(100-e)}}return yj({delta:l?o-e:e-o,initialLayout:r,itemConstraints:i,pivotIndices:l?[s-1,s]:[s,s+1],prevLayout:r,trigger:`imperative-api`})},s=e=>{if(e===a())return;let{defaultLayoutDeferred:t,derivedItemConstraints:r,axis:i,axisSize:s,layout:c,separatorToItems:l}=n(),u=Rj({layout:o({nextSize:e,items:i.items,prevLayout:c,derivedItemConstraints:r}),itemConstraints:r});bj(c,u)||mj(i,{defaultLayoutDeferred:t,derivedItemConstraints:r,axisSize:s,layout:u,requestedAxisSize:s,requestedLayout:u,separatorToItems:l})};return{collapse:()=>{let{collapsible:e,collapsedSize:t}=r(),{mutableValues:n}=i(),o=a();e&&o!==t&&(n.expandToSize=o,s(t))},expand:()=>{let{collapsible:e,collapsedSize:t,minSize:n}=r(),{mutableValues:o}=i(),c=a();if(e&&c===t){let e=o.expandToSize??n;e===0&&(e=1),s(e)}},getSize:()=>{let{axis:e}=n(),r=a(),{element:o}=i();return{asPercentage:r,inPixels:e.layoutStrategy?e.layoutStrategy.getItemSizeInPixels(t):e.orientation===`horizontal`?o.offsetWidth:o.offsetHeight}},isCollapsed:()=>{let{collapsible:e,collapsedSize:t}=r(),n=a();return e&&gj(t,n)},resize:e=>{let{axis:t}=n(),{element:r}=i(),a=GA({axis:t}),o=aj(ij({axisSize:a,itemElement:r,styleProp:e})/a*100);s(o)}}}function Bj(e){e.defaultPrevented||Lj(e,fj()).forEach(t=>{if(t.separator&&!t.separator.disableDoubleClick){let n=t.items.find(e=>e.constraintProps.defaultSize!==void 0);if(n){let r=n.constraintProps.defaultSize,i=zj({axisId:t.axis.id,itemId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function Vj(e){let t=fj();for(let[n]of t)if(n.separators.some(t=>t.element===e))return n;throw Error(`Could not find parent Group for separator element`)}function Hj({axisId:e}){let t=()=>{let t=fj();for(let[n,r]of t)if(n.id===e)return{axis:n,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){let{defaultLayoutDeferred:e,layout:n}=t();return e?{}:n},setLayout(e){let{defaultLayoutDeferred:n,derivedItemConstraints:r,axis:i,axisSize:a,layout:o,separatorToItems:s}=t(),c=Rj({layout:e,itemConstraints:r});return n?o:(bj(o,c)||mj(i,{defaultLayoutDeferred:n,derivedItemConstraints:r,axisSize:a,layout:c,requestedAxisSize:a,requestedLayout:c,separatorToItems:s}),c)}}}function Uj(e,t){let n=Vj(e),r=dj(n.id,!0),i=n.separators.find(t=>t.element===e);dA(i,`Matching separator not found`);let a=r.separatorToItems.get(i);dA(a,`Matching panels not found`);let o=a.map(e=>n.items.indexOf(e)),s=Hj({axisId:n.id}).getLayout(),c=Rj({layout:yj({delta:t,initialLayout:s,itemConstraints:r.derivedItemConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),itemConstraints:r.derivedItemConstraints});bj(s,c)||mj(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedItemConstraints:r.derivedItemConstraints,axisSize:r.axisSize,layout:c,requestedAxisSize:r.axisSize,requestedLayout:c,separatorToItems:r.separatorToItems},{isUserInteraction:!0})}function Wj(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=Vj(t);if(!(n.disabled||n.separators.find(e=>e.element===t)?.disabled))switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&Uj(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&Uj(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&Uj(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&Uj(t,-5);break;case`End`:e.preventDefault(),Uj(t,100);break;case`Enter`:{e.preventDefault();let{derivedItemConstraints:r,layout:i,separatorToItems:a}=dj(n.id,!0),o=n.separators.find(e=>e.element===t);dA(o,`Matching separator not found`);let s=a.get(o);dA(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.itemId===c.id);if(dA(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];Uj(t,(l.collapsedSize===e?n.mutableState.expandedItemSizes[c.id]??l.minSize:l.collapsedSize)-e)}break}case`F6`:{e.preventDefault();let t=n.separators.map(e=>e.element),r=Array.from(t).findIndex(t=>t===e.currentTarget);dA(r!==null,`Index not found`),t[e.shiftKey?r>0?r-1:t.length-1:r+1<t.length?r+1:0].focus({preventScroll:!0});break}case`Home`:e.preventDefault(),Uj(t,-100);break}}function Gj(e,t){let{element:n,orientation:r,items:i}=e,a=n.getBoundingClientRect(),o=r===`horizontal`;return $A({expandHitTargets:!1,axis:e,includeDisabled:!0}).map(({items:r,rect:s,separator:c},l)=>{let u=i.indexOf(r[0]),d=o?s.left+s.width/2:s.top+s.height/2;return{active:t.some(t=>{if(t.axis!==e||t.items[0]!==r[0])return!1;if(c||t.separator)return t.separator===c;let n=o?t.rect.left+t.rect.width/2:t.rect.top+t.rect.height/2;return gj(d,n)}),axis:e,key:c?`separator-${c.id}`:`panel-${r[0].id}-${l}`,offset:0,itemIndex:u,rect:new DOMRect((o&&!c?d:s.left)-a.left-n.clientLeft+n.scrollLeft,(!o&&!c?d:s.top)-a.top-n.clientTop+n.scrollTop,o&&!c?0:s.width,!o&&!c?0:s.height),separator:c}})}function Kj(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=fj(),n=Lj(e,t);if(n.length===0)return;let r=new Map,i=!1;n.forEach(e=>{e.separator&&(i||(i=!0,e.separator.element.focus({focusVisible:!1,preventScroll:!0})));let n=t.get(e.axis);n&&r.set(e.axis,n.layout)});let a=Array.from(r.keys()).flatMap(e=>e.resizePreviewMode===`separator`?Gj(e,n):[]);kA({cursorFlags:0,didPointerMove:!1,hitRegions:n,initialLayoutMap:r,pointerDownAtPoint:{x:e.clientX,y:e.clientY},previewLayoutMap:new Map(r),previews:a,state:`active`}),e.preventDefault()}function qj(e){let t=fj(),n=EA();switch(n.state){case`active`:xj({commit:!1,document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:t,prevCursorFlags:n.cursorFlags})}}function Jj(e){if(e.defaultPrevented)return;let t=EA(),n=fj();switch(t.state){case`active`:if(e.buttons===0){t.previewLayoutMap.forEach((e,t)=>{let r=n.get(t);t.resizePreviewMode===`separator`&&r&&!bj(e,r.layout)&&mj(t,{...r,layout:e,requestedAxisSize:r.axisSize,requestedLayout:e})}),kA({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{if(!n.has(e.axis))return;let t=dj(e.axis.id,!0);mj(e.axis,t,{isUserInteraction:!0})}),WA(e.currentTarget);return}for(let n of t.hitRegions)if(n.separator){let{element:t}=n.separator;t.isConnected&&!t.hasPointerCapture?.(e.pointerId)&&t.setPointerCapture?.(e.pointerId)}xj({commit:!1,document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedAxes:n,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break;default:{let r=Lj(e,n);r.length===0?t.state!==`inactive`&&kA({cursorFlags:0,state:`inactive`}):kA({cursorFlags:0,hitRegions:r,state:`hover`}),WA(e.currentTarget);break}}}function Yj(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(EA().state){case`hover`:kA({cursorFlags:0,state:`inactive`})}}function Xj(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||Sj(e.currentTarget,e)&&e.preventDefault()}function Zj(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=aj(i.defaultSize);n+=e,r[i.itemId]=e}else r[i.itemId]=void 0;let i=e.length-t;if(i!==0){let t=aj((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.itemId]=t)}return r}function Qj(e,t){let n=e.map(e=>e.id),r=Object.keys(t);if(n.length!==r.length)return!1;for(let e of n)if(!r.includes(e))return!1;return!0}function $j({axis:e,itemConstraints:t}){let n=e.items.map(({id:e})=>e).join(`,`),r=e.mutableState.defaultLayout;return e.mutableState.layouts[n]??(r&&Qj(e.items,r)?r:Zj(t))}function eM({itemIds:e,layout:t}){return Rj({layout:t,itemConstraints:e.map(e=>({collapsedSize:0,collapsible:!1,defaultSize:void 0,disabled:void 0,itemId:e,maxSize:100,minSize:0}))})}function tM(e,t,n){if(!n[0])return;let r=e.items.find(e=>e.element===t);if(!r||!r.onResize)return;let i=GA({axis:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:aj(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function nM(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(e[n]!==t[n])return!1;return!0}function rM(e,t){return e.length===t.length&&e.every((e,n)=>nM(e,t[n]))}function iM({axis:e,nextAxisSize:t,prevAxisSize:n,prevLayout:r}){if(n<=0||t<=0||n===t)return r;let i=0,a=0,o=!1,s=new Map,c=[];for(let l of e.items){let e=r[l.id]??0;switch(l.constraintProps.groupResizeBehavior){case`preserve-pixel-size`:{o=!0;let r=aj(e/100*n/t*100);s.set(l.id,r),i+=r;break}default:c.push(l.id),a+=e;break}}if(!o||c.length===0)return r;let l=100-i,u={...r};if(s.forEach((e,t)=>{u[t]=e}),a>0)for(let e of c)u[e]=aj((r[e]??0)/a*l);else{let e=aj(l/c.length);for(let t of c)u[t]=e}return u}var aM=new Map;function oM(e){let t=!0;dA(e.element.ownerDocument.defaultView,`Cannot register an unmounted Group`);let n=e.element.ownerDocument.defaultView.ResizeObserver,r=new Set,i=new Set,a=new n(n=>{for(let r of n){let{borderBoxSize:n,target:i}=r;if(i===e.element){if(t){let t=GA({axis:e});if(t===0)return;let n=dj(e.id);if(!n)return;let r=oj(e),i=n.requestedAxisSize,a=n.requestedLayout;n.defaultLayoutDeferred&&(i=t,a=eM({itemIds:e.items.map(({id:e})=>e),layout:$j({axis:e,itemConstraints:r})}));let o=Rj({layout:iM({axis:e,nextAxisSize:t,prevAxisSize:i,prevLayout:a}),itemConstraints:r});if(!n.defaultLayoutDeferred&&bj(n.layout,o)&&rM(n.derivedItemConstraints,r)&&n.axisSize===t)continue;mj(e,{defaultLayoutDeferred:!1,derivedItemConstraints:r,axisSize:t,layout:o,requestedAxisSize:i,requestedLayout:a,separatorToItems:n.separatorToItems})}}else tM(e,i,n)}});a.observe(e.element),e.items.forEach(e=>{dA(!r.has(e.id),`Panel ids must be unique; id "${e.id}" was used more than once`),r.add(e.id),e.onResize&&a.observe(e.element)});let o=GA({axis:e}),s=oj(e),c=$j({axis:e,itemConstraints:s}),l=Rj({layout:c,itemConstraints:s}),u=e.element.ownerDocument;aM.set(u,(aM.get(u)??0)+1);let d=new Map;return $A({axis:e,includeDisabled:!0}).forEach(e=>{e.separator&&d.set(e.separator,e.items)}),mj(e,{defaultLayoutDeferred:o===0,derivedItemConstraints:s,axisSize:o,layout:l,requestedAxisSize:o,requestedLayout:eM({itemIds:e.items.map(({id:e})=>e),layout:c}),separatorToItems:d}),e.separators.forEach(e=>{dA(!i.has(e.id),`Separator ids must be unique; id "${e.id}" was used more than once`),i.add(e.id),e.element.addEventListener(`keydown`,Wj)}),aM.get(u)===1&&(u.addEventListener(`contextmenu`,Cj,!0),u.addEventListener(`dblclick`,Bj,!0),u.addEventListener(`pointerdown`,Kj,!0),u.addEventListener(`pointerleave`,qj),u.addEventListener(`pointermove`,Jj),u.addEventListener(`pointerout`,Yj),u.addEventListener(`pointerup`,Xj,!0)),function(){t=!1,aM.set(u,Math.max(0,(aM.get(u)??0)-1)),lj(e),jA(e)&&WA(u),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,Wj)}),aM.get(u)||(u.removeEventListener(`contextmenu`,Cj,!0),u.removeEventListener(`dblclick`,Bj,!0),u.removeEventListener(`pointerdown`,Kj,!0),u.removeEventListener(`pointerleave`,qj),u.removeEventListener(`pointermove`,Jj),u.removeEventListener(`pointerout`,Yj),u.removeEventListener(`pointerup`,Xj,!0)),a.disconnect()}}function sM({derivedItemConstraints:e,axis:t,layout:n,prevLayout:r,requestedLayout:i}){let a=t.items.map(({id:e})=>e).join(`,`);t.mutableState.layouts[a]=i,r&&e.forEach(e=>{if(e.collapsible){let i=gj(e.collapsedSize,n[e.itemId]),a=gj(e.collapsedSize,r[e.itemId]);i&&!a&&(t.mutableState.expandedItemSizes[e.itemId]=r[e.itemId])}})}function cM(){let[e,t]=(0,G.useState)({});return[e,(0,G.useCallback)(()=>t({}),[])]}function lM(e){let t=(0,G.useRef)({...e});return nA(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var uM=(0,G.createContext)(null);function dM({layout:e,itemConstraints:t,itemId:n,itemIndex:r}){let i,a,o=e[n],s=t.find(e=>e.itemId===n);if(s){let c=s.maxSize,l=s.collapsible?s.collapsedSize:s.minSize,u=[r,r+1];a=Rj({layout:yj({delta:l-o,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n],i=Rj({layout:yj({delta:c-o,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function fM({attributes:e,axisId:t,axisOrientation:n,children:r,className:i,disableCursor:a,disabled:o,disableDoubleClick:s,elementRef:c,id:l,isSharedHitRegion:u,preview:d,registerSeparator:f,requiredStyle:p,style:m,styleDefaults:h,tabIndex:g=0,updateSeparatorProps:_}){let v=lM({disabled:o,disableDoubleClick:s,children:r,className:i,preview:d,style:m}),[y,b]=(0,G.useState)({}),[x,S]=(0,G.useState)(`inactive`),[C,w]=(0,G.useState)(!1),T=(0,G.useRef)(null),E=(0,G.useRef)(null),D=iA(T,c),O=n===`horizontal`?`vertical`:`horizontal`;nA(()=>{let e=T.current;if(e!==null){let n={disabled:v.disabled,disableDoubleClick:v.disableDoubleClick,element:e,id:l,get children(){return v.children},get className(){return v.className},get preview(){return v.preview},get style(){return v.style}};E.current=n;let r=f(n),i=DA(e=>{S(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===n||(u?.(e)??!1))?e.next.state:`inactive`)}),a=pj(t,e=>{let{derivedItemConstraints:t,layout:r,separatorToItems:i}=e.next,a=i.get(n);if(a){let n=a[0],i=t.findIndex(e=>e.itemId===n.id),{layoutStrategy:o}=e.axis;b({...dM({layout:r,itemConstraints:t,itemId:n.id,itemIndex:i}),...o?.getItemAriaControls&&{valueControls:o.getItemAriaControls(n.id)}})}});return()=>{E.current=null,i(),a(),r()}}},[t,l,u,f,v]),nA(()=>{let e=E.current;e&&AA(e)},[d]),(0,G.useEffect)(()=>{_(l,{disabled:o,disableDoubleClick:s})},[o,s,l,_]);let k;o&&!a&&(k=`not-allowed`);let A;if(o)A=`disabled`;else switch(x){case`active`:A=`active`;break;default:A=C?`focus`:x}return(0,K.jsx)(`div`,{...e,"aria-controls":y.valueControls,"aria-disabled":o||void 0,"aria-orientation":O,"aria-valuemax":y.valueMax,"aria-valuemin":y.valueMin,"aria-valuenow":y.valueNow,children:r,className:i,"data-separator":A,"data-testid":l,id:l,onBlur:()=>w(!1),onFocus:()=>w(!0),ref:D,role:`separator`,style:{...h,cursor:k,...m,...p,touchAction:`none`},tabIndex:o?void 0:g})}function pM({axis:e,children:t,className:n,crossSpan:r,crossStart:i,disabled:a,elementRef:o,index:s,style:c}){let l=tA(void 0),{getDisableCursor:u,getResizeAxisId:d,gutters:f,registerSeparator:p,separatorPlacements:m,trackCounts:h,updateSeparatorProps:g}=pA(),_=d(e),v=e===`column`?`row`:`column`,y=h[v],b=!!a||!uA(s,h[e]),x=!0;for(let t of m.values())if(t.axis===e&&t.index===s&&!t.disabled&&t.crossStart<i){x=!1;break}let S=(0,G.useCallback)(e=>e.axis.id===_&&e.axis.items.indexOf(e.items[1])===s,[_,s]),C=(0,G.useCallback)(t=>p({axis:e,crossSpan:r,crossStart:i,disabled:!!a,index:s},t),[e,r,i,a,s,p]),w=cA(s),T=lA({crossCount:y,crossSpan:r,crossStart:i,hasGutters:f[v]});return(0,K.jsx)(fM,{axisId:_,axisOrientation:e===`column`?`horizontal`:`vertical`,className:n,disableCursor:u(),disabled:b,disableDoubleClick:void 0,elementRef:o,id:l,isSharedHitRegion:S,registerSeparator:C,requiredStyle:{gridColumn:e===`column`?w:T,gridRow:e===`row`?w:T},style:c,tabIndex:x?0:-1,updateSeparatorProps:g,children:t})}function mM(e){let{children:t,className:n,disabled:r,elementRef:i,style:a}=e;return e.type===`column`?(0,K.jsx)(pM,{axis:`column`,className:n,crossSpan:e.rowSpan,crossStart:e.row??0,disabled:r,elementRef:i,index:e.column,style:a,children:t}):(0,K.jsx)(pM,{axis:`row`,className:n,crossSpan:e.columnSpan,crossStart:e.column??0,disabled:r,elementRef:i,index:e.row,style:a,children:t})}mM.displayName=`Gridline`;var hM=[`column`,`row`],gM={columns:{},rows:{}};function _M({children:e,className:t,columns:n,defaultLayout:r,disableCursor:i,disabled:a,elementRef:o,gridRef:s,id:c,onLayoutChange:l,onLayoutChanged:u,resizeTargetMinimumSize:d={coarse:20,fine:10},rows:f,style:p,...m}){let h=tA(c),g=(0,G.useCallback)(e=>e===`column`?`${h}:columns`:`${h}:rows`,[h]),_=vM(n,`columns`),v=vM(f,`rows`),y=e=>e===`column`?_:v,b=(0,G.useRef)({onLayoutChange:gM,onLayoutChanged:gM}),x=rA(e=>{SM(b.current.onLayoutChange,e)||(b.current.onLayoutChange=e,l?.(e))}),S=rA((e,t,n)=>{SM(b.current.onLayoutChanged,e)||(b.current.onLayoutChanged=e,u?.(e,{isUserInteraction:t,requestedLayout:n}))}),C=(0,G.useRef)(null),w=iA(C,o),[T,E]=cM(),D=(0,G.useRef)({cells:[],column:{expandedItemSizes:{},layouts:{}},loggedErrors:new Set,row:{expandedItemSizes:{},layouts:{}},separators:new Map}),O={column:!1,row:!1};for(let e of D.current.separators.values())O[e.axis]=!0;yM(e,O);let k=lM({defaultLayout:r,disableCursor:i,resizeTargetMinimumSize:d}),A=rA(()=>!!k.disableCursor),j=(0,G.useCallback)(e=>{let t=D.current;return t.cells=[...t.cells,e],E(),()=>{t.cells=t.cells.filter(t=>t!==e),E()}},[E]),M=(0,G.useCallback)((e,t)=>{let n=D.current;return n.separators=new Map(n.separators),n.separators.set(t,e),E(),()=>{n.separators=new Map(n.separators),n.separators.delete(t),E()}},[E]),N=(0,G.useCallback)((e,{disabled:t,disableDoubleClick:n})=>{for(let r of D.current.separators.keys())r.id===e&&(r.disabled=t,r.disableDoubleClick=n)},[]),P=D.current.separators,ee=(0,G.useMemo)(()=>({getDisableCursor:A,getResizeAxisId:g,gutters:{column:O.column,row:O.row},id:h,registerCell:j,registerSeparator:M,separatorPlacements:P,trackCounts:{column:_.length,row:v.length},updateSeparatorProps:N}),[_.length,A,g,O.column,O.row,h,j,M,v.length,P,N]),te=(0,G.useRef)([]);nA(()=>{let e=C.current;if(e===null)return;let t=D.current,n=xM({cells:t.cells,separatorPlacements:t.separators,trackCounts:{column:_.length,row:v.length}});n.forEach(e=>{t.loggedErrors.has(e)||console.error(e)}),t.loggedErrors=new Set(n);let r=e=>Array.from(t.separators.entries()).filter(([,t])=>t.axis===e).sort(([,e],[,t])=>e.index-t.index).map(([e])=>e),i=hM.map(n=>{let i=n===`column`?_:v,o=n===`column`?v:_,s=i.map(e=>e.id),c=g(n),l=r(n),u=l.length>0,d=i.map(({id:t,...n},r)=>({element:e,id:s[r],idIsStable:!0,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:void 0,constraintProps:n})),f=()=>{let r=[];if(u){for(let[e,a]of t.separators)if(a.axis===n&&uA(a.index,i.length)){let t=e.element.getBoundingClientRect();r[a.index]=Math.max(r[a.index]??0,n===`column`?t.width:t.height)}}return xA({axis:n,element:e,gutterSizes:r.filter(e=>e!==void 0),hasGutters:u,layout:dj(c)?.layout,trackIds:s})},p,m=k.defaultLayout?.[n===`column`?`columns`:`rows`];if(m!==void 0&&Object.keys(m).length===s.length){p={};for(let e of s){let t=m[e];t!==void 0&&(p[e]=t)}}return{disabled:!!a,element:e,id:c,layoutStrategy:{getItemAriaControls:e=>{let r=s.indexOf(e);return t.cells.filter(e=>{let t=n===`column`?e.column:e.row,i=n===`column`?e.columnSpan:e.rowSpan;return t<=r&&r<t+i}).map(e=>e.element.id).filter(Boolean).join(` `)||void 0},calculateAvailableSize:()=>f().availableSize,calculateHitRegions:({expandHitTargets:e,axis:r,includeDisabled:i})=>yA({axis:n,cells:t.cells,crossTrackCount:o.length,expandHitTargets:e,resizeAxis:r,axisSize:f().availableSize,includeDisabled:i,separatorPlacements:t.separators}),getItemSizeInPixels:e=>f().trackSizes[s.indexOf(e)]??0},mutableState:{defaultLayout:p,disableCursor:!!k.disableCursor,expandedItemSizes:t[n].expandedItemSizes,layouts:t[n].layouts},orientation:n===`column`?`horizontal`:`vertical`,items:d,resizePreviewMode:`panel`,get resizeTargetMinimumSize(){return k.resizeTargetMinimumSize},separators:l}});te.current=i;let o=i.map(e=>oM(e)),s=()=>{let[e,t]=i.map(e=>dj(e.id));if(!(!e||!t||e.defaultLayoutDeferred||t.defaultLayoutDeferred))return{layout:{columns:e.layout,rows:t.layout},requestedLayout:{columns:e.requestedLayout,rows:t.requestedLayout}}};{let e=s();e&&(x(e.layout),S(e.layout,!1,e.requestedLayout))}let c=i.map(e=>pj(e.id,t=>{let{defaultLayoutDeferred:n,derivedItemConstraints:r,layout:a,requestedLayout:o}=t.next;if(n||r.length===0)return;sM({derivedItemConstraints:r,axis:e,layout:a,prevLayout:t.prev?.layout,requestedLayout:o});let c=s();if(c){let e=EA(),n=e.state!==`active`||!e.hitRegions.some(e=>i.includes(e.axis));x(c.layout),n&&S(c.layout,t.isUserInteraction,c.requestedLayout)}}));return()=>{te.current=[],o.forEach(e=>e()),c.forEach(e=>e())}},[_,a,g,h,S,x,v,T,k]),(0,G.useEffect)(()=>{te.current.forEach(e=>{e.mutableState.defaultLayout=r?.[e.orientation===`horizontal`?`columns`:`rows`],e.mutableState.disableCursor=!!i})}),(0,G.useImperativeHandle)(s,()=>{let e=()=>{let[e,t]=hM.map(g);return!uj(e)||!uj(t)?{columns:{},rows:{}}:{columns:Hj({axisId:e}).getLayout(),rows:Hj({axisId:t}).getLayout()}},t=e=>e.map(e=>`"${e}"`).join(`, `),n=(e,n)=>{let r=g(e),i=()=>{let i=uj(r);return dA(i,`Grid "${h}" has not been mounted`),dA(i.items.some(e=>e.id===n),`Grid "${h}" no longer contains a ${e} with id "${n}"; ${e} ids are ${t(i.items.map(e=>e.id))}`),zj({axisId:r,itemId:n})};return{collapse:()=>i().collapse(),expand:()=>i().expand(),getSize:()=>i().getSize(),isCollapsed:()=>i().isCollapsed(),resize:e=>i().resize(e)}};return{getLayout:e,getTrackById:(e,r)=>{let i=e===`column`?_:v,a=`${r}`;return dA(i.some(e=>e.id===a),`Grid "${h}" does not contain a ${e} with id "${a}"; ${e} ids are ${t(i.map(e=>e.id))}`),n(e,a)},getTrackByIndex:(e,t)=>{let r=e===`column`?_:v,i=Number.isInteger(t)?r[t]:void 0;return dA(i,`Grid "${h}" does not contain a ${e} at index ${t}; it has ${r.length} ${e}s`),n(e,i.id)},setLayout:t=>(hM.forEach(e=>{let n=t[e===`column`?`columns`:`rows`],r=g(e);n&&uj(r)&&Hj({axisId:r}).setLayout(n)}),e())}},[_,g,h,v]);let ne=()=>hM.map(e=>{let t=dj(g(e)),n=y(e);return(t&&!t.defaultLayoutDeferred?n.map(e=>`minmax(0, ${t.layout[e.id]??1}fr)`):bM(n,r?.[e===`column`?`columns`:`rows`])).join(O[e]?` auto `:` `)}).join(`|`),[re,ie]=(0,G.useSyncExternalStore)((0,G.useCallback)(e=>{let t=hM.map(t=>pj(g(t),e));return()=>t.forEach(e=>e())},[g]),ne,ne).split(`|`);return(0,K.jsx)(fA.Provider,{value:ee,children:(0,K.jsx)(`div`,{...m,className:t,"data-grid":!0,"data-testid":h,id:h,ref:w,style:{height:`100%`,width:`100%`,overflow:`hidden`,...p,display:`grid`,gridTemplateColumns:re,gridTemplateRows:ie,touchAction:`none`},children:(0,K.jsx)(uM.Provider,{value:null,children:e})})})}_M.displayName=`Grid`;function vM(e,t){let n=JSON.stringify(e);return(0,G.useMemo)(()=>{let r=typeof e==`number`?Array.from({length:e},(e,t)=>({id:`${t}`})):e.map((e,t)=>({...e,id:`${e.id??t}`}));return dA(r.length>0,`Grid must have at least one track; "${t}" is ${n}`),r},[n])}function yM(e,t){G.Children.forEach(e,e=>{if((0,G.isValidElement)(e))if(e.type===mM){let{type:n}=e.props;n===`column`?t.column=!0:n===`row`&&(t.row=!0)}else typeof e.type==`symbol`&&e.props!==null&&typeof e.props==`object`&&`children`in e.props&&yM(e.props.children,t)})}function bM(e,t){if(t)return e.map(e=>`minmax(0, ${t[e.id]??1}fr)`);let n=e.map(e=>e.defaultSize===void 0?void 0:SA(e.defaultSize)),r=100,i=0;return n.forEach(e=>{e===void 0?i++:e[1]===`%`&&(r-=e[0])}),n.map(e=>{if(e===void 0)return`minmax(0, ${Math.max(0,r)/Math.max(1,i)}fr)`;let[t,n]=e;return n===`%`?`minmax(0, ${t}fr)`:`${t}${n}`})}function xM({cells:e,separatorPlacements:t,trackCounts:n}){let r=[];for(let t of e)hM.forEach(e=>{let[i,a]=e===`column`?[t.column,t.columnSpan]:[t.row,t.rowSpan],o=n[e];(!Number.isInteger(i)||!Number.isInteger(a)||i<0||a<1||i+a>o)&&r.push(`Invalid Cell ${e} placement (${e}: ${i}, ${e}Span: ${a}); Grid has ${o} ${e}s`)});let i=({axis:e,crossSpan:t,crossStart:n,disabled:r,index:i})=>{let a=e===`column`?`row`:`column`,o=`type="${e}" ${e}={${i}}`;return(n!==0||t!==void 0)&&(o+=` ${a}={${n}}`),t!==void 0&&(o+=` ${a}Span={${t}}`),r&&(o+=` disabled`),`<Gridline ${o} />`},a=Array.from(t.values()).filter(e=>{let{axis:t,crossSpan:i,crossStart:a,index:o}=e,s=t===`column`?`row`:`column`,c=n[t],l=n[s],u=!0;return uA(o,c)||(r.push(`Invalid ${t} Gridline ${t} (${o}); must be between 1 and ${c-1}`),u=!1),!Number.isInteger(a)||a<0||a>=l?(r.push(`Invalid ${t} Gridline ${s} (${a}); must be between 0 and ${l-1}`),u=!1):i!==void 0&&(!Number.isInteger(i)||i<1||a+i>l)&&(r.push(`Invalid ${t} Gridline ${s}Span (${i}); Grid has ${l} ${s}s`),u=!1),u}),o=e=>{let t=n[e.axis===`column`?`row`:`column`];return[e.crossStart,e.crossSpan===void 0?t:e.crossStart+e.crossSpan]};return a.forEach((t,n)=>{let{axis:s,index:c}=t,[l,u]=o(t);for(let n of e){let[e,a,o,d]=s===`column`?[n.column,n.columnSpan,n.row,n.rowSpan]:[n.row,n.rowSpan,n.column,n.columnSpan];if(e<c&&c<e+a&&o<u&&l<o+d){let n=s===`column`?`row`:`column`;r.push(`${i(t)} overlaps a Cell that spans across it (${s}: ${e}, ${s}Span: ${a}, ${n}: ${o}, ${n}Span: ${d}); use the ${n} and ${n}Span props to render gridlines beside the Cell instead`)}}for(let e of a.slice(n+1))if(e.axis===s&&e.index===c){let[n,a]=o(e);n<u&&l<a&&r.push(`${i(t)} overlaps ${i(e)}`)}}),r}function SM(e,t){return bj(e.columns,t.columns)&&bj(e.rows,t.rows)}function CM(e){for(let t=1;t<e.length;t++)if(KA(e[t-1],e[t])>0)return!1;return!0}function wM({separator:e}){let{element:t}=e,n=(0,G.useRef)(null);return nA(()=>{let e=t.cloneNode(!0),r=[t,...t.querySelectorAll(`*`)],i=[e,...e.querySelectorAll(`*`)],a=t.ownerDocument.defaultView;return r.forEach((e,t)=>{let n=i[t];if(n instanceof a.HTMLElement||n instanceof a.SVGElement){let t=a.getComputedStyle(e);for(let e=0;e<t.length;e++){let r=t.item(e);n.style.setProperty(r,t.getPropertyValue(r))}}n.removeAttribute(`data-testid`),n.removeAttribute(`id`)}),Object.assign(e.style,{boxSizing:`border-box`,height:`100%`,margin:`0`,position:`static`,transform:`none`,width:`100%`}),n.current.appendChild(e),()=>e.remove()},[t]),(0,K.jsx)(`div`,{ref:n,style:{height:`100%`,opacity:.65,pointerEvents:`none`,width:`100%`}})}function TM(){let e=(0,G.useContext)(uM);return dA(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function EM(e){let{registerOverlay:t}=TM(),n=(0,G.useRef)(e);nM(n.current,e)||(n.current=e);let r=n.current;return nA(()=>t(r),[t,r]),null}EM.displayName=`SeparatorOverlay`;function DM({active:e,orientation:t,style:n,...r}){let i;switch(t){case`horizontal`:i={height:`100%`,minWidth:`1px`};break;case`vertical`:i={minHeight:`1px`,width:`100%`};break}return(0,K.jsx)(`div`,{...r,"data-separator-overlay":e?`active`:`inactive`,style:{...i,...n,flexShrink:0,pointerEvents:`none`}})}function OM({overlay:e,preview:t}){let{axis:n,offset:r,rect:i,separator:a}=t,o=n.orientation===`horizontal`,s=a?.preview,c=e;return(0,G.isValidElement)(s)&&s.type===EM&&(c=s.props,s=void 0),s??(c?s=(0,K.jsx)(DM,{...c,active:t.active,orientation:n.orientation}):a&&(s=(0,K.jsx)(wM,{separator:a}))),(0,K.jsx)(`div`,{"aria-hidden":`true`,"data-resize-preview":!0,inert:!0,style:{height:i.height,left:i.left,pointerEvents:`none`,position:`absolute`,top:i.top,transform:o?`translateX(${r}px)`:`translateY(${r}px)`,width:i.width},children:s})}function kM(e){return Array.from(e).sort(KA)}function AM(e,t){let n=(0,G.useRef)({getLayout:()=>({}),setLayout:MA});(0,G.useImperativeHandle)(t,()=>n.current,[]),nA(()=>{Object.assign(n.current,Hj({axisId:e}))})}function jM({groupId:e,resizePreviewMode:t}){let[n,r]=(0,G.useState)([]),i=(0,G.useRef)(n);return nA(()=>{let n=n=>{let a=uj(e),o=t===`separator`&&n.state===`active`?n.previews.filter(e=>e.axis===a&&(e.active||!gj(e.offset,0))):[],s=i.current;s.length===o.length&&o.every((e,t)=>e===s[t])||(i.current=o,r(o))};if(t!==`separator`){n(EA());return}let a=DA(({next:e})=>n(e));return n(EA()),a},[e,t]),n}function MM({children:e,className:t,defaultLayout:n,disableCursor:r,disabled:i,elementRef:a,groupRef:o,id:s,onLayoutChange:c,onLayoutChanged:l,orientation:u=`horizontal`,resizePreviewMode:d=`panel`,resizeTargetMinimumSize:f={coarse:20,fine:10},style:p,...m}){let h=(0,G.useRef)({onLayoutChange:{},onLayoutChanged:{}}),g=rA(e=>{bj(h.current.onLayoutChange,e)||(h.current.onLayoutChange=e,c?.(e))}),_=rA((e,t,n)=>{bj(h.current.onLayoutChanged,e)||(h.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t,requestedLayout:n}))}),v=tA(s),[y,b]=(0,G.useState)(),x=jM({groupId:v,resizePreviewMode:d}),S=(0,G.useRef)(null),[C,w]=cM(),T=(0,G.useRef)([]),E=(0,G.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],separators:[]}),D=iA(S,a);AM(v,o);let O=rA((e,t)=>{let r=dj(e);if(r)return{flexGrow:r.layout[t]??1};if(n?.[t])return{flexGrow:n?.[t]}}),k=lM({defaultLayout:n,disableCursor:r,resizeTargetMinimumSize:f}),A=(0,G.useMemo)(()=>({get disableCursor(){return!!k.disableCursor},getPanelStyles:O,id:v,orientation:u,registerPanel:e=>{let t=E.current;return t.panels=qA(u,[...t.panels,e]),w(),()=>{t.panels=t.panels.filter(t=>t!==e),w()}},registerOverlay:e=>(b(e),()=>{b(void 0)}),registerSeparator:e=>{let t=E.current;return t.separators=qA(u,[...t.separators,e]),w(),()=>{t.separators=t.separators.filter(t=>t!==e),w()}},updatePanelProps:(e,{disabled:t})=>{let n=E.current.panels.find(t=>t.id===e);n&&(n.constraintProps.disabled=t);let r=uj(v),i=dj(v);r&&i&&mj(r,{...i,derivedItemConstraints:oj(r)})},updateSeparatorProps:(e,{disabled:t,disableDoubleClick:n})=>{let r=E.current.separators.find(t=>t.id===e);r&&(r.disabled=t,r.disableDoubleClick=n)}}),[O,v,w,u,k]),j=(0,G.useRef)(null);return nA(()=>{let e=S.current;if(e===null)return;let t=E.current;t.panels=qA(u,t.panels),t.separators=qA(u,t.separators),T.current=kM([...t.panels.map(({element:e})=>e),...t.separators.map(({element:e})=>e)]);let n;if(k.defaultLayout!==void 0&&Object.keys(k.defaultLayout).length===t.panels.length){n={};for(let e of t.panels){let t=k.defaultLayout[e.id];t!==void 0&&(n[e.id]=t)}}let r={disabled:!!i,element:e,id:v,mutableState:{defaultLayout:n,disableCursor:!!k.disableCursor,expandedItemSizes:E.current.lastExpandedPanelSizes,layouts:E.current.layouts},orientation:u,items:t.panels,resizePreviewMode:d,get resizeTargetMinimumSize(){return k.resizeTargetMinimumSize},separators:t.separators};j.current=r;let a=oM(r),{defaultLayoutDeferred:o,derivedItemConstraints:s,layout:c,requestedLayout:l}=dj(r.id,!0);!o&&s.length>0&&(g(c),_(c,!1,l));let f=pj(v,e=>{let{defaultLayoutDeferred:t,derivedItemConstraints:n,layout:i,requestedLayout:a}=e.next;if(t||n.length===0)return;sM({derivedItemConstraints:n,axis:r,layout:i,prevLayout:e.prev?.layout,requestedLayout:a});let o=EA(),s=o.state!==`active`||!o.hitRegions.some(e=>e.axis===r);g(i),s&&_(i,e.isUserInteraction,a)});return()=>{j.current=null,a(),f()}},[i,v,_,g,u,C,d,k]),nA(()=>{CM(T.current)||w()}),(0,G.useEffect)(()=>{let e=j.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,K.jsx)(uM.Provider,{value:A,children:(0,K.jsxs)(`div`,{...m,className:t,"data-group":!0,"data-testid":v,id:v,ref:D,style:{height:`100%`,width:`100%`,overflow:`hidden`,position:d===`separator`?`relative`:void 0,...p,display:`flex`,flexDirection:u===`horizontal`?`row`:`column`,flexWrap:`nowrap`,touchAction:u===`horizontal`?`pan-y`:`pan-x`},children:[e,x.map(e=>(0,K.jsx)(OM,{overlay:y,preview:e},e.key))]})})}MM.displayName=`Group`;function NM(e,t){let{id:n}=TM(),r=(0,G.useRef)({collapse:NA,expand:NA,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:NA});(0,G.useImperativeHandle)(t,()=>r.current,[]),nA(()=>{Object.assign(r.current,zj({axisId:n,itemId:e}))})}function PM({children:e,className:t,collapsedSize:n=`0%`,collapsedThreshold:r,collapsible:i=!1,defaultSize:a,disabled:o,elementRef:s,groupResizeBehavior:c=`preserve-relative-size`,id:l,maxSize:u=`100%`,minSize:d=`0%`,onResize:f,panelRef:p,style:m,...h}){let g=!!l,_=tA(l),v=lM({disabled:o}),y=(0,G.useRef)(null),b=iA(y,s),{getPanelStyles:x,id:S,orientation:C,registerPanel:w,updatePanelProps:T}=TM(),E=f!==null,D=rA((e,t,n)=>{f?.(e,l,n)});nA(()=>{let e=y.current;if(e!==null){let t={element:e,id:_,idIsStable:g,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:E?D:void 0,constraintProps:{groupResizeBehavior:c,collapsedSize:n,collapsedThreshold:r,collapsible:i,defaultSize:a,disabled:v.disabled,maxSize:u,minSize:d}};return w(t)}},[c,n,r,i,a,E,_,g,u,d,D,w,v]),(0,G.useEffect)(()=>{T(_,{disabled:o})},[o,_,T]),NM(_,p);let O=()=>{let e=x(S,_);if(e)return JSON.stringify(e)},k=(0,G.useSyncExternalStore)(e=>pj(S,e),O,O),A;return A=k?JSON.parse(k):a===void 0?{flexGrow:1}:{flexGrow:void 0,flexShrink:void 0,flexBasis:a},(0,K.jsx)(`div`,{...h,"data-disabled":o||void 0,"data-panel":!0,"data-testid":_,id:_,ref:b,style:{...FM,display:`flex`,flexBasis:0,flexShrink:1,overflow:`visible`,...A},children:(0,K.jsx)(`div`,{className:t,style:{maxHeight:`100%`,maxWidth:`100%`,flexGrow:1,overflow:`auto`,...m,touchAction:C===`horizontal`?`pan-y`:`pan-x`},children:e})})}PM.displayName=`Panel`;var FM={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0},IM={flexBasis:`auto`},LM={flexGrow:0,flexShrink:0};function RM({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,preview:o,style:s,...c}){let l=tA(a),{disableCursor:u,id:d,orientation:f,registerSeparator:p,updateSeparatorProps:m}=TM();return(0,K.jsx)(fM,{attributes:c,axisId:d,axisOrientation:f,className:t,disableCursor:u,disabled:n,disableDoubleClick:r,elementRef:i,id:l,preview:o,registerSeparator:p,requiredStyle:LM,style:s,styleDefaults:IM,updateSeparatorProps:m,children:e})}RM.displayName=`Separator`;function zM({className:e,...t}){return(0,K.jsx)(MM,{"data-slot":`resizable-panel-group`,className:B(`flex h-full w-full`,e),...t})}function BM(e){return(0,K.jsx)(PM,{"data-slot":`resizable-panel`,...e})}function VM({className:e,...t}){return(0,K.jsx)(RM,{"data-slot":`resizable-handle`,className:B(`group/handle relative shrink-0 bg-border outline-none`,`aria-[orientation=vertical]:w-px aria-[orientation=horizontal]:h-px`,e),...t,children:(0,K.jsx)(`div`,{className:B(`pointer-events-none absolute z-10 bg-transparent transition-colors`,`group-aria-[orientation=vertical]/handle:inset-y-0 group-aria-[orientation=vertical]/handle:-left-px group-aria-[orientation=vertical]/handle:w-[3px]`,`group-aria-[orientation=horizontal]/handle:inset-x-0 group-aria-[orientation=horizontal]/handle:-top-px group-aria-[orientation=horizontal]/handle:h-[3px]`,`group-data-[separator=hover]/handle:bg-primary group-data-[separator=focus]/handle:bg-primary group-data-[separator=active]/handle:bg-primary`)})})}var HM=`oa.panes`,UM=200,WM=new Set,GM=[];function KM(e,t){return t?`${e}/${t}`:`new`}var qM=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function JM(e){if(!qM(e))return{};let t={};for(let[n,r]of Object.entries(e))qM(r)&&Object.values(r).every(e=>typeof e==`number`)&&(t[n]=r);return t}function YM(e){let t;try{t=JSON.parse(e??`null`)}catch{t=null}let n={};if(qM(t)&&qM(t.pages))for(let[e,r]of Object.entries(t.pages))qM(r)&&(n[e]={open:Array.isArray(r.open)?r.open.filter(e=>typeof e==`string`):[],sizes:JM(r.sizes)});return{pages:n,last:qM(t)?JM(t.last):{}}}var XM,ZM;function QM(){let e=ZM??null;if(ZM===void 0)try{e=globalThis.localStorage?.getItem(HM)??null}catch{e=null}return XM?.raw!==e&&(XM={raw:e,kept:YM(e)}),XM.kept}function $M(e,t,n){let r=QM(),{[e]:i,...a}=r.pages,o=t(i??{open:[],sizes:{}}),s=o.open.length>0||Object.keys(o.sizes).length>0?{...a,[e]:o}:a,c=Object.keys(s);for(let e of c.slice(0,Math.max(0,c.length-UM)))delete s[e];let l=JSON.stringify({pages:s,last:n??r.last});try{globalThis.localStorage?.setItem(HM,l),ZM=void 0}catch{ZM=l}for(let e of WM)e()}function eN(e){return WM.add(e),()=>WM.delete(e)}function tN(e,t,n){!n&&cN.get(e)===t&&cN.delete(e),$M(e,e=>e.open.includes(t)===n?e:{...e,open:n?[...e.open,t]:e.open.filter(e=>e!==t)})}function nN(e){cN.delete(e),$M(e,e=>({...e,open:[]}))}function rN(e){return(0,G.useSyncExternalStore)(eN,()=>QM().pages[e]?.open??GM,()=>GM)}function iN(e,t){let n=QM();return n.pages[e]?.sizes[t]??n.last[t]}var aN=0;function oN(e,t){return QM().pages[e]?.sizes[t]?e:`~${aN}`}function sN(e,t,n){aN++,$M(e,e=>({...e,sizes:{...e.sizes,[t]:n}}),{...QM().last,[t]:n})}var cN=new Map;function lN(e,t){t===void 0?cN.delete(e):cN.set(e,t);for(let e of WM)e()}function uN(e){return(0,G.useSyncExternalStore)(eN,()=>cN.get(e),()=>void 0)}var dN=new Map,fN=new Map,pN=new Map,mN=new Set,hN=0;function gN(e){return mN.add(e),()=>mN.delete(e)}function _N(e,t){dN.set(e,t===void 0?{at:++hN}:{path:t,at:++hN});for(let e of mN)e()}function vN(e){return(0,G.useSyncExternalStore)(gN,()=>dN.get(e),()=>void 0)}function yN(e){fN.set(e,++hN);for(let e of mN)e()}function bN(e){return(0,G.useSyncExternalStore)(gN,()=>fN.get(e),()=>void 0)}function xN(e,t){pN.set(e,{key:t,at:++hN});for(let e of mN)e()}function SN(e){return(0,G.useSyncExternalStore)(gN,()=>pN.get(e),()=>void 0)}var CN=e=>`${e.package}/${e.id}`,wN=`docs`,TN=`subagent`,EN=`workspace`,DN=`chat`,ON=`panes`,kN=50,AN=(0,G.createContext)({page:``,enabled:!1,panes:[],open:[],expanded:void 0,panelProps:void 0,reveal:void 0,docs:[],docsLoaded:!1,subagent:null}),jN=0;function MN({projectId:e,agentId:t,enabled:n,files:r,context:i,toggleContext:a,activity:o,subagent:s,children:c}){let l=n?e:null,{value:u,loaded:d}=g(l?()=>wr(l):null,[],4e3,[l],l?{remember:`docs:${l}`}:void 0),{panels:f}=sn(),p=KM(l??``,t),m=SN(p),h=s!==void 0&&m!==void 0,_=(0,G.useMemo)(()=>{if(!l)return[];let e=f.filter(e=>e.projects.includes(l)).map(e=>({id:CN(e),label:e.label,icon:e.icon,panel:e})),t=[...u.length>0?[{id:wN,label:`Docs`,icon:ua}]:[],...h?[{id:TN,label:`Subagent`,icon:Yi,hidden:!0}]:[]];return[...e,...t]},[f,l,u.length,h]),v=rN(p),y=(0,G.useMemo)(()=>v.flatMap(e=>_.find(t=>t.id===e)??[]),[v,_]),b=uN(p);(0,G.useEffect)(()=>()=>{F()&&nN(p)},[p]);let x=vN(p),S=_.find(e=>e.panel?.changes)?.id,C=x?.at;(0,G.useEffect)(()=>{C===void 0||S===void 0||C<=jN||(jN=C,tN(p,S,!0))},[C,S,p]);let w=bN(p),T=_.find(e=>e.panel?.screen)?.id;(0,G.useEffect)(()=>{w===void 0||T===void 0||w<=jN||(jN=w,tN(p,T,!0))},[w,T,p]);let E=m?.at;(0,G.useEffect)(()=>{E===void 0||!h||E<=jN||(jN=E,tN(p,TN,!0))},[E,h,p]);let D=(0,G.useMemo)(()=>new Set(r.filter(e=>i.has(e))),[r,i]),O=(0,G.useMemo)(()=>({files:D,toggle:a}),[D,a]),k=(0,G.useMemo)(()=>l?{projectId:l,...t?{agentId:t,...o===void 0?{}:{activity:o}}:{},context:O}:void 0,[l,t,o,O]),A=(0,G.useMemo)(()=>({page:p,enabled:l!==null,panes:_,open:y,expanded:y.some(e=>e.id===b)?b:void 0,panelProps:k,reveal:x,docs:u,docsLoaded:d,subagent:s??null}),[p,l,_,y,b,k,x,u,d,s]);return(0,K.jsx)(AN.Provider,{value:A,children:c})}function NN(){let{open:e}=(0,G.useContext)(AN);return Se()&&e.length>0}function PN(){let{page:e,panes:t,open:n}=(0,G.useContext)(AN),r=t.filter(e=>!e.hidden);return NN()||r.length===0?null:(0,K.jsx)(`div`,{role:`group`,"aria-label":`Panes`,className:`flex shrink-0 items-center gap-0.5`,children:r.map(t=>{let r=n.includes(t);return(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(V,{variant:`ghost`,size:`icon-sm`,className:B(`shrink-0 text-muted-foreground`,r&&`bg-accent text-accent-foreground`),"aria-label":t.label,"aria-pressed":r,onClick:()=>tN(e,t.id,!r)}),children:(0,K.jsx)(t.icon,{className:`h-4 w-4`})}),(0,K.jsx)(z,{children:t.label})]},t.id)})})}function FN(){let{page:e,panes:t,open:n}=(0,G.useContext)(AN);return NN()?(0,K.jsxs)(re,{children:[(0,K.jsx)(bt,{"aria-label":`Panes`,className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground`,children:(0,K.jsx)(sa,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsx)(Be,{align:`start`,className:`min-w-[12rem]`,children:t.filter(e=>!e.hidden||n.includes(e)).map(t=>(0,K.jsxs)(He,{closeOnClick:!0,checked:n.includes(t),onCheckedChange:n=>tN(e,t.id,n),children:[(0,K.jsx)(t.icon,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),` `,t.label]},t.id))})]}):null}function IN({pane:e}){let{page:t,expanded:n,panelProps:r,reveal:i,docs:a,docsLoaded:o,subagent:s}=(0,G.useContext)(AN),c=n===e.id,[l,u]=(0,G.useState)(null),[d,f]=(0,G.useState)(null),p=(0,G.useMemo)(()=>({title:l,actions:d}),[l,d]);return(0,K.jsx)(`div`,{className:c?`absolute inset-0 z-30 flex bg-background`:`flex h-full min-h-0 min-w-0`,children:(0,K.jsxs)(`section`,{"aria-label":e.label,className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-background`,children:[(0,K.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-0.5 border-b border-border pr-2 pl-2`,children:[(0,K.jsx)(`div`,{ref:u,className:`peer flex min-w-0 flex-1 items-center gap-0.5 empty:hidden`}),(0,K.jsx)(`h2`,{className:`min-w-0 flex-1 truncate pl-2 text-[13px] text-muted-foreground peer-[:not(:empty)]:hidden`,children:e.label}),(0,K.jsx)(`div`,{ref:f,className:`flex shrink-0 items-center gap-0.5 empty:hidden`}),(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(V,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground`,"aria-label":c?`Bring ${e.label} back to its place`:`Let ${e.label} fill the page`,"aria-pressed":c,onClick:()=>lN(t,c?void 0:e.id)}),children:c?(0,K.jsx)(Aa,{className:`h-3.5 w-3.5`}):(0,K.jsx)(Oa,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(z,{children:c?`Back to its place`:`Fill the page`})]}),(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(V,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground`,"aria-label":`Close ${e.label}`,onClick:()=>tN(t,e.id,!1)}),children:(0,K.jsx)(ee,{className:`h-4 w-4`})}),(0,K.jsx)(z,{children:`Close`})]})]}),(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:e.id===TN?(0,K.jsx)(Ct.Provider,{value:p,children:s}):e.panel&&r?(0,K.jsx)(Qk,{package:e.panel.package,label:`${e.label} pane`,children:(0,K.jsx)(Ct.Provider,{value:p,children:(0,K.jsx)(e.panel.Panel,{...e.panel.changes&&i?{...r,reveal:i}:r})})}):(0,K.jsx)(Xk,{docs:a,loaded:o})})]})})}var LN=e=>e.map(e=>e.id).join(`+`);function RN(){let{page:e,open:t,expanded:n}=(0,G.useContext)(AN),r=LN(t),i=iN(e,r),a=oN(e,r),o=e=>`${e.id}@${a}`;return(0,K.jsx)(zM,{orientation:`vertical`,disabled:n!==void 0,onLayoutChanged:(n,{isUserInteraction:i})=>{let a=t.map(e=>[e.id,n[o(e)]]);i&&a.every(([,e])=>e!==void 0)&&sN(e,r,Object.fromEntries(a))},children:t.flatMap((e,n)=>[...n>0?[(0,K.jsx)(VM,{"aria-label":`The height of ${t[n-1].label} and ${e.label}`},`above-${e.id}`)]:[],(0,K.jsx)(BM,{id:o(e),defaultSize:`${i?.[e.id]??100/t.length}%`,minSize:96,style:{overflow:`hidden`},children:(0,K.jsx)(IN,{pane:e})},e.id)])})}function zN({children:e}){let{page:t,enabled:n,open:r,expanded:i}=(0,G.useContext)(AN),a=Se(),o=r.length>0&&!a;if(!n)return e;let s=iN(t,EN)?.[ON]??kN,c=`${ON}@${oN(t,EN)}`;return(0,K.jsxs)(`div`,{className:`relative flex min-w-0 flex-1`,children:[(0,K.jsxs)(zM,{orientation:`horizontal`,disabled:i!==void 0,onLayoutChanged:(e,{isUserInteraction:n})=>{let[r,i]=[e[DN],e[c]];n&&r!==void 0&&i!==void 0&&sN(t,EN,{[DN]:r,[ON]:i})},children:[(0,K.jsx)(BM,{id:DN,minSize:320,className:`flex min-w-0 flex-col`,style:{overflow:`hidden`},children:e}),o&&(0,K.jsx)(VM,{"aria-label":`The width of the chat and the panes`}),o&&(0,K.jsx)(BM,{id:c,defaultSize:`${s}%`,minSize:288,style:{overflow:`hidden`},children:(0,K.jsx)(RN,{})})]}),a&&r.length>0&&(0,K.jsx)(`div`,{className:B(`absolute inset-y-0 right-0 z-20 flex flex-col divide-y divide-border border-l border-border bg-background`,i?`left-0`:`w-2/3 min-w-64 max-w-full`),children:r.map(e=>(0,K.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,K.jsx)(IN,{pane:e})},e.id))})]})}var BN=[];function VN({projectId:e,onProjectRemoved:t}){return(0,K.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 overflow-hidden pr-2 md:pl-4 max-md:pl-11`,children:[(0,K.jsx)(v,{}),(0,K.jsx)(FN,{}),(0,K.jsx)(`div`,{className:`grow shrink-0`}),(0,K.jsx)(Yk,{projectId:e,events:BN,onProjectRemoved:t}),(0,K.jsx)(PN,{})]})}var HN=W(`onProjectSkills`),UN=W(`sendChangeSkills`),WN=W(`sendProjectSkills`),GN=e=>e.standing!==`absent`,KN=e=>e.groups.flatMap(e=>e.skills),qN=(e,t,n)=>`${e} ${e===1?t:n}`;function JN({names:e}){return e.length>3?(0,K.jsxs)(`span`,{className:`text-foreground`,children:[e.length,` skills`]}):(0,K.jsxs)(K.Fragment,{children:[`The`,` `,e.map((t,n)=>(0,K.jsxs)(`span`,{children:[n>0&&(n===e.length-1?` and `:`, `),(0,K.jsx)(`span`,{className:`text-foreground`,children:t})]},t)),` `,e.length===1?`skill`:`skills`]})}var YN=e=>e.length===1?`is`:`are`,XN=e=>e.length===1?`it`:`them`,ZN={newer:`a newer version is there`,changed:`changed by hand`,own:`your own text`},QN=e=>e.remote?`Send to ${e.remote}`:`Commit`;function $N({projectId:e,onChanged:t,door:n}){let{value:r,reload:i,loaded:a}=g(()=>HN(e).catch(()=>null),null,15e3,[e],`previous`),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),{error:u,run:d}=en(),f=n?.open??!1;if((0,G.useEffect)(()=>{f&&r&&s(e=>e??r)},[f,r]),!r)return f&&a?(0,K.jsx)(`p`,{role:`alert`,className:`m-3 rounded-lg border border-border px-3 py-2 text-sm text-danger`,children:`This project’s skills could not be read.`}):null;let p=async()=>{await i(),t?.()},m=async(e,t)=>{l(e);try{(await t()).ok&&await p()}finally{l(null)}},{newer:h,waiting:_,here:v,sending:y,inRequest:b,onBranch:x}=eP(r),S=()=>m(`update`,()=>tP(e,r,d)),C=()=>m(`send`,()=>d(()=>WN(e),`Could not send the skills.`)),w=o&&(0,K.jsx)(rP,{projectId:e,skills:o,onClose:()=>{s(null),n?.onClose()},onSaved:()=>void p()});return h.length===0&&!y&&!b&&!x&&!u?w||null:(0,K.jsxs)(`div`,{role:`status`,"aria-label":`This project's skills`,className:`m-3 flex flex-col gap-1.5 rounded-lg border border-border px-3 py-2 text-sm text-muted-foreground`,children:[h.length>0&&(0,K.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(JN,{names:h}),` `,h.length===1?`has a newer version`:`have newer versions`,`.`]}),(0,K.jsx)(V,{type:`button`,variant:`outline`,size:`xs`,className:`shrink-0`,disabled:c!==null,onClick:()=>void S(),children:c===`update`?`Updating…`:`Update`})]}),y&&(0,K.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(JN,{names:v}),` `,YN(v),` `,r.remote?`on this computer only`:`not committed`,`, so your agents do not have `,XN(v),` yet.`,r.local&&r.remote&&` Or pick My local branch when you start an agent.`]}),(0,K.jsx)(V,{type:`button`,variant:`outline`,size:`xs`,className:`shrink-0`,disabled:c!==null,onClick:()=>void C(),children:c===`send`?`Sending…`:QN(r)})]}),b&&(0,K.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(JN,{names:_}),` `,YN(_),` in pull request #`,r.request.number,`. Your agents get `,XN(_),` once it is merged.`]}),(0,K.jsxs)(`a`,{href:r.request.url,target:`_blank`,rel:`noreferrer`,className:_t({variant:`outline`,size:`xs`,className:`shrink-0`}),children:[`Open #`,r.request.number]})]}),x&&(0,K.jsxs)(`span`,{children:[(0,K.jsx)(JN,{names:_}),` `,YN(_),` on the branch `,r.branch,` on `,r.remote,`. Merge it into `,r.startBranch??`the default branch`,`, and your agents get `,XN(_),`.`]}),u&&(0,K.jsx)(`span`,{className:`text-danger`,children:u}),w]})}function eP(e){let t=KN(e).filter(e=>e.standing===`newer`).map(e=>e.name),n=KN(e).filter(e=>e.waiting).map(e=>e.name),r=e.request||e.branch?e.uncommitted:[...new Set([...e.uncommitted,...n])],i=e.git&&r.length>0,a=e.request!==void 0&&n.length>0,o=!a&&e.branch!==void 0&&n.length>0,s=KN(e).filter(GN).map(e=>e.name);return{newer:t,waiting:n,here:r,sending:i,inRequest:a,onBranch:o,held:s.length,heldNames:s}}async function tP(e,t,n){let{newer:r}=eP(t),i=await n(()=>UN(e,{write:r}),`Could not update the skills.`);return!i.ok||!t.git?i:n(()=>WN(e,r),`Could not send the skills.`)}function nP(e){let t=KN(e).filter(GN);return t.length>0?new Set(t.map(e=>e.name)):new Set(e.groups.filter(e=>e.ticked).flatMap(e=>e.skills.map(e=>e.name)))}function rP({projectId:e,skills:t,onClose:n,onSaved:r}){let[i,a]=(0,G.useState)(()=>nP(t)),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),{busy:u,error:d,run:f}=en(),p=(e,t)=>a(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),m=KN(t).filter(e=>i.has(e.name)&&!GN(e)).map(e=>e.name),h=KN(t).filter(e=>!i.has(e.name)&&GN(e)).map(e=>e.name),g=m.length===0&&h.length===0,_=async t=>{l(null);let n=await f(()=>WN(e,t),`Could not send the skills.`);n.ok&&l(n.value),r()},v=async()=>{let n=await f(()=>UN(e,{write:m,remove:h}),`Could not change the skills.`);if(!n.ok)return;s(n.value),r();let i=[...n.value.written,...n.value.removed];i.length>0&&t.git&&await _(i)},y=g||!t.git?`Save`:t.remote?`Save and send to ${t.remote}`:`Save and commit`,b=t.startBranch??`the default branch`;return(0,K.jsx)(mt,{open:!0,onOpenChange:e=>{!e&&!u&&n()},title:`Skills`,children:o?(0,K.jsxs)(`div`,{className:`space-y-2 text-xs leading-relaxed text-muted-foreground`,children:[o.written.length>0&&(0,K.jsxs)(`p`,{children:[`Wrote `,qN(o.written.length,`skill`,`skills`),` in `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`.agents/skills`}),`, linked in`,` `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1`,children:`.claude/skills`}),`: `,(0,K.jsx)(`span`,{className:`text-foreground`,children:o.written.join(`, `)}),`.`]}),o.removed.length>0&&(0,K.jsxs)(`p`,{children:[`Deleted `,qN(o.removed.length,`skill`,`skills`),`: `,(0,K.jsx)(`span`,{className:`text-foreground`,children:o.removed.join(`, `)}),`.`]}),o.scheduler===`on`&&(0,K.jsx)(`p`,{children:`The scheduler is on for this project, on this machine. Every automation starts switched off.`}),o.scheduler===`off`&&(0,K.jsx)(`p`,{children:`The scheduler is off for this project on this machine, and stopped.`}),o.left.map(({path:e,reason:t})=>(0,K.jsxs)(`p`,{children:[`Left as it is: `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1`,children:e}),` (`,t,`).`]},e)),o.schedulerError&&(0,K.jsxs)(`p`,{className:`text-danger`,children:[`The scheduler was not switched: `,o.schedulerError]}),o.written.length+o.removed.length>0&&!t.git&&(0,K.jsx)(`p`,{children:`This folder is not a git repository, so there is nothing to commit.`}),c?.ok&&c.sent===`committed`&&(0,K.jsx)(`p`,{children:`Committed. Your agents get this change from their next start.`}),c?.ok&&c.sent===`pushed`&&(0,K.jsxs)(`p`,{children:[`Sent to `,t.remote,`, on `,c.branch,`. Your agents get this change from their next start.`]}),c?.ok&&c.sent===`request`&&(0,K.jsxs)(`p`,{children:[t.remote,` took no push to `,b,`, so the change is in`,` `,(0,K.jsxs)(`a`,{href:c.request.url,target:`_blank`,rel:`noreferrer`,className:`text-foreground underline underline-offset-2`,children:[`pull request #`,c.request.number]}),`. Your agents get it once it is merged.`]}),c?.ok&&c.sent===`branch`&&(0,K.jsxs)(`p`,{children:[b,` took no push, so the change is on the branch `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1`,children:c.branch}),`. Merge it into `,b,`, and your agents get it.`]}),d&&(0,K.jsx)(`p`,{className:`text-danger`,children:o.written.length+o.removed.length>0?`Saved in the project's folder, not sent: ${d}`:d}),(0,K.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[d&&o.written.length+o.removed.length>0&&t.git&&(0,K.jsx)(V,{type:`button`,size:`sm`,disabled:u,onClick:()=>void _([...o.written,...o.removed]),children:u?`Sending…`:`Send again`}),(0,K.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,disabled:u,onClick:n,children:`Done`})]})]}):(0,K.jsxs)(`div`,{className:`text-xs`,children:[(0,K.jsxs)(`p`,{className:`mb-2 leading-relaxed text-muted-foreground`,children:[`A ticked skill is written into the project’s folder and an unticked one is deleted`,t.remote?`; Save sends the change to ${t.remote}, where your agents start from`:t.git?`; Save commits the change`:``,`. The skills every agent gets by default come with every run and are not here.`]}),(0,K.jsx)(`div`,{className:`max-h-[55vh] space-y-3 overflow-y-auto pr-1`,children:t.groups.map(e=>(0,K.jsxs)(`fieldset`,{children:[(0,K.jsx)(`legend`,{className:`mb-1 font-medium text-foreground`,children:e.title}),e.skills.map(e=>(0,K.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 py-0.5`,children:[(0,K.jsx)(Nt,{checked:i.has(e.name),onCheckedChange:t=>p(e.name,t===!0),disabled:u,className:`mt-0.5`,"aria-label":e.name}),(0,K.jsxs)(`span`,{className:`min-w-0`,children:[(0,K.jsx)(`span`,{className:`text-foreground`,children:e.name}),ZN[e.standing]&&(0,K.jsxs)(`span`,{className:`text-warning`,children:[` (`,ZN[e.standing],`)`]}),e.waiting&&t.startBranch!==void 0&&(0,K.jsxs)(`span`,{className:`text-warning`,children:[` (waiting to reach `,t.startBranch,`)`]}),(0,K.jsx)(`span`,{className:`block text-muted-foreground`,children:e.description})]})]},e.name))]},e.title))}),d&&(0,K.jsx)(`p`,{className:`mt-2 text-danger`,children:d}),(0,K.jsxs)(`div`,{className:`mt-3 flex items-center justify-end gap-2`,children:[(0,K.jsx)(`span`,{className:`mr-auto text-muted-foreground`,children:g?`Nothing to change.`:[m.length>0?`${qN(m.length,`skill`,`skills`)} to write`:``,h.length>0?`${qN(h.length,`skill`,`skills`)} to delete`:``].filter(Boolean).join(`, `)+`.`}),(0,K.jsx)(V,{type:`button`,variant:`outline`,size:`sm`,disabled:u,onClick:n,children:`Cancel`}),(0,K.jsx)(V,{type:`button`,size:`sm`,disabled:u||g,onClick:()=>void v(),children:u?`Saving…`:y})]})]})})}function iP({events:e,headline:t=!1}){let n=aP(e);if(n.length===0)return null;let r=n[n.length-1];return(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsxs)(`span`,{role:`alert`,className:`flex shrink-0 items-center gap-1.5 text-danger`,children:[(0,K.jsx)(Wa,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsxs)(`span`,{className:`font-medium`,children:[n.length,` `,n.length===1?`error`:`errors`]}),t&&(0,K.jsxs)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:[`· `,r.headline]})]})}),(0,K.jsx)(z,{className:`whitespace-pre-line`,children:n.map(e=>e.headline).join(`
131
131
  `)})]})}function aP(e){let t=Dn(e),n=Ik(e),r=n&&!n.ok&&!n.stopped&&!n.waiting?n.detail:void 0;return r?t.filter(e=>!r.includes(e.headline)):t}function oP(e){if(e.length===0)return null;let t=Ik(e);return t!==void 0&&!t.ok&&!t.stopped&&!t.waiting?{dot:`bg-danger`,label:`failed`,tone:`text-danger`,...t?.detail?{detail:t.detail}:{}}:t?.stopped?{dot:`bg-warning`,label:`stopped`,tone:`text-warning`}:t?.waiting?{dot:`bg-warning`,label:`waiting for an answer`,tone:`text-warning`}:Fk(e)?{dot:`animate-pulse bg-warning`,label:`building…`,tone:`text-muted-foreground`}:{dot:`bg-muted-foreground`,label:`finished`,tone:`text-muted-foreground`}}function sP({events:e}){let t=On(e),n=oP(e),r=aP(e),i=Vk(t);return!i&&!n&&r.length===0?null:(0,K.jsxs)(`div`,{className:`grid gap-3 border-b border-border p-4 md:grid-cols-2`,children:[n&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm md:col-span-2`,children:[(0,K.jsx)(`span`,{className:B(`h-2.5 w-2.5 shrink-0 rounded-full`,n.dot),"aria-hidden":!0}),(0,K.jsx)(`span`,{className:B(`text-xs`,n.tone),children:n.detail?`${n.label} — ${n.detail}`:n.label})]}),r.length>0&&(0,K.jsx)(`div`,{className:`text-sm md:col-span-2`,children:(0,K.jsx)(iP,{events:e,headline:!0})}),i&&(0,K.jsx)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer`,className:`text-xs text-primary underline underline-offset-2 md:col-span-2`,children:i.label})]})}function cP({projectId:e,projectName:t,waiting:n,events:r,onAgentStarted:i,files:a,context:o,addContext:s,removeContext:c,toggleContext:l,onOpenAgent:u,errors:d,onProjectRemoved:f,onSkillsChanged:p,home:m}){let[h,g]=(0,G.useState)(null);return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(VN,{projectId:e,onProjectRemoved:m===void 0?f:void 0}),(0,K.jsx)(Mo,{errors:d}),(0,K.jsx)(Ye,{className:`min-h-0 flex-1`,children:(0,K.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl`,children:[r.length>0&&(0,K.jsx)(sP,{events:r}),n.length>0&&(0,K.jsxs)(`section`,{"aria-label":`Waiting on you`,className:`p-3`,children:[(0,K.jsxs)(`h2`,{className:`mb-3 px-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:[`Waiting on you · `,n.length]}),(0,K.jsx)(Vo,{items:n,onOpenAgent:u},e)]}),(0,K.jsx)($N,{projectId:e,onChanged:p,door:{open:h===e,onClose:()=>g(null)}},e)]})}),(0,K.jsx)(jk,{projectId:e,projectName:t,onAgentStarted:i,files:a,context:o,addContext:s,removeContext:c,toggleContext:l,onOpenSkills:()=>g(e),home:m})]})}var lP=W(`onQuota`),uP=3e4;function dP(){return g(lP,void 0,uP,[],{remember:`quota`,stored:!0}).value}function fP(e){return new Intl.DateTimeFormat(`en-US`,{weekday:`short`}).format(e).slice(0,2).toUpperCase()}function pP(e,t,n=fP){let r=t-e;if(!(r>0))return[];let i=[e],a=new Date(e);for(a.setHours(24,0,0,0);a.getTime()<t;)i.push(a.getTime()),a.setHours(24,0,0,0);i.push(t);let o=[];for(let t=0;t<i.length-1;t++){let a=i[t],s=i[t+1];o.push({startPercent:(a-e)/r*100,endPercent:(s-e)/r*100,label:n(a)})}let s=o[0],c=o.at(-1);return o.length>1&&s.label===c.label&&(s.endPercent-s.startPercent>=c.endPercent-c.startPercent?c.label=void 0:s.label=void 0),o}var mP=5;function hP(e,t,n=mP){return e>=100?`full`:e>t+n?`over`:e>=t-n?`near`:`under`}function gP(e,t){return Math.min(Math.max(e+t,0),100)}function _P(e,t,n){return(e-t)/100*n}function vP(e,t){return Math.min(Math.max(e,0),100)/100*t}function yP(e,t){if(!(t<=0))return e/t*100}function bP(e,t){let n=Math.min(Math.max(e,0),100);return{start:n,end:Math.max(n,Math.min(Math.max(t,0),100))}}var xP={under:`bg-success`,near:`bg-info`,over:`bg-warning`,full:`bg-danger`},SP={under:`text-success`,near:`text-info`,over:`text-warning`,full:`text-danger`},CP=` — `;function wP(e){return e.find(e=>e.kind===`week`)}function TP(e,t){let n=t.map(e=>`“${e.label}”`).join(`, `);return e?e.resetsAtText?`Couldn't parse quota: the week resets “${e.resetsAtText}”, which isn't a phrasing this version recognizes.`:`No quota week to place: “${e.label}” reports ${e.percentUsed}% used but no reset time, and the week is drawn between its start and its reset — there is no span to place it in.`:`Couldn't parse quota: no “Current week (all models)” line in the readout — it reported ${n}.`}function EP({swatch:e,children:t}){return(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e,t]})}function DP({boundary:e,percentUsed:t,offset:n,onChangeOffset:r,others:i}){let a=pP(e.startsAt,e.resetsAt),o=hP(t,e.percent),s=n!==void 0,c=gP(e.percent,n??0),l=bP(t,s?c:t),u=s&&l.end>l.start,d=_P(c,e.percent,e.resetsAt-e.startsAt),f=s&&c>e.percent+14.285714285714286,p=`${Math.round(t)}% of the week used, against a boundary of ${Math.round(e.percent)}% on day ${e.day} of 7`,m=e.resetsAt-e.startsAt,h=_P(t,e.percent,m),g=h>=0,_=vP(t,m),v=yP(t,e.percent);return(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`div`,{className:`relative h-4 text-[10px] font-medium tracking-wide text-muted-foreground`,children:a.map((e,t)=>e.label&&(0,K.jsx)(`span`,{className:`absolute top-0 -translate-x-1/2`,style:{left:`${(e.startPercent+e.endPercent)/2}%`},children:e.label},t))}),(0,K.jsxs)(`div`,{className:`relative h-4`,children:[(0,K.jsxs)(`div`,{role:`img`,"aria-label":p,className:`absolute inset-x-0 top-[3px] h-2.5 overflow-hidden rounded-full bg-muted`,children:[(0,K.jsx)(`div`,{className:B(`absolute inset-y-0 left-0`,xP[o]),style:{width:`${l.start}%`}}),u&&(0,K.jsx)(`div`,{className:B(`absolute inset-y-0 opacity-35`,xP[o]),style:{left:`${l.start}%`,width:`${l.end-l.start}%`}}),a.slice(1).map((e,t)=>(0,K.jsx)(`div`,{className:`absolute inset-y-0 w-1 bg-background/60`,style:{left:`${e.startPercent}%`},"aria-hidden":!0},t)),(0,K.jsx)(`div`,{className:`absolute inset-y-0 w-0.5 -translate-x-1/2 bg-foreground`,style:{left:`${Math.min(Math.max(e.percent,0),100)}%`},"aria-hidden":!0})]}),s&&(0,K.jsx)(`input`,{type:`range`,"aria-label":`Unattended work stops at`,className:B(`absolute inset-0 h-full w-full cursor-grab appearance-none bg-transparent active:cursor-grabbing`,`[&::-webkit-slider-runnable-track]:bg-transparent`,`[&::-moz-range-track]:border-none [&::-moz-range-track]:bg-transparent`,`[&::-webkit-slider-thumb]:h-3.5 [&::-webkit-slider-thumb]:w-3.5 [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:rounded-full`,`[&::-webkit-slider-thumb]:border [&::-webkit-slider-thumb]:border-background [&::-webkit-slider-thumb]:bg-foreground [&::-webkit-slider-thumb]:shadow-sm`,`[&::-moz-range-thumb]:h-3.5 [&::-moz-range-thumb]:w-3.5 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:border-none`,`[&::-moz-range-thumb]:border [&::-moz-range-thumb]:border-background [&::-moz-range-thumb]:bg-foreground [&::-moz-range-thumb]:shadow-sm`),min:0,max:100,step:`any`,value:c,onChange:t=>{let n=Math.round(Number(t.target.value)-e.percent);r?.(Math.min(Math.max(n,-50),50))}})]}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[(0,K.jsxs)(U,{children:[(0,K.jsxs)(H,{render:(0,K.jsx)(`span`,{className:`cursor-default`}),children:[`You are `,(0,K.jsx)(`span`,{className:B(`font-medium`,SP[o]),children:b(Math.abs(h))}),` `,g?`over`:`under`,` the week's pace`]}),(0,K.jsxs)(z,{className:`max-w-64`,children:[`You are `,pe(Math.abs(h)),` `,g?`above`:`below`,` the quota boundary.`,(0,K.jsx)(`br`,{}),(0,K.jsx)(`br`,{}),`You're`,` `,g?`over-consuming`:`under-consuming`,`: you spend `,g?`faster`:`slower`,` than the week's pace allows.`]})]}),`:`,` `,(0,K.jsxs)(U,{children:[(0,K.jsxs)(H,{render:(0,K.jsx)(`span`,{className:`cursor-default`}),children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:b(_)}),` spent`]}),(0,K.jsxs)(z,{className:`max-w-64`,children:[pe(_),` of the week's allowance has been consumed — `,Math.round(t),`% of it, said in the same unit as the pace figure beside it.`]})]}),v!==void 0&&(0,K.jsxs)(K.Fragment,{children:[`,`,` `,(0,K.jsxs)(U,{children:[(0,K.jsxs)(H,{render:(0,K.jsx)(`span`,{className:`cursor-default`}),children:[(0,K.jsxs)(`span`,{className:B(`font-medium`,SP[o]),children:[Math.round(v),`%`]}),` of pace`]}),(0,K.jsxs)(z,{className:`max-w-64`,children:[`Against the `,Math.round(e.percent),`% of the week allowed by day `,e.day,` of 7 — 100% is exactly on pace. This is the line that parks unattended work, not the week's total.`]})]})]}),`.`,` `,(0,K.jsxs)(U,{children:[(0,K.jsxs)(H,{render:(0,K.jsx)(`span`,{className:`cursor-default`}),children:[`Resets `,wt(e.resetsAt)]}),(0,K.jsx)(z,{children:oe(e.resetsAt)})]}),`.`,i.length>1?(0,K.jsxs)(K.Fragment,{children:[` `,(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(`span`,{className:`cursor-default`}),children:`Show all limits`}),(0,K.jsx)(z,{children:(0,K.jsx)(`table`,{className:`border-collapse text-left`,children:(0,K.jsx)(`tbody`,{children:i.map(e=>(0,K.jsx)(kP,{window:e},e.label))})})})]})]}):null]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1 text-[11px] text-muted-foreground max-sm:text-xs`,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[(0,K.jsx)(EP,{swatch:(0,K.jsx)(`span`,{className:B(`h-2 w-2 rounded-sm`,xP[o]),"aria-hidden":!0}),children:`Used`}),s&&(0,K.jsx)(EP,{swatch:(0,K.jsx)(`span`,{className:B(`h-2 w-2 rounded-sm opacity-35`,xP[o]),"aria-hidden":!0}),children:`Budget for Autonomous AI`}),(0,K.jsx)(EP,{swatch:(0,K.jsx)(`span`,{className:`h-2 w-0.5 bg-foreground`,"aria-hidden":!0}),children:(0,K.jsxs)(U,{children:[(0,K.jsxs)(H,{render:(0,K.jsx)(`span`,{className:`inline-flex cursor-default items-center gap-0.5`}),children:[`Quota boundary`,(0,K.jsx)(ea,{className:`h-3 w-3`,"aria-hidden":!0})]}),(0,K.jsxs)(z,{className:`max-w-64 space-y-2`,children:[(0,K.jsx)(`p`,{children:`Not a hard limit — just an indication of whether you're over- or under-consuming. It's calculated as a pro-rated share of the weekly limit.`}),(0,K.jsx)(`p`,{children:`If your usage matches the quota boundary, then you're spending exactly what the week's pace allows.`}),(0,K.jsx)(`p`,{children:`Fun fact: the quota boundary is shown exactly at the current time in the week usage bar above.`})]})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[f&&(0,K.jsxs)(U,{children:[(0,K.jsxs)(H,{render:(0,K.jsx)(`span`,{className:`inline-flex cursor-default items-center gap-1 text-warning`}),children:[(0,K.jsx)(Wa,{className:`h-3 w-3`,"aria-hidden":!0}),`Eager consumption`,(0,K.jsx)(ea,{className:`h-3 w-3`,"aria-hidden":!0})]}),(0,K.jsxs)(z,{children:[`Autonomous AI will spend tokens `,pe(d),` faster than the week's pace allows`]})]}),s&&(0,K.jsxs)(U,{children:[(0,K.jsxs)(H,{render:(0,K.jsx)(`span`,{className:B(`inline-flex cursor-default items-center gap-1.5 text-xs`,u?`text-foreground`:`text-warning`)}),children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:B(`size-1.5 shrink-0 rounded-full`,u?`bg-success`:`bg-warning`)}),u?(0,K.jsxs)(K.Fragment,{children:[`Agents may start work on their own up to `,(0,K.jsxs)(`strong`,{className:`tabular-nums`,children:[Math.round(c),`%`]}),` of the week`,(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`· drag the handle to change`})]}):(0,K.jsxs)(K.Fragment,{children:[`Agents start no work on their own`,(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`· drag the handle right to allow it`})]})]}),(0,K.jsx)(z,{className:`max-w-64`,children:u?`Autonomous AI enabled means that unattended work may start on its own while the account is under the line.`:`Autonomous AI disabled means that no agent starts on its own — every new agentic work is triggered by you manually.`})]})]})]})]})}function OP({window:e}){return(0,K.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:e.label}),(0,K.jsxs)(`span`,{className:`text-muted-foreground`,children:[Math.round(e.percentUsed),`% used`,e.resetsAtText?`${CP}resets ${e.resetsAtText}`:``]})]})}function kP({window:e}){return(0,K.jsxs)(`tr`,{children:[(0,K.jsx)(`td`,{className:`pr-3 align-baseline text-muted-foreground`,children:e.label}),(0,K.jsxs)(`td`,{className:`whitespace-nowrap align-baseline text-muted-foreground`,children:[Math.round(e.percentUsed),`% used`,e.resetsAtText?`${CP}resets ${e.resetsAtText}`:``]})]})}function AP(e){switch(e.unavailable){case void 0:return;case`no-subscription`:return`This account has no subscription usage to report, so there is no boundary to measure against.`;case`agent-not-found`:return`Claude Code was not found, so usage cannot be read.`;case`unrecognized`:return e.windows.length?`Claude Code's latest usage readout wasn't one this version recognizes, so these numbers are from the reading before it.`:`Claude Code reported its usage in a way this version does not recognize. Trying again shortly.`;default:return e.windows.length?`Couldn't refresh just now, so these numbers may be a little behind.`:`Reading your usage now.`}}var jP=500;function MP(e,t){let[n,r]=(0,G.useState)(e),[i,a]=(0,G.useState)(),o=(0,G.useRef)(null),s=(0,G.useRef)(void 0);return(0,G.useEffect)(()=>{e!==void 0&&(o.current!==null&&o.current!==e||(o.current=null,r(e)))},[e]),(0,G.useEffect)(()=>()=>clearTimeout(s.current),[]),[n,n=>{r(n),a(void 0),o.current=n,clearTimeout(s.current),s.current=setTimeout(()=>{t(n).then(t=>{t.ok||o.current!==n||(o.current=null,a(t.error),e!==void 0&&r(e))})},jP)},i]}function NP({limit:e,projects:t,boundary:n,percentUsed:r,others:i}){let a=yt(),o=t.map(e=>e.id).join(`,`),{value:s}=g(()=>e.read(a,t),void 0,1e4,[e.package,o],{remember:`usage-limit:${e.package}:${o}`,stored:!0}),[c,l,u]=MP(s,n=>e.save(a,t,n));return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(DP,{boundary:n,percentUsed:r,...c===void 0?{}:{offset:c,onChangeOffset:l},others:i}),u&&(0,K.jsxs)(`p`,{role:`alert`,className:`text-xs text-danger`,children:[`The limit was not saved: `,u]})]})}function PP({projects:e}){let t=dP(),{usageLimit:n}=sn(),r=(cc(`claude`).view?.accounts??[]).filter(e=>!e.own),i=t&&!(t.windows.length===0&&r.length>0)?AP(t):void 0,a=t?.unavailable!==void 0&&t.windows.length>0?t.readAt:void 0,s=t?wP(t.windows):void 0,c=t?.windows??[];return(0,K.jsxs)(o,{children:[(0,K.jsx)($t,{children:(0,K.jsx)(Rt,{className:`text-base`,children:`Usage`})}),(0,K.jsxs)(lt,{className:`space-y-4`,children:[!t&&(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Reading your usage…`}),t?.boundary&&s?n?(0,K.jsx)(Qk,{package:n.package,label:`usage limit`,children:(0,K.jsx)(NP,{limit:n,projects:$k(n.projects,e),boundary:t.boundary,percentUsed:s.percentUsed,others:c})}):(0,K.jsx)(DP,{boundary:t.boundary,percentUsed:s.percentUsed,others:c}):t&&t.windows.length?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:TP(s,c)}):null,!(t?.boundary&&s)&&c.length?(0,K.jsx)(`div`,{className:`space-y-1 border-t border-border pt-3`,children:c.map(e=>(0,K.jsx)(OP,{window:e},e.label))}):null,(0,K.jsx)(xc,{}),i?(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[i,a===void 0?``:` Last read ${u(new Date(a).toISOString())}.`]}):null]})]})}var FP=`/update-tickets`;function IP({busy:e,onStart:t,onConfigure:n,lastImportedAt:r,disabled:i,variant:a,size:o=`sm`,className:s}){return(0,K.jsx)(Ce,{...a?{variant:a}:{},size:o,...i===void 0?{}:{disabled:i},...s?{className:s}:{},icon:(0,K.jsx)(La,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),label:`Update tickets`,menuAriaLabel:`Other ways to update the tickets`,tooltip:r?`Bring tickets/ up to date with the issues and comments changed since the last import.`:`Bring tickets/ up to date with the issue tracker. With no import on record, everything open comes across.`,busy:e,starting:e,onStart:t,onConfigure:n,prompt:FP,configureDescription:`Opens the launcher with the update prompt, so you can set the model and where it runs.`})}var LP=`Hide; Settings › Appearance brings it back`,RP=e=>e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;function zP(){let[e,t]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`space-y-1`,children:[(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Agents work in the project's folder, each in its own copy and on its own branch. Your files and your branch stay as they are.`}),(0,K.jsxs)(`button`,{type:`button`,"aria-expanded":e,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,onClick:()=>t(!e),children:[(0,K.jsx)(m,{"aria-hidden":!0,className:e?`h-3 w-3 rotate-90`:`h-3 w-3`}),`What adding a project does`]}),e&&(0,K.jsx)(`div`,{className:`pl-4`,children:(0,K.jsx)(ko,{})})]})}function BP({onAgentStarted:e,onSelectProject:t}){let{value:n,reload:r}=g(kr,null,1e4,[]),{value:i,reload:a}=g(li,null,3e4,[]),s=lr(),c=$o(),{start:l,busy:u,error:d}=fl(),{missing:f}=zs(),[p,m]=(0,G.useState)(null),h=i?.cwdProjectId??n?.projects[0]?.projectId??null,_=n?.totals.projects??0,v=n?.projects.some(e=>e.hasTickets)??!1,y=c===`granted`&&pr(s),b=()=>{or({notifyBrowser:!0}),c==="default"&&Notification.requestPermission()},x=async()=>{if(!h)return;let t=await l(h,FP,cl(s));t&&e(h,FP,t.agentId)},S=i?.cwd&&!i.cwdProjectId?i.cwd:void 0,C=[...f.length>0?[{key:`ready`,label:`Get ready`,description:`What runs need on this computer. Each is one press, with no admin.`,done:!1,action:(0,K.jsx)(`ul`,{className:`space-y-3`,children:f.map(e=>(0,K.jsxs)(`li`,{className:`space-y-1.5`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium`,children:e.words}),e.fix]},e.key))})}]:[],{key:`project`,label:`Add a project`,description:n&&_===0?(0,K.jsx)(zP,{}):`A project is a git repo OpenAgent may work in.`,done:_>0,action:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[S&&(0,K.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,K.jsxs)(V,{size:`sm`,onClick:()=>m({folder:S}),children:[(0,K.jsx)(fa,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Add “${RP(S)}”`]}),(0,K.jsx)(`p`,{className:`truncate font-mono text-[11px] text-muted-foreground`,title:S,children:`The folder OpenAgent runs in: ${S}`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i?.canPickFolder!==!1&&(0,K.jsx)(V,{size:`sm`,variant:S?`outline`:`default`,onClick:()=>m({}),children:S?`Choose another folder…`:`Choose a folder…`}),(0,K.jsx)(V,{size:`sm`,variant:`outline`,onClick:()=>m({fromAddress:!0}),children:`Add from a GitHub address`})]})]})},...(n?.queue.length??0)>0?[{key:`todos`,label:`Populate the queue of AI tasks`,description:`The agent queue: each entry is work the agent picks up on its own, so a filled queue is what lets it keep going without you.`,done:(n?.totals.openTodos??0)>0}]:[],...n?.projects.some(e=>e.providesTickets)?[{key:`tickets`,label:`Populate tickets/`,description:`tickets/ holds the bigger things to work on, in the repo. The agent researches and plans them, and they are the input the queue is filled from.`,done:v,optional:!0,action:(0,K.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,K.jsx)(IP,{variant:`default`,busy:u,disabled:!h,onStart:()=>void x(),onConfigure:()=>h&&t(h)}),!h&&(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Add a project first`}),d&&(0,K.jsx)(`span`,{className:`text-xs text-destructive`,children:d})]})}]:[],{key:`browser-notification`,label:`Add browser notifications`,description:`Desktop pings while the dashboard is open, so a session waiting on you does not sit unnoticed.`,done:y,optional:!0,action:c===`denied`?(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Blocked in your browser settings`}):c===`unsupported`?(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Not supported by this browser`}):(0,K.jsx)(V,{size:`sm`,variant:`outline`,onClick:b,children:`Enable`})}],w=C.filter(e=>e.done).length;return(0,K.jsxs)(o,{children:[(0,K.jsxs)($t,{className:`flex flex-row items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Rt,{className:`text-base`,children:`Onboarding`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[w,` of `,C.length,` set up.`]}),(0,K.jsx)(`div`,{"aria-hidden":!0,className:`mt-2 h-1 w-40 overflow-hidden rounded-full bg-muted-foreground/15`,children:(0,K.jsx)(`div`,{className:`h-full rounded-full bg-[var(--color-primary)]`,style:{width:`${w/Math.max(1,C.length)*100}%`}})})]}),(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>or({onboardingDismissed:!0}),"aria-label":LP}),children:(0,K.jsx)(ee,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsx)(z,{children:LP})]})]}),(0,K.jsx)(lt,{children:(0,K.jsx)(`ul`,{className:`divide-y divide-border`,children:C.map(e=>(0,K.jsxs)(`li`,{className:`flex items-start gap-3 py-4 first:pt-0 last:pb-0`,children:[e.done?(0,K.jsx)(Ba,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--color-primary)]`,"aria-label":`Done`}):(0,K.jsx)(Va,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`,"aria-label":`Not done`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`p`,{className:e.done?`text-sm text-muted-foreground line-through`:`text-sm font-medium`,children:[e.label,e.optional&&(0,K.jsx)(`span`,{className:`ml-2 rounded-full border border-border px-1.5 py-0.5 align-middle text-[10px] font-normal uppercase tracking-wide text-muted-foreground`,children:`Optional`})]}),typeof e.description==`string`?(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.description}):(0,K.jsx)(`div`,{className:`mt-1`,children:e.description})]}),!e.done&&e.action&&(0,K.jsx)(`div`,{className:`max-w-full`,children:e.action})]})]},e.key))})}),p&&(0,K.jsx)(Ao,{folder:p.folder,fromAddress:p.fromAddress===!0,onAdded:()=>{r(),a()},onClose:()=>m(null)})]})}function VP({working:e,onSelectAgent:t}){return(0,K.jsxs)(o,{children:[(0,K.jsx)($t,{children:(0,K.jsxs)(Rt,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)(Yi,{className:`h-4 w-4 shrink-0 text-muted-foreground`}),`Agents`,(0,K.jsx)(`span`,{className:`truncate text-xs font-normal text-muted-foreground`,children:`Agents currently working`})]})}),(0,K.jsx)(lt,{children:e.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No agent is at work.`}):(0,K.jsx)(`ul`,{className:`space-y-0.5`,children:e.map(e=>(0,K.jsx)(HP,{label:UP(e),cloud:e.cloud,computer:e.computer,at:e.updatedAt,projectName:e.projectName,onOpen:()=>t(e.projectId,e.agentId)},`${e.projectId}:${e.agentId}`))})})]})}function HP({label:e,cloud:t,computer:n,at:r,projectName:i,onOpen:a}){return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,onClick:a,className:`flex w-full items-baseline gap-2 rounded-md px-2 py-1.5 text-left hover:bg-accent focus-visible:bg-accent focus-visible:outline-none`,children:[(0,K.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-muted-foreground/50`,children:`•`}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:e}),t&&(0,K.jsx)(`span`,{className:`shrink-0 text-[10px] uppercase text-muted-foreground`,children:t===`waiting`?`waiting`:`in cloud`}),(0,K.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:i}),n&&(0,K.jsx)(O,{computer:n}),r&&(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-xs tabular-nums text-muted-foreground/80`}),children:an(r)}),(0,K.jsx)(z,{children:Oe(r)})]})]})})}function UP(e){return e.intent?.trim()||e.scope?.trim()||e.projectName}function WP(e){let{cards:t}=sn();return t.flatMap(t=>{let n=t.Card,r=t.computer?$k(e.map(e=>e.id),e):$k(t.projects,e);return r.length===0&&!t.computer?[]:[{id:`${t.package}/${t.id}`,label:t.label,order:t.order??50,width:t.width??`1/2`,minWidth:t.minWidth??`1/3`,node:(0,K.jsx)(Qk,{package:t.package,label:`${t.id} card`,children:(0,K.jsx)(n,{projects:r})})}]})}var GP=`@openagt/skill-logs`,KP=5;function qP(e){let t=new Map;for(let n of e.flatMap(e=>e.used)){let e=t.get(n.skill);e?(e.uses+=n.uses,e.runs+=n.runs,n.lastAt>e.lastAt&&(e.lastAt=n.lastAt)):t.set(n.skill,{...n})}return[...t.values()].sort((e,t)=>t.uses-e.uses||t.lastAt.localeCompare(e.lastAt))}var JP=[];function YP({projects:e,onSelectProject:t}){let n=e.map(e=>e.id).join(`,`),{value:r,loaded:i,reload:a}=g(()=>Promise.all(e.map(async e=>{let[t,n]=await Promise.all([HN(e.id).catch(()=>null),it(e.id,GP,[`skills`,`--local`,`--days`,`30`]).then(e=>e.ok&&Array.isArray(e.output)?e.output:[],()=>[])]);return{project:e,skills:t,used:n}})),JP,6e4,[n],{remember:`skills-card:${n}`,stored:!0}),s=qP(r),c=new Set(s.map(e=>e.skill)),l=[...new Set(r.flatMap(e=>e.skills?eP(e.skills).heldNames:[]))].filter(e=>!c.has(e)).sort(),u=r.filter(e=>e.skills&&eP(e.skills).newer.length>0),[d,f]=(0,G.useState)(!1),p=en(),m=async()=>{f(!0);try{for(let e of u)if(!(await tP(e.project.id,e.skills,p.run)).ok)break;await a()}finally{f(!1)}};return(0,K.jsxs)(o,{children:[(0,K.jsxs)($t,{children:[(0,K.jsxs)(Rt,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)(Ia,{className:`h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),`Skills`,u.length>1&&(0,K.jsx)(V,{variant:`outline`,size:`xs`,className:`ml-auto font-normal`,disabled:d,onClick:()=>void m(),title:`Take the newer versions in ${u.map(e=>e.project.name).join(`, `)}`,children:d?`Updating…`:`Update all (${u.length})`})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`What your agents know, and what is new`})]}),(0,K.jsx)(lt,{children:i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ul`,{className:`space-y-2`,children:r.map(e=>(0,K.jsx)(XP,{read:e,reload:a,onOpen:()=>t(e.project.id)},e.project.id))}),p.error&&(0,K.jsx)(`p`,{className:`mt-2 text-xs text-danger`,children:p.error}),(0,K.jsx)(ZP,{used:s,unused:l})]}):(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`})})]})}function XP({read:e,reload:t,onOpen:n}){let{project:r,skills:i}=e,[a,o]=(0,G.useState)(!1),{error:s,run:c}=en(),l=async e=>{o(!0);try{(await e()).ok&&await t()}finally{o(!1)}},u=i?eP(i):void 0;return(0,K.jsxs)(`li`,{"aria-label":r.name,className:`min-w-0`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-sm`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:n,className:`min-w-0 truncate font-medium hover:underline`,children:r.name}),u&&u.held>0&&(0,K.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:u.held===1?`1 skill`:`${u.held} skills`}),(0,K.jsx)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1.5`,children:!i||!u?(0,K.jsx)(`span`,{className:`text-xs text-danger`,children:`could not be read`}):u.held===0?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`no skills yet`}),(0,K.jsx)(V,{variant:`outline`,size:`xs`,onClick:n,title:`Open the project, where Skills lists them to pick`,children:`Add`})]}):u.newer.length>0?(0,K.jsx)(V,{variant:`outline`,size:`xs`,disabled:a,onClick:()=>void l(()=>tP(r.id,i,c)),title:`Newer versions: ${u.newer.join(`, `)}`,children:a?`Updating…`:`Update ${u.newer.length}`}):u.sending?(0,K.jsx)(V,{variant:`outline`,size:`xs`,disabled:a,onClick:()=>void l(()=>c(()=>WN(r.id),`Could not send the skills.`)),title:`Not where agents start from yet: ${u.here.join(`, `)}`,children:a?`Sending…`:QN(i)}):u.inRequest?(0,K.jsxs)(`a`,{href:i.request.url,target:`_blank`,rel:`noreferrer`,className:`text-xs text-info hover:underline`,children:[`in #`,i.request.number]}):u.onBranch?(0,K.jsx)(`span`,{className:`text-xs text-warning`,title:`On the branch ${i.branch}: merge it into ${i.startBranch??`the default branch`}`,children:`to merge`}):(0,K.jsxs)(`span`,{className:`flex items-center gap-1 text-xs text-success`,children:[(0,K.jsx)($i,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`up to date`]})})]}),u&&(u.newer.length>0||u.sending||u.inRequest)&&(0,K.jsx)(`p`,{className:B(`truncate text-xs`,u.newer.length>0?`text-warning`:`text-muted-foreground`),children:u.newer.length>0?`${u.newer.length===1?`1 has a newer version`:`${u.newer.length} have newer versions`}: ${u.newer.join(`, `)}`:u.sending?`${u.here.length} not where agents start from yet`:`${u.waiting.length} waiting in pull request #${i.request.number}`}),s&&(0,K.jsx)(`p`,{className:`text-xs text-danger`,children:s})]})}function ZP({used:e,unused:t}){if(e.length===0)return null;let n=e[0].uses,r=e.length-KP;return(0,K.jsxs)(`section`,{"aria-label":`Most used`,className:`mt-3 border-t border-border pt-3`,children:[(0,K.jsx)(`h4`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:`Most used, last 30 days`}),(0,K.jsx)(`ul`,{className:`space-y-1`,children:e.slice(0,KP).map(e=>(0,K.jsxs)(`li`,{"aria-label":e.skill,className:`flex items-center gap-2 text-xs`,title:`Used ${e.uses} times in ${e.runs===1?`1 run`:`${e.runs} runs`}`,children:[(0,K.jsx)(`span`,{className:`w-24 shrink-0 truncate font-mono`,children:e.skill}),(0,K.jsx)(`span`,{className:`h-1 min-w-0 flex-1 overflow-hidden rounded-full bg-muted-foreground/15`,"aria-hidden":!0,children:(0,K.jsx)(`span`,{className:`block h-full rounded-full bg-primary/70`,style:{width:`${Math.max(4,Math.round(e.uses/n*100))}%`}})}),(0,K.jsx)(`span`,{className:`w-8 shrink-0 text-right text-muted-foreground tabular-nums`,children:e.uses})]},e.skill))}),r>0&&(0,K.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`and `,r===1?`1 more`:`${r} more`]}),t.length>0&&(0,K.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,title:t.join(`, `),children:[(0,K.jsx)(`span`,{className:`text-foreground/80`,children:`Not used:`}),` `,t.slice(0,4).join(`, `),t.length>4?` and ${t.length-4} more`:``]})]})}var QP={"1/4":`@2xl:col-span-6 @5xl:col-span-3`,"1/3":`@2xl:col-span-6 @5xl:col-span-4`,"1/2":`@2xl:col-span-6`,"2/3":`@2xl:col-span-6 @5xl:col-span-8`,"3/4":`@2xl:col-span-6 @5xl:col-span-9`,1:``};function $P({cards:e}){return(0,K.jsx)(nF,{children:e.map(({card:e,width:t})=>(0,K.jsx)(tF,{card:e,className:B(`col-span-12 flex min-w-0 flex-col *:flex-1`,QP[t])},e.id))})}var eF=new Set;function tF({card:e,className:t}){let[n,r]=(0,G.useState)(eF),i=(0,G.useCallback)((e,t)=>{r(n=>{if(n.has(e)===t)return n;let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),a=e.stale===!0||n.size>0;return(0,K.jsx)(`div`,{"data-card":e.id,"data-stale":a||void 0,className:B(t,`transition-opacity duration-300`,a&&`opacity-60`),children:(0,K.jsx)(fn.Provider,{value:i,children:e.node})})}function nF({children:e,onDragOver:t,onDrop:n}){return(0,K.jsx)(`div`,{className:`@container`,children:(0,K.jsx)(`div`,{className:`grid grid-cols-12 gap-4`,onDragOver:t,onDrop:n,children:e})})}var rF={"1/4":`¼`,"1/3":`⅓`,"1/2":`½`,"2/3":`⅔`,"3/4":`¾`,1:`Full`},iF=(e,t)=>e===`end`||t===`end`?e===t:e.id===t.id&&e.side===t.side,aF=e=>`card-${e.replace(/[^a-zA-Z0-9_-]/g,`-`)}`;function oF({side:e}){return(0,K.jsx)(`span`,{"data-drop":e,"aria-hidden":!0,className:B(`pointer-events-none absolute inset-y-0 z-20 w-1 rounded-full bg-primary`,e===`before`?`-left-2.5`:`-right-2.5`)})}function sF({arranged:e,layouts:t,layoutKey:n}){let[r,i]=(0,G.useState)(null),[a,o]=(0,G.useState)(void 0),s=()=>{i(null),o(void 0)},c=e=>{(a===void 0||!iF(a,e))&&o(e)},l=e=>or({overviewLayouts:{...t,[n]:e.map(({card:e,width:t,hidden:n})=>({id:e.id,...n?{hidden:!0}:{},...t===e.width?{}:{width:t}}))}}),u=e=>{let t=()=>(0,Ul.flushSync)(()=>l(e));typeof document.startViewTransition==`function`?document.startViewTransition(t):t()},d=t=>e.findIndex(e=>e.card.id===t),f=(t,n,r)=>{let i=e[d(t)];if(!i)return;let a=e.filter(e=>e.card.id!==t),o=n===void 0?a.length:a.findIndex(e=>e.card.id===n);a.splice(o<0?a.length:o,0,{...i,hidden:r}),u(a)},p=(t,n)=>u(e.map(e=>e.card.id===t?{...e,...n}:e)),m=e.filter(e=>!e.hidden),h=e.filter(e=>e.hidden),g=(e,t)=>{let n=m.findIndex(t=>t.card.id===e)+t;n<0||n>=m.length||f(e,t<0?m[n].card.id:m[n+1]?.card.id,!1)},_=e=>{if(e.preventDefault(),e.stopPropagation(),r&&a!==void 0){let e=a===`end`?void 0:a;if(e?.id!==r.id){let t=e===void 0?void 0:e.side===`before`?e.id:m.slice(m.findIndex(t=>t.card.id===e.id)+1).find(e=>e.card.id!==r.id)?.card.id;t!==r.id&&f(r.id,t,!1)}}s()},v=m.at(-1)?.card.id;return(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsxs)(`section`,{"aria-label":`Cards not on the page`,onDragOver:e=>r?.from===`page`&&e.preventDefault(),onDrop:e=>{e.preventDefault(),r?.from===`page`&&p(r.id,{hidden:!0}),s()},className:B(`rounded-lg border border-dashed border-border px-3 py-2.5`,r?.from===`page`&&`border-primary bg-accent/40`),children:[(0,K.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:h.length===0?`Every card is on the page. Drag one here, or press its ✕, to take it off.`:`Not on the page: drag one onto a card to put it there, or press + to add it at the end.`}),h.length>0&&(0,K.jsx)(`ul`,{className:`flex flex-wrap gap-2`,children:h.map(({card:e})=>(0,K.jsxs)(`li`,{"aria-label":e.label,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,i({id:e.id,from:`tray`})},onDragEnd:s,className:`flex cursor-grab items-center gap-1 rounded-md border border-border bg-card py-0.5 pr-0.5 pl-2 text-sm`,children:[(0,K.jsx)(Sa,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":!0}),e.label,(0,K.jsx)(`button`,{type:`button`,"aria-label":`Add ${e.label}`,onClick:()=>f(e.id,void 0,!1),className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground`,children:(0,K.jsx)(Fa,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]},e.id))})]}),(0,K.jsxs)(nF,{onDragOver:e=>{r!==null&&(e.preventDefault(),c(`end`))},onDrop:_,children:[m.length===0&&(0,K.jsx)(`div`,{"data-empty":!0,onDragOver:e=>{r!==null&&(e.preventDefault(),e.stopPropagation(),c(`end`))},onDragLeave:()=>o(void 0),onDrop:_,className:B(`col-span-12 flex min-h-40 items-center justify-center rounded-lg border-2 border-dashed text-sm text-muted-foreground transition-colors`,r&&a===`end`?`border-primary bg-primary/5 text-primary`:`border-border`),children:`No card on the page. Drag one here, or press its +.`}),m.map(({card:e,width:t},n)=>(0,K.jsxs)(`div`,{"data-card":e.id,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,i({id:e.id,from:`page`})},onDragOver:t=>{t.preventDefault(),t.stopPropagation();let n=t.currentTarget.getBoundingClientRect();c({id:e.id,side:t.clientX>n.left+n.width/2?`after`:`before`})},onDrop:_,onDragEnd:s,className:B(`relative col-span-12 flex min-w-0 cursor-grab flex-col rounded-lg outline-1 outline-offset-2 outline-border outline-dashed`,QP[t],r?.id===e.id&&`opacity-40`),style:{viewTransitionName:aF(e.id)},children:[r&&a!==void 0&&(a===`end`?e.id===v&&(0,K.jsx)(oF,{side:`after`}):a.id===e.id&&(0,K.jsx)(oF,{side:a.side})),(0,K.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none flex flex-1 select-none flex-col *:flex-1`,children:e.node}),(0,K.jsx)(cF,{label:e.label,widths:Ln(e),width:t,first:n===0,last:n===m.length-1,onStep:t=>g(e.id,t),onWidth:t=>p(e.id,{width:t}),onHide:()=>p(e.id,{hidden:!0})})]},e.id))]})]})}function cF({label:e,widths:t,width:n,first:r,last:i,onStep:a,onWidth:o,onHide:s}){return(0,K.jsxs)(`div`,{role:`toolbar`,"aria-label":e,className:`absolute top-2 right-2 z-10 flex items-center gap-1 rounded-md border border-border bg-popover p-0.5 text-popover-foreground shadow-sm`,children:[(0,K.jsx)(`button`,{type:`button`,"aria-label":`Move ${e}: arrow keys`,onKeyDown:e=>{let t=e.key===`ArrowLeft`||e.key===`ArrowUp`?-1:+(e.key===`ArrowRight`||e.key===`ArrowDown`);t!==0&&(e.preventDefault(),a(t))},className:`flex size-6 cursor-grab items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-primary)] pointer-coarse:hidden`,children:(0,K.jsx)(Sa,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsxs)(`span`,{className:`hidden pointer-coarse:flex`,children:[(0,K.jsx)(lF,{label:`Move ${e} earlier`,disabled:r,onClick:()=>a(-1),children:(0,K.jsx)(Xi,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsx)(lF,{label:`Move ${e} later`,disabled:i,onClick:()=>a(1),children:(0,K.jsx)(m,{className:`h-4 w-4`,"aria-hidden":!0})})]}),t.length>1&&(0,K.jsx)(`div`,{role:`group`,"aria-label":`Width of ${e}`,className:`flex overflow-hidden rounded border border-border text-xs`,children:t.map(e=>(0,K.jsx)(`button`,{type:`button`,"aria-pressed":e===n,onClick:()=>o(e),className:B(`min-w-7 px-1.5 py-0.5 tabular-nums transition-colors`,e===n?`bg-accent text-accent-foreground`:`text-muted-foreground hover:text-foreground`),children:rF[e]},e))}),(0,K.jsx)(lF,{label:`Take ${e} off the page`,onClick:s,children:(0,K.jsx)(ee,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})}function lF({label:e,disabled:t=!1,onClick:n,children:r}){return(0,K.jsx)(`button`,{type:`button`,"aria-label":e,title:e,disabled:t,onClick:n,className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-40`,children:r})}function uF({onSelectProject:e,onSelectAgent:t,onAgentStarted:n,interventions:r,interventionsStale:i,active:a,projects:o,scope:s}){let c=lr().onboardingDismissed??!1,l=a.active.filter(e=>s===null||e.projectId===s),u=s===null?o:o.filter(e=>e.id===s),d=WP(u),f=r.filter(e=>e.kind===`awaiting`).length,p=[{id:`needs-you`,stale:i,label:`Needs you`,order:1,width:`1/3`,minWidth:`1/4`,node:(0,K.jsx)(C,{label:`Needs you`,value:r.length,tone:`text-warning`,note:r.length===0?`Nothing waits on you`:f>0?f===1?`1 question to answer`:`${f} questions to answer`:`Work to review or publish`,onClick:()=>fe(De)})},{id:`working-now`,stale:a.stale,label:`Working now`,order:2,width:`1/3`,minWidth:`1/4`,node:(0,K.jsx)(C,{label:`Working now`,value:l.length,live:l.length>0,note:l.length===0?`No agent is at work`:l.length===1?`1 agent at work`:`${l.length} agents at work`,...l.length>0?{onClick:()=>fe(y)}:{}})},{id:`usage`,label:`Usage`,order:5,width:`1`,minWidth:`1/2`,node:(0,K.jsx)(PP,{projects:o})},{id:`human-queue`,stale:i,label:`Human Queue`,order:6,width:`1`,minWidth:`1/2`,node:(0,K.jsx)(`div`,{id:De,className:`flex scroll-mt-6 flex-col *:flex-1`,children:(0,K.jsx)(dF,{items:r,onSelectProject:e,onSelectAgent:t})})},{id:`working`,stale:a.stale,label:`Agents at work`,order:7,width:`1/2`,minWidth:`1/3`,node:(0,K.jsx)(`div`,{id:y,className:`flex scroll-mt-6 flex-col *:flex-1`,children:(0,K.jsx)(VP,{working:l,onSelectAgent:t})})},{id:`skills`,label:`Skills`,order:8,width:`1/3`,minWidth:`1/4`,node:(0,K.jsx)(YP,{projects:u,onSelectProject:e})},...d];p.sort((e,t)=>e.order-t.order);let m=s??`*`,h=lr().overviewLayouts,g=ur(),_=Rn(p,h,m),[v,b]=(0,G.useState)(!1),x=s===null?void 0:o.find(e=>e.id===s)?.name,S=h?.[m]!==void 0;return(0,K.jsx)(Dt,{title:`Overview`,description:`What needs you, the agents at work, and what comes next.`,actions:v?(0,K.jsxs)(K.Fragment,{children:[S&&(0,K.jsx)(V,{variant:`ghost`,size:`sm`,onClick:()=>{let{[m]:e,...t}=h??{};or({overviewLayouts:t})},children:m===`*`?`Reset to the default layout`:`Use the all-projects layout`}),(0,K.jsx)(V,{size:`sm`,onClick:()=>b(!1),children:`Done`})]}):(0,K.jsxs)(V,{variant:`ghost`,size:`sm`,className:`gap-1.5 text-muted-foreground`,onClick:()=>b(!0),children:[(0,K.jsx)(za,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Customize`]}),bar:v&&(0,K.jsxs)(`p`,{role:`status`,className:`rounded-md bg-accent/60 px-3 py-2 text-xs text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:x===void 0?`Arranging the layout for all projects.`:`Arranging the layout for ${x}.`}),` `,x===void 0?`A project you never arranged on its own uses it too.`:`Each project keeps its own; a project you never arranged uses the all-projects one.`,` Drag a card by its handle, pick its width, or take it off with ✕. On a phone every card is full width.`]}),children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[!c&&!v&&(0,K.jsx)(BP,{onAgentStarted:n,onSelectProject:e}),g?v?(0,K.jsx)(sF,{arranged:_,layouts:h,layoutKey:m}):_.some(({hidden:e})=>!e)?(0,K.jsx)($P,{cards:_.filter(({hidden:e})=>!e)}):(0,K.jsx)(`p`,{className:`rounded-lg border border-dashed border-border px-4 py-10 text-center text-sm text-muted-foreground`,children:`Every card is off the Overview. Press Customize to put some back.`}):null]})})}function dF({items:e,onSelectProject:t,onSelectAgent:n}){let r=fF.map(t=>({...t,items:e.filter(e=>e.kind===t.value)})).filter(e=>e.items.length>0);return(0,K.jsxs)(o,{children:[(0,K.jsxs)($t,{children:[(0,K.jsxs)(Rt,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)(Ca,{className:`h-4 w-4 text-muted-foreground`}),`Human Queue`,e.length>0&&(0,K.jsx)(`span`,{className:`rounded-full bg-primary px-1.5 text-xs font-semibold text-primary-foreground tabular-nums`,children:e.length})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Agents awaiting your approval, review, or input`})]}),(0,K.jsx)(lt,{children:e.length===0?(0,K.jsx)(`p`,{className:`py-2 text-sm text-muted-foreground`,children:`AI doesn't need you.`}):(0,K.jsx)(`div`,{className:`-mx-2 space-y-3`,children:r.map(e=>(0,K.jsxs)(`section`,{"aria-label":e.label,children:[(0,K.jsxs)(`h4`,{className:`flex items-baseline gap-1.5 px-2 pb-0.5 text-xs font-medium text-muted-foreground`,children:[e.label,(0,K.jsx)(`span`,{className:`tabular-nums opacity-70`,children:e.items.length})]}),(0,K.jsx)(Vo,{grouped:!0,items:e.items,onOpenAgent:n,onOpenProject:t})]},e.value))})})]})}var fF=[{value:`awaiting`,label:`Questions`},{value:`pr`,label:`Pull requests`},{value:`unpushed`,label:`To publish`},{value:`uncommitted`,label:`To commit`}];function pF({enabled:e,onChange:t}){let[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{if(!e){s(null),l(!1);return}let t=!0,n=()=>void Fr().then(e=>{t&&(s(e.version?.blocked?{got:e.version.got,expected:e.version.expected}:null),l(e.lastContact?.status===401))}).catch(()=>{});n();let r=setInterval(n,5e3);return()=>{t=!1,clearInterval(r)}},[e]),(0,G.useEffect)(()=>{if(!e){r(null),a(!1);return}let t=!0;return Ir().then(e=>{t&&r(e)}).catch(()=>{}),()=>{t=!1}},[e]),e?(0,K.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-md border border-border bg-muted/30 p-3 text-xs`,children:[(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:`Install the browser extension, open its options, and paste this token. It reports the question a Claude web session is parked on, so it shows up here instead of only on claude.ai.`}),o&&(0,K.jsxs)(`p`,{className:`text-danger`,children:[`The extension is blocked: it is v`,o.got,` and this dashboard expects v`,o.expected,`. Update it — pull the repo, then reload the extension at chrome://extensions.`]}),!o&&c&&(0,K.jsx)(`p`,{className:`text-danger`,children:`Something is calling the bridge with a token this dashboard rejects, so the calls get nowhere. Open the extension's options and save the token shown below again.`}),n===null?(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:`Restart the dashboard to generate the token.`}):(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(`code`,{className:`min-w-0 flex-1 truncate rounded bg-muted px-2 py-1 font-mono`,children:i?n:`•`.repeat(24)}),(0,K.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>a(e=>!e),children:i?`Hide`:`Reveal`}),(0,K.jsx)(on,{text:n,label:`Copy the bridge token`})]})]}):null}function mF(){return(0,K.jsx)(Ws,{children:(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Runs use these accounts. When one hits its limit, the next free one takes the run over where it stopped.`}),(0,K.jsx)(hF,{}),(0,K.jsx)(Gs,{}),(0,K.jsx)(`h3`,{className:`pt-1 text-sm font-medium`,children:`Coding agents`}),(0,K.jsx)(vc,{agent:`claude`}),(0,K.jsx)(vc,{agent:`codex`}),(0,K.jsx)(`h3`,{className:`pt-1 text-sm font-medium`,children:`Git hosts`}),(0,K.jsx)(Sc,{})]})})}function hF(){let e=cc(`claude`).view?.from,t=cc(`codex`).view?.from,n=e??t;return n===void 0?null:(0,K.jsxs)(`div`,{className:`rounded-lg bg-muted px-3 py-2.5`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium`,children:`Your logins and settings from ${n}`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Log in or out there, or change a setting, and this server follows.`})]})}var gF=`project-accounts`,_F=e=>`project-accounts:${e}`;function vF(e){cn(_F(e),()=>hs(e))}function yF(e){let{value:t,reload:n}=g(e?()=>hs(e):null,null,3e4,[e],e?{remember:_F(e)}:void 0);return{view:t&&(t.gitHost||t.claude||t.codex)?t:null,reload:n}}var bF=``,xF=`some`;function SF({projectId:e}){let{view:t,reload:n}=yF(e),[r,i]=(0,G.useState)(),a=async t=>{i(void 0);let r=await gs(e,t);r.ok||i(r.error),await n()};if(!t)return(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This computer has one account of each kind: this project's runs use those.`});let o=t.gitHost;return(0,K.jsxs)(pt,{description:`The accounts this project's runs work as, when not this computer's. Kept on this computer only, never in the repository.`,children:[o&&(0,K.jsx)(Ge,{label:o.name,description:`Which account this project's runs push and open a ${o.requestWord} as.${o.computer===void 0?``:` This computer's runs use @${o.computer}.`}`,value:o.project??bF,options:[{value:bF,label:`Same as this computer`},...o.accounts.map(e=>({value:e,label:`@${e}`}))],onChange:e=>void a({gitHost:e===bF?null:e})}),t.claude&&(0,K.jsx)(CF,{label:`Claude`,accounts:t.claude,onChange:e=>void a({claude:e})}),t.codex&&(0,K.jsx)(CF,{label:`Codex`,accounts:t.codex,onChange:e=>void a({codex:e})}),r!==void 0&&(0,K.jsx)(`p`,{role:`alert`,className:`pt-2 text-xs text-danger`,children:r})]})}function CF({label:e,accounts:t,onChange:n}){let r=new Set(t.project??[]);return(0,K.jsxs)(`div`,{className:`py-3`,children:[(0,K.jsx)(Ge,{label:e,description:`Which ${e} accounts this project's runs use, in the order Settings › Accounts has them.`,value:t.project?xF:bF,options:[{value:bF,label:`Same as this computer`},{value:xF,label:`Only some of them`}],onChange:e=>n(e===bF?null:t.accounts.map(e=>e.id))}),t.project&&(0,K.jsx)(`ul`,{className:`mt-2 space-y-2 pl-1`,children:t.accounts.map(e=>(0,K.jsx)(`li`,{children:(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,K.jsx)(Nt,{checked:r.has(e.id),onCheckedChange:i=>{let a=t.accounts.map(e=>e.id).filter(t=>t===e.id?i:r.has(t));n(a.length>0?a:null)}}),e.name]})},e.id))})]})}function wF({enabled:e}){let[t,n]=(0,G.useState)(null);if((0,G.useEffect)(()=>{if(!e){n(null);return}let t=!0,r=()=>void zr().then(e=>{t&&n(e)}).catch(()=>{});r();let i=setInterval(r,3e3);return()=>{t=!1,clearInterval(i)}},[e]),!e||!t)return null;let r=e=>void Wr(e).catch(()=>{});return(0,K.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-md border border-border bg-muted/30 p-3 text-xs`,children:[t.state===`off`&&(0,K.jsx)(`p`,{className:`text-muted-foreground`,children:`The bridge browser is off.`}),t.state===`starting`&&(0,K.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Starting the bridge browser: `,t.detail,`.`]}),t.state===`stopped`&&(0,K.jsxs)(`p`,{className:`text-danger`,children:[`The bridge browser is not running: `,t.detail,`.`,` `,(0,K.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>r(`restart`),children:`Restart`})]}),t.state===`running`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`text-muted-foreground`,children:[`The bridge browser is running`,t.visible?` with its window shown`:`, minimized`,`.`,t.signIn&&` It is on claude.ai’s sign-in page: show the window and sign in once, then hide it again.`]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[t.visible?(0,K.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>r(`hide`),children:`Hide the window`}):(0,K.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>r(`show`),children:t.signIn?`Show the window to sign in`:`Show the window`}),(0,K.jsx)(V,{variant:`outline`,size:`sm`,onClick:()=>r(`restart`),children:`Restart`})]})]})]})}var TF=``;function EF({entry:e,openItem:t,onEntry:n,onClose:r,scope:i,projects:a}){let{settings:o}=sn(),s=Se(),c=s&&e===``,l=(0,G.useRef)(null),[u,d]=(0,G.useState)(i??TF),f=a.find(e=>e.id===u)??null,p=to(),g=OF(),[_,v]=(0,G.useState)(),y=(n,r)=>{let i=n.Section;return{id:n.id,title:n.title,icon:n.icon,body:(0,K.jsx)(Qk,{package:n.package,label:`${n.title} settings`,children:(0,K.jsx)(i,{projects:$k(n.projects,r),...t!==void 0&&n.id===e?{item:t}:{}})})}},b=[...g,...o.filter(e=>e.computer).map(e=>y(e,[]))],x=o.filter(e=>!e.computer&&(f?e.projects.includes(f.id):e.projects.length>0)),{view:S}=yF(f?.id);(0,G.useEffect)(()=>{for(let e of a)vF(e.id)},[a]);let C=[...f&&S?[{id:gF,title:`Accounts`,icon:Ta,body:(0,K.jsx)(SF,{projectId:f.id})}]:[],...x.map(e=>y(e,f?[f]:a))],w=[...b,...C].find(t=>t.id===e)??b[0],T=C.includes(w),E=T&&!f?$k(x.find(e=>e.id===w.id)?.projects??[],a):[],D=e=>{let t=e.icon;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,"aria-current":e===w?`page`:void 0,onClick:()=>n(e.id),className:B(`flex w-full items-center gap-2 rounded-md px-2 text-left text-sm outline-none hover:bg-sidebar-accent/50 hover:text-sidebar-accent-foreground focus-visible:ring-2 focus-visible:ring-[var(--color-primary)]`,s?`h-10`:`h-8 aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium`),children:[(0,K.jsx)(t,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`truncate`,children:e.title})]})},e.id)};return(0,K.jsx)(h,{open:!0,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(Ie,{children:[(0,K.jsx)(j,{className:`fixed inset-0 z-50 bg-black/40 backdrop-blur-[1px]`}),(0,K.jsxs)(P,{ref:l,initialFocus:l,className:B(`fixed z-50 flex overflow-hidden bg-background text-foreground outline-none`,s?`inset-0`:`top-1/2 left-1/2 h-[min(40rem,calc(100dvh-2rem))] w-[min(56rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border shadow-lg`),children:[(!s||c)&&(0,K.jsxs)(`nav`,{"aria-label":`Settings`,className:B(`flex shrink-0 flex-col gap-4 overflow-y-auto bg-sidebar p-2`,s?`w-full`:`w-56 border-r border-border`),children:[s&&(0,K.jsxs)(`div`,{className:`flex h-10 items-center justify-between px-2`,children:[(0,K.jsx)(hn,{className:`text-base font-semibold`,children:`Settings`}),(0,K.jsx)(Re,{"aria-label":`Close settings`,className:`rounded p-1 text-muted-foreground outline-none hover:text-foreground`,children:(0,K.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})]}),(0,K.jsx)(`section`,{"aria-label":`You and this computer`,children:(0,K.jsx)(`ul`,{className:`flex flex-col gap-1`,children:b.map(D)})}),(0,K.jsxs)(`section`,{"aria-label":`Project`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-2 pb-1`,children:[(0,K.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Project`}),(0,K.jsx)(DF,{projects:a,value:f?.id??TF,onChange:d})]}),C.length>0?(0,K.jsx)(`ul`,{className:`flex flex-col gap-1`,children:C.map(D)}):(0,K.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground`,children:f?`Nothing to set for this project.`:`Nothing to set for your projects.`})]})]}),!c&&(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,K.jsxs)(`div`,{className:`flex h-12 shrink-0 items-center gap-2 px-4`,children:[_?(0,K.jsx)(`button`,{type:`button`,"aria-label":`Back to ${w.title}`,onClick:_.back,className:`-ml-1 rounded p-1 text-muted-foreground outline-none hover:text-foreground`,children:(0,K.jsx)(Wi,{className:`size-4`,"aria-hidden":!0})}):s&&(0,K.jsx)(`button`,{type:`button`,"aria-label":`All settings`,onClick:()=>n(``),className:`-ml-1 rounded p-1 text-muted-foreground outline-none hover:text-foreground`,children:(0,K.jsx)(Wi,{className:`size-4`,"aria-hidden":!0})}),(0,K.jsxs)(hn,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-sm font-normal`,children:[!s&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`Settings`}),(0,K.jsx)(m,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}),T&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`span`,{className:`truncate text-muted-foreground`,children:f?p(f.id,f.name):`All projects`}),(0,K.jsx)(m,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}),_?(0,K.jsxs)(K.Fragment,{children:[!s&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,onClick:_.back,className:`truncate rounded text-muted-foreground outline-none hover:text-foreground`,children:w.title}),(0,K.jsx)(m,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}),(0,K.jsx)(`span`,{className:`truncate font-medium`,children:_.title})]}):(0,K.jsx)(`span`,{className:`truncate font-medium`,children:w.title})]}),(0,K.jsx)(Re,{"aria-label":`Close settings`,className:`rounded p-1 text-muted-foreground outline-none hover:text-foreground`,children:(0,K.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})]}),(0,K.jsx)(Ye,{className:`min-h-0 flex-1`,children:(0,K.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-3 px-4 pb-6`,children:[E.length>0&&(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Saved to `,E.length===1?`one project`:`${E.length} projects`,`: `,E.map(e=>p(e.id,e.name)).join(`, `),`.`]}),(0,K.jsx)(`div`,{children:(0,K.jsx)(Ht.Provider,{value:v,children:w.body})},`${w.id}/${f?.id??TF}`)]})})]})]})]})})}function DF({projects:e,value:t,onChange:n}){let r=to(),i=[{value:TF,label:`All projects`},...e.map(e=>({value:e.id,label:r(e.id,e.name)}))];return(0,K.jsxs)(p,{items:i,value:t,onValueChange:e=>n(String(e??TF)),children:[(0,K.jsx)(je,{size:`sm`,"aria-label":`Project`,className:`h-6 min-w-0 flex-1 border-transparent bg-transparent px-1.5 text-xs shadow-none`,children:(0,K.jsx)(Le,{})}),(0,K.jsx)(Pe,{children:i.map(e=>(0,K.jsx)(M,{value:e.value,children:e.label},e.value))})]})}function OF(){let e=lr(),t=Uk(),n=dr(e),r=ut(Ke()),i=e.driver??Tt[0],a=e.model??``,o=$o()===`denied`;return[{id:`appearance`,title:`Appearance`,icon:Na,body:(0,K.jsxs)(pt,{children:[(0,K.jsx)(Ge,{label:`Theme`,description:`Follow the system, or pin light or dark.`,value:n,options:[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],onChange:e=>or({theme:e})}),(0,K.jsx)(Ge,{label:`Editor`,description:`Which editor “Open in editor” launches.`,value:e.editor??``,options:[{value:``,label:`Auto-detect`},...t.map(e=>({value:e.bin,label:e.label}))],onChange:e=>or({editor:e})}),(0,K.jsx)(AF,{label:`Onboarding on the Overview`,description:`The checklist of what a new install needs, at the top of the Overview.`,checked:!(e.onboardingDismissed??!1),onChange:e=>or({onboardingDismissed:!e})})]})},{id:`notifications`,title:`Notifications`,icon:qi,body:(0,K.jsxs)(pt,{children:[(0,K.jsx)(AF,{label:`Browser`,description:o?`Blocked in your browser settings`:`Desktop notifications while the dashboard is open.`,checked:(e.notifyBrowser??!0)&&!o,disabled:o,onChange:e=>or({notifyBrowser:e})}),(0,K.jsx)(AF,{label:`Human Queue`,description:`An agent awaiting your answer, or a PR ready to review.`,checked:e.notifyHumanIntervention??!0,onChange:e=>or({notifyHumanIntervention:e})}),(0,K.jsx)(AF,{label:`New activity`,description:`Also ping when an agent starts or finishes.`,checked:e.notifyNewActivity??!1,onChange:e=>or({notifyNewActivity:e})})]})},{id:`agent`,title:`Agent`,icon:Yi,body:(0,K.jsxs)(pt,{children:[(0,K.jsx)(Ge,{label:`Agent`,description:`Which coding agent runs the work.`,value:i,options:r,onChange:e=>or({driver:e,model:``})}),(0,K.jsx)(Ge,{label:`Model`,description:`The models the agent lists. Its own default when none is picked.`,value:a,options:jF(r.find(e=>e.value===i),a),onChange:e=>or({model:e})}),(0,K.jsx)(AF,{label:`Name each run`,description:`A small model is asked for the two to five words a run's row shows, in place of the first line of your prompt. One short turn with no tools, about a thirtieth of a cent a run. Off, a run is listed by what you asked for.`,checked:e.nameRuns??!0,onChange:e=>or({nameRuns:e})}),(0,K.jsx)(AF,{label:`Show what the agent thought`,description:`Inside a run of steps, a row for each thought between them. Off, the panel is the steps the agent took and nothing else.`,checked:e.showThinking??!1,onChange:e=>or({showThinking:e})}),(0,K.jsx)(AF,{label:`Post-merge cleanup`,description:`The box in the launcher's Auto menu, ticked by default: once a run ends done with a pull request, a fresh agent runs /post-merge-cleanup on its branch before it merges. In projects with that command.`,checked:e.postMergeCleanup??!1,onChange:e=>or({postMergeCleanup:e})})]})},{id:_s,title:`Accounts`,icon:Ka,body:(0,K.jsx)(mF,{})},{id:`claude-web`,title:`Claude web`,icon:xa,body:(0,K.jsxs)(pt,{description:`A Claude web agent hands off and ends, so the questions its session asks never reach this dashboard. The browser bridge carries them back and types your answers into the session.`,children:[(0,K.jsx)(AF,{label:`Browser bridge`,description:`Carry claude.ai questions into this dashboard and type your answers back. A browser signed in to claude.ai does the work, through the bridge extension.`,checked:e.bridge??!1,onChange:e=>or({bridge:e})}),(e.bridge??!1)&&(0,K.jsx)(kF,{daemonBrowser:e.bridgeBrowser??!1,onChange:e=>or({bridgeBrowser:e})})]})}]}function kF({daemonBrowser:e,onChange:t}){let n=(0,G.useId)(),r=(t,n,r,i)=>(0,K.jsxs)(`label`,{className:B(`flex cursor-pointer gap-3 rounded-md border p-3`,e===t?`border-primary/60 bg-muted/20`:`border-border`),children:[(0,K.jsx)(Jt,{value:t?`daemon`:`own`,"aria-label":n,className:`mt-1`}),(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`span`,{className:`block text-sm font-medium`,children:n}),(0,K.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:r}),e===t&&i]})]});return(0,K.jsxs)(`div`,{className:`mt-3`,children:[(0,K.jsx)(`p`,{id:n,className:`mb-2 text-sm font-medium`,children:`Which browser does the work?`}),(0,K.jsxs)(zt,{"aria-labelledby":n,value:e?`daemon`:`own`,onValueChange:e=>t(e===`daemon`),children:[r(!0,`A browser the daemon runs — recommended`,`Chrome for Testing, downloaded once, signed in once, kept minimized. Web runs work with your own Chrome closed.`,(0,K.jsx)(wF,{enabled:!0})),r(!1,`Your own Chrome`,`Install the extension, open its options and paste the token. Web runs need your Chrome open.`,(0,K.jsx)(pF,{enabled:!0,onChange:()=>{}}))]})]})}function AF({label:e,description:t,checked:n,onChange:r,disabled:i=!1}){return(0,K.jsx)(ht,{label:e,description:t,dimmed:i,control:(0,K.jsx)(ye,{checked:n,disabled:i,onCheckedChange:e=>r(e===!0),"aria-label":e})})}function jF(e,t){let n=e?.models??[];return[{value:``,label:zO},...n,...t&&!n.some(e=>e.value===t)?[{value:t,label:t}]:[],...n.length===0&&e?.modelsNote?[{value:e.modelsNote,label:e.modelsNote,disabled:!0}]:[]]}var MF=15e3,NF=1e4,PF=1e3;function FF(e){return e?e.landed?!0:e.exists?!e.empty||e.commits.length>0||!!e.pendingFiles?.length:!e.unchanged:!1}function IF(e,t,n=!0,r=!1,i=!1){let a=t?`handoff:${e}:${t}`:void 0;(0,G.useEffect)(()=>{i&&a!==void 0&&$e(a)},[i,a]);let[o,s]=(0,G.useState)(!1),c=(0,G.useRef)(i);(0,G.useEffect)(()=>{c.current&&!i&&s(!0),c.current=i},[i]),(0,G.useEffect)(()=>{if(!o)return;let e=setTimeout(()=>s(!1),NF);return()=>clearTimeout(e)},[o]);let[l,u]=(0,G.useState)(MF),{value:d,reload:f,loaded:p}=g(n&&t?()=>Nr(e,t):null,null,l,[e,t,n,l,r],a===void 0?void 0:{remember:a});(0,G.useEffect)(()=>u(d?.prPending?300:o?PF:MF),[d?.prPending,o]),(0,G.useEffect)(()=>{o&&FF(d)&&s(!1)},[o,d]);let{busy:m,error:h,run:_}=en(),[v,y]=(0,G.useState)(null);return{handoff:d,loaded:p,busy:m,error:h,pending:v,act:(e,t,n)=>{y(e),_(t,n).then(e=>e.ok?f():void 0).then(()=>y(null))}}}function LF(e,t,n){let[r,i]=(0,G.useState)(1e4),[a,o]=(0,G.useState)(!1),{value:s,reload:c}=g(()=>xr(e,t),null,r,[e,t,r],{remember:`worktree:${e}:${t}`});(0,G.useEffect)(()=>i(s?.prPending?300:a?PF:1e4),[s?.prPending,a]),(0,G.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>o(!1),NF);return()=>clearTimeout(e)},[a]);let l=(0,G.useRef)({key:``,turn:n});return(0,G.useEffect)(()=>{let r=`${e}\0${t}`,i=l.current.key===r&&l.current.turn!==n,u=i&&l.current.turn===!0&&!n;l.current={key:r,turn:n},i&&(u&&o(!0),(!u||a||s?.prPending)&&c())},[e,t,n,c,a,s?.prPending]),s}function RF({projectId:e,agentId:t,events:n,retainedWorktree:r=!1,onWorktreeRemoved:i,onDeleted:a,label:o,projectName:s,runsOn:c=ol(),expanded:l=!1,onToggle:u,ready:d=!0,checkout:f}){let p=d?En(f?.checkout?.sizeBytes,``):``;return(0,K.jsxs)(`div`,{className:`@container flex h-11 shrink-0 items-center gap-2 overflow-hidden pr-2 md:pl-4 max-md:pl-11`,children:[(0,K.jsx)(v,{}),(0,K.jsx)(FN,{}),(0,K.jsx)(Yk,{projectId:e,agentId:t,events:n,label:o,retainedWorktree:r,onWorktreeRemoved:i,onDeleted:a,...u?{details:{open:l,onToggle:u}}:{},size:p}),(0,K.jsx)(`span`,{"data-testid":`runs-on`,className:`max-w-64 shrink-0 truncate rounded bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground @max-md:hidden`,title:s?`${c} · ${s}`:c,children:s?`${c} · ${s}`:c}),(0,K.jsx)(`div`,{className:`grow shrink-0`}),d&&(0,K.jsx)(iP,{events:n}),(0,K.jsx)(PN,{})]})}function zF({prs:e}){return e.length===0?null:(0,K.jsx)(`span`,{className:`flex min-w-0 items-center gap-1.5 max-sm:shrink-0`,children:e.map(e=>{let t=e.state===void 0?void 0:uo(e.state),n=t?lo[t]:void 0,r=n?.Icon??ya;return(0,K.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,"aria-label":`PR #${e.number}${n?` ${n.word}`:``}, on the git host`,className:`inline-flex h-6 shrink-0 items-center gap-1 rounded-full border border-border px-2 text-xs text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:[(0,K.jsx)(r,{className:B(`h-3 w-3 shrink-0`,n?.tone),"aria-hidden":!0}),(0,K.jsxs)(`span`,{className:`tabular-nums text-foreground`,children:[`#`,e.number]}),n&&(0,K.jsx)(`span`,{children:n.word})]},e.url)})})}function BF({projectId:e,agentId:t,live:n,files:r,onAgentStarted:i,onSending:a,onQueued:o,outcome:s,model:c,context:l,controls:u,contextSet:d,publish:f}){let p=(0,G.useRef)(null),{busy:m,error:h,run:g}=en(),{busy:_,error:v,run:y}=en(),[b,x]=(0,G.useState)(!1);(0,G.useEffect)(()=>x(!1),[t]),(0,G.useEffect)(()=>{n||x(!1)},[n]);let[S,C]=(0,G.useState)(!1);(0,G.useEffect)(()=>C(!1),[t]),(0,G.useEffect)(()=>{n&&C(!1)},[n]);let w=_||b&&n,T=_l(e),E=me(f)?f:`nothing`,[D,O]=(0,G.useState)(null);(0,G.useEffect)(()=>O(null),[t]),(0,G.useEffect)(()=>{D===E&&O(null)},[D,E]);let k=async r=>{let s=n;return s||a?.(r),(await g(()=>Gr(e,r,t,...D===null?[]:[D]),`Could not send. Your text is kept, try again.`)).ok?(s||O(null),s?o?.(r):i?.(r,t),!0):(s||a?.(null),!1)},A=async e=>{m||(await k(d?Pl(e,d.context):e)&&(p.current?.clear(),d?.reset()),p.current?.focus())},j=()=>void y(()=>Br(e,t).then(()=>!0),`Could not stop the agent.`).then(e=>{e&&x(!0)}),M=async()=>{m||await k(`This session was stopped before it finished, not because the work was done. Look at what you had already done, then carry on from there.`)&&C(!0)},N=n?(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(V,{type:`button`,size:`icon-sm`,onClick:j,disabled:w,"aria-label":`Stop agent`,className:`h-8 w-8 shrink-0 disabled:opacity-100`}),children:w?(0,K.jsx)(ae,{className:`h-4 w-4 animate-spin`}):(0,K.jsx)(Va,{className:`h-3 w-3 fill-current`})}),(0,K.jsx)(z,{children:w?`Stopping…`:`Stop agent`})]}):s?.stopped||S?(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(V,{type:`button`,size:`icon-sm`,onClick:()=>void M(),disabled:m||S,"aria-label":`Resume`,className:`h-8 w-8 shrink-0 disabled:opacity-100`}),children:m||S?(0,K.jsx)(ae,{className:`h-4 w-4 animate-spin`}):(0,K.jsx)(Pa,{className:`h-3.5 w-3.5 fill-current`})}),(0,K.jsx)(z,{children:m||S?`Resuming…`:`Resume the agent`})]}):void 0,P=h??v;return(0,K.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl p-2`,children:[P&&(0,K.jsx)(`p`,{role:`alert`,className:`mb-1 px-2 text-xs text-danger`,children:P}),(0,K.jsx)(QO,{ref:p,files:r,onSubmit:A,busy:m,submitLabel:`Send`,submitBusyLabel:n?`Sending…`:`Resuming…`,showDriverModel:!1,inAgent:!0,sessionModel:c,sessionContext:l,...d?{addContext:d.add,removeContext:d.remove}:{},controls:(0,K.jsxs)(K.Fragment,{children:[d&&(0,K.jsx)(Vl,{projectId:e,context:d.context,busy:m,onToggle:d.toggle}),(0,K.jsx)(zl,{publish:D??E,picks:kt(T?.gitHost??!0,T?.remote??!0),onPublish:e=>O(e===E?null:e),cleanup:void 0,onCleanup:()=>{},busy:m}),u]}),idleControl:N,placeholder:n?`Send now, and the agent reads it when its turn ends`:`Message the agent to continue it…`})]})}function VF({projectName:e,checkout:t,summary:n,actions:r,show:i,state:a}){let o=t?.branch,s=a??`${o??``}|${t?.pr?.number??``}|${t?.pr?.state??``}`,[c,l]=(0,G.useState)(null);return o===void 0||!i||c===s?null:(0,K.jsx)(`div`,{className:`mx-auto w-full max-w-3xl px-2 pt-2`,children:(0,K.jsxs)(`div`,{role:`group`,"aria-label":`This agent's work`,className:`flex items-center overflow-hidden rounded-[10px] bg-muted px-2 dark:[--accent:#374145] dark:[--color-accent:#374145] text-[13px] md:h-10 md:gap-2 max-md:min-h-10 max-md:flex-wrap max-md:gap-x-2 max-md:gap-y-1 max-md:py-1.5`,children:[e&&(0,K.jsx)(`span`,{className:`max-w-32 shrink-0 truncate text-muted-foreground`,title:e,children:e}),(0,K.jsx)(`span`,{className:`flex min-w-0 items-center text-muted-foreground`,children:(0,K.jsxs)(U,{children:[(0,K.jsx)(H,{render:(0,K.jsx)(`span`,{className:`truncate font-mono`}),children:o}),(0,K.jsx)(z,{className:`whitespace-pre-line`,children:[o,t?.checkout?.path].filter(Boolean).join(`
132
132
  `)})]})}),(0,K.jsx)(`div`,{className:`grow`}),(0,K.jsx)(`span`,{className:`shrink-0`,children:n}),t?.pr&&(0,K.jsxs)(U,{children:[(0,K.jsxs)(H,{render:(0,K.jsx)(`a`,{href:t.pr.url,target:`_blank`,rel:`noreferrer`,className:`flex shrink-0 items-center gap-1.5 text-primary hover:underline`}),children:[(0,K.jsxs)(`span`,{children:[`PR #`,t.pr.number]}),(0,K.jsx)(`span`,{className:`rounded-full border border-border px-1.5 text-[10px] uppercase text-muted-foreground`,children:t.pr.state.toLowerCase()})]}),(0,K.jsx)(z,{children:t.pr.title})]}),(0,K.jsx)(`div`,{className:`flex items-center gap-2 md:shrink-0 max-md:min-w-0 max-md:flex-wrap`,children:r}),(0,K.jsx)(`button`,{type:`button`,"aria-label":`Hide this bar`,title:`Hide this bar`,onClick:()=>l(s),className:`flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-primary)]`,children:(0,K.jsx)(ee,{className:`h-3.5 w-3.5`})})]})})}function HF({top:e,bottom:t,children:n}){let r=(0,G.useRef)(null),i=(0,G.useRef)(null),a=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>{let e=typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches,t=()=>{let t=r.current.style,n=i.current.getBoundingClientRect().height;t.setProperty(`--chat-bar`,`${n}px`),t.setProperty(`--chat-bottom`,e?`0px`:`${n}px`),t.setProperty(`--chat-scroll-bar`,`${a.current.offsetWidth-a.current.clientWidth}px`)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);for(let e of[i,a])n.observe(e.current);return()=>n.disconnect()},[]),(0,K.jsxs)(`div`,{ref:r,"data-testid":`chat-pane`,className:`flex min-h-0 flex-1 flex-col`,children:[(0,K.jsx)(`div`,{"data-testid":`chat-top`,className:`shrink-0`,children:e}),(0,K.jsxs)(`div`,{className:`relative isolate flex min-h-0 flex-1 flex-col overflow-hidden pointer-coarse:pb-(--chat-bar)`,children:[(0,K.jsx)(`div`,{ref:a,className:`scrollbar-thin invisible absolute h-0 w-8 overflow-y-scroll`,"aria-hidden":!0}),n,(0,K.jsx)(`div`,{ref:i,"data-testid":`chat-bottom`,className:`absolute right-[max(var(--chat-scroll-bar),0.75rem)] bottom-0 left-0 z-10 max-h-full overflow-y-auto bg-background pl-[calc(max(var(--chat-scroll-bar),0.75rem)_-_var(--chat-scroll-bar))] pointer-coarse:right-(--chat-scroll-bar) pointer-coarse:pl-0`,children:t}),(0,K.jsx)(`div`,{className:`pointer-events-none absolute top-0 right-[max(var(--chat-scroll-bar),0.75rem)] left-0 z-10 h-4 bg-gradient-to-b from-background to-transparent`,"aria-hidden":!0}),(0,K.jsx)(`div`,{className:`pointer-events-none absolute right-[max(var(--chat-scroll-bar),0.75rem)] bottom-(--chat-bar) left-0 z-10 h-4 bg-gradient-to-t from-background to-transparent`,"aria-hidden":!0})]})]})}function UF({children:e}){return(0,K.jsx)(`div`,{className:`grid flex-1 place-items-center pb-(--chat-bottom) text-sm text-muted-foreground`,children:e})}function WF(e,t){return`You paused to ask: "${e}". The user chose: ${t}. Continue with that decision.`}function GF(e){return`You paused to ask: "${e}". The user skipped it. Continue without an answer.`}function KF(e){let t=/^You paused to ask: "([\s\S]*)"\. The user chose: ([\s\S]*)\. Continue with that decision\.$/.exec(e);if(t)return{question:t[1],answer:t[2]};let n=/^You paused to ask: "([\s\S]*)"\. The user skipped it\. Continue without an answer\.$/.exec(e);return n?{question:n[1]}:void 0}function qF(e){switch(e.kind){case`end`:return e.stopped?{said:`Stopped`}:!e.ok&&!e.waiting?{said:`Failed — ${e.detail??`unknown error`}`}:void 0;case`error`:return{said:e.headline,...e.detail!==void 0&&e.detail!==``?{detail:e.detail}:{}};case`settled`:return{said:`Done for now — waiting for your next message`};case`branch`:return{said:`Branch`,thing:e.branch};case`pull-request`:return{said:`Pull request`,thing:`#${e.number}`,href:e.url};case`cloud-anchor`:return{said:`Handed off at`,thing:e.sha.slice(0,7)};case`log`:return{said:e.message};case`intent`:return{said:`Asked for`,thing:e.text};case`driver`:return JF(e.event);default:return}}function JF(e){switch(e.type){case`notice`:return{said:e.message};case`error`:return{said:`The agent reported an error`,detail:e.message};case`rate-limit`:{let t=e.limit.window.replace(/_/g,`-`),n=`resets ${new Date(e.limit.resetsAt).toLocaleString()}`;return e.limit.status===`rejected`?{said:`The ${t} quota is used up`,thing:n}:e.limit.status===`allowed_warning`?{said:`The ${t} quota is running low`,thing:n}:void 0}default:return}}function YF({choice:e,pick:t}){let[n,r]=(0,G.useState)(!1),i=new Set(vn(t));return(0,K.jsxs)(`div`,{className:`overflow-hidden rounded-md border border-border`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),className:`flex w-full items-baseline gap-2 px-4 py-2 text-left text-xs text-muted-foreground hover:bg-accent/40`,"aria-expanded":n,children:[(0,K.jsx)(`span`,{className:`shrink-0 text-success`,children:`✓`}),(0,K.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:e.title}),(0,K.jsx)(`span`,{className:`ml-auto shrink-0`,children:n?`Collapse`:`Expand`})]}),n&&(0,K.jsx)(`div`,{className:`border-t border-border p-4`,children:(0,K.jsxs)(`ul`,{className:`space-y-1 text-sm`,children:[e.options.map(e=>(0,K.jsxs)(`li`,{className:B(`flex items-baseline gap-2`,i.has(e.id)?``:`text-muted-foreground`),children:[(0,K.jsx)(`span`,{className:B(`w-4 shrink-0`,i.has(e.id)?`text-success`:``),children:i.has(e.id)?`✓`:``}),(0,K.jsx)(`span`,{children:e.label})]},e.id)),i.size===0&&(0,K.jsx)(`li`,{className:`text-muted-foreground`,children:`Accepted none`})]})})]})}var XF=Symbol(`other`),ZF=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl`;function QF({on:e,multi:t}){return t?(0,K.jsx)(`span`,{className:B(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded border`,e?`border-primary bg-primary text-primary-foreground`:`border-foreground/20`),"aria-hidden":!0,children:e&&(0,K.jsx)(N,{className:`h-3 w-3`})}):(0,K.jsx)(`span`,{className:B(`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-full`,e?`bg-primary`:`border border-foreground/20`),"aria-hidden":!0,children:e&&(0,K.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary-foreground`})})}function $F({projectId:e,agentId:t,choice:n,active:r=!1,onSaid:i,send:a}){let{busy:o,error:s,run:c}=en(),[l,u]=(0,G.useState)(!1),[d,f]=(0,G.useState)(()=>n.multi?void 0:n.recommended??n.options[0]?.id),[p,m]=(0,G.useState)(()=>new Set(n.multi?n.options.filter(e=>e.default).map(e=>e.id):[])),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(!1),y=(0,G.useRef)(null),b=h.trim(),x=(e,t)=>void c(e,`Could not send your answer — try again.`).then(e=>{e.ok&&(u(!0),t!==void 0&&i?.(t))}),S=r=>{if(a)return x(()=>a(r));let i=n.options.filter(e=>[r].flat().includes(e.id)).map(e=>e.label);x(()=>Vr(e,n.id,r,t),WF(n.title,i.length?i.join(`, `):`(none)`))},C=n=>x(()=>Gr(e,n,t),n),w=n.multi?_:d===XF,T=!w||b!==``,E=()=>{if(!(o||!T)){if(n.multi)return _?C(WF(n.title,[...n.options.filter(e=>p.has(e.id)).map(e=>e.label),b].join(`, `))):S([...p]);if(d===XF)return C(WF(n.title,b));d!==void 0&&S(d)}},D=()=>{o||(n.multi?v(e=>!e):f(XF))},O=e=>{if(!o){if(!n.multi)return f(e);m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}},k=(0,G.useRef)({submit:E,pick:O,pickOther:D});k.current={submit:E,pick:O,pickOther:D},(0,G.useEffect)(()=>{if(!r||l)return;let e=e=>{let t=e.target,r=t!==null&&(t.isContentEditable||t.tagName===`INPUT`||t.tagName===`TEXTAREA`);if((e.ctrlKey||e.metaKey)&&e.key===`Enter`){if(r&&t!==y.current)return;e.preventDefault(),k.current.submit();return}if(r||e.ctrlKey||e.metaKey||e.altKey||!/^[1-9]$/.test(e.key))return;let i=Number(e.key),o=n.options[i-1];if(o)k.current.pick(o.id);else if(!a&&i===n.options.length+1)k.current.pickOther();else return;e.preventDefault()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,l,n.options,a]),(0,G.useEffect)(()=>{w&&y.current?.focus()},[w]);let A=`flex w-full items-start gap-3 p-3 text-left disabled:opacity-60`;return l?null:(0,K.jsxs)(`section`,{role:`region`,"aria-label":n.title,className:`flex w-full max-w-[480px] flex-col overflow-clip rounded-[10px] font-sans text-sm ring-1 ring-border`,children:[(0,K.jsx)(`h2`,{className:`bg-foreground/5 px-3 py-2 font-normal`,children:n.title}),(0,K.jsxs)(`ul`,{className:`flex flex-col`,children:[n.options.map(e=>{let t=n.multi?p.has(e.id):d===e.id;return(0,K.jsx)(`li`,{className:`border-t border-border first:border-t-0`,children:(0,K.jsxs)(`button`,{type:`button`,role:n.multi?`checkbox`:`radio`,"aria-checked":t,disabled:o,onClick:()=>O(e.id),className:A,children:[(0,K.jsx)(QF,{on:t,multi:n.multi}),(0,K.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,K.jsxs)(`span`,{children:[e.label,e.id===n.recommended&&(0,K.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:`Recommended`})]}),e.detail&&(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:e.detail})]})]})},e.id)}),!a&&(0,K.jsxs)(`li`,{className:`flex flex-col border-t border-border`,children:[(0,K.jsxs)(`button`,{type:`button`,role:n.multi?`checkbox`:`radio`,"aria-checked":w,disabled:o,onClick:D,className:A,children:[(0,K.jsx)(QF,{on:w,multi:n.multi}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1`,children:`Other`})]}),w&&(0,K.jsx)(`input`,{ref:y,value:h,disabled:o,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.ctrlKey&&!e.metaKey&&E()},placeholder:`Type your own answer here`,"aria-label":`Other`,className:`mx-3 mb-1 ml-10 rounded-md border border-border bg-transparent px-2.5 py-1.5 outline-none placeholder:text-muted-foreground focus:border-primary`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pt-2 pb-3`,children:[(0,K.jsx)(`span`,{role:s?`alert`:o?`status`:void 0,className:B(`min-w-0 flex-1 truncate text-xs`,s?`text-danger`:`text-muted-foreground`),children:s??(o?`Sending your answer…`:``)}),!a&&(0,K.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>C(GF(n.title)),className:`h-6 rounded-md bg-foreground/10 px-2 text-[13px] hover:bg-foreground/15 disabled:opacity-60`,children:`Skip`}),(0,K.jsxs)(`button`,{type:`button`,disabled:o||!T,onClick:E,className:`flex h-6 items-center gap-1.5 rounded-md bg-foreground px-2 text-[13px] font-medium text-background hover:bg-foreground/90 disabled:opacity-60`,children:[`Submit`,r&&(0,K.jsxs)(`span`,{className:`flex gap-0.5`,"aria-hidden":!0,children:[(0,K.jsx)(`kbd`,{className:`flex h-[17px] min-w-[17px] items-center justify-center rounded border border-background/20 px-0.5 font-sans text-[11px]`,children:ZF}),(0,K.jsx)(`kbd`,{className:`flex h-[17px] min-w-[17px] items-center justify-center rounded border border-background/20 px-0.5 font-sans text-[11px]`,children:`↵`})]})]})]})]})}function eI({label:e,value:t}){return(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)($i,{className:`h-3.5 w-3.5 shrink-0 text-success`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`shrink-0 text-foreground`,children:e}),t!==void 0&&(0,K.jsx)(`span`,{className:`truncate`,title:t,children:t})]})}function tI(e,t){return e.workspace===void 0&&e.branch===void 0&&e.driver===void 0&&(!t||e.elsewhere===!0)}function nI({setup:e,live:t,working:n=!1,added:r,nested:i=!1}){let[a,o]=(0,G.useState)(!1),s=ue(e.driver),c=Ke(),l=s?se[s]:e.driver,u=e.model&&gt(s?c?.[s]:void 0,e.model);if(t){let n=e.branch!==void 0||e.workspace!==void 0?`Starting ${l??`the coding agent`}`:l!==void 0&&!e.elsewhere?`Making the checkout`:`Starting session`;return(0,K.jsxs)(`div`,{role:`status`,className:`flex min-w-0 flex-1 items-center gap-2 font-sans text-sm text-muted-foreground`,children:[(0,K.jsx)(bk,{}),(0,K.jsx)(`span`,{className:`morph-in`,children:(0,K.jsx)(`span`,{className:`text-shimmer`,children:n})},n),t.since!==void 0&&(0,K.jsx)(yk,{since:t.since})]})}return e.workspace===void 0&&e.branch===void 0&&l===void 0?tI(e,n)?null:(0,K.jsx)(`div`,{className:`min-w-0 flex-1 font-sans text-sm text-muted-foreground`,children:`Initialized session`}):(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 font-sans text-sm text-muted-foreground`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,className:`flex items-center gap-1.5 py-0.5 hover:text-foreground`,children:[(0,K.jsx)(`span`,{children:`Initialized session`}),(0,K.jsx)(m,{className:B(`h-3.5 w-3.5 shrink-0 transition-transform`,a&&`rotate-90`),"aria-hidden":!0})]}),a&&(0,K.jsxs)(`div`,{className:B(`mt-1.5 flex flex-col gap-1.5`,!i&&`rounded-lg border border-border px-3 py-2`),children:[e.workspace!==void 0&&(0,K.jsx)(eI,{label:`Made the checkout`,value:e.workspace}),e.branch!==void 0&&(0,K.jsx)(eI,{label:`Made the branch`,value:e.branch}),e.base!==void 0&&(0,K.jsxs)(`div`,{className:`min-w-0 truncate`,title:e.base,children:[`Started from the branch `,(0,K.jsx)(`span`,{className:`text-foreground`,children:e.base}),`, not from the main branch.`]}),l!==void 0&&(0,K.jsx)(eI,{label:`Started ${l}`,...u?{value:u}:{}}),r!==void 0&&(0,K.jsxs)(`div`,{className:`min-w-0`,children:[`Auto adds after each message: `,(0,K.jsxs)(`span`,{className:`text-foreground`,children:[`“`,r,`”`]})]})]})]})}function rI({row:e,onOpen:t}){let n=Ke(),r=e.status===`waiting`?`text-muted-foreground`:no[e.status]??`text-muted-foreground`;return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>t?.(e.key),className:`group/sub flex min-w-0 flex-1 items-baseline gap-2 text-left`,"aria-label":`Open the subagent: ${e.name}`,children:[(0,K.jsx)(`span`,{className:`w-1.5 shrink-0 self-center`,"aria-hidden":!0,children:e.working&&(0,K.jsx)(`span`,{className:`block h-1.5 w-1.5 animate-pulse rounded-full bg-primary`})}),(0,K.jsx)(`span`,{className:`min-w-0 shrink truncate text-foreground group-hover/sub:underline`,children:e.name}),e.model&&(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground max-sm:hidden`,children:at(n,e.model)}),e.call&&(0,K.jsx)(`span`,{className:`shrink-0 rounded-sm border border-border px-1 text-[10px] leading-4 text-muted-foreground`,children:`no branch`}),e.working?e.calls!==void 0&&(0,K.jsx)(`span`,{className:`min-w-0 shrink-0 truncate text-muted-foreground`,title:e.doing,children:[e.tool,`${e.calls} ${e.calls===1?`call`:`calls`}`].filter(Boolean).join(` · `)}):(0,K.jsx)(`span`,{className:B(`shrink-0`,r),children:e.status}),(0,K.jsx)(`span`,{className:`ml-auto shrink-0 tabular-nums text-muted-foreground`,title:`Started ${new Date(e.startedAt).toLocaleString()}`,children:e.working?(0,K.jsx)(yk,{since:e.startedAt}):e.endedAt===void 0?null:Ot(Date.parse(e.endedAt)-Date.parse(e.startedAt))})]})}function iI(e){let[t,n]=(0,G.useState)(()=>Date.now());return(0,G.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),t}function aI(e,t){let{count:n,ms:r,cost:i}=Oo(e,t);return[`${n} ${n===1?`agent`:`agents`}`,Ot(r),...i===void 0?[]:[`$${i.toFixed(2)}`]].join(` · `)}function oI({rows:e,onOpen:t}){let n=iI(e.some(e=>e.working));return(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[e.length>1&&(0,K.jsx)(`div`,{className:`text-muted-foreground`,children:aI(e,n)}),e.map(e=>(0,K.jsx)(rI,{row:e,onOpen:t},e.key))]})}function sI({agent:e,end:t,onOpen:n}){let r=To(e,void 0),i=Ke(),a=t.status===`done`?$i:t.status===`failed`?na:t.status===`waiting`?ea:ta,o=t.status===`waiting`?`text-muted-foreground`:no[t.status]??`text-muted-foreground`;return(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n?.(r.key),className:`group/sub flex min-w-0 items-center gap-1.5 text-left font-sans text-sm`,"aria-label":`Open the subagent: ${r.name}`,children:[(0,K.jsx)(a,{className:B(`h-3.5 w-3.5 shrink-0`,o),"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground group-hover/sub:underline`,children:r.name}),r.model&&(0,K.jsx)(`span`,{className:`shrink-0 text-muted-foreground max-sm:hidden`,children:at(i,r.model)}),(0,K.jsxs)(`span`,{className:`min-w-0 shrink-0 truncate text-muted-foreground`,children:[`ended `,(0,K.jsx)(`span`,{className:o,children:t.status}),t.detail&&`: ${t.detail}`]})]})}function cI({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:i}){let a=lI(uI(r,i),t);if(!n)return G.createElement(e,a);if(typeof n==`function`)return n(a,r);if(!G.isValidElement(n))return null;let o=n.props,s={...lI(a,o),ref:pI(a.ref,o.ref)};return G.cloneElement(n,s)}function lI(...e){let t={};for(let n of e){if(!n)continue;let e=n;for(let n of Object.keys(e)){let r=e[n];if(r===void 0)continue;let i=t[n];n===`className`?t[n]=[i,r].filter(Boolean).join(` `):n===`style`?t[n]={...i,...r}:n===`ref`?t[n]=pI(i,r):fI(n)&&typeof i==`function`&&typeof r==`function`?t[n]=dI(r,i):t[n]=r}}return t}function uI(e,t){let n={};for(let r of Object.keys(e)){let i=e[r],a=t?.[r]?.(i);if(a){Object.assign(n,a);continue}if(r===`slot`){n[`data-slot`]=i;continue}let o=`data-${String(r).replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}`;typeof i==`boolean`?n[o]=i?``:void 0:i!=null&&(n[o]=String(i))}return n}function dI(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function fI(e){return/^on[A-Z]/.test(e)}function pI(...e){let t=e.filter(Boolean);if(t.length!==0)return e=>{for(let n of t)typeof n==`function`?n(e):n&&(n.current=e)}}var mI=8,hI=64,gI=0,_I=.5,vI=180,yI=new Set([`ArrowDown`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`,` `]),bI={start:!1,end:!1},xI={currentAnchorId:null,visibleMessageIds:[]};function SI({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return bI;let i=PI({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:i-r.scrollTop-r.clientHeight>t}}function CI({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:i,visibleMessageIds:a}){if(!e||!i)return xI;let o=i.getBoundingClientRect(),s=o.top+t+n,c=typeof IntersectionObserver>`u`,l=[],u=null;for(let t of wI(e,r)){let e=t.dataset.messageId;if(!e)continue;let n=t.dataset.scrollAnchor===`true`,r=n||c?t.getBoundingClientRect():null;(c&&r?r.bottom>s&&r.top<o.bottom:a.has(e))&&l.push(e),n&&r&&r.top<=s+_I&&(u=e)}return l.length===0&&u===null?xI:{currentAnchorId:u,visibleMessageIds:l}}function wI(e,t){return Array.from(e.children).filter(e=>e instanceof HTMLElement&&e!==t)}function TI(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(t?.dataset.scrollAnchor===`true`)return t}return null}function EI(e,t){for(let n of e)if(n.dataset.scrollAnchor===`true`&&!t.has(n))return n;return null}function DI(e,t){let n=0;for(let r=t;r<e.length;r++)if(e[r]?.dataset.scrollAnchor===`true`&&(n+=1,n>1))return!0;return!1}function OI(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor===`true`)return n}return null}function kI({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let n of wI(e,t)){if(!n.dataset.messageId)continue;let e=n.getBoundingClientRect();if(e.bottom>r.top&&e.top<r.bottom)return n}return null}function AI({align:e,element:t,scrollMargin:n,spacer:r,viewport:i}){let a=jI(t,i),o=t.getBoundingClientRect().height,s=LI(r);if(e===`center`){let e=Math.max(0,i.clientHeight-s.start-s.end);return a-s.start-(e-o)/2-n}if(e===`end`)return a-i.clientHeight+o+s.end+n;if(e===`nearest`){let e=a+o,t=i.scrollTop+s.start,r=i.scrollTop+i.clientHeight-s.end;return a>=t&&e<=r?i.scrollTop:a<t?a-s.start-n:e-i.clientHeight+s.end+n}return a-s.start-n}function jI(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function MI(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function NI({content:e,scrollTop:t,spacer:n,viewport:r}){let i=PI({content:e,spacer:n,viewport:r});return t+r.clientHeight-i}function PI({content:e,spacer:t,viewport:n}){let r=wI(e,t),i=II(e),a=n.getBoundingClientRect(),o=n.scrollTop,s=i.start+i.end;for(let e of r){let t=e.getBoundingClientRect();s=Math.max(s,t.bottom-a.top+o+i.end)}return s}function FI(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function II(e){let t=window.getComputedStyle(e);return{end:zI(t.paddingBlockEnd||t.paddingBottom),start:zI(t.paddingBlockStart||t.paddingTop)}}function LI(e){let t=e?.parentElement;return t?II(t):{end:0,start:0}}function RI(e){if(!e)return 0;let t=window.getComputedStyle(e);return zI(t.rowGap===`normal`?t.gap:t.rowGap)}function zI(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function BI({refs:e,commitScrollState:t,scheduleStateCommit:n,scheduleVisibilitySync:r}){let{streamingTurnRef:i,autoScrollRef:a,autoscrollingRef:o,autoscrollingTimeoutRef:s,contentRef:c,defaultScrollPositionAppliedRef:l,itemCountRef:u,messageElementsRef:d,modeRef:f,pendingScrollToMessageRef:p,prependRestoreRef:m,scrollMarginRef:h,scrollPreviousItemPeekRef:g,spacerGapRef:_,spacerHeightRef:v,spacerRef:y,viewportRef:b}=e,x=G.useCallback(e=>{s.current!==null&&(window.clearTimeout(s.current),s.current=null),o.current!==e&&(o.current=e,t()),e&&(s.current=window.setTimeout(()=>{s.current=null,o.current=!1,t()},vI))},[t]),S=G.useCallback(e=>{let t=y.current;if(!t)return;let n=Math.max(0,Math.ceil(e));v.current!==n&&(v.current=n,t.hidden=n===0,t.style.height=`${n}px`,t.style.marginTop=n>0?`${-_.current}px`:``)},[]),C=G.useCallback((e,{behavior:r=`auto`,autoscrolling:i=!1}={})=>{let a=b.current;if(!a)return;let o=Math.max(0,e);if(Math.abs(a.scrollTop-o)<=_I){a.scrollTop=o,t();return}i&&x(!0),a.scrollTo({top:o,behavior:r}),n()},[t,n,x]),w=G.useCallback(({behavior:e=`auto`}={})=>b.current?(S(0),i.current=null,f.current=`free-scrolling`,C(0,{behavior:e}),r(),!0):!1,[r,C,S]),T=G.useCallback(({behavior:e=`auto`}={})=>{let t=b.current;return t?(S(0),i.current=null,f.current=a.current?`following-bottom`:`free-scrolling`,C(FI(t),{autoscrolling:!0,behavior:e}),r(),!0):!1},[r,C,S]),E=G.useCallback((e,{align:t=`start`,behavior:n=`auto`,scrollMargin:a=h.current}={},{keepPreviousPeek:o=!1}={})=>{let s=c.current,l=b.current;if(!s||!l||!s.contains(e))return!1;let u=AI({align:t,element:e,scrollMargin:o?a+g.current:a,spacer:y.current,viewport:l}),d=NI({content:s,scrollTop:u,spacer:y.current,viewport:l});return S(d),m.current={element:e,viewportTop:MI(e,l)},f.current=o?`anchored-to-message`:`settling-jump`,i.current=o?e:null,C(u,{behavior:n}),r(),!0},[r,C,S]),D=G.useCallback(()=>{let e=i.current;return!e||!e.isConnected||f.current!==`anchored-to-message`?!1:E(e,{align:`start`},{keepPreviousPeek:!0})},[E]),O=G.useCallback((e,t)=>{let n=d.current.get(e);return n?(l.current=!0,E(n,t)?(p.current=null,!0):(p.current={messageId:e,options:t},!0)):u.current===0?(p.current={messageId:e,options:t},l.current=!0,!0):!1},[E]);return{flushPendingScrollToMessage:G.useCallback(()=>{let e=p.current;if(!e)return!1;let t=d.current.get(e.messageId);return!t||!E(t,e.options)?!1:(p.current=null,l.current=!0,!0)},[E]),reanchorToAnchoredMessage:D,scrollToElement:E,scrollToEnd:T,scrollToMessage:O,scrollToStart:w}}function VI(e,t){let n=e,r=new Set;return{getSnapshot:()=>n,hasListeners:()=>r.size>0,setSnapshot:e=>{t(n,e)||(n=e,r.forEach(e=>e()))},subscribe:(e,t,n)=>{let i=r.size===0;return r.add(e),i&&t?.(),()=>{r.delete(e),r.size===0&&n?.()}}}}function HI(e,t){return VI(e,t)}function UI(){return VI(xI,GI)}function WI(e,t){return e.start===t.start&&e.end===t.end}function GI(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((e,n)=>e===t.visibleMessageIds[n])}function KI({autoScroll:e,scrollEdgeThreshold:t,scrollMargin:n,scrollPreviousItemPeek:r}){let i=G.useRef(e),a=G.useRef(!1),o=G.useRef(null),s=G.useRef(!1),c=G.useRef(t),l=G.useRef(0),u=G.useRef(null),d=G.useRef(0),f=G.useRef(e?`following-bottom`:`free-scrolling`),p=G.useRef(new Map),m=G.useRef(null),h=G.useRef(null),g=G.useRef(null),_=G.useRef(r),v=G.useRef(!0),y=G.useRef(null),b=G.useRef(n),x=G.useRef(null),S=G.useRef(0),C=G.useRef(0),w=G.useRef(null),T=G.useRef(null),E=G.useRef(null),D=G.useRef(null),O=G.useRef(null),k=G.useRef(null),A=G.useRef(null),j=G.useRef(null),M=G.useRef(new Set),N=G.useRef(new WeakSet);return E.current===null&&(E.current=HI(bI,WI)),j.current===null&&(j.current=UI()),i.current=e,c.current=t,b.current=n,_.current=r,{autoScrollRef:i,autoscrollingRef:a,autoscrollingTimeoutRef:D,streamingTurnRef:g,contentRef:o,defaultScrollPositionAppliedRef:s,firstItemRef:u,itemCountRef:l,lastScrollTopRef:d,messageElementsRef:p,modeRef:f,pendingScrollFrameRef:x,pendingScrollToMessageRef:m,prependRestoreRef:h,preserveScrollOnPrependRef:v,rootRef:y,scrollEdgeThresholdRef:c,scrollMarginRef:b,scrollPreviousItemPeekRef:_,spacerGapRef:S,spacerHeightRef:C,spacerRef:w,stateFrameRef:T,stateStore:E.current,viewportRef:O,visibilityFrameRef:k,visibilityObserverRef:A,visibilityStore:j.current,visibleMessageIdsRef:M,handledScrollAnchorsRef:N}}function qI(e,t){return G.useCallback(n=>{e.current=n,n&&t()},[e,t])}function JI({autoScroll:e=!1,defaultScrollPosition:t=`end`,scrollEdgeThreshold:n=mI,scrollPreviousItemPeek:r=hI,scrollMargin:i=gI}){let a=KI({autoScroll:e,scrollEdgeThreshold:n,scrollMargin:i,scrollPreviousItemPeek:r}),{streamingTurnRef:o,autoScrollRef:s,autoscrollingRef:c,autoscrollingTimeoutRef:l,contentRef:u,defaultScrollPositionAppliedRef:d,firstItemRef:f,itemCountRef:p,lastScrollTopRef:m,messageElementsRef:h,modeRef:g,pendingScrollFrameRef:_,pendingScrollToMessageRef:v,prependRestoreRef:y,preserveScrollOnPrependRef:b,rootRef:x,scrollEdgeThresholdRef:S,scrollMarginRef:C,scrollPreviousItemPeekRef:w,spacerGapRef:T,spacerHeightRef:E,spacerRef:D,stateFrameRef:O,stateStore:k,viewportRef:A,visibilityFrameRef:j,visibilityObserverRef:M,visibilityStore:N,visibleMessageIdsRef:P,handledScrollAnchorsRef:ee}=a,te=G.useRef(t);te.current!==t&&(te.current=t,d.current=!1);let ne=G.useCallback(e=>{let t=x.current,n=A.current,r=[e.start&&`start`,e.end&&`end`].filter(Boolean).join(` `),i=c.current;for(let e of[t,n])e&&(r?e.setAttribute(`data-scrollable`,r):e.removeAttribute(`data-scrollable`),e.toggleAttribute(`data-autoscrolling`,i))},[]),re=G.useCallback(e=>{let t=A.current?.scrollTop??0,n=t<m.current-_I;m.current=t,s.current&&!e.end&&g.current!==`settling-jump`&&g.current!==`anchored-to-message`?g.current=`following-bottom`:g.current===`following-bottom`&&e.end&&n&&!c.current&&(g.current=`free-scrolling`)},[]),ie=G.useCallback(()=>{let e=SI({content:u.current,scrollEdgeThreshold:S.current,spacer:D.current,viewport:A.current});re(e);let t=g.current===`following-bottom`?{...e,end:!1}:e;ne(t),k.setSnapshot(t)},[re,k,ne]),ae=G.useCallback(()=>{O.current===null&&(O.current=window.requestAnimationFrame(()=>{O.current=null,ie()}))},[ie]),F=G.useCallback(()=>{N.hasListeners()&&j.current===null&&(j.current=window.requestAnimationFrame(()=>{j.current=null,N.hasListeners()&&N.setSnapshot(CI({content:u.current,scrollMargin:C.current,scrollPreviousItemPeek:w.current,spacer:D.current,viewport:A.current,visibleMessageIds:P.current}))}))},[N]),{flushPendingScrollToMessage:I,reanchorToAnchoredMessage:oe,scrollToElement:se,scrollToEnd:ce,scrollToMessage:le,scrollToStart:ue}=BI({refs:a,commitScrollState:ie,scheduleStateCommit:ae,scheduleVisibilitySync:F}),de=G.useCallback(()=>{let e=y.current,t=A.current;if(!e||!t||!e.element.isConnected)return!1;let n=MI(e.element,t)-e.viewportTop;return Math.abs(n)<=_I?!1:(t.scrollTop+=n,e.viewportTop=MI(e.element,t),ae(),F(),!0)},[ae,F]),fe=G.useCallback(()=>{let e=u.current,t=A.current;if(!e||!t){y.current=null;return}let n=kI({content:e,spacer:D.current,viewport:t});y.current=n?{element:n,viewportTop:MI(n,t)}:null},[]),pe=G.useCallback(()=>{_.current===null&&(_.current=window.requestAnimationFrame(()=>{_.current=null,I()&&fe()}))},[fe,I]),me=G.useCallback(()=>{if(!t||d.current||p.current===0)return!1;let e=!1;if(t===`last-anchor`){let t=u.current,n=A.current,r=t&&n?OI(wI(t,D.current)):null;if(!t||!n||!r)e=ce({behavior:`auto`});else{let i=jI(r,n);e=PI({content:t,spacer:D.current,viewport:n})-i<=n.clientHeight?ce({behavior:`auto`}):se(r,{align:`start`},{keepPreviousPeek:!0})}}else e=t===`end`?ce({behavior:`auto`}):ue({behavior:`auto`});return e?(d.current=!0,!0):!1},[t,se,ce,ue]),he=G.useCallback(()=>{let e=u.current;if(!e)return;let t=wI(e,D.current),n=p.current,r=f.current;p.current=t.length,f.current=t[0]??null,(()=>{if(I())return;if(n===0){if(me()||t.length>0&&s.current&&ce({behavior:`auto`}))return;ie(),F();return}let e=r?t.indexOf(r):-1;if(b.current&&e>0){de();return}if(t.length>n){let e=TI(t,n);if(e){if(s.current&&g.current===`following-bottom`&&DI(t,n)){ce({behavior:`auto`});return}se(e,{align:`start`},{keepPreviousPeek:!0}),ee.current.add(e);return}}if(t.length===n){let e=EI(t,ee.current);if(e){se(e,{align:`start`},{keepPreviousPeek:!0}),ee.current.add(e);return}}g.current===`following-bottom`&&s.current?ce({behavior:`auto`}):(ie(),F())})(),fe()},[me,fe,ie,I,de,F,se,ce]),ge=G.useCallback(()=>{if(g.current===`following-bottom`&&s.current){ce({behavior:`auto`});return}let e=E.current;if(oe()){s.current&&e>0&&E.current===0&&ce({behavior:`auto`});return}ae(),F()},[oe,ae,F,ce]),_e=G.useCallback(()=>{let e=A.current;if(!(!e||!N.hasListeners())){if(typeof IntersectionObserver>`u`){F();return}M.current||=new IntersectionObserver(e=>{for(let t of e){let e=t.target.dataset.messageId;e&&(t.isIntersecting?P.current.add(e):P.current.delete(e))}F()},{root:e,rootMargin:`${-(C.current+w.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]}),h.current.forEach(e=>{M.current?.observe(e)}),F()}},[F,N]),ve=G.useCallback(()=>{j.current!==null&&(window.cancelAnimationFrame(j.current),j.current=null),M.current?.disconnect(),M.current=null,P.current.clear(),N.setSnapshot(xI)},[N]),ye=G.useCallback((e,t,n)=>{if(t){h.current.set(e,t),M.current?.observe(t),F(),v.current?.messageId===e&&pe();return}n&&h.current.get(e)===n&&(h.current.delete(e),P.current.delete(e),M.current?.unobserve(n),F())},[pe,F]),be=G.useCallback(()=>{(g.current===`following-bottom`||g.current===`anchored-to-message`||g.current===`settling-jump`)&&(o.current=null,g.current=`free-scrolling`)},[]),L=G.useCallback(()=>ne(k.getSnapshot()),[k,ne]),xe=qI(x,L),Se=qI(A,L),Ce=G.useCallback(e=>{u.current=e},[]),we=G.useCallback(e=>{D.current=e,T.current=RI(e?.parentElement??null)},[]),Te=G.useCallback(()=>{ie(),F(),fe()},[fe,ie,F]),Ee=G.useMemo(()=>({handleContentChange:he,handleResize:ge,observeVisibility:_e,preserveScrollOnPrependRef:b,scrollToEnd:ce,scrollToMessage:le,scrollToStart:ue,setContentElement:Ce,setRootElement:xe,setSpacerElement:we,setViewportElement:Se,stateStore:k,syncAfterScroll:Te,unobserveVisibility:ve,userScrollIntent:be,viewportRef:A,visibilityStore:N}),[he,ge,_e,ce,le,ue,Ce,xe,we,Se,k,Te,ve,be,N]);return G.useLayoutEffect(()=>{me()},[me]),G.useEffect(()=>()=>{O.current!==null&&(window.cancelAnimationFrame(O.current),O.current=null),j.current!==null&&(window.cancelAnimationFrame(j.current),j.current=null),l.current!==null&&(window.clearTimeout(l.current),l.current=null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null),M.current?.disconnect(),M.current=null},[]),G.useLayoutEffect(()=>{if(e&&g.current===`following-bottom`&&p.current>0){ce({behavior:`auto`});return}ie()},[e,ie,ce]),{context:Ee,registerMessage:ye}}function YI(e){let t=G.useRef(e);return t.current=e,t}var XI=G.createContext(null),ZI=G.createContext(null);function QI(){let e=G.useContext(XI);if(!e)throw Error(`useMessageScroller must be used within a MessageScroller.`);return e}function $I(){let e=G.useContext(ZI);if(!e)throw Error(`MessageScrollerItem must be used within a MessageScroller.`);return e}function eL(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=QI();return G.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function tL({autoScroll:e=!1,children:t,defaultScrollPosition:n=`end`,scrollEdgeThreshold:r,scrollPreviousItemPeek:i,scrollMargin:a}){let{context:o,registerMessage:s}=JI({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:i,scrollMargin:a});return(0,K.jsx)(XI.Provider,{value:o,children:(0,K.jsx)(ZI.Provider,{value:s,children:t})})}function nL({children:e,...t}){let{setRootElement:n}=QI();return(0,K.jsx)(`div`,{ref:n,...t,children:e})}function rL({"aria-label":e,children:t,onKeyDown:n,onScroll:r,onTouchMove:i,onWheel:a,preserveScrollOnPrepend:o=!0,ref:s,role:c,tabIndex:l,...u}){let{handleResize:d,preserveScrollOnPrependRef:f,setViewportElement:p,syncAfterScroll:m,userScrollIntent:h,viewportRef:g}=QI();f.current=o;let _=G.useCallback(e=>{p(e),pI(s)?.(e)},[s,p]);function v(e){m(),r?.(e)}function y(e){h(),a?.(e)}function b(e){h(),i?.(e)}function x(e){yI.has(e.key)&&h(),n?.(e)}return G.useEffect(()=>{let e=g.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=new ResizeObserver(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(d)});return n.observe(e),()=>{window.cancelAnimationFrame(t),n.disconnect()}},[d,g]),(0,K.jsx)(`div`,{ref:_,role:c??`region`,"aria-label":e??`Messages`,tabIndex:l??0,onKeyDown:x,onScroll:v,onTouchMove:b,onWheel:y,...u,children:t})}function iL({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:i,...a}){let{handleContentChange:o,handleResize:s,setContentElement:c,setSpacerElement:l}=QI(),u=G.useRef(null),d=G.useCallback(e=>{u.current=e,c(e),pI(n)?.(e)},[n,c]);return G.useLayoutEffect(()=>{let e=u.current;if(!e||(o(),typeof MutationObserver>`u`))return;let t=new MutationObserver(()=>{o()});return t.observe(e,{childList:!0}),()=>t.disconnect()},[o]),G.useEffect(()=>{let e=u.current;if(!e||typeof ResizeObserver>`u`)return;let t=0,n=new ResizeObserver(()=>{window.cancelAnimationFrame(t),t=window.requestAnimationFrame(s)});return n.observe(e),()=>{window.cancelAnimationFrame(t),n.disconnect()}},[s]),(0,K.jsxs)(`div`,{ref:d,role:r??`log`,"aria-relevant":e??`additions`,...a,children:[t,(0,K.jsx)(`div`,{ref:l,"aria-hidden":`true`,"data-message-scroller-spacer":``,hidden:!0,className:i})]})}function aL({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let i=$I(),a=G.useRef(null);return(0,K.jsx)(`div`,{ref:G.useCallback(n=>{let r=a.current;a.current=n,e&&i(e,n,r),pI(t)?.(n)},[e,t,i]),"data-message-id":e,"data-scroll-anchor":n?`true`:`false`,...r})}function oL({behavior:e=`smooth`,children:t,direction:n=`end`,onClick:r,render:i,tabIndex:a,type:o=`button`,...s}){let{scrollToEnd:c,scrollToStart:l,stateStore:u}=QI(),d=YI(r),f=G.useCallback(e=>u.subscribe(e),[u]),p=G.useCallback(()=>{let e=u.getSnapshot();return n===`start`?e.start:e.end},[n,u]),m=G.useSyncExternalStore(f,p,p),h=G.useCallback(t=>{m&&(d.current?.(t),t.defaultPrevented||(t.currentTarget.blur(),n===`start`?l({behavior:e}):c({behavior:e})))},[e,n,m,d,c,l]);return cI({defaultTagName:`button`,props:lI({type:o,inert:!m,tabIndex:m?a:-1,children:t??(0,K.jsxs)(`span`,{children:[`Scroll to `,n]}),onClick:h},s),render:i,state:{active:m,direction:n},stateAttributesMapping:{active:e=>({"data-active":e?`true`:`false`})}})}var sL={Provider:tL,Root:nL,Viewport:rL,Content:iL,Item:aL,Button:oL},cL=sL.Provider;function lL({className:e,...t}){return(0,K.jsx)(sL.Root,{"data-slot":`message-scroller`,className:B(`group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden`,e),...t})}function uL({className:e,...t}){return(0,K.jsx)(sL.Viewport,{"data-slot":`message-scroller-viewport`,className:B(`size-full min-h-0 min-w-0 overflow-y-auto overscroll-contain`,`scrollbar-thin scrollbar-gutter-stable data-autoscrolling:scrollbar-quiet`,e),...t})}function dL({className:e,...t}){return(0,K.jsx)(sL.Content,{"data-slot":`message-scroller-content`,className:B(`flex h-max min-h-full flex-col`,e),...t})}function fL({className:e,scrollAnchor:t=!1,...n}){return(0,K.jsx)(sL.Item,{"data-slot":`message-scroller-item`,scrollAnchor:t,className:B(`min-w-0 shrink-0`,e),...n})}function pL({direction:e=`end`,className:t,children:n,...r}){return(0,K.jsx)(sL.Button,{"data-slot":`message-scroller-button`,"data-direction":e,direction:e,className:B(`absolute left-1/2 z-10 flex -translate-x-1/2 items-center gap-1 rounded-full border border-border bg-background/90 px-3 py-1 text-xs text-foreground shadow-sm backdrop-blur transition-[translate,scale,opacity] duration-200 hover:bg-accent`,`data-[active=false]:pointer-events-none data-[active=false]:scale-95 data-[active=false]:opacity-0`,`data-[active=true]:translate-y-0 data-[active=true]:scale-100 data-[active=true]:opacity-100`,`data-[direction=end]:bottom-3 data-[direction=end]:data-[active=false]:translate-y-full`,`data-[direction=start]:top-3 data-[direction=start]:data-[active=false]:-translate-y-full`,t),...r,children:n??(0,K.jsxs)(K.Fragment,{children:[`Jump to latest`,(0,K.jsx)(Ui,{className:`size-3.5`,"aria-hidden":!0})]})})}function mL(e){return e.kind===`driver`?e.event.type===`start`?e.event.prompt:e.event.type===`text`?e.event.text:null:null}function hL(e){return e.replace(/\s+/g,` `).trim().length>100}function gL(e){return e.kind===`driver`?e.event.type===`start`?`you`:`agent`:e.kind}function _L(e){return e.kind===`driver`&&e.event.type===`start`}function vL(e){return e.kind===`driver`?e.event.type===`error`:e.kind===`error`||e.kind===`end`&&!e.ok&&!e.stopped&&!e.waiting}function yL(e){return vL(e)?`text-danger`:``}function bL(e){return vL(e)?`bg-danger/10`:``}function xL(e){let t=e.findIndex(_L);return t<=0?e:[e[t],...e.slice(0,t),...e.slice(t+1)]}function SL(e){return new Date(e).toLocaleTimeString()}function CL(e){let t=new Map,n=new Set,r=new Map,i=new Map;e.forEach((e,t)=>{e.kind===`choice`?r.set(e.id,{e,at:t}):e.kind===`choice-resolved`&&i.set(e.id,{e,at:t})});let a=new Set(e.flatMap(e=>_L(e)?[KF(e.event.prompt)?.question]:[]));for(let t of e)t.kind===`choice`&&a.has(t.title)&&n.add(t);let o=new Set(kn(e).map(e=>e.id));for(let[e,a]of r){if(n.has(a.e))continue;let{kind:r,...s}=a.e,c=i.get(e);o.has(e)?t.set(a.e,{choice:s}):c&&c.at>a.at&&(t.set(a.e,{choice:s,pick:c.e.picked}),n.add(c.e))}return{rows:t,hidden:n}}function wL(e){return new Set(e.filter(e=>e.kind===`end`&&(e.ok||e.waiting)))}function TL(e){let t=new Set,n;for(let r of e)_L(r)?n=void 0:r.kind===`driver`&&r.event.type===`text`?n=r:r.kind===`choice`&&n&&t.add(n);return t}function EL(e){return e.replace(/```await-choices\b[\s\S]*?(```|$)/g,``).trim()}function DL({text:e}){return(0,K.jsx)(`div`,{className:`min-w-0 flex-1 font-sans text-foreground`,children:(0,K.jsx)(Wt,{text:e})})}function OL({text:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsx)(`button`,{type:`button`,"aria-label":t?`Copied`:`Copy this message`,title:t?`Copied`:`Copy this message`,onClick:()=>{navigator.clipboard?.writeText(e).then(()=>n(!0),()=>void 0)},className:`flex h-6 w-6 items-center justify-center rounded-md hover:bg-accent hover:text-accent-foreground`,children:t?(0,K.jsx)(N,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):(0,K.jsx)(mn,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})}function kL({text:e,at:t}){return(0,K.jsxs)(`div`,{className:`turn-footer flex h-6 items-center gap-1 font-sans text-muted-foreground opacity-0 transition-opacity focus-within:opacity-100`,children:[(0,K.jsx)(OL,{text:e}),t!==void 0&&(0,K.jsx)(`time`,{dateTime:t,title:new Date(t).toLocaleString(),className:`px-1 text-[11px]`,children:an(t)})]})}var AL=8,jL=600;function ML(e){return e.length>jL||e.trim().split(`
133
133
  `).length>AL}function NL({question:e,answer:t}){return(0,K.jsxs)(`div`,{role:`group`,"aria-label":`Your answer`,className:`flex w-full max-w-[480px] flex-col gap-0.5 rounded-lg px-3 py-2 font-sans text-sm ring-1 ring-border`,children:[(0,K.jsx)(`div`,{className:`font-medium text-foreground`,children:e}),t===void 0?(0,K.jsx)(`div`,{className:`italic text-muted-foreground`,children:`Skipped`}):(0,K.jsx)(`div`,{className:`text-muted-foreground`,children:t})]})}var PL=`group/row -mx-1.5 mt-2 flex items-start gap-2 rounded-sm px-1.5`;function FL({files:e,onOpen:t,footer:n}){return(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,K.jsx)(vk,{files:e,onOpen:t}),n&&(0,K.jsx)(kL,{text:n.text,at:n.at})]})}function IL({text:e,at:t,queued:n=!1,attached:r,fresh:i=!1}){let[a,o]=(0,G.useState)(!1),s=ML(e);return(0,K.jsxs)(`div`,{className:`group/prompt flex min-w-0 flex-1 flex-col items-end font-sans text-foreground ${i?`bubble-in`:``}`,children:[(0,K.jsxs)(`div`,{role:`group`,"aria-label":n?`Your message, queued`:`Your message`,className:`max-w-[85%] min-w-0 rounded-xl bg-muted px-3.5 py-2 ${n?`opacity-60`:``}`,children:[(0,K.jsx)(`div`,{className:s&&!a?`max-h-40 overflow-hidden`:``,children:(0,K.jsx)(Wt,{text:e})}),s&&(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":a,className:`mt-1 text-xs text-muted-foreground hover:text-foreground`,children:a?`Show less`:`Show more`})]}),r!==void 0&&(0,K.jsx)(LL,{text:r}),n?(0,K.jsx)(`span`,{className:`mt-1.5 h-6 pr-1 text-[11px] leading-6 text-muted-foreground`,children:`Queued`}):(0,K.jsxs)(`div`,{className:`mt-1.5 flex h-6 items-center gap-1 text-muted-foreground opacity-0 transition-opacity focus-within:opacity-100 group-hover/prompt:opacity-100`,children:[t!==void 0&&(0,K.jsx)(`time`,{dateTime:t,title:new Date(t).toLocaleString(),className:`px-1 text-[11px]`,children:an(t)}),(0,K.jsx)(OL,{text:e})]})]})}function LL({text:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`mt-1 flex max-w-[85%] min-w-0 flex-col items-end text-xs text-muted-foreground`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>n(e=>!e),"aria-expanded":t,className:`flex items-center gap-1 hover:text-foreground`,children:[(0,K.jsx)(`span`,{children:`Sent with this message`}),(0,K.jsx)(m,{className:`h-3.5 w-3.5 shrink-0 transition-transform ${t?`rotate-90`:``}`,"aria-hidden":!0})]}),t&&(0,K.jsx)(`pre`,{className:`mt-1 max-h-80 w-full overflow-auto whitespace-pre-wrap break-words rounded-lg border border-border px-3 py-2 text-left font-mono text-foreground`,children:e})]})}function RL({text:e}){let[t,n]=(0,G.useState)(!1);return hL(e)?(0,K.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>n(!t),"aria-expanded":t,"aria-label":t?`Collapse message`:`Expand message`,className:`mt-0.5 shrink-0 select-none text-muted-foreground transition-transform ${t?`rotate-90`:``}`,children:(0,K.jsx)(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,K.jsx)(`div`,{className:t?`min-w-0 flex-1`:`max-h-[1.35rem] min-w-0 flex-1 cursor-pointer overflow-hidden`,onClick:t?void 0:()=>n(!0),children:(0,K.jsx)(Wt,{text:e,compact:!0})})]}):(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,K.jsx)(Wt,{text:e,compact:!0})})}function zL(e){return e.kind===`driver`&&(e.event.type===`action`||e.event.type===`thought`)?{...e.event}:void 0}function BL(e){return e.kind===`driver`&&e.event.type===`output`?e.event:void 0}function VL(e,t=!1){let n=e[e.length-1],r=t&&n!==void 0?zL(n):void 0;if(r?.type===`action`)return{...VL(e.slice(0,-1)),current:r};let i=[],a=new Map,o,s=new Map,c=()=>{o?.steps.some(e=>e.type===`action`)&&(i.push(o.head),a.set(o.head,o.steps)),o=void 0};for(let t of e){let e=BL(t);if(e){let t=s.get(e.id);t&&(t.output={text:e.text,...e.failed?{failed:!0}:{},...e.exitCode===void 0?{}:{exitCode:e.exitCode},...e.changed?{changed:e.changed}:{}});continue}let n=zL(t);n?.type===`action`&&n.id!==void 0&&s.set(n.id,n),n===void 0?(c(),i.push(t)):o?o.steps.push(n):o={head:t,steps:[n]}}return c(),{rows:i,steps:a}}function HL({words:e,tone:t}){let{said:n,thing:r,href:i,detail:a}=e,o=t===``?`text-foreground`:t;return(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 font-sans text-sm`,children:[(0,K.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,K.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words ${t||`text-muted-foreground`}`,children:n}),r!==void 0&&(i===void 0?(0,K.jsx)(`span`,{className:`min-w-0 truncate ${o}`,children:r}):(0,K.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer`,className:`min-w-0 shrink-0 truncate hover:underline ${o}`,children:r}))]}),a!==void 0&&(0,K.jsx)(`div`,{className:`mt-0.5 whitespace-pre-wrap break-words opacity-80 ${t||`text-muted-foreground`}`,children:a})]})}function UL({label:e,onOpen:t}){return t?(0,K.jsxs)(`button`,{type:`button`,onClick:t,className:`group/screen flex min-w-0 flex-1 items-center gap-1.5 text-left font-sans text-sm text-foreground`,children:[(0,K.jsx)(`span`,{className:`min-w-0 truncate group-hover/screen:underline`,children:e}),(0,K.jsx)(m,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}):(0,K.jsx)(`div`,{className:`min-w-0 flex-1 truncate font-sans text-sm text-muted-foreground`,children:e})}var WL=`ml-auto shrink-0 pt-0.5 text-[10px] tabular-nums text-muted-foreground opacity-0 transition-opacity group-hover/row:opacity-100`,GL=`subagent`,KL=8,qL=[],JL=[],YL={};function XL(e){return e.kind===`session-update`||e.kind===`usage`||e.kind===`title`||e.kind===`driver`&&e.event.type===`result`?!1:e.kind===`driver`&&e.event.type===`rate-limit`?e.event.limit.status!==`allowed`:!0}function ZL(e,t){(0,G.useLayoutEffect)(()=>{let n=e.current,r=t.current;if(!n||!r||typeof ResizeObserver>`u`)return;let i=()=>n.clientHeight-r.getBoundingClientRect().height,a=i(),o=new ResizeObserver(()=>{let e=a-i();a-=e,!(e<=0)&&n.scrollHeight-n.scrollTop-n.clientHeight-e<=KL&&(n.scrollTop=n.scrollHeight)});return o.observe(r),o.observe(n),()=>o.disconnect()},[e,t])}function QL({sent:e}){let{scrollToEnd:t}=eL(),n=(0,G.useRef)(e);return(0,G.useLayoutEffect)(()=>{e>n.current&&t({behavior:`smooth`}),n.current=e},[e,t]),null}function $L({events:e,writing:t=``,sending:n,working:r=!1,queued:i=JL,waitingOn:a=0,stick:o=!0,openAt:s,tail:c,projectId:l,agentId:u,onSaid:d,subagents:f=qL,doing:p=YL,setup:m,onOpenSubagent:h,onOpenChange:g,onOpenScreen:_}){let v=(0,G.useMemo)(()=>l?CL(e):void 0,[l,e]),y=(0,G.useMemo)(()=>wn(e),[e]),b=(0,G.useMemo)(()=>wL(e),[e]),x=m?.workspace,S=(0,G.useMemo)(()=>ok(e,x),[e,x]),C=(0,G.useMemo)(()=>new Map(e.map((e,t)=>[e,String(t)])),[e]),w=(0,G.useMemo)(()=>TL(e),[e]),T=(0,G.useMemo)(()=>So(e),[e]),E=(0,G.useMemo)(()=>Co(e),[e]),D=xL(e).filter(e=>XL(e)&&!v?.hidden.has(e)&&!y.hidden.has(e)&&!E.has(e)),O=n===void 0?void 0:KF(n),k=O&&v?[...v.rows].find(([,e])=>e.pick===void 0&&e.choice.title===O.question)?.[0]:void 0,A=n===void 0||k?D:[...D,{kind:`driver`,event:{type:`start`,prompt:n}}],j=e=>{let t=mL(e);return t!==null&&w.has(e)?EL(t):t},M=EL(t),N=A.filter(e=>!b.has(e)&&j(e)!==``),{rows:P,steps:ee,current:te}=VL(N,r&&!M),ne=N.length>0&&_L(N[N.length-1]),re=[...N].reverse().find(_L)?.at??N[N.length-1]?.at,ie=new Map;for(let e of P){let t=e.kind===`driver`&&e.event.type===`start`?bo(e.event.prompt,f):void 0;t&&ie.set(e,t)}let ae=e=>C.get(e)??`sending`,F=e=>ie.has(e)?GL:gL(e),I=Do(P,[...f.map(e=>To(e,p[e.id])),...T.map(t=>Eo(t,r,e[0]?.at??new Date(0).toISOString()))],_L),oe=e=>{let t=I.get(e);if(!t)return null;let n=t[0];return(0,K.jsx)(fL,{messageId:`subagent-${n.key}`,className:`group/row -mx-1.5 flex items-start gap-2 rounded-sm px-1.5`,children:(0,K.jsx)(oI,{rows:t,onOpen:h})},`subagent-${n.key}`)},se=m===void 0?-1:P.length>0&&_L(P[0])?1:0,ce=m!==void 0&&r&&!M&&ne&&N.filter(_L).length===1,le=e.find(_L),ue=le?.kind===`driver`&&le.event.type===`start`?le.event.added:void 0,de=m!==void 0&&(0,K.jsx)(nI,{setup:m,working:r,added:ue,...ce?{live:{since:re}}:{}}),fe=m!==void 0&&(0,K.jsx)(nI,{setup:m,working:r,added:ue,nested:!0}),pe=de!==!1&&!tI(m,r)&&!ce&&se>=0&&P[se]!==void 0&&ee.has(P[se]),me=de&&!pe&&(0,K.jsx)(fL,{messageId:`setup`,className:`-mx-1.5 flex items-start gap-2 rounded-sm px-1.5 empty:hidden`,children:de},`setup`),he=(0,G.useRef)(null),ge=(0,G.useRef)(null);ZL(he,ge);let _e=new Map,ve=new Map,ye,be=[];for(let e of P){let t=j(e),n=v?.rows.get(e);if(_L(e)){if(ie.has(e)||t!==null&&KF(t))continue;ye&&(S.ended.has(e)?ve.set(e,{text:ye.text,at:ye.row.at}):_e.set(ye.row,ye.text)),ye=void 0,be=[]}else t===null?n&&(ye={row:e,text:be.length>0?be.join(`