@openagt/dashboard 0.47.0 → 0.48.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.
- package/dist/dashboard/logins-sync.d.ts +4 -0
- package/dist/dashboard/logins-sync.d.ts.map +1 -1
- package/dist/dashboard/logins-sync.js +21 -2
- package/dist/dashboard/logins-sync.js.map +1 -1
- package/dist/dashboard-bundle/assets/{main-Ca6eaXat.css → main-CbO78PA9.css} +1 -1
- package/dist/dashboard-bundle/assets/{main-DftJ_BI6.js → main-DyfbReQD.js} +1 -1
- package/dist/dashboard-bundle/index.html +2 -2
- package/dist/module-types/src/dashboard/logins-sync.d.ts +4 -0
- package/package.json +16 -16
|
@@ -126,7 +126,7 @@ ${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>`)}}}}}}),DD=Nb.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?xD.storage.markdown.serialize.call(this,e,t,n):`\\
|
|
127
127
|
`);return}},parse:{}}}}}),OD=Nb.create({name:`heading`}).extend({addStorage(){return{markdown:{serialize:$E.nodes.heading,parse:{}}}}}),kD=Nb.create({name:`horizontalRule`}).extend({addStorage(){return{markdown:{serialize:$E.nodes.horizontal_rule,parse:{}}}}}),AD=Nb.create({name:`image`}).extend({addStorage(){return{markdown:{serialize:$E.nodes.image,parse:{}}}}}),jD=Nb.create({name:`listItem`}).extend({addStorage(){return{markdown:{serialize:$E.nodes.list_item,parse:{}}}}}),MD=Nb.create({name:`orderedList`});function ND(e,t,n){let r=0;for(;n-r>0&&t.child(n-r-1).type.name===e.type.name;r++);return r}var PD=MD.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=ND(t,n,r)%2?`) `:`. `;e.renderList(t,o,t=>{let n=String(i+t);return e.repeat(` `,a-n.length)+n+s})},parse:{}}}}}),FD=Nb.create({name:`paragraph`}).extend({addStorage(){return{markdown:{serialize:$E.nodes.paragraph,parse:{}}}}});function ID(e){var t;return(e==null||(t=e.content)==null?void 0:t.content)??[]}var LD=Nb.create({name:`table`}).extend({addStorage(){return{markdown:{serialize(e,t,n){if(!zD(t)){xD.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 RD(e){return e.attrs.colspan>1||e.attrs.rowspan>1}function zD(e){let t=ID(e),n=t[0],r=t.slice(1);return!(ID(n).some(e=>e.type.name!==`tableHeader`||RD(e)||e.childCount>1)||r.some(e=>ID(e).some(e=>e.type.name===`tableHeader`||RD(e)||e.childCount>1)))}var BD=[wD,TD,ED,DD,OD,kD,xD,AD,jD,PD,FD,LD,Nb.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())})}}}}}}),Nb.create({name:`taskList`}).extend({addStorage(){return{markdown:{serialize:TD.storage.markdown.serialize,parse:{setup(e){e.use(rD.default)},updateDOM(e){[...e.querySelectorAll(`.contains-task-list`)].forEach(e=>{e.setAttribute(`data-type`,`taskList`)})}}}}}}),Nb.create({name:`text`}).extend({addStorage(){return{markdown:{serialize(e,t){e.text(vD(t.text))},parse:{}}}}}),xv.create({name:`bold`}).extend({addStorage(){return{markdown:{serialize:$E.marks.strong,parse:{}}}}}),xv.create({name:`code`}).extend({addStorage(){return{markdown:{serialize:$E.marks.code,parse:{}}}}}),hD,xv.create({name:`italic`}).extend({addStorage(){return{markdown:{serialize:$E.marks.em,parse:{}}}}}),xv.create({name:`link`}).extend({addStorage(){return{markdown:{serialize:$E.marks.link,parse:{}}}}}),xv.create({name:`strike`}).extend({addStorage(){return{markdown:{serialize:{open:`~~`,close:`~~`,expelEnclosingWhitespace:!0},parse:{}}}}})];function VD(e){let t=e.storage?.markdown,n=BD.find(t=>t.name===e.name)?.storage.markdown;return t||n?{...n,...t}:null}var HD=class{constructor(e){oD(this,`editor`,null),this.editor=e}serialize(e){let t=new mD(this.nodes,this.marks,{hardBreakNodeName:DD.name});return t.renderContent(e),t.out}get nodes(){return{...Object.fromEntries(Object.keys(this.editor.schema.nodes).map(e=>[e,this.serializeNode(xD)])),...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(hD)])),...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=VD(e))==null||(t=t.serialize)==null?void 0:t.bind({editor:this.editor,options:e.options})}serializeMark(e){let t=VD(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}},UD=class{constructor(e,t){oD(this,`editor`,null),oD(this,`md`,null);let{html:n,linkify:r,breaks:i}=t;this.editor=e,this.md=this.withPatchedRenderer(VE({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=VD(e))==null||(t=t.parse)==null||(t=t.setup)==null?void 0:t.call({editor:this.editor,options:e.options},this.md)});let n=_D(this.md.render(e));return this.editor.extensionManager.extensions.forEach(e=>{var t;return(t=VD(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}bD(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}},WD=jv.create({name:`markdownClipboard`,addOptions(){return{transformPastedText:!1,transformCopiedText:!1}},addProseMirrorPlugins(){return[new vf({key:new xf(`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 _u.fromSchema(this.editor.schema).parseSlice(_D(r),{preserveWhitespace:!0,context:t})},clipboardTextSerializer:e=>this.options.transformCopiedText?this.editor.storage.markdown.serializer.serialize(e.content):null}})]}}),GD=jv.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=wb.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 UD(this.editor,this.options),serializer:new HD(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[sD.configure({tight:this.options.tightLists,tightClass:this.options.tightListClass}),WD.configure({transformPastedText:this.options.transformPastedText,transformCopiedText:this.options.transformCopiedText})]}}),KD=Nb.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`,tv(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 qD(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=Ib(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 JD=new xf(`suggestion`);function YD({pluginKey:e=JD,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=qD}){let g,_=p?.(),v=new vf({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),ig.create(e.doc,[tg.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return v}function XD(e){return`prompt-suggestion-option-${e}`}var ZD=(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?XD(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:XD(r),role:`option`,"aria-selected":r===a,...n.title?{title:n.title}:{},onMouseDown:e=>{e.preventDefault(),t(n)},onMouseEnter:()=>o(r),className:H(`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 QD(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 $D(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)(ZD,{items:c,command:l,emptyNote:u,onActiveChange:s,ref:e=>{r=e}}))},l=()=>{t&&QD(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,Tn.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 eO(e){return jv.create({name:`suggestion-${e.key}`,addProseMirrorPlugins(){return[YD({editor:this.editor,char:e.char,pluginKey:new xf(e.key),items:({query:t})=>e.items(t.toLowerCase()),command:({editor:t,range:n,props:r})=>e.onSelect(r,{editor:t,range:n}),render:()=>$D(e)})]}})}function tO(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 nO(e,t){e.commands.setContent(t),e.commands.focus(`end`),/\s$/.test(t)&&e.commands.insertContent({type:`text`,text:` `})}var rO=(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 ee=(0,G.useRef)(new Set),j=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 ee.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)}}ee.current=t},M=(e,t)=>{let n=!e.isEmpty;return nO(e,t),j(e),v(e.isEmpty),k.current(e.storage.markdown.getMarkdown()),n},N=sx({immediatelyRender:!1,extensions:[MS,GD.configure({html:!1,linkify:!1,breaks:!0,transformPastedText:!0}),KD,eO({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=M(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=M(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=M(t,r.prompt);T.current?.(r.label,e)}return}e.id===`new-preset`&&(t.chain().focus().deleteRange(n).run(),w.current?.())}}),eO({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&&(tO(t,n,{kind:`project`,label:`@${r.name}`,text:`@${r.name}`}),E.current?.(r.path))}}),eO({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);tO(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})=>{j(e),v(e.isEmpty),k.current(e.storage.markdown.getMarkdown())}});(0,G.useImperativeHandle)(g,()=>({clear:()=>{N?.commands.clearContent(),N&&j(N),v(!0),k.current(``)},focus:()=>N?.commands.focus(`end`),loadTemplate:e=>N?M(N,e):!1})),(0,G.useEffect)(()=>{N?.setEditable(!f,!1)},[N,f]);let P=(0,G.useRef)(!1);(0,G.useEffect)(()=>{!N||P.current||!m||(P.current=!0,M(N,m))},[N,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)(Qe,{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)(Jb,{editor:N,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})]})}),iO=80;function aO(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`p-${Date.now()}`}function oO({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:aO(),label:e,prompt:t},n?l:`user`)};return(0,K.jsx)(bt,{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)(Lt,{type:`text`,value:a,maxLength:iO,placeholder:`Name`,disabled:t,autoFocus:!0,onChange:e=>o(e.target.value),className:`h-8 bg-background px-2`}),(0,K.jsx)(Ze,{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)(B,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,children:`Cancel`}),(0,K.jsx)(B,{type:`button`,size:`sm`,disabled:t||!a.trim()||!s.trim(),onClick:d,children:`Save prompt`})]})]})})}function sO({preset:e,busy:t,onLoad:n,onDelete:r}){return(0,K.jsxs)(z,{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)(V,{children:[(0,K.jsx)(U,{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)(R,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,K.jsxs)(W,{children:[`Delete "`,e.label,`"`]})]})]})}function cO({commands:e,customPresets:t,projectPresets:n,busy:r,onLoad:i,onNew:a,onDelete:o,onDeleteProject:s}){return(0,K.jsxs)(I,{children:[(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(Et,{type:`button`,disabled:r,"aria-label":`Commands`,className:H(v({variant:`ghost`,size:`icon-sm`}),`h-8 w-8`)}),children:(0,K.jsx)(Qa,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsx)(W,{children:`Run a command or load a saved prompt. In the box: / commands · @ projects · # files`})]}),(0,K.jsxs)(We,{align:`start`,className:`min-w-[16rem] max-w-[20rem]`,children:[(0,K.jsxs)(Je,{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)(Me,{label:`/${e.name}`,...e.waiting===void 0?{}:{description:`waiting to reach ${e.waiting}`}});return e.description?(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(z,{...t}),children:n}),(0,K.jsx)(W,{className:`max-w-[22rem]`,children:e.description})]},e.name):(0,K.jsx)(z,{...t,children:n},e.name)})]}),t.length>0&&(0,K.jsxs)(Je,{children:[(0,K.jsx)(dt,{}),(0,K.jsx)(c,{children:`Your saved prompts`}),t.map(e=>(0,K.jsx)(sO,{preset:e,busy:r,onLoad:i,onDelete:o},e.id))]}),n.length>0&&(0,K.jsxs)(Je,{children:[(0,K.jsx)(dt,{}),(0,K.jsx)(c,{children:`Project saved prompts`}),n.map(e=>(0,K.jsx)(sO,{preset:e,busy:r,onLoad:i,onDelete:s},e.id))]}),a&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dt,{}),(0,K.jsxs)(z,{disabled:r,onClick:a,children:[(0,K.jsx)(Qa,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Save prompt…`]})]})]})]})}var lO=`the CLI's own default`,uO={xhigh:`Extra high`};function dO(e){return uO[e]??e.charAt(0).toUpperCase()+e.slice(1)}function fO(e,t){return e.find(e=>e.value===t)??e[0]}function pO(e,t){if(t)return e?.models.find(e=>e.value===t)?.label??t}function mO({drivers:e,driver:t,model:n,onChange:r,effort:i,busy:a}){let o=fO(e,t),s=pO(o,n),l=i?.levels??[],u=i?.level===void 0?void 0:dO(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)(I,{children:[(0,K.jsxs)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(Et,{type:`button`,disabled:a,"aria-label":d,className:H(ol,`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)(Pe,{className:`h-3 w-3 shrink-0 opacity-70`})]}),(0,K.jsx)(W,{children:d})]}),(0,K.jsxs)(We,{align:`end`,children:[e.map(e=>(0,K.jsxs)(on,{children:[(0,K.jsxs)(en,{children:[(0,K.jsx)(Ve,{className:H(`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}),e.account&&(0,K.jsxs)(`span`,{className:`flex max-w-36 min-w-0 text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e.account.name}),(0,K.jsx)(`span`,{className:`shrink-0 whitespace-pre`,children:e.account.percent})]})]}),(0,K.jsxs)(Ut,{className:`min-w-[15rem]`,children:[e.models.length===0&&e.modelsNote&&(0,K.jsx)(z,{disabled:!0,children:e.modelsNote}),e.models.map(i=>(0,K.jsxs)(z,{onClick:()=>r(e.value,i.value),children:[(0,K.jsx)(Ve,{className:H(`h-3.5 w-3.5 shrink-0`,e.value===t&&i.value===n?`opacity-100`:`opacity-0`)}),i.label]},i.value)),e.accounts]})]},e.value)),l.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dt,{}),(0,K.jsxs)(Je,{children:[(0,K.jsx)(c,{children:`Effort`}),(0,K.jsxs)(z,{onClick:()=>i.onChange(void 0),children:[(0,K.jsx)(Ve,{className:H(`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)(z,{onClick:()=>i.onChange(e),children:[(0,K.jsx)(Ve,{className:H(`h-3.5 w-3.5 shrink-0`,i?.level===e?`opacity-100`:`opacity-0`)}),dO(e)]},e))]})]})]})]})}function hO(e){let{kind:t,place:n}=S(e);return t===`shared`?`${n}. Runs use your own logins.`:n}function gO({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=Ac(),a=r?ge(r):i,o=!r,s=o?m:ve[S(r).kind];return(0,K.jsxs)(I,{children:[(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(Et,{type:`button`,disabled:t,"aria-label":`Run on`,className:n?ol:H(v({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)(Pe,{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)(W,{children:`Run on — ${r?.label??i}`})]}),(0,K.jsxs)(We,{align:n?`start`:`end`,className:`min-w-[19rem] max-w-[22rem]`,children:[(0,K.jsxs)(z,{className:H(`items-start gap-2`,e.onlyThere&&`opacity-60`),disabled:e.onlyThere,onClick:()=>e.onSelectLocal(),children:[(0,K.jsx)(Ve,{className:H(`mt-0.5 h-3.5 w-3.5 shrink-0`,o?`opacity-100`:`opacity-0`)}),(0,K.jsx)(m,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,K.jsx)(Me,{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=hO(t),o=e.home===void 0?a:t.id===e.home?`${a}. Has this project.`:`${a}. Cloned there first, then runs there.`,s=i?Ft(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)(z,{className:H(`items-start gap-2`,(i||c)&&`opacity-60`),disabled:c,onClick:()=>e.onSelect(t),children:[(0,K.jsx)(Ve,{className:H(`mt-0.5 h-3.5 w-3.5 shrink-0`,r?.id===t.id?`opacity-100`:`opacity-0`)}),(0,K.jsx)(k,{kind:S(t).kind,online:n===`online`,className:`mt-0.5`}),(0,K.jsx)(Me,{label:ge(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)(z,{className:`items-start`,disabled:t,onClick:()=>e.onAddMachine(),children:[(0,K.jsx)(Qa,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsx)(Me,{label:`Add a machine…`,description:`Connect a computer, or join with a code.`})]})]})]})}var _O=1e4;function vO(e){let t=e.map(e=>e.id).join(`|`),n=mn((0,G.useMemo)(()=>t?()=>sn():null,[t]),{},_O,[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=E(`onAgentAccounts`),bO=E(`sendAddAgentAccount`),xO=E(`sendRemoveAgentAccount`),SO=E(`sendUseAgentAccountFirst`);E(`sendNameOwnAgentAccount`);var CO=E(`sendAgentAccountCode`),wO=2e3,TO=3e4,EO=(0,G.createContext)({view:void 0,reload:async()=>{}});function DO(){return(0,G.useContext)(EO)}function OO({children:e}){let[t,n]=(0,G.useState)(!1),{value:r,reload:i}=mn(Si,void 0,t?wO:TO,[t]),a=r?.servers.some(e=>e.allowing)??!1;return(0,G.useEffect)(()=>{a!==t&&n(a)},[a,t]),(0,K.jsx)(EO.Provider,{value:{view:r,reload:i},children:e})}function kO(){let{view:e,reload:t}=DO();return(0,K.jsx)(K.Fragment,{children:(e?.servers??[]).map(n=>(0,K.jsx)(jO,{server:n,computer:e.computer,onChanged:t},n.machineId))})}var AO=e=>e.logins.filter(e=>e.state===`allow`||e.state===`switched`);function jO({server:e,computer:t,onChanged:n}){let{tone:r,body:i}=MO(e,t,n);return i===null?null:(0,K.jsx)(IO,{label:e.label,tone:r,children:i})}function MO(e,t,n){let[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(),s=async e=>{i(!0),o(void 0);try{let t=await e();t.ok||o(t.error),await n()}finally{i(!1)}},c=a??e.failed,l=e.logins.filter(e=>e.state===`failed`).map(e=>e.name),u=AO(e),d=e.logins.filter(e=>e.state===`there`).length;return e.on?e.allowing?{tone:`ask`,body:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LO,{title:`Making ${e.allowing.name}'s login for ${e.label}`,words:`Say yes in the page your browser opened. If it is signed in to another account, copy the link into a private window.`}),e.allowing.url!==void 0&&(0,K.jsx)(hn,{text:e.allowing.url,label:`Copy link`})]})}:e.reachable?u.length>0?{tone:`ask`,body:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LO,{title:`${e.label} uses your logins: ${d} of ${e.logins.length} there`,words:`${u.map(e=>e.name).join(` and `)} ${u.length===1?`needs`:`need`} your yes once: your browser opens, you press Allow or Continue.`}),(0,K.jsx)(B,{size:`sm`,disabled:r,onClick:()=>void s(()=>wi(e.machineId)),children:u.length===1?`Allow 1 login`:`Allow ${u.length} logins`}),(0,K.jsx)(RO,{error:c})]})}:d<e.logins.length?{tone:`ask`,body:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LO,{title:`${e.label} uses your logins: ${d} of ${e.logins.length} there`,words:l.length>0?`${l.join(` and `)} did not get there: see ${l.length===1?`its row`:`their rows`} below. Tried again every minute.`:`These did not get there. They are tried again every minute.`}),(0,K.jsx)(RO,{error:c})]})}:c===void 0?{tone:`quiet`,body:null}:{tone:`quiet`,body:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`flex flex-1 items-center gap-1.5 text-sm`,children:[(0,K.jsx)(Ve,{className:`size-3.5 text-success`,"aria-hidden":!0}),`${e.label} uses your logins: all ${e.logins.length} there`]}),(0,K.jsx)(RO,{error:c})]})}:{tone:`quiet`,body:(0,K.jsx)(LO,{title:`${e.label} does not answer`,words:`Its logins are brought up to date once it does.`})}:{tone:`ask`,body:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LO,{title:`Use your logins on ${e.label}?`,words:`Runs there use the accounts you're logged into on ${t}, and its page follows your settings. The server gets logins of its own: nothing here is logged out.`}),(0,K.jsx)(B,{size:`sm`,disabled:r,onClick:()=>void s(()=>Ci(e.machineId)),children:`Use them`}),(0,K.jsx)(RO,{error:c})]})}}function NO({machineId:e,onAccounts:t}){return(0,K.jsx)(OO,{children:(0,K.jsx)(PO,{machineId:e,onAccounts:t})})}function PO({machineId:e,onAccounts:t}){let{view:n,reload:r}=DO(),i=n?.servers.find(t=>t.machineId===e);return n?i?(0,K.jsx)(FO,{server:i,computer:n.computer,onChanged:r}):(0,K.jsx)(B,{size:`sm`,variant:`outline`,onClick:t,children:`Open Accounts`}):null}function FO({server:e,computer:t,onChanged:n}){return(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 text-foreground`,children:MO(e,t,n).body})}function IO({label:e,tone:t,children:n}){return(0,K.jsx)(`section`,{"aria-label":`Your logins on ${e}`,className:H(`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border px-3 py-2.5`,t===`ask`?`border-warning/40 bg-warning/10`:`border-border`),children:n})}function LO({title:e,words:t}){return(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 basis-60`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium`,children:e}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]})}function RO({error:e}){return e===void 0?null:(0,K.jsx)(`p`,{role:`alert`,className:`basis-full text-xs whitespace-pre-line text-danger`,children:e})}var zO=(e,t)=>e.kind===t.kind&&(e.host??``)===(t.host??``)&&e.source===t.source;function BO({row:e}){let{view:t}=DO(),n=(t?.servers??[]).flatMap(t=>{let n=t.on&&t.reachable?t.logins.find(t=>zO(t,e)):void 0;return n&&n.state!==`switched`?[{server:t,login:n}]:[]});if(n.length===0)return null;let r=e=>n.filter(t=>t.login.state===e).map(e=>e.server.label),i=r(`there`),a=r(`allow`),o=new Map;for(let{server:e,login:t}of n)t.state===`failed`&&o.set(t.error??`it did not get there`,[...o.get(t.error??`it did not get there`)??[],e.label]);return(0,K.jsxs)(`div`,{className:`basis-full space-y-0.5 text-xs`,children:[i.length>0&&(0,K.jsx)(`p`,{className:`text-success`,children:`✓ on ${i.join(` · `)}`}),a.length>0&&(0,K.jsx)(`p`,{className:`text-warning`,children:`not on ${a.join(` · `)} yet`}),[...o].map(([e,t])=>(0,K.jsx)(`p`,{className:`text-danger`,children:`Not on ${t.join(` · `)}: ${e}`},e))]})}function VO({row:e}){let{view:t,reload:n}=DO(),[r,i]=(0,G.useState)(),a=(t?.servers??[]).flatMap(t=>{let n=t.on&&!t.allowing?t.logins.find(t=>zO(t,e)&&t.state===`switched`):void 0;return n?[{server:t,login:n}]:[]}),o=async e=>{i(void 0);let t=await e();t.ok||i(t.error),await n()};return(0,K.jsx)(K.Fragment,{children:a.map(({server:n,login:i})=>(0,K.jsxs)(`div`,{role:`status`,className:`mx-3 mb-3 space-y-2 rounded-lg border border-warning/40 bg-warning/10 p-3`,children:[(0,K.jsx)(`p`,{className:`text-sm`,children:`${n.label} still runs on ${i.was}, the account you left on ${t.computer}.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(B,{size:`sm`,onClick:()=>void o(()=>wi(n.machineId)),children:`Use ${i.name} there`}),(0,K.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>void o(()=>Ti(n.machineId,e,!0)),children:`Keep ${i.was}`})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Use ${i.name} there opens your browser once. Runs go on until you pick.`}),r!==void 0&&(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]},n.machineId))})}function HO({kind:e,host:t}){let{view:n,reload:r}=DO(),[i,a]=(0,G.useState)(),o=(n?.servers??[]).flatMap(n=>n.left.filter(n=>n.kind===e&&(n.host??``)===(t??``)).map(e=>({server:n,login:e})));if(o.length===0)return null;let s=async(e,{kind:t,host:n,source:i},o)=>{a(void 0);let s=await Ti(e,{kind:t,...n===void 0?{}:{host:n},source:i},o);s.ok||a(s.error),await r()};return(0,K.jsxs)(`div`,{className:`space-y-2 border-t border-border px-3 py-2.5`,children:[o.map(({server:e,login:t})=>(0,K.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,K.jsx)(`p`,{className:`min-w-0 flex-1 basis-60 text-sm`,children:`${e.label} still has ${t.name}, which is no longer on ${n.computer}.`}),(0,K.jsx)(B,{size:`xs`,variant:`outline`,onClick:()=>void s(e.machineId,t,!0),children:`Keep it there`}),(0,K.jsx)(B,{size:`xs`,variant:`ghost`,onClick:()=>void s(e.machineId,t,!1),children:`Take it off`})]},`${e.machineId} ${t.source}`)),i!==void 0&&(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:i})]})}var UO=2e3,WO=3e4,GO={claude:{title:`Claude Code`,short:`Claude`,driver:`claude-code`,Logo:So,logIn:`Log in to Claude`,adding:e=>`Adding ${e}'s account: say yes in the page this computer's browser opened, signed in to ${e}'s Claude account.`,help:`Opens this computer's browser, where you say yes once, signed in to that account. The login is kept on this computer alone and lasts a year.`,remove:`Runs no longer use it. Its login is not ended: take it back on claude.ai to end it.`},codex:{title:`Codex`,short:`Codex`,driver:`codex`,Logo:Co,logIn:`Log in to Codex`,adding:e=>`Adding ${e}'s account: sign in to ${e}'s ChatGPT account in the page this computer's browser opened.`,help:`Opens this computer's browser, where you sign in once to that account. If the browser is signed in to another account, copy the link into a private window. The login is kept on this computer alone, and Codex renews it.`,remove:`Runs no longer use it, and its login is taken off this computer.`}};function KO(e,t=!1){let{value:n,reload:r}=mn(()=>yO(e),void 0,t?UO:WO,[e,t],{remember:`agent-accounts:${e}`});return{view:n,reload:r}}function qO(e,t){let n=Math.max(1,Math.ceil((e-t)/6e4)),r=Math.floor(n/60),i=n%60;return r>=48?`${Math.round(r/24)} days`:r===0?`${i} min`:i===0?`${r} h`:`${r} h ${i} min`}function JO(e){return new Date(e).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`})}function YO(e,t){return e.own?`login on ${t}`:e.from===void 0?e.added?`added ${new Date(e.added).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}`:`added`:`from ${e.from}`}function XO(e){return e.windows[e.windows.length-1]}function ZO(e){let t=XO(e);return t===void 0?e.own?void 0:`not used yet`:`${Math.round(t.percent)}% ${t.label===`5 h`?`of 5 h`:`this ${t.label}`}${e.asOf===void 0?``:` · as of ${JO(e.asOf)}`}`}function QO({percent:e,className:t}){let n=Math.min(100,Math.max(0,e??0));return(0,K.jsx)(`span`,{"aria-hidden":!0,className:H(`relative block h-1.5 w-20 shrink-0 overflow-hidden rounded-full bg-muted-foreground/15`,t),children:(0,K.jsx)(`span`,{className:H(`absolute inset-y-0 left-0 rounded-full`,n>=100?`bg-danger`:n>=80?`bg-warning`:`bg-success`),style:{width:`${n}%`}})})}function $O({account:e,now:t}){return e.state===`limited`&&e.limitedUntil!==void 0?(0,K.jsxs)(`span`,{className:`text-xs text-warning`,children:[`limited, free in `,qO(e.limitedUntil,t)]}):e.state===`in-use`?(0,K.jsx)(`span`,{className:`text-xs font-medium text-success`,children:`in use`}):e.state===`next`?(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`next`}):null}function ek({agent:e,adding:t,words:n}){let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)();if(t.code!==void 0&&t.url!==void 0)return(0,K.jsx)(qs,{code:t.code,url:t.url});if(t.paste&&t.url!==void 0){let n=async()=>{o(void 0);let t=await CO(e,r);t.ok||o(t.error)};return(0,K.jsxs)(`div`,{role:`status`,className:`space-y-2`,children:[(0,K.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex h-9 items-center rounded-md border border-border px-3 text-sm hover:bg-accent`,children:`1. Open Claude and press Authorize ↗`}),(0,K.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),n()},children:[(0,K.jsx)(Lt,{"aria-label":`Code from Claude`,placeholder:`2. Paste the code it shows`,value:r,onChange:e=>i(e.target.value),className:`h-9 min-w-0 flex-1 basis-48 text-base sm:text-sm`}),(0,K.jsx)(B,{size:`sm`,type:`submit`,disabled:r.trim()===``,children:`Done`})]}),a!==void 0&&(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:a})]})}return(0,K.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}),t.url!==void 0&&(0,K.jsx)(tk,{url:t.url})]})}function tk({url:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(B,{size:`xs`,variant:`ghost`,onClick:()=>void navigator.clipboard.writeText(e).then(()=>n(!0),()=>{}),children:[t?(0,K.jsx)(Ve,{className:`size-3.5`,"aria-hidden":!0}):(0,K.jsx)(Le,{className:`size-3.5`,"aria-hidden":!0}),t?`Copied`:`Copy link for a private window`]})}function nk({agent:e}){let t=GO[e],[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(),[c,l]=(0,G.useState)(!1),{view:u,reload:d}=KO(e,!0),{state:f,reload:p}=Ns(t.driver),m=u?.adding,h=Fs(f)===`not-installed`&&(u?.accounts.length??0)<2,g=f?.ownLoggedOut===!0||Fs(f)===`step`,_=(u?.accounts??[]).filter(e=>!(e.own&&g)),v=async e=>{l(!0),s(void 0);try{let t=await e();return t.ok||s(t.error),await d(),t.ok}finally{l(!1)}},y=async()=>{await v(()=>bO(e,i))&&(r(!1),a(``))};return(0,K.jsxs)(`section`,{"aria-label":t.title,className:`rounded-lg border border-border`,children:[(0,K.jsxs)(`header`,{className:H(`flex items-center gap-2 px-3 py-2.5`,!h&&`border-b border-border`),children:[(0,K.jsx)(t.Logo,{className:`size-4 shrink-0`}),(0,K.jsx)(`h3`,{className:`flex-1 text-sm font-medium`,children:t.title}),f&&(0,K.jsx)(Rs,{state:Fs(f)})]}),f&&!f.ready&&(f.fix!==void 0||Fs(f)===`not-installed`)&&(0,K.jsxs)(`div`,{className:H(`space-y-2 px-3 py-2.5`,!h&&`border-b border-border`,h&&`pt-0`),children:[(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Hs(f)}),(0,K.jsx)(Ks,{state:f,onChanged:()=>void p()})]}),!h&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ul`,{className:`divide-y divide-border`,children:_.map(n=>(0,K.jsxs)(`li`,{"aria-label":n.name,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 max-sm:basis-full!`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm`,children:n.name}),(0,K.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:YO(n,u.computer)})]}),ZO(n)!==void 0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(QO,{percent:XO(n)?.percent}),(0,K.jsx)(`span`,{className:`w-44 truncate text-xs text-muted-foreground max-sm:w-auto`,children:ZO(n)})]}),(0,K.jsxs)(`div`,{className:`flex w-36 items-center justify-end gap-2 max-sm:w-auto`,children:[u&&(0,K.jsx)($O,{account:n,now:u.now}),!n.own&&n.from===void 0&&(0,K.jsx)(B,{size:`xs`,variant:`ghost`,disabled:c,"aria-label":`Remove ${n.name}'s account`,title:t.remove,onClick:()=>void v(()=>xO(e,n.id)),children:`Remove`})]}),(0,K.jsx)(BO,{row:{kind:e,source:n.own?`own`:n.id}})]}),(0,K.jsx)(VO,{row:{kind:e,source:n.own?`own`:n.id}})]},n.id))}),(0,K.jsx)(HO,{kind:e}),(0,K.jsxs)(`div`,{className:H(`px-3 py-2.5`,_.length>0&&`border-t border-border`),children:[m?(0,K.jsx)(ek,{agent:e,adding:m,words:t.adding(m.name)}):n?(0,K.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,K.jsx)(Lt,{autoFocus:!0,"aria-label":`Whose account`,placeholder:`Whose account, e.g. Dani`,value:i,onChange:e=>a(e.target.value),className:`h-8 w-56 max-sm:w-full`}),(0,K.jsx)(B,{size:`sm`,type:`submit`,disabled:c||i.trim()===``,children:t.logIn}),(0,K.jsx)(B,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>(r(!1),s(void 0)),children:`Cancel`})]}):(0,K.jsxs)(B,{size:`sm`,variant:_.length===0?`default`:`ghost`,onClick:()=>r(!0),children:[(0,K.jsx)(Qa,{className:`size-3.5`,"aria-hidden":!0}),_.length===0?t.logIn:`Add account`]}),n&&!m&&(0,K.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:t.help}),(o??u?.failed)!==void 0&&(0,K.jsx)(`p`,{role:`alert`,className:`mt-1.5 whitespace-pre-line text-xs text-danger`,children:o??u?.failed})]})]})]})}var rk=(e,t)=>`machine-agent-accounts:${e}:${t}`;function ik(e){for(let t of[`claude`,`codex`])De(rk(e,t),()=>ae(e,t))}function ak(e,t,n=!0){let r=mn(n&&t===void 0?()=>yO(e):null,void 0,WO,[e,n,t===void 0],{remember:`agent-accounts:${e}`}),i=mn(n&&t!==void 0?()=>ae(t,e):null,void 0,WO,[e,n,t],t===void 0?void 0:{remember:rk(t,e)});return t===void 0?{view:r.value,unanswered:!1,pick:t=>SO(e,t).then(r.reload)}:{view:i.value??void 0,unanswered:i.value===null,pick:n=>rn(t,e,n).then(i.reload)}}function ok(e){let t=e?.accounts[0];if(!t)return;let n=XO(t);return{name:t.name,percent:t.state===`limited`?` · limited`:n===void 0?``:` · ${Math.round(n.percent)}%`}}function sk({view:e,on:t,onPick:n,onAdd:r}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dt,{}),(0,K.jsxs)(Je,{children:[(0,K.jsx)(c,{children:t===void 0?`Accounts`:`Accounts on ${t}`}),e.accounts.map((e,t)=>(0,K.jsxs)(z,{closeOnClick:!1,onClick:()=>n(e.id),children:[(0,K.jsx)(Ve,{className:H(`h-3.5 w-3.5 shrink-0`,t===0?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.state===`limited`?`limited`:XO(e)===void 0?``:`${Math.round(XO(e).percent)}%`})]},e.id)),(0,K.jsxs)(z,{onClick:r,children:[(0,K.jsx)(Qa,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0}),`Add account…`]})]})]})}function ck(){let{view:e}=KO(`claude`),t=e&&e.accounts.length>1?e.accounts.filter(e=>!e.own):[];return t.length===0?null:(0,K.jsx)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,"aria-label":`Other Claude accounts`,children:t.map(t=>(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,K.jsx)(`span`,{className:`w-24 truncate`,children:t.name}),(0,K.jsx)(QO,{percent:XO(t)?.percent}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.state===`limited`&&t.limitedUntil!==void 0?`limited, free in ${qO(t.limitedUntil,e.now)}`:ZO(t)??``})]},t.id))})}function lk(){let{view:e,reload:t}=Ps();return e&&e.hosts.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`None of your projects has a remote yet. A project pushed to a git host gets its card here.`}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The accounts runs open pull requests and push with. A switch here changes what runs use; the terminal keeps its own.`}),(e?.hosts??[]).map(e=>e.provider?(0,K.jsx)(fk,{row:e,onChanged:t},e.host):(0,K.jsx)(dk,{row:e},e.host))]})}function uk(e){return e.projects.length>0?`used by ${e.projects.join(`, `)}`:`no project on it yet`}function dk({row:e}){return(0,K.jsxs)(`p`,{"aria-label":e.host,className:`rounded-lg border border-dashed border-border px-3 py-2.5 text-sm text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:e.host}),` · ${uk(e)} · no package for it yet`]})}function fk({row:e,onChanged:t}){let n=e.provider,r=Is(e),[i,a]=(0,G.useState)(),o=Js(t),s=DO(),[c,l]=(0,G.useState)(),u=async(e,n,r)=>{l({login:e,press:n}),a(void 0);try{let e=await r();e.ok||a(e.error),await Promise.all([t(),s.reload()])}finally{l(void 0)}},d=(e,t)=>c?.login===e&&c.press===t;return(0,K.jsxs)(`section`,{"aria-label":n.name,className:`rounded-lg border border-border`,children:[(0,K.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 border-b border-border px-3 py-2.5`,children:[(0,K.jsx)(zs,{svg:n.logo}),(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:n.name}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:`${e.host} · ${uk(e)}`}),(0,K.jsx)(Rs,{state:r})]}),n.accounts.length>0&&(0,K.jsx)(`ul`,{className:`divide-y divide-border`,children:n.accounts.map(t=>(0,K.jsxs)(`li`,{"aria-label":`@${t.login}`,className:`flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`p`,{className:`truncate text-sm`,children:[`@`,t.login]}),(0,K.jsx)(`p`,{className:H(`truncate text-xs`,t.ok?`text-muted-foreground`:`text-warning`),children:t.ok?t.from===void 0?t.terminal?`the terminal's account`:`logged in to ${n.tool}`:`from ${t.from}`:`${n.name} no longer takes this login: add it again`})]}),t.runs?(0,K.jsx)(`span`,{className:`text-xs font-medium text-success`,children:`in use for runs`}):(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsxs)(B,{size:`xs`,variant:`ghost`,disabled:c!==void 0||!t.ok,onClick:()=>void u(t.login,`use`,()=>bs(e.host,t.login)),children:[d(t.login,`use`)&&(0,K.jsx)(xn,{className:`size-3 animate-spin`,"aria-hidden":!0}),d(t.login,`use`)?`Switching…`:`Use for runs`]}),(0,K.jsxs)(B,{size:`xs`,variant:`ghost`,disabled:c!==void 0,"aria-label":`Remove @${t.login}`,title:`${n.tool} on this computer forgets it. The login is not ended: it goes on working wherever else it is.`,onClick:()=>void u(t.login,`remove`,()=>xs(e.host,t.login)),children:[d(t.login,`remove`)&&(0,K.jsx)(xn,{className:`size-3 animate-spin`,"aria-hidden":!0}),d(t.login,`remove`)?`Removing…`:`Remove`]})]}),(0,K.jsx)(BO,{row:{kind:`git`,host:e.host,source:t.login}})]},t.login))}),(0,K.jsx)(HO,{kind:`git`,host:e.host}),(0,K.jsxs)(`div`,{className:H(`px-3 py-2.5`,n.accounts.length>0&&`border-t border-border`),children:[!n.installed||n.accounts.length===0?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Us(e)}),(0,K.jsx)(Ys,{row:e,onChanged:t})]}):n.loggingIn?(0,K.jsx)(qs,{code:n.loggingIn.code,url:n.loggingIn.url}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(B,{size:`sm`,variant:`ghost`,disabled:o.busy,onClick:()=>void o.start(e.host),children:[(0,K.jsx)(Qa,{className:`size-3.5`,"aria-hidden":!0}),`Add account`]}),(0,K.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Logs another account in to ${n.tool} with a code you type at ${n.name}. The terminal's account stays as it is.`})]}),(i??o.error)!==void 0&&(0,K.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:i??o.error})]})]})}var pk=e=>`machine-git-hosts:${e}`;function mk(e){De(pk(e),()=>Ge(e))}function hk(e){let t=Ps(),n=mn(e===void 0?null:()=>Ge(e),void 0,3e4,[e],e===void 0?void 0:{remember:pk(e)});return e===void 0?{view:t.view,pick:(e,n)=>bs(e,n).then(t.reload)}:{view:n.value??void 0,pick:(t,r)=>Rt(e,t,r).then(n.reload)}}function gk({address:e,machineId:t,on:n,busy:r,onAdd:i}){let{view:a,pick:o}=hk(t),s=e?.split(`/`)[0],l=s===void 0?void 0:a?.hosts.find(e=>e.host===s),u=l?.provider;if(!l||!u)return null;let d=u.accounts.find(e=>e.runs);if(!d)return(0,K.jsxs)(`button`,{type:`button`,disabled:r,onClick:i,className:H(ol,`text-warning`),children:[(0,K.jsx)(zs,{svg:u.logo,className:`size-3.5`}),(0,K.jsx)(`span`,{className:`truncate`,children:u.installed?`Log in to ${u.name}`:`${u.tool} not installed`})]});let f=`Runs push and open pull requests as @${d.login}${n===void 0?``:` on ${n}`}`;return(0,K.jsxs)(I,{children:[(0,K.jsxs)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(Et,{type:`button`,disabled:r,"aria-label":`${u.name} account: @${d.login}`,className:ol}),children:[(0,K.jsx)(zs,{svg:u.logo,className:`size-3.5`}),(0,K.jsxs)(`span`,{className:`max-w-32 truncate`,children:[`@`,d.login]}),(0,K.jsx)(Pe,{className:`h-3 w-3 shrink-0 opacity-70`,"aria-hidden":!0})]}),(0,K.jsx)(W,{children:f})]}),(0,K.jsxs)(We,{align:`end`,className:`min-w-[14rem]`,children:[(0,K.jsxs)(Je,{children:[(0,K.jsx)(c,{children:`${u.name} account${n===void 0?``:` on ${n}`}`}),u.accounts.map(e=>(0,K.jsxs)(z,{closeOnClick:!1,disabled:!e.ok,onClick:()=>void o(l.host,e.login),children:[(0,K.jsx)(Ve,{className:H(`h-3.5 w-3.5 shrink-0`,e.runs?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,K.jsxs)(`span`,{className:`flex-1 truncate`,children:[`@`,e.login]}),e.terminal&&(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`terminal`})]},e.login))]}),(0,K.jsx)(dt,{}),(0,K.jsxs)(z,{onClick:i,children:[(0,K.jsx)(Qa,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0}),`Add account…`]})]})]})}var _k={"claude-code":{icon:(0,K.jsx)(So,{className:`h-4 w-4`})},codex:{icon:(0,K.jsx)(Co,{className:`h-4 w-4`})}},vk=`flex h-8 items-center gap-2`,yk=`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)]`,bk=(0,G.forwardRef)(function({files:e,addContext:t,removeContext:n,startsAt:r,startsAtEnd:i,controls:a,sessionModel:o,sessionContext:s,onSubmit:c,onPromptChange:l,onPreset:u,busy:d,submitLabel:f,submitBusyLabel:p,placeholder:m,compact:h=!1,showDriverModel:g=!0,inAgent:v=!1,canSubmit:y=!0,idleControl:b,home:x},S){let[C,w]=(0,G.useState)(``),[T,E]=(0,G.useState)(!1),D=(0,G.useRef)(null),O=ia(),k=vO(O),A=_(li,[],[]),ee=(0,G.useMemo)(()=>A.filter(e=>e.machine===void 0),[A]),j=_r(),M=j.model??``,N=j.driver??`claude-code`,P=j.customPresets??[],te=fr(),ne=gr(),F=Vc(ne),re=F?.commands??[],ie=x===void 0&&F!==null&&F.address===void 0,ae=x!==void 0&&F!==null&&F.address===void 0,I=Li(),L=vr(),R=ra();(0,G.useEffect)(()=>{v||zi(j.runOn,L&&R?O:null,k)},[v,j.runOn,L,R,O,k]),(0,G.useEffect)(()=>{if(!v)for(let e of O)k[e.id]===`online`&&(vt(e.id),ik(e.id),mk(e.id))},[v,O,k]);let oe=Ri(),se=oe?.why===`offline`?O.find(e=>e.id===oe.id):void 0,ce=Vi(O,I,F,x),{models:le,theirs:ue}=bn(v?void 0:ce?.id),de=v||!g?void 0:ce?.id,fe=ak(`claude`,de,!v&&g),pe=ak(`codex`,de,!v&&g),me=e=>{let{view:t,pick:n}=e===`codex`?pe:fe,r=le?.[e],i=r!==void 0&&!(`error`in r&&r.missing);if(!t||t.accounts.length===0||e===`codex`&&t.accounts.length<2&&!i)return{};let a=ce?ge(ce):void 0;return{account:ok(t),accounts:(0,K.jsx)(sk,{view:t,on:a,onPick:e=>void n(e),onAdd:()=>ce?nl(`devices`,ce.id):nl(Os)})}},he=!!ce&&k[ce.id]===`offline`,[_e,ve]=(0,G.useState)(null),ye=ce?.owner,be=!v&&!!ce&&ye!==void 0&&!ce.told&&_e!==ce.id;(0,G.useImperativeHandle)(S,()=>({clear:()=>{D.current?.clear(),w(``)},focus:()=>D.current?.focus()}));let[xe,Se]=(0,G.useState)(void 0);(0,G.useEffect)(()=>{if(h||v)return;let e=wt();e&&Se(e)},[h,v]);let z=(0,G.useRef)(!1),Ce=e=>{e?.preventDefault();let t=C.trim();!t||d||z.current||he||be||!y||(z.current=!0,Promise.resolve(c(t)).finally(()=>{z.current=!1}))},we=(e,t)=>{let n=D.current?.loadTemplate(e)??!1;u?.(t,n)},Te=(0,K.jsx)(rO,{ref:D,compact:h,onChange:e=>{w(e),l?.(e)},onSubmit:Ce,...u?{onPreset:u}:{},...t?{onMentionProject:t,onMentionFile:t}:{},...n?{onMentionRemoved:n}:{},projects:ee,files:e,commands:Hc(re),customPresets:P,projectPresets:te,...h?{}:{onNewPreset:()=>E(!0)},disabled:d,...m?{placeholder:m}:{},...xe?{initialText:xe}:{}}),Ee=g&&(0,K.jsx)(mO,{drivers:mt(le,ue&&ce?ge(ce):void 0).map(e=>({...e,..._k[e.value],...me(e.value)})),driver:N,model:M,onChange:(e,t)=>mr({driver:e,model:t}),effort:{levels:Bt(le,N,M),level:j.effort||void 0,onChange:e=>mr({effort:e??``})},busy:d}),De=!h&&(0,K.jsx)(cO,{commands:re,customPresets:P,projectPresets:te,busy:d,onLoad:we,onNew:()=>E(!0),onDelete:e=>mr({customPresets:P.filter(t=>t.id!==e)}),onDeleteProject:e=>pr(ne,te.filter(t=>t.id!==e))}),Oe=v?null:(0,K.jsx)(gO,{busy:d,inRow:!h,connection:{machines:O,selectedMachineId:I,onlyHere:ie,home:x,onlyThere:ae,onSelect:e=>Pi(e.id),onSelectLocal:()=>Pi(null),onAddMachine:()=>nl(`devices`),status:k}}),ke=!!C.trim(),Ae=(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(B,{type:`submit`,size:`icon-sm`,onClick:Ce,disabled:d||!ke||he||be||!y,"aria-hidden":!ke,tabIndex:ke?void 0:-1,"aria-label":f,className:H(`h-8 w-8 shrink-0 transition-[margin,opacity,transform] duration-150 ease-out`,ke?H(`ml-0 translate-x-0 opacity-100`,d?`disabled:opacity-100`:`disabled:opacity-40`):H(`pointer-events-none translate-x-2 opacity-0 disabled:opacity-0`,h?`-ml-[2.375rem]`:`-ml-8`))}),children:d?(0,K.jsx)(xn,{className:`h-4 w-4 animate-spin`}):(0,K.jsx)(ca,{className:`h-4 w-4`})}),(0,K.jsx)(W,{children:d?p:`${f} (Enter · Shift+Enter for a new line)`})]}),je=!ke&&b?b:Ae,Me=he&&(0,K.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:`${ce?ge(ce):`The selected machine`} is offline. Pick another place to run, then start.`}),Ne=Ac()===`This machine`?`this machine`:Ac(),Pe=!v&&!h&&oe&&!ce&&(0,K.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-muted-foreground`,children:oe.why===`gone`?`The computer you last picked to run on is no longer saved, so runs start on ${Ne}.`:`${se?ge(se):`The computer you last picked`} is offline, so runs start on ${Ne}. Pick it again once it is on.`}),Fe=be&&(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 @${ye}'s server.`}),` `,(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`@${ye} can see what is on it. Runs there start once you say OK.`})]}),(0,K.jsx)(B,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>{ve(ce.id),ta(ce.id)},children:`OK`})]});return h?(0,K.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:Te}),Ee,Oe,je]}):(0,K.jsxs)(K.Fragment,{children:[!v&&(0,K.jsxs)(`div`,{className:H(`mb-1`,vk),children:[(0,K.jsxs)(`div`,{className:yk,children:[Oe,r]}),i&&(0,K.jsx)(`div`,{className:`shrink-0`,children:i})]}),Fe,(0,K.jsxs)(`div`,{className:`flex items-end rounded-xl border border-border bg-card focus-within:border-muted-foreground/40`,children:[De&&(0,K.jsx)(`div`,{className:`-mr-2 flex shrink-0 items-center p-1`,children:De}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:Te}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center p-1`,children:je})]}),(0,K.jsxs)(`div`,{className:H(`mt-1`,vk),children:[(0,K.jsx)(`div`,{className:yk,children:a}),(0,K.jsx)(`div`,{className:`shrink-0`,children:Ee||(0,K.jsxs)(`span`,{className:`flex items-center`,children:[o!==void 0&&(0,K.jsx)(`span`,{className:`px-2 text-[13px] text-muted-foreground`,children:o}),s]})})]}),Me,Pe,T&&(0,K.jsx)(oO,{currentPrompt:C,busy:d,canSaveToProject:ne!==null,onCancel:()=>{E(!1),D.current?.focus()},onSave:(e,t)=>{t===`project`?pr(ne,[...te,e]):mr({customPresets:[...P,e]}),E(!1),D.current?.focus()}})]})});function xk(e,t,n){return e===`local`?`${n} (local)`:t}function Sk({main:e,local:t,pick:n,onPick:r,busy:i}){let a=xk(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)(I,{children:[(0,K.jsxs)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(Et,{type:`button`,disabled:i,"aria-label":`The agent starts from`,className:ol}),children:[(0,K.jsx)(Ma,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`truncate`,children:a}),(0,K.jsx)(Pe,{className:`h-3 w-3 shrink-0 opacity-70`,"aria-hidden":!0})]}),(0,K.jsx)(W,{children:`The agent starts from ${a}`})]}),(0,K.jsx)(We,{align:`start`,className:`min-w-[19rem] max-w-[22rem]`,children:(0,K.jsxs)(Je,{children:[(0,K.jsx)(c,{className:`font-normal`,children:`The agent starts from`}),o.map(e=>(0,K.jsxs)(z,{className:`items-start`,"aria-current":e.pick===n,onClick:()=>r(e.pick),children:[(0,K.jsx)(Ve,{className:H(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.pick===n?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,K.jsx)(Me,{label:e.label,description:e.description})]},e.pick))]})})]})}function Ck(e,t){let n=t?.replace(/\/+$/,``);return n&&e.startsWith(`${n}/`)?e.slice(n.length+1):e}function wk(e,t){let n=t?.replace(/\/+$/,``);return n===void 0||!e.startsWith(`/`)||e.startsWith(`${n}/`)}function Tk(e){return e.kind===`driver`&&e.event.type===`output`?e.event.changed??[]:[]}function Ek(e){return e.kind===`driver`&&e.event.type===`start`}function Dk(e,t){let n=new Map;for(let r of e){if(!wk(r.path,t))continue;let e=Ck(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(Ek(i)){r.length>0&&n.set(i,Dk(r,t)),r=[];continue}r.push(...Tk(i))}return{ended:n,last:Dk(r,t)}}function kk(e){return{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)}}var Ak={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 jk(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 Mk(e){return e.split(`, `).map(e=>e.replace(/\/+$/,``).split(`/`).pop()||e).join(`, `)}function Nk(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 Pk(e,t,n){let r=Ak[e],i=Nk(e),a={verb:r?.verb??i?.verb??jk(e),doing:r?.doing??i?.doing??jk(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?Mk(t):r?.slash?`/${t.replace(/^\//,``)}`:t),n!==void 0&&n.length>0){let e=Dk(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=kk(e)}return a}var Fk=(e,t,n)=>e===1?t:`${e} ${n}`;function Ik(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 ${Fk(o,`a command`,`commands`)}`}),r>0&&i.push({words:`read ${Fk(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=Dk(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 ${Fk(n.length,`a file`,`files`)}`}):(t>0&&i.push({words:`created ${Fk(t,`a file`,`files`)}`}),e.length>t&&i.push({words:`edited ${Fk(e.length-t,`a file`,`files`)}`})),e.length>0&&(a.size=kk(e))}let s=t(`skill`).length+t(`other`).length;return s>0&&i.push({words:`used ${Fk(s,`a tool`,`tools`)}`}),i[0]&&(i[0].words=i[0].words.charAt(0).toUpperCase()+i[0].words.slice(1)),a}function Lk(e){return e.parts.map(e=>e.target===void 0?e.words:`${e.words} ${e.target}`).join(`, `)}function Rk({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 zk({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 Bk({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)(Da,{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)(Rk,{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)(Rk,{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)})})]})]})}function Vk({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:u(t-Date.parse(e))})}function Hk(){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 Uk(e){let t=e.trim().split(`
|
|
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}},WD=jv.create({name:`markdownClipboard`,addOptions(){return{transformPastedText:!1,transformCopiedText:!1}},addProseMirrorPlugins(){return[new vf({key:new xf(`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 _u.fromSchema(this.editor.schema).parseSlice(_D(r),{preserveWhitespace:!0,context:t})},clipboardTextSerializer:e=>this.options.transformCopiedText?this.editor.storage.markdown.serializer.serialize(e.content):null}})]}}),GD=jv.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=wb.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 UD(this.editor,this.options),serializer:new HD(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[sD.configure({tight:this.options.tightLists,tightClass:this.options.tightListClass}),WD.configure({transformPastedText:this.options.transformPastedText,transformCopiedText:this.options.transformCopiedText})]}}),KD=Nb.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`,tv(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 qD(e){let{char:t,allowSpaces:n,allowToIncludeChar:r,allowedPrefixes:i,startOfLine:a,$position:o}=e,s=n&&!r,c=Ib(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 JD=new xf(`suggestion`);function YD({pluginKey:e=JD,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=qD}){let g,_=p?.(),v=new vf({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),ig.create(e.doc,[tg.inline(n.from,n.to,{nodeName:s,class:o.join(` `),"data-decoration-id":r,"data-decoration-content":l})])}}});return v}function XD(e){return`prompt-suggestion-option-${e}`}var ZD=(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?XD(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:XD(r),role:`option`,"aria-selected":r===a,...n.title?{title:n.title}:{},onMouseDown:e=>{e.preventDefault(),t(n)},onMouseEnter:()=>o(r),className:H(`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 QD(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 $D(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)(ZD,{items:c,command:l,emptyNote:u,onActiveChange:s,ref:e=>{r=e}}))},l=()=>{t&&QD(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,Tn.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 eO(e){return jv.create({name:`suggestion-${e.key}`,addProseMirrorPlugins(){return[YD({editor:this.editor,char:e.char,pluginKey:new xf(e.key),items:({query:t})=>e.items(t.toLowerCase()),command:({editor:t,range:n,props:r})=>e.onSelect(r,{editor:t,range:n}),render:()=>$D(e)})]}})}function tO(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 nO(e,t){e.commands.setContent(t),e.commands.focus(`end`),/\s$/.test(t)&&e.commands.insertContent({type:`text`,text:` `})}var rO=(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 ee=(0,G.useRef)(new Set),j=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 ee.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)}}ee.current=t},M=(e,t)=>{let n=!e.isEmpty;return nO(e,t),j(e),v(e.isEmpty),k.current(e.storage.markdown.getMarkdown()),n},N=sx({immediatelyRender:!1,extensions:[MS,GD.configure({html:!1,linkify:!1,breaks:!0,transformPastedText:!0}),KD,eO({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=M(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=M(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=M(t,r.prompt);T.current?.(r.label,e)}return}e.id===`new-preset`&&(t.chain().focus().deleteRange(n).run(),w.current?.())}}),eO({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&&(tO(t,n,{kind:`project`,label:`@${r.name}`,text:`@${r.name}`}),E.current?.(r.path))}}),eO({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);tO(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})=>{j(e),v(e.isEmpty),k.current(e.storage.markdown.getMarkdown())}});(0,G.useImperativeHandle)(g,()=>({clear:()=>{N?.commands.clearContent(),N&&j(N),v(!0),k.current(``)},focus:()=>N?.commands.focus(`end`),loadTemplate:e=>N?M(N,e):!1})),(0,G.useEffect)(()=>{N?.setEditable(!f,!1)},[N,f]);let P=(0,G.useRef)(!1);(0,G.useEffect)(()=>{!N||P.current||!m||(P.current=!0,M(N,m))},[N,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)(Qe,{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)(Jb,{editor:N,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})]})}),iO=80;function aO(){return typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`p-${Date.now()}`}function oO({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:aO(),label:e,prompt:t},n?l:`user`)};return(0,K.jsx)(bt,{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)(Lt,{type:`text`,value:a,maxLength:iO,placeholder:`Name`,disabled:t,autoFocus:!0,onChange:e=>o(e.target.value),className:`h-8 bg-background px-2`}),(0,K.jsx)(Ze,{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)(B,{type:`button`,variant:`ghost`,size:`sm`,onClick:i,children:`Cancel`}),(0,K.jsx)(B,{type:`button`,size:`sm`,disabled:t||!a.trim()||!s.trim(),onClick:d,children:`Save prompt`})]})]})})}function sO({preset:e,busy:t,onLoad:n,onDelete:r}){return(0,K.jsxs)(z,{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)(V,{children:[(0,K.jsx)(U,{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)(R,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),(0,K.jsxs)(W,{children:[`Delete "`,e.label,`"`]})]})]})}function cO({commands:e,customPresets:t,projectPresets:n,busy:r,onLoad:i,onNew:a,onDelete:o,onDeleteProject:s}){return(0,K.jsxs)(I,{children:[(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(Et,{type:`button`,disabled:r,"aria-label":`Commands`,className:H(v({variant:`ghost`,size:`icon-sm`}),`h-8 w-8`)}),children:(0,K.jsx)(Qa,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsx)(W,{children:`Run a command or load a saved prompt. In the box: / commands · @ projects · # files`})]}),(0,K.jsxs)(We,{align:`start`,className:`min-w-[16rem] max-w-[20rem]`,children:[(0,K.jsxs)(Je,{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)(Me,{label:`/${e.name}`,...e.waiting===void 0?{}:{description:`waiting to reach ${e.waiting}`}});return e.description?(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(z,{...t}),children:n}),(0,K.jsx)(W,{className:`max-w-[22rem]`,children:e.description})]},e.name):(0,K.jsx)(z,{...t,children:n},e.name)})]}),t.length>0&&(0,K.jsxs)(Je,{children:[(0,K.jsx)(dt,{}),(0,K.jsx)(c,{children:`Your saved prompts`}),t.map(e=>(0,K.jsx)(sO,{preset:e,busy:r,onLoad:i,onDelete:o},e.id))]}),n.length>0&&(0,K.jsxs)(Je,{children:[(0,K.jsx)(dt,{}),(0,K.jsx)(c,{children:`Project saved prompts`}),n.map(e=>(0,K.jsx)(sO,{preset:e,busy:r,onLoad:i,onDelete:s},e.id))]}),a&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dt,{}),(0,K.jsxs)(z,{disabled:r,onClick:a,children:[(0,K.jsx)(Qa,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Save prompt…`]})]})]})]})}var lO=`the CLI's own default`,uO={xhigh:`Extra high`};function dO(e){return uO[e]??e.charAt(0).toUpperCase()+e.slice(1)}function fO(e,t){return e.find(e=>e.value===t)??e[0]}function pO(e,t){if(t)return e?.models.find(e=>e.value===t)?.label??t}function mO({drivers:e,driver:t,model:n,onChange:r,effort:i,busy:a}){let o=fO(e,t),s=pO(o,n),l=i?.levels??[],u=i?.level===void 0?void 0:dO(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)(I,{children:[(0,K.jsxs)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(Et,{type:`button`,disabled:a,"aria-label":d,className:H(ol,`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)(Pe,{className:`h-3 w-3 shrink-0 opacity-70`})]}),(0,K.jsx)(W,{children:d})]}),(0,K.jsxs)(We,{align:`end`,children:[e.map(e=>(0,K.jsxs)(on,{children:[(0,K.jsxs)(en,{children:[(0,K.jsx)(Ve,{className:H(`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}),e.account&&(0,K.jsxs)(`span`,{className:`flex max-w-36 min-w-0 text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e.account.name}),(0,K.jsx)(`span`,{className:`shrink-0 whitespace-pre`,children:e.account.percent})]})]}),(0,K.jsxs)(Ut,{className:`min-w-[15rem]`,children:[e.models.length===0&&e.modelsNote&&(0,K.jsx)(z,{disabled:!0,children:e.modelsNote}),e.models.map(i=>(0,K.jsxs)(z,{onClick:()=>r(e.value,i.value),children:[(0,K.jsx)(Ve,{className:H(`h-3.5 w-3.5 shrink-0`,e.value===t&&i.value===n?`opacity-100`:`opacity-0`)}),i.label]},i.value)),e.accounts]})]},e.value)),l.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dt,{}),(0,K.jsxs)(Je,{children:[(0,K.jsx)(c,{children:`Effort`}),(0,K.jsxs)(z,{onClick:()=>i.onChange(void 0),children:[(0,K.jsx)(Ve,{className:H(`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)(z,{onClick:()=>i.onChange(e),children:[(0,K.jsx)(Ve,{className:H(`h-3.5 w-3.5 shrink-0`,i?.level===e?`opacity-100`:`opacity-0`)}),dO(e)]},e))]})]})]})]})}function hO(e){let{kind:t,place:n}=S(e);return t===`shared`?`${n}. Runs use your own logins.`:n}function gO({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=Ac(),a=r?ge(r):i,o=!r,s=o?m:ve[S(r).kind];return(0,K.jsxs)(I,{children:[(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(Et,{type:`button`,disabled:t,"aria-label":`Run on`,className:n?ol:H(v({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)(Pe,{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)(W,{children:`Run on — ${r?.label??i}`})]}),(0,K.jsxs)(We,{align:n?`start`:`end`,className:`min-w-[19rem] max-w-[22rem]`,children:[(0,K.jsxs)(z,{className:H(`items-start gap-2`,e.onlyThere&&`opacity-60`),disabled:e.onlyThere,onClick:()=>e.onSelectLocal(),children:[(0,K.jsx)(Ve,{className:H(`mt-0.5 h-3.5 w-3.5 shrink-0`,o?`opacity-100`:`opacity-0`)}),(0,K.jsx)(m,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,K.jsx)(Me,{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=hO(t),o=e.home===void 0?a:t.id===e.home?`${a}. Has this project.`:`${a}. Cloned there first, then runs there.`,s=i?Ft(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)(z,{className:H(`items-start gap-2`,(i||c)&&`opacity-60`),disabled:c,onClick:()=>e.onSelect(t),children:[(0,K.jsx)(Ve,{className:H(`mt-0.5 h-3.5 w-3.5 shrink-0`,r?.id===t.id?`opacity-100`:`opacity-0`)}),(0,K.jsx)(k,{kind:S(t).kind,online:n===`online`,className:`mt-0.5`}),(0,K.jsx)(Me,{label:ge(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)(z,{className:`items-start`,disabled:t,onClick:()=>e.onAddMachine(),children:[(0,K.jsx)(Qa,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsx)(Me,{label:`Add a machine…`,description:`Connect a computer, or join with a code.`})]})]})]})}var _O=1e4;function vO(e){let t=e.map(e=>e.id).join(`|`),n=mn((0,G.useMemo)(()=>t?()=>sn():null,[t]),{},_O,[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=E(`onAgentAccounts`),bO=E(`sendAddAgentAccount`),xO=E(`sendRemoveAgentAccount`),SO=E(`sendUseAgentAccountFirst`);E(`sendNameOwnAgentAccount`);var CO=E(`sendAgentAccountCode`),wO=2e3,TO=3e4,EO=(0,G.createContext)({view:void 0,reload:async()=>{}});function DO(){return(0,G.useContext)(EO)}function OO({children:e}){let[t,n]=(0,G.useState)(!1),{value:r,reload:i}=mn(Si,void 0,t?wO:TO,[t],`previous`),a=r?.servers.some(e=>e.allowing)??!1;return(0,G.useEffect)(()=>{a!==t&&n(a)},[a,t]),(0,K.jsx)(EO.Provider,{value:{view:r,reload:i},children:e})}function kO(){let{view:e,reload:t}=DO();return(0,K.jsx)(K.Fragment,{children:(e?.servers??[]).map(n=>(0,K.jsx)(jO,{server:n,computer:e.computer,onChanged:t},n.machineId))})}var AO=e=>e.logins.filter(e=>e.state===`allow`||e.state===`switched`);function jO({server:e,computer:t,onChanged:n}){let{tone:r,body:i}=MO(e,t,n);return i===null?null:(0,K.jsx)(IO,{label:e.label,tone:r,children:i})}function MO(e,t,n){let[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(),s=async e=>{i(!0),o(void 0);try{let t=await e();t.ok||o(t.error),await n()}finally{i(!1)}},c=a??e.failed,l=e.logins.filter(e=>e.state===`failed`).map(e=>e.name),u=AO(e),d=e.logins.filter(e=>e.state===`there`).length;return e.on?e.allowing?{tone:`ask`,body:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LO,{title:`Making ${e.allowing.name}'s login for ${e.label}`,words:`Say yes in the page your browser opened. If it is signed in to another account, copy the link into a private window.`}),e.allowing.url!==void 0&&(0,K.jsx)(hn,{text:e.allowing.url,label:`Copy link`})]})}:e.reachable?u.length>0?{tone:`ask`,body:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LO,{title:`${e.label} uses your logins: ${d} of ${e.logins.length} there`,words:`${u.map(e=>e.name).join(` and `)} ${u.length===1?`needs`:`need`} your yes once: your browser opens, you press Allow or Continue.`}),(0,K.jsx)(B,{size:`sm`,disabled:r,onClick:()=>void s(()=>wi(e.machineId)),children:u.length===1?`Allow 1 login`:`Allow ${u.length} logins`}),(0,K.jsx)(RO,{error:c})]})}:d<e.logins.length?{tone:`ask`,body:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LO,{title:`${e.label} uses your logins: ${d} of ${e.logins.length} there`,words:l.length>0?`${l.join(` and `)} did not get there: see ${l.length===1?`its row`:`their rows`} below. Tried again every minute.`:`These did not get there. They are tried again every minute.`}),(0,K.jsx)(RO,{error:c})]})}:c===void 0?{tone:`quiet`,body:null}:{tone:`quiet`,body:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`flex flex-1 items-center gap-1.5 text-sm`,children:[(0,K.jsx)(Ve,{className:`size-3.5 text-success`,"aria-hidden":!0}),`${e.label} uses your logins: all ${e.logins.length} there`]}),(0,K.jsx)(RO,{error:c})]})}:{tone:`quiet`,body:(0,K.jsx)(LO,{title:`${e.label} does not answer`,words:`Its logins are brought up to date once it does.`})}:{tone:`ask`,body:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(LO,{title:`Use your logins on ${e.label}?`,words:`Runs there use the accounts you're logged into on ${t}, and its page follows your settings. The server gets logins of its own: nothing here is logged out.`}),(0,K.jsx)(B,{size:`sm`,disabled:r,onClick:()=>void s(()=>Ci(e.machineId)),children:`Use them`}),(0,K.jsx)(RO,{error:c})]})}}function NO({machineId:e,onAccounts:t}){return(0,K.jsx)(OO,{children:(0,K.jsx)(PO,{machineId:e,onAccounts:t})})}function PO({machineId:e,onAccounts:t}){let{view:n,reload:r}=DO(),i=n?.servers.find(t=>t.machineId===e);return n?i?(0,K.jsx)(FO,{server:i,computer:n.computer,onChanged:r}):(0,K.jsx)(B,{size:`sm`,variant:`outline`,onClick:t,children:`Open Accounts`}):null}function FO({server:e,computer:t,onChanged:n}){return(0,K.jsx)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 text-foreground`,children:MO(e,t,n).body})}function IO({label:e,tone:t,children:n}){return(0,K.jsx)(`section`,{"aria-label":`Your logins on ${e}`,className:H(`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border px-3 py-2.5`,t===`ask`?`border-warning/40 bg-warning/10`:`border-border`),children:n})}function LO({title:e,words:t}){return(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 basis-60`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium`,children:e}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t})]})}function RO({error:e}){return e===void 0?null:(0,K.jsx)(`p`,{role:`alert`,className:`basis-full text-xs whitespace-pre-line text-danger`,children:e})}var zO=(e,t)=>e.kind===t.kind&&(e.host??``)===(t.host??``)&&e.source===t.source;function BO({row:e}){let{view:t,reload:n}=DO(),[r,i]=(0,G.useState)(!1),[a,o]=(0,G.useState)(),s=(t?.servers??[]).flatMap(t=>{let n=t.on&&t.reachable?t.logins.find(t=>zO(t,e)):void 0;return n&&n.state!==`switched`?[{server:t,login:n}]:[]});if(s.length===0)return null;let c=e=>s.filter(t=>t.login.state===e).map(e=>e.server.label),l=s.filter(e=>e.login.state===`there`),u=c(`allow`),d=new Map;for(let{server:e,login:t}of s)t.state===`failed`&&d.set(t.error??`it did not get there`,[...d.get(t.error??`it did not get there`)??[],e.label]);let f=async t=>{i(!0),o(void 0);let r=await Ti(t,e,!1);r.ok||o(r.error),await n(),i(!1)};return(0,K.jsxs)(`div`,{className:`basis-full space-y-0.5 text-xs`,children:[l.length>0&&(0,K.jsxs)(`p`,{className:`text-success`,children:[`✓ on `,l.map(({server:e,login:t},n)=>(0,K.jsxs)(`span`,{children:[n>0&&` · `,t.anew?(0,K.jsxs)(I,{children:[(0,K.jsx)(Et,{type:`button`,disabled:r,"aria-label":`${t.name} on ${e.label}`,className:`rounded-sm underline decoration-dotted underline-offset-2 hover:text-foreground`,children:e.label}),(0,K.jsx)(We,{align:`start`,className:`min-w-[14rem]`,children:(0,K.jsx)(z,{onClick:()=>void f(e.machineId),children:`Take off ${e.label}`})})]}):e.label]},e.machineId))]}),u.length>0&&(0,K.jsx)(`p`,{className:`text-warning`,children:`not on ${u.join(` · `)} yet`}),[...d].map(([e,t])=>(0,K.jsx)(`p`,{className:`text-danger`,children:`Not on ${t.join(` · `)}: ${e}`},e)),a!==void 0&&(0,K.jsx)(`p`,{role:`alert`,className:`text-danger`,children:a})]})}function VO({row:e}){let{view:t,reload:n}=DO(),[r,i]=(0,G.useState)(),a=(t?.servers??[]).flatMap(t=>{let n=t.on&&!t.allowing?t.logins.find(t=>zO(t,e)&&t.state===`switched`):void 0;return n?[{server:t,login:n}]:[]}),o=async e=>{i(void 0);let t=await e();t.ok||i(t.error),await n()};return(0,K.jsx)(K.Fragment,{children:a.map(({server:n,login:i})=>(0,K.jsxs)(`div`,{role:`status`,className:`mx-3 mb-3 space-y-2 rounded-lg border border-warning/40 bg-warning/10 p-3`,children:[(0,K.jsx)(`p`,{className:`text-sm`,children:`${n.label} still runs on ${i.was}, the account you left on ${t.computer}.`}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(B,{size:`sm`,onClick:()=>void o(()=>wi(n.machineId)),children:`Use ${i.name} there`}),(0,K.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>void o(()=>Ti(n.machineId,e,!0)),children:`Keep ${i.was}`})]}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Use ${i.name} there opens your browser once. Runs go on until you pick.`}),r!==void 0&&(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]},n.machineId))})}function HO({kind:e,host:t}){let{view:n,reload:r}=DO(),[i,a]=(0,G.useState)(),o=(n?.servers??[]).flatMap(n=>n.left.filter(n=>n.kind===e&&(n.host??``)===(t??``)).map(e=>({server:n,login:e})));if(o.length===0)return null;let s=async(e,{kind:t,host:n,source:i},o)=>{a(void 0);let s=await Ti(e,{kind:t,...n===void 0?{}:{host:n},source:i},o);s.ok||a(s.error),await r()};return(0,K.jsxs)(`div`,{className:`space-y-2 border-t border-border px-3 py-2.5`,children:[o.map(({server:e,login:t})=>(0,K.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,K.jsx)(`p`,{className:`min-w-0 flex-1 basis-60 text-sm`,children:`${e.label} still has ${t.name}, which is no longer on ${n.computer}.`}),(0,K.jsx)(B,{size:`xs`,variant:`outline`,onClick:()=>void s(e.machineId,t,!0),children:`Keep it there`}),(0,K.jsx)(B,{size:`xs`,variant:`ghost`,onClick:()=>void s(e.machineId,t,!1),children:`Take it off`})]},`${e.machineId} ${t.source}`)),i!==void 0&&(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:i})]})}var UO=2e3,WO=3e4,GO={claude:{title:`Claude Code`,short:`Claude`,driver:`claude-code`,Logo:So,logIn:`Log in to Claude`,adding:e=>`Adding ${e}'s account: say yes in the page this computer's browser opened, signed in to ${e}'s Claude account.`,help:`Opens this computer's browser, where you say yes once, signed in to that account. The login is kept on this computer alone and lasts a year.`,remove:`Runs no longer use it. Its login is not ended: take it back on claude.ai to end it.`},codex:{title:`Codex`,short:`Codex`,driver:`codex`,Logo:Co,logIn:`Log in to Codex`,adding:e=>`Adding ${e}'s account: sign in to ${e}'s ChatGPT account in the page this computer's browser opened.`,help:`Opens this computer's browser, where you sign in once to that account. If the browser is signed in to another account, copy the link into a private window. The login is kept on this computer alone, and Codex renews it.`,remove:`Runs no longer use it, and its login is taken off this computer.`}};function KO(e,t=!1){let{value:n,reload:r}=mn(()=>yO(e),void 0,t?UO:WO,[e,t],{remember:`agent-accounts:${e}`});return{view:n,reload:r}}function qO(e,t){let n=Math.max(1,Math.ceil((e-t)/6e4)),r=Math.floor(n/60),i=n%60;return r>=48?`${Math.round(r/24)} days`:r===0?`${i} min`:i===0?`${r} h`:`${r} h ${i} min`}function JO(e){return new Date(e).toLocaleTimeString(void 0,{hour:`numeric`,minute:`2-digit`})}function YO(e,t){return e.own?`login on ${t}`:e.from===void 0?e.added?`added ${new Date(e.added).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}`:`added`:`from ${e.from}`}function XO(e){return e.windows[e.windows.length-1]}function ZO(e){let t=XO(e);return t===void 0?e.own?void 0:`not used yet`:`${Math.round(t.percent)}% ${t.label===`5 h`?`of 5 h`:`this ${t.label}`}${e.asOf===void 0?``:` · as of ${JO(e.asOf)}`}`}function QO({percent:e,className:t}){let n=Math.min(100,Math.max(0,e??0));return(0,K.jsx)(`span`,{"aria-hidden":!0,className:H(`relative block h-1.5 w-20 shrink-0 overflow-hidden rounded-full bg-muted-foreground/15`,t),children:(0,K.jsx)(`span`,{className:H(`absolute inset-y-0 left-0 rounded-full`,n>=100?`bg-danger`:n>=80?`bg-warning`:`bg-success`),style:{width:`${n}%`}})})}function $O({account:e,now:t}){return e.state===`limited`&&e.limitedUntil!==void 0?(0,K.jsxs)(`span`,{className:`text-xs text-warning`,children:[`limited, free in `,qO(e.limitedUntil,t)]}):e.state===`in-use`?(0,K.jsx)(`span`,{className:`text-xs font-medium text-success`,children:`in use`}):e.state===`next`?(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`next`}):null}function ek({agent:e,adding:t,words:n}){let[r,i]=(0,G.useState)(``),[a,o]=(0,G.useState)();if(t.code!==void 0&&t.url!==void 0)return(0,K.jsx)(qs,{code:t.code,url:t.url});if(t.paste&&t.url!==void 0){let n=async()=>{o(void 0);let t=await CO(e,r);t.ok||o(t.error)};return(0,K.jsxs)(`div`,{role:`status`,className:`space-y-2`,children:[(0,K.jsx)(`a`,{href:t.url,target:`_blank`,rel:`noreferrer`,className:`inline-flex h-9 items-center rounded-md border border-border px-3 text-sm hover:bg-accent`,children:`1. Open Claude and press Authorize ↗`}),(0,K.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),n()},children:[(0,K.jsx)(Lt,{"aria-label":`Code from Claude`,placeholder:`2. Paste the code it shows`,value:r,onChange:e=>i(e.target.value),className:`h-9 min-w-0 flex-1 basis-48 text-base sm:text-sm`}),(0,K.jsx)(B,{size:`sm`,type:`submit`,disabled:r.trim()===``,children:`Done`})]}),a!==void 0&&(0,K.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:a})]})}return(0,K.jsxs)(`div`,{role:`status`,className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}),t.url!==void 0&&(0,K.jsx)(tk,{url:t.url})]})}function tk({url:e}){let[t,n]=(0,G.useState)(!1);return(0,K.jsxs)(B,{size:`xs`,variant:`ghost`,onClick:()=>void navigator.clipboard.writeText(e).then(()=>n(!0),()=>{}),children:[t?(0,K.jsx)(Ve,{className:`size-3.5`,"aria-hidden":!0}):(0,K.jsx)(Le,{className:`size-3.5`,"aria-hidden":!0}),t?`Copied`:`Copy link for a private window`]})}function nk({agent:e}){let t=GO[e],[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(),[c,l]=(0,G.useState)(!1),{view:u,reload:d}=KO(e,!0),{state:f,reload:p}=Ns(t.driver),m=u?.adding,h=Fs(f)===`not-installed`&&(u?.accounts.length??0)<2,g=f?.ownLoggedOut===!0||Fs(f)===`step`,_=(u?.accounts??[]).filter(e=>!(e.own&&g)),v=async e=>{l(!0),s(void 0);try{let t=await e();return t.ok||s(t.error),await d(),t.ok}finally{l(!1)}},y=async()=>{await v(()=>bO(e,i))&&(r(!1),a(``))};return(0,K.jsxs)(`section`,{"aria-label":t.title,className:`rounded-lg border border-border`,children:[(0,K.jsxs)(`header`,{className:H(`flex items-center gap-2 px-3 py-2.5`,!h&&`border-b border-border`),children:[(0,K.jsx)(t.Logo,{className:`size-4 shrink-0`}),(0,K.jsx)(`h3`,{className:`flex-1 text-sm font-medium`,children:t.title}),f&&(0,K.jsx)(Rs,{state:Fs(f)})]}),f&&!f.ready&&(f.fix!==void 0||Fs(f)===`not-installed`)&&(0,K.jsxs)(`div`,{className:H(`space-y-2 px-3 py-2.5`,!h&&`border-b border-border`,h&&`pt-0`),children:[(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Hs(f)}),(0,K.jsx)(Ks,{state:f,onChanged:()=>void p()})]}),!h&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ul`,{className:`divide-y divide-border`,children:_.map(n=>(0,K.jsxs)(`li`,{"aria-label":n.name,children:[(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1 max-sm:basis-full!`,children:[(0,K.jsx)(`p`,{className:`truncate text-sm`,children:n.name}),(0,K.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:YO(n,u.computer)})]}),ZO(n)!==void 0&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(QO,{percent:XO(n)?.percent}),(0,K.jsx)(`span`,{className:`w-44 truncate text-xs text-muted-foreground max-sm:w-auto`,children:ZO(n)})]}),(0,K.jsxs)(`div`,{className:`flex w-36 items-center justify-end gap-2 max-sm:w-auto`,children:[u&&(0,K.jsx)($O,{account:n,now:u.now}),!n.own&&n.from===void 0&&(0,K.jsx)(B,{size:`xs`,variant:`ghost`,disabled:c,"aria-label":`Remove ${n.name}'s account`,title:t.remove,onClick:()=>void v(()=>xO(e,n.id)),children:`Remove`})]}),(0,K.jsx)(BO,{row:{kind:e,source:n.own?`own`:n.id}})]}),(0,K.jsx)(VO,{row:{kind:e,source:n.own?`own`:n.id}})]},n.id))}),(0,K.jsx)(HO,{kind:e}),(0,K.jsxs)(`div`,{className:H(`px-3 py-2.5`,_.length>0&&`border-t border-border`),children:[m?(0,K.jsx)(ek,{agent:e,adding:m,words:t.adding(m.name)}):n?(0,K.jsxs)(`form`,{className:`flex flex-wrap items-center gap-2`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,K.jsx)(Lt,{autoFocus:!0,"aria-label":`Whose account`,placeholder:`Whose account, e.g. Dani`,value:i,onChange:e=>a(e.target.value),className:`h-8 w-56 max-sm:w-full`}),(0,K.jsx)(B,{size:`sm`,type:`submit`,disabled:c||i.trim()===``,children:t.logIn}),(0,K.jsx)(B,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>(r(!1),s(void 0)),children:`Cancel`})]}):(0,K.jsxs)(B,{size:`sm`,variant:_.length===0?`default`:`ghost`,onClick:()=>r(!0),children:[(0,K.jsx)(Qa,{className:`size-3.5`,"aria-hidden":!0}),_.length===0?t.logIn:`Add account`]}),n&&!m&&(0,K.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:t.help}),(o??u?.failed)!==void 0&&(0,K.jsx)(`p`,{role:`alert`,className:`mt-1.5 whitespace-pre-line text-xs text-danger`,children:o??u?.failed})]})]})]})}var rk=(e,t)=>`machine-agent-accounts:${e}:${t}`;function ik(e){for(let t of[`claude`,`codex`])De(rk(e,t),()=>ae(e,t))}function ak(e,t,n=!0){let r=mn(n&&t===void 0?()=>yO(e):null,void 0,WO,[e,n,t===void 0],{remember:`agent-accounts:${e}`}),i=mn(n&&t!==void 0?()=>ae(t,e):null,void 0,WO,[e,n,t],t===void 0?void 0:{remember:rk(t,e)});return t===void 0?{view:r.value,unanswered:!1,pick:t=>SO(e,t).then(r.reload)}:{view:i.value??void 0,unanswered:i.value===null,pick:n=>rn(t,e,n).then(i.reload)}}function ok(e){let t=e?.accounts[0];if(!t)return;let n=XO(t);return{name:t.name,percent:t.state===`limited`?` · limited`:n===void 0?``:` · ${Math.round(n.percent)}%`}}function sk({view:e,on:t,onPick:n,onAdd:r}){return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dt,{}),(0,K.jsxs)(Je,{children:[(0,K.jsx)(c,{children:t===void 0?`Accounts`:`Accounts on ${t}`}),e.accounts.map((e,t)=>(0,K.jsxs)(z,{closeOnClick:!1,onClick:()=>n(e.id),children:[(0,K.jsx)(Ve,{className:H(`h-3.5 w-3.5 shrink-0`,t===0?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`flex-1 truncate`,children:e.name}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.state===`limited`?`limited`:XO(e)===void 0?``:`${Math.round(XO(e).percent)}%`})]},e.id)),(0,K.jsxs)(z,{onClick:r,children:[(0,K.jsx)(Qa,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0}),`Add account…`]})]})]})}function ck(){let{view:e}=KO(`claude`),t=e&&e.accounts.length>1?e.accounts.filter(e=>!e.own):[];return t.length===0?null:(0,K.jsx)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,"aria-label":`Other Claude accounts`,children:t.map(t=>(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-sm`,children:[(0,K.jsx)(`span`,{className:`w-24 truncate`,children:t.name}),(0,K.jsx)(QO,{percent:XO(t)?.percent}),(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.state===`limited`&&t.limitedUntil!==void 0?`limited, free in ${qO(t.limitedUntil,e.now)}`:ZO(t)??``})]},t.id))})}function lk(){let{view:e,reload:t}=Ps();return e&&e.hosts.length===0?(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`None of your projects has a remote yet. A project pushed to a git host gets its card here.`}):(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The accounts runs open pull requests and push with. A switch here changes what runs use; the terminal keeps its own.`}),(e?.hosts??[]).map(e=>e.provider?(0,K.jsx)(fk,{row:e,onChanged:t},e.host):(0,K.jsx)(dk,{row:e},e.host))]})}function uk(e){return e.projects.length>0?`used by ${e.projects.join(`, `)}`:`no project on it yet`}function dk({row:e}){return(0,K.jsxs)(`p`,{"aria-label":e.host,className:`rounded-lg border border-dashed border-border px-3 py-2.5 text-sm text-muted-foreground`,children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:e.host}),` · ${uk(e)} · no package for it yet`]})}function fk({row:e,onChanged:t}){let n=e.provider,r=Is(e),[i,a]=(0,G.useState)(),o=Js(t),s=DO(),[c,l]=(0,G.useState)(),u=async(e,n,r)=>{l({login:e,press:n}),a(void 0);try{let e=await r();e.ok||a(e.error),await Promise.all([t(),s.reload()])}finally{l(void 0)}},d=(e,t)=>c?.login===e&&c.press===t;return(0,K.jsxs)(`section`,{"aria-label":n.name,className:`rounded-lg border border-border`,children:[(0,K.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 border-b border-border px-3 py-2.5`,children:[(0,K.jsx)(zs,{svg:n.logo}),(0,K.jsx)(`h3`,{className:`text-sm font-medium`,children:n.name}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:`${e.host} · ${uk(e)}`}),(0,K.jsx)(Rs,{state:r})]}),n.accounts.length>0&&(0,K.jsx)(`ul`,{className:`divide-y divide-border`,children:n.accounts.map(t=>(0,K.jsxs)(`li`,{"aria-label":`@${t.login}`,className:`flex flex-wrap items-center gap-x-3 gap-y-1 px-3 py-2.5`,children:[(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`p`,{className:`truncate text-sm`,children:[`@`,t.login]}),(0,K.jsx)(`p`,{className:H(`truncate text-xs`,t.ok?`text-muted-foreground`:`text-warning`),children:t.ok?t.from===void 0?t.terminal?`the terminal's account`:`logged in to ${n.tool}`:`from ${t.from}`:`${n.name} no longer takes this login: add it again`})]}),t.runs?(0,K.jsx)(`span`,{className:`text-xs font-medium text-success`,children:`in use for runs`}):(0,K.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,K.jsxs)(B,{size:`xs`,variant:`ghost`,disabled:c!==void 0||!t.ok,onClick:()=>void u(t.login,`use`,()=>bs(e.host,t.login)),children:[d(t.login,`use`)&&(0,K.jsx)(xn,{className:`size-3 animate-spin`,"aria-hidden":!0}),d(t.login,`use`)?`Switching…`:`Use for runs`]}),(0,K.jsxs)(B,{size:`xs`,variant:`ghost`,disabled:c!==void 0,"aria-label":`Remove @${t.login}`,title:`${n.tool} on this computer forgets it. The login is not ended: it goes on working wherever else it is.`,onClick:()=>void u(t.login,`remove`,()=>xs(e.host,t.login)),children:[d(t.login,`remove`)&&(0,K.jsx)(xn,{className:`size-3 animate-spin`,"aria-hidden":!0}),d(t.login,`remove`)?`Removing…`:`Remove`]})]}),(0,K.jsx)(BO,{row:{kind:`git`,host:e.host,source:t.login}})]},t.login))}),(0,K.jsx)(HO,{kind:`git`,host:e.host}),(0,K.jsxs)(`div`,{className:H(`px-3 py-2.5`,n.accounts.length>0&&`border-t border-border`),children:[!n.installed||n.accounts.length===0?(0,K.jsxs)(`div`,{className:`space-y-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Us(e)}),(0,K.jsx)(Ys,{row:e,onChanged:t})]}):n.loggingIn?(0,K.jsx)(qs,{code:n.loggingIn.code,url:n.loggingIn.url}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(B,{size:`sm`,variant:`ghost`,disabled:o.busy,onClick:()=>void o.start(e.host),children:[(0,K.jsx)(Qa,{className:`size-3.5`,"aria-hidden":!0}),`Add account`]}),(0,K.jsx)(`p`,{className:`mt-1.5 text-xs text-muted-foreground`,children:`Logs another account in to ${n.tool} with a code you type at ${n.name}. The terminal's account stays as it is.`})]}),(i??o.error)!==void 0&&(0,K.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:i??o.error})]})]})}var pk=e=>`machine-git-hosts:${e}`;function mk(e){De(pk(e),()=>Ge(e))}function hk(e){let t=Ps(),n=mn(e===void 0?null:()=>Ge(e),void 0,3e4,[e],e===void 0?void 0:{remember:pk(e)});return e===void 0?{view:t.view,pick:(e,n)=>bs(e,n).then(t.reload)}:{view:n.value??void 0,pick:(t,r)=>Rt(e,t,r).then(n.reload)}}function gk({address:e,machineId:t,on:n,busy:r,onAdd:i}){let{view:a,pick:o}=hk(t),s=e?.split(`/`)[0],l=s===void 0?void 0:a?.hosts.find(e=>e.host===s),u=l?.provider;if(!l||!u)return null;let d=u.accounts.find(e=>e.runs);if(!d)return(0,K.jsxs)(`button`,{type:`button`,disabled:r,onClick:i,className:H(ol,`text-warning`),children:[(0,K.jsx)(zs,{svg:u.logo,className:`size-3.5`}),(0,K.jsx)(`span`,{className:`truncate`,children:u.installed?`Log in to ${u.name}`:`${u.tool} not installed`})]});let f=`Runs push and open pull requests as @${d.login}${n===void 0?``:` on ${n}`}`;return(0,K.jsxs)(I,{children:[(0,K.jsxs)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(Et,{type:`button`,disabled:r,"aria-label":`${u.name} account: @${d.login}`,className:ol}),children:[(0,K.jsx)(zs,{svg:u.logo,className:`size-3.5`}),(0,K.jsxs)(`span`,{className:`max-w-32 truncate`,children:[`@`,d.login]}),(0,K.jsx)(Pe,{className:`h-3 w-3 shrink-0 opacity-70`,"aria-hidden":!0})]}),(0,K.jsx)(W,{children:f})]}),(0,K.jsxs)(We,{align:`end`,className:`min-w-[14rem]`,children:[(0,K.jsxs)(Je,{children:[(0,K.jsx)(c,{children:`${u.name} account${n===void 0?``:` on ${n}`}`}),u.accounts.map(e=>(0,K.jsxs)(z,{closeOnClick:!1,disabled:!e.ok,onClick:()=>void o(l.host,e.login),children:[(0,K.jsx)(Ve,{className:H(`h-3.5 w-3.5 shrink-0`,e.runs?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,K.jsxs)(`span`,{className:`flex-1 truncate`,children:[`@`,e.login]}),e.terminal&&(0,K.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`terminal`})]},e.login))]}),(0,K.jsx)(dt,{}),(0,K.jsxs)(z,{onClick:i,children:[(0,K.jsx)(Qa,{className:`h-3.5 w-3.5 shrink-0 opacity-70`,"aria-hidden":!0}),`Add account…`]})]})]})}var _k={"claude-code":{icon:(0,K.jsx)(So,{className:`h-4 w-4`})},codex:{icon:(0,K.jsx)(Co,{className:`h-4 w-4`})}},vk=`flex h-8 items-center gap-2`,yk=`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)]`,bk=(0,G.forwardRef)(function({files:e,addContext:t,removeContext:n,startsAt:r,startsAtEnd:i,controls:a,sessionModel:o,sessionContext:s,onSubmit:c,onPromptChange:l,onPreset:u,busy:d,submitLabel:f,submitBusyLabel:p,placeholder:m,compact:h=!1,showDriverModel:g=!0,inAgent:v=!1,canSubmit:y=!0,idleControl:b,home:x},S){let[C,w]=(0,G.useState)(``),[T,E]=(0,G.useState)(!1),D=(0,G.useRef)(null),O=ia(),k=vO(O),A=_(li,[],[]),ee=(0,G.useMemo)(()=>A.filter(e=>e.machine===void 0),[A]),j=_r(),M=j.model??``,N=j.driver??`claude-code`,P=j.customPresets??[],te=fr(),ne=gr(),F=Vc(ne),re=F?.commands??[],ie=x===void 0&&F!==null&&F.address===void 0,ae=x!==void 0&&F!==null&&F.address===void 0,I=Li(),L=vr(),R=ra();(0,G.useEffect)(()=>{v||zi(j.runOn,L&&R?O:null,k)},[v,j.runOn,L,R,O,k]),(0,G.useEffect)(()=>{if(!v)for(let e of O)k[e.id]===`online`&&(vt(e.id),ik(e.id),mk(e.id))},[v,O,k]);let oe=Ri(),se=oe?.why===`offline`?O.find(e=>e.id===oe.id):void 0,ce=Vi(O,I,F,x),{models:le,theirs:ue}=bn(v?void 0:ce?.id),de=v||!g?void 0:ce?.id,fe=ak(`claude`,de,!v&&g),pe=ak(`codex`,de,!v&&g),me=e=>{let{view:t,pick:n}=e===`codex`?pe:fe,r=le?.[e],i=r!==void 0&&!(`error`in r&&r.missing);if(!t||t.accounts.length===0||e===`codex`&&t.accounts.length<2&&!i)return{};let a=ce?ge(ce):void 0;return{account:ok(t),accounts:(0,K.jsx)(sk,{view:t,on:a,onPick:e=>void n(e),onAdd:()=>ce?nl(`devices`,ce.id):nl(Os)})}},he=!!ce&&k[ce.id]===`offline`,[_e,ve]=(0,G.useState)(null),ye=ce?.owner,be=!v&&!!ce&&ye!==void 0&&!ce.told&&_e!==ce.id;(0,G.useImperativeHandle)(S,()=>({clear:()=>{D.current?.clear(),w(``)},focus:()=>D.current?.focus()}));let[xe,Se]=(0,G.useState)(void 0);(0,G.useEffect)(()=>{if(h||v)return;let e=wt();e&&Se(e)},[h,v]);let z=(0,G.useRef)(!1),Ce=e=>{e?.preventDefault();let t=C.trim();!t||d||z.current||he||be||!y||(z.current=!0,Promise.resolve(c(t)).finally(()=>{z.current=!1}))},we=(e,t)=>{let n=D.current?.loadTemplate(e)??!1;u?.(t,n)},Te=(0,K.jsx)(rO,{ref:D,compact:h,onChange:e=>{w(e),l?.(e)},onSubmit:Ce,...u?{onPreset:u}:{},...t?{onMentionProject:t,onMentionFile:t}:{},...n?{onMentionRemoved:n}:{},projects:ee,files:e,commands:Hc(re),customPresets:P,projectPresets:te,...h?{}:{onNewPreset:()=>E(!0)},disabled:d,...m?{placeholder:m}:{},...xe?{initialText:xe}:{}}),Ee=g&&(0,K.jsx)(mO,{drivers:mt(le,ue&&ce?ge(ce):void 0).map(e=>({...e,..._k[e.value],...me(e.value)})),driver:N,model:M,onChange:(e,t)=>mr({driver:e,model:t}),effort:{levels:Bt(le,N,M),level:j.effort||void 0,onChange:e=>mr({effort:e??``})},busy:d}),De=!h&&(0,K.jsx)(cO,{commands:re,customPresets:P,projectPresets:te,busy:d,onLoad:we,onNew:()=>E(!0),onDelete:e=>mr({customPresets:P.filter(t=>t.id!==e)}),onDeleteProject:e=>pr(ne,te.filter(t=>t.id!==e))}),Oe=v?null:(0,K.jsx)(gO,{busy:d,inRow:!h,connection:{machines:O,selectedMachineId:I,onlyHere:ie,home:x,onlyThere:ae,onSelect:e=>Pi(e.id),onSelectLocal:()=>Pi(null),onAddMachine:()=>nl(`devices`),status:k}}),ke=!!C.trim(),Ae=(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(B,{type:`submit`,size:`icon-sm`,onClick:Ce,disabled:d||!ke||he||be||!y,"aria-hidden":!ke,tabIndex:ke?void 0:-1,"aria-label":f,className:H(`h-8 w-8 shrink-0 transition-[margin,opacity,transform] duration-150 ease-out`,ke?H(`ml-0 translate-x-0 opacity-100`,d?`disabled:opacity-100`:`disabled:opacity-40`):H(`pointer-events-none translate-x-2 opacity-0 disabled:opacity-0`,h?`-ml-[2.375rem]`:`-ml-8`))}),children:d?(0,K.jsx)(xn,{className:`h-4 w-4 animate-spin`}):(0,K.jsx)(ca,{className:`h-4 w-4`})}),(0,K.jsx)(W,{children:d?p:`${f} (Enter · Shift+Enter for a new line)`})]}),je=!ke&&b?b:Ae,Me=he&&(0,K.jsx)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:`${ce?ge(ce):`The selected machine`} is offline. Pick another place to run, then start.`}),Ne=Ac()===`This machine`?`this machine`:Ac(),Pe=!v&&!h&&oe&&!ce&&(0,K.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-muted-foreground`,children:oe.why===`gone`?`The computer you last picked to run on is no longer saved, so runs start on ${Ne}.`:`${se?ge(se):`The computer you last picked`} is offline, so runs start on ${Ne}. Pick it again once it is on.`}),Fe=be&&(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 @${ye}'s server.`}),` `,(0,K.jsx)(`span`,{className:`text-muted-foreground`,children:`@${ye} can see what is on it. Runs there start once you say OK.`})]}),(0,K.jsx)(B,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>{ve(ce.id),ta(ce.id)},children:`OK`})]});return h?(0,K.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:Te}),Ee,Oe,je]}):(0,K.jsxs)(K.Fragment,{children:[!v&&(0,K.jsxs)(`div`,{className:H(`mb-1`,vk),children:[(0,K.jsxs)(`div`,{className:yk,children:[Oe,r]}),i&&(0,K.jsx)(`div`,{className:`shrink-0`,children:i})]}),Fe,(0,K.jsxs)(`div`,{className:`flex items-end rounded-xl border border-border bg-card focus-within:border-muted-foreground/40`,children:[De&&(0,K.jsx)(`div`,{className:`-mr-2 flex shrink-0 items-center p-1`,children:De}),(0,K.jsx)(`div`,{className:`min-w-0 flex-1`,children:Te}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center p-1`,children:je})]}),(0,K.jsxs)(`div`,{className:H(`mt-1`,vk),children:[(0,K.jsx)(`div`,{className:yk,children:a}),(0,K.jsx)(`div`,{className:`shrink-0`,children:Ee||(0,K.jsxs)(`span`,{className:`flex items-center`,children:[o!==void 0&&(0,K.jsx)(`span`,{className:`px-2 text-[13px] text-muted-foreground`,children:o}),s]})})]}),Me,Pe,T&&(0,K.jsx)(oO,{currentPrompt:C,busy:d,canSaveToProject:ne!==null,onCancel:()=>{E(!1),D.current?.focus()},onSave:(e,t)=>{t===`project`?pr(ne,[...te,e]):mr({customPresets:[...P,e]}),E(!1),D.current?.focus()}})]})});function xk(e,t,n){return e===`local`?`${n} (local)`:t}function Sk({main:e,local:t,pick:n,onPick:r,busy:i}){let a=xk(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)(I,{children:[(0,K.jsxs)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(Et,{type:`button`,disabled:i,"aria-label":`The agent starts from`,className:ol}),children:[(0,K.jsx)(Ma,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`truncate`,children:a}),(0,K.jsx)(Pe,{className:`h-3 w-3 shrink-0 opacity-70`,"aria-hidden":!0})]}),(0,K.jsx)(W,{children:`The agent starts from ${a}`})]}),(0,K.jsx)(We,{align:`start`,className:`min-w-[19rem] max-w-[22rem]`,children:(0,K.jsxs)(Je,{children:[(0,K.jsx)(c,{className:`font-normal`,children:`The agent starts from`}),o.map(e=>(0,K.jsxs)(z,{className:`items-start`,"aria-current":e.pick===n,onClick:()=>r(e.pick),children:[(0,K.jsx)(Ve,{className:H(`mt-0.5 h-3.5 w-3.5 shrink-0`,e.pick===n?`opacity-100`:`opacity-0`),"aria-hidden":!0}),(0,K.jsx)(Me,{label:e.label,description:e.description})]},e.pick))]})})]})}function Ck(e,t){let n=t?.replace(/\/+$/,``);return n&&e.startsWith(`${n}/`)?e.slice(n.length+1):e}function wk(e,t){let n=t?.replace(/\/+$/,``);return n===void 0||!e.startsWith(`/`)||e.startsWith(`${n}/`)}function Tk(e){return e.kind===`driver`&&e.event.type===`output`?e.event.changed??[]:[]}function Ek(e){return e.kind===`driver`&&e.event.type===`start`}function Dk(e,t){let n=new Map;for(let r of e){if(!wk(r.path,t))continue;let e=Ck(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(Ek(i)){r.length>0&&n.set(i,Dk(r,t)),r=[];continue}r.push(...Tk(i))}return{ended:n,last:Dk(r,t)}}function kk(e){return{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)}}var Ak={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 jk(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 Mk(e){return e.split(`, `).map(e=>e.replace(/\/+$/,``).split(`/`).pop()||e).join(`, `)}function Nk(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 Pk(e,t,n){let r=Ak[e],i=Nk(e),a={verb:r?.verb??i?.verb??jk(e),doing:r?.doing??i?.doing??jk(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?Mk(t):r?.slash?`/${t.replace(/^\//,``)}`:t),n!==void 0&&n.length>0){let e=Dk(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=kk(e)}return a}var Fk=(e,t,n)=>e===1?t:`${e} ${n}`;function Ik(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 ${Fk(o,`a command`,`commands`)}`}),r>0&&i.push({words:`read ${Fk(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=Dk(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 ${Fk(n.length,`a file`,`files`)}`}):(t>0&&i.push({words:`created ${Fk(t,`a file`,`files`)}`}),e.length>t&&i.push({words:`edited ${Fk(e.length-t,`a file`,`files`)}`})),e.length>0&&(a.size=kk(e))}let s=t(`skill`).length+t(`other`).length;return s>0&&i.push({words:`used ${Fk(s,`a tool`,`tools`)}`}),i[0]&&(i[0].words=i[0].words.charAt(0).toUpperCase()+i[0].words.slice(1)),a}function Lk(e){return e.parts.map(e=>e.target===void 0?e.words:`${e.words} ${e.target}`).join(`, `)}function Rk({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 zk({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 Bk({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)(Da,{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)(Rk,{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)(Rk,{added:e.reduce((e,t)=>e+t.added,0),removed:e.reduce((e,t)=>e+t.removed,0)})})]})]})}function Vk({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:u(t-Date.parse(e))})}function Hk(){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 Uk(e){let t=e.trim().split(`
|
|
130
130
|
`).find(e=>e.trim()!==``)?.trim()??`Thought`;return t.length>90?`${t.slice(0,90).trimEnd()}…`:t}var Wk=`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 Gk({label:e,detail:t,whole:n,summary:r,output:i,live:a}){let[o,s]=(0,G.useState)(!1),c=Pk(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:H(`shrink-0`,a&&`text-shimmer`),children:a?c.doing:c.verb}),c.target!==void 0&&(0,K.jsx)(`span`,{className:H(`truncate`,a?`text-shimmer`:!c.plain&&`text-foreground`),children:c.target})]}):(0,K.jsx)(`span`,{className:H(`truncate`,a&&`text-shimmer`),children:u}),c.size!==void 0&&(0,K.jsx)(zk,{...c.size}),a?.since!==void 0&&(0,K.jsx)(Vk,{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)(P,{className:H(`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:H(Wk,`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:H(Wk,`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 Kk({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:Uk(e)}),(0,K.jsx)(P,{className:H(`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)(Qt,{text:e,compact:!0})})]})}function qk({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)(Hk,{}),(0,K.jsx)(`span`,{className:`morph-in flex min-w-0 items-center gap-2`,children:e?(0,K.jsx)(Gk,{...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)(Vk,{since:n})]})},e?e.id??`${e.label} ${e.detail??``}`:t)]})}function Jk({steps:e,lead:t}){let[n,r]=(0,G.useState)(!1),i=_r().showThinking===!0?e:e.filter(e=>e.type===`action`),a=e.filter(e=>e.type===`action`);if(a.length===0)return null;let o=Ik(a.map(e=>Pk(e.label,e.detail,e.output?.changed))),s=Lk(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)(Gk,{...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)(zk,{...o.size}),(0,K.jsx)(P,{className:H(`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)(Gk,{...e}):(0,K.jsx)(Kk,{text:e.text})},t))]})]})}var Yk=`Starting session`,Xk=8e3,Zk=6e4,Qk=8e3;function $k({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:g,cloning:v,error:y,reset:b,start:x}=Ic(e),S=(0,G.useRef)(null),C=_r(),w=Vc(e),T=ia(),E=Li();(0,G.useEffect)(()=>Bi(l),[e,l]);let D=Vi(T,E,w,l),O=l!==void 0&&D?.id===l,k=D!==void 0&&!O,A=l!==void 0&&D===void 0,ee=w!==null&&!w.startHook&&!k&&!A,j=k?[]:Hc(w?.commands??[]),M=Pc(j),N=k?!0:w?.gitHost??!0,P=k?!0:w?.remote??!0,ne=we(C.publish,N,P),F=k||A?void 0:w?.startFrom,re=C.startFrom?.[e]??`main`,ie=vr(),ae=t=>{let{[e]:n,...r}=C.startFrom??{};mr({startFrom:t===`local`?{...r,[e]:`local`}:r})},I=C.driver,[L,R]=(0,G.useState)(0),se=w?.address,ce=_(D?null:A?se===void 0?null:()=>bi(se,I):()=>yi(e,I),null,[e,I,D===void 0,A,se,L]),[le,ue]=(0,G.useState)(Zk),de=mn(D?()=>Se(e,D.id,I):null,null,le,[e,I,D?.id]).value,fe=D?de:ce;(0,G.useEffect)(()=>{let e=de&&de.problems.length>0?Xk:Zk;e!==le&&ue(e)},[de,le]);let pe=!D&&fe?.fix!==void 0,{state:me,reload:he}=Ns(te(I)?I:void 0,pe),_e=h[te(I)?I:`claude-code`],ve=mn(D?.owner===void 0?null:()=>Ue(D.id),null,Qk,[D?.id]).value,ye=D?.owner!==void 0&&ve?.ok?[`GitHub`,`Claude`].filter(e=>ve.logins[e===`GitHub`?`github`:`claude`]===void 0):[],be=D?ge(D):void 0,xe=(0,G.useRef)(void 0);return(0,G.useEffect)(()=>{let e=pe?me?.ready:void 0;xe.current===!1&&e===!0&&R(e=>e+1),xe.current=e},[pe,me?.ready]),(0,K.jsxs)(`form`,{onSubmit:e=>e.preventDefault(),className:`relative mx-auto w-full max-w-3xl p-2`,children:[(0,K.jsx)(bk,{ref:S,home:l,files:r,addContext:a,removeContext:o,startsAt:t?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(sl,{icon:(0,K.jsx)(ja,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),children:t}),F&&ie&&(0,K.jsx)(Sk,{main:F.main,local:F.local,pick:re,onPick:ae,busy:g})]}):null,startsAtEnd:P&&(0,K.jsx)(gk,{address:se,machineId:D?.id,on:be,busy:g,onAdd:()=>D?nl(`devices`,D.id):nl(`accounts`)}),controls:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dl,{projectId:e,context:i,busy:g,onToggle:s}),(0,K.jsx)(ll,{publish:ne,picks:oe(N,P),onPublish:e=>mr({publish:e}),cleanup:M?C.postMergeCleanup??!1:void 0,onCleanup:e=>mr({postMergeCleanup:e}),busy:g}),c&&(0,K.jsxs)(`button`,{type:`button`,onClick:c,className:ol,children:[(0,K.jsx)($a,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),(0,K.jsx)(`span`,{className:`truncate`,children:`Skills`})]})]}),onSubmit:async t=>{if(g)return;f(Yk),m(D?ge(D):A?eA():null);let r=await x(e,il(t,i),{...Mc(C),...Fc(C,j),...F&&re===`local`?{base:F.local}:{},...D?{machine:D.id}:{}});f(null),r&&(n?.(t,r.agentId,D?.label,r.projectId),S.current?.clear())},onPromptChange:e=>{!e.trim()&&u&&f(null),y&&b()},onPreset:(e,t)=>{b(),f(t?`${e} loaded over your draft — undo (⌘Z) brings the draft back`:`${e} loaded — review or edit, then Start`)},busy:g,canSubmit:!ee,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:[y&&ye.length===0&&!fe?.problems.length&&(0,K.jsx)(tA,{...nA(y)}),D&&ye.length>0&&(0,K.jsx)(tA,{title:`Your ${ye.join(` and `)} ${ye.length===1?`login is`:`logins are`} not on ${be} yet.`,detail:`Runs there use your own logins. Log ${ye.length===1?`it`:`them`} in on its page, or start your first run there from your page on ${d(D.url)??`its server`}, which copies yours.`,actions:(0,K.jsx)(B,{type:`button`,size:`xs`,onClick:()=>nl(`devices`,D.id),children:`Log in on ${be}`})}),fe?.problems.map(e=>e===fe.fix?.problem?D?fe.fix.kind===`log-in`?(0,K.jsx)(tA,{title:`${_e} is not logged in on ${be}.`,actions:(0,K.jsx)(NO,{machineId:D.id,onAccounts:()=>nl(Os)})},e):(0,K.jsx)(tA,{title:`${_e} is not installed on ${be}.`,detail:`Update ${be} to get it.`,actions:(0,K.jsx)(B,{type:`button`,size:`xs`,onClick:()=>nl(`devices`,D.id),children:`Update ${be}`})},e):(0,K.jsx)(tA,{...me&&!me.ready?{title:Hs(me),actions:(0,K.jsx)(Ks,{state:me,onChanged:()=>void he(),size:`xs`})}:nA(e)},e):(0,K.jsx)(tA,{...nA(e)},e)),fe?.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)),ee&&(0,K.jsx)(tA,{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===Yk&&!y&&(0,K.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 px-1.5 text-sm text-muted-foreground`,children:[(0,K.jsx)(Hk,{}),(0,K.jsx)(`span`,{className:`text-shimmer`,children:v&&p?`Cloning ${t??`this project`} on ${p}, the first time only`:u})]})]}),u!==Yk&&u&&!y&&(0,K.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-muted-foreground`,children:u})]})}function eA(){let e=Ac();return e===`This machine`?`this computer`:e}function tA({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)(ha,{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 nA(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 rA(e){let t=cA(e);return t.length>0&&!t.some(e=>e.kind===`end`)}function iA(e){let t=cA(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 aA(e){if(e!==`running`)return{ok:e===`done`,stopped:e===`stopped`,...e===`waiting`?{waiting:!0}:{}}}function oA(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 sA(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 cA(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 lA(e){let t=e?.sessionLink,n=e?.sessionId;return!t||!n||!t.includes(n)?null:{href:t,label:`Open session (${n}) ↗`}}function uA(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 dA(){return _(()=>Zn(),[],[])}function fA(e){let t=dA();return e&&!t.some(t=>t.bin===e)?[...t,{bin:e,label:e}]:t}function pA({busy:e}){let t=_r().editor,n=fA(t);return(0,K.jsxs)(Je,{children:[(0,K.jsx)(c,{children:`Preferred editor`}),(0,K.jsxs)(z,{disabled:e,closeOnClick:!1,onClick:()=>mr({editor:``}),className:`items-start`,children:[(0,K.jsx)(Ve,{className:H(`mt-0.5 h-3.5 w-3.5 shrink-0`,t?`opacity-0`:`opacity-100`)}),(0,K.jsx)(Me,{label:`Default`,description:`$OPENAGENT_EDITOR, or code`})]}),n.map(n=>(0,K.jsxs)(z,{disabled:e,closeOnClick:!1,onClick:()=>mr({editor:n.bin}),className:`items-start`,children:[(0,K.jsx)(Ve,{className:H(`mt-0.5 h-3.5 w-3.5 shrink-0`,t===n.bin?`opacity-100`:`opacity-0`)}),(0,K.jsx)(Me,{label:n.label,description:n.bin})]},n.bin))]})}var mA=`font-medium text-foreground`;function hA({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}=ln();(0,G.useEffect)(()=>{t&&(a(!1),d())},[t,d]);let f=()=>{n(!1),queueMicrotask(r)};return(0,K.jsx)(ut,{open:t,onOpenChange:e=>{c||o||n(e)},children:(0,K.jsxs)(ze,{children:[(0,K.jsx)(M,{className:`fixed inset-0 z-50 bg-black/40 backdrop-blur-[1px]`}),(0,K.jsx)(ne,{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)(Cn,{className:`text-sm font-semibold`,children:`Project removed`}),(0,K.jsx)(Fe,{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)(gA,{title:`Deleted`,empty:`Nothing: there was nothing of OpenAgent’s to delete.`,lines:o.removed}),o.kept.length>0&&(0,K.jsx)(gA,{title:`Kept`,lines:o.kept.map(e=>`${e.path}: ${e.reason}`)}),o.failed.length>0&&(0,K.jsx)(gA,{title:`Could not be cleaned`,lines:o.failed,danger:!0}),(0,K.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,K.jsx)(B,{size:`sm`,onClick:f,children:`Done`})})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Cn,{className:`text-sm font-semibold`,children:`Remove this project?`}),(0,K.jsxs)(Fe,{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:mA,children:`.openagent`}),`, `,(0,K.jsx)(`span`,{className:mA,children:`.branches`}),`,`,` `,(0,K.jsx)(`span`,{className:mA,children:`.agent-runner`}),` and the branch `,(0,K.jsx)(`span`,{className:mA,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)(zt,{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:mA,children:`.branches`}),`, the folders`,` `,(0,K.jsx)(`span`,{className:mA,children:`.openagent`}),` (with `,(0,K.jsx)(`span`,{className:mA,children:`hooks.yml`}),`, the project’s start lines) and`,` `,(0,K.jsx)(`span`,{className:mA,children:`.agent-runner`}),`, and the local branch `,(0,K.jsx)(`span`,{className:mA,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:mA,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:mA,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:mA,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)(He,{render:(0,K.jsx)(B,{variant:`outline`,size:`sm`,disabled:c,children:`Cancel`})}),(0,K.jsx)(B,{variant:`destructive`,size:`sm`,disabled:c,onClick:()=>{u(()=>pi(e,i),`Could not remove the project.`).then(e=>{if(!e.ok)return;let t=e.value.cleanup;t?s(t):f()})},className:H(c&&`cursor-progress`),children:c?`Removing…`:i?`Remove and delete`:`Remove`})]})]})})]})})}function gA({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:H(`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 _A({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=rA(n),f=In(n),p=lA(f),m=d||i,h=uA(f),[g,y]=(0,G.useState)(!1),b=(0,G.useRef)(void 0);(0,G.useEffect)(()=>()=>clearTimeout(b.current),[]);let x=()=>{h&&navigator.clipboard?.writeText(h).then(()=>{y(!0),clearTimeout(b.current),b.current=setTimeout(()=>y(!1),1500)})},[S,C]=(0,G.useState)(0),w=_(()=>zr(e),null,[e,S],`previous`),T=_(u?null:()=>Br(e),null,[e,u,S]),[E,D]=(0,G.useState)(!1),[O,k]=(0,G.useState)(0),A=_(u?null:()=>mi(e),null,[e,u,S,O],`previous`),[ee,j]=(0,G.useState)(!1),[M,N]=(0,G.useState)(!1),P=()=>void F(()=>hi(e,!1),`Could not stop sharing.`).then(e=>{e.ok&&k(e=>e+1)}),{busy:te,error:ne,run:F}=ln(),[re,ie]=(0,G.useState)(!1);(0,G.useEffect)(()=>ie(!1),[t]);let ae=te||re&&d,[L,R]=(0,G.useState)(!1),oe=n=>F(()=>ri(e,n,t??void 0),`Failed to open.`),se=()=>void F(()=>Jr(e,t??void 0),`Could not stop the session.`).then(e=>{e.ok&&ie(!0)}),ce=()=>{t&&F(()=>ei(e,t),`Could not remove the worktree.`).then(e=>{e.ok&&a?.()})},le=r?.trim()||t,ue=u?`Session actions`:`Project actions`,de=i&&!d&&!!t,fe=!!o&&!d&&!!t,pe=w&&(0,K.jsxs)(z,{render:(0,K.jsx)(`a`,{href:w.url,target:`_blank`,rel:`noreferrer`}),children:[(0,K.jsx)(Ta,{className:`h-3.5 w-3.5 shrink-0`}),` Open on `,w.name]});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(I,{children:[u?(0,K.jsxs)(Et,{type:`button`,"aria-label":ue,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)(Pe,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}):(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(Et,{type:`button`,"aria-label":ue,className:v({variant:`outline`,size:`icon-sm`})}),children:(0,K.jsx)(wa,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(W,{children:ue})]}),(0,K.jsxs)(We,{align:u?`start`:`end`,className:`min-w-[14rem]`,children:[c&&(0,K.jsxs)(z,{onClick:c.onToggle,children:[(0,K.jsx)(Va,{className:`h-3.5 w-3.5 shrink-0`}),` `,c.open?`Hide details`:`Show details`]}),!u&&pe,T&&(0,K.jsxs)(z,{onClick:()=>D(!0),children:[(0,K.jsx)(xa,{className:`h-3.5 w-3.5 shrink-0`}),` Create a repository on `,T.name,`…`]}),A===`kept`&&(0,K.jsxs)(z,{onClick:()=>j(!0),children:[(0,K.jsx)(xa,{className:`h-3.5 w-3.5 shrink-0`}),` Share the agents’ records to the remote…`]}),A===`origin`&&(0,K.jsxs)(z,{disabled:te,onClick:P,children:[(0,K.jsx)(ba,{className:`h-3.5 w-3.5 shrink-0`}),` Stop sharing the agents’ records`]}),(0,K.jsxs)(z,{disabled:te,onClick:()=>void oe(`files`),title:t&&!m?`This session no longer has its own checkout`:void 0,children:[(0,K.jsx)(Oa,{className:`h-3.5 w-3.5 shrink-0`}),` `,t?m?`Open session's folder`:`Open project folder`:`Open folder`]}),(0,K.jsxs)(on,{children:[(0,K.jsxs)(en,{disabled:te,children:[(0,K.jsx)(Ca,{className:`h-3.5 w-3.5 shrink-0`}),` Open in editor`]}),(0,K.jsxs)(Ut,{className:`min-w-[15rem]`,children:[(0,K.jsxs)(z,{disabled:te,onClick:()=>void oe(`editor`),children:[(0,K.jsx)(Ca,{className:`h-3.5 w-3.5 shrink-0`}),` `,t?`Open this session's checkout`:`Open in your editor`]}),(0,K.jsx)(dt,{}),(0,K.jsx)(pA,{busy:te})]})]}),u&&pe,p&&(0,K.jsxs)(z,{render:(0,K.jsx)(`a`,{href:p.href,target:`_blank`,rel:`noreferrer`}),children:[(0,K.jsx)(Ta,{className:`h-3.5 w-3.5 shrink-0`}),` `,p.label.replace(` ↗`,``)]}),h&&f?.sessionId&&(0,K.jsxs)(z,{closeOnClick:!1,onClick:x,title:h,children:[g?(0,K.jsx)(Ve,{className:`h-3.5 w-3.5 shrink-0 text-success`}):(0,K.jsx)(Le,{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||de||fe)&&(0,K.jsx)(dt,{}),d&&(0,K.jsxs)(z,{disabled:ae,onClick:()=>void se(),children:[(0,K.jsx)(io,{className:`h-3 w-3 shrink-0 fill-current`}),` `,ae?`Stopping…`:`Stop agent`]}),de&&(0,K.jsxs)(z,{disabled:te,onClick:()=>ce(),children:[(0,K.jsx)(Aa,{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})]}),fe&&(0,K.jsxs)(z,{onClick:()=>R(!0),className:`text-danger`,children:[(0,K.jsx)(oo,{className:`h-3.5 w-3.5 shrink-0`}),` Delete session`]}),s&&!u&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dt,{}),(0,K.jsxs)(z,{onClick:()=>N(!0),className:`text-danger`,children:[(0,K.jsx)(oo,{className:`h-3.5 w-3.5 shrink-0`}),` Remove project…`]})]}),ne&&(0,K.jsx)(`p`,{className:`px-2 py-1.5 text-xs text-danger`,children:ne})]})]}),T&&(0,K.jsx)(dn,{open:E,onOpenChange:D,title:`Create a private repository on ${T.name}?`,body:(0,K.jsxs)(K.Fragment,{children:[`This creates the private repository `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:T.repository}),` on your`,` `,T.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:()=>ci(e),onSuccess:()=>C(e=>e+1)}),A===`kept`&&(0,K.jsx)(dn,{open:ee,onOpenChange:j,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:()=>hi(e,!0),onSuccess:()=>k(e=>e+1)}),s&&!u&&(0,K.jsx)(hA,{projectId:e,open:M,onOpenChange:N,onRemoved:s}),o&&t&&(0,K.jsx)(dn,{open:L,onOpenChange:R,title:`Delete this agent?`,body:(0,K.jsxs)(K.Fragment,{children:[`Deleting `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:le}),` 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:()=>ti(e,t),onSuccess:o})]})}function vA({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)(B,{variant:`ghost`,size:`sm`,className:H(`h-7 text-xs`,t===n&&`bg-accent text-accent-foreground`),onClick:()=>r(t),children:e.name},e.name))}),(0,K.jsx)(Qe,{className:`min-h-0 flex-auto`,children:(0,K.jsx)(`div`,{className:`p-4`,children:(0,K.jsx)(Qt,{text:i.content})})})]})}var yA=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 bA({package:e,label:t,children:n}){let r=et(e);return(0,K.jsx)(an.Provider,{value:r,children:(0,K.jsx)(yA,{label:t,children:n})})}function xA(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 SA({page:e,projects:t,projectId:n,path:r}){let i=e.Page;return(0,K.jsx)(bA,{package:e.package,label:`${e.label} page`,children:(0,K.jsx)(i,{projects:xA(e.projects,t),projectId:n,path:r})},e.segment)}function CA(e){let t=(0,G.useId)();return`${e??t}`}var wA=typeof window<`u`?G.useLayoutEffect:G.useEffect;function TA(e){let t=(0,G.useRef)(e);return wA(()=>{t.current=e},[e]),(0,G.useCallback)((...e)=>t.current?.(...e),[t])}function EA(...e){return TA(t=>{e.forEach(e=>{if(e)switch(typeof e){case`function`:e(t);break;case`object`:e.current=t;break}})})}function DA(e,t){return t?e*2+1:e+1}function OA(e,t){return t?e*2-1:e}function kA(e,t,n){let r=DA(e,n);return t===void 0?`${r} / -1`:`${r} / span ${OA(t,n)}`}function AA(e){return`${e*2} / span 1`}function jA({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=DA(n,r),o=DA(i-1,r)+1;return r&&(n>0&&a--,i<e&&o++),`${a} / ${o}`}function MA(e,t){return Number.isInteger(e)&&e>=1&&e<t}function NA(e,t=`Assertion error`){if(!e)throw Error(t)}var PA=(0,G.createContext)(null);function FA(){let e=(0,G.useContext)(PA);return NA(e,`Grid Context not found; did you render a Cell or Gridline outside of a Grid?`),e}function IA({children:e,className:t,column:n,columnSpan:r=1,elementRef:i,id:a,row:o,rowSpan:s=1,style:c,...l}){let u=CA(a),{gutters:d,registerCell:f}=FA(),p=(0,G.useRef)(null),m=EA(p,i);return wA(()=>{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:kA(n,r,d.column),gridRow:kA(o,s,d.row)},children:e})}IA.displayName=`Cell`;var LA;function RA(){return LA===void 0&&(LA=typeof matchMedia==`function`&&!!matchMedia(`(pointer:coarse)`).matches),LA}function zA({expandHitTargets:e,axis:t,rect:n}){let r=e?RA()?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 BA({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 VA({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=zA({expandHitTargets:r,axis:i,rect:l}),o?h.push(g(c.index,l,a)):BA({axis:e,cells:t,index:c.index,rect:l}).forEach(e=>{h.push(g(c.index,e,a))})}let y=(n,a)=>{BA({axis:e,cells:t,index:n,rect:zA({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 HA(e){let t=parseFloat(e??``);return Number.isFinite(t)?t:0}function UA({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)=>HA(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`?HA(c?.paddingLeft)+HA(c?.paddingRight)+HA(c?.borderLeftWidth)+HA(c?.borderRightWidth):HA(c?.paddingTop)+HA(c?.paddingBottom)+HA(c?.borderTopWidth)+HA(c?.borderBottomWidth),f=HA(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 WA(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 GA=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)}}},KA={cursorFlags:0,state:`inactive`},qA=new GA;function JA(){return KA}function YA(e){return qA.addListener(`change`,e)}function XA(e,t=[],n,r=!1){let i=KA,a={...KA};a.cursorFlags=e,a.state===`active`&&(a.didPointerMove||=r,a.previews=t,n&&(a.previewLayoutMap=n)),KA=a,qA.emit(`change`,{prev:i,next:a})}function ZA(e){let t=KA;KA=e,t.state===`active`&&e.state!==`active`&&t.didPointerMove&&t.hitRegions.forEach(({separator:e})=>{e&&e.element.ownerDocument.activeElement===e.element&&e.element.blur()}),qA.emit(`change`,{prev:t,next:e})}function QA(e){KA.state!==`active`||!KA.previews.some(t=>t.separator===e)||ZA({...KA,previews:KA.previews.map(t=>t.separator===e?{...t}:t)})}function $A(e){if(KA.state===`inactive`)return!1;let t=KA.hitRegions.filter(t=>t.axis!==e),n=KA.state===`active`&&KA.previews.some(t=>t.axis===e);if(t.length===KA.hitRegions.length&&!n)return!1;if(t.length===0)ZA({cursorFlags:0,state:`inactive`});else if(KA.state===`active`){let n=new Map(KA.initialLayoutMap),r=new Map(KA.previewLayoutMap);n.delete(e),r.delete(e),ZA({...KA,cursorFlags:0,hitRegions:t,initialLayoutMap:n,previewLayoutMap:r,previews:KA.previews.filter(t=>t.axis!==e)})}else ZA({...KA,hitRegions:t});return!0}var ej=e=>e,tj=()=>{},nj=1,rj=2,ij=4,aj=8,oj=3,sj=12,cj;function lj(){return cj===void 0&&(cj=!1,typeof window<`u`&&(window.navigator.userAgent.includes(`Chrome`)||window.navigator.userAgent.includes(`Firefox`))&&(cj=!0)),cj}function uj({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&&lj()){let t=(e&nj)!==0,n=(e&rj)!==0,r=(e&ij)!==0,i=(e&aj)!==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 lj()?r>0&&i>0?`move`:r>0?`ew-resize`:`ns-resize`:r>0&&i>0?`grab`:r>0?`col-resize`:`row-resize`}}var dj=new WeakMap;function fj(e){if(!e.defaultView||!e.adoptedStyleSheets)return;let{prevStyle:t,styleSheet:n}=dj.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=JA();switch(r.state){case`active`:case`hover`:{let e=uj({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}dj.set(e,{prevStyle:t,styleSheet:n})}function pj({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 mj(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 hj(e,t){return Array.from(t).sort((t,n)=>{let r=e===`horizontal`?gj(t,n):_j(t,n);return r===0?mj(t.element,n.element):r})}function gj(e,t){let n=e.element.offsetLeft-t.element.offsetLeft;return n===0?e.element.offsetWidth-t.element.offsetWidth:n}function _j(e,t){let n=e.element.offsetTop-t.element.offsetTop;return n===0?e.element.offsetHeight-t.element.offsetHeight:n}function vj(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.ELEMENT_NODE}function yj(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 bj({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}=yj(r,n),s=e===`horizontal`?t:o;s<a&&(a=s,i=n)}return NA(i,`No rect found`),i}function xj({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=hj(i,Array.from(r.children).filter(vj).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,bj({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=zA({expandHitTargets:e,axis:t,rect:`width`in i?i:i.element.getBoundingClientRect()});(n||!l&&!(r<=d||r>p))&&(f??=pj({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 Sj(e,t){let n=getComputedStyle(e);return t*parseFloat(n.fontSize)}function Cj(e,t){let n=getComputedStyle(e.ownerDocument.documentElement);return t*parseFloat(n.fontSize)}function wj(e){return e/100*window.innerHeight}function Tj(e){return e/100*window.innerWidth}function Ej({axisSize:e,itemElement:t,styleProp:n}){let r,[i,a]=WA(n);switch(a){case`%`:r=i/100*e;break;case`px`:r=i;break;case`rem`:r=Cj(t,i);break;case`em`:r=Sj(t,i);break;case`vh`:r=wj(i);break;case`vw`:r=Tj(i);break}return r}function Dj(e){return parseFloat(e.toFixed(3))}function Oj(e){let{items:t}=e,n=pj({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=Dj(Ej({axisSize:n,itemElement:t,styleProp:r.collapsedSize})/n*100));let a;r.collapsedThreshold!==void 0&&(a=Dj(Ej({axisSize:n,itemElement:t,styleProp:r.collapsedThreshold})/n*100));let o;r.defaultSize!==void 0&&(o=Dj(Ej({axisSize:n,itemElement:t,styleProp:r.defaultSize})/n*100));let s=0;r.minSize!==void 0&&(s=Dj(Ej({axisSize:n,itemElement:t,styleProp:r.minSize})/n*100));let c=100;return r.maxSize!==void 0&&(c=Dj(Ej({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 kj=new Map,Aj=new GA;function jj(e){kj=new Map(kj),kj.delete(e)}function Mj(e,t){for(let[t]of kj)if(t.id===e)return t}function Nj(e,t){for(let[t,n]of kj)if(t.id===e)return n;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Pj(){return kj}function Fj(e,t){return Aj.addListener(`axisChange`,n=>{n.axis.id===e&&t(n)})}function Ij(e,t,n){let r=kj.get(e);kj=new Map(kj),kj.set(e,t),Aj.emit(`axisChange`,{axis:e,isUserInteraction:n?.isUserInteraction===!0,prev:r,next:t})}function Lj(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 Rj(e,t,n=0){return Math.abs(Dj(e)-Dj(t))<=n}function zj(e,t){return Rj(e,t)?0:e>t?1:-1}function Bj({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(zj(r,l)<0)if(o){let e=a??(l-i)/2,t=zj(n,i)<=0,o=t?i+e:l-e,s=zj(r,o);r=zj(r,i)<=0||s<0||a!==void 0&&t&&s===0?i:l}else r=l;return r=Math.min(c,r),r=Dj(r),r}function Vj({delta:e,initialLayout:t,itemConstraints:n,pivotIndices:r,prevLayout:i,trigger:a}){if(Rj(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;NA(u!=null,`Invalid first pivot index`),NA(d!=null,`Invalid second pivot index`);let f=0;switch(a){case`keyboard`:{let t=e<0?d:u,r=n[t];NA(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(NA(n!=null,`Previous layout not found for panel index ${t}`),Rj(n,i)){let t=o-n;zj(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{let t=e<0?u:d,r=n[t];NA(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(NA(n!=null,`Previous layout not found for panel index ${t}`),Rj(n,o)){let t=n-i;zj(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}break;default:{let t=e<0?d:u,r=n[t];NA(r,`Panel constraints not found for index ${t}`);let i=s[t],{collapsedSize:a,collapsedThreshold:o,collapsible:c,minSize:l}=r;if(c&&zj(i,l)<0){let t=l-a,n=o??t/2;if(zj(i+Math.abs(e),l)<0){let r=zj(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];NA(e!=null,`Previous layout not found for panel index ${r}`);let a=Bj({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];NA(i!=null,`Previous layout not found for panel index ${t}`);let a=i-r,c=Bj({overrideDisabledItems:o,itemConstraints:n[t],prevSize:i,size:a});if(!Rj(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(Lj(c,l))return i;{let t=e<0?d:u,r=s[t];NA(r!=null,`Previous layout not found for panel index ${t}`);let i=r+f,a=Bj({overrideDisabledItems:o,itemConstraints:n[t],prevSize:r,size:i});if(l[t]=a,!Rj(a,i)){let t=i-a,r=e<0?d:u;for(;r>=0&&r<n.length;){let i=l[r];NA(i!=null,`Previous layout not found for panel index ${r}`);let a=i+t,s=Bj({overrideDisabledItems:o,itemConstraints:n[r],prevSize:i,size:a});if(Rj(i,s)||(t-=s-i,l[r]=s),Rj(t,0))break;e>0?r--:r++}}}return Rj(Object.values(l).reduce((e,t)=>t+e,0),100,.1)?l.reduce((e,t,r)=>(e[n[r].itemId]=t,e),{}):i}function Hj(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let n in e)if(t[n]===void 0||zj(e[n],t[n])!==0)return!1;return!0}function Uj({commit:e,document:t,event:n,hitRegions:r,initialLayoutMap:i,mountedAxes:a,pointerDownAtPoint:o,prevCursorFlags:s}){let c=0,l=JA(),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=Vj({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&&!Hj(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(Hj(i,n)&&m!==0&&!p)switch(l){case`horizontal`:c|=m<0?nj:rj;break;case`vertical`:c|=m<0?ij:aj;break}(r.resizePreviewMode!==`separator`||e)&&!Hj(i,b)&&Ij(t.axis,{defaultLayoutDeferred:_,derivedItemConstraints:v,axisSize:y,layout:i,requestedAxisSize:y,requestedLayout:i,separatorToItems:x})}});let f=0;n.movementX===0?f|=s&oj:f|=c&oj,n.movementY===0?f|=s&sj:f|=c&sj;let p=l.state===`active`&&(n.clientX!==l.pointerDownAtPoint.x||n.clientY!==l.pointerDownAtPoint.y);XA(f,u,d,p),fj(t)}function Wj(e,t){let n=JA(),r=Pj(),i=!1;switch(n.state){case`active`:Uj({commit:!0,document:e,event:t,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:r,pointerDownAtPoint:n.pointerDownAtPoint,prevCursorFlags:n.cursorFlags}),ZA({cursorFlags:0,state:`inactive`}),n.hitRegions.length>0&&(fj(e),i=!0,n.hitRegions.forEach(e=>{if(!r.has(e.axis))return;let t=Nj(e.axis.id,!0);Ij(e.axis,t,{isUserInteraction:!0})}))}return i}function Gj(e){e.defaultPrevented||Wj(e.currentTarget,e)}function Kj(e,t,n){let r,i={x:1/0,y:1/0};for(let a of t){let t=yj(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 qj(e){return typeof e==`object`&&!!e&&`nodeType`in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Jj(e,t){if(e===t)throw Error(`Cannot compare node with itself`);let n={a:eM(e),b:eM(t)},r;for(;n.a.at(-1)===n.b.at(-1);)r=n.a.pop(),n.b.pop();NA(r,`Stacking order can only be calculated for elements with a common ancestor`);let i={a:$j(Qj(n.a)),b:$j(Qj(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 Yj=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Xj(e){let t=getComputedStyle(tM(e)??e).display;return t===`flex`||t===`inline-flex`}function Zj(e){let t=getComputedStyle(e);return!!(t.position===`fixed`||t.zIndex!==`auto`&&(t.position!==`static`||Xj(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`||Yj.test(t.willChange)||t.webkitOverflowScrolling===`touch`)}function Qj(e){let t=e.length;for(;t--;){let n=e[t];if(NA(n,`Missing node`),Zj(n))return n}return null}function $j(e){return e&&Number(getComputedStyle(e).zIndex)||0}function eM(e){let t=[];for(;e;)t.push(e),e=tM(e);return t}function tM(e){let{parentNode:t}=e;return qj(t)?t.host:t}function nM(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 rM(e){try{return e.matches(`:modal`)}catch{return!1}}function iM({axisElement:e,hitRegion:t,pointerEventTarget:n}){if(vj(n)){let t=n.closest(`dialog`);if(t&&!t.contains(e)&&rM(t))return!1}if(!vj(n)||n.contains(e)||e.contains(n))return!0;if(Jj(n,e)>0){let r=n;for(;r;){if(r.contains(e))return!0;if(nM(r.getBoundingClientRect(),t))return!1;r=r.parentElement}}return!0}function aM(e,t){let n=[];return t.forEach((t,r)=>{if(r.disabled)return;let i=xj({axis:r}),a=Kj(r.orientation,i,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&iM({axisElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&n.push(a.hitRegion)}),n}function oM({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(!Rj(i,100)&&r.length>0)for(let e=0;e<t.length;e++){let t=r[e];NA(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];NA(i!=null,`No layout data found for index ${e}`);let o=r[e];NA(o!=null,`No layout data found for index ${e}`);let s=Bj({overrideDisabledItems:!0,itemConstraints:t[e],prevSize:i,size:o});o!=s&&(a+=o-s,r[e]=s)}if(!Rj(a,0))for(let e=0;e<t.length;e++){let n=r[e];NA(n!=null,`No layout data found for index ${e}`);let i=n+a,o=Bj({overrideDisabledItems:!0,itemConstraints:t[e],prevSize:n,size:i});if(n!==o&&(a-=o-n,r[e]=o,Rj(a,0)))break}return r.reduce((e,n,r)=>(e[t[r].itemId]=n,e),{})}function sM({axisId:e,itemId:t}){let n=()=>{let t=Pj();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&&Rj(n.collapsedSize,r[n.itemId])}))){let e=n.slice(0,s).reduce((e,t)=>e+r[t.id],0);return{...r,[t]:Dj(100-e)}}return Vj({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=oM({layout:o({nextSize:e,items:i.items,prevLayout:c,derivedItemConstraints:r}),itemConstraints:r});Hj(c,u)||Ij(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&&Rj(t,n)},resize:e=>{let{axis:t}=n(),{element:r}=i(),a=pj({axis:t}),o=Dj(Ej({axisSize:a,itemElement:r,styleProp:e})/a*100);s(o)}}}function cM(e){e.defaultPrevented||aM(e,Pj()).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=sM({axisId:t.axis.id,itemId:n.id});i&&r!==void 0&&(i.resize(r),e.preventDefault())}}})}function lM(e){let t=Pj();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 uM({axisId:e}){let t=()=>{let t=Pj();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=oM({layout:e,itemConstraints:r});return n?o:(Hj(o,c)||Ij(i,{defaultLayoutDeferred:n,derivedItemConstraints:r,axisSize:a,layout:c,requestedAxisSize:a,requestedLayout:c,separatorToItems:s}),c)}}}function dM(e,t){let n=lM(e),r=Nj(n.id,!0),i=n.separators.find(t=>t.element===e);NA(i,`Matching separator not found`);let a=r.separatorToItems.get(i);NA(a,`Matching panels not found`);let o=a.map(e=>n.items.indexOf(e)),s=uM({axisId:n.id}).getLayout(),c=oM({layout:Vj({delta:t,initialLayout:s,itemConstraints:r.derivedItemConstraints,pivotIndices:o,prevLayout:s,trigger:`keyboard`}),itemConstraints:r.derivedItemConstraints});Hj(s,c)||Ij(n,{defaultLayoutDeferred:r.defaultLayoutDeferred,derivedItemConstraints:r.derivedItemConstraints,axisSize:r.axisSize,layout:c,requestedAxisSize:r.axisSize,requestedLayout:c,separatorToItems:r.separatorToItems},{isUserInteraction:!0})}function fM(e){if(e.defaultPrevented)return;let t=e.currentTarget,n=lM(t);if(!(n.disabled||n.separators.find(e=>e.element===t)?.disabled))switch(e.key){case`ArrowDown`:e.preventDefault(),n.orientation===`vertical`&&dM(t,5);break;case`ArrowLeft`:e.preventDefault(),n.orientation===`horizontal`&&dM(t,-5);break;case`ArrowRight`:e.preventDefault(),n.orientation===`horizontal`&&dM(t,5);break;case`ArrowUp`:e.preventDefault(),n.orientation===`vertical`&&dM(t,-5);break;case`End`:e.preventDefault(),dM(t,100);break;case`Enter`:{e.preventDefault();let{derivedItemConstraints:r,layout:i,separatorToItems:a}=Nj(n.id,!0),o=n.separators.find(e=>e.element===t);NA(o,`Matching separator not found`);let s=a.get(o);NA(s,`Matching panels not found`);let c=s[0],l=r.find(e=>e.itemId===c.id);if(NA(l,`Panel metadata not found`),l.collapsible){let e=i[c.id];dM(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);NA(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(),dM(t,-100);break}}function pM(e,t){let{element:n,orientation:r,items:i}=e,a=n.getBoundingClientRect(),o=r===`horizontal`;return xj({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 Rj(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 mM(e){if(e.defaultPrevented||e.pointerType===`mouse`&&e.button>0)return;let t=Pj(),n=aM(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`?pM(e,n):[]);ZA({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 hM(e){let t=Pj(),n=JA();switch(n.state){case`active`:Uj({commit:!1,document:e.currentTarget,event:e,hitRegions:n.hitRegions,initialLayoutMap:n.initialLayoutMap,mountedAxes:t,prevCursorFlags:n.cursorFlags})}}function gM(e){if(e.defaultPrevented)return;let t=JA(),n=Pj();switch(t.state){case`active`:if(e.buttons===0){t.previewLayoutMap.forEach((e,t)=>{let r=n.get(t);t.resizePreviewMode===`separator`&&r&&!Hj(e,r.layout)&&Ij(t,{...r,layout:e,requestedAxisSize:r.axisSize,requestedLayout:e})}),ZA({cursorFlags:0,state:`inactive`}),t.hitRegions.forEach(e=>{if(!n.has(e.axis))return;let t=Nj(e.axis.id,!0);Ij(e.axis,t,{isUserInteraction:!0})}),fj(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)}Uj({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=aM(e,n);r.length===0?t.state!==`inactive`&&ZA({cursorFlags:0,state:`inactive`}):ZA({cursorFlags:0,hitRegions:r,state:`hover`}),fj(e.currentTarget);break}}}function _M(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(JA().state){case`hover`:ZA({cursorFlags:0,state:`inactive`})}}function vM(e){e.defaultPrevented||e.pointerType===`mouse`&&e.button>0||Wj(e.currentTarget,e)&&e.preventDefault()}function yM(e){let t=0,n=0,r={};for(let i of e)if(i.defaultSize!==void 0){t++;let e=Dj(i.defaultSize);n+=e,r[i.itemId]=e}else r[i.itemId]=void 0;let i=e.length-t;if(i!==0){let t=Dj((100-n)/i);for(let n of e)n.defaultSize===void 0&&(r[n.itemId]=t)}return r}function bM(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 xM({axis:e,itemConstraints:t}){let n=e.items.map(({id:e})=>e).join(`,`),r=e.mutableState.defaultLayout;return e.mutableState.layouts[n]??(r&&bM(e.items,r)?r:yM(t))}function SM({itemIds:e,layout:t}){return oM({layout:t,itemConstraints:e.map(e=>({collapsedSize:0,collapsible:!1,defaultSize:void 0,disabled:void 0,itemId:e,maxSize:100,minSize:0}))})}function CM(e,t,n){if(!n[0])return;let r=e.items.find(e=>e.element===t);if(!r||!r.onResize)return;let i=pj({axis:e}),a=e.orientation===`horizontal`?r.element.offsetWidth:r.element.offsetHeight,o=r.mutableValues.prevSize,s={asPercentage:Dj(a/i*100),inPixels:a};r.mutableValues.prevSize=s,r.onResize(s,r.id,o)}function wM(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 TM(e,t){return e.length===t.length&&e.every((e,n)=>wM(e,t[n]))}function EM({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=Dj(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]=Dj((r[e]??0)/a*l);else{let e=Dj(l/c.length);for(let t of c)u[t]=e}return u}var DM=new Map;function OM(e){let t=!0;NA(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=pj({axis:e});if(t===0)return;let n=Nj(e.id);if(!n)return;let r=Oj(e),i=n.requestedAxisSize,a=n.requestedLayout;n.defaultLayoutDeferred&&(i=t,a=SM({itemIds:e.items.map(({id:e})=>e),layout:xM({axis:e,itemConstraints:r})}));let o=oM({layout:EM({axis:e,nextAxisSize:t,prevAxisSize:i,prevLayout:a}),itemConstraints:r});if(!n.defaultLayoutDeferred&&Hj(n.layout,o)&&TM(n.derivedItemConstraints,r)&&n.axisSize===t)continue;Ij(e,{defaultLayoutDeferred:!1,derivedItemConstraints:r,axisSize:t,layout:o,requestedAxisSize:i,requestedLayout:a,separatorToItems:n.separatorToItems})}}else CM(e,i,n)}});a.observe(e.element),e.items.forEach(e=>{NA(!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=pj({axis:e}),s=Oj(e),c=xM({axis:e,itemConstraints:s}),l=oM({layout:c,itemConstraints:s}),u=e.element.ownerDocument;DM.set(u,(DM.get(u)??0)+1);let d=new Map;return xj({axis:e,includeDisabled:!0}).forEach(e=>{e.separator&&d.set(e.separator,e.items)}),Ij(e,{defaultLayoutDeferred:o===0,derivedItemConstraints:s,axisSize:o,layout:l,requestedAxisSize:o,requestedLayout:SM({itemIds:e.items.map(({id:e})=>e),layout:c}),separatorToItems:d}),e.separators.forEach(e=>{NA(!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`,fM)}),DM.get(u)===1&&(u.addEventListener(`contextmenu`,Gj,!0),u.addEventListener(`dblclick`,cM,!0),u.addEventListener(`pointerdown`,mM,!0),u.addEventListener(`pointerleave`,hM),u.addEventListener(`pointermove`,gM),u.addEventListener(`pointerout`,_M),u.addEventListener(`pointerup`,vM,!0)),function(){t=!1,DM.set(u,Math.max(0,(DM.get(u)??0)-1)),jj(e),$A(e)&&fj(u),e.separators.forEach(e=>{e.element.removeEventListener(`keydown`,fM)}),DM.get(u)||(u.removeEventListener(`contextmenu`,Gj,!0),u.removeEventListener(`dblclick`,cM,!0),u.removeEventListener(`pointerdown`,mM,!0),u.removeEventListener(`pointerleave`,hM),u.removeEventListener(`pointermove`,gM),u.removeEventListener(`pointerout`,_M),u.removeEventListener(`pointerup`,vM,!0)),a.disconnect()}}function kM({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=Rj(e.collapsedSize,n[e.itemId]),a=Rj(e.collapsedSize,r[e.itemId]);i&&!a&&(t.mutableState.expandedItemSizes[e.itemId]=r[e.itemId])}})}function AM(){let[e,t]=(0,G.useState)({});return[e,(0,G.useCallback)(()=>t({}),[])]}function jM(e){let t=(0,G.useRef)({...e});return wA(()=>{for(let n in e)t.current[n]=e[n]},[e]),t.current}var MM=(0,G.createContext)(null);function NM({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=oM({layout:Vj({delta:l-o,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n],i=oM({layout:Vj({delta:c-o,initialLayout:e,itemConstraints:t,pivotIndices:u,prevLayout:e}),itemConstraints:t})[n]}return{valueControls:n,valueMax:i,valueMin:a,valueNow:o}}function PM({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=jM({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=EA(T,c),O=n===`horizontal`?`vertical`:`horizontal`;wA(()=>{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=YA(e=>{S(e.next.state!==`inactive`&&e.next.hitRegions.some(e=>e.separator===n||(u?.(e)??!1))?e.next.state:`inactive`)}),a=Fj(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({...NM({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]),wA(()=>{let e=E.current;e&&QA(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 FM({axis:e,children:t,className:n,crossSpan:r,crossStart:i,disabled:a,elementRef:o,index:s,style:c}){let l=CA(void 0),{getDisableCursor:u,getResizeAxisId:d,gutters:f,registerSeparator:p,separatorPlacements:m,trackCounts:h,updateSeparatorProps:g}=FA(),_=d(e),v=e===`column`?`row`:`column`,y=h[v],b=!!a||!MA(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=AA(s),T=jA({crossCount:y,crossSpan:r,crossStart:i,hasGutters:f[v]});return(0,K.jsx)(PM,{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 IM(e){let{children:t,className:n,disabled:r,elementRef:i,style:a}=e;return e.type===`column`?(0,K.jsx)(FM,{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)(FM,{axis:`row`,className:n,crossSpan:e.columnSpan,crossStart:e.column??0,disabled:r,elementRef:i,index:e.row,style:a,children:t})}IM.displayName=`Gridline`;var LM=[`column`,`row`],RM={columns:{},rows:{}};function zM({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=CA(c),g=(0,G.useCallback)(e=>e===`column`?`${h}:columns`:`${h}:rows`,[h]),_=BM(n,`columns`),v=BM(f,`rows`),y=e=>e===`column`?_:v,b=(0,G.useRef)({onLayoutChange:RM,onLayoutChanged:RM}),x=TA(e=>{WM(b.current.onLayoutChange,e)||(b.current.onLayoutChange=e,l?.(e))}),S=TA((e,t,n)=>{WM(b.current.onLayoutChanged,e)||(b.current.onLayoutChanged=e,u?.(e,{isUserInteraction:t,requestedLayout:n}))}),C=(0,G.useRef)(null),w=EA(C,o),[T,E]=AM(),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;VM(e,O);let k=jM({defaultLayout:r,disableCursor:i,resizeTargetMinimumSize:d}),A=TA(()=>!!k.disableCursor),ee=(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]),j=(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]),M=(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)},[]),N=D.current.separators,P=(0,G.useMemo)(()=>({getDisableCursor:A,getResizeAxisId:g,gutters:{column:O.column,row:O.row},id:h,registerCell:ee,registerSeparator:j,separatorPlacements:N,trackCounts:{column:_.length,row:v.length},updateSeparatorProps:M}),[_.length,A,g,O.column,O.row,h,ee,j,v.length,N,M]),te=(0,G.useRef)([]);wA(()=>{let e=C.current;if(e===null)return;let t=D.current,n=UM({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=LM.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&&MA(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 UA({axis:n,element:e,gutterSizes:r.filter(e=>e!==void 0),hasGutters:u,layout:Nj(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})=>VA({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=>Nj(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=>Fj(e.id,t=>{let{defaultLayoutDeferred:n,derivedItemConstraints:r,layout:a,requestedLayout:o}=t.next;if(n||r.length===0)return;kM({derivedItemConstraints:r,axis:e,layout:a,prevLayout:t.prev?.layout,requestedLayout:o});let c=s();if(c){let e=JA(),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]=LM.map(g);return!Mj(e)||!Mj(t)?{columns:{},rows:{}}:{columns:uM({axisId:e}).getLayout(),rows:uM({axisId:t}).getLayout()}},t=e=>e.map(e=>`"${e}"`).join(`, `),n=(e,n)=>{let r=g(e),i=()=>{let i=Mj(r);return NA(i,`Grid "${h}" has not been mounted`),NA(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))}`),sM({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 NA(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 NA(i,`Grid "${h}" does not contain a ${e} at index ${t}; it has ${r.length} ${e}s`),n(e,i.id)},setLayout:t=>(LM.forEach(e=>{let n=t[e===`column`?`columns`:`rows`],r=g(e);n&&Mj(r)&&uM({axisId:r}).setLayout(n)}),e())}},[_,g,h,v]);let ne=()=>LM.map(e=>{let t=Nj(g(e)),n=y(e);return(t&&!t.defaultLayoutDeferred?n.map(e=>`minmax(0, ${t.layout[e.id]??1}fr)`):HM(n,r?.[e===`column`?`columns`:`rows`])).join(O[e]?` auto `:` `)}).join(`|`),[F,re]=(0,G.useSyncExternalStore)((0,G.useCallback)(e=>{let t=LM.map(t=>Fj(g(t),e));return()=>t.forEach(e=>e())},[g]),ne,ne).split(`|`);return(0,K.jsx)(PA.Provider,{value:P,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:F,gridTemplateRows:re,touchAction:`none`},children:(0,K.jsx)(MM.Provider,{value:null,children:e})})})}zM.displayName=`Grid`;function BM(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 NA(r.length>0,`Grid must have at least one track; "${t}" is ${n}`),r},[n])}function VM(e,t){G.Children.forEach(e,e=>{if((0,G.isValidElement)(e))if(e.type===IM){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&&VM(e.props.children,t)})}function HM(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:WA(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 UM({cells:e,separatorPlacements:t,trackCounts:n}){let r=[];for(let t of e)LM.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 MA(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 WM(e,t){return Hj(e.columns,t.columns)&&Hj(e.rows,t.rows)}function GM(e){for(let t=1;t<e.length;t++)if(mj(e[t-1],e[t])>0)return!1;return!0}function KM({separator:e}){let{element:t}=e,n=(0,G.useRef)(null);return wA(()=>{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 qM(){let e=(0,G.useContext)(MM);return NA(e,`Group Context not found; did you render a Panel or Separator outside of a Group?`),e}function JM(e){let{registerOverlay:t}=qM(),n=(0,G.useRef)(e);wM(n.current,e)||(n.current=e);let r=n.current;return wA(()=>t(r),[t,r]),null}JM.displayName=`SeparatorOverlay`;function YM({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 XM({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===JM&&(c=s.props,s=void 0),s??(c?s=(0,K.jsx)(YM,{...c,active:t.active,orientation:n.orientation}):a&&(s=(0,K.jsx)(KM,{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 ZM(e){return Array.from(e).sort(mj)}function QM(e,t){let n=(0,G.useRef)({getLayout:()=>({}),setLayout:ej});(0,G.useImperativeHandle)(t,()=>n.current,[]),wA(()=>{Object.assign(n.current,uM({axisId:e}))})}function $M({groupId:e,resizePreviewMode:t}){let[n,r]=(0,G.useState)([]),i=(0,G.useRef)(n);return wA(()=>{let n=n=>{let a=Mj(e),o=t===`separator`&&n.state===`active`?n.previews.filter(e=>e.axis===a&&(e.active||!Rj(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(JA());return}let a=YA(({next:e})=>n(e));return n(JA()),a},[e,t]),n}function eN({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=TA(e=>{Hj(h.current.onLayoutChange,e)||(h.current.onLayoutChange=e,c?.(e))}),_=TA((e,t,n)=>{Hj(h.current.onLayoutChanged,e)||(h.current.onLayoutChanged=e,l?.(e,{isUserInteraction:t,requestedLayout:n}))}),v=CA(s),[y,b]=(0,G.useState)(),x=$M({groupId:v,resizePreviewMode:d}),S=(0,G.useRef)(null),[C,w]=AM(),T=(0,G.useRef)([]),E=(0,G.useRef)({lastExpandedPanelSizes:{},layouts:{},panels:[],separators:[]}),D=EA(S,a);QM(v,o);let O=TA((e,t)=>{let r=Nj(e);if(r)return{flexGrow:r.layout[t]??1};if(n?.[t])return{flexGrow:n?.[t]}}),k=jM({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=hj(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=hj(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=Mj(v),i=Nj(v);r&&i&&Ij(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]),ee=(0,G.useRef)(null);return wA(()=>{let e=S.current;if(e===null)return;let t=E.current;t.panels=hj(u,t.panels),t.separators=hj(u,t.separators),T.current=ZM([...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};ee.current=r;let a=OM(r),{defaultLayoutDeferred:o,derivedItemConstraints:s,layout:c,requestedLayout:l}=Nj(r.id,!0);!o&&s.length>0&&(g(c),_(c,!1,l));let f=Fj(v,e=>{let{defaultLayoutDeferred:t,derivedItemConstraints:n,layout:i,requestedLayout:a}=e.next;if(t||n.length===0)return;kM({derivedItemConstraints:n,axis:r,layout:i,prevLayout:e.prev?.layout,requestedLayout:a});let o=JA(),s=o.state!==`active`||!o.hitRegions.some(e=>e.axis===r);g(i),s&&_(i,e.isUserInteraction,a)});return()=>{ee.current=null,a(),f()}},[i,v,_,g,u,C,d,k]),wA(()=>{GM(T.current)||w()}),(0,G.useEffect)(()=>{let e=ee.current;e&&(e.mutableState.defaultLayout=n,e.mutableState.disableCursor=!!r)}),(0,K.jsx)(MM.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)(XM,{overlay:y,preview:e},e.key))]})})}eN.displayName=`Group`;function tN(e,t){let{id:n}=qM(),r=(0,G.useRef)({collapse:tj,expand:tj,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:tj});(0,G.useImperativeHandle)(t,()=>r.current,[]),wA(()=>{Object.assign(r.current,sM({axisId:n,itemId:e}))})}function nN({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,_=CA(l),v=jM({disabled:o}),y=(0,G.useRef)(null),b=EA(y,s),{getPanelStyles:x,id:S,orientation:C,registerPanel:w,updatePanelProps:T}=qM(),E=f!==null,D=TA((e,t,n)=>{f?.(e,l,n)});wA(()=>{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]),tN(_,p);let O=()=>{let e=x(S,_);if(e)return JSON.stringify(e)},k=(0,G.useSyncExternalStore)(e=>Fj(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:{...rN,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})})}nN.displayName=`Panel`;var rN={minHeight:0,maxHeight:`100%`,height:`auto`,minWidth:0,maxWidth:`100%`,width:`auto`,border:`none`,borderWidth:0,padding:0,margin:0},iN={flexBasis:`auto`},aN={flexGrow:0,flexShrink:0};function oN({children:e,className:t,disabled:n,disableDoubleClick:r,elementRef:i,id:a,preview:o,style:s,...c}){let l=CA(a),{disableCursor:u,id:d,orientation:f,registerSeparator:p,updateSeparatorProps:m}=qM();return(0,K.jsx)(PM,{attributes:c,axisId:d,axisOrientation:f,className:t,disableCursor:u,disabled:n,disableDoubleClick:r,elementRef:i,id:l,preview:o,registerSeparator:p,requiredStyle:aN,style:s,styleDefaults:iN,updateSeparatorProps:m,children:e})}oN.displayName=`Separator`;function sN({className:e,...t}){return(0,K.jsx)(eN,{"data-slot":`resizable-panel-group`,className:H(`flex h-full w-full`,e),...t})}function cN(e){return(0,K.jsx)(nN,{"data-slot":`resizable-panel`,...e})}function lN({className:e,...t}){return(0,K.jsx)(oN,{"data-slot":`resizable-handle`,className:H(`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:H(`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 uN=`oa.panes`,dN=200,fN=new Set,pN=[];function mN(e,t){return t?`${e}/${t}`:`new`}var hN=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function gN(e){if(!hN(e))return{};let t={};for(let[n,r]of Object.entries(e))hN(r)&&Object.values(r).every(e=>typeof e==`number`)&&(t[n]=r);return t}function _N(e){let t;try{t=JSON.parse(e??`null`)}catch{t=null}let n={};if(hN(t)&&hN(t.pages))for(let[e,r]of Object.entries(t.pages))hN(r)&&(n[e]={open:Array.isArray(r.open)?r.open.filter(e=>typeof e==`string`):[],sizes:gN(r.sizes)});return{pages:n,last:hN(t)?gN(t.last):{}}}var vN,yN;function bN(){let e=yN??null;if(yN===void 0)try{e=globalThis.localStorage?.getItem(uN)??null}catch{e=null}return vN?.raw!==e&&(vN={raw:e,kept:_N(e)}),vN.kept}function xN(e,t,n){let r=bN(),{[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-dN)))delete s[e];let l=JSON.stringify({pages:s,last:n??r.last});try{globalThis.localStorage?.setItem(uN,l),yN=void 0}catch{yN=l}for(let e of fN)e()}function SN(e){return fN.add(e),()=>fN.delete(e)}function CN(e,t,n){!n&&AN.get(e)===t&&AN.delete(e),xN(e,e=>e.open.includes(t)===n?e:{...e,open:n?[...e.open,t]:e.open.filter(e=>e!==t)})}function wN(e){AN.delete(e),xN(e,e=>({...e,open:[]}))}function TN(e){return(0,G.useSyncExternalStore)(SN,()=>bN().pages[e]?.open??pN,()=>pN)}function EN(e,t){let n=bN();return n.pages[e]?.sizes[t]??n.last[t]}var DN=0;function ON(e,t){return bN().pages[e]?.sizes[t]?e:`~${DN}`}function kN(e,t,n){DN++,xN(e,e=>({...e,sizes:{...e.sizes,[t]:n}}),{...bN().last,[t]:n})}var AN=new Map;function jN(e,t){t===void 0?AN.delete(e):AN.set(e,t);for(let e of fN)e()}function MN(e){return(0,G.useSyncExternalStore)(SN,()=>AN.get(e),()=>void 0)}var NN=new Map,PN=new Map,FN=new Map,IN=new Set,LN=0;function RN(e){return IN.add(e),()=>IN.delete(e)}function zN(e,t){NN.set(e,t===void 0?{at:++LN}:{path:t,at:++LN});for(let e of IN)e()}function BN(e){return(0,G.useSyncExternalStore)(RN,()=>NN.get(e),()=>void 0)}function VN(e){PN.set(e,++LN);for(let e of IN)e()}function HN(e){return(0,G.useSyncExternalStore)(RN,()=>PN.get(e),()=>void 0)}function UN(e,t){FN.set(e,{key:t,at:++LN});for(let e of IN)e()}function WN(e){return(0,G.useSyncExternalStore)(RN,()=>FN.get(e),()=>void 0)}var GN=e=>`${e.package}/${e.id}`,KN=`docs`,qN=`subagent`,JN=`workspace`,YN=`chat`,XN=`panes`,ZN=50,QN=(0,G.createContext)({page:``,enabled:!1,panes:[],open:[],expanded:void 0,panelProps:void 0,reveal:void 0,docs:[],docsLoaded:!1,subagent:null}),$N=0;function eP({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}=mn(l?()=>Mr(l):null,[],4e3,[l],l?{remember:`docs:${l}`}:void 0),{panels:f}=gn(),p=mN(l??``,t),m=WN(p),h=s!==void 0&&m!==void 0,g=(0,G.useMemo)(()=>{if(!l)return[];let e=f.filter(e=>e.projects.includes(l)).map(e=>({id:GN(e),label:e.label,icon:e.icon,panel:e})),t=[...u.length>0?[{id:KN,label:`Docs`,icon:Da}]:[],...h?[{id:qN,label:`Subagent`,icon:fa,hidden:!0}]:[]];return[...e,...t]},[f,l,u.length,h]),_=TN(p),v=(0,G.useMemo)(()=>_.flatMap(e=>g.find(t=>t.id===e)??[]),[_,g]),y=MN(p);(0,G.useEffect)(()=>()=>{se()&&wN(p)},[p]);let b=BN(p),x=g.find(e=>e.panel?.changes)?.id,S=b?.at;(0,G.useEffect)(()=>{S===void 0||x===void 0||S<=$N||($N=S,CN(p,x,!0))},[S,x,p]);let C=HN(p),w=g.find(e=>e.panel?.screen)?.id;(0,G.useEffect)(()=>{C===void 0||w===void 0||C<=$N||($N=C,CN(p,w,!0))},[C,w,p]);let T=m?.at;(0,G.useEffect)(()=>{T===void 0||!h||T<=$N||($N=T,CN(p,qN,!0))},[T,h,p]);let E=(0,G.useMemo)(()=>new Set(r.filter(e=>i.has(e))),[r,i]),D=(0,G.useMemo)(()=>({files:E,toggle:a}),[E,a]),O=(0,G.useMemo)(()=>l?{projectId:l,...t?{agentId:t,...o===void 0?{}:{activity:o}}:{},context:D}:void 0,[l,t,o,D]),k=(0,G.useMemo)(()=>({page:p,enabled:l!==null,panes:g,open:v,expanded:v.some(e=>e.id===y)?y:void 0,panelProps:O,reveal:b,docs:u,docsLoaded:d,subagent:s??null}),[p,l,g,v,y,O,b,u,d,s]);return(0,K.jsx)(QN.Provider,{value:k,children:c})}function tP(){let{open:e}=(0,G.useContext)(QN);return Te()&&e.length>0}function nP(){let{page:e,panes:t,open:n}=(0,G.useContext)(QN),r=t.filter(e=>!e.hidden);return tP()||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)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(B,{variant:`ghost`,size:`icon-sm`,className:H(`shrink-0 text-muted-foreground`,r&&`bg-accent text-accent-foreground`),"aria-label":t.label,"aria-pressed":r,onClick:()=>CN(e,t.id,!r)}),children:(0,K.jsx)(t.icon,{className:`h-4 w-4`})}),(0,K.jsx)(W,{children:t.label})]},t.id)})})}function rP(){let{page:e,panes:t,open:n}=(0,G.useContext)(QN);return tP()?(0,K.jsxs)(I,{children:[(0,K.jsx)(Et,{"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)(wa,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsx)(We,{align:`start`,className:`min-w-[12rem]`,children:t.filter(e=>!e.hidden||n.includes(e)).map(t=>(0,K.jsxs)(Ke,{closeOnClick:!0,checked:n.includes(t),onCheckedChange:n=>CN(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 iP({pane:e}){let{page:t,expanded:n,panelProps:r,reveal:i,docs:a,docsLoaded:o,subagent:s}=(0,G.useContext)(QN),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)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(B,{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:()=>jN(t,c?void 0:e.id)}),children:c?(0,K.jsx)(qa,{className:`h-3.5 w-3.5`}):(0,K.jsx)(Ga,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(W,{children:c?`Back to its place`:`Fill the page`})]}),(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(B,{variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground`,"aria-label":`Close ${e.label}`,onClick:()=>CN(t,e.id,!1)}),children:(0,K.jsx)(R,{className:`h-4 w-4`})}),(0,K.jsx)(W,{children:`Close`})]})]}),(0,K.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:e.id===qN?(0,K.jsx)(kt.Provider,{value:p,children:s}):e.panel&&r?(0,K.jsx)(bA,{package:e.panel.package,label:`${e.label} pane`,children:(0,K.jsx)(kt.Provider,{value:p,children:(0,K.jsx)(e.panel.Panel,{...e.panel.changes&&i?{...r,reveal:i}:r})})}):(0,K.jsx)(vA,{docs:a,loaded:o})})]})})}var aP=e=>e.map(e=>e.id).join(`+`);function oP(){let{page:e,open:t,expanded:n}=(0,G.useContext)(QN),r=aP(t),i=EN(e,r),a=ON(e,r),o=e=>`${e.id}@${a}`;return(0,K.jsx)(sN,{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)&&kN(e,r,Object.fromEntries(a))},children:t.flatMap((e,n)=>[...n>0?[(0,K.jsx)(lN,{"aria-label":`The height of ${t[n-1].label} and ${e.label}`},`above-${e.id}`)]:[],(0,K.jsx)(cN,{id:o(e),defaultSize:`${i?.[e.id]??100/t.length}%`,minSize:96,style:{overflow:`hidden`},children:(0,K.jsx)(iP,{pane:e})},e.id)])})}function sP({children:e}){let{page:t,enabled:n,open:r,expanded:i}=(0,G.useContext)(QN),a=Te(),o=r.length>0&&!a;if(!n)return e;let s=EN(t,JN)?.[XN]??ZN,c=`${XN}@${ON(t,JN)}`;return(0,K.jsxs)(`div`,{className:`relative flex min-w-0 flex-1`,children:[(0,K.jsxs)(sN,{orientation:`horizontal`,disabled:i!==void 0,onLayoutChanged:(e,{isUserInteraction:n})=>{let[r,i]=[e[YN],e[c]];n&&r!==void 0&&i!==void 0&&kN(t,JN,{[YN]:r,[XN]:i})},children:[(0,K.jsx)(cN,{id:YN,minSize:320,className:`flex min-w-0 flex-col`,style:{overflow:`hidden`},children:e}),o&&(0,K.jsx)(lN,{"aria-label":`The width of the chat and the panes`}),o&&(0,K.jsx)(cN,{id:c,defaultSize:`${s}%`,minSize:288,style:{overflow:`hidden`},children:(0,K.jsx)(oP,{})})]}),a&&r.length>0&&(0,K.jsx)(`div`,{className:H(`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)(iP,{pane:e})},e.id))})]})}var cP=[];function lP({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)(y,{}),(0,K.jsx)(rP,{}),(0,K.jsx)(`div`,{className:`grow shrink-0`}),(0,K.jsx)(_A,{projectId:e,events:cP,onProjectRemoved:t}),(0,K.jsx)(nP,{})]})}var uP=E(`onProjectSkills`),dP=E(`sendChangeSkills`),fP=E(`sendProjectSkills`),pP=e=>e.standing!==`absent`,mP=e=>e.groups.flatMap(e=>e.skills),hP=(e,t,n)=>`${e} ${e===1?t:n}`;function gP({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 _P=e=>e.length===1?`is`:`are`,vP=e=>e.length===1?`it`:`them`,yP={newer:`a newer version is there`,changed:`changed by hand`,own:`your own text`},bP=e=>e.remote?`Send to ${e.remote}`:`Commit`;function xP({projectId:e,onChanged:t,door:n}){let{value:r,reload:i,loaded:a}=mn(()=>uP(e).catch(()=>null),null,15e3,[e],`previous`),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),{error:u,run:d}=ln(),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:g,here:_,sending:y,inRequest:b,onBranch:x}=SP(r),S=()=>m(`update`,()=>CP(e,r,d)),C=()=>m(`send`,()=>d(()=>fP(e),`Could not send the skills.`)),w=o&&(0,K.jsx)(TP,{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)(gP,{names:h}),` `,h.length===1?`has a newer version`:`have newer versions`,`.`]}),(0,K.jsx)(B,{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)(gP,{names:_}),` `,_P(_),` `,r.remote?`on this computer only`:`not committed`,`, so your agents do not have `,vP(_),` yet.`,r.local&&r.remote&&` Or pick My local branch when you start an agent.`]}),(0,K.jsx)(B,{type:`button`,variant:`outline`,size:`xs`,className:`shrink-0`,disabled:c!==null,onClick:()=>void C(),children:c===`send`?`Sending…`:bP(r)})]}),b&&(0,K.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,K.jsxs)(`span`,{children:[(0,K.jsx)(gP,{names:g}),` `,_P(g),` in pull request #`,r.request.number,`. Your agents get `,vP(g),` once it is merged.`]}),(0,K.jsxs)(`a`,{href:r.request.url,target:`_blank`,rel:`noreferrer`,className:v({variant:`outline`,size:`xs`,className:`shrink-0`}),children:[`Open #`,r.request.number]})]}),x&&(0,K.jsxs)(`span`,{children:[(0,K.jsx)(gP,{names:g}),` `,_P(g),` on the branch `,r.branch,` on `,r.remote,`. Merge it into `,r.startBranch??`the default branch`,`, and your agents get `,vP(g),`.`]}),u&&(0,K.jsx)(`span`,{className:`text-danger`,children:u}),w]})}function SP(e){let t=mP(e).filter(e=>e.standing===`newer`).map(e=>e.name),n=mP(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=mP(e).filter(pP).map(e=>e.name);return{newer:t,waiting:n,here:r,sending:i,inRequest:a,onBranch:o,held:s.length,heldNames:s}}async function CP(e,t,n){let{newer:r}=SP(t),i=await n(()=>dP(e,{write:r}),`Could not update the skills.`);return!i.ok||!t.git?i:n(()=>fP(e,r),`Could not send the skills.`)}function wP(e){let t=mP(e).filter(pP);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 TP({projectId:e,skills:t,onClose:n,onSaved:r}){let[i,a]=(0,G.useState)(()=>wP(t)),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),{busy:u,error:d,run:f}=ln(),p=(e,t)=>a(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r}),m=mP(t).filter(e=>i.has(e.name)&&!pP(e)).map(e=>e.name),h=mP(t).filter(e=>!i.has(e.name)&&pP(e)).map(e=>e.name),g=m.length===0&&h.length===0,_=async t=>{l(null);let n=await f(()=>fP(e,t),`Could not send the skills.`);n.ok&&l(n.value),r()},v=async()=>{let n=await f(()=>dP(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)(bt,{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 `,hP(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 `,hP(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)(B,{type:`button`,size:`sm`,disabled:u,onClick:()=>void _([...o.written,...o.removed]),children:u?`Sending…`:`Send again`}),(0,K.jsx)(B,{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)(zt,{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}),yP[e.standing]&&(0,K.jsxs)(`span`,{className:`text-warning`,children:[` (`,yP[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?`${hP(m.length,`skill`,`skills`)} to write`:``,h.length>0?`${hP(h.length,`skill`,`skills`)} to delete`:``].filter(Boolean).join(`, `)+`.`}),(0,K.jsx)(B,{type:`button`,variant:`outline`,size:`sm`,disabled:u,onClick:n,children:`Cancel`}),(0,K.jsx)(B,{type:`button`,size:`sm`,disabled:u||g,onClick:()=>void v(),children:u?`Saving…`:y})]})]})})}function EP({events:e,headline:t=!1}){let n=DP(e);if(n.length===0)return null;let r=n[n.length-1];return(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsxs)(`span`,{role:`alert`,className:`flex shrink-0 items-center gap-1.5 text-danger`,children:[(0,K.jsx)(so,{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)(W,{className:`whitespace-pre-line`,children:n.map(e=>e.headline).join(`
|
|
131
131
|
`)})]})}function DP(e){let t=Fn(e),n=iA(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=iA(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`}:rA(e)?{dot:`animate-pulse bg-warning`,label:`building…`,tone:`text-muted-foreground`}:{dot:`bg-muted-foreground`,label:`finished`,tone:`text-muted-foreground`}}function kP({events:e}){let t=In(e),n=OP(e),r=DP(e),i=lA(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:H(`h-2.5 w-2.5 shrink-0 rounded-full`,n.dot),"aria-hidden":!0}),(0,K.jsx)(`span`,{className:H(`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)(EP,{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 AP({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)(lP,{projectId:e,onProjectRemoved:m===void 0?f:void 0}),(0,K.jsx)(Jo,{errors:d}),(0,K.jsx)(Qe,{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)(kP,{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)(rs,{items:n,onOpenAgent:u},e)]}),(0,K.jsx)(xP,{projectId:e,onChanged:p,door:{open:h===e,onClose:()=>g(null)}},e)]})}),(0,K.jsx)($k,{projectId:e,projectName:t,onAgentStarted:i,files:a,context:o,addContext:s,removeContext:c,toggleContext:l,onOpenSkills:()=>g(e),home:m})]})}var jP=E(`onQuota`),MP=3e4;function NP(){return mn(jP,void 0,MP,[],{remember:`quota`,stored:!0}).value}function PP(e){return new Intl.DateTimeFormat(`en-US`,{weekday:`short`}).format(e).slice(0,2).toUpperCase()}function FP(e,t,n=PP){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 IP=5;function LP(e,t,n=IP){return e>=100?`full`:e>t+n?`over`:e>=t-n?`near`:`under`}function RP(e,t){return Math.min(Math.max(e+t,0),100)}function zP(e,t,n){return(e-t)/100*n}function BP(e,t){return Math.min(Math.max(e,0),100)/100*t}function VP(e,t){if(!(t<=0))return e/t*100}function HP(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 UP={under:`bg-success`,near:`bg-info`,over:`bg-warning`,full:`bg-danger`},WP={under:`text-success`,near:`text-info`,over:`text-warning`,full:`text-danger`},GP=` — `;function KP(e){return e.find(e=>e.kind===`week`)}function qP(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 JP({swatch:e,children:t}){return(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[e,t]})}function YP({boundary:e,percentUsed:t,offset:n,onChangeOffset:r,others:i}){let a=FP(e.startsAt,e.resetsAt),o=LP(t,e.percent),s=n!==void 0,c=RP(e.percent,n??0),l=HP(t,s?c:t),u=s&&l.end>l.start,d=zP(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=zP(t,e.percent,m),g=h>=0,_=BP(t,m),v=VP(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:H(`absolute inset-y-0 left-0`,UP[o]),style:{width:`${l.start}%`}}),u&&(0,K.jsx)(`div`,{className:H(`absolute inset-y-0 opacity-35`,UP[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:H(`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)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(`span`,{className:`cursor-default`}),children:[`You are `,(0,K.jsx)(`span`,{className:H(`font-medium`,WP[o]),children:he(Math.abs(h))}),` `,g?`over`:`under`,` the week's pace`]}),(0,K.jsxs)(W,{className:`max-w-64`,children:[`You are `,Pt(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)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(`span`,{className:`cursor-default`}),children:[(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:he(_)}),` spent`]}),(0,K.jsxs)(W,{className:`max-w-64`,children:[Pt(_),` 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)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(`span`,{className:`cursor-default`}),children:[(0,K.jsxs)(`span`,{className:H(`font-medium`,WP[o]),children:[Math.round(v),`%`]}),` of pace`]}),(0,K.jsxs)(W,{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)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(`span`,{className:`cursor-default`}),children:[`Resets `,le(e.resetsAt)]}),(0,K.jsx)(W,{children:de(e.resetsAt)})]}),`.`,i.length>1?(0,K.jsxs)(K.Fragment,{children:[` `,(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(`span`,{className:`cursor-default`}),children:`Show all limits`}),(0,K.jsx)(W,{children:(0,K.jsx)(`table`,{className:`border-collapse text-left`,children:(0,K.jsx)(`tbody`,{children:i.map(e=>(0,K.jsx)(ZP,{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)(JP,{swatch:(0,K.jsx)(`span`,{className:H(`h-2 w-2 rounded-sm`,UP[o]),"aria-hidden":!0}),children:`Used`}),s&&(0,K.jsx)(JP,{swatch:(0,K.jsx)(`span`,{className:H(`h-2 w-2 rounded-sm opacity-35`,UP[o]),"aria-hidden":!0}),children:`Budget for Autonomous AI`}),(0,K.jsx)(JP,{swatch:(0,K.jsx)(`span`,{className:`h-2 w-0.5 bg-foreground`,"aria-hidden":!0}),children:(0,K.jsxs)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(`span`,{className:`inline-flex cursor-default items-center gap-0.5`}),children:[`Quota boundary`,(0,K.jsx)(_a,{className:`h-3 w-3`,"aria-hidden":!0})]}),(0,K.jsxs)(W,{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)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(`span`,{className:`inline-flex cursor-default items-center gap-1 text-warning`}),children:[(0,K.jsx)(so,{className:`h-3 w-3`,"aria-hidden":!0}),`Eager consumption`,(0,K.jsx)(_a,{className:`h-3 w-3`,"aria-hidden":!0})]}),(0,K.jsxs)(W,{children:[`Autonomous AI will spend tokens `,Pt(d),` faster than the week's pace allows`]})]}),s&&(0,K.jsxs)(V,{children:[(0,K.jsxs)(U,{render:(0,K.jsx)(`span`,{className:H(`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:H(`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)(W,{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 XP({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?`${GP}resets ${e.resetsAtText}`:``]})]})}function ZP({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?`${GP}resets ${e.resetsAtText}`:``]})]})}function QP(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 $P=500;function eF(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))})},$P)},i]}function tF({limit:e,projects:t,boundary:n,percentUsed:r,others:i}){let a=Tt(),o=t.map(e=>e.id).join(`,`),{value:s}=mn(()=>e.read(a,t),void 0,1e4,[e.package,o],{remember:`usage-limit:${e.package}:${o}`,stored:!0}),[c,l,u]=eF(s,n=>e.save(a,t,n));return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(YP,{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 nF({projects:e}){let t=NP(),{usageLimit:n}=gn(),r=(KO(`claude`).view?.accounts??[]).filter(e=>!e.own),i=t&&!(t.windows.length===0&&r.length>0)?QP(t):void 0,a=t?.unavailable!==void 0&&t.windows.length>0?t.readAt:void 0,s=t?KP(t.windows):void 0,c=t?.windows??[];return(0,K.jsxs)(o,{children:[(0,K.jsx)(cn,{children:(0,K.jsx)(Gt,{className:`text-base`,children:`Usage`})}),(0,K.jsxs)(pt,{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)(bA,{package:n.package,label:`usage limit`,children:(0,K.jsx)(tF,{limit:n,projects:xA(n.projects,e),boundary:t.boundary,percentUsed:s.percentUsed,others:c})}):(0,K.jsx)(YP,{boundary:t.boundary,percentUsed:s.percentUsed,others:c}):t&&t.windows.length?(0,K.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:qP(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)(XP,{window:e},e.label))}):null,(0,K.jsx)(ck,{}),i?(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[i,a===void 0?``:` Last read ${At(new Date(a).toISOString())}.`]}):null]})]})}var rF=`/update-tickets`;function iF({busy:e,onStart:t,onConfigure:n,lastImportedAt:r,disabled:i,variant:a,size:o=`sm`,className:s}){return(0,K.jsx)(Ee,{...a?{variant:a}:{},size:o,...i===void 0?{}:{disabled:i},...s?{className:s}:{},icon:(0,K.jsx)(eo,{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:rF,configureDescription:`Opens the launcher with the update prompt, so you can set the model and where it runs.`})}var aF=`Hide; Settings › Appearance brings it back`,oF=e=>e.replace(/[\\/]+$/,``).split(/[\\/]/).pop()||e;function sF(){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)(P,{"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)(Go,{})})]})}function cF({onAgentStarted:e,onSelectProject:t}){let{value:n,reload:r}=mn(Lr,null,1e4,[]),{value:i,reload:a}=mn(_i,null,3e4,[]),s=_r(),c=gs(),{start:l,busy:u,error:d}=Ic(),{missing:f}=Xs(),[p,m]=(0,G.useState)(null),h=i?.cwdProjectId??n?.projects[0]?.projectId??null,g=n?.totals.projects??0,_=n?.projects.some(e=>e.hasTickets)??!1,v=c===`granted`&&xr(s),y=()=>{mr({notifyBrowser:!0}),c==="default"&&Notification.requestPermission()},b=async()=>{if(!h)return;let t=await l(h,rF,Mc(s));t&&e(h,rF,t.agentId)},x=i?.cwd&&!i.cwdProjectId?i.cwd:void 0,S=[...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&&g===0?(0,K.jsx)(sF,{}):`A project is a git repo OpenAgent may work in.`,done:g>0,action:(0,K.jsxs)(`div`,{className:`space-y-2`,children:[x&&(0,K.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,K.jsxs)(B,{size:`sm`,onClick:()=>m({folder:x}),children:[(0,K.jsx)(ka,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),`Add “${oF(x)}”`]}),(0,K.jsx)(`p`,{className:`truncate font-mono text-[11px] text-muted-foreground`,title:x,children:`The folder OpenAgent runs in: ${x}`})]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[i?.canPickFolder!==!1&&(0,K.jsx)(B,{size:`sm`,variant:x?`outline`:`default`,onClick:()=>m({}),children:x?`Choose another folder…`:`Choose a folder…`}),(0,K.jsx)(B,{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:_,optional:!0,action:(0,K.jsxs)(`div`,{className:`flex flex-col items-start gap-1`,children:[(0,K.jsx)(iF,{variant:`default`,busy:u,disabled:!h,onStart:()=>void b(),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:v,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)(B,{size:`sm`,variant:`outline`,onClick:y,children:`Enable`})}],C=S.filter(e=>e.done).length;return(0,K.jsxs)(o,{children:[(0,K.jsxs)(cn,{className:`flex flex-row items-start justify-between gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Gt,{className:`text-base`,children:`Onboarding`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[C,` of `,S.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:`${C/Math.max(1,S.length)*100}%`}})})]}),(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(B,{variant:`ghost`,size:`sm`,onClick:()=>mr({onboardingDismissed:!0}),"aria-label":aF}),children:(0,K.jsx)(R,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsx)(W,{children:aF})]})]}),(0,K.jsx)(pt,{children:(0,K.jsx)(`ul`,{className:`divide-y divide-border`,children:S.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)(ro,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--color-primary)]`,"aria-label":`Done`}):(0,K.jsx)(io,{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)(Ko,{folder:p.folder,fromAddress:p.fromAddress===!0,onAdded:()=>{r(),a()},onClose:()=>m(null)})]})}function lF({working:e,onSelectAgent:t}){return(0,K.jsxs)(o,{children:[(0,K.jsx)(cn,{children:(0,K.jsxs)(Gt,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)(fa,{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)(pt,{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)(uF,{label:dF(e),cloud:e.cloud,computer:e.computer,at:e.updatedAt,projectName:e.projectName,onOpen:()=>t(e.projectId,e.agentId)},`${e.projectId}:${e.agentId}`))})})]})}function uF({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)(F,{computer:n}),r&&(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-xs tabular-nums text-muted-foreground/80`}),children:Ae(r)}),(0,K.jsx)(W,{children:T(r)})]})]})})}function dF(e){return e.intent?.trim()||e.scope?.trim()||e.projectName}function fF(e){let{cards:t}=gn();return t.flatMap(t=>{let n=t.Card,r=t.computer?xA(e.map(e=>e.id),e):xA(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)(bA,{package:t.package,label:`${t.id} card`,children:(0,K.jsx)(n,{projects:r})})}]})}var pF=`@openagt/skill-logs`,mF=5;function hF(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 gF=[];function _F({projects:e,onSelectProject:t}){let n=e.map(e=>e.id).join(`,`),{value:r,loaded:i,reload:a}=mn(()=>Promise.all(e.map(async e=>{let[t,n]=await Promise.all([uP(e.id).catch(()=>null),st(e.id,pF,[`skills`,`--local`,`--days`,`30`]).then(e=>e.ok&&Array.isArray(e.output)?e.output:[],()=>[])]);return{project:e,skills:t,used:n}})),gF,6e4,[n],{remember:`skills-card:${n}`,stored:!0}),s=hF(r),c=new Set(s.map(e=>e.skill)),l=[...new Set(r.flatMap(e=>e.skills?SP(e.skills).heldNames:[]))].filter(e=>!c.has(e)).sort(),u=r.filter(e=>e.skills&&SP(e.skills).newer.length>0),[d,f]=(0,G.useState)(!1),p=ln(),m=async()=>{f(!0);try{for(let e of u)if(!(await CP(e.project.id,e.skills,p.run)).ok)break;await a()}finally{f(!1)}};return(0,K.jsxs)(o,{children:[(0,K.jsxs)(cn,{children:[(0,K.jsxs)(Gt,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)($a,{className:`h-4 w-4 text-muted-foreground`,"aria-hidden":!0}),`Skills`,u.length>1&&(0,K.jsx)(B,{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)(pt,{children:i?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`ul`,{className:`space-y-2`,children:r.map(e=>(0,K.jsx)(vF,{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)(yF,{used:s,unused:l})]}):(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading…`})})]})}function vF({read:e,reload:t,onOpen:n}){let{project:r,skills:i}=e,[a,o]=(0,G.useState)(!1),{error:s,run:c}=ln(),l=async e=>{o(!0);try{(await e()).ok&&await t()}finally{o(!1)}},u=i?SP(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)(B,{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)(B,{variant:`outline`,size:`xs`,disabled:a,onClick:()=>void l(()=>CP(r.id,i,c)),title:`Newer versions: ${u.newer.join(`, `)}`,children:a?`Updating…`:`Update ${u.newer.length}`}):u.sending?(0,K.jsx)(B,{variant:`outline`,size:`xs`,disabled:a,onClick:()=>void l(()=>c(()=>fP(r.id),`Could not send the skills.`)),title:`Not where agents start from yet: ${u.here.join(`, `)}`,children:a?`Sending…`:bP(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)(ga,{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:H(`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 yF({used:e,unused:t}){if(e.length===0)return null;let n=e[0].uses,r=e.length-mF;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,mF).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 bF={"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 xF({cards:e}){return(0,K.jsx)(wF,{children:e.map(({card:e,width:t})=>(0,K.jsx)(CF,{card:e,className:H(`col-span-12 flex min-w-0 flex-col *:flex-1`,bF[t])},e.id))})}var SF=new Set;function CF({card:e,className:t}){let[n,r]=(0,G.useState)(SF),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:H(t,`transition-opacity duration-300`,a&&`opacity-60`),children:(0,K.jsx)(nt.Provider,{value:i,children:e.node})})}function wF({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 TF={"1/4":`¼`,"1/3":`⅓`,"1/2":`½`,"2/3":`⅔`,"3/4":`¾`,1:`Full`},EF=(e,t)=>e===`end`||t===`end`?e===t:e.id===t.id&&e.side===t.side,DF=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:H(`pointer-events-none absolute inset-y-0 z-20 w-1 rounded-full bg-primary`,e===`before`?`-left-2.5`:`-right-2.5`)})}function kF({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||!EF(a,e))&&o(e)},l=e=>mr({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,pl.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:H(`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)(za,{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)(Qa,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]},e.id))})]}),(0,K.jsxs)(wF,{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:H(`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:H(`relative col-span-12 flex min-w-0 cursor-grab flex-col rounded-lg outline-1 outline-offset-2 outline-border outline-dashed`,bF[t],r?.id===e.id&&`opacity-40`),style:{viewTransitionName:DF(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)(AF,{label:e.label,widths:Gn(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 AF({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)(za,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsxs)(`span`,{className:`hidden pointer-coarse:flex`,children:[(0,K.jsx)(jF,{label:`Move ${e} earlier`,disabled:r,onClick:()=>a(-1),children:(0,K.jsx)(pa,{className:`h-4 w-4`,"aria-hidden":!0})}),(0,K.jsx)(jF,{label:`Move ${e} later`,disabled:i,onClick:()=>a(1),children:(0,K.jsx)(P,{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:H(`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:TF[e]},e))}),(0,K.jsx)(jF,{label:`Take ${e} off the page`,onClick:s,children:(0,K.jsx)(R,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})}function jF({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 MF({onSelectProject:e,onSelectAgent:t,onAgentStarted:n,interventions:r,interventionsStale:i,active:a,projects:o,scope:s}){let c=_r().onboardingDismissed??!1,l=a.active.filter(e=>s===null||e.projectId===s),u=s===null?o:o.filter(e=>e.id===s),d=fF(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)(w,{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:()=>me(ke)})},{id:`working-now`,stale:a.stale,label:`Working now`,order:2,width:`1/3`,minWidth:`1/4`,node:(0,K.jsx)(w,{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:()=>me(b)}:{}})},{id:`usage`,label:`Usage`,order:5,width:`1`,minWidth:`1/2`,node:(0,K.jsx)(nF,{projects:o})},{id:`human-queue`,stale:i,label:`Human Queue`,order:6,width:`1`,minWidth:`1/2`,node:(0,K.jsx)(`div`,{id:ke,className:`flex scroll-mt-6 flex-col *:flex-1`,children:(0,K.jsx)(NF,{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:b,className:`flex scroll-mt-6 flex-col *:flex-1`,children:(0,K.jsx)(lF,{working:l,onSelectAgent:t})})},{id:`skills`,label:`Skills`,order:8,width:`1/3`,minWidth:`1/4`,node:(0,K.jsx)(_F,{projects:u,onSelectProject:e})},...d];p.sort((e,t)=>e.order-t.order);let m=s??`*`,h=_r().overviewLayouts,g=vr(),_=Kn(p,h,m),[v,y]=(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)(Nt,{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)(B,{variant:`ghost`,size:`sm`,onClick:()=>{let{[m]:e,...t}=h??{};mr({overviewLayouts:t})},children:m===`*`?`Reset to the default layout`:`Use the all-projects layout`}),(0,K.jsx)(B,{size:`sm`,onClick:()=>y(!1),children:`Done`})]}):(0,K.jsxs)(B,{variant:`ghost`,size:`sm`,className:`gap-1.5 text-muted-foreground`,onClick:()=>y(!0),children:[(0,K.jsx)(no,{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)(cF,{onAgentStarted:n,onSelectProject:e}),g?v?(0,K.jsx)(kF,{arranged:_,layouts:h,layoutKey:m}):_.some(({hidden:e})=>!e)?(0,K.jsx)(xF,{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 NF({items:e,onSelectProject:t,onSelectAgent:n}){let r=PF.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)(cn,{children:[(0,K.jsxs)(Gt,{className:`flex items-center gap-2 text-base`,children:[(0,K.jsx)(Ba,{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)(pt,{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)(rs,{grouped:!0,items:e.items,onOpenAgent:n,onOpenProject:t})]},e.value))})})]})}var PF=[{value:`awaiting`,label:`Questions`},{value:`pr`,label:`Pull requests`},{value:`unpushed`,label:`To publish`},{value:`uncommitted`,label:`To commit`}];function FF({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 Ur().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 Wr().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)(B,{variant:`outline`,size:`sm`,onClick:()=>a(e=>!e),children:i?`Hide`:`Reveal`}),(0,K.jsx)(hn,{text:n,label:`Copy the bridge token`})]})]}):null}function IF(){return(0,K.jsx)(OO,{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)(LF,{}),(0,K.jsx)(kO,{}),(0,K.jsx)(`h3`,{className:`pt-1 text-sm font-medium`,children:`Coding agents`}),(0,K.jsx)(nk,{agent:`claude`}),(0,K.jsx)(nk,{agent:`codex`}),(0,K.jsx)(`h3`,{className:`pt-1 text-sm font-medium`,children:`Git hosts`}),(0,K.jsx)(lk,{})]})})}function LF(){let e=KO(`claude`).view?.from,t=KO(`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 RF=`project-accounts`,zF=e=>`project-accounts:${e}`;function BF(e){De(zF(e),()=>Es(e))}function VF(e){let{value:t,reload:n}=mn(e?()=>Es(e):null,null,3e4,[e],e?{remember:zF(e)}:void 0);return{view:t&&(t.gitHost||t.claude||t.codex)?t:null,reload:n}}var HF=``,UF=`some`;function WF({projectId:e}){let{view:t,reload:n}=VF(e),[r,i]=(0,G.useState)(),a=async t=>{i(void 0);let r=await Ds(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)(_t,{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)(Ye,{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??HF,options:[{value:HF,label:`Same as this computer`},...o.accounts.map(e=>({value:e,label:`@${e}`}))],onChange:e=>void a({gitHost:e===HF?null:e})}),t.claude&&(0,K.jsx)(GF,{label:`Claude`,accounts:t.claude,onChange:e=>void a({claude:e})}),t.codex&&(0,K.jsx)(GF,{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 GF({label:e,accounts:t,onChange:n}){let r=new Set(t.project??[]);return(0,K.jsxs)(`div`,{className:`py-3`,children:[(0,K.jsx)(Ye,{label:e,description:`Which ${e} accounts this project's runs use, in the order Settings › Accounts has them.`,value:t.project?UF:HF,options:[{value:HF,label:`Same as this computer`},{value:UF,label:`Only some of them`}],onChange:e=>n(e===HF?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)(zt,{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 KF({enabled:e}){let[t,n]=(0,G.useState)(null);if((0,G.useEffect)(()=>{if(!e){n(null);return}let t=!0,r=()=>void qr().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 Qr(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)(B,{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)(B,{variant:`outline`,size:`sm`,onClick:()=>r(`hide`),children:`Hide the window`}):(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>r(`show`),children:t.signIn?`Show the window to sign in`:`Show the window`}),(0,K.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>r(`restart`),children:`Restart`})]})]})]})}var qF=``;function JF({entry:e,openItem:t,onEntry:n,onClose:r,scope:i,projects:a}){let{settings:o}=gn(),s=Te(),c=s&&e===``,l=(0,G.useRef)(null),[u,d]=(0,G.useState)(i??qF),f=a.find(e=>e.id===u)??null,p=vo(),m=XF(),[h,_]=(0,G.useState)(),v=(n,r)=>{let i=n.Section;return{id:n.id,title:n.title,icon:n.icon,body:(0,K.jsx)(bA,{package:n.package,label:`${n.title} settings`,children:(0,K.jsx)(i,{projects:xA(n.projects,r),...t!==void 0&&n.id===e?{item:t}:{}})})}},y=[...m,...o.filter(e=>e.computer).map(e=>v(e,[]))],b=o.filter(e=>!e.computer&&(f?e.projects.includes(f.id):e.projects.length>0)),{view:x}=VF(f?.id);(0,G.useEffect)(()=>{for(let e of a)BF(e.id)},[a]);let S=[...f&&x?[{id:RF,title:`Accounts`,icon:Ha,body:(0,K.jsx)(WF,{projectId:f.id})}]:[],...b.map(e=>v(e,f?[f]:a))],C=[...y,...S].find(t=>t.id===e)??y[0],w=S.includes(C),T=w&&!f?xA(b.find(e=>e.id===C.id)?.projects??[],a):[],E=e=>{let t=e.icon;return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`button`,{type:`button`,"aria-current":e===C?`page`:void 0,onClick:()=>n(e.id),className:H(`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)(g,{open:!0,onOpenChange:e=>!e&&r(),children:(0,K.jsxs)(ze,{children:[(0,K.jsx)(M,{className:`fixed inset-0 z-50 bg-black/40 backdrop-blur-[1px]`}),(0,K.jsxs)(ne,{ref:l,initialFocus:l,className:H(`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:H(`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)(Cn,{className:`text-base font-semibold`,children:`Settings`}),(0,K.jsx)(He,{"aria-label":`Close settings`,className:`rounded p-1 text-muted-foreground outline-none hover:text-foreground`,children:(0,K.jsx)(R,{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:y.map(E)})}),(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)(YF,{projects:a,value:f?.id??qF,onChange:d})]}),S.length>0?(0,K.jsx)(`ul`,{className:`flex flex-col gap-1`,children:S.map(E)}):(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:[h?(0,K.jsx)(`button`,{type:`button`,"aria-label":`Back to ${C.title}`,onClick:h.back,className:`-ml-1 rounded p-1 text-muted-foreground outline-none hover:text-foreground`,children:(0,K.jsx)(sa,{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)(sa,{className:`size-4`,"aria-hidden":!0})}),(0,K.jsxs)(Cn,{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)(P,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}),w&&(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)(P,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}),h?(0,K.jsxs)(K.Fragment,{children:[!s&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`button`,{type:`button`,onClick:h.back,className:`truncate rounded text-muted-foreground outline-none hover:text-foreground`,children:C.title}),(0,K.jsx)(P,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":!0})]}),(0,K.jsx)(`span`,{className:`truncate font-medium`,children:h.title})]}):(0,K.jsx)(`span`,{className:`truncate font-medium`,children:C.title})]}),(0,K.jsx)(He,{"aria-label":`Close settings`,className:`rounded p-1 text-muted-foreground outline-none hover:text-foreground`,children:(0,K.jsx)(R,{className:`size-4`,"aria-hidden":!0})})]}),(0,K.jsx)(Qe,{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:[T.length>0&&(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Saved to `,T.length===1?`one project`:`${T.length} projects`,`: `,T.map(e=>p(e.id,e.name)).join(`, `),`.`]}),(0,K.jsx)(`div`,{children:(0,K.jsx)(Yt.Provider,{value:_,children:C.body})},`${C.id}/${f?.id??qF}`)]})})]})]})]})})}function YF({projects:e,value:t,onChange:n}){let r=vo(),i=[{value:qF,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??qF)),children:[(0,K.jsx)(Ne,{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)(Be,{})}),(0,K.jsx)(Ie,{children:i.map(e=>(0,K.jsx)(N,{value:e.value,children:e.label},e.value))})]})}function XF(){let e=_r(),t=dA(),n=yr(e),r=mt(fn()),i=e.driver??Sn[0],a=e.model??``,o=gs()===`denied`;return[{id:`appearance`,title:`Appearance`,icon:Xa,body:(0,K.jsxs)(_t,{children:[(0,K.jsx)(Ye,{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=>mr({theme:e})}),(0,K.jsx)(Ye,{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=>mr({editor:e})}),(0,K.jsx)(QF,{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=>mr({onboardingDismissed:!e})})]})},{id:`notifications`,title:`Notifications`,icon:ua,body:(0,K.jsxs)(_t,{children:[(0,K.jsx)(QF,{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=>mr({notifyBrowser:e})}),(0,K.jsx)(QF,{label:`Human Queue`,description:`An agent awaiting your answer, or a PR ready to review.`,checked:e.notifyHumanIntervention??!0,onChange:e=>mr({notifyHumanIntervention:e})}),(0,K.jsx)(QF,{label:`New activity`,description:`Also ping when an agent starts or finishes.`,checked:e.notifyNewActivity??!1,onChange:e=>mr({notifyNewActivity:e})})]})},{id:`agent`,title:`Agent`,icon:fa,body:(0,K.jsxs)(_t,{children:[(0,K.jsx)(Ye,{label:`Agent`,description:`Which coding agent runs the work.`,value:i,options:r,onChange:e=>mr({driver:e,model:``})}),(0,K.jsx)(Ye,{label:`Model`,description:`The models the agent lists. Its own default when none is picked.`,value:a,options:$F(r.find(e=>e.value===i),a),onChange:e=>mr({model:e})}),(0,K.jsx)(QF,{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=>mr({nameRuns:e})}),(0,K.jsx)(QF,{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=>mr({showThinking:e})}),(0,K.jsx)(QF,{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=>mr({postMergeCleanup:e})})]})},{id:Os,title:`Accounts`,icon:Ce,body:(0,K.jsx)(IF,{})},{id:`claude-web`,title:`Claude web`,icon:Ra,body:(0,K.jsxs)(_t,{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)(QF,{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=>mr({bridge:e})}),(e.bridge??!1)&&(0,K.jsx)(ZF,{daemonBrowser:e.bridgeBrowser??!1,onChange:e=>mr({bridgeBrowser:e})})]})}]}function ZF({daemonBrowser:e,onChange:t}){let n=(0,G.useId)(),r=(t,n,r,i)=>(0,K.jsxs)(`label`,{className:H(`flex cursor-pointer gap-3 rounded-md border p-3`,e===t?`border-primary/60 bg-muted/20`:`border-border`),children:[(0,K.jsx)(nn,{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)(Kt,{"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)(KF,{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)(FF,{enabled:!0,onChange:()=>{}}))]})]})}function QF({label:e,description:t,checked:n,onChange:r,disabled:i=!1}){return(0,K.jsx)(xt,{label:e,description:t,dimmed:i,control:(0,K.jsx)(xe,{checked:n,disabled:i,onCheckedChange:e=>r(e===!0),"aria-label":e})})}function $F(e,t){let n=e?.models??[];return[{value:``,label:lO},...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 eI=15e3,tI=1e4,nI=1e3;function rI(e){return e?e.landed?!0:e.exists?!e.empty||e.commits.length>0||!!e.pendingFiles?.length:!e.unchanged:!1}function iI(e,t,n=!0,r=!1,i=!1){let a=t?`handoff:${e}:${t}`:void 0;(0,G.useEffect)(()=>{i&&a!==void 0&&_n(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),tI);return()=>clearTimeout(e)},[o]);let[l,u]=(0,G.useState)(eI),{value:d,reload:f,loaded:p}=mn(n&&t?()=>Vr(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?nI:eI),[d?.prPending,o]),(0,G.useEffect)(()=>{o&&rI(d)&&s(!1)},[o,d]);let{busy:m,error:h,run:g}=ln(),[_,v]=(0,G.useState)(null);return{handoff:d,loaded:p,busy:m,error:h,pending:_,act:(e,t,n)=>{v(e),g(t,n).then(e=>e.ok?f():void 0).then(()=>v(null))}}}function aI(e,t,n){let[r,i]=(0,G.useState)(1e4),[a,o]=(0,G.useState)(!1),{value:s,reload:c}=mn(()=>kr(e,t),null,r,[e,t,r],{remember:`worktree:${e}:${t}`});(0,G.useEffect)(()=>i(s?.prPending?300:a?nI:1e4),[s?.prPending,a]),(0,G.useEffect)(()=>{if(!a)return;let e=setTimeout(()=>o(!1),tI);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 oI({projectId:e,agentId:t,events:n,retainedWorktree:r=!1,onWorktreeRemoved:i,onDeleted:a,label:o,projectName:s,runsOn:c=Ac(),expanded:l=!1,onToggle:u,ready:d=!0,checkout:f}){let p=d?Pn(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)(y,{}),(0,K.jsx)(rP,{}),(0,K.jsx)(_A,{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)(EP,{events:n}),(0,K.jsx)(nP,{})]})}function sI({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:Do(e.state),n=t?Eo[t]:void 0,r=n?.Icon??Ia;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:H(`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 cI({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}=ln(),{busy:_,error:v,run:y}=ln(),[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=Vc(e),E=re(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(()=>$r(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?il(e,d.context):e)&&(p.current?.clear(),d?.reset()),p.current?.focus())},ee=()=>void y(()=>Jr(e,t).then(()=>!0),`Could not stop the agent.`).then(e=>{e&&x(!0)}),j=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)},M=n?(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(B,{type:`button`,size:`icon-sm`,onClick:ee,disabled:w,"aria-label":`Stop agent`,className:`h-8 w-8 shrink-0 disabled:opacity-100`}),children:w?(0,K.jsx)(xn,{className:`h-4 w-4 animate-spin`}):(0,K.jsx)(io,{className:`h-3 w-3 fill-current`})}),(0,K.jsx)(W,{children:w?`Stopping…`:`Stop agent`})]}):s?.stopped||S?(0,K.jsxs)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(B,{type:`button`,size:`icon-sm`,onClick:()=>void j(),disabled:m||S,"aria-label":`Resume`,className:`h-8 w-8 shrink-0 disabled:opacity-100`}),children:m||S?(0,K.jsx)(xn,{className:`h-4 w-4 animate-spin`}):(0,K.jsx)(Za,{className:`h-3.5 w-3.5 fill-current`})}),(0,K.jsx)(W,{children:m||S?`Resuming…`:`Resume the agent`})]}):void 0,N=h??v;return(0,K.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl p-2`,children:[N&&(0,K.jsx)(`p`,{role:`alert`,className:`mb-1 px-2 text-xs text-danger`,children:N}),(0,K.jsx)(bk,{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)(dl,{projectId:e,context:d.context,busy:m,onToggle:d.toggle}),(0,K.jsx)(ll,{publish:D??E,picks:oe(T?.gitHost??!0,T?.remote??!0),onPublish:e=>O(e===E?null:e),cleanup:void 0,onCleanup:()=>{},busy:m}),u]}),idleControl:M,placeholder:n?`Send now, and the agent reads it when its turn ends`:`Message the agent to continue it…`})]})}function lI({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)(V,{children:[(0,K.jsx)(U,{render:(0,K.jsx)(`span`,{className:`truncate font-mono`}),children:o}),(0,K.jsx)(W,{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)(V,{children:[(0,K.jsxs)(U,{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)(W,{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)(R,{className:`h-3.5 w-3.5`})})]})})}function uI({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 dI({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 fI(e,t){return`You paused to ask: "${e}". The user chose: ${t}. Continue with that decision.`}function pI(e){return`You paused to ask: "${e}". The user skipped it. Continue without an answer.`}function mI(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 hI(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 gI(e.event);default:return}}function gI(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 _I({choice:e,pick:t}){let[n,r]=(0,G.useState)(!1),i=new Set(En(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:H(`flex items-baseline gap-2`,i.has(e.id)?``:`text-muted-foreground`),children:[(0,K.jsx)(`span`,{className:H(`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 vI=Symbol(`other`),yI=typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl`;function bI({on:e,multi:t}){return t?(0,K.jsx)(`span`,{className:H(`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)(Ve,{className:`h-3 w-3`})}):(0,K.jsx)(`span`,{className:H(`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 xI({projectId:e,agentId:t,choice:n,active:r=!1,onSaid:i,send:a}){let{busy:o,error:s,run:c}=ln(),[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(()=>Yr(e,n.id,r,t),fI(n.title,i.length?i.join(`, `):`(none)`))},C=n=>x(()=>$r(e,n,t),n),w=n.multi?_:d===vI,T=!w||b!==``,E=()=>{if(!(o||!T)){if(n.multi)return _?C(fI(n.title,[...n.options.filter(e=>p.has(e.id)).map(e=>e.label),b].join(`, `))):S([...p]);if(d===vI)return C(fI(n.title,b));d!==void 0&&S(d)}},D=()=>{o||(n.multi?v(e=>!e):f(vI))},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)(bI,{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)(bI,{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:H(`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(pI(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:yI}),(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 SI({label:e,value:t}){return(0,K.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,K.jsx)(ga,{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 CI(e,t){return e.workspace===void 0&&e.branch===void 0&&e.driver===void 0&&(!t||e.elsewhere===!0)}function wI({setup:e,live:t,working:n=!1,added:r,nested:i=!1}){let[a,o]=(0,G.useState)(!1),s=Re(e.driver),c=fn(),l=s?h[s]:e.driver,u=e.model&&St(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)(Hk,{}),(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)(Vk,{since:t.since})]})}return e.workspace===void 0&&e.branch===void 0&&l===void 0?CI(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)(P,{className:H(`h-3.5 w-3.5 shrink-0 transition-transform`,a&&`rotate-90`),"aria-hidden":!0})]}),a&&(0,K.jsxs)(`div`,{className:H(`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)(SI,{label:`Made the checkout`,value:e.workspace}),e.branch!==void 0&&(0,K.jsx)(SI,{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)(SI,{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 TI({row:e,onOpen:t}){let n=fn(),r=e.status===`waiting`?`text-muted-foreground`:yo[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:ct(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:H(`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)(Vk,{since:e.startedAt}):e.endedAt===void 0?null:u(Date.parse(e.endedAt)-Date.parse(e.startedAt))})]})}function EI(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 DI(e,t){let{count:n,ms:r,cost:i}=Wo(e,t);return[`${n} ${n===1?`agent`:`agents`}`,u(r),...i===void 0?[]:[`$${i.toFixed(2)}`]].join(` · `)}function OI({rows:e,onOpen:t}){let n=EI(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:DI(e,n)}),e.map(e=>(0,K.jsx)(TI,{row:e,onOpen:t},e.key))]})}function kI({agent:e,end:t,onOpen:n}){let r=Vo(e,void 0),i=fn(),a=t.status===`done`?ga:t.status===`failed`?ya:t.status===`waiting`?_a:va,o=t.status===`waiting`?`text-muted-foreground`:yo[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:H(`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:ct(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 AI({defaultTagName:e,props:t,render:n,state:r={},stateAttributesMapping:i}){let a=jI(MI(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={...jI(a,o),ref:FI(a.ref,o.ref)};return G.cloneElement(n,s)}function jI(...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]=FI(i,r):PI(n)&&typeof i==`function`&&typeof r==`function`?t[n]=NI(r,i):t[n]=r}}return t}function MI(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 NI(e,t){return function(n){e(n),n.defaultPrevented||t(n)}}function PI(e){return/^on[A-Z]/.test(e)}function FI(...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 II=8,LI=64,RI=0,zI=.5,BI=180,VI=new Set([`ArrowDown`,`ArrowUp`,`End`,`Home`,`PageDown`,`PageUp`,` `]),HI={start:!1,end:!1},UI={currentAnchorId:null,visibleMessageIds:[]};function WI({content:e,scrollEdgeThreshold:t,spacer:n,viewport:r}){if(!r||!e)return HI;let i=nL({content:e,spacer:n,viewport:r});return{start:r.scrollTop>t,end:i-r.scrollTop-r.clientHeight>t}}function GI({content:e,scrollMargin:t,scrollPreviousItemPeek:n,spacer:r,viewport:i,visibleMessageIds:a}){if(!e||!i)return UI;let o=i.getBoundingClientRect(),s=o.top+t+n,c=typeof IntersectionObserver>`u`,l=[],u=null;for(let t of KI(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+zI&&(u=e)}return l.length===0&&u===null?UI:{currentAnchorId:u,visibleMessageIds:l}}function KI(e,t){return Array.from(e.children).filter(e=>e instanceof HTMLElement&&e!==t)}function qI(e,t){for(let n=t;n<e.length;n++){let t=e[n];if(t?.dataset.scrollAnchor===`true`)return t}return null}function JI(e,t){for(let n of e)if(n.dataset.scrollAnchor===`true`&&!t.has(n))return n;return null}function YI(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 XI(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n?.dataset.scrollAnchor===`true`)return n}return null}function ZI({content:e,spacer:t,viewport:n}){let r=n.getBoundingClientRect();for(let n of KI(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 QI({align:e,element:t,scrollMargin:n,spacer:r,viewport:i}){let a=$I(t,i),o=t.getBoundingClientRect().height,s=aL(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 $I(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return n.top-r.top+t.scrollTop}function eL(e,t){return e.getBoundingClientRect().top-t.getBoundingClientRect().top}function tL({content:e,scrollTop:t,spacer:n,viewport:r}){let i=nL({content:e,spacer:n,viewport:r});return t+r.clientHeight-i}function nL({content:e,spacer:t,viewport:n}){let r=KI(e,t),i=iL(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 rL(e){return Math.max(0,e.scrollHeight-e.clientHeight)}function iL(e){let t=window.getComputedStyle(e);return{end:sL(t.paddingBlockEnd||t.paddingBottom),start:sL(t.paddingBlockStart||t.paddingTop)}}function aL(e){let t=e?.parentElement;return t?iL(t):{end:0,start:0}}function oL(e){if(!e)return 0;let t=window.getComputedStyle(e);return sL(t.rowGap===`normal`?t.gap:t.rowGap)}function sL(e){if(!e)return 0;let t=Number.parseFloat(e);return Number.isFinite(t)?t:0}function cL({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()},BI))},[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)<=zI){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(rL(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=QI({align:t,element:e,scrollMargin:o?a+g.current:a,spacer:y.current,viewport:l}),d=tL({content:s,scrollTop:u,spacer:y.current,viewport:l});return S(d),m.current={element:e,viewportTop:eL(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 lL(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 uL(e,t){return lL(e,t)}function dL(){return lL(UI,pL)}function fL(e,t){return e.start===t.start&&e.end===t.end}function pL(e,t){return e.currentAnchorId!==t.currentAnchorId||e.visibleMessageIds.length!==t.visibleMessageIds.length?!1:e.visibleMessageIds.every((e,n)=>e===t.visibleMessageIds[n])}function mL({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),ee=G.useRef(null),j=G.useRef(new Set),M=G.useRef(new WeakSet);return E.current===null&&(E.current=uL(HI,fL)),ee.current===null&&(ee.current=dL()),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:ee.current,visibleMessageIdsRef:j,handledScrollAnchorsRef:M}}function hL(e,t){return G.useCallback(n=>{e.current=n,n&&t()},[e,t])}function gL({autoScroll:e=!1,defaultScrollPosition:t=`end`,scrollEdgeThreshold:n=II,scrollPreviousItemPeek:r=LI,scrollMargin:i=RI}){let a=mL({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:ee,visibilityObserverRef:j,visibilityStore:M,visibleMessageIdsRef:N,handledScrollAnchorsRef:P}=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))},[]),F=G.useCallback(e=>{let t=A.current?.scrollTop??0,n=t<m.current-zI;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`)},[]),re=G.useCallback(()=>{let e=WI({content:u.current,scrollEdgeThreshold:S.current,spacer:D.current,viewport:A.current});F(e);let t=g.current===`following-bottom`?{...e,end:!1}:e;ne(t),k.setSnapshot(t)},[F,k,ne]),ie=G.useCallback(()=>{O.current===null&&(O.current=window.requestAnimationFrame(()=>{O.current=null,re()}))},[re]),ae=G.useCallback(()=>{M.hasListeners()&&ee.current===null&&(ee.current=window.requestAnimationFrame(()=>{ee.current=null,M.hasListeners()&&M.setSnapshot(GI({content:u.current,scrollMargin:C.current,scrollPreviousItemPeek:w.current,spacer:D.current,viewport:A.current,visibleMessageIds:N.current}))}))},[M]),{flushPendingScrollToMessage:I,reanchorToAnchoredMessage:L,scrollToElement:R,scrollToEnd:oe,scrollToMessage:se,scrollToStart:ce}=cL({refs:a,commitScrollState:re,scheduleStateCommit:ie,scheduleVisibilitySync:ae}),le=G.useCallback(()=>{let e=y.current,t=A.current;if(!e||!t||!e.element.isConnected)return!1;let n=eL(e.element,t)-e.viewportTop;return Math.abs(n)<=zI?!1:(t.scrollTop+=n,e.viewportTop=eL(e.element,t),ie(),ae(),!0)},[ie,ae]),ue=G.useCallback(()=>{let e=u.current,t=A.current;if(!e||!t){y.current=null;return}let n=ZI({content:e,spacer:D.current,viewport:t});y.current=n?{element:n,viewportTop:eL(n,t)}:null},[]),de=G.useCallback(()=>{_.current===null&&(_.current=window.requestAnimationFrame(()=>{_.current=null,I()&&ue()}))},[ue,I]),fe=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?XI(KI(t,D.current)):null;if(!t||!n||!r)e=oe({behavior:`auto`});else{let i=$I(r,n);e=nL({content:t,spacer:D.current,viewport:n})-i<=n.clientHeight?oe({behavior:`auto`}):R(r,{align:`start`},{keepPreviousPeek:!0})}}else e=t===`end`?oe({behavior:`auto`}):ce({behavior:`auto`});return e?(d.current=!0,!0):!1},[t,R,oe,ce]),pe=G.useCallback(()=>{let e=u.current;if(!e)return;let t=KI(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(fe()||t.length>0&&s.current&&oe({behavior:`auto`}))return;re(),ae();return}let e=r?t.indexOf(r):-1;if(b.current&&e>0){le();return}if(t.length>n){let e=qI(t,n);if(e){if(s.current&&g.current===`following-bottom`&&YI(t,n)){oe({behavior:`auto`});return}R(e,{align:`start`},{keepPreviousPeek:!0}),P.current.add(e);return}}if(t.length===n){let e=JI(t,P.current);if(e){R(e,{align:`start`},{keepPreviousPeek:!0}),P.current.add(e);return}}g.current===`following-bottom`&&s.current?oe({behavior:`auto`}):(re(),ae())})(),ue()},[fe,ue,re,I,le,ae,R,oe]),me=G.useCallback(()=>{if(g.current===`following-bottom`&&s.current){oe({behavior:`auto`});return}let e=E.current;if(L()){s.current&&e>0&&E.current===0&&oe({behavior:`auto`});return}ie(),ae()},[L,ie,ae,oe]),he=G.useCallback(()=>{let e=A.current;if(!(!e||!M.hasListeners())){if(typeof IntersectionObserver>`u`){ae();return}j.current||=new IntersectionObserver(e=>{for(let t of e){let e=t.target.dataset.messageId;e&&(t.isIntersecting?N.current.add(e):N.current.delete(e))}ae()},{root:e,rootMargin:`${-(C.current+w.current)}px 0px 0px 0px`,threshold:[0,.01,.5,1]}),h.current.forEach(e=>{j.current?.observe(e)}),ae()}},[ae,M]),ge=G.useCallback(()=>{ee.current!==null&&(window.cancelAnimationFrame(ee.current),ee.current=null),j.current?.disconnect(),j.current=null,N.current.clear(),M.setSnapshot(UI)},[M]),_e=G.useCallback((e,t,n)=>{if(t){h.current.set(e,t),j.current?.observe(t),ae(),v.current?.messageId===e&&de();return}n&&h.current.get(e)===n&&(h.current.delete(e),N.current.delete(e),j.current?.unobserve(n),ae())},[de,ae]),ve=G.useCallback(()=>{(g.current===`following-bottom`||g.current===`anchored-to-message`||g.current===`settling-jump`)&&(o.current=null,g.current=`free-scrolling`)},[]),ye=G.useCallback(()=>ne(k.getSnapshot()),[k,ne]),be=hL(x,ye),xe=hL(A,ye),Se=G.useCallback(e=>{u.current=e},[]),z=G.useCallback(e=>{D.current=e,T.current=oL(e?.parentElement??null)},[]),Ce=G.useCallback(()=>{re(),ae(),ue()},[ue,re,ae]),we=G.useMemo(()=>({handleContentChange:pe,handleResize:me,observeVisibility:he,preserveScrollOnPrependRef:b,scrollToEnd:oe,scrollToMessage:se,scrollToStart:ce,setContentElement:Se,setRootElement:be,setSpacerElement:z,setViewportElement:xe,stateStore:k,syncAfterScroll:Ce,unobserveVisibility:ge,userScrollIntent:ve,viewportRef:A,visibilityStore:M}),[pe,me,he,oe,se,ce,Se,be,z,xe,k,Ce,ge,ve,M]);return G.useLayoutEffect(()=>{fe()},[fe]),G.useEffect(()=>()=>{O.current!==null&&(window.cancelAnimationFrame(O.current),O.current=null),ee.current!==null&&(window.cancelAnimationFrame(ee.current),ee.current=null),l.current!==null&&(window.clearTimeout(l.current),l.current=null),_.current!==null&&(window.cancelAnimationFrame(_.current),_.current=null),j.current?.disconnect(),j.current=null},[]),G.useLayoutEffect(()=>{if(e&&g.current===`following-bottom`&&p.current>0){oe({behavior:`auto`});return}re()},[e,re,oe]),{context:we,registerMessage:_e}}function _L(e){let t=G.useRef(e);return t.current=e,t}var vL=G.createContext(null),yL=G.createContext(null);function bL(){let e=G.useContext(vL);if(!e)throw Error(`useMessageScroller must be used within a MessageScroller.`);return e}function xL(){let e=G.useContext(yL);if(!e)throw Error(`MessageScrollerItem must be used within a MessageScroller.`);return e}function SL(){let{scrollToEnd:e,scrollToMessage:t,scrollToStart:n}=bL();return G.useMemo(()=>({scrollToEnd:e,scrollToMessage:t,scrollToStart:n}),[e,t,n])}function CL({autoScroll:e=!1,children:t,defaultScrollPosition:n=`end`,scrollEdgeThreshold:r,scrollPreviousItemPeek:i,scrollMargin:a}){let{context:o,registerMessage:s}=gL({autoScroll:e,defaultScrollPosition:n,scrollEdgeThreshold:r,scrollPreviousItemPeek:i,scrollMargin:a});return(0,K.jsx)(vL.Provider,{value:o,children:(0,K.jsx)(yL.Provider,{value:s,children:t})})}function wL({children:e,...t}){let{setRootElement:n}=bL();return(0,K.jsx)(`div`,{ref:n,...t,children:e})}function TL({"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}=bL();f.current=o;let _=G.useCallback(e=>{p(e),FI(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){VI.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 EL({"aria-relevant":e,children:t,ref:n,role:r,spacerClassName:i,...a}){let{handleContentChange:o,handleResize:s,setContentElement:c,setSpacerElement:l}=bL(),u=G.useRef(null),d=G.useCallback(e=>{u.current=e,c(e),FI(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 DL({messageId:e,ref:t,scrollAnchor:n=!1,...r}){let i=xL(),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),FI(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}=bL(),d=_L(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 AI({defaultTagName:`button`,props:jI({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 kL={Provider:CL,Root:wL,Viewport:TL,Content:EL,Item:DL,Button:OL},AL=kL.Provider;function jL({className:e,...t}){return(0,K.jsx)(kL.Root,{"data-slot":`message-scroller`,className:H(`group/message-scroller relative flex size-full min-h-0 flex-col overflow-hidden`,e),...t})}function ML({className:e,...t}){return(0,K.jsx)(kL.Viewport,{"data-slot":`message-scroller-viewport`,className:H(`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 NL({className:e,...t}){return(0,K.jsx)(kL.Content,{"data-slot":`message-scroller-content`,className:H(`flex h-max min-h-full flex-col`,e),...t})}function PL({className:e,scrollAnchor:t=!1,...n}){return(0,K.jsx)(kL.Item,{"data-slot":`message-scroller-item`,scrollAnchor:t,className:H(`min-w-0 shrink-0`,e),...n})}function FL({direction:e=`end`,className:t,children:n,...r}){return(0,K.jsx)(kL.Button,{"data-slot":`message-scroller-button`,"data-direction":e,direction:e,className:H(`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)(oa,{className:`size-3.5`,"aria-hidden":!0})]})})}function IL(e){return e.kind===`driver`?e.event.type===`start`?e.event.prompt:e.event.type===`text`?e.event.text:null:null}function LL(e){return e.replace(/\s+/g,` `).trim().length>100}function RL(e){return e.kind===`driver`?e.event.type===`start`?`you`:`agent`:e.kind}function zL(e){return e.kind===`driver`&&e.event.type===`start`}function BL(e){return e.kind===`driver`?e.event.type===`error`:e.kind===`error`||e.kind===`end`&&!e.ok&&!e.stopped&&!e.waiting}function VL(e){return BL(e)?`text-danger`:``}function HL(e){return BL(e)?`bg-danger/10`:``}function UL(e){let t=e.findIndex(zL);return t<=0?e:[e[t],...e.slice(0,t),...e.slice(t+1)]}function WL(e){return new Date(e).toLocaleTimeString()}function GL(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=>zL(e)?[mI(e.event.prompt)?.question]:[]));for(let t of e)t.kind===`choice`&&a.has(t.title)&&n.add(t);let o=new Set(Ln(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 KL(e){return new Set(e.filter(e=>e.kind===`end`&&(e.ok||e.waiting)))}function qL(e){let t=new Set,n;for(let r of e)zL(r)?n=void 0:r.kind===`driver`&&r.event.type===`text`?n=r:r.kind===`choice`&&n&&t.add(n);return t}function JL(e){return e.replace(/```await-choices\b[\s\S]*?(```|$)/g,``).trim()}function YL({text:e}){return(0,K.jsx)(`div`,{className:`min-w-0 flex-1 font-sans text-foreground`,children:(0,K.jsx)(Qt,{text:e})})}function XL({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)(Ve,{className:`h-3.5 w-3.5`,"aria-hidden":!0}):(0,K.jsx)(Le,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})}function ZL({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)(XL,{text:e}),t!==void 0&&(0,K.jsx)(`time`,{dateTime:t,title:new Date(t).toLocaleString(),className:`px-1 text-[11px]`,children:Ae(t)})]})}var QL=8,$L=600;function eR(e){return e.length>$L||e.trim().split(`
|