@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/{WizardDialog-Br__pRN3.js → WizardDialog-B0B_R8ya.js} +2 -2
- package/dist/WizardDialog-B0B_R8ya.js.map +1 -0
- package/dist/compat.js +1 -1
- package/dist/{i18n-Cx-Il2qw.js → i18n-DH-JhkWE.js} +5 -5
- package/dist/i18n-DH-JhkWE.js.map +1 -0
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/standalone.js +1 -1
- package/package.json +5 -5
- package/dist/WizardDialog-Br__pRN3.js.map +0 -1
- package/dist/i18n-Cx-Il2qw.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./i18n-
|
|
1
|
+
import{n as e}from"./i18n-DH-JhkWE.js";import{createRequire as t}from"node:module";import n from"string-width";import r from"wrap-ansi";import i,{createContext as a,createElement as o,useCallback as s,useContext as c,useEffect as l,useMemo as u,useRef as d,useState as f}from"react";import{Fragment as p,jsx as m,jsxs as h}from"react/jsx-runtime";import{Box as g,Text as _,useCursor as v,useInput as y}from"ink";import{isShadowModeEnabled as b}from"@x-otto/env";var x=t(import.meta.url);const S={ink:`#0D0E11`,carbon:`#16181D`,white:`#F4F3EF`,brandNavy:`#14348C`,brandPurple:`#A28EF9`,brandInk:`#12152B`,purpleBright:`#D1BCFF`,purpleDim:`#4F3E8C`,navyBright:`#2D59C8`,navyDim:`#0F2A73`,comment:`#9498B8`},C={success:`#98C379`,error:`#E06C75`,warning:`#E5C07B`,info:`#61AFEF`,special:`#C678DD`},w={brand:S.brandPurple,brandShimmer:S.purpleBright,accent:S.brandPurple,accentDim:S.purpleDim,accentBright:S.purpleBright,text:void 0,inactive:S.comment,secondary:`#C8CBDB`,subtle:S.comment,replyPrefix:`#8F7FD6`,success:`#7EE095`,error:`#FF9592`,warning:`#FFC966`,special:`#DD78C9`,suggestion:`#6187EF`,permission:`#6187EF`,codeText:`#56B6C2`,diffAdd:`#7EE095`,diffRemove:`#FF9592`,diffAddBg:`#183820`,diffRemoveBg:`#3C181A`,panelBorder:S.comment,overlayBg:S.brandInk,tagBg:`#262A3D`,toolText:`#C8CBDB`,focusBorder:`#4D7CFF`,selection:S.brandPurple};function T(e){return e===`high`?w.error:e===`medium`?w.warning:w.success}const E=/^(zh|ja|ko)[_-]/i,D=(()=>{for(let e of[`LC_ALL`,`LC_CTYPE`,`LANG`]){let t=process.env[e];if(t&&E.test(t))return!0}return!1})(),O={countAnsiEscapeCodes:!1};D&&(O.ambiguousIsNarrow=!1);const k=(e,t)=>`[${e};${t}r`,A=()=>`\x1B[r`,j=(e,t)=>`[${t+1};${e+1}H`,M=()=>`\x1B[K`,ee=()=>`\x1B[J`,te=()=>`\x1B[0m`,N=()=>`\x1B7`,P=()=>`\x1B8`,F=/(?:https?:\/\/|www\.)\S+|\b[\w-]+(?:\.[\w-]+)+\/\S+/i,ne=RegExp(`\x1B\\][^\\x07\x1B]*(?:\\x07|\x1B\\\\)|\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),I=e=>e.replace(ne,``),L=e=>n(e,O),re=e=>F.test(I(e));function ie(e,t,n=`pre`){if(n===`terminal`||t<=0)return[e];if(e===``)return[``];let i=r(e,t,{hard:!re(e),trim:!1,wordWrap:!0});return i.length===0?[``]:i.split(`
|
|
2
2
|
`)}function R(e,t,n=`pre`){let r=[];for(let i of e)r.push(...ie(i,t,n));return r}function ae(e,t){let n=Math.max(1,Math.ceil(L(e)/t)),r=``;if(n>1){r+=N();for(let e=1;e<n;e++)r+=`[1B[1G${M()}`;r+=P()}return r+=M()+e+te(),r}function oe(e,t,n,r){let i=Math.max(1,t.rows-t.liveTop),a=j(0,t.liveTop)+ee()+j(0,t.liveTop);e.forEach((e,t)=>{t>0&&(a+=`\r
|
|
3
3
|
`),a+=ae(e,n)});for(let e=0;e<i;e++)a+=`\r\n${M()}`;return a+=j(r.x,r.y),a}function z(e,t){let n=Math.max(1,t.columns),r=t.wrap??`pre`,i=t.mode??`standard`,a=t.cursor??{x:0,y:t.liveTop},o=R(e,n,r);if(o.length===0)return``;if(i===`raw`||t.liveTop<1)return oe(o,t,n,a);let s=t.liveTop,c=k(1,s)+j(0,s-1);for(let e of o)c+=`\r
|
|
4
4
|
`+ae(e,n);return c+=A()+j(a.x,a.y),c}function se(e,t,n){let r=z(t,n);r&&e.write(r)}function ce(e=process.env){return e.ZELLIJ?`raw`:`standard`}const B={bullet:`●`,toolResult:`⎿`,thinking:`∴`,quoteBar:`▎`,userPrompt:`>`,commandPrompt:`❯`,hr:`─`,check:`✓`,cross:`✗`,checkboxOff:`☐`,checkboxOn:`☑`,todoPending:`○`,todoActive:`◐`,todoDone:`●`,breatheDim:`○`,breatheBright:`●`,ellipsis:`…`,pointer:`▶`,toggleOn:`◉`,toggleOff:`○`,warn:`⚠`,frozen:`❄`,needsInput:`◑`,statusDot:`●`,itemActive:`▸`,attention:`◆`,sparkline:`▁▂▃▄▅▆▇█`,gaugeFilled:`━`,gaugeRest:`╌`,scrollThumb:`▐`,service:`↕`,edited:`✎`,scheduled:`◷`,clipboard:`✓`,requesting:`↑`,responding:`↓`};function V(){return`${B.pointer} `}function H(){return` `.repeat(L(V()))}const U=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],le=Array.from({length:6},(e,t)=>t/5);[...le,...le.slice(1,-1).reverse()].map(e=>e<.5?B.breatheDim:B.breatheBright);const ue={borderStyle:`single`,borderTop:!0,borderBottom:!0,borderLeft:!1,borderRight:!1},W={borderStyle:`single`,borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1},de={borderStyle:`round`,borderTop:!0,borderBottom:!0,borderLeft:!0,borderRight:!0},G={none:0,tight:1,section:2,loose:4},fe={contentInset:4,borderInset:2},pe=w,me={brand:S.brandNavy,brandShimmer:S.navyBright,accent:S.brandNavy,accentDim:S.navyDim,accentBright:S.navyBright,text:void 0,inactive:`#6B7280`,secondary:`#374151`,subtle:`#6B7280`,replyPrefix:`#5B21B6`,success:`#16A34A`,error:`#DC2626`,warning:`#CA8A04`,special:`#9333EA`,suggestion:`#2563EB`,permission:`#2563EB`,codeText:`#0891B2`,diffAdd:`#16A34A`,diffRemove:`#DC2626`,diffAddBg:`#DCFCE7`,diffRemoveBg:`#FEE2E2`,panelBorder:`#D1D5DB`,overlayBg:`#F9FAFB`,tagBg:`#E5E7EB`,toolText:`#374151`,focusBorder:`#2563EB`,selection:S.brandNavy};function he(e){return e.kind===`builtin`?`builtin`:`extension:${e.extensionId}`}function ge(e){return/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e)}function _e(e,t){if(e.kind===`builtin`){let e=t.id??t.localId;if(!e)throw Error(`Builtin theme preset requires id`);return e}let n=t.localId??t.id;if(!n)throw Error(`Extension theme preset requires localId`);if(!ge(n))throw Error(`Invalid extension theme preset localId: ${n}`);return`${e.extensionId}/${n}`}var ve=class{presets=new Map;presetSourceKeys=new Map;register(e,t){let n=_e(e,t),r=this.presets.get(n);if(r){let t=r.source.kind===`builtin`||e.kind===`builtin`;throw Error(t?`Cannot override builtin theme preset: ${n}`:`Duplicate theme preset id: ${n}`)}let i={...t,id:n,source:e};return this.presets.set(n,i),this.presetSourceKeys.set(n,he(e)),i}unregisterBySource(e){if(e.kind===`builtin`)return 0;let t=he(e),n=0;for(let[e,r]of[...this.presetSourceKeys])r===t&&(this.presetSourceKeys.delete(e),this.presets.delete(e)&&(n+=1));return n}get(e){return this.presets.get(e)}list(){return[...this.presets.values()]}resolve(e,t,n){let r=e===`system`?t??`dark`:e,i=n?.[r]??r,a=this.presets.get(i);if(a&&a.appearance===r)return a;let o=this.presets.get(r);if(!o)throw Error(`Missing builtin theme preset fallback for ${r}`);return o}};function ye(){let e=new ve;return e.register({kind:`builtin`},{id:`dark`,label:`Dark`,appearance:`dark`,colors:pe}),e.register({kind:`builtin`},{id:`light`,label:`Light`,appearance:`light`,colors:me}),e}let be=null;function xe(e){be=e}function Se(){return be}const Ce=a({resolvedTheme:`dark`,resolvedAppearance:`dark`,presetId:`dark`,colors:pe,setSystemTheme:()=>{},setPresetSelection:()=>{}});function we({children:e,systemTheme:t,themeRegistry:n,presetSelection:r}){let[i,a]=f(t),[o,s]=f(r);l(()=>(xe({setPresetSelection:s,setSystemTheme:a}),()=>xe(null)),[]);let c=u(()=>n??ye(),[n]).resolve(`system`,i,o),d=c.appearance,p=c.appearance,h=c.colors,g=u(()=>({resolvedTheme:d,resolvedAppearance:p,presetId:c.id,colors:h,setSystemTheme:a,setPresetSelection:s}),[d,p,c.id,h]);return m(Ce.Provider,{value:g,children:e})}function Te(){return c(Ce)}function K(){return c(Ce).colors}function Ee(e){return Buffer.isBuffer(e)?e:Buffer.from(e,`utf8`)}function De(e=process.stdin){let t=e._readableState;if(!t)return;let n=Oe(t.decoder);if(t.decoder=null,t.encoding=null,n&&n.length>0)try{e.unshift(n)}catch{}}function Oe(e){if(!e?.lastNeed||!e.lastChar||typeof e.lastTotal!=`number`)return null;let t=e.lastTotal-e.lastNeed;return t<=0?null:Buffer.from(e.lastChar.subarray(0,t))}function ke(e=200){return new Promise(t=>{if(!process.stdin.isTTY||!process.stdout.isTTY){t(void 0);return}let n=setTimeout(()=>{o(),t(void 0)},e),r=process.stdin.isRaw;process.stdin.setRawMode(!0),process.stdin.resume();let i=[],a=e=>{i.push(Ee(e));let n=Buffer.concat(i).toString().match(/\x1b\]11;rgb:([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)/);if(n){o();let e=parseInt(n[1].slice(0,2),16),r=parseInt(n[2].slice(0,2),16),i=parseInt(n[3].slice(0,2),16);t(.2126*e+.7152*r+.0722*i<128?`dark`:`light`)}},o=()=>{clearTimeout(n),process.stdin.removeListener(`data`,a),process.stdin.setRawMode(r??!1),process.stdin.pause()};process.stdin.on(`data`,a),process.stdout.write(`\x1B]11;?\x07`)})}function Ae(){return process.platform===`darwin`?`macos`:process.platform===`win32`?`windows`:`linux`}const q={enter:`↵`,up:`↑`,down:`↓`,left:`←`,right:`→`,esc:`Esc`,tab:`⇥`};function je(e,t=Ae()){let n=e.length===1?e.toUpperCase():e;return t===`macos`?`⌃+${n}`:`Ctrl+${n}`}function Me(e=Ae()){return e===`macos`?`⌘+${q.enter}`:`Ctrl+${q.enter}`}function Ne(e=Ae()){return`⇧+${q.enter}`}function Pe({header:e,children:t,footer:n,paddingY:r=G.none,maxHeight:i,borderStyle:a}){let o=K();return h(g,{...de,borderStyle:a??de.borderStyle,borderColor:o.panelBorder,backgroundColor:o.overlayBg,paddingX:G.tight,paddingY:r,marginTop:G.tight,maxHeight:i,flexDirection:`column`,children:[e,t,n&&m(g,{marginTop:G.tight,children:m(_,{dimColor:!0,children:n})})]})}function Fe({children:e,color:t}){let n=K();return m(_,{color:t??n.secondary,bold:!0,children:e})}function Ie({children:e}){return m(_,{color:K().secondary,children:e})}function Le({items:e,dim:t=!1}){return m(_,{dimColor:t||void 0,children:e.map(([e,t],n)=>h(_,{children:[n>0?` · `:``,m(Ie,{children:e}),` ${t}`]},`${e}-${n}`))})}const Re=a({focused:!1,id:``,disabled:!1,focusStyle:`pointer`});function ze(){return c(Re)}const Be=B.pointer;let Ve=0;var He=class{entries=new Map;focusMemory=new Map;register(e){this.entries.set(e.id,e)}unregister(e){this.entries.delete(e)}getTabable(e){return[...this.entries.values()].filter(t=>t.routePath===e&&t.tabIndex>=0&&!t.disabled).sort((e,t)=>e.tabIndex-t.tabIndex||e.order-t.order)}getInitialFocus(e){let t=this.focusMemory.get(e);if(t&&this.entries.has(t)&&!this.entries.get(t).disabled)return t;let n=[...this.entries.values()].filter(t=>t.routePath===e&&!t.disabled).find(e=>e.autoFocus);return n?n.id:this.getTabable(e)[0]?.id??null}next(e,t){let n=this.getTabable(t);return n.length===0?null:n[(n.findIndex(t=>t.id===e)+1)%n.length]?.id??null}prev(e,t){let n=this.getTabable(t);return n.length===0?null:n[(n.findIndex(t=>t.id===e)-1+n.length)%n.length]?.id??null}rememberFocus(e,t){this.focusMemory.set(e,t)}get(e){return this.entries.get(e)}static nextOrder(){return Ve++}};const Ue=a({routePath:`/`,currentPath:`/`,activeId:null,registry:new He,hasRouter:!1});let We=0;function Ge(e={}){let{tabIndex:t=0,disabled:n=!1,autoFocus:r=!1,onAction:i,onEscape:a,onTab:o,id:s}=e,u=d(s??`tabable-${++We}`).current,f=c(Ue),p=f.activeId===u&&!n,m=d(i);m.current=i;let h=d(a);h.current=a;let g=d(o);g.current=o;let _=d(f);return _.current=f,l(()=>{let e={id:u,tabIndex:t,disabled:n,order:He.nextOrder(),routePath:f.routePath,autoFocus:r,get onAction(){return m.current},get onEscape(){return h.current},get onTab(){return g.current}};return f.registry.register(e),()=>{let e=_.current;if(e.registry.unregister(u),e.activeId===u){let t=e.registry.getInitialFocus(e.routePath);Promise.resolve().then(()=>{let e=_.current;e.activeId===u&&e.onFocusFallback?.(t)})}}},[u,t,n,f.routePath,r]),{focused:p,id:u}}function Ke({tabIndex:e=0,disabled:t=!1,autoFocus:n=!1,onAction:r,onEscape:i,id:a,focusStyle:o=`pointer`,children:s}){let{focused:c,id:l}=Ge({tabIndex:e,disabled:t,autoFocus:n,onAction:r,onEscape:i,id:a}),d=u(()=>({focused:c,id:l,disabled:t,focusStyle:o}),[c,l,t,o]);return m(Re.Provider,{value:d,children:m(qe,{focused:c,disabled:t,style:o,children:s})})}function qe({focused:e,disabled:t,style:n,children:r}){let i=K();if(n===`none`||t)return m(p,{children:r});switch(n){case`pointer`:return h(g,{flexDirection:`row`,children:[m(_,{color:e?i.selection:i.inactive,bold:e,children:e?`${Be} `:` `}),m(g,{flexDirection:`column`,children:m(_,{color:e?i.selection:void 0,bold:e,children:r})})]});case`highlight`:return m(_,{color:e?i.selection:void 0,bold:e,children:r});case`background`:return e?h(_,{backgroundColor:`#4D7CFF`,color:`#FFFFFF`,bold:!0,children:[` `,r,` `]}):h(_,{color:i.inactive,children:[`[ `,r,` ]`]});case`border`:return m(g,{borderStyle:`single`,borderColor:e?i.selection:i.inactive,children:r});case`cursor`:return m(p,{children:r});default:return m(p,{children:r})}}var Je=class{entries=[];register(e,t,n){let r={id:e,handler:t,priority:n};return this.entries.push(r),this.entries.sort((e,t)=>t.priority-e.priority),()=>{this.entries=this.entries.filter(e=>e!==r)}}dispatch(e,t){for(let n of this.entries)if(n.handler(e,t))return!0;return!1}debug(){return this.entries.map(e=>`[${e.priority}] ${e.id}`)}};const Ye=100,Xe=50,Ze=10,Qe=a(null);function $e({children:e}){let t=i.useMemo(()=>new Je,[]);return m(Qe.Provider,{value:{focusBus:t},children:e})}function et(){let e=c(Qe);if(!e)throw Error(`useFocusBus() must be used inside <FocusBusProvider>`);return e.focusBus}function tt(){return c(Qe)?.focusBus??null}function nt(e,t,n){let r=tt(),i=d(t);i.current=t;let a=d(n??`tabable-input-${++it}`).current;y((t,n)=>{!r&&e&&i.current(t,n)},{isActive:!r&&e}),l(()=>{if(!(!r||!e))return r.register(a,(e,t)=>i.current(e,t),100)},[e,r,a])}function rt(e,t,n){let r=tt(),i=d(t);i.current=t;let a=n?.isActive??!0;y((e,t)=>{!r&&a&&i.current(e,t)},{isActive:!r&&a}),l(()=>{if(!(!r||!a))return r.register(e,(e,t)=>i.current(e,t),1e3)},[r,e,a])}let it=0;function at(e,t,n,r){let i=tt(),a=c(Ue),o=d(t);o.current=t;let s=r?.ignoreRoute||!a.hasRouter||a.routePath===a.currentPath||a.currentPath.startsWith(`${a.routePath}/`),u=(r?.isActive??!0)&&s;y((e,t)=>{!i&&u&&o.current(e,t)},{isActive:!i&&u}),l(()=>{if(!(!i||!u))return i.register(e,(e,t)=>o.current(e,t),n)},[i,e,u,n])}function J(e,t,n){at(e,t,10,n)}function ot(e,t,n){at(e,t,200,{...n,ignoreRoute:!0})}function st(e,t,n){let r=d(t);r.current=t,at(e,()=>(r.current(),!1),0,{...n,ignoreRoute:!0})}function ct(e,t,n){at(e,t,0,n)}function lt(e){let{items:t,onPick:n,direction:r=`vertical`,activeIndex:i,onActiveChange:a,escapeIndex:o,tabIndex:s=0,id:l}=e,u=t.length,d=i!==void 0,[p,m]=f(0),h=d?i:p,g=e=>{d||m(e),a?.(e)},_=c(Ue).hasRouter===!0,{focused:v}=Ge({tabIndex:s,disabled:!_||s<0,id:l,onAction:()=>{let e=t[h];return e&&!e.disabled&&n(h),!0}}),y=e=>{if(u===0)return;let n=(h+e+u)%u;for(let r=0;r<u&&t[n]?.disabled;r++)n=(n+e+u)%u;g(n)},b=(e,i)=>{let a=r===`vertical`?i.upArrow:i.leftArrow,s=r===`vertical`?i.downArrow:i.rightArrow;if(a)return y(-1),!0;if(s)return y(1),!0;if(i.return){let e=t[h];return e&&!e.disabled&&n(h),!0}if(i.escape)return o===void 0?!1:(n(o),!0);if(e>=`1`&&e<=`9`){let r=e.charCodeAt(0)-49;return r<u&&!t[r]?.disabled?(n(r),!0):!1}let c=e.toLowerCase(),l=t.findIndex(e=>e.shortcut===c&&!e.disabled);return l>=0?(n(l),!0):!1};return nt(v&&_,b),J(`roving-${l??t.map(e=>e.key).join(`-`)}`,b,{isActive:!v||!_}),{active:h,focused:v}}function ut(e,t){switch(e){case void 0:case`accent`:return t.accent;case`amber`:return t.warning;case`red`:return t.error;case`green`:return t.success;case`gray`:return t.inactive;default:return e}}function dt(e){return null}dt.displayName=`Menu.Item`;function ft(e){let t=[];return i.Children.forEach(e,e=>{i.isValidElement(e)&&e.type.displayName===`Menu.Item`&&t.push(e.props)}),t}function pt({children:e,onPick:t,activeIndex:n,onActiveChange:r,escapeIndex:i,tabIndex:a=0,id:s}){let c=K(),l=ft(e),{active:u}=lt({items:l.map((e,t)=>({key:`${t}`,shortcut:e.shortcut,disabled:e.disabled})),onPick:t,direction:`vertical`,activeIndex:n,onActiveChange:r,escapeIndex:i,tabIndex:a,id:s});return o(g,{flexDirection:`column`},...l.map((e,t)=>{let n=t===u,r=o(_,{color:e.disabled?c.inactive:n?ut(e.color,c):c.inactive,bold:n,dimColor:e.disabled},`${n?B.pointer:` `} ${t+1}. ${e.label}`);return e.detail?o(g,{key:`item-${t}`,flexDirection:`column`},r,o(g,{marginLeft:5},o(_,{color:c.inactive,dimColor:!0},e.detail))):o(g,{key:`item-${t}`,flexDirection:`column`},r)}))}pt.displayName=`Menu.Root`;const Y={Root:pt,Item:dt},mt=new Map;function ht(e){let t=e.includes(` `)?e.replace(/\t/g,` `):e;return D?n(t,{ambiguousIsNarrow:!1}):n(t)}function gt(e){if(e.length>0&&e.length<=16){let t=mt.get(e);if(t!==void 0)return t;let n=ht(e);return mt.size<4096&&mt.set(e,n),n}return ht(e)}function _t(e){return n(e,{ambiguousIsNarrow:!1})}const vt=new Intl.Segmenter(`en`,{granularity:`grapheme`}),yt=new Intl.Segmenter(`en`,{granularity:`word`}),X=/\[(?:@paste:(?:#\d+(?:\s+\+\d+\s+lines)?|image #\d+)|@(?:file|agent|skill|mcp|person|plugin|model):[^\]]+)\]/g;function bt(e){if(/^\[@paste:/.test(e))return`paste`;let t=e.match(/^\[@(file|agent|skill|mcp|person|plugin|model):/);return t?t[1]:`unknown`}function xt(e){let t=e.match(/^\[@paste:#(\d+)/);return t?Number.parseInt(t[1],10):void 0}function St(e,t){X.lastIndex=0;let n,r=null;for(;(n=X.exec(e))!==null;)n.index+n[0].length===t&&(r={start:n.index,end:n.index+n[0].length,text:n[0]});return r}function Ct(e,t){X.lastIndex=0;let n;for(;(n=X.exec(e))!==null;)if(t>n.index&&t<n.index+n[0].length)return{start:n.index,end:n.index+n[0].length,text:n[0]};return null}function wt(e,t){X.lastIndex=0;let n;for(;(n=X.exec(e))!==null;)if(n.index===t)return{start:n.index,end:n.index+n[0].length,text:n[0]};return null}function Tt(e,t){let n=Ct(e,t);return n?n.start:t}function Et(e){return[...vt.segment(e)]}var Z=class{text;columns;lines;_graphemes;_wordBreaks;constructor(e,t){let n=e.normalize(`NFC`);this.text=n===e?e:n,this.columns=Math.max(1,t),this.lines=this.text===``?[``]:this.text.split(`
|
|
@@ -7,4 +7,4 @@ import{n as e}from"./i18n-Cx-Il2qw.js";import{createRequire as t}from"node:modul
|
|
|
7
7
|
`),action:`insert`}}return Nt(),{cursor:e,action:i||a||r||o?`submit_force`:`submit`}}let s=kt(e,t);return s?(s.action===`kill_to_end`&&s.killed?Mt(s.killed,!1):s.action===`kill_to_start`&&s.killed||s.action===`kill_word_before`&&s.killed?Mt(s.killed,!0):(s.action===`delete_backward`||s.action===`insert`)&&Nt(),s):null}function Ft(e){return e.replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)/g,``).replace(/\x1b\][^\x1b]*$/g,``).replace(/\x1b\[[0-9;]*[~a-zA-Z]/g,``).replace(/\r\n?/g,`
|
|
8
8
|
`).replace(/[\x00-\x08\x0b-\x1f\x7f]/g,``)}function It(e){return e.measuredText.lineCount>10}function Lt(e,t){let n=e.measuredText.lineCount;if(n<=t)return null;let r=e.position,i=e.getViewportStartLine(t),a=Math.min(i+t,n);return{startLine:i,endLine:a,visibleLines:e.measuredText.lines.slice(i,a),cursorLine:r.line-i}}function Rt(e,t,n){return{x:e,y:t,lastChangeAt:n,targetX:e,targetY:t}}function zt(e,t,n,r,i){let a=t!==e.targetX||n!==e.targetY;return i?a?r-e.lastChangeAt<150?{...e,targetX:t,targetY:n,lastChangeAt:r}:{x:t,y:n,targetX:t,targetY:n,lastChangeAt:r}:(e.x!==t||e.y!==n)&&r-e.lastChangeAt>=150?{...e,x:t,y:n}:e:!a&&e.x===t&&e.y===n?e:{x:t,y:n,targetX:t,targetY:n,lastChangeAt:r}}function Bt(e){if(!e?.yogaNode)return null;let t=0,n=0,r=e;for(;r?.yogaNode;)t+=r.yogaNode.getComputedLeft(),n+=r.yogaNode.getComputedTop(),r=r.parentNode;return{x:Math.round(t),y:Math.round(n)}}function Vt(e){let t=e??void 0;for(;t;){if(!t.parentNode)return t.nodeName===`ink-root`?t:void 0;t=t.parentNode}}let Ht=0;function Ut(e){if(!e)return`NULL`;let t=[],n=e;for(let e=0;e<4&&n;e++)t.push(n.nodeName??`?`),n=n.parentNode;let r=e.childNodes?.[0]?.nodeValue;return`${t.join(`<`)}${r?`:${JSON.stringify(r.slice(0,12))}`:``}`}function Wt(e){let[t,n]=f(null),r=i.useRef(0);r.current===0&&(r.current=++Ht);let a=s(()=>{if(!e.current)return;let t=Bt(e.current);n(n=>{let i=b()?void 0:process.env.OTTO_TUI_CURSOR_DEBUG;if(i)try{x(`node:fs`).appendFileSync(i,`[ORG#${r.current}] t=${Date.now()%1e5} next=${t?`${t.x},${t.y}`:`NULL`} prev=${n?`${n.x},${n.y}`:`NULL`} node=${Ut(e.current)}\n`)}catch{}return t===null||n!==null&&n.x===t.x&&n.y===t.y?n:t})},[e]);return l(a),l(()=>{let t=Vt(e.current);if(t)return t.internal_layoutListeners??=new Set,t.internal_layoutListeners.add(a),()=>{t.internal_layoutListeners?.delete(a)}}),t}let Gt=0;function Kt({active:e,containerRef:t,text:n,inline:r,deleteKeyAt:i}){let{setCursorPosition:a}=v(),o=Wt(t),s=d(0);s.current===0&&(s.current=++Gt);let c=d(null),u=d(null),p=d(n.length),m=d(0);n.length<p.current&&(m.current=Date.now()),p.current=n.length;let[,h]=f(0);if(e&&o){let e=Date.now(),t=e-i<300,l=n.length===0,d=!t&&!l&&e-m.current<300,f=zt(c.current??Rt(r.column,r.lineOffset,e),r.column,r.lineOffset,e,d);c.current=f;let p=o.x+f.x,h=o.y+f.y,g=u.current;g!==null&&f.y>g.inlineOffset&&o.y===g.originY&&(h=g.y),u.current={y:h,originY:o.y,inlineOffset:f.y},a({x:p,y:h});let _=b()?void 0:process.env.OTTO_TUI_CURSOR_DEBUG;if(_)try{x(`node:fs`).appendFileSync(_,`[ON #${s.current}] t=${e%1e5} out=${p},${h} target=${o.x+r.column},${o.y+r.lineOffset} origin=${o.x},${o.y} inline=${r.column},${r.lineOffset} frozenInline=${f.x},${f.y} armed=${d?1:0} byDel=${t?1:0} byClr=${l?1:0} len=${n.length}\n`)}catch{}}else{c.current=null,u.current=null,a(void 0);let t=b()?void 0:process.env.OTTO_TUI_CURSOR_DEBUG;if(t)try{x(`node:fs`).appendFileSync(t,`[OFF#${s.current}] t=${Date.now()%1e5} active=${e?1:0} origin=${o?`${o.x},${o.y}`:`NULL`} len=${n.length}\n`)}catch{}}l(()=>{let e=c.current;if(!e||e.x===e.targetX&&e.y===e.targetY)return;let t=setTimeout(()=>h(e=>e+1),160);return()=>clearTimeout(t)})}const qt=new Intl.Segmenter(`en`,{granularity:`grapheme`});function Jt(e,t,n){let r=0,i=e,a=t;if(e>n){let o=Math.floor(n/2);r=Math.max(0,t-o),Math.min(e,r+n)-r<n&&(r=Math.max(0,e-n)),i=n,a=t-r}return{startLine:r,visibleRows:i,cursorLineInWindow:a}}const Yt={send:`> `,bash:`! `,bash_async:`!! `,memory:`# `,steer:`» `,dialog:``};function Xt(e,t){return e===`bash`||e===`bash_async`?t.warning:e===`memory`?t.special:e===`steer`?t.success:t.suggestion}function Zt(e,t,n){if(!e)return{lines:[``],cursorLine:0,cursorCharInLine:0};let r=[...qt.segment(e)],i=[],a=``,o=0,s=0,c=0,l=0;for(let e=0;e<r.length;e++){let u=r[e],d=gt(u.segment);if(l===n&&(s=i.length,c=a.length),u.segment===`
|
|
9
9
|
`){i.push(a),a=``,o=0,l+=u.segment.length;continue}o+d>t&&a.length>0&&(i.push(a),a=``,o=0),a+=u.segment,o+=d,l+=u.segment.length}return n>=l&&(s=i.length,c=a.length),i.push(a),{lines:i,cursorLine:s,cursorCharInLine:c}}function Qt(e){X.lastIndex=0;let t=[],n=0,r;for(;(r=X.exec(e))!==null;){r.index>n&&t.push({chunk:e.slice(n,r.index),isChip:!1});let i=r[0],a=bt(i);t.push({chunk:i,isChip:!0,kind:a,pasteId:a===`paste`?xt(i):void 0}),n=r.index+i.length}return n<e.length&&t.push({chunk:e.slice(n),isChip:!1}),t}function $t(e,t){switch(e){case`file`:return t.suggestion;case`agent`:return t.accent;case`skill`:case`mcp`:case`plugin`:return t.special;case`person`:return t.success;case`paste`:return t.inactive;default:return}}function en(e,t){return e.kind===`paste`&&e.pasteId!==void 0&&(t?.has(e.pasteId)??!1)}function tn(e,t){X.lastIndex=0;let n;for(;(n=X.exec(e))!==null;)if(t>n.index&&t<n.index+n[0].length){let e=bt(n[0]);return{kind:e,pasteId:e===`paste`?xt(n[0]):void 0}}}function nn(e,t){let n=wt(e,t);if(!n)return;let r=bt(n.text);return{text:n.text,kind:r,pasteId:r===`paste`?xt(n.text):void 0}}function rn(e){return`•`.repeat(e.length)}const an=i.memo(function({value:t,offset:n,columns:r,mode:a=`send`,placeholder:o=``,maxVisibleLines:s=10,focused:c,tabIndex:l=-1,mask:u=!1,noPrefix:d=!1,ghostSuffix:f,invalidPasteIds:p,containerRef:v,physicalCursor:y=!1,deleteKeyAt:b=0}){let x=K(),{focused:S}=Ge({tabIndex:l,disabled:l<0}),C=c??S,w=d?``:a===`dialog`&&!u?`> `:Yt[a],T=gt(w),E=w,D=Math.max(20,r-T),O=C,{lines:k,cursorLine:A,cursorCharInLine:j}=i.useMemo(()=>Zt(t,D,n),[t,D,n]),M=i.useRef(null),ee=i.useCallback(e=>{M.current=e,typeof v==`function`?v(e):v&&(v.current=e)},[v]),te=Jt(k.length,A,s),N=te.startLine>0?1:0,P={column:T+gt((k[A]??``).slice(0,j)),lineOffset:N+te.cursorLineInWindow};if(Kt({active:y&&C,containerRef:M,text:t,inline:P,deleteKeyAt:b}),t.length===0&&o)return h(g,{ref:ee,flexDirection:`row`,children:[m(_,{color:C?Xt(a,x):x.inactive,children:E}),C&&m(_,{inverse:O,children:` `}),m(_,{dimColor:!0,children:o})]});let F=k.length,{startLine:ne,visibleRows:I}=Jt(F,A,s),L=ne+I,re=k.slice(ne,L);return h(g,{ref:ee,flexDirection:`column`,children:[ne>0&&m(_,{dimColor:!0,children:` … ${ne} ${e.t(`scroll.viewportLinesAbove`)}`}),re.map((e,t)=>{let n=ne+t,r=n===A,i=u?rn(e):e;if(!r||!C){let r=u?[{chunk:i,isChip:!1}]:Qt(i);return h(g,{flexDirection:`row`,children:[n===0&&E?m(_,{color:C?Xt(a,x):x.inactive,children:E}):T>0&&m(_,{dimColor:!0,children:` `.repeat(T)}),r.length===0?m(_,{children:` `}):r.map((e,t)=>{let n=e.isChip&&en(e,p);return m(_,{color:n?x.error:e.isChip?$t(e.kind,x):void 0,strikethrough:n,children:e.chunk},t)})]},`${t}-${e.slice(0,10)}`)}let o=Math.max(0,Math.min(j,i.length)),s=!u&&o<i.length?nn(i,o):void 0;if(s){let r=i.slice(0,o),c=i.slice(o+s.text.length),l=s.kind===`paste`&&s.pasteId!==void 0&&(p?.has(s.pasteId)??!1);return h(g,{flexDirection:`row`,children:[n===0&&E?m(_,{color:C?Xt(a,x):x.inactive,children:E}):T>0&&m(_,{dimColor:!0,children:` `.repeat(T)}),Qt(r).map((e,t)=>{let n=e.isChip&&en(e,p);return m(_,{color:n?x.error:e.isChip?$t(e.kind,x):void 0,strikethrough:n,children:e.chunk},`b-${t}`)}),m(_,{inverse:!0,color:l?x.error:void 0,strikethrough:l,children:s.text}),Qt(c).map((e,t)=>{let n=e.isChip&&en(e,p);return m(_,{color:n?x.error:e.isChip?$t(e.kind,x):void 0,strikethrough:n,children:e.chunk},`a-${t}`)}),f?m(_,{dimColor:!0,children:f}):null]},`${t}-${e.slice(0,10)}`)}let c=i.slice(0,o),l=i.slice(o),d=l.length>0?[...l][0]??` `:` `,v=l.length>0?l.slice(d.length):``,y=!u&&l.length>0?tn(i,o):void 0,b=y?.kind===`paste`&&y.pasteId!==void 0&&(p?.has(y.pasteId)??!1);return h(g,{flexDirection:`row`,children:[n===0&&E?m(_,{color:C?Xt(a,x):x.inactive,children:E}):T>0&&m(_,{dimColor:!0,children:` `.repeat(T)}),(u?[{chunk:c,isChip:!1}]:Qt(c)).map((e,t)=>{let n=e.isChip&&en(e,p);return m(_,{color:n?x.error:e.isChip?$t(e.kind,x):void 0,strikethrough:n,children:e.chunk},`b-${t}`)}),m(_,{inverse:O,color:b?x.error:y==null?void 0:$t(y.kind,x),strikethrough:b,children:d}),(u?[{chunk:v,isChip:!1}]:Qt(v)).map((e,t)=>{let n=e.isChip&&en(e,p);return m(_,{color:n?x.error:e.isChip?$t(e.kind,x):void 0,strikethrough:n,children:e.chunk},`a-${t}`)}),f?m(_,{dimColor:!0,children:f}):null]},`${t}-${e.slice(0,10)}`)}),L<F&&m(_,{dimColor:!0,children:` … ${F-L} ${e.t(`scroll.viewportLinesBelow`)}`})]})}),on=[{commandId:`cycle-permission-mode`,description:`循环切换权限模式`,predicate:{shift:!0,key:`tab`},scopes:`*`},{commandId:`toggle-notifications`,description:`打开/关闭通知中心`,predicate:{ctrl:!0,input:`n`},scopes:`*`},{commandId:`toggle-edited-files`,description:`打开/关闭编辑文件面板`,predicate:{ctrl:!0,input:`v`},scopes:`*`},{commandId:`toggle-subagents`,description:`打开/关闭子代理面板`,predicate:{ctrl:!0,input:`t`},scopes:`*`},{commandId:`toggle-delegates`,description:`打开/关闭委派面板`,predicate:{ctrl:!0,input:`p`},scopes:`*`},{commandId:`toggle-draft-pane`,description:`打开/关闭草稿面板`,predicate:{ctrl:!0,input:`o`},scopes:`*`},{commandId:`toggle-queue-pane`,description:`打开/关闭队列面板`,predicate:{ctrl:!0,input:`q`},scopes:`*`},{commandId:`smart-close`,description:`智能关闭当前最上层面板`,predicate:{ctrl:!0,input:`k`},scopes:`*`},{commandId:`save-draft`,description:`保存当前输入为草稿`,predicate:{ctrl:!0,input:`s`},scopes:[`prompt`]},{commandId:`open-keybinding-panel`,description:`打开快捷键面板:浏览、搜索、重映射、重置快捷键`,predicate:{ctrl:!0,input:`/`},scopes:`*`}];function sn(e){return e.ctrl===void 0&&e.shift===void 0&&e.meta===void 0&&e.input===void 0&&e.key===void 0&&e.upArrow===void 0&&e.downArrow===void 0}function cn(e,t,n){let r=n?.[e];return r===void 0?t:r}function ln(e,t,n){if(e.ctrl!==void 0&&!!n.ctrl!==e.ctrl||e.shift!==void 0&&!!n.shift!==e.shift||e.meta!==void 0&&!!n.meta!==e.meta||e.input!==void 0&&t!==e.input)return!1;if(e.key!==void 0)switch(e.key){case`tab`:if(!n.tab)return!1;break;case`escape`:if(!n.escape)return!1;break;case`return`:if(!n.return)return!1;break}return!(e.upArrow!==void 0&&n.upArrow!==e.upArrow||e.downArrow!==void 0&&n.downArrow!==e.downArrow)}function un(e,t){return e===`*`?!0:e.includes(t)}function dn(e,t,n,r,i){for(let a of e){if(!un(a.scopes,t))continue;let e=cn(a.commandId,a.predicate,i);if(!sn(e)&&ln(e,n,r))return a.commandId}}const fn=[{commandId:`list-nav-up`,description:`列表选中项上移`,predicate:{upArrow:!0},scopes:`*`},{commandId:`list-nav-up`,description:`列表选中项上移(vim k)`,predicate:{input:`k`,ctrl:!1,meta:!1},scopes:[`editedFiles`,`subagents`,`taskFocus`,`draft`,`queue`,`schedule`,`select`,`questions`]},{commandId:`list-nav-down`,description:`列表选中项下移`,predicate:{downArrow:!0},scopes:`*`},{commandId:`list-nav-down`,description:`列表选中项下移(vim j)`,predicate:{input:`j`,ctrl:!1,meta:!1},scopes:[`editedFiles`,`subagents`,`taskFocus`,`draft`,`queue`,`schedule`,`select`,`questions`]}];function pn(e,t,n,r,i){for(let a of fn){if(r!==void 0&&!mn(a.scopes,r))continue;let o=cn(a.commandId,a.predicate,i);if(!sn(o)&&ln(o,t,n))return a.commandId===e}return!1}function mn(e,t){return e===`*`?!0:e.includes(t)}function hn(e,t,n,r){let i=[...on,...fn];for(let a of i){if(a.commandId===e)continue;let i=cn(a.commandId,a.predicate,r);if(!sn(i)&&un(a.scopes,n)&&gn(i,t))return{conflictsWith:a.commandId}}return null}function gn(e,t){return e.ctrl===t.ctrl&&e.shift===t.shift&&e.meta===t.meta&&e.input===t.input&&e.key===t.key&&e.upArrow===t.upArrow&&e.downArrow===t.downArrow}function _n(){let e=new Set(on.map(e=>e.commandId)),t=new Set(fn.map(e=>e.commandId));for(let n of e)if(t.has(n))throw Error(`[keybindings] duplicate commandId '${n}' found across KEY_BINDINGS and CONTROL_BINDINGS`)}_n();function vn(e,t,n){if(!t)return!1;let r=e.get(t);return r?n.tab?!!(r.onTab&&r.onTab(n.shift??!1)):n.escape?!!(r.onEscape&&r.onEscape()):n.return?!!(r.onAction&&r.onAction()):!1:!1}function yn(e,t,n,r,i){if(i.tab){let a=t;if(e.getTabable(n).length===0)return!1;if(a){let t=i.shift?e.prev(a,n):e.next(a,n);t&&r(t)}else if(!i.shift){let t=e.getInitialFocus(n);t&&r(t)}return!0}return!1}let bn=null;function xn(e){bn=e}function Sn(){return bn}const Cn=`/overlay/toast`,wn=`/overlay/pause`,Tn=`/overlay/retry`,En=`/overlay/error-retry`,Dn=`/overlay/pulse-survey`,On=`/overlay/forced-upgrade`,kn=`/overlay/paste-confirm`,An=`/overlay/services`,jn=`/overlay/chip-viewer`,Mn=[Cn,wn,Tn,En,Dn,On,kn,An,jn];function Nn(e){return e.startsWith(`/overlay/`)}function Pn(e){return e.startsWith(`/dialog/`)}function Fn(e,t,n){e&&(n?e.ensure(t):e.dismiss(t))}const In=a(null);function Ln(){let e=c(In);if(!e)throw Error(`useRouter() must be used inside <Router>`);return e}function Rn(){return c(In)}function zn(){let{stack:e}=Ln(),t=e[e.length-1];return t?{path:t.path,params:t.params,state:t.state}:{path:`/`,params:{},state:void 0}}function Bn(e){let{stack:t}=Ln();for(let n=t.length-1;n>=0;n--){let r=t[n];if(r.path===e&&r.state!==void 0)return r.state}}function Vn(){let{stack:e}=Ln(),t=c(Ue).routePath;for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.path===t)return r.state}}function Hn(e,t){let n=e.split(`/`),r=t.split(`/`);if(n.length!==r.length)return null;let i={};for(let e=0;e<n.length;e++){let t=n[e],a=r[e];if(t.startsWith(`:`))i[t.slice(1)]=a;else if(t!==a)return null}return i}function Un({children:e,initialPath:t=`/`}){let n=u(()=>new He,[]),[r,i]=f(()=>({entries:[{path:t,params:{}}],index:0})),[a,o]=f(null),c=d(null);c.current=a;let p=r.entries[r.index]?.path??t,h=r.entries.slice(0,r.index+1),g=d(h);g.current=h;let _=s(e=>{o(e)},[]),v=s(e=>{setTimeout(()=>{e?.lastFocusId?o(e.lastFocusId):o(n.getInitialFocus(e?.path??`/`))},0)},[n]),y=s(e=>{setTimeout(()=>{o(n.getInitialFocus(e))},0)},[n]),b=s((e,t)=>{if(typeof e==`number`){i(t=>{if(e===0||t.entries.length===0)return t;let n=t.index+e;return n<0||n>=t.entries.length?t:(v(t.entries[n]),{...t,index:n})});return}let r={path:e,params:{},state:t?.state};i(i=>{if(t?.reset){if(Pn(e))return{entries:[r],index:0};let t=i.entries.slice(0,i.index+1).filter(e=>Pn(e.path));if(t.length===0)return{entries:[r],index:0};let n=[r,...t];return{entries:n,index:n.length-1}}let a=c.current,o=[...i.entries];if(o.length>0&&a){let e=o[i.index];e&&(n.rememberFocus(e.path,a),o[i.index]={...e,lastFocusId:a})}if(t?.replace&&o.length>0)return o[i.index]=r,{entries:o,index:i.index};let s=[...o.slice(0,i.index+1),r];return{entries:s,index:s.length-1}}),y(e)},[y,n,v]),x=s(()=>{b(-1)},[b]),S=s(e=>{i(t=>{if(t.entries.slice(0,t.index+1).some(t=>t.path===e))return t;let r=c.current,i=[...t.entries],a=i[t.index];a&&r&&(n.rememberFocus(a.path,r),i[t.index]={...a,lastFocusId:r});let o=[...i.slice(0,t.index+1),{path:e,params:{}}];return y(e),{entries:o,index:o.length-1}})},[y,n]),C=s(e=>{i(t=>{if(t.entries.length<=1)return t;let n=-1;for(let r=t.index;r>=0;r--)if(t.entries[r].path===e){n=r;break}if(n<=0)return t;let r=[...t.entries.slice(0,n),...t.entries.slice(n+1)],i=n<=t.index?Math.max(0,t.index-1):t.index;return n===t.index&&v(r[i]),{entries:r,index:Math.min(i,r.length-1)}})},[v]),w=s(e=>{o(e)},[]),T=s((e,t)=>vn(n,c.current,t),[n]),E=s((e,t)=>yn(n,c.current,p,o,t)?!0:t.escape&&h.length>1?(x(),!0):!1,[n,p,h.length,x]),D=s((e,t)=>T(e,t)||E(e,t),[T,E]);l(()=>(xn({navigate:b,goBack:x,ensure:S,dismiss:C,get stack(){return g.current},get currentPath(){return g.current[g.current.length-1]?.path??`/`}}),()=>xn(null)),[b,x,S,C]);let O=et(),k=d(T);k.current=T;let A=d(E);A.current=E,l(()=>{let e=O.register(`router-intercept`,(e,t)=>k.current(e,t),50),t=O.register(`router-default`,(e,t)=>A.current(e,t),5);return()=>{e(),t()}},[O]),l(()=>{let e=n.getInitialFocus(p);e&&!c.current&&o(e)},[p]);let j=u(()=>({routePath:p,currentPath:p,activeId:a,registry:n,onFocusFallback:_,hasRouter:!0}),[p,a,n,_]),M=u(()=>({stack:h,currentPath:p,activeId:a,navigate:b,goBack:x,ensure:S,dismiss:C,focus:w,handleKey:D}),[h,p,a,b,x,S,C,w,D]);return m(In.Provider,{value:M,children:m(Ue.Provider,{value:j,children:e})})}function Wn(e,t){return t===e||t.startsWith(e+`/`)}function Gn(e){for(let t=e.length-1;t>=0;t--){let n=e[t].path;if(!n.startsWith(`/overlay/`))return n}}function Kn({path:e,prefix:t,inStack:n,dismissibleByOverlay:r,element:i,children:a}){let{currentPath:o,stack:s,activeId:l}=Ln(),u=c(Ue),d=e=>u?h(Ue.Provider,{value:{...u,routePath:e,activeId:l},children:[i,a]}):h(p,{children:[i,a]});if(e===`*`)return d(o);if(n)return s.some(t=>t.path===e)?d(e):null;if(r){let n=Gn(s);return n===void 0||(t?!Wn(e,n):n!==e)?null:d(e)}return t?Wn(e,o)?d(e):null:Hn(e,o)?d(e):null}function qn({hasMore:t,count:n,indent:r=` `}){let i=K();return t?h(_,{color:i.inactive,dimColor:!0,children:[r,n===void 0?`▲ ${e.t(`common.more`)}`:e.t(`scroll.above`,{n})]}):null}function Jn({hasMore:t,count:n,indent:r=` `}){let i=K();return t?h(_,{color:i.inactive,dimColor:!0,children:[r,n===void 0?`▼ ${e.t(`common.more`)}`:e.t(`scroll.below`,{n})]}):null}function Yn(e,t){switch(e){case`primary`:return t.text;case`secondary`:return t.inactive;case`danger`:return t.error;case`success`:return t.success;case`warning`:return t.warning;case`accent`:return t.accent}}function $({children:e,type:t=`primary`,bold:n,italic:r,dim:i,wrap:a}){return m(_,{color:Yn(t,K()),bold:n,italic:r,dimColor:i,wrap:a,children:e})}function Xn(e){return e.leftArrow?-1:e.rightArrow?1:e.tab?e.shift?-1:1:0}function Zn(e,t,n){return n<=0?0:(e+t+n)%n}function Qn({children:e,type:t=`secondary`,leadingSpace:n=!1}){let r=K();return h(_,{children:[n?` `:``,h(_,{color:Yn(t,r),backgroundColor:r.tagBg,children:[` `,`[`,e,`]`,` `]})]})}function $n(e,t,n=0){return Math.max(3,e-t-3-2-Math.max(0,n))}function er(e){return Math.max(14,Math.floor((Number.isFinite(e)&&e>0?e:24)*.3333333333333333))}function tr(e,t){let n=Number.isFinite(e)&&e>0?e:0;return Math.min(er(t),Math.max(15,n))}function nr(e){return Math.max(14,Math.floor((Number.isFinite(e)&&e>0?e:24)/3))}function rr(e,t,n=0){let r=Math.min(Number.isFinite(e)&&e>0?Math.floor(e):0,5),i=Math.max(1,er(t)-n);return Math.min(r,i)}function ir(e,t){let n=L(B.ellipsis);if(t<=1)return B.ellipsis;if(L(e)<=t)return e;let r=t-n,i=``;for(let t of e){let e=L(t);if(e>r)break;i+=t,r-=e}return`${i}${B.ellipsis}`}function ar(e,t){let n=L(e);return n<=0||t<=0?``:e.repeat(Math.max(0,Math.floor(t/n)))}function or(e,t){let n=L(e);return n>=t?e:e+` `.repeat(t-n)}function sr(e){return Number.isFinite(e)?Math.max(0,Math.min(100,e)):0}function cr(e){let t=Math.round(sr(e.percent)),n=Math.max(0,Math.floor(e.width));if(n===0)return{pct:t,filledCount:0,cells:[]};let r=e.segments?.filter(e=>e.width>0)??[],i=r.length>0,a,o;if(i){a=[];for(let e of r)for(let t=0;t<e.width;t++)a.push({filled:!0,segmentKey:e.key});for(o=a.length;a.length<n;)a.push({filled:!1})}else o=Math.max(0,Math.min(n,Math.round(t/100*n))),a=Array.from({length:n},(e,t)=>({filled:t<o}));if(e.markers)for(let[t,r]of Object.entries(e.markers)){if(!Number.isFinite(r))continue;let e=Math.max(0,Math.min(n-1,Math.round(r/100*n))),i=a[e];i&&(i.markerKey=t)}return{pct:t,filledCount:o,cells:a}}const lr={ascii:{filled:`=`,empty:`.`},block:{filled:`█`,empty:`░`},dot:{filled:`▰`,empty:`▱`}};function ur(e){return e?typeof e==`string`?lr[e]:e:lr.block}function dr({label:e,indent:t=` `}){let n=K(),r=typeof e==`string`?e:String(e??``);return h(_,{color:n.inactive,bold:!0,children:[t,r.toUpperCase()]})}function fr(e,t,n,r,i){let a=e.length;if(!Number.isFinite(n))return{rows:[...e],fillerCount:0,hasMoreAbove:!1,hasMoreBelow:!1,scrollTop:0};if(n<=0||a===0)return{rows:[],fillerCount:Math.max(0,n),hasMoreAbove:!1,hasMoreBelow:!1,scrollTop:0};let o=t>=0?t:0,s=r;o<s?s=i?Math.min(o,Math.max(0,i(o))):o:o>=s+n&&(s=o-n+1);let c=Math.max(0,a-n);s=Math.min(Math.max(0,s),c);let l=Math.min(a,s+n),u=e.slice(s,l);return{rows:u,fillerCount:Math.max(0,n-u.length),hasMoreAbove:s>0,hasMoreBelow:l<a,scrollTop:s}}function pr(e,t=`below`){let n=[],r,i=0;return e.forEach((e,a)=>{e.group&&e.group!==r&&(i>0&&n.push({kind:`spacer`}),n.push({kind:`divider`,label:e.group}),i++),r=e.group,n.push({kind:`item`,option:e,optionIndex:a}),e.detail&&t===`below`&&n.push({kind:`detail`,option:e,optionIndex:a})}),n}function mr(e,t,n,r){return fr(e,e.findIndex(e=>e.kind===`item`&&e.optionIndex===t),n,r,t=>{let n=t;for(;n>0&&e[n-1]?.kind===`divider`;)n--;for(;n>0&&e[n-1]?.kind===`spacer`;)n--;return n})}function hr(){let e=process.env.OTTO_TUI_REDUCED_MOTION;return e===`1`||e===`true`}function gr(e){return Math.max(1,Math.round(e/80))*80}const _r={now:()=>Date.now(),setTimer:(e,t)=>{let n=setTimeout(e,t);return n.unref?.(),n},clearTimer:e=>clearTimeout(e)};function vr(e={}){let t=e.clock??_r,n=e.reducedMotion??(()=>{let e=process.env.OTTO_TUI_REDUCED_MOTION;return e===`1`||e===`true`}),r=new Set,i=null,a=t.now(),o=e=>e.startedAtElapsed+(e.lastFrame+1)*e.periodMs,s=()=>{if(i!==null&&(t.clearTimer(i),i=null),r.size===0)return;let e=t.now()-a,n=1/0;for(let e of r){let t=o(e);t<n&&(n=t)}let s=Math.max(0,n-e);i=t.setTimer(c,s)},c=()=>{i=null;let e=t.now()-a;for(let t of r){let n=Math.floor((e-t.startedAtElapsed)/t.periodMs);if(n!==t.lastFrame){t.lastFrame=n;try{t.onFrame(n)}catch{}}}s()};return{subscribe(e,i){if(!Number.isFinite(e)||e<=0||n())return()=>{};let o=gr(e),c=t.now()-a,l={periodMs:o,onFrame:i,lastFrame:0,startedAtElapsed:Math.floor(c/80)*80};return r.add(l),s(),()=>{r.delete(l),s()}},minPeriodMs(){let e;for(let t of r)e=e===void 0?t.periodMs:Math.min(e,t.periodMs);return e},size:()=>r.size,dispose(){r.clear(),i!==null&&(t.clearTimer(i),i=null)}}}const yr=vr();function br(e,t){let n=d(t);n.current=t,l(()=>{if(e!=null)return yr.subscribe(e,e=>n.current(e))},[e])}function xr(e,t={}){let n=t.maxVisible??10,r=e.findIndex(e=>!e.disabled);r<0&&(r=0);let i=0;function a(){r<i?i=r:r>=i+n&&(i=r-n+1);let t=Math.max(0,e.length-n);i<0&&(i=0),i>t&&(i=t)}function o(n){if(n<0){t.onBoundary?.(`top`);return}if(n>=e.length){t.onBoundary?.(`bottom`);return}let i=n>r?1:-1,o=n;for(;o>=0&&o<e.length&&e[o]?.disabled;)o+=i;if(o<0){t.onBoundary?.(`top`);return}if(o>=e.length){t.onBoundary?.(`bottom`);return}r=o,a(),o===0&&t.onBoundary?.(`top`),o===e.length-1&&t.onBoundary?.(`bottom`)}return a(),{get selectedIndex(){return r},get scrollOffset(){return i},getVisibleOptions(){return e.slice(i,i+n)},getOptionAt(t){return e[t]},hasMoreAbove(){return i>0},hasMoreBelow(){return i+n<e.length},getSelected(){return e[r]??null},moveUp(){o(r-1)},moveDown(){o(r+1)},accept(){return e[r]??null},selectByHotkey(t){let n=e.findIndex(e=>e.hotkey===t);return n>=0&&!e[n]?.disabled?(r=n,a(),e[n]):null},selectByIndex(t){t>=0&&t<e.length&&!e[t]?.disabled&&(r=t,a())}}}function Sr(e,t){return t.escape?{type:`cancel`}:t.return?{type:`accept`}:pn(`list-nav-up`,e,t)?{type:`up`}:pn(`list-nav-down`,e,t)?{type:`down`}:/^[1-9]$/.test(e)?{type:`index`,index:Number(e)-1}:null}const Cr={black:0,red:.3,green:.55,yellow:.93,blue:.2,magenta:.4,cyan:.7,white:1,gray:.5,grey:.5};function wr(e){if(e.startsWith(`#`)){let t=e.slice(1),[n,r,i]=(t.length===3?[t[0]+t[0],t[1]+t[1],t[2]+t[2]]:[t.slice(0,2),t.slice(2,4),t.slice(4,6)]).map(e=>parseInt(e,16)/255);return .299*n+.587*r+.114*i}return Cr[e.toLowerCase()]??.5}function Tr(e){return e&&wr(e)>.55?`black`:`white`}function Er(e,t){switch(e){case`accent`:return t.selection;case`amber`:return t.warning;case`red`:return t.error;case`green`:return t.success;case`gray`:return t.panelBorder}}function Dr(e,t){return Er(e,t)}function Or(e,t=w){let{label:n,variant:r=`ghost`,color:i=`accent`,focused:a=!1,disabled:o=!1}=e,s=e.brackets??r===`outline`,c=`[ ${n} ]`;if(o)return{label:c,color:t.inactive,bold:!1,dim:!0};if(r===`ghost`){let e=` ${n} `;if(a){let n=Er(i,t);return{label:s?c:e,color:Tr(n),backgroundColor:n,bold:!0,dim:!1}}return{label:s?c:e,color:t.inactive,bold:!1,dim:!1}}let l=Er(i,t),u=Dr(i,t);if(r===`solid`){let e=` ${n} `;return a?{label:s?c:e,color:Tr(l),backgroundColor:l,bold:!0,dim:!1}:{label:s?c:e,color:s?t.inactive:u,bold:!1,dim:!1}}return a?{label:s?c:` ${n} `,color:u,bold:!0,dim:!1}:{label:s?c:` ${n} `,color:t.inactive,bold:!1,dim:!1}}function kr({label:e,variant:t=`ghost`,color:n=`accent`,focused:r,disabled:i=!1,brackets:a,tabIndex:o=-1,onAction:s}){let c=K(),{focused:l}=Ge({tabIndex:o,disabled:i||o<0,onAction:s}),u=Or({label:e,variant:t,color:n,focused:r??l,disabled:i,brackets:a},c);return m(_,{color:u.color,backgroundColor:u.backgroundColor,bold:u.bold,dimColor:u.dim||void 0,children:u.label})}function Ar(e){return null}Ar.displayName=`Select.Item`;function jr(e){return null}jr.displayName=`Select.Label`;function Mr(e){return null}Mr.displayName=`Select.Group`;function Nr(){return null}Nr.displayName=`Select.Separator`;function Pr({children:e}){return m(p,{children:e})}Pr.displayName=`Select.Content`;function Fr(e){return null}Fr.displayName=`Select.Trigger`;function Ir(e){if(typeof e==`string`||typeof e==`number`)return String(e);if(Array.isArray(e))return e.map(Ir).join(``);if(i.isValidElement(e)){let t=e.props;return Ir(t.children)}return``}function Lr(e){let t=[],n=0;function r(e,a){i.Children.forEach(e,e=>{if(!i.isValidElement(e))return;let o=e.type;if(o.displayName===`Select.Item`){let r=e.props;n+=1,t.push({value:r.value,label:Ir(r.children),disabled:r.disabled,detail:r.detail,indent:r.indent,marker:r.marker,ordinal:n,trailingLabel:r.trailingLabel,trailingColor:r.trailingColor,labelColor:r.labelColor,group:a});return}if(o.displayName===`Select.Group`){let t=e.props,n;i.Children.forEach(t.children,e=>{i.isValidElement(e)&&e.type.displayName===`Select.Label`&&(n=Ir(e.props.children))}),r(t.children,n);return}if(o.displayName===`Select.Label`||o.displayName===`Select.Separator`||o.displayName===`Select.Trigger`)return;let s=e.props;s.children!==void 0&&r(s.children,a)})}return r(e,void 0),t}function Rr({title:t,subtitle:n,headerAction:r,defaultValue:i,onValueChange:a,onCancel:o,maxVisible:s=10,footer:c,active:l=!0,onKey:v,frame:y=!0,highlightSelection:b=!0,rows:x=24,extensionHeightBudget:S=!1,detailPlacement:C=`below`,children:w}){let T=K(),E=u(()=>Lr(w),[w]),D=u(()=>C===`inline`?Math.max(0,...E.map(e=>L(e.label))):0,[C,E]),O=u(()=>C===`inline`?Math.max(0,...E.map(e=>L(e.trailingLabel??``))):0,[C,E]),k=d(null);if(!k.current){let e=i?E.findIndex(e=>e.value===i):-1;k.current=xr(E,{maxVisible:s}),e>=0&&k.current.selectByIndex(e)}let A=k.current,[j,M]=f(!1);br(2e3,e=>M(e%2==1));let[,ee]=f(0),te=()=>ee(e=>e+1),[N,P]=f(()=>!!r&&!E.some(e=>!e.disabled));J(`select-primitive`,(e,t)=>{if(v?.(e,t,A.getSelected())){te();return}if(r&&N){if(t.return){r.onPress();return}if(t.downArrow){P(!1),te();return}if(t.escape){o?.();return}return}let n=Sr(e,t);if(n)switch(n.type){case`cancel`:o?.();return;case`up`:{let e=A.selectedIndex;A.moveUp(),r&&A.selectedIndex===e&&P(!0),te();return}case`down`:A.moveDown(),te();return;case`index`:{A.selectByIndex(n.index);let e=A.getSelected();e&&!e.disabled&&a?.(e.value);return}case`accept`:{let e=A.accept();e&&!e.disabled&&a?.(e.value);return}}},{isActive:l});let F=u(()=>pr(E,C),[E,C]),ne=d(0),I=3+(t?2:0)+(n?1:0)+(r?1+(n?1:0):0)+2+2,re=nr(x),ie=y?S?Math.max(1,Math.min(F.length,re-I)):tr(F.length+I,x)-I:1/0,R=mr(F,A.selectedIndex,ie,ne.current);ne.current=R.scrollTop;let ae=E[A.selectedIndex]??null,oe=h(p,{children:[t&&m(Fe,{children:t}),t&&m(g,{marginTop:G.tight}),n&&m($,{type:`secondary`,children:n}),r&&h(g,{flexDirection:`row`,alignSelf:`flex-start`,marginTop:n?G.tight:G.none,children:[h(_,{color:T.accent,children:[r.hint,` `]}),m(kr,{variant:`ghost`,brackets:!0,color:`accent`,label:r.label,focused:N,tabIndex:-1})]})]}),z=h(p,{children:[m(g,{height:1,children:m(qn,{hasMore:R.hasMoreAbove})}),R.rows.map((t,n)=>{if(t.kind===`spacer`)return m(_,{children:` `},`spacer-${n}`);if(t.kind===`divider`)return m(g,{flexDirection:`column`,children:m(dr,{label:t.label,indent:``})},`div-${n}`);let r=t.option;if(t.kind===`detail`){let e=r.indent??` `,n=r.detail??``,i=r.marker===`number`?` `.repeat(`${r.ordinal}. `.length):r.marker?` `.repeat(`${r.marker} `.length):``,a=/^● (.+?) · /u.exec(n),o=a?.[1],s=a?n.slice(a[0].length):n;return h(g,{flexDirection:`row`,children:[m(g,{flexShrink:0,children:h($,{type:`secondary`,dim:!0,children:[` `,e,i]})}),o?m(g,{flexShrink:0,children:h(_,{color:T.accent,children:[j?B.breatheBright:B.breatheDim,` `,o]})}):null,m(g,{flexGrow:1,flexShrink:1,minWidth:0,children:m($,{type:`secondary`,dim:!0,wrap:`truncate-end`,children:o?` · ${s}`:s})})]},`detail-${t.optionIndex}`)}let i=r.indent??` `,a=r.marker===`number`?`${r.ordinal}. `:r.marker?`${r.marker} `:``,o=b&&r===ae&&!N,s=C===`inline`&&r.detail;return h(g,{flexDirection:`row`,children:[m(g,{flexShrink:0,children:h(_,{color:r.disabled?T.inactive:o?T.selection:r.labelColor??T.inactive,dimColor:r.disabled,bold:o&&!r.disabled,wrap:`truncate-end`,children:[o&&!r.disabled?V():H(),i,a,s?`${or(r.label,D)} ${or(r.trailingLabel??``,O)} `:r.label,r.disabled?` (${e.t(`common.disabled`)})`:``]})}),s&&m(g,{flexGrow:1,flexShrink:1,minWidth:0,children:m($,{type:`secondary`,dim:!0,wrap:`truncate-end`,children:r.detail})}),r.trailingLabel&&!s&&h(p,{children:[m($,{type:`secondary`,children:` `}),m(_,{color:r.trailingColor??T.inactive,dimColor:!r.trailingColor,children:r.trailingLabel})]})]},`item-${t.optionIndex}`)}),Array.from({length:R.fillerCount},(e,t)=>m(_,{children:` `},`filler-${t}`)),m(g,{height:1,children:m(Jn,{hasMore:R.hasMoreBelow})})]});return y?m(Pe,{header:oe,footer:c??m(Le,{items:[[`${q.up}${q.down}`,e.t(`hint.select`)],[q.enter,e.t(`hint.confirm`)],[q.esc,e.t(`hint.cancel`)]]}),maxHeight:S&&y?re:void 0,children:z}):h(g,{flexDirection:`column`,children:[oe,z]})}const zr={Root:Rr,Trigger:Fr,Content:Pr,Group:Mr,Label:jr,Item:Ar,Separator:Nr};function Br({title:t,message:n,confirmLabel:r,cancelLabel:i,confirmColor:a=`accent`,dangerous:o=!1,extraLabel:c,extraColor:l=`amber`,checkLabel:u,checked:d=!1,onConfirm:p,onCancel:v,onExtra:y,onCheckChange:b}){let x=!!c,S=x?2:1,[C,w]=f(o?S:0),[T,E]=f(d),D=Array.isArray(n)?n:[n],O=s(()=>{let e=!T;E(e),b?.(e)},[T,b]);Ge({onEscape:()=>(v(),!0)}),J(`confirm-dialog-buttons`,(e,t)=>{if(t.escape)return v(),!0;let n=Xn(t);return n===0?t.return?(w(e=>(e===0?p():x&&e===1?y?.():v(),e)),!0):u&&e===` `&&!t.ctrl&&!t.meta?(O(),!0):!1:(w(e=>Zn(e,n,S+1)),!0)});let k=r??e.t(`common.confirmButton`),A=i??e.t(`common.genericCancelButton`);return h(Pe,{header:m(Fe,{children:t}),footer:m(Le,{items:[[`${q.left}${q.right}`,e.t(`hint.switch`)],[q.enter,e.t(`hint.confirm`)],[q.esc,e.t(`hint.cancel`)]]}),children:[m(g,{marginTop:G.tight,flexDirection:`column`,children:D.map((e,t)=>m(_,{wrap:`truncate-end`,children:e===``?` `:e},t))}),u&&h(g,{marginTop:G.tight,children:[h($,{type:`secondary`,children:[T?B.bullet:B.todoPending,` `]}),m($,{type:`secondary`,children:u})]}),h(g,{marginTop:G.tight,flexDirection:`row`,gap:G.section,children:[m(kr,{variant:`solid`,brackets:!0,color:a,label:k,focused:C===0}),x&&m(kr,{variant:`solid`,brackets:!0,color:l,label:c,focused:C===1}),m(kr,{variant:`solid`,brackets:!0,color:`gray`,label:A,focused:C===S})]})]})}function Vr({tabIndex:e=0,autoFocus:t=!1,options:n,onSelect:r,initialIndex:i=0,maxVisible:a=8,id:o,compact:s=!1}){let c=K(),{focused:l}=Ge({tabIndex:e,autoFocus:t,id:o}),[u,d]=f(Math.min(i,n.length-1));nt(l,(e,t)=>{if(t.upArrow)return d(e=>{let t=e;for(let r=1;r<=n.length;r++){let i=(e-r+n.length)%n.length;if(!n[i]?.disabled){t=i;break}}return t}),!0;if(t.downArrow)return d(e=>{let t=e;for(let r=1;r<=n.length;r++){let i=(e+r)%n.length;if(!n[i]?.disabled){t=i;break}}return t}),!0;if(t.return){let e=n[u];return e&&!e.disabled&&r(e.value),!0}for(let t=0;t<Math.min(n.length,9);t++)if(e===String(t+1)&&n[t]&&!n[t].disabled)return r(n[t].value),!0;return!1});let p=n.length,v=p<=a?0:Math.min(Math.max(0,u-Math.floor(a/2)),p-a),y=n.slice(v,v+a);return h(g,{flexDirection:`column`,children:[v>0&&m(g,{children:h(_,{color:c.inactive,dimColor:!0,children:[` ▲ `,v]})}),y.map((e,t)=>{let n=v+t===u,r=n&&l,i=e.disabled?c.inactive:r||n?c.selection:c.inactive,a=n&&!e.disabled;return h(g,{marginBottom:s?G.none:G.tight,flexDirection:`column`,children:[h(_,{color:i,bold:a,children:[r?V():H(),e.label]}),e.detail&&m(g,{marginLeft:G.section,children:m(_,{color:c.inactive,children:e.detail})})]},e.value)}),v+a<p&&m(g,{children:h(_,{color:c.inactive,dimColor:!0,children:[` ▼ `,p-v-a]})})]})}function Hr({label:e,detail:t,disabled:n,children:r}){let i=K();return h(g,{flexDirection:`column`,children:[m(_,{color:n?i.inactive:void 0,children:e}),t&&m(_,{color:i.inactive,dimColor:!0,children:t}),r]})}function Ur(e,t){switch(e){case`success`:return t.success;case`warning`:return t.warning;case`error`:return t.error;case`muted`:return t.inactive;case`secondary`:return t.secondary}}function Wr(e){let t=[],n=[];for(let r of e)r.kind===`group`?(n.length>0&&t.push(n),n=[r]):n.push(r);return n.length>0&&t.push(n),t}function Gr({entries:e}){let t=K();return m(g,{flexDirection:`column`,children:Wr(e).map((e,n)=>{let r=e.filter(e=>e.kind===`row`),i=Math.max(0,...r.map(e=>L(e.label)));return m(g,{flexDirection:`column`,marginTop:n>0?G.tight:G.none,children:e.map((e,n)=>{if(e.kind===`group`)return m(dr,{label:e.title},n);if(e.kind===`blank`)return m(_,{children:` `},n);if(e.kind===`text`)return m(_,{color:e.tone?Ur(e.tone,t):void 0,dimColor:e.tone===`muted`,children:e.value},n);let r=` `.repeat(Math.max(0,i-L(e.label)));return h(_,{children:[` `,m(_,{color:t.inactive,children:e.label}),r,` `,m(_,{color:e.tone?Ur(e.tone,t):void 0,children:e.value})]},n)})},n)})})}function Kr(t){switch(t){case`retry`:return e.t(`retry.nowButton`);case`login`:return e.t(`model.goToLoginButton`);case`extension`:return e.t(`model.goToExtensionButton`)}}function qr(e,t){switch(e){case`success`:return t.success;case`muted`:return t.inactive;case`warning`:return t.warning}}function Jr({title:t,lines:n,lineTones:r,onDismiss:i,action:a,dataListEntries:o}){let s=K();J(`info-dialog`,(e,t)=>t.escape?(i(),!0):t.return&&a?(i(),queueMicrotask(()=>a.run()),!0):!1);let c=a?Kr(a.kind):void 0;return h(Pe,{header:m(Fe,{children:t}),footer:m(Le,{items:a?[[q.enter,c],[q.esc,e.t(`hint.close`)]]:[[q.esc,e.t(`hint.close`)]]}),children:[m(g,{marginTop:G.tight,flexDirection:`column`,children:o?m(Gr,{entries:o}):n.map((e,t)=>{let n=r?.[t];return m(_,{color:n?qr(n,s):void 0,dimColor:n===`muted`,wrap:`truncate-end`,children:e===``?` `:e},t)})}),a&&m(g,{marginTop:G.tight,children:m(kr,{variant:`solid`,brackets:!0,color:`accent`,label:c,focused:!0})})]})}function Yr({percent:e,width:t,chars:n,color:r,segments:i,markers:a,labelPosition:o=`suffix`,labelPrefix:s=``}){let c=K(),{filled:l,empty:u}=ur(n),d=cr({percent:e,width:t,segments:i?.map(e=>({key:e.key,width:e.width}))}),f=new Map((i??[]).map(e=>[e.key,e.color])),p=new Map((i??[]).map(e=>[e.key,e.dimColor??!1])),g=new Map(Object.entries(a??{}).map(([e,t])=>[t.pos,{name:e,color:t.color}])),v=(e=>typeof r==`function`?r(e):typeof r==`string`?r:c.inactive)(d.pct),y=`${s}${d.pct}%`;return h(_,{children:[o===`prefix`?h(_,{color:v,bold:!0,children:[y,` `]}):null,d.cells.map((e,t)=>{let n=g.get(t),r=c.inactive;e.filled&&(r=e.segmentKey?f.get(e.segmentKey)??v:v),n&&e.filled&&(r=n.color);let i=e.filled&&e.segmentKey?p.get(e.segmentKey)??!1:!1;return m(_,{color:r,dimColor:i,children:e.filled?l:u},t)}),o===`suffix`?h(_,{children:[` `,y]}):null]})}const Xr={pending:B.todoPending,active:B.todoActive,done:B.check,error:B.cross};function Zr(e,t){let n=[];return e.forEach((e,r)=>{let i=t[r]??`pending`;i!==`pending`&&n.push({label:e,status:i})}),n}function Qr({title:t,phases:n,phaseStatuses:r,percent:a,detail:o,subProgress:s,status:c,errorMessage:u,nextStep:v,onDismiss:y}){let b=K(),x=c===`running`,S=d(null);l(()=>{if(c===`success`)return S.current=setTimeout(y,2e3),()=>{S.current&&clearTimeout(S.current)}},[c,y]);let[C,w]=f(0);return br(c===`running`?160:null,e=>{w(e%U.length)}),J(`progress-dialog`,(e,t)=>(t.return||t.escape)&&c!==`running`?(y(),!0):!1),m(Pe,{header:m(Fe,{children:t}),footer:c===`partial`||c===`error`?m(Le,{items:[[`${q.enter}/${q.esc}`,e.t(`hint.close`)]]}):void 0,children:h(g,{flexDirection:`column`,paddingX:G.tight,children:[m(g,{height:1}),x?n.map((e,t)=>{let n=r[t]??`pending`,i=n===`active`,a=n===`error`,s=n===`done`,c=b.inactive;return i?c=b.accent:a?c=b.error:s&&(c=b.success),h(g,{children:[h(_,{color:c,children:[Xr[n]??` `,` `]}),m(_,{color:i?b.accent:a?b.error:s?b.success:b.inactive,children:e}),i?h(p,{children:[h(_,{color:b.accent,children:[` `,U[C],` `]}),m($,{type:`secondary`,children:o})]}):null]},t)}):null,!x&&c!==`success`?m(g,{children:Zr(n,r).map((e,t)=>h(i.Fragment,{children:[t>0?m($,{type:`secondary`,children:` · `}):null,h(_,{color:e.status===`error`?b.error:e.status===`done`?b.success:b.accent,children:[Xr[e.status],` `]}),m($,{type:`secondary`,children:e.label})]},t))}):null,s&&c===`running`?m(g,{marginTop:G.tight,children:h(Qn,{children:[s.current,`/`,s.total]})}):null,x?m(g,{marginTop:G.tight,marginBottom:G.tight,children:m(Yr,{percent:a,width:40,chars:`ascii`,color:b.accent})}):null,x?null:h(g,{marginTop:c===`success`?G.none:G.tight,flexDirection:`column`,children:[m(g,{children:h(_,{bold:!0,color:c===`success`?b.success:c===`partial`?b.warning:b.error,children:[c===`success`?B.check:c===`partial`?B.warn:B.cross,` `,c===`success`?e.t(`install.done`):c===`partial`?e.t(`install.summaryPartial`):e.t(`install.summaryFailed`)]})}),c!==`success`&&u?m(g,{marginTop:G.tight,children:m($,{type:`secondary`,wrap:`wrap`,children:u})}):null,v?m(g,{marginTop:G.tight,children:m($,{type:`secondary`,children:v.label})}):null]})]})})}function $r(e){return e.some(e=>e.freeformInput===!0)}function ei(e){return{tab:0,cursor:0,selected:e.map(()=>[]),freeformText:``,freeformOffset:0}}function ti(e,t,n=!1){return t.escape?{type:`cancel`}:t.tab?{type:t.shift?`tabPrev`:`tabNext`}:pn(`list-nav-up`,e,t)?{type:`cursorPrev`}:pn(`list-nav-down`,e,t)?{type:`cursorNext`}:!n&&(e===` `||t.return)?{type:`choose`}:null}function ni(e,t,n){let r=$r(n),i=n.length+(r?1:0),a=r?n.length:-1;switch(t?.type){case`cancel`:return{state:e,done:`cancel`};case`tabPrev`:return{state:{...e,tab:(e.tab-1+i+1)%(i+1),cursor:0}};case`tabNext`:return{state:{...e,tab:(e.tab+1)%(i+1),cursor:0}};case`cursorPrev`:return e.tab===i||e.tab===a?{state:e}:{state:{...e,cursor:Math.max(0,e.cursor-1)}};case`cursorNext`:{if(e.tab===i||e.tab===a)return{state:e};let t=n[e.tab].options.length;return{state:{...e,cursor:Math.min(t-1,e.cursor+1)}}}case`choose`:{if(e.tab===i)return{state:e,done:`submit`};if(e.tab===a)return{state:{...e,tab:i}};let t=n[e.tab],r=e.selected[e.tab]??[],o=t.multiSelect?r.includes(e.cursor)?r.filter(t=>t!==e.cursor):[...r,e.cursor]:[e.cursor],s=e.selected.map((t,n)=>n===e.tab?o:t),c=t.multiSelect?e.tab:Math.min(i,e.tab+1);return{state:{...e,selected:s,tab:c,cursor:0}}}default:return{state:e}}}function ri(e,t){let n={};return t.forEach((t,r)=>{n[t.header]=(e.selected[r]??[]).map(e=>t.options[e]?.label).filter(e=>typeof e==`string`)}),n}function ii(e,t){return t.every((t,n)=>(e.selected[n]?.length??0)>0)}function ai(e){return ir(e,23)}function oi({title:t,questions:n,onSubmit:r,onCancel:a,columns:o=60}){let s=K(),c=$r(n),l=d(null);l.current??=ei(n);let[,u]=f(0),v=c?n.length:-1,y=n.length+(c?1:0),b=e=>{let t=l.current,i=ti(``,{tab:!0,shift:e},t.tab===v);if(!i)return!1;let{state:o,done:s}=ni(t,i,n);return l.current=o,s===`cancel`?(a?.(),!0):s===`submit`?(r(ri(o,n),o.freeformText||void 0),!0):(u(e=>e+1),!0)};Ge({onEscape:()=>(a?.(),!0),onTab:e=>b(e)}),J(`questions-dialog`,(e,t)=>{let i=l.current;if(i.tab===v){if(t.escape&&i.freeformText.length===0){a?.();return}if(t.tab){b(t.shift??!1);return}if(t.leftArrow){let e=Dt.fromText(i.freeformText,o,i.freeformOffset).left();l.current={...i,freeformText:e.text,freeformOffset:e.offset},u(e=>e+1);return}if(t.rightArrow){let e=Dt.fromText(i.freeformText,o,i.freeformOffset).right();l.current={...i,freeformText:e.text,freeformOffset:e.offset},u(e=>e+1);return}if(e.length>1&&!t.ctrl&&!t.meta&&!t.return&&!t.escape&&!t.backspace&&!t.delete&&!t.leftArrow&&!t.rightArrow){let t=Ft(e);if(t){let e=i.freeformText,n=i.freeformOffset;l.current={...i,freeformText:e.slice(0,n)+t+e.slice(n),freeformOffset:n+t.length},u(e=>e+1)}return}if(t.return){let{state:e,done:t}=ni(i,ti(``,{tab:!0},!0),n);if(l.current=e,t===`submit`){r(ri(e,n),e.freeformText||void 0);return}u(e=>e+1);return}let s={name:t.escape?`escape`:t.backspace?`backspace`:t.delete?`delete`:e||`unknown`,ctrl:t.ctrl??!1,shift:!1,alt:t.meta??!1,meta:t.meta??!1},c=Pt(Dt.fromText(i.freeformText,o,i.freeformOffset),s);if(!c)return;l.current={...i,freeformText:c.cursor.text,freeformOffset:c.cursor.offset},u(e=>e+1);return}let s=ti(e,t);if(!s)return;let{state:c,done:d}=ni(i,s,n);if(l.current=c,d===`cancel`){a?.();return}if(d===`submit`){r(ri(c,n),c.freeformText||void 0);return}u(e=>e+1)});let x=l.current,S=x.tab===y,C=x.tab===v?m(Le,{items:[[q.enter,e.t(`freeform.advance`)],[q.esc,e.t(`hint.cancel`)]]}):m(Le,{items:[[`${q.up}${q.down}`,e.t(`hint.option`)],[q.tab,e.t(`hint.question`)],S?[q.enter,e.t(`hint.submit`)]:[`space/${q.enter}`,e.t(`hint.choose`)],[q.esc,e.t(`hint.cancel`)]]});return h(Pe,{header:t?m(Fe,{children:t}):void 0,footer:C,children:[h(g,{flexDirection:`row`,marginTop:G.tight,children:[n.map((e,t)=>{let n=(x.selected[t]?.length??0)>0,r=x.tab===t,a=r?s.selection:n?s.success:s.inactive;return h(i.Fragment,{children:[t>0&&m($,{type:`secondary`,dim:!0,children:` · `}),m(_,{color:a,bold:r,children:ai(e.header)})]},t)}),c&&h(p,{children:[m($,{type:`secondary`,dim:!0,children:` · `}),m(_,{color:x.tab===v?s.selection:x.freeformText?s.success:s.inactive,bold:x.tab===v,children:e.t(`freeform.tab`)})]}),m($,{type:`secondary`,dim:!0,children:` · `}),m(_,{color:S?s.selection:s.inactive,bold:S,children:e.t(`prompt.submit`)})]}),S?h(g,{flexDirection:`column`,marginTop:G.tight,children:[m(_,{color:ii(x,n)?s.success:s.warning,children:ii(x,n)?e.t(`questions.readyToSubmit`):e.t(`questions.someUnanswered`)}),m(g,{marginTop:G.tight,children:m(kr,{variant:`solid`,brackets:!0,color:`accent`,label:e.t(`prompt.submit`),focused:!0})})]}):x.tab===v?h(g,{flexDirection:`column`,marginTop:G.tight,children:[m(_,{color:s.secondary,children:e.t(`freeform.label`)}),m(g,{marginTop:G.tight,children:m(an,{value:x.freeformText,offset:x.freeformOffset,columns:o,mode:`dialog`,placeholder:e.t(`freeform.placeholder`),focused:!0,physicalCursor:!0})})]}):h(g,{flexDirection:`column`,marginTop:G.tight,children:[n[x.tab].question!==t&&m(_,{color:s.text,children:n[x.tab].question}),m(g,{flexDirection:`column`,marginTop:G.tight,children:n[x.tab].options.map((e,t)=>{let n=t===x.cursor,r=(x.selected[x.tab]??[]).includes(t),i=r?B.bullet:B.todoPending;return h(g,{flexDirection:`column`,children:[h(g,{flexDirection:`row`,children:[m(_,{color:n?s.selection:s.inactive,bold:n,children:n?V():H()}),m(_,{color:n?s.selection:r?s.success:s.inactive,bold:n,children:i}),m(_,{children:` `}),m(_,{color:n?s.selection:r?s.success:s.inactive,bold:n,children:e.label})]}),e.description&&m(g,{marginLeft:G.loose,children:m($,{type:`secondary`,dim:!0,children:e.description})})]},t)})})]})]})}function si(e,t,n,r){return h(g,{flexDirection:`row`,marginBottom:G.tight,children:[n.map((n,a)=>{let o=t.has(a),s=a===e,c=o?B.check:s?B.todoDone:B.todoPending,l=o?r.inactive:s?r.text:r.inactive;return h(i.Fragment,{children:[a>0&&m($,{type:`secondary`,children:` · `}),h(_,{color:l,bold:s,children:[c,` `,n]})]},a)}),h(g,{marginLeft:G.section,children:[m($,{type:`secondary`,children:`Step `}),m(_,{color:r.text,bold:!0,children:e+1}),h($,{type:`secondary`,children:[`/`,4]})]})]})}function ci(){return m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,dim:!0,children:ar(B.hr,60)})})}function li({request:t}){let n=K(),[r,i]=f(!1),[a,o]=f(!1),[c,u]=f(()=>Math.min(t.initialCurrent,3)),[p,v]=f(()=>new Set(t.initialCompleted)),[y,b]=f(null),[x,S]=f(null),[C,w]=f(null),[T,E]=f(null),[D,O]=f(null),[k,A]=f([]),[j,M]=f(!1),[ee,te]=f(null),N=d(null),[P,F]=f(`select`),[ne,I]=f(null),[L,re]=f(null),[ie,R]=f(null),[ae,oe]=f(``),z=d(``),[se,ce]=f(t.authProviderName??``),V=s(e=>{z.current=e,oe(e)},[]),H=d(null),U=d(!1),le=s(()=>{U.current=!0,H.current?.cancel(),N.current&&=(clearTimeout(N.current),null),t.onDismiss()},[t]),ue=s(()=>{if(P!==`select`&&c===1){H.current?.cancel(),F(`select`),I(null),re(null),R(null),V(``),z.current=``,b(null);return}if(T){E(null),b(null);return}c===0?le():(v(e=>{let t=new Set(e);return t.delete(c-1),t}),u(e=>e-1),b(null),F(`select`),I(null),re(null),R(null),V(``),w(null),A([]),M(!1),E(null),N.current&&=(clearTimeout(N.current),null))},[c,le,P,T]);l(()=>()=>{H.current?.cancel(),N.current&&clearTimeout(N.current)},[]);let W=s(()=>{v(e=>new Set([...e,c])),b(null),S(null),w(null),A([]),M(!1),E(null),F(`select`),O(null),I(null),re(null),R(null),V(``),z.current=``,H.current=null,c>=3?(le(),t.onComplete()):u(e=>e+1)},[c,le,t]),de=d(null),fe=s(async e=>{S(e),b(null);let n=await t.onInstallProvider(e,()=>{});U.current||(S(null),n.ok?(ce(n.providerId??e),A(n.capabilities??[]),M(n.pendingCapabilities===!0),w(e),N.current=setTimeout(()=>{N.current=null,W()},900)):(E(e),b(n.error)))},[t,W]);de.current=fe;let pe=s(()=>{let e=T;e&&(E(null),b(null),de.current?.(e))},[T]),me=s(()=>{E(null),b(null)},[]),he=d(null),ge=s(async()=>{if(t.onRefreshModelOptions)try{te(await t.onRefreshModelOptions())}catch{}},[t]),_e=s(async()=>{if(!t.onProviderOAuthStart)return;b(null),F(`oauth-wait`);let e=await t.onProviderOAuthStart(se);if(!e){F(`select`),b(`OAuth flow not available for this provider.`);return}H.current=e,I(e.authorizationUrl),re(e.code??null),R(e.instructions??null);let n=async()=>{if(U.current)return;let t=await e.poll();if(U.current)return;let r=typeof t==`string`?t:t.status,i=typeof t==`string`?void 0:t.reason;r===`pending`?setTimeout(()=>{n().catch(()=>{})},1500):r===`done`?(await ge(),W()):i===`cancelled`?F(`select`):O(i===`network`?`network`:`rejected`)};n().catch(()=>{})},[t,W,se,ge]),ve=s(()=>{O(null),b(null),he.current?.()},[]),ye=s(()=>{O(null),t.onOpenProxySettings?.()},[t]);he.current=_e;let be=s(()=>{H.current?.openAgain?.()},[]),xe=s(()=>{H.current?.cancel(),H.current=null,I(null),re(null),R(null),b(null),V(``),F(`key-input`)},[V]),Se=s(async()=>{if(!t.onSubmitProviderApiKey||!z.current.trim())return;b(null),F(`logging-in`);let e=await t.onSubmitProviderApiKey(se,z.current.trim());e.ok?(await ge(),W()):(F(`key-input`),b(e.error))},[t,W,ae,se,ge]),Ce=s(async e=>{b(null);try{await t.onSelectModel(e),W()}catch(e){b(e instanceof Error?e.message:String(e))}},[t,W]),we=s(()=>W(),[W]);J(`wizard-dialog`,(e,n)=>r?n.escape?(ue(),!0):!1:n.return?(t.onDontShowAgain(a),i(!0),!0):n.escape?(le(),!0):e===` `?(o(e=>!e),!0):!1);let Te=(()=>{if(!r)return[[q.enter,t.welcomeStartLabel],[q.esc,t.welcomeCancelLabel],[`Space`,t.welcomeDontShowAgainLabel]];let n=c===0&&!T?`exit`:`back`;switch(c){case 0:{let r=Math.min(t.providerOptions.length,9);return[[`${q.up}${q.down}`,e.t(`hint.select`)],[`1-${r}`,e.t(`hint.quick`)],[q.enter,e.t(`setup.actionInstall`)],[q.esc,n]]}case 1:return P===`key-input`?[[q.enter,`submit`],[q.esc,n]]:P===`oauth-wait`?[[q.esc,`cancel`]]:[[`1-${Math.min(t.providerAuthOptions(se).length,9)}`,e.t(`hint.quick`)],[q.enter,e.t(`setup.actionLogin`)],[q.esc,n]];case 2:{let r=Math.min((ee??t.modelOptions).length,9);return[[`${q.up}${q.down}`,e.t(`hint.select`)],[`1-${r}`,e.t(`hint.quick`)],[q.enter,e.t(`hint.confirm`)],[q.esc,n]]}case 3:return[[q.enter,e.t(`hint.confirm`)]];default:return[[q.esc,n]]}})();return m(Pe,{header:m(Fe,{children:t.title}),footer:m(Le,{items:Te}),children:r?h(g,{flexDirection:`column`,marginTop:G.tight,paddingX:G.section,children:[si(c,p,t.stepNames,n),m(g,{marginBottom:G.tight,flexDirection:`column`,children:m(_,{bold:!0,children:t.stepSubtitles[c]})}),m(ci,{}),y&&h(g,{marginBottom:G.tight,flexDirection:`column`,children:[h(_,{color:n.error,children:[e.t(`setup.errorTitle`),`:`]}),m(_,{color:n.error,children:y})]}),m(ui,{step:c,request:t,installing:x,installSucceeded:C,installedCapabilities:k,installPendingCaps:j,installFailed:T,onRetryInstall:pe,onChooseAnother:me,authMode:P,setAuthMode:F,oauthUrl:ne,oauthCode:L,oauthInstructions:ie,apiKey:ae,apiKeyRef:z,setApiKey:V,onInstall:fe,onOAuthStart:_e,onApiKeySubmit:Se,onOpenAgain:be,onSwitchToApiKey:xe,onRetryAuth:ve,onOpenProxySettings:ye,authFailure:D,onModel:Ce,onComplete:we,selectedProvider:se,modelOptionsOverride:ee})]}):h(g,{flexDirection:`column`,marginTop:G.tight,paddingX:G.section,children:[m(g,{marginBottom:G.tight,children:m(_,{bold:!0,children:t.welcomeTitle})}),t.welcomeGreeting&&m(g,{marginBottom:G.tight,children:m(_,{children:t.welcomeGreeting})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:t.welcomeDescription})}),m(ci,{}),m(g,{marginBottom:G.tight,children:h(_,{color:a?n.text:n.inactive,children:[a?B.bullet:B.todoPending,` `,t.welcomeDontShowAgainLabel]})})]})})}function ui(e){switch(e.step){case 0:return m(fi,{request:e.request,installing:e.installing,installSucceeded:e.installSucceeded,installedCapabilities:e.installedCapabilities,installPendingCaps:e.installPendingCaps,installFailed:e.installFailed,onRetryInstall:e.onRetryInstall,onChooseAnother:e.onChooseAnother,onInstall:e.onInstall});case 1:return m(pi,{request:e.request,authMode:e.authMode,setAuthMode:e.setAuthMode,oauthUrl:e.oauthUrl,oauthCode:e.oauthCode,oauthInstructions:e.oauthInstructions,apiKey:e.apiKey,apiKeyRef:e.apiKeyRef,setApiKey:e.setApiKey,onOAuthStart:e.onOAuthStart,onApiKeySubmit:e.onApiKeySubmit,onOpenAgain:e.onOpenAgain,onSwitchToApiKey:e.onSwitchToApiKey,onRetryAuth:e.onRetryAuth,onOpenProxySettings:e.onOpenProxySettings,authFailure:e.authFailure,selectedProvider:e.selectedProvider});case 2:return m(mi,{request:e.request,onModel:e.onModel,modelOptionsOverride:e.modelOptionsOverride});case 3:return m(hi,{request:e.request,onComplete:e.onComplete});default:return m(_,{children:`Unknown step`})}}function di(){let e=K(),t=hr(),[n,r]=f(0);return br(160,e=>r(e%U.length)),t?null:h(_,{color:e.accent,children:[` `,U[n]]})}function fi({request:t,installing:n,installSucceeded:r,installedCapabilities:i,installPendingCaps:a,installFailed:o,onRetryInstall:s,onChooseAnother:c,onInstall:l}){let u=K(),[d,p]=f(0),v=t.providerOptions,y=n!==null;if(r){let t=v.find(e=>e.value===r)?.label??r;return h(g,{flexDirection:`column`,children:[m(g,{children:h(_,{color:u.success,bold:!0,children:[B.check,` `,e.t(`setup.installedProvider`,{provider:t})]})}),a&&m(g,{marginTop:G.tight,children:m(_,{color:u.warning,children:e.t(`setup.installPendingCapabilities`)})}),i.length>0&&h(g,{marginTop:G.tight,flexDirection:`column`,children:[m($,{type:`secondary`,children:e.t(`setup.capabilityGranted`,{caps:i.join(`, `)})}),m($,{type:`secondary`,children:e.t(`setup.capabilityRevokeHint`)})]})]})}if(o)return h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.installFailedRecovery`,{provider:o})})}),h(Y.Root,{id:`wizard-install-failed`,onPick:e=>{e===0?s():c()},children:[m(Y.Item,{label:e.t(`setup.actionRetryInstall`)}),m(Y.Item,{label:e.t(`setup.actionChooseAnotherProvider`)})]})]});if(y){let t=v.find(e=>e.value===n)?.label??n;return h(g,{children:[m(_,{color:u.text,children:e.t(`setup.installingProvider`,{provider:t})}),m(di,{})]})}return m(Y.Root,{id:`wizard-dialog-2`,onPick:e=>{!y&&v[e]&&l(v[e].value)},activeIndex:d,onActiveChange:p,children:v.map(e=>m(Y.Item,{label:e.label,detail:e.detail,color:u.selection},e.value))})}function pi({request:t,authMode:n,setAuthMode:r,oauthUrl:i,oauthCode:a,oauthInstructions:o,apiKey:s,apiKeyRef:c,setApiKey:l,onOAuthStart:u,onApiKeySubmit:d,onOpenAgain:v,onSwitchToApiKey:y,onRetryAuth:b,onOpenProxySettings:x,authFailure:S,selectedProvider:C}){let w=K(),[T,E]=f(0),D=n,O=t.providerAuthOptions(C);if(J(`wizard-dialog-3`,(e,n)=>{if(D===`key-input`)return n.return&&c.current.trim()?(d(),!0):n.escape?(r(`select`),!0):e&&e.length>0?(l(c.current+e),!0):((n.backspace||n.delete)&&l(c.current.slice(0,-1)),!0);if(D!==`select`)return!1;if(n.upArrow||n.downArrow)return E(e=>(e+1)%Math.max(O.length,1)),!0;if(n.return&&O[T]){let e=O[T];return e.value===`oauth`&&t.onProviderOAuthStart?u():e.value===`key`&&(l(``),r(`key-input`)),!0}let i=e?Number(e):NaN;if(Number.isInteger(i)&&i>=1&&i<=O.length){let e=O[i-1];return e.value===`oauth`&&t.onProviderOAuthStart?u():e.value===`key`&&(l(``),r(`key-input`)),!0}return!1}),S){let t=S===`network`;return h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m(_,{color:w.error,children:e.t(t?`setup.authFailedNetwork`:`setup.authFailedRejected`)})}),h(Y.Root,{id:`wizard-auth-failed`,onPick:e=>{if(t&&e===0){x();return}(t?e-1:e)===0?b():y()},children:[t?m(Y.Item,{label:e.t(`setup.actionOpenProxySettings`)}):null,m(Y.Item,{label:e.t(`setup.actionRetryAuth`)}),m(Y.Item,{label:e.t(`setup.actionUseApiKeyInstead`)})]})]})}return t.onProviderOAuthStart&&n===`oauth-wait`?h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m(_,{children:a?`Complete device authorization`:`Sign in via OAuth`})}),a?h(p,{children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`1. Open this page:`})}),i&&m(g,{marginBottom:G.tight,children:h($,{type:`secondary`,children:[` `,i]})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`2. Enter this code:`})}),m(g,{marginBottom:G.tight,children:h(_,{bold:!0,color:w.text,children:[` `,a]})}),o&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:o})})]}):h(p,{children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`Open this URL in your browser to authorize:`})}),i&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:i})})]}),m(g,{marginBottom:G.tight,children:m(_,{color:w.text,children:e.t(`setup.oauthWaiting`)})}),h(Y.Root,{id:`wizard-oauth-wait`,onPick:e=>{e===0?v():y()},children:[m(Y.Item,{label:e.t(`setup.actionOpenAgain`)}),m(Y.Item,{label:e.t(`setup.actionUseApiKeyInstead`)})]})]}):n===`key-input`?h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m(_,{children:`Paste your API key`})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:`Generate a key on your provider dashboard and paste it below.`})}),m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.apiKeyStorageNote`)})}),m(g,{marginBottom:G.tight,children:m(an,{value:s,offset:0,columns:60,mode:`dialog`,mask:!0,placeholder:e.t(`setup.wizardApiKeyPlaceholder`),focused:!0})})]}):n===`logging-in`?m(g,{flexDirection:`column`,children:m(_,{color:w.text,children:e.t(`setup.loggingIn`)})}):h(g,{flexDirection:`column`,children:[C&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:C})}),m(g,{flexDirection:`column`,children:O.map((e,t)=>h(g,{marginBottom:G.tight,flexDirection:`column`,children:[h(_,{color:t===T?w.selection:w.inactive,bold:t===T,children:[t===T?B.pointer:` `,` `,e.label]}),e.detail&&m(g,{marginLeft:G.section,children:m($,{type:`secondary`,children:e.detail})})]},e.value))})]})}function mi({request:t,onModel:n,modelOptionsOverride:r}){let i=r??t.modelOptions,a=t=>t===`unauthenticated`?e.t(`setup.modelUnusableUnauthenticated`):t===`oauth-429-risk`?e.t(`setup.modelUnusableOauthRisk`):``;return h(g,{flexDirection:`column`,children:[i.some(e=>e.recommended)&&m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.modelRecommendedHint`)})}),m(zr.Root,{maxVisible:8,frame:!1,onValueChange:e=>{n(e)},children:i.map(t=>{let n=a(t.unusableReason),r=[t.recommended?e.t(`setup.modelRecommendedTag`):``,n,t.detail??``].filter(Boolean).join(` · `);return m(zr.Item,{value:t.value,detail:r||void 0,children:t.label},t.value)})})]})}function hi({request:t,onComplete:n}){let r=K();return J(`wizard-dialog-4`,(e,t)=>t.return?(n(),!0):!1),h(g,{flexDirection:`column`,children:[m(g,{marginBottom:G.tight,children:m($,{type:`secondary`,children:e.t(`setup.tryAsking`)})}),m(g,{flexDirection:`column`,marginBottom:G.tight,children:t.examplePrompts.map((e,t)=>h($,{type:`secondary`,children:[` "`,e,`"`]},t))}),m(_,{color:r.text,children:e.t(`setup.pressEnterToStart`)})]})}export{An as $,je as $t,rr as A,x as An,Y as At,Rn as B,st as Bt,or as C,ce as Cn,Dt as Ct,er as D,C as Dn,xt as Dt,nr as E,S as En,bt as Et,qn as F,Xe as Ft,jn as G,He as Gt,zn as H,nt as Ht,Jn as I,ct as It,kn as J,Le as Jt,En as K,Ge as Kt,Kn as L,J as Lt,Zn as M,$e as Mt,Xn as N,Ze as Nt,$n as O,w as On,gt as Ot,$ as P,Ye as Pt,Tn as Q,q as Qt,Un as R,et as Rt,cr as S,z as Sn,X as St,ir as T,R as Tn,wt as Tt,Vn as U,Ue as Ut,Bn as V,ot as Vt,Ln as W,Ke as Wt,wn as X,Fe as Xt,Mn as Y,Ie as Yt,Dn as Z,Pe as Zt,pr as _,U as _n,kt as _t,Jr as a,we as an,yn as at,dr as b,L as bn,Ft as bt,Hr as c,Se as cn,pn as ct,kr as d,fe as dn,cn as dt,Ne as en,Cn as et,Sr as f,G as fn,on as ft,hr as g,B as gn,At as gt,br as h,W as hn,Lt as ht,Yr as i,Ee as in,vn as it,Qn as j,Je as jt,tr as k,T as kn,_t as kt,Br as l,ve as ln,dn as lt,yr as m,ue as mn,Kt as mt,oi as n,ke as nn,Fn as nt,Gr as o,K as on,hn as ot,xr as p,de as pn,an as pt,On as q,ze as qt,Qr as r,De as rn,Sn as rt,Vr as s,Te as sn,fn as st,li as t,Me as tn,Nn as tt,zr as u,ye as un,sn as ut,fr as v,H as vn,Pt as vt,ar as w,ie as wn,Z as wt,ur as x,se as xn,It as xt,mr as y,V as yn,jt as yt,Hn as z,rt as zt};
|
|
10
|
-
//# sourceMappingURL=WizardDialog-
|
|
10
|
+
//# sourceMappingURL=WizardDialog-B0B_R8ya.js.map
|