@x-otto/tui 0.0.1-alpha.10 → 0.0.1-alpha.12

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{$ as e,$t as t,A as n,An as r,At as i,B as a,Bt as o,C as s,Cn as c,Ct as l,D as u,Dn as d,Dt as f,E as p,En as m,Et as h,F as g,G as _,Gt as v,Ht as y,I as b,It as x,J as S,Jt as C,K as w,Kt as T,L as E,Lt as D,M as ee,Mt as te,N as O,O as ne,On as k,Ot as re,P as A,Q as ie,Qt as j,R as ae,Rt as oe,S as se,Sn as M,St as N,T as P,Tn as ce,Tt as le,U as ue,Ut as de,V as fe,Vt as pe,W as me,Wt as he,X as ge,Xt as _e,Y as ve,Yt as ye,Z as be,Zt as F,_ as xe,_n as Se,_t as Ce,a as we,an as Te,at as Ee,b as De,bn as Oe,bt as ke,c as Ae,cn as je,ct as Me,d as Ne,dn as Pe,dt as Fe,en as Ie,et as Le,f as Re,fn as I,ft as ze,g as Be,gn as L,gt as Ve,h as He,hn as Ue,ht as We,i as Ge,in as Ke,it as qe,j as Je,k as Ye,kn as Xe,kt as Ze,l as Qe,ln as $e,lt as et,m as tt,mn as nt,mt as rt,n as it,nn as at,nt as ot,o as st,on as R,ot as ct,p as lt,pn as ut,pt as dt,q as ft,r as pt,rn as mt,rt as z,s as ht,sn as gt,st as _t,t as vt,tn as yt,tt as bt,u as B,un as xt,ut as St,v as Ct,vn as wt,vt as Tt,w as Et,wn as Dt,wt as Ot,x as kt,xn as At,xt as jt,y as Mt,yn as Nt,yt as Pt,zt as Ft}from"./WizardDialog-Br__pRN3.js";import{i as It,n as V,r as Lt,t as Rt}from"./i18n-Cx-Il2qw.js";import{CommandRegistry as zt,createBuiltinCommands as Bt,showCommandPalette as Vt}from"./compat.js";import{createRequire as Ht}from"node:module";import Ut from"wrap-ansi";import H,{createContext as Wt,createElement as U,useCallback as Gt,useContext as Kt,useEffect as W,useMemo as qt,useRef as G,useState as K}from"react";import{Fragment as Jt,jsx as q,jsxs as J}from"react/jsx-runtime";import*as Yt from"ink";import{Box as Y,Static as Xt,Text as X,render as Zt,useBoxMetrics as Qt,useInput as $t,usePaste as en,useStdin as tn,useStdout as nn}from"ink";import{I18nextProvider as rn}from"react-i18next";import{createStore as an}from"zustand/vanilla";import{useStore as on}from"zustand";import{LARGE_FILE_BYTE_THRESHOLD as sn,matchSubsequence as cn,matchesGlobPattern as ln,positionsToHighlightRanges as un,rankCandidates as dn,rankLabeledItems as fn,rankNamedItems as pn,readFileCapped as mn,scoreSubsequence as hn}from"@x-otto/shared";import{readdirSync as gn,statSync as _n}from"node:fs";import{adjustDismissedSigil as vn,applySigilCompletion as yn,applySigilReplacement as bn,evaluateSigilTrigger as xn,extractSigilPrefix as Sn}from"@x-otto/interchange";import{basename as Cn,dirname as wn,join as Tn,resolve as En}from"node:path";import{execSync as Dn,spawn as On}from"node:child_process";import kn from"chalk";import{DEFAULT_DELEGATION_TOOLS as An,SESSION_MAX_PER_SESSION_BYTES as jn,SESSION_RESUME_WINDOW_MESSAGES as Mn}from"@x-otto/session-contract";import{marked as Nn}from"marked";import{PassThrough as Pn}from"node:stream";const Fn=[`trust`,`readonly`,`exit`];function In({root:e,onChoice:t}){let n=[{key:`trust`,label:V.t(`trust.optTrust`),color:k.success},{key:`readonly`,label:V.t(`trust.optReadonly`),color:k.accent},{key:`exit`,label:V.t(`trust.optExit`),color:k.inactive}];return J(F,{header:q(_e,{color:k.warning,children:V.t(`trust.title`)}),footer:q(C,{items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[`1/2/3`,V.t(`hint.quick`)],[j.enter,V.t(`hint.confirm`)],[j.esc,V.t(`hint.exit`)]]}),children:[q(Y,{marginTop:I.tight,children:q(X,{wrap:`truncate-end`,children:V.t(`trust.body`,{path:e})})}),q(Y,{marginTop:I.tight,children:q(i.Root,{id:`trust-prompt-dialog`,onPick:e=>t(Fn[e]??`exit`),escapeIndex:Fn.indexOf(`exit`),children:n.map(e=>q(i.Item,{label:e.label,color:e.color},e.key))})})]})}function Ln(e){return Lt(e.language===`zh`?`zh`:e.language===`en`?`en`:Rt()),new Promise(t=>{let n=!1,r=Zt(H.createElement(In,{root:e.root,onChoice:e=>{n||(n=!0,r.clear(),r.unmount(),mt(),t(e))}}),{exitOnCtrlC:!1})})}const Rn=[`use_parent`,`create_new`,`exit`];function zn({parentRoot:e,currentRoot:t,onChoice:n}){let r=[{key:`use_parent`,label:V.t(`parent.optUseParent`),color:k.success},{key:`create_new`,label:V.t(`parent.optCreateNew`),color:k.accent},{key:`exit`,label:V.t(`parent.optExit`),color:k.inactive}];return J(F,{header:q(_e,{color:k.warning,children:V.t(`parent.title`)}),footer:q(C,{items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[`1/2/3`,V.t(`hint.quick`)],[j.enter,V.t(`hint.confirm`)],[j.esc,V.t(`hint.exit`)]]}),children:[q(Y,{marginTop:I.tight,children:q(X,{wrap:`truncate-end`,children:V.t(`parent.body`,{parentRoot:e,currentRoot:t})})}),q(Y,{marginTop:I.tight,children:q(i.Root,{id:`parent-workspace-dialog`,onPick:e=>n(Rn[e]??`exit`),escapeIndex:Rn.indexOf(`exit`),children:r.map(e=>q(i.Item,{label:e.label,color:e.color},e.key))})})]})}function Bn(e){return Lt(e.language===`zh`?`zh`:e.language===`en`?`en`:Rt()),new Promise(t=>{let n=!1,r=Zt(H.createElement(zn,{parentRoot:e.parentRoot,currentRoot:e.currentRoot,onChoice:e=>{n||(n=!0,r.clear(),r.unmount(),mt(),t(e))}}),{exitOnCtrlC:!1})})}const Vn={five_hour:`5h`,seven_day:`7d`,seven_day_opus:`7d-opus`,seven_day_sonnet:`7d-sonnet`,seven_day_overage_included:`7d`},Hn={five_hour:`5-hour`,seven_day:`7-day`,seven_day_opus:`7-day (Opus)`,seven_day_sonnet:`7-day (Sonnet)`,seven_day_overage_included:`7-day`};function Un(e){return Hn[e]??e}function Wn(e,t){let n=Math.max(0,Math.round(e-t/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60);return r>0?`${r}h${i>0?`${i}m`:``}`:i>0?`${i}m`:`<1m`}function Gn(e,t){return e===`rejected`&&(t===`allowed`||t===`allowed_warning`)}function Kn(e,t){let n=e.limitType?Vn[e.limitType]??e.limitType:``,r=e.usedPercent===void 0?``:` ${Math.round(e.usedPercent)}%`,i=!!(n||r);if(Gn(e.status,e.overageStatus)&&e.overageResetsAt!==void 0)return`${n}${r} +${Wn(e.overageResetsAt,t)}`.trim();let a=i?` → `:``;return`${n}${r}${e.resetsAt===void 0?``:`${a}${Wn(e.resetsAt,t)}`}`.trim()}const qn={five_hour:300*60,seven_day:10080*60,seven_day_opus:10080*60,seven_day_sonnet:10080*60,seven_day_overage_included:10080*60};function Jn(e,t,n,r){if(!e||t===void 0||n===void 0)return null;let i=qn[e];if(!i)return null;let a=r/1e3,o=n-i,s=Math.max(0,Math.min(100,Math.round((a-o)/i*100)));return(e===`five_hour`?[[90,72]]:[[75,60],[50,35],[25,15]]).some(([e,n])=>t>=e&&s<=n)?{usedPct:t,timePct:s}:null}function Yn(e,t,n,r,i,a){return Gn(e,a)||e===`allowed_warning`||e===`allowed`&&i!==void 0&&Jn(t,n,r,i)?`warning`:`inactive`}function Z(e,t){return on(e.zustand,t)}function Xn(e){let t=an()(()=>e);return{getState:()=>t.getState(),setState:e=>{let n=t.getState(),r=typeof e==`function`?e(n):e,i=!1;for(let e of Object.keys(r))if(!Object.is(n[e],r[e])){i=!0;break}i&&t.setState(r)},subscribe:e=>t.subscribe(()=>e()),zustand:t}}var Zn=class{buffer=``;active=!1;timer=null;timeoutMs;onEmptyPaste;constructor(e={}){this.timeoutMs=e.timeoutMs??100,this.onEmptyPaste=e.onEmptyPaste}get isPasting(){return this.active}get currentBuffer(){return this.active?this.buffer:``}feed(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(`\x1B[200~`,n),i=e.indexOf(`\x1B[201~`,n),a=r>=0&&i>=0&&i<r;if(this.active){if(r>=0&&!a){this.buffer+=e.slice(n,r),this.clearTimer(),t.push(this.flushPasteEnd()),n=r+6,this.active=!0,this.resetTimer(),t.push({type:`paste_start`});continue}if(i>=0){this.buffer+=e.slice(n,i),this.clearTimer(),t.push(this.flushPasteEnd()),n=i+6;continue}this.buffer+=e.slice(n),this.resetTimer();break}if(r>=0){this.active=!0,this.resetTimer(),t.push({type:`paste_start`}),n=r+6;continue}if(i>=0){n=i+6;continue}break}return t}forceEnd(){if(!this.active)return null;this.clearTimer();let e=this.buffer;return this.buffer=``,this.active=!1,{type:`paste_timeout`,partialText:e}}reset(){this.clearTimer(),this.buffer=``,this.active=!1}destroy(){this.reset()}resetTimer(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.forceEnd(),this.timeoutMs)}clearTimer(){this.timer&&=(clearTimeout(this.timer),null)}flushPasteEnd(){let e=this.buffer,t=e.length===0;return this.buffer=``,this.active=!1,t&&this.onEmptyPaste?.(),{type:`paste_end`,text:e,isEmpty:t}}};const Qn=/^\x1b\[(\d+)(?:;(\d+))?u$/,$n=/^\x1b\[27;(\d+);(\d+)~$/,er=/^\x1b\[(\d+)~$/;function tr(e){if(!e.startsWith(`\x1B[`)&&!e.startsWith(`\x1BO`))return null;let t=e.match(Qn);if(t){let n=parseInt(t[1],10),r=t[2]?parseInt(t[2],10):1,i=r>0?r-1:0;return{name:nr(n),ctrl:!!(i&4),alt:!!(i&2),shift:!!(i&1),meta:!!(i&8),sequence:e}}let n=e.match($n);if(n){let t=parseInt(n[1],10),r=parseInt(n[2],10),i=!!(t&8);return{name:nr(r),ctrl:!!(t&4),alt:i,shift:!!(t&2),meta:i,sequence:e}}if(e.startsWith(`\x1BO`)){let t=e[2],n={A:`up`,B:`down`,C:`right`,D:`left`,H:`home`,F:`end`,P:`f1`,Q:`f2`,R:`f3`,S:`f4`};return t&&t in n?{name:n[t],shift:!1,alt:!1,ctrl:!1,meta:!1,sequence:e}:null}let r=e.match(/^\x1b\[(?:\d+;)?(\d+)?([ABCD])$/);if(r){let t={A:`up`,B:`down`,C:`right`,D:`left`},n=r[1]?parseInt(r[1],10):1;return{name:t[r[2]],ctrl:!!(n&4),alt:!!(n&8),shift:!!(n&2),meta:!!(n&8),sequence:e}}let i=e.match(er);return i?{name:rr(parseInt(i[1],10)),shift:!1,alt:!1,ctrl:!1,meta:!1,sequence:e}:null}function nr(e){return e>=97&&e<=122?String.fromCharCode(e):e>=65&&e<=90?String.fromCharCode(e+32):e===13?`return`:e===9?`tab`:e===27?`escape`:e===32?`space`:e===127||e===8?`backspace`:String.fromCharCode(e)}function rr(e){switch(e){case 1:case 7:return`home`;case 2:return`insert`;case 3:return`delete`;case 4:case 8:return`end`;case 5:return`pageup`;case 6:return`pagedown`;case 11:return`f1`;case 12:return`f2`;case 13:return`f3`;case 14:return`f4`;case 15:return`f5`;case 17:return`f6`;case 18:return`f7`;case 19:return`f8`;case 20:return`f9`;case 21:return`f10`;case 23:return`f11`;case 24:return`f12`;default:return`f${e}`}}function ir(e){if(!process.stdout.isTTY)return;let t=ar(e);t&&process.stdout.write(`\x1b]0;${t}\x07`)}function ar(e){let t=e.replace(/[\x00-\x1f\x7f-\x9f]/g,``).replace(/[\u200b\u200c\u200e\u200f\u202a-\u202e\u2060-\u206f\ufeff]/g,``).replace(/\s+/g,` `).trim();return t.length>240?t.slice(0,240):t}function or(e,t,n){return t?`\x1b]8;${n?`id=${encodeURIComponent(n)}`:``};${encodeURIComponent(t)}\x1b\\${e}\x1b]8;;\x1b\\`:e}function sr(e,t,n,r){let i=t.startsWith(`file://`)?t:`file://${t}`;return n!==void 0&&(i+=`#L${n}`),r!==void 0&&(i+=`:${r}`),or(e,i)}function cr(e,t=`c`){let n=Buffer.from(e,`utf-8`).toString(`base64`);process.stdout.write(`\x1b]52;${t};${n}\x07`)}function lr(e=`c`){return`\x1b]52;${e};?\x07`}function ur(){process.stdout.write(`\x1BP=1s\x1B\\`)}function dr(){process.stdout.write(`\x1BP=2s\x1B\\`)}function fr(e){ur();try{return e()}finally{dr()}}const pr=RegExp(`\x1B\\[\\?2026[hl]`,`g`);function mr(e){return e.includes(`\x1B[?2026`)?e.replace(pr,``):e}function hr(e){return new Proxy(e,{get(e,t){if(t===`write`)return(t,...n)=>e.write(typeof t==`string`?mr(t):t,...n);let n=Reflect.get(e,t);return typeof n==`function`?n.bind(e):n}})}function gr(e=process.env){return!!e.TMUX&&e.OTTO_TUI_SYNC!==`1`}const _r=RegExp(`\x1B\\[3J`,`g`);function vr(e){return e.includes(`\x1B[3J`)?e.replace(_r,``):e}function yr(e){return new Proxy(e,{get(e,t){if(t===`write`)return(t,...n)=>e.write(typeof t==`string`?vr(t):t,...n);let n=Reflect.get(e,t);return typeof n==`function`?n.bind(e):n}})}function br(e=50){let t=[],n=0;return{snapshot(r){let i=Date.now();if(i-n<1e3)return;n=i;let a=t[t.length-1];a&&a.text===r.text&&a.offset===r.offset||(t.push({text:r.text,offset:r.offset,timestamp:i}),t.length>e&&t.splice(0,t.length-e))},undo(){return t.length===0?null:(n=0,t.pop())},get depth(){return t.length},reset(){t.length=0,n=0}}}function xr(e,t){if(!e)return[];let n=[];for(let r=t.length-1;r>=0;r--){let i=t[r],a=cn(e,i);a&&n.push({entry:i,index:r,score:a.score,highlightRanges:un(a.positions)})}return n.sort((e,t)=>t.score-e.score||t.index-e.index),n.map(({entry:e,highlightRanges:t})=>{let n=t[0],r=t.at(-1);return{entry:e,matchStart:n?.start??0,matchEnd:r?.end??0,highlightRanges:t}})}function Sr(e={}){let t=e.maxSize??100,n=e.initialEntries?[...e.initialEntries]:[];n.length>t&&n.splice(0,n.length-t);let r=-1,i=``,a=!1,o=[],s=``;return{push(e){e.length!==0&&(n.length>0&&n[n.length-1]===e||(n.push(e),n.length>t&&n.shift()))},navigateUp(e){return n.length===0?null:r===-1?(i=e,r=n.length-1,n[r]):r<=0?null:(r--,n[r])},navigateDown(){return r===-1?null:(r++,r>=n.length?(r=-1,i):n[r])},resetNavigation(){r=-1,i=``},beginSearch(e){s=e,a=!0,o=[],r===-1&&(i=e)},search(e){return!a||!e?[]:(o=xr(e,n),o)},acceptSearch(e){if(e<0||e>=o.length)return null;let t=o[e].entry;return a=!1,r=n.indexOf(t),t},cancelSearch(){return a=!1,o=[],s},get size(){return n.length},get navState(){return r===-1?null:{position:n.length-r,total:n.length}},getAll(){return n},clear(){n.length=0,r=-1,i=``,a=!1,o=[]}}}function Cr(e,t){let n=process.env[e];if(!n)return t;let r=Number.parseInt(n,10);return Number.isFinite(r)&&r>0?r:t}const wr=Cr(`OTTO_PASTE_STORE_MAX_ENTRIES`,64),Tr=Cr(`OTTO_PASTE_STORE_MAX_BYTES`,33554432),Er=Cr(`OTTO_PASTE_STORE_PERSIST_MAX_BYTES`,8388608),Dr={healthy:1,warning:2,critical:4},Or=/\[@paste:#(\d+)(?:\s+\+(\d+)\s+lines)?\]/g;function kr(e){let t=[];Or.lastIndex=0;let n;for(;(n=Or.exec(e))!==null;)t.push({start:n.index,end:n.index+n[0].length,id:Number.parseInt(n[1],10)});return t}function Ar(e){return Buffer.byteLength(e,`utf-8`)}function jr(e){if(!(typeof e!=`number`||!Number.isFinite(e)))return Math.floor(e)}function Mr(e={}){let{residencyGovernor:t}=e,n=new Map,r=1,i=0,a=0;function o(){return t?.currentLevel??`healthy`}function s(){return Math.max(1,Math.floor(wr/Dr[o()]))}function c(){return Math.max(1,Math.floor(Tr/Dr[o()]))}function l(e){let t=s(),r=c();for(;n.size>0&&(n.size>=t||i+e>r);){let e=n.keys().next().value;if(e===void 0)break;let t=n.get(e);t&&(i-=t.byteLength),n.delete(e),a++}}return{foldIfLarge(e){let t=e.split(`
1
+ import{$ as e,$t as t,A as n,An as r,At as i,B as a,Bt as o,C as s,Cn as c,Ct as l,D as u,Dn as d,Dt as f,E as p,En as m,Et as h,F as g,G as _,Gt as v,Ht as y,I as b,It as x,J as S,Jt as C,K as w,Kt as T,L as E,Lt as D,M as ee,Mt as te,N as O,O as ne,On as k,Ot as re,P as A,Q as ie,Qt as j,R as ae,Rt as oe,S as se,Sn as M,St as N,T as P,Tn as ce,Tt as le,U as ue,Ut as de,V as fe,Vt as pe,W as me,Wt as he,X as ge,Xt as _e,Y as ve,Yt as ye,Z as be,Zt as F,_ as xe,_n as Se,_t as Ce,a as we,an as Te,at as Ee,b as De,bn as Oe,bt as ke,c as Ae,cn as je,ct as Me,d as Ne,dn as Pe,dt as Fe,en as Ie,et as Le,f as Re,fn as I,ft as ze,g as Be,gn as L,gt as Ve,h as He,hn as Ue,ht as We,i as Ge,in as Ke,it as qe,j as Je,k as Ye,kn as Xe,kt as Ze,l as Qe,ln as $e,lt as et,m as tt,mn as nt,mt as rt,n as it,nn as at,nt as ot,o as st,on as R,ot as ct,p as lt,pn as ut,pt as dt,q as ft,r as pt,rn as mt,rt as z,s as ht,sn as gt,st as _t,t as vt,tn as yt,tt as bt,u as B,un as xt,ut as St,v as Ct,vn as wt,vt as Tt,w as Et,wn as Dt,wt as Ot,x as kt,xn as At,xt as jt,y as Mt,yn as Nt,yt as Pt,zt as Ft}from"./WizardDialog-B0B_R8ya.js";import{i as It,n as V,r as Lt,t as Rt}from"./i18n-DH-JhkWE.js";import{CommandRegistry as zt,createBuiltinCommands as Bt,showCommandPalette as Vt}from"./compat.js";import{createRequire as Ht}from"node:module";import Ut from"wrap-ansi";import H,{createContext as Wt,createElement as U,useCallback as Gt,useContext as Kt,useEffect as W,useMemo as qt,useRef as G,useState as K}from"react";import{Fragment as Jt,jsx as q,jsxs as J}from"react/jsx-runtime";import*as Yt from"ink";import{Box as Y,Static as Xt,Text as X,render as Zt,useBoxMetrics as Qt,useInput as $t,usePaste as en,useStdin as tn,useStdout as nn}from"ink";import{I18nextProvider as rn}from"react-i18next";import{createStore as an}from"zustand/vanilla";import{useStore as on}from"zustand";import{LARGE_FILE_BYTE_THRESHOLD as sn,matchSubsequence as cn,matchesGlobPattern as ln,positionsToHighlightRanges as un,rankCandidates as dn,rankLabeledItems as fn,rankNamedItems as pn,readFileCapped as mn,scoreSubsequence as hn}from"@x-otto/shared";import{readdirSync as gn,statSync as _n}from"node:fs";import{adjustDismissedSigil as vn,applySigilCompletion as yn,applySigilReplacement as bn,evaluateSigilTrigger as xn,extractSigilPrefix as Sn}from"@x-otto/interchange";import{basename as Cn,dirname as wn,join as Tn,resolve as En}from"node:path";import{execSync as Dn,spawn as On}from"node:child_process";import kn from"chalk";import{DEFAULT_DELEGATION_TOOLS as An,SESSION_MAX_PER_SESSION_BYTES as jn,SESSION_RESUME_WINDOW_MESSAGES as Mn}from"@x-otto/session-contract";import{marked as Nn}from"marked";import{PassThrough as Pn}from"node:stream";const Fn=[`trust`,`readonly`,`exit`];function In({root:e,onChoice:t}){let n=[{key:`trust`,label:V.t(`trust.optTrust`),color:k.success},{key:`readonly`,label:V.t(`trust.optReadonly`),color:k.accent},{key:`exit`,label:V.t(`trust.optExit`),color:k.inactive}];return J(F,{header:q(_e,{color:k.warning,children:V.t(`trust.title`)}),footer:q(C,{items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[`1/2/3`,V.t(`hint.quick`)],[j.enter,V.t(`hint.confirm`)],[j.esc,V.t(`hint.exit`)]]}),children:[q(Y,{marginTop:I.tight,children:q(X,{wrap:`truncate-end`,children:V.t(`trust.body`,{path:e})})}),q(Y,{marginTop:I.tight,children:q(i.Root,{id:`trust-prompt-dialog`,onPick:e=>t(Fn[e]??`exit`),escapeIndex:Fn.indexOf(`exit`),children:n.map(e=>q(i.Item,{label:e.label,color:e.color},e.key))})})]})}function Ln(e){return Lt(e.language===`zh`?`zh`:e.language===`en`?`en`:Rt()),new Promise(t=>{let n=!1,r=Zt(H.createElement(In,{root:e.root,onChoice:e=>{n||(n=!0,r.clear(),r.unmount(),mt(),t(e))}}),{exitOnCtrlC:!1})})}const Rn=[`use_parent`,`create_new`,`exit`];function zn({parentRoot:e,currentRoot:t,onChoice:n}){let r=[{key:`use_parent`,label:V.t(`parent.optUseParent`),color:k.success},{key:`create_new`,label:V.t(`parent.optCreateNew`),color:k.accent},{key:`exit`,label:V.t(`parent.optExit`),color:k.inactive}];return J(F,{header:q(_e,{color:k.warning,children:V.t(`parent.title`)}),footer:q(C,{items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[`1/2/3`,V.t(`hint.quick`)],[j.enter,V.t(`hint.confirm`)],[j.esc,V.t(`hint.exit`)]]}),children:[q(Y,{marginTop:I.tight,children:q(X,{wrap:`truncate-end`,children:V.t(`parent.body`,{parentRoot:e,currentRoot:t})})}),q(Y,{marginTop:I.tight,children:q(i.Root,{id:`parent-workspace-dialog`,onPick:e=>n(Rn[e]??`exit`),escapeIndex:Rn.indexOf(`exit`),children:r.map(e=>q(i.Item,{label:e.label,color:e.color},e.key))})})]})}function Bn(e){return Lt(e.language===`zh`?`zh`:e.language===`en`?`en`:Rt()),new Promise(t=>{let n=!1,r=Zt(H.createElement(zn,{parentRoot:e.parentRoot,currentRoot:e.currentRoot,onChoice:e=>{n||(n=!0,r.clear(),r.unmount(),mt(),t(e))}}),{exitOnCtrlC:!1})})}const Vn={five_hour:`5h`,seven_day:`7d`,seven_day_opus:`7d-opus`,seven_day_sonnet:`7d-sonnet`,seven_day_overage_included:`7d`},Hn={five_hour:`5-hour`,seven_day:`7-day`,seven_day_opus:`7-day (Opus)`,seven_day_sonnet:`7-day (Sonnet)`,seven_day_overage_included:`7-day`};function Un(e){return Hn[e]??e}function Wn(e,t){let n=Math.max(0,Math.round(e-t/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60);return r>0?`${r}h${i>0?`${i}m`:``}`:i>0?`${i}m`:`<1m`}function Gn(e,t){return e===`rejected`&&(t===`allowed`||t===`allowed_warning`)}function Kn(e,t){let n=e.limitType?Vn[e.limitType]??e.limitType:``,r=e.usedPercent===void 0?``:` ${Math.round(e.usedPercent)}%`,i=!!(n||r);if(Gn(e.status,e.overageStatus)&&e.overageResetsAt!==void 0)return`${n}${r} +${Wn(e.overageResetsAt,t)}`.trim();let a=i?` → `:``;return`${n}${r}${e.resetsAt===void 0?``:`${a}${Wn(e.resetsAt,t)}`}`.trim()}const qn={five_hour:300*60,seven_day:10080*60,seven_day_opus:10080*60,seven_day_sonnet:10080*60,seven_day_overage_included:10080*60};function Jn(e,t,n,r){if(!e||t===void 0||n===void 0)return null;let i=qn[e];if(!i)return null;let a=r/1e3,o=n-i,s=Math.max(0,Math.min(100,Math.round((a-o)/i*100)));return(e===`five_hour`?[[90,72]]:[[75,60],[50,35],[25,15]]).some(([e,n])=>t>=e&&s<=n)?{usedPct:t,timePct:s}:null}function Yn(e,t,n,r,i,a){return Gn(e,a)||e===`allowed_warning`||e===`allowed`&&i!==void 0&&Jn(t,n,r,i)?`warning`:`inactive`}function Z(e,t){return on(e.zustand,t)}function Xn(e){let t=an()(()=>e);return{getState:()=>t.getState(),setState:e=>{let n=t.getState(),r=typeof e==`function`?e(n):e,i=!1;for(let e of Object.keys(r))if(!Object.is(n[e],r[e])){i=!0;break}i&&t.setState(r)},subscribe:e=>t.subscribe(()=>e()),zustand:t}}var Zn=class{buffer=``;active=!1;timer=null;timeoutMs;onEmptyPaste;constructor(e={}){this.timeoutMs=e.timeoutMs??100,this.onEmptyPaste=e.onEmptyPaste}get isPasting(){return this.active}get currentBuffer(){return this.active?this.buffer:``}feed(e){let t=[],n=0;for(;n<e.length;){let r=e.indexOf(`\x1B[200~`,n),i=e.indexOf(`\x1B[201~`,n),a=r>=0&&i>=0&&i<r;if(this.active){if(r>=0&&!a){this.buffer+=e.slice(n,r),this.clearTimer(),t.push(this.flushPasteEnd()),n=r+6,this.active=!0,this.resetTimer(),t.push({type:`paste_start`});continue}if(i>=0){this.buffer+=e.slice(n,i),this.clearTimer(),t.push(this.flushPasteEnd()),n=i+6;continue}this.buffer+=e.slice(n),this.resetTimer();break}if(r>=0){this.active=!0,this.resetTimer(),t.push({type:`paste_start`}),n=r+6;continue}if(i>=0){n=i+6;continue}break}return t}forceEnd(){if(!this.active)return null;this.clearTimer();let e=this.buffer;return this.buffer=``,this.active=!1,{type:`paste_timeout`,partialText:e}}reset(){this.clearTimer(),this.buffer=``,this.active=!1}destroy(){this.reset()}resetTimer(){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>this.forceEnd(),this.timeoutMs)}clearTimer(){this.timer&&=(clearTimeout(this.timer),null)}flushPasteEnd(){let e=this.buffer,t=e.length===0;return this.buffer=``,this.active=!1,t&&this.onEmptyPaste?.(),{type:`paste_end`,text:e,isEmpty:t}}};const Qn=/^\x1b\[(\d+)(?:;(\d+))?u$/,$n=/^\x1b\[27;(\d+);(\d+)~$/,er=/^\x1b\[(\d+)~$/;function tr(e){if(!e.startsWith(`\x1B[`)&&!e.startsWith(`\x1BO`))return null;let t=e.match(Qn);if(t){let n=parseInt(t[1],10),r=t[2]?parseInt(t[2],10):1,i=r>0?r-1:0;return{name:nr(n),ctrl:!!(i&4),alt:!!(i&2),shift:!!(i&1),meta:!!(i&8),sequence:e}}let n=e.match($n);if(n){let t=parseInt(n[1],10),r=parseInt(n[2],10),i=!!(t&8);return{name:nr(r),ctrl:!!(t&4),alt:i,shift:!!(t&2),meta:i,sequence:e}}if(e.startsWith(`\x1BO`)){let t=e[2],n={A:`up`,B:`down`,C:`right`,D:`left`,H:`home`,F:`end`,P:`f1`,Q:`f2`,R:`f3`,S:`f4`};return t&&t in n?{name:n[t],shift:!1,alt:!1,ctrl:!1,meta:!1,sequence:e}:null}let r=e.match(/^\x1b\[(?:\d+;)?(\d+)?([ABCD])$/);if(r){let t={A:`up`,B:`down`,C:`right`,D:`left`},n=r[1]?parseInt(r[1],10):1;return{name:t[r[2]],ctrl:!!(n&4),alt:!!(n&8),shift:!!(n&2),meta:!!(n&8),sequence:e}}let i=e.match(er);return i?{name:rr(parseInt(i[1],10)),shift:!1,alt:!1,ctrl:!1,meta:!1,sequence:e}:null}function nr(e){return e>=97&&e<=122?String.fromCharCode(e):e>=65&&e<=90?String.fromCharCode(e+32):e===13?`return`:e===9?`tab`:e===27?`escape`:e===32?`space`:e===127||e===8?`backspace`:String.fromCharCode(e)}function rr(e){switch(e){case 1:case 7:return`home`;case 2:return`insert`;case 3:return`delete`;case 4:case 8:return`end`;case 5:return`pageup`;case 6:return`pagedown`;case 11:return`f1`;case 12:return`f2`;case 13:return`f3`;case 14:return`f4`;case 15:return`f5`;case 17:return`f6`;case 18:return`f7`;case 19:return`f8`;case 20:return`f9`;case 21:return`f10`;case 23:return`f11`;case 24:return`f12`;default:return`f${e}`}}function ir(e){if(!process.stdout.isTTY)return;let t=ar(e);t&&process.stdout.write(`\x1b]0;${t}\x07`)}function ar(e){let t=e.replace(/[\x00-\x1f\x7f-\x9f]/g,``).replace(/[\u200b\u200c\u200e\u200f\u202a-\u202e\u2060-\u206f\ufeff]/g,``).replace(/\s+/g,` `).trim();return t.length>240?t.slice(0,240):t}function or(e,t,n){return t?`\x1b]8;${n?`id=${encodeURIComponent(n)}`:``};${encodeURIComponent(t)}\x1b\\${e}\x1b]8;;\x1b\\`:e}function sr(e,t,n,r){let i=t.startsWith(`file://`)?t:`file://${t}`;return n!==void 0&&(i+=`#L${n}`),r!==void 0&&(i+=`:${r}`),or(e,i)}function cr(e,t=`c`){let n=Buffer.from(e,`utf-8`).toString(`base64`);process.stdout.write(`\x1b]52;${t};${n}\x07`)}function lr(e=`c`){return`\x1b]52;${e};?\x07`}function ur(){process.stdout.write(`\x1BP=1s\x1B\\`)}function dr(){process.stdout.write(`\x1BP=2s\x1B\\`)}function fr(e){ur();try{return e()}finally{dr()}}const pr=RegExp(`\x1B\\[\\?2026[hl]`,`g`);function mr(e){return e.includes(`\x1B[?2026`)?e.replace(pr,``):e}function hr(e){return new Proxy(e,{get(e,t){if(t===`write`)return(t,...n)=>e.write(typeof t==`string`?mr(t):t,...n);let n=Reflect.get(e,t);return typeof n==`function`?n.bind(e):n}})}function gr(e=process.env){return!!e.TMUX&&e.OTTO_TUI_SYNC!==`1`}const _r=RegExp(`\x1B\\[3J`,`g`);function vr(e){return e.includes(`\x1B[3J`)?e.replace(_r,``):e}function yr(e){return new Proxy(e,{get(e,t){if(t===`write`)return(t,...n)=>e.write(typeof t==`string`?vr(t):t,...n);let n=Reflect.get(e,t);return typeof n==`function`?n.bind(e):n}})}function br(e=50){let t=[],n=0;return{snapshot(r){let i=Date.now();if(i-n<1e3)return;n=i;let a=t[t.length-1];a&&a.text===r.text&&a.offset===r.offset||(t.push({text:r.text,offset:r.offset,timestamp:i}),t.length>e&&t.splice(0,t.length-e))},undo(){return t.length===0?null:(n=0,t.pop())},get depth(){return t.length},reset(){t.length=0,n=0}}}function xr(e,t){if(!e)return[];let n=[];for(let r=t.length-1;r>=0;r--){let i=t[r],a=cn(e,i);a&&n.push({entry:i,index:r,score:a.score,highlightRanges:un(a.positions)})}return n.sort((e,t)=>t.score-e.score||t.index-e.index),n.map(({entry:e,highlightRanges:t})=>{let n=t[0],r=t.at(-1);return{entry:e,matchStart:n?.start??0,matchEnd:r?.end??0,highlightRanges:t}})}function Sr(e={}){let t=e.maxSize??100,n=e.initialEntries?[...e.initialEntries]:[];n.length>t&&n.splice(0,n.length-t);let r=-1,i=``,a=!1,o=[],s=``;return{push(e){e.length!==0&&(n.length>0&&n[n.length-1]===e||(n.push(e),n.length>t&&n.shift()))},navigateUp(e){return n.length===0?null:r===-1?(i=e,r=n.length-1,n[r]):r<=0?null:(r--,n[r])},navigateDown(){return r===-1?null:(r++,r>=n.length?(r=-1,i):n[r])},resetNavigation(){r=-1,i=``},beginSearch(e){s=e,a=!0,o=[],r===-1&&(i=e)},search(e){return!a||!e?[]:(o=xr(e,n),o)},acceptSearch(e){if(e<0||e>=o.length)return null;let t=o[e].entry;return a=!1,r=n.indexOf(t),t},cancelSearch(){return a=!1,o=[],s},get size(){return n.length},get navState(){return r===-1?null:{position:n.length-r,total:n.length}},getAll(){return n},clear(){n.length=0,r=-1,i=``,a=!1,o=[]}}}function Cr(e,t){let n=process.env[e];if(!n)return t;let r=Number.parseInt(n,10);return Number.isFinite(r)&&r>0?r:t}const wr=Cr(`OTTO_PASTE_STORE_MAX_ENTRIES`,64),Tr=Cr(`OTTO_PASTE_STORE_MAX_BYTES`,33554432),Er=Cr(`OTTO_PASTE_STORE_PERSIST_MAX_BYTES`,8388608),Dr={healthy:1,warning:2,critical:4},Or=/\[@paste:#(\d+)(?:\s+\+(\d+)\s+lines)?\]/g;function kr(e){let t=[];Or.lastIndex=0;let n;for(;(n=Or.exec(e))!==null;)t.push({start:n.index,end:n.index+n[0].length,id:Number.parseInt(n[1],10)});return t}function Ar(e){return Buffer.byteLength(e,`utf-8`)}function jr(e){if(!(typeof e!=`number`||!Number.isFinite(e)))return Math.floor(e)}function Mr(e={}){let{residencyGovernor:t}=e,n=new Map,r=1,i=0,a=0;function o(){return t?.currentLevel??`healthy`}function s(){return Math.max(1,Math.floor(wr/Dr[o()]))}function c(){return Math.max(1,Math.floor(Tr/Dr[o()]))}function l(e){let t=s(),r=c();for(;n.size>0&&(n.size>=t||i+e>r);){let e=n.keys().next().value;if(e===void 0)break;let t=n.get(e);t&&(i-=t.byteLength),n.delete(e),a++}}return{foldIfLarge(e){let t=e.split(`
2
2
  `);if(e.length<=800&&t.length<=20)return e;let a=Ar(e);l(a);let o=r++;return n.set(o,{text:e,byteLength:a}),i+=a,t.length>1?`[@paste:#${o} +${t.length} lines]`:`[@paste:#${o}]`},expandAll(e){let t=kr(e);if(t.length===0)return{text:e,missingIds:[]};let r=[],s=o(),c=[...t].sort((e,t)=>t.start-e.start),l=e;for(let e of c){let t=n.get(e.id);if(t===void 0){r.push(e.id);continue}l=l.slice(0,e.start)+t.text+l.slice(e.end),s===`healthy`?(n.delete(e.id),n.set(e.id,t)):(n.delete(e.id),i-=t.byteLength,a++)}return{text:l,missingIds:r.sort((e,t)=>e-t)}},findMissingIds(e){let t=kr(e),r=[];for(let e of t)n.has(e.id)||r.push(e.id);return[...new Set(r)].sort((e,t)=>e-t)},peek(e){return n.get(e)?.text},truncateIfNeeded(e){return e.length<=1e4?e:e.slice(0,500)+`\n[...Truncated ${e.length-500-500} chars...]\n`+e.slice(e.length-500)},addImageRef(){return`[@paste:image #${r++}]`},afterSubmit(e){if(o()!==`healthy`)for(let t of kr(e)){let e=n.get(t.id);e!==void 0&&(n.delete(t.id),i-=e.byteLength,a++)}},toSnapshot(){let e=[...n.entries()].map(([e,t])=>({id:e,text:t.text,byteLength:t.byteLength})),t=e.reduce((e,t)=>e+t.byteLength,0),i=0;for(;i<e.length&&t>Er;)t-=e[i].byteLength,i++;return{entries:i>0?e.slice(i):e,nextId:r}},hydrate(e){n.clear(),i=0;let t=Math.max(1,Math.floor(jr(e?.nextId)??0));for(let n of e?.entries??[]){let e=jr(n?.id);e!==void 0&&(t=Math.max(t,e+1))}r=Math.max(r,t);for(let t of e?.entries??[]){let e=jr(t?.id);if(e===void 0||typeof t?.text!=`string`||n.has(e))continue;let r=Ar(t.text);n.set(e,{text:t.text,byteLength:r}),i+=r}},get size(){return n.size},get bytesUsed(){return i},get evictionCount(){return a},clear(){n.clear(),i=0}}}function Nr(e){let t=e?[...e]:[],n=new Map;return{register(e){for(let n of e)t.some(e=>e.name===n.name)||t.push(n);t.sort((e,t)=>(e.sortKey??e.name).localeCompare(t.sortKey??t.name))},search(e,n=50){return dn(t.map(e=>({text:e.name,aliases:[...e.aliases??[],...e.description?[e.description]:[]],payload:e,sortKey:e.sortKey})),e,{maxResults:n}).map(e=>e.item.payload)},getAll:()=>t,find:e=>t.find(t=>t.name===e),registerArgumentSuggester(e,t){n.set(e,t)},getArgumentSuggester(e){return n.get(e)}}}function Pr(e,t){let n=e.slice(0,t).trimStart();if(!n.startsWith(`/`))return null;let r=n.match(/^\/(.*)$/);return r?r[1]??``:null}function Fr(e,t,n){let r=Pr(e,t);if(r===null)return null;let i=r.indexOf(` `);if(i>0){let e=r.slice(0,i),t=r.slice(i+1),a=n.getArgumentSuggester(e);if(a){let n=pn(a(t),t);if(n.length>0)return{suggestions:n,selectedIndex:0,prefix:`/${r}`,panelOpen:!0,argCommand:e}}return null}let a=n.search(r);return a.length===0?null:{suggestions:a,selectedIndex:0,prefix:`/${r}`,panelOpen:!0}}function Ir(e,t){switch(t){case`prev`:return{...e,selectedIndex:(e.selectedIndex-1+e.suggestions.length)%e.suggestions.length};case`next`:return{...e,selectedIndex:(e.selectedIndex+1)%e.suggestions.length};case`accept`:return`accept`;case`dismiss`:return`dismiss`}}function Lr(e,t,n){let r=e.slice(0,t),i=r.lastIndexOf(`/`);if(i<0)return{text:e,offset:t};let a=r.slice(i+1),o=a.indexOf(` `),s=o>=0?a.slice(o):` `,c=`/${n.name}${s}`;return{text:e.slice(0,i)+c+e.slice(t),offset:i+c.length}}function Rr(e){return{text:e,offset:e.length}}function zr(e,t,n,r){if(!e)return null;let i=t.slice(0,n),a=i.lastIndexOf(`
3
3
  `)+1;return re(i.slice(a)+(t.slice(n).split(`
4
4
  `)[0]??``))+re(e)>r?null:e}function Br(e){return e.startsWith(`!!`)?{prefix:`!!`,body:e.slice(2)}:e.startsWith(`!`)?{prefix:`!`,body:e.slice(1)}:{prefix:``,body:e}}function Vr(e){return e.startsWith(`!!`)?e.slice(2):e.startsWith(`!`)?e.slice(1):e}function Hr(e,t,n){let{prefix:r,body:i}=Br(e);if(r.length>0){if(i.length===0)return null;let e=i.toLowerCase();for(let a=n.length-1;a>=0;a--){let o=Vr(n[a]);if(o.length<=i.length||!o.toLowerCase().startsWith(e))continue;let s=r+o;return{fullText:s,suffix:s.slice(t),kind:`history`}}return null}let a=e.toLowerCase();for(let r=n.length-1;r>=0;r--){let i=n[r];if(!(i.length<=e.length)&&i.toLowerCase().startsWith(a))return{fullText:i,suffix:i.slice(t),kind:`history`}}return null}function Ur(e,t,n){let r=Pr(e,t);if(r===null||r.length===0)return null;let i=r.indexOf(` `);if(i>0){let a=r.slice(0,i),o=r.slice(i+1),s=n.getArgumentSuggester(a);if(!s)return null;let c=pn(s(o),o,{maxResults:1});if(c.length===0)return null;let l=Gr(e,t,a,c[0].name);return{fullText:l.text,suffix:l.text.slice(t),kind:`slash-arg`}}let a=n.search(r,1);if(a.length===0)return null;let o=Lr(e,t,a[0]);return{fullText:o.text,suffix:o.text.slice(t),kind:`slash-command`}}function Wr(e){let{text:t,offset:n,dismissedPrefix:r,history:i,registry:a}=e;if(n!==t.length||t.length===0||r!==void 0&&r===t)return null;if(a&&t.trimStart().startsWith(`/`)){let e=Pr(t,n);if(e!==null&&e.length===0)return null;let r=Ur(t,n,a);if(r)return r}return Hr(t,n,i)}function Gr(e,t,n,r){let i=e.slice(0,t),a=i.lastIndexOf(`/`);if(a<0)return{text:e,offset:t};let o=i.slice(a+1).indexOf(` `);if(o<0)return{text:e,offset:t};let s=a+1+o+1;return{text:e.slice(0,s)+r+e.slice(t),offset:s+r.length}}function Kr(e){return(e.VISUAL||e.EDITOR||``).trim()||(process.platform===`win32`?`notepad`:`vi`)}function qr(e,t){let n=Kr(t.env),r=null;try{r=t.mkdtempSync(t.join(t.tmpdir(),`otto-edit-`));let i=t.join(r,`prompt.md`);t.writeFileSync(i,e);let a=n.split(/\s+/).filter(Boolean),o=a[0],s=[...a.slice(1),i],c=t.spawnSync(o,s,{stdio:`inherit`});return c.error?{ok:!1,error:`cannot launch editor "${n}": ${c.error.message}`}:c.status!=null&&c.status!==0?{ok:!1,error:`editor exited with code ${c.status}`}:{ok:!0,text:t.readFileSync(i).replace(/\n$/,``)}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}finally{if(r)try{t.rmSync(r,{recursive:!0,force:!0})}catch{}}}function Jr(){let e=r(`fs`),t=r(`os`),n=r(`path`),i=r(`child_process`);return{env:process.env,tmpdir:()=>t.tmpdir(),join:(...e)=>n.join(...e),mkdtempSync:t=>e.mkdtempSync(t),writeFileSync:(t,n)=>e.writeFileSync(t,n),readFileSync:t=>e.readFileSync(t,`utf8`),rmSync:(t,n)=>e.rmSync(t,n),spawnSync:(e,t,n)=>{let r=i.spawnSync(e,t,n);return{status:r.status,error:r.error}}}}const Yr=[/\bpassword\s*=/i,/\btoken\s*=/i,/export\s+\w*key\w*\s*=/i,/\bsecret\s*=/i];function Xr(e,t=Yr){return t.some(t=>t.test(e))}const Zr=`zsh-histfile`,Qr=/^: (\d+):(\d+);(.*)$/s;function $r(e){let t=[],n;for(let r of e){let e=n===void 0?r:`${n}\n${r}`;if(ei(r)){n=e.slice(0,-1);continue}t.push(e),n=void 0}return n!==void 0&&t.push(n),t}function ei(e){let t=0;for(let n=e.length-1;n>=0&&e[n]===`\\`;n--)t++;return t%2==1}function ti(e,t={}){let{source:n=Zr,sensitivePatterns:r,filterSensitive:i=!0}=t,a=[],o=0;for(let t of $r(e.split(`
@@ -49,11 +49,11 @@ import{$ as e,$t as t,A as n,An as r,At as i,B as a,Bt as o,C as s,Cn as c,Ct as
49
49
  `))}`);break}case`assistant_stream`:t.text.trim()&&n.push(`⏺ ${V.t(`transcript.assistant`)}\n${Cl(t.text)}`);break;case`tool`:{let e=t.args?`${t.name}(${wl(t.args,60)})`:t.name,r=t.result?` → ${t.isError?`${L.cross} `:``}${wl(t.result,200)}`:t.isError?` → ${L.cross}`:``;n.push(` ${L.toolResult} ${e}${r}`);break}case`summary`:{let e=t.status===`incomplete`?V.t(`status.stopped`):Sl(t.status),r=Number(t.tasksDone??0),i=Number(t.tasksTotal??0),a=Number.isFinite(r)?r:0,o=Number.isFinite(i)?i:0,s=t.status===`incomplete`&&t.tasksTotal!=null?` · ${V.t(`task.leftLabel`,{done:a,total:o,left:Math.max(0,o-a)})}`:``,c=typeof t.cacheHitRatio==`number`?`(${Math.round(t.cacheHitRatio*100)}%)`:``,l=t.tokensUsed==null?c?` · cache${c}`:``:` · ${xl(t.tokensUsed)}${c}`;n.push(`— ${e} · ${V.t(`tool.countLabel`,{count:t.toolCount})} · ${Math.round(t.elapsedMs/1e3)}s${l}${s}`);break}}return t.trim()&&n.push(`⏺ ${V.t(`transcript.assistant`)} (${V.t(`prompt.streaming`)})\n${Cl(t)}`),n.join(`
50
50
 
51
51
  `)}function El(e){let t=e.filter(e=>e!==null),n=Math.max(0,...t.map(e=>Oe(e.label)));return e.map(e=>{if(e===null)return``;let t=` `.repeat(Math.max(0,n-Oe(e.label))+1);return`${e.label}:${t}${e.value}`})}function Dl(e,t){let n=/^- \[(.+?)\]\(memory\/(.+?)\.md\)(?: — (.+))?$/gm,r=[],i;for(;(i=n.exec(e))!==null;)r.push({name:i[1]??``,slug:i[2]??``,description:(i[3]??``).trim(),source:t});return r}function Ol({projectIndex:e,userIndex:t,onViewEntry:n,onForget:r,onDismiss:i,rows:a=24,columns:o=80}){let[s,c]=K(()=>Dl(e,`project`)),[l,u]=K(()=>Dl(t,`user`)),[d,f]=K({mode:`list`}),[p,m]=K(void 0),h=s.length>0||l.length>0;function g(e){e.source===`project`?c(t=>t.filter(t=>t.slug!==e.slug)):u(t=>t.filter(t=>t.slug!==e.slug))}function _(e){m(`${e.source}:${e.slug}`),f({mode:`detail`,entry:e,content:null,loading:!0}),n(e).then(t=>{f(n=>n.mode===`detail`&&n.entry.slug===e.slug?{...n,content:t,loading:!1}:n)})}async function v(e){await r(e),g(e),f({mode:`list`})}return d.mode===`confirm-forget`?q(Ml,{entry:d.entry,onConfirm:()=>void v(d.entry),onCancel:()=>f({mode:`list`})}):d.mode===`detail`?q(Al,{entry:d.entry,content:d.content,loading:d.loading,onForget:()=>f({mode:`confirm-forget`,entry:d.entry}),onBack:()=>f({mode:`list`}),rows:a,columns:o}):q(kl,{projEntries:s,userEntries:l,hasAny:h,defaultValue:p,onView:_,onForget:e=>f({mode:`confirm-forget`,entry:e}),onDismiss:i,rows:a})}function kl({projEntries:e,userEntries:t,hasAny:n,defaultValue:r,onView:i,onForget:a,onDismiss:o,rows:s}){let c=new Map;for(let n of[...e,...t])c.set(`${n.source}:${n.slug}`,n);return n?q(B.Root,{rows:s,title:V.t(`cmd.titleMemory`),defaultValue:r,onCancel:o,onKey:(e,t,n)=>{if(e===`d`&&n){let e=c.get(n.value);return e&&a(e),!0}return!1},onValueChange:e=>{let t=c.get(e);t&&i(t)},footer:q(C,{items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.enter,V.t(`cmd.memoryDialogHintView`)],[`d`,V.t(`cmd.memoryDialogHintForget`)],[j.esc,V.t(`hint.close`)]]}),children:J(B.Content,{children:[J(B.Group,{children:[q(B.Label,{children:V.t(`cmd.memoryDialogProjGroup`,{count:e.length})}),e.map(e=>q(B.Item,{value:`project:${e.slug}`,detail:e.description||void 0,marker:`number`,children:e.name},`project:${e.slug}`))]}),q(B.Separator,{}),J(B.Group,{children:[q(B.Label,{children:V.t(`cmd.memoryDialogUserGroup`,{count:t.length})}),t.map(e=>q(B.Item,{value:`user:${e.slug}`,detail:e.description||void 0,marker:`number`,children:e.name},`user:${e.slug}`))]})]})}):q(F,{header:q(_e,{children:V.t(`cmd.titleMemory`)}),footer:q(C,{items:[[j.esc,V.t(`hint.close`)]]}),children:q(Y,{marginTop:I.tight,children:q(X,{dimColor:!0,children:V.t(`cmd.memoryDialogEmptyHint`)})})})}function Al({entry:e,content:t,loading:n,onForget:r,onBack:i,rows:a,columns:o}){let s=R(),c=e.source===`project`?V.t(`cmd.memoryDialogDetailSourceProject`):V.t(`cmd.memoryDialogDetailSourceUser`),l=V.t(`cmd.memoryDialogDetailTitle`,{name:e.name,source:c}),u=qt(()=>(t??``).split(`
52
- `),[t]);return n?q(jl,{title:l,onForget:r,onBack:i}):q(sc,{lines:u,rows:a,columns:o,wrapMode:`pre-wrap`,header:q(Y,{children:q(X,{color:s.selection,children:l})}),onDismiss:i,initialScroll:`top`,contentKey:e.slug,emptyMessage:V.t(`cmd.memoryDialogDetailEmpty`),onKey:e=>e===`d`?(r(),!0):!1,extraHints:[[`d`,V.t(`cmd.memoryDialogHintForget`)]]})}function jl({title:e,onForget:t,onBack:n}){return D(`memory-dialog-detail-loading`,(e,r)=>{if(r.escape){n();return}e===`d`&&t()}),q(F,{header:q(_e,{children:e}),footer:q(C,{items:[[j.esc,V.t(`cmd.memoryDialogHintBack`)]]}),children:q(Y,{marginTop:I.tight,children:q(X,{dimColor:!0,children:`…`})})})}function Ml({entry:e,onConfirm:t,onCancel:n}){let r=R(),[i,a]=K(0);return D(`memory-dialog`,(e,r)=>{if(r.escape){n();return}if(r.leftArrow||r.rightArrow||r.tab){let e=O(r);e!==0&&a(t=>ee(t,e,2));return}r.return&&(i===1?t():n())}),q(F,{header:q(_e,{children:V.t(`cmd.memoryDialogConfirmForgetTitle`)}),children:J(Y,{marginTop:I.tight,flexDirection:`column`,children:[q(X,{color:r.warning,children:V.t(`cmd.memoryDialogConfirmForgetMessage`,{name:e.name})}),J(Y,{marginTop:I.section,flexDirection:`row`,gap:I.section,children:[q(Ne,{variant:`solid`,brackets:!0,label:V.t(`common.genericCancelButton`),focused:i===0,color:`gray`}),q(Ne,{variant:`solid`,brackets:!0,label:V.t(`hint.delete`),focused:i===1,color:`red`})]})]})})}function Nl(e){return e.replace(/\s+/g,` `).trim()}function Pl({req:e,rows:t=24}){let{entries:n,menuContributions:r=[],onSelect:i,onCancel:a}=e,o=n.filter(e=>e.enabled).length,s=n.length>0?V.t(`cmd.extListTitle`,{enabled:o,total:n.length}):V.t(`cmd.extListEmptyTitle`),c=r.find(e=>e.id===`__discover__`),l=r.filter(e=>e.id!==`__discover__`),u=c?{hint:V.t(`cmd.extDiscoverHint`),label:V.t(`cmd.extDiscoverButton`),onPress:()=>i(`contrib:${c.id}`)}:void 0;if(n.length===0)return q(B.Root,{title:s,headerAction:u,onCancel:a,rows:t,extensionHeightBudget:!0,children:q(B.Content,{children:q(B.Item,{value:``,children:V.t(`cmd.extListEmptyOption`)})})});let d=new Map;for(let e of n){let t=V.t(`cmd.extCategoryLabel`,{category:e.category}),n=d.get(t);n?n.push(e):d.set(t,[e])}let f=e=>e.name;return q(B.Root,{title:s,headerAction:u,onValueChange:i,onCancel:a,rows:t,extensionHeightBudget:!0,defaultValue:e.lastSelectedValue,detailPlacement:`inline`,children:J(B.Content,{children:[[...d.entries()].map(([e,t])=>J(B.Group,{children:[q(B.Label,{children:e}),t.map(e=>{let t=[];e.enabled||t.push(V.t(`cmd.extStateDisabled`)),e.description&&t.push(e.description),e.applies&&e.applies!==`live`&&t.push(V.t(`cmd.extAppliesNextTurn`));let n=t.length>0?Nl(t.join(` · `)):void 0;return q(B.Item,{value:`${e.category}:${e.id}`,detail:n,children:f(e)},`${e.category}:${e.id}`)})]},e)),l.length>0&&J(B.Group,{children:[q(B.Label,{children:V.t(`cmd.extCategoryLabel`,{category:`plugin`})}),l.map(e=>q(B.Item,{value:`contrib:${e.id}`,children:e.title},`contrib:${e.id}`))]},`contrib`)]})})}const Fl={y:0,n:1,a:2};function Il({tool:e,input:t,risk:n,onApprove:r,onDeny:i}){let a=R(),[o,s]=K(0),c=Xe(n),l=e=>{e===0?r(`once`):e===1?i():r(`always`)};return D(`permission-dialog-buttons`,(e,t)=>{if(t.escape)return i(),!0;let n=O(t);if(n!==0)return s(e=>ee(e,n,3)),!0;if(t.return)return s(e=>(l(e),e)),!0;let r=Fl[e.toLowerCase()];return r===void 0?!1:(l(r),!0)}),J(F,{header:J(_e,{children:[V.t(`permission.allowTool`),` `,q(X,{color:a.permission,children:e}),` `,J(X,{color:c,children:[`(`,V.t(`permission.riskLabel`,{context:n}),`)`]})]}),footer:q(C,{items:[[`${j.left}${j.right}`,V.t(`hint.switch`)],[j.enter,V.t(`hint.confirm`)],[`y/n/a`,V.t(`hint.shortcut`)],[j.esc,V.t(`hint.cancel`)]]}),children:[q(Y,{marginTop:I.tight,children:q(X,{dimColor:!0,children:P(t,200)})}),J(Y,{marginTop:I.tight,flexDirection:`row`,gap:I.section,children:[q(Ne,{variant:`solid`,brackets:!0,color:`accent`,label:V.t(`permission.approve`),focused:o===0}),q(Ne,{variant:`solid`,brackets:!0,color:`red`,label:V.t(`permission.deny`),focused:o===1}),q(Ne,{variant:`solid`,brackets:!0,color:`amber`,label:V.t(`permission.alwaysAllow`),focused:o===2})]})]})}function Ll(e){let t=/^\s*cd\s+(.+?)\s*&&\s*(.*)$/s.exec(e);return t?{workDir:t[1]}:{workDir:null}}const Rl={y:0,n:1,a:2},zl={y:0,n:1};function Bl({command:e,risk:t,description:n,alwaysAllowLabel:r,onApprove:i,onDeny:a}){let o=R(),[s,c]=K(0),l=Xe(t),u=r!=null,d=u?3:2,f=u?Rl:zl,p=e=>{e===0?i(`once`):e===1?a():i(`always`)};D(`bash-permission-dialog-buttons`,(e,t)=>{if(t.escape)return a(),!0;let n=O(t);if(n!==0)return c(e=>ee(e,n,d)),!0;if(t.return)return c(e=>(p(e),e)),!0;let r=f[e.toLowerCase()];return r===void 0?!1:(p(r),!0)});let{workDir:m}=Ll(e),h=P(e,500);return J(F,{header:J(_e,{children:[V.t(`permission.bashCommand`),` `,J(X,{color:l,children:[`(`,V.t(`permission.riskLabel`,{context:t}),`)`]})]}),footer:q(C,{items:[[`${j.left}${j.right}`,V.t(`hint.switch`)],[j.enter,V.t(`hint.confirm`)],[u?`y/n/a`:`y/n`,V.t(`hint.shortcut`)],[j.esc,V.t(`hint.cancel`)]]}),children:[q(Y,{marginTop:I.tight,children:q(X,{color:o.suggestion,children:h})}),(m||n)&&J(Y,{marginTop:I.tight,flexDirection:`column`,children:[m&&q(X,{dimColor:!0,children:m}),n&&q(X,{dimColor:!0,children:n})]}),r&&J(Y,{marginTop:I.tight,children:[J(X,{dimColor:!0,children:[V.t(`permission.alwaysAllow`),`: `]}),q(X,{color:o.suggestion,children:r})]}),J(Y,{marginTop:I.tight,flexDirection:`row`,gap:I.section,children:[q(Ne,{variant:`solid`,brackets:!0,color:`accent`,label:V.t(`permission.approve`),focused:s===0}),q(Ne,{variant:`solid`,brackets:!0,color:`red`,label:V.t(`permission.deny`),focused:s===1}),u&&q(Ne,{variant:`solid`,brackets:!0,color:`amber`,label:V.t(`permission.alwaysAllow`),focused:s===2})]})]})}function Vl({title:e,message:t,okLabel:n,onOk:r}){let i=Array.isArray(t)?t:[t];return T({tabIndex:0,id:`alert-ok`,onAction:()=>(r(),!0),onEscape:()=>(r(),!0)}),D(`alert-dialog`,(e,t)=>t.return||t.escape?(r(),!0):!1),J(F,{header:q(_e,{children:e}),footer:q(C,{items:[[`${j.enter}/${j.esc}`,V.t(`hint.close`)]]}),children:[q(Y,{marginTop:I.tight,flexDirection:`column`,children:i.map((e,t)=>q(X,{wrap:`truncate-end`,children:e===``?` `:e},t))}),q(Y,{marginTop:I.tight,children:q(Ne,{variant:`solid`,brackets:!0,color:`accent`,label:n??V.t(`common.okButton`),focused:!0})})]})}function Hl({title:e,message:t,placeholder:n,initialValue:r=``,submitLabel:i,cancelLabel:a,columns:o=60,onSubmit:s,onCancel:c}){let[u,d]=K(r),[f,p]=K(r.length),[m,h]=K(`input`),g=t?Array.isArray(t)?t:[t]:[],_=(e,t)=>{d(e),p(t)};return D(`prompt-dialog`,(e,t)=>{if(t.escape){c();return}if(t.return&&m===`input`){u.trim()!==``&&h(`submit`);return}if(t.return){m===`submit`&&u.trim()!==``?s(u):c();return}if(t.tab||t.ctrl&&e===`n`){h(e=>e===`input`?`submit`:e===`submit`?`cancel`:`input`);return}if(t.leftArrow&&m!==`input`){h(e=>`submit`);return}if(t.rightArrow&&m!==`input`){h(e=>`cancel`);return}if(m!==`input`)return;if(e.length>1&&!t.ctrl&&!t.meta&&!t.return&&!t.escape&&!t.backspace&&!t.delete&&!t.tab&&!t.upArrow&&!t.downArrow&&!t.leftArrow&&!t.rightArrow){let t=ke(e);t&&_(u.slice(0,f)+t+u.slice(f),f+t.length);return}if(t.leftArrow){let e=l.fromText(u,o,f).left();_(e.text,e.offset);return}if(t.rightArrow){let e=l.fromText(u,o,f).right();_(e.text,e.offset);return}let n={name:t.backspace?`backspace`:t.delete?`delete`:e||`unknown`,ctrl:t.ctrl??!1,shift:!1,alt:t.meta??!1,meta:t.meta??!1},r=Tt(l.fromText(u,o,f),n);if(r){if(r.action===`clear_text`){_(``,0);return}r.action===`submit`||r.action===`submit_force`||_(r.cursor.text,r.cursor.offset)}}),J(F,{header:q(_e,{children:e??V.t(`prompt.defaultTitle`)}),footer:q(C,{items:[[j.enter,V.t(`hint.confirm`)],[j.esc,V.t(`hint.cancel`)]]}),children:[g.length>0&&q(Y,{marginTop:I.tight,flexDirection:`column`,children:g.map((e,t)=>q(X,{wrap:`truncate-end`,children:e===``?` `:e},t))}),q(Y,{marginTop:I.tight,flexDirection:`row`,children:q(dt,{value:u,offset:f,columns:o,mode:`dialog`,placeholder:n,focused:m===`input`,physicalCursor:m===`input`})}),J(Y,{marginTop:I.tight,flexDirection:`row`,gap:I.section,children:[q(Ne,{variant:`solid`,brackets:!0,color:`accent`,label:i??V.t(`prompt.submitButton`),focused:m===`submit`,disabled:u.trim()===``}),q(Ne,{variant:`solid`,brackets:!0,color:`gray`,label:a??V.t(`common.genericCancelButton`),focused:m===`cancel`})]})]})}function Ul(){return{toast:null,retryCountdown:null,errorRetry:null,providerUsage:null,notifications:[],paused:!1,pauseDialog:null,pausePending:null,pulseSurvey:null}}function Wl(){let e=Xn(Ul()),t,n={};return{store:e,reset(){e.setState(Ul())},setNotify(e){t=e},setEffects(e){n=e},setProviderUsage(n){e.setState({providerUsage:n}),t?.()},setPausePending(n){e.setState({pausePending:n}),t?.()},setPaused(r){e.setState({paused:r}),r||n.drainQueueOnResume?.(),t?.()},setPulseSurvey(r){e.setState({pulseSurvey:r}),n.syncPulseSurveyRoute?.(r!==null),t?.()}}}function Gl(e,t){return{role:`history_capped`,removedCount:e,trigger:t}}const Kl=e=>{try{return JSON.stringify(e).length}catch{return 0}};function ql(e,t=Mn,n=jn){let r=e.filter(e=>e.role!==`history_capped`);if(r.length===0)return e;let i=0,a=null;r.length>t&&(i+=r.length-t,r.splice(0,i),a=`count`);let o=r.map(Kl),s=o.reduce((e,t)=>e+t,0);if(s>n){let e=0;for(;e<o.length-1&&s>n;)s-=o[e],e++,i++;r.splice(0,e),a=`bytes`}return i===0?e:[...r,Gl(i,a??`count`)]}function Jl(){let e=Xn({messages:[]}),t=t=>{e.setState({messages:ql(t)})};return{store:e,append(n,r,i){t([...e.getState().messages,{...n,id:n.id??r,...i==null?{}:{seq:i}}])},appendMany(n,r){n.length!==0&&t([...e.getState().messages,...n.map(e=>({...e,id:e.id??r()}))])},prependMany(n){if(n.length===0)return;let r=e.getState();t([...n.map(e=>({...e})),...r.messages])},patchLast(n){let r=e.getState();if(r.messages.length===0)return;let i=r.messages[r.messages.length-1];t([...r.messages.slice(0,-1),{...i,...n}])},patchById(n,r){let i=e.getState(),a=i.messages.findIndex(e=>e.id===n);if(a===-1)return;let o=i.messages[a],s=[...i.messages];s[a]={...o,...r},t(s)},removeLast(){let n=e.getState();n.messages.length!==0&&t(n.messages.slice(0,-1))},removeById(n){let r=e.getState(),i=r.messages.findIndex(e=>e.id===n);if(i===-1)return;let a=[...r.messages];a.splice(i,1),t(a)},reset(){e.setState({messages:[]})}}}const Yl=[{label:`Tool guidance`,lane:`stable`,priority:20},{label:`Environment`,lane:`stable`,priority:25},{label:`Memory index`,lane:`stable`,priority:35},{label:`Skill catalog`,lane:`stable`,priority:38},{label:`Lesson`,lane:`stable`,priority:40},{label:`Memory delta`,lane:`volatile`,priority:60},{label:`TODO reminder`,lane:`volatile`,priority:62}];function Xl(e){let t=Yl.length,n=Math.round(e/t);return Yl.map(e=>({label:e.label,lane:e.lane,estimatedTokens:n}))}function Zl(){let e=Xn({open:!1,conversationTurns:[],systemSections:[],modelName:``,contextWindow:0,contextPercent:0,totalUsed:0,free:0});return{store:e,toggle(t){e.setState({open:t??!e.getState().open})},reset(){e.setState({open:!1,conversationTurns:[],systemSections:[],modelName:``,contextWindow:0,contextPercent:0,totalUsed:0,free:0})},addTurn(t){let n=[...e.getState().conversationTurns,t];e.setState({conversationTurns:n.length>Mn?n.slice(n.length-Mn):n})},markTurns(t){let{turnIndex:n,...r}=t,i=e.getState().conversationTurns.map(e=>e.turnIndex===n?{...e,...r}:e);e.setState({conversationTurns:i})},setBudget(t){e.setState({modelName:t.modelName,contextWindow:t.contextWindow,contextPercent:t.contextPercent,totalUsed:t.totalUsed,free:t.free,systemSections:Xl(t.overheadTokens)})}}}const Ql=Wt(void 0),$l=Ql.Provider;function eu(){let e=Kt(Ql);if(!e)throw Error(`useAppStoresContext must be used within <AppStoresProvider>`);return e}const tu=[`/pane/tasks`,`/pane/delegates`,`/pane/edited-files`,`/pane/subagents`,`/pane/schedule`,`/pane/clipboard`];function nu(e){return tu.includes(e)}const ru=[`taskFocus`,`background`,`editedFiles`,`subagents`,`schedule`,`clipboard`];function iu(e){return nu(e)||e===`/overlay/paste-confirm`}function au(e){return e===`/`||nu(e)||e===`/overlay/paste-confirm`}function ou(e){return e===`prompt`||ru.includes(e)}function su(){z()?.navigate(`/`,{reset:!0})}function cu(){let{currentPath:e}=me();return e===`/`?`prompt`:e===`/home`?`home`:e===`/pane/delegates`||e===`/pane/delegates/output`?`background`:e===`/pane/edited-files`?`editedFiles`:e.startsWith(`/pane/edited-files/`)?`editedFileFull`:e===`/subagent`?`subagentContext`:e===`/pane/subagents`?`subagents`:e===`/pane/clipboard`?`clipboard`:e===`/pane/schedule`?`schedule`:e===`/pane/tasks`?`taskFocus`:e.startsWith(`/pane/tasks/`)?`taskDetail`:e===`/pane/draft`?`draft`:e===`/pane/queue`?`queue`:e.startsWith(`/pane/queue/`)?`queueEdit`:e===`/pane/shell`?`shell`:e===`/pane/sigil`?`sigilPane`:e===`/pane/perf`?`perf`:e===`/pane/cache`?`cacheStats`:e===`/pane/compaction-log`?`compactionLog`:e===`/pane/gallery`?`gallery`:e===`/pane/notifications`?`notifications`:e===`/pane/proxy`?`proxy`:e===`/pane/prompts`?`prompts`:e===`/pane/context`?`info`:(e.startsWith(`/dialog/`)||e.startsWith(`/viewer/`),`prompt`)}const lu=`onA2uiAction.onAlertResolve.onBackToContextPane.onBackgroundApply.onBackgroundClose.onBackgroundDelete.onBackgroundKill.onBackgroundOutputClose.onBackgroundSwitch.onBackgroundViewOutput.onCacheDismiss.onCancelUpgrade.onCloseNotifications.onCompactionLogDismiss.onContextDismiss.onConfirmResolve.onCyclePermissionMode.onDelegateSupply.onDismissNotification.onDismissToast.onDraftDelete.onDraftDeleteMany.onDraftSave.onErrorRetryFocusChange.onExitSubagentContext.onFocusOwnerChange.onScrollActiveChange.onGalleryDismiss.onHistoryPush.onInfoDismiss.onInputAction.onInputResolve.onOnboardingResolve.onInterrupt.onKeybindingPanelDismiss.onMemoryDismiss.onPaneOwnsViewportChange.onPerfDismiss.onPerfRefresh.onPermissionDecision.onPopQueued.onPromptResolve.onProxyClear.onProxyTest.onProxyDismiss.onProxyOpenModal.onProxySubmitUrl.onProxyToggleEnabled.onPulseSurveyChange.onQuestionsResolve.onQueueDelete.onQueueEditText.onQueueMove.onQueueSendNow.onSelectResolve.onSessionSelect.onInstallCapability.onDismissCapabilityRecommendations.onShellAbort.onShellAskAi.onShellCopyOutput.onShellDismiss.onShortcutsDialogDismiss.onSigilSelect.onSubmit.onToast.onToggleDelegates.onToggleDraftPane.onToggleEditedFiles.onToggleNotifications.onToggleQueuePane.onTogglePrompts.onToggleSchedule.onToggleSubagents.onUpgrade.onViewDetails.onWithdrawPending.onWithdrawSteer`.split(`.`);function uu(e){let t={};for(let n of lu)t[n]=e[n];return t}const du=Wt(null),fu=du.Provider;function pu(){let e=Kt(du);if(!e)throw Error(`useAppCallbacks must be used within AppCallbacksProvider`);return e}function mu(e){let{editedFilesLength:t,queuedItemsLength:n,subagentContext:r,backgroundOutput:i}=e,{onPaneOwnsViewportChange:a}=pu(),{currentPath:o}=me(),[s,c]=K(null),[l,u]=K(null),[d,f]=K(null),p=Gt(e=>{f(e),e?z()?.navigate(`/viewer/shell-output`):z()?.goBack()},[]),[m,h]=K(null),[g,_]=K(!1),[v,y]=K(!1),[b,x]=K(!1),[S,C]=K(!1),[w,T]=K(``),E=!!r||s!==null||!!i||l!=null,D=Gt(e=>{a?.(!0),c(e),z()?.navigate(`/pane/edited-files/${e}`)},[a]),ee=Gt(()=>{a?.(l!=null),c(null),z()?.goBack()},[a,l]),te=Gt(e=>{a?.(!0),u(e),z()?.navigate(`/pane/tasks/${e}`)},[a]),O=Gt(()=>{a?.(s!==null),u(null),z()?.goBack()},[a,s]);return W(()=>{let e=o.startsWith(`/pane/edited-files/`)?s:null,t=o.startsWith(`/pane/tasks/`)?l:null;e!==s&&c(e),t!==l&&u(t),(e!==s||t!==l)&&a?.(e!==null||t!=null),m!==null&&o!==`/pane/queue/edit`&&(h(null),_(!1),y(!1)),d&&!o.startsWith(`/viewer/shell-output`)&&f(null)},[o,s,a,m,d,l]),W(()=>{s!==null&&s>=t&&(a?.(l!=null),c(null),z()?.goBack())},[s,t,l,a]),W(()=>{m!==null&&m>=n&&(h(null),_(!1),y(!1),o===`/pane/queue/edit`&&z()?.goBack())},[o,m,n]),{editedFileFullIndex:s,openEditedFileFull:D,closeEditedFileFull:ee,taskDetailTurn:l,openTaskDetail:te,closeTaskDetail:O,shellFullOutput:d,setShellFullOutput:p,queueEditIndex:m,setQueueEditIndex:h,queueCloseConfirm:g,setQueueCloseConfirm:_,queueEscSuppress:v,setQueueEscSuppress:y,interruptConfirm:b,setInterruptConfirm:x,popQueuedConfirm:S,setPopQueuedConfirm:C,supplyDraft:w,setSupplyDraft:T,fullScreenPaneActive:E}}let hu=null;function gu(e){hu=e}function _u(){let e=hu;return e?.hasSelection()?(e.clear(),!0):!1}function vu(e,t){let n=e.getState().offset;return e.subscribe(()=>{let r=e.getState().offset;r!==n&&(n=r,t())})}function yu(e){let{showHome:t,tasksLength:n,backgroundTasksLength:r,editedFilesLength:i,subagentsLength:a,draftsLength:o,draftOpen:s,queuedItemsLength:c,queueOpen:l,clipboardHasContent:u,shellExecutionRunning:d,routeDerivedOwner:f,currentPath:p,backgroundOutput:m,a2uiButtons:h,scrollOffset:g,editedFilesOpen:_,subagentsOpen:v,setTasksCollapsed:y,keybindingOverrides:b,promptSuggestions:S,onFillPromptSuggestion:C,isPromptDraftEmpty:w,capabilityCardShown:T,capabilityItemIds:E,onInstallCapability:D,onDismissCapabilityRecommendations:ee}=e,{onToggleDelegates:te,onToggleEditedFiles:O,onToggleSubagents:ne,onToggleDraftPane:k,onToggleQueuePane:re,onShellAbort:A,onInterrupt:ie,onA2uiAction:j,onCyclePermissionMode:ae,onToggleNotifications:se,onSubmit:M}=pu(),N=Gt(()=>{let e=z();e&&e.currentPath!==`/`&&e.navigate(`/`,{reset:!0})},[]),P=Gt(e=>{let o=z();if(!o)return!1;let s=[{path:`/`,activate:()=>N()},...t?[{path:`/home`,activate:()=>o.navigate(`/home`,{replace:!0})}]:[],...n>0?[{path:`/pane/tasks`,activate:()=>o.navigate(`/pane/tasks`,{replace:!0})}]:[],...r>0?[{path:`/pane/delegates`,activate:()=>{te?.()}}]:[],...i>0?[{path:`/pane/edited-files`,activate:()=>{O?.()}}]:[],...a>0?[{path:`/pane/subagents`,activate:()=>{ne?.()}}]:[],...u?[{path:`/pane/clipboard`,activate:()=>{o.navigate(`/pane/clipboard`,{replace:!0})}}]:[]];return s.length<=1?!1:(s[(Math.max(0,s.findIndex(e=>o.currentPath===e.path||o.currentPath.startsWith(e.path+`/`)))+e+s.length)%s.length]?.activate(),!0)},[r,N,s,o,i,te,k,O,re,ne,l,c,t,a,n,u]);Ft(`app-global-prelude`,(e,t)=>t.ctrl&&e===`c`?d?(A?.(),!0):(ie?.(),!0):!1),pe(`selection-escape`,(e,t)=>!t.escape||t.ctrl||t.meta||t.shift?!1:iu(p)?(_u(),!1):_u()),x(`app-prompt-global`,(e,r)=>{if(r.tab&&!r.ctrl&&!r.meta&&!r.shift)return p.startsWith(`/dialog/`)||p.startsWith(`/viewer/`)||bt(p)||![`prompt`,`home`,`taskFocus`,`background`,`editedFiles`,`subagents`,`schedule`,`draft`,`queue`,`clipboard`].includes(f)||p===`/pane/delegates`&&m?!1:P(r.shift?-1:1);let i=w?.()??!0;if(i&&g===0&&h&&h.length>0&&e>=`1`&&e<=`9`&&!r.ctrl&&!r.meta){let t=h.find(t=>t.key===e);if(t&&j)return j(t.componentId,t.action,t.payload),!0}if(i&&t&&S&&S.length>0&&e>=`1`&&e<=`9`&&!r.ctrl&&!r.meta){let t=S[Number(e)-1];if(t&&C)return C(t),!0}if(i&&t&&T&&E&&E.length>0&&!r.ctrl&&!r.meta){if(e===`0`)return ee?.(),!0;if(e>=`1`&&e<=`9`){let t=E[Number(e)-1];if(t&&D)return D(t),!0}}if(p===`/`&&r.ctrl&&e===`k`)return!1;let a=et(ze,f,e,r,b);if(a===`smart-close`)return p===`/pane/tasks`?(su(),!0):_?(O?.(),!0):v?(ne?.(),!0):(n>0?(y(()=>!1),z()?.navigate(`/pane/tasks`,{replace:!0})):y(e=>!e),!0);let o={"cycle-permission-mode":()=>{ae?.()},"toggle-notifications":()=>{se?.()},"toggle-edited-files":()=>{O?.()},"toggle-subagents":()=>{ne?.()},"toggle-delegates":()=>{te?.()},"toggle-draft-pane":()=>{k?.()},"toggle-queue-pane":()=>{re?.()},"open-keybinding-panel":()=>{M?.(`/keybindings`,`send`)}};return a&&o[a]?(o[a](),!0):!1});let ce=oe();$t((e,t)=>{ce.dispatch(e,t)})}function bu(e){let t=e>=60,n=e>=76,r=e>=100;return{modelName:!0,occupancyBar:!0,hintText:!0,permissionMode:t,perfIndicator:t,notificationBell:t,backgroundTaskIndicator:t,scheduleIndicator:t,serviceIndicator:t,cost:n,providerUsage:n,language:n,pluginStatusItems:r,liveClock:r}}const xu={narrow:0,medium:1,low:2};function Su(e){return e.map((e,t)=>({entry:e,index:t})).sort((e,t)=>{let n=xu[e.entry.tier]-xu[t.entry.tier];if(n!==0)return n;if(e.entry.isHost!==t.entry.isHost)return e.entry.isHost?-1:1;let r=(e.entry.order??0)-(t.entry.order??0);return r===0?e.index-t.index:r}).map(e=>e.entry)}const Cu=new Map;function wu(e){let t=Cu.get(e);return t||(t={consecutiveSlowCalls:0,tripped:!1},Cu.set(e,t)),t}function Tu(){Cu.clear()}function Eu(e,t){let n=wu(e.id);if(n.tripped)return null;let r=Date.now(),i=null;try{i=e.render(t)}catch{i=null}if(Date.now()-r>5){if(n.consecutiveSlowCalls+=1,n.consecutiveSlowCalls>=3)return n.tripped=!0,null}else n.consecutiveSlowCalls=0;return i}function Du(e){let t;for(let n of e){if(n.tickMs===void 0)continue;let e=Math.max(1e3,n.tickMs);(t===void 0||e<t)&&(t=e)}return t}function Ou(e){let{columns:t,permissionMode:n,cost:r,providerUsage:i,pluginStatusItems:a,statusWidgets:o,modelName:s}=e,[c,l]=K(0);W(()=>{if(!i)return;let e=setInterval(()=>l(e=>e+1),3e4);return()=>clearInterval(e)},[i]);let[u,d]=K(0);W(()=>{let e=Du(o);if(e===void 0)return;let t=setInterval(()=>d(e=>e+1),e);return()=>clearInterval(t)},[o]);let f=qt(()=>bu(t),[t]);return{footerVisible:f,badgeEntries:qt(()=>{let e=[];if(f.permissionMode&&n&&e.push({id:`host:permission-mode`,text:V.t(`pref.permModeLabel`,{context:n}),color:n===`bypass`?`warning`:`inactive`,separator:`dot`,tier:`narrow`,isHost:!0}),f.cost&&r&&e.push({id:`host:cost`,text:r,separator:`space`,tier:`medium`,isHost:!0}),f.providerUsage&&i){let t=Date.now(),n=Kn(i,t);n&&e.push({id:`host:provider-usage`,text:n,color:Yn(i.status,i.limitType,i.usedPercent,i.resetsAt,t,i.overageStatus),separator:`dot`,tier:`medium`,isHost:!0})}if(f.pluginStatusItems&&a)for(let t of a)e.push({id:t.id,text:t.text,separator:`space`,tier:`low`,isHost:!1});if(f.pluginStatusItems&&o.length>0){let n={nowMs:Date.now(),model:s,providerUsage:i,columns:t};for(let t of o){let r=Eu(t,n);r&&e.push({id:t.id,text:r.text,color:r.color,separator:`space`,tier:`low`,isHost:!1,order:t.order})}}return Su(e)},[f,n,r,i,c,a,o,u,s,t])}}function ku(e){let{shellExecution:t,subagentContext:n,agentProcessing:r,queuedItems:i,pendingEcho:a,pendingSteers:o,onRequestPopQueuedConfirm:s}=e,{onExitSubagentContext:c,onPopQueued:l,onInterrupt:u,onWithdrawPending:d,onWithdrawSteer:f}=pu();return Gt(()=>{if(!t){if(n){c?.();return}if(r){if(i.length>0){s?s():l?.();return}if(o&&o.length>0){let e=o[o.length-1];e&&f?.(e.id);return}if(a){d?.(a.text,a.mode);return}u?.();return}}},[t,n,c,r,i,a,o,l,u,d,f,s])}let Au=null;function ju(e){Au=e}function Mu(){return Au}function Nu(){let[e,t]=K(null),n=G(null),r=Gt(e=>{n.current=e,t(e),!e&&z()?.currentPath===`/pane/sigil`&&z()?.goBack()},[]),i=G(null),[a,o]=K(null),s=G(!1),[c,l]=K(null),u=G(null),d=Gt((e,t,n)=>{i.current=n,r({sigil:e,query:t,mode:`sigil`}),z()?.navigate(`/pane/sigil`)},[]),f=Gt(()=>{if(n.current?.mode===`history`){r(null);return}i.current=null,r({sigil:`#`,query:``,mode:`history`}),z()?.navigate(`/pane/sigil`)},[]);return W(()=>(ju(f),()=>ju(null)),[f]),{sigilState:e,setSigilState:r,sigilApplyRef:i,hadSigilFocusRef:s,chipContentViewerRequest:a,pasteContent:c,handleSigilTrigger:d,handleHistorySearch:f,handleChipReopen:Gt((e,n,r)=>{i.current={select:r.select,cancel:()=>r.cancel()},t({sigil:`@`,query:``}),z()?.navigate(`/pane/sigil`)},[]),handleChipViewPaste:Gt((e,t)=>{ot(z(),_,!0),o({label:e,content:t,onDismiss:()=>{o(null),ot(z(),_,!1)}})},[]),handleSigilClose:Gt(()=>{r(null)},[]),handlePasteConfirmRequest:Gt((e,t)=>{u.current=t,l(e),ot(z(),S,!0)},[]),handlePasteConfirm:Gt(()=>{u.current?.confirm(),u.current=null,l(null),ot(z(),S,!1)},[]),handlePasteCancel:Gt(()=>{u.current?.cancel(),u.current=null,l(null),ot(z(),S,!1)},[])}}function Pu(e){let{sigilState:t,setSigilState:n,sigilApplyRef:r,hadSigilFocusRef:i,focusOwner:a,preempted:o}=e;W(()=>{if(!t){i.current=!1;return}if(a===`sigilPane`&&!o){i.current=!0;return}i.current&&=(n(null),r.current?.cancel(!1),!1)},[t,a,o])}function Fu(){let e=Xn({budget:null});return{store:e,setBudget(t){e.setState({budget:t})},reset(){e.setState({budget:null})}}}function Iu(e,t){return e.toolCallId&&t.toolCallId&&e.toolCallId===t.toolCallId?{...e,...t}:{...e,...t,oldContent:e.oldContent??t.oldContent,newContent:t.newContent??e.newContent,addedLines:e.addedLines+t.addedLines,removedLines:e.removedLines+t.removedLines,timestamp:Math.max(e.timestamp,t.timestamp),turnId:t.turnId??e.turnId,toolCallId:t.toolCallId??e.toolCallId}}function Lu(e){let t=e.split(`/`);return t.length<=3?e:`…/${t.slice(-2).join(`/`)}`}function Ru(e){switch(e){case`edit`:return`~`;case`write`:return`+`;case`delete`:return`-`}}function zu(e,t){switch(e){case`edit`:return t.accent;case`write`:return t.success;case`delete`:return t.error}}function Bu({files:e,focused:r,onDismiss:i,onOpenFileFull:a,fullOpenIndex:o=null,rows:s=24}){let c=R(),[l,u]=ra(`editedFiles`,e.length),d=G(0);if(D(`edited-files-pane`,(t,n)=>n.escape?o===null?(z()?.navigate(`/`,{reset:!0}),i?.(),!0):!0:Me(`list-nav-up`,t,n,`editedFiles`)?(u(e=>Math.max(0,e-1)),!0):Me(`list-nav-down`,t,n,`editedFiles`)?(u(t=>Math.min(e.length-1,t+1)),!0):n.return?(a?.(l),!0):!1,{isActive:r}),e.length===0)return null;let f=e.reduce((e,t)=>e+t.addedLines,0),p=e.reduce((e,t)=>e+t.removedLines,0),m=Math.min(l,e.length-1),h=Ct(e,m,n(e.length,s,3),d.current);return d.current=h.scrollTop,J(Y,{flexDirection:`column`,marginTop:I.tight,children:[J(Y,{children:[q(X,{color:c.special,children:`▸ `}),q(X,{color:r?c.text:c.inactive,children:V.t(`panelTitle.editedFilesTitle`)}),J(A,{type:`secondary`,children:[` `,V.t(`diff.fileCountLabel`,{count:e.length})]}),f>0&&J(X,{color:c.diffAdd,children:[` +`,f]}),p>0&&J(X,{color:c.diffRemove,children:[` -`,p]}),!r&&J(A,{type:`secondary`,dim:!0,children:[` `,t(`v`)]}),r&&q(Y,{marginLeft:I.tight,children:q(C,{dim:!0,items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.enter,V.t(`hint.view`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]})})]}),J(Y,{marginLeft:I.section,flexDirection:`column`,children:[h.hasMoreAbove&&q(X,{dimColor:!0,children:V.t(`scroll.above`,{n:1})}),h.rows.map((e,t)=>{let n=h.scrollTop+t===m,i=n&&r?c.selection:c.inactive;return J(Y,{flexDirection:`row`,children:[q(X,{color:i,children:n?Nt():wt()}),J(X,{color:zu(e.operation,c),children:[Ru(e.operation),` `]}),q(X,{color:i,children:Lu(e.path)}),e.addedLines>0&&J(X,{color:c.diffAdd,children:[` +`,e.addedLines]}),e.removedLines>0&&J(X,{color:c.diffRemove,children:[` -`,e.removedLines]})]},`${e.path}-${e.timestamp}`)}),h.hasMoreBelow&&q(X,{dimColor:!0,children:V.t(`scroll.below`,{n:1})})]})]})}function Vu(e={}){return{tasks:[],tasksTitle:void 0,turnBoundaries:[],editedFiles:[],backgroundTasks:[],subagentsAccum:new Map,scheduleTasks:[],drafts:e.drafts??[],queued:[],pendingPermission:null,clipboardChars:0,clipboardText:``,clipboardFailed:!1,clipboardJustCopied:!1,backgroundOutput:null,subagentContext:null,forcedUpgrade:null,pendingEcho:null,pendingSteers:[],modelName:e.modelName??``,pluginStatusItems:[],statusWidgets:[],needsSetup:e.needsSetup??!1,permissionMode:e.permissionMode??`auto`,commands:e.commands??[],paneOwnsViewportFlag:!1,shellExecution:null,recentMentions:e.recentMentions??[],sessionList:[],sessionTitle:``,ftueStage:void 0,capabilityRecommendations:[],capabilityDismissed:!1}}function Hu(e={}){let t=Xn(Vu(e)),n,r={},i=()=>n?.();return{store:t,reset(){t.setState(Vu(e))},setNotify(e){n=e},setEffects(e){r=e},actions:{setTasks(e,n){t.setState({tasks:e}),t.setState({tasksTitle:n}),i()},setEditedFiles(e){t.setState({editedFiles:e.sort((e,t)=>t.timestamp-e.timestamp)}),i()},addEditedFile(e){let n=[...t.getState().editedFiles],r=n.findIndex(t=>t.path===e.path);r>=0?n[r]=Iu(n[r],e):n.push(e),n.sort((e,t)=>t.timestamp-e.timestamp),t.setState({editedFiles:n}),i()},setBackgroundTasks(e){if(t.setState({backgroundTasks:e}),e.some(e=>e.type===`agent-session`)){let n=new Map(t.getState().subagentsAccum);for(let t of e)t.type===`agent-session`&&n.set(t.id,t);t.setState({subagentsAccum:n})}i()},setTurnBoundaries(e){t.setState({turnBoundaries:[...e]})},addTurnBoundary(e){t.setState({turnBoundaries:[...t.getState().turnBoundaries,e]})},setDrafts(e){t.setState({drafts:e}),i()},setScheduleTasks(e){t.setState({scheduleTasks:e}),i()},setRecentMentions(e){t.setState({recentMentions:e}),i()},setModelName(e){t.setState({modelName:e}),i()},setSessionList(e){t.setState({sessionList:e}),i()},setSessionTitle(e){t.setState({sessionTitle:e}),i()},setNeedsSetup(e){t.getState().needsSetup!==e&&(t.setState({needsSetup:e}),i())},setFtueStage(e){t.getState().ftueStage!==e&&(t.setState({ftueStage:e}),i())},setCapabilityRecommendations(e){t.setState({capabilityRecommendations:e}),i()},dismissCapabilityRecommendations(){t.getState().capabilityDismissed||(t.setState({capabilityDismissed:!0}),i())},setPermissionMode(e){t.setState({permissionMode:e}),i()},setForcedUpgrade(e){t.setState({forcedUpgrade:e}),r.syncForcedUpgradeRoute?.(!!e),i()},setPluginStatusItems(e){t.setState({pluginStatusItems:e}),r.registerStatusItems?.(e),i()},setBackgroundOutput(e){t.setState({backgroundOutput:e}),r.backgroundOutputRoute?.(e!==null),r.flushScrollbackIfIdle?.(),i()}}}}function Uu(){let e=Xn({memory:void 0,memoryHistory:[],notify:void 0,indicatorLevel:`healthy`,pluginMetrics:[]});return{store:e,reset(){e.setState({memory:void 0,memoryHistory:[],notify:void 0,indicatorLevel:`healthy`,pluginMetrics:[]})},setMemory(t){let n=[...e.getState().memoryHistory,t.heapUsed].slice(-32);e.setState({memory:t,memoryHistory:n})},setNotify(t){e.setState({notify:t})},setIndicatorLevel(t){e.setState({indicatorLevel:t})},setPluginMetrics(t){e.setState({pluginMetrics:t})}}}function Wu(){let e=Xn({view:null});return{store:e,setView(t){e.setState({view:t})}}}function Gu(){return{view:{configPath:`~/.otto/config.json`}}}function Ku(){let e=Xn(Gu());return{store:e,setView(t){e.setState({view:t})}}}function qu(e=Date.now){let t=Xn({entries:[]}),n=1,r=r=>{let i=[{...r,id:n++,timestamp:e()},...t.getState().entries].slice(0,20);t.setState({entries:i})};return{store:t,recordCompaction(e,t,n){r({kind:`compact`,before:e,after:t,summary:n})},recordPrune(e,t){r({kind:`prune`,tokensSaved:e,prunedCount:t})},recordHistoryCapped(e){r({kind:`history_capped`,removedCount:e})}}}const Ju={categoryIndex:0,itemIndex:0,variantIndex:0};function Yu(){let e=Xn({...Ju});return{store:e,reset(){e.setState({...Ju})},setCategoryIndex(t){e.setState({categoryIndex:t,itemIndex:0,variantIndex:0})},setItemIndex(t){e.setState({itemIndex:t,variantIndex:0})},setVariantIndex(t){e.setState({variantIndex:t})}}}function Xu(e){let{taskStore:t,budgetStore:n,perfStore:r,cacheStore:i,proxyStore:a,compactionLogStore:o,galleryStore:s,streamStore:c}=e;return{taskStore:qt(()=>t??Hu(),[t]),budgetStore:qt(()=>n??Fu(),[n]),perfStore:qt(()=>r??Uu(),[r]),cacheStore:qt(()=>i??Wu(),[i]),proxyStore:qt(()=>a??Ku(),[a]),compactionLogStore:qt(()=>o??qu(),[o]),galleryStore:qt(()=>s??Yu(),[s]),streamStore:qt(()=>c??pl(),[c])}}const Zu=[{en:`Use ↑/↓ for input history; Ctrl+R opens fuzzy history search.`,zh:`输入框里按 ↑/↓ 浏览历史输入,Ctrl+R 模糊搜索历史。`},{en:`Use /feedback to report a bug or request a feature via GitHub.`,zh:`输入 /feedback 可通过 GitHub 提交 bug 或功能建议。`},{en:`During a run, press Esc on an empty prompt to interrupt and steer.`,zh:`运行时输入框为空按 Esc 可中断,otto 停下来让你接管方向。`},{en:`During a run, Shift+Enter queues a follow-up; Ctrl+Q manages it.`,zh:`运行中按 Shift+Enter 排队追加消息(本回合后执行),Ctrl+Q 管理队列。`},{en:`While otto works, plain Enter steers the current turn.`,zh:`otto 工作中按普通 Enter 可注入引导消息到当前回合。`},{en:`Type /model then Tab to pick a model and switch mid-session.`,zh:`输入 /model 后按 Tab 自动补全可用模型,会话中途即可切换。`},{en:`Use /install for skills/plugins/MCP; manage them in /extension.`,zh:`/install 从文件或 URL 安装技能/插件/MCP,/extension 面板管理。`},{en:`Reasoning streams inline; /effort changes its intensity.`,zh:`推理过程实时内联在对话流中生成,/effort 调节推理强度。`},{en:`Type /open then Tab to browse and open files in the viewer.`,zh:`输入 /open 按 Tab 浏览目录,在内置查看器打开文件。`},{en:`Ctrl+S saves the current input as a draft; Ctrl+O lists and loads drafts.`,zh:`Ctrl+S 把当前输入存为草稿,Ctrl+O 打开草稿面板选择载入。`},{en:`Ctrl+R or /history searches session and shell history.`,zh:`Ctrl+R(或 /history)搜索会话与 shell 历史,选中即回填。`},{en:`Large pastes become chips; press Enter on a chip to view it.`,zh:`大段粘贴自动折叠成占位标记,光标停在标记上按 Enter 查看原文。`},{en:`Use /compact to free context; /compact log shows pruned items.`,zh:`长会话用 /compact 释放上下文,/compact log 查看裁剪明细。`},{en:"Run `otto doctor` in another terminal for a full health check.",zh:"在另一个终端运行 `otto doctor` 做完整环境健康诊断。"},{en:`Otto can fall back to another model after failure or rate limits.`,zh:`当前模型失败或限流时,otto 自动回退到已配置的其他模型。`},{en:`Use /schedule add with cron syntax for recurring tasks.`,zh:`/schedule add 用 cron 表达式设定期任务(如日报)。`},{en:`Use /queue to reorder or remove queued follow-ups.`,zh:`/queue 面板管理排队消息,move 调顺序,remove 删除。`},{en:`Tab completes slash commands and arguments: /model gpt<Tab>.`,zh:`Tab 补全斜杠命令及其参数(试试 /model gpt<Tab>)。`},{en:`Ctrl+P opens Delegates; press Enter to view job output.`,zh:`Ctrl+P 打开委派面板查看后台任务,Enter 实时查看其输出。`},{en:`Use /job <directive> to run work in a background worktree.`,zh:`/job <指令> 在后台 worktree 跑任务,不阻塞当前会话。`},{en:`Language, model, and permission mode persist across sessions.`,zh:`语言、模型、权限模式跨会话自动持久化。`},{en:`Ctrl+V lists edited files; Enter opens a full-screen diff.`,zh:`Ctrl+V 列出本会话修改的文件及 +/- 统计,Enter 打开全屏 diff。`},{en:`Scroll with Alt+↑/↓ or PgUp/PgDn; press / in review to search.`,zh:`Alt+↑/↓ 或 PageUp/PageDown 滚动对话流,回看态按 / 搜索。`},{en:`Use /perf for memory and rendering health; /diagnose for failures.`,zh:`/perf 查看内存占用与渲染健康度,/diagnose 汇总反复出现的失败并给改进建议。`},{en:`Use /preference to switch theme or language.`,zh:`/preference theme 切 dark/light/system 主题,/preference lang 切中英文。`},{en:`Wheel scrolling works by default; drag to select, release to copy.`,zh:`滚轮/触控板开箱即用,拖拽即选中、松手自动复制。`},{en:`Use /upgrade for otto updates; /upgrade --check checks extensions.`,zh:`/upgrade 检查 otto 更新,/upgrade --check 检查扩展更新。`},{en:`Use /resume for recent sessions; /pin keeps favorites on top.`,zh:`/resume 切换最近会话,/pin 把常用会话置顶。`}];function Qu({active:e,resetKey:t,isZh:n,delayMs:r=6e4,rotateMs:i=2e4}){let[a,s]=K(!1),[c,l]=K(()=>$u()),u=G(e);u.current=e;let d=G(0),[f,p]=K(0);if(o(`idle-tip-activity`,()=>{d.current+=1,p(d.current)},{isActive:e}),W(()=>{if(!e){s(!1);return}s(!1);let t=setTimeout(()=>{u.current&&s(!0)},r);return()=>{clearTimeout(t)}},[e,t,r,f]),W(()=>{if(!a)return;let e=setInterval(()=>{l(e=>(e+1)%Zu.length)},i);return()=>clearInterval(e)},[a,i]),!e||!a)return null;let m=Zu[c%Zu.length];return m?n?m.zh:m.en:null}function $u(){let e=new Date,t=`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`,n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e)|0;return Math.abs(n)%Zu.length}function ed(){return q(Y,{children:q(X,{color:R().warning,children:`🕶 ${V.t(`welcome.shadowChip`)}`})})}function td(){let e=R();return J(Y,{flexDirection:`column`,marginBottom:I.tight,children:[q(X,{bold:!0,color:e.warning,children:`🕶 ${V.t(`welcome.shadowBannerTitle`)}`}),q(X,{color:e.suggestion,children:V.t(`welcome.shadowGuarantee`)}),J(Y,{marginTop:I.tight,flexDirection:`column`,children:[q(X,{color:e.inactive,children:V.t(`welcome.shadowNotGuaranteedTitle`)}),q(X,{color:e.inactive,children:` • ${V.t(`welcome.shadowNg1`)}`}),q(X,{color:e.inactive,children:` • ${V.t(`welcome.shadowNg2`)}`}),q(X,{color:e.inactive,children:` • ${V.t(`welcome.shadowNg3`)}`}),q(X,{color:e.inactive,children:` • ${V.t(`welcome.shadowNg4`)}`})]})]})}const nd=[`#E06C75`,`#D19A66`,`#E5C07B`,`#98C379`,`#61AFEF`,`#C678DD`],rd=[`#B5403A`,`#B45F1F`,`#96740F`,`#4E7A34`,`#2364A8`,`#7B4FC4`];function id(e){let t=2*e;return 375+t+188+t}function ad(e){return 2*e}function od(e,t){return Math.min(t,Math.floor(e/2)+1)}function sd(e,t){let n=ad(t),r=e%id(t);if(r<375)return{phase:`brand`,progress:0,t:r};let i=r-375;if(i<n)return{phase:`entering`,progress:od(i,t),t:i};let a=i-n;if(a<188)return{phase:`hold`,progress:t,t:a};let o=a-188;return o<n?{phase:`exiting`,progress:od(o,t),t:o}:{phase:`brand`,progress:0,t:r}}function cd(e){let t=e%16;return t<=8?t/8:(16-t)/8}function ld(e){return Math.floor(e/3)%nd.length}function ud(e,t,n){let r=n===`light`?rd:nd,i=ld(t),a=[];for(let t=0;t<e;t++)a.push(r[(t+i)%r.length]);return a}function dd(e,t){let n=parseInt(e.slice(1),16),r=n>>16&255,i=n>>8&255,a=n&255,o=e=>Math.round(e+(255-e)*t),s=e=>e.toString(16).padStart(2,`0`).toUpperCase();return`#${s(o(r))}${s(o(i))}${s(o(a))}`}function fd(e,t,n,r,i,a,o){let s=i===`light`?rd:nd,c=a.phase===`hold`?cd(a.t):0,l=[];for(let i=0;i<e.length;i++){let u=a.phase===`hold`||a.phase===`entering`&&i<a.progress||a.phase===`exiting`&&i>=a.progress,d=Math.abs(i-t)<=n,f;if(u){let e=s[(i+r)%s.length];f=dd(e,d?.5+.25*c:.5*c)}else f=d?o.brandShimmer:o.brand;let p=l[l.length-1];p&&p.color===f?p.text+=e[i]:l.push({text:e[i],color:f})}return l}const pd=[`✦`,`✧`,`·`,`⋆`],md=[`~`,`°`,`·`,`˘`,`∼`],hd=[`▄▀▀▄ ▀█▀ ▀█▀ ▄▀▀▄`,`▀▄▄▀ █ █ ▀▄▄▀`],gd=[{left:2,phase:0},{left:8,phase:11},{left:13,phase:22}],_d=[{left:1,phase:16}],vd=[{left:1,phase:0},{left:5,phase:10},{left:9,phase:20},{left:14,phase:30}],yd=[{left:3,phase:15},{left:10,phase:35}];function bd(e,t){let n=(e+t)%32,r=n<=16?n/16:(32-n)/16;return r<.15?0:r<.5?1:r<.85?2:3}function xd(e,t){let n=(e+t)%70,r=(Math.sin(n/70*Math.PI*2)+1)/2;return r<.1?0:r<.4?1:r<.75?2:3}function Sd(e,t){return md[Math.floor((e+t)/8)%md.length]}function Cd({isNight:e=!1}){let t=R(),{resolvedTheme:n}=gt(),[r,i]=H.useState(0),a=Be();He(80,i);let o=e&&!a,s=!e&&!a,c=a?null:sd(r,hd[0].length),l=ld(r),u={brand:t.brand,brandShimmer:t.brandShimmer},d=e=>e===1?t.accentDim:e===3?t.accentBright:t.accent,f=(e,t,n)=>{let i=bd(r,e.phase);return i===0?null:q(Y,{position:`absolute`,top:t,left:e.left,children:q(X,{color:d(i),children:pd[n%pd.length]})},`${t}-${e.left}`)},p=(e,t,n)=>{let i=xd(r,e.phase);return i===0?null:q(Y,{position:`absolute`,top:t,left:e.left,children:q(X,{color:d(i),children:Sd(r,e.phase)})},`ripple-${n}`)};return J(Y,{position:`relative`,flexDirection:`column`,children:[hd.map((e,i)=>{let a=el(r+i*3,e.length);return q(Y,{flexDirection:`row`,children:c&&c.phase!==`brand`?fd(e,a,2,l,n,c,u).map((e,t)=>q(X,{bold:!0,color:e.color,children:e.text},t)):$c(e,a,2).map((e,n)=>q(X,{bold:!0,color:e.bright?t.brandShimmer:t.brand,children:e.text},n))},i)}),o&&gd.map((e,t)=>f(e,-1,t)),o&&_d.map((e,t)=>f(e,hd.length,t)),s&&vd.map((e,t)=>p(e,-1,t)),s&&yd.map((e,t)=>p(e,hd.length,t))]})}const wd=[`provider`,`authentication`,`model`],Td={provider:{titleKey:`recovery.titleProvider`,ctaKey:`recovery.ctaProvider`,hintKey:`recovery.hintProvider`},authentication:{titleKey:`recovery.titleAuth`,ctaKey:`recovery.ctaAuth`,hintKey:`recovery.hintAuth`},model:{titleKey:`recovery.titleModel`,ctaKey:`recovery.ctaModel`,hintKey:`recovery.hintModel`}};function Ed(e,t){if(e===`ready`||e===`first-prompt`)return null;let n=Td[e],r=wd.indexOf(e)+1,i=t<80;return{titleKey:n.titleKey,ctaKey:n.ctaKey,...i?{}:{hintKey:n.hintKey},step:r,totalSteps:wd.length}}function Dd(e,t){return e||(t?`model`:void 0)}function Od(e){return!e||e===`ready`||e===`first-prompt`?null:Td[e].ctaKey}function kd(e,t){return e===void 0?t:!(e===`ready`||e===`first-prompt`)}function Ad(e,t,n){return t!==`first-prompt`||n||e.length===0?null:{items:e.slice(0,3)}}function jd({version:e=`0.1.0`,buildId:t,cwd:n,width:r,nickname:i,updateAvailable:a,weather:o,ftueStage:c,promptSuggestions:l,capabilityRecommendations:u,capabilityDismissed:d=!1,shadow:f=!1}){let p=R(),m=n?n.replace(process.env.HOME??`~`,`~`):void 0,h=r??process.stdout.columns??80,g=h>=60,_=H.useMemo(()=>{let e=new Date().getHours();return e<5?`late`:e<9?`earlyMorning`:e<12?`morning`:e<18?`afternoon`:e<22?`evening`:`night`},[]),v=_===`night`||_===`late`,[y]=H.useState(()=>{let e=new Date,t=V.language===`zh`?[`日`,`一`,`二`,`三`,`四`,`五`,`六`]:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],n=t[e.getDay()]??t[0],r=i?V.language===`zh`?`,${i}`:`, ${i}`:``;return V.t(`welcome.greeting`,{context:_,wday:n,who:r})}),b=y,x=V.t(`welcome.version`),S=V.t(`welcome.workspace`),C=Math.max(Oe(x),Oe(S))+4,w=hd.map(e=>Oe(e)),T=Math.max(...w),E=e=>` `.repeat(Math.max(0,T-(w[e]??T))),D=c?Ed(c,h):null,ee=(c===void 0||c===`ready`)&&l&&l.length>0?l.slice(0,3):[],te=Ad(u??[],c,d);return q(Y,{flexDirection:`column`,children:J(Y,{flexDirection:`column`,paddingX:I.tight,paddingTop:I.section,...Ue,borderColor:p.panelBorder,children:[g&&J(Y,{marginBottom:I.tight,flexDirection:`row`,children:[q(Cd,{isNight:v}),J(Y,{flexDirection:`column`,marginLeft:I.loose,children:[J(Y,{flexDirection:`row`,children:[J(A,{type:`secondary`,children:[E(0),s(x,C)]}),J(A,{type:`secondary`,children:[`v`,e]}),t!=null&&J(A,{type:`secondary`,dim:!0,children:[` `,`(build `,t,`)`]}),a&&a.newer&&J(X,{color:a.forced?p.warning:p.accent,children:[` `,a.forced?V.t(`update.forcedBanner`,{latest:a.latest}):V.t(`update.availableBanner`,{latest:a.latest})]})]}),m&&J(Y,{flexDirection:`row`,children:[J(A,{type:`secondary`,children:[E(1),s(S,C)]}),q(A,{type:`secondary`,children:m})]})]})]}),!g&&J(Y,{flexDirection:`column`,marginBottom:I.tight,children:[J(Y,{flexDirection:`row`,children:[$c(`otto`,1).map((e,t)=>q(X,{bold:!0,color:e.bright?p.brandShimmer:p.brand,children:e.text},t)),q(A,{type:`secondary`,children:` ${s(x,C)}`}),J(A,{type:`secondary`,children:[`v`,e]}),t!=null&&J(A,{type:`secondary`,dim:!0,children:[` `,`(build `,t,`)`]})]}),m&&J(Y,{flexDirection:`row`,children:[q(A,{type:`secondary`,children:` ${s(S,C)}`}),q(A,{type:`secondary`,children:m})]})]}),q(Y,{marginBottom:I.tight,children:i&&b.includes(i)?J(X,{color:p.text,bold:!0,children:[b.slice(0,b.indexOf(i)),q(X,{color:p.accent,children:i}),b.slice(b.indexOf(i)+i.length)]}):q(X,{color:p.text,bold:!0,children:b})}),D&&J(Y,{flexDirection:`column`,marginBottom:I.tight,children:[J(Y,{children:[q(X,{color:p.warning,bold:!0,children:V.t(D.titleKey)}),q(A,{type:`secondary`,children:` ${D.step}/${D.totalSteps}`})]}),D.hintKey&&q(A,{type:`secondary`,children:V.t(D.hintKey)}),q(X,{color:p.accent,children:V.t(D.ctaKey)})]}),ee.length>0&&J(Y,{flexDirection:`column`,marginBottom:I.tight,children:[q(A,{type:`secondary`,children:V.t(`welcome.suggestionsLabel`)}),ee.map((e,t)=>J(Y,{flexDirection:`row`,children:[J(X,{color:p.accent,children:[` [`,t+1,`] `]}),q(A,{type:`secondary`,children:e})]},t))]}),te&&J(Y,{flexDirection:`column`,marginBottom:I.tight,children:[q(A,{type:`secondary`,children:V.t(`capability.sectionTitle`)}),te.items.map((e,t)=>J(Y,{flexDirection:`row`,children:[J(X,{color:p.accent,children:[` [`,t+1,`] `]}),q(A,{type:`secondary`,children:V.t(e.reasonKey)})]},e.extensionId)),J(Y,{flexDirection:`row`,children:[q(X,{color:p.accent,children:` [0] `}),q(A,{type:`secondary`,children:V.t(`capability.actionNotNow`)})]})]}),f&&q(td,{}),o&&J(Y,{marginBottom:I.tight,children:[J(X,{color:p.accent,children:[o.condition,` `,o.temp,`°C`]}),J(A,{type:`secondary`,children:[` `,o.location]})]})]})})}function Md(e,t){let n=la();W(()=>{if(n)return n.registerWheel(e)},[n,...t])}function Nd({title:e,status:t,messages:n,streamText:r=``,rows:i=24,columns:o=80,onDismiss:s}){let c=R(),l=a();D(`subagent-context-view`,(e,t)=>t.escape?(s?.(),!0):t.upArrow?(m(e=>b(e+1)),!0):t.downArrow?(m(e=>b(e-1)),!0):t.pageUp?(m(e=>b(e+v)),!0):t.pageDown?(m(e=>b(e-v)),!0):e===`g`&&!t.ctrl&&!t.meta?(m(y),!0):e===`G`&&!t.ctrl&&!t.meta?(m(0),!0):!1,{isActive:l?l.currentPath===`/subagent`:!0});let d=[];for(let e of n){let t=rc(e,o);t.length>0&&d.push(t)}let f=[];for(let e=0;e<d.length;e++)e>0&&f.push(``),f.push(...d[e]);let[p,m]=K(0),h=p===0,g=Qc(r,o-Pe.borderInset,3);if(h&&g.length>0){f.length>0&&f.push(``),f.push(`⏺ assistant (streaming)`);for(let e of g)f.push(` ${e}`)}let _=u(i),v=Math.max(1,_-7),y=Math.max(0,f.length-v),b=e=>Math.min(y,Math.max(0,e)),x=y-b(p),S=f.slice(x,x+v);return Md(e=>m(t=>b(t+e*3)),[y]),J(F,{maxHeight:_,header:J(Y,{flexDirection:`column`,children:[q(X,{color:c.secondary,italic:!0,children:V.t(`subagent.header`,{title:e,status:t})}),q(X,{children:` `})]}),footer:q(C,{items:[...y>0?[[`${j.up}${j.down}`,V.t(`hint.scroll`)]]:[],[j.esc,V.t(`hint.back`)]]}),children:[q(Y,{height:1,children:x>0&&q(A,{type:`secondary`,dim:!0,children:V.t(`subagent.contextEarlierLines`,{n:x})})}),q(Y,{flexDirection:`column`,children:S.map((e,t)=>q(X,{children:e},`${x+t}`))})]})}function Pd(e,t,n=60){if(e.length===0)return null;let r=Math.max(0,Math.min(t,e.length-1));for(let t=r;t>=0;t--){let r=e[t];if(!r||r.role!==`user`)continue;let i=Fd(r.content);if(i)return Ld(i,n)}return null}function Fd(e){return typeof e==`string`?e.trim():Array.isArray(e)?e.map(e=>typeof e==`string`?e:Id(e)?e.text:``).filter(Boolean).join(` `).trim():Id(e)?String(e.text).trim():``}function Id(e){return!!e&&typeof e==`object`&&typeof e.text==`string`}function Ld(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,Math.max(1,t-1))}…`}function Rd(e,t){let n=e.replace(/\s+/g,` `).trim();return t<=0?``:P(n,t)}function zd({sessionTitle:e,reviewing:t,turnPrompt:n,maxWidth:r}){let i=t&&n?n:e??``;return i===``||r===void 0?i:Rd(i,r)}function Bd(e){return typeof e==`string`&&/^[a-f\d]{8}$/i.test(e)}function Vd(e){let t=pu(),{taskStore:n}=eu(),r=Z(n.store,e=>e.sessionTitle),i=Z(n.store,e=>e.sessionList),a=Z(n.store,e=>e.needsSetup),o=Z(n.store,e=>e.ftueStage),s=Z(n.store,e=>e.pendingPermission),c=Z(n.store,e=>e.subagentContext),l=Z(n.store,e=>e.pendingEcho),u=Z(n.store,e=>e.pendingSteers),d=Z(e.scrollStore.store,e=>e.offset>0),[f,p]=H.useState(null);H.useEffect(()=>{c&&p(null)},[c]);let m=Z(e.scrollStore.store,e=>e.offset),h=Z(e.scrollStore.store,e=>e.atTranscriptTop),g=H.useMemo(()=>{if(!d)return null;let t=Math.max(0,e.messages.length-1-Math.floor(m/3));return Pd(e.messages,t)},[d,m,e.messages]),_=Dd(o,a);if(e.welcome&&e.showHome)return q(jd,{version:e.welcome.version,buildId:e.welcome.buildId,cwd:e.welcome.cwd,width:e.columns,nickname:e.welcome.nickname,updateAvailable:e.welcome.updateAvailable,weather:e.welcome.weather,sessionList:i,onSessionSelect:t.onSessionSelect,ftueStage:_,promptSuggestions:e.promptSuggestions,capabilityRecommendations:e.capabilityRecommendations,capabilityDismissed:e.capabilityDismissed,shadow:e.shadow});let v=zd({sessionTitle:r,reviewing:d,turnPrompt:g,maxWidth:Math.max(1,e.columns-2)}),y=v.length>0&&!Bd(v)&&!h,b=Math.max(1,e.rows-(y?1:0)-(f?1:0));return J(Y,{flexDirection:`column`,flexGrow:1,justifyContent:`flex-end`,children:[y&&q(Y,{height:1,flexShrink:0,flexDirection:`row`,children:q(X,{dimColor:!0,children:`${L.userPrompt} ${v}`})}),c?(()=>{let n=c;return q(Nd,{title:n.title,status:n.status,messages:n.messages,streamText:n.streamText,rows:b,columns:e.columns,onDismiss:t.onExitSubagentContext})})():q(Jt,{children:q(bl,{streamStore:e.streamStore,completedMessages:e.messages,columns:e.columns,rows:b,maxPreviewRows:e.fullScreenPaneActive?0:e.maxPreviewRows,suppressLive:e.fullScreenPaneActive||d,pendingEcho:l??null,scrollbackMode:e.scrollbackMode??!1,pendingSteers:u??[],windowMode:e.windowMode,scrollStore:e.scrollStore,earlierLoading:e.earlierLoading,earlierEnded:e.earlierEnded,onNeedEarlier:e.onNeedEarlier,onPrepend:e.onPrepend,findQuery:e.findQuery,findActiveMatch:e.findActiveMatch,onFindNavigateTo:e.onFindNavigateTo,onFindCountChange:e.onFindCountChange,onReviewHintChange:p,renderReviewHint:!1,topbarReserved:y,pendingPermission:s??null,suppressSpinner:e.fullScreenPaneActive})}),f&&q(Y,{height:1,flexShrink:0,flexDirection:`row`,children:q(X,{dimColor:!0,children:f})})]})}const Hd=Oe(` · `),Ud=Oe(`←`)+4;function Wd(e,t,n,r){let i=e.map((e,n)=>({item:e,index:n,label:t(e)}));if(e.length===0)return{items:[],hiddenLeft:0,hiddenRight:0};if(r===void 0||!Number.isFinite(r)||r<=0)return{items:i,hiddenLeft:0,hiddenRight:0};let a=Math.max(0,Math.min(n,e.length-1)),o=e=>Oe(i[e].label)+2;if(i.reduce((e,t,n)=>e+o(n),0)+(i.length-1)*Hd<=r)return{items:i,hiddenLeft:0,hiddenRight:0};let s=Math.max(6,r-Ud*2),c=a,l=a+1,u=Math.min(o(a),s);for(;;){let e=l<i.length,t=c>0;if(!e&&!t)break;let n=!1;if(e){let e=o(l)+Hd;u+e<=s&&(u+=e,l++,n=!0)}if(t){let e=o(c-1)+Hd;u+e<=s&&(u+=e,c--,n=!0)}if(!n)break}return{items:i.slice(c,l).map(e=>{let t=Math.max(1,s-2);return Oe(e.label)>t?{...e,label:P(e.label,t)}:e}),hiddenLeft:c,hiddenRight:i.length-l}}function Gd({label:e,active:t,disabled:n,color:r=`accent`}){return q(Ne,{variant:`ghost`,color:r,label:e,focused:t,disabled:n})}function Kd({items:e,activeKey:t,color:n=`accent`,tabIndex:r=-1,onSelect:i,availableWidth:a,enableDigitAccess:o=!1}){let s=R(),{focused:c}=T({tabIndex:r,disabled:r<0}),l=(n,r)=>{if(!i||e.length===0)return!1;let a=e.findIndex(e=>e.key===t);if(r.leftArrow||r.rightArrow)return i(e[(a+(r.leftArrow?-1:1)+e.length)%e.length].key),!0;if(o&&n>=`1`&&n<=`9`){let t=n.charCodeAt(0)-49;return t<e.length&&!e[t].disabled?(i(e[t].key),!0):!1}return!1};y(c,l),D(`segmented-${e.map(e=>e.key).join(`-`)}`,l,{isActive:!!i&&!c});let u=Wd(e,e=>e.label,e.findIndex(e=>e.key===t),a);return J(Y,{flexDirection:`row`,gap:I.tight,children:[u.hiddenLeft>0&&q(X,{color:s.inactive,children:`←${u.hiddenLeft}`}),u.items.map((e,r)=>J(H.Fragment,{children:[r>0&&q(X,{color:s.inactive,children:`·`}),q(Gd,{label:e.label,active:e.item.key===t,disabled:e.item.disabled,color:n})]},e.item.key)),u.hiddenRight>0&&q(X,{color:s.inactive,children:`→${u.hiddenRight}`})]})}const qd={running:L.todoActive,exited:L.check,killed:L.cross,failed:L.cross};function Jd(e,t){return e===`running`?t.special:e===`exited`?t.success:t.error}function Yd(e){if((e.type??`process`)===`agent-session`)switch(e.agentStatus){case`running`:return L.todoActive;case`ready`:return L.attention;case`needs_input`:return L.attention;case`applied`:return L.check;default:return L.cross}return qd[e.status]}function Xd(e,t){if((e.type??`process`)===`agent-session`){if(e.stall===`stalled`)return t.error;if(e.stall===`warn`)return t.warning;switch(e.agentStatus){case`running`:return t.special;case`ready`:return t.selection;case`needs_input`:return t.warning;case`applied`:return t.success;default:return t.error}}return Jd(e.status,t)}function Zd({tasks:e,columns:r=80,onClose:i,onKill:a,onViewOutput:o,onApply:s,onSwitch:c,onDelete:l,active:u=!0,rows:d=24}){let f=R(),[p,m]=ra(`delegates`,e.length),h=G(0),g=e.some(e=>(e.type??`process`)===`agent-session`?e.agentStatus===`running`:e.status===`running`),[,_]=K(0);W(()=>{if(!g)return;let e=setInterval(()=>_(e=>(e+1)%1e6),1e3);return()=>clearInterval(e)},[g]),D(`delegates-pane`,(t,n)=>{if(n.escape||t===`q`)return i?.(),!0;if(Me(`list-nav-up`,t,n,`background`))return m(e=>Math.max(0,e-1)),!0;if(Me(`list-nav-down`,t,n,`background`))return m(t=>Math.max(0,Math.min(e.length-1,t+1))),!0;let r=e[p],u=r?yo(r):!1;return t===`k`&&u&&r?(a?.(r.id),!0):(t===`o`||n.return)&&r?(o?.(r.id),!0):t===`a`&&r?.type===`agent-session`&&r.agentStatus===`ready`&&r.diffStat?(s?.(r.id),!0):t===`s`&&r?.type===`agent-session`?(c?.(r.id),!0):t===`d`&&r&&!u?(l?.(r.id),!0):!1},{isActive:u,ignoreRoute:!0});let v=e.filter(yo).length,y=Date.now(),b=Math.max(12,Math.min(48,r-28));if(!u){if(e.length===0)return null;let n=e[Math.min(p,e.length-1)];return J(Y,{flexDirection:`column`,children:[J(Y,{children:[q(X,{color:f.special,children:`▸ `}),q(A,{type:`secondary`,children:V.t(`bg.tasksTitle`)}),J(A,{type:`secondary`,children:[` `,e.length]}),v>0&&J(A,{type:`secondary`,children:[` · `,V.t(`bg.runningSuffix`,{n:v})]}),J(A,{type:`secondary`,dim:!0,children:[` `,t(`p`)]})]}),n&&J(Y,{flexDirection:`row`,children:[q(A,{type:`secondary`,children:`${L.pointer} `}),q(A,{type:`secondary`,children:P(n.command,b).padEnd(b)}),J(A,{type:`secondary`,dim:!0,children:[` `,To(n,y)]})]})]})}let x=e[Math.min(p,e.length-1)],S=(x?.type??`process`)===`agent-session`&&x?.agentStatus===`ready`&&!!x?.diffStat,w=!!x&&!yo(x),T=Math.min(p,e.length-1),E=[],ee,te=0;e.forEach((e,t)=>{let n=_o(e);n!==ee&&(te>0&&E.push({type:`spacer`}),E.push({type:`header`,category:n}),te++,ee=n),E.push({type:`entry`,task:e,index:t})});let O=Ct(E,E.findIndex(e=>e.type===`entry`&&e.index===T),n(E.length,d,3),h.current);return h.current=O.scrollTop,J(Y,{flexDirection:`column`,marginTop:I.tight,children:[J(Y,{children:[q(X,{color:f.special,children:`▸ `}),q(X,{color:f.text,children:V.t(`bg.tasksTitle`)}),J(A,{type:`secondary`,children:[` `,v>0?V.t(`bg.runningSuffix`,{n:v}):`${e.length} total`,e.length>v?` · ${V.t(`bg.doneSuffix`,{n:e.length-v})}`:``]}),q(Y,{marginLeft:I.tight,children:q(C,{dim:!0,items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[`k`,V.t(`hint.kill`)],[`o`,V.t(`hint.output`)],...S?[[`a`,V.t(`hint.apply`)]]:[],...w?[[`d`,V.t(`hint.delete`)]]:[],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]})})]}),q(Y,{marginLeft:I.section,flexDirection:`column`,children:e.length===0?q(A,{type:`secondary`,dim:!0,children:V.t(`bg.empty`)}):J(Jt,{children:[O.hasMoreAbove&&q(X,{dimColor:!0,children:V.t(`scroll.above`,{n:1})}),O.rows.map((e,t)=>{if(e.type===`spacer`)return q(X,{children:` `},`spacer-${t}`);if(e.type===`header`)return q(A,{type:`secondary`,dim:!0,children:V.t(`bg.categoryLabel`,{context:e.category})},`h-${t}`);let n=e.task,r=e.index===p;return J(Y,{flexDirection:`row`,children:[q(X,{color:r?f.selection:f.inactive,children:r?Nt():wt()}),J(X,{color:Xd(n,f),children:[Yd(n),` `]}),q(X,{color:r?f.selection:f.inactive,children:P(n.command,b).padEnd(b)}),(n.type??`process`)===`agent-session`&&n.model&&J(A,{type:`secondary`,dim:!0,children:[` `,String(n.model)]}),J(A,{type:`secondary`,dim:!0,children:[` `,To(n,y)]})]},n.id)}),O.hasMoreBelow&&q(X,{dimColor:!0,children:V.t(`scroll.below`,{n:1})})]})})]})}function Qd({view:e,columns:t=80,rows:n,active:r=!0,onDismiss:i}){let a=R(),o=e.prompt!==void 0,s=e.messages!==void 0&&e.messages.length>0,c=!!e.diff?.trim(),l=(o?1:0)+(s?1:0)+(c?1:0)>=2,[u,d]=K(c?`diff`:s?`conversation`:`prompt`),[f,p]=K(0),[m,h]=K(!1),[g,_]=K(``),[v,y]=K(-1),b=n?ne(n,12):18;W(()=>p(0),[e.id,u]);let x=Math.max(8,t-Pe.contentInset),S=[],w=[];if(u===`diff`)S=(e.diff??``).split(`
52
+ `),[t]);return n?q(jl,{title:l,onForget:r,onBack:i}):q(sc,{lines:u,rows:a,columns:o,wrapMode:`pre-wrap`,header:q(Y,{children:q(X,{color:s.selection,children:l})}),onDismiss:i,initialScroll:`top`,contentKey:e.slug,emptyMessage:V.t(`cmd.memoryDialogDetailEmpty`),onKey:e=>e===`d`?(r(),!0):!1,extraHints:[[`d`,V.t(`cmd.memoryDialogHintForget`)]]})}function jl({title:e,onForget:t,onBack:n}){return D(`memory-dialog-detail-loading`,(e,r)=>{if(r.escape){n();return}e===`d`&&t()}),q(F,{header:q(_e,{children:e}),footer:q(C,{items:[[j.esc,V.t(`cmd.memoryDialogHintBack`)]]}),children:q(Y,{marginTop:I.tight,children:q(X,{dimColor:!0,children:`…`})})})}function Ml({entry:e,onConfirm:t,onCancel:n}){let r=R(),[i,a]=K(0);return D(`memory-dialog`,(e,r)=>{if(r.escape){n();return}if(r.leftArrow||r.rightArrow||r.tab){let e=O(r);e!==0&&a(t=>ee(t,e,2));return}r.return&&(i===1?t():n())}),q(F,{header:q(_e,{children:V.t(`cmd.memoryDialogConfirmForgetTitle`)}),children:J(Y,{marginTop:I.tight,flexDirection:`column`,children:[q(X,{color:r.warning,children:V.t(`cmd.memoryDialogConfirmForgetMessage`,{name:e.name})}),J(Y,{marginTop:I.section,flexDirection:`row`,gap:I.section,children:[q(Ne,{variant:`solid`,brackets:!0,label:V.t(`common.genericCancelButton`),focused:i===0,color:`gray`}),q(Ne,{variant:`solid`,brackets:!0,label:V.t(`hint.delete`),focused:i===1,color:`red`})]})]})})}function Nl(e){return e.replace(/\s+/g,` `).trim()}function Pl({req:e,rows:t=24}){let{entries:n,menuContributions:r=[],onSelect:i,onCancel:a}=e,o=n.filter(e=>e.enabled).length,s=n.length>0?V.t(`cmd.extListTitle`,{enabled:o,total:n.length}):V.t(`cmd.extListEmptyTitle`),c=r.find(e=>e.id===`__discover__`),l=r.filter(e=>e.id!==`__discover__`),u=c?{hint:V.t(`cmd.extDiscoverHint`),label:V.t(`cmd.extDiscoverButton`),onPress:()=>i(`contrib:${c.id}`)}:void 0;if(n.length===0)return q(B.Root,{title:s,headerAction:u,onCancel:a,rows:t,extensionHeightBudget:!0,children:q(B.Content,{children:q(B.Item,{value:``,children:V.t(`cmd.extListEmptyOption`)})})});let d=new Map;for(let e of n){let t=V.t(`cmd.extCategoryLabel`,{category:e.category}),n=d.get(t);n?n.push(e):d.set(t,[e])}let f=e=>e.name;return q(B.Root,{title:s,headerAction:u,onValueChange:i,onCancel:a,rows:t,extensionHeightBudget:!0,defaultValue:e.lastSelectedValue,detailPlacement:`inline`,children:J(B.Content,{children:[[...d.entries()].map(([e,t])=>J(B.Group,{children:[q(B.Label,{children:e}),t.map(e=>{let t=[];e.enabled||t.push(V.t(`cmd.extStateDisabled`)),e.description&&t.push(e.description),e.applies&&e.applies!==`live`&&t.push(V.t(`cmd.extAppliesNextTurn`));let n=t.length>0?Nl(t.join(` · `)):void 0;return q(B.Item,{value:`${e.category}:${e.id}`,detail:n,children:f(e)},`${e.category}:${e.id}`)})]},e)),l.length>0&&J(B.Group,{children:[q(B.Label,{children:V.t(`cmd.extCategoryLabel`,{category:`plugin`})}),l.map(e=>q(B.Item,{value:`contrib:${e.id}`,children:e.title},`contrib:${e.id}`))]},`contrib`)]})})}const Fl={y:0,n:1,a:2};function Il({tool:e,input:t,risk:n,onApprove:r,onDeny:i}){let a=R(),[o,s]=K(0),c=Xe(n),l=e=>{e===0?r(`once`):e===1?i():r(`always`)};return D(`permission-dialog-buttons`,(e,t)=>{if(t.escape)return i(),!0;let n=O(t);if(n!==0)return s(e=>ee(e,n,3)),!0;if(t.return)return s(e=>(l(e),e)),!0;let r=Fl[e.toLowerCase()];return r===void 0?!1:(l(r),!0)}),J(F,{header:J(_e,{children:[V.t(`permission.allowTool`),` `,q(X,{color:a.permission,children:e}),` `,J(X,{color:c,children:[`(`,V.t(`permission.riskLabel`,{context:n}),`)`]})]}),footer:q(C,{items:[[`${j.left}${j.right}`,V.t(`hint.switch`)],[j.enter,V.t(`hint.confirm`)],[`y/n/a`,V.t(`hint.shortcut`)],[j.esc,V.t(`hint.cancel`)]]}),children:[q(Y,{marginTop:I.tight,children:q(X,{dimColor:!0,children:P(t,200)})}),J(Y,{marginTop:I.tight,flexDirection:`row`,gap:I.section,children:[q(Ne,{variant:`solid`,brackets:!0,color:`accent`,label:V.t(`permission.approve`),focused:o===0}),q(Ne,{variant:`solid`,brackets:!0,color:`red`,label:V.t(`permission.deny`),focused:o===1}),q(Ne,{variant:`solid`,brackets:!0,color:`amber`,label:V.t(`permission.alwaysAllow`),focused:o===2})]})]})}function Ll(e){let t=/^\s*cd\s+(.+?)\s*&&\s*(.*)$/s.exec(e);return t?{workDir:t[1]}:{workDir:null}}const Rl={y:0,n:1,a:2},zl={y:0,n:1};function Bl({command:e,risk:t,description:n,alwaysAllowLabel:r,onApprove:i,onDeny:a}){let o=R(),[s,c]=K(0),l=Xe(t),u=r!=null,d=u?3:2,f=u?Rl:zl,p=e=>{e===0?i(`once`):e===1?a():i(`always`)};D(`bash-permission-dialog-buttons`,(e,t)=>{if(t.escape)return a(),!0;let n=O(t);if(n!==0)return c(e=>ee(e,n,d)),!0;if(t.return)return c(e=>(p(e),e)),!0;let r=f[e.toLowerCase()];return r===void 0?!1:(p(r),!0)});let{workDir:m}=Ll(e),h=P(e,500);return J(F,{header:J(_e,{children:[V.t(`permission.bashCommand`),` `,J(X,{color:l,children:[`(`,V.t(`permission.riskLabel`,{context:t}),`)`]})]}),footer:q(C,{items:[[`${j.left}${j.right}`,V.t(`hint.switch`)],[j.enter,V.t(`hint.confirm`)],[u?`y/n/a`:`y/n`,V.t(`hint.shortcut`)],[j.esc,V.t(`hint.cancel`)]]}),children:[q(Y,{marginTop:I.tight,children:q(X,{color:o.suggestion,children:h})}),(m||n)&&J(Y,{marginTop:I.tight,flexDirection:`column`,children:[m&&q(X,{dimColor:!0,children:m}),n&&q(X,{dimColor:!0,children:n})]}),r&&J(Y,{marginTop:I.tight,children:[J(X,{dimColor:!0,children:[V.t(`permission.alwaysAllow`),`: `]}),q(X,{color:o.suggestion,children:r})]}),J(Y,{marginTop:I.tight,flexDirection:`row`,gap:I.section,children:[q(Ne,{variant:`solid`,brackets:!0,color:`accent`,label:V.t(`permission.approve`),focused:s===0}),q(Ne,{variant:`solid`,brackets:!0,color:`red`,label:V.t(`permission.deny`),focused:s===1}),u&&q(Ne,{variant:`solid`,brackets:!0,color:`amber`,label:V.t(`permission.alwaysAllow`),focused:s===2})]})]})}function Vl({title:e,message:t,okLabel:n,onOk:r}){let i=Array.isArray(t)?t:[t];return T({tabIndex:0,id:`alert-ok`,onAction:()=>(r(),!0),onEscape:()=>(r(),!0)}),D(`alert-dialog`,(e,t)=>t.return||t.escape?(r(),!0):!1),J(F,{header:q(_e,{children:e}),footer:q(C,{items:[[`${j.enter}/${j.esc}`,V.t(`hint.close`)]]}),children:[q(Y,{marginTop:I.tight,flexDirection:`column`,children:i.map((e,t)=>q(X,{wrap:`truncate-end`,children:e===``?` `:e},t))}),q(Y,{marginTop:I.tight,children:q(Ne,{variant:`solid`,brackets:!0,color:`accent`,label:n??V.t(`common.okButton`),focused:!0})})]})}function Hl({title:e,message:t,placeholder:n,initialValue:r=``,submitLabel:i,cancelLabel:a,columns:o=60,onSubmit:s,onCancel:c}){let[u,d]=K(r),[f,p]=K(r.length),[m,h]=K(`input`),g=t?Array.isArray(t)?t:[t]:[],_=(e,t)=>{d(e),p(t)};return D(`prompt-dialog`,(e,t)=>{if(t.escape){c();return}if(t.return&&m===`input`){u.trim()!==``&&h(`submit`);return}if(t.return){m===`submit`&&u.trim()!==``?s(u):c();return}if(t.tab||t.ctrl&&e===`n`){h(e=>e===`input`?`submit`:e===`submit`?`cancel`:`input`);return}if(t.leftArrow&&m!==`input`){h(e=>`submit`);return}if(t.rightArrow&&m!==`input`){h(e=>`cancel`);return}if(m!==`input`)return;if(e.length>1&&!t.ctrl&&!t.meta&&!t.return&&!t.escape&&!t.backspace&&!t.delete&&!t.tab&&!t.upArrow&&!t.downArrow&&!t.leftArrow&&!t.rightArrow){let t=ke(e);t&&_(u.slice(0,f)+t+u.slice(f),f+t.length);return}if(t.leftArrow){let e=l.fromText(u,o,f).left();_(e.text,e.offset);return}if(t.rightArrow){let e=l.fromText(u,o,f).right();_(e.text,e.offset);return}let n={name:t.backspace?`backspace`:t.delete?`delete`:e||`unknown`,ctrl:t.ctrl??!1,shift:!1,alt:t.meta??!1,meta:t.meta??!1},r=Tt(l.fromText(u,o,f),n);if(r){if(r.action===`clear_text`){_(``,0);return}r.action===`submit`||r.action===`submit_force`||_(r.cursor.text,r.cursor.offset)}}),J(F,{header:q(_e,{children:e??V.t(`prompt.defaultTitle`)}),footer:q(C,{items:[[j.enter,V.t(`hint.confirm`)],[j.esc,V.t(`hint.cancel`)]]}),children:[g.length>0&&q(Y,{marginTop:I.tight,flexDirection:`column`,children:g.map((e,t)=>q(X,{wrap:`truncate-end`,children:e===``?` `:e},t))}),q(Y,{marginTop:I.tight,flexDirection:`row`,children:q(dt,{value:u,offset:f,columns:o,mode:`dialog`,placeholder:n,focused:m===`input`,physicalCursor:m===`input`})}),J(Y,{marginTop:I.tight,flexDirection:`row`,gap:I.section,children:[q(Ne,{variant:`solid`,brackets:!0,color:`accent`,label:i??V.t(`prompt.submitButton`),focused:m===`submit`,disabled:u.trim()===``}),q(Ne,{variant:`solid`,brackets:!0,color:`gray`,label:a??V.t(`common.genericCancelButton`),focused:m===`cancel`})]})]})}function Ul(){return{toast:null,retryCountdown:null,errorRetry:null,providerUsage:null,notifications:[],paused:!1,pauseDialog:null,pausePending:null,pulseSurvey:null}}function Wl(){let e=Xn(Ul()),t,n={};return{store:e,reset(){e.setState(Ul())},setNotify(e){t=e},setEffects(e){n=e},setProviderUsage(n){e.setState({providerUsage:n}),t?.()},setPausePending(n){e.setState({pausePending:n}),t?.()},setPaused(r){e.setState({paused:r}),r||n.drainQueueOnResume?.(),t?.()},setPulseSurvey(r){e.setState({pulseSurvey:r}),n.syncPulseSurveyRoute?.(r!==null),t?.()}}}function Gl(e,t){return{role:`history_capped`,removedCount:e,trigger:t}}const Kl=e=>{try{return JSON.stringify(e).length}catch{return 0}};function ql(e,t=Mn,n=jn){let r=e.filter(e=>e.role!==`history_capped`);if(r.length===0)return e;let i=0,a=null;r.length>t&&(i+=r.length-t,r.splice(0,i),a=`count`);let o=r.map(Kl),s=o.reduce((e,t)=>e+t,0);if(s>n){let e=0;for(;e<o.length-1&&s>n;)s-=o[e],e++,i++;r.splice(0,e),a=`bytes`}return i===0?e:[...r,Gl(i,a??`count`)]}function Jl(){let e=Xn({messages:[]}),t=t=>{e.setState({messages:ql(t)})};return{store:e,append(n,r,i){t([...e.getState().messages,{...n,id:n.id??r,...i==null?{}:{seq:i}}])},appendMany(n,r){n.length!==0&&t([...e.getState().messages,...n.map(e=>({...e,id:e.id??r()}))])},prependMany(n){if(n.length===0)return;let r=e.getState();t([...n.map(e=>({...e})),...r.messages])},patchLast(n){let r=e.getState();if(r.messages.length===0)return;let i=r.messages[r.messages.length-1];t([...r.messages.slice(0,-1),{...i,...n}])},patchById(n,r){let i=e.getState(),a=i.messages.findIndex(e=>e.id===n);if(a===-1)return;let o=i.messages[a],s=[...i.messages];s[a]={...o,...r},t(s)},removeLast(){let n=e.getState();n.messages.length!==0&&t(n.messages.slice(0,-1))},removeById(n){let r=e.getState(),i=r.messages.findIndex(e=>e.id===n);if(i===-1)return;let a=[...r.messages];a.splice(i,1),t(a)},reset(){e.setState({messages:[]})}}}const Yl=[{label:`Tool guidance`,lane:`stable`,priority:20},{label:`Environment`,lane:`stable`,priority:25},{label:`Memory index`,lane:`stable`,priority:35},{label:`Skill catalog`,lane:`stable`,priority:38},{label:`Lesson`,lane:`stable`,priority:40},{label:`Memory delta`,lane:`volatile`,priority:60},{label:`TODO reminder`,lane:`volatile`,priority:62}];function Xl(e){let t=Yl.length,n=Math.round(e/t);return Yl.map(e=>({label:e.label,lane:e.lane,estimatedTokens:n}))}function Zl(){let e=Xn({open:!1,conversationTurns:[],systemSections:[],modelName:``,contextWindow:0,contextPercent:0,totalUsed:0,free:0});return{store:e,toggle(t){e.setState({open:t??!e.getState().open})},reset(){e.setState({open:!1,conversationTurns:[],systemSections:[],modelName:``,contextWindow:0,contextPercent:0,totalUsed:0,free:0})},addTurn(t){let n=[...e.getState().conversationTurns,t];e.setState({conversationTurns:n.length>Mn?n.slice(n.length-Mn):n})},markTurns(t){let{turnIndex:n,...r}=t,i=e.getState().conversationTurns.map(e=>e.turnIndex===n?{...e,...r}:e);e.setState({conversationTurns:i})},setBudget(t){e.setState({modelName:t.modelName,contextWindow:t.contextWindow,contextPercent:t.contextPercent,totalUsed:t.totalUsed,free:t.free,systemSections:Xl(t.overheadTokens)})}}}const Ql=Wt(void 0),$l=Ql.Provider;function eu(){let e=Kt(Ql);if(!e)throw Error(`useAppStoresContext must be used within <AppStoresProvider>`);return e}const tu=[`/pane/tasks`,`/pane/delegates`,`/pane/edited-files`,`/pane/subagents`,`/pane/schedule`,`/pane/clipboard`];function nu(e){return tu.includes(e)}const ru=[`taskFocus`,`background`,`editedFiles`,`subagents`,`schedule`,`clipboard`];function iu(e){return nu(e)||e===`/overlay/paste-confirm`}function au(e){return e===`/`||nu(e)||e===`/overlay/paste-confirm`}function ou(e){return e===`prompt`||ru.includes(e)}function su(){z()?.navigate(`/`,{reset:!0})}function cu(){let{currentPath:e}=me();return e===`/`?`prompt`:e===`/home`?`home`:e===`/pane/delegates`||e===`/pane/delegates/output`?`background`:e===`/pane/edited-files`?`editedFiles`:e.startsWith(`/pane/edited-files/`)?`editedFileFull`:e===`/subagent`?`subagentContext`:e===`/pane/subagents`?`subagents`:e===`/pane/clipboard`?`clipboard`:e===`/pane/schedule`?`schedule`:e===`/pane/tasks`?`taskFocus`:e.startsWith(`/pane/tasks/`)?`taskDetail`:e===`/pane/draft`?`draft`:e===`/pane/queue`?`queue`:e.startsWith(`/pane/queue/`)?`queueEdit`:e===`/pane/shell`?`shell`:e===`/pane/sigil`?`sigilPane`:e===`/pane/perf`?`perf`:e===`/pane/cache`?`cacheStats`:e===`/pane/compaction-log`?`compactionLog`:e===`/pane/gallery`?`gallery`:e===`/pane/notifications`?`notifications`:e===`/pane/proxy`?`proxy`:e===`/pane/prompts`?`prompts`:e===`/pane/context`?`info`:(e.startsWith(`/dialog/`)||e.startsWith(`/viewer/`),`prompt`)}const lu=`onA2uiAction.onAlertResolve.onBackToContextPane.onBackgroundApply.onBackgroundClose.onBackgroundDelete.onBackgroundKill.onBackgroundOutputClose.onBackgroundSwitch.onBackgroundViewOutput.onCacheDismiss.onCancelUpgrade.onCloseNotifications.onCompactionLogDismiss.onContextDismiss.onConfirmResolve.onCyclePermissionMode.onDelegateSupply.onDismissNotification.onDismissToast.onDraftDelete.onDraftDeleteMany.onDraftSave.onErrorRetryFocusChange.onExitSubagentContext.onFocusOwnerChange.onScrollActiveChange.onGalleryDismiss.onHistoryPush.onInfoDismiss.onInputAction.onInputResolve.onOnboardingResolve.onInterrupt.onKeybindingPanelDismiss.onMemoryDismiss.onPaneOwnsViewportChange.onPerfDismiss.onPerfRefresh.onPermissionDecision.onPopQueued.onPromptResolve.onProxyClear.onProxyTest.onProxyDismiss.onProxyOpenModal.onProxySubmitUrl.onProxyToggleEnabled.onPulseSurveyChange.onQuestionsResolve.onQueueDelete.onQueueEditText.onQueueMove.onQueueSendNow.onSelectResolve.onSessionSelect.onInstallCapability.onDismissCapabilityRecommendations.onShellAbort.onShellAskAi.onShellCopyOutput.onShellDismiss.onShortcutsDialogDismiss.onSigilSelect.onSubmit.onToast.onToggleDelegates.onToggleDraftPane.onToggleEditedFiles.onToggleNotifications.onToggleQueuePane.onTogglePrompts.onToggleSchedule.onToggleSubagents.onUpgrade.onViewDetails.onWithdrawPending.onWithdrawSteer`.split(`.`);function uu(e){let t={};for(let n of lu)t[n]=e[n];return t}const du=Wt(null),fu=du.Provider;function pu(){let e=Kt(du);if(!e)throw Error(`useAppCallbacks must be used within AppCallbacksProvider`);return e}function mu(e){let{editedFilesLength:t,queuedItemsLength:n,subagentContext:r,backgroundOutput:i}=e,{onPaneOwnsViewportChange:a}=pu(),{currentPath:o}=me(),[s,c]=K(null),[l,u]=K(null),[d,f]=K(null),p=Gt(e=>{f(e),e?z()?.navigate(`/viewer/shell-output`):z()?.goBack()},[]),[m,h]=K(null),[g,_]=K(!1),[v,y]=K(!1),[b,x]=K(!1),[S,C]=K(!1),[w,T]=K(``),E=!!r||s!==null||!!i||l!=null,D=Gt(e=>{a?.(!0),c(e),z()?.navigate(`/pane/edited-files/${e}`)},[a]),ee=Gt(()=>{a?.(l!=null),c(null),z()?.goBack()},[a,l]),te=Gt(e=>{a?.(!0),u(e),z()?.navigate(`/pane/tasks/${e}`)},[a]),O=Gt(()=>{a?.(s!==null),u(null),z()?.goBack()},[a,s]);return W(()=>{let e=o.startsWith(`/pane/edited-files/`)?s:null,t=o.startsWith(`/pane/tasks/`)?l:null;e!==s&&c(e),t!==l&&u(t),(e!==s||t!==l)&&a?.(e!==null||t!=null),m!==null&&o!==`/pane/queue/edit`&&(h(null),_(!1),y(!1)),d&&!o.startsWith(`/viewer/shell-output`)&&f(null)},[o,s,a,m,d,l]),W(()=>{s!==null&&s>=t&&(a?.(l!=null),c(null),z()?.goBack())},[s,t,l,a]),W(()=>{m!==null&&m>=n&&(h(null),_(!1),y(!1),o===`/pane/queue/edit`&&z()?.goBack())},[o,m,n]),{editedFileFullIndex:s,openEditedFileFull:D,closeEditedFileFull:ee,taskDetailTurn:l,openTaskDetail:te,closeTaskDetail:O,shellFullOutput:d,setShellFullOutput:p,queueEditIndex:m,setQueueEditIndex:h,queueCloseConfirm:g,setQueueCloseConfirm:_,queueEscSuppress:v,setQueueEscSuppress:y,interruptConfirm:b,setInterruptConfirm:x,popQueuedConfirm:S,setPopQueuedConfirm:C,supplyDraft:w,setSupplyDraft:T,fullScreenPaneActive:E}}let hu=null;function gu(e){hu=e}function _u(){let e=hu;return e?.hasSelection()?(e.clear(),!0):!1}function vu(e,t){let n=e.getState().offset;return e.subscribe(()=>{let r=e.getState().offset;r!==n&&(n=r,t())})}function yu(e){let{showHome:t,tasksLength:n,backgroundTasksLength:r,editedFilesLength:i,subagentsLength:a,draftsLength:o,draftOpen:s,queuedItemsLength:c,queueOpen:l,clipboardHasContent:u,shellExecutionRunning:d,routeDerivedOwner:f,currentPath:p,backgroundOutput:m,a2uiButtons:h,scrollOffset:g,editedFilesOpen:_,subagentsOpen:v,setTasksCollapsed:y,keybindingOverrides:b,promptSuggestions:S,onFillPromptSuggestion:C,isPromptDraftEmpty:w,capabilityCardShown:T,capabilityItemIds:E,onInstallCapability:D,onDismissCapabilityRecommendations:ee}=e,{onToggleDelegates:te,onToggleEditedFiles:O,onToggleSubagents:ne,onToggleDraftPane:k,onToggleQueuePane:re,onShellAbort:A,onInterrupt:ie,onA2uiAction:j,onCyclePermissionMode:ae,onToggleNotifications:se,onSubmit:M}=pu(),N=Gt(()=>{let e=z();e&&e.currentPath!==`/`&&e.navigate(`/`,{reset:!0})},[]),P=Gt(e=>{let o=z();if(!o)return!1;let s=[{path:`/`,activate:()=>N()},...t?[{path:`/home`,activate:()=>o.navigate(`/home`,{replace:!0})}]:[],...n>0?[{path:`/pane/tasks`,activate:()=>o.navigate(`/pane/tasks`,{replace:!0})}]:[],...r>0?[{path:`/pane/delegates`,activate:()=>{te?.()}}]:[],...i>0?[{path:`/pane/edited-files`,activate:()=>{O?.()}}]:[],...a>0?[{path:`/pane/subagents`,activate:()=>{ne?.()}}]:[],...u?[{path:`/pane/clipboard`,activate:()=>{o.navigate(`/pane/clipboard`,{replace:!0})}}]:[]];return s.length<=1?!1:(s[(Math.max(0,s.findIndex(e=>o.currentPath===e.path||o.currentPath.startsWith(e.path+`/`)))+e+s.length)%s.length]?.activate(),!0)},[r,N,s,o,i,te,k,O,re,ne,l,c,t,a,n,u]);Ft(`app-global-prelude`,(e,t)=>t.ctrl&&e===`c`?d?(A?.(),!0):(ie?.(),!0):!1),pe(`selection-escape`,(e,t)=>!t.escape||t.ctrl||t.meta||t.shift?!1:iu(p)?(_u(),!1):_u()),x(`app-prompt-global`,(e,r)=>{if(r.tab&&!r.ctrl&&!r.meta&&!r.shift)return p.startsWith(`/dialog/`)||p.startsWith(`/viewer/`)||bt(p)||![`prompt`,`home`,`taskFocus`,`background`,`editedFiles`,`subagents`,`schedule`,`draft`,`queue`,`clipboard`].includes(f)||p===`/pane/delegates`&&m?!1:P(r.shift?-1:1);let i=w?.()??!0;if(i&&g===0&&h&&h.length>0&&e>=`1`&&e<=`9`&&!r.ctrl&&!r.meta){let t=h.find(t=>t.key===e);if(t&&j)return j(t.componentId,t.action,t.payload),!0}if(i&&t&&S&&S.length>0&&e>=`1`&&e<=`9`&&!r.ctrl&&!r.meta){let t=S[Number(e)-1];if(t&&C)return C(t),!0}if(i&&t&&T&&E&&E.length>0&&!r.ctrl&&!r.meta){if(e===`0`)return ee?.(),!0;if(e>=`1`&&e<=`9`){let t=E[Number(e)-1];if(t&&D)return D(t),!0}}if(p===`/`&&r.ctrl&&e===`k`)return!1;let a=et(ze,f,e,r,b);if(a===`smart-close`)return p===`/pane/tasks`?(su(),!0):_?(O?.(),!0):v?(ne?.(),!0):(n>0?(y(()=>!1),z()?.navigate(`/pane/tasks`,{replace:!0})):y(e=>!e),!0);let o={"cycle-permission-mode":()=>{ae?.()},"toggle-notifications":()=>{se?.()},"toggle-edited-files":()=>{O?.()},"toggle-subagents":()=>{ne?.()},"toggle-delegates":()=>{te?.()},"toggle-draft-pane":()=>{k?.()},"toggle-queue-pane":()=>{re?.()},"open-keybinding-panel":()=>{M?.(`/keybindings`,`send`)}};return a&&o[a]?(o[a](),!0):!1});let ce=oe();$t((e,t)=>{ce.dispatch(e,t)})}function bu(e){let t=e>=60,n=e>=76,r=e>=100;return{modelName:!0,occupancyBar:!0,hintText:!0,permissionMode:t,perfIndicator:t,notificationBell:t,backgroundTaskIndicator:t,scheduleIndicator:t,serviceIndicator:t,cost:n,providerUsage:n,language:n,pluginStatusItems:r,liveClock:r}}const xu={narrow:0,medium:1,low:2};function Su(e){return e.map((e,t)=>({entry:e,index:t})).sort((e,t)=>{let n=xu[e.entry.tier]-xu[t.entry.tier];if(n!==0)return n;if(e.entry.isHost!==t.entry.isHost)return e.entry.isHost?-1:1;let r=(e.entry.order??0)-(t.entry.order??0);return r===0?e.index-t.index:r}).map(e=>e.entry)}const Cu=new Map;function wu(e){let t=Cu.get(e);return t||(t={consecutiveSlowCalls:0,tripped:!1},Cu.set(e,t)),t}function Tu(){Cu.clear()}function Eu(e,t){let n=wu(e.id);if(n.tripped)return null;let r=Date.now(),i=null;try{i=e.render(t)}catch{i=null}if(Date.now()-r>5){if(n.consecutiveSlowCalls+=1,n.consecutiveSlowCalls>=3)return n.tripped=!0,null}else n.consecutiveSlowCalls=0;return i}function Du(e){let t;for(let n of e){if(n.tickMs===void 0)continue;let e=Math.max(1e3,n.tickMs);(t===void 0||e<t)&&(t=e)}return t}function Ou(e){let{columns:t,permissionMode:n,cost:r,providerUsage:i,pluginStatusItems:a,statusWidgets:o,modelName:s}=e,[c,l]=K(0);W(()=>{if(!i)return;let e=setInterval(()=>l(e=>e+1),3e4);return()=>clearInterval(e)},[i]);let[u,d]=K(0);W(()=>{let e=Du(o);if(e===void 0)return;let t=setInterval(()=>d(e=>e+1),e);return()=>clearInterval(t)},[o]);let f=qt(()=>bu(t),[t]);return{footerVisible:f,badgeEntries:qt(()=>{let e=[];if(f.permissionMode&&n&&e.push({id:`host:permission-mode`,text:V.t(`pref.permModeLabel`,{context:n}),color:n===`bypass`?`warning`:`inactive`,separator:`dot`,tier:`narrow`,isHost:!0}),f.cost&&r&&e.push({id:`host:cost`,text:r,separator:`space`,tier:`medium`,isHost:!0}),f.providerUsage&&i){let t=Date.now(),n=Kn(i,t);n&&e.push({id:`host:provider-usage`,text:n,color:Yn(i.status,i.limitType,i.usedPercent,i.resetsAt,t,i.overageStatus),separator:`dot`,tier:`medium`,isHost:!0})}if(f.pluginStatusItems&&a)for(let t of a)e.push({id:t.id,text:t.text,separator:`space`,tier:`low`,isHost:!1});if(f.pluginStatusItems&&o.length>0){let n={nowMs:Date.now(),model:s,providerUsage:i,columns:t};for(let t of o){let r=Eu(t,n);r&&e.push({id:t.id,text:r.text,color:r.color,separator:`space`,tier:`low`,isHost:!1,order:t.order})}}return Su(e)},[f,n,r,i,c,a,o,u,s,t])}}function ku(e){let{shellExecution:t,subagentContext:n,agentProcessing:r,queuedItems:i,pendingEcho:a,pendingSteers:o,onRequestPopQueuedConfirm:s}=e,{onExitSubagentContext:c,onPopQueued:l,onInterrupt:u,onWithdrawPending:d,onWithdrawSteer:f}=pu();return Gt(()=>{if(!t){if(n){c?.();return}if(r){if(i.length>0){s?s():l?.();return}if(o&&o.length>0){let e=o[o.length-1];e&&f?.(e.id);return}if(a){d?.(a.text,a.mode);return}u?.();return}}},[t,n,c,r,i,a,o,l,u,d,f,s])}let Au=null;function ju(e){Au=e}function Mu(){return Au}function Nu(){let[e,t]=K(null),n=G(null),r=Gt(e=>{n.current=e,t(e),!e&&z()?.currentPath===`/pane/sigil`&&z()?.goBack()},[]),i=G(null),[a,o]=K(null),s=G(!1),[c,l]=K(null),u=G(null),d=Gt((e,t,n)=>{i.current=n,r({sigil:e,query:t,mode:`sigil`}),z()?.navigate(`/pane/sigil`)},[]),f=Gt(()=>{if(n.current?.mode===`history`){r(null);return}i.current=null,r({sigil:`#`,query:``,mode:`history`}),z()?.navigate(`/pane/sigil`)},[]);return W(()=>(ju(f),()=>ju(null)),[f]),{sigilState:e,setSigilState:r,sigilApplyRef:i,hadSigilFocusRef:s,chipContentViewerRequest:a,pasteContent:c,handleSigilTrigger:d,handleHistorySearch:f,handleChipReopen:Gt((e,n,r)=>{i.current={select:r.select,cancel:()=>r.cancel()},t({sigil:`@`,query:``}),z()?.navigate(`/pane/sigil`)},[]),handleChipViewPaste:Gt((e,t)=>{ot(z(),_,!0),o({label:e,content:t,onDismiss:()=>{o(null),ot(z(),_,!1)}})},[]),handleSigilClose:Gt(()=>{r(null)},[]),handlePasteConfirmRequest:Gt((e,t)=>{u.current=t,l(e),ot(z(),S,!0)},[]),handlePasteConfirm:Gt(()=>{u.current?.confirm(),u.current=null,l(null),ot(z(),S,!1)},[]),handlePasteCancel:Gt(()=>{u.current?.cancel(),u.current=null,l(null),ot(z(),S,!1)},[])}}function Pu(e){let{sigilState:t,setSigilState:n,sigilApplyRef:r,hadSigilFocusRef:i,focusOwner:a,preempted:o}=e;W(()=>{if(!t){i.current=!1;return}if(a===`sigilPane`&&!o){i.current=!0;return}i.current&&=(n(null),r.current?.cancel(!1),!1)},[t,a,o])}function Fu(){let e=Xn({budget:null});return{store:e,setBudget(t){e.setState({budget:t})},reset(){e.setState({budget:null})}}}function Iu(e,t){return e.toolCallId&&t.toolCallId&&e.toolCallId===t.toolCallId?{...e,...t}:{...e,...t,oldContent:e.oldContent??t.oldContent,newContent:t.newContent??e.newContent,addedLines:e.addedLines+t.addedLines,removedLines:e.removedLines+t.removedLines,timestamp:Math.max(e.timestamp,t.timestamp),turnId:t.turnId??e.turnId,toolCallId:t.toolCallId??e.toolCallId}}function Lu(e){let t=e.split(`/`);return t.length<=3?e:`…/${t.slice(-2).join(`/`)}`}function Ru(e){switch(e){case`edit`:return`~`;case`write`:return`+`;case`delete`:return`-`}}function zu(e,t){switch(e){case`edit`:return t.accent;case`write`:return t.success;case`delete`:return t.error}}function Bu({files:e,focused:r,onDismiss:i,onOpenFileFull:a,fullOpenIndex:o=null,rows:s=24}){let c=R(),[l,u]=ra(`editedFiles`,e.length),d=G(0);if(D(`edited-files-pane`,(t,n)=>n.escape?o===null?(z()?.navigate(`/`,{reset:!0}),i?.(),!0):!0:Me(`list-nav-up`,t,n,`editedFiles`)?(u(e=>Math.max(0,e-1)),!0):Me(`list-nav-down`,t,n,`editedFiles`)?(u(t=>Math.min(e.length-1,t+1)),!0):n.return?(a?.(l),!0):!1,{isActive:r}),e.length===0)return null;let f=e.reduce((e,t)=>e+t.addedLines,0),p=e.reduce((e,t)=>e+t.removedLines,0),m=Math.min(l,e.length-1),h=Ct(e,m,n(e.length,s,3),d.current);return d.current=h.scrollTop,J(Y,{flexDirection:`column`,children:[J(Y,{children:[q(X,{color:c.special,children:`▸ `}),q(X,{color:r?c.text:c.inactive,children:V.t(`panelTitle.editedFilesTitle`)}),J(A,{type:`secondary`,children:[` `,V.t(`diff.fileCountLabel`,{count:e.length})]}),f>0&&J(X,{color:c.diffAdd,children:[` +`,f]}),p>0&&J(X,{color:c.diffRemove,children:[` -`,p]}),!r&&J(A,{type:`secondary`,dim:!0,children:[` `,t(`v`)]}),r&&q(Y,{marginLeft:I.tight,children:q(C,{dim:!0,items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.enter,V.t(`hint.view`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]})})]}),J(Y,{marginLeft:I.section,flexDirection:`column`,children:[h.hasMoreAbove&&q(X,{dimColor:!0,children:V.t(`scroll.above`,{n:1})}),h.rows.map((e,t)=>{let n=h.scrollTop+t===m,i=n&&r?c.selection:c.inactive;return J(Y,{flexDirection:`row`,children:[q(X,{color:i,children:n?Nt():wt()}),J(X,{color:zu(e.operation,c),children:[Ru(e.operation),` `]}),q(X,{color:i,children:Lu(e.path)}),e.addedLines>0&&J(X,{color:c.diffAdd,children:[` +`,e.addedLines]}),e.removedLines>0&&J(X,{color:c.diffRemove,children:[` -`,e.removedLines]})]},`${e.path}-${e.timestamp}`)}),h.hasMoreBelow&&q(X,{dimColor:!0,children:V.t(`scroll.below`,{n:1})})]})]})}function Vu(e={}){return{tasks:[],tasksTitle:void 0,turnBoundaries:[],editedFiles:[],backgroundTasks:[],subagentsAccum:new Map,scheduleTasks:[],drafts:e.drafts??[],queued:[],pendingPermission:null,clipboardChars:0,clipboardText:``,clipboardFailed:!1,clipboardJustCopied:!1,backgroundOutput:null,subagentContext:null,forcedUpgrade:null,pendingEcho:null,pendingSteers:[],modelName:e.modelName??``,pluginStatusItems:[],statusWidgets:[],needsSetup:e.needsSetup??!1,permissionMode:e.permissionMode??`auto`,commands:e.commands??[],paneOwnsViewportFlag:!1,shellExecution:null,recentMentions:e.recentMentions??[],sessionList:[],sessionTitle:``,ftueStage:void 0,capabilityRecommendations:[],capabilityDismissed:!1}}function Hu(e={}){let t=Xn(Vu(e)),n,r={},i=()=>n?.();return{store:t,reset(){t.setState(Vu(e))},setNotify(e){n=e},setEffects(e){r=e},actions:{setTasks(e,n){t.setState({tasks:e}),t.setState({tasksTitle:n}),i()},setEditedFiles(e){t.setState({editedFiles:e.sort((e,t)=>t.timestamp-e.timestamp)}),i()},addEditedFile(e){let n=[...t.getState().editedFiles],r=n.findIndex(t=>t.path===e.path);r>=0?n[r]=Iu(n[r],e):n.push(e),n.sort((e,t)=>t.timestamp-e.timestamp),t.setState({editedFiles:n}),i()},setBackgroundTasks(e){if(t.setState({backgroundTasks:e}),e.some(e=>e.type===`agent-session`)){let n=new Map(t.getState().subagentsAccum);for(let t of e)t.type===`agent-session`&&n.set(t.id,t);t.setState({subagentsAccum:n})}i()},setTurnBoundaries(e){t.setState({turnBoundaries:[...e]})},addTurnBoundary(e){t.setState({turnBoundaries:[...t.getState().turnBoundaries,e]})},setDrafts(e){t.setState({drafts:e}),i()},setScheduleTasks(e){t.setState({scheduleTasks:e}),i()},setRecentMentions(e){t.setState({recentMentions:e}),i()},setModelName(e){t.setState({modelName:e}),i()},setSessionList(e){t.setState({sessionList:e}),i()},setSessionTitle(e){t.setState({sessionTitle:e}),i()},setNeedsSetup(e){t.getState().needsSetup!==e&&(t.setState({needsSetup:e}),i())},setFtueStage(e){t.getState().ftueStage!==e&&(t.setState({ftueStage:e}),i())},setCapabilityRecommendations(e){t.setState({capabilityRecommendations:e}),i()},dismissCapabilityRecommendations(){t.getState().capabilityDismissed||(t.setState({capabilityDismissed:!0}),i())},setPermissionMode(e){t.setState({permissionMode:e}),i()},setForcedUpgrade(e){t.setState({forcedUpgrade:e}),r.syncForcedUpgradeRoute?.(!!e),i()},setPluginStatusItems(e){t.setState({pluginStatusItems:e}),r.registerStatusItems?.(e),i()},setBackgroundOutput(e){t.setState({backgroundOutput:e}),r.backgroundOutputRoute?.(e!==null),r.flushScrollbackIfIdle?.(),i()}}}}function Uu(){let e=Xn({memory:void 0,memoryHistory:[],notify:void 0,indicatorLevel:`healthy`,pluginMetrics:[]});return{store:e,reset(){e.setState({memory:void 0,memoryHistory:[],notify:void 0,indicatorLevel:`healthy`,pluginMetrics:[]})},setMemory(t){let n=[...e.getState().memoryHistory,t.heapUsed].slice(-32);e.setState({memory:t,memoryHistory:n})},setNotify(t){e.setState({notify:t})},setIndicatorLevel(t){e.setState({indicatorLevel:t})},setPluginMetrics(t){e.setState({pluginMetrics:t})}}}function Wu(){let e=Xn({view:null});return{store:e,setView(t){e.setState({view:t})}}}function Gu(){return{view:{configPath:`~/.otto/config.json`}}}function Ku(){let e=Xn(Gu());return{store:e,setView(t){e.setState({view:t})}}}function qu(e=Date.now){let t=Xn({entries:[]}),n=1,r=r=>{let i=[{...r,id:n++,timestamp:e()},...t.getState().entries].slice(0,20);t.setState({entries:i})};return{store:t,recordCompaction(e,t,n){r({kind:`compact`,before:e,after:t,summary:n})},recordPrune(e,t){r({kind:`prune`,tokensSaved:e,prunedCount:t})},recordHistoryCapped(e){r({kind:`history_capped`,removedCount:e})}}}const Ju={categoryIndex:0,itemIndex:0,variantIndex:0};function Yu(){let e=Xn({...Ju});return{store:e,reset(){e.setState({...Ju})},setCategoryIndex(t){e.setState({categoryIndex:t,itemIndex:0,variantIndex:0})},setItemIndex(t){e.setState({itemIndex:t,variantIndex:0})},setVariantIndex(t){e.setState({variantIndex:t})}}}function Xu(e){let{taskStore:t,budgetStore:n,perfStore:r,cacheStore:i,proxyStore:a,compactionLogStore:o,galleryStore:s,streamStore:c}=e;return{taskStore:qt(()=>t??Hu(),[t]),budgetStore:qt(()=>n??Fu(),[n]),perfStore:qt(()=>r??Uu(),[r]),cacheStore:qt(()=>i??Wu(),[i]),proxyStore:qt(()=>a??Ku(),[a]),compactionLogStore:qt(()=>o??qu(),[o]),galleryStore:qt(()=>s??Yu(),[s]),streamStore:qt(()=>c??pl(),[c])}}const Zu=[{en:`Use ↑/↓ for input history; Ctrl+R opens fuzzy history search.`,zh:`输入框里按 ↑/↓ 浏览历史输入,Ctrl+R 模糊搜索历史。`},{en:`Use /feedback to report a bug or request a feature via GitHub.`,zh:`输入 /feedback 可通过 GitHub 提交 bug 或功能建议。`},{en:`During a run, press Esc on an empty prompt to interrupt and steer.`,zh:`运行时输入框为空按 Esc 可中断,otto 停下来让你接管方向。`},{en:`During a run, Shift+Enter queues a follow-up; Ctrl+Q manages it.`,zh:`运行中按 Shift+Enter 排队追加消息(本回合后执行),Ctrl+Q 管理队列。`},{en:`While otto works, plain Enter steers the current turn.`,zh:`otto 工作中按普通 Enter 可注入引导消息到当前回合。`},{en:`Type /model then Tab to pick a model and switch mid-session.`,zh:`输入 /model 后按 Tab 自动补全可用模型,会话中途即可切换。`},{en:`Use /install for skills/plugins/MCP; manage them in /extension.`,zh:`/install 从文件或 URL 安装技能/插件/MCP,/extension 面板管理。`},{en:`Reasoning streams inline; /effort changes its intensity.`,zh:`推理过程实时内联在对话流中生成,/effort 调节推理强度。`},{en:`Type /open then Tab to browse and open files in the viewer.`,zh:`输入 /open 按 Tab 浏览目录,在内置查看器打开文件。`},{en:`Ctrl+S saves the current input as a draft; Ctrl+O lists and loads drafts.`,zh:`Ctrl+S 把当前输入存为草稿,Ctrl+O 打开草稿面板选择载入。`},{en:`Ctrl+R or /history searches session and shell history.`,zh:`Ctrl+R(或 /history)搜索会话与 shell 历史,选中即回填。`},{en:`Large pastes become chips; press Enter on a chip to view it.`,zh:`大段粘贴自动折叠成占位标记,光标停在标记上按 Enter 查看原文。`},{en:`Use /compact to free context; /compact log shows pruned items.`,zh:`长会话用 /compact 释放上下文,/compact log 查看裁剪明细。`},{en:"Run `otto doctor` in another terminal for a full health check.",zh:"在另一个终端运行 `otto doctor` 做完整环境健康诊断。"},{en:`Otto can fall back to another model after failure or rate limits.`,zh:`当前模型失败或限流时,otto 自动回退到已配置的其他模型。`},{en:`Use /schedule add with cron syntax for recurring tasks.`,zh:`/schedule add 用 cron 表达式设定期任务(如日报)。`},{en:`Use /queue to reorder or remove queued follow-ups.`,zh:`/queue 面板管理排队消息,move 调顺序,remove 删除。`},{en:`Tab completes slash commands and arguments: /model gpt<Tab>.`,zh:`Tab 补全斜杠命令及其参数(试试 /model gpt<Tab>)。`},{en:`Ctrl+P opens Delegates; press Enter to view job output.`,zh:`Ctrl+P 打开委派面板查看后台任务,Enter 实时查看其输出。`},{en:`Use /job <directive> to run work in a background worktree.`,zh:`/job <指令> 在后台 worktree 跑任务,不阻塞当前会话。`},{en:`Language, model, and permission mode persist across sessions.`,zh:`语言、模型、权限模式跨会话自动持久化。`},{en:`Ctrl+V lists edited files; Enter opens a full-screen diff.`,zh:`Ctrl+V 列出本会话修改的文件及 +/- 统计,Enter 打开全屏 diff。`},{en:`Scroll with Alt+↑/↓ or PgUp/PgDn; press / in review to search.`,zh:`Alt+↑/↓ 或 PageUp/PageDown 滚动对话流,回看态按 / 搜索。`},{en:`Use /perf for memory and rendering health; /diagnose for failures.`,zh:`/perf 查看内存占用与渲染健康度,/diagnose 汇总反复出现的失败并给改进建议。`},{en:`Use /preference to switch theme or language.`,zh:`/preference theme 切 dark/light/system 主题,/preference lang 切中英文。`},{en:`Wheel scrolling works by default; drag to select, release to copy.`,zh:`滚轮/触控板开箱即用,拖拽即选中、松手自动复制。`},{en:`Use /upgrade for otto updates; /upgrade --check checks extensions.`,zh:`/upgrade 检查 otto 更新,/upgrade --check 检查扩展更新。`},{en:`Use /resume for recent sessions; /pin keeps favorites on top.`,zh:`/resume 切换最近会话,/pin 把常用会话置顶。`}];function Qu({active:e,resetKey:t,isZh:n,delayMs:r=6e4,rotateMs:i=2e4}){let[a,s]=K(!1),[c,l]=K(()=>$u()),u=G(e);u.current=e;let d=G(0),[f,p]=K(0);if(o(`idle-tip-activity`,()=>{d.current+=1,p(d.current)},{isActive:e}),W(()=>{if(!e){s(!1);return}s(!1);let t=setTimeout(()=>{u.current&&s(!0)},r);return()=>{clearTimeout(t)}},[e,t,r,f]),W(()=>{if(!a)return;let e=setInterval(()=>{l(e=>(e+1)%Zu.length)},i);return()=>clearInterval(e)},[a,i]),!e||!a)return null;let m=Zu[c%Zu.length];return m?n?m.zh:m.en:null}function $u(){let e=new Date,t=`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`,n=0;for(let e=0;e<t.length;e++)n=(n<<5)-n+t.charCodeAt(e)|0;return Math.abs(n)%Zu.length}function ed(){return q(Y,{children:q(X,{color:R().warning,children:`🕶 ${V.t(`welcome.shadowChip`)}`})})}function td(){let e=R();return J(Y,{flexDirection:`column`,marginBottom:I.tight,children:[q(X,{bold:!0,color:e.warning,children:`🕶 ${V.t(`welcome.shadowBannerTitle`)}`}),q(X,{color:e.suggestion,children:V.t(`welcome.shadowGuarantee`)}),J(Y,{marginTop:I.tight,flexDirection:`column`,children:[q(X,{color:e.inactive,children:V.t(`welcome.shadowNotGuaranteedTitle`)}),q(X,{color:e.inactive,children:` • ${V.t(`welcome.shadowNg1`)}`}),q(X,{color:e.inactive,children:` • ${V.t(`welcome.shadowNg2`)}`}),q(X,{color:e.inactive,children:` • ${V.t(`welcome.shadowNg3`)}`}),q(X,{color:e.inactive,children:` • ${V.t(`welcome.shadowNg4`)}`})]})]})}const nd=[`#E06C75`,`#D19A66`,`#E5C07B`,`#98C379`,`#61AFEF`,`#C678DD`],rd=[`#B5403A`,`#B45F1F`,`#96740F`,`#4E7A34`,`#2364A8`,`#7B4FC4`];function id(e){let t=2*e;return 375+t+188+t}function ad(e){return 2*e}function od(e,t){return Math.min(t,Math.floor(e/2)+1)}function sd(e,t){let n=ad(t),r=e%id(t);if(r<375)return{phase:`brand`,progress:0,t:r};let i=r-375;if(i<n)return{phase:`entering`,progress:od(i,t),t:i};let a=i-n;if(a<188)return{phase:`hold`,progress:t,t:a};let o=a-188;return o<n?{phase:`exiting`,progress:od(o,t),t:o}:{phase:`brand`,progress:0,t:r}}function cd(e){let t=e%16;return t<=8?t/8:(16-t)/8}function ld(e){return Math.floor(e/3)%nd.length}function ud(e,t,n){let r=n===`light`?rd:nd,i=ld(t),a=[];for(let t=0;t<e;t++)a.push(r[(t+i)%r.length]);return a}function dd(e,t){let n=parseInt(e.slice(1),16),r=n>>16&255,i=n>>8&255,a=n&255,o=e=>Math.round(e+(255-e)*t),s=e=>e.toString(16).padStart(2,`0`).toUpperCase();return`#${s(o(r))}${s(o(i))}${s(o(a))}`}function fd(e,t,n,r,i,a,o){let s=i===`light`?rd:nd,c=a.phase===`hold`?cd(a.t):0,l=[];for(let i=0;i<e.length;i++){let u=a.phase===`hold`||a.phase===`entering`&&i<a.progress||a.phase===`exiting`&&i>=a.progress,d=Math.abs(i-t)<=n,f;if(u){let e=s[(i+r)%s.length];f=dd(e,d?.5+.25*c:.5*c)}else f=d?o.brandShimmer:o.brand;let p=l[l.length-1];p&&p.color===f?p.text+=e[i]:l.push({text:e[i],color:f})}return l}const pd=[`✦`,`✧`,`·`,`⋆`],md=[`~`,`°`,`·`,`˘`,`∼`],hd=[`▄▀▀▄ ▀█▀ ▀█▀ ▄▀▀▄`,`▀▄▄▀ █ █ ▀▄▄▀`],gd=[{left:2,phase:0},{left:8,phase:11},{left:13,phase:22}],_d=[{left:1,phase:16}],vd=[{left:1,phase:0},{left:5,phase:10},{left:9,phase:20},{left:14,phase:30}],yd=[{left:3,phase:15},{left:10,phase:35}];function bd(e,t){let n=(e+t)%32,r=n<=16?n/16:(32-n)/16;return r<.15?0:r<.5?1:r<.85?2:3}function xd(e,t){let n=(e+t)%70,r=(Math.sin(n/70*Math.PI*2)+1)/2;return r<.1?0:r<.4?1:r<.75?2:3}function Sd(e,t){return md[Math.floor((e+t)/8)%md.length]}function Cd({isNight:e=!1}){let t=R(),{resolvedTheme:n}=gt(),[r,i]=H.useState(0),a=Be();He(80,i);let o=e&&!a,s=!e&&!a,c=a?null:sd(r,hd[0].length),l=ld(r),u={brand:t.brand,brandShimmer:t.brandShimmer},d=e=>e===1?t.accentDim:e===3?t.accentBright:t.accent,f=(e,t,n)=>{let i=bd(r,e.phase);return i===0?null:q(Y,{position:`absolute`,top:t,left:e.left,children:q(X,{color:d(i),children:pd[n%pd.length]})},`${t}-${e.left}`)},p=(e,t,n)=>{let i=xd(r,e.phase);return i===0?null:q(Y,{position:`absolute`,top:t,left:e.left,children:q(X,{color:d(i),children:Sd(r,e.phase)})},`ripple-${n}`)};return J(Y,{position:`relative`,flexDirection:`column`,children:[hd.map((e,i)=>{let a=el(r+i*3,e.length);return q(Y,{flexDirection:`row`,children:c&&c.phase!==`brand`?fd(e,a,2,l,n,c,u).map((e,t)=>q(X,{bold:!0,color:e.color,children:e.text},t)):$c(e,a,2).map((e,n)=>q(X,{bold:!0,color:e.bright?t.brandShimmer:t.brand,children:e.text},n))},i)}),o&&gd.map((e,t)=>f(e,-1,t)),o&&_d.map((e,t)=>f(e,hd.length,t)),s&&vd.map((e,t)=>p(e,-1,t)),s&&yd.map((e,t)=>p(e,hd.length,t))]})}const wd=[`provider`,`authentication`,`model`],Td={provider:{titleKey:`recovery.titleProvider`,ctaKey:`recovery.ctaProvider`,hintKey:`recovery.hintProvider`},authentication:{titleKey:`recovery.titleAuth`,ctaKey:`recovery.ctaAuth`,hintKey:`recovery.hintAuth`},model:{titleKey:`recovery.titleModel`,ctaKey:`recovery.ctaModel`,hintKey:`recovery.hintModel`}};function Ed(e,t){if(e===`ready`||e===`first-prompt`)return null;let n=Td[e],r=wd.indexOf(e)+1,i=t<80;return{titleKey:n.titleKey,ctaKey:n.ctaKey,...i?{}:{hintKey:n.hintKey},step:r,totalSteps:wd.length}}function Dd(e,t){return e||(t?`model`:void 0)}function Od(e){return!e||e===`ready`||e===`first-prompt`?null:Td[e].ctaKey}function kd(e,t){return e===void 0?t:!(e===`ready`||e===`first-prompt`)}function Ad(e,t,n){return t!==`first-prompt`||n||e.length===0?null:{items:e.slice(0,3)}}function jd({version:e=`0.1.0`,buildId:t,cwd:n,width:r,nickname:i,updateAvailable:a,weather:o,ftueStage:c,promptSuggestions:l,capabilityRecommendations:u,capabilityDismissed:d=!1,shadow:f=!1}){let p=R(),m=n?n.replace(process.env.HOME??`~`,`~`):void 0,h=r??process.stdout.columns??80,g=h>=60,_=H.useMemo(()=>{let e=new Date().getHours();return e<5?`late`:e<9?`earlyMorning`:e<12?`morning`:e<18?`afternoon`:e<22?`evening`:`night`},[]),v=_===`night`||_===`late`,[y]=H.useState(()=>{let e=new Date,t=V.language===`zh`?[`日`,`一`,`二`,`三`,`四`,`五`,`六`]:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],n=t[e.getDay()]??t[0],r=i?V.language===`zh`?`,${i}`:`, ${i}`:``;return V.t(`welcome.greeting`,{context:_,wday:n,who:r})}),b=y,x=V.t(`welcome.version`),S=V.t(`welcome.workspace`),C=Math.max(Oe(x),Oe(S))+4,w=hd.map(e=>Oe(e)),T=Math.max(...w),E=e=>` `.repeat(Math.max(0,T-(w[e]??T))),D=c?Ed(c,h):null,ee=(c===void 0||c===`ready`)&&l&&l.length>0?l.slice(0,3):[],te=Ad(u??[],c,d);return q(Y,{flexDirection:`column`,children:J(Y,{flexDirection:`column`,paddingX:I.tight,paddingTop:I.section,...Ue,borderColor:p.panelBorder,children:[g&&J(Y,{marginBottom:I.tight,flexDirection:`row`,children:[q(Cd,{isNight:v}),J(Y,{flexDirection:`column`,marginLeft:I.loose,children:[J(Y,{flexDirection:`row`,children:[J(A,{type:`secondary`,children:[E(0),s(x,C)]}),J(A,{type:`secondary`,children:[`v`,e]}),t!=null&&J(A,{type:`secondary`,dim:!0,children:[` `,`(build `,t,`)`]}),a&&a.newer&&J(X,{color:a.forced?p.warning:p.accent,children:[` `,a.forced?V.t(`update.forcedBanner`,{latest:a.latest}):V.t(`update.availableBanner`,{latest:a.latest})]})]}),m&&J(Y,{flexDirection:`row`,children:[J(A,{type:`secondary`,children:[E(1),s(S,C)]}),q(A,{type:`secondary`,children:m})]})]})]}),!g&&J(Y,{flexDirection:`column`,marginBottom:I.tight,children:[J(Y,{flexDirection:`row`,children:[$c(`otto`,1).map((e,t)=>q(X,{bold:!0,color:e.bright?p.brandShimmer:p.brand,children:e.text},t)),q(A,{type:`secondary`,children:` ${s(x,C)}`}),J(A,{type:`secondary`,children:[`v`,e]}),t!=null&&J(A,{type:`secondary`,dim:!0,children:[` `,`(build `,t,`)`]})]}),m&&J(Y,{flexDirection:`row`,children:[q(A,{type:`secondary`,children:` ${s(S,C)}`}),q(A,{type:`secondary`,children:m})]})]}),q(Y,{marginBottom:I.tight,children:i&&b.includes(i)?J(X,{color:p.text,bold:!0,children:[b.slice(0,b.indexOf(i)),q(X,{color:p.accent,children:i}),b.slice(b.indexOf(i)+i.length)]}):q(X,{color:p.text,bold:!0,children:b})}),D&&J(Y,{flexDirection:`column`,marginBottom:I.tight,children:[J(Y,{children:[q(X,{color:p.warning,bold:!0,children:V.t(D.titleKey)}),q(A,{type:`secondary`,children:` ${D.step}/${D.totalSteps}`})]}),D.hintKey&&q(A,{type:`secondary`,children:V.t(D.hintKey)}),q(X,{color:p.accent,children:V.t(D.ctaKey)})]}),ee.length>0&&J(Y,{flexDirection:`column`,marginBottom:I.tight,children:[q(A,{type:`secondary`,children:V.t(`welcome.suggestionsLabel`)}),ee.map((e,t)=>J(Y,{flexDirection:`row`,children:[J(X,{color:p.accent,children:[` [`,t+1,`] `]}),q(A,{type:`secondary`,children:e})]},t))]}),te&&J(Y,{flexDirection:`column`,marginBottom:I.tight,children:[q(A,{type:`secondary`,children:V.t(`capability.sectionTitle`)}),te.items.map((e,t)=>J(Y,{flexDirection:`row`,children:[J(X,{color:p.accent,children:[` [`,t+1,`] `]}),q(A,{type:`secondary`,children:V.t(e.reasonKey)})]},e.extensionId)),J(Y,{flexDirection:`row`,children:[q(X,{color:p.accent,children:` [0] `}),q(A,{type:`secondary`,children:V.t(`capability.actionNotNow`)})]})]}),f&&q(td,{}),o&&J(Y,{marginBottom:I.tight,children:[J(X,{color:p.accent,children:[o.condition,` `,o.temp,`°C`]}),J(A,{type:`secondary`,children:[` `,o.location]})]})]})})}function Md(e,t){let n=la();W(()=>{if(n)return n.registerWheel(e)},[n,...t])}function Nd({title:e,status:t,messages:n,streamText:r=``,rows:i=24,columns:o=80,onDismiss:s}){let c=R(),l=a();D(`subagent-context-view`,(e,t)=>t.escape?(s?.(),!0):t.upArrow?(m(e=>b(e+1)),!0):t.downArrow?(m(e=>b(e-1)),!0):t.pageUp?(m(e=>b(e+v)),!0):t.pageDown?(m(e=>b(e-v)),!0):e===`g`&&!t.ctrl&&!t.meta?(m(y),!0):e===`G`&&!t.ctrl&&!t.meta?(m(0),!0):!1,{isActive:l?l.currentPath===`/subagent`:!0});let d=[];for(let e of n){let t=rc(e,o);t.length>0&&d.push(t)}let f=[];for(let e=0;e<d.length;e++)e>0&&f.push(``),f.push(...d[e]);let[p,m]=K(0),h=p===0,g=Qc(r,o-Pe.borderInset,3);if(h&&g.length>0){f.length>0&&f.push(``),f.push(`⏺ assistant (streaming)`);for(let e of g)f.push(` ${e}`)}let _=u(i),v=Math.max(1,_-7),y=Math.max(0,f.length-v),b=e=>Math.min(y,Math.max(0,e)),x=y-b(p),S=f.slice(x,x+v);return Md(e=>m(t=>b(t+e*3)),[y]),J(F,{maxHeight:_,header:J(Y,{flexDirection:`column`,children:[q(X,{color:c.secondary,italic:!0,children:V.t(`subagent.header`,{title:e,status:t})}),q(X,{children:` `})]}),footer:q(C,{items:[...y>0?[[`${j.up}${j.down}`,V.t(`hint.scroll`)]]:[],[j.esc,V.t(`hint.back`)]]}),children:[q(Y,{height:1,children:x>0&&q(A,{type:`secondary`,dim:!0,children:V.t(`subagent.contextEarlierLines`,{n:x})})}),q(Y,{flexDirection:`column`,children:S.map((e,t)=>q(X,{children:e},`${x+t}`))})]})}function Pd(e,t,n=60){if(e.length===0)return null;let r=Math.max(0,Math.min(t,e.length-1));for(let t=r;t>=0;t--){let r=e[t];if(!r||r.role!==`user`)continue;let i=Fd(r.content);if(i)return Ld(i,n)}return null}function Fd(e){return typeof e==`string`?e.trim():Array.isArray(e)?e.map(e=>typeof e==`string`?e:Id(e)?e.text:``).filter(Boolean).join(` `).trim():Id(e)?String(e.text).trim():``}function Id(e){return!!e&&typeof e==`object`&&typeof e.text==`string`}function Ld(e,t){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,Math.max(1,t-1))}…`}function Rd(e,t){let n=e.replace(/\s+/g,` `).trim();return t<=0?``:P(n,t)}function zd({sessionTitle:e,reviewing:t,turnPrompt:n,maxWidth:r}){let i=t&&n?n:e??``;return i===``||r===void 0?i:Rd(i,r)}function Bd(e){return typeof e==`string`&&/^[a-f\d]{8}$/i.test(e)}function Vd(e){let t=pu(),{taskStore:n}=eu(),r=Z(n.store,e=>e.sessionTitle),i=Z(n.store,e=>e.sessionList),a=Z(n.store,e=>e.needsSetup),o=Z(n.store,e=>e.ftueStage),s=Z(n.store,e=>e.pendingPermission),c=Z(n.store,e=>e.subagentContext),l=Z(n.store,e=>e.pendingEcho),u=Z(n.store,e=>e.pendingSteers),d=Z(e.scrollStore.store,e=>e.offset>0),[f,p]=H.useState(null);H.useEffect(()=>{c&&p(null)},[c]);let m=Z(e.scrollStore.store,e=>e.offset),h=Z(e.scrollStore.store,e=>e.atTranscriptTop),g=H.useMemo(()=>{if(!d)return null;let t=Math.max(0,e.messages.length-1-Math.floor(m/3));return Pd(e.messages,t)},[d,m,e.messages]),_=Dd(o,a);if(e.welcome&&e.showHome)return q(jd,{version:e.welcome.version,buildId:e.welcome.buildId,cwd:e.welcome.cwd,width:e.columns,nickname:e.welcome.nickname,updateAvailable:e.welcome.updateAvailable,weather:e.welcome.weather,sessionList:i,onSessionSelect:t.onSessionSelect,ftueStage:_,promptSuggestions:e.promptSuggestions,capabilityRecommendations:e.capabilityRecommendations,capabilityDismissed:e.capabilityDismissed,shadow:e.shadow});let v=zd({sessionTitle:r,reviewing:d,turnPrompt:g,maxWidth:Math.max(1,e.columns-2)}),y=v.length>0&&!Bd(v)&&!h,b=Math.max(1,e.rows-(y?1:0)-(f?1:0));return J(Y,{flexDirection:`column`,flexGrow:1,justifyContent:`flex-end`,children:[y&&q(Y,{height:1,flexShrink:0,flexDirection:`row`,children:q(X,{dimColor:!0,children:`${L.userPrompt} ${v}`})}),c?(()=>{let n=c;return q(Nd,{title:n.title,status:n.status,messages:n.messages,streamText:n.streamText,rows:b,columns:e.columns,onDismiss:t.onExitSubagentContext})})():q(Jt,{children:q(bl,{streamStore:e.streamStore,completedMessages:e.messages,columns:e.columns,rows:b,maxPreviewRows:e.fullScreenPaneActive?0:e.maxPreviewRows,suppressLive:e.fullScreenPaneActive||d,pendingEcho:l??null,scrollbackMode:e.scrollbackMode??!1,pendingSteers:u??[],windowMode:e.windowMode,scrollStore:e.scrollStore,earlierLoading:e.earlierLoading,earlierEnded:e.earlierEnded,onNeedEarlier:e.onNeedEarlier,onPrepend:e.onPrepend,findQuery:e.findQuery,findActiveMatch:e.findActiveMatch,onFindNavigateTo:e.onFindNavigateTo,onFindCountChange:e.onFindCountChange,onReviewHintChange:p,renderReviewHint:!1,topbarReserved:y,pendingPermission:s??null,suppressSpinner:e.fullScreenPaneActive})}),f&&q(Y,{height:1,flexShrink:0,flexDirection:`row`,children:q(X,{dimColor:!0,children:f})})]})}const Hd=Oe(` · `),Ud=Oe(`←`)+4;function Wd(e,t,n,r){let i=e.map((e,n)=>({item:e,index:n,label:t(e)}));if(e.length===0)return{items:[],hiddenLeft:0,hiddenRight:0};if(r===void 0||!Number.isFinite(r)||r<=0)return{items:i,hiddenLeft:0,hiddenRight:0};let a=Math.max(0,Math.min(n,e.length-1)),o=e=>Oe(i[e].label)+2;if(i.reduce((e,t,n)=>e+o(n),0)+(i.length-1)*Hd<=r)return{items:i,hiddenLeft:0,hiddenRight:0};let s=Math.max(6,r-Ud*2),c=a,l=a+1,u=Math.min(o(a),s);for(;;){let e=l<i.length,t=c>0;if(!e&&!t)break;let n=!1;if(e){let e=o(l)+Hd;u+e<=s&&(u+=e,l++,n=!0)}if(t){let e=o(c-1)+Hd;u+e<=s&&(u+=e,c--,n=!0)}if(!n)break}return{items:i.slice(c,l).map(e=>{let t=Math.max(1,s-2);return Oe(e.label)>t?{...e,label:P(e.label,t)}:e}),hiddenLeft:c,hiddenRight:i.length-l}}function Gd({label:e,active:t,disabled:n,color:r=`accent`}){return q(Ne,{variant:`ghost`,color:r,label:e,focused:t,disabled:n})}function Kd({items:e,activeKey:t,color:n=`accent`,tabIndex:r=-1,onSelect:i,availableWidth:a,enableDigitAccess:o=!1}){let s=R(),{focused:c}=T({tabIndex:r,disabled:r<0}),l=(n,r)=>{if(!i||e.length===0)return!1;let a=e.findIndex(e=>e.key===t);if(r.leftArrow||r.rightArrow)return i(e[(a+(r.leftArrow?-1:1)+e.length)%e.length].key),!0;if(o&&n>=`1`&&n<=`9`){let t=n.charCodeAt(0)-49;return t<e.length&&!e[t].disabled?(i(e[t].key),!0):!1}return!1};y(c,l),D(`segmented-${e.map(e=>e.key).join(`-`)}`,l,{isActive:!!i&&!c});let u=Wd(e,e=>e.label,e.findIndex(e=>e.key===t),a);return J(Y,{flexDirection:`row`,gap:I.tight,children:[u.hiddenLeft>0&&q(X,{color:s.inactive,children:`←${u.hiddenLeft}`}),u.items.map((e,r)=>J(H.Fragment,{children:[r>0&&q(X,{color:s.inactive,children:`·`}),q(Gd,{label:e.label,active:e.item.key===t,disabled:e.item.disabled,color:n})]},e.item.key)),u.hiddenRight>0&&q(X,{color:s.inactive,children:`→${u.hiddenRight}`})]})}const qd={running:L.todoActive,exited:L.check,killed:L.cross,failed:L.cross};function Jd(e,t){return e===`running`?t.special:e===`exited`?t.success:t.error}function Yd(e){if((e.type??`process`)===`agent-session`)switch(e.agentStatus){case`running`:return L.todoActive;case`ready`:return L.attention;case`needs_input`:return L.attention;case`applied`:return L.check;default:return L.cross}return qd[e.status]}function Xd(e,t){if((e.type??`process`)===`agent-session`){if(e.stall===`stalled`)return t.error;if(e.stall===`warn`)return t.warning;switch(e.agentStatus){case`running`:return t.special;case`ready`:return t.selection;case`needs_input`:return t.warning;case`applied`:return t.success;default:return t.error}}return Jd(e.status,t)}function Zd({tasks:e,columns:r=80,onClose:i,onKill:a,onViewOutput:o,onApply:s,onSwitch:c,onDelete:l,active:u=!0,rows:d=24}){let f=R(),[p,m]=ra(`delegates`,e.length),h=G(0),g=e.some(e=>(e.type??`process`)===`agent-session`?e.agentStatus===`running`:e.status===`running`),[,_]=K(0);W(()=>{if(!g)return;let e=setInterval(()=>_(e=>(e+1)%1e6),1e3);return()=>clearInterval(e)},[g]),D(`delegates-pane`,(t,n)=>{if(n.escape||t===`q`)return i?.(),!0;if(Me(`list-nav-up`,t,n,`background`))return m(e=>Math.max(0,e-1)),!0;if(Me(`list-nav-down`,t,n,`background`))return m(t=>Math.max(0,Math.min(e.length-1,t+1))),!0;let r=e[p],u=r?yo(r):!1;return t===`k`&&u&&r?(a?.(r.id),!0):(t===`o`||n.return)&&r?(o?.(r.id),!0):t===`a`&&r?.type===`agent-session`&&r.agentStatus===`ready`&&r.diffStat?(s?.(r.id),!0):t===`s`&&r?.type===`agent-session`?(c?.(r.id),!0):t===`d`&&r&&!u?(l?.(r.id),!0):!1},{isActive:u,ignoreRoute:!0});let v=e.filter(yo).length,y=Date.now(),b=Math.max(12,Math.min(48,r-28));if(!u){if(e.length===0)return null;let n=e[Math.min(p,e.length-1)];return J(Y,{flexDirection:`column`,children:[J(Y,{children:[q(X,{color:f.special,children:`▸ `}),q(A,{type:`secondary`,children:V.t(`bg.tasksTitle`)}),J(A,{type:`secondary`,children:[` `,e.length]}),v>0&&J(A,{type:`secondary`,children:[` · `,V.t(`bg.runningSuffix`,{n:v})]}),J(A,{type:`secondary`,dim:!0,children:[` `,t(`p`)]})]}),n&&J(Y,{flexDirection:`row`,children:[q(A,{type:`secondary`,children:`${L.pointer} `}),q(A,{type:`secondary`,children:P(n.command,b).padEnd(b)}),J(A,{type:`secondary`,dim:!0,children:[` `,To(n,y)]})]})]})}let x=e[Math.min(p,e.length-1)],S=(x?.type??`process`)===`agent-session`&&x?.agentStatus===`ready`&&!!x?.diffStat,w=!!x&&!yo(x),T=Math.min(p,e.length-1),E=[],ee,te=0;e.forEach((e,t)=>{let n=_o(e);n!==ee&&(te>0&&E.push({type:`spacer`}),E.push({type:`header`,category:n}),te++,ee=n),E.push({type:`entry`,task:e,index:t})});let O=Ct(E,E.findIndex(e=>e.type===`entry`&&e.index===T),n(E.length,d,3),h.current);return h.current=O.scrollTop,J(Y,{flexDirection:`column`,children:[J(Y,{children:[q(X,{color:f.special,children:`▸ `}),q(X,{color:f.text,children:V.t(`bg.tasksTitle`)}),J(A,{type:`secondary`,children:[` `,v>0?V.t(`bg.runningSuffix`,{n:v}):`${e.length} total`,e.length>v?` · ${V.t(`bg.doneSuffix`,{n:e.length-v})}`:``]}),q(Y,{marginLeft:I.tight,children:q(C,{dim:!0,items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[`k`,V.t(`hint.kill`)],[`o`,V.t(`hint.output`)],...S?[[`a`,V.t(`hint.apply`)]]:[],...w?[[`d`,V.t(`hint.delete`)]]:[],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]})})]}),q(Y,{marginLeft:I.section,flexDirection:`column`,children:e.length===0?q(A,{type:`secondary`,dim:!0,children:V.t(`bg.empty`)}):J(Jt,{children:[O.hasMoreAbove&&q(X,{dimColor:!0,children:V.t(`scroll.above`,{n:1})}),O.rows.map((e,t)=>{if(e.type===`spacer`)return q(X,{children:` `},`spacer-${t}`);if(e.type===`header`)return q(A,{type:`secondary`,dim:!0,children:V.t(`bg.categoryLabel`,{context:e.category})},`h-${t}`);let n=e.task,r=e.index===p;return J(Y,{flexDirection:`row`,children:[q(X,{color:r?f.selection:f.inactive,children:r?Nt():wt()}),J(X,{color:Xd(n,f),children:[Yd(n),` `]}),q(X,{color:r?f.selection:f.inactive,children:P(n.command,b).padEnd(b)}),(n.type??`process`)===`agent-session`&&n.model&&J(A,{type:`secondary`,dim:!0,children:[` `,String(n.model)]}),J(A,{type:`secondary`,dim:!0,children:[` `,To(n,y)]})]},n.id)}),O.hasMoreBelow&&q(X,{dimColor:!0,children:V.t(`scroll.below`,{n:1})})]})})]})}function Qd({view:e,columns:t=80,rows:n,active:r=!0,onDismiss:i}){let a=R(),o=e.prompt!==void 0,s=e.messages!==void 0&&e.messages.length>0,c=!!e.diff?.trim(),l=(o?1:0)+(s?1:0)+(c?1:0)>=2,[u,d]=K(c?`diff`:s?`conversation`:`prompt`),[f,p]=K(0),[m,h]=K(!1),[g,_]=K(``),[v,y]=K(-1),b=n?ne(n,12):18;W(()=>p(0),[e.id,u]);let x=Math.max(8,t-Pe.contentInset),S=[],w=[];if(u===`diff`)S=(e.diff??``).split(`
53
53
  `);else if(u===`prompt`)S=eo(e.prompt??``,x);else if(e.messages&&e.messages.length>0){let t=[];for(let n=0;n<e.messages.length;n++){let r=e.messages[n],i=rc(r,x);i.length!==0&&(t.length>0&&t.push(``),t.push(...i))}S=t,w=e.streamText?Qc(e.streamText,x-Pe.borderInset,3):[]}let T=u===`prompt`,E=u===`diff`,ee=e=>e.startsWith(`+`)&&!e.startsWith(`+++`)?a.diffAdd:e.startsWith(`-`)&&!e.startsWith(`---`)?a.diffRemove:e.startsWith(`@@`)||e.startsWith(`diff --git`)?a.special:a.secondary,te=e.status===`running`,O=H.useMemo(()=>{if(!g)return{flat:[],byLine:new Map};let e=[],t=new Map;for(let n=0;n<S.length;n++){let r=ya(ks(S[n]),g);if(r.length!==0){t.set(n,r);for(let t of r)e.push({line:n,range:t})}}return{flat:e,byLine:t}},[g,S]),k=Fo(S.length,b,f),re=S.slice(k.start,k.end),ie=g?re.map((e,t)=>{let n=k.start+t,r=O.byLine.get(n);if(!r||r.length===0)return e;let i=v>=0?O.flat[v]:void 0;return va(e,r,i&&i.line===n?i.range:void 0)}):re,ae=e.responseText?.split(`
54
54
  `)[0],[oe,se]=K(!1);Md(e=>p(t=>Math.max(0,t+e)),[]),D(`delegates-pane-2`,(t,n)=>{if(m){if(n.escape)return h(!1),_(``),y(-1),!0;if(n.backspace)return _(e=>e.slice(0,-1)),y(-1),!0;if((t===`n`||t===`N`)&&g.length>0){let e=t===`n`?1:-1;return y(t=>O.flat.length>0?(t+e+O.flat.length)%O.flat.length:-1),!0}return t.length===1?(_(e=>e+t),y(-1),!0):!0}return t===`/`&&!n.ctrl&&!n.meta?(h(!0),_(``),y(-1),!0):n.escape?(i?.(),!0):t===`]`&&l?(d(e=>{let t=[...c?[`diff`]:[],...s?[`conversation`]:[],...o?[`prompt`]:[]];return t[(t.indexOf(e)+1)%t.length]??e}),!0):t===`d`&&e.responseText?(se(e=>!e),!0):n.upArrow?(p(e=>e+1),!0):n.downArrow?(p(e=>Math.max(0,e-1)),!0):n.pageUp?(p(e=>e+b),!0):n.pageDown?(p(e=>Math.max(0,e-b)),!0):!1},{isActive:r,ignoreRoute:!0});let M=J(Y,{flexDirection:`column`,children:[J(Y,{flexDirection:`row`,children:[J(X,{color:Jd(e.status,a),children:[qd[e.status],` `]}),q(X,{color:a.secondary,bold:!0,children:P(e.command,Math.max(12,t-12))}),q(A,{type:`secondary`,children:te?` ${L.statusDot} ${V.t(`bg.live`)}`:` ${V.t(`status.done`)}`})]}),ae&&J(Y,{flexDirection:`column`,children:[J(A,{type:`secondary`,dim:!0,children:[` `,ae,` `,q(X,{color:a.suggestion,children:`[d] ${oe?V.t(`hint.collapse`):V.t(`find.tabDiagnostics`)}`})]}),oe&&e.responseText&&q(Y,{flexDirection:`column`,marginTop:I.tight,children:e.responseText.split(`
55
- `).slice(1).map((e,t)=>q(X,{color:a.secondary,dimColor:!0,wrap:`truncate-end`,children:e===``?` `:e},t))})]}),q(X,{children:` `})]}),N=[...c?[{key:`diff`,label:V.t(`find.tabDiff`)}]:[],...s?[{key:`conversation`,label:V.t(`find.tabConversation`)}]:[],...o?[{key:`prompt`,label:V.t(`find.tabPrompt`)}]:[]];return J(F,{header:M,footer:q(C,{dim:!0,items:[...l?[[`]`,V.t(`hint.switch`)]]:[],...e.responseText?[[`d`,oe?V.t(`hint.collapse`):V.t(`find.tabDiagnostics`)]]:[],...S.length>b?[[`${j.up}${j.down}`,V.t(`hint.scroll`)]]:[],[j.esc,V.t(`hint.back`)]]}),children:[l&&q(Y,{marginBottom:I.tight,children:q(Kd,{items:N.map(e=>({key:e.key,label:e.label})),activeKey:u,availableWidth:t-4,onSelect:e=>d(e)})}),J(Y,{flexDirection:`column`,children:[m&&q(Y,{height:1,children:q(X,{color:a.selection,children:V.t(`transcript.findBar`,{query:g,count:O.flat.length})})}),q(X,{color:a.special,dimColor:!0,children:k.above>0?`↑ ${k.above}`:` `}),S.length===0?q(A,{type:`secondary`,dim:!0,children:V.t(`bg.noOutput`)}):ie.map((e,t)=>E?q(X,{color:ee(e),wrap:`truncate-end`,children:e===``?` `:e},k.start+t):T?q(X,{color:a.secondary,wrap:`truncate-end`,children:e===``?` `:e},k.start+t):q(X,{wrap:`truncate-end`,children:e===``?` `:e},k.start+t)),w.length>0&&q(Y,{flexDirection:`column`,children:w.map((e,t)=>J(Y,{flexDirection:`row`,children:[q(X,{color:a.replyPrefix,children:t===0?`${L.bullet} `:` `}),q(X,{children:e})]},t))}),q(X,{color:a.special,dimColor:!0,children:k.below>0?`↓ ${k.below}`:` `})]})]})}function $d(e){let t=e.agentStatus??`running`;return t===`running`||t===`ready`||t===`needs_input`}function ef(e,t){if(e.stall===`stalled`)return{ch:L.statusDot,color:t.error};if(e.stall===`warn`)return{ch:L.statusDot,color:t.warning};switch(e.agentStatus??`running`){case`running`:return{ch:L.statusDot,color:t.accent};case`needs_input`:return{ch:L.needsInput,color:t.warning};case`ready`:return{ch:L.check,color:t.success};case`applied`:return{ch:L.check,color:t.success};case`failed`:return{ch:L.cross,color:t.error};case`canceled`:return{ch:L.cross,color:t.inactive};default:return{ch:L.statusDot,color:t.inactive}}}function tf(e){return P(e,44)}function nf({tasks:e,focused:r,now:i,onDismiss:a,onSwitch:o,onViewOutput:s,rows:c=24}){let l=R(),[u,d]=ra(`subagents`,e.length),f=G(0);if(D(`subagents-pane`,(t,n)=>{if(n.escape)return z()?.navigate(`/`,{reset:!0}),a?.(),!0;if(Me(`list-nav-up`,t,n,`subagents`))return d(e=>Math.max(0,e-1)),!0;if(Me(`list-nav-down`,t,n,`subagents`))return d(t=>Math.min(e.length-1,t+1)),!0;let r=e[Math.max(0,Math.min(u,e.length-1))];return n.return?(r&&o?.(r.id),!0):t===`s`?(r&&s?.(r.id),!0):!1},{isActive:r}),e.length===0)return null;let p=i??Date.now(),m=e.filter($d).length;if(!r)return J(Y,{children:[q(X,{color:l.special,children:`▸ `}),q(A,{type:`secondary`,children:V.t(`subagent.sTitle`)}),J(A,{type:`secondary`,children:[` `,e.length,m>0?` · ${V.t(`subagent.sRunning`,{n:m})}`:``]}),J(A,{type:`secondary`,dim:!0,children:[` `,t(`t`)]})]});let h=Math.min(u,e.length-1),g=Ct(e,h,n(e.length,c,3),f.current);return f.current=g.scrollTop,J(Y,{flexDirection:`column`,marginTop:I.tight,children:[J(Y,{children:[q(X,{color:l.special,children:`▸ `}),q(X,{color:l.text,children:V.t(`subagent.sTitle`)}),J(A,{type:`secondary`,children:[` `,e.length,m>0?` · ${V.t(`subagent.sRunning`,{n:m})}`:``]}),q(Y,{marginLeft:I.tight,children:q(C,{dim:!0,items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.enter,V.t(`hint.switch`)],[`s`,V.t(`hint.view`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]})})]}),J(Y,{marginLeft:I.section,flexDirection:`column`,children:[g.hasMoreAbove&&q(X,{dimColor:!0,children:V.t(`scroll.above`,{n:1})}),g.rows.map((e,t)=>{let n=g.scrollTop+t===h,r=ef(e,l),i=n?l.selection:void 0;return J(Y,{flexDirection:`row`,children:[q(X,{color:n?l.selection:l.inactive,children:n?Nt():wt()}),J(X,{color:r.color,children:[r.ch,` `]}),q(X,{color:i??l.inactive,children:tf(e.command)}),e.model&&J(A,{type:`secondary`,children:[` `,e.model,e.modelDecidedBy?` (${e.modelDecidedBy})`:``]}),J(A,{type:`secondary`,children:[` `,To(e,p)]})]},e.id)}),g.hasMoreBelow&&q(X,{dimColor:!0,children:V.t(`scroll.below`,{n:1})})]})]})}function rf(e,t){return t===0?0:Math.max(0,Math.min(e,t-1))}function af(e,t,n){let r=globalThis;r[`__ottoSchedule${e===`run`?`Run`:e===`toggle`?`Toggle`:`Remove`}Request`]=e===`toggle`?{taskId:t,...n}:t}function of({tasks:e,focused:r,onDismiss:i,rows:a=24}){let o=R(),[c,l]=ra(`schedule`,e.length),u=G(0);if(D(`schedule-pane`,(t,n)=>{if(n.escape)return z()?.navigate(`/`,{reset:!0}),i?.(),!0;if(Me(`list-nav-up`,t,n,`schedule`))return l(e=>Math.max(0,e-1)),!0;if(Me(`list-nav-down`,t,n,`schedule`))return l(t=>Math.min(e.length-1,t+1)),!0;let r=e[Math.max(0,Math.min(c,e.length-1))];return r?n.return||t===`r`?(af(`run`,r.id),!0):t===` `||t===`t`?(af(`toggle`,r.id,{enabled:!r.enabled}),!0):t===`d`?(af(`remove`,r.id),!0):!1:!1},{isActive:r}),e.length===0&&!r)return null;if(!r)return J(Y,{children:[q(X,{color:o.special,children:`▸ `}),q(A,{type:`secondary`,children:V.t(`schedule.sLabel`)}),J(A,{type:`secondary`,children:[` `,e.length]}),J(A,{type:`secondary`,dim:!0,children:[` `,t(`s`)]})]});let d=rf(c,e.length),f=Math.min(32,Math.max(0,...e.map(e=>Oe(e.name)))),p=Ct(e,d,n(e.length,a,3),u.current);return u.current=p.scrollTop,J(Y,{flexDirection:`column`,children:[J(Y,{children:[q(X,{color:o.special,children:`▸ `}),q(X,{color:o.text,children:V.t(`schedule.sLabel`)}),J(A,{type:`secondary`,children:[` `,e.length]}),q(Y,{marginLeft:I.tight,children:q(C,{dim:!0,items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[`↵/r`,V.t(`hint.execute`)],[`t`,V.t(`hint.toggle`)],[`d`,V.t(`hint.delete`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]})})]}),J(Y,{marginLeft:I.section,flexDirection:`column`,children:[e.length===0&&q(A,{type:`secondary`,children:V.t(`schedule.sEmpty`)}),p.hasMoreAbove&&q(X,{dimColor:!0,children:V.t(`scroll.above`,{n:1})}),p.rows.map((e,t)=>{let n=p.scrollTop+t===d,r=e.lastFireFailed===!0,i=r?`!`:e.enabled?L.toggleOn:L.toggleOff,a=r?o.error:e.enabled?o.accent:o.inactive,c=n?o.selection:void 0,l=new Date(e.nextFireAt).toLocaleString(),u=e.recurring?e.cronExpression:V.t(`schedule.oneShot`),m=r&&e.lastFireError?` (failed: ${e.lastFireError})`:``;return J(Y,{flexDirection:`row`,children:[q(X,{color:n?o.selection:o.inactive,children:n?Nt():wt()}),J(X,{color:a,children:[i,` `]}),q(X,{color:c??o.inactive,children:s(e.name,f)}),J(A,{type:`secondary`,children:[` `,u,` `,V.t(`schedule.next`),l]}),m&&q(X,{color:o.error,children:m})]},e.id)}),p.hasMoreBelow&&q(X,{dimColor:!0,children:V.t(`scroll.below`,{n:1})})]})]})}function sf({text:e,focused:t,columns:n=80,onDismiss:r,onOpenViewer:i}){let a=R();if(D(`clipboard-pane`,(e,t)=>t.escape?(z()?.navigate(`/`,{reset:!0}),r?.(),!0):t.return?(i?.(),!0):!1,{isActive:t}),e.length===0)return null;let o=Array.from(e).length;if(!t)return J(Y,{children:[q(X,{color:a.special,children:`▸ `}),q(A,{type:`secondary`,children:V.t(`clipboard.paneTitle`)}),J(A,{type:`secondary`,children:[` `,V.t(`clipboard.charsLabel`,{count:o})]})]});let s=Math.max(10,n-I.section-2),c=e.split(`
56
- `),l=c.slice(0,5),u=c.length-l.length;return J(Y,{flexDirection:`column`,marginTop:I.tight,children:[J(Y,{children:[q(X,{color:a.special,children:`▸ `}),q(X,{color:a.text,children:V.t(`clipboard.paneTitle`)}),J(A,{type:`secondary`,children:[` `,V.t(`clipboard.charsLabel`,{count:o})]}),q(Y,{marginLeft:I.tight,children:q(C,{dim:!0,items:[[j.enter,V.t(`clipboard.openHint`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]})})]}),J(Y,{marginLeft:I.section,flexDirection:`column`,children:[l.map((e,t)=>q(A,{type:`secondary`,wrap:`truncate-end`,children:P(e===``?` `:e,s)},t)),u>0&&q(A,{type:`secondary`,dim:!0,children:` ${L.ellipsis} ${u} more`})]})]})}const cf={pending:L.todoPending,in_progress:L.todoActive,done:L.check,skipped:L.todoPending,failed:L.cross};function lf(e,t){switch(e){case`done`:return t.success;case`in_progress`:return t.accent;case`failed`:return t.error;case`skipped`:return t.warning;default:return t.inactive}}function uf({tasks:e,title:t,collapsed:r=!1,selectedIndex:i,focused:a=!1,rows:o,onDismiss:s,onSelectIndex:c}){let l=R();D(`task-pane`,(t,n)=>n.escape?(s?.(),!0):Me(`list-nav-up`,t,n,`taskFocus`)?(c?.(e=>Math.max(0,e-1)),!0):Me(`list-nav-down`,t,n,`taskFocus`)?(c?.(t=>Math.min(e.length-1,t+1)),!0):!1,{isActive:a,ignoreRoute:!0});let u=G(0);if(e.length===0)return null;let d=e.filter(e=>e.status===`done`).length,f=e.filter(e=>e.status===`failed`).length,p=f>0?`${d}/${e.length}!`:`${d}/${e.length}`;return J(Y,{flexDirection:`column`,marginTop:I.tight,children:[J(Y,{children:[q(X,{color:l.special,children:`▸ `}),q(X,{color:l.text,children:t??V.t(`task.title`)}),J(X,{color:f>0?l.error:l.inactive,children:[` `,p]}),J(A,{type:`secondary`,children:[` `,pa(e.filter(e=>e.status===`done`||e.status===`skipped`).length/e.length,8)]}),r&&J(A,{type:`secondary`,dim:!0,children:[` `,V.t(`task.collapsedHint`)]}),a&&!r&&q(Y,{marginLeft:I.tight,children:q(C,{dim:!0,items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]})})]}),!r&&q(Y,{marginLeft:I.section,flexDirection:`column`,children:(()=>{let t=Math.max(0,...e.map(e=>Oe(e.title??``))),r=n(e.length,o??24,3),s=Ct(e,Math.min(i??0,e.length-1),r,u.current);u.current=s.scrollTop;let c=s.rows.map((e,n)=>{let r=s.scrollTop+n,o=e.status===`done`||e.status===`skipped`,c=a&&r===(i??0),u=e.title??``,d=` `.repeat(Math.max(0,t-Oe(u))),f=V.t(`task.statusLabel`,{context:e.status??`pending`});return J(Y,{flexDirection:`row`,children:[q(X,{color:c?l.accent:lf(e.status,l),children:c?`${L.pointer} `:`${cf[e.status??`pending`]} `}),q(X,{color:c?l.accent:e.status===`skipped`?l.warning:o?l.inactive:l.text,strikethrough:o,italic:e.status===`skipped`,children:u}),q(X,{children:d}),J(X,{color:c?l.accent:lf(e.status,l),dimColor:!0,children:[` `,f]})]},e.id??r)});return J(Jt,{children:[s.hasMoreAbove&&q(X,{dimColor:!0,children:V.t(`scroll.above`,{n:1})}),c,s.hasMoreBelow&&q(X,{dimColor:!0,children:V.t(`scroll.below`,{n:1})})]})})()})]})}const df={tasks:L.itemActive,delegates:L.service,edited:L.edited,subagents:L.attention,clipboard:L.clipboard},ff=L.clipboard,pf={tasks:`/pane/tasks`,delegates:`/pane/delegates`,edited:`/pane/edited-files`,subagents:`/pane/subagents`,clipboard:`/pane/clipboard`};function mf({counts:e,labels:t,currentPath:n=``}){let r=[{id:`tasks`,count:e.tasks,label:t.tasks},{id:`delegates`,count:e.delegates,label:t.delegates},{id:`edited`,count:e.edited,label:t.edited},{id:`subagents`,count:e.subagents,label:t.subagents},{id:`clipboard`,count:e.clipboard,label:t.clipboard}].map(t=>{let r=pf[t.id],i=r!==``&&(n===r||n.startsWith(`${r}/`));return t.id===`clipboard`&&e.clipboardJustCopied?{id:t.id,icon:ff,label:t.label,count:t.count,active:i,tone:`success`}:{id:t.id,icon:df[t.id],label:t.label,count:t.count,active:i}}).filter(e=>e.count>0);if(e.clipboardFailed){let e=r.filter(e=>e.id!==`clipboard`);return e.push({id:`clipboard`,icon:df.clipboard,label:t.clipboardFailed,count:0,active:!1,hideCount:!0,tone:`warning`}),e}return r}function hf(e){return e.length>0}const gf=H.memo(function({counts:e,labels:t,currentPath:n=``,tabHint:r}){let i=R(),a=mf({counts:e,labels:t,currentPath:n});return a.length===0?q(Y,{flexDirection:`row`,height:1}):q(Y,{flexDirection:`row`,height:1,children:J(Jt,{children:[a.map((e,t)=>{let n=e.hideCount?`${e.icon} ${e.label}`:`${e.icon} ${e.label} ${e.count}`;return e.tone===`success`?J(X,{wrap:`truncate-end`,children:[t>0?` · `:``,q(X,{color:i.success,bold:!0,children:n})]},e.id):J(A,{type:e.tone===`warning`?`warning`:e.active?`accent`:`secondary`,wrap:`truncate-end`,children:[t>0?` · `:``,n]},e.id)}),r&&hf(a)&&q(A,{type:`secondary`,dim:!0,wrap:`truncate-end`,children:` · ${r}`})]})})});function _f(e=process.env,t=process.platform){let n=e.TERM_PROGRAM;return n===`Apple_Terminal`?`Fn`:n===`iTerm.app`||e.LC_TERMINAL===`iTerm2`?`Option`:n===`vscode`||n===`ghostty`||n===`WarpTerminal`||n===`Hyper`?t===`darwin`?`Option`:`Shift`:n===`tmux`||e.TMUX?`Shift`:`Shift/Option/Fn`}function vf(e=process.env,t=process.platform){let n=_f(e,t);return n===`Shift/Option/Fn`?`Shift (Option in iTerm2, Fn in Terminal.app)`:n}const yf=H.memo(function(e){let t=R(),{fullScreenPaneActive:n,tipVisible:r,tasksCollapsed:i,taskSelIndex:a,setTaskSelIndex:o,backgroundTasksOrdered:s,columns:c,openEditedFileFull:l,editedFileFullIndex:u,subagents:d}=e,{taskStore:f}=eu(),p=Z(f.store,e=>e.tasks),m=Z(f.store,e=>e.tasksTitle),h=Z(f.store,e=>e.editedFiles),g=Z(f.store,e=>e.scheduleTasks),_=Z(f.store,e=>e.clipboardChars),v=Z(f.store,e=>e.clipboardFailed),y=Z(f.store,e=>e.clipboardText),b=Z(f.store,e=>e.clipboardJustCopied),x=Z(f.store,e=>e.subagentContext),S=Z(f.store,e=>e.backgroundTasks.length),{onBackgroundClose:C,onBackgroundKill:w,onBackgroundViewOutput:T,onBackgroundApply:E,onBackgroundSwitch:D,onBackgroundDelete:ee,onToggleEditedFiles:te,onToggleSubagents:O,onToggleSchedule:ne}=pu(),{currentPath:k}=me(),re=k===`/pane/tasks`&&p.length>0,A=k===`/pane/delegates`&&S>0,ie=k===`/pane/edited-files`,j=k===`/pane/subagents`,ae=k===`/pane/schedule`,oe=k===`/pane/clipboard`&&y.length>0;if(n||x)return null;let se=r?I.none:I.tight,M=re||A||ie||j||ae||oe;return J(Y,{flexDirection:`column`,marginTop:se,children:[q(gf,{currentPath:k,tabHint:V.t(`signalBar.tabHint`),counts:{tasks:p.length,delegates:S,edited:h.length,subagents:d.length,clipboard:_,clipboardFailed:v,clipboardJustCopied:b},labels:{tasks:m??V.t(`task.title`),delegates:V.t(`bg.tasksTitle`),edited:V.t(`panelTitle.editedFilesTitle`),subagents:V.t(`hint.subagents`),clipboard:V.t(`signalBar.clipboard`),clipboardFailed:V.t(`signalBar.clipboardFailed`,{modifier:vf()})}}),!M&&q(Y,{height:1,flexShrink:0}),M&&J(Y,{flexDirection:`column`,...nt,borderColor:t.panelBorder,children:[re&&q(uf,{tasks:p,title:m,collapsed:i,focused:!0,selectedIndex:a,onDismiss:su,onSelectIndex:o}),A&&S>0&&q(Zd,{tasks:s,columns:c,onClose:C,onKill:w,onViewOutput:T,onApply:E,onSwitch:D,onDelete:ee,active:!0}),ie&&q(Bu,{files:h,focused:!0,onDismiss:te,onOpenFileFull:l,fullOpenIndex:u}),j&&q(nf,{tasks:d,focused:!0,onDismiss:O,onSwitch:D,onViewOutput:T}),ae&&q(of,{tasks:g,focused:!0,onDismiss:ne}),oe&&q(sf,{text:y,focused:!0,columns:c,onDismiss:su,onOpenViewer:()=>z()?.navigate(`/viewer/clipboard`,{state:{content:y}})})]})]})});function bf({items:e,focused:r,onDismiss:i,onLoad:a,onDelete:o,onDeleteMany:s,rows:c=24}){let l=R(),[u,d]=ra(`drafts`,e.length),f=G(0),[p,m]=K(new Set);if(D(`draft-pane`,(t,n)=>{if(n.escape)return p.size>0&&m(new Set),i?.(),!0;if(Me(`list-nav-up`,t,n,`draft`))return d(e=>Math.max(0,e-1)),!0;if(Me(`list-nav-down`,t,n,`draft`))return d(t=>Math.min(e.length-1,t+1)),!0;if(n.return)return a?.(u),!0;if(t===` `){let t=e[Math.max(0,Math.min(u,e.length-1))];return t&&m(e=>{let n=new Set(e);return n.has(t.id)?n.delete(t.id):n.add(t.id),n}),!0}return t===`d`?(p.size>0?(s?.([...p]),m(new Set)):o?.(u),!0):!1},{isActive:r}),e.length===0&&!r)return null;if(!r)return J(Y,{children:[q(X,{color:l.special,children:`▸ `}),q(A,{type:`secondary`,children:V.t(`draft.sLabel`)}),J(A,{type:`secondary`,children:[` `,e.length]}),J(A,{type:`secondary`,dim:!0,children:[` `,t(`o`)]})]});let h=rf(u,e.length),g=Ct(e,h,n(e.length,c,7),f.current);return f.current=g.scrollTop,q(F,{header:J(Y,{children:[q(X,{color:l.secondary,bold:!0,children:V.t(`draft.sLabel`)}),J(A,{type:`secondary`,children:[` `,e.length]})]}),footer:q(C,{items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.enter,V.t(`hint.load`)],[`space`,V.t(`hint.check`)],[`d`,V.t(`hint.delete`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]}),children:J(Y,{marginTop:I.tight,flexDirection:`column`,children:[e.length===0&&q(A,{type:`secondary`,children:V.t(`draft.sEmpty`)}),g.rows.map((e,t)=>{let n=g.scrollTop+t,r=n===h,i=p?.has(e.id)??!1,a=r?l.selection:l.text,o=P(e.text,51),s=new Date(e.savedAt).toLocaleString();return J(Y,{flexDirection:`row`,children:[q(X,{color:r?l.selection:l.inactive,children:r?Nt():wt()}),q(A,{type:`secondary`,children:`${n+1}. `}),q(X,{color:i?l.accent:l.inactive,children:i?`${L.bullet} `:`${L.todoPending} `}),q(X,{color:a,bold:!0,children:e.name}),J(X,{dimColor:!0,children:[` `,o]}),J(X,{dimColor:!0,children:[` `,s]})]},e.id)}),g.fillerCount>0&&Array.from({length:g.fillerCount},(e,t)=>q(X,{children:` `},`filler-${t}`))]})})}function xf({items:e,focused:t,rows:r=24,onDismiss:i,closeConfirmOpen:a=!1,editOpen:o=!1,onDelete:s,onMove:c,onEditOpen:l}){let u=R(),[d,f]=ra(`queue`,e.length),[p,m]=K(!1),h=G(0);if(!t&&p&&m(!1),D(`queue-pane`,(t,n)=>p?t===` `||n.escape?(m(!1),!0):n.upArrow||n.tab&&n.shift?(c?.(d,-1),f(e=>Math.max(0,e-1)),!0):n.downArrow||n.tab&&!n.shift?(c?.(d,1),f(t=>Math.min(e.length-1,t+1)),!0):!0:n.escape?(i?.(),!0):Me(`list-nav-up`,t,n,`queue`)?(f(e=>Math.max(0,e-1)),!0):Me(`list-nav-down`,t,n,`queue`)?(f(t=>Math.min(e.length-1,t+1)),!0):n.tab&&!n.ctrl&&!n.meta?(f(t=>n.shift?Math.max(0,t-1):Math.min(e.length-1,t+1)),!0):t===` `?(e.length>0&&m(!0),!0):n.return?(e.length>0&&l?.(d),!0):t===`d`?(s?.(d),!0):!1,{isActive:t&&!a&&!o}),!t)return null;let g=rf(d,e.length),_=Ct(e,g,n(e.length,r,7),h.current);return h.current=_.scrollTop,q(F,{header:J(Y,{children:[q(X,{color:u.secondary,bold:!0,children:V.t(`queue.label`)}),J(A,{type:`secondary`,children:[` `,e.length]})]}),footer:q(C,{items:p?[[`${j.up}${j.down}`,V.t(`hint.move`)],[`space/Esc`,V.t(`hint.drop`)]]:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.enter,V.t(`hint.edit`)],[`space`,V.t(`hint.grab`)],[`d`,V.t(`hint.delete`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.select`)]]}),children:J(Y,{marginTop:I.tight,flexDirection:`column`,children:[e.length===0&&q(A,{type:`secondary`,children:V.t(`queue.empty`)}),_.rows.map((e,t)=>{let n=_.scrollTop+t,r=n===g,i=r&&p,a=i?u.accent:r?u.selection:u.text,o=i?`⇅ `:r?Nt():wt(),s=e.mode===`bash_async`?`!! `:e.mode===`bash`?`! `:e.mode===`memory`?`# `:` `,c=e.text.length>60?P(e.text,61):e.text;return J(Y,{flexDirection:`row`,children:[q(A,{type:`secondary`,children:`${n+1}. `}),q(X,{color:a,bold:r,children:o}),q(X,{color:a,bold:r,children:s}),q(X,{color:a,bold:r,children:c})]},n)}),Array.from({length:_.fillerCount},(e,t)=>q(X,{children:` `},`filler-${t}`))]})})}function Sf(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];r.role===`user`&&typeof r.content==`string`&&r.content.trim().length>0&&t.push({text:r.content,index:n})}return t}function Cf(e){return Math.max(1,u(e)-5-2)}function wf(e,t){let n=Math.max(20,t-12);return e.map((e,t)=>({value:String(e.index),label:`${t+1}. ${P(e.text.replace(/\s+/g,` `),n)}`}))}function Tf({messageStore:e,focused:t,rows:n=24,columns:r=80,onDismiss:i}){let a=Sf(Z(e.store,e=>e.messages));if(D(`prompt-log-pane`,(e,t)=>t.escape?(i?.(),!0):!1,{isActive:t,ignoreRoute:!0}),!t)return null;let o=u(n),s=Cf(n),c=wf(a,r);return q(F,{maxHeight:o,header:J(Y,{children:[q(A,{type:`secondary`,bold:!0,children:V.t(`prompts.label`)}),J(A,{type:`secondary`,children:[` `,a.length]})]}),footer:q(C,{items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.esc,V.t(`hint.close`)]]}),children:a.length===0?q(A,{type:`secondary`,children:V.t(`prompts.empty`)}):q(ht,{id:`prompt-log-list`,tabIndex:0,autoFocus:!0,options:c,maxVisible:s,compact:!0,onSelect:()=>{}})})}function Ef(e={}){let{columns:t=120,onEmptyBackspace:n,onClearText:r,onCommit:i}=e,[a,o]=K(``),[s,c]=K(0),u=Gt((e,t)=>{o(e),c(t)},[]);return{text:a,offset:s,update:Gt((e,t)=>{o(e),c(t)},[]),handleEditing:Gt((e,o)=>{if(e.length>1&&!o.ctrl&&!o.meta&&!o.return&&!o.escape&&!o.backspace&&!o.delete&&!o.tab&&!o.upArrow&&!o.downArrow&&!o.leftArrow&&!o.rightArrow){let t=ke(e);return t&&u(a.slice(0,s)+t+a.slice(s),s+t.length),!0}if(o.leftArrow){let e=l.fromText(a,t,s).left();return u(e.text,e.offset),!0}if(o.rightArrow){let e=l.fromText(a,t,s).right();return u(e.text,e.offset),!0}if((o.backspace||o.delete)&&a.length===0)return n?.(),!0;let c={name:o.backspace?`backspace`:o.delete?`delete`:o.tab?`tab`:o.escape?`escape`:o.return?`return`:e||`unknown`,ctrl:o.ctrl??!1,shift:!1,alt:o.meta??!1,meta:o.meta??!1},d=Tt(l.fromText(a,t,s),c);return d?d.action===`clear_text`?(u(``,0),r?.(),!0):d.action===`submit`||d.action===`submit_force`?(i?.(),!0):(u(d.cursor.text,d.cursor.offset),!0):!1},[a,s,t,n,r,u])}}const Df={send:`dialog`,bash:`bash`,bash_async:`bash_async`,memory:`memory`},Of=[`input`,`sendNow`,`confirm`,`cancel`];function kf({index:e,total:t,initialValue:n,mode:r,busy:i,columns:a=60,onSendNow:o,onConfirm:s,onCancel:c}){let[l,u]=K(`input`),{text:d,offset:f,update:p,handleEditing:m}=Ef({columns:a});H.useEffect(()=>{n&&p(n,n.length)},[]);let h=d.trim()===``,g=e=>{u(Of[(Of.indexOf(l)+e+Of.length)%Of.length])},_=()=>{if(l===`sendNow`){h||o(d);return}if(l===`confirm`){h||s(d);return}if(l===`cancel`){c();return}};D(`queue-edit-dialog`,(e,t)=>{if(t.return&&t.meta){h||o(d);return}if(t.escape){if(l===`input`&&d.length>0){p(``,0);return}c();return}if(t.tab||t.ctrl&&e===`n`){g(1);return}if(l!==`input`){if(t.leftArrow){g(-1);return}if(t.rightArrow){g(1);return}if(t.upArrow){u(`input`);return}if(t.downArrow){g(1);return}if(t.return){_();return}return}if(t.downArrow){g(1);return}if(t.upArrow){g(-1);return}if(t.return){h||u(`confirm`);return}return m(e,t)});let v=i?V.t(`queue.editSendNowHintBusy`):V.t(`queue.editSendNowHintIdle`);return J(F,{header:q(_e,{children:V.t(`queue.editTitle`,{index:e,total:t})}),footer:q(C,{items:[[j.tab,V.t(`hint.quick`)],[`${j.up}${j.down}`,V.t(`hint.switch`)],[j.enter,V.t(`hint.confirm`)],[yt(),V.t(`queue.editSendNowButton`)],[j.esc,V.t(`hint.cancel`)]]}),children:[q(Y,{marginTop:I.tight,flexDirection:`row`,children:q(dt,{value:d,offset:f,columns:a,mode:Df[r],focused:l===`input`})}),J(Y,{marginTop:I.tight,flexDirection:`row`,gap:I.section,children:[q(Ne,{variant:`solid`,brackets:!0,color:`green`,label:V.t(`queue.editSendNowButton`),focused:l===`sendNow`,disabled:h}),q(Ne,{variant:`solid`,brackets:!0,color:`accent`,label:V.t(`queue.editConfirmButton`),focused:l===`confirm`,disabled:h}),q(Ne,{variant:`solid`,brackets:!0,color:`gray`,label:V.t(`common.genericCancelButton`),focused:l===`cancel`})]}),q(Y,{marginTop:I.tight,children:q(A,{type:`secondary`,dim:!0,children:v})})]})}function Af(e,t){let n=t?.length?[...e,...t]:[...e];return{search:(e,t,r=50)=>(e?xr(e,n).map(e=>e.entry):[...n].reverse()).slice(0,r).map(e=>({label:e,value:e,kind:`shortcut`}))}}function jf({showHome:e,agentProcessing:t,hasTip:n}){return e||t||!n?0:3}function Mf(e){let t=pu(),{currentPath:n,stack:r,navigate:i,goBack:a}=me(),o=r.some(e=>e.path===`/pane/queue`),{columns:s,rows:c,agentProcessing:l,handlePromptEscape:u,pluginInput:d,handleSigilTrigger:f,handleSigilClose:p,handleHistorySearch:m,handleChipReopen:h,handleChipViewPaste:g,handlePasteConfirmRequest:_,welcome:v,historyInsertRef:y,pasteBridgeRef:b,initialHistory:x,externalHistoryCommands:S,residencyGovernor:C,registryRef:w,shellBackendRef:T,sigilState:E,setSigilState:D,sigilApplyRef:ee,readFileContent:te,handleDraftLoad:O,onQueueEscConfirm:ne,queueEscSuppress:k,queueCloseConfirm:re,setQueueCloseConfirm:A,interruptConfirm:ie,popQueuedConfirm:j,queueEditIndex:ae,setQueueEditIndex:oe,scrollStore:se,messageStore:M}=e,{taskStore:N}=eu(),P=Z(N.store,e=>e.forcedUpgrade),ce=Z(N.store,e=>e.commands),le=Z(N.store,e=>e.needsSetup),ue=Z(N.store,e=>e.ftueStage),de=Z(N.store,e=>e.recentMentions),fe=Z(N.store,e=>e.drafts),pe=Z(N.store,e=>e.queued),he=kd(ue,le),ge=Od(ue),_e=Z(se.store,e=>e.offset>0),[ve,ye]=K(x??[]),be=Gt(e=>{ye(e),t.onHistoryPush?.(e)},[t]),F=qt(()=>Af(ve,S),[ve,S]),xe=()=>{oe(null),n===`/pane/queue/edit`&&a()},Se=Gt((e,n,r)=>{t.onSubmit?.(e,n,r);let i=e.trimStart().startsWith(`/`);if(he&&!i)return`rejected`},[t,he]);return J(Jt,{children:[e.shadow&&q(ed,{}),E&&d&&q(Y,{flexDirection:`column`,marginTop:I.tight,children:q(Tc,{sigil:E.sigil,initialQuery:E.query,registry:E.mode===`history`?F:d,active:n===`/pane/sigil`,rows:c,columns:Math.min(60,s-Pe.borderInset),viewerColumns:s,readFileContent:te,recentEntries:E.sigil===`@`?de:void 0,title:E.mode===`history`?V.t(`history.label`):void 0,onSelect:e=>{if(D(null),E.mode===`history`){y.current?.fill(e.value);return}ee.current?.select(e),E.sigil===`@`&&t.onSigilSelect?.(e)},onClose:({deleteSigil:e})=>{D(null),ee.current?.cancel(e)}})}),q(Pi,{columns:s-Pe.borderInset,rows:c,disabled:!!P||re||ie||j,reviewing:_e,idleTipVisible:!!e.idleTip,commands:ce,placeholder:P?V.t(`prompt.upgradeRequired`):l?V.t(`prompt.working`):he?V.t(ge??`prompt.setup`):V.t(`prompt.default`),onSubmit:Se,onInterrupt:t.onInterrupt,onEscape:u,sigilEnabled:!!d,onSigilTrigger:f,onSigilClose:p,onChipReopen:h,onChipViewPaste:g,onToast:t.onToast,onDraftSave:t.onDraftSave,keybindingOverrides:e.keybindingOverrides,onPasteConfirm:_,cwd:v?.cwd,historyInsertRef:y,pasteBridgeRef:b,initialHistory:x,externalHistoryCommands:S,onHistoryPush:be,onHistorySearch:m,historySearchOpen:E?.mode===`history`,residencyGovernor:C,registryRef:w,shellBackendRef:T}),q(bf,{items:fe,focused:n===`/pane/draft`,onDismiss:t.onToggleDraftPane,onLoad:O,onDelete:t.onDraftDelete,onDeleteMany:t.onDraftDeleteMany}),M&&n===`/pane/prompts`&&q(Y,{flexDirection:`column`,marginTop:I.tight,children:q(Tf,{messageStore:M,focused:!0,rows:c,columns:s,onDismiss:()=>t.onTogglePrompts?.()})}),o&&n===`/pane/queue`&&q(Y,{flexDirection:`column`,marginTop:I.tight,children:q(xf,{items:pe,focused:!0,rows:c,onDismiss:()=>{re&&A(!1),t.onToggleQueuePane?.()},onEscConfirm:ne,escSuppress:k,closeConfirmOpen:re,editOpen:ae!==null,onDelete:t.onQueueDelete,onMove:t.onQueueMove,onEditOpen:e=>{oe(e),i(`/pane/queue/edit`)}})}),n===`/pane/queue/edit`&&ae!==null&&pe[ae]&&q(kf,{index:ae+1,total:pe.length,initialValue:pe[ae].text,mode:pe[ae].mode,busy:l,onSendNow:e=>{t.onQueueSendNow?.(ae,e),xe()},onConfirm:e=>{t.onQueueEditText?.(ae,e),xe()},onCancel:xe}),n!==`/pane/queue`&&!n.startsWith(`/pane/queue/`)&&q(Fi,{items:pe})]})}function Nf(e,t){let n=V.language===`zh`,r=n?`行`:e===1?`line`:`lines`,i=n?`字符`:t===1?`char`:`chars`;return V.t(`paste.previewSummary`,{context:`body`,lines:e,lineWord:r,chars:t,charWord:i})}function Pf(e){let t=e.replace(/\n/g,`↵`);return t.length<=16?`[@${t}:]`:`[@${t.slice(0,5)}…${t.slice(-5)}:]`}function Ff(e,t){let n=e.split(`
55
+ `).slice(1).map((e,t)=>q(X,{color:a.secondary,dimColor:!0,wrap:`truncate-end`,children:e===``?` `:e},t))})]}),q(X,{children:` `})]}),N=[...c?[{key:`diff`,label:V.t(`find.tabDiff`)}]:[],...s?[{key:`conversation`,label:V.t(`find.tabConversation`)}]:[],...o?[{key:`prompt`,label:V.t(`find.tabPrompt`)}]:[]];return J(F,{header:M,footer:q(C,{dim:!0,items:[...l?[[`]`,V.t(`hint.switch`)]]:[],...e.responseText?[[`d`,oe?V.t(`hint.collapse`):V.t(`find.tabDiagnostics`)]]:[],...S.length>b?[[`${j.up}${j.down}`,V.t(`hint.scroll`)]]:[],[j.esc,V.t(`hint.back`)]]}),children:[l&&q(Y,{marginBottom:I.tight,children:q(Kd,{items:N.map(e=>({key:e.key,label:e.label})),activeKey:u,availableWidth:t-4,onSelect:e=>d(e)})}),J(Y,{flexDirection:`column`,children:[m&&q(Y,{height:1,children:q(X,{color:a.selection,children:V.t(`transcript.findBar`,{query:g,count:O.flat.length})})}),q(X,{color:a.special,dimColor:!0,children:k.above>0?`↑ ${k.above}`:` `}),S.length===0?q(A,{type:`secondary`,dim:!0,children:V.t(`bg.noOutput`)}):ie.map((e,t)=>E?q(X,{color:ee(e),wrap:`truncate-end`,children:e===``?` `:e},k.start+t):T?q(X,{color:a.secondary,wrap:`truncate-end`,children:e===``?` `:e},k.start+t):q(X,{wrap:`truncate-end`,children:e===``?` `:e},k.start+t)),w.length>0&&q(Y,{flexDirection:`column`,children:w.map((e,t)=>J(Y,{flexDirection:`row`,children:[q(X,{color:a.replyPrefix,children:t===0?`${L.bullet} `:` `}),q(X,{children:e})]},t))}),q(X,{color:a.special,dimColor:!0,children:k.below>0?`↓ ${k.below}`:` `})]})]})}function $d(e){let t=e.agentStatus??`running`;return t===`running`||t===`ready`||t===`needs_input`}function ef(e,t){if(e.stall===`stalled`)return{ch:L.statusDot,color:t.error};if(e.stall===`warn`)return{ch:L.statusDot,color:t.warning};switch(e.agentStatus??`running`){case`running`:return{ch:L.statusDot,color:t.accent};case`needs_input`:return{ch:L.needsInput,color:t.warning};case`ready`:return{ch:L.check,color:t.success};case`applied`:return{ch:L.check,color:t.success};case`failed`:return{ch:L.cross,color:t.error};case`canceled`:return{ch:L.cross,color:t.inactive};default:return{ch:L.statusDot,color:t.inactive}}}function tf(e){return P(e,44)}function nf({tasks:e,focused:r,now:i,onDismiss:a,onSwitch:o,onViewOutput:s,rows:c=24}){let l=R(),[u,d]=ra(`subagents`,e.length),f=G(0);if(D(`subagents-pane`,(t,n)=>{if(n.escape)return z()?.navigate(`/`,{reset:!0}),a?.(),!0;if(Me(`list-nav-up`,t,n,`subagents`))return d(e=>Math.max(0,e-1)),!0;if(Me(`list-nav-down`,t,n,`subagents`))return d(t=>Math.min(e.length-1,t+1)),!0;let r=e[Math.max(0,Math.min(u,e.length-1))];return n.return?(r&&o?.(r.id),!0):t===`s`?(r&&s?.(r.id),!0):!1},{isActive:r}),e.length===0)return null;let p=i??Date.now(),m=e.filter($d).length;if(!r)return J(Y,{children:[q(X,{color:l.special,children:`▸ `}),q(A,{type:`secondary`,children:V.t(`subagent.sTitle`)}),J(A,{type:`secondary`,children:[` `,e.length,m>0?` · ${V.t(`subagent.sRunning`,{n:m})}`:``]}),J(A,{type:`secondary`,dim:!0,children:[` `,t(`t`)]})]});let h=Math.min(u,e.length-1),g=Ct(e,h,n(e.length,c,3),f.current);return f.current=g.scrollTop,J(Y,{flexDirection:`column`,children:[J(Y,{children:[q(X,{color:l.special,children:`▸ `}),q(X,{color:l.text,children:V.t(`subagent.sTitle`)}),J(A,{type:`secondary`,children:[` `,e.length,m>0?` · ${V.t(`subagent.sRunning`,{n:m})}`:``]}),q(Y,{marginLeft:I.tight,children:q(C,{dim:!0,items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.enter,V.t(`hint.switch`)],[`s`,V.t(`hint.view`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]})})]}),J(Y,{marginLeft:I.section,flexDirection:`column`,children:[g.hasMoreAbove&&q(X,{dimColor:!0,children:V.t(`scroll.above`,{n:1})}),g.rows.map((e,t)=>{let n=g.scrollTop+t===h,r=ef(e,l),i=n?l.selection:void 0;return J(Y,{flexDirection:`row`,children:[q(X,{color:n?l.selection:l.inactive,children:n?Nt():wt()}),J(X,{color:r.color,children:[r.ch,` `]}),q(X,{color:i??l.inactive,children:tf(e.command)}),e.model&&J(A,{type:`secondary`,children:[` `,e.model,e.modelDecidedBy?` (${e.modelDecidedBy})`:``]}),J(A,{type:`secondary`,children:[` `,To(e,p)]})]},e.id)}),g.hasMoreBelow&&q(X,{dimColor:!0,children:V.t(`scroll.below`,{n:1})})]})]})}function rf(e,t){return t===0?0:Math.max(0,Math.min(e,t-1))}function af(e,t,n){let r=globalThis;r[`__ottoSchedule${e===`run`?`Run`:e===`toggle`?`Toggle`:`Remove`}Request`]=e===`toggle`?{taskId:t,...n}:t}function of({tasks:e,focused:r,onDismiss:i,rows:a=24}){let o=R(),[c,l]=ra(`schedule`,e.length),u=G(0);if(D(`schedule-pane`,(t,n)=>{if(n.escape)return z()?.navigate(`/`,{reset:!0}),i?.(),!0;if(Me(`list-nav-up`,t,n,`schedule`))return l(e=>Math.max(0,e-1)),!0;if(Me(`list-nav-down`,t,n,`schedule`))return l(t=>Math.min(e.length-1,t+1)),!0;let r=e[Math.max(0,Math.min(c,e.length-1))];return r?n.return||t===`r`?(af(`run`,r.id),!0):t===` `||t===`t`?(af(`toggle`,r.id,{enabled:!r.enabled}),!0):t===`d`?(af(`remove`,r.id),!0):!1:!1},{isActive:r}),e.length===0&&!r)return null;if(!r)return J(Y,{children:[q(X,{color:o.special,children:`▸ `}),q(A,{type:`secondary`,children:V.t(`schedule.sLabel`)}),J(A,{type:`secondary`,children:[` `,e.length]}),J(A,{type:`secondary`,dim:!0,children:[` `,t(`s`)]})]});let d=rf(c,e.length),f=Math.min(32,Math.max(0,...e.map(e=>Oe(e.name)))),p=Ct(e,d,n(e.length,a,3),u.current);return u.current=p.scrollTop,J(Y,{flexDirection:`column`,children:[J(Y,{children:[q(X,{color:o.special,children:`▸ `}),q(X,{color:o.text,children:V.t(`schedule.sLabel`)}),J(A,{type:`secondary`,children:[` `,e.length]}),q(Y,{marginLeft:I.tight,children:q(C,{dim:!0,items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[`↵/r`,V.t(`hint.execute`)],[`t`,V.t(`hint.toggle`)],[`d`,V.t(`hint.delete`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]})})]}),J(Y,{marginLeft:I.section,flexDirection:`column`,children:[e.length===0&&q(A,{type:`secondary`,children:V.t(`schedule.sEmpty`)}),p.hasMoreAbove&&q(X,{dimColor:!0,children:V.t(`scroll.above`,{n:1})}),p.rows.map((e,t)=>{let n=p.scrollTop+t===d,r=e.lastFireFailed===!0,i=r?`!`:e.enabled?L.toggleOn:L.toggleOff,a=r?o.error:e.enabled?o.accent:o.inactive,c=n?o.selection:void 0,l=new Date(e.nextFireAt).toLocaleString(),u=e.recurring?e.cronExpression:V.t(`schedule.oneShot`),m=r&&e.lastFireError?` (failed: ${e.lastFireError})`:``;return J(Y,{flexDirection:`row`,children:[q(X,{color:n?o.selection:o.inactive,children:n?Nt():wt()}),J(X,{color:a,children:[i,` `]}),q(X,{color:c??o.inactive,children:s(e.name,f)}),J(A,{type:`secondary`,children:[` `,u,` `,V.t(`schedule.next`),l]}),m&&q(X,{color:o.error,children:m})]},e.id)}),p.hasMoreBelow&&q(X,{dimColor:!0,children:V.t(`scroll.below`,{n:1})})]})]})}function sf({text:e,focused:t,columns:n=80,onDismiss:r,onOpenViewer:i}){let a=R();if(D(`clipboard-pane`,(e,t)=>t.escape?(z()?.navigate(`/`,{reset:!0}),r?.(),!0):t.return?(i?.(),!0):!1,{isActive:t}),e.length===0)return null;let o=Array.from(e).length;if(!t)return J(Y,{children:[q(X,{color:a.special,children:`▸ `}),q(A,{type:`secondary`,children:V.t(`clipboard.paneTitle`)}),J(A,{type:`secondary`,children:[` `,V.t(`clipboard.charsLabel`,{count:o})]})]});let s=Math.max(10,n-I.section-2),c=e.split(`
56
+ `),l=c.slice(0,5),u=c.length-l.length;return J(Y,{flexDirection:`column`,children:[J(Y,{children:[q(X,{color:a.special,children:`▸ `}),q(X,{color:a.text,children:V.t(`clipboard.paneTitle`)}),J(A,{type:`secondary`,children:[` `,V.t(`clipboard.charsLabel`,{count:o})]}),q(Y,{marginLeft:I.tight,children:q(C,{dim:!0,items:[[j.enter,V.t(`clipboard.openHint`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]})})]}),J(Y,{marginLeft:I.section,flexDirection:`column`,children:[l.map((e,t)=>q(A,{type:`secondary`,wrap:`truncate-end`,children:P(e===``?` `:e,s)},t)),u>0&&q(A,{type:`secondary`,dim:!0,children:` ${L.ellipsis} ${u} more`})]})]})}const cf={pending:L.todoPending,in_progress:L.todoActive,done:L.check,skipped:L.todoPending,failed:L.cross};function lf(e,t){switch(e){case`done`:return t.success;case`in_progress`:return t.accent;case`failed`:return t.error;case`skipped`:return t.warning;default:return t.inactive}}function uf({tasks:e,title:t,collapsed:r=!1,selectedIndex:i,focused:a=!1,rows:o,onDismiss:s,onSelectIndex:c}){let l=R();D(`task-pane`,(t,n)=>n.escape?(s?.(),!0):Me(`list-nav-up`,t,n,`taskFocus`)?(c?.(e=>Math.max(0,e-1)),!0):Me(`list-nav-down`,t,n,`taskFocus`)?(c?.(t=>Math.min(e.length-1,t+1)),!0):!1,{isActive:a,ignoreRoute:!0});let u=G(0);if(e.length===0)return null;let d=e.filter(e=>e.status===`done`).length,f=e.filter(e=>e.status===`failed`).length,p=f>0?`${d}/${e.length}!`:`${d}/${e.length}`;return J(Y,{flexDirection:`column`,children:[J(Y,{children:[q(X,{color:l.special,children:`▸ `}),q(X,{color:l.text,children:t??V.t(`task.title`)}),J(X,{color:f>0?l.error:l.inactive,children:[` `,p]}),J(A,{type:`secondary`,children:[` `,pa(e.filter(e=>e.status===`done`||e.status===`skipped`).length/e.length,8)]}),r&&J(A,{type:`secondary`,dim:!0,children:[` `,V.t(`task.collapsedHint`)]}),a&&!r&&q(Y,{marginLeft:I.tight,children:q(C,{dim:!0,items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]})})]}),!r&&q(Y,{marginLeft:I.section,flexDirection:`column`,children:(()=>{let t=Math.max(0,...e.map(e=>Oe(e.title??``))),r=n(e.length,o??24,3),s=Ct(e,Math.min(i??0,e.length-1),r,u.current);u.current=s.scrollTop;let c=s.rows.map((e,n)=>{let r=s.scrollTop+n,o=e.status===`done`||e.status===`skipped`,c=a&&r===(i??0),u=e.title??``,d=` `.repeat(Math.max(0,t-Oe(u))),f=V.t(`task.statusLabel`,{context:e.status??`pending`});return J(Y,{flexDirection:`row`,children:[q(X,{color:c?l.accent:lf(e.status,l),children:c?`${L.pointer} `:`${cf[e.status??`pending`]} `}),q(X,{color:c?l.accent:e.status===`skipped`?l.warning:o?l.inactive:l.text,strikethrough:o,italic:e.status===`skipped`,children:u}),q(X,{children:d}),J(X,{color:c?l.accent:lf(e.status,l),dimColor:!0,children:[` `,f]})]},e.id??r)});return J(Jt,{children:[s.hasMoreAbove&&q(X,{dimColor:!0,children:V.t(`scroll.above`,{n:1})}),c,s.hasMoreBelow&&q(X,{dimColor:!0,children:V.t(`scroll.below`,{n:1})})]})})()})]})}const df={tasks:L.itemActive,delegates:L.service,edited:L.edited,subagents:L.attention,clipboard:L.clipboard},ff=L.clipboard,pf={tasks:`/pane/tasks`,delegates:`/pane/delegates`,edited:`/pane/edited-files`,subagents:`/pane/subagents`,clipboard:`/pane/clipboard`};function mf({counts:e,labels:t,currentPath:n=``}){let r=[{id:`tasks`,count:e.tasks,label:t.tasks},{id:`delegates`,count:e.delegates,label:t.delegates},{id:`edited`,count:e.edited,label:t.edited},{id:`subagents`,count:e.subagents,label:t.subagents},{id:`clipboard`,count:e.clipboard,label:t.clipboard}].map(t=>{let r=pf[t.id],i=r!==``&&(n===r||n.startsWith(`${r}/`));return t.id===`clipboard`&&e.clipboardJustCopied?{id:t.id,icon:ff,label:t.label,count:t.count,active:i,tone:`success`}:{id:t.id,icon:df[t.id],label:t.label,count:t.count,active:i}}).filter(e=>e.count>0);if(e.clipboardFailed){let e=r.filter(e=>e.id!==`clipboard`);return e.push({id:`clipboard`,icon:df.clipboard,label:t.clipboardFailed,count:0,active:!1,hideCount:!0,tone:`warning`}),e}return r}function hf(e){return e.length>0}const gf=H.memo(function({counts:e,labels:t,currentPath:n=``,tabHint:r}){let i=R(),a=mf({counts:e,labels:t,currentPath:n});return a.length===0?q(Y,{flexDirection:`row`,height:1}):q(Y,{flexDirection:`row`,height:1,children:J(Jt,{children:[a.map((e,t)=>{let n=e.hideCount?`${e.icon} ${e.label}`:`${e.icon} ${e.label} ${e.count}`;return e.tone===`success`?J(X,{wrap:`truncate-end`,children:[t>0?` · `:``,q(X,{color:i.success,bold:!0,children:n})]},e.id):J(A,{type:e.tone===`warning`?`warning`:e.active?`accent`:`secondary`,wrap:`truncate-end`,children:[t>0?` · `:``,n]},e.id)}),r&&hf(a)&&q(A,{type:`secondary`,dim:!0,wrap:`truncate-end`,children:` · ${r}`})]})})});function _f(e=process.env,t=process.platform){let n=e.TERM_PROGRAM;return n===`Apple_Terminal`?`Fn`:n===`iTerm.app`||e.LC_TERMINAL===`iTerm2`?`Option`:n===`vscode`||n===`ghostty`||n===`WarpTerminal`||n===`Hyper`?t===`darwin`?`Option`:`Shift`:n===`tmux`||e.TMUX?`Shift`:`Shift/Option/Fn`}function vf(e=process.env,t=process.platform){let n=_f(e,t);return n===`Shift/Option/Fn`?`Shift (Option in iTerm2, Fn in Terminal.app)`:n}const yf=H.memo(function(e){let t=R(),{fullScreenPaneActive:n,tipVisible:r,tasksCollapsed:i,taskSelIndex:a,setTaskSelIndex:o,backgroundTasksOrdered:s,columns:c,openEditedFileFull:l,editedFileFullIndex:u,subagents:d}=e,{taskStore:f}=eu(),p=Z(f.store,e=>e.tasks),m=Z(f.store,e=>e.tasksTitle),h=Z(f.store,e=>e.editedFiles),g=Z(f.store,e=>e.scheduleTasks),_=Z(f.store,e=>e.clipboardChars),v=Z(f.store,e=>e.clipboardFailed),y=Z(f.store,e=>e.clipboardText),b=Z(f.store,e=>e.clipboardJustCopied),x=Z(f.store,e=>e.subagentContext),S=Z(f.store,e=>e.backgroundTasks.length),{onBackgroundClose:C,onBackgroundKill:w,onBackgroundViewOutput:T,onBackgroundApply:E,onBackgroundSwitch:D,onBackgroundDelete:ee,onToggleEditedFiles:te,onToggleSubagents:O,onToggleSchedule:ne}=pu(),{currentPath:k}=me(),re=k===`/pane/tasks`&&p.length>0,A=k===`/pane/delegates`&&S>0,ie=k===`/pane/edited-files`,j=k===`/pane/subagents`,ae=k===`/pane/schedule`,oe=k===`/pane/clipboard`&&y.length>0;if(n||x)return null;let se=r?I.none:I.tight,M=re||A||ie||j||ae||oe;return J(Y,{flexDirection:`column`,marginTop:se,children:[q(gf,{currentPath:k,tabHint:V.t(`signalBar.tabHint`),counts:{tasks:p.length,delegates:S,edited:h.length,subagents:d.length,clipboard:_,clipboardFailed:v,clipboardJustCopied:b},labels:{tasks:m??V.t(`task.title`),delegates:V.t(`bg.tasksTitle`),edited:V.t(`panelTitle.editedFilesTitle`),subagents:V.t(`hint.subagents`),clipboard:V.t(`signalBar.clipboard`),clipboardFailed:V.t(`signalBar.clipboardFailed`,{modifier:vf()})}}),!M&&q(Y,{height:1,flexShrink:0}),M&&J(Y,{flexDirection:`column`,...nt,borderColor:t.panelBorder,children:[re&&q(uf,{tasks:p,title:m,collapsed:i,focused:!0,selectedIndex:a,onDismiss:su,onSelectIndex:o}),A&&S>0&&q(Zd,{tasks:s,columns:c,onClose:C,onKill:w,onViewOutput:T,onApply:E,onSwitch:D,onDelete:ee,active:!0}),ie&&q(Bu,{files:h,focused:!0,onDismiss:te,onOpenFileFull:l,fullOpenIndex:u}),j&&q(nf,{tasks:d,focused:!0,onDismiss:O,onSwitch:D,onViewOutput:T}),ae&&q(of,{tasks:g,focused:!0,onDismiss:ne}),oe&&q(sf,{text:y,focused:!0,columns:c,onDismiss:su,onOpenViewer:()=>z()?.navigate(`/viewer/clipboard`,{state:{content:y}})})]})]})});function bf({items:e,focused:r,onDismiss:i,onLoad:a,onDelete:o,onDeleteMany:s,rows:c=24}){let l=R(),[u,d]=ra(`drafts`,e.length),f=G(0),[p,m]=K(new Set);if(D(`draft-pane`,(t,n)=>{if(n.escape)return p.size>0&&m(new Set),i?.(),!0;if(Me(`list-nav-up`,t,n,`draft`))return d(e=>Math.max(0,e-1)),!0;if(Me(`list-nav-down`,t,n,`draft`))return d(t=>Math.min(e.length-1,t+1)),!0;if(n.return)return a?.(u),!0;if(t===` `){let t=e[Math.max(0,Math.min(u,e.length-1))];return t&&m(e=>{let n=new Set(e);return n.has(t.id)?n.delete(t.id):n.add(t.id),n}),!0}return t===`d`?(p.size>0?(s?.([...p]),m(new Set)):o?.(u),!0):!1},{isActive:r}),e.length===0&&!r)return null;if(!r)return J(Y,{children:[q(X,{color:l.special,children:`▸ `}),q(A,{type:`secondary`,children:V.t(`draft.sLabel`)}),J(A,{type:`secondary`,children:[` `,e.length]}),J(A,{type:`secondary`,dim:!0,children:[` `,t(`o`)]})]});let h=rf(u,e.length),g=Ct(e,h,n(e.length,c,7),f.current);return f.current=g.scrollTop,q(F,{header:J(Y,{children:[q(X,{color:l.secondary,bold:!0,children:V.t(`draft.sLabel`)}),J(A,{type:`secondary`,children:[` `,e.length]})]}),footer:q(C,{items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.enter,V.t(`hint.load`)],[`space`,V.t(`hint.check`)],[`d`,V.t(`hint.delete`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]}),children:J(Y,{marginTop:I.tight,flexDirection:`column`,children:[e.length===0&&q(A,{type:`secondary`,children:V.t(`draft.sEmpty`)}),g.rows.map((e,t)=>{let n=g.scrollTop+t,r=n===h,i=p?.has(e.id)??!1,a=r?l.selection:l.text,o=P(e.text,51),s=new Date(e.savedAt).toLocaleString();return J(Y,{flexDirection:`row`,children:[q(X,{color:r?l.selection:l.inactive,children:r?Nt():wt()}),q(A,{type:`secondary`,children:`${n+1}. `}),q(X,{color:i?l.accent:l.inactive,children:i?`${L.bullet} `:`${L.todoPending} `}),q(X,{color:a,bold:!0,children:e.name}),J(X,{dimColor:!0,children:[` `,o]}),J(X,{dimColor:!0,children:[` `,s]})]},e.id)}),g.fillerCount>0&&Array.from({length:g.fillerCount},(e,t)=>q(X,{children:` `},`filler-${t}`))]})})}function xf({items:e,focused:t,rows:r=24,onDismiss:i,closeConfirmOpen:a=!1,editOpen:o=!1,onDelete:s,onMove:c,onEditOpen:l}){let u=R(),[d,f]=ra(`queue`,e.length),[p,m]=K(!1),h=G(0);if(!t&&p&&m(!1),D(`queue-pane`,(t,n)=>p?t===` `||n.escape?(m(!1),!0):n.upArrow||n.tab&&n.shift?(c?.(d,-1),f(e=>Math.max(0,e-1)),!0):n.downArrow||n.tab&&!n.shift?(c?.(d,1),f(t=>Math.min(e.length-1,t+1)),!0):!0:n.escape?(i?.(),!0):Me(`list-nav-up`,t,n,`queue`)?(f(e=>Math.max(0,e-1)),!0):Me(`list-nav-down`,t,n,`queue`)?(f(t=>Math.min(e.length-1,t+1)),!0):n.tab&&!n.ctrl&&!n.meta?(f(t=>n.shift?Math.max(0,t-1):Math.min(e.length-1,t+1)),!0):t===` `?(e.length>0&&m(!0),!0):n.return?(e.length>0&&l?.(d),!0):t===`d`?(s?.(d),!0):!1,{isActive:t&&!a&&!o}),!t)return null;let g=rf(d,e.length),_=Ct(e,g,n(e.length,r,7),h.current);return h.current=_.scrollTop,q(F,{header:J(Y,{children:[q(X,{color:u.secondary,bold:!0,children:V.t(`queue.label`)}),J(A,{type:`secondary`,children:[` `,e.length]})]}),footer:q(C,{items:p?[[`${j.up}${j.down}`,V.t(`hint.move`)],[`space/Esc`,V.t(`hint.drop`)]]:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.enter,V.t(`hint.edit`)],[`space`,V.t(`hint.grab`)],[`d`,V.t(`hint.delete`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.select`)]]}),children:J(Y,{marginTop:I.tight,flexDirection:`column`,children:[e.length===0&&q(A,{type:`secondary`,children:V.t(`queue.empty`)}),_.rows.map((e,t)=>{let n=_.scrollTop+t,r=n===g,i=r&&p,a=i?u.accent:r?u.selection:u.text,o=i?`⇅ `:r?Nt():wt(),s=e.mode===`bash_async`?`!! `:e.mode===`bash`?`! `:e.mode===`memory`?`# `:` `,c=e.text.length>60?P(e.text,61):e.text;return J(Y,{flexDirection:`row`,children:[q(A,{type:`secondary`,children:`${n+1}. `}),q(X,{color:a,bold:r,children:o}),q(X,{color:a,bold:r,children:s}),q(X,{color:a,bold:r,children:c})]},n)}),Array.from({length:_.fillerCount},(e,t)=>q(X,{children:` `},`filler-${t}`))]})})}function Sf(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];r.role===`user`&&typeof r.content==`string`&&r.content.trim().length>0&&t.push({text:r.content,index:n})}return t}function Cf(e){return Math.max(1,u(e)-5-2)}function wf(e,t){let n=Math.max(20,t-12);return e.map((e,t)=>({value:String(e.index),label:`${t+1}. ${P(e.text.replace(/\s+/g,` `),n)}`}))}function Tf({messageStore:e,focused:t,rows:n=24,columns:r=80,onDismiss:i}){let a=Sf(Z(e.store,e=>e.messages));if(D(`prompt-log-pane`,(e,t)=>t.escape?(i?.(),!0):!1,{isActive:t,ignoreRoute:!0}),!t)return null;let o=u(n),s=Cf(n),c=wf(a,r);return q(F,{maxHeight:o,header:J(Y,{children:[q(A,{type:`secondary`,bold:!0,children:V.t(`prompts.label`)}),J(A,{type:`secondary`,children:[` `,a.length]})]}),footer:q(C,{items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.esc,V.t(`hint.close`)]]}),children:a.length===0?q(A,{type:`secondary`,children:V.t(`prompts.empty`)}):q(ht,{id:`prompt-log-list`,tabIndex:0,autoFocus:!0,options:c,maxVisible:s,compact:!0,onSelect:()=>{}})})}function Ef(e={}){let{columns:t=120,onEmptyBackspace:n,onClearText:r,onCommit:i}=e,[a,o]=K(``),[s,c]=K(0),u=Gt((e,t)=>{o(e),c(t)},[]);return{text:a,offset:s,update:Gt((e,t)=>{o(e),c(t)},[]),handleEditing:Gt((e,o)=>{if(e.length>1&&!o.ctrl&&!o.meta&&!o.return&&!o.escape&&!o.backspace&&!o.delete&&!o.tab&&!o.upArrow&&!o.downArrow&&!o.leftArrow&&!o.rightArrow){let t=ke(e);return t&&u(a.slice(0,s)+t+a.slice(s),s+t.length),!0}if(o.leftArrow){let e=l.fromText(a,t,s).left();return u(e.text,e.offset),!0}if(o.rightArrow){let e=l.fromText(a,t,s).right();return u(e.text,e.offset),!0}if((o.backspace||o.delete)&&a.length===0)return n?.(),!0;let c={name:o.backspace?`backspace`:o.delete?`delete`:o.tab?`tab`:o.escape?`escape`:o.return?`return`:e||`unknown`,ctrl:o.ctrl??!1,shift:!1,alt:o.meta??!1,meta:o.meta??!1},d=Tt(l.fromText(a,t,s),c);return d?d.action===`clear_text`?(u(``,0),r?.(),!0):d.action===`submit`||d.action===`submit_force`?(i?.(),!0):(u(d.cursor.text,d.cursor.offset),!0):!1},[a,s,t,n,r,u])}}const Df={send:`dialog`,bash:`bash`,bash_async:`bash_async`,memory:`memory`},Of=[`input`,`sendNow`,`confirm`,`cancel`];function kf({index:e,total:t,initialValue:n,mode:r,busy:i,columns:a=60,onSendNow:o,onConfirm:s,onCancel:c}){let[l,u]=K(`input`),{text:d,offset:f,update:p,handleEditing:m}=Ef({columns:a});H.useEffect(()=>{n&&p(n,n.length)},[]);let h=d.trim()===``,g=e=>{u(Of[(Of.indexOf(l)+e+Of.length)%Of.length])},_=()=>{if(l===`sendNow`){h||o(d);return}if(l===`confirm`){h||s(d);return}if(l===`cancel`){c();return}};D(`queue-edit-dialog`,(e,t)=>{if(t.return&&t.meta){h||o(d);return}if(t.escape){if(l===`input`&&d.length>0){p(``,0);return}c();return}if(t.tab||t.ctrl&&e===`n`){g(1);return}if(l!==`input`){if(t.leftArrow){g(-1);return}if(t.rightArrow){g(1);return}if(t.upArrow){u(`input`);return}if(t.downArrow){g(1);return}if(t.return){_();return}return}if(t.downArrow){g(1);return}if(t.upArrow){g(-1);return}if(t.return){h||u(`confirm`);return}return m(e,t)});let v=i?V.t(`queue.editSendNowHintBusy`):V.t(`queue.editSendNowHintIdle`);return J(F,{header:q(_e,{children:V.t(`queue.editTitle`,{index:e,total:t})}),footer:q(C,{items:[[j.tab,V.t(`hint.quick`)],[`${j.up}${j.down}`,V.t(`hint.switch`)],[j.enter,V.t(`hint.confirm`)],[yt(),V.t(`queue.editSendNowButton`)],[j.esc,V.t(`hint.cancel`)]]}),children:[q(Y,{marginTop:I.tight,flexDirection:`row`,children:q(dt,{value:d,offset:f,columns:a,mode:Df[r],focused:l===`input`})}),J(Y,{marginTop:I.tight,flexDirection:`row`,gap:I.section,children:[q(Ne,{variant:`solid`,brackets:!0,color:`green`,label:V.t(`queue.editSendNowButton`),focused:l===`sendNow`,disabled:h}),q(Ne,{variant:`solid`,brackets:!0,color:`accent`,label:V.t(`queue.editConfirmButton`),focused:l===`confirm`,disabled:h}),q(Ne,{variant:`solid`,brackets:!0,color:`gray`,label:V.t(`common.genericCancelButton`),focused:l===`cancel`})]}),q(Y,{marginTop:I.tight,children:q(A,{type:`secondary`,dim:!0,children:v})})]})}function Af(e,t){let n=t?.length?[...e,...t]:[...e];return{search:(e,t,r=50)=>(e?xr(e,n).map(e=>e.entry):[...n].reverse()).slice(0,r).map(e=>({label:e,value:e,kind:`shortcut`}))}}function jf({showHome:e,agentProcessing:t,hasTip:n}){return e||t||!n?0:3}function Mf(e){let t=pu(),{currentPath:n,stack:r,navigate:i,goBack:a}=me(),o=r.some(e=>e.path===`/pane/queue`),{columns:s,rows:c,agentProcessing:l,handlePromptEscape:u,pluginInput:d,handleSigilTrigger:f,handleSigilClose:p,handleHistorySearch:m,handleChipReopen:h,handleChipViewPaste:g,handlePasteConfirmRequest:_,welcome:v,historyInsertRef:y,pasteBridgeRef:b,initialHistory:x,externalHistoryCommands:S,residencyGovernor:C,registryRef:w,shellBackendRef:T,sigilState:E,setSigilState:D,sigilApplyRef:ee,readFileContent:te,handleDraftLoad:O,onQueueEscConfirm:ne,queueEscSuppress:k,queueCloseConfirm:re,setQueueCloseConfirm:A,interruptConfirm:ie,popQueuedConfirm:j,queueEditIndex:ae,setQueueEditIndex:oe,scrollStore:se,messageStore:M}=e,{taskStore:N}=eu(),P=Z(N.store,e=>e.forcedUpgrade),ce=Z(N.store,e=>e.commands),le=Z(N.store,e=>e.needsSetup),ue=Z(N.store,e=>e.ftueStage),de=Z(N.store,e=>e.recentMentions),fe=Z(N.store,e=>e.drafts),pe=Z(N.store,e=>e.queued),he=kd(ue,le),ge=Od(ue),_e=Z(se.store,e=>e.offset>0),[ve,ye]=K(x??[]),be=Gt(e=>{ye(e),t.onHistoryPush?.(e)},[t]),F=qt(()=>Af(ve,S),[ve,S]),xe=()=>{oe(null),n===`/pane/queue/edit`&&a()},Se=Gt((e,n,r)=>{t.onSubmit?.(e,n,r);let i=e.trimStart().startsWith(`/`);if(he&&!i)return`rejected`},[t,he]);return J(Jt,{children:[e.shadow&&q(ed,{}),E&&d&&q(Y,{flexDirection:`column`,marginTop:I.tight,children:q(Tc,{sigil:E.sigil,initialQuery:E.query,registry:E.mode===`history`?F:d,active:n===`/pane/sigil`,rows:c,columns:Math.min(60,s-Pe.borderInset),viewerColumns:s,readFileContent:te,recentEntries:E.sigil===`@`?de:void 0,title:E.mode===`history`?V.t(`history.label`):void 0,onSelect:e=>{if(D(null),E.mode===`history`){y.current?.fill(e.value);return}ee.current?.select(e),E.sigil===`@`&&t.onSigilSelect?.(e)},onClose:({deleteSigil:e})=>{D(null),ee.current?.cancel(e)}})}),q(Pi,{columns:s-Pe.borderInset,rows:c,disabled:!!P||re||ie||j,reviewing:_e,idleTipVisible:!!e.idleTip,commands:ce,placeholder:P?V.t(`prompt.upgradeRequired`):l?V.t(`prompt.working`):he?V.t(ge??`prompt.setup`):V.t(`prompt.default`),onSubmit:Se,onInterrupt:t.onInterrupt,onEscape:u,sigilEnabled:!!d,onSigilTrigger:f,onSigilClose:p,onChipReopen:h,onChipViewPaste:g,onToast:t.onToast,onDraftSave:t.onDraftSave,keybindingOverrides:e.keybindingOverrides,onPasteConfirm:_,cwd:v?.cwd,historyInsertRef:y,pasteBridgeRef:b,initialHistory:x,externalHistoryCommands:S,onHistoryPush:be,onHistorySearch:m,historySearchOpen:E?.mode===`history`,residencyGovernor:C,registryRef:w,shellBackendRef:T}),q(bf,{items:fe,focused:n===`/pane/draft`,onDismiss:t.onToggleDraftPane,onLoad:O,onDelete:t.onDraftDelete,onDeleteMany:t.onDraftDeleteMany}),M&&n===`/pane/prompts`&&q(Y,{flexDirection:`column`,marginTop:I.tight,children:q(Tf,{messageStore:M,focused:!0,rows:c,columns:s,onDismiss:()=>t.onTogglePrompts?.()})}),o&&n===`/pane/queue`&&q(Y,{flexDirection:`column`,marginTop:I.tight,children:q(xf,{items:pe,focused:!0,rows:c,onDismiss:()=>{re&&A(!1),t.onToggleQueuePane?.()},onEscConfirm:ne,escSuppress:k,closeConfirmOpen:re,editOpen:ae!==null,onDelete:t.onQueueDelete,onMove:t.onQueueMove,onEditOpen:e=>{oe(e),i(`/pane/queue/edit`)}})}),n===`/pane/queue/edit`&&ae!==null&&pe[ae]&&q(kf,{index:ae+1,total:pe.length,initialValue:pe[ae].text,mode:pe[ae].mode,busy:l,onSendNow:e=>{t.onQueueSendNow?.(ae,e),xe()},onConfirm:e=>{t.onQueueEditText?.(ae,e),xe()},onCancel:xe}),n!==`/pane/queue`&&!n.startsWith(`/pane/queue/`)&&q(Fi,{items:pe})]})}function Nf(e,t){let n=V.language===`zh`,r=n?`行`:e===1?`line`:`lines`,i=n?`字符`:t===1?`char`:`chars`;return V.t(`paste.previewSummary`,{context:`body`,lines:e,lineWord:r,chars:t,charWord:i})}function Pf(e){let t=e.replace(/\n/g,`↵`);return t.length<=16?`[@${t}:]`:`[@${t.slice(0,5)}…${t.slice(-5)}:]`}function Ff(e,t){let n=e.split(`
57
57
  `);return n.length<=t?e:`${n.slice(0,t).join(`
58
58
  `)}\n${Nf(n.length,e.length)}`}function If({content:e,previewLines:t=10,rows:n=24,columns:r=80,onConfirm:i,onCancel:a}){let o=R(),[s,c]=K(0),[l,u]=K(!1),d=G(0);d.current=s;let f=G(!1);W(()=>{let e=setTimeout(()=>{f.current=!0},0);return()=>{clearTimeout(e)}},[]);let p=Ff(e,t),m=Pf(e),h=qt(()=>e.split(`
59
59
  `),[e]);return D(`paste-confirm-dialog-buttons`,(e,t)=>{if(l)return!1;if(t.escape)return f.current&&a(),!0;if(t.leftArrow||t.rightArrow||t.tab){if(f.current){let e=O(t);e!==0&&c(t=>ee(t,e,3))}return!0}return t.return?(f.current&&c(e=>(e===0?i():e===1?u(!0):a(),e)),!0):!1}),l?q(sc,{lines:h,rows:n,columns:r,header:J(Y,{children:[q(X,{color:o.selection,children:V.t(`paste.viewTitle`)}),J(A,{type:`secondary`,children:[` `,Nf(h.length,e.length)]})]}),onDismiss:()=>u(!1),initialScroll:`top`,contentKey:e}):J(F,{header:q(_e,{children:V.t(`paste.confirmTitle`)}),footer:q(C,{items:[[`${j.left}${j.right}`,V.t(`hint.switch`)],[j.enter,`${V.t(`hint.confirm`)}/${V.t(`paste.view`)}`],[j.esc,V.t(`hint.cancel`)]]}),children:[q(Y,{marginTop:I.tight,flexDirection:`column`,children:q(A,{type:`secondary`,children:p})}),J(Y,{marginTop:I.tight,children:[q(X,{dimColor:!0,children:V.t(`paste.collapseLabel`)}),q(X,{color:o.selection,children:m})]}),J(Y,{marginTop:I.tight,flexDirection:`row`,gap:I.section,children:[q(Ne,{variant:`solid`,brackets:!0,color:`amber`,label:V.t(`paste.confirm`),focused:s===0}),q(Ne,{variant:`solid`,brackets:!0,color:`gray`,label:V.t(`paste.view`),focused:s===1}),q(Ne,{variant:`solid`,brackets:!0,color:`gray`,label:V.t(`paste.cancel`),focused:s===2})]})]})}function Lf(e,t){let n=Math.floor((t-e)/1e3);return n<60?V.t(`time.justNow`):n<3600?V.t(`time.minAgo`,{min:Math.floor(n/60)}):n<86400?V.t(`time.hourAgo`,{hr:Math.floor(n/3600)}):V.t(`time.dayAgo`,{day:Math.floor(n/86400)})}function Rf(e,t){return e===`error`?t.error:e===`warning`?t.warning:t.inactive}function zf({notifications:e,onClose:t,rows:n=24}){let r=R();D(`notification-center`,(e,n)=>n.escape?(t(),!0):!1);let[i,a]=K(()=>Date.now()),o=G(0);W(()=>{let e=setInterval(()=>a(Date.now()),3e4);return()=>clearInterval(e)},[]);let s=e.filter(e=>!e.read),c=e.filter(e=>e.read),l=[...s,...c];if(l.length===0)return null;let u=Ct(l,-1,Ye(l.length+6,n)-6,o.current);return o.current=u.scrollTop,q(F,{header:J(Y,{marginBottom:I.tight,children:[q(X,{color:r.secondary,bold:!0,children:V.t(`notif.title`)}),s.length>0&&J(X,{color:r.accent,children:[` `,s.length]})]}),footer:q(C,{items:[[`${j.up}${j.down}`,V.t(`hint.scroll`)],[j.enter,V.t(`hint.dismiss`)],[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]}),children:u.rows.map((e,t)=>J(Y,{flexDirection:`column`,children:[u.scrollTop+t===s.length&&c.length>0&&s.length>0&&q(Y,{marginY:I.tight,children:q(A,{type:`secondary`,dim:!0,children:V.t(`notif.readDivider`)})}),J(Y,{flexDirection:`row`,children:[q(X,{color:Rf(e.level,r),children:e.level===`error`?L.cross:e.level===`warning`?L.warn:`i`}),q(A,{type:`secondary`,children:` `}),J(X,{color:e.read?r.inactive:r.secondary,dimColor:e.read,wrap:`truncate-end`,children:[`[`,e.source,`] `,e.title,` · `,e.message]}),J(A,{type:`secondary`,dim:!0,children:[` `,`(`,Lf(e.timestamp,i),`)`]})]})]},e.id))})}function Bf({focusOwner:e,pasteContent:t,onPasteConfirm:n,onPasteCancel:r,notifications:i,rows:a,columns:o}){let{onDismissNotification:s,onCloseNotifications:c}=pu();return J(Jt,{children:[t!=null&&q(E,{path:`/overlay/paste-confirm`,inStack:!0,element:q(If,{content:t,rows:a,columns:o,onConfirm:n,onCancel:r})}),e===`notifications`&&q(zf,{notifications:i,onDismiss:e=>s?.(e),onClose:()=>c?.()})]})}function Vf({component:e,columns:t=60,onAction:n,onDismiss:r}){let i=R(),a=e.fields??[],o=e.formTitle??`表单`,[s,c]=K(Gt(()=>{let e={},t={},n={};for(let r of a)if(r.type===`toggle`)t[r.id]=r.defaultValue===!0;else{let t=r.defaultValue==null?``:String(r.defaultValue);e[r.id]=t,n[r.id]=t.length}return{strings:e,toggles:t,offsets:n}},[a])),[u,d]=K({kind:`field`,index:0}),f=u.kind===`field`?u.index:-1,p=a.length,m=f>=0&&f<p?a[f]:void 0,h=(e,t,n)=>{c(r=>({strings:{...r.strings,[e]:t},toggles:r.toggles,offsets:{...r.offsets,[e]:n}}))},g=e=>{c(t=>({strings:t.strings,toggles:{...t.toggles,[e]:!(t.toggles[e]??!1)},offsets:t.offsets}))},_=()=>{u.kind===`field`&&u.index<p-1?d({kind:`field`,index:u.index+1}):d({kind:`submit`})},v=()=>{u.kind===`submit`?d({kind:`field`,index:Math.max(0,p-1)}):u.kind===`cancel`?d({kind:`submit`}):u.kind===`field`&&u.index>0&&d({kind:`field`,index:u.index-1})},y=()=>{let t={};for(let e of a)e.type===`toggle`?t[e.id]=s.toggles[e.id]??!1:t[e.id]=s.strings[e.id]??``;let r=e.action??`submit`;n(e.id,r,t)};D(`a2ui-form-dialog`,(e,n)=>{if(n.escape){if(u.kind===`field`){if(m?.type===`text`&&(s.strings[m.id]??``).length>0){h(m.id,``,0);return}v();return}r();return}if(n.tab||n.ctrl&&e===`n`){_();return}if(n.return&&n.meta){y();return}if(u.kind!==`field`){if(n.leftArrow){v();return}if(n.rightArrow){_();return}if(n.return&&u.kind===`submit`){y();return}if(n.return&&u.kind===`cancel`){r();return}return}if(m){if(n.upArrow){v();return}if(n.downArrow){_();return}if(n.return){f>=p-1?y():_();return}if(m.type===`text`){let r=m.id,i=s.strings[r]??``,a=s.offsets[r]??0;if(n.leftArrow){let e=l.fromText(i,t,a).left();h(r,e.text,e.offset);return}if(n.rightArrow){let e=l.fromText(i,t,a).right();h(r,e.text,e.offset);return}if(e.length>1&&!n.ctrl&&!n.meta&&!n.return&&!n.escape&&!n.backspace&&!n.delete&&!n.tab&&!n.upArrow&&!n.downArrow&&!n.leftArrow&&!n.rightArrow){let t=ke(e);t&&h(r,i.slice(0,a)+t+i.slice(a),a+t.length);return}let o={name:n.backspace?`backspace`:n.delete?`delete`:n.tab?`tab`:e||`unknown`,ctrl:n.ctrl??!1,shift:n.shift??!1,alt:n.meta??!1,meta:n.meta??!1},c=Tt(l.fromText(i,t,a),o);if(!c)return;if(c.action===`clear_text`){h(r,``,0);return}h(r,c.cursor.text,c.cursor.offset);return}if(m.type===`select`){n.leftArrow?v():n.rightArrow&&_();return}if(m.type===`toggle`&&e===` `){g(m.id);return}}});let b=a.map(e=>e.label).join(` · `);return J(F,{header:q(_e,{children:o}),footer:q(C,{items:[[j.tab,`next`],[j.enter,V.t(`hint.confirm`)],[j.esc,V.t(`hint.cancel`)]]}),children:[q(Y,{flexDirection:`column`,marginTop:I.tight,children:q(A,{type:`secondary`,dim:!0,children:b})}),q(Y,{flexDirection:`column`,marginTop:I.tight,children:a.map((e,n)=>{let r=u.kind===`field`&&u.index===n,a=e.required?` *`:``;return J(Y,{flexDirection:`column`,marginBottom:I.tight,children:[J(Y,{flexDirection:`row`,children:[q(X,{color:r?i.selection:i.inactive,children:r?Nt():wt()}),J(X,{bold:r,color:r?i.selection:void 0,children:[e.label,a]})]}),e.type===`text`&&q(Y,{flexDirection:`row`,marginLeft:I.section,children:q(dt,{value:s.strings[e.id]??``,offset:s.offsets[e.id]??0,columns:t-4,mode:`dialog`,focused:r,placeholder:e.placeholder})}),e.type===`select`&&q(Y,{flexDirection:`row`,gap:I.tight,marginLeft:I.section,children:q(X,{dimColor:!r,color:r?i.selection:i.inactive,children:(e.options??[]).map((t,n)=>J(H.Fragment,{children:[r?J(X,{color:s.strings[e.id]===t.id?i.selection:i.inactive,children:[s.strings[e.id]===t.id?`${L.toggleOn} `:`${L.toggleOff} `,t.label]}):q(A,{type:`secondary`,children:t.label}),n<(e.options??[]).length-1&&q(A,{type:`secondary`,children:` · `})]},t.id))})}),e.type===`toggle`&&q(Y,{flexDirection:`row`,marginLeft:I.section,children:J(X,{color:r?i.selection:i.inactive,children:[s.toggles[e.id]?L.check:L.cross,` `,s.toggles[e.id]?`enabled`:`disabled`]})}),![`text`,`select`,`toggle`].includes(e.type)&&q(Y,{flexDirection:`row`,marginLeft:I.section,children:q(A,{type:`secondary`,dim:!0,children:String(s.strings[e.id]??``)||`?`})})]},e.id)})}),J(Y,{flexDirection:`row`,gap:I.tight,marginTop:I.tight,children:[q(Ne,{variant:`solid`,brackets:!0,color:`accent`,label:V.t(`prompt.submit`),focused:u.kind===`submit`}),q(Ne,{variant:`solid`,brackets:!0,color:`gray`,label:V.t(`common.genericCancelButton`),focused:u.kind===`cancel`})]})]})}function Hf({columns:e}){let t=ue();return t?q(Vf,{component:t.component,columns:e,onAction:t.onAction,onDismiss:t.onDismiss}):null}function Uf({onOk:e}){let t=ue();return t?q(Vl,{title:t.title,message:t.message,okLabel:t.okLabel,onOk:e}):null}function Wf({onConfirm:e,onCancel:t,onExtra:n}){let r=ue(),i=G(t);return i.current=t,W(()=>()=>{i.current()},[]),r?q(Qe,{title:r.title,message:r.message,confirmLabel:r.confirmLabel,cancelLabel:r.cancelLabel,confirmColor:r.confirmColor,dangerous:r.dangerous,extraLabel:r.extraLabel,extraColor:r.extraColor,onConfirm:e,onCancel:t,onExtra:r.extraLabel?n:void 0}):null}function Gf(e,t){switch(e){case`warn`:return t.warning;case`error`:return t.error;default:return}}function Kf(e){let t=Date.now()-e,n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);return r<60?`${r}m ago`:`${Math.floor(r/60)}h ago`}function qf({req:e,rows:t=24,columns:n=80}){let r=R(),[i,o]=K(0),s=(a()?.currentPath??`/`)===`/dialog/extension/full-text`,c=e=>{let t=z();t&&(e&&t.currentPath===`/dialog/extension`?t.navigate(`/dialog/extension/full-text`):!e&&t.currentPath===`/dialog/extension/full-text`&&t.goBack())},[l,u]=K(0),[d,f]=K(Da());W(()=>{c(!1),u(0)},[e.fullText]),W(()=>{if(d)return;let e=!0;return Ea().then(()=>{e&&f(Da())}),()=>{e=!1}},[d]);let p=qt(()=>e.fullText?e.fullText.kind===`plain`?[{id:`plain`,label:`Plain`,lines:e.fullText.content.split(`
@@ -64,9 +64,9 @@ import{$ as e,$t as t,A as n,An as r,At as i,B as a,Bt as o,C as s,Cn as c,Ct as
64
64
  `),[e.content]),rows:t,columns:n,wrapMode:`pre-wrap`,header:q(Y,{children:q(X,{color:i.selection,children:e.label})}),onDismiss:e.onDismiss,initialScroll:`top`,active:r,contentKey:e.label})}function Yp(e){let t=pu(),{stdout:n}=nn(),{taskStore:r,notificationStore:i}=eu(),a=Z(i.store,e=>e.notifications),o=Z(r.store,e=>e.queued),{stack:s}=me(),c=e=>s.some(t=>t.path===e);return J(Jt,{children:[q(Bf,{focusOwner:e.routeDerivedOwner,pasteContent:c(`/overlay/paste-confirm`)?e.pasteContent:null,onPasteConfirm:e.handlePasteConfirm,onPasteCancel:e.handlePasteCancel,notifications:a,rows:e.rows,columns:e.columns}),q(qp,{columns:e.columns,rows:e.rows}),e.chipContentViewerRequest&&c(`/overlay/chip-viewer`)&&q(E,{path:`/overlay/chip-viewer`,inStack:!0,element:q(Jp,{req:e.chipContentViewerRequest,rows:n?.rows??e.rows,columns:e.columns,active:c(`/overlay/chip-viewer`)})}),e.queueCloseConfirm&&q(Qe,{title:V.t(`queue.exitTitle`),message:V.t(`queue.exitMessage`).replace(`%d`,String(o.length)),confirmLabel:V.t(`queue.exitConfirm`),checkLabel:V.t(`common.dontRemind`),checked:e.queueEscSuppress,onCheckChange:e.setQueueEscSuppress,onConfirm:()=>{e.setQueueCloseConfirm(!1),t.onToggleQueuePane?.()},onCancel:()=>e.setQueueCloseConfirm(!1)}),e.interruptConfirm&&q(Qe,{title:V.t(`agent.interruptTitle`),message:V.t(`agent.interruptMessage`),confirmLabel:V.t(`agent.interruptConfirm`),confirmColor:`red`,dangerous:!0,onConfirm:()=>{e.setInterruptConfirm(!1),t.onInterrupt?.()},onCancel:()=>e.setInterruptConfirm(!1)}),e.popQueuedConfirm&&q(Qe,{title:V.t(`queue.popTitle`),message:V.t(`queue.popMessage`),confirmLabel:V.t(`queue.popConfirm`),confirmColor:`red`,dangerous:!0,onConfirm:()=>{e.setPopQueuedConfirm(!1),t.onPopQueued?.()},onCancel:()=>e.setPopQueuedConfirm(!1)})]})}function Xp({exec:e,maxLines:t=8,totalLines:n,onCopyOutput:r,onAskAi:i,onAbort:a,onDismiss:o,onViewFullOutput:s,active:c=!0}){let l=R(),u=e.status===`running`,d=e.terminated||e.exitCode===null,f=!u&&(e.terminated===!0||e.exitCode!==0);D(`shell-pane`,(t,n)=>n.escape?(u&&a?.(),o?.(),!0):t===`v`&&!n.ctrl&&!n.meta&&!u?(s?.({command:e.command,output:e.output,isError:e.terminated===!0||e.exitCode!==0}),!0):t===`c`&&!n.ctrl&&!n.meta&&!u?(r?.(),!0):t===`a`&&!n.ctrl&&!n.meta&&f?(i?.(),o?.(),!0):!1,{isActive:c});let p=G(c);W(()=>{p.current&&!c&&(u&&a?.(),o?.()),p.current=c},[c,u,a,o]);let m=u?l.accent:d?l.error:e.exitCode===0?l.success:l.error,h=u?V.t(`shell.running`):e.terminated?V.t(`shell.terminated`):e.exitCode===null?V.t(`shell.errored`):V.t(`shell.exit`,{code:e.exitCode}),g=u?L.todoActive:d?L.cross:e.exitCode===0?L.check:L.cross,_=e.output.split(`
65
65
  `),v=n??_.length,y=_.slice(-t),b=u&&y.length<t?[...y,...Array.from({length:t-y.length},()=>``)]:y,x=Math.max(0,_.length-t),S=u?V.t(`hint.toInterrupt`):V.t(`hint.close`),w=q(C,{items:[...!u&&v>t?[[`v`,V.t(`shell.viewAll`,{count:v})]]:[],...!u&&r?[[`c`,V.t(`shell.copyHint`)]]:[],...!u&&f&&i?[[`a`,V.t(`shell.hint`)]]:[],[j.esc,S]]});return J(F,{header:J(X,{children:[J(A,{type:`secondary`,children:[`>`,` `]}),q(X,{color:l.secondary,children:e.command}),q(X,{children:` `}),J(X,{color:m,children:[g,` `,h]})]}),footer:w,children:[(u||x>0)&&q(Y,{flexDirection:`row`,height:1,children:x>0?J(A,{type:`secondary`,dim:!0,children:[` `,V.t(`shell.moreLines`,{count:x})]}):q(X,{children:` `})}),b.map((e,t)=>q(Y,{flexDirection:`row`,children:q(X,{wrap:`truncate-end`,children:e===``?` `:e})},t))]})}function Zp(e){if(e.operation===`edit`){if(e.oldContent!=null&&e.newContent!=null)return fo(e.oldContent,e.newContent,2**53-1)}else if(e.operation===`delete`){if(e.oldContent!=null)return[{header:``,lines:e.oldContent.split(`
66
66
  `).map((e,t)=>({type:`remove`,content:e,oldLine:t+1}))}]}else if(e.operation===`write`&&e.newContent!=null)return[{header:``,lines:e.newContent.split(`
67
- `).map((e,t)=>({type:`add`,content:e,newLine:t+1}))}];return[]}function Qp({file:e,rows:t,columns:n=80,onDismiss:r,active:i=!0,resolveWholeFileDiff:o}){let s=R(),[c,l]=K(`diff`),[u,d]=K(0),[f,p]=K(Da()),m=G(i);W(()=>{m.current&&!i&&r(),m.current=i},[i,r]);let[h,g]=K({status:`idle`});W(()=>{if(f)return;let e=!0;return Ea().then(()=>{e&&p(Da())}),()=>{e=!1}},[f]),W(()=>{d(0)},[c,e.path]),W(()=>{g({status:`idle`})},[e.path]);let _=H.useRef(!1);W(()=>{_.current=!1},[e.path]),W(()=>{if(c!==`wholeFileDiff`||!o||_.current)return;_.current=!0;let t=!0;return g({status:`loading`}),o(e.path,e.operation).then(e=>{t&&g(e.error?{status:`error`,message:e.error}:{status:`ready`,oldContent:e.oldContent,newContent:e.newContent})}).catch(e=>{t&&g({status:`error`,message:e instanceof Error?e.message:String(e)})}),()=>{t=!1}},[c,e.path,e.operation,o]);let v=qt(()=>{if(c!==`full`)return[];let t=e.operation===`delete`?e.oldContent:e.newContent;return t==null?[]:_c(e.path,t,n,f)},[e,f,c,n]),y=v[Math.min(u,Math.max(0,v.length-1))],b=qt(()=>{if(c!==`wholeFileDiff`||h.status!==`ready`)return[];let{oldContent:e,newContent:t}=h;return e!=null&&t!=null?fo(e,t,2**53-1,2**53-1):e==null&&t!=null?[{header:``,lines:t.split(`
67
+ `).map((e,t)=>({type:`add`,content:e,newLine:t+1}))}];return[]}function Qp({file:e,rows:t,columns:n=80,onDismiss:r,active:i=!0,resolveWholeFileDiff:o}){let s=R(),[c,l]=K(`diff`),[u,d]=K(0),[f,p]=K(Da()),m=G(i);W(()=>{m.current&&!i&&r(),m.current=i},[i,r]);let[h,g]=K({status:`idle`});W(()=>{if(f)return;let e=!0;return Ea().then(()=>{e&&p(Da())}),()=>{e=!1}},[f]),W(()=>{d(0)},[c,e.path]),W(()=>{g({status:`idle`})},[e.path]);let _=H.useRef(!1);W(()=>{_.current=!1},[e.path]),W(()=>{if(c!==`wholeFileDiff`&&c!==`full`||!o||_.current)return;_.current=!0;let t=!0;return g({status:`loading`}),o(e.path,e.operation).then(e=>{t&&g(e.error?{status:`error`,message:e.error}:{status:`ready`,oldContent:e.oldContent,newContent:e.newContent})}).catch(e=>{t&&g({status:`error`,message:e instanceof Error?e.message:String(e)})}),()=>{t=!1}},[c,e.path,e.operation,o]);let v=qt(()=>{let t=e.operation===`delete`?e.oldContent:e.newContent;return h.status===`ready`?e.operation===`delete`?h.oldContent??t:h.newContent??t:t},[e,h]),y=qt(()=>c!==`full`||v==null?[]:_c(e.path,v,n,f),[e.path,f,c,n,v]),b=y[Math.min(u,Math.max(0,y.length-1))],x=qt(()=>{if(c!==`wholeFileDiff`||h.status!==`ready`)return[];let{oldContent:e,newContent:t}=h;return e!=null&&t!=null?fo(e,t,2**53-1,2**53-1):e==null&&t!=null?[{header:``,lines:t.split(`
68
68
  `).map((e,t)=>({type:`add`,content:e,newLine:t+1}))}]:e!=null&&t==null?[{header:``,lines:e.split(`
69
- `).map((e,t)=>({type:`remove`,content:e,oldLine:t+1}))}]:[]},[c,h]),x=qt(()=>{if(c===`full`)return y?.lines??[];if(c===`wholeFileDiff`){let t=b.reduce((e,t)=>e+t.lines.length,0),n=Zs(e.path);return ec(b,f&&n!==``&&t<=2e3?{highlight:Oa,lang:n}:{})}let t=Zp(e),n=t.reduce((e,t)=>e+t.lines.length,0),r=Zs(e.path);return ec(t,f&&r!==``&&n<=2e3?{highlight:Oa,lang:r}:{})},[e,f,c,y,b]),S=c===`full`?y?.wrapMode??`truncate`:`truncate`,C=(e.operation===`delete`?e.oldContent:e.newContent)!=null,w=o!=null,T=Gt(()=>{l(e=>e===`diff`?w?`wholeFileDiff`:C?`full`:`diff`:e===`wholeFileDiff`&&C?`full`:`diff`)},[w,C]),E=w||C,D=V.t(`diff.fileOpLabel`,{context:e.operation}),ee=e.operation===`edit`?s.accent:e.operation===`write`?s.success:s.error,te=c===`wholeFileDiff`?h.status===`loading`?V.t(`diff.loading`):h.status===`error`?V.t(`diff.error`,{message:h.message}):void 0:e.oldContent==null&&e.newContent==null&&(e.addedLines>0||e.removedLines>0)?V.t(`common.contentUnavailable`):void 0,O=qt(()=>c!==`wholeFileDiff`||h.status!==`ready`?null:po(b),[c,h.status,b]),ne=(a()?.currentPath??`/`).endsWith(`/find`),k=e=>{let t=z();t&&(e&&!t.currentPath.endsWith(`/find`)?t.navigate(t.currentPath+`/find`):!e&&t.currentPath.endsWith(`/find`)&&t.goBack())};return q(sc,{lines:x,rows:t,header:J(Y,{children:[q(X,{color:ee,bold:!0,children:D}),J(X,{color:s.text,children:[` `,e.path]}),c===`wholeFileDiff`?q(Je,{leadingSpace:!0,children:V.t(`diff.modeLabel`)}):c===`full`&&v.length>1&&y?q(Je,{leadingSpace:!0,children:y.label}):null,J(A,{type:`secondary`,children:[` `,V.t(`diff.linesTotalLabel`,{count:x.length}),c===`wholeFileDiff`&&O?J(Jt,{children:[O.added>0&&` +${O.added}`,O.removed>0&&` -${O.removed}`,` `,`(`,V.t(`diff.modeLabel`),`)`]}):J(Jt,{children:[e.addedLines>0&&` +${e.addedLines}`,e.removedLines>0&&` -${e.removedLines}`]})]})]}),onDismiss:r,onKey:(e,t)=>e===`f`&&E?(T(),!0):e===`]`&&c===`full`&&v.length>1?(d(e=>(e+1)%v.length),!0):!1,initialScroll:`bottom`,emptyMessage:te,active:i,contentKey:`${e.path}:${c}:${y?.id??``}:${h.status}`,columns:n,wrapMode:c===`full`?S:`truncate`,extraHints:[...E?[[`f`,V.t(`hint.switch`)]]:[],...c===`full`&&v.length>1?[[`]`,V.t(`hint.tabSwitchOutput`)]]:[],[j.tab,V.t(`hint.tabFocus`)]],findActive:ne,onFindModeChange:k})}function $p({tasks:e,rows:t,onDismiss:n}){let r=R(),i=qt(()=>e.filter(e=>(e.type??`process`)===`process`&&e.status===`running`&&e.detectedService),[e]),[a,o]=K(0),s=Math.max(3,t-6),c=Math.max(0,i.length-s),l=Math.min(a,c),u=i.slice(l,l+s),d=i.length===0;return T({tabIndex:0,id:`services-dialog`,onEscape:()=>(n(),!0)}),Md(e=>o(t=>Math.min(c,Math.max(0,t-e))),[c]),D(`services-dialog`,(e,t)=>t.escape?(n(),!0):t.upArrow?(o(e=>Math.max(0,e-1)),!0):t.downArrow?(o(e=>Math.min(c,e+1)),!0):t.pageUp?(o(e=>Math.max(0,e-s)),!0):t.pageDown?(o(e=>Math.min(c,e+s)),!0):e===`g`&&!t.ctrl&&!t.meta?(o(0),!0):e===`G`&&!t.ctrl&&!t.meta?(o(c),!0):!1),q(F,{header:q(_e,{children:V.t(`service.sTitle`)}),footer:q(C,{items:[[`${j.up}${j.down}/g/G`,V.t(`hint.scroll`)],[j.esc,V.t(`hint.close`)]]}),children:d?q(Y,{marginTop:I.tight,children:q(A,{type:`secondary`,dim:!0,children:V.t(`service.sEmpty`)})}):J(Y,{flexDirection:`column`,children:[q(Y,{height:1,children:l>0?q(g,{hasMore:!0,count:l}):q(X,{children:` `})}),u.map((e,t)=>{let n=e.detectedService,i=n.url?n.url.replace(/^https?:\/\//,``).replace(/^wss?:\/\//,``).replace(/\/$/,``):`:${n.port}`,a=n.protocol===`ws`?`ws`:n.protocol===`tcp`?`tcp`:`http`;return J(Y,{flexDirection:`column`,children:[J(Y,{flexDirection:`row`,children:[q(X,{color:r.accent,children:`↕ `}),q(X,{color:r.selection,children:i})]}),q(Y,{marginLeft:I.section,children:J(A,{type:`secondary`,dim:!0,children:[e.command,` · `,a,n.port?` · :${n.port}`:``]})})]},l+t)}),q(Y,{height:1,children:l+s<i.length?q(b,{hasMore:!0,count:i.length-l-s}):q(X,{children:` `})})]})})}function em({command:e,output:t,rows:n,columns:r,onDismiss:i,active:o=!0,isError:s=!1,onCopyOutput:c,onAskAi:l,scrollStore:u}){let d=G(o);W(()=>{d.current&&!o&&i(),d.current=o},[o,i]);let f=qt(()=>t.split(`
69
+ `).map((e,t)=>({type:`remove`,content:e,oldLine:t+1}))}]:[]},[c,h]),S=qt(()=>{if(c===`full`)return b?.lines??[];if(c===`wholeFileDiff`){let t=x.reduce((e,t)=>e+t.lines.length,0),n=Zs(e.path);return ec(x,f&&n!==``&&t<=2e3?{highlight:Oa,lang:n}:{})}let t=Zp(e),n=t.reduce((e,t)=>e+t.lines.length,0),r=Zs(e.path);return ec(t,f&&r!==``&&n<=2e3?{highlight:Oa,lang:r}:{})},[e,f,c,b,x]),C=c===`full`?b?.wrapMode??`truncate`:`truncate`,w=o!=null||(e.operation===`delete`?e.oldContent:e.newContent)!=null,T=o!=null,E=Gt(()=>{l(e=>e===`diff`?T?`wholeFileDiff`:w?`full`:`diff`:e===`wholeFileDiff`&&w?`full`:`diff`)},[T,w]),D=T||w,ee=V.t(`diff.fileOpLabel`,{context:e.operation}),te=e.operation===`edit`?s.accent:e.operation===`write`?s.success:s.error,O=c===`wholeFileDiff`?h.status===`loading`?V.t(`diff.loading`):h.status===`error`?V.t(`diff.error`,{message:h.message}):void 0:c===`full`&&v==null&&h.status===`error`?V.t(`diff.error`,{message:h.message}):v==null&&(e.addedLines>0||e.removedLines>0)?V.t(`common.contentUnavailable`):void 0,ne=qt(()=>c!==`wholeFileDiff`||h.status!==`ready`?null:po(x),[c,h.status,x]),k=(a()?.currentPath??`/`).endsWith(`/find`),re=e=>{let t=z();t&&(e&&!t.currentPath.endsWith(`/find`)?t.navigate(t.currentPath+`/find`):!e&&t.currentPath.endsWith(`/find`)&&t.goBack())};return q(sc,{lines:S,rows:t,header:J(Y,{children:[q(X,{color:te,bold:!0,children:ee}),J(X,{color:s.text,children:[` `,e.path]}),c===`wholeFileDiff`?q(Je,{leadingSpace:!0,children:V.t(`diff.modeLabel`)}):c===`full`&&y.length>1&&b?q(Je,{leadingSpace:!0,children:b.label}):null,J(A,{type:`secondary`,children:[` `,V.t(`diff.linesTotalLabel`,{count:S.length}),c===`wholeFileDiff`&&ne?J(Jt,{children:[ne.added>0&&` +${ne.added}`,ne.removed>0&&` -${ne.removed}`,` `,`(`,V.t(`diff.modeLabel`),`)`]}):J(Jt,{children:[e.addedLines>0&&` +${e.addedLines}`,e.removedLines>0&&` -${e.removedLines}`]})]})]}),onDismiss:r,onKey:(e,t)=>e===`f`&&D?(E(),!0):e===`]`&&c===`full`&&y.length>1?(d(e=>(e+1)%y.length),!0):!1,initialScroll:`bottom`,emptyMessage:O,active:i,contentKey:`${e.path}:${c}:${b?.id??``}:${h.status}`,columns:n,wrapMode:c===`full`?C:`truncate`,extraHints:[...D?[[`f`,V.t(`hint.switch`)]]:[],...c===`full`&&y.length>1?[[`]`,V.t(`hint.tabSwitchOutput`)]]:[],[j.tab,V.t(`hint.tabFocus`)]],findActive:k,onFindModeChange:re})}function $p({tasks:e,rows:t,onDismiss:n}){let r=R(),i=qt(()=>e.filter(e=>(e.type??`process`)===`process`&&e.status===`running`&&e.detectedService),[e]),[a,o]=K(0),s=Math.max(3,t-6),c=Math.max(0,i.length-s),l=Math.min(a,c),u=i.slice(l,l+s),d=i.length===0;return T({tabIndex:0,id:`services-dialog`,onEscape:()=>(n(),!0)}),Md(e=>o(t=>Math.min(c,Math.max(0,t-e))),[c]),D(`services-dialog`,(e,t)=>t.escape?(n(),!0):t.upArrow?(o(e=>Math.max(0,e-1)),!0):t.downArrow?(o(e=>Math.min(c,e+1)),!0):t.pageUp?(o(e=>Math.max(0,e-s)),!0):t.pageDown?(o(e=>Math.min(c,e+s)),!0):e===`g`&&!t.ctrl&&!t.meta?(o(0),!0):e===`G`&&!t.ctrl&&!t.meta?(o(c),!0):!1),q(F,{header:q(_e,{children:V.t(`service.sTitle`)}),footer:q(C,{items:[[`${j.up}${j.down}/g/G`,V.t(`hint.scroll`)],[j.esc,V.t(`hint.close`)]]}),children:d?q(Y,{marginTop:I.tight,children:q(A,{type:`secondary`,dim:!0,children:V.t(`service.sEmpty`)})}):J(Y,{flexDirection:`column`,children:[q(Y,{height:1,children:l>0?q(g,{hasMore:!0,count:l}):q(X,{children:` `})}),u.map((e,t)=>{let n=e.detectedService,i=n.url?n.url.replace(/^https?:\/\//,``).replace(/^wss?:\/\//,``).replace(/\/$/,``):`:${n.port}`,a=n.protocol===`ws`?`ws`:n.protocol===`tcp`?`tcp`:`http`;return J(Y,{flexDirection:`column`,children:[J(Y,{flexDirection:`row`,children:[q(X,{color:r.accent,children:`↕ `}),q(X,{color:r.selection,children:i})]}),q(Y,{marginLeft:I.section,children:J(A,{type:`secondary`,dim:!0,children:[e.command,` · `,a,n.port?` · :${n.port}`:``]})})]},l+t)}),q(Y,{height:1,children:l+s<i.length?q(b,{hasMore:!0,count:i.length-l-s}):q(X,{children:` `})})]})})}function em({command:e,output:t,rows:n,columns:r,onDismiss:i,active:o=!0,isError:s=!1,onCopyOutput:c,onAskAi:l,scrollStore:u}){let d=G(o);W(()=>{d.current&&!o&&i(),d.current=o},[o,i]);let f=qt(()=>t.split(`
70
70
  `),[t]),p=(e,t)=>e===`c`&&!t.ctrl&&!t.meta&&c?(c(),!0):e===`a`&&!t.ctrl&&!t.meta&&s&&l?(l(),!0):!1,m=[...c?[[`c`,V.t(`shell.copyHint`)]]:[],...s&&l?[[`a`,V.t(`shell.hint`)]]:[]],h=(a()?.currentPath??`/`)===`/viewer/shell-output/find`;return q(sc,{lines:f,rows:n,columns:r,wrapMode:`truncate`,scrollStore:u,header:J(Y,{flexDirection:`row`,justifyContent:`space-between`,children:[J(_e,{children:[`>`,` `,e]}),q(X,{dimColor:!0,children:V.t(`diff.linesTotalLabel`,{count:f.length})})]}),onDismiss:i,onKey:p,extraHints:m.length>0?m:void 0,initialScroll:`top`,active:o,contentKey:e,findActive:h,onFindModeChange:e=>{let t=z();t&&(e&&t.currentPath===`/viewer/shell-output`?t.navigate(`/viewer/shell-output/find`):!e&&t.currentPath===`/viewer/shell-output/find`&&t.goBack())}})}function tm(e){let t=pu(),{stdout:n}=nn(),{currentPath:r,stack:i,dismiss:a}=me(),o=e=>i.some(t=>t.path===e),{taskStore:s}=eu(),c=Z(s.store,e=>e.backgroundOutput),l=Z(s.store,e=>e.editedFiles),u=Z(s.store,e=>e.backgroundTasks),{columns:d,rows:f,fullScreenPaneActive:p,shellFullOutput:m,shellExecution:h,setShellFullOutput:g,editedFileFullIndex:_,closeEditedFileFull:v,resolveWholeFileDiff:y}=e;return J(Jt,{children:[!p&&!m&&h&&q(Xp,{exec:h,totalLines:h.output.split(`
71
71
  `).length,columns:d,onCopyOutput:t.onShellCopyOutput,onAskAi:t.onShellAskAi,onAbort:t.onShellAbort,onDismiss:t.onShellDismiss,onViewFullOutput:g,active:r===`/pane/shell`}),c&&q(Qd,{view:c,columns:d,rows:n?.rows,active:r===`/pane/delegates/output`,onDismiss:t.onBackgroundOutputClose}),_!==null&&_<l.length&&q(Qp,{file:l[_],rows:n?.rows??f,columns:d,onDismiss:v,active:r.startsWith(`/pane/edited-files/`),resolveWholeFileDiff:y}),o(`/overlay/services`)&&q(E,{path:`/overlay/services`,inStack:!0,element:q($p,{tasks:u,columns:d,rows:n?.rows??f,onDismiss:()=>{a(`/overlay/services`)}})}),m&&q(em,{command:m.command,output:m.output,rows:n?.rows??f,columns:d,onDismiss:()=>g(null),active:r===`/viewer/shell-output`,scrollStore:e.scrollStore,isError:m.isError,onCopyOutput:t.onShellCopyOutput,onAskAi:t.onShellAskAi?()=>{t.onShellAskAi?.(),g(null),t.onShellDismiss?.()}:void 0})]})}function nm(e,t){switch(e){case`healthy`:return t.accent;case`warning`:return t.warning;case`critical`:return t.error}}function rm(e){return`${(e/1024/1024).toFixed(1)}MB`}function im({memory:e,history:t}){let n=R();return e?J(Y,{flexDirection:`column`,children:[J(Y,{children:[q(X,{color:nm(e.level,n),bold:!0,children:e.level}),J(A,{type:`secondary`,children:[` `,e.usedPct.toFixed(1),`%`]}),t.length>=2&&J(A,{type:`secondary`,children:[` `,fa(t,20)]})]}),J(A,{type:`secondary`,children:[rm(e.heapUsed),` / `,rm(e.heapSizeLimit),` heap`]})]}):q(A,{type:`secondary`,children:`collecting…`})}function am({notify:e}){let t=R();if(!e)return q(A,{type:`secondary`,dim:!0,children:`渲染数据将在 M2 接入`});let n=e.coalescedCalls===0,r=n?`idle`:e.alert;return J(Y,{flexDirection:`column`,children:[J(Y,{children:[q(X,{color:n?t.inactive:e.alert===`warning`?t.warning:t.accent,bold:!0,children:r}),J(A,{type:`secondary`,children:[` `,e.coalesceRatio.toFixed(1),`x merge`]})]}),J(A,{type:`secondary`,children:[`coalesced `,e.coalescedCalls,`→`,e.coalescedFires,` · direct `,e.immediateCalls,` · flush `,e.flushFires]})]})}function om(e){let t=typeof e==`string`?e:JSON.stringify(e);return t===void 0?`undefined`:P(t,121)}function sm({metrics:e,maxRows:t=1/0}){let n=R();if(e.length===0)return null;let r=e.slice(0,t),i=e.length-r.length;return J(Y,{flexDirection:`column`,children:[q(Y,{marginTop:I.loose,marginBottom:I.tight,children:q(A,{type:`secondary`,bold:!0,children:`Plugins`})}),r.map(e=>J(Y,{flexDirection:`row`,children:[q(X,{color:n.suggestion,children:e.label}),q(A,{type:`secondary`,children:` `}),e.error?J(X,{color:n.error,children:[`error: `,e.error]}):q(A,{type:`secondary`,children:om(e.value)})]},e.id)),i>0&&J(A,{type:`secondary`,dim:!0,children:[` `,i,` more`]})]})}function cm({perfStore:e,onDismiss:t,onRefresh:n,rows:r=24}){let i=R(),o=Z(e.store,e=>e),s=a();return D(`perf-panel`,(e,r)=>{if(r.escape){t();return}e===`r`&&n()},{isActive:s?s.currentPath===`/pane/perf`:!0}),q(F,{header:q(X,{color:i.secondary,bold:!0,children:`Performance`}),footer:q(C,{items:[[j.esc,V.t(`hint.close`)],[`r`,V.t(`hint.refresh`)],[j.tab,V.t(`hint.tabFocus`)]]}),children:J(Y,{marginTop:I.tight,flexDirection:`column`,children:[q(Y,{marginBottom:I.tight,children:q(A,{type:`secondary`,bold:!0,children:`Memory`})}),q(im,{memory:o.memory,history:o.memoryHistory}),q(Y,{marginTop:I.loose,marginBottom:I.tight,children:q(A,{type:`secondary`,bold:!0,children:`Rendering`})}),q(am,{notify:o.notify}),q(sm,{metrics:o.pluginMetrics,maxRows:Ye(9+o.pluginMetrics.length+7,r)-9-7})]})})}function lm(e,t,n,r){let i=Math.max(0,n-r);return e.upArrow?Math.max(0,t-1):e.downArrow?Math.min(i,t+1):e.pageUp?Math.max(0,t-r):e.pageDown?Math.min(i,t+r):null}function um({children:e,visibleRows:t,offset:n,showHint:r=!0,onScroll:i}){let a=qt(()=>H.Children.toArray(e),[e]),o=la();W(()=>{if(!(!o||!i))return o.registerWheel(e=>{i(oa(n,e,a.length,t))})},[o,i,a.length,t]);let s=a.length>t,c=s&&r?Math.max(1,t-1):t,l=ia(a.length,c,n);return J(Y,{flexDirection:`column`,children:[a.slice(l.start,l.end),s&&r&&q(A,{type:`secondary`,children:l.below>0?` ↓ ${l.below} more${l.above>0?` · ↑ ${l.above}`:``}`:` ↑ ${l.above} above`})]})}function dm(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(1)}m`}function fm(e,t){return e>=80?t.accent:e>=40?t.warning:t.error}function pm({ratio:e,width:t}){let n=R(),r=Math.max(0,Math.min(100,Math.round(e*100))),i=Math.min(24,Math.max(8,t-20)),a=fm(r,n);return J(Y,{children:[J(X,{color:a,bold:!0,children:[String(r).padStart(3),`%`,` `]}),q(Ge,{percent:r,width:i,chars:`block`,color:a,labelPosition:`none`})]})}function mm({label:e}){return J(A,{type:`secondary`,dim:!0,children:[e,`: n/a(供应商未报告缓存数据)`]})}function hm({row:e,width:t}){let n=R(),r=e.cacheReadTokens+e.cacheWriteTokens+e.inputTokens,i=e.hitRatio===null?`n/a`:`${Math.round(e.hitRatio*100)}%`,a=e.hitRatio===null?n.inactive:fm(Math.round(e.hitRatio*100),n),o=`${e.modelName} read ${dm(e.cacheReadTokens)} · write ${dm(e.cacheWriteTokens)} · total ${dm(r)}`;return J(Y,{justifyContent:`space-between`,children:[q(X,{color:n.suggestion,children:P(o,t-8)}),q(X,{color:a,bold:e.hitRatio!==null,children:i})]})}function gm({view:e,width:t,colors:n}){if(!e)return[q(A,{type:`secondary`,children:`collecting…`},`collecting`)];if(!(e.totalCacheReadTokens+e.totalCacheWriteTokens+e.totalInputTokens>0))return[q(A,{type:`secondary`,children:`本会话暂无缓存用量数据`},`nodata`)];let r=[];if(r.push(q(A,{type:`secondary`,bold:!0,children:`Session hit rate`},`h-session`)),r.push(e.sessionHitRatio===null?q(mm,{label:V.t(`cache.sessionLabel`)},`v-session`):q(pm,{ratio:e.sessionHitRatio,width:t},`v-session`)),r.push(q(Y,{},`gap-1`)),r.push(q(A,{type:`secondary`,bold:!0,children:`Last turn`},`h-last`)),r.push(e.lastTurnHitRatio===null?q(mm,{label:V.t(`cache.lastTurnLabel`)},`v-last`):q(pm,{ratio:e.lastTurnHitRatio,width:t},`v-last`)),r.push(q(Y,{},`gap-2`)),r.push(q(A,{type:`secondary`,children:`cache read ${dm(e.totalCacheReadTokens)} · cache write ${dm(e.totalCacheWriteTokens)} · input ${dm(e.totalInputTokens)}`},`totals`)),e.totalCostUSD!==void 0&&e.totalCostUSD>0&&r.push(q(X,{color:n.suggestion,children:`~$${e.totalCostUSD.toFixed(4)}`},`cost`)),e.perModel.length>1){r.push(q(Y,{},`gap-3`)),r.push(q(A,{type:`secondary`,bold:!0,children:`By model`},`h-model`));for(let n of e.perModel)r.push(q(hm,{row:n,width:t},n.modelId))}return r}function _m({cacheStore:e,onDismiss:t,rows:n=24}){let r=R(),i=Z(e.store,e=>e),[o,s]=K(0),c=gm({view:i.view,width:60,colors:r}),l=Math.max(1,u(n)-7),d=a();return D(`cache-panel`,(e,n)=>{if(n.escape){t();return}let r=lm(n,o,c.length,l);r!==null&&s(r)},{isActive:d?d.currentPath===`/pane/cache`:!0}),q(F,{header:q(X,{color:r.secondary,bold:!0,children:`Cache`}),footer:q(C,{items:[[j.esc,V.t(`hint.close`)],[j.tab,V.t(`hint.tabFocus`)]]}),children:q(Y,{marginTop:I.tight,flexDirection:`column`,children:q(um,{visibleRows:l,offset:o,onScroll:s,children:c})})})}function vm(e,t,n,r=[],i){let[a,o]=K(0),[s,c]=K(!1),l=e.length+r.length,u=l>0?Math.min(a,l-1):0,d=u>=e.length,f=e=>{if(e.kind===`input`){c(!0),t({kind:`input`,title:e.title??e.label,placeholder:e.placeholder,mask:e.mask}).then(t=>{t!=null&&t.trim()&&n(e.id,t.trim())}).finally(()=>c(!1));return}if(e.kind===`switch`){n(e.id,!e.value);return}if(e.kind===`select`){c(!0),t({kind:`select`,title:e.title??e.label,options:e.options,onSelect:t=>{c(!1),n(e.id,t)},onCancel:()=>c(!1)});return}};return{selectedIndex:u,editing:s,handleKey:(t,n)=>{if(s||l===0)return!1;if(Me(`list-nav-up`,t,n))return o(e=>(e-1+l)%l),!0;if(Me(`list-nav-down`,t,n))return o(e=>(e+1)%l),!0;if(n.return){if(d){let t=r[u-e.length];return t&&i?.(t.id),!0}let t=e[u];return t&&f(t),!0}return!1},isTrailingSelected:d}}function ym({field:e,selected:t,emptyLabel:n=`未设置`}){let r=R(),i=t?Nt():wt(),a=t?r.selection:void 0;if(e.kind===`switch`){let n=e.value?L.statusDot:L.toggleOff,o=e.value?e.onLabel??`已启用`:e.offLabel??`已停用`,s=e.value?r.accent:r.inactive;return J(X,{children:[J(X,{color:a,bold:t,children:[i,e.label]}),q(X,{color:r.inactive,children:` `}),J(X,{color:s,children:[n,` `,o]})]})}let o=e.value?e.value:n;return J(X,{children:[J(X,{color:a,bold:t,children:[i,e.label]}),q(X,{color:r.inactive,children:` `}),q(X,{color:r.inactive,dimColor:!e.value,children:o})]})}function bm(e){try{let t=new URL(e);return t.password?e.replace(`:${t.password}@`,`:••••@`):e}catch{return e}}function xm({view:e,onDismiss:t,onOpenModal:n,onSubmitUrl:r,onToggleEnabled:i,onClear:a,onTest:o,rows:s=24}){let c=R(),l=e.url?e.enabled===!1?`disabled`:`enabled`:`unconfigured`,d=e.url?[{kind:`input`,id:`url`,label:V.t(`proxy.fieldUrl`),value:bm(e.url),title:V.t(`proxy.dialogEditUrl`),placeholder:V.t(`proxy.urlPlaceholder`)},{kind:`switch`,id:`enabled`,label:V.t(`proxy.fieldEnabled`),value:l===`enabled`,onLabel:V.t(`proxy.stateEnabled`),offLabel:V.t(`proxy.stateDisabled`)}]:[{kind:`input`,id:`url`,label:V.t(`proxy.fieldUrl`),value:``,title:V.t(`proxy.dialogSetUrl`),placeholder:V.t(`proxy.urlPlaceholder`)}],f=(e,t)=>{e===`url`&&typeof t==`string`&&r(t),e===`enabled`&&typeof t==`boolean`&&i()},p=l!==`unconfigured`,m=l===`unconfigured`?e.detectedEnvProxy:void 0,h=[...m?[{id:`adopt-env`,label:V.t(`proxy.actionAdoptEnv`,{value:bm(m.value),source:m.source})}]:[],...p&&o?[{id:`test`,label:V.t(`proxy.actionTest`)}]:[],...p?[{id:`clear`,label:V.t(`proxy.actionClear`)}]:[]],[g,_]=K(!1),v=()=>{_(!0),n({kind:`confirm`,title:V.t(`proxy.clearTitle`),message:V.t(`proxy.clearMessage`,{url:e.url??``}),confirmLabel:V.t(`proxy.clearConfirm`),confirmColor:`red`,dangerous:!0,onConfirm:()=>{_(!1),a()},onCancel:()=>_(!1)})},{selectedIndex:y,editing:b,handleKey:x,isTrailingSelected:S}=vm(d,n,f,h,e=>{e===`clear`&&v(),e===`test`&&o?.(),e===`adopt-env`&&m&&r(m.value)}),w=b||g,T=Math.max(1,u(s)-7),E=1+(S?d.length:y),ee=Math.max(0,E-T+2),te=e.url&&e.enabled!==!1?e.url:void 0,O=e.effectiveUrl!==te,ne=e.probe,k=null;ne&&ne.status!==`idle`?k=ne.status===`probing`?q(A,{type:`secondary`,children:V.t(`proxy.probeProbing`)},`note`):ne.status===`ok`?J(X,{color:c.success,children:[L.check,` `,V.t(`proxy.probeOk`,{latency:ne.latencyMs,target:ne.target})]},`note`):J(X,{color:ne.blamesProxy?c.error:c.warning,children:[L.cross,` `,V.t(ne.blamesProxy?`proxy.probeFailedProxy`:`proxy.probeFailedTarget`,{reason:ne.reason})]},`note`):l!==`unconfigured`&&O&&(k=J(X,{color:c.warning,children:[L.warn,` `,e.effectiveUrl?V.t(`proxy.effectiveMismatch`,{effective:bm(e.effectiveUrl)}):V.t(`proxy.effectiveNotApplied`)]},`note`));let re=la();return W(()=>{if(re)return re.registerWheel(e=>{if(w)return;let t=Math.abs(e)*3,n={upArrow:e>0,downArrow:e<0};for(let e=0;e<t;e++)x(``,n)})},[re,w,x]),D(`proxy-pane`,(e,n)=>{if(n.escape){t();return}x(e,n)},{isActive:!w}),q(F,{header:q(X,{color:c.secondary,bold:!0,children:V.t(`proxy.title`)}),footer:w?void 0:q(C,{items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.enter,V.t(`hint.execute`)],[j.esc,V.t(`hint.close`)]]}),children:q(Y,{marginTop:I.tight,flexDirection:`column`,children:J(um,{visibleRows:T,offset:ee,children:[q(De,{label:V.t(`proxy.groupConfig`),indent:``},`h-config`),d.map((e,t)=>q(ym,{field:e,selected:!w&&t===y,emptyLabel:V.t(`proxy.urlEmpty`)},e.id)),h.map((e,t)=>{let n=S&&!w&&y-d.length===t,r=e.id===`clear`?c.error:void 0;return J(X,{color:n?c.selection:r,bold:n,children:[n?Nt():wt(),e.label]},e.id)}),k,q(X,{children:` `},`gap`),q(De,{label:V.t(`proxy.groupAbout`),indent:``},`h-about`),q(A,{type:`secondary`,children:V.t(`proxy.aboutScope`)},`d1`),q(A,{type:`secondary`,children:V.t(`proxy.aboutLoopback`)},`d2`),q(A,{type:`secondary`,children:V.t(`proxy.aboutStorage`,{path:e.configPath})},`d3`),q(A,{type:`secondary`,dim:!0,children:V.t(`proxy.aboutCommand`)},`d4`)]})})})}function Sm(e){let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}:${String(t.getSeconds()).padStart(2,`0`)}`}function Cm(e){switch(e.kind){case`compact`:{let t=e.before&&e.before>0?Math.round((e.after??0)/e.before*100):0;return V.t(`compact.logCompactRow`,{before:e.before??0,after:e.after??0,pct:t})}case`prune`:return e.prunedCount===void 0?V.t(`compact.logPruneRow`,{tokensSaved:e.tokensSaved??0}):V.t(`compact.logPruneRow`,{context:`pruned`,count:e.prunedCount,tokensSaved:e.tokensSaved??0});case`history_capped`:return V.t(`compact.logHistoryCappedRow`,{count:e.removedCount??0})}}const wm={compact:`compact`,prune:`prune`,history_capped:`history`};function Tm({entry:e}){return e.kind===`compact`?J(Y,{flexDirection:`column`,children:[q(A,{type:`secondary`,children:Cm(e)}),q(Y,{marginTop:I.tight,children:e.summary?q(X,{children:e.summary}):q(A,{type:`secondary`,dim:!0,children:V.t(`compact.logNoSummary`)})})]}):q(A,{type:`secondary`,children:Cm(e)})}function Em({entries:e,onClose:t,rows:n=24}){let r=R(),[i,o]=ra(`compactionLog`,e.length),s=a(),c=s?.currentPath??`/`,l=s?c.startsWith(`/pane/compaction-log`):!0,u=c.match(/^\/pane\/compaction-log\/(\d+)$/),d=u?Number(u[1]):null,f=e=>{let t=z();t&&(e==null?t.currentPath.startsWith(`/pane/compaction-log/`)&&t.goBack():t.navigate(`/pane/compaction-log/${e}`))},p=e.length===0?0:Math.min(i,e.length-1),m=d==null?void 0:e.find(e=>e.id===d),h=G(0),g=Ct(e,p,Ye(e.length+7,n)-7,h.current);return h.current=g.scrollTop,D(`compaction-log-dialog`,Gt((n,r)=>{if(r.escape){m?f(null):t();return}if(!m){if(Me(`list-nav-up`,n,r)){o(t=>e.length===0?0:(t-1+e.length)%e.length);return}if(Me(`list-nav-down`,n,r)){o(t=>e.length===0?0:(t+1)%e.length);return}if(r.return){let t=e[p];t&&f(t.id)}}},[m,e,p,t]),{isActive:l}),m?q(F,{header:q(X,{color:r.secondary,bold:!0,children:V.t(`compact.logDetailTitle`,{kind:wm[m.kind],time:Sm(m.timestamp)})}),footer:q(C,{items:[[j.esc,V.t(`hint.cancel`)]]}),children:q(Y,{marginTop:I.tight,flexDirection:`column`,children:q(Tm,{entry:m})})}):q(F,{header:q(X,{color:r.secondary,bold:!0,children:V.t(`compact.logTitle`)}),footer:q(C,{items:[[`${j.up}${j.down}`,V.t(`hint.select`)],[j.enter,V.t(`compact.logViewSummary`)],[j.esc,V.t(`hint.cancel`)],[j.tab,V.t(`hint.tabFocus`)]]}),children:J(Y,{marginTop:I.tight,flexDirection:`column`,children:[e.length===0?q(A,{type:`secondary`,dim:!0,children:V.t(`compact.logEmpty`)}):g.rows.map((e,t)=>{let n=g.scrollTop+t===p;return q(Y,{flexDirection:`row`,children:J(X,{color:n?r.selection:r.inactive,bold:n,children:[n?Nt():wt(),Sm(e.timestamp),` `,wm[e.kind].padEnd(8),` `,Cm(e)]})},e.id)}),g.fillerCount>0&&Array.from({length:g.fillerCount},(e,t)=>q(X,{children:` `},`filler-${t}`))]})})}function Dm({checked:e,onChange:t,label:n,tabIndex:r=0,disabled:i=!1}){let a=R(),{focused:o}=T({tabIndex:r,disabled:i});y(o,(n,r)=>n===` `?(t(!e),!0):!1);let s=e?L.check:L.todoPending;return J(X,{color:o?a.selection:e?a.success:a.inactive,children:[o?Nt():wt(),s,` `,n]})}function Om({options:e,selected:t,onSelect:n,onPick:r,escapeIndex:a,tabIndex:o=0}){return U(i.Root,{onPick:r,activeIndex:t,onActiveChange:n,escapeIndex:a,tabIndex:o,id:`choices-${e.map(e=>e.key).join(`-`)}`},...e.map(e=>U(i.Item,{key:e.key,label:e.label,color:e.color,shortcut:e.shortcut})))}const km=[`good`,`neutral`,`bad`];function Am(e){switch(e){case`good`:return V.t(`pulse.ratingGood`);case`neutral`:return V.t(`pulse.ratingNeutral`);case`bad`:return V.t(`pulse.ratingBad`)}}function jm({item:e,columns:t=60,onChange:n}){if(T({tabIndex:0,id:`pulse-survey-overlay`,onEscape:()=>{if(e.phase===`rating`)return!1;let t=e.rating??`good`,n=e.commentText.length>0?e.commentText:void 0;return e.onSubmit(t,n),e.onClose(),!0}}),D(`pulse-survey-overlay`,(r,i)=>{if(e.phase===`rating`)return i.escape?(e.onClose(),!0):!1;let a=e.rating??`good`,o=()=>{let t=e.commentText.length>0?e.commentText:void 0;e.onSubmit(a,t),e.onClose()};if(i.return||i.escape)return o(),!0;if(i.leftArrow){let r=l.fromText(e.commentText,t,e.commentOffset).left();return n?.({commentText:r.text,commentOffset:r.offset}),!0}if(i.rightArrow){let r=l.fromText(e.commentText,t,e.commentOffset).right();return n?.({commentText:r.text,commentOffset:r.offset}),!0}if(r.length>1&&!i.ctrl&&!i.meta&&!i.backspace&&!i.delete&&!i.tab&&!i.upArrow&&!i.downArrow){let t=ke(r);return t&&n?.({commentText:e.commentText.slice(0,e.commentOffset)+t+e.commentText.slice(e.commentOffset),commentOffset:e.commentOffset+t.length}),!0}let s={name:i.backspace?`backspace`:i.delete?`delete`:i.tab?`tab`:r||`unknown`,ctrl:i.ctrl??!1,shift:!1,alt:i.meta??!1,meta:i.meta??!1},c=Tt(l.fromText(e.commentText,t,e.commentOffset),s);return c?c.action===`submit`||c.action===`submit_force`?(o(),!0):(n?.({commentText:c.cursor.text,commentOffset:c.cursor.offset}),!0):!1}),e.phase===`rating`){let t=km.map(e=>({key:e,label:Am(e)}));return q(F,{header:q(_e,{children:V.t(`pulse.title`)}),footer:q(X,{children:V.t(`pulse.hintRating`)}),children:q(Y,{marginTop:I.tight,children:q(Om,{options:t,selected:e.selectedIndex,onSelect:e=>n?.({selectedIndex:e}),onPick:r=>{if(r>=t.length){e.onClose();return}n?.({phase:`comment`,rating:km[r]??`good`})},escapeIndex:t.length})})})}return q(F,{header:q(_e,{children:e.rating?V.t(`pulse.commentTitle`,{ratingLabel:Am(e.rating)}):V.t(`pulse.title`)}),footer:q(X,{children:V.t(`pulse.hintComment`)}),children:q(Y,{marginTop:I.tight,flexDirection:`row`,children:q(dt,{value:e.commentText,offset:e.commentOffset,columns:t,mode:`dialog`,placeholder:V.t(`pulse.commentPlaceholder`),focused:!0,physicalCursor:!0})})})}function Mm({enabledCount:e}){let t=R();return e===0?null:q(X,{color:t.accent,children:` * ${e} scheduled`})}function Nm({title:e,indent:t=I.section,titleIndent:n,children:r}){return J(Y,{flexDirection:`column`,children:[e!=null&&q(De,{label:e,indent:n}),q(Y,{marginLeft:t,flexDirection:`column`,children:r})]})}const Pm=Math.max(...Zu.map(e=>Math.max(Oe(e.en),Oe(e.zh))));function Fm({tip:e}){let{resolvedTheme:t}=gt();if(!e)return null;let n=V.t(`welcome.tipLabel`),r=Oe(n)+1+Pm+I.tight*2,i=Oe(e),a=i<Pm?e+` `.repeat(Pm-i):e,o=(t===`light`?rd:nd)[ld(0)],s=ud(r,0,t);return J(Y,{flexDirection:`column`,alignSelf:`flex-start`,children:[J(Y,{flexDirection:`row`,children:[q(X,{color:o,children:`╭`}),s.map((e,t)=>q(X,{color:e,children:`─`},t)),q(X,{color:o,children:`╮`})]}),J(Y,{flexDirection:`row`,children:[q(X,{color:o,children:`│`}),J(Y,{flexDirection:`row`,paddingX:I.tight,children:[J(A,{type:`accent`,children:[n,` `]}),q(A,{type:`secondary`,children:a})]}),q(X,{color:o,children:`│`})]}),J(Y,{flexDirection:`row`,children:[q(X,{color:o,children:`╰`}),s.map((e,t)=>q(X,{color:e,children:`─`},t)),q(X,{color:o,children:`╯`})]})]})}const Im={pointer:L.pointer,check:L.check,cross:L.cross,bullet:L.bullet,todoPending:L.todoPending,todoActive:L.todoActive,todoDone:L.todoDone,toggleOn:L.toggleOn,toggleOff:L.toggleOff,statusDot:L.statusDot,warn:L.warn,ellipsis:L.ellipsis};function Lm(e,t){if(e)return t[e]}function Rm({name:e,color:t,bold:n,dim:r,trailingSpace:i}){return J(X,{color:Lm(t,R()),bold:n,dimColor:r,children:[Im[e],i?` `:``]})}function zm(e){let t=new Date,n=e=>String(e).padStart(2,`0`),r=`${n(t.getHours())}:${n(t.getMinutes())}`;return e?`${r}:${n(t.getSeconds())}`:r}function Bm({color:e,dimColor:t=!0,showSeconds:n=!1}){let r=R(),[i,a]=K(()=>zm(n));return W(()=>{let e=setInterval(()=>{a(zm(n))},n?1e3:3e4);return()=>clearInterval(e)},[n]),q(X,{color:e??r.inactive,dimColor:t,children:i})}function Vm({level:e,usedPct:t}){let n=R();return e===`healthy`?q(Y,{}):q(Y,{flexDirection:`row`,children:J(X,{color:e===`critical`?n.error:n.warning,children:[` `,`<mem`,e===`critical`?`!!`:`!`,t===void 0?``:` ${Math.round(t)}%`,`> `]})})}function Hm({count:e,hasUrgent:t}){let n=R();return e===0?q(Y,{}):q(Y,{flexDirection:`row`,children:J(X,{color:t?n.warning:n.accent,children:[` [`,e,`!]`]})})}const Um=3500;function Wm({toast:e,onDismiss:t}){return T({tabIndex:0,id:`toast`,onEscape:()=>(t?.(),!0),onAction:()=>(t?.(),!0)}),D(`toast`,(e,n)=>n.ctrl?!1:(t?.(),!0)),q(F,{header:q(_e,{children:e.title}),footer:q(C,{items:[[j.esc,V.t(`hint.close`)]]}),children:q(Y,{marginTop:I.tight,children:q(X,{children:e.content})})})}function Gm(e,t=10,n){let r=Math.max(1,Math.floor(t)),i=se({percent:e,width:r}),a=i.pct,o=i.filledCount,s=a>=90?k.error:a>=80?k.warning:k.suggestion,c=n?.prune!==void 0&&Number.isFinite(n.prune)?Math.max(0,Math.min(r-1,Math.round(n.prune/100*r))):null,l=n?.compact!==void 0&&Number.isFinite(n.compact)?Math.max(0,Math.min(r-1,Math.round(n.compact/100*r))):null,u=i.cells.map(e=>e.filled?`▰`:`▱`),d=u.join(``),f=u.map((e,t)=>({char:e,isPrune:c===t,isCompact:l===t}));return{pct:a,filled:o,total:r,color:s,bar:d,label:`${d} ${a}%`,segments:f}}function Km({tasks:e=[]}){let t=R(),n=e.filter(e=>e.status===`running`).length,[r,i]=K(()=>Date.now());W(()=>{if(n===0)return;i(Date.now());let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[n]);let a=xo(e,r);return a?q(X,{color:t.accent,children:` · ${a}`}):null}function qm({tasks:e=[]}){let t=R(),n=So(e);return n?q(X,{color:t.accent,children:` · ${n}`}):null}function Jm({columns:e,footerVisible:n,perfIndicatorLevel:r,perfIndicatorUsedPct:i,modelName:a,budget:o,badgeEntries:s,fullScreenPaneActive:c,backgroundTasks:l,scheduleEnabledCount:u,agentProcessing:d,queuedItems:f,notifications:p,language:m,welcome:h,messages:g,hasHistory:_,paused:v=!1,pausePending:y=null,shadow:b=!1}){let x=R();return J(Y,{flexDirection:`row`,justifyContent:`space-between`,width:e,height:1,overflow:`hidden`,children:[J(Y,{flexDirection:`row`,children:[b&&q(X,{bold:!0,color:x.warning,children:`🕶 ${V.t(`welcome.shadowBadge`)} `}),n.perfIndicator&&q(Vm,{level:r,usedPct:i}),n.modelName&&a&&q(X,{color:x.suggestion,children:a}),n.occupancyBar&&o&&o.contextWindow>0&&(()=>{let e={prune:o.pruneLine>0?o.pruneLine/o.contextWindow*100:void 0,compact:o.compactLine>0?o.compactLine/o.contextWindow*100:void 0},t=Gm(o.contextPercent,10,e),n={},r=t.segments.findIndex(e=>e.isPrune),i=t.segments.findIndex(e=>e.isCompact);return r>=0&&(n.prune={pos:r,color:x.warning}),i>=0&&(n.compact={pos:i,color:x.error}),J(X,{children:[` `,q(Ge,{percent:t.pct,width:t.total,chars:`dot`,color:t.color,markers:n,labelPosition:`suffix`,labelPrefix:o.live?`~`:``})]})})(),s.map(e=>J(X,{color:e.color===`warning`?x.warning:x.inactive,children:[e.separator===`dot`?` · `:` `,e.text]},e.id)),n.backgroundTaskIndicator&&!c&&q(Km,{tasks:l}),n.scheduleIndicator&&!c&&q(Mm,{enabledCount:u}),n.serviceIndicator&&q(qm,{tasks:l})]}),J(Y,{flexDirection:`row`,children:[n.hintText&&q(X,{color:v||y?x.warning:x.inactive,children:y?`${V.t(`pause.toolCount`,{n:y.toolCount,s:y.elapsedSec})} /continue ${V.t(`pause.btnCancel`)}`:v?`${V.t(`cmd.titlePaused`)} · ${V.t(`hint.pausedContinue`)}`:d?e>=76?`${j.enter} ${V.t(`hint.steer`)} · ${Ie()} ${V.t(`hint.queue`)} · ${j.esc} ${f.length>0?V.t(`hint.delOne`):V.t(`hint.toInterrupt`)}`:`${j.esc}${f.length>0?` ${V.t(`hint.delOne`)}`:`/${t(`c`)} ${V.t(`hint.toInterrupt`)}`}`:e>=76?`${j.right} ${V.t(`hint.autosuggestAccept`)} · Tab ${V.t(`hint.autosuggestMenu`)} · ${t(`r`)} ${V.t(`hint.history`)} · /help`:`/help`}),n.notificationBell&&p.some(e=>!e.read)&&q(A,{type:`secondary`,children:` · `}),n.notificationBell&&q(Hm,{count:p.filter(e=>!e.read).length,hasUrgent:p.some(e=>e.level===`error`&&!e.read)}),(()=>{let e=n.language&&!!m,t=n.liveClock&&!c&&(!h||g.length>0||_);return!e&&!t?null:J(A,{type:`secondary`,children:[` `,e&&(m===`zh`?`中`:`EN`),e&&t&&` `,t&&q(Bm,{color:x.inactive,dimColor:!1})]})})()]})]})}const Ym=()=>{},Xm=[{id:`Button`,category:`components`,title:`Button`,variants:[{name:`solid/accent`,render:()=>U(Ne,{variant:`solid`,color:`accent`,label:`Approve`,focused:!0})},{name:`solid/amber`,render:()=>U(Ne,{variant:`solid`,color:`amber`,label:`Upgrade`,focused:!0})},{name:`solid/red`,render:()=>U(Ne,{variant:`solid`,color:`red`,label:`Delete`,focused:!0})},{name:`solid/green`,render:()=>U(Ne,{variant:`solid`,color:`green`,label:`Confirm`,focused:!0})},{name:`outline/accent`,render:()=>U(Ne,{variant:`outline`,color:`accent`,label:`Select`,focused:!0})},{name:`outline/gray`,render:()=>U(Ne,{variant:`outline`,color:`gray`,label:`Cancel`,focused:!1})},{name:`ghost/accent`,render:()=>U(Ne,{variant:`ghost`,color:`accent`,label:`Escape`,focused:!0})},{name:`ghost/gray`,render:()=>U(Ne,{variant:`ghost`,color:`gray`,label:`Dismiss`,focused:!1})},{name:`disabled`,render:()=>U(Ne,{variant:`solid`,color:`accent`,label:`Unavailable`,disabled:!0})}]},{id:`Segmented`,category:`components`,title:`Segmented`,variants:[{name:`three-tabs`,render:()=>U(Kd,{items:[{key:`events`,label:`Events`},{key:`tools`,label:`Tools`},{key:`budget`,label:`Budget`}],activeKey:`tools`})},{name:`with-disabled`,render:()=>U(Kd,{items:[{key:`events`,label:`Events`},{key:`stats`,label:`Stats`,disabled:!0}],activeKey:`events`,color:`amber`})}]},{id:`SegmentItem`,category:`components`,title:`SegmentItem`,variants:[{name:`active`,render:()=>U(Gd,{label:`Events`,active:!0})},{name:`inactive`,render:()=>U(Gd,{label:`Tools`,active:!1})}]},{id:`GroupDivider`,category:`components`,title:`GroupDivider`,variants:[{name:`default`,render:()=>U(De,{label:`File`})}]},{id:`ScrollIndicatorAbove`,category:`components`,title:`ScrollIndicatorAbove`,variants:[{name:`with-count`,render:()=>U(g,{hasMore:!0,count:12})},{name:`no-count`,render:()=>U(g,{hasMore:!0})}]},{id:`ScrollIndicatorBelow`,category:`components`,title:`ScrollIndicatorBelow`,variants:[{name:`with-count`,render:()=>U(b,{hasMore:!0,count:7})},{name:`no-count`,render:()=>U(b,{hasMore:!0})}]},{id:`Group`,category:`components`,title:`Group`,variants:[{name:`with-title`,render:()=>U(Nm,{title:`Settings`,children:U(X,{},`Auto-indented content`)})},{name:`no-title`,render:()=>U(Nm,{children:U(X,{},`Indent only, no title divider`)})},{name:`custom-indent=4`,render:()=>U(Nm,{title:`Wide indent`,indent:4,children:U(X,{},`Indented by 4 columns`)})}]},{id:`Choices`,category:`components`,title:`Choices`,variants:[{name:`vertical-numbered`,render:()=>U(Om,{options:[{key:`approve`,label:`Approve`,color:`green`,shortcut:`y`},{key:`deny`,label:`Deny`,color:`red`,shortcut:`n`},{key:`always`,label:`Always`,color:`accent`,shortcut:`a`}],selected:0,onSelect:Ym,onPick:Ym,escapeIndex:1})}]},{id:`Menu`,category:`components`,title:`Menu (RFC-268 竖排编号原语)`,variants:[{name:`composite-api`,render:()=>U(i.Root,{onPick:Ym},U(i.Item,{label:`Trust — full access`,color:`green`}),U(i.Item,{label:`Read-only this session`,color:`accent`}),U(i.Item,{label:`No, exit`,color:`gray`}))}]},{id:`Typography`,category:`components`,title:`Typography (RFC-269 文字层级)`,variants:[{name:`type-scale`,render:()=>U(Y,{flexDirection:`column`},U(A,{type:`primary`},`primary — 正文(终端默认前景)`),U(A,{type:`secondary`},`secondary — 次级/说明文字`),U(A,{type:`danger`},`danger — 错误态`),U(A,{type:`success`},`success — 成功态`),U(A,{type:`warning`},`warning — 警示态`),U(A,{type:`accent`},`accent — 品牌强调(守恒 ≤5%)`))}]},{id:`Tag`,category:`components`,title:`Tag (RFC-269 内联标签)`,variants:[{name:`view-label`,render:()=>U(Je,{leadingSpace:!0},`Rendered`)},{name:`counter`,render:()=>U(Je,null,`2/5`)}]},{id:`Kbd`,category:`components`,title:`Kbd (RFC-269 键位标签)`,variants:[{name:`single-key`,render:()=>U(ye,null,`↵`)},{name:`chord`,render:()=>U(ye,null,`⇧+↵`)}]},{id:`ProgressBar`,category:`components`,title:`ProgressBar (RFC-279)`,variants:[{name:`simple/ascii`,render:()=>U(Ge,{percent:45,width:30,chars:`ascii`,color:k.accent})},{name:`simple/block`,render:()=>U(Ge,{percent:68,width:24,chars:`block`,color:k.warning})},{name:`simple/dot`,render:()=>U(Ge,{percent:30,width:10,chars:`dot`,color:k.suggestion})},{name:`segments`,render:()=>U(Ge,{percent:0,width:30,chars:`block`,labelPosition:`prefix`,segments:[{key:`overhead`,width:4,color:k.accent},{key:`messages`,width:18,color:k.success},{key:`free`,width:8,color:k.inactive,dimColor:!0}]})},{name:`markers`,render:()=>U(Ge,{percent:90,width:10,chars:`dot`,color:k.suggestion,markers:{prune:{pos:7,color:k.warning},compact:{pos:9,color:k.error}}})}]},{id:`ScrollableBody`,category:`components`,title:`ScrollableBody (RFC-271 滚动容器)`,variants:[{name:`overflow-with-hint`,render:()=>U(um,{visibleRows:5,offset:0},...Array.from({length:8},(e,t)=>U(X,{key:t},`row ${t+1}`)))},{name:`fits-no-scroll`,render:()=>U(um,{visibleRows:5,offset:0},...Array.from({length:3},(e,t)=>U(X,{key:t},`row ${t+1}`)))}]},{id:`IdleTipCard`,category:`components`,title:`IdleTipCard (空闲技巧卡片)`,variants:[{name:`with-tip`,render:()=>U(Fm,{tip:`Ctrl+R 搜索历史命令`})}]},{id:`Icon`,category:`components`,title:`Icon (RFC-273 具名图标)`,variants:[{name:`named-icons`,render:()=>U(Y,{flexDirection:`column`},U(Rm,{name:`pointer`,color:`selection`,trailingSpace:!0}),U(Rm,{name:`check`,color:`success`}),U(Rm,{name:`cross`,color:`error`}),U(Rm,{name:`statusDot`,color:`accent`}))}]},{id:`DialogFrame`,category:`components`,title:`DialogFrame`,variants:[{name:`default`,render:()=>U(F,{header:U(_e,{children:`Confirm action`}),children:U(Ne,{variant:`ghost`,color:`gray`,label:`Body content goes here`}),footer:`Enter confirm · Esc cancel`})}]},{id:`DialogTitle`,category:`components`,title:`DialogTitle`,variants:[{name:`default`,render:()=>U(_e,{children:`Settings`})},{name:`warning-color`,render:()=>U(_e,{color:k.warning,children:`Forced upgrade`})}]},{id:`HintBar`,category:`components`,title:`HintBar`,variants:[{name:`multi-hint`,render:()=>U(C,{items:[[`← →`,`select`],[`Enter`,`confirm`],[`y/n/a`,`shortcut`],[`Esc`,`cancel`]]})}]},{id:`LiveClock`,category:`components`,title:`LiveClock`,variants:[{name:`default`,render:()=>U(Bm,{})}]},{id:`Spinner`,category:`components`,title:`Spinner`,variants:[{name:`responding`,render:()=>U(dl,{verb:`Thinking`,mode:`responding`,responseLength:128,tokens:6800,progressPercent:42})},{name:`requesting`,render:()=>U(dl,{verb:`Reticulating`,mode:`requesting`})},{name:`stalled`,render:()=>U(dl,{verb:`Waiting`,responseLength:64,hasActiveTools:!1,toolTurnCount:8,maxToolTurns:10})}]},{id:`StreamingSpinner`,category:`components`,title:`StreamingSpinner`,variants:[{name:`streaming`,render:()=>{let e=pl();return e.store.setState({processing:!0,streamingText:`Generating a response for the user request…`,spinnerMode:`responding`,outputTokensThisTurn:512,maxOutputTokens:4096,toolTurnCount:3,maxToolTurns:12,activeTool:null}),U(vl,{streamStore:e,pendingPermission:null})}}]},{id:`BreathingTool`,category:`components`,title:`BreathingTool`,variants:[{name:`default`,render:()=>U(al,{name:`grep`})}]},{id:`ThinkingLine`,category:`components`,title:`ThinkingLine`,variants:[{name:`default`,render:()=>U(rl,{tokens:6800,toolTurnCount:2,maxToolTurns:12,promptOutputTokens:1200,promptOutputTokenBudget:8e3})}]},{id:`PerfIndicator`,category:`components`,title:`PerfIndicator`,variants:[{name:`warning`,render:()=>U(Vm,{level:`warning`,usedPct:72.4})},{name:`critical`,render:()=>U(Vm,{level:`critical`,usedPct:91.2})},{name:`warning (no usedPct)`,render:()=>U(Vm,{level:`warning`})}]},{id:`NotificationBell`,category:`components`,title:`NotificationBell`,variants:[{name:`normal`,render:()=>U(Hm,{count:3,hasUrgent:!1})},{name:`urgent`,render:()=>U(Hm,{count:1,hasUrgent:!0})}]},{id:`Toast`,category:`components`,title:`Toast`,variants:[{name:`default`,render:()=>U(Wm,{toast:{id:1,title:`Theme changed`,content:`Switched to dark theme`}})}]},{id:`Home`,category:`components`,title:`Home`,variants:[{name:`default`,render:()=>U(jd,{version:`0.1.0`,buildId:1234,cwd:`/home/user/project`})}]},{id:`SignalBar`,category:`components`,title:`SignalBar`,variants:[{name:`all counts (delegates active)`,render:()=>U(gf,{counts:{tasks:4,delegates:3,edited:7,subagents:2,clipboard:0},labels:{tasks:`Tasks`,delegates:`Delegates`,edited:`Edited`,subagents:`Subagents`,clipboard:`Clipboard`,clipboardFailed:`Copy blocked — hold Shift and drag`},currentPath:`/pane/delegates`,tabHint:`Tab to switch`})},{name:`partial (only non-zero signals shown)`,render:()=>U(gf,{counts:{tasks:0,delegates:0,edited:2,subagents:0,clipboard:0},labels:{tasks:`Tasks`,delegates:`Delegates`,edited:`Edited`,subagents:`Subagents`,clipboard:`Clipboard`,clipboardFailed:`Copy blocked — hold Shift and drag`},tabHint:`Tab to switch`})},{name:`clipboard copied (success)`,render:()=>U(gf,{counts:{tasks:0,delegates:0,edited:0,subagents:0,clipboard:128},labels:{tasks:`Tasks`,delegates:`Delegates`,edited:`Edited`,subagents:`Subagents`,clipboard:`Copied`,clipboardFailed:`Copy blocked — hold Shift and drag`}})},{name:`clipboard failed (warning, no count)`,render:()=>U(gf,{counts:{tasks:0,delegates:0,edited:0,subagents:0,clipboard:0,clipboardFailed:!0},labels:{tasks:`Tasks`,delegates:`Delegates`,edited:`Edited`,subagents:`Subagents`,clipboard:`Copied`,clipboardFailed:`Copy blocked — hold Shift and drag for native copy`}})},{name:`empty (blank 1-row placeholder)`,render:()=>U(gf,{counts:{tasks:0,delegates:0,edited:0,subagents:0,clipboard:0},labels:{tasks:`Tasks`,delegates:`Delegates`,edited:`Edited`,subagents:`Subagents`,clipboard:`Clipboard`,clipboardFailed:`Copy blocked — hold Shift and drag`}})}]},{id:`StatusBar`,category:`components`,title:`StatusBar`,variants:[{name:`wide (full visibility)`,render:()=>U(Jm,{columns:120,footerVisible:bu(120),perfIndicatorLevel:`healthy`,perfIndicatorUsedPct:void 0,modelName:`claude-sonnet-4-5`,budget:{modelName:`claude-sonnet-4-5`,contextWindow:2e5,contextPercent:42,overheadTokens:2e3,messageTokens:82e3,pruneLine:16e4,compactLine:18e4},badgeEntries:[{id:`host:permission-mode`,text:`Auto`,separator:`dot`,tier:`narrow`,isHost:!0},{id:`host:cost`,text:`$0.12`,separator:`space`,tier:`medium`,isHost:!0},{id:`demo:status`,text:`demo-plugin ready`,separator:`space`,tier:`low`,isHost:!1}],fullScreenPaneActive:!1,backgroundTasks:[],scheduleEnabledCount:0,agentProcessing:!1,queuedItems:[],notifications:[],language:`en`,welcome:void 0,messages:[],hasHistory:!0})},{name:`narrow (agent processing)`,render:()=>U(Jm,{columns:60,footerVisible:bu(60),perfIndicatorLevel:`warning`,perfIndicatorUsedPct:78.5,modelName:`deepseek-v4`,budget:null,badgeEntries:[{id:`host:permission-mode`,text:`Autopilot`,color:`warning`,separator:`dot`,tier:`narrow`,isHost:!0}],fullScreenPaneActive:!1,backgroundTasks:[],scheduleEnabledCount:2,agentProcessing:!0,queuedItems:[],notifications:[],language:`zh`,welcome:void 0,messages:[],hasHistory:!0})}]},{id:`Checkbox`,category:`components`,title:`Checkbox`,variants:[{name:`checked`,render:()=>U(Dm,{checked:!0,label:`Enable telemetry`,onChange:()=>{}})},{name:`unchecked`,render:()=>U(Dm,{checked:!1,label:`Enable telemetry`,onChange:()=>{}})}]},{id:`List`,category:`components`,title:`List`,variants:[{name:`three-options`,render:()=>U(ht,{options:[{value:`a`,label:`model-a`,detail:`fast`},{value:`b`,label:`model-b`,detail:`balanced`},{value:`c`,label:`model-c`,detail:`deep`,disabled:!0}],onSelect:()=>{}})}]},{id:`ListItem`,category:`components`,title:`ListItem`,variants:[{name:`label-detail`,render:()=>U(Ae,{label:`model-a`,detail:`fast · 200k ctx`})},{name:`disabled`,render:()=>U(Ae,{label:`model-x`,detail:`unavailable`,disabled:!0})}]},{id:`Wordmark`,category:`components`,title:`Wordmark`,variants:[{name:`default`,render:()=>U(Cd)}]},{id:`ScheduleIndicator`,category:`components`,title:`ScheduleIndicator`,variants:[{name:`two-scheduled`,render:()=>U(Mm,{enabledCount:2})}]},{id:`PulseSurveyOverlay`,category:`components`,title:`PulseSurveyOverlay`,variants:[{name:`rating`,render:()=>U(jm,{item:{phase:`rating`,rating:null,selectedIndex:0,commentText:``,commentOffset:0,onSubmit:()=>{},onClose:()=>{}},columns:60})}]}],Zm=()=>{},Qm=Date.UTC(2026,6,10,12,0,0),$m=[{id:`t1`,title:`Read type contract`,status:`done`,turn:1},{id:`t2`,title:`Implement pane examples`,status:`in_progress`,turn:3},{id:`t3`,title:`Wire registry aggregation`,status:`pending`},{id:`t4`,title:`Skip redundant EditedFilesPane`,status:`skipped`,turn:2},{id:`t5`,title:`Run typecheck gate`,status:`failed`,turn:4}],eh=[{id:`d1`,command:`refactor error handling in run-modes.ts`,type:`agent-session`,origin:`user`,status:`running`,agentStatus:`ready`,startedAt:Qm-92e3,diffStat:`+42/-18`,turnIndex:4,toolUseCount:11,tokenCount:8400,model:`claude-sonnet-4`,modelDecidedBy:`category`},{id:`d2`,command:`npm run build`,type:`process`,status:`running`,startedAt:Qm-45e3,port:5173},{id:`d3`,command:`grep -rn TODO packages/`,type:`process`,status:`exited`,startedAt:Qm-3e5,exitCode:0},{id:`d4`,command:`audit security surface`,type:`agent-session`,origin:`main`,status:`running`,agentStatus:`needs_input`,startedAt:Qm-15e3,turnIndex:2,toolUseCount:3,model:`deepseek-v4`}],th={id:`d1`,command:`refactor error handling in run-modes.ts`,status:`running`,prompt:`Refactor the error handling in run-modes.ts to use the shared classifier.`,responseText:`turn 4 ${L.check} 3 tools 2.1s\n activity editing run-modes.ts\n tokens 8.4k out · 11 tools`,text:`applying edit to run-modes.ts …
72
72
  + import { classify } from "./classify"